function saveconfig($task) { global $database, $mosConfig_absolute_path; $row = new mosConfig(); if (!$row->bind($_POST)) { mosRedirect("index2.php", $row->getError()); } $editor = intval(mosGetParam($_POST, 'editor', 0)); if ($editor > 0) { $query = "UPDATE #__mambots" . "\n SET published = 0" . "\n WHERE published >= 0 AND folder='editors'"; $database->setQuery($query); $database->query() or die($database->getErrorMsg()); $query = "UPDATE #__mambots" . "\n SET published = 1" . "\n WHERE id = {$editor}"; $database->setQuery($query); $database->query() or die($database->getErrorMsg()); } $language =& new mamboLanguage($row->config_locale); $row->config_lang = $language->get('lang'); $config = "<?php \n"; $config .= $row->getVarText(); //$config .= "setlocale (LC_TIME, \$mosConfig_locale);\n"; $config .= '?>'; $fname = '../configuration.php'; $enable_write = mosGetParam($_POST, 'enable_write', 0); $oldperms = fileperms($fname); if ($enable_write) { @chmod($fname, $oldperms | 0222); } if ($fp = fopen($fname, 'w')) { fputs($fp, $config, strlen($config)); fclose($fp); if ($enable_write) { @chmod($fname, $oldperms); } else { if (mosGetParam($_POST, 'disable_write', 0)) { @chmod($fname, $oldperms & 0777555); } } // if $msg = T_('The Configuration Details have been updated'); // apply file and directory permissions if requested by user $applyFilePerms = mosGetParam($_POST, 'applyFilePerms', 0) && $row->config_fileperms != ''; $applyDirPerms = mosGetParam($_POST, 'applyDirPerms', 0) && $row->config_dirperms != ''; if ($applyFilePerms || $applyDirPerms) { $mosrootfiles = array('administrator', 'cache', 'components', 'editor', 'help', 'images', 'includes', 'parameters', 'installation', 'language', 'mambots', 'media', 'modules', 'templates', 'CHANGELOG', 'configuration.php', 'htaccess.txt', 'index.php', 'index2.php', 'index3.php', 'INSTALL', 'LICENSE', 'mainbody.php', 'offline.php', 'page404.php', 'pathway.php', 'README', 'robots.txt'); $filemode = NULL; if ($applyFilePerms) { $filemode = octdec($row->config_fileperms); } $dirmode = NULL; if ($applyDirPerms) { $dirmode = octdec($row->config_dirperms); } foreach ($mosrootfiles as $file) { mosChmodRecursive($mosConfig_absolute_path . '/' . $file, $filemode, $dirmode); } } // if switch ($task) { case 'apply': mosRedirect('index2.php?option=com_config&hidemainmenu=1', $msg); break; case 'save': default: mosRedirect('index2.php', $msg); break; } } else { if ($enable_write) { @chmod($fname, $oldperms); } mosRedirect('index2.php', T_('An Error Has Occurred! Unable to open config file to write!')); } }
function saveconfig() { global $database, $adminLanguage; $row = new mosConfig(); if (!$row->bind($_POST)) { mosRedirect("index2.php", $row->getError()); } $editor = intval(mosGetParam($_POST, 'editor', 0)); if ($editor > 0) { $query = "UPDATE #__mambots" . "\n SET published = 0" . "\n WHERE published >= 0 AND folder='editors'"; $database->setQuery($query); $database->query() or die($database->getErrorMsg()); $query = "UPDATE #__mambots" . "\n SET published = 1" . "\n WHERE id = {$editor}"; $database->setQuery($query); $database->query() or die($database->getErrorMsg()); } $config = "<?php \n"; $config .= $row->getVarText(); $config .= "setlocale (LC_TIME, \$mosConfig_locale);\n"; $config .= '?>'; if ($fp = fopen('../configuration.php', 'w')) { fputs($fp, $config, strlen($config)); fclose($fp); mosRedirect('index2.php', $adminLanguage->A_COMP_CONF_UPDATED); } else { mosRedirect('index2.php', $adminLanguage->A_COMP_CONF_ERR_OCC); } }
/** * Save the configuration */ function saveconfig($task) { global $database, $mosConfig_absolute_path, $mosConfig_password, $mosConfig_session_type; josSpoofCheck(); $row = new mosConfig(); if (!$row->bind($_POST)) { mosRedirect('index2.php', $row->getError()); } // if Session Authentication Type changed, delete all old Frontend sessions only - which used old Authentication Type if ($mosConfig_session_type != $row->config_session_type) { $past = time(); $query = "DELETE FROM #__session" . "\n WHERE time < " . $database->Quote($past) . "\n AND (" . "\n ( guest = 1 AND userid = 0 ) OR ( guest = 0 AND gid > 0 )" . "\n )"; $database->setQuery($query); $database->query(); } $server_time = date('O') / 100; $offset = $_POST['config_offset_user'] - $server_time; $row->config_offset = $offset; //override any possible database password change $row->config_password = $mosConfig_password; // handling of special characters $row->config_sitename = htmlspecialchars($row->config_sitename, ENT_QUOTES); // handling of quotes (double and single) and amp characters // htmlspecialchars not used to preserve ability to insert other html characters $row->config_offline_message = ampReplace($row->config_offline_message); $row->config_offline_message = str_replace('"', '"', $row->config_offline_message); $row->config_offline_message = str_replace("'", ''', $row->config_offline_message); // handling of quotes (double and single) and amp characters // htmlspecialchars not used to preserve ability to insert other html characters $row->config_error_message = ampReplace($row->config_error_message); $row->config_error_message = str_replace('"', '"', $row->config_error_message); $row->config_error_message = str_replace("'", ''', $row->config_error_message); $config = "<?php \n"; $RGEmulation = intval(mosGetParam($_POST, 'rgemulation', 0)); $config .= "if(!defined('RG_EMULATION')) { define( 'RG_EMULATION', {$RGEmulation} ); }\n"; $config .= $row->getVarText(); $config .= "setlocale (LC_TIME, \$mosConfig_locale);\n"; $config .= '?>'; $fname = $mosConfig_absolute_path . '/configuration.php'; $enable_write = intval(mosGetParam($_POST, 'enable_write', 0)); $oldperms = fileperms($fname); if ($enable_write) { @chmod($fname, $oldperms | 0222); } if ($fp = fopen($fname, 'w')) { fputs($fp, $config, strlen($config)); fclose($fp); if ($enable_write) { @chmod($fname, $oldperms); } else { if (mosGetParam($_POST, 'disable_write', 0)) { @chmod($fname, $oldperms & 0777555); } } // if $msg = 'Configuração atualizada com sucesso'; // apply file and directory permissions if requested by user $applyFilePerms = mosGetParam($_POST, 'applyFilePerms', 0) && $row->config_fileperms != ''; $applyDirPerms = mosGetParam($_POST, 'applyDirPerms', 0) && $row->config_dirperms != ''; if ($applyFilePerms || $applyDirPerms) { $mosrootfiles = array('administrator', 'cache', 'components', 'images', 'language', 'mambots', 'media', 'modules', 'templates', 'configuration.php'); $filemode = NULL; if ($applyFilePerms) { $filemode = octdec($row->config_fileperms); } $dirmode = NULL; if ($applyDirPerms) { $dirmode = octdec($row->config_dirperms); } foreach ($mosrootfiles as $file) { mosChmodRecursive($mosConfig_absolute_path . '/' . $file, $filemode, $dirmode); } } // if switch ($task) { case 'apply': mosRedirect('index2.php?option=com_config&hidemainmenu=1', $msg); break; case 'save': default: mosRedirect('index2.php', $msg); break; } } else { if ($enable_write) { @chmod($fname, $oldperms); } mosRedirect('index2.php', 'Ocorreu um Erro! Não foi possível abrir o arquivo de configuração em modo de escrita!'); } }