index.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. require('../../../class/connect.php'); //引入数据库配置文件和公共函数文件
  4. require('../../../class/db_sql.php'); //引入数据库操作文件
  5. require('../../../class/functions.php');
  6. $link=db_connect(); //连接MYSQL
  7. $empire=new mysqlquery(); //声明数据库操作类
  8. $editor=9; //声明目录层次
  9. require_once '../skycaiji2cms/skycaiji2cms.php';
  10. $GLOBALS['scj2cms']=$scj2cms=new skycaiji2cms(
  11. dirname(dirname(__FILE__)),
  12. $public_r['newsurl'].'e/extend/skycaijidg',
  13. $ecms_config['db']['dbchar'],
  14. true
  15. );
  16. $scj2cms->formUrl=$scj2cms->pluginUrl.'index/index.php';
  17. $scj2cms->apiUrl=($scj2cms->isSsl()?'https':'http').'://'.$scj2cms->getHost().$scj2cms->pluginUrl.'post.php';
  18. if(stripos($ecms_config['sets']['pagechar'],'gb')===0){
  19. //gbk编码
  20. $scj2cms->pluginLang=include '../data/lang_gbk.php';
  21. }else{
  22. $scj2cms->pluginLang=include '../data/lang_utf8.php';
  23. }
  24. //验证用户
  25. $cacheCkhash=$ecms_config['esafe']['ckhash'];
  26. $ecms_config['esafe']['ckhash']=2;//关闭HASH模式
  27. $lur=is_login();
  28. $logininid=$lur['userid'];
  29. $loginin=$lur['username'];
  30. $loginrnd=$lur['rnd'];
  31. $loginlevel=$lur['groupid'];
  32. $loginadminstyleid=$lur['adminstyleid'];
  33. //ehash
  34. $ecms_config['esafe']['ckhash']=$cacheCkhash;
  35. $ecms_hashur=hReturnEcmsHashStrAll();
  36. $ecms_config['esafe']['ckhash']=2;//关闭HASH模式
  37. //验证权限
  38. try{
  39. CheckLevel($logininid,$loginin,'','news');
  40. }catch (\Exception $ex){
  41. $scj2cms->returnJson(0,$ex->getMessage());
  42. }
  43. define('SKYCAIJIDG_CONFIG', ECMS_PATH.'d/file/skycaijidg_config.php');
  44. if($scj2cms->formIsPost()){
  45. //提交
  46. $scj2cms->funcFormPost='_scjFuncFormPost';
  47. $scj2cms->formPost();
  48. echo '<script>window.location.href="'.$scj2cms->formUrl.'";</script>';
  49. exit();
  50. }else{
  51. //添加菜单
  52. $hasMenu=$empire->num("select * from {$dbtbpre}enewsmenuclass where classname='{$scj2cms->pluginLang['dg_menu_name']}' and classtype=2");
  53. if($hasMenu<=0){
  54. $empire->query("insert into {$dbtbpre}enewsmenuclass(classname,myorder,classtype) values('{$scj2cms->pluginLang['dg_menu_name']}','0','2');");
  55. $menuId=$empire->lastid();
  56. if($menuId>0){
  57. $hasMenuSub=$empire->num("select * from {$dbtbpre}enewsmenu where menuname='{$scj2cms->pluginLang['dg_menu_sub_name']}' and classid={$menuId}");
  58. if($hasMenuSub<=0){
  59. $empire->query("insert into {$dbtbpre}enewsmenu(menuname,menuurl,myorder,classid,addhash) values('{$scj2cms->pluginLang['dg_menu_sub_name']}','{$scj2cms->formUrl}','0','{$menuId}','0');");
  60. }
  61. }
  62. }
  63. $pluginConfig=null;
  64. if(file_exists(SKYCAIJIDG_CONFIG)){
  65. $pluginConfig=include SKYCAIJIDG_CONFIG;
  66. $pluginConfig=unserialize(base64_decode($pluginConfig));
  67. }
  68. $scj2cms->pluginConfig=is_array($pluginConfig)?$pluginConfig:array();
  69. //修改文字
  70. $scj2cms->pluginLang['dg_f_classid']=sprintf($scj2cms->pluginLang['dg_f_classid'],$public_r['newsurl'].'e/admin/ListClass.php'.$ecms_hashur['whhref']);
  71. $scj2cms->pluginLang['dg_f_copyclassid']=sprintf($scj2cms->pluginLang['dg_f_copyclassid'],$public_r['newsurl'].'e/admin/ListClass.php'.$ecms_hashur['whhref']);
  72. $scj2cms->pluginLang['dg_f_isgood']=sprintf($scj2cms->pluginLang['dg_f_isgood'],$public_r['newsurl'].'e/admin/info/ListGoodType.php?ttype=0'.$ecms_hashur['href']);
  73. $scj2cms->pluginLang['dg_f_firsttitle']=sprintf($scj2cms->pluginLang['dg_f_firsttitle'],$public_r['newsurl'].'e/admin/info/ListGoodType.php?ttype=1'.$ecms_hashur['href']);
  74. //必填
  75. $scj2cms->formRequired=array(
  76. 'title'=>$scj2cms->pluginLang['dg_f_title'],
  77. 'newstext'=>$scj2cms->pluginLang['dg_f_newstext'],
  78. 'classid'=>$scj2cms->pluginLang['dg_f_classid'],
  79. );
  80. //选填
  81. $scj2cms->formOptional=array();
  82. $groups=array();
  83. $sql=$empire->query("select * from {$dbtbpre}enewsmembergroup order by groupid");
  84. while($r=$empire->fetch($sql)){
  85. $groups[]=$r['groupid'].':'.$r['groupname'];
  86. }
  87. $groups=implode(', ', $groups);
  88. $scj2cms->pluginLang['dg_f_groupid']=sprintf($scj2cms->pluginLang['dg_f_groupid'],$groups);
  89. foreach ($scj2cms->pluginLang as $k=>$v){
  90. if(preg_match('/^dg_f_(\w+)$/',$k,$mk)){
  91. $mk=$mk[1];
  92. if(isset($scj2cms->formRequired[$mk])){
  93. //过滤必填项
  94. continue;
  95. }
  96. $scj2cms->formOptional[$mk]=$v;
  97. }
  98. }
  99. ob_clean();
  100. ob_start();
  101. $scj2cms->formView();
  102. $html=ob_get_contents();
  103. ob_clean();
  104. require('index.temp.php'); //导入模板文件
  105. }
  106. db_close(); //关闭MYSQL链接
  107. $empire=null; //注消操作类变量
  108. function _scjFuncFormPost($data){
  109. $data=base64_encode(serialize($data));
  110. if(file_put_contents(SKYCAIJIDG_CONFIG,'<?php return "'.$data.'"; ?>')===false){
  111. exit('请设置目录/d/file的可写权限!');
  112. }
  113. }
  114. function scjloadlang($file,&$error,&$gotourl,&$gotourl_js){
  115. global $public_r;
  116. if($error=='NotLogin'){
  117. $gotourl=$public_r['newsurl'].'e/admin';
  118. $gotourl_js='self.location.href="'.$gotourl.'";';
  119. }
  120. return ECMS_PATH.'e/data/language/'.$file;
  121. }
  122. ?>