⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 authentication.front.php

📁 FP2 CRM code+Mysql DB
💻 PHP
字号:
<?php
session_start();
$_SESSION['session_id'] = session_id();
class Authentication
{
	var $validateuser = false;
	var $msg = '';
	var $clientid;
	var $userType;
//-----------------------------------------------------------------------------	
	function getLoginId()
	{
		return $this->clientid;
	}
//-----------------------------------------------------------------------------
	function getLoginUserName()
	{
		return isset($_SESSION['loginusername']) ? $_SESSION['loginusername'] : '';
	}
//-----------------------------------------------------------------------------
	function getUserRoles()
	{
		$empid = isset($_SESSION['clientid']) ? $_SESSION['clientid'] : '';
		if($empid == '1')
			return '';
		
		return isset($this->userRoles) ? $this->userRoles : '';
	}
//-----------------------------------------------------------------------------
	function Authentication($fileName='',$pageBase='',$security,$userType)
	{		
		$cmd = isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : '';		
       	
		if(empty($fileName) || empty($pageBase) )
		{
			die('Invalid Arguments for pageBage (parent) Constructor.');
		}
		
		if(!$security)
		{
			$this->validateuser = true;		
			return;			
		}
		
		$this->pageBase = $pageBase;

				
		$empid = isset($_SESSION['clientid']) ? $_SESSION['clientid'] : '';
		
		if($cmd == 'login')
		{
			//if($this->validateuser == true)		return;
			
			$username = isset($_REQUEST['username']) ? $_REQUEST['username'] : '';
			$pwd = isset($_REQUEST['pwd']) ? $_REQUEST['pwd'] : '';			
			$type = isset($_REQUEST['logintype']) ? $_REQUEST['logintype'] : '';			
			
			$id = $pageBase->db->getField('user','id','user_name="'.$username.'" and pwd="'.$pwd.'" and user_type="'.$type.'"');			
			if(!empty($id))
			{
					$login_status = $pageBase->db->getField('user','active','id='.$id);
					if($login_status == '0' || $login_status == '')
					{
						$this->msg = 'Your Account is Inactive Now, Please Contact to Administrator.';
						$this->validateuser = false;
						return false;
					}
					else
					{
						$_SESSION['usertype'] = $pageBase->db->getField('user','user_type','id='.$id);
						$this->validateuser = true;		
						$_SESSION['clientid'] = $id;
						$un = $pageBase->db->getField('user','user_name','id='.$id);
						$_SESSION['loginusername'] = $un;
						//$this->userType = 'client';
						//if($un == 'Admin')
							//$this->userType = 'Admin';
						//else
							//$this->userType = 'user';
						$this->clientid = $id;
						header('location:'.$_SERVER['HTTP_REFERER']);
						die();
					}
			}
			else
			{
					$this->msg = 'Invalid User Name or Password.';
					$this->validateuser = false;
					return false;
			}
		}
		else
		if($cmd == 'logout')
		{
			$this->validateuser = false;
			unset($_SESSION['clientid']);
			header('location:'.APP_WEB_ROOT.'/index.php');
			die();
		}
		else
		if(!isset($_SESSION['clientid']))
		{
			$this->validateuser = false;
			return;
		}

		$login_status = $pageBase->db->getField('user','active','id='.$empid);
		if($login_status == '0' || $login_status == '')
		{
			 $msg = 'Sorry Your Login is No Longer Active Please : Contact To Super Admin';
			 $this->showAccessError($msg);
			 die();
		}
		
		
					
		
		//--------------------------


	//-------------------------------------------------------------------------
			//print APP_WEB_ROOT.'<br />';
			//
	//------------------Both apper lies should be the same basic path-----------
/*			$fileName = APP_WEB_SERVER.$fileName;
			$chars = strlen(APP_WEB_ROOT);
			$file = substr($fileName,$chars+1);
			$fileid = $pageBase->db->getField('page','id','filename="'.$file.'"');
			$this->clientid = isset($_SESSION['clientid']) ? $_SESSION['clientid'] : '';
*/			if(isset($_SESSION['clientid']))
			{
				$this->validateuser = true;
			}
	}
//-----------------------------------------------------------------------------
	function validUser()
	{
		return $this->validateuser;
	}
//-----------------------------------------------------------------------------	
	function showAccessError($msg)
	{
		$validCmdid=false;
		$this->pageBase->subTitle = 'Access Denied';
		$this->pageBase->msg = $msg;
		$this->pageBase->contentTemplate = 'notauthorize.html';		
		$this->pageBase->displayPage();	
		die();
	}
//-----------------------------------------------------------------------------	
	function showAutoFileInserterDialog($file)
	{
		$validCmdid=false;
		$this->pageBase->subTitle = 'Security Of This Page is not Implemented';
		$this->pageBase->form->addElement('header','emphead','File Informatin:');	
		$this->pageBase->form->addElement('static','st_fname','File Name:','<label>'.$file.'</label>');
		$this->pageBase->form->addElement('static','st_cname','Command Name:','<label class="subTitle">'."File is not Exist in Database".'</label>');
		$this->pageBase->form->addElement('link','linksde','',APP_WEB_ROOT.'/page.auto.php?cmd=file&fileName='.$file,'Click Hear To Proceed');
		$this->pageBase->contentTemplate = 'generaltemplates/generalform.html';
		$this->pageBase->displayPage();	
		die();
	}
//-----------------------------------------------------------------------------
	function showAutoComandInserterDialog($file,$cmdName)
	{
		$validCmdid=false;
		$this->pageBase->subTitle = 'Security Of This Page is not Implemented';
		$this->pageBase->form->addElement('header','emphead','File Informatin:');	
		$this->pageBase->form->addElement('static','st_fname','File Name:','<label>'.$file.'</label>');
		$this->pageBase->form->addElement('static','st_cname','Command Name:','<label>'.$cmdName.'</label>');
		$this->pageBase->form->addElement('static','st_cname','Command Name:','<label class="subTitle">'."Cammond is not associated with page".'</label>');
		$this->pageBase->form->addElement('link','linksde','',APP_WEB_ROOT.'/page.auto.php?cmd=cmd&cmdName='.$cmdName.'&fileName='.$file,'Click Hear To Proceed');
		$this->pageBase->contentTemplate = 'generaltemplates/generalform.html';
		$this->pageBase->displayPage();	
		die();
	}
//-----------------------------------------------------------------------------
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -