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