indexAction.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <?php
  2. class indexClassAction extends Action{
  3. public $homestylebool = false;
  4. private $menuwhere,$addmenu;
  5. public function defaultAction()
  6. {
  7. if(strlen(getconfig('randkey'))!=26)exit('配置文件randkey不正确,请重新设置为:'.$this->jm->getRandkey().'');
  8. $notuserids = getconfig('notuserids');
  9. $this->pannouser();
  10. $homestyle = getconfig('homestyle');
  11. if($homestyle>=1 && !$this->homestylebool){
  12. $temshot = $this->getsession('homestyle');
  13. if(!$temshot){
  14. $urlt = '?a=home';
  15. if($homestyle==2)$urlt = '?a=new';
  16. $this->rock->location($urlt);
  17. return;
  18. }
  19. }
  20. $afrom = $this->get('afrom');
  21. $this->tpltype = 'html';
  22. $my = $this->db->getone('[Q]admin', "`id`='$this->adminid' and `status`=1",'`face`,`id`,`name`,`ranking`,`deptname`,`deptallname`,`type`,`style`,`user`');
  23. if(!$my)return '登录用户不存在了,<a href="?m=login&a=exit">重新登录</a>';
  24. $allmenuid = m('sjoin')->getuserext($this->adminid, $my['type']);
  25. m('dept')->online(1);
  26. $mewhere = '';
  27. $isadmin = 1;
  28. $myext = $allmenuid;
  29. if($myext != '-1'){
  30. $isadmin = 0;
  31. $mewhere = ' and `id` in('.str_replace(array('[',']'), array('',''), $myext).')';
  32. }
  33. if($this->adminid!=1)$mewhere.=' and `type`=0';
  34. $this->rock->savesession(array(
  35. 'adminallmenuid' => $allmenuid,
  36. 'isadmin' => $isadmin,
  37. 'homestyle' => 'rock',
  38. 'adminuser' => $my['user']
  39. ));
  40. $this->smartydata['adminuser'] = $my['user'];
  41. $this->smartydata['topmenu'] = m('menu')->getall("`pid`=0 and `status`=1 $mewhere order by `sort`");
  42. $homeurl = $this->jm->base64decode($this->get('homeurl'));
  43. $homename = $this->jm->base64decode($this->get('homename'));
  44. $menuid = (int)$this->jm->base64decode($this->get('menuid'));
  45. $showkey = $this->jm->base64encode($this->jm->getkeyshow());
  46. if($menuid<1)$menuid = '';
  47. if($homeurl=='')$showkey = '';
  48. if(!isempt($homeurl) && isempt($menuid))return '无权限打开['.$homename.']的页面1';
  49. if(!isempt($menuid) && $isadmin==0){
  50. if(!contain($myext,'['.$menuid.']'))return '无权限打开['.$homename.']的页面2';
  51. }
  52. $this->smartydata['showkey'] = $showkey;
  53. $this->smartydata['homeurl'] = $homeurl;
  54. $this->smartydata['homename'] = $homename;
  55. $this->smartydata['admintype'] = $isadmin;
  56. $this->smartydata['my'] = $my;
  57. $this->smartydata['afrom'] = $afrom;
  58. $this->smartydata['tanwidth'] = $this->option->getval('tanwidth', '900x800');
  59. $this->smartydata['face'] = $this->rock->repempt($my['face'], 'images/noface.png');
  60. if(!isempt($homename))$this->title = $homename;
  61. //样式主题处理
  62. $strs = explode(',', ',cerulean,cosmo,cyborg,darkly,flatly,journal,lumen,paper,readable,sandstone,simplex,slate,spacelab,superhero,united,xinhu,yeti');
  63. $zys = count($strs)-1;
  64. $style= (int)$this->rock->repempt($my['style'], '0');//默认样式
  65. $styys= 'inverse';
  66. $this->smartydata['style'] = $style;
  67. if($style==0)$style = (int)getconfig('defstype','1');//默认的主题皮肤
  68. if($style>$zys){
  69. $styys= 'default';
  70. $style= $style-$zys;
  71. }
  72. $stylecs1 = 'mode/bootstrap3.3/css/bootstrap';
  73. $stylecss = ''.$stylecs1.'_'.$strs[$style].'.css';
  74. if(!file_exists($stylecss))$stylecss= ''.$stylecs1.'_cerulean.css';
  75. $this->smartydata['stylecss'] = $stylecss;
  76. $this->smartydata['styledev'] = $styys;
  77. //读取单位
  78. $this->smartydata['logo'] = 'images/xh829.png';
  79. $this->smartydata['icon'] = 'favicon.ico';
  80. $companyinfo = false;
  81. if(COMPANYNUM)$companyinfo = m('company')->getone(1);
  82. if(ISMORECOM)$companyinfo = m('admin')->getcompanyinfo($this->adminid, 1);
  83. if($companyinfo){
  84. $this->title = $companyinfo['name'];
  85. if(!isempt($companyinfo['oaname']))$this->title = $companyinfo['oaname'];
  86. if(!isempt($companyinfo['logo'])){
  87. $this->smartydata['logo'] = $companyinfo['logo'];
  88. $this->smartydata['icon'] = $this->smartydata['logo'];
  89. }
  90. }
  91. }
  92. public function newAction()
  93. {
  94. $this->homestylebool = true;
  95. $this->defaultAction();
  96. $stylecss = 'mode/bootstrap3.3/css/bootstrap4_default.css';
  97. $stylecss = 'mode/bootstrap3.3/css/bootstrap3_xinhuoa.css';
  98. if(!file_exists('webmain/index/tpl_index_new.html')){
  99. $this->displayfile = 'webmain/index/tpl_index.html';
  100. }else{
  101. $_ysts = $this->smartydata['stylecss'];
  102. if(contain($_ysts,'xinhu') || contain($_ysts,'cerulean'))$this->smartydata['stylecss'] = $stylecss;
  103. }
  104. }
  105. public function homeAction()
  106. {
  107. $this->homestylebool = true;
  108. $this->defaultAction();
  109. $homewidth = getconfig('homewidth');
  110. if(!$homewidth)$homewidth='1300px';
  111. $this->smartydata['homewidth']= $homewidth;
  112. $this->smartydata['beijing'] = $this->option->getval('beijing_'.$this->adminid.'','images/beijing/bj0.jpg');
  113. if(!file_exists('webmain/index/tpl_index_home.html'))$this->displayfile = 'webmain/index/tpl_index.html';
  114. }
  115. public function testnetAction()
  116. {
  117. $curl = c('curl');
  118. $url = 'https://www.baidu.com/';
  119. $cont = $curl->getcurl($url);
  120. if(contain($cont,'http')){
  121. echo '可以访问地址:'.$url.'<br>';
  122. }else{
  123. echo '无法访问地址:'.$url.'<br>';
  124. }
  125. $url = 'http://www.rockoa.com/';
  126. $cont = $curl->getcurl($url);
  127. if(contain($cont,'http')){
  128. echo '可以访问地址:'.$url.'<br>';
  129. }else{
  130. echo '无法访问地址:'.$url.'<br>';
  131. }
  132. return '测试完成';
  133. }
  134. public function phpinfoAction()
  135. {
  136. $this->display = false;
  137. phpinfo();
  138. }
  139. private function menuwheres()
  140. {
  141. $this->menuwhere = '';
  142. $myext = $this->getsession('adminallmenuid');
  143. if(isempt($myext))$myext = '0';
  144. if($myext != '-1'){
  145. $this->menuwhere = ' and `id` in('.str_replace(array('[',']'), array('',''), $myext).')';
  146. }
  147. if($this->adminid!=1)$this->menuwhere.=' and `type`=0';//非admin只能看普通菜单
  148. }
  149. /**
  150. * 搜索菜单
  151. */
  152. public function getmenusouAjax()
  153. {
  154. $key = $this->post('key');
  155. $this->menuwheres();
  156. $this->addmenu = m('menu')->getall("`status`=1 $this->menuwhere and `name` like '%$key%' and ifnull(`url`,'')<>'' order by `pid`,`sort` limit 10",'`id`,`num`,`url`,`icons`,`name`,`pid`');
  157. $arr = $this->getmenu(0, 1);
  158. $this->returnjson($arr);
  159. }
  160. /**
  161. * 获取菜单
  162. */
  163. public function getmenuAjax()
  164. {
  165. $pid = $this->get('pid');
  166. $loadci = (int)$this->get('loadci');
  167. $this->menuwheres();
  168. $this->addmenu = m('menu')->getall("`status`=1 $this->menuwhere order by `sort`,`id`",'`id`,`num`,`url`,`icons`,`name`,`pid`');
  169. $barr = array(
  170. 'menuarr' => $this->getmenu($pid,0)
  171. );
  172. if($loadci==1)$barr['menutopid'] = $this->menutopid();
  173. return $barr;
  174. }
  175. private function getmenu($pid, $lx=0)
  176. {
  177. $menu = $this->addmenu;
  178. $rows = array();
  179. foreach($menu as $k=>$rs){
  180. if($lx == 0 && $pid != $rs['pid'])continue;
  181. $num = $rs['num'];
  182. $rs['bh'] = $num;
  183. $sid = $rs['id'];
  184. $icons = $rs['icons'];
  185. if(isempt($num))$num = 'num'.$sid;
  186. if(isempt($icons))$icons = 'bookmark-empty';
  187. $rs['icons'] = $icons;
  188. $rs['num'] = $num;
  189. if($lx == 0){
  190. $children = $this->getmenu($sid);
  191. $rs['children'] = $children;
  192. $rs['stotal'] = count($children);
  193. }else{
  194. $rs['stotal'] = 0;
  195. }
  196. $rs['name'] = lang($rs['name'],'menu');
  197. $rows[] = $rs;
  198. }
  199. return $rows;
  200. }
  201. private function menutopid()
  202. {
  203. $pnuma = array();
  204. $gpar = array();
  205. foreach($this->addmenu as $k=>$rs)if($rs['pid']>0)$pnuma[$rs['id']]=$rs['pid'];
  206. foreach($this->addmenu as $k=>$rs){
  207. if($rs['pid']>0 && !isempt($rs['num'])){
  208. $pid = $rs['pid'];
  209. if(isset($pnuma[$pid])){
  210. $pid=$pnuma[$pid];
  211. if(isset($pnuma[$pid]))$pid=$pnuma[$pid];
  212. }
  213. $gpar[$rs['num']]=$pid;
  214. }
  215. }
  216. return $gpar;
  217. }
  218. public function downAction()
  219. {
  220. $this->display = false;
  221. $id = (int)$this->jm->gettoken('id');
  222. m('file')->show($id);
  223. }
  224. /**
  225. * 单页显示
  226. */
  227. public function showAction()
  228. {
  229. $url = $this->get('url');
  230. if($url=='')exit('无效请求');
  231. $this->defaultAction();
  232. }
  233. /**
  234. * 获取模版文件
  235. */
  236. public function getshtmlAction()
  237. {
  238. $this->pannouser();
  239. $surl = $this->jm->base64decode($this->get('surl'));
  240. $num = $this->get('num');
  241. $menuname = $this->jm->base64decode($this->get('menuname'));
  242. $urlpms = $this->jm->base64decode($this->get('urlpms'));
  243. if(isempt($surl))exit('not found');
  244. $file = ''.P.'/'.$surl.'.php';
  245. if(!file_exists($file))$file = ''.P.'/'.$surl.'.shtml';
  246. if(!file_exists($file))exit('404 not found '.$surl.'');
  247. $params = array();
  248. if($urlpms)$params = json_decode('{'.str_replace('\'','"', $urlpms).'}', true);
  249. $this->assign('pageparams', $params);
  250. if(contain($surl,'home/index/rock_index'))$this->showhomeitems();//首页的显示
  251. $this->displayfile = $file;
  252. //记录打开菜单日志
  253. if($num!='home' && getconfig('useropt')=='1')
  254. m('log')->addlog('打开菜单', '菜单['.$num.'.'.$menuname.']');
  255. }
  256. //显示桌面项目
  257. private function showhomeitems()
  258. {
  259. $rows = m('homeitems')->getmyshow();
  260. if(!$rows)$rows = json_decode('[{"num":"kjrk","row":"0","name":"快捷入口","sort":"0"},{"num":"gong","row":"0","name":"通知公告","sort":"1"},{"num":"kqdk","row":"0","name":"考勤打卡","sort":"2"},{"num":"gwwx","row":"0","receid":"u1","recename":"管理员","name":"微信办公","sort":"10"},{"num":"apply","row":"1","name":"我的申请","sort":"0"},{"num":"meet","row":"1","name":"今日会议","sort":"2"},{"num":"syslog","receid":"u1","recename":"管理员","row":"1","name":"系统日志","sort":"3"},{"num":"about","row":"1","receid":"u1","recename":"管理员","name":"关于信呼","sort":"10"}]', true);
  261. $homeitems = $homearrs = array();
  262. foreach($rows as $k=>$rs)$homearrs[] = $rs['num'];
  263. foreach($rows as $k=>$rs){
  264. $bh = $rs['num'];
  265. if($bh != 'kjrko'){
  266. if(in_array('kjrko',$homearrs) && $bh == 'kjrk'){
  267. }else{
  268. $homeitems[$rs['row']][] = array(
  269. 'num' => $bh,
  270. 'name'=> $rs['name']
  271. );
  272. }
  273. }
  274. }
  275. $this->assign('homeitems', $homeitems);
  276. $this->assign('homearrs', $homearrs);
  277. }
  278. //开发时快速打开文件
  279. public function openfileAjax()
  280. {
  281. $file = $this->rock->jm->base64decode($this->get('file'));
  282. $str = ''.ROOT_PATH.'/'.$file.'';
  283. $bo = c('socket')->udpsend($str,'cmd');
  284. if(is_string($bo))return $bo;
  285. return 'ok';
  286. }
  287. public function testAjax()
  288. {
  289. //header("HTTP/1.1 500 Not Found");
  290. echo $this->get('abc');
  291. }
  292. public function getxings($str)
  293. {
  294. if(!isempt($str))$str = substr($str,0,5).'*****'.substr($str,-5);
  295. return $str;
  296. }
  297. }
粤ICP备19079148号