function phpAds_compileLimitation($bannerid = '') { global $phpAds_config; if ($bannerid == '') { // Loop through all banners $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\tbannerid\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t"); while ($current = phpAds_dbFetchArray($res)) { phpAds_compileLimitation($current['bannerid']); } } else { // Compile limitation $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_acls'] . "\n\t\t\tWHERE\n\t\t\t\tbannerid = '" . $bannerid . "'\n\t\t\tORDER BY\n\t\t\t\texecutionorder\n\t\t") or phpAds_sqlDie(); while ($row = phpAds_dbFetchArray($res)) { $acl[$row['executionorder']]['logical'] = $row['logical']; $acl[$row['executionorder']]['type'] = $row['type']; $acl[$row['executionorder']]['comparison'] = $row['comparison']; $acl[$row['executionorder']]['data'] = addslashes($row['data']); } $expression = ''; $i = 0; if (isset($acl) && count($acl)) { reset($acl); while (list($key, ) = each($acl)) { if ($i > 0) { $expression .= ' ' . $acl[$key]['logical'] . ' '; } switch ($acl[$key]['type']) { case 'clientip': $expression .= "phpAds_aclCheckClientIP(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'browser': $expression .= "phpAds_aclCheckUseragent(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'os': $expression .= "phpAds_aclCheckUseragent(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'useragent': $expression .= "phpAds_aclCheckUseragent(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'language': $expression .= "phpAds_aclCheckLanguage(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'country': $expression .= "phpAds_aclCheckCountry(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'continent': $expression .= "phpAds_aclCheckContinent(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'region': $expression .= "phpAds_aclCheckRegion(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'weekday': $expression .= "phpAds_aclCheckWeekday(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'domain': $expression .= "phpAds_aclCheckDomain(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'source': $expression .= "phpAds_aclCheckSource(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\', \$" . "source)"; break; case 'time': $expression .= "phpAds_aclCheckTime(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'date': $expression .= "phpAds_aclCheckDate(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; case 'referer': $expression .= "phpAds_aclCheckReferer(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')"; break; default: return 0; } $i++; } } if ($expression == '') { $expression = 'true'; } $res = phpAds_dbQuery("\n\t\t\tUPDATE\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\tSET\n\t\t\t\tcompiledlimitation='" . $expression . "'\n\t\t\tWHERE\n\t\t\t\tbannerid='" . $bannerid . "'\n\t\t") or phpAds_sqlDie(); } }
} } } // 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("\n\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\t" . $phpAds_config['tbl_acls'] . "\n\t\t\t\t\tSET\n\t\t\t\t\t\tbannerid \t = '" . $bannerid . "',\n\t\t\t\t\t\tlogical \t = '" . $acl[$key]['logical'] . "',\n\t\t\t\t\t\ttype \t \t = '" . $acl[$key]['type'] . "',\n\t\t\t\t\t\tdata \t \t = '" . $acl[$key]['data'] . "',\n\t\t\t\t\t\tcomparison = '" . $acl[$key]['comparison'] . "',\n\t\t\t\t\t\texecutionorder = '" . $key . "'\n\t\t\t\t"); } } // 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;
// Send the output to the browser flush(); phpAds_upgradeData(); // Go to the next step echo "<meta http-equiv='refresh' content='0;URL=upgrade.php?step=5'>"; exit; } elseif ($step == 5) { // Setup busy indicator phpAds_PageHeader("1"); echo "<br><br><img src='images/install-busy.gif' align='absmiddle'> "; echo "<span class='install'>" . $strSystemRebuildingCache . "</span>"; phpAds_PageFooter(); // Update banner cache of all banners phpAds_upgradeHTMLCache(); // Update compiled limitation of all banners phpAds_compileLimitation(); // Rebuild cache if (!defined('LIBVIEWCACHE_INCLUDED')) { include phpAds_path . '/libraries/deliverycache/cache-' . $phpAds_config['delivery_caching'] . '.inc.php'; } phpAds_cacheDelete(); // Check if priority recalculation is needed list($banners, $priority_sum) = phpAds_dbFetchRow(phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\tCOUNT(bannerid),\n\t\t\t\tSUM(priority)\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t")); if ($banners && !$priority_sum) { // Recalculate priority include "../libraries/lib-priority.inc.php"; phpAds_PriorityCalculate(); } // Send the output to the browser flush(); // Go to the next step