Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

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
  #42  
Old 04-14-2005, 05:49 PM
epic1 epic1 is offline
 
Join Date: Jan 2005
Location: Chicago, Illinois
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Has anyone integrated phpadsnew with magnus's AdColumns1.0 ?

I want to add a sidebar that rotates the display order on my forum on every refresh. I already have the zone and ads setup, just not sure how to deliver it with this script.
Reply With Quote
  #43  
Old 04-16-2005, 11:04 AM
bL@De bL@De is offline
 
Join Date: Feb 2004
Location: Adelaide, Australia
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,
I've struck a slight problem which I can't workout. I have tested the following on my internal test site which works flawlessly following the instructions on page 1 however no matter what I do it doesn't show the banner.

My phpinclude_start is as follows
Quote:
if (@include(getenv('DOCUMENT_ROOT').'/sponsors/phpadsnew.inc.php')) {
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('', 0, '_blank', '', '0', $phpAds_context);
}
I've then put in my header
Quote:
<center>$phpAds_raw[html] <center />
I've removed the 'center' part but the problem is persisting that's for sure. No error bounces back just no banners are displayed and the pages looks as normal as it normally is.

Any ideas would be great.

Cheers
Darren
Reply With Quote
  #44  
Old 04-20-2005, 01:44 AM
Pulsorock Pulsorock is offline
 
Join Date: Oct 2001
Posts: 111
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm using Max Media Manager 0.1x (same as PAN2.1) but I can't make it work. The phpinclude_start has this:
PHP Code:
ob_start();
    if (@include(
getenv('DOCUMENT_ROOT').'/maxserver/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_local (''500'_blank''''0'$phpAds_context);
    }
ob_end_clean(); 
But on the forum I get Database error
Quote:
Database error in vBulletin 3.0.3:

Invalid SQL:
SELECT
user.username, (user.options & 512) AS invisible, user.usergroupid,
session.userid, session.inforum, session.lastactivity,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
FROM session AS session
LEFT JOIN user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > 1113963706
ORDER BY username ASC

mysql error: Table 'maxmediamanager.user' doesn't exist

mysql error number: 1146

Date: Tuesday 19th of April 2005 10:36:46 PM
Script: http://www.pulsorock6.com:8081/foro/?styleid=5
Any idea? :disappointed:
Reply With Quote
  #45  
Old 04-21-2005, 11:29 AM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Pulsorock
I'm using Max Media Manager 0.1x (same as PAN2.1) but I can't make it work. The phpinclude_start has this:
PHP Code:
ob_start();
    if (@include(
getenv('DOCUMENT_ROOT').'/maxserver/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_local (''500'_blank''''0'$phpAds_context);
    }
ob_end_clean(); 
But on the forum I get Database error

Any idea? :disappointed:
Not familiar with MaxMediaManager, but your view_local function call isn't specifying a zone, and the PHP Ads new function is view_raw.

Also, is you're ad server on the same machine as your vbulletin? If not that would explain the SQL error, which appears to be caused by the SQL server you're talking to not having the appropriate table.
Reply With Quote
  #46  
Old 04-27-2005, 05:13 AM
sdsvtdriver sdsvtdriver is offline
 
Join Date: Mar 2005
Posts: 77
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Michael,

Thanks for the information. It works great.

Oddly enough, on my first site, it gives me the option to use local invocation, but on the second, only javascript.

This is probably due to the fact the second site is on a different webserver, but alas, it works.

Thanks again
Reply With Quote
  #47  
Old 06-14-2005, 03:03 AM
cerebro's Avatar
cerebro cerebro is offline
 
Join Date: Dec 2001
Posts: 77
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i have a logout problem whit this code...some1 test if can logout whit this code on?
Reply With Quote
  #48  
Old 06-17-2005, 09:51 PM
GetGamer.com GetGamer.com is offline
 
