8
This is what I did to modify
irmtfan's script to use the main configuration of XOOPS. It works to some extend because of my poor php knowledge.
1. I need to display the Admin name to be sure that the user has the proper permission to delete old PMs.
2. I would like to have a dropdown box to select number of days to delete such as 5, 10, 15, 30, 60 etc...
3. I would like to see a result of how many messages were deleted.
4. I DO NOT KNOW how to implement all of the above features. If anyone can help, please share your script.
5. THIS SCRIPT HAS NO WARRANTY.
Quote:
<?php
include "mainfile.php";
include "header.php";
/*
define("XOOPS_DB_USER", "username"); // write user of your database here
define("XOOPS_DB_PASS", "password"); // write password here
define("XOOPS_DB_HOST", "localhost"); // change it if your localhost is different
define("XOOPS_DB_NAME", "xoops"); //write name of your database here
$cxn = mysql_connect(XOOPS_DB_HOST , XOOPS_DB_USER, XOOPS_DB_PASS);
mysql_select_db(XOOPS_DB_NAME);
*/
if ($xoopsUserIsAdmin){
$delete_day = "30"; //Plan to use a drop-box to select day: 5, 10, 15, 30, 60, 90 etc...
echo "<br />Delete Days: $delete_day";
//$delete_time = time() - ( 30 * 24 * 60 * 60 ); // 30 days/month * 24 hrs/day
// * 60 minutes/hour * 60 seconds/min.
$delete_time = time() - ( ("$delete_day") * 24 * 60 * 60 );
echo "<br />Delete time is: $delete_time"; //Show delete time
echo "<br />The admin is: $xoopsUserIsAdmin"; //Show admin ID
$sql = "DELETE FROM `xoops_priv_msgs` WHERE `read_msg` = '0' AND `msg_time` < '$delete_time'";
//This script would delete everything older than 30 days that has been not read.
//note: if your perfix is different plz notice that change the 'xoops' with your perfix at 'xoops_priv_msgs' table
//$result = mysql_query($sql, $cxn);
echo "<br />Old Unread Private Messages Deleted: $delete_count"; //Need to count, but don't know how yet.
}else{
redirect_header("index.php",0);
exit();
}
include "footer.php";
?>