loginAction.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. $upkey = md5('upkey'.time().$this->jm->getRandkey());
  100. $this->showreturn(array(
  101. 'maxup' => $maxup,
  102. 'upkey' => $upkey
  103. ));
  104. }
  105. /**
  106. * 钉钉jssdk签名
  107. */
  108. public function ddsignAction()
  109. {
  110. $bo = m('dingding:signjssdk');
  111. $corpId = $bo->readwxset();
  112. $agentid= $this->post('agentid');
  113. if(isempt($agentid))$agentid = $this->rock->session('wxqyagentid');
  114. if(isempt($corpId) || isempt($agentid)){
  115. $arr['corpId'] = '';
  116. }else{
  117. $url = $this->getvals('url');
  118. $arr = $bo->getsignsdk($url);
  119. $arr['agentId'] = $agentid;
  120. }
  121. $this->showreturn($arr);
  122. }
  123. /**
  124. * 获取钉钉企业Id
  125. */
  126. public function ddqiyeidAction()
  127. {
  128. $this->showreturn(array(
  129. 'qiyeid' => $this->option->getval('dingding_qiyeid')
  130. ));
  131. }
  132. /**
  133. * 钉钉获取登录
  134. */
  135. public function dingcheckAction()
  136. {
  137. $code = $this->post('code');
  138. $barr = m('dingding:user')->getuserjssdk($code);
  139. if($barr['errcode']!=0){
  140. $this->showreturn('', $barr['msg'], 201);
  141. }else{
  142. $this->showreturn($barr);
  143. }
  144. }
  145. //初始化验证
  146. public function initsetAction()
  147. {
  148. $call = $this->get('callback');
  149. $barr['title'] = getconfig('reimtitle','REIM');
  150. $barr['stype'] = 'new';
  151. $barr['version']= VERSION;
  152. echo ''.$call.'('.json_encode($barr).')';
  153. }
  154. public function inauthAction()
  155. {
  156. $call = $this->get('callback');
  157. $barr['host'] = HOST;
  158. echo ''.$call.'('.json_encode($barr).')';
  159. }
  160. public function getewmAction()
  161. {
  162. $randkey = $this->get('randkey');
  163. if(isempt($randkey))return;
  164. $dfrom = $this->get('dfrom');
  165. $key = md5($randkey);
  166. c('cache')->set($key,'-2',70);
  167. header("Content-type:image/png");
  168. $url = ''.getconfig('outurl', URL).'?m=logn&d=we&randkey='.$key.'&dfrom='.$dfrom.'';
  169. if(COMPANYNUM)$url.='&dwnum='.COMPANYNUM.'';
  170. $img = c('qrcode')->show($url);
  171. echo $img;
  172. }
  173. public function checkewmAction()
  174. {
  175. $randkey = $this->get('randkey');
  176. $key = md5($randkey);
  177. $val = c('cache')->get($key);
  178. $data['val'] = $val;
  179. if(isempt($randkey))$this->showreturn($data);
  180. if($val>'0'){
  181. $dbs = m('admin');
  182. $urs = $dbs->getone("`id`='$val' and `status`=1",'`id`,`name`,`user`,`face`,`pass`');
  183. if(!$urs){
  184. $val = '-1';
  185. }else{
  186. c('cache')->set('login'.$urs['user'].'', $urs['id'], 60);
  187. $data['user'] = $urs['user'];
  188. $data['face'] = $dbs->getface($urs['face']);
  189. $data['pass'] = md5($urs['pass']);
  190. c('cache')->del($key);
  191. }
  192. }
  193. $data['val'] = $val;
  194. $this->showreturn($data);
  195. }
  196. /**
  197. * 创建二维码
  198. */
  199. public function ewmAction()
  200. {
  201. header("Content-type:image/png");
  202. $url = $this->jm->base64decode($this->get('url'));
  203. if(substr($url,0,4)!='http')$url =''.$this->rock->getouturl().''.$url.'';
  204. $img = c('qrcode')->show($url);
  205. echo $img;
  206. }
  207. /**
  208. * 安卓检查是否有app更新
  209. */
  210. public function appupdateAction()
  211. {
  212. $nowver = getconfig('app_version');//app的版本
  213. $ver = $this->get('ver');
  214. $barr['success'] = false;
  215. $path = getconfig('app_verpath','images/app.apk');//app文件版本
  216. if(!isempt($nowver) && file_exists($path) && $ver<$nowver){
  217. $barr['success'] = true;
  218. $barr['version'] = $nowver;
  219. $barr['size'] = '3.2M';
  220. $barr['updateurl'] = ''.URL.''.$path.'';
  221. $barr['explain'] = getconfig('app_verremark','完善推送功能');
  222. }
  223. echo json_encode($barr);
  224. }
  225. /**
  226. * reim平台快捷登录到oa
  227. */
  228. public function reimplatloginAction()
  229. {
  230. return m('reimplat:oauth')->login();
  231. }
  232. /**
  233. * 验证小程序地址
  234. */
  235. public function yzxcyAction()
  236. {
  237. return retuenerror('20240429最新已弃用');
  238. $openid = $this->get('openid');
  239. $mobile = $this->get('mobile');
  240. if(!$openid || !$mobile)return returnerror('err');
  241. $mobile = $this->jm->base64decode($mobile);
  242. if(!c('check')->iscnmobile($mobile))return returnerror('err2');
  243. $where = "`mobile`='$mobile'";
  244. if(m('admin')->rows($where)==0 && m('customer')->rows($where)==0 )return retuenerror('此手机号没在我们系统登记过');
  245. $na = getconfig('titleout');
  246. if(!$na)$na = TITLE;
  247. return returnsuccess(array(
  248. 'name' => $na,
  249. 'key' => md5(getconfig('openkey')),
  250. 'logo' => 'images/logo.png'
  251. ));
  252. }
  253. /**
  254. * 获取第三方上传图片地址
  255. */
  256. public function upimagepathAction()
  257. {
  258. $fileid = (int)$this->get('fileid');
  259. $fid = $this->get('fid');
  260. $adddt = date('Y-m-d H:i:s', time()-20);
  261. $frs = m('file')->getone("`id`='$fileid' and `adddt`>'$adddt'");
  262. if(!$frs)return returnerror('404');
  263. $path = '';
  264. if(!isempt($frs['thumbplat'])){
  265. $path = str_replace('_s.','.',$frs['thumbplat']);
  266. }
  267. $filepathout = arrvalue($frs,'filepathout');
  268. if($filepathout)$path = $filepathout;
  269. return returnsuccess(array(
  270. 'path' => $path,
  271. 'fid' => $fid,
  272. ));
  273. }
  274. //保存设置
  275. public function setwxqyAction()
  276. {
  277. $callback= $this->get('callback');
  278. $num = $this->get('num');
  279. $agentid = (int)$this->get('agentid');
  280. $shouji = $this->jm->base64decode($this->get('shouji'));
  281. $userid = $this->jm->base64decode($this->get('userid'));
  282. $urs = m('admin')->getone("`mobile`='$shouji' AND `status`=1");
  283. $barr = returnerror('错误');
  284. if(!$urs){
  285. $barr = returnerror('手机号“'.$shouji.'”在设置OA地址里不存在');
  286. }else{
  287. $barr = returnsuccess(array());
  288. }
  289. if($barr['success']){
  290. if($urs['type']==1)$this->option->setval('wxqyplat_cnum@-10', $num);
  291. $obj = m('zwxqy_user');
  292. $uarr['uid'] = $urs['id'];
  293. $uarr['mobile'] = $shouji;
  294. $uarr['userid'] = $userid;
  295. $uarr['agentid'] = $agentid;
  296. $uarr['cnum'] = $num;
  297. $uarr['state'] = 1;
  298. $ors = $obj->getone("`userid`='$userid'");
  299. if($ors){
  300. $obj->update($uarr, $ors['id']);
  301. }else{
  302. $obj->insert($uarr);
  303. }
  304. $data['user'] = $urs['user'];
  305. $barr['data'] = $data;
  306. }
  307. return ''.$callback.'('.json_encode($barr).')';
  308. }
  309. //读取表结构
  310. public function dbinfoAction()
  311. {
  312. $tab = $this->get('tab');
  313. if(!$tab)return 'error';
  314. $table= ''.PREFIX.''.$tab.'';
  315. $rows = $this->db->gettablefields($table);
  316. if(!$rows)return '无表';
  317. $barr[$table]['fields'] = $rows;
  318. return $barr;
  319. }
  320. }
粤ICP备19079148号