Join Date: Jul 2004
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For the life of me, I can't get this to work. Here is my phpinclude_start template:
PHP Code:
/*
// Example of how to include a seperate file:

ob_start();
include('yourheader.html');
$your_code = ob_get_contents();
ob_end_clean();

// Now place a reference to $your_code where you want the resulting HTML to be displayed.
// This will most likely be the header or footer template.
*/

    
if (@include(getenv('DOCUMENT_ROOT').'/a/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_raw ('zone:24'0'''''0'$phpAds_context);
    } 
The invocation code was cut-and-pasted from phpAdsNew (which I've been using successfully with Javascript invocation for ages).

And here is a snippet from my footer template showing two different zones, one with local invocation and the other with javascript:
PHP Code:
<!-- 120 x 600 zone -->            
$phpAds_raw[html]
<
br />
<!-- 
120 x 240 zone -->
<
script language='JavaScript' type='text/javascript'>
<!--
   if (!
document.phpAds_useddocument.phpAds_used ',';
   
phpAds_random = new String (Math.random()); phpAds_random phpAds_random.substring(2,11);
   
   
document.write ("<" "script language='JavaScript' type='text/javascript' src='");
   
document.write ("http://www.bigblueball.com/a/adjs.php?n=" phpAds_random);
   
document.write ("&amp;what=zone:19");
   
document.write ("&amp;exclude=" document.phpAds_used);
   if (
document.referer)
      
document.write ("&amp;referer=" escape(document.referer));
   
document.write ("'><" "/script>");
//-->
</script><noscript><a href='http://www.bigblueball.com/a/adclick.php?n=aa4c0db4' target='_blank'><img src='http://www.bigblueball.com/a/adview.php?what=zone:19&amp;n=aa4c0db4' border='0' alt=''></a></noscript
The javascript invocation method works fine, but not the local method. You can see this in action here. Note that the ads actually appear in the right-hand column, even though the are part of the footer template.

Any ideas as to why I can't get local invocation to work?

EDIT: As a test, I tried local invocation on a non-forum page at the same site, and it works fine. You can see this on http://www.bigblueball.com/index.php (it's serving the 120x90 ad in in the right column). Still can't get it to work in the forums though.

EDIT: After re-pasting the invocation code a second time, it seems to be working now. Nevermind.....
Reply With Quote
  #49  
Old 06-23-2005, 05:43 AM
Trana Trana is offline
 
Join Date: Apr 2005
Posts: 604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am experiencing a strange problem when using this script.

To begin with, I originally added the banner to my page with the ob method described on the vbulletin website. When I found this thread, I removed those methods and added the php code directly to the include file as described here.

The banners work fine.

Unfortunately, I have a "shoutbox" module (CMPS) which is not working now that I added the phpadsnew script to my header. The shoutbox has not displayed properly with either method of calling the phpadsnew script.

The reason that I know these two are related, is that in the shoutbox module window, I get the following error message:

Table 'bannerads.adv_shoutbox' doesn't exist

So obviously, phpadsnew is changing the database from "forum" to "bannerads", running the script, and then for some reason not going back to the original database. I am guessing that it needs to do a USE FORUM sql statement in order to get the default database back into the focus.

So, do you think it is the phpadsnew or the shoutbox that needs the tweak? Any ideas on what could be causing this?

Thanks.
Reply With Quote
  #50  
Old 07-06-2005, 03:02 PM
jsharper jsharper is offline
 
Join Date: Jun 2005
Location: Gilbert, AZ, US
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by cerebro
i have a logout problem whit this code...some1 test if can logout whit this code on?
I'm also having a logout problem. Whenever my phpinclude_start is calling phpadsnew.inc.php, my vBulletin logout function is broken. clicking Log Out just returns a blank page and doesn't actually perform the logout.

Ideas? I'm using vBulletin 3.0.7 and phpAdsNew 2.0.5. I did try both with and without "Use database compatibility mode".
Reply With Quote
  #51  
Old 07-07-2005, 04:04 PM
Razasharp's Avatar
Razasharp Razasharp is offline
 
Join Date: Feb 2005
Location: UK
Posts: 373
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for a brill tutorial Michael!

Can I just ask you to check what I'm doing is ok please? (It all seems to be working ok)

I have two zones on the same page and this is how I've set it up:

My phpinclude star file contains:

HTML Code:
if (@include(getenv('DOCUMENT_ROOT').'/adserver/phpadsnew.inc.php')) 

if (!isset($phpAds_context))
{
     $phpAds_context = array();
        $phpAds_raw = view_raw ('zone:2', 0, '_blank', '', '0', $phpAds_context);
}
{

$phpAds_context2 = array();
        $phpAds_raw2 = view_raw ('zone:3', 0, '_blank', '', '0', $phpAds_context2);
 }
And the pages contain:

$phpAds_raw[html] -where I want the first zones ads to show, and,

$phpAds_raw2[html] -where I want zone two ads to show.

It all seems to be working fine, but just wondered if I have done it right or not!

Thanks for looking.
Reply With Quote
Reply

Thread Tools

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 10:31 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.04627 seconds
  • Memory Usage 2,353KB
  • 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
  • (1)bbcode_html
  • (8)bbcode_php
  • (5)bbcode_quote
  • (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