/** * Load configuration parameters from the database * * This function retrieves all the parameters from the database and merge * them with the basis configuration object. * * Parameters that exists in the basis configuration object will be replaced * by them that come from the database. The basis configuration object * contains parameters that come from the easyscp.conf configuration file or * any parameter defined in the {@link environment.php} file. * * @return void */ protected function _processConfiguration() { // We get an EasySCP_Config_Handler_Db object $dbConfig = new EasySCP_Config_Handler_Db(); // Now, we can override our basis configuration object with parameter // that come from the database $this->_config->replaceWith($dbConfig); // Finally, we register the EasySCP_Config_Handler_Db for shared access EasySCP_Registry::set('Db_Config', $dbConfig); }
*/ require_once INCLUDEPATH . '/easyscp-autoloader.php'; spl_autoload_register('AutoLoader::loadClass'); /** * Exception Handler for uncaught exceptions * * Sets the exception handler for uncaught exceptions */ EasySCP_Exception::setHandler(); /** * Encryption data */ require_once INCLUDEPATH . '/easyscp-load-db-keys.php'; if ($easyscp_db_pass_key != '{KEY}' && $easyscp_db_pass_iv != '{IV}') { EasySCP_Registry::set('MCRYPT_KEY', $easyscp_db_pass_key); EasySCP_Registry::set('MCRYPT_IV', $easyscp_db_pass_iv); unset($easyscp_db_pass_key, $easyscp_db_pass_iv); } else { throw new EasySCP_Exception('Error: Database key and/or initialization vector was not generated!'); } /** * Include EasySCP common functions */ require_once 'Net/IDNA2.php'; require_once INCLUDEPATH . '/easyscp-functions.php'; /** * Bootstrap the EasySCP environment, and default configuration * * @see {@link EasySCP_Bootstrap} class * @see {@link EasySCP_Initializer} class */
/** * Adds or updates a services ports * * @since 1.0.7 * @param boolean $mode TRUE on add, FALSE on update * @return void */ function add_update_services($mode) { // Gets a reference to the EasySCP_ConfigHandler_Db instance $db_cfg = EasySCP_Registry::get('Db_Config'); // Create a pool for messages on error and gets a reference to him $messages =& EasySCP_Registry::set('Page_Messages', array()); // Create a pool for error fields ids and gets a reference to him $error_fields_ids =& EasySCP_Registry::set('Error_Fields_Ids', array()); // Adds a service port if ($mode) { $port = $_POST['port_new']; $proto = $_POST['port_type_new']; $name = strtoupper($_POST['name_new']); $show = $_POST['show_val_new']; $ip = $_POST['ip_new']; if (validates_service($name, $ip, $port, $proto, $show)) { $db_sname = "PORT_{$name}"; // Add the service port in the database // See EasySCP_ConfigHandler_Db adapter class to learn how it work $db_cfg->{$db_sname} = "{$port};{$proto};{$name};{$show};1;{$ip}"; write_log(get_session('user_logged') . ": Added service port {$name} ({$port})!"); } // Updates one or more services ports } else { // Reset counter of update queries $db_cfg->resetQueriesCounter('update'); foreach ($_POST['name'] as $index => $name) { $port = $_POST['port'][$index]; $proto = $_POST['port_type'][$index]; $name = strtoupper($name); $show = $_POST['show_val'][$index]; $custom = $_POST['custom'][$index]; $ip = $_POST['ip'][$index]; if (validates_service($name, $ip, $port, $proto, $show, $index)) { $db_sname = $_POST['var_name'][$index]; // Update the service port in the database // See EasySCP_ConfigHandler_Db adapter class to learn how it work $db_cfg->{$db_sname} = "{$port};{$proto};{$name};{$show};{$custom};{$ip}"; } } } // Prepare data and messages for error page if (!empty($error_fields_ids)) { to_session($mode); set_page_message(implode('<br />', array_unique($messages)), 'error'); // Prepares message for page on add } elseif ($mode) { set_page_message(tr('Service port was added!'), 'success'); // Prepares message for page on update } else { // gets the number of queries that were been executed $updt_count = $db_cfg->countQueries('update'); // An Update was been made in the database ? if ($updt_count == 1) { set_page_message(tr('%d Service port was updated!', $updt_count), 'success'); } elseif ($updt_count > 1) { set_page_message(tr('%d Services port were updated!', $updt_count), 'success'); } else { set_page_message(tr("Nothing's been changed!"), 'info'); } } }