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.


All times are GMT. The time now is 09:19 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.01449 seconds
  • Memory Usage 1,765KB
  • 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
  • (6)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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