PageRenderTime 73ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/e/class/connect.php

https://github.com/westeast/xwdede
PHP | 2568 lines | 2249 code | 138 blank | 181 comment | 212 complexity | 6e84914860578e9985ef65344e46b040 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. error_reporting(E_ALL ^ E_NOTICE);
  3. define('InEmpireCMS',TRUE);
  4. define('ECMS_PATH',substr(dirname(__FILE__),0,-7));
  5. define('MAGIC_QUOTES_GPC',function_exists('get_magic_quotes_gpc')&&get_magic_quotes_gpc());
  6. $public_r=array();
  7. $emod_pubr=array();
  8. $etable_r=array();
  9. $emod_r=array();
  10. $notcj_r=array();
  11. $fun_r=array();
  12. $message_r=array();
  13. $qmessage_r=array();
  14. $enews_r=array();
  15. $class_r=array();
  16. $class_zr=array();
  17. $class_tr=array();
  18. $eyh_r=array();
  19. $schalltb_r=array();
  20. $level_r=array();
  21. $r=array();
  22. $addr=array();
  23. $search='';
  24. $start=0;
  25. $addgethtmlpath='';
  26. $editor=0;
  27. $navinfor=array();
  28. $navclassid='';
  29. $navnewsid='';
  30. $formattxt='';
  31. $link='';
  32. $efileftp='';
  33. $efileftp_fr=array();
  34. $efileftp_dr=array();
  35. $doetran=0;
  36. require_once ECMS_PATH.'e/class/config.php';
  37. if(!defined('EmpireCMSConfig'))
  38. {
  39. exit();
  40. }
  41. //超时设置
  42. if($public_r['php_outtime'])
  43. {
  44. @set_time_limit($public_r['php_outtime']);
  45. }
  46. //页面编码
  47. if($phome_headercharset==1)
  48. {
  49. if($phome_ecms_charver=='gb2312'||$phome_ecms_charver=='big5'||$phome_ecms_charver=='utf-8')
  50. {
  51. @header('Content-Type: text/html; charset='.$phome_ecms_charver);
  52. }
  53. }
  54. //时区
  55. if(function_exists('date_default_timezone_set'))
  56. {
  57. @date_default_timezone_set("PRC");
  58. }
  59. //禁止IP
  60. eCheckAccessIp(0);
  61. if(defined('EmpireCMSAdmin'))
  62. {
  63. eCheckAccessIp(1);//禁止IP
  64. //FireWall
  65. if(!empty($efw_open))
  66. {
  67. DoEmpireCMSFireWall();
  68. }
  69. }
  70. else
  71. {
  72. if(!empty($public_r['closeqdt']))
  73. {
  74. echo $public_r['closeqdtmsg'];
  75. exit();
  76. }
  77. }
  78. //--------------- 数据库 ---------------
  79. function db_connect(){
  80. global $phome_db_server,$phome_db_username,$phome_db_password,$phome_db_dbname,$phome_db_port,$phome_db_char,$phome_use_dbver;
  81. $dblocalhost=$phome_db_server;
  82. //端口
  83. if($phome_db_port)
  84. {
  85. $dblocalhost.=":".$phome_db_port;
  86. }
  87. $link=@mysql_connect($dblocalhost,$phome_db_username,$phome_db_password);
  88. if(!$link)
  89. {
  90. echo"Cann't connect to DB!";
  91. exit();
  92. }
  93. //编码
  94. if($phome_use_dbver>='4.1')
  95. {
  96. $q='';
  97. if($phome_db_char)
  98. {
  99. $q='character_set_connection='.$phome_db_char.',character_set_results='.$phome_db_char.',character_set_client=binary';
  100. }
  101. if($phome_use_dbver>='5.0')
  102. {
  103. $q.=(empty($q)?'':',').'sql_mode=\'\'';
  104. }
  105. if($q)
  106. {
  107. @mysql_query('SET '.$q);
  108. }
  109. }
  110. @mysql_select_db($phome_db_dbname);
  111. return $link;
  112. }
  113. //设置编码
  114. function DoSetDbChar($dbchar){
  115. if($dbchar&&$dbchar!='auto')
  116. {
  117. //@mysql_query("set names '".$dbchar."';");
  118. @mysql_query('set character_set_connection='.$dbchar.',character_set_results='.$dbchar.',character_set_client=binary;');
  119. }
  120. }
  121. function db_close(){
  122. global $link;
  123. if($link)
  124. {
  125. @mysql_close($link);
  126. }
  127. }
  128. //--------------- 公共 ---------------
  129. //设置COOKIE
  130. function esetcookie($var,$val,$life=0,$ecms=0){
  131. global $phome_cookiedomain,$phome_cookiepath,$phome_cookievarpre,$phome_cookieadminvarpre;
  132. $varpre=empty($ecms)?$phome_cookievarpre:$phome_cookieadminvarpre;
  133. return setcookie($varpre.$var,$val,$life,$phome_cookiepath,$phome_cookiedomain);
  134. }
  135. //返回cookie
  136. function getcvar($var,$ecms=0){
  137. global $phome_cookievarpre,$phome_cookieadminvarpre;
  138. $tvar=empty($ecms)?$phome_cookievarpre.$var:$phome_cookieadminvarpre.$var;
  139. return $_COOKIE[$tvar];
  140. }
  141. //错误提示
  142. function printerror($error="",$gotourl="",$ecms=0,$noautourl=0,$novar=0){
  143. global $empire,$editor,$ecmslang,$public_r;
  144. if($editor==1){$a="../";}
  145. elseif($editor==2){$a="../../";}
  146. elseif($editor==3){$a="../../../";}
  147. else{$a="";}
  148. if($ecms==1||$ecms==9)
  149. {
  150. $a=ECMS_PATH.'e/data/';
  151. }
  152. if(strstr($gotourl,"(")||empty($gotourl))
  153. {
  154. $gotourl_js="history.go(-1)";
  155. $gotourl="javascript:history.go(-1)";
  156. }
  157. else
  158. {$gotourl_js="self.location.href='$gotourl';";}
  159. if(empty($error))
  160. {$error="DbError";}
  161. if($ecms==9)//前台弹出对话框
  162. {
  163. @include $a.LoadLang("pub/q_message.php");
  164. $error=empty($novar)?$qmessage_r[$error]:$error;
  165. echo"<script>alert('".$error."');".$gotourl_js."</script>";
  166. db_close();
  167. $empire=null;
  168. exit();
  169. }
  170. elseif($ecms==8)//后台弹出对话框
  171. {
  172. @include $a.LoadLang("pub/message.php");
  173. $error=empty($novar)?$message_r[$error]:$error;
  174. echo"<script>alert('".$error."');".$gotourl_js."</script>";
  175. db_close();
  176. $empire=null;
  177. exit();
  178. }
  179. elseif($ecms==0)
  180. {
  181. @include $a.LoadLang("pub/message.php");
  182. $error=empty($novar)?$message_r[$error]:$error;
  183. @include($a."message.php");
  184. }
  185. else
  186. {
  187. @include $a.LoadLang("pub/q_message.php");
  188. $error=empty($novar)?$qmessage_r[$error]:$error;
  189. @include($a."../message/index.php");
  190. }
  191. db_close();
  192. $empire=null;
  193. exit();
  194. }
  195. //错误提示2:直接文字
  196. function printerror2($error='',$gotourl='',$ecms=0,$noautourl=0){
  197. global $empire,$public_r;
  198. if(strstr($gotourl,"(")||empty($gotourl))
  199. {
  200. $gotourl_js="history.go(-1)";
  201. $gotourl="javascript:history.go(-1)";
  202. }
  203. else
  204. {$gotourl_js="self.location.href='$gotourl';";}
  205. if($ecms==9)//弹出对话框
  206. {
  207. echo"<script>alert('".$error."');".$gotourl_js."</script>";
  208. }
  209. else
  210. {
  211. @include(ECMS_PATH.'e/message/index.php');
  212. }
  213. db_close();
  214. exit();
  215. }
  216. //ajax错误提示
  217. function ajax_printerror($result='',$ajaxarea='ajaxarea',$error='',$ecms=0,$novar=0){
  218. global $empire,$editor,$ecmslang,$public_r;
  219. if($editor==1){$a="../";}
  220. elseif($editor==2){$a="../../";}
  221. elseif($editor==3){$a="../../../";}
  222. else{$a="";}
  223. if($ecms==1)
  224. {
  225. $a=ECMS_PATH.'e/data/';
  226. }
  227. if($ecms==0)
  228. {
  229. @include $a.LoadLang("pub/message.php");
  230. $error=empty($novar)?$message_r[$error]:$error;
  231. }
  232. else
  233. {
  234. @include $a.LoadLang("pub/q_message.php");
  235. $error=empty($novar)?$qmessage_r[$error]:$error;
  236. }
  237. if(empty($ajaxarea))
  238. {
  239. $ajaxarea='ajaxarea';
  240. }
  241. $string=$result.'|'.$ajaxarea.'|'.$error;
  242. echo $string;
  243. db_close();
  244. $empire=null;
  245. exit();
  246. }
  247. //编码转换
  248. function DoIconvVal($code,$targetcode,$str,$inc=0){
  249. global $editor;
  250. if($editor==1){$a="../";}
  251. elseif($editor==2){$a="../../";}
  252. elseif($editor==3){$a="../../../";}
  253. else{$a="";}
  254. if($inc)
  255. {
  256. @include_once(ECMS_PATH."e/class/doiconv.php");
  257. }
  258. $iconv=new Chinese($a);
  259. $str=$iconv->Convert($code,$targetcode,$str);
  260. return $str;
  261. }
  262. //模板表转换
  263. function GetTemptb($temptb){
  264. global $public_r,$ecmsdeftempid,$dbtbpre;
  265. if(!empty($ecmsdeftempid))
  266. {
  267. $tempid=$ecmsdeftempid;
  268. }
  269. else
  270. {
  271. $tempid=$public_r['deftempid'];
  272. }
  273. if(!empty($tempid)&&$tempid!=1)
  274. {
  275. $en="_".$tempid;
  276. }
  277. return $dbtbpre.$temptb.$en;
  278. }
  279. //返回操作模板表
  280. function GetDoTemptb($temptb,$gid){
  281. global $dbtbpre;
  282. if(!empty($gid)&&$gid!=1)
  283. {
  284. $en="_".$gid;
  285. }
  286. return $dbtbpre.$temptb.$en;
  287. }
  288. //返回当前使用模板组ID
  289. function GetDoTempGid(){
  290. global $ecmsdeftempid,$public_r;
  291. if($ecmsdeftempid)
  292. {
  293. $gid=$ecmsdeftempid;
  294. }
  295. elseif($public_r['deftempid'])
  296. {
  297. $gid=$public_r['deftempid'];
  298. }
  299. else
  300. {
  301. $gid=1;
  302. }
  303. return $gid;
  304. }
  305. //导入语言包
  306. function LoadLang($file){
  307. global $ecmslang;
  308. return "../data/language/".$ecmslang."/".$file;
  309. }
  310. //取得IP
  311. function egetip(){
  312. if(getenv('HTTP_CLIENT_IP')&&strcasecmp(getenv('HTTP_CLIENT_IP'),'unknown'))
  313. {
  314. $ip=getenv('HTTP_CLIENT_IP');
  315. }
  316. elseif(getenv('HTTP_X_FORWARDED_FOR')&&strcasecmp(getenv('HTTP_X_FORWARDED_FOR'),'unknown'))
  317. {
  318. $ip=getenv('HTTP_X_FORWARDED_FOR');
  319. }
  320. elseif(getenv('REMOTE_ADDR')&&strcasecmp(getenv('REMOTE_ADDR'),'unknown'))
  321. {
  322. $ip=getenv('REMOTE_ADDR');
  323. }
  324. elseif(isset($_SERVER['REMOTE_ADDR'])&&$_SERVER['REMOTE_ADDR']&&strcasecmp($_SERVER['REMOTE_ADDR'],'unknown'))
  325. {
  326. $ip=$_SERVER['REMOTE_ADDR'];
  327. }
  328. $ip=RepPostVar(preg_replace("/^([\d\.]+).*/","\\1",$ip));
  329. return $ip;
  330. }
  331. //返回地址
  332. function DoingReturnUrl($url,$from=''){
  333. if(empty($from))
  334. {
  335. return $url;
  336. }
  337. elseif($from==9)
  338. {
  339. $from=$_SERVER['HTTP_REFERER']?$_SERVER['HTTP_REFERER']:$url;
  340. }
  341. return $from;
  342. }
  343. //参数处理函数
  344. function RepPostVar($val){
  345. if($val!=addslashes($val))
  346. {
  347. exit();
  348. }
  349. CkPostStrChar($val);
  350. $val=str_replace(" ","",$val);
  351. $val=str_replace("%20","",$val);
  352. $val=str_replace("%27","",$val);
  353. $val=str_replace("*","",$val);
  354. $val=str_replace("'","",$val);
  355. $val=str_replace("\"","",$val);
  356. $val=str_replace("/","",$val);
  357. $val=str_replace(";","",$val);
  358. $val=str_replace("#","",$val);
  359. $val=str_replace("--","",$val);
  360. $val=RepPostStr($val,1);
  361. $val=addslashes($val);
  362. //FireWall
  363. FWClearGetText($val);
  364. return $val;
  365. }
  366. //参数处理函数2
  367. function RepPostVar2($val){
  368. if($val!=addslashes($val))
  369. {
  370. exit();
  371. }
  372. CkPostStrChar($val);
  373. $val=str_replace("%20","",$val);
  374. $val=str_replace("%27","",$val);
  375. $val=str_replace("*","",$val);
  376. $val=str_replace("'","",$val);
  377. $val=str_replace("\"","",$val);
  378. $val=str_replace("/","",$val);
  379. $val=str_replace(";","",$val);
  380. $val=str_replace("#","",$val);
  381. $val=str_replace("--","",$val);
  382. $val=RepPostStr($val,1);
  383. $val=addslashes($val);
  384. //FireWall
  385. FWClearGetText($val);
  386. return $val;
  387. }
  388. //处理提交字符
  389. function RepPostStr($val,$ecms=0){
  390. $val=htmlspecialchars($val,ENT_QUOTES);
  391. if($ecms==0)
  392. {
  393. CkPostStrChar($val);
  394. $val=AddAddsData($val);
  395. //FireWall
  396. FWClearGetText($val);
  397. }
  398. return $val;
  399. }
  400. //处理提交字符2
  401. function RepPostStr2($val){
  402. CkPostStrChar($val);
  403. $val=AddAddsData($val);
  404. //FireWall
  405. FWClearGetText($val);
  406. return $val;
  407. }
  408. //处理编码字符
  409. function CkPostStrChar($val){
  410. if(substr($val,-1)=="\\")
  411. {
  412. exit();
  413. }
  414. }
  415. //返回转义
  416. function egetzy($n='2'){
  417. if($n=='rn')
  418. {
  419. $str="\r\n";
  420. }
  421. elseif($n=='n')
  422. {
  423. $str="\n";
  424. }
  425. elseif($n=='r')
  426. {
  427. $str="\r";
  428. }
  429. elseif($n=='t')
  430. {
  431. $str="\t";
  432. }
  433. elseif($n=='syh')
  434. {
  435. $str="\\\"";
  436. }
  437. elseif($n=='dyh')
  438. {
  439. $str="\'";
  440. }
  441. else
  442. {
  443. for($i=0;$i<$n;$i++)
  444. {
  445. $str.="\\";
  446. }
  447. }
  448. return $str;
  449. }
  450. //取得文件扩展名
  451. function GetFiletype($filename){
  452. $filer=explode(".",$filename);
  453. $count=count($filer)-1;
  454. return strtolower(".".RepGetFiletype($filer[$count]));
  455. }
  456. function RepGetFiletype($filetype){
  457. $filetype=str_replace('|','_',$filetype);
  458. $filetype=str_replace(',','_',$filetype);
  459. $filetype=str_replace('.','_',$filetype);
  460. return $filetype;
  461. }
  462. //取得文件名
  463. function GetFilename($filename){
  464. if(strstr($filename,"\\"))
  465. {
  466. $exp="\\";
  467. }
  468. else
  469. {
  470. $exp='/';
  471. }
  472. $filer=explode($exp,$filename);
  473. $count=count($filer)-1;
  474. return $filer[$count];
  475. }
  476. //返回目录函数
  477. function eReturnCPath($path,$ypath=''){
  478. if(strstr($path,'..')||strstr($path,"\\")||strstr($path,'%')||strstr($path,':'))
  479. {
  480. return $ypath;
  481. }
  482. return $path;
  483. }
  484. //字符截取函数
  485. function sub($string,$start=0,$length,$mode=false,$dot=''){
  486. global $phome_ecms_charver;
  487. $strlen=strlen($string);
  488. if($strlen<=$length)
  489. {
  490. return $string;
  491. }
  492. $string = str_replace(array('&nbsp;','&amp;','&quot;','&lt;','&gt;','&#039;'), array(' ','&','"','<','>',"'"), $string);
  493. $strcut = '';
  494. if(strtolower($phome_ecms_charver) == 'utf-8') {
  495. $n = $tn = $noc = 0;
  496. while($n < $strlen) {
  497. $t = ord($string[$n]);
  498. if($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) {
  499. $tn = 1; $n++; $noc++;
  500. } elseif(194 <= $t && $t <= 223) {
  501. $tn = 2; $n += 2; $noc += 2;
  502. } elseif(224 <= $t && $t < 239) {
  503. $tn = 3; $n += 3; $noc += 2;
  504. } elseif(240 <= $t && $t <= 247) {
  505. $tn = 4; $n += 4; $noc += 2;
  506. } elseif(248 <= $t && $t <= 251) {
  507. $tn = 5; $n += 5; $noc += 2;
  508. } elseif($t == 252 || $t == 253) {
  509. $tn = 6; $n += 6; $noc += 2;
  510. } else {
  511. $n++;
  512. }
  513. if($noc >= $length) {
  514. break;
  515. }
  516. }
  517. if($noc > $length) {
  518. $n -= $tn;
  519. }
  520. $strcut = substr($string, 0, $n);
  521. } else {
  522. for($i = 0; $i < $length; $i++) {
  523. $strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
  524. }
  525. }
  526. $strcut = str_replace(array('&','"','<','>',"'"), array('&amp;','&quot;','&lt;','&gt;','&#039;'), $strcut);
  527. return $strcut.$dot;
  528. }
  529. //截取字数
  530. function esub($string,$length,$dot=''){
  531. return sub($string,0,$length,false,$dot);
  532. }
  533. //取得随机数
  534. function make_password($pw_length){
  535. $low_ascii_bound=50;
  536. $upper_ascii_bound=122;
  537. $notuse=array(58,59,60,61,62,63,64,73,79,91,92,93,94,95,96,108,111);
  538. while($i<$pw_length)
  539. {
  540. mt_srand((double)microtime()*1000000);
  541. $randnum=mt_rand($low_ascii_bound,$upper_ascii_bound);
  542. if(!in_array($randnum,$notuse))
  543. {
  544. $password1=$password1.chr($randnum);
  545. $i++;
  546. }
  547. }
  548. return $password1;
  549. }
  550. //取得随机数(数字)
  551. function no_make_password($pw_length){
  552. $low_ascii_bound=48;
  553. $upper_ascii_bound=57;
  554. $notuse=array(58,59,60,61,62,63,64,73,79,91,92,93,94,95,96,108,111);
  555. while($i<$pw_length)
  556. {
  557. mt_srand((double)microtime()*1000000);
  558. $randnum=mt_rand($low_ascii_bound,$upper_ascii_bound);
  559. if(!in_array($randnum,$notuse))
  560. {
  561. $password1=$password1.chr($randnum);
  562. $i++;
  563. }
  564. }
  565. return $password1;
  566. }
  567. //颜色转RGB
  568. function ToReturnRGB($rgb){
  569. $rgb=str_replace('#','',htmlspecialchars($rgb));
  570. return array(
  571. base_convert(substr($rgb,0,2),16,10),
  572. base_convert(substr($rgb,2,2),16,10),
  573. base_convert(substr($rgb,4,2),16,10)
  574. );
  575. }
  576. //前台分页
  577. function page1($num,$line,$page_line,$start,$page,$search){
  578. global $fun_r;
  579. if($num<=$line)
  580. {
  581. return '';
  582. }
  583. $search=htmlspecialchars($search,ENT_QUOTES);
  584. $url=$_SERVER['PHP_SELF'].'?page';
  585. $snum=2;//最小页数
  586. $totalpage=ceil($num/$line);//取得总页数
  587. $firststr='';
  588. //上一页
  589. if($page<>0)
  590. {
  591. $toppage='<a href="'.$url.'=0'.$search.'">'.$fun_r['startpage'].'</a>';
  592. $pagepr=$page-1;
  593. $prepage='<a href="'.$url.'='.$pagepr.$search.'">'.$fun_r['pripage'].'</a>';
  594. }
  595. //下一页
  596. if($page!=$totalpage-1)
  597. {
  598. $pagenex=$page+1;
  599. $nextpage='<a href="'.$url.'='.$pagenex.$search.'">'.$fun_r['nextpage'].'</a>';
  600. $lastpage='<a href="'.$url.'='.($totalpage-1).$search.'">'.$fun_r['lastpage'].'</a>';
  601. }
  602. $starti=$page-$snum<0?0:$page-$snum;
  603. $no=0;
  604. for($i=$starti;$i<$totalpage&&$no<$page_line;$i++)
  605. {
  606. $no++;
  607. if($page==$i)
  608. {
  609. $is_1="<b>";
  610. $is_2="</b>";
  611. }
  612. else
  613. {
  614. $is_1='<a href="'.$url.'='.$i.$search.'">';
  615. $is_2="</a>";
  616. }
  617. $pagenum=$i+1;
  618. $returnstr.="".$is_1.$pagenum.$is_2;
  619. }
  620. $returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage;
  621. return $returnstr;
  622. }
  623. //时间转换函数
  624. function to_time($datetime){
  625. if(strlen($datetime)==10)
  626. {
  627. $datetime.=" 00:00:00";
  628. }
  629. $r=explode(" ",$datetime);
  630. $t=explode("-",$r[0]);
  631. $k=explode(":",$r[1]);
  632. $dbtime=@mktime($k[0],$k[1],$k[2],$t[1],$t[2],$t[0]);
  633. return $dbtime;
  634. }
  635. //时期转日期
  636. function date_time($time,$format="Y-m-d H:i:s"){
  637. $threadtime=date($format,$time);
  638. return $threadtime;
  639. }
  640. //格式化日期
  641. function format_datetime($newstime,$format){
  642. if($newstime=="0000-00-00 00:00:00")
  643. {return $newstime;}
  644. $time=is_numeric($newstime)?$newstime:to_time($newstime);
  645. $newdate=date_time($time,$format);
  646. return $newdate;
  647. }
  648. //时间转换函数
  649. function to_date($date){
  650. $date.=" 00:00:00";
  651. $r=explode(" ",$date);
  652. $t=explode("-",$r[0]);
  653. $k=explode(":",$r[1]);
  654. $dbtime=@mktime($k[0],$k[1],$k[2],$t[1],$t[2],$t[0]);
  655. return $dbtime;
  656. }
  657. //选择时间
  658. function ToChangeTime($time,$day){
  659. $truetime=$time-$day*24*3600;
  660. $date=date_time($truetime,"Y-m-d");
  661. return $date;
  662. }
  663. //删除文件
  664. function DelFiletext($filename){
  665. @unlink($filename);
  666. }
  667. //取得文件内容
  668. function ReadFiletext($filepath){
  669. $filepath=trim($filepath);
  670. $htmlfp=@fopen($filepath,"r");
  671. //远程
  672. if(strstr($filepath,"://"))
  673. {
  674. while($data=@fread($htmlfp,500000))
  675. {
  676. $string.=$data;
  677. }
  678. }
  679. //本地
  680. else
  681. {
  682. $string=@fread($htmlfp,@filesize($filepath));
  683. }
  684. @fclose($htmlfp);
  685. return $string;
  686. }
  687. //写文件
  688. function WriteFiletext($filepath,$string){
  689. global $public_r;
  690. $string=stripSlashes($string);
  691. $fp=@fopen($filepath,"w");
  692. @fputs($fp,$string);
  693. @fclose($fp);
  694. if(empty($public_r[filechmod]))
  695. {
  696. @chmod($filepath,0777);
  697. }
  698. }
  699. //写文件
  700. function WriteFiletext_n($filepath,$string){
  701. global $public_r;
  702. $fp=@fopen($filepath,"w");
  703. @fputs($fp,$string);
  704. @fclose($fp);
  705. if(empty($public_r[filechmod]))
  706. {
  707. @chmod($filepath,0777);
  708. }
  709. }
  710. //标题属性后
  711. function DoTitleFont($titlefont,$title){
  712. if(empty($titlefont))
  713. {
  714. return $title;
  715. }
  716. $r=explode(',',$titlefont);
  717. if(!empty($r[0]))
  718. {
  719. $title="<font color='".$r[0]."'>".$title."</font>";
  720. }
  721. if(empty($r[1]))
  722. {return $title;}
  723. //粗体
  724. if(strstr($r[1],"b"))
  725. {$title="<strong>".$title."</strong>";}
  726. //斜体
  727. if(strstr($r[1],"i"))
  728. {$title="<i>".$title."</i>";}
  729. //删除线
  730. if(strstr($r[1],"s"))
  731. {$title="<s>".$title."</s>";}
  732. return $title;
  733. }
  734. //替换全角逗号
  735. function DoReplaceQjDh($text){
  736. return str_replace(',',',',$text);
  737. }
  738. //建立目录函数
  739. function DoMkdir($path){
  740. global $public_r;
  741. //不存在则建立
  742. if(!file_exists($path))
  743. {
  744. //安全模式
  745. if($public_r[phpmode])
  746. {
  747. $pr[0]=$path;
  748. FtpMkdir($ftpid,$pr,0777);
  749. $mk=1;
  750. }
  751. else
  752. {
  753. $mk=@mkdir($path,0777);
  754. @chmod($path,0777);
  755. }
  756. if(empty($mk))
  757. {
  758. echo $path;
  759. printerror("CreatePathFail","history.go(-1)");
  760. }
  761. }
  762. return true;
  763. }
  764. //建立上级目录
  765. function DoFileMkDir($file){
  766. $path=dirname($file.'empirecms.txt');
  767. DoMkdir($path);
  768. }
  769. //设置上传文件权限
  770. function DoChmodFile($file){
  771. global $public_r;
  772. if($public_r['filechmod']!=1)
  773. {
  774. @chmod($file,0777);
  775. }
  776. }
  777. //返回栏目链接字符串
  778. function ReturnClassLink($classid){
  779. global $class_r,$public_r,$fun_r;
  780. if(empty($class_r[$classid][featherclass]))
  781. {$class_r[$classid][featherclass]="|";}
  782. $r=explode("|",$class_r[$classid][featherclass].$classid."|");
  783. $string="<a href=\"".$public_r[newsurl]."\">".$fun_r['index']."</a>";
  784. for($i=1;$i<count($r)-1;$i++)
  785. {
  786. //静态列表
  787. if(empty($class_r[$r[$i]][listdt]))
  788. {
  789. //无绑定域名
  790. if(empty($class_r[$r[$i]][classurl]))
  791. {$url=$public_r[newsurl].$class_r[$r[$i]][classpath]."/";}
  792. else
  793. {$url=$class_r[$r[$i]][classurl];}
  794. }
  795. else
  796. {
  797. $url=$public_r[newsurl]."e/action/ListInfo/?classid=$r[$i]";
  798. }
  799. $string.="&nbsp;".$public_r[navfh]."&nbsp;<a href=\"".$url."\">".$class_r[$r[$i]][classname]."</a>";
  800. }
  801. return $string;
  802. }
  803. //返回专题链接字符串
  804. function ReturnZtLink($ztid){
  805. global $class_zr,$public_r,$fun_r;
  806. $string="<a href=\"".$public_r[newsurl]."\">".$fun_r['index']."</a>";
  807. //无绑定域名
  808. if(empty($class_zr[$ztid][zturl]))
  809. {$url=$public_r[newsurl].$class_zr[$ztid][ztpath]."/";}
  810. else
  811. {$url=$class_zr[$ztid][zturl];}
  812. $string.="&nbsp;".$public_r[navfh]."&nbsp;<a href=\"".$url."\">".$class_zr[$ztid][ztname]."</a>";
  813. return $string;
  814. }
  815. //返回单页链接字符串
  816. function ReturnUserPLink($title,$titleurl){
  817. global $public_r,$fun_r;
  818. $string='<a href="'.$public_r[newsurl].'">'.$fun_r['index'].'</a>&nbsp;'.$public_r[navfh].'&nbsp;'.$title;
  819. return $string;
  820. }
  821. //返回标题链接
  822. function sys_ReturnBqTitleLink($r){
  823. global $public_r,$class_r;
  824. if(empty($r[titleurl]))
  825. {
  826. if($class_r[$r[classid]][showdt]==1)//动态生成
  827. {
  828. $titleurl=$public_r[newsurl]."e/action/ShowInfo/?classid=$r[classid]&id=$r[id]";
  829. return $titleurl;
  830. }
  831. elseif($class_r[$r[classid]][showdt]==2)
  832. {
  833. $titleurl=$public_r[newsurl]."e/action/ShowInfo.php?classid=$r[classid]&id=$r[id]";
  834. return $titleurl;
  835. }
  836. if($class_r[$r[classid]][filename]==3)
  837. {
  838. $filename=ReturnInfoSPath($r[filename]);
  839. }
  840. else
  841. {
  842. $filetype=$r[groupid]?'.php':$class_r[$r[classid]][filetype];
  843. $filename=$r[filename].$filetype;
  844. }
  845. $iclasspath=ReturnSaveInfoPath($r[classid],$r[id]);
  846. $newspath=empty($r[newspath])?'':$r[newspath]."/";
  847. if($class_r[$r[classid]][classurl]&&$class_r[$r[classid]][ipath]=='')//域名
  848. {
  849. $titleurl=$class_r[$r[classid]][classurl]."/".$newspath.$filename;
  850. }
  851. else
  852. {
  853. $titleurl=$public_r[newsurl].$iclasspath.$newspath.$filename;
  854. }
  855. }
  856. else
  857. {
  858. if($public_r['opentitleurl'])
  859. {
  860. $titleurl=$r[titleurl];
  861. }
  862. else
  863. {
  864. $titleurl=$public_r[newsurl]."e/public/jump/?classid=".$r[classid]."&id=".$r[id]."&url=".urlencode($r[titleurl]);
  865. }
  866. }
  867. return $titleurl;
  868. }
  869. //返回标题链接
  870. function sys_ReturnBqAutoTitleLink($r){
  871. global $public_r,$class_r;
  872. if(empty($r[titleurl]))
  873. {
  874. if($class_r[$r[classid]][showdt]==2)
  875. {
  876. $titleurl=$public_r[newsurl]."e/action/ShowInfo.php?classid=$r[classid]&id=$r[id]";
  877. return $titleurl;
  878. }
  879. if($class_r[$r[classid]][filename]==3)
  880. {
  881. $filename=ReturnInfoSPath($r[filename]);
  882. }
  883. else
  884. {
  885. $filetype=$r[groupid]?'.php':$class_r[$r[classid]][filetype];
  886. $filename=$r[filename].$filetype;
  887. }
  888. $iclasspath=ReturnSaveInfoPath($r[classid],$r[id]);
  889. $newspath=empty($r[newspath])?'':$r[newspath]."/";
  890. if($class_r[$r[classid]][classurl]&&$class_r[$r[classid]][ipath]=='')//域名
  891. {
  892. $titleurl=$class_r[$r[classid]][classurl]."/".$newspath.$filename;
  893. }
  894. else
  895. {
  896. $titleurl=$public_r[newsurl].$iclasspath.$newspath.$filename;
  897. }
  898. }
  899. else
  900. {
  901. if($public_r['opentitleurl'])
  902. {
  903. $titleurl=$r[titleurl];
  904. }
  905. else
  906. {
  907. $titleurl=$public_r[newsurl]."e/public/jump/?classid=".$r[classid]."&id=".$r[id]."&url=".urlencode($r[titleurl]);
  908. }
  909. }
  910. return $titleurl;
  911. }
  912. //返回内容页地址前缀
  913. function ReturnInfoPageQz($r){
  914. global $public_r,$class_r;
  915. $ret_r['titleurl']='';
  916. $ret_r['filetype']='';
  917. $ret_r['nametype']=0;
  918. //动态页面
  919. if($class_r[$r[classid]][showdt]==2)
  920. {
  921. $ret_r['titleurl']=$public_r[newsurl]."e/action/ShowInfo.php?classid=$r[classid]&id=$r[id]";
  922. $ret_r['filetype']='';
  923. $ret_r['nametype']=1;
  924. return $ret_r;
  925. }
  926. //静态页面
  927. $ret_r['filetype']=$r[groupid]?'.php':$class_r[$r[classid]][filetype];
  928. $filename=$r[filename];
  929. $iclasspath=ReturnSaveInfoPath($r[classid],$r[id]);
  930. $newspath=empty($r[newspath])?'':$r[newspath]."/";
  931. if($class_r[$r[classid]][classurl]&&$class_r[$r[classid]][ipath]=='')//域名
  932. {
  933. $ret_r['titleurl']=$class_r[$r[classid]][classurl]."/".$newspath.$filename;
  934. }
  935. else
  936. {
  937. $ret_r['titleurl']=$public_r[newsurl].$iclasspath.$newspath.$filename;
  938. }
  939. return $ret_r;
  940. }
  941. //返回栏目链接
  942. function sys_ReturnBqClassname($r,$have_class=0){
  943. global $public_r,$class_r;
  944. if($have_class)
  945. {
  946. //外部栏目
  947. if($class_r[$r[classid]][wburl])
  948. {
  949. $classurl=$class_r[$r[classid]][wburl];
  950. }
  951. //动态列表
  952. elseif($class_r[$r[classid]][listdt])
  953. {
  954. $classurl=$public_r[newsurl]."e/action/ListInfo/?classid=$r[classid]";
  955. }
  956. elseif($class_r[$r[classid]][classurl])
  957. {
  958. $classurl=$class_r[$r[classid]][classurl];
  959. }
  960. else
  961. {
  962. $classurl=$public_r[newsurl].$class_r[$r[classid]][classpath]."/";
  963. }
  964. if(empty($class_r[$r[classid]][bname]))
  965. {$classname=$class_r[$r[classid]][classname];}
  966. else
  967. {$classname=$class_r[$r[classid]][bname];}
  968. $myadd="[<a href=".$classurl.">".$classname."</a>]";
  969. //只返回链接
  970. if($have_class==9)
  971. {$myadd=$classurl;}
  972. }
  973. else
  974. {$myadd="";}
  975. return $myadd;
  976. }
  977. //返回专题链接
  978. function sys_ReturnBqZtname($r){
  979. global $public_r,$class_zr;
  980. if($class_zr[$r[ztid]][zturl])
  981. {
  982. $zturl=$class_zr[$r[ztid]][zturl];
  983. }
  984. else
  985. {
  986. $zturl=$public_r[newsurl].$class_zr[$r[ztid]][ztpath]."/";
  987. }
  988. return $zturl;
  989. }
  990. //文件大小格式转换
  991. function ChTheFilesize($size){
  992. if($size>=1024*1024)//MB
  993. {
  994. $filesize=number_format($size/(1024*1024),2,'.','')." MB";
  995. }
  996. elseif($size>=1024)//KB
  997. {
  998. $filesize=number_format($size/1024,2,'.','')." KB";
  999. }
  1000. else
  1001. {
  1002. $filesize=$size." Bytes";
  1003. }
  1004. return $filesize;
  1005. }
  1006. //返回栏目自定义字段内容
  1007. function ReturnClassAddField($classid,$f){
  1008. global $empire,$dbtbpre,$navclassid;
  1009. if(empty($classid))
  1010. {
  1011. $classid=$navclassid;
  1012. }
  1013. $fr=$empire->fetch1("select ".$f." from {$dbtbpre}enewsclassadd where classid='$classid' limit 1");
  1014. if(strstr($f,','))
  1015. {
  1016. return $fr;
  1017. }
  1018. else
  1019. {
  1020. return $fr[$f];
  1021. }
  1022. }
  1023. //返回专题自定义字段内容
  1024. function ReturnZtAddField($classid,$f){
  1025. global $empire,$dbtbpre,$navclassid;
  1026. if(empty($classid))
  1027. {
  1028. $classid=$navclassid;
  1029. }
  1030. $fr=$empire->fetch1("select ".$f." from {$dbtbpre}enewsztadd where ztid='$classid' limit 1");
  1031. if(strstr($f,','))
  1032. {
  1033. return $fr;
  1034. }
  1035. else
  1036. {
  1037. return $fr[$f];
  1038. }
  1039. }
  1040. //返回扩展变量值
  1041. function ReturnPublicAddVar($myvar){
  1042. global $empire,$dbtbpre;
  1043. if(strstr($myvar,','))
  1044. {
  1045. $myvr=explode(',',$myvar);
  1046. $count=count($myvr);
  1047. for($i=0;$i<$count;$i++)
  1048. {
  1049. $v=$myvr[$i];
  1050. $vr=$empire->fetch1("select varvalue from {$dbtbpre}enewspubvar where myvar='$v' limit 1");
  1051. $ret_vr[$v]=$vr['varvalue'];
  1052. }
  1053. return $ret_vr;
  1054. }
  1055. else
  1056. {
  1057. $vr=$empire->fetch1("select varvalue from {$dbtbpre}enewspubvar where myvar='$myvar' limit 1");
  1058. return $vr['varvalue'];
  1059. }
  1060. }
  1061. //返回排序字段
  1062. function ReturnDoOrderF($mid,$orderby,$myorder){
  1063. global $emod_r;
  1064. $orderby=str_replace(',','',$orderby);
  1065. $orderf=',newstime,id,onclick,totaldown,plnum';
  1066. if(!empty($emod_r[$mid]['orderf']))
  1067. {
  1068. $orderf.=$emod_r[$mid]['orderf'];
  1069. }
  1070. else
  1071. {
  1072. $orderf.=',';
  1073. }
  1074. if(strstr($orderf,','.$orderby.','))
  1075. {
  1076. $rr['returnorder']=$orderby;
  1077. $rr['returnf']=$orderby;
  1078. }
  1079. else
  1080. {
  1081. $rr['returnorder']='newstime';
  1082. $rr['returnf']='newstime';
  1083. }
  1084. if(empty($myorder))
  1085. {
  1086. $rr['returnorder'].=' desc';
  1087. }
  1088. return $rr;
  1089. }
  1090. //返回置顶
  1091. function ReturnSetTopSql($ecms){
  1092. global $public_r;
  1093. if(empty($public_r['settop']))
  1094. {
  1095. return '';
  1096. }
  1097. $top='istop desc,';
  1098. if($ecms=='list')
  1099. {
  1100. if($public_r['settop']==1||$public_r['settop']==4||$public_r['settop']==5||$public_r['settop']==6)
  1101. {
  1102. return $top;
  1103. }
  1104. }
  1105. elseif($ecms=='bq')
  1106. {
  1107. if($public_r['settop']==2||$public_r['settop']==4||$public_r['settop']==5||$public_r['settop']==7)
  1108. {
  1109. return $top;
  1110. }
  1111. }
  1112. elseif($ecms=='js')
  1113. {
  1114. if($public_r['settop']==3||$public_r['settop']==4||$public_r['settop']==6||$public_r['settop']==7)
  1115. {
  1116. return $top;
  1117. }
  1118. }
  1119. return '';
  1120. }
  1121. //返回优化方案SQL
  1122. function ReturnYhSql($yhid,$yhvar){
  1123. global $eyh_r;
  1124. if(empty($yhid))
  1125. {
  1126. return '';
  1127. }
  1128. $query='';
  1129. if($eyh_r[$yhid][$yhvar])
  1130. {
  1131. $t=time()-($eyh_r[$yhid][$yhvar]*86400);
  1132. $query='newstime>'.$t.' and ';
  1133. }
  1134. return $query;
  1135. }
  1136. //返回查询字段
  1137. function ReturnSqlListF($mid){
  1138. global $emod_r;
  1139. if(empty($mid))
  1140. {
  1141. return '*';
  1142. }
  1143. $f='id,classid,onclick,newspath,keyboard,userid,username,ztid,checked,istop,truetime,ismember,userfen,isgood,titlefont,titleurl,filename,groupid,plnum,firsttitle,isqf,totaldown,closepl,lastdotime,infopfen,infopfennum,votenum,stb,ttid,infotags,ispic'.substr($emod_r[$mid]['listtempf'],0,-1);
  1144. return $f;
  1145. }
  1146. //返回替换列表
  1147. function ReturnReplaceListF($mid){
  1148. global $emod_r;
  1149. $r['mid']=$mid;
  1150. $r['fr']=explode(',',$emod_r[$mid]['listtempf']);
  1151. $r['fcount']=count($r['fr'])-1;
  1152. return $r;
  1153. }
  1154. //替换列表模板/标签模板/搜索模板
  1155. function ReplaceListVars($no,$listtemp,$subnews,$subtitle,$formatdate,$url,$haveclass=0,$r,$field,$docode=0){
  1156. global $empire,$public_r,$class_r,$class_zr,$fun_r,$dbtbpre,$emod_r,$class_tr,$level_r,$navclassid,$etable_r;
  1157. if($haveclass)
  1158. {
  1159. $add=sys_ReturnBqClassname($r,$haveclass);
  1160. }
  1161. if(empty($r[oldtitle]))
  1162. {
  1163. $r[oldtitle]=$r[title];
  1164. }
  1165. if($docode==1)
  1166. {
  1167. $listtemp=stripSlashes($listtemp);
  1168. eval($listtemp);
  1169. }
  1170. $ylisttemp=$listtemp;
  1171. $mid=$field['mid'];
  1172. $fr=$field['fr'];
  1173. $fcount=$field['fcount'];
  1174. for($i=1;$i<$fcount;$i++)
  1175. {
  1176. $f=$fr[$i];
  1177. $value=$r[$f];
  1178. $spf=0;
  1179. if($f=='title')//标题
  1180. {
  1181. if(!empty($subtitle))//截取字符
  1182. {
  1183. $value=sub($value,0,$subtitle,false);
  1184. }
  1185. $value=DoTitleFont($r[titlefont],$value);
  1186. $spf=1;
  1187. }
  1188. elseif($f=='newstime')//时间
  1189. {
  1190. //$value=date($formatdate,$value);
  1191. $value=format_datetime($value,$formatdate);
  1192. $spf=1;
  1193. }
  1194. elseif($f=='titlepic')//标题图片
  1195. {
  1196. if(empty($value))
  1197. {
  1198. $value=$public_r[newsurl].'e/data/images/notimg.gif';
  1199. }
  1200. $spf=1;
  1201. }
  1202. elseif(strstr($emod_r[$mid]['smalltextf'],','.$f.','))//简介
  1203. {
  1204. if(!empty($subnews))//截取字符
  1205. {
  1206. $value=sub($value,0,$subnews,false);
  1207. }
  1208. }
  1209. elseif($f=='befrom')//信息来源
  1210. {
  1211. $spf=1;
  1212. }
  1213. elseif($f=='writer')//作者
  1214. {
  1215. $spf=1;
  1216. }
  1217. if($spf==0&&!strstr($emod_r[$mid]['editorf'],','.$f.','))
  1218. {
  1219. if(strstr($emod_r[$mid]['tobrf'],','.$f.','))//加br
  1220. {
  1221. $value=nl2br($value);
  1222. }
  1223. if(!strstr($emod_r[$mid]['dohtmlf'],','.$f.','))//去除html
  1224. {
  1225. $value=RepFieldtextNbsp(htmlspecialchars($value));
  1226. }
  1227. }
  1228. $listtemp=str_replace('[!--'.$f.'--]',$value,$listtemp);
  1229. }
  1230. $titleurl=sys_ReturnBqTitleLink($r);//链接
  1231. $listtemp=str_replace('[!--id--]',$r[id],$listtemp);
  1232. $listtemp=str_replace('[!--classid--]',$r[classid],$listtemp);
  1233. $listtemp=str_replace('[!--class.name--]',$add,$listtemp);
  1234. $listtemp=str_replace('[!--ttid--]',$r[ttid],$listtemp);
  1235. $listtemp=str_replace('[!--tt.name--]',$class_tr[$r[ttid]][tname],$listtemp);
  1236. $listtemp=str_replace('[!--userfen--]',$r[userfen],$listtemp);
  1237. $listtemp=str_replace('[!--titleurl--]',$titleurl,$listtemp);
  1238. $listtemp=str_replace('[!--no.num--]',$no,$listtemp);
  1239. $listtemp=str_replace('[!--plnum--]',$r[plnum],$listtemp);
  1240. $listtemp=str_replace('[!--userid--]',$r[userid],$listtemp);
  1241. $listtemp=str_replace('[!--username--]',$r[username],$listtemp);
  1242. $listtemp=str_replace('[!--onclick--]',$r[onclick],$listtemp);
  1243. $listtemp=str_replace('[!--oldtitle--]',$r[oldtitle],$listtemp);
  1244. $listtemp=str_replace('[!--totaldown--]',$r[totaldown],$listtemp);
  1245. //栏目链接
  1246. if(strstr($ylisttemp,'[!--this.classlink--]'))
  1247. {
  1248. $thisclasslink=sys_ReturnBqClassname($r,9);
  1249. $listtemp=str_replace('[!--this.classlink--]',$thisclasslink,$listtemp);
  1250. }
  1251. $thisclassname=$class_r[$r[classid]][bname]?$class_r[$r[classid]][bname]:$class_r[$r[classid]][classname];
  1252. $listtemp=str_replace('[!--this.classname--]',$thisclassname,$listtemp);
  1253. return $listtemp;
  1254. }
  1255. //加上防复制字符
  1256. function AddNotCopyRndStr($text){
  1257. global $public_r;
  1258. if($public_r['opencopytext'])
  1259. {
  1260. $rnd=make_password(3).$public_r['sitename'];
  1261. $text=str_replace("<br />","<span style=\"display:none\">".$rnd."</span><br />",$text);
  1262. $text=str_replace("</p>","<span style=\"display:none\">".$rnd."</span></p>",$text);
  1263. }
  1264. return $text;
  1265. }
  1266. //替换信息来源
  1267. function ReplaceBefrom($befrom){
  1268. global $empire,$dbtbpre;
  1269. if(empty($befrom))
  1270. {return $befrom;}
  1271. $befrom=addslashes($befrom);
  1272. $r=$empire->fetch1("select befromid,sitename,siteurl from {$dbtbpre}enewsbefrom where sitename='$befrom' limit 1");
  1273. if(empty($r[befromid]))
  1274. {return $befrom;}
  1275. $return_befrom="<a href='".$r[siteurl]."' target=_blank>".$r[sitename]."</a>";
  1276. return $return_befrom;
  1277. }
  1278. //替换作者
  1279. function ReplaceWriter($writer){
  1280. global $empire,$dbtbpre;
  1281. if(empty($writer))
  1282. {return $writer;}
  1283. $writer=addslashes($writer);
  1284. $r=$empire->fetch1("select wid,writer,email from {$dbtbpre}enewswriter where writer='$writer' limit 1");
  1285. if(empty($r[wid])||empty($r[email]))
  1286. {
  1287. return $writer;
  1288. }
  1289. $return_writer="<a href='".$r[email]."'>".$r[writer]."</a>";
  1290. return $return_writer;
  1291. }
  1292. //备份下载记录
  1293. function BakDown($classid,$id,$pathid,$userid,$username,$title,$cardfen,$online=0){
  1294. global $empire,$dbtbpre;
  1295. $truetime=time();
  1296. $id=(int)$id;
  1297. $pathid=(int)$pathid;
  1298. $userid=(int)$userid;
  1299. $cardfen=(int)$cardfen;
  1300. $classid=(int)$classid;
  1301. $sql=$empire->query("insert into {$dbtbpre}enewsdownrecord(id,pathid,userid,username,title,cardfen,truetime,classid,online) values($id,$pathid,$userid,'$username','".addslashes($title)."',$cardfen,$truetime,$classid,'$online');");
  1302. }
  1303. //备份充值记录
  1304. function BakBuy($userid,$username,$buyname,$userfen,$money,$userdate,$type=0){
  1305. global $empire,$dbtbpre;
  1306. $buytime=date("y-m-d H:i:s");
  1307. $buyname=addslashes($buyname);
  1308. $empire->query("insert into {$dbtbpre}enewsbuybak(userid,username,card_no,cardfen,money,buytime,userdate,type) values('$userid','$username','$buyname','$userfen','$money','$buytime','$userdate','$type');");
  1309. }
  1310. //截取简介
  1311. function SubSmalltextVal($value,$len){
  1312. if(empty($len))
  1313. {
  1314. return '';
  1315. }
  1316. $value=str_replace(array("\r\n","<br />","<br>","&nbsp;","[!--empirenews.page--]","[/!--empirenews.page--]"),array("","\r\n","\r\n"," ","",""),$value);
  1317. $value=strip_tags($value);
  1318. if($len)
  1319. {
  1320. $value=sub($value,0,$len,false);
  1321. }
  1322. $value=trim($value,"\r\n");
  1323. $value=str_replace('&amp;ldquo;','&ldquo;',$value);
  1324. $value=str_replace('&amp;rdquo;','&rdquo;',$value);
  1325. $value=str_replace('&amp;mdash;','&mdash;',$value);
  1326. return $value;
  1327. }
  1328. //全站搜索简介
  1329. function SubSchallSmalltext($value,$len){
  1330. $value=str_replace(array("\r\n","&nbsp;","[!--empirenews.page--]","[/!--empirenews.page--]"),array("","","",""),$value);
  1331. $value=strip_tags($value);
  1332. if($len)
  1333. {
  1334. $value=sub($value,0,$len,false);
  1335. }
  1336. $value=trim($value,"\r\n");
  1337. return $value;
  1338. }
  1339. //加红替换
  1340. function DoReplaceFontRed($text,$key){
  1341. return str_replace($key,'<font color="red">'.$key.'</font>',$text);
  1342. }
  1343. //返回不生成html的栏目
  1344. function ReturnNreInfoWhere(){
  1345. global $public_r;
  1346. if(empty($public_r['nreinfo'])||$public_r['nreinfo']==',')
  1347. {
  1348. return '';
  1349. }
  1350. $cids=substr($public_r['nreinfo'],1,strlen($public_r['nreinfo'])-2);
  1351. $where=' and classid not in ('.$cids.')';
  1352. return $where;
  1353. }
  1354. //返回标签不调用栏目
  1355. function ReturnNottoBqWhere(){
  1356. global $public_r;
  1357. if(empty($public_r['nottobq'])||$public_r['nottobq']==',')
  1358. {
  1359. return '';
  1360. }
  1361. $cids=substr($public_r['nottobq'],1,strlen($public_r['nottobq'])-2);
  1362. $where=' and classid not in ('.$cids.')';
  1363. return $where;
  1364. }
  1365. //返回文件名及扩展名
  1366. function ReturnCFiletype($file){
  1367. $r=explode('.',$file);
  1368. $count=count($r)-1;
  1369. $re['filetype']=strtolower($r[$count]);
  1370. $re['filename']=substr($file,0,strlen($file)-strlen($re['filetype'])-1);
  1371. return $re;
  1372. }
  1373. //返回栏目目录
  1374. function ReturnSaveClassPath($classid,$f=0){
  1375. global $class_r;
  1376. $classpath=$class_r[$classid][classpath];
  1377. if($f==1){
  1378. $classpath.="/index".$class_r[$classid][classtype];
  1379. }
  1380. return $classpath;
  1381. }
  1382. //返回专题目录
  1383. function ReturnSaveZtPath($classid,$f=0){
  1384. global $class_zr;
  1385. $classpath=$class_zr[$classid][ztpath];
  1386. if($f==1){
  1387. $classpath.="/index".$class_zr[$classid][zttype];
  1388. }
  1389. return $classpath;
  1390. }
  1391. //返回首页文件
  1392. function ReturnSaveIndexFile(){
  1393. global $public_r;
  1394. $file="index".$public_r[indextype];
  1395. return $file;
  1396. }
  1397. //返回内容页存放目录
  1398. function ReturnSaveInfoPath($classid,$id){
  1399. global $class_r;
  1400. if($class_r[$classid][ipath]==''){
  1401. $path=$class_r[$classid][classpath].'/';
  1402. }
  1403. else{
  1404. $path=$class_r[$classid][ipath]=='/'?'':$class_r[$classid][ipath].'/';
  1405. }
  1406. return $path;
  1407. }
  1408. //返回内容页文件名
  1409. function GetInfoFilename($classid,$id){
  1410. global $empire,$dbtbpre,$public_r,$class_r;
  1411. $infor=$empire->fetch1("select titleurl,groupid,classid,newspath,filename,id from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$id' limit 1");
  1412. if(!$infor['id']||$infor['titleurl'])
  1413. {
  1414. return '';
  1415. }
  1416. $filetype=$infor['groupid']?'.php':$class_r[$classid]['filetype'];
  1417. $iclasspath=ReturnSaveInfoPath($classid,$id);
  1418. $doclasspath=ECMS_PATH.$iclasspath;
  1419. $newspath='';
  1420. if($infor['newspath'])
  1421. {
  1422. $newspath=$infor['newspath'].'/';
  1423. }
  1424. $file=$doclasspath.$newspath.$infor['filename'].$filetype;
  1425. return $file;
  1426. }
  1427. //格式化信息目录
  1428. function FormatPath($classid,$mynewspath,$enews=0){
  1429. global $class_r;
  1430. if($enews)
  1431. {
  1432. $newspath=$mynewspath;
  1433. }
  1434. else
  1435. {
  1436. $newspath=date($class_r[$classid][newspath]);
  1437. }
  1438. if(empty($newspath))
  1439. {
  1440. return "";
  1441. }
  1442. $path=ECMS_PATH.ReturnSaveInfoPath($classid,$id);
  1443. $returnpath="";
  1444. $r=explode("/",$newspath);
  1445. $count=count($r);
  1446. for($i=0;$i<$count;$i++){
  1447. if($i>0)
  1448. {
  1449. $returnpath.="/".$r[$i];
  1450. }
  1451. else
  1452. {
  1453. $returnpath.=$r[$i];
  1454. }
  1455. $createpath=$path.$returnpath;
  1456. $mk=DoMkdir($createpath);
  1457. if(empty($mk))
  1458. {
  1459. printerror("CreatePathFail","");
  1460. }
  1461. }
  1462. return $returnpath;
  1463. }
  1464. //返回内容页目录
  1465. function ReturnInfoSPath($filename){
  1466. return str_replace('/index','',$filename);
  1467. }
  1468. //------------- 附件 -------------
  1469. //返回附件域名地址
  1470. function eReturnFileUrl($ecms=0){
  1471. global $public_r;
  1472. if($ecms==1)
  1473. {
  1474. return $public_r['fileurl'];
  1475. }
  1476. $fileurl=$public_r['openfileserver']?$public_r['fs_purl']:$public_r['fileurl'];
  1477. return $fileurl;
  1478. }
  1479. //返回附件目录
  1480. function ReturnFileSavePath($classid,$fpath=''){
  1481. global $public_r,$class_r;
  1482. $fpath=$fpath||strstr(','.$fpath.',',',0,')?$fpath:$public_r['fpath'];
  1483. $efileurl=eReturnFileUrl();
  1484. if($fpath==1)//p目录
  1485. {
  1486. $r['filepath']='d/file/p/';
  1487. $r['fileurl']=$efileurl.'p/';
  1488. }
  1489. elseif($fpath==2)//file目录
  1490. {
  1491. $r['filepath']='d/file/';
  1492. $r['fileurl']=$efileurl;
  1493. }
  1494. else
  1495. {
  1496. if(empty($classid))
  1497. {
  1498. $r['filepath']='d/file/p/';
  1499. $r['fileurl']=$efileurl.'p/';
  1500. }
  1501. else
  1502. {
  1503. $r['filepath']='d/file/'.$class_r[$classid][classpath].'/';
  1504. $r['fileurl']=$efileurl.$class_r[$classid][classpath].'/';
  1505. }
  1506. }
  1507. return $r;
  1508. }
  1509. //格式化附件目录
  1510. function FormatFilePath($classid,$mynewspath,$enews=0){
  1511. global $public_r;
  1512. if($enews)
  1513. {
  1514. $newspath=$mynewspath;
  1515. }
  1516. else
  1517. {
  1518. $newspath=date($public_r['filepath']);
  1519. }
  1520. if(empty($newspath))
  1521. {
  1522. return "";
  1523. }
  1524. $fspath=ReturnFileSavePath($classid);
  1525. $path=ECMS_PATH.$fspath['filepath'];
  1526. $returnpath="";
  1527. $r=explode("/",$newspath);
  1528. $count=count($r);
  1529. for($i=0;$i<$count;$i++){
  1530. if($i>0){
  1531. $returnpath.="/".$r[$i];
  1532. }
  1533. else{
  1534. $returnpath.=$r[$i];
  1535. }
  1536. $createpath=$path.$returnpath;
  1537. $mk=DoMkdir($createpath);
  1538. if(empty($mk)){
  1539. printerror("CreatePathFail","");
  1540. }
  1541. }
  1542. return $returnpath;
  1543. }
  1544. //返回上传文件名
  1545. function ReturnDoTranFilename($file_name,$classid){
  1546. $filename=md5(uniqid(microtime()));
  1547. return $filename;
  1548. }
  1549. //上传文件
  1550. function DoTranFile($file,$file_name,$file_type,$file_size,$classid,$ecms=0){
  1551. global $public_r,$class_r,$doetran,$efileftp_fr;
  1552. //文件类型
  1553. $r[filetype]=GetFiletype($file_name);
  1554. //文件名
  1555. $r[insertfile]=ReturnDoTranFilename($file_name,$classid);
  1556. $r[filename]=$r[insertfile].$r[filetype];
  1557. //日期目录
  1558. $r[filepath]=FormatFilePath($classid,$mynewspath,0);
  1559. $filepath=$r[filepath]?$r[filepath].'/':$r[filepath];
  1560. //存放目录
  1561. $fspath=ReturnFileSavePath($classid);
  1562. $r[savepath]=ECMS_PATH.$fspath['filepath'].$filepath;
  1563. //附件地址
  1564. $r[url]=$fspath['fileurl'].$filepath.$r[filename];
  1565. //缩图文件
  1566. $r[name]=$r[savepath]."small".$r[insertfile];
  1567. //附件文件
  1568. $r[yname]=$r[savepath].$r[filename];
  1569. $r[tran]=1;
  1570. //验证类型
  1571. if(CheckSaveTranFiletype($r[filetype]))
  1572. {
  1573. if($doetran)
  1574. {
  1575. $r[tran]=0;
  1576. return $r;
  1577. }
  1578. else
  1579. {
  1580. printerror('TranFail','',$ecms);
  1581. }
  1582. }
  1583. //上传文件
  1584. $cp=@move_uploaded_file($file,$r[yname]);
  1585. if(empty($cp))
  1586. {
  1587. if($doetran)
  1588. {
  1589. $r[tran]=0;
  1590. return $r;
  1591. }
  1592. else
  1593. {
  1594. printerror('TranFail','',$ecms);
  1595. }
  1596. }
  1597. DoChmodFile($r[yname]);
  1598. $r[filesize]=(int)$file_size;
  1599. //FileServer
  1600. if($public_r['openfileserver'])
  1601. {
  1602. $efileftp_fr[]=$r['yname'];
  1603. }
  1604. return $r;
  1605. }
  1606. //远程保存忽略地址
  1607. function CheckNotSaveUrl($url){
  1608. global $public_r;
  1609. if(empty($public_r['notsaveurl']))
  1610. {
  1611. return 0;
  1612. }
  1613. $r=explode("\r\n",$public_r['notsaveurl']);
  1614. $count=count($r);
  1615. $re=0;
  1616. for($i=0;$i<$count;$i++)
  1617. {
  1618. if(empty($r[$i]))
  1619. {continue;}
  1620. if(stristr($url,$r[$i]))
  1621. {
  1622. $re=1;
  1623. break;
  1624. }
  1625. }
  1626. return $re;
  1627. }
  1628. //远程保存
  1629. function DoTranUrl($url,$classid){
  1630. global $public_r,$class_r,$tranpicturetype,$tranflashtype,$mediaplayertype,$realplayertype,$efileftp_fr;
  1631. //处理地址
  1632. $url=trim($url);
  1633. $url=str_replace(" ","%20",$url);
  1634. $r[tran]=1;
  1635. //附件地址
  1636. $r[url]=$url;
  1637. //文件类型
  1638. $r[filetype]=GetFiletype($url);
  1639. if(CheckSaveTranFiletype($r[filetype]))
  1640. {
  1641. $r[tran]=0;
  1642. return $r;
  1643. }
  1644. //是否已上传的文件
  1645. $havetr=CheckNotSaveUrl($url);
  1646. if($havetr)
  1647. {
  1648. $r[tran]=0;
  1649. return $r;
  1650. }
  1651. $string=ReadFiletext($url);
  1652. if(empty($string))//读取不了
  1653. {
  1654. $r[tran]=0;
  1655. return $r;
  1656. }
  1657. //文件名
  1658. $r[insertfile]=ReturnDoTranFilename($file_name,$classid);
  1659. $r[filename]=$r[insertfile].$r[filetype];
  1660. //日期目录
  1661. $r[filepath]=FormatFilePath($classid,$mynewspath,0);
  1662. $filepath=$r[filepath]?$r[filepath].'/':$r[filepath];
  1663. //存放目录
  1664. $fspath=ReturnFileSavePath($classid);
  1665. $r[savepath]=ECMS_PATH.$fspath['filepath'].$filepath;
  1666. //附件地址
  1667. $r[url]=$fspath['fileurl'].$filepath.$r[filename];
  1668. //缩图文件
  1669. $r[name]=$r[savepath]."small".$r[insertfile];
  1670. //附件文件
  1671. $r[yname]=$r[savepath].$r[filename];
  1672. WriteFiletext_n($r[yname],$string);
  1673. $r[filesize]=@filesize($r[yname]);
  1674. //返回类型
  1675. if(strstr($tranflashtype,','.$r[filetype].','))
  1676. {
  1677. $r[type]=2;
  1678. }
  1679. elseif(strstr($tranpicturetype,','.$r[filetype].','))
  1680. {
  1681. $r[type]=1;
  1682. }
  1683. elseif(strstr($mediaplayertype,','.$r[filetype].',')||strstr($realplayertype,','.$r[filetype].','))//多媒体
  1684. {
  1685. $r[type]=3;
  1686. }
  1687. else
  1688. {
  1689. $r[type]=0;
  1690. }
  1691. //FileServer
  1692. if($public_r['openfileserver'])
  1693. {
  1694. $efileftp_fr[]=$r['yname'];
  1695. }
  1696. return $r;
  1697. }
  1698. //删除附件
  1699. function DoDelFile($r){
  1700. global $class_r,$public_r,$efileftp_dr;
  1701. $path=$r['path']?$r['path'].'/':$r['path'];
  1702. $fspath=ReturnFileSavePath($r[classid],$r[fpath]);
  1703. $delfile=ECMS_PATH.$fspath['filepath'].$path.$r['filename'];
  1704. DelFiletext($delfile);
  1705. //FileServer
  1706. if($public_r['openfileserver'])
  1707. {
  1708. $efileftp_dr[]=$delfile;
  1709. }
  1710. }
  1711. //替换表前缀
  1712. function RepSqlTbpre($sql){
  1713. global $dbtbpre;
  1714. $sql=str_replace('[!db.pre!]',$dbtbpre,$sql);
  1715. return $sql;
  1716. }
  1717. //反替换表前缀
  1718. function ReRepSqlTbpre($sql){
  1719. global $dbtbpre;
  1720. $sql=str_replace($dbtbpre,'***_',$sql);
  1721. return $sql;
  1722. }
  1723. //时间转换
  1724. function ToChangeUseTime($time){
  1725. global $fun_r;
  1726. $usetime=time()-$time;
  1727. if($usetime<60)
  1728. {
  1729. $tstr=$usetime.$fun_r['TimeSecond'];
  1730. }
  1731. else
  1732. {
  1733. $usetime=round($usetime/60);
  1734. $tstr=$usetime.$fun_r['TimeMinute'];
  1735. }
  1736. return $tstr;
  1737. }
  1738. //返回栏目集合
  1739. function ReturnClass($sonclass){
  1740. if($sonclass==''||$sonclass=='|'){
  1741. return 'classid=0';
  1742. }
  1743. $where='classid in ('.RepSonclassSql($sonclass).')';
  1744. return $where;
  1745. }
  1746. //替换子栏目子
  1747. function RepSonclassSql($sonclass){
  1748. if($sonclass==''||$sonclass=='|'){
  1749. return 0;
  1750. }
  1751. $sonclass=substr($sonclass,1,strlen($sonclass)-2);
  1752. $sonclass=str_replace('|',',',$sonclass);
  1753. return $sonclass;
  1754. }
  1755. //返回多栏目
  1756. function sys_ReturnMoreClass($sonclass,$son=0){
  1757. global $class_r;
  1758. $r=explode(',',$sonclass);
  1759. $count=count($r);
  1760. $return_r[0]=intval($r[0]);
  1761. $where='';
  1762. $or='';
  1763. for($i=0;$i<$count;$i++)
  1764. {
  1765. $r[$i]=intval($r[$i]);
  1766. if($son==1)
  1767. {
  1768. if($class_r[$r[$i]]['tbname']&&!$class_r[$r[$i]]['islast'])
  1769. {
  1770. $where.=$or."classid in (".RepSonclassSql($class_r[$r[$i]]['sonclass']).")";
  1771. }
  1772. else
  1773. {
  1774. $where.=$or."classid='".$r[$i]."'";
  1775. }
  1776. }
  1777. else
  1778. {
  1779. $where.=$or."classid='".$r[$i]."'";
  1780. }
  1781. $or=' or ';
  1782. }
  1783. $return_r[1]=$where;
  1784. return $return_r;
  1785. }
  1786. //返回多专题
  1787. function sys_ReturnMoreZt($zt){
  1788. $r=explode(',',$zt);
  1789. $count=count($r);
  1790. $return_r[0]=intval($r[0]);
  1791. $where='';
  1792. $or='';
  1793. for($i=0;$i<$count;$i++)
  1794. {
  1795. $r[$i]=intval($r[$i]);
  1796. $where.=$or."ztid like '%|".$r[$i]."|%'";
  1797. $or=' or ';
  1798. }
  1799. $return_r[1]=$where;
  1800. return $return_r;
  1801. }
  1802. //返回多标题分类
  1803. function sys_ReturnMoreTT($tt){
  1804. $r=explode(',',$tt);
  1805. $count=count($r);
  1806. $return_r[0]=intval($r[0]);
  1807. $ids='';
  1808. $dh='';
  1809. for($i=0;$i<$count;$i++)
  1810. {
  1811. $r[$i]=intval($r[$i]);
  1812. $ids.=$dh.$r[$i];
  1813. $dh=',';
  1814. }
  1815. $return_r[1]='ttid in ('.$ids.')';
  1816. return $return_r;
  1817. }
  1818. //验证是否包含栏目
  1819. function CheckHaveInClassid($cr,$checkclass){
  1820. global $class_r;
  1821. if($cr['islast'])
  1822. {
  1823. $chclass='|'.$cr['classid'].'|';
  1824. }
  1825. else
  1826. {
  1827. $chclass=$cr['sonclass'];
  1828. }
  1829. $return=0;
  1830. $r=explode('|',$chclass);
  1831. $count=count($r);
  1832. for($i=1;$i<$count-1;$i++)
  1833. {
  1834. if(strstr($checkclass,'|'.$r[$i].'|'))
  1835. {
  1836. $return=1;
  1837. break;
  1838. }
  1839. }
  1840. return $return;
  1841. }
  1842. //返回加前缀的下载地址
  1843. function ReturnDownQzPath($path,$urlid){
  1844. global $empire,$dbtbpre;
  1845. $urlid=(int)$urlid;
  1846. if(empty($urlid))
  1847. {
  1848. $re['repath']=$path;
  1849. $re['downtype']=0;
  1850. }
  1851. else
  1852. {
  1853. $r=$empire->fetch1("select urlid,url,downtype from {$dbtbpre}enewsdownurlqz where urlid='$urlid'");
  1854. if($r['urlid'])
  1855. {
  1856. $re['repath']=$r['url'].$path;
  1857. }
  1858. else
  1859. {
  1860. $re['repath']=$path;
  1861. }
  1862. $re['downtype']=$r['downtype'];
  1863. }
  1864. return $re;
  1865. }
  1866. //返回带防盗链的绝对地址
  1867. function ReturnDSofturl($downurl,$qz,$path='../../',$isdown=0){
  1868. $urlr=ReturnDownQzPath(stripSlashes($downurl),$qz);
  1869. $url=$urlr['repath'];
  1870. @include_once(ECMS_PATH."e/class/enpath.php");//防盗链
  1871. if($isdown)
  1872. {
  1873. $url=DoEnDownpath($url);
  1874. }
  1875. else
  1876. {
  1877. $url=DoEnOnlinepath($url);
  1878. }
  1879. return $url;
  1880. }
  1881. //验证提交来源
  1882. function CheckCanPostUrl(){
  1883. global $public_r;
  1884. if($public_r['canposturl'])
  1885. {
  1886. $r=explode("\r\n",$public_r['canposturl']);
  1887. $count=count($r);
  1888. $b=0;
  1889. for($i=0;$i<$count;$i++)
  1890. {
  1891. if(strstr($_SERVER['HTTP_REFERER'],$r[$i]))
  1892. {
  1893. $b=1;
  1894. break;
  1895. }
  1896. }
  1897. if($b==0)
  1898. {
  1899. printerror('NotCanPostUrl','',1);
  1900. }
  1901. }
  1902. }
  1903. //验证IP
  1904. function eCheckAccessIp($ecms=0){
  1905. global $public_r;
  1906. $userip=egetip();
  1907. if($ecms)//后台
  1908. {
  1909. //允许IP
  1910. if($public_r['hopenip'])
  1911. {
  1912. $close=1;
  1913. foreach(explode("\n",$public_r['hopenip']) as $ctrlip)
  1914. {
  1915. if(preg_match("/^(".preg_quote(($ctrlip=trim($ctrlip)),'/').")/",$userip))
  1916. {
  1917. $close=0;
  1918. break;
  1919. }
  1920. }
  1921. if($close==1)
  1922. {
  1923. echo"Ip<font color='#cccccc'>(".$userip.")</font> be prohibited.";
  1924. exit();
  1925. }
  1926. }
  1927. }
  1928. else
  1929. {
  1930. //允许IP
  1931. if($public_r['openip'])
  1932. {
  1933. $close=1;
  1934. foreach(explode("\n",$public_r['openip']) as $ctrlip)
  1935. {
  1936. if(preg_match("/^(".preg_quote(($ctrlip=trim($ctrlip)),'/').")/",$userip))
  1937. {
  1938. $close=0;
  1939. break;
  1940. }
  1941. }
  1942. if($close==1)
  1943. {
  1944. echo"Ip<font color='#cccccc'>(".$userip.")</font> be prohibited.";
  1945. exit();
  1946. }
  1947. }
  1948. //禁止IP
  1949. if($public_r['closeip'])
  1950. {
  1951. foreach(explode("\n",$public_r['closeip']) as $ctrlip)
  1952. {
  1953. if(preg_match("/^(".preg_quote(($ctrlip=trim($ctrlip)),'/').")/",$userip))
  1954. {
  1955. echo"Ip<font color='#cccccc'>(".$userip.")</font> be prohibited.";
  1956. exit();
  1957. }
  1958. }
  1959. }
  1960. }
  1961. }
  1962. //验证提交IP
  1963. function eCheckAccessDoIp($doing){
  1964. global $public_r,$empire,$dbtbpre;
  1965. $pr=$empire->fetch1("select opendoip,closedoip,doiptype from {$dbtbpre}enewspublic limit 1");
  1966. if(!strstr($pr['doiptype'],','.$doing.','))
  1967. {
  1968. return '';
  1969. }
  1970. $userip=egetip();
  1971. //允许IP
  1972. if($pr['opendoip'])
  1973. {
  1974. $close=1;
  1975. foreach(explode("\n",$pr['opendoip']) as $ctrlip)
  1976. {
  1977. if(preg_match("/^(".preg_quote(($ctrlip=trim($ctrlip)),'/').")/",$userip))
  1978. {
  1979. $close=0;
  1980. break;
  1981. }
  1982. }
  1983. if($close==1)
  1984. {
  1985. printerror('NotCanPostIp','history.go(-1)',1);
  1986. }
  1987. }
  1988. //禁止IP
  1989. if($pr['closedoip'])
  1990. {
  1991. foreach(explode("\n",$pr['closedoip']) as $ctrlip)
  1992. {
  1993. if(preg_match("/^(".preg_quote(($ctrlip=trim($ctrlip)),'/').")/",$userip))
  1994. {
  1995. printerror('NotCanPostIp','history.go(-1)',1);
  1996. }
  1997. }
  1998. }
  1999. }
  2000. //验证是否关闭相关模块
  2001. function eCheckCloseMods($mod){
  2002. global $public_r;
  2003. if(strstr($public_r['closemods'],','.$mod.','))
  2004. {
  2005. echo $mod.' is close';
  2006. exit();
  2007. }
  2008. }
  2009. //验证包含字符
  2010. function toCheckCloseWord($word,$closestr,$mess){
  2011. if($closestr&&$closestr!='|')
  2012. {
  2013. $checkr=explode('|',$closestr);
  2014. $ckcount=count($checkr);
  2015. for($i=0;$i<$ckcount;$i++)
  2016. {
  2017. if($checkr[$i]&&stristr($word,$checkr[$i]))
  2018. {
  2019. printerror($mess,"history.go(-1)",1);
  2020. }
  2021. }
  2022. }
  2023. }
  2024. //替换评论表情
  2025. function RepPltextFace($text){
  2026. global $public_r;
  2027. if(empty($public_r['plface'])||$public_r['plface']=='||')
  2028. {
  2029. return $text;
  2030. }
  2031. $facer=explode('||',$public_r['plface']);
  2032. $count=count($facer);
  2033. for($i=1;$i<$count-1;$i++)
  2034. {
  2035. $r=explode('##',$facer[$i]);
  2036. $text=str_replace($r[0],"<img src='".$public_r['newsurl']."e/data/face/".$r[1]."' border=0>",$text);
  2037. }
  2038. return $text;
  2039. }
  2040. //替换空格
  2041. function RepFieldtextNbsp($text){
  2042. return str_replace(array("\t",' ',' '),array('&nbsp; &nbsp; &nbsp; &nbsp; ','&nbsp; &nbsp;','&nbsp;&nbsp;'),$text);
  2043. }
  2044. //保留扩展名验证
  2045. function CheckSaveTranFiletype($filetype){
  2046. $savetranfiletype=',.php,.php3,.php4,.php5,.php6,.asp,.aspx,.jsp,.cgi,.phtml,.asa,.asax,.fcgi,.pl,.ascx,.ashx,.cer,.cdx,.pht,.shtml,.shtm,.stm,';
  2047. if(stristr($savetranfiletype,','.$filetype.','))
  2048. {
  2049. return true;
  2050. }
  2051. return false;
  2052. }
  2053. //设置验证码
  2054. function ecmsSetShowKey($varname,$val,$ecms=0){
  2055. global $public_r;
  2056. $time=time();
  2057. $checkpass=md5(md5($val.'EmpireCMS'.$time).$public_r['keyrnd']);
  2058. $key=$time.','.$checkpass.','.$val;
  2059. esetcookie($varname,$key,0,$ecms);
  2060. }
  2061. //检查验证码
  2062. function ecmsCheckShowKey($varname,$postval,$dopr,$ecms=0){
  2063. global $public_r;
  2064. $r=explode(',',getcvar($varname,$ecms));
  2065. $cktime=$r[0];
  2066. $pa

Large files files are truncated, but you can click here to view the full file