indexAction.php 10 KB

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