我是PHP的初学者
为了做一个PW论坛的引用直接到快速回复栏做了好久都没成功
今天总算有了突破 可是出现了乱码问题
首先我写了一个getquote.php(功能是通过PID可以查询到某个贴的时间 作者 内容 并按一定的格式返回)
效果是这样的:
http://anime.62m.net/getquote.php?pid=501
他的源代码是这样的(不完善 只能显示非顶楼的 我昨天才学啊 55555555)
<?php
require_once('global.php');
if($article==0){
$atcarray=$tpcarray?
} else{
!is_numeric($pid) && showmsg('illegal_tid');
$atcarray = $db->get_one("SELECT author,subject,ifsign,postdate,content FROM pw_posts WHERE pid='$pid'");
}
$ifsign=$atcarray['ifsign'];
$old_author=$atcarray['author'];
$replytitle=$atcarray['subject'];
$wtof_oldfile=get_date($atcarray['postdate']);
require_once GetLang('post');
$old_content=stripslashes($atcarray['content']);
$old_content=preg_replace("/\[hide=(.+?)\](.+?)\[\/hide\]/is",$lang['hide_post'],$old_content);
$old_content=preg_replace("/\[post\](.+?)\[\/post\]/is",$lang['post_post'],$old_content);
$old_content=preg_replace("/\[sell=(.+?)\](.+?)\[\/sell\]/is",$lang['sell_post'],$old_content);
$old_content=preg_replace("/\[quote\](.*)\[\/quote\]/is","",$old_content);
if(strpos($old_content,$db_bbsurl)!==false){
$old_content=str_replace('p_w_picpath',$picpath,$old_content);
}
//
$bit_content = explode("\n",$old_content);
if (count($bit_content) > 5){
$old_content = "$bit_content[0]\n$bit_content[1]\n$bit_content[2]\n$bit_content[3]\n$bit_content[4]\n.......";
}
//
if(strpos($old_content,$db_bbsurl)!==false){
$old_content=str_replace('p_w_picpath',$picpath,$old_content);
$old_content=str_replace('p_w_upload',$attachpath,$old_content);
}
//
$old_content=preg_replace("/\<(.+?)\>/eis","",$old_content);
if($winddb['editor']){
$atc_content="
\n";
} else{
$atc_content="
\n";
}
echo $atc_content;
?>
虽然不能显示顶楼 但是其他回帖都没有问题
然后呢。。。
我写了一个JS文件
是这样的:取名为greedland.js
var uniqnum_counter = (new Date).getTime();
function UniqueNum() {
++uniqnum_counter;
return uniqnum_counter;
}
function XHConn()
{
var xmlhttp, bComplete = false;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { try { xmlhttp = new XMLHttpRequest(); }
catch (e) { xmlhttp = false; }}}
if (!xmlhttp) return null;
this.quote = function(sURL,sVars)
{
if (!xmlhttp) return false;
bComplete = false;
try {
xmlhttp.open("GET", sURL+"?"+sVars+ "&rand=" + UniqueNum(), true);
sVars = "";
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && !bComplete)
{
bComplete = true;
d = xmlhttp.responseText;
document.FORM.atc_content.focus();
document.FORM.atc_content.value+=d;
document.FORM.atc_content.value+="大家好~~~\r\n\r\n";
document.FORM.atc_content.focus();
}};
xmlhttp.send(null);
}
catch(z) { return false; }
};
return this;
}
var myConn = new XHConn();
if (!myConn) alert("你的浏览器不支持xmlhttp技术,您将无法使用本站的某些功能,请尝试新版本的浏览器。");
之后
我就可以在相应的论坛相应引用符号处
写成
<a href=### class=white onClick="myConn.quote('getquote.php','fid=$fid&tid=$tid&pid=$read[pid]&article=$read[lou]');return false;"><img src='$imgpath/$stylepath/read/quote.gif' align=absmiddle alt='引用回复这个帖子'></a>
修改好一切以后 我点引用
内容就能按照格式出现在快速回复栏中了
可是...
出现的竟然是乱码
我哭啊~~~~~
谁能帮我解决 可以到我的论坛看具体的效果(开放了游客的)
http://anime.62m.net/read.php?tid=149&fpage=1
论坛现在运行中 所有引用我改回去了 不过快速回复栏旁边有一个测试按钮1 你点一下就能看到具体的效果了。。。。
有个论坛用的和我一样的JS文件能正常显示
他的get_quote.php文件访问时时这样的效果:
http://bbs.greedland.net/get_quote.php?postId=31181008&topicId=656860&forumId=8