remove old topics by date

Started by tesser, August 06, 2010, 12:53:12 AM

Previous topic - Next topic

tesser

Is there any way to remove old posts by date and not by  how many days it has not been posted in ?

RC3

Kill Em All

Well there is a problem with that, what if you have a topic that hasn't been posted in awhile but then it is bumped and brought back to life.

You would be getting rid of posts that you don't want to be getting rid of, and possibly entire topics.


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

Oranos

#2
you can run this code, it should do what you want:


<?php
require_once(dirname(__FILE__) . '/SSI.php');
global 
$smcFunc$user_info;

if(isset(
$_POST['submit']) && $user_info['is_admin']){
$delete_time $_POST['delete_time'];
$operation $smcFunc['db_query']('''
DELETE FROM {db_prefix}messages
WHERE poster_time < {int:time}'
,
array(
'time' => strtotime($delete_time),
)
);
echo $operation '<div style="text-align: center; color: green;">Operation completed successfully</div>' '<div style="text-align: center; color: red;">There was an error...</div>';
}else if(
$user_info['is_admin'])
echo '
<form action="delete_post.php" method="post">
<div style="text-align: center;">Enter Date (mm/dd/yyyy): <input type="text" name="delete_time" /> <input type="submit" name="submit" value="Submit" /></div>
</form>'
;
else
echo '<div style="text-align: center;">Go Away...</div>';
?>



You should be able to just put that in a php file named "delete_post" in your smf install dir and run it from your web browser. Just put in the date you want in the text box and click submit. The format should be mm/dd/yyyy, but the script will tell you that anyway. All post before that day will be deleted. Also, only logged on administrators can run that script, as a security precaution.

EDIT:

Remember to recount totals and statistics after running this.

tesser

thank you il give it a go  once my back up is done

the reason i need to delete posts from a certain date is they contain links from  a 2 nd site i once had and that site is now gone so hence dead links there is about 2000 posts and thats alot to move one by one

tesser

The code above works in every way but  the posts are still in place  i installed to where my smf is  then run it from my browser  entered the date wanted hit submit and got a green Operation completed successfully but there still there ??

any ideas ?

Deaks

tesser did yuo get this working?
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Advertisement: