AuthenticationController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class AuthenticationController extends DooController {
  6. function getAuthentication(){
  7. $key = $this->get_args('key')? $this->get_args('key') :"";
  8. if (!empty($key)){
  9. Doo::loadModel ( 'longle' );
  10. $longle = new longle ();
  11. Doo::loadModel('staff');
  12. $staff=new staff();
  13. Doo::loadModel('client');
  14. $client=new client();
  15. $longleInfo=$longle->getOne(array ('where' => "key_num= '".$key."' and (status=3 or status=4 or status=5)",'asArray' => TRUE));
  16. if (empty($longleInfo)){
  17. echo json_encode(array('list'=>array()));die;
  18. }
  19. $clientInfo=$client->getOne(array ('where' => "cid= '".$longleInfo['clientid']."'",'asArray' => TRUE));
  20. $staffInfo=$staff->getOne(array ('where' => "username= '".$longleInfo['responsible']."'",'asArray' => TRUE));
  21. $productCount=explode('+', $longleInfo['product']);
  22. $list['product']=strtr($longleInfo['product'],"+"," ");
  23. $list['productCount']=count($productCount);
  24. $list['key_num']=$key;
  25. $list['telephone']=$staffInfo['telephone'];
  26. $list['username']=$staffInfo['category'].$staffInfo['username'];
  27. $list['qq']=$staffInfo['qq'];
  28. $count=mb_strlen($longleInfo['client'],'UTF8');
  29. if ($clientInfo['gender']=='男')
  30. $k=' 先生';
  31. else
  32. $k=' 女士';
  33. if ($count<=2)
  34. $list['client']=mb_strcut($longleInfo['client'],0,4,'utf8')."*".$k;
  35. elseif ($count>2&&$count<=4)
  36. $list['client']=mb_strcut($longleInfo['client'],0,4,'utf8')."**".$k;
  37. else
  38. $list['client']=mb_strcut($longleInfo['client'],0,4,'utf8')."***".$k;
  39. echo json_encode(array('list'=>$list));die;
  40. }
  41. echo json_encode(array('list'=>array()));die;
  42. }
  43. function getAuthenticationBySerial(){
  44. $key = $this->get_args('SerialNumber')? $this->get_args('SerialNumber') :"";
  45. if (!empty($key)){
  46. Doo::loadModel ( 'longle' );
  47. $longle = new longle ();
  48. Doo::loadModel('staff');
  49. $staff=new staff();
  50. Doo::loadModel('client');
  51. $client=new client();
  52. $longleInfo=$longle->getOne(array ('where' => "SerialNumber= '".$key."' and (status=3 or status=4 or status=5)",'asArray' => TRUE));
  53. if (empty($longleInfo)){
  54. echo json_encode(array('list'=>array()));die;
  55. }
  56. $clientInfo=$client->getOne(array ('where' => "cid= '".$longleInfo['clientid']."'",'asArray' => TRUE));
  57. $staffInfo=$staff->getOne(array ('where' => "username= '".$longleInfo['responsible']."'",'asArray' => TRUE));
  58. $productCount=explode('+', $longleInfo['product']);
  59. $list['product']=strtr($longleInfo['product'],"+"," ");
  60. $list['productCount']=count($productCount);
  61. $list['key_num']=$longleInfo['key_num'];
  62. $list['telephone']=$staffInfo['telephone'];
  63. $list['username']=$staffInfo['category'].$staffInfo['username'];
  64. $list['qq']=$staffInfo['qq'];
  65. if ($clientInfo['gender']=='男')
  66. $k=' 先生';
  67. else
  68. $k=' 女士';
  69. $list['client']=$longleInfo['client'].$k;
  70. $list['SerialNumber']=$this->half_replace($longleInfo['SerialNumber']);
  71. echo json_encode(array('list'=>$list));die;
  72. }
  73. echo json_encode(array('list'=>array()));die;
  74. }
  75. function half_replace($str){
  76. $len = strlen($str)/2;
  77. return substr_replace($str,str_repeat('*',$len),ceil(($len)/2),$len);
  78. }
  79. /**
  80. * 获取get或者POST值
  81. * @param string $name 属性名称
  82. * @return fixed 值
  83. */
  84. function get_args($name) {
  85. if (isset ( $_GET [$name] )) {
  86. if (is_array ( $_GET [$name] ))
  87. return $_GET [$name];
  88. else {
  89. //return addslashes ( $_GET [$name] );
  90. return $_GET [$name] ;
  91. }
  92. } elseif (isset ( $_POST [$name] )) {
  93. if (is_array ( $_POST [$name] ))
  94. return $_POST [$name];
  95. else {
  96. //return addslashes ( $_POST [$name] );
  97. return $_POST [$name];
  98. }
  99. } else {
  100. return false;
  101. }
  102. }
  103. }
  104. ?>