/**
  * Called before any action gets executed
  */
 protected function init()
 {
     // No upgrade file? No installer! Unless the user is in the last step
     if (!file_exists(MAX_PATH . '/var/UPGRADE') && 'finish' != $_REQUEST['action']) {
         header("Location: index.php");
         exit;
     }
     @set_time_limit(0);
     //  load translations for installer
     Language_Loader::load('installer');
     Language_Loader::load('default');
     Language_Loader::load('settings');
     Language_Loader::load('settings-help');
     // Setup oUpgrader
     $this->initUpgrader();
     $this->oTranslation = new OX_Translation();
     // clear the $session variable to prevent users pretending to be logged in.
     global $session;
     unset($session);
     $this->initInstallStatus();
     //check if market is required, if login is required (this will be used by wizard)
     $this->initStepConfig();
     //check if recovery required
     $oRequest = $this->getRequest();
     if ($this->oInstallStatus->isRecovery() && $oRequest->getParam('action') != 'recovery') {
         //if recovery required and not recovering already, force recovery to be started
         $oRequest->setParam('action', 'recovery');
     }
     parent::init();
 }
예제 #2
0
 /**
  * A method for returning an array of the available delivery caching modes.
  *
  * @return array An array of strings representing the available delivery caching modes.
  */
 function AvailableCachingModes()
 {
     Language_Loader::load('default');
     $modes = array();
     $modes['none'] = $GLOBALS['strNone'];
     if (is_writable(MAX_PATH . '/var/cache')) {
         $modes['file'] = $GLOBALS['strCacheFiles'];
     }
     return $modes;
 }
예제 #3
0
 /**
  * A method for returning an array of the available geotargeting modes.
  *
  * @return array  An array of strings representing the available geotargeting modes.
  */
 function AvailableGeotargetingModes()
 {
     Language_Loader::load('default');
     $plugins =& MAX_Plugin::getPlugins('geotargeting');
     $modes['none'] = $GLOBALS['strNone'];
     $pluginModes = MAX_Plugin::callOnPlugins($plugins, 'getModuleInfo');
     foreach ($pluginModes as $key => $pluginMode) {
         $modes[$key] = $pluginMode;
     }
     return $modes;
 }
예제 #4
0
 /**
  * The constructor method.
  *
  * Requires, includes and loads the the required files.
  *
  * @param string $optionType One of "settings", "preferences" or "user", depending
  *                           on if the options are to be displayed in the Settings,
  *                           Account Preferences or User Preferences section.
  */
 function OA_Admin_Option($optionType)
 {
     // Load the required language files
     Language_Loader::load('default');
     Language_Loader::load('settings');
     Language_Loader::load('settings-help');
     // Set the supplied Settings or Preferences information
     $this->_optionType = 'account-' . $optionType;
     // Setup template object
     $this->oTpl = new OA_Admin_Template('option.html');
 }
 /**
  * Login to OpenX without using the login form in the user interface and
  * receive a session ID.
  *
  * @access private
  *
  * @param string $username
  * @param string $password
  *
  * @return boolean
  */
 function _internalLogin($username, $password)
 {
     // Require the default language file.
     include_once MAX_PATH . '/lib/max/language/Loader.php';
     // Load the required language file.
     Language_Loader::load('default');
     $oPlugin = OA_Auth::staticGetAuthPlugin();
     $doUser = $oPlugin->checkPassword($username, $password);
     if ($doUser) {
         phpAds_SessionDataRegister(OA_Auth::getSessionData($doUser));
         return true;
     } else {
         return false;
     }
 }
