PHP 8.1.33
Preview: UserpinIdentity_bk.php Size: 2.27 KB
/home/jambtst2015/public_html/protected/components/UserpinIdentity_bk.php

<?php

/**
 * UserIdentity represents the data needed to identity a user.
 * It contains the authentication method that checks if the provided
 * data can identity the user.
 */
class UserpinIdentity extends CUserIdentity
{
	/**
	 * Authenticates a user.
	 * The example implementation makes sure if the username and password
	 * are both 'demo'.
	 * In practical applications, this should be changed to authenticate
	 * against some persistent user identity storage (e.g. database).
	 * @return boolean whether authentication succeeds.
	 */
	private $_userpinid;
	public function authenticate()
	{
		$record=Pin::model()->findByAttributes(array('userid'=>$this->username));
		$curr_time = date('Y-m-d H:i:s');
		
		$exam_id = Yii::app()->user->getState('user_xam_id');
		
		$getExist = Examuser::model()->find("pin_id = '".addslashes($record['id'])."' AND exam_id='".$exam_id['id']."'");
		//echo count($getExist);
		//exit;
		$isValid =  Examuser::model()->find("pin_id = '".addslashes($record['id'])."' AND exam_id='".$exam_id['id']."' AND expiry_date>'".$curr_time."'");
		
        if($record===null){
            $this->errorCode=self::ERROR_USERNAME_INVALID;
			return !$this->errorCode;
		}
        /*else if($record->password!==crypt($this->password,$record->password)){
            $this->errorCode=self::ERROR_PASSWORD_INVALID;
		}*/
		else if($record->password!==$this->password){
            $this->errorCode=self::ERROR_PASSWORD_INVALID;
			return !$this->errorCode;
		}else if(count($getExist)==0){
			$this->errorCode=self::ERROR_EXAM_HAS_NOT_MAPPED;
			return $this->errorCode;
		}else if($isValid==''){
			$this->errorCode=self::ERROR_VALIDITY_OVER;
			return $this->errorCode;
		}
        else
        {
			//exit('yes');
            $this->_userpinid=$record->id;
			$this->setState('isUser',$record->id);
            $this->setState('userName',$record->userid);
            //$this->setState('AdminNname',$record->username);
			//Yii::app()->user->isGuest = false;
            //$this->setState('title', $record->title);
            $this->errorCode=self::ERROR_NONE;
			return !$this->errorCode;
        }
        //return !$this->errorCode;
	}
	
	public function getId()       //  override Id
    {
       return $this->_userpinid;
    }
}

Directory Contents

Dirs: 0 × Files: 12

Name Size Perms Modified Actions
2.16 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.32 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.88 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.96 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.63 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.43 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
42.64 KB lrw-r--r-- 2025-11-04 10:28:05
Edit Download
8.77 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
8.17 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.61 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.61 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.27 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).