cogAction.php 15 KB

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