Пример #1
0
function processBanners($commit = false)
{
    $doBanners = OA_Dal::factoryDO('banners');
    if (OA_INSTALLATION_STATUS === OA_INSTALLATION_STATUS_INSTALLED && OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        $doBanners->addReferenceFilter('agency', $agencyId = OA_Permission::getEntityId());
    }
    $doBanners->find();
    $different = 0;
    $same = 0;
    $errors = array();
    while ($doBanners->fetch()) {
        // Rebuild filename
        if ($doBanners->storagetype == 'sql' || $doBanners->storagetype == 'web') {
            $doBanners->imageurl = '';
        }
        $GLOBALS['_MAX']['bannerrebuild']['errors'] = false;
        if ($commit) {
            $doBannersClone = clone $doBanners;
            $doBannersClone->update();
            $newCache = $doBannersClone->htmlcache;
        } else {
            $newCache = phpAds_getBannerCache($doBanners->toArray());
        }
        if (empty($GLOBALS['_MAX']['bannerrebuild']['errors'])) {
            if ($doBanners->htmlcache != $newCache && $doBanners->storagetype == 'html') {
                $different++;
            } else {
                $same++;
            }
        } else {
            $errors[] = $doBanners->toArray();
        }
    }
    return array('errors' => $errors, 'different' => $different, 'same' => $same);
}
 function test_getBannerCache()
 {
     $this->aBanners[] = $this->_getBanner1();
     $this->aBanners[] = $this->_getBanner2();
     $this->aBanners[] = $this->_getBanner3();
     $this->aBanners[] = $this->_getBanner4();
     $this->aBanners[] = $this->_getBanner5();
     $this->aBanners[] = $this->_getBanner6();
     $this->aBanners[] = $this->_getBanner7();
     $this->aBanners[] = $this->_getBanner8();
     $this->aBanners[] = $this->_getBanner9();
     foreach ($this->aBanners as $k => $aBanner) {
         $expected = $aBanner['expected'];
         $result = phpAds_getBannerCache($aBanner);
         $this->assertEqual($expected, $result);
     }
 }
// Include required files
require "config.php";
require "lib-banner.inc.php";
require "lib-storage.inc.php";
// Security check
phpAds_checkAccess(phpAds_Admin);
/*********************************************************/
/* Main code                                             */
/*********************************************************/
$res = phpAds_dbQuery("\n\tSELECT\n\t\t*\n\tFROM\n\t\t" . $phpAds_config['tbl_banners'] . "\n");
while ($current = phpAds_dbFetchArray($res)) {
    if ($current['storagetype'] == 'sql') {
        // Get the filename
        $filename = $current['filename'];
        // Copy the file
        $buffer = phpAds_ImageRetrieve('sql', $filename);
        $current['filename'] = phpAds_ImageStore('web', $filename, $buffer);
        if ($current['filename'] != false) {
            // Delete the original file
            phpAds_ImageDelete('sql', $filename);
            // Update fields
            $current['imageurl'] = '{image_url_prefix}/' . $current['filename'];
            $current['storagetype'] = 'web';
            // Rebuild banner cache
            $current['htmltemplate'] = stripslashes($current['htmltemplate']);
            $current['htmlcache'] = addslashes(phpAds_getBannerCache($current));
            phpAds_dbQuery("\n\t\t\t\tUPDATE\n\t\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\t\tSET\n\t\t\t\t\tfilename  = '" . $current['filename'] . "',\n\t\t\t\t\timageurl  = '" . $current['imageurl'] . "',\n\t\t\t\t\tstoragetype = '" . $current['storagetype'] . "',\n\t\t\t\t\thtmlcache = '" . $current['htmlcache'] . "'\n\t\t\t\tWHERE\n\t\t\t\t\tbannerid = " . $current['bannerid'] . "\n\t\t\t");
        }
    }
}
Header("Location: maintenance-storage.php");
Пример #4
0
 function _rebuildCache()
 {
     if (!is_null($this->htmltemplate)) {
         $this->htmlcache = phpAds_getBannerCache($this->toArray());
     }
 }
