Originally posted by Mas*Mind
This is what the hack does: It let's you preview a message when you're editing it, you can only preview when you're posting or replying the way it is now:
It works on my testserver, but I've not tested on a 'live' forum, but it seems to be working allright...
Instructions
1 Backup your editpost.php file!!! and open the original one...
Then:
after:
PHP Code:
if (!isset($action) or $action=="") {
$action="editpost";
}
insert:
PHP Code:
if($preview AND $action="updatepost")
$action = "editpost";
after:
PHP Code:
if ($action=="editpost") {
// draw nav bar
$navbar=makenavbar($threadinfo[threadid],"thread",1);
insert:
PHP Code:
if($preview)
{ $parseurl=iif($parseurl=="yes",1,0);
$email=iif($email=="yes",1,0);
$allowsmilie=iif($disablesmilies=="yes",0,1);
$signature=iif($signature=="yes",1,0);
$previewmessage=$message;
if ($parseurl) {
$previewmessage = $postinfo[message]=parseurl($previewmessage);
}
$previewpost=1;
$previewmessage=bbcodeparse($previewmessage,$foruminfo[forumid],$allowsmilie);
$postinfo[message]=$message;
if ($signature) {
$previewmessage.=bbcodeparse("\n__________________\n$bbuserinfo[signature]",0,$allowsmilies);
}
eval("\$postpreview=\"".gettemplate("editpost_postpreview")."\";");
$parseurlchecked=iif($parseurl,"checked","");
$postinfo[allowsmilie] = $allowsmilie;
$postinfo[showsignature] = $signature;
$postinfo[iconid] = $iconid;
$postinfo[title] = $title;
$previewchecked=0;
}
else{
$postinfo[message]=htmlspecialchars($postinfo[pagetext]);
$parseurlchecked="CHECKED";
}
Replace:
PHP Code:
$postinfo[message]=htmlspecialchars($postinfo[pagetext]);
with:
PHP Code:
//$postinfo[message]=htmlspecialchars($postinfo[pagetext]);
replace:
PHP Code:
if ($checkid=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid='$userinfo[userid]' AND threadid=$threadinfo[threadid]")) {
$emailchecked="CHECKED";
} else {
$emailchecked="";
}
with:
PHP Code:
if(!$preview)
$email=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid=$userinfo[userid] AND threadid=$threadinfo[threadid]");
$emailchecked=iif($email,"CHECKED","");
Make a new template called 'editpost_postpreview' with the following content:
Code:
<table width=100% border=0 cellspacing=1 cellpadding=4>
<TR bgcolor="#6c6081">
<TD valign=middle><smallfont color="#afa3c5"><B>Post Preview:</B></smallfont></TD>
</TR>
<tr bgcolor="#DEDEDE">
<td><normalfont>$previewmessage</normalfont></td>
</tr>
</table>
<br>
then edit your 'editpost' template:
insert the '
$postpreview' variable at the appropiate place (look into the 'newthread' template for an example)
and replace:
Code:
<INPUT TYPE="Submit" NAME="SUBMIT" ACCESSKEY="S" VALUE="Submit Now">
with:
Code:
<INPUT TYPE="Submit" NAME="preview" ACCESSKEY="P" VALUE="Preview">
<INPUT TYPE="Submit" NAME="SUBMIT" ACCESSKEY="S" VALUE="Submit Now">
All done! Enjoy