| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 | 
							- <?php
 
- /**
 
-  * @author darkredz
 
-  */
 
- class AuthenticationController extends DooController {
 
- 	function getAuthentication(){
 
- 		$key = $this->get_args('key')? $this->get_args('key') :"";
 
- 		
 
- 		if (!empty($key)){
 
- 			Doo::loadModel ( 'longle' );
 
- 			$longle = new longle ();
 
- 			Doo::loadModel('staff');
 
- 			$staff=new staff();
 
- 			Doo::loadModel('client');
 
- 			$client=new client();
 
- 			
 
- 			$longleInfo=$longle->getOne(array ('where' => "key_num= '".$key."' and (status=3 or status=4 or status=5)",'asArray' => TRUE));
 
- 			if (empty($longleInfo)){
 
- 				echo json_encode(array('list'=>array()));die;
 
- 			}
 
- 			
 
- 			$clientInfo=$client->getOne(array ('where' => "cid= '".$longleInfo['clientid']."'",'asArray' => TRUE));
 
- 			$staffInfo=$staff->getOne(array ('where' => "username= '".$longleInfo['responsible']."'",'asArray' => TRUE));
 
- 			$productCount=explode('+', $longleInfo['product']);
 
- 			
 
- 			$list['productCount']=count($productCount);
 
- 			$list['key_num']=$key;
 
- 			$list['telephone']=$staffInfo['telephone'];
 
- 			$list['username']=$staffInfo['category'].$staffInfo['username'];
 
- 			$list['qq']=$staffInfo['qq'];
 
- 			$count=mb_strlen($longleInfo['client'],'UTF8');
 
- 			if ($clientInfo['gender']=='男')
 
- 				$k=' 先生';
 
- 			else 
 
- 				$k=' 女士';
 
- 			
 
- 			if ($count<=2)
 
- 				$list['client']=mb_strcut($longleInfo['client'],0,4,'utf8')."*".$k;
 
- 			elseif ($count>2&&$count<=4)
 
- 				$list['client']=mb_strcut($longleInfo['client'],0,4,'utf8')."**".$k;
 
- 			else 
 
- 				$list['client']=mb_strcut($longleInfo['client'],0,4,'utf8')."***".$k;
 
- 			echo json_encode(array('list'=>$list));die;
 
- 		}
 
- 		echo json_encode(array('list'=>array()));die;
 
- 	}
 
- 	
 
- 	function getAuthenticationBySerial(){
 
- 		$key = $this->get_args('SerialNumber')? $this->get_args('SerialNumber') :"";
 
- 		
 
- 		if (!empty($key)){
 
- 			Doo::loadModel ( 'longle' );
 
- 			$longle = new longle ();
 
- 			Doo::loadModel('staff');
 
- 			$staff=new staff();
 
- 			Doo::loadModel('client');
 
- 			$client=new client();
 
- 			
 
- 			$longleInfo=$longle->getOne(array ('where' => "SerialNumber= '".$key."' and (status=3 or status=4 or status=5)",'asArray' => TRUE));
 
- 			if (empty($longleInfo)){
 
- 				echo json_encode(array('list'=>array()));die;
 
- 			}
 
- 			
 
- 			$clientInfo=$client->getOne(array ('where' => "cid= '".$longleInfo['clientid']."'",'asArray' => TRUE));
 
- 			$staffInfo=$staff->getOne(array ('where' => "username= '".$longleInfo['responsible']."'",'asArray' => TRUE));
 
- 			$productCount=explode('+', $longleInfo['product']);
 
- 			
 
- 			$list['productCount']=count($productCount);
 
- 			$list['key_num']=$longleInfo['key_num'];
 
- 			$list['telephone']=$staffInfo['telephone'];
 
- 			$list['username']=$staffInfo['category'].$staffInfo['username'];
 
- 			$list['qq']=$staffInfo['qq'];
 
- 			if ($clientInfo['gender']=='男')
 
- 				$k=' 先生';
 
- 			else 
 
- 				$k=' 女士';
 
- 			$list['client']=$longleInfo['client'].$k;
 
- 			
 
- 			$list['SerialNumber']=$this->half_replace($longleInfo['SerialNumber']);
 
- 			
 
- 			echo json_encode(array('list'=>$list));die;
 
- 		}
 
- 		echo json_encode(array('list'=>array()));die;
 
- 	}
 
- 	
 
- 	function half_replace($str){
 
- 	    $len = strlen($str)/2;
 
- 	    return substr_replace($str,str_repeat('*',$len),ceil(($len)/2),$len);
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 获取get或者POST值
 
- 	 * @param string $name 属性名称
 
- 	 * @return fixed 值
 
- 	 */
 
- 	function get_args($name) {
 
- 		if (isset ( $_GET [$name] )) {
 
- 			if (is_array ( $_GET [$name] ))
 
- 				return $_GET [$name];
 
- 			else {
 
- 				//return addslashes ( $_GET [$name] );
 
- 		return  $_GET [$name] ;
 
- 			}
 
- 		} elseif (isset ( $_POST [$name] )) {
 
- 			if (is_array ( $_POST [$name] ))
 
- 				return $_POST [$name];
 
- 			else {
 
- 				//return addslashes ( $_POST [$name] );
 
- 		return $_POST [$name];
 
- 			}
 
- 		} else {
 
- 			return false;
 
- 		}
 
- 	}
 
- }
 
- ?>
 
 
  |