forked from kevinowino869/mitrobill
Path Configuration
This commit is contained in:
@ -1,21 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
|
||||
Class Admin{
|
||||
class Admin
|
||||
{
|
||||
|
||||
public static function getID(){
|
||||
public static function getID()
|
||||
{
|
||||
global $db_password;
|
||||
if(isset($_SESSION['aid'])){
|
||||
if (isset($_SESSION['aid'])) {
|
||||
return $_SESSION['aid'];
|
||||
}else if(isset($_COOKIE['aid'])){
|
||||
} else if (isset($_COOKIE['aid'])) {
|
||||
// id.time.sha1
|
||||
$tmp = explode('.',$_COOKIE['aid']);
|
||||
if(sha1($tmp[0].$tmp[1].$db_password)==$tmp[2]){
|
||||
if($tmp[1] < 86400*7){
|
||||
$tmp = explode('.', $_COOKIE['aid']);
|
||||
if (sha1($tmp[0] . '.' . $tmp[1] . '.' . $db_password) == $tmp[2]) {
|
||||
if (time() - $tmp[1] < 86400 * 7) {
|
||||
$_SESSION['aid'] = $tmp[0];
|
||||
return $tmp[0];
|
||||
}
|
||||
@ -24,28 +27,31 @@ Class Admin{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function setCookie($aid){
|
||||
public static function setCookie($aid)
|
||||
{
|
||||
global $db_password;
|
||||
if(isset($aid)){
|
||||
if (isset($aid)) {
|
||||
$time = time();
|
||||
setcookie('aid', $aid.'.'.$time.'.'.sha1($aid.'.'.$time.'.'.$db_password), time()+86400*7);
|
||||
setcookie('aid', $aid . '.' . $time . '.' . sha1($aid . '.' . $time . '.' . $db_password), time() + 86400 * 7);
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeCookie(){
|
||||
if(isset($_COOKIE['aid'])){
|
||||
setcookie('aid', '', time()-86400);
|
||||
public static function removeCookie()
|
||||
{
|
||||
if (isset($_COOKIE['aid'])) {
|
||||
setcookie('aid', '', time() - 86400);
|
||||
}
|
||||
}
|
||||
|
||||
public static function _info($id = 0){
|
||||
if(empty($id) && $id==0){
|
||||
public static function _info($id = 0)
|
||||
{
|
||||
if (empty($id) && $id == 0) {
|
||||
$id = Admin::getID();
|
||||
}
|
||||
if($id){
|
||||
if ($id) {
|
||||
return ORM::for_table('tbl_users')->find_one($id);
|
||||
}else{
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,13 @@ class User
|
||||
{
|
||||
public static function getID(){
|
||||
global $db_password;
|
||||
if(isset($_SESSION['uid'])){
|
||||
if(isset($_SESSION['uid']) && !empty($_SESSION['uid'])){
|
||||
return $_SESSION['uid'];
|
||||
}else if(isset($_COOKIE['uid'])){
|
||||
// id.time.sha1
|
||||
$tmp = explode('.',$_COOKIE['uid']);
|
||||
if(sha1($tmp[0].$tmp[1].$db_password)==$tmp[2]){
|
||||
if($tmp[1] < 86400*30){
|
||||
if(sha1($tmp[0].'.'.$tmp[1].'.'.$db_password)==$tmp[2]){
|
||||
if(time()-$tmp[1] < 86400*30){
|
||||
$_SESSION['uid'] = $tmp[0];
|
||||
return $tmp[0];
|
||||
}
|
||||
|
Reference in New Issue
Block a user