cogAction.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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. $arr['openkey']='';
  94. $arr['asynkey']='';
  95. }
  96. if(!isempt($arr['xinhukey']))$arr['xinhukey'] = substr($arr['xinhukey'],0,5).'*****'.substr($arr['xinhukey'],-5);
  97. $this->returnjson($arr);
  98. }
  99. private function isshouquan()
  100. {
  101. $key = getconfig('authorkey');
  102. if(!isempt($key) && $this->rock->isjm($key)){
  103. return true;
  104. }else{
  105. return false;
  106. }
  107. }
  108. public function savecongAjax()
  109. {
  110. if(getconfig('systype')=='demo')exit('演示上禁止设置');
  111. if($this->getsession('isadmin')!='1')exit('非管理员不能操作');
  112. $puurl = $this->option->getval('reimpushurlsystem',1);
  113. $_confpath = $this->rock->strformat('?0/?1/?1Config.php', ROOT_PATH, PROJECT);
  114. $arr = require($_confpath);
  115. $title = $this->post('title');
  116. if(!isempt($title))$arr['title'] = $title;
  117. $arr['url'] = $this->post('url');
  118. $arr['outurl'] = $this->post('outurl');
  119. $arr['reimtitle'] = $this->post('reimtitle');
  120. $arr['platurl'] = $this->post('platurl');
  121. $apptitle = $this->post('apptitle');
  122. if(!isempt($apptitle))$arr['apptitle'] = $apptitle;
  123. $asynkey = $this->post('asynkey');
  124. if(!isempt($asynkey))$arr['asynkey'] = $asynkey;
  125. $db_drive = $this->post('db_drive');
  126. if(!isempt($db_drive)){
  127. if($db_drive=='mysql' && !function_exists('mysql_connect'))exit('未开启mysql扩展模块');
  128. if($db_drive=='mysqli' && !class_exists('mysqli'))exit('未开启mysqli扩展模块');
  129. if($db_drive=='pdo' && !class_exists('PDO'))exit('未开启pdo扩展模块');
  130. $arr['db_drive'] = $db_drive;
  131. }
  132. $arr['localurl'] = $this->post('localurl');
  133. $arr['openkey'] = $this->post('openkey');
  134. $arr['xinhukey'] = $this->post('xinhukey');
  135. if(contain($arr['xinhukey'],'**'))$arr['xinhukey'] = getconfig('xinhukey');
  136. $arr['bcolorxiang'] = $this->post('bcolorxiang');
  137. $arr['officeyl'] = $this->post('officeyl');
  138. $arr['useropt'] = $this->post('useropt');
  139. $arr['editpass'] = $this->post('editpass');
  140. $arr['defstype'] = $this->post('defstype','1');
  141. $arr['officebj'] = $this->post('officebj');
  142. $arr['officebj_key']= $this->post('officebj_key');
  143. $asynsend = $this->post('asynsend');
  144. $arr['asynsend'] = $asynsend;
  145. $arr['sqllog'] = $this->post('sqllog')=='1';
  146. $arr['debug'] = $this->post('debug')=='1';
  147. $arr['reim_show'] = $this->post('reim_show')=='1';
  148. $arr['mobile_show'] = $this->post('mobile_show')=='1';
  149. $arr['companymode'] = $this->post('companymode')=='1';
  150. $arr['loginyzm'] = $this->post('loginyzm');
  151. $arr['apptheme'] = $this->post('apptheme');
  152. if($asynsend == '1' && isempt($puurl))exit('未安装或开启服务端不能使用异步发送消息');
  153. $xpd = explode(',', "\\,', ,<,>,*,%,&");
  154. $xpd[]= "\n";
  155. foreach($arr as $k=>$v)if(!is_bool($v))$arr[$k] = str_replace($xpd,'',$v);
  156. $smarr['url'] = '系统URL';
  157. $smarr['localurl'] = '本地系统URL,用于服务器上浏览地址';
  158. $smarr['title'] = '系统默认标题';
  159. $smarr['neturl'] = '系统外网地址,用于公网';
  160. $smarr['apptitle'] = 'APP上和手机网页版上的标题';
  161. $smarr['reimtitle'] = 'REIM即时通信上标题';
  162. $smarr['weblogo'] = 'PC客户端上的logo图片';
  163. $smarr['db_host'] = '数据库地址';
  164. $smarr['db_user'] = '数据库用户名';
  165. $smarr['db_pass'] = '数据库密码';
  166. $smarr['db_base'] = '数据库名称';
  167. $smarr['perfix'] = '数据库表名前缀';
  168. $smarr['qom'] = 'session、cookie前缀';
  169. $smarr['highpass'] = '超级管理员密码,可用于登录任何帐号';
  170. $smarr['db_drive'] = '操作数据库驱动有mysql,mysqli,pdo三种';
  171. $smarr['randkey'] = '系统随机字符串密钥';
  172. $smarr['asynkey'] = '这是异步任务key';
  173. $smarr['openkey'] = '对外接口openkey';
  174. $smarr['sqllog'] = '是否记录sql日志保存'.UPDIR.'/sqllog下';
  175. $smarr['asynsend'] = '是否异步发送提醒消息,0同步,1自己服务端异步,2官网VIP用户异步';
  176. $smarr['install'] = '已安装,不要去掉啊';
  177. $smarr['xinhukey'] = '信呼官网key,用于在线升级使用';
  178. $smarr['bcolorxiang'] = '单据详情页面上默认展示线条的颜色';
  179. $smarr['debug'] = '为true调试开发模式,false上线模式';
  180. $smarr['reim_show'] = '首页是否显示REIM';
  181. $smarr['mobile_show'] = '首页是否显示手机版';
  182. $smarr['loginyzm'] = '登录方式:0仅使用帐号+密码,1帐号+密码/手机+验证码,2帐号+密码+验证码,3仅使用手机+验证码';
  183. $smarr['officeyl'] = '文档Excel.Doc预览类型,0自己部署插件,1使用官网支持任何平台';
  184. $smarr['officedk'] = '文件预览打开方式1新窗口打开';
  185. $smarr['useropt'] = '1记录用户操作保存到日志里,空不记录';
  186. $smarr['defstype'] = 'PC后台主题皮肤,可以设置1到34';
  187. $smarr['editpass'] = '用户登录修改密码:0不用修改,1强制用户必须修改';
  188. $smarr['companymode'] = '多单位模式,true就是开启';
  189. $smarr['outurl'] = '这个地址当你内网地址访问时向手机推送消息的地址';
  190. $smarr['officebj'] = '文档在线编辑,1官网提供或者自己部署';
  191. $smarr['officebj_key'] = '文档在线编辑agentkey';
  192. $smarr['apptheme'] = '系统或app的主题颜色';
  193. $str1 = '';
  194. foreach($arr as $k=>$v){
  195. $bz = '';
  196. if(isset($smarr[$k]))$bz=' //'.$smarr[$k].'';
  197. if(is_bool($v)){
  198. $v = $v ? 'true' : 'false';
  199. }else{
  200. $v = "'$v'";
  201. }
  202. $str1.= " '$k' => $v,$bz\n";
  203. }
  204. $str = '<?php
  205. if(!defined(\'HOST\'))die(\'not access\');
  206. //[管理员]在'.$this->now.'通过[系统→系统工具→系统设置],保存修改了配置文件
  207. return array(
  208. '.$str1.'
  209. );';
  210. @$bo = file_put_contents($_confpath, $str);
  211. if($bo){
  212. echo 'ok';
  213. }else{
  214. echo '保存失败无法写入:'.$_confpath.'';
  215. }
  216. }
  217. public function logbefore($table)
  218. {
  219. $key = $this->post('key');
  220. $s = '';
  221. m('log')->readPHPerr();
  222. if($key != ''){
  223. $s = "and (`type`='$key' or `optname` like '$key%' or `remark` like '$key%' or `web`='$key' or `ip`='$key')";
  224. }
  225. return $s;
  226. }
  227. public function logintokenbefore($table)
  228. {
  229. $key = $this->post('key');
  230. $s = '';
  231. if($key != ''){
  232. $s = "and (`name` like '%$key%' or `cfrom` like '%$key%' or `web` like '%$key%')";
  233. }
  234. return $s;
  235. }
  236. public function delloginAjax()
  237. {
  238. $id = c('check')->onlynumber($this->post('id'));
  239. m('logintoken')->delete('id in('.$id.')');
  240. backmsg();
  241. }
  242. public function dellogAjax()
  243. {
  244. $id = c('check')->onlynumber($this->post('id'));
  245. m('log')->delete('id in('.$id.')');
  246. backmsg();
  247. }
  248. public function clearlogAjax()
  249. {
  250. $lx = (int)$this->get('lx','0');
  251. $where = "`type`='异步队列'";
  252. if($lx==0)$where = '1=1';
  253. m('log')->delete($where);
  254. return returnsuccess();
  255. }
  256. public function saveautherAjax()
  257. {
  258. if(getconfig('systype')=='demo')exit('演示上不要操作');
  259. $autherkey = $this->post('key');
  260. $ym = $this->post('ym');
  261. $barr = c('xinhuapi')->authercheck($autherkey, $ym);
  262. if($barr['success']){
  263. echo 'ok';
  264. }else{
  265. echo $barr['msg'];
  266. }
  267. }
  268. public function savelixianAjax()
  269. {
  270. if(getconfig('systype')=='demo')exit('演示上不要操作');
  271. $aukey = $this->post('key');
  272. $ym = $this->post('ym');
  273. $path = 'config/rockauther.php';
  274. if(!file_exists($path))exit('没有下载签授文件到系统上');
  275. $da = require($path);
  276. $barr = c('xinhuapi')->autherfile($da, $aukey, $ym);
  277. if($barr['success']){
  278. @unlink($path);
  279. echo 'ok';
  280. }else{
  281. echo $barr['msg'];
  282. }
  283. }
  284. public function autherAjax()
  285. {
  286. $aukey = $this->option->getval('auther_aukey');
  287. $use = '1';
  288. $barr = array();
  289. if(isempt($aukey)){
  290. $use = '0';
  291. }else{
  292. $barr['enddt'] = $this->option->getval('auther_enddt');
  293. $barr['yuming']= $this->option->getval('auther_yuming');
  294. $barr['aukey'] = substr($aukey,0,5).'****'.substr($aukey,-5);
  295. }
  296. $barr['use'] = $use;
  297. return returnsuccess($barr);
  298. }
  299. public function autherdelAjax()
  300. {
  301. if(getconfig('systype')=='demo')return returnerror('演示上不要操作');
  302. return c('xinhuapi')->autherdel();
  303. }
  304. public function tongbudwAjax()
  305. {
  306. $rows = m('company')->getall('iscreate=1');
  307. foreach($rows as $k=>$rs){
  308. $base = ''.DB_BASE.'_company_'.$rs['num'].'';
  309. $this->sevessee($base, 'auther_aukey');
  310. $this->sevessee($base, 'auther_enddt');
  311. $this->sevessee($base, 'auther_yuming');
  312. $this->sevessee($base, 'auther_authkey');
  313. }
  314. return '同步成功';
  315. }
  316. private function sevessee($base, $key)
  317. {
  318. $val = $this->option->getval($key);
  319. $sql = "update ".$base.".`[Q]option` set `value`='$val',`optdt`='{$this->now}' where `num`='$key'";
  320. $this->db->query($sql, false);
  321. }
  322. /**
  323. * 更多保存设置
  324. */
  325. public function savemoresetAjax()
  326. {
  327. if(getconfig('systype')=='demo')return '演示不要改';
  328. $stype = (int)$this->post('stype','0');
  329. $msg = 'ok';
  330. if($stype==0)$msg = $this->saveconfig('title,imgcompress,watertype,video_bool,flowchehuitime,saasmode,hoemtimeout,usercache,xiangrecord,beianhao,locallang,savefiletype',',video_bool,');
  331. return $msg;
  332. }
  333. private function saveconfig($cont, $bsto)
  334. {
  335. $path = ''.P.'/'.P.'Config.php';
  336. $neir = file_get_contents($path);
  337. $zdar = explode(',', $cont);
  338. $neira= explode("\n", $neir);
  339. $strs = '';
  340. $szida= array();
  341. foreach($neira as $line){
  342. if($line==');')break;
  343. $bo = false;
  344. foreach($zdar as $fid){
  345. if(contain($line,"'".$fid."'")){
  346. $val = $this->post($fid);
  347. if(contain($val,'*****')){
  348. $strs.="".$line."\n";
  349. }else{
  350. $val = $this->rock->xssrepstr($val);
  351. $vals = "'".$val."'";
  352. if(contain($bsto,','.$fid.','))$vals = ($val=='1') ? 'true' : 'false';
  353. $strs.=" '".$fid."' => ".$vals.",\n";
  354. }
  355. $bo = true;
  356. $szida[]=$fid;
  357. }
  358. }
  359. if(!$bo)$strs.="".$line."\n";
  360. }
  361. foreach($zdar as $fid){
  362. if(!in_array($fid, $szida)){
  363. $val = $this->post($fid);
  364. $strs.=" '".$fid."' => '".$val."',\n";
  365. }
  366. }
  367. $strs.=');';
  368. $bo = @file_put_contents($path,$strs);
  369. if(!$bo)return '无权限写入:'.$path.'';
  370. return 'ok';
  371. }
  372. public function getmodeAjax()
  373. {
  374. $modearr = m('mode')->getmodearr('all');
  375. return array(
  376. 'modearr' => $modearr
  377. );
  378. }
  379. public function savemodeAjax()
  380. {
  381. if(getconfig('systype')=='demo')return '演示不要改';
  382. $dbs = m('mode');
  383. $allnum = $this->post('allnum');
  384. $allarr = explode(',', $allnum);
  385. $allstr = "'".str_replace(',',"','", $allnum)."'";
  386. $dbs->update('status=0', "`type`<>'系统' and `num` not in($allstr)");
  387. $dbs->update('status=1', "`num` in($allstr)");
  388. //菜单更新
  389. $menuarr = $dbs->menulist();
  390. $mdb = m('menu');
  391. $cdid = '';
  392. foreach($menuarr as $bh=>$vs){
  393. if($bh=='wxgzh' || $bh=='ding' || $bh=='weixinqy')continue;
  394. $zt = 0;
  395. if(contain($allstr,"'".$bh."'")){
  396. $zt = 1;
  397. $cdid.=','.$vs.'';
  398. }
  399. $mdb->update('`status`='.$zt.'', '`id` in('.$vs.')');
  400. }
  401. $menuarr = $dbs->yinglist();
  402. $mdb = m('im_group');
  403. foreach($menuarr as $bh=>$vs){
  404. $zt = 1;
  405. if(!contain($allstr,"'".$bh."'")){
  406. $zt = 0;
  407. }
  408. $mdb->update('`valid`='.$zt.'', '`id` in('.$vs.')');
  409. }
  410. $tdb= m('task');
  411. $hdb= m('homeitems');
  412. $zt = contain($allstr,"'kqdkjl'") ? 1 : 0;
  413. $tdb->update("`status`='$zt'", "`fenlei`='考勤'");
  414. $hdb->update("`status`='$zt'", "`num` in('kqdk','kqtotal')");
  415. $zt = contain($allstr,"'userract'") ? 1 : 0;
  416. $tdb->update("`status`='$zt'", "`fenlei`='人事'");
  417. $zt = contain($allstr,"'officic'") ? 1 : 0;
  418. $hdb->update("`status`='$zt'", "`num` in('officic')");
  419. $zt = contain($allstr,"'meet'") ? 1 : 0;
  420. $hdb->update("`status`='$zt'", "`num` in('meet')");
  421. $zt = contain($allstr,"'bianjian'") ? 1 : 0;
  422. $hdb->update("`status`='$zt'", "`num` in('bianjian')");
  423. $zt = contain($allstr,"'gong'") ? 1 : 0;
  424. $hdb->update("`status`='$zt'", "`num` in('gong')");
  425. return '保存成功';
  426. }
  427. /**
  428. * 2026-05-10安全设置的
  429. */
  430. public function safegetAjax()
  431. {
  432. $iplist = ''.ROOT_PATH.'/config/iplist.php';
  433. $iparr = array();
  434. if(file_exists($iplist)){
  435. $iparr = require($iplist);
  436. }
  437. $db = m('menu');
  438. if($db->rows("`num`='safeset'")==0)$db->insert(array(
  439. 'name' => '安全设置',
  440. 'pid' => '46',
  441. 'sort' => '8',
  442. 'url' => 'system,cog,safeset',
  443. 'icons' => 'shield',
  444. 'optdt' => $this->now,
  445. 'num' => 'safeset',
  446. 'ispir' => '1',
  447. 'type' => '1'
  448. ));
  449. return $iparr;
  450. }
  451. public function safesaveAjax()
  452. {
  453. if(getconfig('systype')=='demo')exit('演示上禁止设置');
  454. $iplist = ''.ROOT_PATH.'/config/iplist.php';
  455. $blackip = str_replace(':','.', $this->post('blackip'));
  456. $whiteip = str_replace(':','.', $this->post('whiteip'));
  457. $whitecity = $this->rock->xssrepstr($this->post('whitecity'));
  458. $gaptime = (int)$this->post('gaptime','0');
  459. $gapnums = (int)$this->post('gapnums','0');
  460. if($zf = c('check')->onlynoen(str_replace(array('.',',','*'),'', $blackip)))return '无效字符:'.$zf.'';
  461. if($zf = c('check')->onlynoen(str_replace(array('.',',','*'),'', $whiteip)))return '无效字符:'.$zf.'';
  462. $str = "<?php
  463. return array(
  464. //黑名单IP,多个,分开如:127.0.0.1,192.168.1.100,也可以写192.168.1这样就是限制192.168.1.*所有的
  465. 'blackip' => '$blackip',
  466. //白名单
  467. 'whiteip' => '$whiteip',
  468. //可访问的区域
  469. 'whitecity' => '$whitecity',
  470. //几秒内
  471. 'gaptime' => $gaptime,
  472. //限制访问次数
  473. 'gapnums' => $gapnums
  474. );";
  475. $bool = @file_put_contents($iplist, $str);
  476. if(!$bool)return '保存失败无法写入:config/iplist.php';
  477. return 'ok';
  478. }
  479. }
粤ICP备19079148号