indexAction.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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 oldAction()
  93. {
  94. $this->defaultAction();
  95. }
  96. public function newAction()
  97. {
  98. $this->homestylebool = true;
  99. $this->defaultAction();
  100. $stylecss = 'mode/bootstrap3.3/css/bootstrap4_default.css';
  101. $stylecss = 'mode/bootstrap3.3/css/bootstrap3_xinhuoa.css';
  102. if(!file_exists('webmain/index/tpl_index_new.html')){
  103. $this->displayfile = 'webmain/index/tpl_index.html';
  104. }else{
  105. $_ysts = $this->smartydata['stylecss'];
  106. if(contain($_ysts,'xinhu') || contain($_ysts,'cerulean'))$this->smartydata['stylecss'] = $stylecss;
  107. }
  108. }
  109. public function homeAction()
  110. {
  111. $this->homestylebool = true;
  112. $this->defaultAction();
  113. $homewidth = getconfig('homewidth');
  114. if(!$homewidth)$homewidth='1300px';
  115. $this->smartydata['homewidth']= $homewidth;
  116. $this->smartydata['beijing'] = $this->option->getval('beijing_'.$this->adminid.'','images/beijing/bj0.jpg');
  117. if(!file_exists('webmain/index/tpl_index_home.html'))$this->displayfile = 'webmain/index/tpl_index.html';
  118. }
  119. public function testnetAction()
  120. {
  121. $curl = c('curl');
  122. $url = 'https://www.baidu.com/';
  123. $cont = $curl->getcurl($url);
  124. if(contain($cont,'http')){
  125. echo '可以访问地址:'.$url.'<br>';
  126. }else{
  127. echo '无法访问地址:'.$url.'<br>';
  128. }
  129. $url = 'http://www.rockoa.com/';
  130. $cont = $curl->getcurl($url);
  131. if(contain($cont,'http')){
  132. echo '可以访问地址:'.$url.'<br>';
  133. }else{
  134. echo '无法访问地址:'.$url.'<br>';
  135. }
  136. return '测试完成';
  137. }
  138. public function phpinfoAction()
  139. {
  140. $this->display = false;
  141. phpinfo();
  142. }
  143. private function menuwheres()
  144. {
  145. $this->menuwhere = '';
  146. $myext = $this->getsession('adminallmenuid');
  147. if(isempt($myext))$myext = '0';
  148. if($myext != '-1'){
  149. $this->menuwhere = ' and `id` in('.str_replace(array('[',']'), array('',''), $myext).')';
  150. }
  151. if($this->adminid!=1)$this->menuwhere.=' and `type`=0';//非admin只能看普通菜单
  152. }
  153. /**
  154. * 搜索菜单
  155. */
  156. public function getmenusouAjax()
  157. {
  158. $key = $this->post('key');
  159. $this->menuwheres();
  160. $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`');
  161. $arr = $this->getmenu(0, 1);
  162. $this->returnjson($arr);
  163. }
  164. /**
  165. * 获取菜单
  166. */
  167. public function getmenuAjax()
  168. {
  169. $pid = $this->get('pid');
  170. $loadci = (int)$this->get('loadci');
  171. $this->menuwheres();
  172. $this->addmenu = m('menu')->getall("`status`=1 $this->menuwhere order by `sort`,`id`",'`id`,`num`,`url`,`icons`,`name`,`pid`');
  173. $barr = array(
  174. 'menuarr' => $this->getmenu($pid,0)
  175. );
  176. if($loadci==1)$barr['menutopid'] = $this->menutopid();
  177. return $barr;
  178. }
  179. private function getmenu($pid, $lx=0)
  180. {
  181. $menu = $this->addmenu;
  182. $rows = array();
  183. foreach($menu as $k=>$rs){
  184. if($lx == 0 && $pid != $rs['pid'])continue;
  185. $num = $rs['num'];
  186. $rs['bh'] = $num;
  187. $sid = $rs['id'];
  188. $icons = $rs['icons'];
  189. if(isempt($num))$num = 'num'.$sid;
  190. if(isempt($icons))$icons = 'bookmark-empty';
  191. $rs['icons'] = $icons;
  192. $rs['num'] = $num;
  193. if($lx == 0){
  194. $children = $this->getmenu($sid);
  195. $rs['children'] = $children;
  196. $rs['stotal'] = count($children);
  197. }else{
  198. $rs['stotal'] = 0;
  199. }
  200. $rs['name'] = lang($rs['name'],'menu');
  201. $rows[] = $rs;
  202. }
  203. return $rows;
  204. }
  205. private function menutopid()
  206. {
  207. $pnuma = array();
  208. $gpar = array();
  209. foreach($this->addmenu as $k=>$rs)if($rs['pid']>0)$pnuma[$rs['id']]=$rs['pid'];
  210. foreach($this->addmenu as $k=>$rs){
  211. if($rs['pid']>0 && !isempt($rs['num'])){
  212. $pid = $rs['pid'];
  213. if(isset($pnuma[$pid])){
  214. $pid=$pnuma[$pid];
  215. if(isset($pnuma[$pid]))$pid=$pnuma[$pid];
  216. }
  217. $gpar[$rs['num']]=$pid;
  218. }
  219. }
  220. return $gpar;
  221. }
  222. public function downAction()
  223. {
  224. $this->display = false;
  225. $id = (int)$this->jm->gettoken('id');
  226. m('file')->show($id);
  227. }
  228. /**
  229. * 单页显示
  230. */
  231. public function showAction()
  232. {
  233. $url = $this->get('url');
  234. if($url=='')exit('无效请求');
  235. $this->defaultAction();
  236. }
  237. /**
  238. * 获取模版文件
  239. */
  240. public function getshtmlAction()
  241. {
  242. $this->pannouser();
  243. $surl = $this->jm->base64decode($this->get('surl'));
  244. $num = $this->get('num');
  245. $menuname = $this->jm->base64decode($this->get('menuname'));
  246. $urlpms = $this->jm->base64decode($this->get('urlpms'));
  247. if(isempt($surl))exit('not found');
  248. $file = ''.P.'/'.$surl.'.php';
  249. if(!file_exists($file))$file = ''.P.'/'.$surl.'.shtml';
  250. if(!file_exists($file))exit('404 not found '.$surl.'');
  251. $params = array();
  252. if($urlpms)$params = json_decode('{'.str_replace('\'','"', $urlpms).'}', true);
  253. $this->assign('pageparams', $params);
  254. if(contain($surl,'home/index/rock_index'))$this->showhomeitems();//首页的显示
  255. $this->displayfile = $file;
  256. //记录打开菜单日志
  257. if($num!='home' && getconfig('useropt')=='1')
  258. m('log')->addlog('打开菜单', '菜单['.$num.'.'.$menuname.']');
  259. }
  260. //显示桌面项目
  261. private function showhomeitems()
  262. {
  263. $rows = m('homeitems')->getmyshow();
  264. 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);
  265. $homeitems = $homearrs = array();
  266. foreach($rows as $k=>$rs)$homearrs[] = $rs['num'];
  267. foreach($rows as $k=>$rs){
  268. $bh = $rs['num'];
  269. if($bh != 'kjrko'){
  270. if(in_array('kjrko',$homearrs) && $bh == 'kjrk'){
  271. }else{
  272. $homeitems[$rs['row']][] = array(
  273. 'num' => $bh,
  274. 'name'=> $rs['name']
  275. );
  276. }
  277. }
  278. }
  279. $this->assign('homeitems', $homeitems);
  280. $this->assign('homearrs', $homearrs);
  281. }
  282. //开发时快速打开文件
  283. public function openfileAjax()
  284. {
  285. $file = $this->rock->jm->base64decode($this->get('file'));
  286. $str = ''.ROOT_PATH.'/'.$file.'';
  287. $bo = c('socket')->udpsend($str,'cmd');
  288. if(is_string($bo))return $bo;
  289. return 'ok';
  290. }
  291. public function testAjax()
  292. {
  293. //header("HTTP/1.1 500 Not Found");
  294. echo $this->get('abc');
  295. }
  296. public function testAction()
  297. {
  298. }
  299. public function getxings($str)
  300. {
  301. if(!isempt($str))$str = substr($str,0,5).'*****'.substr($str,-5);
  302. return $str;
  303. }
  304. }
粤ICP备19079148号