コード例 #1
0
 function _getControllerClass($controllerType = '', $aParams = null, &$class, &$file)
 {
     if (!is_array($aParams)) {
         $aParams = array();
     }
     if (empty($controllerType) || $controllerType == '-') {
         $controllerType = basename($_SERVER['SCRIPT_NAME']);
         $controllerType = preg_replace('#^(?:stats-)?(.*)\\.php#', '$1', $controllerType);
     }
     // Validate
     if (!preg_match('/^[a-z-]+$/Di', $controllerType)) {
         $errMsg = "OA_Admin_Statistics_Factory::_getControllerClass() Unsupported controller type";
         return MAX::raiseError($errMsg, MAX_ERROR_INVALIDARGS, PEAR_ERROR_RETURN);
     }
     // Prepare the strings required to generate the file and class names
     list($primary, $secondary) = explode('-', $controllerType, 2);
     $primary = ucfirst(strtolower($primary));
     $aSecondary = explode('-', $secondary);
     foreach ($aSecondary as $key => $string) {
         $aSecondary[$key] = ucfirst(strtolower($string));
     }
     $file = MAX_PATH . '/lib/OA/Admin/Statistics/Delivery/Controller/';
     $file .= $primary;
     foreach ($aSecondary as $string) {
         $file .= $string;
     }
     $file .= '.php';
     $class = 'OA_Admin_Statistics_Delivery_Controller_';
     $class .= $primary;
     foreach ($aSecondary as $string) {
         $class .= $string;
     }
 }
 /**
  * Process an aggregate-type bucket.  This is MySQL specific.
  *
  * @param Plugins_DeliveryLog $oBucket a reference to the using (context) object.
  * @param Date $oEnd A PEAR_Date instance, interval_start to process up to (inclusive).
  */
 public function processBucket($oBucket, $oEnd)
 {
     $sTableName = $oBucket->getBucketTableName();
     $oMainDbh =& OA_DB_Distributed::singleton();
     if (PEAR::isError($oMainDbh)) {
         MAX::raiseError($oMainDbh, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
     }
     OA::debug('  - Processing the ' . $sTableName . ' table for data with operation interval start equal to or before ' . $oEnd->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEnd->tz->getShortName(), PEAR_LOG_INFO);
     // Select all rows with interval_start <= previous OI start.
     $rsData =& $this->getBucketTableContent($sTableName, $oEnd);
     $rowCount = $rsData->getRowCount();
     OA::debug('  - ' . $rsData->getRowCount() . ' records found', PEAR_LOG_DEBUG);
     if ($rowCount) {
         // We can't do bulk inserts with ON DUPLICATE.
         $aExecQueries = array();
         while ($rsData->fetch()) {
             // Get first row
             $aRow = $rsData->toArray();
             // Insert or update
             $aExecQueries[] = "SELECT bucket_update_{$sTableName}(" . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ")";
         }
         if (count($aExecQueries)) {
             foreach ($aExecQueries as $execQuery) {
                 $result = $oMainDbh->exec($execQuery);
                 if (PEAR::isError($result)) {
                     MAX::raiseError($result, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                 }
             }
         }
     }
 }
コード例 #3
0
 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'));
 }
コード例 #4
0
ファイル: Grid.php プロジェクト: hostinger/revive-adserver
 /**
  * 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();
 }
コード例 #5
0
 /**
  * The belongsToAccount() method behaves in a different way when looking
  * at entries in the "audit" table. To check if an account has access
  * to view specific audit data, we only need to check if the account's
  * ID is set in the appropriate column in the record.
  *
  * @param string $accountId The account ID to test if this DB_DataObject is
  *                          owned by.
  * @return boolean|null     Returns true if the entity belongs to the specified
  *                          account, false if doesn't, or null if it was not
  *                          possible to find the required object references.
  */
 function belongsToAccount($accountId = null)
 {
     // Set the account ID, if not passed in
     if (empty($accountId)) {
         $accountId = OA_Permission::getAccountId();
     }
     // Prepare $this with the required info of the "entity" to be tested
     if (!$this->N) {
         $key = $this->getFirstPrimaryKey();
         if (empty($this->{$key})) {
             MAX::raiseError('Key on object is not set, table: ' . $this->getTableWithoutPrefix());
             return null;
         }
         if (!$this->find($autoFetch = true)) {
             return null;
         }
     }
     // Test the account ID type, and then test for access
     $accountType = OA_Permission::getAccountTypeByAccountId($accountId);
     // Test the access to the audit trail entry
     if ($accountType == OA_ACCOUNT_ADMIN) {
         // Admin always has access
         return true;
     } else {
         if ($accountType == OA_ACCOUNT_MANAGER) {
             // Test if the account ID is equal to the account_id field
             if (is_null($this->account_id)) {
                 return null;
             }
             if ($this->account_id == $accountId) {
                 return true;
             }
         } else {
             if ($accountType == OA_ACCOUNT_ADVERTISER) {
                 // Test if the account ID is equal to the advertiser_account_id field
                 if (is_null($this->advertiser_account_id)) {
                     return null;
                 }
                 if ($this->advertiser_account_id == $accountId) {
                     return true;
                 }
             } else {
                 if ($accountType == OA_ACCOUNT_TRAFFICKER) {
                     // Test if the account ID is equal to the website_account_id field
                     if (is_null($this->website_account_id)) {
                         return null;
                     }
                     if ($this->website_account_id == $accountId) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
コード例 #6
0
 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;
 }
 /**
  * Process a raw-type bucket.
  *
  * @param Plugins_DeliveryLog a reference to the using (context) object.
  * @param Date $oEnd A PEAR_Date instance, interval_start to process up to (inclusive).
  */
 public function processBucket($oBucket, $oEnd)
 {
     $sTableName = $oBucket->getBucketTableName();
     $oMainDbh =& OA_DB_Distributed::singleton();
     if (PEAR::isError($oMainDbh)) {
         MAX::raiseError($oMainDbh, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
     }
     OA::debug('  - Processing the ' . $sTableName . ' table for data with operation interval start equal to or before ' . $oEnd->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEnd->tz->getShortName(), PEAR_LOG_INFO);
     // As this is raw data being processed, data will not be logged based on the operation interval,
     // but based on the time the raw data was collected. Adjust the $oEnd value accordingly...
     $aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oEnd);
     OA::debug('    - The ' . $sTableName . ' table is a raw data table. Data logged in real-time, not operation intervals.', PEAR_LOG_INFO);
     OA::debug('    - Accordingly, processing of the ' . $sTableName . ' table will be performed based on data that has a logged date equal to', PEAR_LOG_INFO);
     OA::debug('      or before ' . $aDates['end']->format('%Y-%m-%d %H:%M:%S') . ' ' . $aDates['end']->tz->getShortName(), PEAR_LOG_INFO);
     // Select all rows with interval_start <= previous OI start.
     $rsData =& $this->getBucketTableContent($sTableName, $aDates['end']);
     $count = $rsData->getRowCount();
     OA::debug('  - ' . $rsData->getRowCount() . ' records found', PEAR_LOG_DEBUG);
     if ($count) {
         $packetSize = 16777216;
         // 16 MB hardcoded (there's no max limit)
         $i = 0;
         while ($rsData->fetch()) {
             $aRow = $rsData->toArray();
             $sRow = '(' . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ')';
             if (!$i) {
                 $sInsert = "INSERT INTO {$sTableName} (" . join(',', array_keys($aRow)) . ") VALUES ";
                 $query = '';
                 $aExecQueries = array();
             }
             if (!$query) {
                 $query = $sInsert . $sRow;
                 // Leave 4 bytes headroom for max_allowed_packet
             } elseif (strlen($query) + strlen($sRow) + 4 < $packetSize) {
                 $query .= ',' . $sRow;
             } else {
                 $aExecQueries[] = $query;
                 $query = $sInsert . $sRow;
             }
             if (++$i >= $count || strlen($query) >= $packetSize) {
                 $aExecQueries[] = $query;
                 $query = '';
             }
             if (count($aExecQueries)) {
                 foreach ($aExecQueries as $execQuery) {
                     $result = $oMainDbh->exec($execQuery);
                     if (PEAR::isError($result)) {
                         MAX::raiseError($result, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                     }
                 }
                 $aExecQueries = array();
             }
         }
     }
 }
コード例 #8
0
ファイル: Agency.php プロジェクト: villos/tree_admin
 /**
  * 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');
 }
コード例 #9
0
ファイル: Info.php プロジェクト: ballistiq/revive-adserver
 /**
  * This method returns class field type.
  *
  * @param string $fieldName
  * @return string  field type
  */
 function getFieldType($fieldName)
 {
     $aFieldsTypes = $this->getFieldsTypes();
     if (!isset($aFieldsTypes) || !is_array($aFieldsTypes)) {
         MAX::raiseError('Please provide field types array for Info object creation');
     }
     if (!array_key_exists($fieldName, $aFieldsTypes)) {
         MAX::raiseError('Unknown type for field \'' . $fieldName . '\'');
     }
     return $aFieldsTypes[$fieldName];
 }
コード例 #10
0
ファイル: Redirect.php プロジェクト: villos/tree_admin
 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);
 }
コード例 #11
0
 function OX_Maintenance()
 {
     $this->aConf = $GLOBALS['_MAX']['CONF'];
     OA_Preferences::loadAdminAccountPreferences();
     $this->aPref = $GLOBALS['_MAX']['PREF'];
     // Get a connection to the datbase
     $this->oDbh =& OA_DB::singleton();
     if (PEAR::isError($this->oDbh)) {
         // Unable to continue!
         MAX::raiseError($this->oDbh, null, PEAR_ERROR_DIE);
     }
 }
コード例 #12
0
 /**
  * Registers OA_Admin_UI_Decorator for a decorator
  * 
  * @return true if successfully registered, false if there is already decorator
  * registered for this name. 
  */
 function registerDecorator($decoratorName, $path, $className)
 {
     $decoratorName = strtolower($decoratorName);
     if (empty($decoratorName) || empty($path) || empty($className)) {
         $errMsg = "DecoratorRegistry::add() Cannot register decorator {$decoratorName} from class {$className} included from {$path}";
         return MAX::raiseError($errMsg);
     }
     if (isset($GLOBALS['_OA_Admin_UI_Decorator_Factory_registered_decorators'][$decoratorName])) {
         return false;
     }
     $GLOBALS['_OA_Admin_UI_Decorator_Factory_registered_decorators'][$decoratorName] = array($path, $className);
     return true;
 }
コード例 #13
0
 /**
  * Registers OA_Admin_UI_Rule_QuickFormToJQueryRuleAdaptor for a given quickform rule
  * 
  * @return true if successfully registered, false if there is already adaptor
  * registered for this quickform rule. 
  */
 function registerJQueryRuleAdaptor($quickFormRuleName, $path, $className)
 {
     $quickFormRuleName = strtolower($quickFormRuleName);
     if (empty($quickFormRuleName) || empty($path) || empty($className)) {
         $errMsg = "JQueryRuleAdaptorRegistry::add() Cannot register adaptor for class {$className} for  rule {$quickFormRuleName} included from {$path}";
         return MAX::raiseError($errMsg);
     }
     if (isset($GLOBALS['_OA_Admin_UI_Rule_JQueryRuleAdaptorRegistry_registered_adaptors'][$quickFormRuleName])) {
         return false;
     }
     $GLOBALS['_OA_Admin_UI_Rule_JQueryRuleAdaptorRegistry_registered_adaptors'][$quickFormRuleName] = array($path, $className);
     return true;
 }
 /**
  * Process an aggregate-type bucket.  This is MySQL specific.
  *
  * @param Plugins_DeliveryLog $oBucket a reference to the using (context) object.
  * @param Date $oEnd A PEAR_Date instance, interval_start to process up to (inclusive).
  */
 public function processBucket($oBucket, $oEnd)
 {
     $sTableName = $oBucket->getBucketTableName();
     $oMainDbh =& OA_DB_Distributed::singleton();
     if (PEAR::isError($oMainDbh)) {
         MAX::raiseError($oMainDbh, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
     }
     OA::debug('  - Processing the ' . $sTableName . ' table for data with operation interval start equal to or before ' . $oEnd->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEnd->tz->getShortName(), PEAR_LOG_INFO);
     // Select all rows with interval_start <= previous OI start.
     $rsData =& $this->getBucketTableContent($sTableName, $oEnd);
     $rowCount = $rsData->getRowCount();
     OA::debug('  - ' . $rsData->getRowCount() . ' records found', PEAR_LOG_DEBUG);
     if ($rowCount) {
         // We can't do bulk inserts with ON DUPLICATE.
         $aExecQueries = array();
         if ($rsData->fetch()) {
             // Get first row
             $aRow = $rsData->toArray();
             // Prepare INSERT
             $sInsert = "INSERT INTO {$sTableName} (" . join(',', array_keys($aRow)) . ") VALUES ";
             // Add first row data
             $sRow = '(' . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ')';
             $sOnDuplicate = ' ON DUPLICATE KEY UPDATE count = count + ' . $aRow['count'];
             // Add first insert
             $aExecQueries[] = $sInsert . $sRow . $sOnDuplicate;
             // Deal with the other rows
             while ($rsData->fetch()) {
                 $aRow = $rsData->toArray();
                 $sRow = '(' . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ')';
                 $sOnDuplicate = ' ON DUPLICATE KEY UPDATE count = count + ' . $aRow['count'];
                 $aExecQueries[] = $sInsert . $sRow . $sOnDuplicate;
             }
         }
         if (count($aExecQueries)) {
             // Try to disable the binlog for the inserts so we don't
             // replicate back out over our logged data.
             PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
             $result = $oMainDbh->exec('SET SQL_LOG_BIN = 0');
             if (PEAR::isError($result)) {
                 OA::debug('Unable to disable the bin log, proceeding anyway.', PEAR_LOG_WARNING);
             }
             PEAR::staticPopErrorHandling();
             foreach ($aExecQueries as $execQuery) {
                 $result = $oMainDbh->exec($execQuery);
                 if (PEAR::isError($result)) {
                     MAX::raiseError($result, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
                 }
             }
         }
     }
 }
コード例 #15
0
 /**
  * Creates a new Field object of the appropriate subclass.
  *
  * @param string $fieldType The type of field to create.
  * @return Admin_UI_Field An instance of the correct {@link Admin_UI_Field} subclass.
  */
 function &newField($fieldType)
 {
     switch ($fieldType) {
         case 'advertiser':
             $oField = new Admin_UI_AdvertiserIdField();
             break;
         case 'affiliateid-dropdown':
         case 'publisherid-dropdown':
             $oField = new Admin_UI_PublisherIdField();
             break;
         case 'campaignid-dropdown':
             $oField = new Admin_UI_CampaignSelectionField();
             break;
         case 'clientid-dropdown':
             $oField = new Admin_UI_AdvertiserIdField();
             break;
         case 'channelid-dropdown':
             $oField = new Admin_UI_ChannelIdField();
             break;
         case 'date-month':
         case 'day-span':
         case 'day-span-selector':
             $oField = new Admin_UI_DaySpanField();
             break;
         case 'dropdown':
             $oField = new Admin_UI_DropdownField();
             break;
         case 'edit':
             $oField = new Admin_UI_TextField();
             break;
         case 'scope':
             $oField = new Admin_UI_OrganisationSelectionField();
             break;
         case 'sheet':
             $oField = new Admin_UI_SheetSelectionField();
             break;
         case 'trackerid-dropdown':
             $oField = new Admin_UI_TrackerField();
             break;
         case 'zone-scope':
             $oField = new Admin_UI_ZoneScopeField();
             break;
         case 'zoneid-dropdown':
             $oField = new Admin_UI_ZoneIdField();
             break;
         default:
             MAX::raiseError("The report module discovered a field type that it didn't know how to handle.", MAX_ERROR_INVALIDARGS);
     }
     return $oField;
 }
コード例 #16
0
ファイル: Index.php プロジェクト: Jaree/revive-adserver
 /**
  * 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);
 }
コード例 #17
0
ファイル: Max.php プロジェクト: akirsch/revive-adserver
 /**
  * A method to invoke errors.
  *
  * @static
  * @param mixed $message A string error message, or a {@link PEAR_Error} object.
  * @param integer $type A custom message code - see the {@link setupConstants()} function.
  * @param integer $behaviour Optional behaviour (i.e. PEAR_ERROR_DIE to halt on this error).
  * @return PEAR_Error $error A (@link PEAR_Error} object.
  */
 function raiseError($message, $type = null, $behaviour = null)
 {
     // If fatal
     if ($behaviour == PEAR_ERROR_DIE) {
         // Log fatal message here as execution will stop
         $errorType = MAX::errorConstantToString($type);
         if (!is_string($message)) {
             $message = print_r($message, true);
         }
         OA::debug($type . ' :: ' . $message, PEAR_LOG_EMERG);
         exit;
     }
     $error = PEAR::raiseError($message, $type, $behaviour);
     return $error;
 }
コード例 #18
0
ファイル: OX.php プロジェクト: ballistiq/revive-adserver
 /**
  * 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;
     }
 }
コード例 #19
0
 function display()
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     if (!$conf['audit']['enabled']) {
         $this->oTpl->assign('screen', 'disabled');
         $this->oTpl->assign('siteTitle', $GLOBALS['strAuditTrailSetup']);
         $this->oTpl->assign('siteUrl', MAX::constructUrl(MAX_URL_ADMIN, 'account-settings-debug.php'));
     } else {
         // Account security
         if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
             $aParams['account_id'] = OA_Permission::getAccountId();
         }
         if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
             $aParams['advertiser_account_id'] = OA_Permission::getAccountId();
         }
         if (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
             $aParams['website_account_id'] = OA_Permission::getAccountId();
         }
         $oAudit = new OA_Dll_Audit();
         $aAuditData = $oAudit->getAuditLogForAuditWidget($aParams);
         if (count($aAuditData) > 0) {
             foreach ($aAuditData as $key => $aValue) {
                 $aValue['action'] = $this->oTrans->translate($oAudit->getActionName($aValue['actionid']));
                 $result = $oAudit->getParentContextData($aValue);
                 $str = "{$aValue['username']} {$GLOBALS['strHas']} {$aValue['action']} {$aValue['context']}";
                 if (!empty($aValue['contextid'])) {
                     $str .= " ({$aValue['contextid']})";
                 }
                 if (!empty($aValue['parentcontext'])) {
                     $str .= " {$GLOBALS['strFor']} {$aValue['parentcontext']} ({$aValue['parentcontextid']})";
                 }
                 if (!empty($aValue['hasChildren'])) {
                     $str .= " {$GLOBALS['strAdditionItems']}";
                 }
                 $aAuditData[$key]['desc'] = strlen($str) > 30 ? substr($str, 0, 30) . '...' : $str;
             }
         } else {
             $this->oTpl->assign('noData', $GLOBALS['strAuditNoData']);
         }
         $this->oTpl->assign('screen', 'enabled');
         $this->oTpl->assign('aAuditData', $aAuditData);
         $this->oTpl->assign('siteUrl', MAX::constructUrl(MAX_URL_ADMIN, 'userlog-index.php'));
         $this->oTpl->assign('siteTitle', $GLOBALS['strAuditTrailGoTo']);
     }
     $this->oTpl->display();
 }
コード例 #20
0
 /**
  * A private method to get the required default deliveryLog extension
  * bucket processing strategy class.
  *
  * @access private
  * @param string $type Either "Aggregate" or "Raw".
  * @return OX_Extension_DeliveryLog_BucketProcessingStrategy
  */
 private static function _getBucketProcessingStrategy($type)
 {
     $dbType = $GLOBALS['_MAX']['CONF']['database']['type'];
     // Prepare the required filename for the default bucket processing strategy needed
     $fileName = LIB_PATH . '/Extension/deliveryLog/' . ucfirst(strtolower($type)) . 'BucketProcessingStrategy' . ucfirst(strtolower($dbType)) . '.php';
     // Include the required bucket processing strategy file
     if (file_exists($fileName)) {
         @(include_once $fileName);
         // Prepare the required class name for the default bucket processing strategy needed
         $className = 'OX_Extension_DeliveryLog_' . ucfirst(strtolower($type)) . 'BucketProcessingStrategy' . ucfirst(strtolower($dbType));
         if (class_exists($className)) {
             return new $className();
         }
     }
     $message = 'Unable to instantiate the required default ' . strtolower($type) . " datbase bucket processing strategy for database type '{$dbType}'.";
     MAX::raiseError($message, MAX_ERROR_INVALIDARGS, PEAR_ERROR_DIE);
 }
コード例 #21
0
ファイル: Index.php プロジェクト: villos/tree_admin
 /**
  * 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, '&amp;');
         }
     }
     $oTpl->assign('dashboardURL', $dashboardUrl);
     $oTpl->display();
     phpAds_PageFooter('', true);
 }
コード例 #22
0
ファイル: User.php プロジェクト: ballistiq/revive-adserver
 /**
  * Class constructor
  *
  * @param DataObjects_Users $doUsers
  * @return OA_Permission_User
  */
 function OA_Permission_User($doUsers, $skipDatabaseAccess = false)
 {
     if (!is_a($doUsers, 'DataObjects_Users')) {
         MAX::raiseError('doUser not a DataObjects_Users');
     }
     // Store user information as array
     $this->aUser = $doUsers->toArray();
     // For safety reasons, do not store the password
     unset($this->aUser['password']);
     // Make sure we start with an empty account
     $this->_clearAccountData();
     if (!$skipDatabaseAccess) {
         // Check if the user is linked to the admin account
         $this->aUser['is_admin'] = $this->_isAdmin();
         $this->loadAccountData($this->aUser['default_account_id']);
     } else {
         $this->aUser['is_admin'] = false;
     }
 }
コード例 #23
0
 /**
  * A class to test if an operation interval value is valid.
  *
  * @static
  * @param integer $oi The operation interval value in minutes.
  * @param mixed True if the operation interval value is valid, a {@link PEAR_Error}
  *              object with error type MAX_ERROR_INVALIDOPERATIONINT otherwise.
  */
 function checkOperationIntervalValue($oi)
 {
     if ($oi < 1) {
         // Operation interval must be at least every minute
         $error = 'The operation interval of ' . $oi . ' is invalud';
         return MAX::raiseError($error, MAX_ERROR_INVALIDOPERATIONINT);
     } elseif ($oi < 60) {
         // Operation interval is more often than once an hour
         if (60 % $oi != 0) {
             // Operation interval must be a factor of 60 minutes
             $error = 'The operation interval of ' . $oi . ' is invalud';
             return MAX::raiseError($error, MAX_ERROR_INVALIDOPERATIONINT);
         }
     } elseif ($oi > 60) {
         // Operation interval must not be more than 60
         $error = 'The operation interval of ' . $oi . ' is invalud';
         return MAX::raiseError($error, MAX_ERROR_INVALIDOPERATIONINT);
     }
     return true;
 }
コード例 #24
0
ファイル: Common.php プロジェクト: ballistiq/revive-adserver
 /**
  * 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);
 }
コード例 #25
0
 function setAppendCodes($tracker_id, $codes)
 {
     $tracker_id = is_numeric($tracker_id) ? $tracker_id : (int) $tracker_id;
     $query = "\n            DELETE FROM {$this->prefix}{$this->conf['table']['tracker_append']}\n            WHERE tracker_id = " . $this->oDbh->quote($tracker_id, 'integer');
     $result = $this->oDbh->exec($query);
     if (PEAR::isError($result)) {
         MAX::raiseError($result, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
     }
     $rank = 0;
     $appendcodes = array();
     $doTrackerAppend = OA_Dal::factoryDO('tracker_append');
     $doTrackerAppend->tracker_id = $tracker_id;
     foreach ($codes as $v) {
         $tagcode = trim($v['tagcode']);
         $paused = $v['paused'] ? 't' : 'f';
         $autotrack = $v['autotrack'] ? 't' : 'f';
         if (!strlen($tagcode)) {
             continue;
         }
         $doTA = clone $doTrackerAppend;
         $doTA->tagcode = $tagcode;
         $doTA->paused = $paused;
         $doTA->autotrack = $autotrack;
         $doTA->rank = ++$rank;
         $result = $doTA->insert();
         if (empty($result)) {
             MAX::raiseError("Could not insert tracker append row", MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
         }
         $appendcodes[] = array('tagcode' => $tagcode, 'paused' => $paused, 'autotrack' => $autotrack);
     }
     $query = "\n            UPDATE {$this->prefix}{$this->conf['table']['trackers']}\n            SET appendcode = " . $this->oDbh->quote($this->generateAppendCode($appendcodes)) . "\n            WHERE trackerid = " . $this->oDbh->quote($tracker_id);
     $result = $this->oDbh->exec($query);
     if (PEAR::isError($result)) {
         MAX::raiseError($result, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
     }
 }
コード例 #26
0
 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;
     }
 }
コード例 #27
0
ファイル: Dal.php プロジェクト: akirsch/revive-adserver
 function batchInsertPlain($tableName, $aFields, $aValues)
 {
     if (!is_array($aFields) || !is_array($aValues)) {
         return MAX::raiseError('$aFields and $aData must be arrays', PEAR_ERROR_RETURN);
     }
     $oDbh = OA_DB::singleton();
     // Quote table name
     $tableName = $oDbh->quoteIdentifier($tableName);
     // Quote fields list
     $fieldList = '(' . join(',', array_map(array($oDbh, 'quoteIdentifier'), $aFields)) . ')';
     foreach ($aValues as $aRow) {
         $values = implode(', ', array_map(array($oDbh, 'quote'), $aRow));
         $query = "INSERT INTO {$tableName} {$fieldList} VALUES ({$values})";
         $result = $oDbh->exec($query);
         if (PEAR::isError($result)) {
             return $result;
         }
     }
     return count($aValues);
 }
コード例 #28
0
 /**
  * A method to return an array of account IDs of the account(s) that
  * should "own" any audit trail entries for this entity type; these
  * are NOT related to the account ID of the currently active account
  * (which is performing some kind of action on the entity), but is
  * instead related to the type of entity, and where in the account
  * heirrachy the entity is located.
  *
  * @return array An array containing up to three indexes:
  *                  - "OA_ACCOUNT_ADMIN" or "OA_ACCOUNT_MANAGER":
  *                      Contains the account ID of the manager account
  *                      that needs to be able to see the audit trail
  *                      entry, or, the admin account, if the entity
  *                      is a special case where only the admin account
  *                      should see the entry.
  *                  - "OA_ACCOUNT_ADVERTISER":
  *                      Contains the account ID of the advertiser account
  *                      that needs to be able to see the audit trail
  *                      entry, if such an account exists.
  *                  - "OA_ACCOUNT_TRAFFICKER":
  *                      Contains the account ID of the trafficker account
  *                      that needs to be able to see the audit trail
  *                      entry, if such an account exists.
  */
 function getOwningAccountIds()
 {
     // Placement/zone associations are a special case, as both the
     // advertiser and the website accounts should be able to see
     // the audit entries, so the results of two calls need to be
     // merged
     $aAdvertiserAccountIds = array();
     if (!empty($this->placement_id)) {
         // Placement/zone assocs don't have an account_id, get it from
         // the parent campaign (stored in the "campaigns" table) using
         // the "placement_id" key
         $aAdvertiserAccountIds = parent::getOwningAccountIds('campaigns', 'placement_id');
     }
     $aWebsiteAccountIds = array();
     if (!empty($this->zone_id)) {
         // Placement/zone assocs don't have an account_id, get it from
         // the parent zone (stored in the "zones" table) using
         // the "zone_id" key
         $aWebsiteAccountIds = parent::getOwningAccountIds('zones', 'zone_id');
     }
     // Check that the manager account IDs match from the two results
     if (isset($aAdvertiserAccountIds[OA_ACCOUNT_MANAGER]) && isset($aWebsiteAccountIds[OA_ACCOUNT_MANAGER])) {
         if ($aAdvertiserAccountIds[OA_ACCOUNT_MANAGER] != $aWebsiteAccountIds[OA_ACCOUNT_MANAGER]) {
             $message = "Cannot locate owning account IDs for ad/zone association, as manager account IDs, " . "do not match, where ad ID was {$this->ad_id} and zone ID was {$this->zone_id}.";
             MAX::raiseError($message, PEAR_LOG_ERR);
         }
     }
     // Merge the arrays and return
     $aResult = array_merge($aAdvertiserAccountIds, $aWebsiteAccountIds);
     return $aResult;
 }
コード例 #29
0
            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)) {
コード例 #30
0
ファイル: channel-edit.php プロジェクト: villos/tree_admin
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");
        }
    }
}