コード例 #1
0
// Require the initialisation file
require_once '../../init.php';
// Required files
require_once MAX_PATH . '/lib/OA/Dal.php';
require_once MAX_PATH . '/www/admin/config.php';
require_once MAX_PATH . '/www/admin/lib-banner.inc.php';
require_once MAX_PATH . '/www/admin/lib-storage.inc.php';
// Security check
OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN);
/*-------------------------------------------------------*/
/* Main code                                             */
/*-------------------------------------------------------*/
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->storagetype = 'sql';
$doBanners->find();
while ($doBanners->fetch()) {
    // Get the filename
    $filename = $doBanners->filename;
    // Copy the file
    $buffer = phpAds_ImageRetrieve('sql', $filename);
    $doBanners->filename = phpAds_ImageStore('web', $filename, $buffer);
    // TODO: Would be nice if we gave some indication to the user of success or failure!
    if ($doBanners->filename != false) {
        phpAds_ImageDelete('sql', $filename);
        $doBannersClone = clone $doBanners;
        $doBannersClone->imageurl = '';
        $doBannersClone->storagetype = 'web';
        $doBannersClone->update();
    }
}
Header("Location: maintenance-storage.php");
コード例 #2
0
ファイル: File.php プロジェクト: villos/tree_admin
 function store($type)
 {
     $this->fileName = phpAds_ImageStore($type, $this->fileName, $this->content);
 }
