Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
It seems to work well for what I wanted to do. I have the Hivemail integration mod installed, but it only updates new email on two different pages, categories.php and ubbthreads.php. These lines were added to the top of those pages:
[] // BEGIN HIVEMAIL INTEGRATION
define('UBBT_PLUGIN', true);require($config['hivemail_path'].'/includes/ubbthreads_plugin.php');update_newmail();
// END HIVEMAIL INTEGRATION
[/]

I however wanted to make it so new email updates in every page, much like IMs. I figured it wouldn't be much of a performance hit, one extra query per page. Is that sound logic?

Anyhow, to do this, I added these lines to main.inc.php:
[] $hackpath = "/home/laondal/public_html/foros";
include("$hackpath/hack.inc.php");
[/]

And I added this to the contents of a newly created hack.inc.php file (I got the idea from the Forum Design Integration forum, I think):

[] <?
define('UBBT_PLUGIN', true);
require('/home/laondal/public_html/correo/includes/ubbthreads_plugin.php');
update_newmail();
? [/]

Obviously, I had to remove the parts that had been added to the files previously altered in the hack before to avoid a redeclare type error. Now email updates on all pages, even while browsing PhotoPost powered galleries. I'm happy with this.

I however need to know whether this was a good idea or not and what kind of performance hit this would have on busier forums. I'm planning to update the instructions for the Hivemail mod and doing it the way I just did would certainly make it a lot easier, but I need to know if this is sound. Thanks!

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
well, main is loaded on every page view. So it could slow things down. It depends on exactly what the script you're including is doing.

I'd keep an eye on it and see if it makes things run slower.

If there's queries involved with the include, then just remember, it's doing that many queries on each page load.

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
All the script does is check to see if there are new emails in a user's inbox and updates the number accordingly when there are. I can't imagine the load would be much different than that of the IM function.

Does ubbt.inc.php get loaded with each page? Would it be any different including that blurb that is hack.inc.php in the ubbt.inc.php file?

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Yeah, every script includes main.inc.php - which then, in turn includes ubbt.inc.php - so both are loaded in every page. Doesn't matter what script you include it in.

If it's something that minor, then it shouldn't be a big deal at all. If the script you're including goes through some complex queries etc... then that load is added to every page. But if it's a simple check, it's probably nothing to worry about.

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
This is the function update_newmail():

[] function update_newmail() {
global $dbh, $config,${$config['cookieprefix']."w3t_myid"}, $options;
if (isset(${$config['cookieprefix']."w3t_myid"})) {
$Uid = addslashes(${$config['cookieprefix']."w3t_myid"});
$sth = $dbh -> do_query("SELECT hm_userid FROM {$config['dbname']}.{$config['tbprefix']}Users WHERE U_Number = $Uid");
list($hiveid) = $dbh -> fetch_array($sth);
if ($hiveid != "0") {
$query = "SELECT userid FROM {$options['database']}.hive_message WHERE userid = $hiveid AND status = 0 AND folderid != -2 AND folderid != -3 AND folderid != -4";
$sth = $dbh -> do_query($query);
$count=mysql_num_rows($sth);
if ($count > 0) {
$newemail = $count;
} else {
$newemail = "0";
}
$dbh -> do_query("UPDATE {$config['dbname']}.{$config['tbprefix']}Users SET hm_emails = $newemail WHERE hm_userid = $hiveid");
}
}
}
[/]
Does that appear that it would be overly taxing on the system resources now that it's called on everypage?

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Well it does add 3 queries to each page load. The x factor is how long or difficult the query is to the hive_message table. You might turn on the debug info and try with and without, see if it increases the time limits too much.

The first query done is basically looking for their hm_userid from the Users table. In the authenticate function, you're already doing a query on the user's table. So you could instead add that field into the authenticate function in ubbt.inc.php - then work the rest of the code inside the send_header function.

That would save one query on each page load.

You also could potentially save the third query. If you also queried the hm_emails field in the authentication function. Then you're counting the number of real emails. You could rig that third query so it only needs to update if the count was different than what you already had. No use in updating if the count is the same.

Then a majority of the time, you'd only be adding one query.

Of course, another factor, is that not everyone has the hivemail account. So if the check was added into the authenticate function, you wouldn't even have to check for the email if they don't have an account. Thus 0 new queries on those pages.

Joined: Jun 2002
Posts: 670
Code Monkey
Code Monkey
Offline
Joined: Jun 2002
Posts: 670
Maybe I'll just contract you to update the mod


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)