session_start(); function connectDB(){ $db_username = "critical_admin"; $db_password = "Stonehouse1!~"; $db_database = "critical_site"; $db_host = "localhost"; $_SESSION['db'] = mysqli_connect( $db_host, $db_username, $db_password, $db_database); //Check connection if(mysqli_connect_errno()){ echo "Failed to connect to MySQL:" . mysqli_connect_error(); } } function closeDB(){ mysqli_close($_SESSION['db']); } function msg(){ if($_SESSION['msg']){ echo "
" . $_SESSION['msg'] . "
"; $_SESSION['msg'] = null; $_SESSION['msgtype'] = null; } } function loginForm(){ ?>© Charles Darwin University | Last updated
} function cleanInput($input) { $search = array( '@@si', // Strip out javascript '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@@siU', // Strip style tags properly '@@' // Strip multi-line comments ); $output = preg_replace($search, '', $input); return $output; } function sanitize($input) { connectDB(); if (is_array($input)) { foreach($input as $var=>$val) { $output[$var] = sanitize($val); } } else { if (get_magic_quotes_gpc()) { $input = stripslashes($input); } $input = cleanInput($input); $output = mysqli_real_escape_string ( $_SESSION['db'] , $input ); //$output = mysql_real_escape_string($input); } closeDB(); return $output; } ?>