Файл: adultscript-2.0.3-pro/files/modules/user/helpers/guest.php
Строк: 22
<?php
defined('_VALID') or die('Restricted Access!');
class VHelper_user_guest
{
public static function update($ip, $size, $duration = 0, $mobile = false)
{
$db = VF::factory('database');
$db->query("SELECT bandwidth, duration, views FROM #__guest WHERE ip = ".$ip." LIMIT 1");
if ($db->affected_rows()) {
$method = VF::cfg_item('module.user.guest_limit');
$limit = VF::cfg_item('module.user.guest_'.$method);
$current = $db->fetch_field($method);
if ($method == 'bandwidth') {
$limit = ($limit*1024*1024);
}
if ($current > $limit) {
$_SESSION['message'] = 'Guest bandwidth limit reached. Please create a account or login to watch more videos!';
$URL = ($mobile) ? VF::cfg_item('mobile_url').'/register/' : BASE_URL.'/user/signup/';
VF::redirect($URL);
}
$db->query("UPDATE #__guest
SET bandwidth = bandwidth+".$size.",
last_visit = '".date('Y-m-d h:i:s')."',
duration = duration+".$duration.",
views = views+1
WHERE ip = ".$ip."
LIMIT 1");
} else {
$db->query("INSERT INTO #__guest
SET bandwidth = ".$size.",
duration = ".$duration.",
views = 1,
last_visit = '".date('Y-m-d h:i:s')."',
ip = ".$ip);
}
}
}