Este es el codigo conmpreto:
========== Funcion para los carateles UTF-8
function PHP_Secure($string, $censored_words = 1) {
global $db;
$string = trim($string);
$string = mysqli_real_escape_string($db, $string);
$string = htmlspecialchars($string, ENT_QUOTES,'UTF-8');
$string = str_replace('\r\n', " <br>", $string);
$string = str_replace('\n\r', " <br>", $string);
$string = str_replace('\r', " <br>", $string);
$string = str_replace('\n', " <br>", $string);
$string = str_replace('&#', '&#', $string);
$string = stripslashes($string);
if ($censored_words == 1) {
global $config;
$censored_words = @explode(",", $config['censored_words']);
foreach ($censored_words as $censored_word) {
$censored_word = trim($censored_word);
$string = str_replace($censored_word, '****', $string);
}
}
return $string;
}
========== Funcion del login
function system_login() {
global $con;
if (@$_COOKIE["muser"]!='') {
@header("Location:./");
exit('<meta http-equiv="Refresh" content="0;url=./">');
}
if (!empty($_POST)) {
$username = PHP_Secure($_POST['username']);
$password = PHP_Secure($_POST['password']);
$password_hashed = sha1($password);
// EN ESTA LINIA ME DA EL ERROR
$db->where("(username = ?)", array(
$username
));
// EN ESTA LINIA ME DA EL ERROR
$db->where("password", $password_hashed);
$login = $db->getOne(T_USERS);
if (!empty($login)) {
if ($login->active == 0) {
$errors = 'ERROR';
} else {
$session_id = sha1(rand(11111, 99999)) . time() . md5(microtime());
$insert_data = array(
'user_id' => $login->id,
'session_id' => $session_id,
'time' => time()
);
$insert = $db->insert(T_SESSIONS, $insert_data);
$_SESSION['user_id'] = $session_id;
setcookie("user_id", $session_id, time() + (10 * 365 * 24 * 60 * 60));
$pt->loggedin = true;
if (!empty($_GET['to'])) {
$site_url = $_GET['to'];
}
header("Location: $site_url");
exit();
}
}
}