cogAction.php 13 KB

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