get_results($query, 'ARRAY_A');
if(empty($array)){
return current($result);
}else{
return $result;
}
}
// Check if an IP is valid
function lz_valid_ip($ip){
if(!ip2long($ip)){
return false;
}
return true;
}
// Check if a field is posted via POST else return default value
function lz_optpost($name, $default = ''){
if(!empty($_POST[$name])){
return lz_inputsec(lz_htmlizer(trim($_POST[$name])));
}
return $default;
}
// Check if a field is posted via GET else return default value
function lz_optget($name, $default = ''){
if(!empty($_GET[$name])){
return lz_inputsec(lz_htmlizer(trim($_GET[$name])));
}
return $default;
}
// Check if a field is posted via GET or POST else return default value
function lz_optreq($name, $default = ''){
if(!empty($_REQUEST[$name])){
return lz_inputsec(lz_htmlizer(trim($_REQUEST[$name])));
}
return $default;
}
function lz_inputsec($string){
if(!get_magic_quotes_gpc()){
$string = addslashes($string);
}else{
$string = stripslashes($string);
$string = addslashes($string);
}
// This is to replace ` which can cause the command to be executed in exec()
$string = str_replace('`', '\`', $string);
return $string;
}
function lz_htmlizer($string){
$string = htmlentities($string, ENT_QUOTES, 'UTF-8');
$string = preg_replace('/(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)/e', 'entity_check(\\2);', $string);
return $string;
}
// Check if a checkbox is selected
function lz_is_checked($post){
if(!empty($_POST[$post])){
return true;
}
return false;
}
// Reoort an error
function lz_report_error($error = array()){
if(empty($error)){
return true;
}
$error_string = 'Please fix the below error(s) :
';
foreach($error as $ek => $ev){
$error_string .= '* '.$ev.'
';
}
echo '
' . __($error_string, 'loginizer') . '
' . __($notice_string, 'loginizer') . '