loginAction.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. 'tabbar' => $this->option->getval('appsy_tabbar'),
  55. );
  56. $this->showreturn($arrs);
  57. }
  58. /**
  59. * 下载图片
  60. */
  61. public function downimgAction()
  62. {
  63. $paths= $this->getvals('path');
  64. $path = str_replace(URL, '', $paths);
  65. $obj = c('upfile');
  66. $str = '';
  67. $ext = $obj->getext($path);
  68. if($obj->isimg($ext) && file_exists($path)){
  69. $str = base64_encode(file_get_contents($path));
  70. }
  71. $this->showreturn(array(
  72. 'result' => $str,
  73. 'path' => $paths
  74. ));
  75. }
  76. /**
  77. * 下载图片新
  78. */
  79. public function downimgnewAction()
  80. {
  81. $paths= urldecode($this->get('path'));
  82. $path = str_replace(URL, '', $paths);
  83. $obj = c('upfile');
  84. $str = '';
  85. $ext = $obj->getext($path);
  86. if($obj->isimg($ext) && (file_exists($path) || substr($path,0,4)=='http')){
  87. $str = base64_encode(file_get_contents($path));
  88. }
  89. $this->showreturn(array(
  90. 'result' => $str,
  91. 'path' => $paths
  92. ));
  93. }
  94. /**
  95. * 读取可上传最大M
  96. */
  97. public function getmaxupAction()
  98. {
  99. $maxup = c('upfile')->getmaxzhao();
  100. $upkey = md5('upkey'.time().$this->jm->getRandkey());
  101. $this->showreturn(array(
  102. 'maxup' => $maxup,
  103. 'upkey' => $upkey
  104. ));
  105. }
  106. /**
  107. * 钉钉jssdk签名
  108. */
  109. public function ddsignAction()
  110. {
  111. $bo = m('dingding:signjssdk');
  112. $corpId = $bo->readwxset();
  113. $agentid= $this->post('agentid');
  114. if(isempt($agentid))$agentid = $this->rock->session('wxqyagentid');
  115. if(isempt($corpId) || isempt($agentid)){
  116. $arr['corpId'] = '';
  117. }else{
  118. $url = $this->getvals('url');
  119. $arr = $bo->getsignsdk($url);
  120. $arr['agentId'] = $agentid;
  121. }
  122. $this->showreturn($arr);
  123. }
  124. /**
  125. * 获取钉钉企业Id
  126. */
  127. public function ddqiyeidAction()
  128. {
  129. $this->showreturn(array(
  130. 'qiyeid' => $this->option->getval('dingding_qiyeid')
  131. ));
  132. }
  133. /**
  134. * 钉钉获取登录
  135. */
  136. public function dingcheckAction()
  137. {
  138. $code = $this->post('code');
  139. $barr = m('dingding:user')->getuserjssdk($code);
  140. if($barr['errcode']!=0){
  141. $this->showreturn('', $barr['msg'], 201);
  142. }else{
  143. $this->showreturn($barr);
  144. }
  145. }
  146. //初始化验证
  147. public function initsetAction()
  148. {
  149. $call = $this->get('callback');
  150. $barr['title'] = getconfig('reimtitle','REIM');
  151. $barr['stype'] = 'new';
  152. $barr['ntype'] = 'reim2.0';
  153. $barr['version']= VERSION;
  154. echo ''.$call.'('.json_encode($barr).')';
  155. }
  156. public function inauthAction()
  157. {
  158. $call = $this->get('callback');
  159. $barr['host'] = HOST;
  160. echo ''.$call.'('.json_encode($barr).')';
  161. }
  162. public function getewmAction()
  163. {
  164. $randkey = $this->get('randkey');
  165. if(isempt($randkey))return;
  166. $dfrom = $this->get('dfrom');
  167. $key = md5($randkey);
  168. c('cache')->set($key,'-2',70);
  169. header("Content-type:image/png");
  170. $url = ''.getconfig('outurl', URL).'?m=logn&d=we&randkey='.$key.'&dfrom='.$dfrom.'';
  171. if(COMPANYNUM)$url.='&dwnum='.COMPANYNUM.'';
  172. $img = c('qrcode')->show($url);
  173. echo $img;
  174. }
  175. public function checkewmAction()
  176. {
  177. $randkey = $this->get('randkey');
  178. $key = md5($randkey);
  179. $val = c('cache')->get($key);
  180. $data['val'] = $val;
  181. if(isempt($randkey))$this->showreturn($data);
  182. if($val>'0'){
  183. $dbs = m('admin');
  184. $urs = $dbs->getone("`id`='$val' and `status`=1",'`id`,`name`,`user`,`face`,`pass`');
  185. if(!$urs){
  186. $val = '-1';
  187. }else{
  188. c('cache')->set('login'.$urs['user'].'', $urs['id'], 60);
  189. $data['user'] = $urs['user'];
  190. $data['face'] = $dbs->getface($urs['face']);
  191. $data['pass'] = md5($urs['pass']);
  192. c('cache')->del($key);
  193. }
  194. }
  195. $data['val'] = $val;
  196. $this->showreturn($data);
  197. }
  198. /**
  199. * 创建二维码
  200. */
  201. public function ewmAction()
  202. {
  203. header("Content-type:image/png");
  204. $url = $this->jm->base64decode($this->get('url'));
  205. if(substr($url,0,4)!='http')$url =''.$this->rock->getouturl().''.$url.'';
  206. $img = c('qrcode')->show($url);
  207. echo $img;
  208. }
  209. /**
  210. * 安卓检查是否有app更新
  211. */
  212. public function appupdateAction()
  213. {
  214. $nowver = getconfig('app_version');//app的版本
  215. $ver = $this->get('ver');
  216. $barr['success'] = false;
  217. $path = getconfig('app_verpath','images/app.apk');//app文件版本
  218. if(!isempt($nowver) && file_exists($path) && $ver<$nowver){
  219. $barr['success'] = true;
  220. $barr['version'] = $nowver;
  221. $barr['size'] = '3.2M';
  222. $barr['updateurl'] = ''.URL.''.$path.'';
  223. $barr['explain'] = getconfig('app_verremark','完善推送功能');
  224. }
  225. echo json_encode($barr);
  226. }
  227. /**
  228. * reim平台快捷登录到oa
  229. */
  230. public function reimplatloginAction()
  231. {
  232. return m('reimplat:oauth')->login();
  233. }
  234. /**
  235. * 验证小程序地址
  236. */
  237. public function yzxcyAction()
  238. {
  239. return retuenerror('20240429最新已弃用');
  240. }
  241. /**
  242. * 获取第三方上传图片地址
  243. */
  244. public function upimagepathAction()
  245. {
  246. $fileid = (int)$this->get('fileid');
  247. $fid = $this->get('fid');
  248. $adddt = date('Y-m-d H:i:s', time()-20);
  249. $frs = m('file')->getone("`id`='$fileid' and `adddt`>'$adddt'");
  250. if(!$frs)return returnerror('404');
  251. $path = '';
  252. if(!isempt($frs['thumbplat'])){
  253. $path = str_replace('_s.','.',$frs['thumbplat']);
  254. }
  255. $filepathout = arrvalue($frs,'filepathout');
  256. if($filepathout)$path = $filepathout;
  257. return returnsuccess(array(
  258. 'path' => $path,
  259. 'fid' => $fid,
  260. ));
  261. }
  262. //读取表结构
  263. public function dbinfoAction()
  264. {
  265. $tab = $this->get('tab');
  266. if(!$tab)return 'error';
  267. if(c('check')->onlynoen($tab))return 'err1';
  268. $table= ''.PREFIX.''.$tab.'';
  269. $rows = $this->db->gettablefields($table);
  270. if(!$rows)return '无表';
  271. $barr[$table]['fields'] = $rows;
  272. return $barr;
  273. }
  274. }
粤ICP备19079148号