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)) { Pommo_Helper_Maintenance::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; }
<?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(); require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Maintenance.php'; echo Pommo_Helper_Maintenance::delDir(Pommo::$_workDir) ? 'Work Directory Cleared' : 'Unable to Clear Work Directory -- Does it exist?';
$logger->addErr(sprintf(Pommo::_T('To upgrade poMMo, %s click here %s'), '<a href="' . Pommo::$_baseUrl . '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'); require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Maintenance.php'; if (!Pommo_Helper_Maintenance::delDir(Pommo::$_workDir . '/pommo/smarty')) { $logger->addErr('Unable to Clear Working Directory (non fatal)'); } Pommo::kill(); } $smarty->display('upgrade.tpl'); Pommo::kill();