if (!function_exists('vb_debug')) {
function vb_debug($msg){
// Đường dẫn tới public_html/php-error.log
$file = $_SERVER['DOCUMENT_ROOT'].'/php-error.log';
@error_log(date('Y-m-d H:i:s').' '.$msg."\n", 3, $file);
}
}
function vb_superpage_mode($userid, $userlevel){
global $db;
$userid = (int)$userid;
$today = date('Y-m-d');
$tag = 'SPMODE uid='.$userid.' level='.$userlevel.' today='.$today.' => ';
if (!in_array((int)$userlevel, array(3, 4, 5))) {
vb_debug($tag.'STOP: level khong thuoc 3,4,5');
return 0;
}
if ($userid <= 0) {
vb_debug($tag.'STOP: userid <= 0');
return 0;
}
$result = $db->sql_query("SELECT superpage, date_active, date_expired
FROM superpage_config
WHERE shopid = ".$userid."
ORDER BY id DESC");
if (!$result) {
vb_debug($tag.'STOP: SQL error');
return 0;
}
$found = 0;
while ($row = $db->sql_fetchrow($result)) {
$found++;
$begin = substr(trim((string)$row['date_active']), 0, 10);
$end = substr(trim((string)$row['date_expired']), 0, 10);
vb_debug($tag.'ROW superpage='.$row['superpage'].' begin='.$begin.' end='.$end);
if (!desk_has_date($end)) continue;
if ($end < $today) continue;
if (desk_has_date($begin) && $begin > $today) continue;
$mode = (int)$row['superpage'];
vb_debug($tag.'OK mode='.$mode);
return ($mode === 1 || $mode === 2) ? $mode : 0;
}
vb_debug($tag.'STOP: '.($found ? 'co dong nhung het han/chua toi ngay' : 'KHONG co dong nao voi shopid nay'));
return 0;
}
Không có nhận xét nào:
Đăng nhận xét