/** * Method that is called on settings form submission * Error messages are appended to the 0 index of the array * * @return boolean */ function validate(&$aErrorMessage) { // Store current values from config // overwrite it by tested ones $storeSettings = array(); if (isset($GLOBALS['oxMemcached_memcachedServers'])) { $storeSettings['memcachedServers'] = $GLOBALS['_MAX']['CONF']['oxMemcached']['memcachedServers']; $GLOBALS['_MAX']['CONF']['oxMemcached']['memcachedServers'] = $GLOBALS['oxMemcached_memcachedServers']; } if (isset($GLOBALS['oxMemcached_memcachedExpireTime'])) { $storeSettings['memcachedExpireTime'] = $GLOBALS['_MAX']['CONF']['oxMemcached']['memcachedExpireTime']; $GLOBALS['_MAX']['CONF']['oxMemcached']['memcachedExpireTime'] = $GLOBALS['oxMemcached_memcachedExpireTime']; } // Use memcached plugin getStatus function to validate $oPlgOxMemcached =& OX_Component::factory('deliveryCacheStore', 'oxMemcached', 'oxMemcached'); $result = $oPlgOxMemcached->getStatus(); if ($result !== true) { $aErrorMessage[0] = $result; $result = false; } // Restore config values foreach ($storeSettings as $key => $value) { $GLOBALS['_MAX']['CONF']['oxMemcached'][$key] = $value; } return $result; }
/** * Handle all necessary operations when new agency is created * * @see DB_DataObject::insert() */ function insert() { // Create account first $result = $this->createAccount(OA_ACCOUNT_MANAGER, $this->name); if (!$result) { return $result; } // Store data to create a user if (!empty($this->username) && !empty($this->password)) { $aUser = array('contact_name' => $this->contact, 'email_address' => $this->email, 'username' => $this->username, 'password' => $this->password, 'default_account_id' => $this->account_id); } $agencyid = parent::insert(); if (!$agencyid) { return $agencyid; } // Create user if needed // Is this even required anymore? if (!empty($aUser)) { $this->createUser($aUser); } // Execute any components which have registered at the afterAgencyCreate hook $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterAgencyCreate'); foreach ($aPlugins as $i => $id) { if ($obj = OX_Component::factoryByComponentIdentifier($id)) { $obj->afterAgencyCreate($agencyid); } } return $agencyid; }
function testGetName() { $oPlugin =& OX_Component::factory('deliveryLimitations', 'Geo', 'City'); $oPlugin->init(array()); // Assume it is called in the production after talking to Andrew $this->assertEqual('Geo - Country / City', $oPlugin->displayName); }
function test_compile() { $oPlugin =& OX_Component::factory('deliveryLimitations', 'Geo', 'Continent'); $oPlugin->init(array('data' => 'EU', 'comparison' => '!~')); $this->_assertResourceData(); $result = $oPlugin->compile(); $this->assertEqual("MAX_checkGeo_Continent('eu,yu,gb,uk,ua,ch,se,sj,es,si,sk,sm,ru,ro,pt,pl,no,nl,mc,md,mt,mk,lu,lt,li,lv,it,ie,is,hu,va,gr,gi,de,ge,fx,fr,fi,fo,ee,dk,cz,cy,hr,bg,ba,be,by,at,am,ad,al', '!~')", $result); }
/** * Constructor */ function __construct() { $this->oCacheStorePlugin =& OX_Component::factoryByComponentIdentifier($GLOBALS['_MAX']['CONF']['delivery']['cacheStorePlugin']); // Do not use Plugin if it's not enabled if ($this->oCacheStorePlugin->enabled === false) { $this->oCacheStorePlugin = false; } }
function test_compile() { $oPlugin =& OX_Component::factory('deliveryLimitations', 'Geo', 'Continent'); $oPlugin->init(array('data' => 'EU', 'comparison' => '!~')); $this->_assertResourceData(); $result = $oPlugin->compile(); $this->assertEqual("MAX_checkGeo_Continent('eu,ad,al,at,ba,be,bg,by,ch,cz,de,dk,ee,es,fi,fo,fr,gb,gi,gr,hr,hu,ie,is,it,li,lt,lu,lv,mc,md,mk,mt,nl,no,pl,pt,ro,ru,se,si,sj,sk,sm,tr,ua,va,rs,me,ax,gg,im,je', '!~')", $result); }
function test_oxMemcached_class() { if (extension_loaded('memcache')) { $oComponent =& OX_Component::factory('deliveryCacheStore', 'oxMemcached', 'oxMemcached'); $this->_assertClass($oComponent, 'deliveryCacheStore', 'oxMemcached', 'oxMemcached'); } else { $this->skip("memcache extension not available"); } }
function testCompile() { $oPlugin =& OX_Component::factory('deliveryLimitations', 'Geo', 'Region'); $rawData = 'GB|T5,T7'; $oPlugin->init(array('data' => $rawData, 'comparison' => '==')); $this->assertEqual('MAX_checkGeo_Region(\'gb|t5,t7\', \'==\')', $oPlugin->compile()); $this->assertEqual($rawData, $oPlugin->getData()); $oPlugin->init(array('data' => array('GB', 'T5', 'T7'), 'comparison' => '==')); $this->assertEqual('MAX_checkGeo_Region(\'gb|t5,t7\', \'==\')', $oPlugin->compile()); }
function testCompile() { $oPlugin =& OX_Component::factory('deliveryLimitations', 'Site', 'Channel'); $oPlugin->init(array('data' => '21', 'comparison' => '==')); $this->assertEqual("(MAX_checkSite_Channel('21', '=='))", $oPlugin->compile()); $oPlugin->init(array('data' => '21,43', 'comparison' => '==')); $this->assertEqual("(MAX_checkSite_Channel('21', '==') && MAX_checkSite_Channel('43', '=='))", $oPlugin->compile()); $oPlugin->init(array('data' => '21,43', 'comparison' => '=~')); $this->assertEqual("(MAX_checkSite_Channel('21', '=~') || MAX_checkSite_Channel('43', '=~'))", $oPlugin->compile()); $oPlugin->init(array('data' => '21,43', 'comparison' => '!~')); $this->assertEqual("!(MAX_checkSite_Channel('21', '!~') || MAX_checkSite_Channel('43', '!~'))", $oPlugin->compile()); }
/** * A factory method to return the appropriate * OA_Maintenance_Priority_DeliveryLimitation_Common * subclass object (one of OA_Maintenance_Priority_DeliveryLimitation_Date, * OA_Maintenance_Priority_DeliveryLimitation_Day, * OA_Maintenance_Priority_DeliveryLimitation_Empty or * OA_Maintenance_Priority_DeliveryLimitation_Hour), depending on the data * provided. * * @static * @param array $aDeliveryLimitation An array containing the details of a delivery limitation * associated with an ad. For example: * array( * [ad_id] => 1 * [logical] => and * [type] => Time:Hour * [comparison] => == * [data] => 1,7,18,23 * [executionorder] => 1 * ) * @return object OA_Maintenance_Priority_DeliveryLimitation_Common */ function &factory($aDeliveryLimitation) { // Load plugins if not already in cache if (!isset(self::$aPlugins)) { self::$aPlugins = OX_Component::getComponents('deliveryLimitations', null, false); } // Return instance of the MPE DL class if (isset(self::$aPlugins[$aDeliveryLimitation['type']])) { return self::$aPlugins[$aDeliveryLimitation['type']]->getMpeClassInstance($aDeliveryLimitation); } // Unknown plugin? Return the empty MPE DL class return new OA_Maintenance_Priority_DeliveryLimitation_Empty($aDeliveryLimitation); }
/** * A private method to find all report plugins with can be executed * by the current user. * * @access private * @return array An array of all the plugins that the user has * access to excute, indexed by the plugin type. */ function _findDisplayableReports() { $aDisplayablePlugins = array(); // Get all the report plugins. $aPlugins = OX_Component::getComponents('reports'); // Check the user's authorization level foreach ($aPlugins as $pluginType => $oPlugin) { if (!$oPlugin->isAllowedToExecute()) { continue; } $aDisplayablePlugins[$pluginType] = $oPlugin; } return $aDisplayablePlugins; }
function test_genericHtml_class() { // test the class implementation $oComponent =& OX_Component::factory('bannerTypeHtml', 'demoBannerTypeHtml', 'demoHtml'); // common extension methods $this->_assertClass($oComponent, 'bannerTypeHtml', 'demoBannerTypeHtml', 'demoHtml'); // plugin-specific methods $this->assertTrue(method_exists($oComponent, '_buildHtmlTemplate'), $sender . ' missing method _buildHtmlTemplate'); $this->assertTrue(method_exists($oComponent, 'exportData'), $sender . ' missing method exportData'); // generate test data $doBanners = OA_Dal::factoryDO('banners'); $oDG = new DataGenerator(); $oDG->setData('banners', array('ext_bannertype' => array($oComponent->getComponentIdentifier()))); $aIds = $oDG->generate($doBanners, 5, false); $aFields = $aVariables = array(); // test the processForm method // this method joins the banners and banners_demo tables // by creating a banners_demo record where // banners_demo.banners_demo_id = banners.bannerid foreach ($aIds as $i => $bannerId) { $aFields['description'] = 'description_' . $bannerId; $this->assertTrue($oComponent->processForm(true, $bannerId, $aFields, $aVariables)); $doBannersDemo = OA_Dal::factoryDO('banners_demo'); $doBannersDemo->banners_demo_id = $bannerId; $this->assertTrue($doBannersDemo->find(true)); $this->assertEqual($doBannersDemo->banners_demo_desc, $aFields['description']); } // test the exportData method $aTables = $oComponent->exportData(); $this->assertIsA($aTables, 'array'); $this->assertEqual(count($aTables), 2); $prefix = $GLOBALS['_MAX']['CONF']['table']['prefix']; $pattern = '/' . $prefix . 'z_' . $oComponent->component . '[\\d]{8}_[\\d]{6}' . $prefix . 'banners/'; $this->assertPattern($pattern, $aTables[0]); $pattern = '/' . $prefix . 'z_' . $oComponent->component . '[\\d]{8}_[\\d]{6}' . $prefix . 'banners_demo/'; $this->assertPattern($pattern, $aTables[1]); $oDbh = OA_DB::singleton(); $query = "SELECT * FROM " . $oDbh->quoteIdentifier($aTables[0]); $aResult = $oDbh->queryAll($query, null, MDB2_FETCHMODE_ASSOC); foreach ($aResult as $i => $aFrom) { $this->assertEqual($aFrom['bannerid'], $aIds[$i]); } $query = "SELECT * FROM " . $oDbh->quoteIdentifier($aTables[1]); $aResult = $oDbh->queryAll($query, null, MDB2_FETCHMODE_ASSOC); foreach ($aResult as $i => $aFrom) { $this->assertEqual($aFrom['banners_demo_id'], $aIds[$i]); } }
/** * A method to run distributed maintenance. */ function run() { if (empty($GLOBALS['_MAX']['CONF']['lb']['enabled'])) { OA::debug('Distributed stats disabled, not running Maintenance Distributed Engine', PEAR_LOG_INFO); return; } if (!empty($GLOBALS['_MAX']['CONF']['rawDatabase'])) { $GLOBALS['_MAX']['CONF']['database'] = $GLOBALS['_MAX']['CONF']['rawDatabase'] + $GLOBALS['_MAX']['CONF']['database']; OA::debug('rawDatabase functionality is being used, switching settings', PEAR_LOG_INFO); } $oLock =& OA_DB_AdvisoryLock::factory(); if (!$oLock->get(OA_DB_ADVISORYLOCK_DISTRIBUTED)) { OA::debug('Maintenance Distributed Engine Already Running', PEAR_LOG_INFO); return; } OA::debug('Running Maintenance Distributed Engine', PEAR_LOG_INFO); // Attempt to increase PHP memory OX_increaseMemoryLimit(OX_getMinimumRequiredMemory('maintenance')); // Ensure the current time is registered with the OA_ServiceLocator $oServiceLocator =& OA_ServiceLocator::instance(); $oNow =& $oServiceLocator->get('now'); if (!$oNow) { // Record the current time, and register with the OA_ServiceLocator $oNow = new Date(); $oServiceLocator->register('now', $oNow); } OA::debug(' - Current time is ' . $oNow->format('%Y-%m-%d %H:%M:%S') . ' ' . $oNow->tz->getShortName(), PEAR_LOG_DEBUG); // Get the components of the deliveryLog extension $aBuckets = OX_Component::getComponents('deliveryLog'); // Copy buckets' records with "interval_start" up to and including previous OI start, // and then prune the data processed $aPreviousOperationIntervalDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oNow); OA::debug(' - Will process data for all operation intervals before and up to start', PEAR_LOG_DEBUG); OA::debug(' time of ' . $aPreviousOperationIntervalDates['start']->format('%Y-%m-%d %H:%M:%S') . ' ' . $aPreviousOperationIntervalDates['start']->tz->getShortName(), PEAR_LOG_DEBUG); foreach ($aBuckets as $sBucketName => $oBucketClass) { if ($oBucketClass->testStatisticsMigration($oBucketClass->getStatisticsMigration())) { $oBucketClass->processBucket($aPreviousOperationIntervalDates['start']); $oBucketClass->pruneBucket($aPreviousOperationIntervalDates['start']); } else { OA::debug(' - Skipping ' . $sBucketName, PEAR_LOG_DEBUG); } } $oLock->release(); OA::debug('Maintenance Distributed Engine Completed', PEAR_LOG_INFO); }
/** * Append type-specific form elements to the base form * * @param object &$form * @param array &$row */ function buildForm(&$form, &$row) { $form->setAttribute("onSubmit", "return max_formValidateHtml(this.banner)"); $header = $form->createElement('header', 'header_html', $GLOBALS['strHTMLBanner'] . " - banner code"); $header->setAttribute('icon', 'icon-banner-html.gif'); $form->addElement($header); $adPlugins = OX_Component::getComponents('3rdPartyServers'); $adPluginsNames = OX_Component::callOnComponents($adPlugins, 'getName'); $adPluginsList = array(); $adPluginsList[''] = $GLOBALS['strAdserverTypeGeneric']; $adPluginsList['none'] = $GLOBALS['strDoNotAlterHtml']; foreach ($adPluginsNames as $adPluginKey => $adPluginName) { $adPluginsList[$adPluginKey] = $adPluginName; } $htmlG['textarea'] = $form->createElement('textarea', 'htmltemplate', null, array('class' => 'code', 'cols' => '45', 'rows' => '10', 'wrap' => 'off', 'dir' => 'ltr', 'style' => 'width:550px;')); $aSelectAttributes = array('id' => 'adserver', 'style' => 'margin-left: 15px;width:230px'); $htmlG['select'] = HTML_QuickForm::createElement('select', 'adserver', $GLOBALS['strAlterHTML'], $adPluginsList, $aSelectAttributes); $form->addGroup($htmlG, 'html_banner_g', null, array("<br>", ""), false); $form->addElement('advcheckbox', 'iframe_friendly', $GLOBALS['strIframeFriendly']); if ($row['bannerid'] && ($row['url'] || $row['target'])) { // The "url" and "target" elements remain as part of the form definition // for HTML banners only for existing banners that have either // url or target already set. $form->addElement('header', 'header_b_links', "Banner link"); $form->addElement('text', 'url', $GLOBALS['strURL']); $form->addElement('text', 'target', $GLOBALS['strTarget']); } $form->addElement('header', 'header_b_display', 'Banner display'); $sizeG['width'] = $form->createElement('text', 'width', $GLOBALS['strWidth'] . ":"); $sizeG['width']->setSize(5); $sizeG['height'] = $form->createElement('text', 'height', $GLOBALS['strHeight'] . ":"); $sizeG['height']->setSize(5); if (!empty($row['bannerid'])) { $sizeG['height']->setAttribute('onChange', 'oa_sizeChangeUpdateMessage("warning_change_banner_size");'); $sizeG['width']->setAttribute('onChange', 'oa_sizeChangeUpdateMessage("warning_change_banner_size");'); } $form->addGroup($sizeG, 'size', $GLOBALS['strSize'], " ", false); $form->addElement('hidden', 'ext_bannertype', $this->getComponentIdentifier()); //validation rules $translation = new OX_Translation(); $widthRequiredRule = array($translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strWidth'])), 'required'); $heightRequiredRule = array($translation->translate($GLOBALS['strXRequiredField'], array($GLOBALS['strHeight'])), 'required'); $numericRule = array($GLOBALS['strNumericField'], 'numeric'); $form->addGroupRule('size', array('width' => array($widthRequiredRule, $numericRule), 'height' => array($heightRequiredRule, $numericRule))); }
/** * A private method to locate and instantiate all components that * use the deliveryLog extension, and are in installed plugins, storing * them in an array, grouped by the component's destination statistics * table -- this will provide all of the plugin components that use * the deliveryLog extension (i.e. have bucket-based delivery data that * needs to be migrated to statistics tables), grouped by the detsination * statistics tables (so that all components that have data migrated to * the same table can be migrated in the one call). * * @access private * @return array An array of plugins components, as described above. */ private function locateComponents() { $aSummariseComponents = array(); foreach ($this->aPackages as $aPluginInfo) { foreach ($aPluginInfo['contents'] as $aContents) { if ($aContents['extends'] == 'deliveryLog') { foreach ($aContents['components'] as $aComponent) { $oComponent =& OX_Component::factory('deliveryLog', $aContents['name'], $aComponent['name']); if ($oComponent->enabled) { $destinationTable = $oComponent->getStatisticsTableName(); $aSummariseComponents[$destinationTable][get_class($oComponent)] = $oComponent; } } } } } return $aSummariseComponents; }
/** * Method that is called on settings form submission * Error messages are appended to the 0 index of the array * * @return boolean */ function validate(&$aErrorMessage) { // Store current values from config // overwrite it by tested ones $storeSettings = array(); if (isset($GLOBALS['oxCacheFile_cachePath'])) { $storeSettings['cachePath'] = $GLOBALS['_MAX']['CONF']['oxCacheFile']['cachePath']; $GLOBALS['_MAX']['CONF']['oxCacheFile']['cachePath'] = $GLOBALS['oxCacheFile_cachePath']; } // Use file plugin getStatus function to validate $oPlgoxCacheFile =& OX_Component::factory('deliveryCacheStore', 'oxCacheFile', 'oxCacheFile'); $result = $oPlgoxCacheFile->getStatus(); if ($result !== true) { $aErrorMessage[0] = $result; $result = false; } // Restore config values foreach ($storeSettings as $key => $value) { $GLOBALS['_MAX']['CONF']['oxCacheFile'][$key] = $value; } return $result; }
/** * Returns authentication plugin * * @static * @param string $authType * @return Plugins_Authentication */ static function staticGetAuthPlugin() { static $authPlugin; static $authPluginType; if (!isset($authPlugin) || $authPluginType != $authType) { $aConf = $GLOBALS['_MAX']['CONF']; if (!empty($aConf['authentication']['type'])) { $authType = $aConf['authentication']['type']; $authPlugin = OX_Component::factoryByComponentIdentifier($authType); } if (!$authPlugin) { // Fall back to internal $authType = 'none'; $authPlugin = new Plugins_Authentication(); } if (!$authPlugin) { OA::debug('Error while including authentication plugin and unable to fallback', PEAR_LOG_ERR); } $authPluginType = $authType; } return $authPlugin; }
/** * A method to determine if the delivery limitation stored will prevent an * ad from delivering or not, given a time/date. * * @abstract * @param object $oDate PEAR:Date, represeting the time/date to test if the ACL would * block delivery at that point in time. * @return mixed A boolean (true if the ad is BLOCKED (i.e. will NOT deliver), false * if the ad is NOT BLOCKED (i.e. WILL deliver), or a PEAR::Error. */ function deliveryBlocked($oDate) { $aConf = $GLOBALS['_MAX']['CONF']; if (!is_a($oDate, 'Date')) { return MAX::raiseError('Parameter passed to OA_Maintenance_Priority_DeliveryLimitation_Common is not a PEAR::Date object', MAX_ERROR_INVALIDARGS); } $aParts = OX_Component::parseComponentIdentifier($this->type); if (!empty($aParts) && count($aParts) == 3) { $fileName = MAX_PATH . $aConf['pluginPaths']['plugins'] . join('/', $aParts) . '.delivery.php'; $funcName = "MAX_check{$aParts[1]}_{$aParts[2]}"; $callable = function_exists($funcName); if (!$callable && file_exists($fileName)) { require_once $fileName; $callable = true; } $aParams = array('timestamp' => $oDate->getDate(DATE_FORMAT_UNIXTIME)); if ($callable) { // Return non-delivery return !$funcName($this->data, $this->comparison, $aParams); } } return MAX::raiseError('Limitation parameter passed to OA_Maintenance_Priority_DeliveryLimitation_Common is not correct', MAX_ERROR_INVALIDARGS); }
function buildForm(&$form, &$row) { $form->setAttribute("onSubmit", "return max_formValidateHtml(this.banner)"); $header = $form->createElement('header', 'header_html', $GLOBALS['strHTMLBanner']); $header->setAttribute('icon', 'icon-banner-html.gif'); $form->addElement($header); $adPlugins = OX_Component::getComponents('3rdPartyServers'); $adPluginsNames = OX_Component::callOnComponents($adPlugins, 'getName'); $adPluginsList = array(); $adPluginsList[''] = $GLOBALS['strAdserverTypeGeneric']; $adPluginsList['none'] = $GLOBALS['strDoNotAlterHtml']; foreach ($adPluginsNames as $adPluginKey => $adPluginName) { $adPluginsList[$adPluginKey] = $adPluginName; } $form->addElement('select', 'adserver', $this->translate($GLOBALS['strAlterHTML']), $adPluginsList, $aSelectAttributes); $form->addElement('header', 'header_b_parameters', $this->translate("Banner display")); $form->addElement('text', 'p_link_url', $this->translate($GLOBALS['strURL'])); $form->addElement('text', 'p_link_text', $this->translate("Link text")); $form->addElement('text', 'p_title', $this->translate("Title")); $form->addElement('text', 'p_description', $this->translate("Description")); $form->addElement('text', 'p_image_url', $this->translate("Url Image")); $form->addElement('text', 'p_click_url_unesc', $this->translate("Click url Unesc")); $form->addElement('hidden', 'ext_bannertype', $this->getComponentIdentifier()); $bannerId = $row['bannerid']; if ($bannerId) { $doBanners = OA_Dal::factoryDO('my_banners'); $doBanners->bannerid = $bannerId; $doBanners->find(true); $row['terra_link_url'] = $doBanners->terra_link_url; $row['terra_link_text'] = $doBanners->terra_link_text; $row['terra_title'] = $doBanners->terra_title; $row['terra_description'] = $doBanners->terra_description; $row['terra_image_url'] = $doBanners->terra_image_url; $row['terra_click_url_unesc'] = $doBanners->terra_click_url_unesc; $form->setDefaults(array('p_link_url' => $doBanners->terra_link_url, 'p_link_text' => $doBanners->terra_link_text, 'p_title' => $doBanners->terra_title, 'p_description' => $doBanners->terra_description, 'p_image_url' => $doBanners->terra_image_url, 'p_click_url_unesc' => $doBanners->terra_click_url_unesc)); } }
public function check($oSection) { phpAds_registerGlobal('clientid', 'campaignid'); global $clientid, $campaignid; $sectionId = $oSection->getId(); static $cache = array(); $oMarkedTextAdvertiserComponent = OX_Component::factory('admin', 'oxMarkedTextAdvertiser'); $oEntityHelper = $oMarkedTextAdvertiserComponent->getEntityHelper(); $enabled = true; switch ($sectionId) { case 'advertiser-edit': case 'advertiser-trackers': case 'advertiser-access': case 'campaign-edit_new': case 'campaign-edit': case 'campaign-trackers': case 'campaign-banners': if (isset($cache[$clientid])) { return $cache[$clientid]; } break; case 'banner-edit': if (isset($cache[$clientid])) { return $cache[$clientid]; } break; case 'banner-acl': case 'banner-zone': case 'banner-advanced': case 'campaign-zone': } $sessionClientId = $this->getSessionClientId(); if (isset($sessionClientId)) { $this->clearMarketEntitiesInSession(); } return $enabled; }
/** * A private method to return the appropriate report plugin, based * on the identifying string. * * @access private * @param string $reportIdentifier The string identifying the report. * @return Plugins_Reports The report plugin. */ function _newPluginByName($reportIdentifier) { $pluginKey = explode(':', $reportIdentifier); $oPlugin = OX_Component::factoryByComponentIdentifier($reportIdentifier); return $oPlugin; }
/** * Returns array of allowed invocation tags * * @return array of allowed invocation tags (strings) */ function getAllowedTags() { $aAllowedTags = array(); $invocationTags =& OX_Component::getComponents('invocationTags'); foreach ($invocationTags as $pluginKey => $invocationTag) { if ($invocationTag->isAllowed(null, null)) { $aAllowedTags[] = $pluginKey; } } return $aAllowedTags; }
function _validateTargeting($oTargeting) { if (!isset($oTargeting->data)) { $this->raiseError('Field \'data\' in structure does not exists'); return false; } if (!$this->checkStructureRequiredStringField($oTargeting, 'logical', 255) || !$this->checkStructureRequiredStringField($oTargeting, 'type', 255) || !$this->checkStructureRequiredStringField($oTargeting, 'comparison', 255) || !$this->checkStructureNotRequiredStringField($oTargeting, 'data')) { return false; } // Check that each of the specified targeting plugins are available $oPlugin = OX_Component::factoryByComponentIdentifier($oTargeting->type); if ($oPlugin === false) { $this->raiseError('Unknown targeting plugin: ' . $oTargeting->type); return false; } return true; }
function buildAlgorithmFormSection($form, $aZone) { $aAlgorithmPlugins = OX_Component::getComponents('deliveryAdSelect'); if (!empty($aAlgorithmPlugins) && is_array($aAlgorithmPlugins)) { // Add the 'Default' (internal) algorithm to the list $aItems = array('none' => 'Default (internal)'); foreach ($aAlgorithmPlugins as $oAlgorithmPlugin) { // Only include components which implement the onDemand adselect hook function // This is not the cleanest way to do it :( but it works :) $aInfo = $oAlgorithmPlugin->parseComponentIdentifier($oAlgorithmPlugin->getComponentIdentifier()); if (function_exists('Plugin_' . implode('_', $aInfo) . '_Delivery' . '_adSelect')) { $aItems[$oAlgorithmPlugin->getComponentIdentifier()] = $oAlgorithmPlugin->getName(); } } // Only display the select box if at least one alternative algorithm is provided if (count($aItems) === 1) { $form->addElement('hidden', 'ext_adselection', 'none'); return; } $form->addElement('header', 'header_algorithm', 'Ad selection algorithm'); $form->addElement('select', 'ext_adselection', 'Plugin to use for ad selection in this zone', $aItems); } }
$translation = new OX_Translation(); $translated_message = $translation->translate($GLOBALS['strXSettingsHaveBeenUpdated'], array(htmlspecialchars($title))); OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0); // The settings configuration file was written correctly, OX_Admin_Redirect::redirect(basename($_SERVER['SCRIPT_NAME'])); } // Could not write the settings configuration file, store this // error message and continue $aErrormessage[0][] = $strUnableToWriteConfig; } // Set the correct section of the settings pages and display the drop-down menu $setPref = $oOptions->getSettingsPreferences($prefSection); $title = $setPref[$prefSection]['name']; // Display the settings page's header and sections $oHeaderModel = new OA_Admin_UI_Model_PageHeaderModel($title); phpAds_PageHeader('account-settings-index', $oHeaderModel); // Prepare an array of HTML elements to display for the form, and // output using the $oOption object $aSettings = array(array('text' => $strGeneralSettings, 'items' => array(array('type' => 'checkbox', 'name' => 'ui_enabled', 'text' => $uiEnabled), array('type' => 'break'), array('type' => 'text', 'name' => 'ui_applicationName', 'text' => $strAppName, 'size' => 35), array('type' => 'break'), array('type' => 'text', 'name' => 'ui_headerFilePath', 'text' => $strMyHeader, 'size' => 35), array('type' => 'break'), array('type' => 'text', 'name' => 'ui_footerFilePath', 'text' => $strMyFooter, 'size' => 35), array('type' => 'break'), array('type' => 'text', 'name' => 'ui_logoFilePath', 'text' => $strMyLogo, 'size' => 35), array('type' => 'break'), array('type' => 'text', 'name' => 'ui_headerForegroundColor', 'text' => $strGuiHeaderForegroundColor, 'size' => 35), array('type' => 'break'), array('type' => 'text', 'name' => 'ui_headerBackgroundColor', 'text' => $strGuiHeaderBackgroundColor, 'size' => 35), array('type' => 'break'), array('type' => 'text', 'name' => 'ui_headerActiveTabColor', 'text' => $strGuiActiveTabColor, 'size' => 35), array('type' => 'break'), array('type' => 'text', 'name' => 'ui_headerTextColor', 'text' => $strGuiHeaderTextColor, 'size' => 35), array('type' => 'break'), array('type' => 'checkbox', 'name' => 'ui_gzipCompression', 'text' => $strGzipContentCompression))), array('text' => $strSSLSettings, 'items' => array(array('type' => 'checkbox', 'name' => 'openads_requireSSL', 'text' => $requireSSL), array('type' => 'break'), array('type' => 'text', 'name' => 'openads_sslPort', 'text' => $sslPort, 'check' => 'wholeNumber'))), array('text' => $strDashboardSettings, 'items' => array(array('type' => 'checkbox', 'name' => 'ui_dashboardEnabled', 'text' => $GLOBALS['_MAX']['CONF']['sync']['checkForUpdates'] ? $strEnableDashboard : $strEnableDashboardSyncNotice, 'disabled' => !$GLOBALS['_MAX']['CONF']['sync']['checkForUpdates'])))); $aAuthPlugins = OX_Component::getComponents('authentication'); if (!empty($aAuthPlugins) && is_array($aAuthPlugins)) { // Add the 'none' (internal) authentication scheme to the list $aItems = array('none' => 'None (internal)'); foreach ($aAuthPlugins as $oAuthPlugin) { $aItems[$oAuthPlugin->getComponentIdentifier()] = $oAuthPlugin->getName(); } $aSettings[] = array('text' => 'Authentication mechanism', 'items' => array(array('type' => 'select', 'name' => 'authentication_type', 'text' => 'Select the plugin-component to be used for authentication', 'items' => $aItems))); } $oOptions->show($aSettings, $aErrormessage); // Display the page footer phpAds_PageFooter();
$doAffiliates = OA_Dal::factoryDO('affiliates'); if ($doAffiliates->get($affiliateid)) { $affiliate = $doAffiliates->toArray(); } } } else { //set some default $affiliate['website'] = 'http://'; } /*-------------------------------------------------------*/ /* MAIN REQUEST PROCESSING */ /*-------------------------------------------------------*/ // check if Thorium plugin is enabled $oComponent = null; if (isset($GLOBALS['_MAX']['CONF']['plugins']['openXThorium']) && $GLOBALS['_MAX']['CONF']['plugins']['openXThorium']) { $oComponent =& OX_Component::factory('admin', 'oxThorium', 'oxThorium'); } //build form $websiteForm = buildWebsiteForm($affiliate); if ($websiteForm->validate()) { //process submitted values $oPublisherDll = processForm($affiliateid, $websiteForm, $oComponent); if ($oPublisherDll->_errorMessage || $oPublisherDll->_noticeMessage) { displayPage($affiliateid, $websiteForm, $oPublisherDll); } } else { //either validation failed or form was not submitted, display the form displayPage($affiliateid, $websiteForm); } /*-------------------------------------------------------*/ /* Build form */
function test_genericHtml_class() { $oComponent =& OX_Component::factory('bannerTypeHtml', 'oxHtml', 'genericHtml'); $this->_assertClass($oComponent, 'bannerTypeHtml', 'oxHtml', 'genericHtml'); $this->assertTrue(method_exists($oComponent, 'buildHtmlTemplate'), $sender . ' missing method buildHtmlTemplate'); }
public function finishAction() { $oWizard = new OX_Admin_UI_Install_Wizard($this->getInstallStatus()); $this->setCurrentStepIfReachable($oWizard, 'finish'); $oUpgrader = $this->getUpgrader(); $isUpgrade = $this->getInstallStatus()->isUpgrade(); //finalize - mark OpenX as installed, clear files etc. $this->finalizeInstallation(); $oStorage = OX_Admin_UI_Install_InstallUtils::getSessionStorage(); //collect only job statuses with errors $aJobStatuses = $oStorage->get('aJobStatuses'); $aStatuses = array(); if ($aJobStatuses) { foreach ($aJobStatuses as $jobId => $aJobStatus) { //check session for job statuses if (!empty($aJobStatus['errors'])) { $aStatuses[$jobId] = $aJobStatus; } } } $oRequest = $this->getRequest(); if ($oRequest->isPost()) { $this->resetInstaller(); global $installerIsUpgrade; $installerIsUpgrade = $isUpgrade; // Execute any components which have registered at the afterLogin hook $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterLogin'); foreach ($aPlugins as $i => $id) { if ($obj = OX_Component::factoryByComponentIdentifier($id)) { $obj->afterLogin(); } } require_once LIB_PATH . '/Admin/Redirect.php'; OX_Admin_Redirect::redirect('advertiser-index.php'); } $logPath = str_replace('/', DIRECTORY_SEPARATOR, $oUpgrader->getLogFileName()); $this->setModelProperty('logPath', $logPath); $this->setModelProperty('oWizard', $oWizard); $this->setModelProperty('aStatuses', $aStatuses); $this->setModelProperty('isUpgrade', $isUpgrade); }
function phpAds_getBannerCache($banner) { $aConf = $GLOBALS['_MAX']['CONF']; $aPref = $GLOBALS['_MAX']['PREF']; $buffer = $banner['htmltemplate']; // Strip slashes from urls $banner['url'] = stripslashes($banner['url']); $banner['imageurl'] = stripslashes($banner['imageurl']); // The following properties depend on data from the invocation process // and can't yet be determined: {zoneid}, {bannerid} // These properties will be set during invocation if ($banner['adserver'] == 'none') { $buffer = php_Ads_wrapBannerHtmlInClickUrl($banner, $buffer); return $buffer; } if ($banner['storagetype'] != 'html') { return $buffer; } // Auto change HTML banner if ($buffer != '') { // Put our click URL and our target parameter in all anchors... // The regexp should handle ", ', \", \' as delimiters if (preg_match_all('#<a(\\s[^>]*?)href\\s*=\\s*(\\\\?[\'"])http(.*?)\\2(.*?) *>#is', $buffer, $m)) { foreach ($m[0] as $k => $v) { // Remove target parameters $m[1][$k] = ' ' . trim(preg_replace('#target\\s*=\\s*(\\\\?[\'"]).*?\\1#i', '', $m[1][$k])); $m[4][$k] = ' ' . trim(preg_replace('#target\\s*=\\s*(\\\\?[\'"]).*?\\1#i', '', $m[4][$k])); $m[3][$k] = html_entity_decode($m[3][$k], null, 'UTF-8'); $urlDest = preg_replace('/%7B(.*?)%7D/', '{$1}', urlencode("http" . $m[3][$k])); $buffer = str_replace($v, "<a{$m[1][$k]}href={$m[2][$k]}{clickurl}{$urlDest}{$m[2][$k]}{$m[4][$k]}target={$m[2][$k]}{target}{$m[2][$k]}>", $buffer); } } // Search: <\s*form (.*?)action\s*=\s*['"](.*?)['"](.*?)> // Replace:<form\1 action="{url_prefix}/{$aConf['file']['click']}" \3><input type='hidden' name='{clickurlparams}\2'> $target = !empty($banner['target']) ? $banner['target'] : "_self"; // strip out the method from any <forms> these will be changed to GET $buffer = preg_replace('#<\\s*form (.*?)method\\s*=\\s*[\\\\]?[\'"](.*?)[\'"]#is', "<form \$1 method='GET'", $buffer); if (preg_match_all('#<\\s*form (.*?)action\\s*=\\s*[\\\\]?[\'"](.*?)[\'\\\\"][\'\\\\"]?(.*?)>(.*?)</form>#is', $buffer, $m)) { foreach ($m[0] as $k => $v) { // Remove target parameters $m[3][$k] = trim(preg_replace('#target\\s*=\\s*(\\\\?[\'"]).*?\\1#i', '', $m[3][$k])); $buffer = str_replace($v, "<form {$m[1][$k]} action='{url_prefix}/{$aConf['file']['click']}' {$m[3][$k]} target='{$target}'>{$m[4][$k]}<input type='hidden' name='{$aConf['var']['params']}' value='{clickurlparams}{$m[2][$k]}'></form>", $buffer); } } //$buffer = preg_replace("#<form*action='*'*>#i","<form target='{target}' $1action='{url_prefix}/{}$aConf['file']['click']'$3><input type='hidden' name='{clickurlparams}$2'>", $buffer); //$buffer = preg_replace("#<form*action=\"*\"*>#i","<form target=\"{target}\" $1action=\"{url_prefix}/{$aConf['file']['click']}\"$3><input type=\"hidden\" name=\"{clickurlparams}$2\">", $buffer); // In addition, we need to add our clickURL to the clickTAG parameter if present, for 3rd party flash ads // the clickTag is case insentive match, as it is correct to use clicktag, CLICKTAG, etc. preg_match('/^(.*)(clickTAG)\\s?=\\s?(.*?)([\'"])(.*)$/is', $buffer, $matches); if (count($matches) > 0) { $matches[3] = html_entity_decode($matches[3], null, 'UTF-8'); $buffer = $matches[1] . $matches[2] . "={clickurl}" . urlencode($matches[3]) . $matches[4] . $matches[5]; } // Detect any JavaScript window.open() functions, and prepend the opened URL with our logurl $buffer = preg_replace('#window.open\\s?\\((.*?)\\)#i', "window.open(\\\\'{logurl}&maxdest=\\\\'+\$1)", $buffer); } // Since we don't want to replace adserver noscript and iframe content with click tracking etc $noScript = array(); //Capture noscript content into $noScript[0], for seperate translations preg_match("#<noscript>(.*?)</noscript>#is", $buffer, $noScript); $buffer = preg_replace("#<noscript>(.*?)</noscript>#is", '{noscript}', $buffer); // run 3rd party component if (!empty($banner['adserver'])) { require_once LIB_PATH . '/Plugin/Component.php'; /** * @todo This entire function should be relocated to the DLL and should be object-ified * */ PEAR::pushErrorHandling(null); $adServerComponent = OX_Component::factoryByComponentIdentifier($banner['adserver']); PEAR::popErrorHandling(); if ($adServerComponent) { $buffer = $adServerComponent->getBannerCache($buffer, $noScript); } else { $GLOBALS['_MAX']['bannerrebuild']['errors'] = true; } } $buffer = php_Ads_wrapBannerHtmlInClickUrl($banner, $buffer); // Adserver processing complete, now replace the noscript values back: //$buffer = preg_replace("#{noframe}#", $noFrame[2], $buffer); if (isset($noScript[0])) { $buffer = preg_replace("#{noscript}#", $noScript[0], $buffer); } // Allow custom banner types to alter the banner cache. $bannerTypeComponent = OX_Component::factoryByComponentIdentifier($banner['ext_bannertype']); if ($bannerTypeComponent) { $buffer = $bannerTypeComponent->getBannerCache($buffer, $noScript, $banner); } return $buffer; }
function test_getFallbackHandler() { $this->assertFalse(class_exists('Plugins_tests')); $oHandler = OX_Component::getFallbackHandler('tests'); $this->assertIsA($oHandler, 'Plugins_tests'); $this->assertFalse($oHandler->enabled); $this->assertEqual($oHandler->extension, 'tests'); }