cogAction.php 15 KB

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