[REQ] Remove 1 Database Query Per Page

Remove 1 Database Query Per Page
Reduce your forums query usage !

Summary: (Quoted From Original Hack for vb3)

Removes 1 Query Per Page.

Instructions:

1. Open includes/class_core.php
2. Go to about line 2538 and look for


PHP:
$this->set('location', WOLPATH);

3. Above that, paste the following.


PHP:
$this->set('old_location', $session['location']);

4. Go to about line 2818 and look for the following:


PHP:
            // registered user 
            if (!SESSION_BYPASS) 
            { 
                if (TIMENOW - $this->userinfo['lastactivity'] > $this->registry->options['cookietimeout']) 
                { 
                    // see if session has 'expired' and if new post indicators need resetting 
                    $this->registry->db->shutdown_query(" 
                        UPDATE " . TABLE_PREFIX . "user 
                        SET 
                            lastvisit = lastactivity, 
                            lastactivity = " . TIMENOW . " 
                        WHERE userid = " . $this->userinfo['userid'] . " 
                    ", 'lastvisit'); 

                    $this->userinfo['lastvisit'] = $this->userinfo['lastactivity']; 
                } 
                else 
                { 
                        $this->registry->db->shutdown_query(" 
                            UPDATE " . TABLE_PREFIX . "user 
                            SET lastactivity = " . TIMENOW . " 
                            WHERE userid = " . $this->userinfo['userid'] . " 
                            ", 'lastvisit'); 
                } 
            }

5. Replace that with the following:

PHP:
            // registered user 
            if (!SESSION_BYPASS) 
            { 
                if (TIMENOW - $this->userinfo['lastactivity'] > $this->registry->options['cookietimeout']) 
                { 
                    // see if session has 'expired' and if new post indicators need resetting 
                    $this->registry->db->shutdown_query(" 
                        UPDATE " . TABLE_PREFIX . "user 
                        SET 
                            lastvisit = lastactivity, 
                            lastactivity = " . TIMENOW . " 
                        WHERE userid = " . $this->userinfo['userid'] . " 
                    ", 'lastvisit'); 

                    $this->userinfo['lastvisit'] = $this->userinfo['lastactivity']; 
                } 
                elseif ($this->vars['old_location'] != WOLPATH || THIS_SCRIPT == 'misc' || THIS_SCRIPT == 'online') 
                { 
                    $this->registry->db->shutdown_query(" 
                        UPDATE " . TABLE_PREFIX . "user 
                        SET lastactivity = " . TIMENOW . " 
                        WHERE userid = " . $this->userinfo['userid'] . " 
                        ", 'lastvisit'); 
                } 
            }
 
Back
Top