Пример #5
0
function phpAds_rebuildBannerCache($bannerid)
{
    global $phpAds_config;
    // Retrieve current values
    $res = phpAds_dbQuery("\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\tWHERE\n\t\t\tbannerid = '" . $bannerid . "'\n\t") or phpAds_sqlDie();
    $current = phpAds_dbFetchArray($res);
    // Add slashes to status to prevent javascript errors
    // NOTE: not needed in banner-edit because of magic_quotes_gpc
    $current['status'] = addslashes($current['status']);
    // Rebuild cache
    $current['htmltemplate'] = stripslashes($current['htmltemplate']);
    $current['htmlcache'] = addslashes(phpAds_getBannerCache($current));
    phpAds_dbQuery("\n\t\tUPDATE\n\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\tSET\n\t\t\thtmlcache = '" . $current['htmlcache'] . "'\n\t\tWHERE\n\t\t\tbannerid = '" . $current['bannerid'] . "'\n\t") or phpAds_sqlDie();
}
Пример #6
0
         $final['bannertext'] = '';
         $final['url'] = '';
         $final['target'] = '';
         $final['width'] = $width;
         $final['height'] = $height;
         $final['contenttype'] = 'html';
         $final['storagetype'] = $storagetype;
         // Get the network template
         if (!isset($bannerid) || $bannerid == '') {
             $final['htmltemplate'] = @fread(@fopen(phpAds_path . "/admin/networks/" . $network . ".html", "rb"), @filesize(phpAds_path . "/admin/networks/" . $network . ".html"));
         } else {
             $final['htmltemplate'] = $current['htmltemplate'];
         }
         // Update bannercache
         $final['htmltemplate'] = phpAds_setNetworkInfo($final['htmltemplate'], $vars);
         $final['htmlcache'] = addslashes(phpAds_getBannerCache($final));
         $final['htmltemplate'] = addslashes($final['htmltemplate']);
         break;
 }
 $final['campaignid'] = $campaignid;
 $final['bannerid'] = $bannerid;
 $final['appendtype'] = isset($final['appendtype']) ? addslashes($final['appendtype']) : '';
 $final['append'] = isset($final['append']) ? addslashes($final['append']) : '';
 if (phpAds_isUser(phpAds_Admin) || phpAds_isUser(phpAds_Agency)) {
     if (isset($keyword) && $keyword != '') {
         $keywordArray = split('[ ,]+', trim($keyword));
         $final['keyword'] = implode(' ', $keywordArray);
     } else {
         $final['keyword'] = '';
     }
     $final['active'] = "t";
Пример #7
0
                 // Set default link
                 $row['url'] = $overwrite_link[$chosen_link];
                 $row['target'] = $overwrite_target[$chosen_link];
                 // Prepare the parameters
                 $parameters_complete = array();
                 while (list($key, $val) = each($parameters)) {
                     if (isset($overwrite_source) && $overwrite_source[$val] != '') {
                         $overwrite_link[$val] .= '|source:' . $overwrite_source[$val];
                     }
                     $parameters_complete[] = 'alink' . $key . '={targeturl:' . $overwrite_link[$val] . '}&atar' . $key . '=' . $overwrite_target[$val];
                 }
                 $parameter = implode('&', $parameters_complete);
                 $row['htmltemplate'] = str_replace('{swf_param}', $parameter, $row['htmltemplate']);
             }
             $row['pluginversion'] = phpAds_SWFVersion($result);
             $row['htmlcache'] = addslashes(phpAds_getBannerCache($row));
             $row['htmltemplate'] = addslashes($row['htmltemplate']);
             // Store the HTML Template
             $res = phpAds_dbQuery("\n\t\t\t\t\tUPDATE " . $phpAds_config['tbl_banners'] . " \n\t\t\t\t\tSET url='" . $row['url'] . "', target='" . $row['target'] . "', pluginversion='" . $row['pluginversion'] . "', \n\t\t\t\t\t\thtmltemplate='" . $row['htmltemplate'] . "', htmlcache='" . $row['htmlcache'] . "'\n\t\t\t\t\tWHERE bannerid = '" . $bannerid . "'\n\t\t\t\t") or die(phpAds_dbError());
             // Store the banner
             phpAds_ImageStore($row['storagetype'], $row['filename'], $result, true);
             // Rebuild cache
             if (!defined('LIBVIEWCACHE_INCLUDED')) {
                 include phpAds_path . '/libraries/deliverycache/cache-' . $phpAds_config['delivery_caching'] . '.inc.php';
             }
             phpAds_cacheDelete();
         }
     }
 }
 if (phpAds_isUser(phpAds_Client)) {
     Header('Location: stats-campaign-banners.php?clientid=' . $clientid . '&campaignid=' . $campaignid);
 // Duplicate the banner
 $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t   \t\t*\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\tWHERE\n\t\t\t\tbannerid = '" . $bannerid . "'\n\t\t") or phpAds_sqlDie();
 if ($row = phpAds_dbFetchArray($res)) {
     // Remove bannerid
     unset($row['bannerid']);
     // Duplicate stored banner
     if ($row['storagetype'] == 'web' || $row['storagetype'] == 'sql') {
         $row['filename'] = phpAds_ImageDuplicate($row['storagetype'], $row['filename']);
         if ($row['storagetype'] == 'sql') {
             // SQL-stored banner
             $row['imageurl'] = '{url_prefix}/adimage.php?filename=' . $row['filename'] . '&contenttype=' . $row['contenttype'];
         } else {
             // Web-stored banner
             $row['imageurl'] = $phpAds_config['type_web_url'] . '/' . $row['filename'];
         }
         $row['htmlcache'] = phpAds_getBannerCache($row);
     }
     // Clone banner
     $values_fields = '';
     $values = '';
     while (list($name, $value) = each($row)) {
         $values_fields .= "{$name}, ";
         $values .= "'" . addslashes($value) . "', ";
     }
     $values_fields = ereg_replace(", \$", "", $values_fields);
     $values = ereg_replace(", \$", "", $values);
     $res = phpAds_dbQuery("\n\t\t   \t\tINSERT INTO\n\t\t   \t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t   \t\t\t({$values_fields})\n\t\t   \t\tVALUES\n\t\t   \t\t\t({$values})\n\t   \t\t") or phpAds_sqlDie();
     $new_bannerid = phpAds_dbInsertID();
     if ($phpAds_config['acl']) {
         // Clone display limitations
         $res = phpAds_dbQuery("\n\t\t\t   \t   SELECT\n\t\t\t   \t      *\n\t\t\t   \t   FROM\n\t\t\t   \t      " . $phpAds_config['tbl_acls'] . "\n\t\t\t   \t   WHERE\n\t\t\t   \t      bannerid = '" . $bannerid . "'\n\t\t   \t    ") or phpAds_sqlDie();
function phpAds_upgradeHTMLCache()
{
    global $phpAds_config;
    $res = phpAds_dbQuery("\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t");
    while ($current = phpAds_dbFetchArray($res)) {
        // Rebuild filename
        if ($current['storagetype'] == 'sql') {
            $current['imageurl'] = "{url_prefix}/adimage.php?filename=" . $current['filename'] . "&contenttype=" . $current['contenttype'];
        }
        if ($current['storagetype'] == 'web') {
            $current['imageurl'] = '{image_url_prefix}/' . $current['filename'];
        }
        // Add slashes to status to prevent javascript errors
        // NOTE: not needed in banner-edit because of magic_quotes_gpc
        $current['status'] = addslashes($current['status']);
        // Rebuild cache
        $current['htmltemplate'] = stripslashes($current['htmltemplate']);
        $current['htmlcache'] = addslashes(phpAds_getBannerCache($current));
        phpAds_dbQuery("\n\t\t\tUPDATE\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\tSET\n\t\t\t\thtmlcache = '" . $current['htmlcache'] . "',\n\t\t\t\timageurl  = '" . $current['imageurl'] . "'\n\t\t\tWHERE\n\t\t\t\tbannerid = " . $current['bannerid'] . "\n\t\t");
    }
}