Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2007, 07:28 PM
kofoid kofoid is offline
 
Join Date: Dec 2005
Location: Colorado
Posts: 291
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default cleanup.php / cleanup2.php

Hi - I am running 3.5.4 and these two cron jobs are REALLY slowing down my forums for up to 2 minutes at a time. Is there any reason I can't change these to run once a day? Is there anything I can comment out? Here's what I have in them:

cleanup.php:
PHP Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 3.5.4 - Licence Number XXXXXXXXXX
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2000-2006 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
if (!
is_object($vbulletin->db))
{
    exit;
}

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

$vbulletin->db->query_write("
    DELETE FROM " 
TABLE_PREFIX "session
    WHERE lastactivity < " 
intval(TIMENOW $vbulletin->options['cookietimeout']) . "
    ### Delete stale sessions ###
"
);

$vbulletin->db->query_write("
    DELETE FROM " 
TABLE_PREFIX "cpsession
    WHERE dateline < " 
intval(TIMENOW 3600) . "
    ### Delete stale cpsessions ###
"
);

//searches expire after one hour
$vbulletin->db->query_write("
    DELETE FROM " 
TABLE_PREFIX "search
    WHERE dateline < " 
. (TIMENOW 3600) . "
    ### Remove stale searches ###
"
);

// expired lost passwords and email confirmations after 4 days
$vbulletin->db->query_write("
    DELETE FROM " 
TABLE_PREFIX "useractivation
    WHERE dateline < " 
. (TIMENOW 345600) . " AND
    (type = 1 OR (type = 0 and usergroupid = 2))
    ### Delete stale password and email confirmation requests ###
"
);

// old forum/thread read marking data
$vbulletin->db->query_write("
    DELETE FROM " 
TABLE_PREFIX "threadread
    WHERE readtime < " 
. (TIMENOW - ($vbulletin->options['markinglimit'] * 3600))
);
$vbulletin->db->query_write("
    DELETE FROM " 
TABLE_PREFIX "forumread
    WHERE readtime < " 
. (TIMENOW - ($vbulletin->options['markinglimit'] * 3600))
);

