예제 #1
0
function getValue($value_name, $data_type = "int", $method = "GET", $default_value = 0, $advance = 0)
{
    $value = $default_value;
    switch ($method) {
        case "GET":
            if (isset($_GET[$value_name])) {
                $value = $_GET[$value_name];
            }
            break;
        case "POST":
            if (isset($_POST[$value_name])) {
                $value = $_POST[$value_name];
            }
            break;
        case "COOKIE":
            if (isset($_COOKIE[$value_name])) {
                $value = $_COOKIE[$value_name];
            }
            break;
        case "SESSION":
            if (isset($_SESSION[$value_name])) {
                $value = $_SESSION[$value_name];
            }
            break;
        default:
            if (isset($_GET[$value_name])) {
                $value = $_GET[$value_name];
            }
            break;
    }
    $valueArray = array("int" => intval($value), "str" => trim(strval($value)), "flo" => floatval($value), "dbl" => doubleval($value), "arr" => $value);
    foreach ($valueArray as $key => $returnValue) {
        if ($data_type == $key) {
            if ($advance != 0) {
                switch ($advance) {
                    case 1:
                        $returnValue = replaceMQ($returnValue);
                        break;
                    case 2:
                        $returnValue = htmlspecialbo($returnValue);
                        break;
                }
            }
            //Do số quá lớn nên phải kiểm tra trước khi trả về giá trị
            if (strval($returnValue) == "INF" && $data_type != "str") {
                return 0;
            }
            return $returnValue;
            break;
        }
    }
    return intval($value);
}
예제 #2
0
function checkLogin($username, $password)
{
    $username = replaceMQ($username);
    $password = replaceMQ($password);
    $db_check = new db_query("SELECT adm_id\n                                FROM admin_users\n                                WHERE adm_loginname = '" . $username . "' AND adm_password = '******'");
    if (mysqli_num_rows($db_check->result) > 0) {
        $check = mysqli_fetch_array($db_check->result);
        $adm_id = $check["adm_id"];
        $db_check->close();
        unset($db_check);
        return $adm_id;
    } else {
        $db_check->close();
        unset($db_check);
        return 0;
    }
}
예제 #3
0
function checkLogin($b, $c)
{
    $b = replaceMQ($b);
    $c = replaceMQ($c);
    $f = new db_query("SELECT adm_id \n\t\t\t\t\t\t\t FROM admin_users\n\t\t\t\t\t\t\t WHERE adm_loginname = '" . $b . "' AND adm_password = '******'");
    if (mysqli_num_rows($f->result) > 0) {
        $g = mysqli_fetch_array($f->result);
        $h = $g["adm_id"];
        $f->close();
        unset($f);
        return $h;
    } else {
        $f->close();
        unset($f);
        return 0;
    }
}
예제 #4
0
function t($str)
{
    if (!TRANSLATED) {
        return $str;
    } else {
        $str = replaceMQ($str);
        $str = mb_strtolower($str, 'UTF-8');
        $db = new db_query('SELECT tra_text FROM translate_text WHERE tra_keyword = "' . $str . '" LIMIT 1');
        $text = mysqli_fetch_assoc($db->result);
        if ($text) {
            $text = $text['tra_text'];
            return $text;
        }
        //Nếu chưa tồn tại từ này thì insert vào csdl
        $db_insert = new db_execute('INSERT INTO translate_text (tra_keyword,tra_text) VALUES("' . $str . '","' . $str . '")');
        return '{' . $str . '}';
    }
}
예제 #5
0
function forgetPass($email){
	$email	= replaceMQ($email);
	$user_id		= 0;
	$db_check	= new db_query("SELECT use_id 
										 FROM user_test
										 WHERE use_email = '" . $email . "' AND use_active = 1");
	if(mysql_num_rows($db_check->result) > 0){
		$check	= mysql_fetch_array($db_check->result);
		$user_id	= $check["use_id"];
		$db_check->close();
		unset($db_check);
		return $user_id;
	}
	else{
        ?>
        <script>
            alert('Bạn đã khai báo tên truy cập hoặc email không đúng.');
        </script>
        <?
		$db_check->close();
		unset($db_check);
		return false;
	}
}
예제 #6
0
function set_keyword_search($llllllll)
{
    $llllllll = removeHTML($llllllll);
    $llllllll = replaceMQ($llllllll);
    $llllllll = htmlspecialchars($llllllll);
    $llllllll = mb_strtolower($llllllll);
    $rrrrrrrr = new user();
    if ($rrrrrrrr->logged()) {
        $ssssssss = $rrrrrrrr->id;
    } else {
        $ssssssss = 0;
    }
    $tttttttt = new db_execute('INSERT INTO keyword_temp(key_text,key_user_id) VALUES("' . $llllllll . '",' . $ssssssss . ')');
    unset($tttttttt);
}
예제 #7
0
function set_keyword_search($keyword)
{
    $keyword = removeHTML($keyword);
    $keyword = replaceMQ($keyword);
    $keyword = htmlspecialchars($keyword);
    $keyword = mb_strtolower($keyword);
    $myuser = new user();
    if ($myuser->logged()) {
        $user_id = $myuser->id;
    } else {
        $user_id = 0;
    }
    $db_insert = new db_execute('INSERT INTO keyword_temp(key_text,key_user_id) VALUES("' . $keyword . '",' . $user_id . ')');
    unset($db_insert);
}