loginAction.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <?php
  2. class loginClassAction extends apiAction
  3. {
  4. public function checkAction()
  5. {
  6. $adminuser = str_replace(' ','',$this->rock->jm->base64decode($this->post('user')));
  7. $adminpass = $this->rock->jm->base64decode($this->post('pass'));
  8. $arr = m('login')->start($adminuser, $adminpass);
  9. if(is_array($arr)){
  10. if(isset($arr['mobile'])){
  11. $this->showreturn($arr, $arr['msg'], 205);
  12. }
  13. $arrs = array(
  14. 'uid' => $arr['uid'],
  15. 'name' => $arr['name'],
  16. 'user' => $arr['user'],
  17. 'ranking' => $arr['ranking'],
  18. 'deptname' => $arr['deptname'],
  19. 'deptallname' => $arr['deptallname'],
  20. 'face' => $arr['face'],
  21. 'apptx' => $arr['apptx'],
  22. 'loginyzm' => (int)getconfig('loginyzm','0'),
  23. 'token' => $arr['token'],
  24. 'iskq' => (int)m('userinfo')->getmou('iskq', $arr['uid']), //判断是否需要考勤
  25. 'title' => getconfig('apptitle'),
  26. 'weblogo' => getconfig('weblogo')
  27. );
  28. $uid = $arr['uid'];
  29. $name = $arr['name'];
  30. $user = $arr['user'];
  31. $token = $arr['token'];
  32. m('login')->setsession($uid, $name, $token, $user);
  33. $this->showreturn($arrs);
  34. }else{
  35. $this->showreturn('', $arr, 201);
  36. }
  37. }
  38. public function loginexitAction()
  39. {
  40. m('login')->exitlogin('', $this->token);
  41. $this->showreturn('');
  42. }
  43. /**
  44. * app登录页面初始化
  45. */
  46. public function appinitAction()
  47. {
  48. $arrs = array(
  49. 'loginyzm' => (int)getconfig('loginyzm','0'),
  50. 'title' => getconfig('apptitle'),
  51. 'apptheme' => getconfig('apptheme'),
  52. 'titleall' => TITLE,
  53. 'regtype' => getconfig('regtype','0'), //是否可注册1,可注册
  54. );
  55. $this->showreturn($arrs);
  56. }
  57. /**
  58. * 下载图片
  59. */
  60. public function downimgAction()
  61. {
  62. $paths= $this->getvals('path');
  63. $path = str_replace(URL, '', $paths);
  64. $obj = c('upfile');
  65. $str = '';
  66. $ext = $obj->getext($path);
  67. if($obj->isimg($ext) && file_exists($path)){
  68. $str = base64_encode(file_get_contents($path));
  69. }
  70. $this->showreturn(array(
  71. 'result' => $str,
  72. 'path' => $paths
  73. ));
  74. }
  75. /**
  76. * 下载图片新
  77. */
  78. public function downimgnewAction()
  79. {
  80. $paths= urldecode($this->get('path'));
  81. $path = str_replace(URL, '', $paths);
  82. $obj = c('upfile');
  83. $str = '';
  84. $ext = $obj->getext($path);
  85. if($obj->isimg($ext) && (file_exists($path) || substr($path,0,4)=='http')){
  86. $str = base64_encode(file_get_contents($path));
  87. }
  88. $this->showreturn(array(
  89. 'result' => $str,
  90. 'path' => $paths
  91. ));
  92. }
  93. /**
  94. * 读取可上传最大M
  95. */
  96. public function getmaxupAction()
  97. {
  98. $maxup = c('upfile')->getmaxzhao();
  99. $this->showreturn(array(
  100. 'maxup' => $maxup
  101. ));
  102. }
  103. /**
  104. * 钉钉jssdk签名
  105. */
  106. public function ddsignAction()
  107. {
  108. $bo = m('dingding:signjssdk');
  109. $corpId = $bo->readwxset();
  110. $agentid= $this->post('agentid');
  111. if(isempt($agentid))$agentid = $this->rock->session('wxqyagentid');
  112. if(isempt($corpId) || isempt($agentid)){
  113. $arr['corpId'] = '';
  114. }else{
  115. $url = $this->getvals('url');
  116. $arr = $bo->getsignsdk($url);
  117. $arr['agentId'] = $agentid;
  118. }
  119. $this->showreturn($arr);
  120. }
  121. /**
  122. * 获取钉钉企业Id
  123. */
  124. public function ddqiyeidAction()
  125. {
  126. $this->showreturn(array(
  127. 'qiyeid' => $this->option->getval('dingding_qiyeid')
  128. ));
  129. }
  130. /**
  131. * 钉钉获取登录
  132. */
  133. public function dingcheckAction()
  134. {
  135. $code = $this->post('code');
  136. $barr = m('dingding:user')->getuserjssdk($code);
  137. if($barr['errcode']!=0){
  138. $this->showreturn('', $barr['msg'], 201);
  139. }else{
  140. $this->showreturn($barr);
  141. }
  142. }
  143. //初始化验证
  144. public function initsetAction()
  145. {
  146. $call = $this->get('callback');
  147. $barr['title'] = getconfig('reimtitle','REIM');
  148. $barr['stype'] = 'new';
  149. $barr['version']= VERSION;
  150. echo ''.$call.'('.json_encode($barr).')';
  151. }
  152. public function inauthAction()
  153. {
  154. $call = $this->get('callback');
  155. $barr['host'] = HOST;
  156. echo ''.$call.'('.json_encode($barr).')';
  157. }
  158. public function getewmAction()
  159. {
  160. $randkey = $this->get('randkey');
  161. if(isempt($randkey))return;
  162. $dfrom = $this->get('dfrom');
  163. $key = md5($randkey);
  164. c('cache')->set($key,'-2',70);
  165. header("Content-type:image/png");
  166. $url = ''.getconfig('outurl', URL).'?m=logn&d=we&randkey='.$key.'&dfrom='.$dfrom.'';
  167. if(COMPANYNUM)$url.='&dwnum='.COMPANYNUM.'';
  168. $img = c('qrcode')->show($url);
  169. echo $img;
  170. }
  171. public function checkewmAction()
  172. {
  173. $randkey = $this->get('randkey');
  174. $key = md5($randkey);
  175. $val = c('cache')->get($key);
  176. $data['val'] = $val;
  177. if(isempt($randkey))$this->showreturn($data);
  178. if($val>'0'){
  179. $dbs = m('admin');
  180. $urs = $dbs->getone("`id`='$val' and `status`=1",'`id`,`name`,`user`,`face`,`pass`');
  181. if(!$urs){
  182. $val = '-1';
  183. }else{
  184. c('cache')->set('login'.$urs['user'].'', $urs['id'], 60);
  185. $data['user'] = $urs['user'];
  186. $data['face'] = $dbs->getface($urs['face']);
  187. $data['pass'] = md5($urs['pass']);
  188. c('cache')->del($key);
  189. }
  190. }
  191. $data['val'] = $val;
  192. $this->showreturn($data);
  193. }
  194. /**
  195. * 创建二维码
  196. */
  197. public function ewmAction()
  198. {
  199. header("Content-type:image/png");
  200. $url = $this->jm->base64decode($this->get('url'));
  201. if(substr($url,0,4)!='http')$url =''.$this->rock->getouturl().''.$url.'';
  202. $img = c('qrcode')->show($url);
  203. echo $img;
  204. }
  205. /**
  206. * 安卓检查是否有app更新
  207. */
  208. public function appupdateAction()
  209. {
  210. $nowver = getconfig('app_version');//app的版本
  211. $ver = $this->get('ver');
  212. $barr['success'] = false;
  213. $path = getconfig('app_verpath','images/app.apk');//app文件版本
  214. if(!isempt($nowver) && file_exists($path) && $ver<$nowver){
  215. $barr['success'] = true;
  216. $barr['version'] = $nowver;
  217. $barr['size'] = '3.2M';
  218. $barr['updateurl'] = ''.URL.''.$path.'';
  219. $barr['explain'] = getconfig('app_verremark','完善推送功能');
  220. }
  221. echo json_encode($barr);
  222. }
  223. /**
  224. * reim平台快捷登录到oa
  225. */
  226. public function reimplatloginAction()
  227. {
  228. return m('reimplat:oauth')->login();
  229. }
  230. /**
  231. * 验证小程序地址
  232. */
  233. public function yzxcyAction()
  234. {
  235. $openid = $this->get('openid');
  236. $mobile = $this->get('mobile');
  237. if(!$openid || !$mobile)return returnerror('err');
  238. $mobile = $this->jm->base64decode($mobile);
  239. $where = "`mobile`='$mobile'";
  240. if(m('admin')->rows($where)==0 && m('customer')->rows($where)==0 )return retuenerror('此手机号没在我们系统登记过');
  241. $na = getconfig('titleout');
  242. if(!$na)$na = TITLE;
  243. return returnsuccess(array(
  244. 'name' => $na,
  245. 'key' => md5(getconfig('openkey')),
  246. 'logo' => 'images/logo.png'
  247. ));
  248. }
  249. }