vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Board Optimization - vB AJAX Cron (https://vborg.vbsupport.ru/showthread.php?t=123719)

Code Monkey 08-11-2006 10:00 PM

vB AJAX Cron
 

This is such a small but useful mod that I decided to give it away free. This mod will replace your sheduled task image code at the bottom of your pages and run your sheduled tasks via an AJAX call.

AJAX is asyncronous and offers true background running of sheduled tasks. This does not change anything with the actual tasks or the scripts that run them. It merely replaces the method that initiates the running of those scripts.

There are no template edits of any kind. Simply upload the files to your forumhome directory and import the product xml file.

This should work in any vb or custom script in any directory.
Full support will only be given at vbmodder.com

I will support it here as time permits.


Enjoy

Don't forget to click install if you use it.




******************************************
Do not use this with vb 3.5x! There is a difference in the cron table.
The 3.5x version can be found here






Code:

ekd12x0002w#rt2200cmvbm

alraqee 08-12-2006 01:17 AM

Oops

first replay

i will try it soon

ArabSQuad 08-12-2006 03:41 AM

didn't really get what does the hack do ......

but thnx anyway .... :/

Code Monkey 08-12-2006 03:49 AM

Quote:

Originally Posted by ArabSQuad
didn't really get what does the hack do ......

but thnx anyway .... :/

Currently, when vb needs to run a sheduled task, it loads image code at the bottom of your forum page. Except it has a php file as the src of the img tag. This causes the php file to run which in turn runs the next scheduled task. This can, depending on the cron to run and the size of the site, cause a browser to seemingly hang until the script is finished running. This happens because this is a syncronous event. Meaning, it's waiting for the page to finish loading the image.

This mod replaces that with an asyncronous AJAX call to the cron script.

The image code has served vb well but with the advent of AJAX type methods there is a cleaner way to do it. That's what this does.

Cole2026 08-12-2006 03:50 AM

vBCron is run by a simple link to cron.php in an img tag. This link will activate cron and do updates, then output back to the img tags blank.gif. This mod eliminates that, and instead, uses AJAX processing to activate cron.

x3sphere 08-12-2006 04:01 AM

Great work, thanks! :)

bollie 08-12-2006 04:52 AM

where upload ajax_cron.php ?

Code Monkey 08-12-2006 05:49 AM

Quote:

Originally Posted by bollie
where upload ajax_cron.php ?

Notice that it's in a directory called "upload_the_contents_of_this_directory_to_forumhom e".

So just upload the contents of that, subdirectories intact, to your forumhome directory.

bollie 08-12-2006 06:01 AM

Thx ;)

Code Monkey 08-12-2006 01:04 PM

26 downloads and only 8 installs?

The button must be stuck! :D

Mohamed Ashraf 08-12-2006 02:14 PM

Installed but i didnt get what that mean " This works at vbModder.com with vba in a directory above forum home. Make sure you have your home and forumhome path info acp options filled in or it may not work on vba.
"

thank you
Regards,
Mohamed Ashraf

Eagle Creek 08-12-2006 02:18 PM

I dont understand?

Where is there any image used when using a cron? Crons are made to run automatic, aren't they?

redlabour 08-12-2006 02:21 PM

Thx - works great ! :D

Code Monkey 08-12-2006 02:26 PM

Quote:

Originally Posted by Mohamed Ashraf
Installed but i didnt get what that mean " This works at vbModder.com with vba in a directory above forum home. Make sure you have your home and forumhome path info acp options filled in or it may not work on vba.
"

thank you
Regards,
Mohamed Ashraf

On my site my vbadvanced is in the root directory and vBulletin is in the /forums directory below that.

in vBulettin Options->Site Name / URL / Contact Details there are two settings. Forum Url and Homepage Url. These must both be set or it will not function on your vba home page if you have it in a different directory.

