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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2005, 10:41 AM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default class making page blank

this is my first ever class so i'm not sure why it's going wrong or where but hey it's the only way i'll learn right?

could someone tell me where i'm going wrong, it's based off of Boofo's stats serialize hack

PHP Code:
<?php

class DoStats
{

    var 
$prs_stats = array();
    var 
$updatetime;
    
// var TIMENOW;

    
function DoStats($prs_stats$updatetime)
    {
        
$this->updatetime $updatetime;
        
//$this->prs_stats = $prs_stats;

        
if (!$this->prs_stats['lastupdate'])
        {
            
$this->prs_stats['lastupdate'] = 0;
        }

        if (
$prs_stats['lastupdate'] == OR ($prs_stats['lastupdate'] + ($this->updatetime 60)) < TIMENOW)
        {
            
$starttime mktime(000date('m'), date('d'), date('Y'));

            
// Total Pieces
            
$stats_totalpieces = @$DB_site->query_first("
                SELECT COUNT(*) AS count
                FROM prs_pieces
            "
);

            
// Total Reviews
            
$stats_totalreviews = @$DB_site->query_first("
                SELECT COUNT(*) AS count
                FROM prs_reviews
            "
);
    
            
// Average Rating
            
$stats_avgrate = @$DB_site->query_first("
                SELECT AVG(rating) AS avg
                FROM prs_rating
            "
);

            
// Top Rated Piece
            
$stats_toprated = @$DB_site->query_first("
                SELECT COUNT(prs_ratings.rating) AS count, *
                FROM prs_ratings
                LEFT JOIN prs_pieces ON (prs_pieces.pieceid = prs_rating.pieceid)
                ORDER BY count
                DESC LIMIT 1
            "
);

            
// might need to change this into a quick query of select from piece 'review_count' order by review count
            // Top Reviewed
            
$stats_topreviewed = @$DB_site->query_first("
                SELECT COUNT(prs_reviews.pagetext) AS count, *
                FROM prs_reviews
                LEFT JOIN prs_pieces ON (prs_pieces.pieceid = prs_reviews.pieceid)
                ORDER BY count
                DESC LIMIT 1
            "
);

            
// Top Viewed
            
$stats_topviewed = @$DB_site->query_first("
                SELECT *
                FROM prs_views
                ORDER BY views
                DESC LIMIT 1
            "
);

            
// Top Poster
            
$stats_topposter = @$DB_site->query_first("
                SELECT *
                FROM prs_user
                ORDER BY pieces DESC
                LIMIT 1
            "
);

            
// Top Reviewer
            
$stats_topreviewer = @$DB_site->query_first("
                SELECT *
                FROM prs_user
                ORDER BY reviews DESC
                LIMIT 1
            "
);

            
$prs_stats['totalpieces'] = intval($stats_totalpieces[count]);
            
$prs_stats['totalreviews'] = intval($stats_totalreviews[count]);
            
$prs_stats['avgrate'] = intval(ceil($stats_avgrate[avg]));
            
$prs_stats['toprated'] = $stats_toprated[title];
            
$prs_stats['toprated_pieceid'] = intval($stats_toprated[pieceid]);
            
$prs_stats['topreviewed'] = $stats_topreviewed[title];
            
$prs_stats['topreviewed_pieceid'] = intval($stats_topreviewed[pieceid]);
            
$prs_stats['topviewed'] = $stats_topviewed[title];
            
$prs_stats['topviewed_pieceid'] = intval($stats_topviewed[pieceid]);
            
$prs_stats['topposter'] = $stats_topposter[username];
            
$prs_stats['topposterid'] = intval($stats_topposter[userid]);
            
$prs_stats['topreviewer'] = $stats_topreviewer[username];
            
$prs_stats['topreviewerid'] = intval($stats_topreviewer[userid]);

            
$prs_stats['lastupdate'] = intval(TIMENOW);

            
$DB_site->query ("
                REPLACE INTO " 
TABLE_PREFIX "datastore(title, data)
                VALUES ('prs_stats', '" 
addslashes(serialize($prs_stats)) . "')
            "
);

            
$this->DoStats $prs_stats;
            
// should return the array prs_stats
        
}
        else
        {
            
$this->DoStats $prs_stats;
            
//return array prs_stats;
        
}
        return 
$this->DoStats;
    }

    function 
StatsFormat($prs_stats)
    {
        foreach(
$prs_stats AS $key => $value)
        {
            if (
is_numeric($value))
            {
                
$this->GetStats[] = vb_number_format($value);
            }
            else
            {
                
$this->GetStats[] = $value
            
}
        }
        return 
$this->GetStats;
    }
}

?>
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 04:10 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.04231 seconds
  • Memory Usage 2,299KB
  • Queries Executed 12 (?)
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
  • (1)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