Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Using PHPadsnew 2 with Vbulletin 3.
Michael Morris's Avatar
Michael Morris
Join Date: Nov 2003
Posts: 774

Employee of Digital Media Graphix of Knoxville TN, currently developing a new framework / CMS

Knoxville TN
Show Printable Version Email this Page Subscription
Michael Morris Michael Morris is offline 01-30-2005, 10:00 PM

The following are some tips on using these two programs together, based on my own experience. It's expected that you know how to use phpadsnew 2 to set up ads and generate invocation code.

PHP Invocation
The first tip is how to use php invocation code. Using javascript is possible, but not all browsers support javascript and, in my experience, using php is faster.

The php invocation code phpadsnew generates will look something like this...

PHP Code:
<?php
    
if (@include(getenv('DOCUMENT_ROOT').'/phpads/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_raw ('zone:2'0'''''0'$phpAds_context);
        echo 
$phpAds_raw['html'];
    }
?>
Place it in your PHPINCLUDE_START template, but omit the final echo statement and the <?php ?> tags. It will look like this...

PHP Code:
    if (@include(getenv('DOCUMENT_ROOT').'/phpads/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_raw ('zone:2'0'''''0'$phpAds_context);
    } 
Now, to place the add, put the variable $phpAds_raw[html] in any template that you want that ad to appear (usually your header). Remember to omit the '' marks when placing the variable in a normal template - therefore $phpAds_raw['html'] becomes $phpAds_raw[html]

If you have multiple zones, you can string these together. On EN World we have a zone that only appears on our vbadvanced news page. On those pages we call the view_raw function an additional time for the extra zone (view_raw is the function that actually calls up the ad - the rest of the code initializes phpadsnew). Here's our code, as an example of a 2 zone system.

PHP Code:
if (@include(getenv('DOCUMENT_ROOT').'/phpads/phpadsnew.inc.php')) 
{
    if (!isset(
$phpAds_context)) 
    {
        
$phpAds_context = array();
        
$phpAds_raw view_raw ('zone:2'0'''''0'$phpAds_context);
        if (
defined('VBA_PORTAL'))
        {
            
$phpAds_context2 = array();
            
$phpAds_raw2 view_raw ('zone:3'0'''''0'$phpAds_context2);
        }
    }

Running Maintenance.php from the scheduled task manager
Ads new's maintenance.php file needs to run on a regular basis for it to perform correctly. You can invoke it from your scheduled task manager if you wish. If you do, I'd advise applying the following mod to the code of the maintenance.php file.

Open it and go to the ending ?> mark. Right about it add this.

PHP Code:
log_cron_action('PHP Ads New Maintenance Complete'$nextitem); 
And you're done. The file can now log it's cron action with vbulletin's cron manager. Note that if you make this change you will be unable to call the maintenance.php file without vbulletin since it will trigger a fatal error (call to undefined function). Also, there's a glitch in phpadsnew - when vbulletin invokes maintenance.php it somehow forgets that it was ever invoked. The log files both in vbulletin and in phpadsnew itself speak differently, but phpadsnew continues to echo a message saying the maintenance.php script hasn't been ran which can be ignored.

Any other tips/comments/questions welcomed.

PHP Ads New 2 is at http://www.phpadsnew
Reply With Quote
  #32  
Old 03-23-2005, 12:54 PM
cmiller1014 cmiller1014 is offline
 
Join Date: May 2004
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey pguy..... if that tossed no error before, you must be pasting the php code within the commented out area that already exists within the phpstart template.

Let me know. If you could set me up an admin that only has template access I can have this working for you in no time
Reply With Quote
  #33  
Old 03-23-2005, 07:22 PM
ssanders ssanders is offline
 
Join Date: Feb 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Michael, where exactly do I get my own invocation code? I can't seem to find a button inside the script.

As for the zones, i dont have any.
Reply With Quote
  #34  
Old 03-24-2005, 09:39 AM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To get phpadsnew to generate invocation code you need to go to publisher's & zones - it's in there somewhere.

@pguy> Post the entire contents of your phpinclude_start template into this thread in php bbcode tags, and I'll take a look.
Reply With Quote
  #35  
Old 03-24-2005, 08:06 PM
ssanders ssanders is offline
 
Join Date: Feb 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah i figured it out now. But it doesn't quite work on my froums... it shows up, but it gives me a "?>" at the end of the ad, and the banner is not clickable, but the text below it is :-\

Anyway I can talk to you on AIM?
Reply With Quote
  #36  
Old 03-26-2005, 03:26 AM
tgmorris tgmorris is offline
 
Join Date: Nov 2003
Posts: 180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've done this and it makes life easier rotating google ads with regular ads. The problem arises that it's possible to display a google ad on a non-allowed page. Any idea how to best handle this? It's certainly possible to assign the google ads to a separate zone. Dealing with login and register is pretty easy as they are labeled as such by 'THIS_SCRIPT'. However I believe the error pages are labeled as whatever script was running when the error condition was encountered.
Reply With Quote
  #37  
Old 03-27-2005, 06:32 PM
tgmorris tgmorris is offline
 
Join Date: Nov 2003
Posts: 180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did some experimenting and here's what I'm now using in my phpinclude_start template. I'm running phpAdsNew as my banner ad server and have my google ads served from there as well. I originally had things set up so no ads were placed on the google excluded pages but decided to place ads on all pages - just exclude google ads from the specific pages.

PHP Code:
do
{
    
// phpAdsNew stuff
    
if (@include(getenv('DOCUMENT_ROOT').'/phpAdsNew/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_raw (''0'''''0'$phpAds_context);
    }
} while (
strpos($phpAds_raw['html'], 'google_') AND
         (
           (
THIS_SCRIPT == 'login')          OR
           (
THIS_SCRIPT == 'register')       OR
           (
THIS_SCRIPT == 'usercp')         OR
           (
THIS_SCRIPT == 'private')        OR
           (
THIS_SCRIPT == 'subscription')   OR
           (
THIS_SCRIPT == 'profile')        OR
           (
THIS_SCRIPT == 'faq')            OR
           (
THIS_SCRIPT == 'sendmessage')    OR
          ((
THIS_SCRIPT == 'calendar')       AND $_REQUEST['do'] == 'add')    OR
          ((
THIS_SCRIPT == 'search')         AND $_REQUEST['searchid'] == '') OR
          ((
THIS_SCRIPT == 'gallery_search') AND $_REQUEST['searchid'] == '') OR
           (
THIS_SCRIPT == 'gallery_upload') OR
           (
THIS_SCRIPT == 'THIS_SCRIPT')
         )
        ); 
It's a bit brute force but eliminates the need for zones and such related to google in phpAdsNew.

The last line in the while looks a bit strange but the current version of vBa gallery comes through with things defined that way for upload at the moment, so this serves as a catchall of sorts.

An alternative approach, if you want to only serve ads on "allowed" pages is to do something like
PHP Code:
if (!(
       (
THIS_SCRIPT == 'login')          OR
       (
THIS_SCRIPT == 'register')       OR
       (
THIS_SCRIPT == 'usercp')         OR
       (
THIS_SCRIPT == 'private')        OR
       (
THIS_SCRIPT == 'subscription')   OR
       (
THIS_SCRIPT == 'profile')        OR
       (
THIS_SCRIPT == 'faq')            OR
       (
THIS_SCRIPT == 'sendmessage')    OR
      ((
THIS_SCRIPT == 'calendar')       AND $_REQUEST['do'] == 'add')    OR
      ((
THIS_SCRIPT == 'search')         AND $_REQUEST['searchid'] == '') OR
      ((
THIS_SCRIPT == 'gallery_search') AND $_REQUEST['searchid'] == '') OR
       (
THIS_SCRIPT == 'gallery_upload') OR
       (
THIS_SCRIPT == 'THIS_SCRIPT')
   ) )
{
  
// do ad stuff here

It's pretty easy to convert the latter one to run in the header using template conditionals.
Reply With Quote
  #38  
Old 03-29-2005, 11:26 AM
PuntoPower PuntoPower is offline
 
Join Date: Apr 2004
Posts: 37
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hi

plz forgive me if this has been asked before....

im using phpadsnew and vb3. i have one campaign with 5 ads, the code for this is in the header for vb3 forum. it works fine randomly displayin the ads on all the sub forums. but i have one section in the forum (a sub forum) i want it to display a certain ad. can i modify the phpadsnew code that is inserted with say an "if" statment to only allow a certain add for a section forum in my forum or is there another way around this

i hope the above makes sense
Reply With Quote
  #39  
Old 03-31-2005, 09:38 PM
camoman camoman is offline
 
Join Date: Oct 2004
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think I am looking for a similiar thing.. Basically I want to be able to have a unique zone for each forum... so banners at the top of each forum would be relevent to the forum title. ie. in the boat forum I only want boat related ads showing up, in the snowmobile forum I only want snowmobile ads showing up etc..

Can this be done??
Reply With Quote
  #40  
Old 04-02-2005, 02:43 AM
boiboi boiboi is offline
 
Join Date: Nov 2001
Location: san francisco, ca
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've been using phpadsnew for 3 years now with the remote invocation code because I have it in a subdomain. Will this little workaround work on a subdomain? I'm actually planning to move phpadsnew on a remote server.
Reply With Quote
  #41  
Old 04-07-2005, 09:23 PM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know - I'm sure there's a way, but it might involve some tinkering with the code.
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 09:12 AM.


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.05048 seconds
  • Memory Usage 2,339KB
  • Queries Executed 25 (?)
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
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (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_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
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete