/** * A method to convert PEAR_Error objects to strings. * * @static * @param PEAR_Error $oError A {@link PEAR_Error} object */ function errorObjToString($oError, $additionalInfo = null) { $aConf = $GLOBALS['_MAX']['CONF']; $message = htmlspecialchars($oError->getMessage()); $debugInfo = htmlspecialchars($oError->getDebugInfo()); $additionalInfo = htmlspecialchars($additionalInfo); $level = $oError->getCode(); $errorType = MAX::errorConstantToString($level); $img = MAX::constructURL(MAX_URL_IMAGE, 'errormessage.gif'); // Message $output = <<<EOF <br /> <div class="errormessage"> <img class="errormessage" src="{$img}" align="absmiddle"> <span class='tab-r'>{$errorType} Error</span> <br /> <br />{$message} <br /><pre>{$debugInfo}</pre> {$additionalInfo} </div> <br /> <br /> EOF; return $output; }
function init($templateName) { $this->template_dir = MAX_PATH . '/lib/templates/admin'; $this->compile_dir = MAX_PATH . '/var/templates_compiled'; $this->cache_dir = MAX_PATH . '/var/cache'; $this->caching = 0; $this->cache_lifetime = 3600; $this->register_function('t', array('OA_Admin_Template', '_function_t')); $this->register_function('tabindex', array('OA_Admin_Template', '_function_tabindex')); $this->register_function('oa_icon', array('OA_Admin_Template', '_function_oa_icon')); $this->register_function('oa_title_sort', array('OA_Admin_Template', '_function_oa_title_sort')); $this->register_function('ox_column_title', array('OA_Admin_Template', '_function_ox_column_title')); $this->register_function('ox_column_class', array('OA_Admin_Template', '_function_ox_column_class')); $this->register_function('ox_campaign_type', array('OA_Admin_Template', '_function_ox_campaign_type')); $this->register_function('ox_campaign_status', array('OA_Admin_Template', '_function_ox_campaign_status')); $this->register_function('ox_campaign_icon', array('OA_Admin_Template', '_function_ox_campaign_icon')); $this->register_function('ox_banner_size', array('OA_Admin_Template', '_function_ox_banner_size')); $this->register_function('ox_banner_icon', array('OA_Admin_Template', '_function_ox_banner_icon')); $this->register_function('ox_zone_size', array('OA_Admin_Template', '_function_ox_zone_size')); $this->register_function('ox_zone_icon', array('OA_Admin_Template', '_function_ox_zone_icon')); $this->register_function('ox_tracker_type', array('OA_Admin_Template', '_function_ox_tracker_type')); $this->register_function('ox_entity_id', array('OA_Admin_Template', '_function_ox_entity_id')); $this->register_function('boldSearchPhrase', array('OA_Admin_Template', '_function_boldSearchPhrase')); $this->register_function('oa_is_admin', array('OA_Admin_Template', '_function_oa_is_admin')); $this->register_function('oa_is_manager', array('OA_Admin_Template', '_function_oa_is_manager')); $this->register_function('oa_is_advertiser', array('OA_Admin_Template', '_function_oa_is_advertiser')); $this->register_function('oa_is_trafficker', array('OA_Admin_Template', '_function_oa_is_trafficker')); $this->register_function('phpAds_ShowBreak', array('OA_Admin_Template', '_function_phpAds_ShowBreak')); $this->register_function('phpAds_DelConfirm', array('OA_Admin_Template', '_function_phpAds_DelConfirm')); $this->register_function('MAX_zoneDelConfirm', array('OA_Admin_Template', '_function_MAX_zoneDelConfirm')); $this->register_function('showStatusText', array('OA_Admin_Template', '_function_showStatusText')); $this->register_function('showCampaignType', array('OA_Admin_Template', '_function_showCampaignType')); $this->register_function('oa_form_input_attributes', array('OA_Admin_Template', '_function_form_input_attributes')); $this->register_block('oa_edit', array('OA_Admin_Template', '_block_edit')); $this->register_block('oa_form_element', array('OA_Admin_Template', '_block_form_element')); $this->templateName = $templateName; $this->assign('phpAds_TextDirection', $GLOBALS['phpAds_TextDirection']); $this->assign('phpAds_TextAlignLeft', $GLOBALS['phpAds_TextAlignLeft']); $this->assign('phpAds_TextAlignRight', $GLOBALS['phpAds_TextAlignRight']); $this->assign('assetPath', OX::assetPath()); $this->assign("adminWebPath", MAX::constructURL(MAX_URL_ADMIN, '')); $this->assign("oaTemplateDir", MAX_PATH . '/lib/templates/admin/'); //for pluggable page elements //- plugins may need to refrence their JS in OXP page templates $this->assign("adminPluginWebPath", MAX::constructURL(MAX_URL_ADMIN, 'plugins')); //- plugins may need to inject their own //template based elements into normal templates $this->assign("pluginBaseDir", MAX_PATH . '/www/admin/plugins/'); $this->assign("pluginTemplateDir", '/templates/'); /** * CVE-2013-5954 * * Register the helper method to allow the the required session token to * be placed into GET method calls for CRUD operations in templates. See * OA_Permission::checkSessionToken() method for details. */ $this->register_function('rv_add_session_token', array('OA_Admin_Template', '_add_session_token')); }
/** * A method to launch and display the widget * */ function display() { $oTpl = new OA_Admin_Template('dashboard/grid.html'); $oTpl->assign('dashboardURL', MAX::constructURL(MAX_URL_ADMIN, 'dashboard.php')); $oTpl->assign('cssURL', OX::assetPath() . "/css"); $oTpl->assign('imageURL', OX::assetPath() . "/images"); $oTpl->assign('jsURL', OX::assetPath() . "/js"); $oTpl->display(); }
function test_constructURL_Includes_Nonstandard_Secure_Port_Number() { $http = $GLOBALS['_MAX']['HTTP']; $GLOBALS['_MAX']['HTTP'] = 'https://'; $_SERVER['SERVER_PORT'] = 4430; $GLOBALS['_MAX']['CONF']['openads']['sslPort'] = 4430; $url = MAX::constructURL(MAX_URL_ADMIN, 'test.html'); $this->assertEqual($url, 'https://www.maxstore.net:4430/www/admin/test.html', "A non-standard port number should be explicitly provided in delivery URLs. %s"); $GLOBALS['_MAX']['HTTP'] = $http; }
/** * If the agency has set the logout URL in a database, returns this URL * (trimmed). * Otherwise, returns 'index.php'. * * @param string $agencyId * @return string Url for redirection after logout. */ function getLogoutUrl($agencyId) { $doAgency = null; if ($agencyId) { $doAgency = OA_Dal::staticGetDO('agency', $agencyId); } if ($doAgency && !empty($doAgency->logout_url)) { return trim($doAgency->logout_url); } return MAX::constructURL(MAX_URL_ADMIN, 'index.php'); }
function redirectIfNecessary($adminPage) { $oDesiredUrl = new MAX_Url(); $oCurrentUrl = new MAX_Url(); $full_desired_url_string = MAX::constructURL(MAX_URL_ADMIN, $adminPage); $oDesiredUrl->useValuesFromString($full_desired_url_string); $oCurrentUrl->useValuesFromServerVariableArray($_SERVER); if ($oDesiredUrl->equals($oCurrentUrl)) { return; } $this->redirect($adminPage); }
/** * A method to launch and display the widget * */ function display() { $aConf = $GLOBALS['_MAX']['CONF']; phpAds_PageHeader(null, new OA_Admin_UI_Model_PageHeaderModel(), '', false, false); $oTpl = new OA_Admin_Template('dashboard/main.html'); if (!$aConf['ui']['dashboardEnabled'] || !$aConf['sync']['checkForUpdates']) { $dashboardUrl = MAX::constructURL(MAX_URL_ADMIN, 'dashboard.php?widget=Disabled'); } else { $dashboardUrl = MAX::constructURL(MAX_URL_ADMIN, 'dashboard.php?widget=Grid'); } $oTpl->assign('dashboardURL', $dashboardUrl); $oTpl->display(); phpAds_PageFooter('', true); }
/** * A method to construct URLs for static assets, such as images, CSS and * JavaScript files, based on OpenX installation and configuration details. * * @param string $asset An optional relative path to the asset. * @return string The URL to the asset. If asset was not provided, * the path does not contain a trailing slash. */ function assetPath($asset = null) { global $installing; $aConf = $GLOBALS['_MAX']['CONF']; $assetsVersion = $aConf['webpath']['adminAssetsVersion']; $prefix = $installing ? '' : MAX::constructURL(MAX_URL_ADMIN, ''); $pathWithSuffix = $prefix . "assets"; if (strlen($assetsVersion)) { $pathWithSuffix .= "/" . $assetsVersion; } if ($asset != null) { return $pathWithSuffix . "/" . $asset; } else { return $pathWithSuffix; } }
/** * A method to launch and display the widget * */ function display() { $aConf = $GLOBALS['_MAX']['CONF']; phpAds_PageHeader(null, new OA_Admin_UI_Model_PageHeaderModel(), '', false, false); $oTpl = new OA_Admin_Template('dashboard/main.html'); if (!$aConf['ui']['dashboardEnabled'] || !$aConf['sync']['checkForUpdates']) { $dashboardUrl = MAX::constructURL(MAX_URL_ADMIN, 'dashboard.php?widget=Disabled'); } else { $m2mTicket = OA_Dal_Central_M2M::getM2MTicket(OA_Permission::getAccountId()); if (empty($m2mTicket)) { $dashboardUrl = MAX::constructURL(MAX_URL_ADMIN, 'dashboard.php?widget=Reload'); } else { $dashboardUrl = $this->buildDashboardUrl($m2mTicket, null, '&'); } } $oTpl->assign('dashboardURL', $dashboardUrl); $oTpl->display(); phpAds_PageFooter('', true); }
/** * A private method to prepare the body of an advertiser's "campaign activated" * or "campaign deactivated" report email. * * @access private * @param integer $advertiserId The advertiser's ID. * @param array $acampaign The campaign details. */ function _prepareCampaignActivatedDeactivatedEmailBody($aCampaign) { // Load the "Campaign" and "Banner" strings, and prepare formatting strings global $strCampaign, $strBanner; $strCampaignLength = strlen($strCampaign); $strBannerLength = strlen($strBanner); $maxLength = max($strCampaignLength, $strBannerLength); $strCampaignPrint = '%-' . $maxLength . 's'; $strBannerPrint = ' %-' . ($maxLength - 1) . 's'; // Load remaining strings global $strLinkedTo; // Prepare the result $emailBody = ''; // Add the name of the campaign to the report $emailBody .= "\n" . sprintf($strCampaignPrint, $strCampaign) . ' '; $emailBody .= strip_tags(phpAds_buildName($aCampaign['campaignid'], $aCampaign['campaignname'])) . "\n"; // Add a URL link to the stats page of the campaign $page = 'stats.php?clientid=' . $aCampaign['clientid'] . '&campaignid=' . $aCampaign['campaignid'] . '&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end='; $emailBody .= MAX::constructURL(MAX_URL_ADMIN, $page) . "\n"; // Add a nice divider $emailBody .= "=======================================================\n\n"; // Fetch all ads in the campaign $doBanners = OA_Dal::factoryDO('banners'); $doBanners->campaignid = $aCampaign['campaignid']; $doBanners->orderBy('bannerid'); $doBanners->find(); if ($doBanners->getRowCount() > 0) { while ($doBanners->fetch()) { $aAd = $doBanners->toArray(); // Add the name of the ad to the report $emailBody .= sprintf($strBannerPrint, $strBanner) . ' '; $emailBody .= strip_tags(phpAds_buildBannerName($aAd['bannerid'], $aAd['description'], $aAd['alt'])) . "\n"; // If the ad has a URL, add the URL the add is linked to to the report if (!empty($aAd['url'])) { $emailBody .= ' ' . $strLinkedTo . ': ' . $aAd['url'] . "\n"; } $emailBody .= "\n"; } } return $emailBody; }
function processForm($aZone, $form, $oComponent = null) { $aFields = $form->exportValues(); if (empty($aFields['zoneid'])) { return; } $doZones = OA_Dal::factoryDO('zones'); $doZones->get($aFields['zoneid']); // Determine chain if ($aFields['chaintype'] == '1' && $aFields['chainzone'] != '') { $chain = 'zone:' . $aFields['chainzone']; } else { $chain = ''; } $doZones->chain = $chain; if (!isset($aFields['prepend'])) { $aFields['prepend'] = ''; } $aFields['prepend'] = MAX_commonGetValueUnslashed('prepend'); $doZones->prepend = $aFields['prepend']; // Do not save append until not finished with zone appending, if present if (!empty($aFields['appendsave'])) { if (!isset($aFields['append'])) { $aFields['append'] = ''; } if (!isset($aFields['appendtype'])) { $aFields['appendtype'] = phpAds_ZoneAppendZone; } $aFields['append'] = MAX_commonGetValueUnslashed('append'); $doZones->append = $aFields['append']; $doZones->appendtype = $aFields['appendtype']; } if (isset($aFields['forceappend'])) { $doZones->forceappend = $aFields['forceappend']; } $block = _initCappingVariables($aFields['time'], $aFields['capping'], $aFields['session_capping']); // Set adselection PCI if required if (isset($aFields['ext_adselection'])) { $doZones->ext_adselection = $aFields['ext_adselection'] == 'none' ? OX_DATAOBJECT_NULL : $aFields['ext_adselection']; } $doZones->block = $block; $doZones->capping = $aFields['capping']; $doZones->session_capping = $aFields['session_capping']; if ($aFields['show_capped_no_cookie'] != 1) { $aFields['show_capped_no_cookie'] = 0; } $doZones->show_capped_no_cookie = $aFields['show_capped_no_cookie']; $doZones->update(); // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strZoneAdvancedHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'zone-edit.php?affiliateid=' . $aFields['affiliateid'] . '&zoneid=' . $aFields['zoneid']), htmlspecialchars($doZones->zonename))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); // Rebuild Cache // require_once MAX_PATH . '/lib/max/deliverycache/cache-'.$conf['delivery']['cache'].'.inc.php'; // phpAds_cacheDelete('what=zone:'.$zoneid); $oUI = OA_Admin_UI::getInstance(); OX_Admin_Redirect::redirect("zone-advanced.php?affiliateid=" . $aFields['affiliateid'] . "&zoneid=" . $aFields['zoneid']); }
} } else { if ('settings' == $action) { require_once LIB_PATH . '/Admin/Redirect.php'; OX_Admin_Redirect::redirect("plugin-settings.php?group={$group}&parent={$parent}"); } else { if ('preferences' == $action) { require_once LIB_PATH . '/Admin/Redirect.php'; OX_Admin_Redirect::redirect("plugin-preferences.php?group={$group}&parent={$parent}"); } else { if (array_key_exists('checkdb', $_GET)) { $aInfo = $oComponentGroupManager->getComponentGroupInfo($_GET['checkdb']); $aSchema = $oComponentGroupManager->checkDatabase($_GET['checkdb'], $aInfo); $oTpl = new OA_Admin_Template('plugin-group-index.html'); $oTpl->assign('parent', $_GET['parent']); $oTpl->assign('parenturl', MAX::constructURL(MAX_URL_ADMIN, "plugin-index.php?info={$_GET['parent']}&package=true")); $oTpl->assign('aHeader', $aInfo); $oTpl->assign('aPluginDB', $aSchema); } } } } } } } } } } } } }
} /*-------------------------------------------------------*/ /* Main code */ /*-------------------------------------------------------*/ if (!empty($campaignid)) { if (!empty($duplicate)) { // Duplicate the campaign $doCampaigns = OA_Dal::factoryDO('campaigns'); $doCampaigns->get($campaignid); $oldName = $doCampaigns->campaignname; $newCampaignId = $doCampaigns->duplicate(); if ($newCampaignId) { // Queue confirmation message $newName = $doCampaigns->campaignname; $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strCampaignHasBeenDuplicated'], array(MAX::constructURL(MAX_URL_ADMIN, "campaign-edit.php?clientid={$clientid}&campaignid={$campaignid}"), htmlspecialchars($oldName), MAX::constructURL(MAX_URL_ADMIN, "campaign-edit.php?clientid={$clientid}&campaignid={$newCampaignId}"), htmlspecialchars($newName))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); Header("Location: {$returnurl}?clientid={$clientid}&campaignid={$newCampaignId}"); exit; } else { phpAds_sqlDie(); } } else { if (!empty($newclientid)) { /*-------------------------------------------------------*/ /* Restore cache of $node_array, if it exists */ /*-------------------------------------------------------*/ if (isset($session['prefs']['advertiser-index.php']['nodes'])) { $node_array = $session['prefs']['advertiser-index.php']['nodes']; } /*-------------------------------------------------------*/
/*-------------------------------------------------------*/ if (!empty($action)) { if (empty($acl)) { $acl = array(); } $acl = MAX_AclAdjust($acl, $action); } elseif (!empty($submit)) { $acl = isset($acl) ? $acl : array(); // Only save when inputs are valid if (OX_AclCheckInputsFields($acl, $pageName) === true) { if (MAX_AclSave($acl, $aEntities)) { // Queue confirmation message $doChannel = OA_Dal::factoryDO('channel'); $doChannel->get($channelid); $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strChannelAclHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "channel-edit.php?" . (!empty($affiliateid) ? "affiliateid={$affiliateid}&" : "") . "channelid={$channelid}"), htmlspecialchars($doChannel->name))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); // Redirect if (!empty($affiliateid)) { header("Location: channel-acl.php?affiliateid={$affiliateid}&channelid={$channelid}"); } else { header("Location: channel-acl.php?channelid={$channelid}"); } exit; } } } /*-------------------------------------------------------*/ /* HTML framework */ /*-------------------------------------------------------*/ MAX_displayNavigationChannel($pageName, $aOtherChannels, $aEntities);
/** * A method to launch and display the widget * * @param array $aParams The parameters array, usually $_REQUEST */ function display() { $conf = $GLOBALS['_MAX']['CONF']; if (!$conf['audit']['enabled']) { $this->oTpl->assign('screen', 'disabled'); $this->oTpl->assign('siteTitle', $GLOBALS['strCampaignAuditTrailSetup']); $this->oTpl->assign('siteUrl', MAX::constructUrl(MAX_URL_ADMIN, 'account-settings-debug.php')); } else { $oCache = new OA_Cache('campaignOverview', 'Widgets'); $aCache = $oCache->load(true); $aCampaign = array(); if (isset($aCache['maxItems'])) { if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) { foreach ($aCache['aAccounts'] as $aActions) { foreach ($aActions as $aAction) { $aCampaign[$aAction['auditid']] = $aAction; } } } else { $aAccountsId = OA_Permission::getOwnedAccounts(OA_Permission::getAccountId()); foreach ($aAccountsId as $accountId) { if (isset($aCache['aAccounts'][$accountId])) { foreach ($aCache['aAccounts'][$accountId] as $aAction) { $aCampaign[$aAction['auditid']] = $aAction; } } } } krsort($aCampaign); $aCampaign = array_slice($aCampaign, 0, $aCache['maxItems']); } if (count($aCampaign)) { $aActionMap = array('added' => $GLOBALS['strCampaignStatusAdded'], 'started' => $GLOBALS['strCampaignStatusStarted'], 'restarted' => $GLOBALS['strCampaignStatusRestarted'], 'completed' => $GLOBALS['strCampaignStatusExpired'], 'paused' => $GLOBALS['strCampaignStatusPaused'], 'deleted' => $GLOBALS['strCampaignStatusDeleted']); foreach ($aCampaign as $k => $v) { if (isset($aActionMap[$v['action']])) { $aCampaign[$k]['actionDesc'] = $aActionMap[$v['action']]; } } } else { // Check if the account has any campaign in its realm $doCampaigns = OA_Dal::factoryDO('campaigns'); if (!empty($aParam['account_id'])) { $doClients = OA_Dal::factoryDO('clients'); $doAgency = OA_Dal::factoryDO('agency'); $doAgency->account_id = $aParam['account_id']; $doClients->joinAdd($doAgency); $doCampaigns->joinAdd($doClients); } $doCampaigns->limit(1); $this->oTpl->assign('hasCampaigns', $doCampaigns->count()); if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) { $this->oTpl->assign('isAdmin', true); } } $this->oTpl->assign('screen', 'enabled'); $this->oTpl->assign('aCampaign', $aCampaign); $this->oTpl->assign('siteUrl', MAX::constructURL(MAX_URL_ADMIN, 'advertiser-campaigns.php')); $this->oTpl->assign('baseUrl', MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php')); } $this->oTpl->display(); }
$session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['campaignid'][$clientid] = $campaignid; phpAds_SessionDataStore(); /*-------------------------------------------------------*/ /* Process submitted form */ /*-------------------------------------------------------*/ if (isset($submitbutton)) { if (isset($bannerid) && $bannerid != '') { // Update banner $doBanners = OA_Dal::factoryDO('banners'); $doBanners->get($bannerid); $doBanners->append = $append; $doBanners->appendtype = phpAds_ZoneAppendRaw; $doBanners->update(); // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strBannerAdvancedHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $clientid . '&campaignid=' . $campaignid . '&bannerid=' . $bannerid), htmlspecialchars($doBanners->description))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); } header("Location: banner-advanced.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&bannerid=" . $bannerid); } /*-------------------------------------------------------*/ /* HTML framework */ /*-------------------------------------------------------*/ // Initialise some parameters $pageName = basename($_SERVER['PHP_SELF']); $tabindex = 1; $agencyId = OA_Permission::getAgencyId(); $aEntities = array('clientid' => $clientid, 'campaignid' => $campaignid, 'bannerid' => $bannerid); // Display navigation $aOtherCampaigns = Admin_DA::getPlacements(array('agency_id' => $agencyId)); $aOtherBanners = Admin_DA::getAds(array('placement_id' => $campaignid), false);
function processForm($aAdvertiser, $form) { $aFields = $form->exportValues(); // Name if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) { $aAdvertiser['clientname'] = $aFields['clientname']; } // Default fields $aAdvertiser['contact'] = $aFields['contact']; $aAdvertiser['email'] = $aFields['email']; $aAdvertiser['comments'] = $aFields['comments']; // Same advertiser limitation $aAdvertiser['advertiser_limitation'] = $aFields['advertiser_limitation'] == '1' ? 1 : 0; // Reports $aAdvertiser['report'] = $aFields['report'] == 't' ? 't' : 'f'; $aAdvertiser['reportdeactivate'] = $aFields['reportdeactivate'] == 't' ? 't' : 'f'; $aAdvertiser['reportinterval'] = (int) $aFields['reportinterval']; if ($aAdvertiser['reportinterval'] == 0) { $aAdvertiser['reportinterval'] = 1; } if ($aFields['reportlastdate'] == '' || $aFields['reportlastdate'] == '0000-00-00' || $aFields['reportprevious'] != $aAdvertiser['report']) { $aAdvertiser['reportlastdate'] = date("Y-m-d"); } if (empty($aAdvertiser['clientid'])) { // Set agency ID $aAdvertiser['agencyid'] = OA_Permission::getAgencyId(); $doClients = OA_Dal::factoryDO('clients'); $doClients->setFrom($aAdvertiser); $doClients->updated = OA::getNow(); // Insert $aAdvertiser['clientid'] = $doClients->insert(); // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strAdvertiserHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'advertiser-edit.php?clientid=' . $aAdvertiser['clientid']), htmlspecialchars($aAdvertiser['clientname']), MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php?clientid=' . $aAdvertiser['clientid']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); // Go to next page OX_Admin_Redirect::redirect("advertiser-index.php"); } else { $doClients = OA_Dal::factoryDO('clients'); $doClients->get($aAdvertiser['clientid']); $doClients->setFrom($aAdvertiser); $doClients->updated = OA::getNow(); $doClients->update(); // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strAdvertiserHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'advertiser-edit.php?clientid=' . $aAdvertiser['clientid']), htmlspecialchars($aAdvertiser['clientname']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect('advertiser-edit.php?clientid=' . $aAdvertiser['clientid']); } 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: lib-maintenance-priority.inc.php 37157 2009-05-28 12:31:10Z andrew.hill $ */ function OA_runMPE() { $objResponse = new xajaxResponse(); $objResponse->addAssign("run-mpe", "innerHTML", "<img src='run-mpe.php' />"); return $objResponse; } require_once MAX_PATH . '/lib/Max.php'; require_once MAX_PATH . '/lib/xajax/xajax.inc.php'; $xajax = new xajax(MAX::constructURL(MAX_URL_ADMIN, 'run-mpe-xajax.php')); $xajax->registerFunction("OA_runMPE"); $xajax->processRequests();
if (is_array($v['publisher_hidden'])) { foreach ($v['publisher_hidden'] as $p) { $variable_publisher[$p] = 0; } } foreach ($variable_publisher as $publisher_id => $visible) { $doVariable_publisher = OA_Dal::factoryDO('variable_publisher'); $doVariable_publisher->variable_id = $v['variableid']; $doVariable_publisher->publisher_id = $publisher_id; $doVariable_publisher->visible = $visible; $doVariable_publisher->insert(); } } // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strTrackerVarsHaveBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "tracker-edit.php?clientid=" . $clientid . "&trackerid=" . $trackerid), htmlspecialchars($doTrackers->trackername))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); // unset variables! unset($session['prefs']['tracker-variables.php']); phpAds_SessionDataStore(); // Rebuild cache // require_once MAX_PATH . '/lib/max/deliverycache/cache-'.$conf['delivery']['cache'].'.inc.php'; // phpAds_CacheDelete('what=tracker:' . $trackerid); // redirect to the next page header("Location: tracker-variables.php?clientid=" . $clientid . "&trackerid=" . $trackerid); exit; } } $doClients = OA_Dal::factoryDO('clients'); $doClients->whereAdd('clientid <>' . $trackerid); if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
function processForm($affiliateid, $form, $oComponent) { $aFields = $form->exportValues(); $newWebsite = empty($aFields['affiliateid']); // Setup a new publisher object and set the fields passed in from the form: $oPublisher = new OA_Dll_PublisherInfo(); $oPublisher->agencyId = $aFields['agencyid']; $oPublisher->contactName = $aFields['contact']; $oPublisher->emailAddress = $aFields['email']; $oPublisher->publisherId = $aFields['affiliateid']; $oPublisher->publisherName = $aFields['name']; $oPublisher->website = $aFields['website']; // process form data for oxThorium if this is edit existing website if (!$newWebsite && $oComponent) { $aFields['affiliateid'] = $oPublisher->publisherId; $oComponent->processAffiliateForm($aFields); } $oPublisherDll = new OA_Dll_Publisher(); if ($oPublisherDll->modify($oPublisher) && !$oPublisherDll->_noticeMessage) { // Queue confirmation message $translation = new OX_Translation(); if ($newWebsite) { //process form data for oxThorium for new website if ($oComponent) { $aFields['affiliateid'] = $oPublisher->publisherId; $oComponent->processAffiliateForm($aFields); } $translated_message = $translation->translate($GLOBALS['strWebsiteHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'affiliate-edit.php?affiliateid=' . $oPublisher->publisherId), htmlspecialchars($oPublisher->publisherName), MAX::constructURL(MAX_URL_ADMIN, 'zone-edit.php?affiliateid=' . $oPublisher->publisherId))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); $redirectURL = "website-index.php"; } else { $translated_message = $translation->translate($GLOBALS['strWebsiteHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'affiliate-edit.php?affiliateid=' . $oPublisher->publisherId), htmlspecialchars($oPublisher->publisherName))); $redirectURL = "affiliate-edit.php?affiliateid={$oPublisher->publisherId}"; } OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect($redirectURL); } return $oPublisherDll; }
/** * Processes submit values of zone form * * @param OA_Admin_UI_Component_Form $form form to process * @return An array of Pear::Error objects if any */ function processForm($form) { $aFields = $form->exportValues(); switch ($aFields['delivery']) { case phpAds_ZoneText: $aFields['width'] = $aFields['height'] = 0; break; case OX_ZoneVideoOverlay: $aFields['width'] = $aFields['height'] = -2; break; case OX_ZoneVideoInstream: $aFields['width'] = $aFields['height'] = -3; break; default: if ($aFields['sizetype'] == 'custom') { if (isset($aFields['width']) && $aFields['width'] == '*') { $aFields['width'] = -1; } if (isset($aFields['height']) && $aFields['height'] == '*') { $aFields['height'] = -1; } } else { list($aFields['width'], $aFields['height']) = explode('x', $aFields['size']); } break; } if (!is_numeric($aFields['oac_category_id']) || $aFields['oac_category_id'] <= 0) { $aFields['oac_category_id'] = 'NULL'; } if (empty($errors)) { // Edit if (!empty($aFields['zoneid'])) { // before we commit any changes to db, store whether the size has changed $aZone = Admin_DA::getZone($aFields['zoneid']); $size_changed = $aFields['width'] != $aZone['width'] || $aFields['height'] != $aZone['height'] ? true : false; $type_changed = $aFields['delivery'] != $aZone['delivery'] ? true : false; $doZones = OA_Dal::factoryDO('zones'); $doZones->zonename = $aFields['zonename']; $doZones->description = $aFields['description']; $doZones->width = $aFields['width']; $doZones->height = $aFields['height']; $doZones->comments = $aFields['comments']; $doZones->delivery = $aFields['delivery']; if ($aFields['delivery'] != phpAds_ZoneText && $aFields['delivery'] != phpAds_ZoneBanner) { $doZones->append = ''; } if ($aFields['delivery'] != phpAds_ZoneText) { $doZones->prepend = ''; } $doZones->oac_category_id = $aFields['oac_category_id']; $doZones->zoneid = $aFields['zoneid']; $doZones->update(); // Ad Networks $doPublisher = OA_Dal::factoryDO('affiliates'); $doPublisher->get($aFields['affiliateid']); $anWebsiteId = $doPublisher->as_website_id; if ($anWebsiteId) { $oAdNetworks = new OA_Central_AdNetworks(); $doZones->get($aFields['zoneid']); $oAdNetworks->updateZone($doZones, $anWebsiteId); } // Reset append codes which called this zone $doZones = OA_Dal::factoryDO('zones'); $doZones->appendtype = phpAds_ZoneAppendZone; if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) { $doZones->addReferenceFilter('agency', OA_Permission::getEntityId()); } elseif (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) { $doZones->addReferenceFilter('affiliates', OA_Permission::getEntityId()); } $doZones->find(); while ($doZones->fetch() && ($row = $doZones->toArray())) { $append = phpAds_ZoneParseAppendCode($row['append']); if ($append[0]['zoneid'] == $aFields['zoneid']) { $doZonesClone = clone $doZones; $doZonesClone->appendtype = phpAds_ZoneAppendRaw; $doZonesClone->append = ''; $doZonesClone->update(); } } if ($type_changed && $aFields['delivery'] == MAX_ZoneEmail) { // Unlink all campaigns/banners linked to this zone $aPlacementZones = Admin_DA::getPlacementZones(array('zone_id' => $aFields['zoneid']), true, 'placement_id'); if (!empty($aPlacementZones)) { foreach ($aPlacementZones as $placementId => $aPlacementZone) { Admin_DA::deletePlacementZones(array('zone_id' => $aFields['zoneid'], 'placement_id' => $placementId)); } } $aAdZones = Admin_DA::getAdZones(array('zone_id' => $aFields['zoneid']), false, 'ad_id'); if (!empty($aAdZones)) { foreach ($aAdZones as $adId => $aAdZone) { Admin_DA::deleteAdZones(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId)); } } } else { if ($size_changed) { $aZone = Admin_DA::getZone($aFields['zoneid']); // Loop through all appended banners and make sure that they still fit... $aAds = Admin_DA::getAdZones(array('zone_id' => $aFields['zoneid']), false, 'ad_id'); if (!empty($aAds)) { foreach ($aAds as $adId => $aAd) { $aAd = Admin_DA::getAd($adId); if ($aZone['type'] == phpAds_ZoneText && $aAd['type'] != 'txt' || $aAd['width'] != $aZone['width'] && $aZone['width'] > -1 || $aAd['height'] != $aZone['height'] && $aZone['height'] > -1) { Admin_DA::deleteAdZones(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId)); } } } // Check if any campaigns linked to this zone have ads that now fit. // If so, link them to the zone. $aPlacementZones = Admin_DA::getPlacementZones(array('zone_id' => $aFields['zoneid']), true); if (!empty($aPlacementZones)) { foreach ($aPlacementZones as $aPlacementZone) { // get ads in this campaign $aAds = Admin_DA::getAds(array('placement_id' => $aPlacementZone['placement_id']), true); foreach ($aAds as $adId => $aAd) { Admin_DA::addAdZone(array('zone_id' => $aFields['zoneid'], 'ad_id' => $adId)); } } } } } // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strZoneHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "zone-edit.php?affiliateid=" . $aFields['affiliateid'] . "&zoneid=" . $aFields['zoneid']), htmlspecialchars($aFields['zonename']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect("zone-edit.php?affiliateid=" . $aFields['affiliateid'] . "&zoneid=" . $aFields['zoneid']); } else { $doZones = OA_Dal::factoryDO('zones'); $doZones->affiliateid = $aFields['affiliateid']; $doZones->zonename = $aFields['zonename']; $doZones->zonetype = phpAds_ZoneCampaign; $doZones->description = $aFields['description']; $doZones->comments = $aFields['comments']; $doZones->width = $aFields['width']; $doZones->height = $aFields['height']; $doZones->delivery = $aFields['delivery']; $doZones->oac_category_id = $aFields['oac_category_id']; // The following fields are NOT NULL but do not get values set in the form. // Should these fields be changed to NULL in the schema or should they have a default value? $doZones->category = ''; $doZones->ad_selection = ''; $doZones->chain = ''; $doZones->prepend = ''; $doZones->append = ''; $aFields['zoneid'] = $doZones->insert(); // Ad Networks $doPublisher = OA_Dal::factoryDO('affiliates'); $doPublisher->get($aFields['affiliateid']); $anWebsiteId = $doPublisher->as_website_id; if ($anWebsiteId) { $oAdNetworks = new OA_Central_AdNetworks(); $oAdNetworks->updateZone($doZones, $anWebsiteId); } // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strZoneHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'zone-edit.php?affiliateid=' . $aFields['affiliateid'] . '&zoneid=' . $aFields['zoneid']), htmlspecialchars($aFields['zonename']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect("affiliate-zones.php?affiliateid=" . $aFields['affiliateid']); } } return $errors; }
/** * Processes submit values of campaign form * * @param OA_Admin_UI_Component_Form $form form to process * @return An array of Pear::Error objects if any */ function processCampaignForm($form, &$oComponent = null) { $aFields = $form->exportValues(); if (!empty($aFields['start'])) { $oDate = new Date(date('Y-m-d 00:00:00', strtotime($aFields['start']))); $oDate->toUTC(); $activate = $oDate->getDate(); } else { $oDate = new Date(date('Y-m-d 00:00:00')); $oDate->toUTC(); $activate = $oDate->getDate(); } if (!empty($aFields['end'])) { $oDate = new Date(date('Y-m-d 23:59:59', strtotime($aFields['end']))); $oDate->toUTC(); $expire = $oDate->getDate(); } else { $expire = null; } if (empty($aFields['campaignid'])) { // The form is submitting a new campaign, so, the ID is not set; // set the ID to the string "null" so that the table auto_increment // or sequence will be used when the campaign is created $aFields['campaignid'] = "null"; } else { // The form is submitting a campaign modification; need to test // if any of the banners in the campaign are linked to an email zone, // and if so, if the link(s) would still be valid if the change(s) // to the campaign were made... $dalCampaigns = OA_Dal::factoryDAL('campaigns'); $aCurrentLinkedEmalZoneIds = $dalCampaigns->getLinkedEmailZoneIds($aFields['campaignid']); if (PEAR::isError($aCurrentLinkedEmalZoneIds)) { OX::disableErrorHandling(); $errors[] = PEAR::raiseError($GLOBALS['strErrorDBPlain']); OX::enableErrorHandling(); } $errors = array(); foreach ($aCurrentLinkedEmalZoneIds as $zoneId) { $thisLink = Admin_DA::_checkEmailZoneAdAssoc($zoneId, $aFields['campaignid'], $activate, $expire); if (PEAR::isError($thisLink)) { $errors[] = $thisLink; break; } } } //correct and check revenue and ecpm correctAdnCheckNumericFormField($aFields, $errors, 'revenue', $GLOBALS['strErrorEditingCampaignRevenue']); correctAdnCheckNumericFormField($aFields, $errors, 'ecpm', $GLOBALS['strErrorEditingCampaignECPM']); if (empty($errors)) { //check booked limits values // If this is a remnant, ecpm or exclusive campaign with an expiry date, set the target's to unlimited if (!empty($expire) && ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_ECPM || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_EXCLUSIVE)) { $aFields['impressions'] = $aFields['clicks'] = $aFields['conversions'] = -1; } else { if (!empty($aFields['impr_unlimited']) && $aFields['impr_unlimited'] == 't') { $aFields['impressions'] = -1; } else { if (empty($aFields['impressions']) || $aFields['impressions'] == '-') { $aFields['impressions'] = 0; } } if (!empty($aFields['click_unlimited']) && $aFields['click_unlimited'] == 't') { $aFields['clicks'] = -1; } else { if (empty($aFields['clicks']) || $aFields['clicks'] == '-') { $aFields['clicks'] = 0; } } if (!empty($aFields['conv_unlimited']) && $aFields['conv_unlimited'] == 't') { $aFields['conversions'] = -1; } else { if (empty($aFields['conversions']) || $aFields['conversions'] == '-') { $aFields['conversions'] = 0; } } } //pricing model - reset fields not applicable to model to 0, //note that in new flow MAX_FINANCE_CPA allows all limits to be set if ($aFields['revenue_type'] == MAX_FINANCE_CPM) { $aFields['clicks'] = -1; $aFields['conversions'] = -1; } else { if ($aFields['revenue_type'] == MAX_FINANCE_CPC) { $aFields['conversions'] = -1; } else { if ($aFields['revenue_type'] == MAX_FINANCE_MT) { $aFields['impressions'] = -1; $aFields['clicks'] = -1; $aFields['conversions'] = -1; } } } //check type and set priority if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT) { $aFields['priority'] = 0; //low } else { if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_NORMAL) { $aFields['priority'] = isset($aFields['high_priority_value']) ? $aFields['high_priority_value'] : 5; //high } else { if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_EXCLUSIVE) { $aFields['priority'] = -1; //exclusive } else { if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_ECPM) { $aFields['priority'] = -2; //ecpm } } } } // Set target $target_impression = 0; $target_click = 0; $target_conversion = 0; if ($aFields['priority'] > 0) { // Daily targets need to be set only if the campaign doesn't have both expiration and lifetime targets $hasExpiration = !empty($expire); $hasLifetimeTargets = $aFields['impressions'] != -1 || $aFields['clicks'] != -1 || $aFields['conversions'] != -1; if (!($hasExpiration && $hasLifetimeTargets) && isset($aFields['target_value']) && $aFields['target_value'] != '-') { switch ($aFields['target_type']) { case 'target_impression': $target_impression = $aFields['target_value']; break; case 'target_click': $target_click = $aFields['target_value']; break; case 'target_conversion': $target_conversion = $aFields['target_value']; break; } } $aFields['weight'] = 0; } else { // Set weight if (!isset($aFields['weight']) || $aFields['weight'] == '-' || $aFields['weight'] == '') { $aFields['weight'] = 0; } } if ($aFields['anonymous'] != 't') { $aFields['anonymous'] = 'f'; } if ($aFields['companion'] != 1) { $aFields['companion'] = 0; } if ($aFields['show_capped_no_cookie'] != 1) { $aFields['show_capped_no_cookie'] = 0; } $new_campaign = $aFields['campaignid'] == 'null'; if (empty($aFields['revenue']) || $aFields['revenue'] <= 0) { // No revenue information, set to null $aFields['revenue'] = OX_DATAOBJECT_NULL; } if (empty($aFields['ecpm']) || $aFields['ecpm'] <= 0) { // No ecpm information, set to null $aFields['ecpm'] = OX_DATAOBJECT_NULL; } // Get the capping variables $block = _initCappingVariables($aFields['time'], $aFields['capping'], $aFields['session_capping']); $doCampaigns = OA_Dal::factoryDO('campaigns'); $doCampaigns->campaignname = $aFields['campaignname']; $doCampaigns->clientid = $aFields['clientid']; $doCampaigns->views = $aFields['impressions']; $doCampaigns->clicks = $aFields['clicks']; $doCampaigns->conversions = $aFields['conversions']; $doCampaigns->priority = $aFields['priority']; $doCampaigns->weight = $aFields['weight']; $doCampaigns->target_impression = $target_impression; $doCampaigns->target_click = $target_click; $doCampaigns->target_conversion = $target_conversion; $doCampaigns->min_impressions = $aFields['min_impressions']; $doCampaigns->ecpm = $aFields['ecpm']; $doCampaigns->anonymous = $aFields['anonymous']; $doCampaigns->companion = $aFields['companion']; $doCampaigns->show_capped_no_cookie = $aFields['show_capped_no_cookie']; $doCampaigns->comments = $aFields['comments']; $doCampaigns->revenue = $aFields['revenue']; $doCampaigns->revenue_type = $aFields['revenue_type']; $doCampaigns->block = $block; $doCampaigns->capping = $aFields['capping']; $doCampaigns->session_capping = $aFields['session_capping']; // Activation and expiration $doCampaigns->activate_time = isset($activate) ? $activate : OX_DATAOBJECT_NULL; $doCampaigns->expire_time = isset($expire) ? $expire : OX_DATAOBJECT_NULL; if (!empty($aFields['campaignid']) && $aFields['campaignid'] != "null") { $doCampaigns->campaignid = $aFields['campaignid']; $doCampaigns->setEcpmEnabled(); $doCampaigns->update(); } else { $doCampaigns->setEcpmEnabled(); $aFields['campaignid'] = $doCampaigns->insert(); } if ($oComponent) { $oComponent->processCampaignForm($aFields); } // Recalculate priority only when editing a campaign // or moving banners into a newly created, and when: // // - campaign changes status (activated or deactivated) or // - the campaign is active and target/weight are changed // if (!$new_campaign) { $doCampaigns = OA_Dal::staticGetDO('campaigns', $aFields['campaignid']); $status = $doCampaigns->status; switch (true) { case (bool) $status != (bool) $aFields['status_old']: // Run the Maintenance Priority Engine process OA_Maintenance_Priority::scheduleRun(); break; case $status == OA_ENTITY_STATUS_RUNNING: if (!empty($aFields['target_type']) && ${$aFields['target_type']} != $aFields['target_old'] || !empty($aFields['target_type']) && $aFields['target_type_old'] != $aFields['target_type'] || $aFields['weight'] != $aFields['weight_old'] || $aFields['clicks'] != $aFields['previousclicks'] || $aFields['conversions'] != $aFields['previousconversions'] || $aFields['impressions'] != $aFields['previousimpressions']) { // Run the Maintenance Priority Engine process OA_Maintenance_Priority::scheduleRun(); } break; } } // Rebuild cache // include_once MAX_PATH . '/lib/max/deliverycache/cache-'.$conf['delivery']['cache'].'.inc.php'; // phpAds_cacheDelete(); // Delete channel forecasting cache include_once 'Cache/Lite.php'; $options = array('cacheDir' => MAX_CACHE); $cache = new Cache_Lite($options); $group = 'campaign_' . $aFields['campaignid']; $cache->clean($group); $translation = new OX_Translation(); if ($new_campaign) { // Queue confirmation message $translated_message = $translation->translate($GLOBALS['strCampaignHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid']), htmlspecialchars($aFields['campaignname']), MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect("advertiser-campaigns.php?clientid=" . $aFields['clientid']); } else { $translated_message = $translation->translate($GLOBALS['strCampaignHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid']), htmlspecialchars($aFields['campaignname']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect("campaign-edit.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid']); } } //return processing errors return $errors; }
function processForm($form) { $aFields = $form->exportValues(); // If ID is not set, it should be a null-value for the auto_increment if (empty($aFields['trackerid'])) { $aFields['trackerid'] = "null"; } $doTrackers = OA_Dal::factoryDO('trackers'); $doTrackers->trackername = $aFields['trackername']; $doTrackers->description = $aFields['description']; $doTrackers->status = $aFields['status']; $doTrackers->type = $aFields['type']; $doTrackers->linkcampaigns = $aFields['linkcampaigns'] == "t" ? "t" : "f"; $doTrackers->clientid = $aFields['clientid']; if (empty($aFields['trackerid']) || $aFields['trackerid'] == "null") { $aFields['trackerid'] = $doTrackers->insert(); // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strTrackerHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, "tracker-edit.php?clientid=" . $aFields['clientid'] . "&trackerid=" . $aFields['trackerid']), htmlspecialchars($aFields['trackername']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect('advertiser-trackers.php?clientid=' . $aFields['clientid']); } else { $doTrackers->trackerid = $aFields['trackerid']; $doTrackers->update(); // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strTrackerHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "tracker-edit.php?clientid=" . $aFields['clientid'] . "&trackerid=" . $aFields['trackerid']), htmlspecialchars($aFields['trackername']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect("tracker-edit.php?clientid=" . $aFields['clientid'] . "&trackerid=" . $aFields['trackerid']); } exit; }
function _assignUserAccountInfo($oCurrentSection) { global $session; // Show currently logged on user and IP if (OA_Auth::isLoggedIn() || defined('phpAds_installing')) { $this->oTpl->assign('helpLink', OA_Admin_Help::getHelpLink($oCurrentSection)); if (!defined('phpAds_installing')) { $this->oTpl->assign('infoUser', OA_Permission::getUsername()); $this->oTpl->assign('buttonLogout', true); $this->oTpl->assign('buttonReportBugs', true); // Account switcher OA_Admin_UI_AccountSwitch::assignModel($this->oTpl); $this->oTpl->assign('strWorkingAs', $GLOBALS['strWorkingAs_Key']); $this->oTpl->assign('keyWorkingAs', $GLOBALS['keyWorkingAs']); $this->oTpl->assign('accountId', OA_Permission::getAccountId()); $this->oTpl->assign('accountName', OA_Permission::getAccountName()); $this->oTpl->assign('accountSearchUrl', MAX::constructURL(MAX_URL_ADMIN, 'account-switch-search.php')); $this->oTpl->assign('productUpdatesCheck', OA_Permission::isAccount(OA_ACCOUNT_ADMIN) && $GLOBALS['_MAX']['CONF']['sync']['checkForUpdates'] && !isset($session['maint_update_js'])); if (OA_Permission::isUserLinkedToAdmin()) { $this->oTpl->assign('maintenanceAlert', OA_Dal_Maintenance_UI::alertNeeded()); } } else { $this->oTpl->assign('buttonStartOver', true); } } }
if (isset($trackerids) && is_array($trackerids)) { for ($i = 0; $i < sizeof($trackerids); $i++) { $aFields = array('campaignid', 'trackerid', 'status'); $values = array($campaignid, $trackerids[$i], $statusids[$i]); $fieldsSize = count($aFields); $doCampaigns_trackers = OA_Dal::factoryDO('campaigns_trackers'); for ($k = 0; $k < $fieldsSize; $k++) { $field = $aFields[$k]; $doCampaigns_trackers->{$field} = $values[$k]; } $doCampaigns_trackers->insert(); } } // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strCampaignTrackersHaveBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "campaign-edit.php?clientid=" . $clientid . "&campaignid=" . $campaignid), htmlspecialchars($doCampaigns->campaignname))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect("campaign-trackers.php?clientid=" . $clientid . "&campaignid=" . $campaignid); } } /*-------------------------------------------------------*/ /* HTML framework */ /*-------------------------------------------------------*/ if (!isset($listorder)) { if (isset($session['prefs']['campaign-trackers.php']['listorder'])) { $listorder = $session['prefs']['campaign-trackers.php']['listorder']; } else { $listorder = ''; } } if (!isset($orderdirection)) {
$doTrackers->update(); // Queue confirmation message $trackerName = $doTrackers->trackername; $doClients = OA_Dal::factoryDO('clients'); if ($doClients->get($moveto)) { $advertiserName = $doClients->clientname; } $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strTrackerHasBeenMoved'], array(htmlspecialchars($trackerName), htmlspecialchars($advertiserName))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); } Header("Location: " . $returnurl . "?clientid=" . $moveto . "&trackerid=" . $trackerid); exit; } elseif (isset($duplicate) && $duplicate == 'true') { $doTrackers = OA_Dal::factoryDO('trackers'); if ($doTrackers->get($trackerid)) { $oldName = $doTrackers->trackername; $new_trackerid = $doTrackers->duplicate(); if ($doTrackers->get($new_trackerid)) { $newName = $doTrackers->trackername; } // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strTrackerHasBeenDuplicated'], array(MAX::constructURL(MAX_URL_ADMIN, "tracker-edit.php?clientid={$clientid}&trackerid={$trackerid}"), htmlspecialchars($oldName), MAX::constructURL(MAX_URL_ADMIN, "tracker-edit.php?clientid={$clientid}&trackerid={$new_trackerid}"), htmlspecialchars($newName))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); Header("Location: " . $returnurl . "?clientid=" . $clientid . "&trackerid=" . $new_trackerid); exit; } } } Header("Location: " . $returnurl . "?clientid=" . $clientid . "&trackerid=" . $trackerid);
function processForm($form) { $aFields = $form->exportValues(); if (empty($aFields['affiliateid'])) { $aFields['affiliateid'] = 0; } if ($aFields['channelid']) { $doChannel = OA_Dal::factoryDO('channel'); $doChannel->get($aFields['channelid']); $doChannel->name = $aFields['name']; $doChannel->description = $aFields['description']; $doChannel->comments = $aFields['comments']; $ret = $doChannel->update(); // Queue confirmation message $translation = new OX_Translation(); $channelURL = "channel-edit.php?" . (empty($aFields['affiliateid']) ? "agencyid=" . $aFields['agencyid'] . "&channelid=" . $aFields['channelid'] : "affiliateid=" . $aFields['affiliateid'] . "&channelid=" . $aFields['channelid']); $translated_message = $translation->translate($GLOBALS['strChannelHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, $channelURL), htmlspecialchars($aFields['name']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); if (!empty($aFields['affiliateid'])) { header("Location: channel-edit.php?affiliateid=" . $aFields['affiliateid'] . "&channelid=" . $aFields['channelid']); } else { header("Location: channel-edit.php?agencyid=" . $aFields['agencyid'] . "&channelid=" . $aFields['channelid']); } exit; } else { $doChannel = OA_Dal::factoryDO('channel'); $doChannel->agencyid = $aFields['agencyid']; $doChannel->affiliateid = $aFields['affiliateid']; $doChannel->name = $aFields['name']; $doChannel->description = $aFields['description']; $doChannel->comments = $aFields['comments']; $doChannel->compiledlimitation = 'true'; $doChannel->acl_plugins = 'true'; $doChannel->active = 1; $aFields['channelid'] = $doChannel->insert(); // Queue confirmation message $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strChannelHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'channel-edit.php?affiliateid=' . $aFields['affiliateid'] . '&channelid=' . $aFields['channelid']), htmlspecialchars($aFields['name']), MAX::constructURL(MAX_URL_ADMIN, 'channel-acl.php?affiliateid=' . $aFields['affiliateid'] . '&channelid=' . $aFields['channelid']))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); if (!empty($aFields['affiliateid'])) { OX_Admin_Redirect::redirect("affiliate-channels.php?affiliateid=" . $aFields['affiliateid']); } else { OX_Admin_Redirect::redirect("channel-index.php"); } } }
/** * Place invocation form - generate form with group of options for every plugin, * look into max/docs/developer/plugins.zuml for more details * * @param array $extra * @param boolean $zone_invocation * * @return string Generated invocation form */ function placeInvocationForm($extra = '', $zone_invocation = false) { $conf = $GLOBALS['_MAX']['CONF']; $pref = $GLOBALS['_MAX']['PREF']; $globalVariables = array('affiliateid', 'codetype', 'size', 'text', 'dest'); $buffer = ''; $this->zone_invocation = $zone_invocation; foreach ($globalVariables as $makeMeGlobal) { global ${$makeMeGlobal}; // also make this variable a class attribute // so plugins could have an access to these values and modify them $this->{$makeMeGlobal} =& ${$makeMeGlobal}; } $invocationTypes =& OX_Component::getComponents('invocationTags'); foreach ($invocationTypes as $pluginKey => $invocationType) { if (!empty($invocationType->publisherPlugin)) { $available[$pluginKey] = $invocationType->publisherPlugin; $names[$pluginKey] = $invocationType->getName(); if (!empty($invocationType->default)) { $defaultPublisherPlugin = $pluginKey; } } } $affiliateid = $this->affiliateid; if (count($available) == 1) { // Only one publisher invocation plugin available $codetype = $defaultPublisherPlugin; } elseif (count($available) > 1) { // Multiple publisher invocation plugins available if (is_null($codetype)) { $codetype = $defaultPublisherPlugin; } echo "<form name='generate' action='" . $_SERVER['PHP_SELF'] . "' method='POST' onSubmit='return max_formValidate(this);'>\n"; // Show the publisher invocation selection drop down echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>"; echo "<input type='hidden' name='affiliateid' value='{$affiliateid}'>"; echo "<tr><td height='25' colspan='3'><b>" . $GLOBALS['strChooseTypeOfInvocation'] . "</b></td></tr>"; echo "<tr><td height='35'>"; echo "<select name='codetype' onChange=\"this.form.submit()\" accesskey=" . $GLOBALS['keyList'] . " tabindex='" . $tabindex++ . "'>"; foreach ($names as $pluginKey => $invocationTypeName) { echo "<option value='" . $pluginKey . "'" . ($codetype == $pluginKey ? ' selected' : '') . ">" . $invocationTypeName . "</option>"; } echo "</select>"; echo " <input type='image' src='" . OX::assetPath() . "/images/" . $GLOBALS['phpAds_TextDirection'] . "/go_blue.gif' border='0'>"; echo "</td></tr></table>"; echo "</form>"; echo phpAds_ShowBreak($print = false); echo "<br />"; } else { // No publisher invocation plugins available $code = 'Error: No publisher invocation plugins available'; return; } if (!empty($codetype)) { $invocationTag = OX_Component::factoryByComponentIdentifier($codetype); if ($invocationTag === false) { OA::debug('Error while factory invocationTag plugin'); exit; } $code = $this->generateInvocationCode($invocationTag); } $previewURL = MAX::constructURL(MAX_URL_ADMIN, "affiliate-preview.php?affiliateid={$affiliateid}&codetype={$codetype}"); foreach ($invocationTag->defaultOptionValues as $feature => $value) { if ($invocationTag->maxInvocation->{$feature} != $value) { $previewURL .= "&{$feature}=" . rawurlencode($invocationTag->maxInvocation->{$feature}); } } foreach ($this->defaultOptionValues as $feature => $value) { if ($this->{$feature} != $value) { $previewURL .= "&{$feature}=" . rawurlencode($this->{$feature}); } } echo "<form name='generate' action='" . $previewURL . "' method='get' target='_blank'>\n"; echo "<input type='hidden' name='codetype' value='" . $codetype . "' />"; // Show parameters for the publisher invocation list echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>"; echo "<tr><td height='25' colspan='3'><img src='" . OX::assetPath() . "/images/icon-overview.gif' align='absmiddle'> <b>" . $GLOBALS['strParameters'] . "</b></td></tr>"; echo "<tr height='1'><td width='30'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='30'></td>"; echo "<td width='200'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='200'></td>"; echo "<td width='100%'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='100%'></td></tr>"; echo $invocationTag->generateOptions($this); echo "<tr><td height='10' colspan='3'> </td></tr>"; //echo "<tr height='1'><td colspan='3' bgcolor='#888888'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='100%'></td></tr>"; echo "</table>"; // Pass in current values echo "<input type='hidden' name='affiliateid' value='{$affiliateid}' />"; echo "<input type='submit' value='" . $GLOBALS['strGenerate'] . "' name='submitbutton' tabindex='" . $tabindex++ . "'>"; echo "</form>"; }
function handlePost($vars) { $codes = array(); if (isset($vars['tag']) && is_array($vars['tag'])) { foreach ($vars['tag'] as $k => $v) { $codes[$k] = array('tagcode' => stripslashes($v), 'paused' => false); $codes[$k]['autotrack'] = isset($vars['autotrack'][$k]); } } if (isset($vars['t_paused'])) { foreach (explode(',', $vars['t_paused']) as $k) { if (isset($codes[$k])) { $codes[$k]['paused'] = true; } } } if (isset($vars['t_action'])) { switch ($vars['t_action']) { case 'new': $codes[] = array('tagcode' => '', 'paused' => false); break; case 'del': if (isset($vars['t_id']) && isset($codes[$vars['t_id']])) { unset($codes[$vars['t_id']]); } break; case 'up': if (isset($vars['t_id']) && isset($codes[$vars['t_id']]) && isset($codes[$vars['t_id'] - 1])) { $tmp = $codes[$vars['t_id']]; $codes[$vars['t_id']] = $codes[$vars['t_id'] - 1]; $codes[$vars['t_id'] - 1] = $tmp; } break; case 'down': if (isset($vars['t_id']) && isset($codes[$vars['t_id']]) && isset($codes[$vars['t_id'] + 1])) { $tmp = $codes[$vars['t_id']]; $codes[$vars['t_id']] = $codes[$vars['t_id'] + 1]; $codes[$vars['t_id'] + 1] = $tmp; } break; case 'pause': case 'restart': if (isset($vars['t_id']) && isset($codes[$vars['t_id']])) { $codes[$vars['t_id']]['paused'] = $vars['t_action'] == 'pause'; } break; } } if (isset($vars['save'])) { $this->_dal->setAppendCodes($this->tracker_id, $codes); // Queue confirmation message $doTrackers = OA_Dal::factoryDO('trackers'); $doTrackers->get($this->tracker_id); $translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strTrackerAppendHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, "tracker-edit.php?clientid=" . $this->advertiser_id . "&trackerid=" . $this->tracker_id), htmlspecialchars($doTrackers->trackername))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); OX_Admin_Redirect::redirect("tracker-append.php?clientid={$this->advertiser_id}&trackerid={$this->tracker_id}"); } else { $this->codes = $codes; $this->showReminder = true; } }
// output using the $oOption object $aPreferences[0]['text'] = $group . ' ' . $strPreferences; $count = count($aConfig['preferences']); $i = 0; foreach ($aConfig['preferences'] as $k => $v) { $aPreferences[0]['items'][] = array('type' => $v['type'], 'name' => $group . '_' . $v['name'], 'text' => $v['label'], 'req' => $v['required'], 'size' => $v['size'], 'value' => $v['value'], 'visible' => $v['visible']); //add break after a field excluding last $i++; if ($i < $count) { $aPreferences[0]['items'][] = array('type' => 'break'); } } $aPreferences[0]['items'][] = array('type' => 'hiddenfield', 'name' => 'plugin', 'value' => $plugin); $aPreferences[0]['items'][] = array('type' => 'hiddenfield', 'name' => 'group', 'value' => $group); $GLOBALS['_MAX']['PREF_EXTRA'] = OA_Preferences::loadPreferences(true, true); /*-------------------------------------------------------*/ /* HTML framework */ /*-------------------------------------------------------*/ phpAds_PageHeader("plugin-index", new OA_Admin_UI_Model_PageHeaderModel($GLOBALS['strPluginPreferences']), '', false, true); /*-------------------------------------------------------*/ /* Main code */ /*-------------------------------------------------------*/ //display back link $oTpl = new OA_Admin_Template('plugin-group-preferences.html'); $oTpl->assign('backURL', MAX::constructURL(MAX_URL_ADMIN, $backURL)); $oTpl->assign('plugin', $plugin); $oTpl->assign('group', $group); $oTpl->display(); //display options form $oOptions->show($aPreferences, $aErrormessage); phpAds_PageFooter();