vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Using PHPadsnew 2 with Vbulletin 3. (https://vborg.vbsupport.ru/showthread.php?t=75475)

Michael Morris 01-30-2005 10:00 PM

Using PHPadsnew 2 with Vbulletin 3.
 
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

Michael Morris 02-26-2005 04:43 AM

Here's a way to prevent certain usergroups from being logged as having seen an ad (they'll still see them but the ad view won't be logged). In the file phpadsnew.inc.php find the following code:

PHP Code:

if ($phpAds_config['log_adviews'] && !$phpAds_config['log_beacon']) 

Directly above it add

PHP Code:

if (is_member_of($bbuserinfo6))
{
$phpAds_config['log_adviews'] = false;


If you need to use your phpadsnew installation for non vbulletin pages you'll need to create seperate versions of phpadnew.inc.php for vbulletin and your other pages to call.

FrankieFive 02-26-2005 05:22 AM

What should i put as the file name?

Michael Morris 02-26-2005 05:37 AM

phpads-vbulletin.inc.php would work

FrankieFive 02-27-2005 06:23 PM

I tried running the maintenance.php on my VBulletin 3.0.7 and wanted to make sure it was working so I tried to run it and got this error.

PhpAdsNew Maintenance

Warning: main(/www/adserver/maintenance/maintenance.php): failed to open stream: No such file or directory in /admincp/cronadmin.php on line 56

Fatal error: main(): Failed opening required '/www/adserver/maintenance/maintenance.php' (include_path='.:/usr/local/nf/lib/php') in /mnt/web_h/d48/s32/b0239134/www/forums/admincp/cronadmin.php on line 56

Michael Morris 02-28-2005 08:06 AM

Right there - the error message told me what I need to help you.. The absolute path to the file you want to include should be..

/mnt/web_h/d48/s32/b0239134/www/adserver/maintenance/maintenance.php

FrankieFive 02-28-2005 04:05 PM

Hi mike I tired what you said to put: (/mnt/web_h/d48/s32/b0239134/www/adserver/maintenan
I still get an error! How much will it cost to fix the problem for me?

PhpAdsNew Maintenance

Warning: main(/mnt/web_h/d48/s32/b0239134/www/adserver/maintenan): failed to open stream: No such file or directory in /admincp/cronadmin.php on line 56

Fatal error: main(): Failed opening required '/mnt/web_h/d48/s32/b0239134/www/adserver/maintenan' (include_path='.:/usr/local/nf/lib/php') in /mnt/web_h/d48/s32/b0239134/www/forums/admincp/cronadmin.php on line 56

ALcorn 02-28-2005 06:38 PM

FrankieFive, you need to adjust the number of caracters of the field filename of the table cron of your database because the default value of 50 caracters is not enought.

Try to run this query in the PHPMyAdmin:
Code:

ALTER TABLE `cron` CHANGE `filename` `filename` VARCHAR( 70 ) NOT NULL

FrankieFive 02-28-2005 08:12 PM

Quote:

Originally Posted by ALcorn
FrankieFive, you need to adjust the number of caracters of the field filename of the table cron of your database because the default value of 50 caracters is not enought.

Try to run this query in the PHPMyAdmin:
Code:

ALTER TABLE `cron` CHANGE `filename` `filename` VARCHAR( 70 ) NOT NULL

Is there a step by step instruction on how to do this?

Michael Morris 03-01-2005 09:22 AM

Quote:

Originally Posted by FrankieFive
Is there a step by step instruction on how to do this?

From the Admincp go to Import & Maintenance >> Execute SQL Query. Type int query exactly as given above.

If you get a "You don't have permission to run queries" error you'll need to edit your config.php file to give yourself permission to run queries.

FrankieFive 03-01-2005 06:32 PM

I tried submitting it and got an error enclosed is a picture of my phpadmin. Is there anything missing or needs to be corrected?
http://www.thespeedlounge.com/phpmyadmin.jpg
http://www.thespeedlounge.com/phpmyadmin002.jpg

Super Ted 03-01-2005 08:19 PM

I want to display several zones in a page. Is this possible in VB3?

Edit: Silly Question! Should have read all the thread!

I am getting a Permission denied error when I try and run the cron job for maintenance.php I have tried changing the file permissions to 777 (not the best idea!) but now I get

/pub/home/****/htdocs/adserver/maintenance/maintenance.php: cannot open ?php: no such file
/pub/home/****/htdocs/adserver/maintenance/maintenance.php: /bin/: permission denied
/pub/home/****/htdocs/adserver/maintenance/maintenance.php: /backup: symbolic link loop
/pub/home/****/htdocs/adserver/maintenance/maintenance.php: /backup: symbolic link loop
/pub/home/****/htdocs/adserver/maintenance/maintenance.php: /backup: symbolic link loop
/pub/home/****/htdocs/adserver/maintenance/maintenance.php: 7: Syntax error: "(" unexpected

What permissions should be set to allow this cron job to be run?

Super Ted 03-02-2005 08:33 PM

I have tried running the vbcron and get the same error as Frankie.

FrankieFive 03-02-2005 09:48 PM

Quote:

Originally Posted by Super Ted
I have tried running the vbcron and get the same error as Frankie.


Mike I installed the invocation code into the php_start and the little piece of coding in the header and my banners aren't showing up. Also the maintenance error is still happening.

Michael Morris 03-03-2005 05:12 AM

The most likely reason is a size mismatch. Make sure the banners attached to the zone are exactly the right size.

ALcorn 03-03-2005 06:41 AM

Quote:

Originally Posted by FrankieFive
I tried submitting it and got an error enclosed is a picture of my phpadmin. Is there anything missing or needs to be corrected?

Try to replace the single quotes in the SQL code by double quotes or simply get ride of them

Super Ted 03-03-2005 03:53 PM

My banners are displayed. They were appearing when I went to zones but I realised it was because I hadn't specified the banner size. The only error I get is when I run the Maintenance script.

jugo 03-04-2005 02:33 PM

Quote:

Originally Posted by FrankieFive
Is there a step by step instruction on how to do this?

Just change the filename to this:

../adserver/maintenance/maintenance.php

Super Ted 03-04-2005 04:04 PM

I still get the same error.

Warning: main(../adserver/maintenance/maintenance.php): failed to open stream: Permission denied in /admincp/cronadmin.php on line 56

cmiller1014 03-13-2005 02:48 AM

How would the code look if I wanted to call 468x60 banners, and smaller ones at the same time on 2 different areas on a page? I have the large banners showing up but not sure what I need to add to call the small ones.

Michael Morris 03-13-2005 12:05 PM

Quote:

Originally Posted by DistributorTalk
How would the code look if I wanted to call 468x60 banners, and smaller ones at the same time on 2 different areas on a page? I have the large banners showing up but not sure what I need to add to call the small ones.

Each banner requires a different call of the view_raw function

PHP Code:

if (@include(getenv('DOCUMENT_ROOT').'/phpads/phpadsnew.inc.php'))
{
    if (!isset(
$phpAds_context))
    {
        
$phpAds_context = array();
        
$phpAds_raw view_raw ('zone:1'0'''''0'$phpAds_context);

        
$phpAds_context2 = array();
        
$phpAds_raw2 view_raw ('zone:2'0'''''0'$phpAds_context2);
    }


That would do zones 1 & 2. A third zone would require a third call.

cmiller1014 03-13-2005 07:23 PM

Thanks, but then how would I then call each zone onto the page where I want it? For example I decided I am going to have text ads on the main forum page, plus 2 468X60 banners, plus a small banner on the side. If I only use $phpAds_raw[html] in each of these 4 areas, how does it know to call the correct ad for that spot?

Thanks again!

I guess the bigger question is this......

I will always have text ads in the same place (forum home page), I will always have 468x60 ads in the same place (header and footer), and I will always have the small ad in the same place (side column). How would I setup both VB and PHPADSNEW to randomly call an ad of each type and stick it in these spots?

I figured it out! I wasnt as familar with phpadsnew as I thought. I had no zones setup, and was a little mixed up because of the "Advertiser" and "Publisher" terminology. This program is a lot bigger than I expected it to be.

I then figured out how to use multiple calls.... thanks again!

pguy 03-19-2005 05:34 PM

Using the instructions in the original post, I have been unable to get my site off the ground. The local invocation just wont work. However, when I use java invocation, it works just right. However since its a high traffic site, I would prefer local invocation. I have tried every variation and possibility, but no go. Any leads as to what I can do to get the local php invocation working with my VB3

Michael Morris 03-23-2005 02:41 AM

Uhm, well for starters, you are putting the local mode invocation code into the template phpinclude_start yes?

And are you then placing the variable $phpAds_raw[html] in the appropriate spot?

@Distributor Talk: The first call puts the information in $phpAds_raw[html], the second in $phpAds_raw2[html] and so on...

pguy 03-23-2005 04:12 AM

Ahoy! Thanks for replying.

Quote:

Uhm, well for starters, you are putting the local mode invocation code into the template phpinclude_start yes?
Absolutely. When that didn't work I tried including the quote without the <?php> , but no go.

Quote:

And are you then placing the variable $phpAds_raw[html] in the appropriate spot?
Yes. This too I am sure of because I replaced the $phpAds_raw[html] with the java invocation code and the ads are displaying just right. But I seriously want the local method to work to ensure lower loads

cmiller1014 03-23-2005 04:15 AM

I ended up getting it to work flawlessly on my site. Even setup a template condition to not display it on the homepage of vbadvanced (the banners are in my header and footer)

I'll help you if you want. Drop me an email:

chris@distributortalk.com

it looks like you figured it out :) I see the ad on your homepage

This automerge doublepost "feature" is the most annoying, confusing thing to hit vbulletin. :(

pguy 03-23-2005 04:43 AM

AHoy Chris,

Those ads are based on the javascript invocation, which I don't prefer due to the slightly increased loads. I hope I can still email you to figure this out since we seem to use the same templates! :D

ssanders 03-23-2005 05:06 AM

I can't get it to work.

I followed the tutorial verbatim, but they wont show up on my forums. :(

ideas?

Michael Morris 03-23-2005 12:15 PM

Well, first off - the <?php and ?> tags need to be dropped before inserting the material into phpinclude_start. Their presence will trigger a parse error.

Second, make sure the zone # in the function call is correct - this is the part of the code most likely to change.

Don't copy the code from my tutorial. Go to your phpads setup and have it give you the local mode invocation code. Then paste THAT CODE into phpinclude_start and delete the <?php and ?> markups along with the echo statement. Finally place the variable $phpAds_raw[html] where you need it to appear on your page.

pguy 03-23-2005 12:48 PM

Michael, I had dropped the <?php and ?> tags and tried. But even with their presence I did not receive any error. All code I pasted were from within phpadsnew. If the javainvocation code goes in the same are as $phpAds_raw[html] then all goes well.

cmiller1014 03-23-2005 12:54 PM

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

ssanders 03-23-2005 07:22 PM

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.

Michael Morris 03-24-2005 09:39 AM

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.

ssanders 03-24-2005 08:06 PM

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?

tgmorris 03-26-2005 03:26 AM

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.

tgmorris 03-27-2005 06:32 PM

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.

PuntoPower 03-29-2005 11:26 AM

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

camoman 03-31-2005 09:38 PM

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??

boiboi 04-02-2005 02:43 AM

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.

Michael Morris 04-07-2005 09:23 PM

I don't know - I'm sure there's a way, but it might involve some tinkering with the code.


All times are GMT. The time now is 09:29 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.01798 seconds
  • Memory Usage 1,888KB
  • 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
  • (9)bbcode_php_printable
  • (8)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