This commit is contained in:
Ibnu Maksum
2024-03-13 14:32:10 +07:00
parent ed9a411095
commit ca0edb4e17
21 changed files with 305 additions and 174 deletions

View File

@ -32,12 +32,12 @@ class Package
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one();
if(isset($zero) && $zero==1){
if (isset($zero) && $zero == 1) {
$p['price'] = 0;
}
if(!$p['enabled']){
if(!isset($admin) || !isset($admin['id']) || empty($admin['id'])){
if (!$p['enabled']) {
if (!isset($admin) || !isset($admin['id']) || empty($admin['id'])) {
r2(U . 'home', 'e', Lang::T('Plan Not found'));
}
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
@ -114,12 +114,29 @@ class Package
}
/**
* 1 Customer only can have 1 PPPOE and 1 Hotspot Plan
* 1 Customer only can have 1 PPPOE and 1 Hotspot Plan, 1 prepaid and 1 postpaid
*/
$b = ORM::for_table('tbl_user_recharges')
->select('tbl_user_recharges.id', 'id')
->select('customer_id')
->select('username')
->select('plan_id')
->select('namebp')
->select('recharged_on')
->select('recharged_time')
->select('expiration')
->select('time')
->select('status')
->select('method')
->select('tbl_user_recharges.routers', 'routers')
->select('tbl_user_recharges.type', 'type')
->select('admin_id')
->select('prepaid')
->where('customer_id', $id_customer)
->where('routers', $router_name)
->where('Type', $p['type'])
->where('tbl_user_recharges.routers', $router_name)
->where('tbl_user_recharges.Type', $p['type'])
->where('prepaid', $p['prepaid'])
->join('tbl_plans', array('tbl_plans.id', '=', 'tbl_user_recharges.plan_id'))
->find_one();
run_hook("recharge_user");
@ -608,7 +625,7 @@ class Package
public static function _raid()
{
return ORM::for_table('tbl_transactions')->max('id')+1;
return ORM::for_table('tbl_transactions')->max('id') + 1;
}
/**

View File

@ -8,15 +8,16 @@
class User
{
public static function getID(){
public static function getID()
{
global $db_password;
if(isset($_SESSION['uid']) && !empty($_SESSION['uid'])){
if (isset($_SESSION['uid']) && !empty($_SESSION['uid'])) {
return $_SESSION['uid'];
}else if(isset($_COOKIE['uid'])){
} else if (isset($_COOKIE['uid'])) {
// id.time.sha1
$tmp = explode('.',$_COOKIE['uid']);
if(sha1($tmp[0].'.'.$tmp[1].'.'.$db_password)==$tmp[2]){
if(time()-$tmp[1] < 86400*30){
$tmp = explode('.', $_COOKIE['uid']);
if (sha1($tmp[0] . '.' . $tmp[1] . '.' . $db_password) == $tmp[2]) {
if (time() - $tmp[1] < 86400 * 30) {
$_SESSION['uid'] = $tmp[0];
return $tmp[0];
}
@ -25,37 +26,93 @@ class User
return 0;
}
public static function setCookie($uid){
public static function getAttribute($name, $id = 0)
{
if (!$id) {
$id = User::getID();
}
if (!$id) {
return '';
}
$f = ORM::for_table('tbl_customers_fields')->where('field_name', $name)->where('customer_id', $id)->find_one();
if ($f) {
return $f['field_value'];
}
return '';
}
public static function getAttributes($endWith, $id = 0)
{
if (!$id) {
$id = User::getID();
}
if (!$id) {
return [];
}
$attrs = [];
$f = ORM::for_table('tbl_customers_fields')->where_like('field_name', $endWith)->where('customer_id', $id)->find_one();
if ($f) {
foreach ($f as $k) {
$attrs[$k['field_name']] = $k['field_value'];
}
return $attrs;
}
return [];
}
public static function setCookie($uid)
{
global $db_password;
if(isset($uid)){
if (isset($uid)) {
$time = time();
setcookie('uid', $uid.'.'.$time.'.'.sha1($uid.'.'.$time.'.'.$db_password), time()+86400*30);
setcookie('uid', $uid . '.' . $time . '.' . sha1($uid . '.' . $time . '.' . $db_password), time() + 86400 * 30);
}
}
public static function removeCookie(){
if(isset($_COOKIE['uid'])){
setcookie('uid', '', time()-86400);
public static function removeCookie()
{
if (isset($_COOKIE['uid'])) {
setcookie('uid', '', time() - 86400);
}
}
public static function _info($id = 0)
{
if(!$id){
if (!$id) {
$id = User::getID();
}
$d = ORM::for_table('tbl_customers')->find_one($id);
if(empty($d['username'])){
if (empty($d['username'])) {
r2(U . 'logout', 'd', '');
}
return $d;
}
public static function _billing()
public static function _billing($id = 0)
{
$id = User::getID();
$d = ORM::for_table('tbl_user_recharges')->where('customer_id', $id)->find_many();
if (!$id) {
$id = User::getID();
}
$d = ORM::for_table('tbl_user_recharges')
->select('tbl_user_recharges.id', 'id')
->select('customer_id')
->select('username')
->select('plan_id')
->select('namebp')
->select('recharged_on')
->select('recharged_time')
->select('expiration')
->select('time')
->select('status')
->select('method')
->select('tbl_user_recharges.routers', 'routers')
->select('tbl_user_recharges.type', 'type')
->select('admin_id')
->select('prepaid')
->where('customer_id', $id)
->join('tbl_plans', array('tbl_plans.id', '=', 'tbl_user_recharges.plan_id'))
->find_many();
return $d;
}
}