/** * Chmods files and directories recursively to given permissions * @param path The starting file or directory (no trailing slash) * @param filemode Integer value to chmod files. NULL = dont chmod files. * @param dirmode Integer value to chmod directories. NULL = dont chmod directories. * @return TRUE=all succeeded FALSE=one or more chmods failed */ function mosChmodRecursive($path, $filemode = NULL, $dirmode = NULL) { $ret = TRUE; if (is_dir($path)) { $dh = opendir($path); while ($file = readdir($dh)) { if ($file != '.' && $file != '..') { $fullpath = $path . '/' . $file; if (is_dir($fullpath)) { if (!mosChmodRecursive($fullpath, $filemode, $dirmode)) { $ret = FALSE; } } else { if (isset($filemode)) { if (!@chmod($fullpath, $filemode)) { $ret = FALSE; } } } // if } // if } // while closedir($dh); if (isset($dirmode)) { if (!@chmod($path, $dirmode)) { $ret = FALSE; } } } else { if (isset($filemode)) { $ret = @chmod($path, $filemode); } } // if return $ret; }
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!')); } }
$database->query(); // chmod files and directories if desired $chmod_report = "Permissões de Diretórios e Arquivos não alteradas."; if ($filePerms != '' || $dirPerms != '') { $mosrootfiles = array('administrator', 'cache', 'components', 'images', 'language', 'mambots', 'media', 'modules', 'templates', 'configuration.php'); $filemode = NULL; if ($filePerms != '') { $filemode = octdec($filePerms); } $dirmode = NULL; if ($dirPerms != '') { $dirmode = octdec($dirPerms); } $chmodOk = TRUE; foreach ($mosrootfiles as $file) { if (!mosChmodRecursive($absolutePath . '/' . $file, $filemode, $dirmode)) { $chmodOk = FALSE; } } if ($chmodOk) { $chmod_report = 'Permissões de Diretórios e Arquivos alteradas com sucesso.'; } else { $chmod_report = 'As Permissões dos Diretórios não puderam ser alteradas.<br />' . 'Por favor, altere manualmente as permissões de arquivos (CHOMOD 0644), diretórios gerais (CHOMOD 0755) e diretórios de media e cache do Joomla! (CHOMOD 0766) ou instale o componente joomlaXplorer.'; } } // if chmod wanted } else { ?> <form action="install3.php" method="post" name="stepBack3" id="stepBack3"> <input type="hidden" name="DBhostname" value="<?php echo $DBhostname;
/** * 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!'); } }
function changeFCKChmod($path_root = '') { //set core plugin permissons // Try to recover from bad chmod settings if (!defined('JFCK_BASE')) { define('JFCK_BASE', $path_root . 'mambots/editors/fckeditor/editor'); } //file manager plugin $dir = JFCK_BASE . '/filemanager'; $perms = fileperms($path_root . 'index.php'); $default_fperms = '0644'; $default_dperms = '0755'; if (!stristr(PHP_OS, 'WIN') && file_exists($dir . '/connectors/php/connector.php') && canChmodFCK($dir . '/connectors/php/connector.php') && decoct($perms & 0777) != decoct(fileperms($dir) & 0777)) { $oldumask = umask(0); if (decoct($perms & 0777) == 755) { @chmod(JFCK_BASE, 0755); @chmod($dir, 0755); mosChmodRecursive($dir, 0644, 0755); } else { $default_fperms = '0666'; $default_dperms = '0777'; @chmod(JFCK_BASE, 0777); @chmod($dir, 0777); mosChmodRecursive($dir, 0666, 0777); } // About plugin $dir = JFCK_BASE . '/dialog'; @chmod($dir, octdec($default_dperms)); @chmod($dir . '/about.php', octdec($default_dperms)); //JLink plugin $dir = JFCK_BASE . '/plugins'; @chmod($dir, octdec($default_dperms)); @chmod($dir . '/jlink', octdec($default_dperms)); @chmod($dir . '/jlink/suggest.php', octdec($default_fperms)); @chmod($dir . '/jlink/suggest.class.php', octdec($default_fperms)); //SpellCheck plugin $dir = JFCK_BASE . '/plugins/pspellcheck'; @chmod($dir, octdec($default_dperms)); @chmod($dir . '/spellcheck', octdec($default_dperms)); @chmod($dir . '/spellcheck/spellchecker.php', octdec($default_fperms)); umask($oldumask); } }
/** * Chmods files and directories recursively to mos global permissions. Available from 1.0.0 up. * @param path The starting file or directory (no trailing slash) * @param filemode Integer value to chmod files. NULL = dont chmod files. * @param dirmode Integer value to chmod directories. NULL = dont chmod directories. * @return TRUE=all succeeded FALSE=one or more chmods failed */ function mosChmod($path) { global $mosConfig_fileperms, $mosConfig_dirperms; $filemode = NULL; if ($mosConfig_fileperms != '') { $filemode = octdec($mosConfig_fileperms); } $dirmode = NULL; if ($mosConfig_dirperms != '') { $dirmode = octdec($mosConfig_dirperms); } if (isset($filemode) || isset($dirmode)) { return mosChmodRecursive($path, $filemode, $dirmode); } return TRUE; }