Hello
I try to create a cron php file to physical delete all thread and post logicaly delete and have more than 2 month.
in a first time i just try to create a SQL as :
Code:
DELETE * FROM vb_post WHERE visible = 2 ....
But the post have more than one only table in the database. and i think that delete directly the post in the database is the wrong way .
So i try to create the next file, can you correct this ?
PHP Code:
<?php
error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
exit;
}
// tentative d'adaptation pour les Posts
// delete logical delete post
// note netah : mettre a jour ou en variable la condition de temps exemple avec 4 jours ...
$posts = $vbulletin->db->query_read("
SELECT postid
FROM " . TABLE_PREFIX . "post
WHERE visible='2' AND dateline < " . intval(TIMENOW - 345600) . "
");
while ($post = $vbulletin->db->fetch_array($posts))
{
$post['open'] = 10;
$postman =& datamanager_init('Post', $vbulletin, ERRTYPE_SILENT, 'threadpost');
$postman->set_existing($post);
$postman->delete(false, true, NULL, false);
unset($postman);
}
// fin de la tentative que nous esperons tous pas veine ....
// delete logical delete thread
// note netah : mettre a jour ou en variable la condition de temps exemple avec 4 jours ...
$threads = $vbulletin->db->query_read("
SELECT threadid
FROM " . TABLE_PREFIX . "thread
WHERE visible='2' AND dateline < " . intval(TIMENOW - 345600) . "
");
while ($thread = $vbulletin->db->fetch_array($threads))
{
$thread['open'] = 10;
$threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost');
$threadman->set_existing($thread);
$threadman->delete(false, true, NULL, false);
unset($threadman);
}
($hook = vBulletinHook::fetch_hook('cron_script_cleanlogicaldelete')) ? eval($hook) : false;
log_cron_action('', $nextitem, 1);
?>
i'm ready to explian anything you want about this problem ...
Best reguards !
netah