1
0

indexAction.php 10 KB

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