function testCheckTimeDay()
 {
     OA_setTimeZoneUTC();
     // =~ and !~ - Single value
     $this->assertTrue(MAX_checkTime_Day('3', '=~', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     // Wed
     $this->assertTrue(MAX_checkTime_Day('3', '!~', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // Thu
     // =~ and !~ - Multiple value
     $this->assertTrue(MAX_checkTime_Day('1,3,4', '=~', array('timestamp' => mktime(0, 0, 0, 7, 6, 2009))));
     // Mon
     $this->assertTrue(MAX_checkTime_Day('1,3,4', '=~', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // Thu
     $this->assertTrue(MAX_checkTime_Day('1,3,4', '!~', array('timestamp' => mktime(0, 0, 0, 7, 3, 2009))));
     // Fri
     $this->assertFalse(MAX_checkTime_Day('1,3,4', '!~', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     // Wed
     // =~ and !~ - Single value with TZ
     $this->assertTrue(MAX_checkTime_Day('2@America/New_York', '=~', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     // Wed
     $this->assertTrue(MAX_checkTime_Day('2@America/New_York', '!~', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // Thu
     // =~ and !~ - Multiple value with TZ
     $this->assertTrue(MAX_checkTime_Day('0,2,3@America/New_York', '=~', array('timestamp' => mktime(0, 0, 0, 7, 6, 2009))));
     // Mon
     $this->assertTrue(MAX_checkTime_Day('0,2,3@America/New_York', '=~', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // Thu
     $this->assertTrue(MAX_checkTime_Day('0,2,3@America/New_York', '!~', array('timestamp' => mktime(0, 0, 0, 7, 3, 2009))));
     // Fri
     $this->assertFalse(MAX_checkTime_Day('0,2,3@America/New_York', '!~', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     // Wed
     OA_setTimeZoneLocal();
 }
 /**
  * A method to test the deliveryBlocked() method.
  */
 function testDeliveryBlocked()
 {
     OA_setTimeZoneUTC();
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '=~', 'data' => '1,5,7,20', 'executionorder' => 1);
     $oLimitationHour = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     $oDate = new Date('2006-02-07 23:15:45');
     for ($i = 0; $i < 24; $i++) {
         $oDate->addSeconds(SECONDS_PER_HOUR);
         if ($i == 1 || $i == 5 || $i == 7 || $i == 20) {
             $this->assertFalse($oLimitationHour->deliveryBlocked($oDate));
         } else {
             $this->assertTrue($oLimitationHour->deliveryBlocked($oDate));
         }
     }
     // Test timezone
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '=~', 'data' => '1,5,7,20@Europe/Rome', 'executionorder' => 1);
     $oLimitationHour = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     $oDate = new Date('2006-02-07 23:15:45');
     for ($i = 0; $i < 24; $i++) {
         $oDate->addSeconds(SECONDS_PER_HOUR);
         if ($i == 0 || $i == 4 || $i == 6 || $i == 19) {
             $this->assertFalse($oLimitationHour->deliveryBlocked($oDate));
         } else {
             $this->assertTrue($oLimitationHour->deliveryBlocked($oDate));
         }
     }
     OA_setTimeZoneLocal();
 }
 /**
  * A method to test the deliveryBlocked() method.
  */
 function testDeliveryBlocked()
 {
     OA_setTimeZoneUTC();
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Day', 'comparison' => '=~', 'data' => '1,5,4,6', 'executionorder' => 1);
     $oLimitationDay = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     $oDate = new Date('2006-02-05');
     // Sunday
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-06');
     // Monday
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-07');
     // Tuesday
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-08');
     // Wednesday
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-09');
     // Thursday
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-10');
     // Friday
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-11');
     // Saturday
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     // Test timezone
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Day', 'comparison' => '=~', 'data' => '1,5,4,6@America/New_York', 'executionorder' => 1);
     $oLimitationDay = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     $oDate = new Date('2006-02-05');
     // Sunday, but Saturday in GMT-5
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-06');
     // Monday, but Sunday in GMT-5
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-07');
     // Tuesday, but Monday in GMT-5
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-08');
     // Wednesday, but Tuesday in GMT-5
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-09');
     // Thursday, but Wednesday in GMT-5
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-10');
     // Friday, but Friday in GMT-5
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-11');
     // Saturday, but Friday in GMT-5
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     OA_setTimeZoneLocal();
 }
 function getStats()
 {
     // Set time zone to local
     OA_setTimeZoneLocal();
     $oEnd = new Date();
     $oEnd->setHour(0);
     $oEnd->setMinute(0);
     $oEnd->setSecond(0);
     $oEnd->toUTC();
     $oStart = new Date($oEnd);
     $oStart->subtractSpan(new Date_Span('7-0-0-0'));
     $oStart->toUTC();
     $doDsah = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDsah->selectAdd();
     $doDsah->selectAdd("DATE_FORMAT(date_time, '%Y-%m-%d') AS day");
     $doDsah->selectAdd('SUM(' . $doDsah->tableName() . '.impressions) AS total_impressions');
     $doDsah->selectAdd('SUM(' . $doDsah->tableName() . '.clicks) AS total_clicks');
     $doDsah->whereAdd("date_time >= '" . $doDsah->escape($oStart->format('%Y-%m-%d %H:%M:%S')) . "'");
     $doDsah->whereAdd("date_time < '" . $doDsah->escape($oEnd->format('%Y-%m-%d %H:%M:%S')) . "'");
     if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $doBanners = OA_Dal::factoryDO('banners');
         $doCampaigns = OA_Dal::factoryDO('campaigns');
         $doClients = OA_Dal::factoryDO('clients');
         $doClients->agencyid = OA_Permission::getEntityId();
         $doCampaigns->joinAdd($doClients);
         $doBanners->joinAdd($doCampaigns);
         $doBanners->selectAdd();
         $doBanners->selectAdd("bannerid");
         $doBanners->find();
         $ad_ids = array();
         while ($doBanners->fetch()) {
             $ad_ids[] = $doBanners->bannerid;
         }
         if (empty($ad_ids)) {
             return array();
         }
         $doDsah->whereAdd("ad_id IN (" . implode(",", $ad_ids) . ")");
     }
     $doDsah->groupBy('day');
     $doDsah->orderBy('day');
     $doDsah->find();
     $aStats = array();
     while ($doDsah->fetch()) {
         $row = $doDsah->toArray();
         $aStats[0][date('D', strtotime($row['day']))] = $row['total_impressions'];
         $aStats[1][date('D', strtotime($row['day']))] = $row['total_clicks'];
     }
     return $aStats;
 }
 function testCheckTimeHour()
 {
     OA_setTimeZoneUTC();
     // =~ and !~ - Single value
     $this->assertTrue(MAX_checkTime_Hour('3', '=~', array('timestamp' => mktime(3, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('3', '!~', array('timestamp' => mktime(4, 0, 0, 7, 1, 2009))));
     // =~ and !~ - Multiple value
     $this->assertTrue(MAX_checkTime_Hour('1,3,4', '=~', array('timestamp' => mktime(1, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('1,3,4', '=~', array('timestamp' => mktime(4, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('1,3,4', '!~', array('timestamp' => mktime(5, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Hour('1,3,4', '!~', array('timestamp' => mktime(3, 0, 0, 7, 1, 2009))));
     // =~ and !~ - Single value with TZ
     $this->assertTrue(MAX_checkTime_Hour('5@Europe/Rome', '=~', array('timestamp' => mktime(3, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('5@Europe/Rome', '!~', array('timestamp' => mktime(4, 0, 0, 7, 1, 2009))));
     // =~ and !~ - Multiple value with TZ
     $this->assertTrue(MAX_checkTime_Hour('3,5,6@Europe/Rome', '=~', array('timestamp' => mktime(1, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('3,5,6@Europe/Rome', '=~', array('timestamp' => mktime(4, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('3,5,6@Europe/Rome', '!~', array('timestamp' => mktime(5, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Hour('3,5,6@Europe/Rome', '!~', array('timestamp' => mktime(3, 0, 0, 7, 1, 2009))));
     OA_setTimeZoneLocal();
 }
 function testCheckTimeDay()
 {
     OA_setTimeZoneUTC();
     // All operators, active
     $this->assertTrue(MAX_checkTime_Date('20090701', '==', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '!=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '!=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '<', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '>', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '<=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '<=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '>=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '>=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // All operators, inactive
     $this->assertFalse(MAX_checkTime_Date('20090701', '==', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701', '!=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701', '<', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701', '>', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701', '<=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701', '>=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     // All operators, active with TZ
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '==', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '!=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '!=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '<', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '>', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '<=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '<=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '>=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '>=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // All operators, inactive with TZ
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '==', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '!=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '<', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '>', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '<=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '>=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     OA_setTimeZoneLocal();
 }
 /**
  * A method to test the deliveryBlocked() method.
  *
  * Test 1: Test date == delivery requirement
  * Test 2: Test date != delivery requirement
  * Test 3: Test date <= delivery requirement
  * Test 4: Test date >= delivery requirement
  * Test 5: Test date <  delivery requirement
  * Test 6: Test date >  delivery requirement
  * Test 7: Bad input, no date object passed to method
  */
 function testDeliveryBlocked()
 {
     // Set timezone to UTC
     OA_setTimeZoneUTC();
     $oDate = new Date('2005-04-03');
     $oEarlierDate = new Date('2005-04-02');
     $oLaterDate = new Date('2005-04-04');
     $limitationData = $oDate->format('%Y%m%d@%Z');
     // Test 1
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '==', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 2
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '!=', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 3
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '<=', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 4
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '>=', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 5
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '<', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 6
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '>', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 7
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '>', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     PEAR::pushErrorHandling(null);
     $this->assertTrue(is_a($oLimitationDate->deliveryBlocked('not a date'), 'pear_error'));
     PEAR::popErrorHandling();
     // Test with PST timezone
     $limitationData = $oDate->format('%Y%m%d') . '@America/New_York';
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '==', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date (-1 day, 19pm in EST): true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date (-2 days, 19pm in EST): true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date (-0 days, 19pm in EST): false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oLaterDate));
     // Reset timezone
     OA_setTimeZoneLocal();
 }
Example #8
0
 /**
  * Checks if user has access to specific area (for example admin or agency area)
  * Permissions are defined in www/admin/lib-permissions.inc.php file
  *
  * @access public
  *
  * @param integer $permissions
  * @param string $table  Table name
  * @param integer $id  Id (or empty if new is created)
  * @param unknown $allowed  check allowed
  * @param OA_Permission Does the current call require only a subset of the permissions?
  * 						If set to null, equivalent to asking permission to do everything on the object
  *
  * @return boolean  True if has access
  */
 function checkPermissions($permissions, $table = '', $id = null, $allowed = null, $operationAccessType = OA_Permission::OPERATION_ALL)
 {
     $isError = false;
     if (isset($permissions) && !OA_Permission::isAccount($permissions)) {
         if (!OA_Permission::attemptToSwitchToAccount($permissions)) {
             $isError = true;
         }
     }
     // Should this check also be part of checkPermissions?
     if (!empty($id) && !$this->checkIdExistence($table, $id)) {
         return false;
     }
     if (isset($id) && !OA_Permission::hasAccessToObject($table, $id, $operationAccessType)) {
         if (!OA_Permission::attemptToSwitchForAccess($table, $id)) {
             $isError = true;
         }
     }
     if (isset($allowed)) {
         if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER, OA_ACCOUNT_TRAFFICKER) && !OA_Permission::hasPermission($allowed)) {
             $isError = true;
         }
     }
     if ($isError) {
         $this->raiseError('Access forbidden');
         return false;
     } else {
         // Set system timezone and return
         OA_setTimeZoneLocal();
         return true;
     }
 }
Example #9
0
    }
    $translation = new OX_Translation();
    $translation->htmlSpecialChars = true;
    $translated_message = $translation->translate($GLOBALS['strErrorCantConnectToDatabase'], array(PRODUCT_NAME));
    phpAds_Die($GLOBALS['strErrorDatabaseConnetion'], $translated_message);
}
// First thing to do is clear the $session variable to
// prevent users from pretending to be logged in.
unset($session);
// Authorize the user
OA_Start();
// Load the account's preferences
OA_Preferences::loadPreferences();
$pref = $GLOBALS['_MAX']['PREF'];
// Set time zone to local
OA_setTimeZoneLocal();
// Load the required language files
Language_Loader::load('default');
// Register variables
phpAds_registerGlobalUnslashed('affiliateid', 'agencyid', 'bannerid', 'campaignid', 'channelid', 'clientid', 'day', 'trackerid', 'userlogid', 'zoneid');
if (!isset($affiliateid)) {
    $affiliateid = OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER) ? OA_Permission::getEntityId() : '';
}
if (!isset($agencyid)) {
    $agencyid = OA_Permission::isAccount(OA_ACCOUNT_ADMIN) ? '' : OA_Permission::getAgencyId();
}
if (!isset($bannerid)) {
    $bannerid = '';
}
if (!isset($campaignid)) {
    $campaignid = '';