The reason being is that AJAX (and for good security reasons) does not work on remote sites. It can only access files on the site your visiting. So the path has to be set to the file using /dir/dir/file type structure instead of http://site.ext/dir/dir/file. To accomplish this I had to compare the two settings above in order to change the path to cron.php when on a vba page that is in another directory.

I hope that helps

Code Monkey 08-12-2006 02:31 PM

Quote:

Originally Posted by Eagle Creek
I dont understand?

Where is there any image used when using a cron? Crons are made to run automatic, aren't they?

It's only there if a cron is scheduled to run at time of page load.

In the footer of your page you should see this.

Code:

    <!-- Do not remove  or your scheduled tasks will cease to function -->

    <!-- Do not remove  or your scheduled tasks will cease to function -->

When vb needs to run a task it inserts the image code there. When it does not need to run a task it leaves it blank. This mod elimates that mess and runs the task in the background with an XHR (AJAX) call to the file. Much cleaner.

I should add that just as vb does not insert the image code when there is no task to run. Likewise, this script does nothing, and inserts nothing, not even the link to the javascript file, when there is no task to run.

unitedpunjab 08-12-2006 03:14 PM

Installed
how do i make sure its working properly

Code Monkey 08-12-2006 03:30 PM

Quote:

Originally Posted by unitedpunjab
Installed
how do i make sure its working properly

If your site is busy it is unlikely that you will often win the "load the cron" lottery. :D

There are several ways to view what is happening and if it is happening.

Use Firefox, if you don't already, and get the wonderful Firebug extension. This extension allows you to see many things including all AJAX calls and their responces on any site you visit. Then if you are the lucky one that vb decides will cause the next cron to run, you will see it happen in Firebug.

Another way is to go into your scheduled task log setting in your ACP and empty the log by deleting any logs over 0 days old. Then you can come back later and see if those crons that are set to record a log have run.

Ultimately this is one of those mods that does a wonderful thing but it does it behind the scenes. It's not glamorous, it's functional.

unitedpunjab 08-12-2006 03:39 PM

Thx for the Firebug ;)

Code Monkey 08-12-2006 03:51 PM

Quote:

Originally Posted by unitedpunjab
Thx for the Firebug ;)

Use that baby on a site that missuses AJAX to auto refresh data, such as AJAX chat, and you will see why they are a resource hog. That is if you can keep up with the scrolling.

Floris 08-12-2006 05:09 PM

Quote:

Originally Posted by Code Monkey
26 downloads and only 8 installs?

The button must be stuck! :D

This is common - no need to plug users to go and click it.

Code Monkey 08-12-2006 05:18 PM

Quote:

Originally Posted by Floris
This is common - no need to plug users to go and click it.

I'm quite familiar with what is common around here. I was mocking the faulty system. Was a joke. Lighten up ;)

Lizard King 08-12-2006 09:51 PM

This is a great idea and working perfectly. Thanks for this Code Monkey

Code Monkey 08-12-2006 11:13 PM

You're welcome and thank you.

nicedreams 08-13-2006 02:32 AM

Ok, 2 questions:

1 - How do you correct the link path to not get file not found errors on custom vb pages.

File does not exist: /home/thep/public_html/goto/all_galleries/ajax_cron.php

2 - Why do you not have to edit the footer template to take out the cronimage?

Jimmy

Code Monkey 08-13-2006 02:49 AM

1. That is most likely happening because your Homepage url and Forumpage url settings, in vBulettin Options->Site Name / URL / Contact Details, are wrong. Please post what those settings are.

2. Because this mod takes care of all template edits and disposal on the fly.

Code Monkey 08-13-2006 02:54 AM

Actually, I think I see what you mean in number one. I think I have a way around that.

Code Monkey 08-13-2006 03:08 AM

I'm going to need a link to those pages.

nicedreams 08-13-2006 03:31 AM

Quote:

Originally Posted by Code Monkey
Actually, I think I see what you mean in number one. I think I have a way around that.

I dropped some code for the link and forumdir and changed the link to:

$_link = "/forums/ajax_cron.php";

And that works on all vb pages custom or not for my site.

Jimmy

Code Monkey 08-13-2006 03:35 AM

But that will break it for many other sites so it is not a solution.

nicedreams 08-13-2006 03:42 AM

Quote:

Originally Posted by Code Monkey
But that will break it for many other sites so it is not a solution.

Well, it shouldn't be too hard to figure out based on what I said.

It is looking for /home/thep/public_html/goto/all_galleries/ajax_cron.php from /home/thep/public_html/goto/all_galleries/index.php when it should be looking for /home/thep/public_html/forums/ajax_cron.php

Something to do with your forumdir or string change functions.

Jimmy

Code Monkey 08-13-2006 03:46 AM

Well, in your solution, when you are in the goto/all_galleries directory and the cron fires you are going to get the following error.

File does not exist: /home/thep/public_html/goto/all_galleries/forums/ajax_cron.php

You haven't gotten it yet because there was most likely no cron to run at that time.

nicedreams 08-13-2006 03:55 AM

Quote:

Originally Posted by Code Monkey
Well, in your solution, when you are in the goto/all_galleries directory and the cron fires you are going to get the following error.


File does not exist: /home/thep/public_html/goto/all_galleries/forums/ajax_cron.php

You haven't gotten it yet because there was most likely no cron to run at that time.

No, I changed the code so the final $_link is $_link = "/forums/ajax_cron.php"; which would be /home/thep/public_html/forums/ajax_cron.php

Jimmy

Code Monkey 08-13-2006 04:13 AM

No it won't be if you are in goto/galleries. The link code gets appended to the current working directory. But hey, do as you wish. I can't help you without a link so I will come up with a solution that best works for eveyone.

Have a nice day.

Code Monkey 08-13-2006 04:39 AM

One option I have is to just use the full link in $vbulletin->options['bburl']. The problem with that is the security measures of http and AJAX requests. If the url in $vbulletin->options['bburl'] has http://www.site.com and someone is on your site having typed in http://site.com without the www then it will give a no permision error. And visa versa. The domain must be the same.

I think I will just try that and see if I can detect the difference.

bollie 08-13-2006 05:52 AM

Database error in vBulletin 3.6.0:

Invalid SQL:

SELECT usergroupid FROM icon AS icon
INNER JOIN imagecategorypermission USING (imagecategoryid)
WHERE icon.iconid = 1
AND usergroupid IN ();

MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 4
Error Number : 1064
Date : Saturday, August 12th 2006 @ 04:50:14 PM
Script : http://www.xxxxxxxxx/forum/ajax_cron.php?rand=50548
Referrer : http://www.xxxxxxxxxx/forum/arcade.php?&act=Arcade
IP Address : xxxxxxxxxxxxxxx
Username : Niet geregistreerd
Classname : vB_Database

Code Monkey 08-13-2006 06:10 AM

That has nothing to do with this mod. This mod doesn't change any of the crons that run. Nor does it use any mysql functions. Something is wrong on that page.

Code Monkey 08-13-2006 06:15 AM

Updated. This should now work on any pages. The problem above should be fixed. The fix actually eliminated many lines of php code.

Code Monkey 08-13-2006 06:26 AM

If you just downloaded the update you need to re-download. I put the wrong js file in. Time for bed.

redlabour 08-13-2006 06:54 AM

Thx again for Update !

nicedreams 08-13-2006 01:18 PM

Quote:

Originally Posted by Code Monkey
No it won't be if you are in goto/galleries. The link code gets appended to the current working directory. But hey, do as you wish. I can't help you without a link so I will come up with a solution that best works for eveyone.

Have a nice day.

No, I changed the code like you just did for the update. Starting a link with a / puts it in the home html dir, it does not append it to the current dir.

Jimmy


All times are GMT. The time now is 07:14 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01377 seconds
  • Memory Usage 1,829KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (12)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete