setfun.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. //返回参数内容
  3. function ReturnSettingString($r){
  4. $filename='data/setting.txt';
  5. $text=ReadFiletext($filename);
  6. //后台安全
  7. $text=str_replace('[!@--do_loginauth--@!]',addslashes($r[do_loginauth]),$text);
  8. $text=str_replace('[!@--do_enloginauth--@!]',intval($r[do_enloginauth]),$text);
  9. $text=str_replace('[!@--do_ecookiernd--@!]',addslashes($r[do_ecookiernd]),$text);
  10. $text=str_replace('[!@--do_ckhloginip--@!]',intval($r[do_ckhloginip]),$text);
  11. $text=str_replace('[!@--do_ckhsession--@!]',intval($r[do_ckhsession]),$text);
  12. $text=str_replace('[!@--do_ckhanytime--@!]',intval($r[do_ckhanytime]),$text);
  13. $text=str_replace('[!@--do_theloginlog--@!]',intval($r[do_theloginlog]),$text);
  14. $text=str_replace('[!@--do_thedolog--@!]',intval($r[do_thedolog]),$text);
  15. $text=str_replace('[!@--do_ckfromurl--@!]',intval($r[do_ckfromurl]),$text);
  16. $text=str_replace('[!@--do_ckhash--@!]',intval($r[do_ckhash]),$text);
  17. $text=str_replace('[!@--do_ckhashename--@!]',addslashes($r[do_ckhashename]),$text);
  18. $text=str_replace('[!@--do_ckhashrname--@!]',addslashes($r[do_ckhashrname]),$text);
  19. $text=str_replace('[!@--do_ckhuseragent--@!]',addslashes($r[do_ckhuseragent]),$text);
  20. //COOKIE
  21. $text=str_replace('[!@--phome_cookiedomain--@!]',addslashes($r[phome_cookiedomain]),$text);
  22. $text=str_replace('[!@--phome_cookiepath--@!]',addslashes($r[phome_cookiepath]),$text);
  23. $text=str_replace('[!@--phome_cookiehttponly--@!]',intval($r[phome_cookiehttponly]),$text);
  24. $text=str_replace('[!@--phome_cookiesecure--@!]',intval($r[phome_cookiesecure]),$text);
  25. $text=str_replace('[!@--phome_cookievarpre--@!]',addslashes($r[phome_cookievarpre]),$text);
  26. $text=str_replace('[!@--phome_cookieadminvarpre--@!]',addslashes($r[phome_cookieadminvarpre]),$text);
  27. $text=str_replace('[!@--phome_cookieckrnd--@!]',addslashes($r[phome_cookieckrnd]),$text);
  28. $text=str_replace('[!@--phome_cookieckrndtwo--@!]',addslashes($r[phome_cookieckrndtwo]),$text);
  29. $text=str_replace('[!@--phome_cookieckrndthree--@!]',addslashes($r[phome_cookieckrndthree]),$text);
  30. $text=str_replace('[!@--phome_cookieckrndfour--@!]',addslashes($r[phome_cookieckrndfour]),$text);
  31. $text=str_replace('[!@--phome_cookieckrndfive--@!]',addslashes($r[phome_cookieckrndfive]),$text);
  32. //防火墙
  33. $text=str_replace('[!@--efw_open--@!]',intval($r[efw_open]),$text);
  34. $text=str_replace('[!@--efw_pass--@!]',addslashes($r[efw_pass]),$text);
  35. $text=str_replace('[!@--efw_adminloginurl--@!]',addslashes($r[efw_adminloginurl]),$text);
  36. $text=str_replace('[!@--efw_adminhour--@!]',addslashes($r[efw_adminhour]),$text);
  37. $text=str_replace('[!@--efw_adminweek--@!]',addslashes($r[efw_adminweek]),$text);
  38. $text=str_replace('[!@--efw_adminckpassvar--@!]',addslashes($r[efw_adminckpassvar]),$text);
  39. $text=str_replace('[!@--efw_adminckpassval--@!]',addslashes($r[efw_adminckpassval]),$text);
  40. $text=str_replace('[!@--efw_cleargettext--@!]',addslashes($r[efw_cleargettext]),$text);
  41. return $text;
  42. }
  43. //生成配置文件
  44. function GetSettingConfig($string){
  45. $filename=ECMS_PATH."e/config/config.php";
  46. $exp='//-------EmpireCMS.Seting.area-------';
  47. $text=ReadFiletext($filename);
  48. $r=explode($exp,$text);
  49. if($r[0]=='')
  50. {
  51. return false;
  52. }
  53. $r[1]=$string;
  54. $setting=$r[0].$exp.$r[1].$exp.$r[2];
  55. WriteFiletext_n($filename,$setting);
  56. }
  57. //防火墙设置
  58. function SetFirewall($add,$userid,$username){
  59. global $ecms_config;
  60. $r[efw_open]=(int)$add[fw_open];
  61. $r[efw_pass]=$add[fw_pass];
  62. $r[efw_adminloginurl]=$add[fw_adminloginurl];
  63. //时间点
  64. $hour=$add['fw_adminhour'];
  65. $hcount=count($hour);
  66. $adminhour='';
  67. if($hcount)
  68. {
  69. $dh='';
  70. for($i=0;$i<$hcount;$i++)
  71. {
  72. $adminhour.=$dh.intval($hour[$i]);
  73. $dh=',';
  74. }
  75. }
  76. $r[efw_adminhour]=$adminhour;
  77. //星期
  78. $week=$add['fw_adminweek'];
  79. $wcount=count($week);
  80. $adminweek='';
  81. if($wcount)
  82. {
  83. $dh='';
  84. for($i=0;$i<$wcount;$i++)
  85. {
  86. $adminweek.=$dh.intval($week[$i]);
  87. $dh=',';
  88. }
  89. }
  90. $r[efw_adminweek]=$adminweek;
  91. $r[efw_adminckpassvar]=$add[fw_adminckpassvar];
  92. $r[efw_adminckpassval]=$add[fw_adminckpassval];
  93. $r[efw_cleargettext]=$add[fw_cleargettext];
  94. //原来设置
  95. $r[do_loginauth]=$ecms_config['esafe']['loginauth'];
  96. $r[do_enloginauth]=$ecms_config['esafe']['enloginauth'];
  97. $r[do_ecookiernd]=$ecms_config['esafe']['ecookiernd'];
  98. $r[do_ckhloginip]=$ecms_config['esafe']['ckhloginip'];
  99. $r[do_ckhsession]=$ecms_config['esafe']['ckhsession'];
  100. $r[do_ckhanytime]=$ecms_config['esafe']['ckhanytime'];
  101. $r[do_theloginlog]=$ecms_config['esafe']['theloginlog'];
  102. $r[do_thedolog]=$ecms_config['esafe']['thedolog'];
  103. $r[do_ckfromurl]=$ecms_config['esafe']['ckfromurl'];
  104. $r[do_ckhash]=$ecms_config['esafe']['ckhash'];
  105. $r[do_ckhashename]=$ecms_config['esafe']['ckhashename'];
  106. $r[do_ckhashrname]=$ecms_config['esafe']['ckhashrname'];
  107. $r[do_ckhuseragent]=$ecms_config['esafe']['ckhuseragent'];
  108. $r[phome_cookiedomain]=$ecms_config['cks']['ckdomain'];
  109. $r[phome_cookiepath]=$ecms_config['cks']['ckpath'];
  110. $r[phome_cookiehttponly]=$ecms_config['cks']['ckhttponly'];
  111. $r[phome_cookiesecure]=$ecms_config['cks']['cksecure'];
  112. $r[phome_cookievarpre]=$ecms_config['cks']['ckvarpre'];
  113. $r[phome_cookieadminvarpre]=$ecms_config['cks']['ckadminvarpre'];
  114. $r[phome_cookieckrnd]=$ecms_config['cks']['ckrnd'];
  115. $r[phome_cookieckrndtwo]=$ecms_config['cks']['ckrndtwo'];
  116. $r[phome_cookieckrndthree]=$ecms_config['cks']['ckrndthree'];
  117. $r[phome_cookieckrndfour]=$ecms_config['cks']['ckrndfour'];
  118. $r[phome_cookieckrndfive]=$ecms_config['cks']['ckrndfive'];
  119. $string=ReturnSettingString($r);
  120. GetSettingConfig($string);
  121. //操作日志
  122. insert_dolog('');
  123. if(($r[efw_open]&&!$ecms_config['fw']['eopen'])||$ecms_config['fw']['epass']!=$r[efw_pass]||$ecms_config['fw']['adminckpassvar']!=$r[efw_adminckpassvar]||$ecms_config['fw']['adminckpassval']!=$r[efw_adminckpassval])
  124. {
  125. printerror('SetFirewallSuccessLogin','../index.php');
  126. }
  127. printerror('SetFirewallSuccess','SetFirewall.php'.hReturnEcmsHashStrHref2(1));
  128. }
  129. //安全设置
  130. function SetSafe($add,$userid,$username){
  131. global $ecms_config;
  132. $r[do_loginauth]=$add[loginauth];
  133. $r[do_enloginauth]=(int)$add[enloginauth];
  134. $r[do_ecookiernd]=$add[ecookiernd];
  135. $r[do_ckhloginip]=(int)$add[ckhloginip];
  136. $r[do_ckhsession]=(int)$add[ckhsession];
  137. $r[do_ckhanytime]=(int)$add[ckhanytime];
  138. $r[do_theloginlog]=(int)$add[theloginlog];
  139. $r[do_thedolog]=(int)$add[thedolog];
  140. $r[do_ckfromurl]=(int)$add[ckfromurl];
  141. $r[do_ckhash]=(int)$add[ckhash];
  142. $r[do_ckhashename]=$add[ckhashename];
  143. $r[do_ckhashrname]=$add[ckhashrname];
  144. $r[do_ckhuseragent]=$add[ckhuseragent];
  145. $r[phome_cookiedomain]=$add[cookiedomain];
  146. $r[phome_cookiepath]=$add[cookiepath];
  147. $r[phome_cookiehttponly]=(int)$add[ckhttponly];
  148. $r[phome_cookiesecure]=(int)$add[cksecure];
  149. $r[phome_cookievarpre]=$add[cookievarpre];
  150. $r[phome_cookieadminvarpre]=$add[cookieadminvarpre];
  151. $r[phome_cookieckrnd]=$add[cookieckrnd];
  152. $r[phome_cookieckrndtwo]=$add[cookieckrndtwo];
  153. $r[phome_cookieckrndthree]=$add[cookieckrndthree];
  154. $r[phome_cookieckrndfour]=$add[cookieckrndfour];
  155. $r[phome_cookieckrndfive]=$add[cookieckrndfive];
  156. //原来设置
  157. $r[efw_open]=$ecms_config['fw']['eopen'];
  158. $r[efw_pass]=$ecms_config['fw']['epass'];
  159. $r[efw_adminloginurl]=$ecms_config['fw']['adminloginurl'];
  160. $r[efw_adminhour]=$ecms_config['fw']['adminhour'];
  161. $r[efw_adminweek]=$ecms_config['fw']['adminweek'];
  162. $r[efw_adminckpassvar]=$ecms_config['fw']['adminckpassvar'];
  163. $r[efw_adminckpassval]=$ecms_config['fw']['adminckpassval'];
  164. $r[efw_cleargettext]=$ecms_config['fw']['cleargettext'];
  165. $string=ReturnSettingString($r);
  166. GetSettingConfig($string);
  167. //操作日志
  168. insert_dolog('');
  169. if($ecms_config['esafe']['ecookiernd']!=$r[do_ecookiernd]||$ecms_config['cks']['ckadminvarpre']!=$r[phome_cookieadminvarpre]||$ecms_config['esafe']['ckhanytime']!=$r[do_ckhanytime]||$ecms_config['esafe']['ckhashename']!=$r[do_ckhashename]||$ecms_config['esafe']['ckhashrname']!=$r[do_ckhashrname])
  170. {
  171. printerror('SetSafeSuccessLogin','../index.php');
  172. }
  173. printerror('SetSafeSuccess','SetSafe.php'.hReturnEcmsHashStrHref2(1));
  174. }
  175. ?>