Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Membership extends ClassAbstract
- {
- private $username;
- private $remoteAddress;
- private $status;
- private $reseller;
- private $permission;
- private $serverallow;
- private $profileallow;
- private $totalUser;
- private $activeUser;
- private $currActiveTotalUser;
- private $serverList;
- private $groupList;
- private $updateActiveTotalUser;
- private $cspUpdateTime;
- function setSessionData()
- {
- $_SESSION['username'] = $this->getUsername();
- $_SESSION['remote_address'] = $this->getRemoteAddress();
- $_SESSION['status'] = $this->getStatus();
- $_SESSION['reseller'] = $this->getReseller();
- $_SESSION['permission'] = $this->getPersmission();
- $_SESSION['serverallow'] = $this->getServerAllow();
- $_SESSION['profileallow'] = $this->getProfileAllow();
- $_SESSION['totalUser'] = $this->getTotalUser();
- $_SESSION['activeUser'] = $this->getActiveUser();
- $_SESSION['currActiveTotalUser'] = $this->getCurrActiveTotalUser();
- $_SESSION['serverList'] = $this->getServerList();
- $_SESSION['groupList'] = $this->getGroupList();
- $_SESSION['updateActiveTotalUser'] = $this->getUpdateActiveTotalUser();
- $_SESSION['cspUpdateTime'] = $this->cspUpdateTime;
- }
- /*
- * Setter Functions
- */
- function setUsername($un)
- {
- $this->username = $un;
- }
- function setRemoteAddress($IP)
- {
- $this->remoteAddress = $IP;
- }
- function setStatus($status)
- {
- $this->status = $status;
- }
- function setReseller($reseller)
- {
- $this->reseller = $reseller;
- }
- function setPersmission($permsission)
- {
- $this->permission = $permsission;
- }
- function setServerAllow($serverallow)
- {
- $this->serverallow = $serverallow;
- }
- function setProfileAllow($profileallow)
- {
- $this->profileallow = $profileallow;
- }
- function setTotalUser($totaluser)
- {
- $this->totalUser = $totaluser;
- }
- function setActiveUser($activeuser)
- {
- $this->activeUser = $activeuser;
- }
- function setCurrActiveTotalUser($reseller)
- {
- global $mysql;
- $this->currActiveTotalUser = $mysql->get_info($reseller);
- }
- function setUpdateActiveTotalUser($updateActiveTotalUser)
- {
- $this->updateActiveTotalUser = $updateActiveTotalUser;
- }
- function setServerList()
- {
- global $mysql;
- $this->serverList = $mysql->serverList();
- }
- function setGroupList()
- {
- global $mysql;
- $this->groupList = $mysql->groupsList();
- }
- /*
- * Getter Functions
- */
- function getUsername()
- {
- return $this->username;
- }
- function getRemoteAddress()
- {
- return $this->remoteAddress;
- }
- function getStatus()
- {
- return $this->status;
- }
- function getReseller()
- {
- return $this->reseller;
- }
- function getPersmission()
- {
- return $this->permission;
- }
- function getServerAllow()
- {
- return $this->serverallow;
- }
- function getProfileAllow()
- {
- return $this->profileallow;
- }
- function getTotalUser()
- {
- return $this->totalUser;
- }
- function getActiveUser()
- {
- return $this->activeUser;
- }
- function getCurrActiveTotalUser()
- {
- return $this->currActiveTotalUser;
- }
- function getUpdateActiveTotalUser()
- {
- return $this->updateActiveTotalUser;
- }
- function getServerList()
- {
- return $this->serverList;
- }
- function getGroupList()
- {
- return $this->groupList;
- }
- function validate_user($un, $pwd)
- {
- global $mysql;
- global $log;
- $error = "";
- $this->setUsername($un);
- $this->setRemoteAddress($_SERVER['REMOTE_ADDR']);
- if (preg_match('/^([A-Za-z1-90]+)$/', $un)) {
- $clean_un = $un;
- } else {
- $error = "Bad Username";
- $log->LogWarn('User [' . $this->getUsername() . '](' . $this->getRemoteAddress() . ') try to log in to system. Login Denied. BAD Username or Password.');
- }
- if ($clean_pwd = preg_match('/^([A-Za-z0-9]+)$/', $pwd)) {
- $clean_pwd = $pwd;
- } else {
- if ($error != "") {
- $error .= " And Bad Password";
- $log->LogWarn('User [' . $this->getUsername() . '](' . $this->getRemoteAddress() . ') try to log in to system. Login Denied. BAD Username or Password.');
- } else {
- $error = "Bad Password";
- $log->LogWarn('User [' . $this->getUsername() . '](' . $this->getRemoteAddress() . ') try to log in to system. Login Denied. BAD Username or Password.');
- }
- }
- if ($error != "")
- return $error;
- $ensure_credentials = $mysql->verify_Username_and_Pass($clean_un, md5($clean_pwd));
- $reseller = $mysql->get_reseller_id($un);
- $permission = $mysql->get_permission_id($un);
- if ($ensure_credentials) {
- $this->setStatus('authorized');
- $this->setReseller($mysql->get_reseller_id($un));
- $this->setPersmission($mysql->get_permission_id($un));
- $this->setServerAllow($mysql->get_member_serverallow($un));
- $this->setProfileAllow($mysql->get_member_profileallow($un));
- $this->setTotalUser($mysql->get_member_total_user($un));
- $this->setActiveUser($mysql->get_member_active_user($un));
- $this->setUpdateActiveTotalUser(1);
- $this->setCurrActiveTotalUser($this->getReseller());
- $this->setServerList();
- $this->setGroupList();
- $this->cspUpdateTime = "";
- /*
- * Save all member data in session
- */
- $this->setSessionData();
- header("location: index.php");
- $log->LogInfo('User [' . $this->getUsername() . '] (' . $this->getRemoteAddress() . ') Logged in Successfully.');
- } else {
- $log->LogWarn('User [' . $this->getUsername() . '](' . $this->getRemoteAddress() . ') Login Denied. Wrong Username or Password.');
- return "Please enter a correct username and password";
- }
- }
- function log_User_Out()
- {
- global $log;
- if (isset($_SESSION['status'])) {
- unset($_SESSION['status']);
- $log->LogInfo('User [' . $_SESSION['username'] . '] Logged Out Successfully.');
- if (isset($_COOKIE[session_name()]))
- setcookie(session_name(), '', time() - 1000);
- session_destroy();
- }
- }
- function confirm_Member()
- {
- // session_start();
- if ($_SESSION['status'] != 'authorized')
- header("location: login.php");
- }
- function confirm_permision($section_permission, $user_permission)
- {
- global $mysql;
- if (!$mysql->bitwise_check($section_permission, $user_permission)) {
- echo "Sorry... \nYou are not allow to enter this section. </br>";
- echo '<a href=index.php>back to previous page</a>';
- die();
- }
- }
- }
- $membership = new Membership();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement