generate token
This commit is contained in:
parent
27bd2590f2
commit
1903dc6b45
@ -157,12 +157,25 @@ class User
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function generateToken($uid)
|
||||||
|
{
|
||||||
|
global $db_pass;
|
||||||
|
$time = time();
|
||||||
|
return [
|
||||||
|
'time' => $time,
|
||||||
|
'token' => $uid . '.' . $time . '.' . sha1($uid . '.' . $time . '.' . $db_pass)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public static function setCookie($uid)
|
public static function setCookie($uid)
|
||||||
{
|
{
|
||||||
global $db_pass;
|
global $db_pass;
|
||||||
if (isset($uid)) {
|
if (isset($uid)) {
|
||||||
$time = time();
|
list($time, $token) = self::generateToken($uid);
|
||||||
setcookie('uid', $uid . '.' . $time . '.' . sha1($uid . '.' . $time . '.' . $db_pass), time() + 86400 * 30);
|
setcookie('uid', $token, time() + 86400 * 30);
|
||||||
|
return $token;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +223,8 @@ class User
|
|||||||
return $d;
|
return $d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isUserVoucher($kode) {
|
public static function isUserVoucher($kode)
|
||||||
|
{
|
||||||
$regex = '/^GC\d+C.{10}$/';
|
$regex = '/^GC\d+C.{10}$/';
|
||||||
return preg_match($regex, $kode);
|
return preg_match($regex, $kode);
|
||||||
}
|
}
|
||||||
@ -223,11 +237,21 @@ class User
|
|||||||
$d = ORM::for_table('tbl_user_recharges')
|
$d = ORM::for_table('tbl_user_recharges')
|
||||||
->select('tbl_user_recharges.id', 'id')
|
->select('tbl_user_recharges.id', 'id')
|
||||||
->selects([
|
->selects([
|
||||||
'customer_id', 'username', 'plan_id', 'namebp', 'recharged_on', 'recharged_time', 'expiration', 'time',
|
'customer_id',
|
||||||
'status', 'method', 'plan_type',
|
'username',
|
||||||
|
'plan_id',
|
||||||
|
'namebp',
|
||||||
|
'recharged_on',
|
||||||
|
'recharged_time',
|
||||||
|
'expiration',
|
||||||
|
'time',
|
||||||
|
'status',
|
||||||
|
'method',
|
||||||
|
'plan_type',
|
||||||
['tbl_user_recharges.routers', 'routers'],
|
['tbl_user_recharges.routers', 'routers'],
|
||||||
['tbl_user_recharges.type', 'type'],
|
['tbl_user_recharges.type', 'type'],
|
||||||
'admin_id', 'prepaid'
|
'admin_id',
|
||||||
|
'prepaid'
|
||||||
])
|
])
|
||||||
->left_outer_join('tbl_plans', ['tbl_plans.id', '=', 'tbl_user_recharges.plan_id'])
|
->left_outer_join('tbl_plans', ['tbl_plans.id', '=', 'tbl_user_recharges.plan_id'])
|
||||||
->left_outer_join('tbl_bandwidth', ['tbl_bandwidth.id', '=', 'tbl_plans.id_bw'])
|
->left_outer_join('tbl_bandwidth', ['tbl_bandwidth.id', '=', 'tbl_plans.id_bw'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user