Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 02-08-2011, 11:41 AM
Mutt's Avatar
Mutt Mutt is offline
 
Join Date: Nov 2001
Posts: 331
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sorry Lynne, it's part of vb4.11 function_ad.php the code above my highlighted code is the original code that i'm mimicking and my code works as is. it's when i move it to the plugin that is called at the hook directly below my highlighted code that it stops working. i was thinking my question was less about the code & more about plugin restrictions or maybe something special I need to do when using a plugin like registering variables or something.

i'm gonna keep plugging away at it after work.

I didn't want to post a big pile of code but if you need to see more to put it into context, here's the rest.

PHP Code:
        // active ads on the same location only
        
if ($ad['active'] AND $ad['adlocation'] == $location)
        {
            
$criterion $vbulletin->db->query_read("
                SELECT * FROM " 
TABLE_PREFIX "adcriteria
                WHERE adid = " 
$adid "
            "
);

            
// create the template conditionals
            
$conditional_prefix "";
            
$conditional_postfix "";

            while(
$criteria $vbulletin->db->fetch_array($criterion))
            {
                switch(
$criteria['criteriaid'])
                {
                    case 
"in_usergroup_x":
                        
$conditional_prefix .= '<vb:if condition="is_member_of($' 'bbuserinfo, ' $criteria['condition1'] . ')">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"not_in_usergroup_x":
                        
$conditional_prefix .= '<vb:if condition="!is_member_of($' 'bbuserinfo, ' $criteria['condition1'] . ')">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"browsing_content_page":
                        
$conditional_prefix .= '<vb:if condition="CONTENT_PAGE == ' $criteria['condition1'] . '">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"browsing_forum_x":
                        
$conditional_prefix .= '<vb:if condition="$' 'vbulletin->GPC[\'forumid\'] == ' $criteria['condition1'] . '">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"browsing_forum_x_and_children":
                        
// find out who the children are:
                        
$forum $vbulletin->db->query_first("SELECT childlist FROM " TABLE_PREFIX "forum WHERE forumid = " intval($criteria['condition1']));
                        
$conditional_prefix .= '<vb:if condition="in_array($' 'vbulletin->GPC[\'forumid\'], array(' $forum['childlist'] . '))">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"style_is_x":
                        
$conditional_prefix .= '<vb:if condition="STYLEID == ' intval($criteria['condition1']) . '">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"no_visit_in_x_days":
                        
$conditional_prefix .= '<vb:if condition="$' 'bbuserinfo[\'lastactivity\'] < TIMENOW - (86400*' intval($criteria['condition1']) . ')">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"no_posts_in_x_days":
                        
$conditional_prefix .= '<vb:if condition="$' 'bbuserinfo[\'lastpost\'] < TIMENOW - (86400*' intval($criteria['condition1']) . ')">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"has_x_postcount":
                        
$conditional_prefix .= '<vb:if condition="$' 'bbuserinfo[\'posts\'] > ' intval($criteria['condition1']) . ' AND $' 'bbuserinfo[\'posts\'] < ' intval($criteria['condition2']) . '">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"has_never_posted":
                        
$conditional_prefix .= '<vb:if condition="$' 'bbuserinfo[\'lastpost\'] == 0">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"has_x_reputation":
                        
$conditional_prefix .= '<vb:if condition="$' 'bbuserinfo[\'reputation\'] > ' intval($criteria['condition1']) . ' AND $' 'bbuserinfo[\'reputation\'] < ' intval($criteria['condition2']) . '">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"pm_storage_x_percent_full":
                        
$conditional_prefix .= '<vb:if condition="$' 'pmboxpercentage = $' 'bbuserinfo[\'pmtotal\'] / $' 'bbuserinfo[\'permissions\'][\'pmquota\'] * 100"></vb:if>';
                        
$conditional_prefix .= '<vb:if condition="$' 'pmboxpercentage > ' intval($criteria['condition1']) . ' AND $' 'pmboxpercentage < ' intval($criteria['condition2']) . '">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"came_from_search_engine":
                        
$conditional_prefix .= '<vb:if condition="is_came_from_search_engine()">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                    case 
"is_date":
                        if (
$criteria['condition2'])
                        {
                            
$conditional_prefix .= '<vb:if condition="gmdate(\'d-m-Y\', TIMENOW) == \'' str_replace("'""\'"$criteria['condition1']) .'\'">';
                            
$conditional_postfix .= "</vb:if>";
                        }
                        else
                        {
                            
$conditional_prefix .= '<vb:if condition="vbdate(\'d-m-Y\', TIMENOW, false, false) == \'' str_replace("'""\'"$criteria['condition1']) .'\'">';
                            
$conditional_postfix .= "</vb:if>";
                        }
                        break;
                    case 
"is_time":
                        if (
preg_match('#^(\d{1,2}):(\d{2})$#'$criteria[1], $start_time) AND preg_match('#^(\d{1,2}):(\d{2})$#'$criteria[2], $end_time))
                        {
                            if (
$criteria['condition3'])
                            {
                                
$start gmmktime($start_time[1], $start_time[2]);
                                
$end   gmmktime($end_time[1], $end_time[2]);
                                
// $now   = gmmktime();
                                
$conditional_prefix .= '<vb:if condition="$' 'now = gmmktime()"></vb:if>';
                            }
                            else
                            {
                                
$start mktime($start_time[1], $start_time[2]) + $vbulletin->options['hourdiff'];
                                
$end   mktime($end_time[1], $end_time[2]) + $vbulletin->options['hourdiff'];
                                
// $now   = mktime() + $vbulletin->options['hourdiff'];
                                
$conditional_prefix .= '<vb:if condition="$' 'now = mktime() + ' $vbulletin->options['hourdiff'] . '"></vb:if>';
                            }
                            
$conditional_prefix .= '<vb:if condition="$' 'now > ' $start ' OR $' 'now < ' $end '">';
                            
$conditional_postfix .= '</vb:if>';
                        }
                        break;
                    case 
"ad_x_not_displayed":
                        
// no ad shown? make note of it, and create the array for us
                        
$conditional_prefix .= '<vb:if condition="$noadshown = !isset($' 'adsshown)"></vb:if>';
                        
$conditional_prefix .= '<vb:if condition="$noadshown"><vb:if condition="$' 'adsshown = array()"></vb:if></vb:if>';
                        
// if no ads shown, OR ad x have not been shown, show the ad
                        
$conditional_prefix .= '<vb:if condition="$noadshown OR !in_array(' intval($criteria['condition1']) . ', $' 'adsshown)">';
                        
$conditional_postfix .= '</vb:if>';
                        break;
                    default:
                    case 
"thiscript":
                        
$conditional_prefix .= '<vb:if condition="THIS_SCRIPT == ' $criteria['condition1'] . '">';
                        
$conditional_postfix .= "</vb:if>";
                        break;
                        (
$hook vBulletinHook::fetch_hook('ad_check_criteria')) ? eval($hook) : false;
                        break;
                }
            } 
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:59 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.03125 seconds
  • Memory Usage 2,364KB
  • Queries Executed 13 (?)
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_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • 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_threaded
  • showthread_threaded_construct_link
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete