1
0

cogAction.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <?php
  2. class cogClassAction extends Action
  3. {
  4. public function sysinfoAjax()
  5. {
  6. $fields = array(
  7. 'title' => '系统名称',
  8. 'url' => '系统URL地址',
  9. 'localurl' => '系统本地地址',
  10. 'outurl' => '外网地址',
  11. 'rootpath' => '系统根目录',
  12. 'db_drive' => '操作数据库驱动',
  13. 'db_host' => '数据库地址',
  14. 'db_name' => '数据库名称',
  15. 'version' => '版本',
  16. 'phpos' => '服务器',
  17. 'phpver' => 'PHP版本',
  18. 'mysqlver' => 'mysql版本',
  19. 'SERVER_SOFTWARE' => 'web服务器',
  20. 'upload_max_filesize' => '最大上传大小',
  21. 'post_max_size' => 'POST最大',
  22. 'memory_limit' => '使用最大内存',
  23. 'curl' => '是否支持CURL',
  24. 'max_execution_time' => 'PHP执行超时时间',
  25. );
  26. $data = array(
  27. 'title' => getconfig('title'),
  28. 'url' => getconfig('url'),
  29. 'localurl' => getconfig('localurl'),
  30. 'taskurl' => getconfig('taskurl'),
  31. 'outurl' => getconfig('outurl'),
  32. 'xinhukey' => getconfig('xinhukey'),
  33. 'db_host' => DB_HOST,
  34. 'db_name' => DB_BASE,
  35. 'rootpath' => ROOT_PATH,
  36. 'db_drive' => getconfig('db_drive'),
  37. 'version' => '信呼V'.VERSION.'',
  38. 'phpos' => PHP_OS,
  39. 'phpver' => PHP_VERSION,
  40. 'mysqlver' => $this->db->getsyscount('version'),
  41. 'SERVER_SOFTWARE' => $_SERVER['SERVER_SOFTWARE'],
  42. 'upload_max_filesize' => ini_get('upload_max_filesize'),
  43. 'post_max_size' => ini_get('post_max_size'),
  44. 'memory_limit' => ini_get('memory_limit'),
  45. 'max_execution_time' => ini_get('max_execution_time').'秒',
  46. );
  47. if(!function_exists('curl_init')){
  48. $data['curl'] = '<font color=red>不支持</font>';
  49. }else{
  50. $data['curl'] = '<font color=green>支持</font>';
  51. }
  52. $this->returnjson(array(
  53. 'fields' => $fields,
  54. 'data' => $data,
  55. ));
  56. }
  57. public function getinfoAjax()
  58. {
  59. $arr['title'] = getconfig('title');
  60. $arr['outurl'] = getconfig('outurl');
  61. $arr['url'] = arrvalue($GLOBALS['_tempconf'],'url');
  62. $arr['localurl'] = getconfig('localurl');
  63. $arr['apptitle'] = getconfig('apptitle');
  64. $arr['platurl'] = getconfig('platurl');
  65. $arr['reimtitle'] = getconfig('reimtitle');
  66. $arr['asynkey'] = getconfig('asynkey');
  67. $arr['openkey'] = getconfig('openkey');
  68. $arr['db_drive'] = getconfig('db_drive');
  69. $arr['xinhukey'] = getconfig('xinhukey');
  70. $arr['bcolorxiang'] = getconfig('bcolorxiang');
  71. $arr['qqmapkey'] = getconfig('qqmapkey');
  72. $arr['asynsend'] = getconfig('asynsend');
  73. $arr['defstype'] = getconfig('defstype','1');
  74. $arr['officeyl'] = getconfig('officeyl'); //文档预览
  75. $arr['officebj'] = getconfig('officebj');
  76. $arr['apptheme'] = getconfig('apptheme');
  77. $arr['officebj_key'] = getconfig('officebj_key');
  78. $arr['useropt'] = getconfig('useropt');
  79. $arr['sqllog'] = getconfig('sqllog') ? '1' : '0';
  80. $arr['debug'] = getconfig('debug') ? '1' : '0';
  81. $arr['reim_show'] = getconfig('reim_show') ? '1' : '0';
  82. $arr['mobile_show'] = getconfig('mobile_show') ? '1' : '0';
  83. $arr['companymode'] = getconfig('companymode') ? '1' : '0';
  84. $arr['isshou'] = $this->isshouquan() ? '1' : '0';
  85. $arr['editpass'] = getconfig('editpass','0');
  86. $arr['asyntest'] = $this->option->getval('asyntest');
  87. $loginyzm = getconfig('loginyzm');
  88. if(!$loginyzm)$loginyzm = '0';
  89. $arr['loginyzm'] = $loginyzm;
  90. if(getconfig('systype')=='demo'){
  91. $arr['xinhukey']='';
  92. $arr['officebj_key']='';
  93. }
  94. if(!isempt($arr['xinhukey']))$arr['xinhukey'] = substr($arr['xinhukey'],0,5).'*****'.substr($arr['xinhukey'],-5);
  95. $this->returnjson($arr);
  96. }
  97. private function isshouquan()
  98. {
  99. $key = getconfig('authorkey');
  100. if(!isempt($key) && $this->rock->isjm($key)){
  101. return true;
  102. }else{
  103. return false;
  104. }
  105. }
  106. public function savecongAjax()
  107. {
  108. if(getconfig('systype')=='demo')exit('演示上禁止设置');
  109. if($this->getsession('isadmin')!='1')exit('非管理员不能操作');
  110. $puurl = $this->option->getval('reimpushurlsystem',1);
  111. $_confpath = $this->rock->strformat('?0/?1/?1Config.php', ROOT_PATH, PROJECT);
  112. $arr = require($_confpath);
  113. $title = $this->post('title');
  114. if(!isempt($title))$arr['title'] = $title;
  115. $arr['url'] = $this->post('url');
  116. $arr['outurl'] = $this->post('outurl');
  117. $arr['reimtitle'] = $this->post('reimtitle');
  118. $arr['qqmapkey'] = $this->post('qqmapkey');
  119. $arr['platurl'] = $this->post('platurl');
  120. $apptitle = $this->post('apptitle');
  121. if(!isempt($apptitle))$arr['apptitle'] = $apptitle;
  122. $asynkey = $this->post('asynkey');
  123. if(!isempt($asynkey))$arr['asynkey'] = $asynkey;
  124. $db_drive = $this->post('db_drive');
  125. if(!isempt($db_drive)){
  126. if($db_drive=='mysql' && !function_exists('mysql_connect'))exit('未开启mysql扩展模块');
  127. if($db_drive=='mysqli' && !class_exists('mysqli'))exit('未开启mysqli扩展模块');
  128. if($db_drive=='pdo' && !class_exists('PDO'))exit('未开启pdo扩展模块');
  129. $arr['db_drive'] = $db_drive;
  130. }
  131. $arr['localurl'] = $this->post('localurl');
  132. $arr['openkey'] = $this->post('openkey');
  133. $arr['xinhukey'] = $this->post('xinhukey');
  134. if(contain($arr['xinhukey'],'**'))$arr['xinhukey'] = getconfig('xinhukey');
  135. $arr['bcolorxiang'] = $this->post('bcolorxiang');
  136. $arr['officeyl'] = $this->post('officeyl');
  137. $arr['useropt'] = $this->post('useropt');
  138. $arr['editpass'] = $this->post('editpass');
  139. $arr['defstype'] = $this->post('defstype','1');
  140. $arr['officebj'] = $this->post('officebj');
  141. $arr['officebj_key']= $this->post('officebj_key');
  142. $asynsend = $this->post('asynsend');
  143. $arr['asynsend'] = $asynsend;
  144. $arr['sqllog'] = $this->post('sqllog')=='1';
  145. $arr['debug'] = $this->post('debug')=='1';
  146. $arr['reim_show'] = $this->post('reim_show')=='1';
  147. $arr['mobile_show'] = $this->post('mobile_show')=='1';
  148. $arr['companymode'] = $this->post('companymode')=='1';
  149. $arr['loginyzm'] = $this->post('loginyzm');
  150. $arr['apptheme'] = $this->post('apptheme');
  151. if($asynsend == '1' && isempt($puurl))exit('未安装或开启服务端不能使用异步发送消息');
  152. $xpd = explode(',', "\\,', ,<,>,*,%,&");
  153. $xpd[]= "\n";
  154. foreach($arr as $k=>$v)if(!is_bool($v))$arr[$k] = str_replace($xpd,'',$v);
  155. $smarr['url'] = '系统URL';
  156. $smarr['localurl'] = '本地系统URL,用于服务器上浏览地址';
  157. $smarr['title'] = '系统默认标题';
  158. $smarr['neturl'] = '系统外网地址,用于公网';
  159. $smarr['apptitle'] = 'APP上和手机网页版上的标题';
  160. $smarr['reimtitle'] = 'REIM即时通信上标题';
  161. $smarr['weblogo'] = 'PC客户端上的logo图片';
  162. $smarr['db_host'] = '数据库地址';
  163. $smarr['db_user'] = '数据库用户名';
  164. $smarr['db_pass'] = '数据库密码';
  165. $smarr['db_base'] = '数据库名称';
  166. $smarr['perfix'] = '数据库表名前缀';
  167. $smarr['qom'] = 'session、cookie前缀';
  168. $smarr['highpass'] = '超级管理员密码,可用于登录任何帐号';
  169. $smarr['db_drive'] = '操作数据库驱动有mysql,mysqli,pdo三种';
  170. $smarr['randkey'] = '系统随机字符串密钥';
  171. $smarr['asynkey'] = '这是异步任务key';
  172. $smarr['openkey'] = '对外接口openkey';
  173. $smarr['sqllog'] = '是否记录sql日志保存'.UPDIR.'/sqllog下';
  174. $smarr['asynsend'] = '是否异步发送提醒消息,0同步,1自己服务端异步,2官网VIP用户异步';
  175. $smarr['install'] = '已安装,不要去掉啊';
  176. $smarr['xinhukey'] = '信呼官网key,用于在线升级使用';
  177. $smarr['bcolorxiang'] = '单据详情页面上默认展示线条的颜色';
  178. $smarr['debug'] = '为true调试开发模式,false上线模式';
  179. $smarr['reim_show'] = '首页是否显示REIM';
  180. $smarr['mobile_show'] = '首页是否显示手机版';
  181. $smarr['loginyzm'] = '登录方式:0仅使用帐号+密码,1帐号+密码/手机+验证码,2帐号+密码+验证码,3仅使用手机+验证码';
  182. $smarr['officeyl'] = '文档Excel.Doc预览类型,0自己部署插件,1使用官网支持任何平台';
  183. $smarr['officedk'] = '文件预览打开方式1新窗口打开';
  184. $smarr['useropt'] = '1记录用户操作保存到日志里,空不记录';
  185. $smarr['defstype'] = 'PC后台主题皮肤,可以设置1到34';
  186. $smarr['editpass'] = '用户登录修改密码:0不用修改,1强制用户必须修改';
  187. $smarr['companymode'] = '多单位模式,true就是开启';
  188. $smarr['outurl'] = '这个地址当你内网地址访问时向手机推送消息的地址';
  189. $smarr['officebj'] = '文档在线编辑,1官网提供或者自己部署';
  190. $smarr['officebj_key'] = '文档在线编辑agentkey';
  191. $smarr['apptheme'] = '系统或app的主题颜色';
  192. $str1 = '';
  193. foreach($arr as $k=>$v){
  194. $bz = '';
  195. if(isset($smarr[$k]))$bz=' //'.$smarr[$k].'';
  196. if(is_bool($v)){
  197. $v = $v ? 'true' : 'false';
  198. }else{
  199. $v = "'$v'";
  200. }
  201. $str1.= " '$k' => $v,$bz\n";
  202. }
  203. $str = '<?php
  204. if(!defined(\'HOST\'))die(\'not access\');
  205. //[管理员]在'.$this->now.'通过[系统→系统工具→系统设置],保存修改了配置文件
  206. return array(
  207. '.$str1.'
  208. );';
  209. @$bo = file_put_contents($_confpath, $str);
  210. if($bo){
  211. echo 'ok';
  212. }else{
  213. echo '保存失败无法写入:'.$_confpath.'';
  214. }
  215. }
  216. public function logbefore($table)
  217. {
  218. $key = $this->post('key');
  219. $s = '';
  220. if($key != ''){
  221. $s = "and (`type`='$key' or `optname` like '$key%' or `remark` like '$key%' or `web`='$key' or `ip`='$key')";
  222. }
  223. return $s;
  224. }
  225. public function logintokenbefore($table)
  226. {
  227. $key = $this->post('key');
  228. $s = '';
  229. if($key != ''){
  230. $s = "and (`name` like '%$key%' or `cfrom` like '%$key%' or `web` like '%$key%')";
  231. }
  232. return $s;
  233. }
  234. public function delloginAjax()
  235. {
  236. $id = c('check')->onlynumber($this->post('id'));
  237. m('logintoken')->delete('id in('.$id.')');
  238. backmsg();
  239. }
  240. public function dellogAjax()
  241. {
  242. $id = c('check')->onlynumber($this->post('id'));
  243. m('log')->delete('id in('.$id.')');
  244. backmsg();
  245. }
  246. public function clearlogAjax()
  247. {
  248. $lx = (int)$this->get('lx','0');
  249. $where = "`type`='异步队列'";
  250. if($lx==0)$where = '1=1';
  251. m('log')->delete($where);
  252. return returnsuccess();
  253. }
  254. public function saveautherAjax()
  255. {
  256. if(getconfig('systype')=='demo')exit('演示上不要操作');
  257. $autherkey = $this->post('key');
  258. $ym = $this->post('ym');
  259. $barr = c('xinhuapi')->authercheck($autherkey, $ym);
  260. if($barr['success']){
  261. echo 'ok';
  262. }else{
  263. echo $barr['msg'];
  264. }
  265. }
  266. public function savelixianAjax()
  267. {
  268. if(getconfig('systype')=='demo')exit('演示上不要操作');
  269. $aukey = $this->post('key');
  270. $ym = $this->post('ym');
  271. $path = 'config/rockauther.php';
  272. if(!file_exists($path))exit('没有下载签授文件到系统上');
  273. $da = require($path);
  274. $barr = c('xinhuapi')->autherfile($da, $aukey, $ym);
  275. if($barr['success']){
  276. @unlink($path);
  277. echo 'ok';
  278. }else{
  279. echo $barr['msg'];
  280. }
  281. }
  282. public function autherAjax()
  283. {
  284. $aukey = $this->option->getval('auther_aukey');
  285. $use = '1';
  286. $barr = array();
  287. if(isempt($aukey)){
  288. $use = '0';
  289. }else{
  290. $barr['enddt'] = $this->option->getval('auther_enddt');
  291. $barr['yuming']= $this->option->getval('auther_yuming');
  292. $barr['aukey'] = substr($aukey,0,5).'****'.substr($aukey,-5);
  293. }
  294. $barr['use'] = $use;
  295. return returnsuccess($barr);
  296. }
  297. public function autherdelAjax()
  298. {
  299. if(getconfig('systype')=='demo')return returnerror('演示上不要操作');
  300. return c('xinhuapi')->autherdel();
  301. }
  302. public function tongbudwAjax()
  303. {
  304. $rows = m('company')->getall('iscreate=1');
  305. foreach($rows as $k=>$rs){
  306. $base = ''.DB_BASE.'_company_'.$rs['num'].'';
  307. $this->sevessee($base, 'auther_aukey');
  308. $this->sevessee($base, 'auther_enddt');
  309. $this->sevessee($base, 'auther_yuming');
  310. $this->sevessee($base, 'auther_authkey');
  311. }
  312. return '同步成功';
  313. }
  314. private function sevessee($base, $key)
  315. {
  316. $val = $this->option->getval($key);
  317. $sql = "update ".$base.".`[Q]option` set `value`='$val',`optdt`='{$this->now}' where `num`='$key'";
  318. $this->db->query($sql, false);
  319. }
  320. /**
  321. * 更多保存设置
  322. */
  323. public function savemoresetAjax()
  324. {
  325. if(getconfig('systype')=='demo')return '演示不要改';
  326. $stype = (int)$this->post('stype','0');
  327. $msg = 'ok';
  328. if($stype==0)$msg = $this->saveconfig('title,imgcompress,watertype,video_bool,flowchehuitime,saasmode,hoemtimeout,usercache,xiangrecord',',video_bool,');
  329. return $msg;
  330. }
  331. private function saveconfig($cont, $bsto)
  332. {
  333. $path = ''.P.'/'.P.'Config.php';
  334. $neir = file_get_contents($path);
  335. $zdar = explode(',', $cont);
  336. $neira= explode("\n", $neir);
  337. $strs = '';
  338. $szida= array();
  339. foreach($neira as $line){
  340. if($line==');')break;
  341. $bo = false;
  342. foreach($zdar as $fid){
  343. if(contain($line,"'".$fid."'")){
  344. $val = $this->post($fid);
  345. if(contain($val,'*****')){
  346. $strs.="".$line."\n";
  347. }else{
  348. $val = $this->rock->xssrepstr($val);
  349. $vals = "'".$val."'";
  350. if(contain($bsto,','.$fid.','))$vals = ($val=='1') ? 'true' : 'false';
  351. $strs.=" '".$fid."' => ".$vals.",\n";
  352. }
  353. $bo = true;
  354. $szida[]=$fid;
  355. }
  356. }
  357. if(!$bo)$strs.="".$line."\n";
  358. }
  359. foreach($zdar as $fid){
  360. if(!in_array($fid, $szida)){
  361. $val = $this->post($fid);
  362. $strs.=" '".$fid."' => '".$val."',\n";
  363. }
  364. }
  365. $strs.=');';
  366. $bo = @file_put_contents($path,$strs);
  367. if(!$bo)return '无权限写入:'.$path.'';
  368. return 'ok';
  369. }
  370. public function getmodeAjax()
  371. {
  372. $modearr = m('mode')->getmodearr('all');
  373. return array(
  374. 'modearr' => $modearr
  375. );
  376. }
  377. public function savemodeAjax()
  378. {
  379. if(getconfig('systype')=='demo')return '演示不要改';
  380. $dbs = m('mode');
  381. $allnum = $this->post('allnum');
  382. $allarr = explode(',', $allnum);
  383. $allstr = "'".str_replace(',',"','", $allnum)."'";
  384. $dbs->update('status=0', "`type`<>'系统' and `num` not in($allstr)");
  385. $dbs->update('status=1', "`num` in($allstr)");
  386. //菜单更新
  387. $menuarr = $dbs->menulist();
  388. $mdb = m('menu');
  389. $cdid = '';
  390. foreach($menuarr as $bh=>$vs){
  391. if($bh=='wxgzh' || $bh=='ding' || $bh=='weixinqy')continue;
  392. $zt = 0;
  393. if(contain($allstr,"'".$bh."'")){
  394. $zt = 1;
  395. $cdid.=','.$vs.'';
  396. }
  397. $mdb->update('`status`='.$zt.'', '`id` in('.$vs.')');
  398. }
  399. $menuarr = $dbs->yinglist();
  400. $mdb = m('im_group');
  401. foreach($menuarr as $bh=>$vs){
  402. $zt = 1;
  403. if(!contain($allstr,"'".$bh."'")){
  404. $zt = 0;
  405. }
  406. $mdb->update('`valid`='.$zt.'', '`id` in('.$vs.')');
  407. }
  408. $tdb= m('task');
  409. $hdb= m('homeitems');
  410. $zt = contain($allstr,"'kqdkjl'") ? 1 : 0;
  411. $tdb->update("`status`='$zt'", "`fenlei`='考勤'");
  412. $hdb->update("`status`='$zt'", "`num` in('kqdk','kqtotal')");
  413. $zt = contain($allstr,"'userract'") ? 1 : 0;
  414. $tdb->update("`status`='$zt'", "`fenlei`='人事'");
  415. $zt = contain($allstr,"'officic'") ? 1 : 0;
  416. $hdb->update("`status`='$zt'", "`num` in('officic')");
  417. $zt = contain($allstr,"'meet'") ? 1 : 0;
  418. $hdb->update("`status`='$zt'", "`num` in('meet')");
  419. $zt = contain($allstr,"'bianjian'") ? 1 : 0;
  420. $hdb->update("`status`='$zt'", "`num` in('bianjian')");
  421. $zt = contain($allstr,"'gong'") ? 1 : 0;
  422. $hdb->update("`status`='$zt'", "`num` in('gong')");
  423. return '保存成功';
  424. }
  425. }
粤ICP备19079148号