function XXXtestRun() { $aConf = $GLOBALS['_MAX']['CONF']; $result = OA_Maintenance_Priority::run(); $this->assertTrue($result); $phpPath = $aConf['test']['phpPath'] . ' -f'; $testPath = MAX_PATH . '/lib/OA/Maintenance/tests/unit/PriorityFork.php'; $host = $_SERVER['SERVER_NAME']; system("{$phpPath} {$testPath} {$host}", $result); // 0 means it executed successfully, meaning the test was successful $this->assertEqual($result, 0); }
function testForkRun() { require_once MAX_PATH . '/lib/OA/Maintenance/Priority.php'; $pid = pcntl_fork(); if ($pid == -1) { // something bad happened } else { if ($pid == 0) { $resultChild = OA_Maintenance_Priority::run(); } else { $resultParent = OA_Maintenance_Priority::run(); } } isset($resultParent) && $resultParent === true ? exit : exit(1); }
require_once MAX_PATH . '/lib/OA/Dal.php'; //require_once MAX_PATH . '/lib/max/deliverycache/cache-'.$conf['delivery']['cache'].'.inc.php'; require_once MAX_PATH . '/www/admin/config.php'; require_once MAX_PATH . '/www/admin/lib-storage.inc.php'; require_once MAX_PATH . '/www/admin/lib-zones.inc.php'; require_once MAX_PATH . '/www/admin/lib-statistics.inc.php'; require_once MAX_PATH . '/lib/OA/Maintenance/Priority.php'; require_once OX_PATH . '/lib/pear/DB/DataObject.php'; // Register input variables phpAds_registerGlobal('returnurl', 'agencyid'); // Security check OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); // CVE-2013-5954 - see OA_Permission::checkSessionToken() method for details OA_Permission::checkSessionToken(); /*-------------------------------------------------------*/ /* Main code */ /*-------------------------------------------------------*/ if (!empty($agencyid)) { $doAgency = OA_Dal::factoryDO('agency'); $doAgency->agencyid = $agencyid; $doAgency->get($agencyid); $doAgency->delete(); } // Run the Maintenance Priority Engine process OA_Maintenance_Priority::scheduleRun(); // Rebuild cache // phpAds_cacheDelete(); if (!isset($returnurl) || $returnurl == '') { $returnurl = 'advertiser-index.php'; } OX_Admin_Redirect::redirect($returnurl);
/** * A private method to run MPE. * * @access private */ function _runMPE() { OA_Maintenance_Priority::run(true); }
| it under the terms of the GNU General Public License as published by | | the Free Software Foundation; either version 2 of the License, or | | (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | | | | You should have received a copy of the GNU General Public License | | along with this program; if not, write to the Free Software | | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | +---------------------------------------------------------------------------+ $Id: maintenance-priority-calculate.php 37157 2009-05-28 12:31:10Z andrew.hill $ */ // Require the initialisation file require_once '../../init.php'; // Required files require_once MAX_PATH . '/www/admin/config.php'; require_once MAX_PATH . '/lib/OA/Maintenance/Priority.php'; // Security check OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); /*-------------------------------------------------------*/ /* Main code */ /*-------------------------------------------------------*/ // Run the Maintenance Priority Engine process OA_Maintenance_Priority::run(); // Rebuild cache // include_once MAX_PATH . '/lib/max/deliverycache/cache-'.$conf['delivery']['cache'].'.inc.php'; // phpAds_cacheDelete(); OX_Admin_Redirect::redirect('maintenance-priority.php');
function processStatusForm($form) { $aFields = $form->exportValues(); if (empty($aFields['campaignid'])) { return; } //update status for existing campaign $doCampaigns = OA_Dal::factoryDO('campaigns'); $doCampaigns->campaignid = $aFields['campaignid']; $doCampaigns->as_reject_reason = $aFields['as_reject_reason']; $doCampaigns->status = $aFields['status']; $doCampaigns->update(); // Run the Maintenance Priority Engine process OA_Maintenance_Priority::scheduleRun(); OX_Admin_Redirect::redirect("campaign-edit.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid']); }
<?php /* +---------------------------------------------------------------------------+ | Revive Adserver | | http://www.revive-adserver.com | | | | Copyright: See the COPYRIGHT.txt file. | | License: GPLv2 or later, see the LICENSE.txt file. | +---------------------------------------------------------------------------+ */ //$oMessages initialized by runner OA_Upgrade::runPostUpgradeTask if (!class_exists('OA_Maintenance_Priority')) { require_once MAX_PATH . '/lib/OA/Maintenance/Priority.php'; } $oMessages->logInfo('Starting Maintenance Prioritisation'); $upgradeTaskResult = OA_Maintenance_Priority::run(); if (PEAR::isError($upgradeTaskResult)) { $oMessages->logError($upgradeTaskResult->getCode() . ': ' . $upgradeTaskResult->getMessage()); } $oMessages->logInfo('Maintenance Prioritisation: ' . ($upgradeTaskResult ? 'Complete' : 'Failed'));
function processForm($bannerid, $form, &$oComponent, $formDisabled = false) { $aFields = $form->exportValues(); $doBanners = OA_Dal::factoryDO('banners'); if (!empty($bannerid)) { if ($doBanners->get($bannerid)) { $aBanner = $doBanners->toArray(); } } $aVariables = array(); $aVariables['campaignid'] = $aFields['campaignid']; $aVariables['target'] = isset($aFields['target']) ? $aFields['target'] : ''; $aVariables['height'] = isset($aFields['height']) ? $aFields['height'] : 0; $aVariables['width'] = isset($aFields['width']) ? $aFields['width'] : 0; $aVariables['weight'] = !empty($aFields['weight']) ? $aFields['weight'] : 0; $aVariables['adserver'] = !empty($aFields['adserver']) ? $aFields['adserver'] : ''; $aVariables['alt'] = !empty($aFields['alt']) ? $aFields['alt'] : ''; $aVariables['bannertext'] = !empty($aFields['bannertext']) ? $aFields['bannertext'] : ''; $aVariables['htmltemplate'] = !empty($aFields['htmltemplate']) ? $aFields['htmltemplate'] : ''; $aVariables['description'] = !empty($aFields['description']) ? $aFields['description'] : ''; $aVariables['imageurl'] = !empty($aFields['imageurl']) && $aFields['imageurl'] != 'http://' ? $aFields['imageurl'] : ''; $aVariables['url'] = !empty($aFields['url']) && $aFields['url'] != 'http://' ? $aFields['url'] : ''; $aVariables['status'] = $aFields['status'] != '' ? $aFields['status'] : ''; $aVariables['storagetype'] = $aFields['type']; $aVariables['ext_bannertype'] = 'bannerTypeText:oxMarkedText:oxMarkedTextComponent'; $aVariables['comments'] = $aFields['comments']; $aVariables['contenttype'] = 'txt'; if (isset($aFields['keyword']) && $aFields['keyword'] != '') { $keywordArray = split('[ ,]+', $aFields['keyword']); $aVariables['keyword'] = implode(' ', $keywordArray); } else { $aVariables['keyword'] = ''; } $editSwf = false; $parameters = null; $aVariables['parameters'] = serialize($parameters); $insert = empty($bannerid) ? true : false; $doBanners->setFrom($aVariables); if ($insert) { $bannerid = $doBanners->insert(); OA_Maintenance_Priority::scheduleRun(); } else { $doBanners->update(); if ($aVariables['width'] != $aBanner['width'] || $aVariables['height'] != $aBanner['height']) { MAX_adjustAdZones($bannerid); MAX_addDefaultPlacementZones($bannerid, $aVariables['campaignid']); } } $translation = new OX_Translation(); if ($insert) { $translated_message = $translation->translate($GLOBALS['strBannerHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'] . '&bannerid=' . $bannerid), htmlspecialchars($aFields['description']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); $nextPage = "oxMarkedTextAdvertiser-index.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid']; } else { $translated_message = $translation->translate($GLOBALS['strBannerHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'] . '&bannerid=' . $aFields['bannerid']), htmlspecialchars($aFields['description']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); $nextPage = "banner-edit.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid'] . "&bannerid={$bannerid}"; } Header("Location: {$nextPage}"); exit; }
function processForm($bannerid, $form, &$oComponent, $formDisabled = false) { $aFields = $form->exportValues(); $doBanners = OA_Dal::factoryDO('banners'); // Get the existing banner details (if it is not a new banner) if (!empty($bannerid)) { if ($doBanners->get($bannerid)) { $aBanner = $doBanners->toArray(); } } $aVariables = array(); $aVariables['campaignid'] = $aFields['campaignid']; $aVariables['target'] = isset($aFields['target']) ? $aFields['target'] : ''; $aVariables['height'] = isset($aFields['height']) ? $aFields['height'] : 0; $aVariables['width'] = isset($aFields['width']) ? $aFields['width'] : 0; $aVariables['weight'] = !empty($aFields['weight']) ? $aFields['weight'] : 0; $aVariables['adserver'] = !empty($aFields['adserver']) ? $aFields['adserver'] : ''; $aVariables['alt'] = !empty($aFields['alt']) ? $aFields['alt'] : ''; $aVariables['bannertext'] = !empty($aFields['bannertext']) ? $aFields['bannertext'] : ''; $aVariables['htmltemplate'] = !empty($aFields['htmltemplate']) ? $aFields['htmltemplate'] : ''; $aVariables['description'] = !empty($aFields['description']) ? $aFields['description'] : ''; $aVariables['imageurl'] = !empty($aFields['imageurl']) && $aFields['imageurl'] != 'http://' ? $aFields['imageurl'] : ''; $aVariables['url'] = !empty($aFields['url']) && $aFields['url'] != 'http://' ? $aFields['url'] : ''; $aVariables['status'] = $aFields['status'] != '' ? $aFields['status'] : ''; $aVariables['statustext'] = !empty($aFields['statustext']) ? $aFields['statustext'] : ''; $aVariables['storagetype'] = $aFields['type']; $aVariables['ext_bannertype'] = $aFields['ext_bannertype']; $aVariables['comments'] = $aFields['comments']; $aVariables['filename'] = !empty($aBanner['filename']) ? $aBanner['filename'] : ''; $aVariables['contenttype'] = !empty($aBanner['contenttype']) ? $aBanner['contenttype'] : ''; if ($aFields['type'] == 'url') { $aVariables['contenttype'] = OA_Creative_File::staticGetContentTypeByExtension($aVariables['imageurl']); if (empty($aVariables['contenttype'])) { // Assume dynamic urls (i.e. http://www.example.com/foo?bar) are "gif" $aVariables['contenttype'] = 'gif'; } } elseif ($aFields['type'] == 'txt') { // Text banners should always have a "txt" content type $aVariables['contenttype'] = 'txt'; } $aVariables['alt_filename'] = !empty($aBanner['alt_filename']) ? $aBanner['alt_filename'] : ''; $aVariables['alt_contenttype'] = !empty($aBanner['alt_contenttype']) ? $aBanner['alt_contenttype'] : ''; $aVariables['alt_imageurl'] = !empty($aFields['alt_imageurl']) ? $aFields['alt_imageurl'] : ''; if (isset($aFields['keyword']) && $aFields['keyword'] != '') { $keywordArray = split('[ ,]+', $aFields['keyword']); $aVariables['keyword'] = implode(' ', $keywordArray); } else { $aVariables['keyword'] = ''; } $editSwf = false; // Deal with any files that are uploaded. if (!empty($_FILES['upload']) && $aFields['replaceimage'] == 't') { //TODO refactor upload to be a valid quickform elem $oFile = OA_Creative_File::factoryUploadedFile('upload'); checkForErrorFileUploaded($oFile); $oFile->store($aFields['type']); $aFile = $oFile->getFileDetails(); if (!empty($aFile)) { $aVariables['filename'] = $aFile['filename']; $aVariables['contenttype'] = $aFile['contenttype']; $aVariables['width'] = $aFile['width']; $aVariables['height'] = $aFile['height']; $aVariables['pluginversion'] = $aFile['pluginversion']; $editSwf = $aFile['editswf']; } // Delete the old file for this banner if (!empty($aBanner['filename']) && $aBanner['filename'] != $aFile['filename'] && ($aBanner['storagetype'] == 'web' || $aBanner['storagetype'] == 'sql')) { DataObjects_Banners::deleteBannerFile($aBanner['storagetype'], $aBanner['filename']); } } if (!empty($_FILES['uploadalt']) && $_FILES['uploadalt']['size'] > 0 && $aFields['replacealtimage'] == 't') { //TODO: Check image only? - Wasn't enforced before $oFile = OA_Creative_File::factoryUploadedFile('uploadalt'); checkForErrorFileUploaded($oFile); $oFile->store($aFields['type']); $aFile = $oFile->getFileDetails(); if (!empty($aFile)) { $aVariables['alt_filename'] = $aFile['filename']; $aVariables['alt_contenttype'] = $aFile['contenttype']; } } // Handle SWF transparency if ($aVariables['contenttype'] == 'swf') { $aVariables['transparent'] = isset($aFields['transparent']) && $aFields['transparent'] ? 1 : 0; } // Update existing hard-coded links if new file has not been uploaded if ($aVariables['contenttype'] == 'swf' && empty($_FILES['upload']['tmp_name']) && isset($aFields['alink']) && is_array($aFields['alink']) && count($aFields['alink'])) { // Prepare the parameters $parameters_complete = array(); // Prepare targets if (!isset($aFields['atar']) || !is_array($aFields['atar'])) { $aFields['atar'] = array(); } foreach ($aFields['alink'] as $key => $val) { if (substr($val, 0, 7) == 'http://' && strlen($val) > 7) { if (!isset($aFields['atar'][$key])) { $aFields['atar'][$key] = ''; } if (isset($aFields['alink_chosen']) && $aFields['alink_chosen'] == $key) { $aVariables['url'] = $val; $aVariables['target'] = $aFields['atar'][$key]; } /* if (isset($aFields['asource'][$key]) && $aFields['asource'][$key] != '') { $val .= '|source:'.$aFields['asource'][$key]; } */ $parameters_complete[$key] = array('link' => $val, 'tar' => $aFields['atar'][$key]); } } $parameters = array('swf' => $parameters_complete); } else { $parameters = null; } $aVariables['parameters'] = serialize($parameters); //TODO: deleting images is not viable because they could still be in use in the delivery cache // // Delete any old banners... // if (!empty($aBanner['filename']) && $aBanner['filename'] != $aVariables['filename']) { // phpAds_ImageDelete($aBanner['storagetype'], $aBanner['filename']); // } // if (!empty($aBanner['alt_filename']) && $aBanner['alt_filename'] != $aVariables['alt_filename']) { // phpAds_ImageDelete($aBanner['storagetype'], $aBanner['alt_filename']); // } // Clients are only allowed to modify certain fields, ensure that other fields are unchanged if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) { $aVariables['weight'] = $aBanner['weight']; $aVariables['description'] = $aBanner['name']; $aVariables['comments'] = $aBanner['comments']; } $insert = empty($bannerid) ? true : false; if ($oComponent) { $result = $oComponent->preprocessForm($insert, $bannerid, $aFields, $aVariables); if ($result === false) { // handle error return false; } } // File the data $doBanners->setFrom($aVariables); if ($insert) { $bannerid = $doBanners->insert(); // Run the Maintenance Priority Engine process OA_Maintenance_Priority::scheduleRun(); } else { $doBanners->update(); // check if size has changed if ($aVariables['width'] != $aBanner['width'] || $aVariables['height'] != $aBanner['height']) { MAX_adjustAdZones($bannerid); MAX_addDefaultPlacementZones($bannerid, $aVariables['campaignid']); } } if ($oComponent) { $result = $oComponent->processForm($insert, $bannerid, $aFields, $aVariables); if ($result === false) { // handle error // remove rec from banners table? return false; } } $translation = new OX_Translation(); if ($insert) { // Queue confirmation message $translated_message = $translation->translate($GLOBALS['strBannerHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'] . '&bannerid=' . $bannerid), htmlspecialchars($aFields['description']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); // Determine what the next page is if ($editSwf) { $nextPage = "banner-swf.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid'] . "&bannerid={$bannerid}&insert=true"; } else { $nextPage = "campaign-banners.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid']; } } else { // Determine what the next page is if ($editSwf) { $nextPage = "banner-swf.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid'] . "&bannerid={$bannerid}"; } else { $translated_message = $translation->translate($GLOBALS['strBannerHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'] . '&bannerid=' . $aFields['bannerid']), htmlspecialchars($aFields['description']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); $nextPage = "banner-edit.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid'] . "&bannerid={$bannerid}"; } } // Go to the next page Header("Location: {$nextPage}"); exit; }
| Copyright (c) 2003-2009 OpenX Limited | | For contact details, see: http://www.openx.org/ | | | | This program is free software; you can redistribute it and/or modify | | it under the terms of the GNU General Public License as published by | | the Free Software Foundation; either version 2 of the License, or | | (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | | | | You should have received a copy of the GNU General Public License | | along with this program; if not, write to the Free Software | | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | +---------------------------------------------------------------------------+ $Id: openads_upgrade_task_Maintenance_Priority.php 37157 2009-05-28 12:31:10Z andrew.hill $ */ if (!class_exists('OA_Maintenance_Priority')) { require_once MAX_PATH . '/lib/OA/Maintenance/Priority.php'; } if (!$upgradeTaskMessage) { $upgradeTaskMessage = array(); } $upgradeTaskError[] = 'Starting Maintenance Prioritisation'; $result = OA_Maintenance_Priority::run(); if (is_null($upgradeTaskResult) || $upgradeTaskResult) { $upgradeTaskResult = $result; } $upgradeTaskError[] = ' Maintenance Prioritisation: ' . ($result ? 'Complete' : 'Failed');
function save_ajax_request($banner_id, $campaign_id, $client_id, $image_id, $template_id, $banner_description, $banner_storagetype) { $file = fopen('http://zetaprints.com/preview/' . $image_id, 'rb'); $data = fread($file, 1024); while (!feof($file)) { $data .= fread($file, 1024); } fclose($file); $banner = OA_Dal::factoryDO('banners'); // Get the existing banner details (if it is not a new banner) if (!empty($banner_id)) { $result = $banner->get($banner_id); } if (!$result) { OA::debug('here'); $banner->bannerid = ''; $banner->campaignid = $campaign_id; $banner->clientid = $client_id; $banner->url = ''; $banner->imageurl = ''; $banner->weight = $pref['default_banner_weight']; $banner->description = $banner_description; $banner->storagetype = $banner_storagetype; } require_once MAX_PATH . '/lib/OA/Creative/File.php'; $file = OA_Creative_File::factoryString($image_id, $data); $file->store($banner->storagetype); if (!empty($banner->filename) && ($banner->storagetype == 'web' || $banner->storagetype == 'sql')) { DataObjects_Banners::deleteBannerFile($banner->storagetype, $banner->filename); } $file_detailes = $file->getFileDetails(); $new_banner = empty($banner_id) ? true : false; if ($new_banner) { $size_changed = $file_detailes['width'] != $banner->width || $file_detailes['height'] != $banner->height; } $banner->filename = $file_detailes['filename']; $banner->contenttype = $file_detailes['contenttype']; $banner->width = $file_detailes['width']; $banner->height = $file_detailes['height']; $banner->pluginversion = $file_detailes['pluginversion']; if ($new_banner) { $banner->insert(); require_once MAX_PATH . '/lib/OA/Maintenance/Priority.php'; OA_Maintenance_Priority::scheduleRun(); $banner_id = $banner->bannerid; } else { $banner->update(); // if size has changed if (size_changes) { MAX_adjustAdZones($banner_id); MAX_addDefaultPlacementZones($banner_id, $campaign_id); } } $zp_banners = OA_Dal::factoryDO('Zpbanners'); $zp_banners->set_zp_banner_id($banner_id, $template_id); return "banner-edit.php?clientid={$client_id}&campaignid={$campaign_id}&bannerid={$banner_id}"; }