function Initialize() { global $errors, $t, $C, $template; // Already initialized if (!empty($C['db_username'])) { $t->assign('mode', 'done'); echo $t->parse($template); } else { // Form submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { $connection = TestDBConnection(); if (!$connection) { $t->assign_by_ref('errors', $errors); $t->assign_by_ref('request', $_REQUEST); $t->assign('mode', 'getdb'); echo $t->parse($template); } else { // Create database tables and setup initial login FileWrite("{$GLOBALS['BASE_DIR']}/data/.htaccess", "deny from all"); CreateTables(); WriteConfig($_REQUEST); RecompileTemplates(); // Display initialization finished screen $t->assign('control_panel', "http://{$_SERVER['HTTP_HOST']}" . dirname($_SERVER['REQUEST_URI']) . "/index.php"); $t->assign('mode', 'login'); echo $t->parse($template); } } else { // Run pre-initialization tests ServerTest(); FilesTest(); DirectoriesTest(); TemplatesTest(); if (is_dir('../utilities')) { $errors[] = 'For security purposes, the utilities directory must be removed'; } if (count($errors)) { // Display failed test information $t->assign('mode', 'errors'); $t->assign_by_ref('errors', $errors); echo $t->parse($template); } else { $_REQUEST['db_hostname'] = 'localhost'; $t->assign_by_ref('request', $_REQUEST); $t->assign_by_ref('errors', $errors); $t->assign('mode', 'getdb'); echo $t->parse($template); } } } }
function ReadConfig($configname = NULL) { global $CONFIGURATIONS; if ($configname) { $configname = basename($configname); $tmp = oldReadConfig($configname); WriteConfig($configname, $tmp); @unlink('./config/' . $configname); return $tmp; } else { foreach ($CONFIGURATIONS as $CONFIGURATION) { $GLOBALS[$CONFIGURATION] = ReadConfig($CONFIGURATION); } } }
function ChangeMysql() { global $errors, $t, $C, $template; // Form submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { $connection = TestDBConnection(); if (!$connection) { $t->assign_by_ref('errors', $errors); $t->assign_by_ref('request', $_REQUEST); $t->assign('mode', 'getdb'); } else { // Write data to configuration file WriteConfig($_REQUEST); $t->assign('mode', 'done'); } } else { $_REQUEST['db_hostname'] = 'localhost'; $t->assign_by_ref('request', $_REQUEST); $t->assign('mode', 'getdb'); } echo $t->parse($template); }
private function createConfig() { require $this->directusPath . '/installation/config_setup.php'; $options = $this->options; foreach ($options as $key => $value) { switch ($key) { case 'h': case 'host': $options['db_host'] = $value; unset($options[$key]); break; case 'n': case 'name': $options['db_name'] = $value; unset($options[$key]); break; case 'u': case 'user': $options['db_user'] = $value; unset($options[$key]); break; case 'p': case 'pass': $options['db_pass'] = $value; unset($options[$key]); break; case 'd': case 'dir': $options['directus_path'] = $value; unset($options[$key]); break; } } WriteConfig($options, $this->directusPath); $this->clear(); }
ShowMsg('布尔变量值必须为\'Y\'或\'N\'!', $gourl); exit; } if ($dosql->GetOne("SELECT `varname` FROM `#@__webconfig` WHERE varname='{$varname}'")) { ShowMsg('该变量名称已经存在!', $gourl); exit; } //获取OrderID $row = $dosql->GetOne("SELECT MAX(orderid) AS orderid FROM `#@__webconfig`"); $orderid = $row['orderid'] + 1; $sql = "INSERT INTO `#@__webconfig` (siteid, varname, varinfo, varvalue, vartype, vargroup, orderid) VALUES ('{$cfg_siteid}', '{$varname}', '{$varinfo}', '{$varvalue}', '{$vartype}', '{$vargroup}', '{$orderid}')"; if (!$dosql->ExecNoneQuery($sql)) { ShowMsg('新增变量失败,可能有非法字符!', $gourl); exit; } WriteConfig(); ShowMsg('成功保存变量并更新配置文件!', $gourl); exit; } //保存水印设置 if ($action == 'update_wmk') { $vars = array('cfg_markswitch', 'cfg_marktype', 'cfg_markminwidth', 'cfg_markminheight', 'cfg_markpicurl', 'cfg_marktext', 'cfg_markcolor', 'cfg_marksize', 'cfg_markwhere'); $str = ''; foreach ($vars as $v) { ${$v} = str_replace("'", "", ${$v}); $str .= "\${$v} = '" . ${$v} . "';\r\n"; } $str = '<?php if(!defined(\'IN_PHPMYWIND\')) exit(\'Request Error!\');' . "\r\n\r\n" . $str . "\r\n" . '?>'; if (Writef($watermark_inc, $str)) { ShowMsg('成功更新水印配置!', $gourl); exit;
/** * This function handles updating the configuration *@return boolean */ function UpdatePostieConfig($data) { SetupConfiguration(); $key_arrays = GetListOfArrayConfig(); $config = GetDBConfig(); foreach ($config as $key => $value) { if (isset($data[$key])) { if (in_array($key, $key_arrays)) { //This is stored as an array $data[$key] = trim($data[$key]); if (strstr($data[$key], "\n")) { $delim = "\n"; } else { $delim = ','; } $config[$key] = array(); $values = explode($delim, $data[$key]); foreach ($values as $item) { if (trim($item)) { $config[$key][] = trim($item); } } } else { $config[$key] = FilterNewLines($data[$key]); } } } WriteConfig($config); UpdatePostiePermissions($data["ROLE_ACCESS"]); // If we are using cronless, we also update the cronless events if ($config['CRONLESS'] != '') { postie_decron(); postie_cron(); } return 1; }
/** * This function handles updating the configuration *@return boolean */ function UpdatePostieConfig($data) { SetupConfiguration(); $key_arrays = GetListOfArrayConfig(); $config = GetDBConfig(); foreach ($config as $key => $value) { if (isset($data[$key])) { if (in_array($key, $key_arrays)) { //This is stored as an array $config[$key] = array(); $values = explode("\n", $data[$key]); foreach ($values as $item) { if (trim($item)) { $config[$key][] = trim($item); } } } else { $config[$key] = $data[$key]; } } } WriteConfig($config); UpdatePostiePermissions($data["ROLE_ACCESS"]); return 1; }
foreach ($validConfig as $config) { $ATTACHMENT[$config] = ${$config}; } WriteConfig('ATTACHMENT', $ATTACHMENT); $actiontime = date("F j, Y, g:i a"); write_log("Tracker ATTACHMENT settings updated by {$CURUSER['username']}. {$actiontime}", 'mod'); go_back(); } elseif ($action == 'savesettings_advertisement') { stdhead($lang_settings['head_save_advertisement_settings']); $validConfig = array('enablead', 'enablenoad', 'noad', 'enablebonusnoad', 'bonusnoad', 'bonusnoadpoint', 'bonusnoadtime', 'adclickbonus'); GetVar($validConfig); unset($ADVERTISEMENT); foreach ($validConfig as $config) { $ADVERTISEMENT[$config] = ${$config}; } WriteConfig('ADVERTISEMENT', $ADVERTISEMENT); $actiontime = date("F j, Y, g:i a"); write_log("Tracker ADVERTISEMENT settings updated by {$CURUSER['username']}. {$actiontime}", 'mod'); go_back(); } elseif ($action == 'tweaksettings') { stdhead($lang_settings['head_tweak_settings']); print $notice; print "<form method='post' action='" . $_SERVER["SCRIPT_NAME"] . "'><input type='hidden' name='action' value='savesettings_tweak' />"; yesorno($lang_settings['row_save_user_location'], 'where', $TWEAK["where"], $lang_settings['text_save_user_location_note']); yesorno($lang_settings['row_log_user_ips'], 'iplog1', $TWEAK["iplog1"], $lang_settings['text_store_user_ips_note']); tr($lang_settings['row_kps_enabled'], "<input type='radio' id='bonusenable' name='bonus'" . ($TWEAK["bonus"] == "enable" ? " checked='checked'" : "") . " value='enable' /> <label for='bonusenable'>" . $lang_settings['text_enabled'] . "</label> <input type='radio' id='bonusdisablesave' name='bonus'" . ($TWEAK["bonus"] == "disablesave" ? " checked='checked'" : "") . " value='disablesave' /> <label for='bonusdisablesave'>" . $lang_settings['text_disabled_but_save'] . "</label> <input type='radio' id='bonusdisable' name='bonus'" . ($TWEAK["bonus"] == "disable" ? " checked='checked'" : "") . " value='disable' /> <label for='bonusdisable'>" . $lang_settings['text_disabled_no_save'] . "</label> <br />" . $lang_settings['text_kps_note'], 1); yesorno($lang_settings['row_enable_location'], 'enablelocation', $TWEAK["enablelocation"], $lang_settings['text_enable_location_note']); yesorno($lang_settings['row_enable_tooltip'], 'enabletooltip', $TWEAK["enabletooltip"], $lang_settings['text_enable_tooltip_note']); tr($lang_settings['row_title_keywords'], "<input type='text' style=\"width: 300px\" name='titlekeywords' value='" . ($TWEAK["titlekeywords"] ? $TWEAK["titlekeywords"] : '') . "' /> <br />" . $lang_settings['text_title_keywords_note'], 1); tr($lang_settings['row_promotion_link_example_image'], "<input type='text' style=\"width: 300px\" name='prolinkimg' value='" . ($TWEAK["prolinkimg"] ? $TWEAK["prolinkimg"] : 'pic/prolink.png') . "' /> <br />" . $lang_settings['text_promotion_link_example_note'], 1); tr($lang_settings['row_meta_keywords'], "<input type='text' style=\"width: 300px\" name='metakeywords' value='" . ($TWEAK["metakeywords"] ? $TWEAK["metakeywords"] : '') . "' /> <br />" . $lang_settings['text_meta_keywords_note'], 1);
</tr> <tr> <td class="item">Database Name</td> <td class="result">' . $_SESSION['db_name'] . '</td> </tr> </tbody> </table> <h3>Config File</h3><textarea>' . $configText . '</textarea></html>'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($_SESSION['email'], "Directus Install Config Overview", $mailBody, $headers); } $mysqli->close(); require_once 'config_setup.php'; WriteConfig(array('db_host' => $_SESSION['host_name'], 'db_name' => $_SESSION['db_name'], 'db_user' => $_SESSION['username'], 'db_pass' => $_SESSION['db_password'], 'db_prefix' => '', 'directus_path' => $_SESSION['directus_path'])); // @TODO: put all this data into an array. // so we can clear all session unset($_SESSION['installation']); $install_data = array('step', 'email', 'site_name', 'password', 'directus_path', 'host_name', 'username', 'db_password', 'db_name', 'db_prefix', 'install_sample', 'default_dest', 'default_url', 'thumb_dest', 'thumb_url', 'temp_dest', 'temp_url', 'send_config_email'); foreach ($_SESSION as $key => $value) { if (in_array($key, $install_data)) { unset($_SESSION[$key]); } } header('Location: ../'); } ?> <script>var step = <?php echo $step; ?> ;</script>
function lxSaveGeneralSettings() { global $C; VerifyAdministrator(); CheckAccessList(); $server = GetServerCapabilities(); $GLOBALS['_server_'] = $server; $v = new Validator(); $required = array('base_url' => 'Base URL', 'cookie_domain' => 'Cookie Domain', 'from_email' => 'E-mail Address', 'from_email_name' => 'E-mail Name', 'page_new' => 'New Links Page', 'page_popular' => 'Popular Links Page', 'page_top' => 'Top Links Page', 'page_details' => 'Link Details Page', 'extension' => 'File Extension', 'date_format' => 'Date Format', 'time_format' => 'Time Format', 'dec_point' => 'Decimal Point', 'thousands_sep' => 'Thousands Separator', 'min_desc_length' => 'Minimum Description Length', 'max_desc_length' => 'Maximum Description Length', 'min_title_length' => 'Maximum Title Length', 'max_title_length' => 'Maximum Title Length', 'max_keywords' => 'Maximum Keywords', 'link_weight' => 'Default Link Weight', 'min_comment_length' => 'Maximum Comment Length', 'max_comment_length' => 'Maximum Comment Length', 'max_rating' => 'Maximum Rating', 'font_dir' => 'Font Directory', 'min_code_length' => 'Minimum Code Length', 'max_code_length' => 'Maximum Code Length', 'cache_index' => 'Index Page Cache', 'cache_category' => 'Category Page Cache', 'cache_new' => 'New Link Page Cache', 'cache_popular' => 'Popular Links Page Cache', 'cache_top' => 'Top Links Page Cache', 'cache_search' => 'Search Page Cache', 'cache_details' => 'Details Page Cache'); foreach ($required as $field => $name) { $v->Register($_REQUEST[$field], V_EMPTY, "The {$name} field is required"); } if ($v->Validate()) { if (!preg_match('~%d~', $_REQUEST['page_details'])) { if (strpos($_REQUEST['page_details'], '.') === FALSE) { $_REQUEST['page_details'] .= "%d"; } else { $_REQUEST['page_details'] = preg_replace('~\\.([^.]*)$~', '%d.$1', $_REQUEST['page_details']); } } $_REQUEST['extension'] = preg_replace('~^\\.~', '', $_REQUEST['extension']); $_REQUEST['base_url'] = preg_replace('~/$~', '', $_REQUEST['base_url']); $_REQUEST['domain'] = preg_replace('~^www\\.~', '', $_SERVER['HTTP_HOST']); $_REQUEST = array_merge($server, $_REQUEST); WriteConfig($_REQUEST); $GLOBALS['message'] = 'Your settings have been successfully updated'; } else { $C = array_merge($C, $_REQUEST); $GLOBALS['errstr'] = join('<br />', $v->GetErrors()); } lxShGeneralSettings(); }
foreach ($validConfig as $config) { $ADVERTISEMENT[$config] = ${$config}; } WriteConfig('ADVERTISEMENT', $ADVERTISEMENT); $actiontime = date("F j, Y, g:i a"); write_log("Tracker ADVERTISEMENT settings updated by {$CURUSER['username']}. {$actiontime}", 'mod'); go_back(); } elseif ($action == "savesettings_federation") { stdhead($lang_settings['head_save_federation_settings']); $validConfig = array('cc98clientid', 'cc98clientsecret', 'cc98redirecturi'); GetVar($validConfig); unset($FEDERATION); foreach ($validConfig as $config) { $FEDERATION[$config] = ${$config}; } WriteConfig('FEDERATION', $FEDERATION); $actiontime = date("F j, Y, g:i a"); write_log("Tracker FEDERATION settings updated by {$CURUSER['username']}. {$actiontime}", 'mod'); go_back(); } elseif ($action == 'tweaksettings') { stdhead($lang_settings['head_tweak_settings']); print $notice; print "<form method='post' action='" . $_SERVER["SCRIPT_NAME"] . "'><input type='hidden' name='action' value='savesettings_tweak' />"; yesorno($lang_settings['row_save_user_location'], 'where', $TWEAK["where"], $lang_settings['text_save_user_location_note']); yesorno($lang_settings['row_log_user_ips'], 'iplog1', $TWEAK["iplog1"], $lang_settings['text_store_user_ips_note']); tr($lang_settings['row_kps_enabled'], "<input type='radio' id='bonusenable' name='bonus'" . ($TWEAK["bonus"] == "enable" ? " checked='checked'" : "") . " value='enable' /> <label for='bonusenable'>" . $lang_settings['text_enabled'] . "</label> <input type='radio' id='bonusdisablesave' name='bonus'" . ($TWEAK["bonus"] == "disablesave" ? " checked='checked'" : "") . " value='disablesave' /> <label for='bonusdisablesave'>" . $lang_settings['text_disabled_but_save'] . "</label> <input type='radio' id='bonusdisable' name='bonus'" . ($TWEAK["bonus"] == "disable" ? " checked='checked'" : "") . " value='disable' /> <label for='bonusdisable'>" . $lang_settings['text_disabled_no_save'] . "</label> <br />" . $lang_settings['text_kps_note'], 1); yesorno($lang_settings['row_casino_enabled'], 'enable_casino', $TWEAK["enable_casino"], $lang_settings['text_enable_casino_note']); tr($lang_settings['row_casino_min_bonus'], "<input type='text' style=\"width: 50px\" name='casino_min_bonus' value='" . ($TWEAK["casino_min_bonus"] ? $TWEAK["casino_min_bonus"] : '') . "' /> " . $lang_settings['text_casino_min_bonus_note'], 1); yesorno($lang_settings['row_enable_location'], 'enablelocation', $TWEAK["enablelocation"], $lang_settings['text_enable_location_note']); yesorno($lang_settings['row_enable_tooltip'], 'enabletooltip', $TWEAK["enabletooltip"], $lang_settings['text_enable_tooltip_note']); tr($lang_settings['row_title_keywords'], "<input type='text' style=\"width: 300px\" name='titlekeywords' value='" . ($TWEAK["titlekeywords"] ? $TWEAK["titlekeywords"] : '') . "' /> <br />" . $lang_settings['text_title_keywords_note'], 1);
function txGeneralSettingsSave() { global $C; VerifyAdministrator(); CheckAccessList(); $server = GetServerCapabilities(); $GLOBALS['_server_'] = $server; $v = new Validator(); $required = array('document_root' => 'Document Root', 'install_url' => 'TGPX URL', 'cookie_domain' => 'Cookie Domain', 'from_email' => 'E-mail Address', 'from_email_name' => 'E-mail Name', 'date_format' => 'Date Format', 'time_format' => 'Time Format', 'dec_point' => 'Decimal Point', 'thousands_sep' => 'Thousands Separator', 'max_submissions' => 'Global Submissions Per Day', 'submissions_per_person' => 'Submissions Per Person', 'max_links' => 'Maximum Links Allowed', 'min_desc_length' => 'Minimum Description Length', 'max_desc_length' => 'Maximum Description Length', 'min_thumb_size' => 'Minimum Gallery Thumb Size', 'max_thumb_size' => 'Maximum Gallery Thumb Size', 'max_keywords' => 'Maximum Keywords', 'gallery_weight' => 'Default Gallery Weight', 'font_dir' => 'Font Directory', 'min_code_length' => 'Minimum Code Length', 'max_code_length' => 'Maximum Code Length', 'permanent_hold' => 'Permanent Holding Period', 'submitted_hold' => 'Submitted Holding Period', 'page_permissions' => 'Page Permissions'); if ($_REQUEST['allow_multiple_cats']) { $required['max_categories'] = 'Maximum Categories'; } foreach ($required as $field => $name) { $v->Register($_REQUEST[$field], V_EMPTY, "The {$name} field is required"); } $v->Register($_REQUEST['min_thumb_size'], V_REGEX, "The 'Minimum Gallery Thumb Size' value must be in WxH format", '~\\d+x\\d+~'); $v->Register($_REQUEST['max_thumb_size'], V_REGEX, "The 'Maximum Gallery Thumb Size' value must be in WxH format", '~\\d+x\\d+~'); if (!$v->Validate()) { $C = array_merge($C, $_REQUEST); return $v->ValidationError('txShGeneralSettings'); } if (!isset($_REQUEST['compression'])) { $_REQUEST['compression'] = 80; } list($_REQUEST['min_thumb_width'], $_REQUEST['min_thumb_height']) = explode('x', trim($_REQUEST['min_thumb_size'])); list($_REQUEST['max_thumb_width'], $_REQUEST['max_thumb_height']) = explode('x', trim($_REQUEST['max_thumb_size'])); $_REQUEST['document_root'] = preg_replace('~/$~', '', $_REQUEST['document_root']); $_REQUEST['install_url'] = preg_replace('~/$~', '', $_REQUEST['install_url']); $_REQUEST['preview_url'] = preg_replace('~/$~', '', $_REQUEST['preview_url']); $_REQUEST['domain'] = preg_replace('~^www\\.~', '', $_SERVER['HTTP_HOST']); $_REQUEST['preview_dir'] = DirectoryFromRoot($_REQUEST['document_root'], $_REQUEST['preview_url']); $_REQUEST = array_merge($server, $_REQUEST); WriteConfig($_REQUEST); CleanupThumbSizes(); $GLOBALS['message'] = 'Your settings have been successfully updated'; txShGeneralSettings(); }
function tlxGeneralSettingsSave() { global $C; VerifyAdministrator(); CheckAccessList(); $server = GetServerCapabilities(); $GLOBALS['_server_'] = $server; $v = new Validator(); $required = array('document_root' => 'Document Root', 'install_url' => 'ToplistX URL', 'cookie_domain' => 'Cookie Domain', 'from_email' => 'E-mail Address', 'from_email_name' => 'E-mail Name', 'date_format' => 'Date Format', 'time_format' => 'Time Format', 'dec_point' => 'Decimal Point', 'thousands_sep' => 'Thousands Separator', 'secret_key' => 'Secret Key', 'forward_url' => 'Default Forward URL', 'alternate_out_url' => 'Alternate Out URL', 'redirect_code' => 'Redirect Status Code', 'max_rating' => 'Maximum Site Rating', 'min_comment_length' => 'Minimum Comment Length', 'max_comment_length' => 'Maximum Comment Length', 'comment_interval' => 'Comment Interval', 'min_desc_length' => 'Minimum Description Length', 'max_desc_length' => 'Maximum Description Length', 'max_keywords' => 'Maximum Keywords', 'return_percent' => 'Default Return Percent', 'banner_max_width' => 'Maximum Banner Width', 'banner_max_height' => 'Maximum Banner Height', 'banner_max_bytes' => 'Maximum Banner Filesize', 'font_dir' => 'Font Directory', 'min_code_length' => 'Minimum Code Length', 'max_code_length' => 'Maximum Code Length'); if (!$_REQUEST['using_cron']) { $required['rebuild_interval'] = 'Rebuild Interval'; $v->Register($_REQUEST['rebuild_interval'], V_GREATER_EQ, 'The Rebuild Interval must be 60 or larger', 60); } foreach ($required as $field => $name) { $v->Register($_REQUEST[$field], V_EMPTY, "The {$name} field is required"); } $_REQUEST['return_percent'] /= 100; $_REQUEST['document_root'] = preg_replace('~/$~', '', $_REQUEST['document_root']); $_REQUEST['install_url'] = preg_replace('~/$~', '', $_REQUEST['install_url']); $_REQUEST['domain'] = preg_replace('~^www\\.~', '', $_SERVER['HTTP_HOST']); $_REQUEST['banner_dir'] = DirectoryFromRoot($_REQUEST['document_root'], $_REQUEST['banner_url']); if (!$v->Validate()) { $C = array_merge($C, $_REQUEST); return $v->ValidationError('tlxShGeneralSettings'); } $_REQUEST = array_merge($server, $_REQUEST); WriteConfig($_REQUEST); $GLOBALS['message'] = 'Your settings have been successfully updated'; tlxShGeneralSettings(); }
DoValidImg($imgid); break; case "delcomimg": DelComImg($id, $picid); break; case "rename": if ($actualname == $newname) { redirect_url($ThisRedo); } ChangeName($type, $gcid, $newname, $newgalcat, $newacces); break; case "config": PrintFormConfig(); break; case "wrtconfig": WriteConfig($maxszimg, $maxszthb, $nbimlg, $nbimpg, $nbimcomment, $nbimvote, $viewalea, $viewlast, $votegal, $commgal, $votano, $comano, $postano, $notifadmin); break; case "import": import(); break; case "massimport": massimport($imggal, $descri); break; case "export": PrintExportCat(); break; case "massexport": MassExportCat($cat); break; case "ordre": ordre($img_id, $ordre);