function delDir($dirName, $orig = false) { if (!$orig) { $orig = $dirName; } if (empty($dirName)) { return true; } if (file_exists($dirName)) { $dir = dir($dirName); while ($file = $dir->read()) { if ($file != '.' && $file != '..') { if (is_dir($dirName . '/' . $file)) { PommoHelperMaintenance::delDir($dirName . '/' . $file, $orig); } else { unlink($dirName . '/' . $file) or die('File ' . $dirName . '/' . $file . ' couldn\'t be deleted!'); } } } $dir->close(); if ($dirName != $orig) { @rmdir($dirName) or die('Folder ' . $dirName . ' couldn\'t be deleted!'); } } else { return false; } return true; }
function preInit() { Pommo::requireOnce($this->_baseDir . 'inc/classes/log.php'); Pommo::requireOnce($this->_baseDir . 'inc/lib/safesql/SafeSQL.class.php'); Pommo::requireOnce($this->_baseDir . 'inc/classes/db.php'); Pommo::requireOnce($this->_baseDir . 'inc/classes/auth.php'); // initialize logger $this->_logger = new PommoLog(); // NOTE -> this clears messages that may have been retained (not outputted) from logger. // read in config.php (configured by user) // TODO -> write a web-based frontend to config.php creation $config = PommoHelper::parseConfig($this->_baseDir . 'config.php'); // check to see if config.php was "properly" loaded if (count($config) < 5) { Pommo::kill('Could not read config.php'); } $this->_workDir = empty($config['workDir']) ? $this->_baseDir . 'cache' : $config['workDir']; $this->_debug = strtolower($config['debug']) != 'on' ? false : true; $this->_default_subscriber_sort = empty($config['default_subscriber_sort']) ? 'email' : $config['default_subscriber_sort']; $this->_verbosity = empty($config['verbosity']) ? 3 : $config['verbosity']; $this->_logger->_verbosity = $this->_verbosity; $this->_dateformat = $config['date_format'] >= 1 && $cofig['date_format'] <= 3 ? intval($config['date_format']) : 1; // the regex strips port info from hostname $this->_hostname = empty($config['hostname']) ? preg_replace('/:\\d+$/i', '', $_SERVER['HTTP_HOST']) : $config['hostname']; $this->_hostport = empty($config['hostport']) ? $_SERVER['SERVER_PORT'] : $config['hostport']; $this->_ssl = !isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on' ? false : true; $this->_http = ($this->_ssl ? 'https://' : 'http://') . $this->_hostname; if ($this->_hostport != 80 && $this->_hostport != 443) { $this->_http .= ':' . $this->_hostport; } $this->_language = empty($config['lang']) ? 'en' : strtolower($config['lang']); $this->_slanguage = defined('_poMMo_lang') ? _poMMo_lang : false; // include translation (l10n) methods if language is not English $this->_l10n = FALSE; if ($this->_language != 'en') { $this->_l10n = TRUE; Pommo::requireOnce($this->_baseDir . 'inc/helpers/l10n.php'); PommoHelperL10n::init($this->_language, $this->_baseDir); } // set base URL (e.g. http://mysite.com/news/pommo => 'news/pommo/') // TODO -> provide validation of baseURL ? if (isset($config['baseURL'])) { $this->_baseUrl = $config['baseURL']; } else { // If we're called from an outside (embedded) script, read baseURL from "last known good". // Else, set it based off of REQUEST if (defined('_poMMo_embed')) { Pommo::requireOnce($this->_baseDir . 'inc/helpers/maintenance.php'); $this->_baseUrl = PommoHelperMaintenance::rememberBaseURL(); } else { $baseUrl = preg_replace('@/(inc|setup|user|install|support(/tests)?|admin(/subscribers|/user|/mailings|/setup)?(/ajax|/mailing|/config)?)$@i', '', dirname($_SERVER['PHP_SELF'])); $this->_baseUrl = $baseUrl == '/' ? $baseUrl : $baseUrl . '/'; } } // make sure workDir is writable if (!is_dir($this->_workDir . '/pommo/smarty')) { $wd = $this->_workDir; $this->_workDir = null; if (!is_dir($wd)) { Pommo::kill(sprintf(Pommo::_T('Work Directory (%s) not found! Make sure it exists and the webserver can write to it. You can change its location from the config.php file.'), $wd)); } if (!is_writable($wd)) { Pommo::kill(sprintf(Pommo::_T('Cannot write to Work Directory (%s). Make sure it has the proper permissions.'), $wd)); } if (ini_get('safe_mode') == "1") { Pommo::kill(sprintf(Pommo::_T('Working Directory (%s) cannot be created under PHP SAFE MODE. See Documentation, or disable SAFE MODE.'), $wd)); } if (!is_dir($wd . '/pommo')) { if (!mkdir($wd . '/pommo')) { Pommo::kill(Pommo::_T('Could not create directory') . ' ' . $wd . '/pommo'); } } if (!mkdir($wd . '/pommo/smarty')) { Pommo::kill(Pommo::_T('Could not create directory') . ' ' . $wd . '/pommo/smarty'); } $this->_workdir = $wd; } // set the current "section" -- should be "user" for /user/* files, "mailings" for /admin/mailings/* files, etc. etc. $this->_section = preg_replace('@^admin/?@i', '', str_replace($this->_baseUrl, '', dirname($_SERVER['PHP_SELF']))); // initialize database link $this->_dbo = @new PommoDB($config['db_username'], $config['db_password'], $config['db_database'], $config['db_hostname'], $config['db_prefix']); // turn off debugging if in user area if ($this->_section == 'user') { $this->_debug = false; $this->_dbo->debug(FALSE); } // if debugging is set in config.php, enable debugging on the database. if ($this->_debug) { // don't enable debugging in ajax requests unless verbosity is < 3 if (PommoHelper::isAjax() && $this->_verbosity > 2) { $this->_debug = false; } else { $this->_dbo->debug(TRUE); } } }
if (isset($_GET['logout'])) { $pommo->_auth->logout(); header('Location: ' . $pommo->_http . $pommo->_baseUrl . 'index.php'); } // check if user is already logged in if ($pommo->_auth->isAuthenticated()) { // If user is authenticated (has logged in), redirect to admin.php Pommo::redirect($pommo->_http . $pommo->_baseUrl . 'admin/admin.php'); } elseif (isset($_POST['submit']) && !empty($_POST['username']) && !empty($_POST['password'])) { $auth = PommoAPI::configGet(array('admin_username', 'admin_password')); if ($_POST['username'] == $auth['admin_username'] && md5($_POST['password']) == $auth['admin_password']) { // don't perform maintenance if accessing support area if (!isset($_GET['referer']) || !basename($_GET['referer']) == 'support.php') { // LOGIN SUCCESS -- PERFORM MAINTENANCE, SET AUTH, REDIRECT TO REFERER Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/maintenance.php'); PommoHelperMaintenance::perform(); } $pommo->_auth->login($_POST['username']); Pommo::redirect($pommo->_http . $_POST['referer']); } else { $logger->addMsg(Pommo::_T('Failed login attempt. Try again.')); } } elseif (!empty($_POST['resetPassword'])) { // TODO -- visit this function later // Check if a reset password request has been received // check that captcha matched if (!isset($_POST['captcha'])) { // generate captcha $captcha = substr(md5(rand()), 0, 4); $smarty->assign('captcha', $captcha); } elseif ($_POST['captcha'] == $_POST['realdeal']) {
<?php /** * Copyright (C) 2005, 2006, 2007, 2008 Brice Burgess <*****@*****.**> * * This file is part of poMMo (http://www.pommo.org) * * poMMo is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2, or any later version. * * poMMo is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See * the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with program; see the file docs/LICENSE. If not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ /********************************** INITIALIZATION METHODS *********************************/ define('_poMMo_support', TRUE); require '../../bootstrap.php'; $pommo->init(); Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/maintenance.php'); echo PommoHelperMaintenance::delDir($pommo->_workDir) ? 'Work Directory Cleared' : 'Unable to Clear Work Directory -- Does it exist?';
<?php /** * Copyright (C) 2005, 2006, 2007, 2008 Brice Burgess <*****@*****.**> * * This file is part of poMMo (http://www.pommo.org) * * poMMo is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2, or any later version. * * poMMo is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See * the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with program; see the file docs/LICENSE. If not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ /********************************** INITIALIZATION METHODS *********************************/ define('_poMMo_support', TRUE); require '../../bootstrap.php'; $pommo->init(); Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/maintenance.php'); echo PommoHelperMaintenance::delDir($pommo->_workDir) ? 'Le répertoire de travail est vide.' : 'Impossible de vider le répertoire de travail -- A-t-il déjà été créé?';
$logger->addErr(sprintf(Pommo::_T('To upgrade poMMo, %s click here %s'), '<a href="' . $pommo->_baseUrl . 'install/upgrade.php?continue=TRUE">', '</a>')); } else { $smarty->assign('attempt', TRUE); if (isset($_REQUEST['debugInstall'])) { $dbo->debug(TRUE); } if (isset($_REQUEST['forceUpgrade'])) { $GLOBALS['pommoFakeUpgrade'] = true; } if (PommoUpgrade()) { $logger->addErr(Pommo::_T('Upgrade Complete!')); // Read in RELEASE Notes -- TODO -> use file_get_contents() one day when everyone has PHP 4.3 $filename = $pommo->_baseDir . 'docs/RELEASE'; $handle = fopen($filename, "r"); $x = fread($handle, filesize($filename)); fclose($handle); $smarty->assign('notes', $x); $smarty->assign('upgraded', TRUE); } else { $logger->addErr(Pommo::_T('Upgrade Failed!')); } // clear the working directory template files $smarty->display('upgrade.tpl'); Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/maintenance.php'); if (!PommoHelperMaintenance::delDir($pommo->_workDir . '/pommo/smarty')) { $logger->addErr('Unable to Clear Working Directory (non fatal)'); } Pommo::kill(); } $smarty->display('upgrade.tpl'); Pommo::kill();