예제 #6
0
function phpAds_UserlogSelection($subSection, $mainSection = 'userlog')
{
    global $phpAds_TextDirection, $strBanners, $strCache, $strChooseSection, $strPriority, $strSourceEdit, $strStats, $strStorage, $strMaintenance, $strCheckForUpdates, $strViewPastUpdates;
    require_once MAX_PATH . '/lib/max/language/Loader.php';
    Language_Loader::load('settings');
    Language_Loader::load('default');
    Language_Loader::load('userlog');
    ?>
<script language="JavaScript">
<!--
function audit_goto_section()
{
    s = document.audit_selection.section.selectedIndex;

    s = document.audit_selection.section.options[s].value;
    document.location = '<?php 
    echo $mainSection;
    ?>
-' + s + '.php';
}
// -->
</script>
<?php 
    $conf =& $GLOBALS['_MAX']['CONF'];
    $pref =& $GLOBALS['_MAX']['PREF'];
    echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
    echo "<tr><form name='audit_selection'><td height='35'>";
    echo "<b>" . $strChooseSection . ":&nbsp;</b>";
    echo "<select name='section' onChange='audit_goto_section();'>";
    if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
        echo "<option value='index'" . ($subSection == 'index' ? ' selected' : '') . ">" . $GLOBALS['strAuditTrail'] . "</option>";
        echo "<option value='maintenance'" . ($subSection == 'maintenance' ? ' selected' : '') . ">" . $GLOBALS['strMaintenanceLog'] . "</option>";
    }
    echo "</select>&nbsp;<a href='javascript:void(0)' onClick='audit_goto_section();'>";
    echo "<img src='" . OX::assetPath() . "/images/" . $phpAds_TextDirection . "/go_blue.gif' border='0'></a>";
    echo "</td></form></tr>";
    echo "</table>";
    phpAds_ShowBreak();
}
 /**
  * Tests that an e-mail reporting on impending campaign expiration
  * is able to be generated correctly.
  */
 function testSendAndPrepareCampaignImpendingExpiryEmail()
 {
     $adminContact = 'Andrew Hill';
     $adminName = 'OpenX Limited';
     $adminMail = '*****@*****.**';
     $adminCompany = 'Admin company name';
     $adminAccountId = 100;
     $agencyName = 'Agency Ltd.';
     $agencyContact = 'Mr. Foo Bar Agency';
     $agencyMail = '*****@*****.**';
     $advertiserName = 'Foo Client';
     $advertiserMail = '*****@*****.**';
     $advertiserUsername = '******';
     $aConf =& $GLOBALS['_MAX']['CONF'];
     $aConf['webpath']['admin'] = 'example.com';
     $aConf['email']['fromAddress'] = $adminMail;
     $aConf['email']['fromName'] = $adminName;
     $aConf['email']['fromCompany'] = $adminCompany;
     $aConf['email']['useManagerDetails'] = true;
     $aConf['email']['logOutgoing'] = true;
     $mockName = uniqid('PartialMockOA_Email_');
     Mock::generatePartial('OA_Email', $mockName, array('sendMail'));
     $oEmail = new $mockName();
     $oEmail->setReturnValue('sendMail', true);
     // Prepare valid test data
     $dateReason = 'date';
     $dateValue = '2007-05-15';
     $impReason = 'impressions';
     $impValue = 100;
     // The tests below assume that the number of days before a campaign expires when the
     $oCampaignDate = new Date($dateValue);
     $oCampaignDate->setHour(23);
     $oCampaignDate->setMinute(59);
     $oCampaignDate->setSecond(59);
     $oCampaignDate->toUTC();
     $oTwoDaysPriorDate = new Date($dateValue);
     $oTwoDaysPriorDate->subtractSeconds(2 * 24 * 60 * 60 - 10);
     $oNowDate = new Date($dateValue);
     // Prepare an admin user
     // Create the admin account
     $doAccounts = OA_Dal::factoryDO('accounts');
     $doAccounts->account_name = 'System Administrator';
     $doAccounts->account_type = OA_ACCOUNT_ADMIN;
     $adminAccountId = DataGenerator::generateOne($doAccounts);
     // Setup the admin account id
     $doAppVar = OA_Dal::factoryDO('application_variable');
     $doAppVar->name = 'admin_account_id';
     $doAppVar->value = $adminAccountId;
     // Create an user
     $doAdminUser = OA_Dal::factoryDO('users');
     $doAdminUser->contact_name = $adminContact;
     $doAdminUser->email_address = $adminMail;
     $doAdminUser->username = $adminName;
     $doAdminUser->password = md5('password');
     $doAdminUser->language = 'en';
     $doAdminUser->default_account_id = $adminAccountId;
     $adminUserId = DataGenerator::generateOne($doAdminUser);
     $doAdminUser = OA_Dal::staticGetDO('users', $adminUserId);
     $aAdminUser = $doAdminUser->toArray();
     // Create admin account-user association
     $doAUA = OA_Dal::factoryDO('account_user_assoc');
     $doAUA->account_id = $adminAccountId;
     $doAUA->user_id = $adminUserId;
     $doAUA->insert();
     // Prepare an agency
     $doAgency = OA_Dal::factoryDO('agency');
     $doAgency->name = $agencyName;
     $doAgency->contact = $agencyContact;
     $doAgency->email = $agencyMail;
     $agencyId = DataGenerator::generateOne($doAgency);
     $doAgency = OA_Dal::staticGetDO('agency', $agencyId);
     //get('agencyid', $agencyId);
     $agencyAccountId = $doAgency->account_id;
     // Prepare an agency user
     $doUser = OA_Dal::factoryDO('users');
     $doUser->contact_name = $agencyContact;
     $doUser->email_address = $agencyMail;
     $doUser->username = $agencyName;
     $doUser->language = 'en';
     $agencyUserId = DataGenerator::generateOne($doUser);
     $doAgencyUser = OA_Dal::staticGetDO('users', $agencyUserId);
     $aAgencyUser = $doAgencyUser->toArray();
     $oUserAccess = new OA_Admin_UI_UserAccess();
     // Agency user
     $oUserAccess->linkUserToAccount($agencyUserId, $doAgency->account_id, array(), array());
     // Generate an advertiser owned by the agency with no email adddress,
     // but no placements, and ensure false is returned
     $doClients = OA_Dal::factoryDO('clients');
     $doClients->agencyid = $agencyId;
     $doClients->clientname = $advertiserName;
     $doClients->email = '';
     $advertiserId1 = DataGenerator::generateOne($doClients);
     $doClients = OA_Dal::staticGetDO('clients', 'clientid', $advertiserId1);
     // ->get('clientid', $advertiserId1);
     $advertiserAccountId = $doClients->account_id;
     // Create an advertiser user
     $doUser = OA_Dal::factoryDO('users');
     $doUser->contact_name = $advertiserName;
     $doUser->email_address = $advertiserMail;
     $doUser->username = $advertiserUsername;
     $doUser->language = 'en';
     $userId = DataGenerator::generateOne($doUser);
     $doAdvertiserUser = OA_Dal::staticGetDO('users', $userId);
     $aAdvertiserUser = $doAdvertiserUser->toArray();
     // Link the advertiser user
     $oUserAccess->linkUserToAccount($userId, $doClients->account_id, array(), array());
     // Create a campaign
     $doPlacements = OA_Dal::factoryDO('campaigns');
     $doPlacements->clientid = $advertiserId1;
     $doPlacements->campaignname = 'Default Campaign';
     $doPlacements->views = 50;
     $doPlacements->expire_time = $oCampaignDate->getDate(DATE_FORMAT_ISO);
     $placementId = DataGenerator::generateOne($doPlacements);
     $doPlacements = OA_Dal::staticGetDO('campaigns', $placementId);
     $aCampaign = $doPlacements->toArray();
     $result = $oEmail->sendCampaignImpendingExpiryEmail($oNowDate, $placementId);
     // No emails should be sent yet because the preferences weren't set
     $this->assertEqual($result, 0);
     // No entries in userlog
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->find();
     $this->assertFalse($doUserLog->fetch());
     // Create the preference
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'warn_email_admin';
     $doPreferences->account_type = OA_ACCOUNT_ADMIN;
     $warnEmailAdminPreferenceId = DataGenerator::generateOne($doPreferences);
     // Set the admin preference
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $adminAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailAdminPreferenceId;
     $doAccount_Preference_Assoc->value = 1;
     DataGenerator::generateOne($doAccount_Preference_Assoc);
     // Create the admin threshold preference
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'warn_email_admin_impression_limit';
     $doPreferences->account_type = OA_ACCOUNT_ADMIN;
     $warnEmailAdminImpLimitPreferenceId = DataGenerator::generateOne($doPreferences);
     // Set the admin preference
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $adminAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailAdminImpLimitPreferenceId;
     $doAccount_Preference_Assoc->value = 100;
     DataGenerator::generateOne($doAccount_Preference_Assoc);
     // Create the admin day warning
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'warn_email_admin_day_limit';
     $doPreferences->account_type = OA_ACCOUNT_ADMIN;
     $warnEmailAdminDayLimitPreferenceId = DataGenerator::generateOne($doPreferences);
     // Set the admin preference
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $adminAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailAdminDayLimitPreferenceId;
     $doAccount_Preference_Assoc->value = 2;
     DataGenerator::generateOne($doAccount_Preference_Assoc);
     // Set the agency preferences
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'warn_email_manager';
     $doPreferences->account_type = OA_ACCOUNT_MANAGER;
     $warnEmailManagerPreferenceId = DataGenerator::generateOne($doPreferences);
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $agencyAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailManagerPreferenceId;
     $doAccount_Preference_Assoc->value = 0;
     DataGenerator::generateOne($doAccount_Preference_Assoc);
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'warn_email_manager_impression_limit';
     $doPreferences->account_type = OA_ACCOUNT_MANAGER;
     $warnEmailManagerImpLimitPreferenceId = DataGenerator::generateOne($doPreferences);
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $agencyAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailManagerImpLimitPreferenceId;
     $doAccount_Preference_Assoc->value = 100;
     DataGenerator::generateOne($doAccount_Preference_Assoc);
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'warn_email_manager_day_limit';
     $doPreferences->account_type = OA_ACCOUNT_MANAGER;
     $warnEmailManagerDayLimitPreferenceId = DataGenerator::generateOne($doPreferences);
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $agencyAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailManagerDayLimitPreferenceId;
     $doAccount_Preference_Assoc->value = 2;
     DataGenerator::generateOne($doAccount_Preference_Assoc);
     // Set the advertiser preferences
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'warn_email_advertiser';
     $doPreferences->account_type = OA_ACCOUNT_ADVERTISER;
     $warnEmailAdvertiserPreferenceId = DataGenerator::generateOne($doPreferences);
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $advertiserAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailAdvertiserPreferenceId;
     $doAccount_Preference_Assoc->value = 0;
     DataGenerator::generateOne($doAccount_Preference_Assoc);
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'warn_email_advertiser_impression_limit';
     $doPreferences->account_type = OA_ACCOUNT_ADVERTISER;
     $warnEmailAdvertiserImpLimitPreferenceId = DataGenerator::generateOne($doPreferences);
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $advertiserAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailAdvertiserImpLimitPreferenceId;
     $doAccount_Preference_Assoc->value = 100;
     DataGenerator::generateOne($doAccount_Preference_Assoc);
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'warn_email_advertiser_day_limit';
     $doPreferences->account_type = OA_ACCOUNT_ADVERTISER;
     $warnEmailAdvertiserDayLimitPreferenceId = DataGenerator::generateOne($doPreferences);
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $advertiserAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailAdvertiserDayLimitPreferenceId;
     $doAccount_Preference_Assoc->value = 2;
     DataGenerator::generateOne($doAccount_Preference_Assoc);
     // Create another user linked to the advertiser account and ensure that an additional email is sent
     $doUser = OA_Dal::factoryDO('users');
     $doUser->contact_name = '2_' . $advertiserName;
     $doUser->email_address = '2_' . $advertiserMail;
     $doUser->username = '******' . $clientName;
     $doUser->language = 'de';
     $advertiserUserId2 = DataGenerator::generateOne($doUser);
     $doAdvertiserUser2 = OA_Dal::staticGetDO('users', $advertiserUserId2);
     $aAdvertiserUser2 = $doAdvertiserUser2->toArray();
     // Link the advertiser user
     $oUserAccess->linkUserToAccount($advertiserUserId2, $doClients->account_id, array(), array());
     // If the advertiser preference is off, then the advertiser should not be sent emails
     // even if the admin/manager preference is on
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $advertiserAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailAdvertiserPreferenceId;
     $doAccount_Preference_Assoc->value = 0;
     $doAccount_Preference_Assoc->update();
     // And turning off the manager preference should leave just agency emails (2)
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $agencyAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailManagerPreferenceId;
     $doAccount_Preference_Assoc->value = 0;
     $doAccount_Preference_Assoc->update();
     // -- The above sets up the environment for the tests below -- //
     // Check the body when passing in the admin user:
     $expectedSubject = "Impending campaign expiration: {$advertiserName}";
     $expectedContents = "Dear {$adminContact},\n\n";
     $expectedContents .= "The campaign belonging to {$advertiserName} shown below is due to end on {$dateValue}.\n\n";
     $expectedContents .= "As a result, the campaign will soon be automatically disabled, and the\n";
     $expectedContents .= "following banners in the campaign will also be disabled:\n";
     $expectedContents .= "\nCampaign [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " There are currently no banners defined for this campaign.\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     $expectedContents .= "Regards,\n   {$adminName}, {$adminCompany}";
     // Clear cache
     $oEmail->clearCache();
     Language_Loader::load('default', $aAdminUser['language']);
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAdminUser, $advertiserId1, $placementId, $dateReason, $dateValue, 'admin');
     $this->assertEqual($numSent, 1);
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     // One entry in userlog
     $doUserLog = OA_Dal::factoryDO('userlog');
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 1);
     $this->assertEqual($aUserLog[0]['action'], phpAds_actionWarningMailed);
     // Turn off email logging and send mail again
     $aConf['email']['logOutgoing'] = false;
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $this->assertEqual($numSent, 1);
     // Still one entry in userlog
     $doUserLog = OA_Dal::factoryDO('userlog');
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 1);
     // Set email logging back to true
     $aConf['email']['logOutgoing'] = true;
     // Manager user
     $expectedSubject = "Impending campaign expiration: {$advertiserName}";
     $expectedContents = "Dear {$aAgencyUser['contact_name']},\n\n";
     $expectedContents .= "The campaign belonging to {$advertiserName} shown below is due to end on {$dateValue}.\n\n";
     $expectedContents .= "As a result, the campaign will soon be automatically disabled, and the\n";
     $expectedContents .= "following banners in the campaign will also be disabled:\n";
     $expectedContents .= "\nCampaign [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " There are currently no banners defined for this campaign.\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     $expectedContents .= "Regards,\n   " . $aConf['email']['fromName'] . ", " . $aConf['email']['fromCompany'];
     Language_Loader::load('default', $aAgencyUser['language']);
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAgencyUser, $advertiserId1, $placementId, $dateReason, $dateValue, 'manager');
     $this->assertEqual($numSent, 1);
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     // Should create another entry in userlog
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->action = phpAds_actionWarningMailed;
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 2);
     // Use email from details instead of the owning account's details
     $aConf['email']['useManagerDetails'] = false;
     // Manager user
     $expectedSubject = "Impending campaign expiration: {$advertiserName}";
     $expectedContents = "Dear {$aAgencyUser['contact_name']},\n\n";
     $expectedContents .= "The campaign belonging to {$advertiserName} shown below is due to end on {$dateValue}.\n\n";
     $expectedContents .= "As a result, the campaign will soon be automatically disabled, and the\n";
     $expectedContents .= "following banners in the campaign will also be disabled:\n";
     $expectedContents .= "\nCampaign [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " There are currently no banners defined for this campaign.\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     $expectedContents .= "Regards,\n   " . $aConf['email']['fromName'] . ", " . $aConf['email']['fromCompany'];
     Language_Loader::load('default', $aAgencyUser['language']);
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAgencyUser, $advertiserId1, $placementId, $dateReason, $dateValue, 'manager');
     $this->assertEqual($numSent, 1);
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     // Use email from empty details and test that not Regards are added
     $aConf['email']['fromAddress'] = '';
     $aConf['email']['fromName'] = '';
     $aConf['email']['fromCompany'] = '';
     // Manager user
     $expectedSubject = "Impending campaign expiration: {$advertiserName}";
     $expectedContents = "Dear {$aAgencyUser['contact_name']},\n\n";
     $expectedContents .= "The campaign belonging to {$advertiserName} shown below is due to end on {$dateValue}.\n\n";
     $expectedContents .= "As a result, the campaign will soon be automatically disabled, and the\n";
     $expectedContents .= "following banners in the campaign will also be disabled:\n";
     $expectedContents .= "\nCampaign [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " There are currently no banners defined for this campaign.\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     Language_Loader::load('default', $aAgencyUser['language']);
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAgencyUser, $advertiserId1, $placementId, $dateReason, $dateValue, 'manager');
     $this->assertEqual($numSent, 1);
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     $aConf['email']['useManagerDetails'] = true;
     $aConf['email']['fromAddress'] = $adminMail;
     $aConf['email']['fromName'] = $adminName;
     $aConf['email']['fromCompany'] = $adminCompany;
     // Should create another entry in userlog
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->action = phpAds_actionWarningMailed;
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 4);
     // The following should never be sent because a campaign without banners should never deliver (and therefore never reach the "remaining" threshold)
     $expectedSubject = "Impending campaign expiration: {$advertiserName}";
     $expectedContents = "Dear {$aAdminUser['contact_name']},\n\n";
     $expectedContents .= "The campaign belonging to {$advertiserName} shown below has less than {$impValue} impressions remaining.\n\n";
     $expectedContents .= "As a result, the campaign will soon be automatically disabled, and the\n";
     $expectedContents .= "following banners in the campaign will also be disabled:\n";
     $expectedContents .= "\nCampaign [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " There are currently no banners defined for this campaign.\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     $expectedContents .= "Regards,\n   {$adminName}, {$adminCompany}";
     Language_Loader::load('default', $aAdminUser['language']);
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oNowDate, $placementId);
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAdminUser, $advertiserId1, $placementId, $impReason, $impValue, 'admin');
     $this->assertEqual($numSent, 0);
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     $expectedSubject = "Impending campaign expiration: {$advertiserName}";
     $expectedContents = "Dear {$aAgencyUser['contact_name']},\n\n";
     $expectedContents .= "The campaign belonging to {$advertiserName} shown below has less than {$impValue} impressions remaining.\n\n";
     $expectedContents .= "As a result, the campaign will soon be automatically disabled, and the\n";
     $expectedContents .= "following banners in the campaign will also be disabled:\n";
     $expectedContents .= "\nCampaign [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " There are currently no banners defined for this campaign.\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     $expectedContents .= "Regards,\n   " . $aConf['email']['fromName'] . ", " . $aConf['email']['fromCompany'];
     Language_Loader::load('default', $aAgencyUser['language']);
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oNowDate, $placementId);
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAgencyUser, $advertiserId1, $placementId, $impReason, $impValue, 'manager');
     $this->assertEqual($numSent, 0);
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     // Emails not sent, nothing new in userlog
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->action = phpAds_actionWarningMailed;
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 4);
     // Add some banners and retest
     $doBanners = OA_Dal::factoryDO('banners');
     $doBanners->campaignid = $placementId;
     $doBanners->description = 'Test Banner';
     $doBanners->url = '';
     $bannerId1 = DataGenerator::generateOne($doBanners);
     $doBanners = OA_Dal::factoryDO('banners');
     $doBanners->campaignid = $placementId;
     $doBanners->description = 'Test Banner';
     $doBanners->url = 'http://www.fornax.net/';
     $bannerId2 = DataGenerator::generateOne($doBanners);
     $expectedSubject = "Impending campaign expiration: {$advertiserName}";
     $expectedContents = "Dear {$aAdminUser['contact_name']},\n\n";
     $expectedContents .= "The campaign belonging to {$advertiserName} shown below is due to end on {$dateValue}.\n\n";
     $expectedContents .= "As a result, the campaign will soon be automatically disabled, and the\n";
     $expectedContents .= "following banners in the campaign will also be disabled:\n";
     $expectedContents .= "\nCampaign [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " Banner [id{$bannerId1}] Test Banner\n\n";
     $expectedContents .= " Banner [id{$bannerId2}] Test Banner\n";
     $expectedContents .= "  linked to: http://www.fornax.net/\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     $expectedContents .= "Regards,\n   {$adminName}, {$adminCompany}";
     Language_Loader::load('default', $aAdminUser['language']);
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAdminUser, $advertiserId1, $placementId1, $dateReason, $dateValue, 'admin');
     $this->assertEqual($numSent, 1);
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->action = phpAds_actionWarningMailed;
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 5);
     $expectedSubject = "Impending campaign expiration: {$advertiserName}";
     $expectedContents = "Dear {$aAdvertiserUser['contact_name']},\n\n";
     $expectedContents .= "Your campaign shown below is due to end on {$dateValue}.\n\n";
     $expectedContents .= "As a result, the campaign will soon be automatically disabled, and the\n";
     $expectedContents .= "following banners in the campaign will also be disabled:\n";
     $expectedContents .= "\nCampaign [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " Banner [id{$bannerId1}] Test Banner\n\n";
     $expectedContents .= " Banner [id{$bannerId2}] Test Banner\n";
     $expectedContents .= "  linked to: http://www.fornax.net/\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     $expectedContents .= "Regards,\n   {$agencyContact}, {$agencyName}";
     Language_Loader::load('default', $aAdvertiserUser['language']);
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAdvertiserUser, $advertiserId1, $placementId, $dateReason, $dateValue, 'advertiser');
     $this->assertEqual($numSent, 1);
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->action = phpAds_actionWarningMailed;
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 6);
     // Clear userlog table
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->whereAdd('1=1');
     $doUserLog->delete(DB_DATAOBJECT_WHEREADD_ONLY);
     // Enable the warn_email_advertiser preference and retest
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $advertiserAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailAdvertiserPreferenceId;
     $doAccount_Preference_Assoc->value = 1;
     $doAccount_Preference_Assoc->update();
     // Clear cache
     $oEmail->clearCache();
     // So should now send 1 admin and 2 advertiser emails
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $this->assertEqual($numSent, 3);
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->action = phpAds_actionWarningMailed;
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 3);
     $expectedSubject = "Impending campaign expiration: {$advertiserName}";
     $expectedContents = "Dear {$adminContact},\n\n";
     $expectedContents .= "The campaign belonging to {$advertiserName} shown below has less than {$impValue} impressions remaining.\n\n";
     $expectedContents .= "As a result, the campaign will soon be automatically disabled, and the\n";
     $expectedContents .= "following banners in the campaign will also be disabled:\n";
     $expectedContents .= "\nCampaign [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " Banner [id{$bannerId1}] Test Banner\n\n";
     $expectedContents .= " Banner [id{$bannerId2}] Test Banner\n";
     $expectedContents .= "  linked to: http://www.fornax.net/\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     $expectedContents .= "Regards,\n   {$adminName}, {$adminCompany}";
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAdminUser, $advertiserId1, $placementId, $impReason, $impValue, 'admin');
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $this->assertEqual($numSent, 3);
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->action = phpAds_actionWarningMailed;
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 6);
     // Clear cache
     $oEmail->clearCache();
     // Enable the warn_email_manager preference and retest
     $doAccount_Preference_Assoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccount_Preference_Assoc->account_id = $agencyAccountId;
     $doAccount_Preference_Assoc->preference_id = $warnEmailManagerPreferenceId;
     $doAccount_Preference_Assoc->value = 1;
     $doAccount_Preference_Assoc->update();
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $this->assertEqual($numSent, 4);
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->action = phpAds_actionWarningMailed;
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 10);
     // Turn off email logging and send mail again
     $aConf['email']['logOutgoing'] = false;
     $numSent = $oEmail->sendCampaignImpendingExpiryEmail($oTwoDaysPriorDate, $placementId);
     $this->assertEqual($numSent, 4);
     // No new entries in user log
     $doUserLog = OA_Dal::factoryDO('userlog');
     $doUserLog->action = phpAds_actionWarningMailed;
     $aUserLog = $doUserLog->getAll();
     $this->assertEqual(count($aUserLog), 10);
     // Set email logging back to true
     $aConf['email']['logOutgoing'] = true;
     $expectedSubject = "Impending campaign expiration: {$advertiserName}";
     $expectedContents = "Dear {$aAdvertiserUser['contact_name']},\n\n";
     $expectedContents .= "Your campaign shown below has less than {$impValue} impressions remaining.\n\n";
     $expectedContents .= "As a result, the campaign will soon be automatically disabled, and the\n";
     $expectedContents .= "following banners in the campaign will also be disabled:\n";
     $expectedContents .= "\nCampaign [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " Banner [id{$bannerId1}] Test Banner\n\n";
     $expectedContents .= " Banner [id{$bannerId2}] Test Banner\n";
     $expectedContents .= "  linked to: http://www.fornax.net/\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     $expectedContents .= "Regards,\n   {$agencyContact}, {$agencyName}";
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAdvertiserUser, $advertiserId1, $placementId, $impReason, $impValue, 'advertiser');
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     // Check that advertiser2's email is send in their desired language (german)
     $expectedSubject = "Bevorstehende Deaktivierung der Kampagne: {$advertiserName}";
     $expectedContents = "Sehr geehrte(r) {$aAdvertiserUser2['contact_name']},\n\n";
     $expectedContents .= "Unten angegebene Ihre Kampagne hat weniger als {$impValue} Impressions übrig.\n\n";
     $expectedContents .= "Auf Grund dessen wird die Kampagne bald deaktiviert und weiter unten angegebene Banner aus dieser Kampagne werden deaktiviert:\n";
     $expectedContents .= "\nKampagne [id{$placementId}] Default Campaign\n";
     $expectedContents .= "http://{$aConf['webpath']['admin']}/stats.php?clientid={$advertiserId1}&campaignid={$placementId}&statsBreakdown=day&entity=campaign&breakdown=history&period_preset=all_stats&period_start=&period_end=\n";
     $expectedContents .= "-------------------------------------------------------\n\n";
     $expectedContents .= " Banner [id{$bannerId1}] Test Banner\n\n";
     $expectedContents .= " Banner [id{$bannerId2}] Test Banner\n";
     $expectedContents .= "  verknüpft mit: http://www.fornax.net/\n\n";
     $expectedContents .= "-------------------------------------------------------\n\n\n";
     $expectedContents .= "Mit freundlichem Gruß\n   {$agencyContact}, {$agencyName}";
     $aResult = $oEmail->prepareCampaignImpendingExpiryEmail($aAdvertiserUser2, $advertiserId1, $placementId, $impReason, $impValue, 'advertiser');
     $this->assertTrue(is_array($aResult));
     $this->assertEqual(count($aResult), 2);
     $this->assertEqual($aResult['subject'], $expectedSubject);
     $this->assertEqual(str_replace("\r", "", $aResult['contents']), str_replace("\r", "", $expectedContents));
     DataGenerator::cleanUp(array('accounts', 'account_user_assoc'));
 }
