/** * * @return boolean True */ function execute() { if (isset($GLOBALS['_MAX']['CONF']['logging']['sniff'])) { $value = $GLOBALS['_MAX']['CONF']['logging']['sniff']; unset($GLOBALS['_MAX']['CONF']['logging']['sniff']); $oSettings = new OA_Admin_Settings(); $oSettings->settingChange('Client', 'sniff', $value); $oSettings->writeConfigChange(); } return true; }
function test_postscript_install_Client() { $oSettings = new OA_Admin_Settings(); $oSettings->settingChange('logging', 'sniff', '1'); $oSettings->writeConfigChange(); $this->assertTrue($GLOBALS['_MAX']['CONF']['logging']['sniff']); $oPostInstall = new postscript_install_Client(); $oPostInstall->execute(); $this->assertNull($GLOBALS['_MAX']['CONF']['logging']['sniff']); $this->assertTrue($GLOBALS['_MAX']['CONF']['Client']['sniff']); }
/** * Remove the entire "pluginUpdatesServer" setting section, as this was * deprecated in Revive Adserver 3.1.0 */ function _removePluginUpdateServerSettings() { $this->logOnly("Attempting to remove the 'pluginUpdatesServer' settings from the configuration file"); $oConfiguration = new OA_Admin_Settings(); unset($oConfiguration->aConf['pluginUpdatesServer']['protocol']); unset($oConfiguration->aConf['pluginUpdatesServer']['host']); unset($oConfiguration->aConf['pluginUpdatesServer']['path']); unset($oConfiguration->aConf['pluginUpdatesServer']['httpPort']); if ($oConfiguration->writeConfigChange()) { $this->logOnly("Removed the 'pluginUpdatesServer' settings from the configuration file"); } else { $this->logError("Failed to remove the 'pluginUpdatesServer' settings from the configuration file"); } }
/** * This method takes the array of registered hooks from the plugin/component group's XML files and saves a structured list in the config file * * @return boolean True if writing the config file change was sucessful false otherwise */ function _saveComponentHooks($aHooks = array()) { $oSettings = new OA_Admin_Settings(); if (!$oSettings) { return false; } // Clear out any existing hooks $oSettings->aConf['deliveryHooks'] = array(); foreach ($aHooks as $hookName => &$aComponentIdentifiers) { $aComponentIdentifiers = $this->orderDependencyComponents($hookName, $aComponentIdentifiers, $aHooks); $oSettings->settingChange('deliveryHooks', $hookName, implode('|', $aComponentIdentifiers)); } return $oSettings->writeConfigChange(); }
function OA_Upgrade_Config() { $this->oSettings = new OA_Admin_Settings(); $this->aConfig =& $this->oSettings->getConfigArray(); // set default configPath $this->configPath = MAX_PATH . '/var/'; if (!OA_Admin_Settings::isConfigWritable()) { return false; } }
function __construct() { $this->oSettings = new OA_Admin_Settings(); // Use reference here $this->aConfig =& $this->oSettings->getConfigArray(); // set default configPath $this->configPath = MAX_PATH . '/var/'; if (!OA_Admin_Settings::isConfigWritable()) { return false; } }
function init() { $aConf = $GLOBALS['_MAX']['CONF']; $this->pathPackages = $aConf['pluginPaths']['packages']; $this->pathPlugins = $aConf['pluginPaths']['plugins']; $this->pathPluginsAdmin = $aConf['pluginPaths']['admin']; $this->pathDataObjects = $aConf['pluginPaths']['var'] . 'DataObjects/'; // Attempt to increase the memory limit when using the plugin manager OX_increaseMemoryLimit(OX_getMinimumRequiredMemory('plugin')); $this->basePath = MAX_PATH; $this->configLocked = !OA_Admin_Settings::isConfigWritable(); }
/** * 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; }
function onEnable() { $oSettings = new OA_Admin_Settings(); $oSettings->settingChange('allowedBanners', 'video', '1'); $oSettings->writeConfigChange(); return true; }
/** * Remove the UI "show contact us link" setting, as this was deprecated in * Revive Adserver 3.0.0 */ function _removeShowContactUsLinkSetting() { $this->logOnly("Attempting to remove the 'share data' sync setting from the configuration file"); $oConfiguration = new OA_Admin_Settings(); unset($oConfiguration->aConf['ui']['showContactUsLink']); if ($oConfiguration->writeConfigChange()) { $this->logOnly("Removed the 'share data' sync setting from the configuration file"); } else { $this->logError("Failed to remove the 'share data' sync setting from the configuration file"); } }
/** * Tests the correct backup filename is generated. * */ function test_getBackupFilename() { // Test when backup filename doesn't already exist. $originalFilename = 'oa_test_' . rand() . '.conf.php'; $directory = $this->basePath; $now = date("Ymd"); touch($directory . '/' . $originalFilename); $expected = $now . '_old.' . $originalFilename; $this->assertEqual($expected, OA_Admin_Settings::_getBackupFilename($directory . '/' . $originalFilename), 'Filenames don\'t match'); // Test when backup filename already exists. $existingBackupFile = $expected; touch($directory . '/' . $existingBackupFile); //$expected = $existingBackupFile . '_0'; $expected0 = $now . '_0_old.' . $originalFilename; $this->assertEqual($expected0, OA_Admin_Settings::_getBackupFilename($directory . '/' . $originalFilename), 'Filenames don\'t match'); // Clean up unlink($directory . '/' . $originalFilename); unlink($directory . '/' . $existingBackupFile); // Test when .ini backup filename doesn't already exist. $originalFilename = 'oa_test_' . rand() . '.conf.ini'; $directory = $this->basePath; $now = date("Ymd"); touch($directory . '/' . $originalFilename); $expected = $now . '_old.' . $originalFilename . '.php'; $this->assertEqual($expected, OA_Admin_Settings::_getBackupFilename($directory . '/' . $originalFilename), 'Filenames don\'t match'); // Clean up unlink($directory . '/' . $originalFilename); }
// If the settings page is a submission, deal with the form data if (isset($_POST['submitok']) && $_POST['submitok'] == 'true') { // Prepare an array of the HTML elements to process, and the // location to save the values in the settings configuration // file $aElements = array(); // General Settings $aElements += array('ui_enabled' => array('ui' => 'enabled', 'bool' => true), 'ui_applicationName' => array('ui' => 'applicationName'), 'ui_headerFilePath' => array('ui' => 'headerFilePath'), 'ui_footerFilePath' => array('ui' => 'footerFilePath'), 'ui_logoFilePath' => array('ui' => 'logoFilePath'), 'ui_headerForegroundColor' => array('ui' => 'headerForegroundColor'), 'ui_headerBackgroundColor' => array('ui' => 'headerBackgroundColor'), 'ui_headerActiveTabColor' => array('ui' => 'headerActiveTabColor'), 'ui_headerTextColor' => array('ui' => 'headerTextColor'), 'ui_gzipCompression' => array('ui' => 'gzipCompression', 'bool' => true)); // SSL Settings $aElements += array('openads_requireSSL' => array('openads' => 'requireSSL', 'bool' => true), 'openads_sslPort' => array('openads' => 'sslPort')); // Dashboard Settings $aElements += array('ui_dashboardEnabled' => array('ui' => 'dashboardEnabled', 'bool' => true)); // Dashboard Settings $aElements += array('authentication_type' => array('authentication' => 'type')); // Create a new settings object, and save the settings! $oSettings = new OA_Admin_Settings(); $result = $oSettings->processSettingsFromForm($aElements); if ($result) { // Delete all the sessions if the UI is disabled // to force all the users to be logged out if (!$GLOBALS['ui_enabled']) { $doSession = OA_Dal::factoryDO('session'); $doSession->whereAdd('1=1'); $doSession->delete(DB_DATAOBJECT_WHEREADD_ONLY); } // Rebuild the menu because the Enable Dashboard setting could been changed OA_Admin_Menu::_clearCache(OA_ACCOUNT_ADMIN); OA_Admin_Menu::_clearCache(OA_ACCOUNT_MANAGER); // Queue confirmation message $setPref = $oOptions->getSettingsPreferences($prefSection); $title = $setPref[$prefSection]['name'];
/** * Following method merges geotargeting plugins config * into global config file. By doing that we are improving * delivery performance for scripts using geotargeting data * by more than 15%. * * @return boolean True on success else false */ function mergeConfigWith($section, $mergeWithConf) { $config = new OA_Admin_Settings(); $config->bulkSettingChange($section, $mergeWithConf); return $config->writeConfigChange(); }
} /*-------------------------------------------------------*/ /* HTML framework */ /*-------------------------------------------------------*/ phpAds_PageHeader("plugin-index", new OA_Admin_UI_Model_PageHeaderModel($GLOBALS['strPlugins']), '', false, true); /*-------------------------------------------------------*/ /* Main code */ /*-------------------------------------------------------*/ if (is_null($oTpl)) { if (array_key_exists('selection', $_REQUEST) && $_REQUEST['selection'] == 'groups') { $oTpl = new OA_Admin_Template('plugin-group-index-list.html'); $oTpl->assign('aWarnings', $oComponentGroupManager->aWarnings); $oTpl->assign('selected', 'groups'); $oTpl->assign('aPlugins', $oComponentGroupManager->getComponentGroupsList()); } else { $oTpl = new OA_Admin_Template('plugin-index.html'); $oTpl->assign('selected', 'plugins'); $oTpl->assign('aPackages', $oPluginManager->getPackagesList()); $oTpl->assign('aWarnings', $oPluginManager->aWarnings); $oTpl->assign('aErrors', $oPluginManager->aErrors); $oTpl->assign('aMessages', $oPluginManager->aMessages); } } // Determine if config file is writable $configLocked = !OA_Admin_Settings::isConfigWritable(); $image = $configLocked ? 'closed' : 'open'; $oTpl->assign('configLocked', $configLocked); $oTpl->assign('image', $image); $oTpl->assign('token', phpAds_SessionGetToken()); $oTpl->display(); phpAds_PageFooter();
$GLOBALS['_MAX']['CONF']['pluginPaths']['extensions'] = $GLOBALS['_MAX']['CONF']['pluginPaths']['plugins']; $GLOBALS['_MAX']['CONF']['pluginPaths']['packages'] = $GLOBALS['_MAX']['CONF']['pluginPaths']['extensions'] . 'etc/'; $aErrors = array(); $result = array('name' => '', 'status' => 'Invalid Request', 'errors' => &$aErrors); if (validRequest($result)) { if ($_REQUEST['status'] === '0') { $result = installPlugin($_REQUEST['plugin']); } else { if ($_REQUEST['status'] === '1') { $result = checkPlugin($_REQUEST['plugin']); } } } // Undo hack unset($GLOBALS['_MAX']['CONF']['pluginPaths']['extensions']); $oSettings = new OA_Admin_Settings(); $oSettings->writeConfigChange(); require_once MAX_PATH . '/lib/JSON/JSON.php'; $json = new Services_JSON(); $output = $json->encode($result); header("Content-Type: application/x-javascript"); echo $output; function getPlugin($pluginName) { include MAX_PATH . '/etc/default_plugins.php'; if ($aDefaultPlugins) { foreach ($aDefaultPlugins as $idx => $aPlugin) { if ($pluginName == $aPlugin['name']) { return $aPlugin; } }
/** * A private method to determine if a setting configuration file option item should be * disabled or not, based on the state of settings configuration file (i.e. if the file * be written to, or not). * * @access private * @param array $aItem An array of the option item. * @return boolean True if the option should be disabled, false otherwise. */ function _disabledValue($aItem) { if ($this->_optionType == 'account-settings') { $aConf = $GLOBALS['_MAX']['CONF']; if (OA_INSTALLATION_STATUS == OA_INSTALLATION_STATUS_INSTALLED && isset($aItem['name'])) { $aNameExploded = explode('_', $aItem['name']); $aSettingSection = isset($aNameExploded[0]) ? $aNameExploded[0] : null; $aSettingKey = isset($aNameExploded[1]) ? $aNameExploded[1] : null; if (isset($aConf[$aSettingSection][$aSettingKey]) && !OA_Admin_Settings::isConfigWritable()) { return true; } } } return false; }
function writeDefaultConfigFile($configPath, $configFile, $newHost) { $file = $configPath . '/default' . $configFile . '.conf.php'; if (!OA_Admin_Settings::isConfigWritable($file)) { return false; } $aConfig = array('realConfig' => $newHost); $oConfig = new Config(); $oConfigContainer =& $oConfig->parseConfig($aConfig, 'phpArray'); $oConfigContainer->createComment('*** DO NOT REMOVE THE LINE ABOVE ***', 'top'); $oConfigContainer->createComment('<' . '?php exit; ?>', 'top'); return $oConfig->writeConfig($file, 'IniCommented'); }