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;
}
}