예제 #8
0
 /**
  * Returns an array of available timezones.
  *
  * @static
  * @param boolean $addBlank If set to true an empty entry will be added
  *                          to the beginning of the array.
  * @return array An array containing all the available timezones.
  */
 function availableTimezones($addBlank = false)
 {
     global $_DATE_TIMEZONE_DATA;
     $_aTimezoneBcData = array('Brazil/Acre', 'Brazil/DeNoronha', 'Brazil/East', 'Brazil/West', 'Canada/Atlantic', 'Canada/Central', 'Canada/East-Saskatchewan', 'Canada/Eastern', 'Canada/Mountain', 'Canada/Newfoundland', 'Canada/Pacific', 'Canada/Saskatchewan', 'Canada/Yukon', 'CET', 'Chile/Continental', 'Chile/EasterIsland', 'CST6CDT', 'Cuba', 'EET', 'Egypt', 'Eire', 'EST', 'EST5EDT', 'Etc/GMT', 'Etc/GMT+0', 'Etc/GMT+1', 'Etc/GMT+10', 'Etc/GMT+11', 'Etc/GMT+12', 'Etc/GMT+2', 'Etc/GMT+3', 'Etc/GMT+4', 'Etc/GMT+5', 'Etc/GMT+6', 'Etc/GMT+7', 'Etc/GMT+8', 'Etc/GMT+9', 'Etc/GMT-0', 'Etc/GMT-1', 'Etc/GMT-10', 'Etc/GMT-11', 'Etc/GMT-12', 'Etc/GMT-13', 'Etc/GMT-14', 'Etc/GMT-2', 'Etc/GMT-3', 'Etc/GMT-4', 'Etc/GMT-5', 'Etc/GMT-6', 'Etc/GMT-7', 'Etc/GMT-8', 'Etc/GMT-9', 'Etc/GMT0', 'Etc/Greenwich', 'Etc/UCT', 'Etc/Universal', 'Etc/UTC', 'Etc/Zulu', 'Factory GB', 'GB-Eire', 'GMT', 'GMT+0', 'GMT-0', 'GMT0', 'Greenwich', 'Hongkong', 'HST', 'Iceland', 'Iran', 'Israel', 'Jamaica', 'Japan', 'Kwajalein', 'Libya', 'MET', 'Mexico/BajaNorte', 'Mexico/BajaSur', 'Mexico/General', 'MST', 'MST7MDT', 'Navajo', 'NZ', 'NZ-CHAT', 'Poland', 'Portugal', 'PRC', 'PST8PDT', 'ROC', 'ROK', 'Singapore', 'Turkey', 'UCT', 'Universal', 'US/Alaska', 'US/Aleutian', 'US/Arizona', 'US/Central', 'US/East-Indiana', 'US/Eastern', 'US/Hawaii', 'US/Indiana-Starke', 'US/Michigan', 'US/Mountain', 'US/Pacific', 'US/Pacific-New', 'US/Samoa', 'UTC', 'W-SU', 'WET', 'Zulu');
     // Load translations
     require_once MAX_PATH . '/lib/max/language/Loader.php';
     Language_Loader::load('timezone');
     // Load global array of timezones
     require_once MAX_PATH . '/lib/pear/Date/TimeZone.php';
     $aTimezoneKey = Date_TimeZone::getAvailableIDs();
     if (!defined('MAX_PATH')) {
         $tz = OX_Admin_Timezones::getTimezone();
     } else {
         $tz = $GLOBALS['_MAX']['PREF']['timezone'];
         if (is_null($tz)) {
             $tz = OX_Admin_Timezones::getTimezone();
         }
     }
     foreach ($aTimezoneKey as $key) {
         if (in_array($tz, $_aTimezoneBcData) && $key == $tz || !in_array($key, $_aTimezoneBcData)) {
             // Calculate the timezone offset
             $offset = OX_Admin_Timezones::_convertOffset($_DATE_TIMEZONE_DATA[$key]['offset']);
             // Build the arrays used for sorting time zones
             $origOffset = $_DATE_TIMEZONE_DATA[$key]['offset'];
             $key = !empty($GLOBALS['strTimezoneList'][$key]) ? $GLOBALS['strTimezoneList'][$key] : $key;
             if ($origOffset >= 0) {
                 $aTimezone[$offset][$key] = "(GMT+{$offset}) {$key}";
             } else {
                 $aNegTimezone[$key] = "(GMT-{$offset}) {$key}";
             }
         }
     }
     // Sort timezones with positive offsets descending, and negative
     // offests ascending.
     // Add initial empty key/value pair
     if ($addBlank) {
         $aResult[] = '';
     }
     // Sort time zones
     asort($aNegTimezone);
     // Reverse array element order while preserving alphabetical order
     $hasRun = false;
     foreach ($aTimezone as $offset => $aValue) {
         if ($hasRun == false) {
             $aRevTimezone[] = $aValue;
             $hasRun = true;
         } else {
             array_unshift($aRevTimezone, $aValue);
         }
     }
     // Build the result array
     foreach ($aRevTimezone as $aValue) {
         foreach ($aValue as $k => $v) {
             $aResult[$k] = $v;
         }
     }
     foreach ($aNegTimezone as $key => $value) {
         $aResult[$key] = $value;
     }
     return $aResult;
 }
