121 lines
3.8 KiB
PHP
121 lines
3.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
+--------------------------------------------------------------------------
|
|
| Invision Power Board v2.0.0
|
|
| =============================================
|
|
| by Matthew Mecham
|
|
| (c) 2001 - 2004 Invision Power Services, Inc.
|
|
| http://www.invisionpower.com
|
|
| =============================================
|
|
| Web: http://www.invisionboard.com
|
|
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
|
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
|
| Licence Info: http://www.invisionboard.com/?license
|
|
+---------------------------------------------------------------------------
|
|
|
|
|
| > TASK SCRIPT: Test
|
|
| > Script written by Matt Mecham
|
|
| > Date started: 28th January 2004
|
|
|
|
|
+--------------------------------------------------------------------------
|
|
*/
|
|
|
|
//-----------------------------------------
|
|
// THIS TASKS OPERATIONS:
|
|
// Rebuilds topics, posts, forum, members, last reg. member counts
|
|
//+--------------------------------------------------------------------------
|
|
|
|
if ( ! defined( 'IN_IPB' ) )
|
|
{
|
|
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
|
|
exit();
|
|
}
|
|
|
|
class task_item
|
|
{
|
|
var $class = "";
|
|
var $root_path = "";
|
|
var $task = "";
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// Our 'auto_run' function
|
|
// ADD CODE HERE
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function run_task()
|
|
{
|
|
global $DB, $ibforums, $std;
|
|
|
|
//-----------------------------------------
|
|
// Get current stats...
|
|
//-----------------------------------------
|
|
|
|
$stats = $DB->simple_exec_query( array( 'select' => '*', 'from' => 'cache_store', 'where' => "cs_key='stats'" ) );
|
|
|
|
$stats = unserialize(stripslashes($stats['cs_value']));
|
|
|
|
//-----------------------------------------
|
|
// Rebuild stats
|
|
//-----------------------------------------
|
|
|
|
$r = $DB->simple_exec_query( array( 'select' => 'count(*) as posts', 'from' => 'posts', 'where' => 'queued <> 1' ) );
|
|
$stats['total_replies'] = intval($r['posts']);
|
|
|
|
$r = $DB->simple_exec_query( array( 'select' => 'count(*) as topics', 'from' => 'topics', 'where' => 'approved = 1' ) );
|
|
$stats['total_topics'] = intval($r['topics']);
|
|
|
|
$stats['total_replies'] -= $stats['total_topics'];
|
|
|
|
$r = $DB->simple_exec_query( array( 'select' => 'count(*) as members', 'from' => 'members', 'where' => "mgroup <> ".$ibforums->vars['auth_group'] ) );
|
|
$stats['mem_count'] = intval( $r['members'] );
|
|
|
|
$r = $DB->simple_exec_query( array( 'select' => 'id, name',
|
|
'from' => 'members',
|
|
'where' => "mgroup <> ".$ibforums->vars['auth_group'],
|
|
'order' => 'id DESC',
|
|
'limit' => array(0,1)
|
|
) );
|
|
|
|
$stats['last_mem_name'] = $r['name'];
|
|
$stats['last_mem_id'] = $r['id'];
|
|
|
|
if ( count($stats) > 0 )
|
|
{
|
|
$DB->obj['use_shutdown'] = 0;
|
|
$ibforums->cache['stats'] = $stats;
|
|
$std->update_cache( array( 'name' => 'stats', 'array' => 1, 'deletefirst' => 1 ) );
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Log to log table - modify but dont delete
|
|
//-----------------------------------------
|
|
|
|
$this->class->append_task_log( $this->task, 'Statistics rebuilt' );
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// register_class
|
|
// LEAVE ALONE
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function register_class(&$class)
|
|
{
|
|
$this->class = $class;
|
|
|
|
$this->root_path = $this->class->root_path;
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// pass_task
|
|
// LEAVE ALONE
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function pass_task( $this_task )
|
|
{
|
|
$this->task = $this_task;
|
|
}
|
|
|
|
|
|
}
|
|
?>
|