amykhar |
07-08-2002 02:13 PM |
Here is the rest of what I conceived. I am not supporting this as a released hack because I am not set up to test it thorougly. Use at YOUR OWN RISK.
Find:
PHP Code:
doformheader("thread","pruneuser");
Paste before:
PHP Code:
doformheader("thread","pruneviewed");
maketableheader("Prune by Date Last Viewed");
makeinputcode("Delete threads with last viewed before x days:<BR>(intensive if deleting a lot of threads)","daysdelete","0");
//makeforumchoosercode("Forum","forumid",-1,"All forums");
makeforumchooser("forumid",-1,-1,"","----- all -----","Forum:");
makeyesnocode("Include sub forums","subforums");
doformfooter("Prune");
Find:
PHP Code:
// ###################### Start Prune by date #######################
Paste before:
PHP Code:
// ###################### Start Prune by last viewed #######################
if ($action=="pruneviewed") {
if ($daysdelete=="") {
echo "<p>Please enter an age of last view to delete</p>";
exit;
}
if ($confirm!=1) {
if ($forumid==-1) {
$forumtitle="all forums";
} else {
$forum=$DB_site->query_first("SELECT title FROM forum WHERE forumid=$forumid");
$forumtitle="the \"$forum[title]\" forum";
if ($subforums) {
$forumtitle.=" and sub forums";
}
}
doformheader("thread","pruneviewed");
maketableheader("Prune All Threads Automatically");
makehiddencode("forumid", "$forumid");
makehiddencode("daysdelete", "$daysdelete");
makehiddencode("subforums", "$subforums");
makehiddencode("confirm", "1");
doformfooter("Click Here to Prune All Threads Automatically","",2);
doformheader("thread","prunedatevie");
maketableheader("Prune Threads Selectively");
makehiddencode("forumid", "$forumid");
makehiddencode("daysdelete", "$daysdelete");
makehiddencode("subforums", "$subforums");
doformfooter("Click Here to Prune Threads Selectively","",2);
//<a
href=\"thread.php?s=$session[sessionhash]&action=prunedatesel&forumid=$forumid&daysdelete=$daysdelete&subforums=$subforums\"><b>here</b></a>
to select those to delete.</p>";
exit;
}
if ($forumid!=-1) {
if ($subforums) {
$forumcheck="(thread.forumid=$forumid OR INSTR(parentlist,',$forumid,')>0) AND ";
} else {
$forumcheck="thread.forumid=$forumid AND ";
}
}
$datecut=time()-($daysdelete*86400);
$threads=$DB_site->query("SELECT threadid FROM thread LEFT JOIN forum USING (forumid) WHERE $forumcheck thread.lastview<=$datecut AND
thread.sticky=0");
while ($thread=$DB_site->fetch_array($threads)) {
deletethread($thread[threadid],0);
}
echo "<p>Posts deleted successfully! It is recommended that you <a href=\"misc.php?s=$session[sessionhash]\">update counters</a> now.</p>";
}
// ###################### Start Prune by date selector #######################
if ($action=="prunedatevie") {
doformheader("thread","dopruneviewed");
if ($forumid!=-1) {
if ($subforums) {
$forumcheck="(thread.forumid=$forumid OR INSTR(parentlist,',$forumid,')>0) AND ";
} else {
$forumcheck="thread.forumid=$forumid AND ";
}
}
echo "<tr class='tblhead'><td><font size='1'><b><span class='tblhead'>Thread Title</span></b></font></td><td><font size='1'><b><span
class='tblhead'>Delete?</span></b></font></td></tr>\n";
$datecut=time()-($daysdelete*86400);
$threads=$DB_site->query("SELECT threadid,thread.title,thread.replycount FROM thread LEFT JOIN forum USING (forumid) WHERE $forumcheck
thread.lastview<=$datecut ORDER BY thread.lastpost DESC");
while ($thread=$DB_site->fetch_array($threads)) {
makeyesnocode("<a href=\"../showthread.php?s=$session[sessionhash]&threadid=$thread[threadid]\"
target=_blank>$thread[title]($thread[replycount])</a>","delete[$thread[threadid]]",0);
}
doformfooter("Submit - only click here if you are ABSOLUTELY certain");
}
// ###################### Start Prune by date selected #######################
if ($HTTP_POST_VARS['action']=="dopruneviewed") {
echo "<p>Deleting...</p>";
while (list($key,$val)=each($delete)) {
if ($val==1) {
deletethread($key,0);
}
}
echo "<p>Threads deleted successfully! It is recommended that you <a href=\"misc.php?s=$session[sessionhash]\">update counters</a>
now.</p>";
}
That's it. It seems to work on my board, but I have only pruned selectively and tested minimally. I will be very cautious using this for a while until it is well proven.
Amy
|