예제 #9
0
| along with this program; if not, write to the Free Software               |
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA |
+---------------------------------------------------------------------------+
$Id: Invocation.php 37157 2009-05-28 12:31:10Z andrew.hill $
*/
require_once MAX_PATH . '/lib/OA.php';
require_once MAX_PATH . '/lib/max/Admin_DA.php';
if (!isset($GLOBALS['_MAX']['FILES']['/lib/max/Delivery/common.php'])) {
    require_once MAX_PATH . '/lib/max/Delivery/common.php';
}
require_once MAX_PATH . '/lib/max/language/Loader.php';
require_once MAX_PATH . '/lib/max/other/lib-io.inc.php';
require_once LIB_PATH . '/Plugin/Component.php';
require_once MAX_PATH . '/www/admin/lib-zones.inc.php';
// Load the required language files
Language_Loader::load('invocation');
/**
 * MAX_Admin_Invocation class is a common class for placingInvocationForm(s)
 * and generating invocation codes
 *
 */
class MAX_Admin_Invocation
{
    var $defaultOptionValues = array('thirdPartyServer' => 0, 'cacheBuster' => 1);
    function getAllowedVariables()
    {
        $aVariables = array('affiliateid', 'bannerid', 'clientid', 'campaignid', 'zoneid', 'codetype', 'submitbutton', 'bannerUrl', 'block', 'blockcampaign', 'cachebuster', 'charset', 'comments', 'delay', 'delay_type', 'domains_table', 'extra', 'frame_width', 'frame_height', 'height', 'hostlanguage', 'iframetracking', 'ilayer', 'layerstyle', 'left', 'location', 'menubar', 'noscript', 'parameters', 'popunder', 'raw', 'refresh', 'resizable', 'resize', 'scrollbars', 'source', 'status', 'target', 'template', 'thirdpartytrack', 'timeout', 'toolbars', 'top', 'transparent', 'uniqueid', 'website', 'what', 'width', 'withtext', 'xmlrpcproto', 'xmlrpctimeout');
        // Add any plugin-specific option values to the global array...
        if (isset($invocationTag->defaultOptionValues)) {
            foreach ($invocationTag->defaultOptionValues as $key => $default) {
                $aVariables[] = $key;
예제 #10
0
    require_once LIB_PATH . '/Admin/Redirect.php';
    OX_Admin_Redirect::redirect('advertiser-index.php');
}
// Setup oUpgrader
$oUpgrader = new OA_Upgrade();
@set_time_limit(600);
// required files for header & nav
require_once MAX_PATH . '/lib/max/Admin/Languages.php';
require_once MAX_PATH . '/lib/OA/Permission.php';
require_once MAX_PATH . '/www/admin/lib-gui.inc.php';
require_once MAX_PATH . '/lib/OA/Admin/Template.php';
require_once MAX_PATH . '/lib/OA/Admin/Option.php';
require_once MAX_PATH . '/lib/max/language/Loader.php';
require_once MAX_PATH . '/lib/OA/Upgrade/UpgradePluginImport.php';
//  load translations for installer
Language_Loader::load('installer');
$options = new OA_Admin_Option('settings');
// clear the $session variable to prevent users pretending to be logged in.
unset($session);
define('phpAds_installing', true);
// changed form name for javascript dependent fields
$GLOBALS['settings_formName'] = "frmOpenads";
$imgPath = OX::assetPath() . "/";
$installStatus = 'unknown';
/**
 * Return an array of supported DB types
 *
 * @return array
 */
function getSupportedDbTypes()
{
// Required files
require_once MAX_PATH . '/lib/OA/Dal.php';
require_once MAX_PATH . '/lib/max/language/Loader.php';
require_once MAX_PATH . '/www/admin/config.php';
require_once MAX_PATH . '/lib/max/other/lib-userlog.inc.php';
// Register input variables
phpAds_registerGlobal('start');
// Security check
OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN);
/*-------------------------------------------------------*/
/* HTML framework                                        */
/*-------------------------------------------------------*/
phpAds_PageHeader("userlog-index");
phpAds_UserlogSelection("maintenance");
// Load the required language files
Language_Loader::load('userlog');
/*-------------------------------------------------------*/
/* Main code                                             */
/*-------------------------------------------------------*/
$doUserLog = OA_Dal::factoryDO('userlog');
if (!($count = $doUserLog->count())) {
    $count = 0;
}
$limit = 10;
$start = isset($start) ? (int) $start : 0;
$doUserLog = OA_Dal::factoryDO('userlog');
$doUserLog->orderBy('timestamp DESC');
$doUserLog->limit($start * $limit, $limit);
$doUserLog->find();
echo "<br /><br />";
echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
예제 #12
0
/**
 * Starts or continue existing session
 *
 * @param unknown_type $checkRedirectFunc
 */
function OA_Start($checkRedirectFunc = null)
{
    $conf = $GLOBALS['_MAX']['CONF'];
    global $session;
    // XXX: Why not try loading session data when OpenX is not installed?
    //if ($conf['openads']['installed'])
    if (OA_INSTALLATION_STATUS == OA_INSTALLATION_STATUS_INSTALLED) {
        phpAds_SessionDataFetch();
    }
    if (!OA_Auth::isLoggedIn() || OA_Auth::suppliedCredentials()) {
        // Required files
        include_once MAX_PATH . '/lib/max/language/Loader.php';
        // Load the required language files
        Language_Loader::load('default');
        phpAds_SessionDataRegister(OA_Auth::login($checkRedirectFunc));
        $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterLogin');
        foreach ($aPlugins as $i => $id) {
            if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
                $obj->afterLogin();
            }
        }
    }
    // Overwrite certain preset preferences
    if (!empty($session['language']) && $session['language'] != $GLOBALS['pref']['language']) {
        $GLOBALS['_MAX']['CONF']['max']['language'] = $session['language'];
    }
    // Check if manual account switch has happened and migrate to new global variable
    if (isset($session['accountSwitch'])) {
        $GLOBALS['_OX']['accountSwtich'] = $session['accountSwitch'];
        unset($session['accountSwitch']);
        phpAds_SessionDataStore();
    }
}
예제 #13
0
|                                                                           |
| This program is distributed in the hope that it will be useful,           |
| but WITHOUT ANY WARRANTY; without even the implied warranty of            |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
| GNU General Public License for more details.                              |
|                                                                           |
| You should have received a copy of the GNU General Public License         |
| along with this program; if not, write to the Free Software               |
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA |
+---------------------------------------------------------------------------+
$Id: lib-maintenance.inc.php 37157 2009-05-28 12:31:10Z andrew.hill $
*/
// Required files
require_once MAX_PATH . '/lib/max/language/Loader.php';
// Load the required language files
Language_Loader::load('maintenance');
function phpAds_MaintenanceSelection($subSection, $mainSection = 'maintenance')
{
    global $phpAds_TextDirection, $strBanners, $strCache, $strChooseSection, $strPriority, $strSourceEdit, $strStats, $strStorage, $strMaintenance, $strCheckForUpdates, $strViewPastUpdates, $strEncoding, $strDeliveryLimitations, $strAppendCodes, $strMenus, $strPlugins;
    ?>
<script language="JavaScript">
<!--
function maintenance_goto_section()
{
    s = document.maintenance_selection.section.selectedIndex;

    s = document.maintenance_selection.section.options[s].value;
    document.location = '<?php 
    echo $mainSection;
    ?>
-' + s + '.php';
예제 #14
0
/**
 * Starts or continue existing session
 *
 * @param unknown_type $checkRedirectFunc
 */
function OA_Start($checkRedirectFunc = null)
{
    $conf = $GLOBALS['_MAX']['CONF'];
    global $session;
    // Send no cache headers
    MAX_header('Pragma: no-cache');
    MAX_header('Cache-Control: no-cache, no-store, must-revalidate');
    MAX_header('Expires: 0');
    if (RV_INSTALLATION_STATUS == RV_INSTALLATION_STATUS_INSTALLED) {
        phpAds_SessionDataFetch();
    }
    if (!OA_Auth::isLoggedIn() || OA_Auth::suppliedCredentials()) {
        // Required files
        include_once MAX_PATH . '/lib/max/language/Loader.php';
        // Load the required language files
        Language_Loader::load('default');
        phpAds_SessionDataRegister(OA_Auth::login($checkRedirectFunc));
        $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterLogin');
        foreach ($aPlugins as $i => $id) {
            if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
                $obj->afterLogin();
            }
        }
    }
    // Overwrite certain preset preferences
    if (!empty($session['language']) && $session['language'] != $GLOBALS['pref']['language']) {
        $GLOBALS['_MAX']['CONF']['max']['language'] = $session['language'];
    }
    // Check if manual account switch has happened and migrate to new global variable
    if (isset($session['accountSwitch'])) {
        $GLOBALS['_OX']['accountSwtich'] = $session['accountSwitch'];
        unset($session['accountSwitch']);
        phpAds_SessionDataStore();
    }
}
예제 #15
0
 /**
  * Post init session
  *
  */
 function postInitSession()
 {
     global $session, $pref;
     global $affiliateid, $agencyid, $bannerid, $campaignid, $channelid;
     global $clientid, $day, $trackerid, $userlogid, $zoneid;
     // Overwrite certain preset preferences
     if (!empty($session['language']) && $session['language'] != $GLOBALS['pref']['language']) {
         $GLOBALS['_MAX']['CONF']['max']['language'] = $session['language'];
     }
     // Load the user preferences from the database
     OA_Preferences::loadPreferences();
     // 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 = '';
     }
     if (!isset($agencyid)) {
         $agencyid = OA_Permission::getAgencyId();
     }
     if (!isset($bannerid)) {
         $bannerid = '';
     }
     if (!isset($campaignid)) {
         $campaignid = '';
     }
     if (!isset($channelid)) {
         $channelid = '';
     }
     if (!isset($clientid)) {
         $clientid = '';
     }
     if (!isset($day)) {
         $day = '';
     }
     if (!isset($trackerid)) {
         $trackerid = '';
     }
     if (!isset($userlogid)) {
         $userlogid = '';
     }
     if (!isset($zoneid)) {
         $zoneid = '';
     }
 }
예제 #16
0
 /**
  * A method for preparing an advertiser's "campaign activated" or
  * "campaign deactivated" report.
  *
  * @param string  $campaignId The ID of the activated campaign.
  * @param integer $reason      An optional binary flag field containting the
  *                             representation of the reason(s) the campaign
  *                             was deactivated:
  *                                   2  - No more impressions
  *                                   4  - No more clicks
  *                                   8  - No more conversions
  *                                   16 - Campaign ended (due to date)
  * @return boolean|array False, if the report could not be created, otherwise
  *                       an array of four elements:
  *                          'subject'   => The email subject line.
  *                          'contents'  => The body of the email report.
  *                          'userEmail' => The email address to send the report to.
  *                          'userName'  => The real name of the email address, or null.
  */
 function prepareCampaignActivatedDeactivatedEmail($aUser, $campaignId, $reason = null)
 {
     Language_Loader::load('default', $aUser['language']);
     if (is_null($reason)) {
         OA::debug('   - Preparing "campaign activated" email for campaign ID ' . $campaignId . '.', PEAR_LOG_DEBUG);
     } else {
         OA::debug('   - Preparing "campaign deactivated" email for campaign ID ' . $campaignId . '.', PEAR_LOG_DEBUG);
     }
     // Load the required strings
     global $strMailHeader, $strSirMadam, $strMailBannerActivatedSubject, $strMailBannerDeactivatedSubject, $strMailBannerActivated, $strMailBannerDeactivated, $strNoMoreImpressions, $strNoMoreClicks, $strNoMoreConversions, $strAfterExpire;
     // Fetch the campaign
     $aCampaign = $this->_loadCampaign($campaignId);
     if ($aCampaign === false) {
         return false;
     }
     // Fetch the campaign's owning advertiser
     $aAdvertiser = $this->_loadAdvertiser($aCampaign['clientid']);
     if ($aAdvertiser === false) {
         return false;
     }
     // Prepare the email body
     $emailBody = $this->_prepareCampaignActivatedDeactivatedEmailBody($aCampaign);
     // Prepare the final email - add the greeting to the advertiser
     $email = "{$strMailHeader}\n";
     if (!empty($aUser['contact_name'])) {
         $greetingTo = $aUser['contact_name'];
     } else {
         if (!empty($aAdvertiser['contact'])) {
             $greetingTo = $aAdvertiser['contact'];
         } else {
             if (!empty($aAdvertiser['clientname'])) {
                 $greetingTo = $aAdvertiser['clientname'];
             } else {
                 $greetingTo = $strSirMadam;
             }
         }
     }
     $email = str_replace("{contact}", $greetingTo, $email);
     // Prepare the final email - add the report type description
     // and the name of the advertiser the report is about
     if (is_null($reason)) {
         $email .= "{$strMailBannerActivated}\n";
     } else {
         $email .= "{$strMailBannerDeactivated}:";
         if ($reason & OX_CAMPAIGN_DISABLED_IMPRESSIONS) {
             $email .= "\n  - " . $strNoMoreImpressions;
         }
         if ($reason & OX_CAMPAIGN_DISABLED_CLICKS) {
             $email .= "\n  - " . $strNoMoreClicks;
         }
         if ($reason & OX_CAMPAIGN_DISABLED_CONVERSIONS) {
             $email .= "\n  - " . $strNoMoreConversions;
         }
         if ($reason & OX_CAMPAIGN_DISABLED_DATE) {
             $email .= "\n  - " . $strAfterExpire;
         }
         $email .= ".\n";
     }
     // Prepare the final email - add the report body
     $email .= "{$emailBody}\n";
     // Prepare the final email - add the "regards" signature
     $email .= $this->_prepareRegards($aAdvertiser['agencyid']);
     // Prepare & return the final email array
     if (is_null($reason)) {
         $aResult['subject'] = $strMailBannerActivatedSubject . ': ' . $aAdvertiser['clientname'];
     } else {
         $aResult['subject'] = $strMailBannerDeactivatedSubject . ': ' . $aAdvertiser['clientname'];
     }
     $aResult['contents'] = $email;
     return $aResult;
 }
/*
+---------------------------------------------------------------------------+
| Revive Adserver                                                           |
| http://www.revive-adserver.com                                            |
|                                                                           |
| Copyright: See the COPYRIGHT.txt file.                                    |
| License: GPLv2 or later, see the LICENSE.txt file.                        |
+---------------------------------------------------------------------------+
*/
require_once MAX_PATH . '/lib/max/Plugin/Translation.php';
require_once LIB_PATH . '/Plugin/Component.php';
require_once 'Date.php';
require_once MAX_PATH . '/lib/max/language/Loader.php';
require_once MAX_PATH . '/lib/pear/HTML/QuickForm/Rule/Email.php';
Language_Loader::load('settings');
/**
 * Plugins_Authentication is an parent class for Authentication plugins
 *
 * @package    OpenXPlugin
 * @subpackage Authentication
 */
class Plugins_Authentication extends OX_Component
{
    /**
     * Array to keep a reference to signup errors (if any)
     *
     * @var array
     */
    var $aSignupErrors = array();
    var $aValidationErrors = array();
| License: GPLv2 or later, see the LICENSE.txt file.                        |
+---------------------------------------------------------------------------+
*/
// This is a page that will allow a publisher to view a page with all their zones
if (empty($_GET['affiliateid']) || empty($_GET['codetype'])) {
    echo "Error: No data to display";
    exit;
}
// Require the initialisation file
require_once '../../init.php';
// Required files
require_once MAX_PATH . '/www/admin/config.php';
require_once MAX_PATH . '/lib/max/language/Loader.php';
require_once MAX_PATH . '/lib/max/other/lib-io.inc.php';
require_once MAX_PATH . '/lib/max/Admin/Invocation.php';
require_once MAX_PATH . '/www/admin/lib-zones.inc.php';
require_once MAX_PATH . '/www/admin/lib-gui.inc.php';
phpAds_registerGlobal('affiliateid', 'codetype');
OA_Permission::enforceAccount(OA_ACCOUNT_MANAGER, OA_ACCOUNT_TRAFFICKER);
OA_Permission::enforceAccessToObject('affiliates', $affiliateid);
if (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
    OA_Permission::enforceAllowed(OA_PERM_ZONE_INVOCATION);
}
/*-------------------------------------------------------*/
/* Store preferences									 */
/*-------------------------------------------------------*/
$session['prefs']['inventory_entities'][OA_Permission::getEntityId()]['affiliateid'] = $affiliateid;
phpAds_SessionDataStore();
Language_Loader::load('default');
$maxInvocation = new MAX_Admin_Invocation();
echo $maxInvocation->generateInvocationCode($invocationTag = null);
예제 #19
0
require_once MAX_PATH . '/www/admin/config.php';
require_once MAX_PATH . '/lib/OA/Admin/Reports/Generate.php';
global $session;
if (isset($_REQUEST['submit_type']) && $_REQUEST['submit_type'] == 'change') {
    // Store any values we need to pass to the next page
    switch ($_REQUEST['changed_field']) {
        case 'publisher':
            if (isset($_REQUEST['publisherId'])) {
                $session['prefs']['GLOBALS']['report_publisher'] = $_REQUEST['publisherId'];
                phpAds_SessionDataStore();
            }
        default:
            break;
    }
    echo "<script type='text/javascript'>window.location='" . $_REQUEST['refresh_page'] . "'</script>";
}
// If the report is for a "specific" period, store the period for later user
if (!is_null($_GET['period_preset']) && $_GET['period_preset'] == 'specific') {
    if (!is_null($_GET['period_start'])) {
        $session['prefs']['GLOBALS']['startDate'] = $_GET['period_start'] = date('Y-m-d', strtotime($_GET['period_start']));
    }
    if (!is_null($_GET['period_end'])) {
        $session['prefs']['GLOBALS']['endDate'] = $_GET['period_end'] = date('Y-m-d', strtotime($_GET['period_end']));
    }
}
// Load the required language files
Language_Loader::load('report');
// Register input variables
phpAds_registerGlobal('plugin');
$oModule = new OA_Admin_Reports_Generate();
$oModule->generate($plugin);
 function testLoad()
 {
     //prepare expected value
     include MAX_PATH . '/lib/max/language/en/default.lang.php';
     $aExpected['en']['default']['strHome'] = $GLOBALS['strHome'];
     include MAX_PATH . '/lib/max/language/pl/default.lang.php';
     $aExpected['pl']['default']['strHome'] = $GLOBALS['strHome'];
     include MAX_PATH . '/lib/max/language/ru/default.lang.php';
     $aExpected['ru']['default']['strHome'] = $GLOBALS['strHome'];
     include MAX_PATH . '/lib/max/language/ko/settings.lang.php';
     $aExpected['ko']['settings']['strInstall'] = $GLOBALS['strInstall'];
     include MAX_PATH . '/lib/max/language/en/settings.lang.php';
     $aExpected['en']['settings']['strInstall'] = $GLOBALS['strInstall'];
     include MAX_PATH . '/lib/max/language/de/settings.lang.php';
     $aExpected['de']['settings']['strInstall'] = $GLOBALS['strInstall'];
     include MAX_PATH . '/lib/max/language/pl/settings.lang.php';
     $aExpected['pl']['settings']['strInstall'] = $GLOBALS['strInstall'];
     unset($GLOBALS['strHome']);
     unset($GLOBALS['strInstall']);
     // Try to load file that not exist
     Language_Loader::load('notexist');
     $this->assertNull($GLOBALS['strHome']);
     // Test default load when empty $GLOBALS['_MAX']['CONF'] and  $GLOBALS['_MAX']['PREF']
     Language_Loader::load();
     $this->assertEqual($aExpected['en']['default']['strHome'], $GLOBALS['strHome']);
     // Test load language file by user pref settings
     $GLOBALS['_MAX']['PREF']['language'] = 'pl';
     Language_Loader::load();
     $this->assertEqual($aExpected['pl']['default']['strHome'], $GLOBALS['strHome']);
     // Test load language file by parameter (overwriting user pref settings)
     Language_Loader::load('default', 'ru');
     $this->assertEqual($aExpected['ru']['default']['strHome'], $GLOBALS['strHome']);
     // Test load 'en' again (detect problems with switching languages back)
     Language_Loader::load('default', 'en');
     $this->assertEqual($aExpected['en']['default']['strHome'], $GLOBALS['strHome']);
     // Test load language file by config settings when user language file not exist
     unset($GLOBALS['strHome']);
     unset($GLOBALS['strInstall']);
     $GLOBALS['_MAX']['PREF']['language'] = 'xyz';
     $GLOBALS['_MAX']['CONF']['max']['language'] = 'ko';
     Language_Loader::load('settings');
     $this->assertEqual($aExpected['ko']['settings']['strInstall'], $GLOBALS['strInstall']);
     // Test that language is loaded based on user preferences
     unset($GLOBALS['strInstall']);
     $GLOBALS['_MAX']['PREF']['language'] = 'de';
     $GLOBALS['_MAX']['CONF']['max']['language'] = 'polish';
     Language_Loader::load('settings');
     $this->assertEqual($aExpected['de']['settings']['strInstall'], $GLOBALS['strInstall']);
     // Test that language is loaded based on config file and laguage name is long (like in 2.4)
     unset($GLOBALS['strInstall']);
     unset($GLOBALS['_MAX']['PREF']['language']);
     $GLOBALS['_MAX']['CONF']['max']['language'] = 'polish';
     Language_Loader::load('settings');
     $this->assertEqual($aExpected['pl']['settings']['strInstall'], $GLOBALS['strInstall']);
     // Test load language by PREF setting, CONF should be ignored
     $GLOBALS['_MAX']['PREF']['language'] = 'de';
     Language_Loader::load('settings');
     $this->assertEqual($aExpected['de']['settings']['strInstall'], $GLOBALS['strInstall']);
     // Test load language by parameter, PREF and CONF setting should be ignored
     Language_Loader::load('settings', 'en');
     $this->assertEqual($aExpected['en']['settings']['strInstall'], $GLOBALS['strInstall']);
 }