Shanghai WTO Forum

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6256|回复: 1

首页调用插件 for PW/blog 4x

[复制链接]
发表于 2006-4-30 22:11:18 | 显示全部楼层
我原来在用3.x时,调用一切正常,后来升级到4.3.2时,调用老是出现非法帖子,但能进入blog。后来发现,原来在news.php文件里:有这样一段:
  1. //没有开通“静态目录”功能的朋友将“blog/htm/do_showone/”修改成“blog.php?do_showone/”
  2.    $newlist .= "document.write("<a href=$forumurl/blog/htm/do_showone/tid_$threads[tid].html
复制代码
我在改写时,把下横线及一个/改为上横线,一切正常了。即:正确的修改为:“blog.php?do-showone-tid-$threads[tid].html”
 楼主| 发表于 2006-4-30 21:13:31 | 显示全部楼层 |阅读模式
  1. <?php
  2. /*
  3. ** 插件名称:首页调用插件 for PW/blog 4.x
  4. ** 原 作 者:bg9cx
  5. ** 修  改:无言沙漠
  6. ** 最后更新:2005.12.25
  7. ** 使用说明:
  8. ** 1.把插件文件news.php复制到博客的根目录,根据你的情况设置$lockurl,$forumurl,$cachetime的值。
  9. ** 2.调用方法
  10. ** 在首页(也可是其他页面)里加入(里面的路径请根据实际情况修改)
  11. ** <script src="[url]http://yourhost/blog/news.php?cidin=xx&orders=xx&info=xx&num=xx&length=xx&pre=xx[/url]"></script>
  12. ** 参数说明:
  13. **   cidin(out):是调用博客的板块参数,整个博客调用 cidin=all,调用第一个板块:cidid=1;调用2,3板块:cidid=2_3;
  14. **   不显示2和10两个博客的新帖cidout=2_10;依次类推,
  15. **   orders(可选,默认为0):   新贴排序方式(0最后回复时间1点击2发表时间)
  16. **   num(可选,默认为10):   调用新帖的数目
  17. **   length(可选,默认为70):新贴标题长度限制
  18. **   pre(可选,默认为1):   新贴标题显示前缀参数
  19. **   info(可选):   新贴标题后增加显示信息(0)
  20. ** 例子:<script src="[url]http://blog.5y6s.net/news.php?cidin=all&num=10&length=30&orders=2&pre=1&info=1[/url]"></script>
  21. ** 演示:[url]http://blog.5y6s.net/news.htm[/url]
  22. ** 没有开通“静态目录”功能的朋友将“blog/htm/do_showone/”修改成“blog.php?do_showone/”
  23. */
  24. $lockurl   = &#39;5y6s.net&#39;;   //允许调用网址,为空则不开放此功能.如果你的首页为[url]www.5y6s.net[/url]则只需要修改为5y6s.net其他东西不要加
  25. $forumurl   = &#39;[url]http://blog.5y6s.net[/url]&#39;;   //博客地址。后面不要加&#39;/&#39;
  26. $cachetime   = &#39;6&#39;;   //缓存文件更新时间单位秒
  27. $headin[0]   = &#39;<li>&#39;;// 标题前字符,可以用图片:<img src=http://localhost/20youth/forum/logo.gif border=0>
  28. $headin[1]   = &#39;◇ &#39;;      
  29. $headin[2]   = &#39;· &#39;;
  30. $headin[3]   = &#39;○ &#39;;
  31. $headin[4]   = &#39;● &#39;;
  32. $headin[5]   = &#39;&#39;;
  33. $info_color = &#39;red&#39;;//标题后增加显示信息颜色,例如作者,时间,点击数
  34. error_reporting(0);
  35. set_magic_quotes_runtime(0);
  36. if (!get_magic_quotes_gpc())
  37. {
  38.   Add_S($_GET);
  39. }
  40. //if (trim($lockurl)==""||strpos($_SERVER[&#39;HTTP_REFERER&#39;],$lockurl)===false)
  41. //{
  42. //   exit("document.write("数据被保护,禁止被其他站点调用!或者你没有设置\$lockurl参数。");");
  43. //}
  44. $cidin   = $_GET[&#39;cidin&#39;];
  45. $cidout = $_GET[&#39;cidout&#39;];
  46. $good   = $_GET[&#39;good&#39;];
  47. $info   = $_GET[&#39;info&#39;];
  48. $num   = $_GET[&#39;num&#39;] ? $_GET[&#39;num&#39;] : 10;
  49. $length   = $_GET[&#39;length&#39;] ? $_GET[&#39;length&#39;] : 70;
  50. $pre   = $_GET[&#39;pre&#39;] ? $headin[$_GET[&#39;pre&#39;]] : $headin[0];
  51. $orders   = $_GET[&#39;orders&#39;] ? $_GET[&#39;orders&#39;] : 0;
  52. if ($orders == 0)
  53. {
  54.   $listorder=&#39;lastpost&#39;;
  55. }
  56. else if ($orders == 1)
  57. {
  58.   $listorder=&#39;hits&#39;;   
  59. }
  60. else if ($orders == 2)
  61. {
  62.   $listorder=&#39;postdate&#39;;
  63. }
  64. else if ($orders ==3 )
  65. {
  66.   $listorder=&#39;lastpost&#39;;
  67. }
  68. else
  69. {
  70.   $listorder=&#39;lastpost&#39;;
  71. }
  72. $cachefile = &#39;./data/cache/new_&#39;.md5("$cidin$cidout$orders$good$num$length$pre$info").&#39;.php&#39;;
  73. if ((time() - @filemtime($cachefile) >= $cachetime))
  74. {
  75.   require &#39;data/sql_config.php&#39;;
  76.   mysql_connect($dbhost, $dbuser, $dbpw);
  77.   mysql_select_db($dbname);
  78.   $forumadd = &#39;&#39;;
  79.   if($cidin != &#39;all&#39;)
  80.   {
  81.      $cidin && $forumadd = &#39;WHERE cid IN (\&#39;&#39;.str_replace(&#39;_&#39;, &#39;\&#39;,\&#39;&#39;, $cidin).&#39;\&#39;)&#39;;
  82.      $cidout&& $forumadd = &#39;WHERE cid NOT IN (\&#39;&#39;.str_replace(&#39;_&#39;, &#39;\&#39;,\&#39;&#39;, $cidout).&#39;\&#39;)&#39;;
  83.   }
  84.   if ($good == &#39;yes&#39; && $cidin != &#39;all&#39;)
  85.   {
  86.      $forumadd .= "and digest>0";
  87.   }
  88.   if ($good == &#39;yes&#39; && $cidin == &#39;all&#39;)
  89.   {
  90.      $forumadd = "where digest>0";
  91.   }
  92.   $query = mysql_query("SELECT tid,cid,icon,author,authorid,subject,postdate,hits FROM {$PW}blog $forumadd ORDER BY $listorder DESC LIMIT 0, $num") or die(mysql_error());
  93.   $newlist="";
  94.   while ($threads = mysql_fetch_array($query))
  95.   {
  96.      $threads[subject] = substrs($threads[subject], $length);
  97.      //没有开通“静态目录”功能的朋友将“blog/htm/do_showone/”修改成“blog.php?do_showone/”
  98.      $newlist .= "document.write("<a href=$forumurl/blog/htm/do_showone/tid_$threads[tid].html target=_blank>$pre$threads[subject]</a>");\n";
  99.      switch($info)
  100.      {
  101.       case "1"://时间作者
  102.          $posttime=date("Y-m-d H:i",$threads[postdate]);
  103.           $newlist.="document.write("(<font color=$info_color>$posttime</font>by<a href=http://$threads[author].5y6s.net/ target=_blank>$threads[author]</a>)<br>");\n";
  104.           break;
  105.         case "2"://时间
  106.           $posttime=date("Y-m-d H:i",$threads[postdate]);
  107.           $newlist.="document.write("(<font color=$info_color>$posttime</font>)<br>");\n";
  108.           break;
  109.         case "3"://作者
  110.           $newlist.="document.write("(<a href=http://$threads[author].5y6s.net/ target=_blank><font color=$info_color>$threads[author]</font></a>)<br>");\n";
  111.           break;
  112.         case "4"://点击
  113.           $newlist.="document.write("(<font color=$info_color>$threads[hits]</font>)<br>");\n";
  114.           break;
  115.       default:
  116.       $newlist.="document.write("<br>");\n";
  117.     }
  118.   }
  119.   echo $newlist;
  120.   @writeover($cachefile,$newlist);
  121. }
  122. else
  123. {
  124.   @include($cachefile);
  125. }
  126. /**
  127. *函数列表
  128. */
  129. function writeover($filename,$data,$method="rb+",$iflock=1){
  130.   touch($filename);
  131.   $handle=fopen($filename,$method);
  132.   if($iflock){
  133.      flock($handle,LOCK_EX);
  134.   }
  135.   fputs($handle,$data);
  136.   if($method=="rb+") ftruncate($handle,strlen($data));
  137.   fclose($handle);
  138. }
  139. function substrs($content,$length) {
  140.   if(strlen($content)>$length){
  141.      $num=0;
  142.      for($i=0;$i<$length-3;$i++) {
  143.         if(ord($content[$i])>0xa0)$num++;
  144.      }
  145.      $num%2==1 ? $content=substr($content,0,$length-4):$content=substr($content,0,$length-3);
  146.      $content.=&#39; ...&#39;;
  147.   }
  148.   return $content;
  149. }
  150. function Add_S(&$array){
  151.   foreach($array as $key=>$value){
  152.     if(!is_array($value)){
  153.        $array[$key]=addslashes($value);
  154.     }else{
  155.        Add_S($array[$key]);
  156.     }
  157.   }
  158. }
  159. ?>
复制代码

news.rar

3 KB, 下载次数: 13

您需要登录后才可以回帖 登录 | 注册

本版积分规则


QQ|Archiver|mobile|The little black house|Shanghai WTO Net ( 沪ICP备10034107号-3 )

GMT+8, 2024-5-5 20:54

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表