$v) { // Skip Antartica if ($k == 'AQ') continue; $type_list['fips_code_'.$k] = sprintf($strFIPSRegion, $v); } } if ($info['city']) $type_list['city'] = $strCity; if ($info['postal_code']) $type_list['postal_code'] = $strPostalCode; if ($info['dma_code']) $type_list['dma_code'] = $strDMACode; if ($info['area_code']) $type_list['area_code'] = $strAreaCode; if ($info['org_isp']) $type_list['org_isp'] = $strOrgISP; if ($info['netspeed']) $type_list['netspeed'] = $strNetSpeed; } } $type_list['browser'] = $strBrowser; $type_list['os'] = $strOS; $type_list['useragent'] = $strUserAgent; $type_list['referer'] = $strReferer; $type_list['source'] = $strSource; $comparison_default = array ( '==' => $strEqualTo, '!=' => $strDifferentFrom, ); $comparison_date = array ( '==' => $strEqualTo, '!=' => $strDifferentFrom, '>' => $strLaterThan, '>=' => $strLaterThanOrEqual, '<' => $strEarlierThan, '<=' => $strEarlierThanOrEqual ); $comparison_substr = array ( '==' => $strContains, '!=' => $strNotContains, ); $logical_default = array ( 'or' => $strOR, 'and' => $strAND ); /*********************************************************/ /* Process submitted form */ /*********************************************************/ if (isset($action)) { if (!isset($acl)) $acl = array(); if (isset($action['down'])) { // Move limitation down $source = key($action['down']); $destination = $source + 1; $tmp = $acl[$source]; $acl[$source] = $acl[$destination]; $acl[$destination] = $tmp; } if (isset($action['up'])) { // Move limitation up $source = key($action['up']); $destination = $source - 1; $tmp = $acl[$source]; $acl[$source] = $acl[$destination]; $acl[$destination] = $tmp; } if (isset($action['del'])) { // Delete limitation $first = key($action['del']); $last = count($acl) - 1; $tmp = array(); for ($i=0; $i < $first; $i++) $tmp[$i] = $acl[$i]; for ($i=$first; $i < $last; $i++) $tmp[$i] = $acl[$i + 1]; $acl = $tmp; } if (isset($action['new'])) { // Create new limitation $last = count($acl); $acl[$last]['logical'] = 'and'; $acl[$last]['type'] = $type; $acl[$last]['comparison'] = '=='; if ($type == 'time' || $type == 'weekday' || $type == 'browser' || $type == 'os' || $type == 'country' || $type == 'continent' || $type == 'region' || $type == 'language' || strpos($type, 'fips_code') === 0 || $type == 'dma_code' || $type == 'netspeed') { $acl[$last]['data'] = array(); } elseif ($type == 'date') { $acl[$last]['data'] = array('day' => '-', 'month' => '-', 'year' => '-'); } else { $acl[$last]['data'] = ''; } } } elseif (isset($submit)) { if ($phpAds_config['acl']) { // First delete existing limitations phpAds_dbQuery (" DELETE FROM ".$phpAds_config['tbl_acls']." WHERE bannerid='".$bannerid."' "); // Store limitations if (isset($acl) && count($acl)) { reset($acl); while (list ($key,) = each ($acl)) { if (isset($acl[$key]['data'])) { if (strpos($acl[$key]['type'], 'fips_code') === 0) $acl[$key]['type'] = 'fips_code'; if ($acl[$key]['type'] == 'time' || $acl[$key]['type'] == 'weekday' || $acl[$key]['type'] == 'country' || $acl[$key]['type'] == 'continent' || $acl[$key]['type'] == 'region' || $acl[$key]['type'] == 'fips_code' || $acl[$key]['type'] == 'dma_code' || $acl[$key]['type'] == 'netspeed') { $acl[$key]['data'] = implode (',', $acl[$key]['data']); } elseif ($acl[$key]['type'] == 'language') { $acl[$key]['data'] = '('.implode (')|(', $acl[$key]['data']).')'; } elseif ($acl[$key]['type'] == 'browser') { // Collect regular expressions $regs = array(); reset ($acl[$key]['data']); while (list($k,$v) = each ($acl[$key]['data'])) { reset ($phpAds_Browser); while (list($tk,$tv) = each ($phpAds_Browser)) if ($tk == $v) $regs[] = $tv; } // Use addslashes because these values are not yet slashes by registerGlobal $acl[$key]['data'] = addslashes('('.implode (')|(', $regs).')'); } elseif ($acl[$key]['type'] == 'os') { // Collect regular expressions $regs = array(); reset ($acl[$key]['data']); while (list($k,$v) = each ($acl[$key]['data'])) { reset ($phpAds_OS); while (list($tk,$tv) = each ($phpAds_OS)) if ($tk == $v) $regs[] = $tv; } // Use addslashes because these values are not yet slashes by registerGlobal $acl[$key]['data'] = addslashes('('.implode (')|(', $regs).')'); } elseif ($acl[$key]['type'] == 'date') { $acl[$key]['data'] = sprintf('%04d%02d%02d', $acl[$key]['data']['year'], $acl[$key]['data']['month'], $acl[$key]['data']['day'] ); } } else $acl[$key]['data'] = ''; phpAds_dbQuery (" INSERT INTO ".$phpAds_config['tbl_acls']." ( bannerid, logical, type, data, comparison, executionorder ) VALUES ( '".$bannerid."', '".$acl[$key]['logical']."', '".$acl[$key]['type']."', '".$acl[$key]['data']."', '".$acl[$key]['comparison']."', '".$key."' ) ") or phpAds_sqlDie(); } } // Precompile limitation phpAds_compileLimitation ($bannerid); } // Set time limit if (isset($time)) { $block = 0; if ($time['second'] != '-') $block += (int)$time['second']; if ($time['minute'] != '-') $block += (int)$time['minute'] * 60; if ($time['hour'] != '-') $block += (int)$time['hour'] * 3600; } else $block = 0; // Set capping if (isset($cap) && $cap != '-') $cap = (int)$cap; else $cap = 0; $res = phpAds_dbQuery(" UPDATE ".$phpAds_config['tbl_banners']." SET block='".$block."', capping='".$cap."' WHERE bannerid='".$bannerid."' ") or phpAds_sqlDie(); // Rebuild cache if (!defined('LIBVIEWCACHE_INCLUDED')) include (phpAds_path.'/libraries/deliverycache/cache-'.$phpAds_config['delivery_caching'].'.inc.php'); phpAds_cacheDelete(); Header ('Location: banner-append.php?clientid='.$clientid.'&campaignid='.$campaignid.'&bannerid='.$bannerid); exit; } /*********************************************************/ /* HTML framework */ /*********************************************************/ if (isset($Session['prefs']['campaign-banners.php'][$campaignid]['listorder'])) $navorder = $Session['prefs']['campaign-banners.php'][$campaignid]['listorder']; else $navorder = ''; if (isset($Session['prefs']['campaign-banners.php'][$campaignid]['orderdirection'])) $navdirection = $Session['prefs']['campaign-banners.php'][$campaignid]['orderdirection']; else $navdirection = ''; // Get other banners $res = phpAds_dbQuery(" SELECT * FROM ".$phpAds_config['tbl_banners']." WHERE clientid = '$campaignid' ".phpAds_getBannerListOrder($navorder, $navdirection)." "); while ($row = phpAds_dbFetchArray($res)) { phpAds_PageContext ( phpAds_buildBannerName ($row['bannerid'], $row['description'], $row['alt']), "banner-acl.php?clientid=".$clientid."&campaignid=".$campaignid."&bannerid=".$row['bannerid'], $bannerid == $row['bannerid'] ); } phpAds_PageShortcut($strClientProperties, 'client-edit.php?clientid='.$clientid, 'images/icon-client.gif'); phpAds_PageShortcut($strCampaignProperties, 'campaign-edit.php?clientid='.$clientid.'&campaignid='.$campaignid, 'images/icon-campaign.gif'); phpAds_PageShortcut($strBannerHistory, 'stats-banner-history.php?clientid='.$clientid.'&campaignid='.$campaignid.'&bannerid='.$bannerid, 'images/icon-statistics.gif'); $extra = "
"; $extra .= ""; $extra .= ""; $extra .= ""; $extra .= ""; $extra .= "

"; $extra .= "$strModifyBanner
"; $extra .= "
"; $extra .= " $strDuplicate
"; $extra .= "
"; $extra .= " $strMoveTo
"; $extra .= "
"; $extra .= "     "; $extra .= " 
"; $extra .= "
"; $extra .= " $strApplyLimitationsTo
"; $extra .= "
"; $extra .= "     "; $extra .= " 
"; $extra .= "
"; $extra .= " $strDelete
"; $extra .= "
"; phpAds_PageHeader("4.1.3.4.3", $extra); echo " ".phpAds_getParentName($campaignid); echo "  "; echo " ".phpAds_getClientName($campaignid); echo "  "; echo " ".phpAds_getBannerName($bannerid)."

"; echo phpAds_buildBannerCode($bannerid)."



"; phpAds_ShowSections(array("4.1.3.4.2", "4.1.3.4.3", "4.1.3.4.6", "4.1.3.4.4")); /*********************************************************/ /* Main code */ /*********************************************************/ if (!isset($acl) && $phpAds_config['acl']) { // Fetch all ACLs from the database $res = phpAds_dbQuery(" SELECT * FROM ".$phpAds_config['tbl_acls']." WHERE bannerid = '".$bannerid."' ORDER BY executionorder ") or phpAds_sqlDie(); $type_errors = false; while ($row = phpAds_dbFetchArray ($res)) { // Drop invalid ACLs if (!isset($type_list[$row['type']]) && !($row['type'] == 'fips_code' && isset($type_list['fips_code_EU']))) { $type_errors = true; continue; } $acl[$row['executionorder']]['logical'] = $row['logical']; $acl[$row['executionorder']]['type'] = $row['type']; $acl[$row['executionorder']]['comparison'] = $row['comparison']; // Misc lists if ($row['type'] == 'time' || $row['type'] == 'weekday' || $row['type'] == 'country' || $row['type'] == 'continent' || $row['type'] == 'region' || $row['type'] == 'fips_code' || $row['type'] == 'dma_code' || $row['type'] == 'netspeed') { $acl[$row['executionorder']]['data'] = explode (',', $row['data']); if ($row['type'] == 'fips_code') { if (count($acl[$row['executionorder']]['data'])) $continent = $phpAds_continent[substr(current($acl[$row['executionorder']]['data']), 0, 2)]; else $continent = current($phpAds_continent); $acl[$row['executionorder']]['type'] .= '_'.$continent; } } // Languages elseif ($row['type'] == 'language') { if (ereg("^\(.*\)$", $row['data'])) $row['data'] = substr($row['data'], 1, strlen($row['data']) - 2); $acl[$row['executionorder']]['data'] = explode (')|(', $row['data']); } // Browsers elseif ($row['type'] == 'browser') { if (ereg("^\(.*\)$", $row['data'])) $row['data'] = substr($row['data'], 1, strlen($row['data']) - 2); $keys = explode (')|(', $row['data']); while (list($k,$v) = each($keys)) { reset ($phpAds_Browser); while (list($tk,$tv) = each ($phpAds_Browser)) if ($tv == $v) $acl[$row['executionorder']]['data'][] = $tk; } } // Operating systems elseif ($row['type'] == 'os') { if (ereg("^\(.*\)$", $row['data'])) $row['data'] = substr($row['data'], 1, strlen($row['data']) - 2); $keys = explode (')|(', $row['data']); while (list($k,$v) = each($keys)) { reset ($phpAds_OS); while (list($tk,$tv) = each ($phpAds_OS)) if ($tv == $v) $acl[$row['executionorder']]['data'][] = $tk; } } elseif ($row['type'] == 'date') { if ($row['data'] == '00000000') { $acl[$row['executionorder']]['data'] = array( 'day' => '-', 'month' => '-', 'year' => '-' ); } else { $acl[$row['executionorder']]['data'] = array( 'day' => substr($row['data'], 6, 2), 'month' => substr($row['data'], 4, 2), 'year' => substr($row['data'], 0, 4) ); } } // Others else $acl[$row['executionorder']]['data'] = addslashes($row['data']); } } if (!isset($time) || !isset($cap)) { $res = phpAds_dbQuery(" SELECT * FROM ".$phpAds_config['tbl_banners']." WHERE bannerid = '".$bannerid."' "); if ($row = phpAds_dbFetchArray ($res)) { if (!isset($time)) { $seconds = $row['block']; $time['hour'] = ($seconds - ($seconds % 3600)) / 3600; $seconds = $seconds % 3600; $time['minute'] = ($seconds - ($seconds % 60)) / 60; $seconds = $seconds % 60; $time['second'] = $seconds; } if (!isset($cap)) { $cap = $row['capping']; } } } if ($time['hour'] == 0 && $time['minute'] == 0 && $time['second'] == 0) $time['second'] = '-'; if ($time['hour'] == 0 && $time['minute'] == 0) $time['minute'] = '-'; if ($time['hour'] == 0) $time['hour'] = '-'; if ($cap == 0) $cap = '-'; $tabindex = 1; if (isset($type_errors) && $type_errors) { // Message echo "
"; echo "
"; echo $strLimitationDropped."

"; } // Begin form echo "
"; echo ""; echo ""; echo ""; // Workaround: Include dummy submit image to // prevent first del button to be used when // pressing enter in a text field echo "

"; if ($phpAds_config['acl']) { echo ""; echo ""; echo ""; // Display all ACLs if (isset($acl) && count($acl)) { echo ""; echo ""; $current_i = 0; $previous_i = 0; $previous_type = ''; reset($acl); while (list ($key,) = each ($acl)) { if ($acl[$key]['logical'] == 'or' && $current_i > 0) { echo ""; $previous_i++; } else if ($previous_type != '') echo ""; $bgcolor = $previous_i % 2 == 0 ? "#F6F6F6" : "#FFFFFF"; echo ""; echo ""; // Show buttons echo ""; echo ""; $previous_type = $acl[$key]['type']; $current_i++; } // Show Footer if (!isset($acl[$key]['type']) || $acl[$key]['type'] != $previous_type && $previous_type != '') echo ""; } else { echo ""; echo ""; } echo ""; echo "
".$strDeliveryLimitations."
       ".$strOnlyDisplayWhen."
       "; if ($key == 0) echo " "; else { echo ""; } echo ""; echo " ".$type_list[$acl[$key]['type']]; echo ""; echo ""; echo ""; echo ""; echo "  "; echo ""; echo "  "; if ($key && $key < count($acl)) echo ""; else echo "$strUp"; if ($key < count($acl) - 1) echo ""; else echo "$strDown"; echo "  
  "; if ($acl[$key]['type'] == 'weekday') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo ""; for ($i = 0; $i < 7; $i++) { if ($i % 4 == 0) echo ""; echo ""; if (($i + 1) % 4 == 0) echo ""; } if (($i + 1) % 4 != 0) echo ""; echo "
 ".$strDayShortCuts[$i]."  
"; } elseif ($acl[$key]['type'] == 'time') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo ""; for ($i = 0; $i < 24; $i++) { if ($i % 4 == 0) echo ""; echo ""; if (($i + 1) % 4 == 0) echo ""; } if (($i + 1) % 4 != 0) echo ""; echo "
 ".$i.":00  
"; } elseif ($acl[$key]['type'] == 'date') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array('day' => '-', 'month' => '-', 'year' => '-'); echo " "; echo " "; if ($acl[$key]['data']['year'] != '-') $s = $acl[$key]['data']['year'] < date('Y') ? $acl[$key]['data']['year'] : date('Y'); else $s = date('Y'); echo "\n"; } elseif ($acl[$key]['type'] == 'language') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo "
"; foreach ($phpAds_ISO639 as $iso => $fullname) { echo "
".$fullname; echo "
"; } echo "
"; } elseif ($acl[$key]['type'] == 'country') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo "
"; foreach ($phpAds_ISO3166 as $iso => $fullname) { echo "
".$fullname; echo "
"; } echo "
"; } elseif ($acl[$key]['type'] == 'continent') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo "
"; foreach ($phpAds_cont_name as $iso => $fullname) { echo "
".$fullname; echo "
"; } echo "
"; } elseif ($acl[$key]['type'] == 'region') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo "
"; foreach ($phpAds_ISO3166_2 as $country => $regions) { echo "
 ".$phpAds_ISO3166[$country]."
"; while (list($code,$fullname) = each ($regions)) { echo "
".$fullname; echo "
"; } } echo "
"; } elseif (preg_match('/^fips_code_(.*)$/', $acl[$key]['type'], $m)) { $cont = $m[1]; if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo "".$strShowCountry." 
"; echo "
\n"; foreach ($phpAds_FIPS as $country => $fips_codes) { if ($phpAds_continent[$country] != $cont) continue; echo "
 ".$phpAds_ISO3166[$country]."
"; $i = 0; while (list($code,$fullname) = each ($fips_codes)) { echo "
".$fullname; echo "
\n"; } } echo "
"; } elseif ($acl[$key]['type'] == 'dma_code') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo "
"; foreach ($phpAds_DmaCodes as $dma => $fullname) { echo "
".$dma.' - '.$fullname; echo "
"; } echo "
"; } elseif ($acl[$key]['type'] == 'netspeed') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo "
"; foreach ($phpAds_Netspeeds as $netspeed => $fullname) { echo "
".$fullname; echo "
"; } echo "
"; } elseif ($acl[$key]['type'] == 'browser') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo ""; $i = 0; reset ($phpAds_Browser); while (list($ukey, $uvalue) = each ($phpAds_Browser)) { if ($i % 3 == 0) echo ""; echo ""; if (($i + 1) % 3 == 0) echo ""; $i++; } if (($i + 1) % 3 != 0) echo ""; echo "
 ".$ukey."  
"; } elseif ($acl[$key]['type'] == 'os') { if (!isset($acl[$key]['data'])) $acl[$key]['data'] = array(); echo ""; $i = 0; reset ($phpAds_OS); while (list($ukey, $uvalue) = each ($phpAds_OS)) { if ($i % 3 == 0) echo ""; echo ""; if (($i + 1) % 3 == 0) echo ""; $i++; } if (($i + 1) % 3 != 0) echo ""; echo "
 ".$ukey."  
"; } else echo ""; echo "

       ".$strNoLimitations."
"; if (isset($acl) && count($acl) > 1) { echo " "; echo ""; echo $strRemoveAllLimitations."    "; } echo ""; echo " "; echo ""; echo " "; echo ""; echo "
"; echo "


"; } echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".$strDeliveryCapping."
 
 ".$strTimeCapping.""; echo " ".$strHours."   "; echo " ".$strMinutes."   "; echo " ".$strSeconds."   "; echo "
 ".$strImpressionCapping.""; echo " ".$strTimes; echo "
 
"; echo "


"; echo ""; echo "


"; /*********************************************************/ /* Form requirements */ /*********************************************************/ ?>