//[p:cron_script_cleanup]
if ($vbulletin->options['vbpager_delete_read'])
     {
if (!
function_exists("vbpager_totalpager"))
{
function 
vbpager_totalpager($userid 0)
{
    global 
$vbulletin;

    if (
$userid 0)
     {
        
$result $vbulletin->db->query_first("SELECT count(*) AS totalpager 
                    FROM " 
TABLE_PREFIX "pagerreceipt 
                    WHERE (userid = 
$userid AND active = 1 ) 
                    OR (touserid = 
$userid AND markdeleted = 0)");
        
$totalpager    intval($result['totalpager']);
        return 
$totalpager;
     }
    return 
0;
}
}
if (!
function_exists("vbpager_totalunread"))
{
function 
vbpager_totalunread($userid 0)
{
    global 
$vbulletin;
    if (
$userid 0)
     {
        
$result $vbulletin->db->query_first("SELECT count(*) AS totalpager 
                    FROM " 
TABLE_PREFIX "pagerreceipt 
                    WHERE (touserid = 
$userid AND markdeleted = 0) 
                    AND readtime = 0"
);
        
$totalpager    intval($result['totalpager']);
    
        return 
$totalpager;
     }
}
}

if (!
function_exists("vbpager_updatedb"))
{

function 
vbpager_updatedb($uid 0)
{
    global 
$vbulletin;
    
$pagerusers $vbulletin->db->query_read("SELECT userid 
                        FROM " 
TABLE_PREFIX "user " .
                        
iif($uid 0" WHERE userid = '$uid' "' ') . 
                        ORDER BY userid"
);        
    
$i    0;
    while (
$pageruser $vbulletin->db->fetch_array($pagerusers))
     {        
         
$userid        $pageruser['userid'];
         
$sumpager    vbpager_totalpager($userid);
         
$unreadsum    vbpager_totalunread($userid);

        
$i++;
         
$vbulletin->db->query_write("UPDATE " TABLE_PREFIX "user SET 
                 pagertotal = '
$sumpager', pagerunread = '$unreadsum
                 WHERE userid = 
$userid ");
     }    
    return 
$i;
}
}


// Orphaned pagertext records are removed after one hour.
// When we delete PAGERs we only delete the pager record, leaving
// the pagertext record alone for this script to clean up


$result    $vbulletin->db->query(
        UPDATE " 
TABLE_PREFIX "pagerreceipt
        SET markdeleted =1, active = 0 WHERE readtime > 0"
);
     }

$result    $vbulletin->db->query(
        DELETE FROM " 
TABLE_PREFIX "pagerreceipt
        WHERE active = 0 AND markdeleted = 1"
);
                             
$pagertexts $vbulletin->db->query_read("
        SELECT p.pagerid FROM " 
TABLE_PREFIX "pagertext AS p 
        LEFT JOIN " 
TABLE_PREFIX "pagerreceipt AS r  
        USING (pagerid) WHERE r.pagerid is NULL"
);


if (
$vbulletin->db->num_rows($pagertexts))
{
    
$pids '0';
    while (
$pager $vbulletin->db->fetch_array($pagertexts))
    {
        
$pids .= ",$pager[pagerid]";
    }
    
$vbulletin->db->query_write("DELETE FROM " TABLE_PREFIX "pagertext WHERE pagerid IN($pids)");
}
$vbulletin->db->free_result($pagertexts);
    if (
$vbulletin->options['vbpager_delete_read'])
     {
$result vbpager_updatedb();
     }
//[/p:cron_script_cleanup]

log_cron_action('Hourly Cleanup #1 Completed'$nextitem);

/*======================================================================*\
|| ####################################################################
|| # Downloaded: 10:18, Tue Aug 15th 2006
|| # CVS: $RCSfile: cleanup.php,v $ - $Revision: 1.33 $
|| ####################################################################
\*======================================================================*/
?>

cleanup2.php:
PHP Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 3.5.4 - Licence Number XXXXXXXXXXX
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2000-2006 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
if (!
is_object($vbulletin->db))
{
    exit;
}

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

$vbulletin->db->query_write("
    DELETE FROM " 
TABLE_PREFIX "session
    WHERE lastactivity < " 
intval(TIMENOW $vbulletin->options['cookietimeout']) . "
    ### Delete stale sessions ###
"
);

// posthashes are only valid for 5 minutes
$vbulletin->db->query_write("
    DELETE FROM " 
TABLE_PREFIX "posthash
    WHERE dateline < " 
. (TIMENOW 300)
);

// expired registration images after 1 hour
$vbulletin->db->query_write("
    DELETE FROM " 
TABLE_PREFIX "regimage
    WHERE dateline < " 
. (TIMENOW 3600)
);

// expired cached posts
$vbulletin->db->query_write("
    DELETE FROM " 
TABLE_PREFIX "post_parsed
    WHERE dateline < " 
. (TIMENOW - ($vbulletin->options['cachemaxage'] * 60 60 24))
);

// Orphaned Attachments are removed after one hour
$attachdata =& datamanager_init('Attachment'$vbulletinERRTYPE_SILENT);
$attachdata->set_condition("attachment.postid = 0 AND attachment.dateline < " . (TIMENOW 3600));
$attachdata->delete();

// Orphaned pmtext records are removed after one hour.
// When we delete PMs we only delete the pm record, leaving
// the pmtext record alone for this script to clean up
$pmtexts $vbulletin->db->query_read("
    SELECT pmtext.pmtextid
    FROM " 
TABLE_PREFIX "pmtext AS pmtext
    LEFT JOIN " 
TABLE_PREFIX "pm AS pm USING(pmtextid)
    WHERE pm.pmid IS NULL
"
);
if (
$vbulletin->db->num_rows($pmtexts))
{
    
$pmtextids '0';
    while (
$pmtext $vbulletin->db->fetch_array($pmtexts))
    {
        
$pmtextids .= ",$pmtext[pmtextid]";
    }
    
$vbulletin->db->query_write("DELETE FROM " TABLE_PREFIX "pmtext WHERE pmtextid IN($pmtextids)");
}
$vbulletin->db->free_result($pmtexts);

log_cron_action('Hourly Cleanup #2 Completed'$nextitem);

/*======================================================================*\
|| ####################################################################
|| # Downloaded: 10:18, Tue Aug 15th 2006
|| # CVS: $RCSfile: cleanup2.php,v $ - $Revision: 1.23 $
|| ####################################################################
\*======================================================================*/
?>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:32 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03713 seconds
  • Memory Usage 2,323KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete