ok, tell ya what.. i'm gonna try this again, even thought i came up flat out my face the first time. i'll let you know if i get anything to work properly, with the correct functions. in the meantime, this is the block of code that i will be working on, to see what needs to be tweaked around, to get this feature working.
- editpost.php -
PHP Code:
// ############################### start update post ###############################
if ($HTTP_POST_VARS['action']=="updatepost") {
// check for message
if ($message=="") {
eval("standarderror(\"".gettemplate("error_nosubject")."\");");
exit;
}
// decode check boxes
$parseurl=iif($parseurl=="yes",1,0);
$email=iif($email=="yes",1,0);
$allowsmilie=iif($disablesmilies=="yes",0,1);
$signature=iif($signature=="yes",1,0);
$editedbysql="";
if ($showeditedby and $postinfo[dateline]<(time()-($noeditedbytime*60)) and !($getperms[ismoderator] and !$showeditedbyadmin)) {
$editedbysql=",edituserid='$bbuserinfo[userid]',editdate='".time()."'";
}
// check max images
if ($maximages!=0) {
$parsedmessage=bbcodeparse($message,$threadinfo['forumid'],$allowsmilie);
if (countchar($parsedmessage,"<img")>$maximages) {
eval("standarderror(\"".gettemplate("error_toomanyimages")."\");");
exit;
}
}
if (!isset($iconid) or $iconid=="") {
$iconid=0;
}
$iconid=intval($iconid);
if ($parseurl) {
$message=parseurl($message);
}
$attachmentsql="";
if ($postinfo[attachmentid]!=0) {
// check attachment status
// keep, delete, update
if (trim($attachmentaction)=="delete") {
$attachmentsql=",attachmentid=0";
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
updatethreadcount($threadinfo[threadid]);
}
if (trim($attachmentaction)=="new") {
// sort attachement
if (is_array($HTTP_POST_FILES)) {
$attachment = $HTTP_POST_FILES['attachment']['tmp_name'];
$attachment_name = $HTTP_POST_FILES['attachment']['name'];
$attachment_size = $HTTP_POST_FILES['attachment']['size'];
}
if (trim($attachment)!="none" and trim($attachment)!="" and trim($attachment_name)!="") {
$attachmentid=acceptupload($foruminfo[moderateattach]);
$attachmentsql=",attachmentid='$attachmentid'";
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
}
}
}
// remove sessionhash from urls:
$message = stripsession($message);
$title=censortext($title);
$message=censortext($message);
if (strlen($message)>$postmaxchars and $postmaxchars!=0) {
eval("standarderror(\"".gettemplate("error_toolong")."\");");
}
// find out if first post
$getpost=$DB_site->query_first("SELECT postid FROM post WHERE threadid=$threadinfo[threadid] ORDER BY dateline LIMIT 1");
if ($getpost[postid]==$postid) {
$isfirst=1;
} else {
$isfirst=0;
}
if ($isfirst and $title!="" and $postinfo[dateline]+$editthreadtitlelimit*60>time()) {
$DB_site->query("UPDATE thread SET title='".addslashes(htmlspecialchars($title))."', iconid=".intval($iconid)." WHERE threadid=$threadinfo[threadid]");
//$title="";
}
if ($email) {
if (!$checkid=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid=$postinfo[userid] AND threadid=$threadinfo[threadid]")) {
$DB_site->query("INSERT INTO subscribethread (subscribethreadid,userid,threadid) VALUES (NULL,$postinfo[userid],$threadinfo[threadid])");
} // else : already subscribed, so no need to do that again
} else {
if ($checkid=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid=$postinfo[userid] AND threadid=$threadinfo[threadid]")) {
$DB_site->query("DELETE FROM subscribethread WHERE userid=$postinfo[userid] AND threadid=$threadinfo[threadid]");
} // else : already unsubscribed, so no need to unsubscribe
}
$DB_site->query("UPDATE post SET title='".addslashes(htmlspecialchars($title))."',pagetext='".addslashes($message)."',allowsmilie='$allowsmilie',showsignature='$signature',iconid='$iconid'$editedbysql$attachmentsql WHERE postid='$postid'");
unindexpost($postid);
indexpost($postid);
eval("standardredirect(\"".gettemplate("redirect_editthanks")."\",\"showthread.php?s=$session[sessionhash]&postid=$postid#post$postid\");");
}
if ($action=="deletepost") {
if ($deletepost=="yes") {
//get first post in thread
$getfirst=$DB_site->query_first("SELECT postid,dateline FROM post WHERE threadid='$threadid' ORDER BY dateline LIMIT 1");
if ($getfirst[postid]==$postid) {
// delete thread
if ($getperms[candeletethread]) {
deletethread($threadinfo[threadid],$foruminfo[countposts]);
updateforumcount($threadinfo[forumid]);
eval("standardredirect(\"".gettemplate("redirect_deletethread")."\",\"forumdisplay.php?s=$session[sessionhash]&forumid=$threadinfo[forumid]\");");
} else {
show_nopermission();
}
} else {
//delete just this post
$foruminfo=getforuminfo($threadinfo[forumid]);
deletepost($postid,$foruminfo[countposts],$threadinfo[threadid]);
updatethreadcount($threadinfo[threadid]);
updateforumcount($threadinfo[forumid]);
eval("standardredirect(\"".gettemplate("redirect_deletepost")."\",\"showthread.php?s=$session[sessionhash]&threadid=$threadinfo[threadid]\");");
}
} else {
eval("standardredirect(\"".gettemplate("redirect_nodelete")."\",\"showthread.php?s=$session[sessionhash]&postid=$postid#post$postid\");");
}
}
hopefully for me anyway, the 2nd time around will be a charm. though i'm very pesimistic.. :disappointed:
Metro.