AuthenticationController.php 3.6 KB

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