/** * A method to generate a lock id. * * @access protected * * @param string The lock name. * @return string The lock id. */ function _getId($sName) { $platformHash = OA_Dal_ApplicationVariables::get('platform_hash'); // PostgreSQL needs two int4, we generate them using crc32 $sId = array(crc32($platformHash) & 0x7fffffff, crc32($sName) & 0x7fffffff); return serialize($sId); }
/** * Try to get platform hash. * If it's upgrade it try to read database (searches old config/preference tables) * If this fails it returns 'OXP_upgrade-unknown_platform_hash' * If it's fresh install then it checks if there is already generated * platformHash by previous call of this method, or use suggested one, or generate new one. * New platform hash is stored as already generated. * * @param string $suggestedPlatformHash * @param boolean $forceCheck should check be done once again (or we can use cached results) * @return string platform Hash */ public function getPlatformHash($suggestedPlatformHash = null, $forceCheck = false) { if (!$forceCheck && isset(self::$foundPlatformHash)) { return self::$foundPlatformHash; } // is it upgrade? $oUpgrader = new OA_Upgrade(); if (!$oUpgrader->isFreshInstall()) { // YES: // prepare database connection data $oUpgrader->canUpgradeOrInstall(); $oUpgrader->initDatabaseConnection(); // try read platform hash from database (3 possible locations) $platformHash = $this->readPlatformHashFromDatabase(); // if can't find platformHash - set 'OXP_upgrade-unknown_platform_hash' $platformHash = $platformHash ? $platformHash : self::$UNKNOWN_PLATFORM_HASH; } else { // NO: // is already set generatedPlatformHash if (isset(self::$generatedPlatformHash)) { $platformHash = self::$generatedPlatformHash; } else { // use sugested or generate new one (and remember) if (isset($suggestedPlatformHash)) { $platformHash = $suggestedPlatformHash; } else { $platformHash = OA_Dal_ApplicationVariables::generatePlatformHash(); } // remember genereted platform hash self::$generatedPlatformHash = $platformHash; } } self::$foundPlatformHash = $platformHash; return $platformHash; }
/** * 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() { // Special case - return the admin account ID only, // as changes to the types of preferences in the // system need only be viewed by the admin $aAccountIds = array(OA_ACCOUNT_ADMIN => OA_Dal_ApplicationVariables::get('admin_account_id')); return $aAccountIds; }
function getPluginVersion() { $version = OA_Dal_ApplicationVariables::get('apStatsGraphsUI_version'); if (class_exists('RV_Sync') || @(include MAX_PATH . '/lib/RV/Sync.php')) { return RV_Sync::getConfigVersion($version); } require_once MAX_PATH . '/lib/OA/Sync.php'; return OA_Sync::getConfigVersion($version); }
/** * A helper method to set applicationvariables * * @param Date $oScheduledDate * @param Date $oDate */ function setVariables($oScheduledDate, $oDate) { if (isset($oScheduledDate)) { OA_Dal_ApplicationVariables::set('maintenance_cron_timestamp', $oScheduledDate->getDate(DATE_FORMAT_UNIXTIME)); } else { OA_Dal_ApplicationVariables::delete('maintenance_cron_timestamp'); } if (isset($oDate)) { OA_Dal_ApplicationVariables::set('maintenance_timestamp', $oDate->getDate(DATE_FORMAT_UNIXTIME)); } else { OA_Dal_ApplicationVariables::delete('maintenance_timestamp'); } }
function autoLogin() { $oPlugin =& OA_Auth::staticGetAuthPlugin(); phpAds_SessionStart(); // No auto-login if auth is external if (empty($oPlugin) || get_class($oPlugin) != 'Plugins_Authentication') { phpAds_SessionDataDestroy(); return; } $adminAccountId = OA_Dal_ApplicationVariables::get('admin_account_id'); if (isset($adminAccountId)) { // Fetch the user linked to the admin account $doUser = OA_Dal::factoryDO('users'); $doAUA = OA_Dal::factoryDO('account_user_assoc'); $doAUA->account_id = $adminAccountId; $doUser->joinAdd($doAUA); $doUser->find(); if ($doUser->fetch()) { phpAds_SessionDataRegister(OA_Auth::getSessionData($doUser)); phpAds_SessionDataStore(); } } }
/** * A method to perform a call to the OAC XML-RPC server * * @param string $methodName The RPC method name * @param int $authType Type of required authentication, see constants * @param array $aParams Array of XML_RPC_Values * @return mixed The returned value or PEAR_Error on error */ function call($methodName, $authType, $aParams = null, $recursionLevel = 0) { $aPref = $GLOBALS['_MAX']['PREF']; $oMsg = new XML_RPC_Message('oac.' . $methodName); $oMsg->remove_extra_lines = $this->remove_extra_lines; $aHeader = array('protocolVersion' => OA_DAL_CENTRAL_PROTOCOL_VERSION, 'ph' => OA_Dal_ApplicationVariables::get('platform_hash')); if ($authType & OA_DAL_CENTRAL_AUTH_M2M) { if (empty($this->oCentral)) { MAX::raiseError('M2M authentication used with a non M2M-enabled OA_Central object'); } $aHeader['accountId'] = (int) $this->oCentral->accountId; $aHeader['m2mPassword'] = OA_Dal_Central_M2M::getM2MPassword($this->oCentral->accountId); if (empty($aHeader['m2mPassword']) || isset($GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId]) && $GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId] == true) { // No password stored, connect! $result = $this->oCentral->connectM2M(); if (PEAR::isError($result)) { return $result; } $aHeader['m2mPassword'] = $result; } } if ($authType & OA_DAL_CENTRAL_AUTH_SSO) { $aHeader['ssoUsername'] = $this->ssoUsername; $aHeader['ssoPassword'] = $this->ssoPassword; } if ($authType & OA_DAL_CENTRAL_AUTH_CAPTCHA) { $aHeader['ssoCaptcha'] = isset($_REQUEST['captcha-value']) ? $_REQUEST['captcha-value'] : ''; $aHeader['ssoCaptchaRandom'] = isset($_REQUEST['captcha-random']) ? $_REQUEST['captcha-random'] : ''; } $oMsg->addParam(XML_RPC_encode($aHeader)); if (is_array($aParams)) { foreach ($aParams as $oParam) { $oMsg->addParam($oParam); } } OA::disableErrorHandling(); $oResponse = $this->oXml->send($oMsg, OAC_RPC_TIMEOUT); OA::enableErrorHandling(); if (!$oResponse) { return new PEAR_Error('XML-RPC connection error', OA_CENTRAL_ERROR_XML_RPC_CONNECTION_ERROR); } if ($oResponse->faultCode() || $oResponse->faultString()) { // Deal with particular response codes at Rpc level, avoiding endless recursion if (!$recursionLevel) { switch ($oResponse->faultCode()) { case OA_CENTRAL_ERROR_PLATFORM_DOES_NOT_EXIST: OA::disableErrorHandling(); $oSync = new OA_Sync(); $oSync->checkForUpdates(); OA::enableErrorHandling(); return $this->call($methodName, $authType, $aParams, ++$recursionLevel); case OA_CENTRAL_ERROR_ERROR_NOT_AUTHORIZED: if (!($authType & OA_DAL_CENTRAL_AUTH_M2M)) { break; } else { // Go with OA_CENTRAL_ERROR_M2M_PASSWORD_INVALID } case OA_CENTRAL_ERROR_M2M_PASSWORD_INVALID: // OAP was asked to connect the account to get a password // Set clear the password and retry (old password is in DB in case of problems with receiving new one) $GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId] = true; return $this->call($methodName, $authType, $aParams, ++$recursionLevel, true); case OA_CENTRAL_ERROR_M2M_PASSWORD_EXPIRED: $result = $this->_reconnectM2M(); if (PEAR::isError($result)) { return $result; } return $this->call($methodName, $authType, $aParams, ++$recursionLevel); } } return new PEAR_Error($oResponse->faultString(), $oResponse->faultCode()); } $ret = XML_RPC_decode($oResponse->value()); // handling unknown server errors // this may happen due to difference in Java/PHP XML-RPC handling errors if (is_array($ret) && (isset($ret['faultCode']) || isset($ret['faultCode']))) { return new PEAR_Error('Unknown server error', OA_CENTRAL_ERROR_SERVER_ERROR); } return $ret; }
/** * Process input from user and creates/upgrades DB etc.... * * @param OA_Admin_UI_Component_Form $oForm * @param OX_Admin_UI_Install_Wizard $oWizard */ protected function processDatabaseAction($oForm, $oWizard) { $oUpgrader = $this->getUpgrader(); $upgraderSuccess = false; $aDbConfig = $oForm->populateDbConfig(); if ($oUpgrader->canUpgradeOrInstall()) { $installStatus = $oUpgrader->existing_installation_status; define('DISABLE_ALL_EMAILS', 1); OA_Permission::switchToSystemProcessUser('Installer'); if ($installStatus == OA_STATUS_NOT_INSTALLED) { if ($oUpgrader->install($aDbConfig)) { $message = $GLOBALS['strDBInstallSuccess']; $upgraderSuccess = true; } } else { if ($oUpgrader->upgrade($oUpgrader->package_file)) { // Timezone support - hack if ($oUpgrader->versionInitialSchema['tables_core'] < 538 && empty($aDbConfig['noTzAlert'])) { OA_Dal_ApplicationVariables::set('utc_update', OA::getNowUTC()); } // Clear the menu cache to built a new one with the new settings OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADMIN); OA_Admin_Menu::_clearCache(OA_ACCOUNT_MANAGER); OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADVERTISER); OA_Admin_Menu::_clearCache(OA_ACCOUNT_TRAFFICKER); OA_Admin_Menu::singleton(); $message = $GLOBALS['strDBUpgradeSuccess']; $upgraderSuccess = true; } } OA_Permission::switchToSystemProcessUser(); //get back to normal user previously logged in } else { if ($oUpgrader->existing_installation_status == OA_STATUS_CURRENT_VERSION) { $upgraderSuccess = true; //rare but can occur if DB has been installed and user revisits the screen } } $dbSuccess = $upgraderSuccess && !$oUpgrader->oLogger->errorExists; if ($dbSuccess) { //show success status OA_Admin_UI::getInstance()->queueMessage($message, 'global', 'info'); } else { //sth went wrong, display messages from upgrader $aMessages = OX_Admin_UI_Install_InstallUtils::getMessagesWithType($oUpgrader->getMessages()); $this->setModelProperty('aMessages', $aMessages); } return $dbSuccess; }
/** * A method to update maintenance last run information for * old maintenance code. */ function updateLastRun($bScheduled = false) { $sField = $bScheduled ? 'maintenance_cron_timestamp' : 'maintenance_timestamp'; OA_Dal_ApplicationVariables::set($sField, OA::getNow('U')); // Make sure that the maintenance delivery cache is regenerated MAX_cacheCheckIfMaintenanceShouldRun(false); }
/** * A method to return the ID of the manager account * that "owns" this advertiser account. * * @return integer The account ID of the "owning" * manager account. Returns the * admin account ID if no owning * manager account can be found. */ function getOwningManagerId() { $doAgency = OA_Dal::factoryDO('agency'); $doAgency->agencyid = $this->agencyid; $doAgency->find(); if ($doAgency->getRowCount() == 1) { $doAgency->fetch(); return $doAgency->account_id; } else { // Could not find the owning manager // account ID, return the ID of the // admin account instead return OA_Dal_ApplicationVariables::get('admin_account_id'); } }
/** * A private method to return the owning account IDs in a format suitable * for use by the DB_DataObjectCommon::getOwningAccountIds() method as a * return parameter, given the account ID of the account that is the owner * of the entity being audited. * * @access private * @param integer $accountId The account ID that "owns" the entity being * audited. * @return array An array with the same format as the return array of the * DB_DataObjectCommon::getOwningAccountIds() method. */ protected function _getOwningAccountIdsByAccountId($accountId) { // Get the type of the "owning" account $accountType = OA_Permission::getAccountTypeByAccountId($accountId); if ($accountType == OA_ACCOUNT_ADMIN) { // Simply return the admin account ID $aAccountIds = array(OA_ACCOUNT_ADMIN => $accountId); } else { if ($accountType == OA_ACCOUNT_MANAGER) { // Simply return the manager account ID $aAccountIds = array(OA_ACCOUNT_MANAGER => $accountId); } else { if ($accountType == OA_ACCOUNT_ADVERTISER) { // Set the owning manager account ID to the admin // account ID, in case something goes wrong $managerAccountId = OA_Dal_ApplicationVariables::get('admin_account_id'); // This is an advertiser account, so find the // "owning" manager account ID $doClients = OA_Dal::factoryDO('clients'); $doClients->account_id = $accountId; $doClients->find(); if ($doClients->getRowCount() == 1) { $doClients->fetch(); $managerAccountId = $doClients->getOwningManagerId(); } // Return the manager and advertiser account IDs $aAccountIds = array(OA_ACCOUNT_MANAGER => $managerAccountId, OA_ACCOUNT_ADVERTISER => $accountId); } else { if ($accountType == OA_ACCOUNT_TRAFFICKER) { // Set the owning manager account ID to the admin // account ID, in case something goes wrong $managerAccountId = OA_Dal_ApplicationVariables::get('admin_account_id'); // This is a trafficker account, so find the // "owning" manager account ID $doAffiliates = OA_Dal::factoryDO('affiliates'); $doAffiliates->account_id = $accountId; $doAffiliates->find(); if ($doAffiliates->getRowCount() == 1) { $doAffiliates->fetch(); $managerAccountId = $doAffiliates->getOwningManagerId(); } // Return the manager and trafficker account IDs $aAccountIds = array(OA_ACCOUNT_MANAGER => $managerAccountId, OA_ACCOUNT_TRAFFICKER => $accountId); } } } } return $aAccountIds; }
/** * 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. */ public function getOwningAccountIds($resetCache = false) { // Special case - return the admin account ID only. // This is because we can only store one account ID for each // type of account, however, it's possible for a user to be // linked to (for example) multiple accounts, which are in turn // owned by multiple manager accounts, so it's simply not possible // to record all possible manager account IDs; so, we restrict // auditing of user entities to be only visible to the admin // account $aAccountIds = array(OA_ACCOUNT_ADMIN => OA_Dal_ApplicationVariables::get('admin_account_id')); return $aAccountIds; }
/** * A private method to check if the returned stats may be inaccurate * becuase of an upgrade from a non TZ-enabled version * */ function _checkStatsAccuracy() { $utcUpdate = OA_Dal_ApplicationVariables::get('utc_update'); if (!empty($utcUpdate)) { $oUpdate = new Date($utcUpdate); $oUpdate->setTZbyID('UTC'); // Add 12 hours $oUpdate->addSeconds(3600 * 12); if (!empty($this->aDates['day_begin']) && !empty($this->aDates['day_end'])) { $startDate = new Date($this->aDates['day_begin']); $endDate = new Date($this->aDates['day_end']); if ($oUpdate->after($endDate) || $oUpdate->after($startDate)) { $this->displayInaccurateStatsWarning = true; } } else { // All statistics $this->displayInaccurateStatsWarning = true; } } }
/** * A private method to check if the current user is linked to the admin account * * @return bool True if the user is linked to the admin account */ function _isAdmin() { $doUsers = OA_Dal::factoryDO('users'); $doUsers->user_id = $this->aUser['user_id']; $doAUA = OA_Dal::factoryDO('account_user_assoc'); $doAUA->account_id = OA_Dal_ApplicationVariables::get('admin_account_id'); $doUsers->joinAdd($doAUA); return (bool) $doUsers->count(); }
/** * Connect to OpenX Sync to check for updates * * @param float $already_seen Only check for updates newer than this value. * @return array An array of two items: * * Item 0 is the XML-RPC error code. Meanings: * -2 => The admin user has disabled update checking * -1 => No response from the server * 0 - 799 => XML-RPC library error codes * 0 => No error * 800 => No updates * 801+ => Error codes from the remote XML-RPC server * * Item 1 is either the error message (item 1 != 0), or an array containing update info */ function checkForUpdates($already_seen = 0) { global $XML_RPC_erruser; if (!$this->aConf['sync']['checkForUpdates']) { // Checking for updates has been disabled by the admin user, // so do not communicate with the server that provides the // details of what upgrades are available - just return an // 800 "error" $aReturn = array(-2, 'Check for updates has been disabled by the administrator.'); return $aReturn; } // Create the XML-RPC client object $client = OA_Central::getXmlRpcClient($this->_conf); // Prepare the installation's platform hash $platform_hash = OA_Dal_ApplicationVariables::get('platform_hash'); if (!$platform_hash) { // The installation does not have a platform hash; generate one, // and save it to the database for later use OA::debug("Generating a new platform_hash for the installation", PEAR_LOG_INFO); $platform_hash = OA_Dal_ApplicationVariables::generatePlatformHash(); if (!OA_Dal_ApplicationVariables::set('platform_hash', $platform_hash)) { OA::debug("Could not save the new platform_hash to the database", PEAR_LOG_ERR); unset($platform_hash); OA::debug("Sync process proceeding without a platform_hash", PEAR_LOG_INFO); } } // Prepare the parameters required for the XML-RPC call to // obtain if an update is available for this installation $params = array(new XML_RPC_Value(PRODUCT_NAME, 'string'), new XML_RPC_Value($this->getConfigVersion(OA_Dal_ApplicationVariables::get('oa_version')), 'string'), new XML_RPC_Value($already_seen, 'string'), new XML_RPC_Value($platform_hash, 'string')); // Has the Revive Adserver admin user kindly agreed to share the // technology stack that it is running on, to help the community? $aTechStack = array('data' => false); if ($this->aConf['sync']['shareStack']) { // Thanks, admin user! You're a star! Prepare the technology stack // data and add it to the XML-RPC call if ($this->oDbh->dbsyntax == 'mysql') { $dbms = 'MySQL'; } else { if ($this->oDbh->dbsyntax == 'pgsql') { $dbms = 'PostgreSQL'; } else { $dbms = 'UnknownSQL'; } } $aTechStack = array('os_type' => php_uname('s'), 'os_version' => php_uname('r'), 'webserver_type' => isset($_SERVER['SERVER_SOFTWARE']) ? preg_replace('#^(.*?)/.*$#', '$1', $_SERVER['SERVER_SOFTWARE']) : '', 'webserver_version' => isset($_SERVER['SERVER_SOFTWARE']) ? preg_replace('#^.*?/(.*?)(?: .*)?$#', '$1', $_SERVER['SERVER_SOFTWARE']) : '', 'db_type' => $dbms, 'db_version' => $this->oDbh->queryOne("SELECT VERSION()"), 'php_version' => phpversion(), 'php_sapi' => ucfirst(php_sapi_name()), 'php_extensions' => get_loaded_extensions(), 'php_register_globals' => (bool) ini_get('register_globals'), 'php_magic_quotes_gpc' => (bool) ini_get('magic_quotes_gpc'), 'php_safe_mode' => (bool) ini_get('safe_mode'), 'php_open_basedir' => (bool) strlen(ini_get('open_basedir')), 'php_upload_tmp_readable' => (bool) is_readable(ini_get('upload_tmp_dir') . DIRECTORY_SEPARATOR)); } $params[] = XML_RPC_Encode($aTechStack); // Add the registered email address $params[] = new XML_RPC_Value(OA_Dal_ApplicationVariables::get('sync_registered_email'), 'string'); // Create the XML-RPC request message $msg = new XML_RPC_Message("Revive.Sync", $params); // Send the XML-RPC request message if ($response = $client->send($msg, 10)) { // XML-RPC server found, now checking for errors if (!$response->faultCode()) { // No fault! Woo! Get the response and return it! $aReturn = array(0, XML_RPC_Decode($response->value())); // Prepare cache $cache = $aReturn[1]; // Update last run OA_Dal_ApplicationVariables::set('sync_last_run', date('Y-m-d H:i:s')); // Also write to the debug log OA::debug("Sync: updates found!", PEAR_LOG_INFO); } else { // Boo! An error! (Well, maybe - if it's 800, yay!) $aReturn = array($response->faultCode(), $response->faultString()); // Prepare cache $cache = false; // Update last run if ($response->faultCode() == 800) { // Update last run OA_Dal_ApplicationVariables::set('sync_last_run', date('Y-m-d H:i:s')); // Also write to the debug log OA::debug("Sync: {$aReturn[1]}", PEAR_LOG_INFO); } else { // Write to the debug log OA::debug("Sync: {$aReturn[1]} (code: {$aReturn[0]}", PEAR_LOG_ERR); // Return immediately without writing to cache return $aReturn; } } OA_Dal_ApplicationVariables::set('sync_cache', serialize($cache)); OA_Dal_ApplicationVariables::set('sync_timestamp', time()); return $aReturn; } $aReturn = array(-1, 'No response from the remote XML-RPC server.'); // Also write to the debug log OA::debug("Sync: {$aReturn[1]}", PEAR_LOG_ERR); return $aReturn; }
function autoLogin() { $oPlugin =& OA_Auth::staticGetAuthPlugin(); phpAds_SessionStart(); // No auto-login if auth is external if (empty($oPlugin) || get_class($oPlugin) != 'Plugins_Authentication') { phpAds_SessionDataDestroy(); return; } $doUser = OA_Dal::factoryDO('users'); if (!empty($_COOKIE['oat']) && $_COOKIE['oat'] == OA_UPGRADE_UPGRADE) { // Upgrading, fetch the record using the username of the logged in user $doUser->username = OA_Permission::getUsername(); } else { // Installing, fetch the user linked to the admin account $doAUA = OA_Dal::factoryDO('account_user_assoc'); $doAUA->account_id = OA_Dal_ApplicationVariables::get('admin_account_id'); $doUser->joinAdd($doAUA); } $doUser->find(); if ($doUser->fetch()) { phpAds_SessionDataRegister(OA_Auth::getSessionData($doUser)); phpAds_SessionDataStore(); } }
/** * A static method to update the last run * */ function updateLastRun() { OA_Dal_ApplicationVariables::set('maintenance_timestamp', time()); }
function testGetLastRun() { $oMaintenance = new OX_Maintenance(); $this->assertNull($oMaintenance->getLastRun()); $iLastRun = strtotime('2002-01-01'); OA_Dal_ApplicationVariables::set('maintenance_timestamp', $iLastRun); $oDate = new Date((int) $iLastRun); $this->assertTrue($oDate->equals($oMaintenance->getLastRun())); OA_Dal_ApplicationVariables::delete('maintenance_timestamp'); }
if ($aVars['sync_cache']) { $update_check = unserialize($aVars['sync_cache']); } // If cache timestamp not set or older than 24hrs, re-sync if (isset($aVars['sync_timestamp']) && $aVars['sync_timestamp'] + 86400 < time()) { $oSync = new OA_Sync(); $res = $oSync->checkForUpdates(); if ($res[0] == 0) { $update_check = $res[1]; } } if (!is_array($update_check) || $update_check['config_version'] <= $aVars['sync_last_seen']) { $update_check = false; } else { // Make sure that the alert doesn't display everytime OA_Dal_ApplicationVariables::set('sync_last_seen', $update_check['config_version']); // Format like the XML-RPC response $update_check = array(0, $update_check); } } phpAds_SessionDataRegister('maint_update_js', true); phpAds_SessionDataStore(); // Add Product Update redirector if (isset($update_check[0]) && $update_check[0] == 0) { header("Content-Type: application/x-javascript"); if ($update_check[1]['security_fix']) { echo "alert('" . $strUpdateAlertSecurity . "');\n"; } else { echo "if (confirm('" . $strUpdateAlert . "'))\n\t"; } echo "document.location.replace('updates-product.php');\n";
/** * @param $oDate * @param $campaignId * @return int Number of emails sent */ function sendCampaignImpendingExpiryEmail($oDate, $campaignId) { $aConf = $GLOBALS['_MAX']['CONF']; global $date_format; $oPreference = new OA_Preferences(); if (!isset($this->aAdminCache)) { // Get admin account ID $adminAccountId = OA_Dal_ApplicationVariables::get('admin_account_id'); // Get admin prefs $adminPrefsNames = $this->_createPrefsListPerAccount(OA_ACCOUNT_ADMIN); $aAdminPrefs = $oPreference->loadAccountPreferences($adminAccountId, $adminPrefsNames, OA_ACCOUNT_ADMIN); // Get admin users $aAdminUsers = $this->getAdminUsersLinkedToAccount(); // Store admin cache $this->aAdminCache = array($aAdminPrefs, $aAdminUsers); } else { // Retrieve admin cache list($aAdminPrefs, $aAdminUsers) = $this->aAdminCache; } $aPreviousOIDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oDate); $aPreviousOIDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($aPreviousOIDates['start']); $doCampaigns = OA_Dal::staticGetDO('campaigns', $campaignId); if (!$doCampaigns) { return 0; } $aCampaign = $doCampaigns->toArray(); if (!isset($this->aClientCache[$aCampaign['clientid']])) { $doClients = OA_Dal::staticGetDO('clients', $aCampaign['clientid']); // Add advertiser linked users $aLinkedUsers['advertiser'] = $this->getUsersLinkedToAccount('clients', $aCampaign['clientid']); // Add advertiser prefs $advertiserPrefsNames = $this->_createPrefsListPerAccount(OA_ACCOUNT_ADVERTISER); $aPrefs['advertiser'] = $oPreference->loadAccountPreferences($doClients->account_id, $advertiserPrefsNames, OA_ACCOUNT_ADVERTISER); if (!isset($aAgencyCache[$doClients->agencyid])) { // Add manager linked users $doAgency = OA_Dal::staticGetDO('agency', $doClients->agencyid); $aLinkedUsers['manager'] = $this->getUsersLinkedToAccount('agency', $doClients->agencyid); // Add manager preferences $managerPrefsNames = $this->_createPrefsListPerAccount(OA_ACCOUNT_MANAGER); $aPrefs['manager'] = $oPreference->loadAccountPreferences($doAgency->account_id, $managerPrefsNames, OA_ACCOUNT_MANAGER); // Get agency "From" details $aAgencyFromDetails = $this->_getAgencyFromDetails($doAgency->agencyid); // Store in the agency cache $this->aAgencyCache = array($doClients->agencyid => array($aLinkedUsers['manager'], $aPrefs['manager'], $aAgencyFromDetails)); } else { // Retrieve agency cache list($aLinkedUsers['manager'], $aPrefs['manager'], $aAgencyFromDetails) = $this->aAgencyCache[$doClients->agencyid]; } // Add admin linked users and preferences $aLinkedUsers['admin'] = $aAdminUsers; $aPrefs['admin'] = $aAdminPrefs; // Create a linked user 'special' for the advertiser that will take the admin preferences for advertiser $aLinkedUsers['special']['advertiser'] = $doClients->toArray(); $aLinkedUsers['special']['advertiser']['contact_name'] = $aLinkedUsers['special']['advertiser']['contact']; $aLinkedUsers['special']['advertiser']['email_address'] = $aLinkedUsers['special']['advertiser']['email']; $aLinkedUsers['special']['advertiser']['language'] = ''; $aLinkedUsers['special']['advertiser']['user_id'] = 0; // Check that every user is not going to receive more than one email if they // are linked to more than one account $aLinkedUsers = $this->_deleteDuplicatedUser($aLinkedUsers); // Create the linked special user preferences from the admin preferences // the special user is the client that doesn't have preferences in the database $aPrefs['special'] = $aPrefs['admin']; $aPrefs['special']['warn_email_special'] = $aPrefs['special']['warn_email_advertiser']; $aPrefs['special']['warn_email_special_day_limit'] = $aPrefs['special']['warn_email_advertiser_day_limit']; $aPrefs['special']['warn_email_special_impression_limit'] = $aPrefs['special']['warn_email_advertiser_impression_limit']; // Store in the client cache $this->aClientCache = array($aCampaign['clientid'] => array($aLinkedUsers, $aPrefs, $aAgencyFromDetails)); } else { // Retrieve client cache list($aLinkedUsers, $aPrefs, $aAgencyFromDetails) = $this->aClientCache[$aCampaign['clientid']]; } $copiesSent = 0; foreach ($aLinkedUsers as $accountType => $aUsers) { if ($accountType == 'special' || $accountType == 'advertiser') { // Get the agency details and use them for emailing advertisers $aFromDetails = $aAgencyFromDetails; } else { // Use the Admin details $aFromDetails = ''; } if ($aPrefs[$accountType]['warn_email_' . $accountType]) { // Does the account type want warnings when the impressions are low? if ($aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit'] > 0 && $aCampaign['views'] > 0) { // Test to see if the placements impressions remaining are less than the limit $dalCampaigns = OA_Dal::factoryDAL('campaigns'); $remainingImpressions = $dalCampaigns->getAdImpressionsLeft($aCampaign['campaignid']); if ($remainingImpressions < $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit']) { // Yes, the placement will expire soon! But did the placement just reach // the point where it is about to expire, or did it happen a while ago? $previousRemainingImpressions = $dalCampaigns->getAdImpressionsLeft($aCampaign['campaignid'], $aPreviousOIDates['end']); if ($previousRemainingImpressions >= $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit']) { // Yes! This is the operation interval that the boundary // was crossed to the point where it's about to expire, // so send that email, baby! foreach ($aUsers as $aUser) { $aEmail = $this->prepareCampaignImpendingExpiryEmail($aUser, $aCampaign['clientid'], $aCampaign['campaignid'], 'impressions', $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit'], $accountType); if ($aEmail !== false) { if ($this->sendMail($aEmail['subject'], $aEmail['contents'], $aUser['email_address'], $aUser['contact_name'], $aFromDetails)) { $copiesSent++; if ($aConf['email']['logOutgoing']) { phpAds_userlogSetUser(phpAds_userMaintenance); phpAds_userlogAdd(phpAds_actionWarningMailed, $aPlacement['campaignid'], "{$aEmail['subject']}\n\n\n {$aUser['contact_name']}({$aUser['email_address']})\n\n\n {$aEmail['contents']}"); } } } } } } } // Does the account type want warnings when the days are low? if ($aPrefs[$accountType]['warn_email_' . $accountType . '_day_limit'] > 0 && !empty($aCampaign['expire_time'])) { // Calculate the date that should be used to see if the warning needs to be sent $warnSeconds = (int) ($aPrefs[$accountType]['warn_email_' . $accountType . '_day_limit'] + 1) * SECONDS_PER_DAY; $oEndDate = new Date($aCampaign['expire_time']); $oEndDate->setTZbyID('UTC'); $oTestDate = new Date(); $oTestDate->copy($oDate); $oTestDate->addSeconds($warnSeconds); // Test to see if the test date is after the placement's expiration date if ($oTestDate->after($oEndDate)) { // Yes, the placement will expire soon! But did the placement just reach // the point where it is about to expire, or did it happen a while ago? $oiSeconds = (int) $aConf['maintenance']['operationInterval'] * 60; $oTestDate->subtractSeconds($oiSeconds); if (!$oTestDate->after($oEndDate)) { // Yes! This is the operation interval that the boundary // was crossed to the point where it's about to expire, // so send those emails, baby! foreach ($aUsers as $aUser) { $aEmail = $this->prepareCampaignImpendingExpiryEmail($aUser, $aCampaign['clientid'], $aCampaign['campaignid'], 'date', $oEndDate->format($date_format), $accountType); if ($aEmail !== false) { if ($this->sendMail($aEmail['subject'], $aEmail['contents'], $aUser['email_address'], $aUser['contact_name'], $aFromDetails)) { $copiesSent++; if ($aConf['email']['logOutgoing']) { phpAds_userlogSetUser(phpAds_userMaintenance); phpAds_userlogAdd(phpAds_actionWarningMailed, $aPlacement['campaignid'], "{$aEmail['subject']}\n\n\n {$aUser['contact_name']}({$aUser['email_address']})\n\n\n {$aEmail['contents']}"); } } } } } } } } } // Restore the default language strings Language_Loader::load('default'); return $copiesSent; }
/** * A static method to load the current account's preferences from the * database and store them in the global array $GLOBALS['_MAX']['PREF']. * * @static * @param boolean $loadExtraInfo An optional parameter, when set to true, * the array of preferences is loaded as * an array of arrays, indexed by preference * key, containing the preference "value" and * "account_type" information. When not set, * the preferences are loaded as a * one-dimensional array of values, indexed * by preference key. * @param boolean $return An optional parameter, when set to true, * returns the preferences instead of setting * them into $GLOBALS['_MAX']['PREF']. * @param boolean $parentOnly An optional parameter, when set to true, * only loads those preferences that are * inherited from parent accounts, not preferences * at the current account level. If the current * account is the admin account, and this option * is true, no preferences will be loaded! * @param boolean $loadAdminOnly An optional parameter, when set to true, loads * the admin preferences only, EVEN IF NO ACCUONT * IS LOGGED IN. If set to true, REQUIRES that the * $parentOnly parameter is false. Should only * ever be set when called from * OA_Preferences::loadAdminAccountPreferences(). * @param integer $accountId An optional account ID, when set, the preferences * for this account will be loaded, provided there * is no currently logged in account. * @return mixed The array of preferences if $return is true, otherwise null. */ function loadPreferences($loadExtraInfo = false, $return = false, $parentOnly = false, $loadAdminOnly = false, $accountId = null) { $aConf = $GLOBALS['_MAX']['CONF']; // Ensure $parentOnly and $loadAdminOnly are correctly set if ($parentOnly && $loadAdminOnly) { // Cannot both be true! OA_Preferences::_unsetPreferences(); return; } // Only worry about the current account type and if a user is logged // in if $loadAdminOnly == false if ($loadAdminOnly == false) { // Get the type of the current accout $currentAccountType = OA_Permission::getAccountType(); // If no user logged in, and we are supposed to load a specific account's // preferences, load the account type of that specific account if (empty($currentAccountType) && is_numeric($accountId)) { // Get the account type for the specified account $doAccounts = OA_Dal::factoryDO('accounts'); $doAccounts->account_id = $accountId; $doAccounts->find(); if ($doAccounts->getRowCount() > 0) { $aCurrentAccountType = $doAccounts->getAll(array('account_type'), false, true); $currentAccountType = $aCurrentAccountType[0]; } } // If (still) no user logged in or invalid specific account, return if (is_null($currentAccountType) || $currentAccountType == false) { OA_Preferences::_unsetPreferences(); return; } } // Get all of the preference types that exist $doPreferences = OA_Dal::factoryDO('preferences'); $aPreferenceTypes = $doPreferences->getAll(array(), true); // Are there any preference types in the system? if (empty($aPreferenceTypes)) { OA_Preferences::_unsetPreferences(); return; } // Get the admin account's ID, as this will be required $adminAccountId = OA_Dal_ApplicationVariables::get('admin_account_id'); // Get the admin account's preferences, as these are always required $aAdminPreferenceValues = OA_Preferences::_getPreferenceValues($adminAccountId); if (empty($aAdminPreferenceValues)) { OA_Preferences::_unsetPreferences(); return; } // Prepare an array to store the preferences that should // eventually be set in the global array $aPreferences = array(); // Put the admin account's preferences into the temporary // storage array for preferences if ($loadAdminOnly == true || !($currentAccountType == OA_ACCOUNT_ADMIN && $parentOnly)) { OA_Preferences::_setPreferences($aPreferences, $aPreferenceTypes, $aAdminPreferenceValues, $loadExtraInfo); } // Is the current account NOT the admin account? if ($loadAdminOnly == false && $currentAccountType != OA_ACCOUNT_ADMIN) { // Is the current account not a manager account? if ($currentAccountType == OA_ACCOUNT_MANAGER) { // This is a manager account if (!$parentOnly) { // Locate the owning manager account ID if (!is_numeric($accountId)) { $managerAccountId = OA_Permission::getAccountId(); } else { $managerAccountId = $accountId; } if ($managerAccountId == 0) { OA_Preferences::_unsetPreferences(); return; } // Get the manager account's preference values $aManagerPreferenceValues = OA_Preferences::_getPreferenceValues($managerAccountId); // Merge the preference values into the temporary // storage array for preferences OA_Preferences::_setPreferences($aPreferences, $aPreferenceTypes, $aManagerPreferenceValues, $loadExtraInfo); } } else { // This must be an advertiser or trafficker account, so // need to locate the manager account that "owns" this account if (!is_numeric($accountId)) { $owningAgencyId = OA_Permission::getAgencyId(); } else { $owningAgencyId = 0; if ($currentAccountType == OA_ACCOUNT_ADVERTISER) { $doClients = OA_Dal::factoryDO('clients'); $doClients->account_id = $accountId; $doClients->find(); if ($doClients->getRowCount() == 1) { $aOwningAgencyId = $doClients->getAll(array('agencyid'), false, true); $owningAgencyId = $aOwningAgencyId[0]; } } else { if ($currentAccountType == OA_ACCOUNT_TRAFFICKER) { $doAffiliates = OA_Dal::factoryDO('affiliates'); $doAffiliates->account_id = $accountId; $doAffiliates->find(); if ($doAffiliates->getRowCount() == 1) { $aOwningAgencyId = $doAffiliates->getAll(array('agencyid'), false, true); $owningAgencyId = $aOwningAgencyId[0]; } } } } if ($owningAgencyId == 0) { OA_Preferences::_unsetPreferences(); return; } $doAgency = OA_Dal::factoryDO('agency'); $doAgency->agencyid = $owningAgencyId; $doAgency->find(); if ($doAgency->getRowCount() == 1) { // The manager account "owning" the advertiser or // trafficker account has some preferences that // override the admin account preferences $aManagerAccountId = $doAgency->getAll(array('account_id'), false, true); $managerAccountId = $aManagerAccountId[0]; // Get the manager account's preference values $aManagerPreferenceValues = OA_Preferences::_getPreferenceValues($managerAccountId); // Merge the preference values into the temporary // storage array for preferences OA_Preferences::_setPreferences($aPreferences, $aPreferenceTypes, $aManagerPreferenceValues, $loadExtraInfo); } if (!$parentOnly) { // Get the current account's ID if (!is_numeric($accountId)) { $currentAccountId = OA_Permission::getAccountId(); } else { $currentAccountId = $accountId; } if ($currentAccountId <= 0) { OA_Preferences::_unsetPreferences(); return; } // Get the current account's preference values $aCurrentPreferenceValues = OA_Preferences::_getPreferenceValues($currentAccountId); // Merge the preference values into the temporary // storage array for preferences OA_Preferences::_setPreferences($aPreferences, $aPreferenceTypes, $aCurrentPreferenceValues, $loadExtraInfo); } } } // Set the initial (default) language to conf value or english $aPreferences['language'] = !empty($aConf['max']['language']) ? $aConf['max']['language'] : 'en'; // Add user preferences (currently language) to the prefs array if ($userId = OA_Permission::getUserId()) { $doUser = OA_Dal::factoryDO('users'); $doUser->get('user_id', $userId); if (!empty($doUser->language)) { $aPreferences['language'] = $doUser->language; } } // Return or store the preferences if ($return) { return $aPreferences; } else { $GLOBALS['_MAX']['PREF'] = $aPreferences; } }
function test_rollbackPutAdmin() { $oUpgrade = new OA_UpgradeRollbackTest(); // Call putAdmin method $aAdmin = array('email' => '*****@*****.**', 'name' => 'testadmin', 'pword' => 'testpass', 'language' => 'es'); $aPrefs = array('timezone' => 'Europe/Madrid'); $oUpgrade->putAdmin($aAdmin, $aPrefs); // call rollback method $oUpgrade->_rollbackPutAdmin(); // check tables $doPreferencesAssoc = OA_Dal::factoryDO('account_preference_assoc'); $this->assertEqual($doPreferencesAssoc->getAll(), array()); $doPreferences = OA_Dal::factoryDO('preferences'); $this->assertEqual($doPreferences->getAll(), array()); $doUserAssoc = OA_Dal::factoryDO('account_user_assoc'); $this->assertEqual($doUserAssoc->getAll(), array()); $doUser = OA_Dal::factoryDO('users'); $this->assertEqual($doUser->getAll(), array()); $doAgency = OA_Dal::factoryDO('agency'); $this->assertEqual($doAgency->getAll(), array()); $doAccount = OA_Dal::factoryDO('accounts'); $this->assertEqual($doAccount->getAll(), array()); // admin_account_id in appliation variables should be deleted $this->assertNull(OA_Dal_ApplicationVariables::get('admin_account_id')); }
/** * Update checkForUpdates value into Settings * * @param boolean $syncEnabled * @return boolean */ function putSyncSettings($syncEnabled) { require_once MAX_PATH . '/lib/OA/Admin/Settings.php'; require_once MAX_PATH . '/lib/OA/Sync.php'; $oSettings = new OA_Admin_Settings(); $oSettings->settingChange('sync', 'checkForUpdates', $syncEnabled); // Reset Sync cache OA_Dal_ApplicationVariables::delete('sync_cache'); OA_Dal_ApplicationVariables::delete('sync_timestamp'); OA_Dal_ApplicationVariables::delete('sync_last_seen'); if (!$oSettings->writeConfigChange()) { $this->oLogger->logError('Error saving Sync settings to the config file'); return false; } // Generate a new Platform Hash if empty $platformHash = OA_Dal_ApplicationVariables::get('platform_hash'); if (empty($platformHash) && !OA_Dal_ApplicationVariables::set('platform_hash', OA_Dal_ApplicationVariables::generatePlatformHash())) { $this->oLogger->logError('Error inserting Platform Hash into database'); return false; } $oSync = new OA_Sync(); OA::disableErrorHandling(); $oSync->checkForUpdates(); OA::enableErrorHandling(); return true; }
/** * 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() { // Find the banner that contains this image, if possible $doBanners = OA_Dal::factoryDO('banners'); $doBanners->storagetype = 'sql'; $doBanners->filename = $this->filename; $doBanners->find(); if ($doBanners->getRowCount() == 1) { $doBanners->fetch(); // Return the owning account IDs of the image's owning // banner return $doBanners->getOwningAccountIds(); } // Alas, the image doesn't have an owning banner yet, // so return the special case of $aAccountIds = array(OA_ACCOUNT_ADMIN => OA_Dal_ApplicationVariables::get('admin_account_id')); return $aAccountIds; }
} break; case OA_ACCOUNT_MANAGER: // Check that they have the super account permission if (!OA_Permission::hasPermission(OA_PERM_SUPER_ACCOUNT)) { break; } // A manager account can only "see" those users that are already linked to the // current account, and to the advertiser and trafficker accounts that are in the // current account's realm -- display only these users -- but also exclude any // user that is also linked to the admin account $aAdminUserIds = array(); $aUserIds = array(); $oDbh =& OA_DB::singleton(); // Get the ID of all users linked to the admin account $adminAccountId = OA_Dal_ApplicationVariables::get('admin_account_id'); $doAccount_user_assoc = OA_Dal::factoryDO('account_user_assoc'); $doAccount_user_assoc->account_id = $adminAccountId; $doAccount_user_assoc->find(); while ($doAccount_user_assoc->fetch() > 0) { // Store the user info for later $aInfo = $doAccount_user_assoc->toArray(); $aAdminUserIds[] = $aInfo['user_id']; } // Get the current manager account ID $currentAccountId = OA_Permission::getAccountId(); // Select all of the users that are linked with the current manager account $doAccount_user_assoc = OA_Dal::factoryDO('account_user_assoc'); $doAccount_user_assoc->account_id = $currentAccountId; $doAccount_user_assoc->find(); while ($doAccount_user_assoc->fetch() > 0) {
/** * Returns ADMIN account ID * */ function getAdminAccountId() { return OA_Dal_ApplicationVariables::get('admin_account_id'); }
/** * A private method to prepare the report range information from an * OA_Admin_DaySpan object. * * @access private * @param OA_Admin_DaySpan $oDaySpan The OA_Admin_DaySpan object to set * the report range information from. */ function _prepareReportRange($oDaySpan) { global $date_format; if (!empty($oDaySpan)) { $this->_oDaySpan = $oDaySpan; $this->_startDateString = $oDaySpan->getStartDateString($date_format); $this->_endDateString = $oDaySpan->getEndDateString($date_format); } else { $oDaySpan = new OA_Admin_DaySpan(); // take as the start date the date when adds were serverd $aConf = $GLOBALS['_MAX']['CONF']; $oDbh = OA_DB::singleton(); $query = "SELECT MIN(date_time) as min_datetime FROM " . $oDbh->quoteIdentifier($aConf['table']['prefix'] . $aConf['table']['data_summary_ad_hourly'], true) . " WHERE 1=1"; $startDate = $oDbh->queryRow($query); $startDate = $startDate['min_datetime']; $oStartDate = new Date($startDate); $oEndDate = new Date(); $oDaySpan->setSpanDays($oStartDate, $oEndDate); $this->_oDaySpan =& $oDaySpan; $this->_startDateString = MAX_Plugin_Translation::translate('Beginning', $this->module, $this->package); $this->_endDateString = $oDaySpan->getEndDateString($date_format); } $utcUpdate = OA_Dal_ApplicationVariables::get('utc_update'); if (!empty($utcUpdate)) { $oUpdate = new Date($utcUpdate); $oUpdate->setTZbyID('UTC'); // Add 12 hours $oUpdate->addSeconds(3600 * 12); $startDate = new Date($oDaySpan->oStartDate); $endDate = new Date($oDaySpan->oEndDate); if ($oUpdate->after($endDate) || $oUpdate->after($startDate)) { $this->_displayInaccurateStatsWarning = true; } } }
require_once MAX_PATH . '/www/admin/config.php'; require_once MAX_PATH . '/lib/OA/Dal/ApplicationVariables.php'; require_once MAX_PATH . '/lib/OA/Sync.php'; require_once MAX_PATH . '/lib/max/language/Loader.php'; Language_Loader::load('settings'); // Security check OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); /*-------------------------------------------------------*/ /* HTML framework */ /*-------------------------------------------------------*/ $title = $GLOBALS['strPlatformHashRegenerate']; $oHeaderModel = new OA_Admin_UI_Model_PageHeaderModel($title); phpAds_PageHeader('account-settings-index', $oHeaderModel); /*-------------------------------------------------------*/ /* Main code */ /*-------------------------------------------------------*/ $platformHash = OA_Dal_ApplicationVariables::generatePlatformHash(); if (OA_Dal_ApplicationVariables::set('platform_hash', $platformHash)) { echo $GLOBALS['strNewPlatformHash'] . " " . $platformHash; $oSync = new OA_Sync(); OA::disableErrorHandling(); $oSync->checkForUpdates(); OA::enableErrorHandling(); } else { $this->oLogger->logError('Error inserting Platform Hash into database'); echo $GLOBALS['strPlatformHashInsertingError']; } /*-------------------------------------------------------*/ /* HTML framework */ /*-------------------------------------------------------*/ phpAds_PageFooter();
/** * Reload variables from the database * */ function cleanCache() { OA_Dal_ApplicationVariables::_getAll(false); }
/** * Test generatin platform hash * */ function testGeneratePlatformHash() { $hash1 = OA_Dal_ApplicationVariables::generatePlatformHash(); $hash2 = OA_Dal_ApplicationVariables::generatePlatformHash(); $this->assertEqual(strlen($hash1), 40); $this->assertEqual(strlen($hash2), 40); $this->assertNotEqual($hash1, $hash2); }