コード例 #3
0
// 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
     					list ($final['width'], $final['height']) = phpAds_SWFDimensions($uploaded['buffer']);
     					$final['pluginversion'] = phpAds_SWFVersion($uploaded['buffer']);
     					
     					// Check if the Flash banner includes hard coded urls
     					if (isset($checkswf) && $checkswf == 't' &&
     						$final['pluginversion'] >= 3 &&
     						phpAds_SWFInfo($uploaded['buffer']))
     					{
     						$edit_swf = true;
     					}
     				}
     				else
     					$final['pluginversion'] = 0;
     */
     // Store the file
     $final['alt_filename'] = phpAds_ImageStore($storagetype, $final['alt_filename'], $uploadedalt['buffer']);
     //$final['alt_imageurl'] = $phpAds_config['type_web_url'].'/'.$final['filename'];
     $final['alt_imageurl'] = '{image_url_prefix}/' . $final['alt_filename'];
     // Cleanup existing image, if it exists
     if (isset($current['alt_filename']) && $current['alt_filename'] != '' && $current['alt_filename'] != $final['alt_filename']) {
         phpAds_ImageDelete($current['storagetype'], $current['alt_filename']);
     }
 }
 if (!isset($bannerid) || $bannerid == '0' || $bannerid == '') {
     // New banner set html template
     $final['htmltemplate'] = phpAds_getBannerTemplate($final['contenttype']);
 } elseif ($final['contenttype'] != $current['contenttype']) {
     // Check if the contenttype has changed, if true change html template
     $final['htmltemplate'] = phpAds_getBannerTemplate($final['contenttype']);
 } else {
     // Use existing html template
コード例 #5
0
                    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);
    } else {
        Header('Location: banner-acl.php?clientid=' . $clientid . '&campaignid=' . $campaignid . '&bannerid=' . $bannerid);
    }
    exit;
}
コード例 #6
0
function phpAds_ImageDuplicate($type, $name)
{
    $aConf = $GLOBALS['_MAX']['CONF'];
    $pref = $GLOBALS['_MAX']['PREF'];
    // Strip existing path
    $name = basename($name);
    if ($type == 'web') {
        if ($aConf['store']['mode'] == 'ftp') {
            // FTP mode
            $server = array();
            $server['host'] = $aConf['store']['ftpHost'];
            $server['path'] = $aConf['store']['ftpPath'];
            if ($server['path'] != "" && substr($server['path'], 0, 1) == "/") {
                $server['path'] = substr($server['path'], 1);
            }
            $server['user'] = $aConf['store']['ftpUsername'];
            $server['pass'] = $aConf['store']['ftpPassword'];
            $server['passiv'] = !empty($aConf['store']['ftpPassive']);
            $stored_url = phpAds_FTPDuplicate($server, $name);
        } else {
            // Local mode, do nothing
            $stored_url = $name;
        }
    }
    if ($type == 'sql') {
        if ($buffer = phpAds_ImageRetrieve($type, $name)) {
            $stored_url = phpAds_ImageStore($type, $name, $buffer);
        }
    }
    if (isset($stored_url) && $stored_url != '') {
        return $stored_url;
    } else {
        return false;
    }
}
コード例 #7
0
function phpAds_upgradeSplitBanners()
{
    global $phpAds_config;
    // Check if splitting is needed
    if (!isset($phpAds_config['config_version']) || $phpAds_config['config_version'] < 200.07) {
        $banners = array();
        // Fetch all banners
        $res = phpAds_dbQuery("SELECT * FROM " . $phpAds_config['tbl_banners']);
        while ($row = phpAds_dbFetchArray($res)) {
            $banners[] = $row;
        }
        for ($i = 0; $i < count($banners); $i++) {
            // Requote fields
            $banners[$i]['alt'] = phpAds_htmlQuotes(stripslashes($banners[$i]['alt']));
            $banners[$i]['bannertext'] = phpAds_htmlQuotes(stripslashes($banners[$i]['bannertext']));
            // Resplit keywords
            if (isset($banners[$i]['keyword']) && $banners[$i]['keyword'] != '') {
                $keywordArray = split('[ ,]+', trim($banners[$i]['keyword']));
                $banners[$i]['keyword'] = implode(' ', $keywordArray);
            }
            // Determine storagetype
            switch ($banners[$i]['format']) {
                case 'url':
                    $banners[$i]['storagetype'] = 'url';
                    break;
                case 'html':
                    $banners[$i]['storagetype'] = 'html';
                    break;
                case 'web':
                    $banners[$i]['storagetype'] = 'web';
                    break;
                default:
                    $banners[$i]['storagetype'] = 'sql';
                    break;
            }
            switch ($banners[$i]['storagetype']) {
                case 'sql':
                    // Determine contenttype
                    $banners[$i]['contenttype'] = $banners[$i]['format'];
                    // Store the file
                    $banners[$i]['filename'] = 'banner_' . $banners[$i]['bannerid'] . '.' . $banners[$i]['contenttype'];
                    $banners[$i]['filename'] = phpAds_ImageStore($banners[$i]['storagetype'], $banners[$i]['filename'], $banners[$i]['banner']);
                    $banners[$i]['imageurl'] = $phpAds_config['url_prefix'] . '/adimage.php?filename=' . $banners[$i]['filename'] . "&contenttype=" . $banners[$i]['contenttype'];
                    $banners[$i]['htmltemplate'] = phpAds_getBannerTemplate($banners[$i]['contenttype']);
                    $banners[$i]['htmlcache'] = addslashes(phpAds_getBannerCache($banners[$i]));
                    $banners[$i]['htmltemplate'] = addslashes($banners[$i]['htmltemplate']);
                    $banners[$i]['banner'] = '';
                    break;
                case 'web':
                    // Get the contenttype
                    $ext = substr($banners[$i]['banner'], strrpos($banners[$i]['banner'], ".") + 1);
                    switch (strtolower($ext)) {
                        case 'jpeg':
                            $banners[$i]['contenttype'] = 'jpeg';
                            break;
                        case 'jpg':
                            $banners[$i]['contenttype'] = 'jpeg';
                            break;
                        case 'html':
                            $banners[$i]['contenttype'] = 'html';
                            break;
                        case 'png':
                            $banners[$i]['contenttype'] = 'png';
                            break;
                        case 'gif':
                            $banners[$i]['contenttype'] = 'gif';
                            break;
                        case 'swf':
                            $banners[$i]['contenttype'] = 'swf';
                            break;
                    }
                    // Store the file
                    $banners[$i]['filename'] = basename($banners[$i]['banner']);
                    $banners[$i]['imageurl'] = $banners[$i]['banner'];
                    $banners[$i]['htmltemplate'] = phpAds_getBannerTemplate($banners[$i]['contenttype']);
                    $banners[$i]['htmlcache'] = addslashes(phpAds_getBannerCache($banners[$i]));
                    $banners[$i]['htmltemplate'] = addslashes($banners[$i]['htmltemplate']);
                    $banners[$i]['banner'] = '';
                    break;
                case 'url':
                    // Get the contenttype
                    $ext = parse_url($banners[$i]['banner']);
                    $ext = $ext['path'];
                    $ext = substr($ext, strrpos($ext, ".") + 1);
                    switch (strtolower($ext)) {
                        case 'jpeg':
                            $banners[$i]['contenttype'] = 'jpeg';
                            break;
                        case 'jpg':
                            $banners[$i]['contenttype'] = 'jpeg';
                            break;
                        case 'html':
                            $banners[$i]['contenttype'] = 'html';
                            break;
                        case 'png':
                            $banners[$i]['contenttype'] = 'png';
                            break;
                        case 'gif':
                            $banners[$i]['contenttype'] = 'gif';
                            break;
                        case 'swf':
                            $banners[$i]['contenttype'] = 'swf';
                            break;
                    }
                    $banners[$i]['imageurl'] = $banners[$i]['banner'];
                    $banners[$i]['htmltemplate'] = phpAds_getBannerTemplate($banners[$i]['contenttype']);
                    $banners[$i]['htmlcache'] = addslashes(phpAds_getBannerCache($banners[$i]));
                    $banners[$i]['htmltemplate'] = addslashes($banners[$i]['htmltemplate']);
                    $banners[$i]['filename'] = '';
                    $banners[$i]['banner'] = '';
                    break;
                case 'html':
                    // Get the contenttype
                    $banners[$i]['contenttype'] = 'html';
                    $banners[$i]['htmltemplate'] = stripslashes($banners[$i]['banner']);
                    $banners[$i]['htmlcache'] = addslashes(phpAds_getBannerCache($banners[$i]));
                    $banners[$i]['htmltemplate'] = addslashes($banners[$i]['htmltemplate']);
                    $banners[$i]['imageurl'] = '';
                    $banners[$i]['filename'] = '';
                    $banners[$i]['banner'] = '';
                    break;
            }
            // Update the banner
            $res = 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\tstoragetype = '" . $banners[$i]['storagetype'] . "',\n\t\t\t\t\tcontenttype = '" . $banners[$i]['contenttype'] . "',\n\t\t\t\t\tfilename = '" . $banners[$i]['filename'] . "',\n\t\t\t\t\timageurl = '" . $banners[$i]['imageurl'] . "',\n\t\t\t\t\tbanner = '" . $banners[$i]['banner'] . "',\n\t\t\t\t\thtmltemplate = '" . $banners[$i]['htmltemplate'] . "',\n\t\t\t\t\thtmlcache = '" . $banners[$i]['htmlcache'] . "',\n\t\t\t\t\talt = '" . $banners[$i]['alt'] . "',\n\t\t\t\t\tstatus = '" . $banners[$i]['status'] . "',\n\t\t\t\t\tbannertext = '" . $banners[$i]['bannertext'] . "',\n\t\t\t\t\tkeyword = '" . $banners[$i]['keyword'] . "'\n\t\t\t\tWHERE\n\t\t\t\t\tbannerid = " . $banners[$i]['bannerid'] . "\n\t\t\t");
        }
        // Delete unneeded columns
        $res = phpAds_dbQuery("ALTER TABLE " . $phpAds_config['tbl_banners'] . " DROP COLUMN banner");
        $res = phpAds_dbQuery("ALTER TABLE " . $phpAds_config['tbl_banners'] . " DROP COLUMN format");
    }
}
コード例 #8
0
function phpAds_ImageDuplicate($storagetype, $name)
{
    global $phpAds_config;
    // Strip existing path
    $name = basename($name);
    if ($storagetype == 'web') {
        if ($phpAds_config['type_web_mode'] == 0) {
            // Local mode
            $duplicate = phpAds_LocalUniqueName($name);
            if (@copy($phpAds_config['type_web_dir'] . "/" . $name, $phpAds_config['type_web_dir'] . "/" . $duplicate)) {
                $stored_url = $duplicate;
            }
        } else {
            // FTP mode
            $server = parse_url($phpAds_config['type_web_ftp']);
            // Decode URL parts
            $server['user'] = urldecode($server['user']);
            $server['pass'] = urldecode($server['pass']);
            $server['path'] = urldecode($server['path']);
            if ($server['path'] != "" && substr($server['path'], 0, 1) == "/") {
                $server['path'] = substr($server['path'], 1);
            }
            if ($server['scheme'] == 'ftp') {
                $stored_url = phpAds_FTPDuplicate($server, $name);
            }
        }
    }
    if ($storagetype == 'sql') {
        if ($buffer = phpAds_ImageRetrieve($storagetype, $name)) {
            $stored_url = phpAds_ImageStore($storagetype, $name, $buffer);
        }
    }
    if (isset($stored_url) && $stored_url != '') {
        return $stored_url;
    } else {
        return false;
    }
}