本文整理汇总了PHP中System::rm方法的典型用法代码示例。如果您正苦于以下问题:PHP System::rm方法的具体用法?PHP System::rm怎么用?PHP System::rm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System::rm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processAction
function processAction($action)
{
$this->debug("Action: {$action['action']} on {$action['path']}");
switch ($action['action']) {
case 'M':
// modified
// modified
case 'A':
// added.
/* how to handle moves?? */
// is it a file or directory?
if ($this->isDir($action['path'])) {
if (!file_exists($this->target . $action['path'])) {
require_once 'System.php';
System::mkdir(array('-p', $this->target . $action['path']));
}
return;
}
$this->writeFile($this->target . $action['path'], svn_cat($this->repos . $action['path'], $this->rev));
return;
case 'D':
// deleted.
if (file_exists($this->target . $action['path'])) {
require_once 'System.php';
System::rm($this->target . $action['path']);
}
return;
case 'R':
// replaced????
return;
}
}
示例2: build
/**
* Build an extension from source. Runs "phpize" in the source
* directory, but compiles in a temporary directory
* (/var/tmp/pear-build-USER/PACKAGE-VERSION).
*
* @param string|PEAR_PackageFile_v* $descfile path to XML package description file, or
* a PEAR_PackageFile object
*
* @param mixed $callback callback function used to report output,
* see PEAR_Builder::_runCommand for details
*
* @return array an array of associative arrays with built files,
* format:
* array( array( 'file' => '/path/to/ext.so',
* 'php_api' => YYYYMMDD,
* 'zend_mod_api' => YYYYMMDD,
* 'zend_ext_api' => YYYYMMDD ),
* ... )
*
* @access public
*
* @see PEAR_Builder::_runCommand
*/
function build($descfile, $callback = null)
{
$this->current_callback = $callback;
if (PEAR_OS == "Windows") {
return $this->_build_win32($descfile, $callback);
}
if (PEAR_OS != 'Unix') {
return $this->raiseError("building extensions not supported on this platform");
}
if (is_object($descfile)) {
$pkg = $descfile;
$descfile = $pkg->getPackageFile();
if (is_a($pkg, 'PEAR_PackageFile_v1')) {
$dir = dirname($descfile);
} else {
$dir = $pkg->_config->get('temp_dir') . '/' . $pkg->getName();
// automatically delete at session end
$this->addTempFile($dir);
}
} else {
$pf =& new PEAR_PackageFile($this->config);
$pkg =& $pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($pkg)) {
return $pkg;
}
$dir = dirname($descfile);
}
$old_cwd = getcwd();
if (!file_exists($dir) || !is_dir($dir) || !chdir($dir)) {
return $this->raiseError("could not chdir to {$dir}");
}
$vdir = $pkg->getPackage() . '-' . $pkg->getVersion();
if (is_dir($vdir)) {
chdir($vdir);
}
$dir = getcwd();
$this->log(2, "building in {$dir}");
putenv('PATH=' . $this->config->get('bin_dir') . ':' . getenv('PATH'));
$err = $this->_runCommand("phpize", array(&$this, 'phpizeCallback'));
if (PEAR::isError($err)) {
return $err;
}
if (!$err) {
return $this->raiseError("`phpize' failed");
}
// {{{ start of interactive part
$configure_command = "{$dir}/configure";
$configure_options = $pkg->getConfigureOptions();
if ($configure_options) {
foreach ($configure_options as $o) {
$default = array_key_exists('default', $o) ? $o['default'] : null;
list($r) = $this->ui->userDialog('build', array($o['prompt']), array('text'), array($default));
if (substr($o['name'], 0, 5) == 'with-' && ($r == 'yes' || $r == 'autodetect')) {
$configure_command .= " --{$o['name']}";
} else {
$configure_command .= " --{$o['name']}=" . trim($r);
}
}
}
// }}} end of interactive part
// FIXME make configurable
if (!($user = getenv('USER'))) {
$user = 'defaultuser';
}
$build_basedir = "/var/tmp/pear-build-{$user}";
$build_dir = "{$build_basedir}/{$vdir}";
$inst_dir = "{$build_basedir}/install-{$vdir}";
$this->log(1, "building in {$build_dir}");
if (is_dir($build_dir)) {
System::rm(array('-rf', $build_dir));
}
if (!System::mkDir(array('-p', $build_dir))) {
return $this->raiseError("could not create build dir: {$build_dir}");
}
$this->addTempFile($build_dir);
if (!System::mkDir(array('-p', $inst_dir))) {
return $this->raiseError("could not create temporary install dir: {$inst_dir}");
//.........这里部分代码省略.........
示例3: build
/**
* Build an extension from source. Runs "phpize" in the source
* directory, but compiles in a temporary directory
* (/var/tmp/pear-build-USER/PACKAGE-VERSION).
*
* @param string $descfile path to XML package description file
*
* @param mixed $callback callback function used to report output,
* see PEAR_Builder::_runCommand for details
*
* @return array an array of associative arrays with built files,
* format:
* array( array( 'file' => '/path/to/ext.so',
* 'php_api' => YYYYMMDD,
* 'zend_mod_api' => YYYYMMDD,
* 'zend_ext_api' => YYYYMMDD ),
* ... )
*
* @access public
*
* @see PEAR_Builder::_runCommand
* @see PEAR_Common::infoFromDescriptionFile
*/
function build($descfile, $callback = null)
{
if (PEAR_OS == "Windows") {
return $this->_build_win32($descfile, $callback);
}
if (PEAR_OS != 'Unix') {
return $this->raiseError("building extensions not supported on this platform");
}
if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) {
return $info;
}
$dir = dirname($descfile);
$old_cwd = getcwd();
if (!@chdir($dir)) {
return $this->raiseError("could not chdir to {$dir}");
}
$vdir = "{$info['package']}-{$info['version']}";
if (is_dir($vdir)) {
chdir($vdir);
}
$dir = getcwd();
$this->log(2, "building in {$dir}");
$this->current_callback = $callback;
putenv('PATH=' . $this->config->get('bin_dir') . ':' . getenv('PATH'));
$err = $this->_runCommand("phpize", array(&$this, 'phpizeCallback'));
if (PEAR::isError($err)) {
return $err;
}
if (!$err) {
return $this->raiseError("`phpize' failed");
}
// {{{ start of interactive part
$configure_command = "{$dir}/configure";
if (isset($info['configure_options'])) {
foreach ($info['configure_options'] as $o) {
list($r) = $this->ui->userDialog('build', array($o['prompt']), array('text'), array(@$o['default']));
if (substr($o['name'], 0, 5) == 'with-' && ($r == 'yes' || $r == 'autodetect')) {
$configure_command .= " --{$o['name']}";
} else {
$configure_command .= " --{$o['name']}=" . trim($r);
}
}
}
// }}} end of interactive part
// FIXME make configurable
if (!($user = getenv('USER'))) {
$user = 'defaultuser';
}
$build_basedir = "/var/tmp/pear-build-{$user}";
$build_dir = "{$build_basedir}/{$info['package']}-{$info['version']}";
$inst_dir = "{$build_basedir}/install-{$info['package']}-{$info['version']}";
$this->log(1, "building in {$build_dir}");
if (is_dir($build_dir)) {
System::rm('-rf', $build_dir);
}
if (!System::mkDir(array('-p', $build_dir))) {
return $this->raiseError("could not create build dir: {$build_dir}");
}
$this->addTempFile($build_dir);
if (!System::mkDir(array('-p', $inst_dir))) {
return $this->raiseError("could not create temporary install dir: {$inst_dir}");
}
$this->addTempFile($inst_dir);
if (getenv('MAKE')) {
$make_command = getenv('MAKE');
} else {
$make_command = 'make';
}
$to_run = array($configure_command, $make_command, "{$make_command} INSTALL_ROOT=\"{$inst_dir}\" install", "find \"{$inst_dir}\" -ls");
if (!@chdir($build_dir)) {
return $this->raiseError("could not chdir to {$build_dir}");
}
putenv('PHP_PEAR_VERSION=1.3.5');
foreach ($to_run as $cmd) {
$err = $this->_runCommand($cmd, $callback);
if (PEAR::isError($err)) {
chdir($old_cwd);
//.........这里部分代码省略.........
示例4: build
/**
* Build an extension from source. Runs "phpize" in the source
* directory, but compiles in a temporary directory
* (/var/tmp/pear-build-USER/PACKAGE-VERSION).
*
* @param string $descfile path to XML package description file
*
* @param mixed $callback callback function used to report output,
* see PEAR_Builder::_runCommand for details
*
* @return array an array of associative arrays with built files,
* format:
* array( array( 'file' => '/path/to/ext.so',
* 'php_api' => YYYYMMDD,
* 'zend_mod_api' => YYYYMMDD,
* 'zend_ext_api' => YYYYMMDD ),
* ... )
*
* @access public
*
* @see PEAR_Builder::_runCommand
* @see PEAR_Common::infoFromDescriptionFile
*/
function build($descfile, $callback = null)
{
if (PEAR_OS == "Windows") {
return $this->_build_win32($descfile, $callback);
}
if (PEAR_OS != 'Unix') {
return $this->raiseError("building extensions not supported on this platform");
}
if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) {
return $info;
}
$dir = dirname($descfile);
$old_cwd = getcwd();
if (!@chdir($dir)) {
return $this->raiseError("could not chdir to {$dir}");
}
$vdir = "{$info['package']}-{$info['version']}";
if (is_dir($vdir)) {
chdir($vdir);
}
$dir = getcwd();
$this->log(2, "building in {$dir}");
$this->current_callback = $callback;
$err = $this->_runCommand("phpize", array(&$this, 'phpizeCallback'));
if (PEAR::isError($err)) {
return $err;
}
if (!$err) {
return $this->raiseError("`phpize' failed");
}
// {{{ start of interactive part
$configure_command = "{$dir}/configure";
if (isset($info['configure_options'])) {
foreach ($info['configure_options'] as $o) {
list($r) = $this->ui->userDialog('build', array($o['prompt']), array('text'), array(@$o['default']));
if (substr($o['name'], 0, 5) == 'with-' && ($r == 'yes' || $r == 'autodetect')) {
$configure_command .= " --{$o['name']}";
} else {
$configure_command .= " --{$o['name']}=" . trim($r);
}
}
}
// }}} end of interactive part
// FIXME make configurable
if (!($user = getenv('USER'))) {
$user = 'defaultuser';
}
$build_basedir = "/var/tmp/pear-build-{$user}";
$build_dir = "{$build_basedir}/{$info['package']}-{$info['version']}";
$this->log(1, "building in {$build_dir}");
if (is_dir($build_dir)) {
System::rm("-rf {$build_dir}");
}
if (!System::mkDir("-p {$build_dir}")) {
return $this->raiseError("could not create build dir: {$build_dir}");
}
$this->addTempFile($build_dir);
if (getenv('MAKE')) {
$make_command = getenv('MAKE');
} else {
$make_command = 'make';
}
$to_run = array($configure_command, $make_command);
if (!@chdir($build_dir)) {
return $this->raiseError("could not chdir to {$build_dir}");
}
foreach ($to_run as $cmd) {
$err = $this->_runCommand($cmd, $callback);
if (PEAR::isError($err)) {
chdir($old_cwd);
return $err;
}
if (!$err) {
chdir($old_cwd);
return $this->raiseError("`{$cmd}' failed");
}
}
//.........这里部分代码省略.........
示例5: removeLang
/**
* Remove Language
*
* @param string $langID language ID
* @param bool $force (unused)
*
* @return true|PEAR_Error
* @access public
*/
function removeLang($langID, $force = false)
{
include_once 'System.php';
foreach ((array) $this->_domains as $domain => $path) {
if (is_dir($fp = $path . '/' . $langID)) {
if (PEAR::isError($e = System::rm(array('-rf', $fp))) || !$e) {
return $e ? $e : PEAR::raiseError(sprintf('Could not remove language "%s" from domain "%s" ' . 'in path "%s" (probably insufficient permissions)', $langID, $domain, $path), TRANSLATION2_ERROR);
}
}
}
return true;
}
示例6: pear_rest
$pear_rest = new pear_rest(PEAR_REST_DIR);
} else {
$pear_rest = new pear_rest(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'public_html' . DIRECTORY_SEPARATOR . 'rest');
}
}
include_once "DB.php";
include_once "DB/storage.php";
if (empty($dbh)) {
$options = array('persistent' => false, 'portability' => DB_PORTABILITY_ALL);
$dbh =& DB::connect(PEAR_DATABASE_DSN, $options);
$dbh->query('SET NAMES utf8');
}
ob_end_clean();
PEAR::setErrorHandling(PEAR_ERROR_DIE);
require_once 'System.php';
System::rm(array('-r', $pear_rest->_restdir));
System::mkdir(array('-p', $pear_rest->_restdir));
chmod($pear_rest->_restdir, 0777);
echo "Generating Category REST...\n";
foreach (category::listAll() as $category) {
echo " {$category['name']}...";
$pear_rest->saveCategoryREST($category['name']);
echo "done\n";
}
$pear_rest->saveAllCategoriesREST();
echo "Generating Maintainer REST...\n";
$maintainers = $dbh->getAll('SELECT * FROM users', array(), DB_FETCHMODE_ASSOC);
foreach ($maintainers as $maintainer) {
echo " {$maintainer['handle']}...";
$pear_rest->saveMaintainerREST($maintainer['handle']);
echo "done\n";
示例7: _PEAR_Common
/**
* PEAR_Common destructor
*
* @access private
*/
function _PEAR_Common()
{
// doesn't work due to bug #14744
//$tempfiles = $this->_tempfiles;
$tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];
while ($file = array_shift($tempfiles)) {
if (@is_dir($file)) {
if (!class_exists('System')) {
require_once 'System.php';
}
System::rm(array('-rf', $file));
} elseif (file_exists($file)) {
unlink($file);
}
}
}
示例8: deleteMaintainerREST
function deleteMaintainerREST($handle)
{
require_once 'System.php';
$mdir = $this->_restdir . DIRECTORY_SEPARATOR . 'm';
if (is_dir($mdir . DIRECTORY_SEPARATOR . $handle)) {
System::rm(array('-r', $mdir . DIRECTORY_SEPARATOR . $handle));
}
}
示例9: deleteGeotargetingConfigFiles
/**
* Removes geotargeting folder and all its subfolders - as it is not needed anymore
* after moving its configuration to main folder
*
*/
function deleteGeotargetingConfigFiles()
{
$geotargetingDir = MAX_PATH . '/var/plugins/config/geotargeting';
if (System::rm(array('-rf', $geotargetingDir)) !== true) {
return false;
}
return true;
}
示例10: MONITOR_plugin_upload
/**
* Handle uploaded plugin
*
* @return string HTML or error message
*
*/
function MONITOR_plugin_upload($plugin = '')
{
global $_CONF, $_MONITOR_CONF, $_TABLES;
$retval = '';
if ($plugin == '' || $_MONITOR_CONF['repository'] == '') {
return;
}
$url = "https://api.github.com/repos/{$_MONITOR_CONF['repository']}/" . $plugin . '/releases';
//Get last release for this plugin
$releases = MONITOR_curlRequestOnGitApi($url);
$version = $releases[0]['tag_name'];
$path_admin = $_CONF['path_html'] . substr($_CONF['site_admin_url'], strlen($_CONF['site_url']) + 1) . '/';
$upload_success = false;
//Download the zip file from repository
$source = "https://codeload.github.com/{$_MONITOR_CONF['repository']}/{$plugin}/zip/{$version}";
$destination = fopen($_CONF['path_data'] . $plugin . '.zip', 'w+');
set_time_limit(0);
// unlimited max execution time
$options = array(CURLOPT_FILE => $destination, CURLOPT_TIMEOUT => 28800, CURLOPT_URL => $source, CURLOPT_USERAGENT => $_MONITOR_CONF['repository'], CURLOPT_SSL_VERIFYPEER => false);
$ch = curl_init();
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
$plugin_file = $_CONF['path_data'] . $plugin . '.zip';
// Name the plugin file
if (!file_exists($plugin_file)) {
COM_errorLog('MONITOR - Download failed for Plugin: ' . $plugin);
return 'Download failed for Plugin: ' . $plugin;
} else {
chmod($plugin_file, 0755);
}
require_once $_CONF['path_system'] . 'classes/unpacker.class.php';
$archive = new unpacker($plugin_file, 'application/x-zip');
if ($archive == false) {
return 72;
}
COM_errorLog('MONITOR - Download ' . $plugin . ' plugin: ok');
$pi_did_exist = false;
// plugin directory already existed
$pi_had_entry = false;
// plugin had an entry in the database
$pi_was_enabled = false;
// plugin was enabled
$alternate = false;
if (file_exists($_CONF['path'] . 'plugins/' . $plugin)) {
$pi_did_exist = true;
// plugin directory already exists
$pstatus = DB_query("SELECT pi_name, pi_enabled FROM {$_TABLES['plugins']} WHERE pi_name = '{$plugin}'");
$A = DB_fetchArray($pstatus);
if (isset($A['pi_name'])) {
$pi_had_entry = true;
$pi_was_enabled = $A['pi_enabled'] == 1;
}
if ($pi_was_enabled) {
// disable temporarily while we move the files around
DB_change($_TABLES['plugins'], 'pi_enabled', 0, 'pi_name', $plugin);
COM_errorLog('MONITOR - Disable Plugin: ' . $plugin);
}
require_once 'System.php';
$plugin_dir = $_CONF['path'] . 'plugins/' . $plugin;
if (file_exists($plugin_dir . '.previous')) {
@System::rm('-rf ' . $plugin_dir . '.previous');
}
if (file_exists($plugin_dir)) {
rename($plugin_dir, $plugin_dir . '.previous');
COM_errorLog('MONITOR - Rename: ' . $plugin_dir . ' to ' . $plugin_dir . '.previous');
}
$public_dir = $_CONF['path_html'] . $plugin;
if (file_exists($public_dir . '.previous')) {
@System::rm('-rf ' . $public_dir . '.previous');
}
if (file_exists($public_dir)) {
rename($public_dir, $public_dir . '.previous');
COM_errorLog('MONITOR - Rename: ' . $public_dir . ' to ' . $public_dir . '.previous');
}
$admin_dir = $path_admin . 'plugins/' . $plugin;
if (file_exists($admin_dir . '.previous')) {
@System::rm('-rf ' . $admin_dir . '.previous');
}
if (file_exists($admin_dir)) {
rename($admin_dir, $admin_dir . '.previous');
COM_errorLog('MONITOR - Rename: ' . $admin_dir . ' to ' . $admin_dir . '.previous');
}
}
$upload_success = false;
// Extract the uploaded archive to the data directory
$upload_success = $archive->unpack($_CONF['path_data']);
if (!$upload_success) {
//Try alternative unzip
unset($archive);
require_once 'Archive/Zip.php';
$archive = new Archive_Zip($plugin_file);
if ($archive == false) {
return 72;
//.........这里部分代码省略.........
示例11: setupTempStuff
function setupTempStuff()
{
if (!($this->ptmp = System::mktemp(array('-d')))) {
$this->show("System's Tempdir failed, trying to use \$prefix/tmp ...");
$res = System::mkDir(array($this->prefix . '/tmp'));
if (!$res) {
return PEAR::raiseError('mkdir ' . $this->prefix . '/tmp ... failed');
}
$_temp = tempnam($this->prefix . '/tmp', 'gope');
System::rm(array('-rf', $_temp));
System::mkdir(array('-p', '-m', '0700', $_temp));
$this->ptmp = $this->prefix . '/tmp';
$ok = @chdir($this->ptmp);
if (!$ok) {
// This should not happen, really ;)
$this->bail('chdir ' . $this->ptmp . ' ... failed');
}
print "ok\n";
// Adjust TEMPDIR envvars
if (!isset($_ENV)) {
$_ENV = array();
}
$_ENV['TMPDIR'] = $_ENV['TEMP'] = $this->prefix . '/tmp';
}
return @chdir($this->ptmp);
}
示例12: build
/**
* Build an extension from source. Runs "phpize" in the source
* directory, but compiles in a temporary directory
* (TMPDIR/pear-build-USER/PACKAGE-VERSION).
*
* @param string|PEAR_PackageFile_v* $descfile path to XML package description file, or
* a PEAR_PackageFile object
*
* @param mixed $callback callback function used to report output,
* see PEAR_Builder::_runCommand for details
*
* @return array an array of associative arrays with built files,
* format:
* array( array( 'file' => '/path/to/ext.so',
* 'php_api' => YYYYMMDD,
* 'zend_mod_api' => YYYYMMDD,
* 'zend_ext_api' => YYYYMMDD ),
* ... )
*
* @access public
*
* @see PEAR_Builder::_runCommand
*/
function build($descfile, $callback = null)
{
if (preg_match('/(\\/|\\\\|^)([^\\/\\\\]+)?php(.+)?$/', $this->config->get('php_bin'), $matches)) {
if (isset($matches[2]) && strlen($matches[2]) && trim($matches[2]) != trim($this->config->get('php_prefix'))) {
$this->log(0, 'WARNING: php_bin ' . $this->config->get('php_bin') . ' appears to have a prefix ' . $matches[2] . ', but' . ' config variable php_prefix does not match');
}
if (isset($matches[3]) && strlen($matches[3]) && trim($matches[3]) != trim($this->config->get('php_suffix'))) {
$this->log(0, 'WARNING: php_bin ' . $this->config->get('php_bin') . ' appears to have a suffix ' . $matches[3] . ', but' . ' config variable php_suffix does not match');
}
}
$this->current_callback = $callback;
if (PEAR_OS == "Windows") {
return $this->_build_win32($descfile, $callback);
}
if (PEAR_OS != 'Unix') {
return $this->raiseError("building extensions not supported on this platform");
}
if (is_object($descfile)) {
$pkg = $descfile;
$descfile = $pkg->getPackageFile();
if (is_a($pkg, 'PEAR_PackageFile_v1')) {
$dir = dirname($descfile);
} else {
$dir = $pkg->_config->get('temp_dir') . '/' . $pkg->getName();
// automatically delete at session end
$this->addTempFile($dir);
}
} else {
$pf =& new PEAR_PackageFile($this->config);
$pkg =& $pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($pkg)) {
return $pkg;
}
$dir = dirname($descfile);
}
// Find config. outside of normal path - e.g. config.m4
foreach (array_keys($pkg->getInstallationFileList()) as $item) {
if (stristr(basename($item), 'config.m4') && dirname($item) != '.') {
$dir .= DIRECTORY_SEPARATOR . dirname($item);
break;
}
}
$old_cwd = getcwd();
if (!file_exists($dir) || !is_dir($dir) || !chdir($dir)) {
return $this->raiseError("could not chdir to {$dir}");
}
$vdir = $pkg->getPackage() . '-' . $pkg->getVersion();
if (is_dir($vdir)) {
chdir($vdir);
}
$dir = getcwd();
$this->log(2, "building in {$dir}");
putenv('PATH=' . $this->config->get('bin_dir') . ':' . getenv('PATH'));
$err = $this->_runCommand($this->config->get('php_prefix') . "phpize" . $this->config->get('php_suffix'), array(&$this, 'phpizeCallback'));
if (PEAR::isError($err)) {
return $err;
}
if (!$err) {
print "If the command failed with 'phpize: not found' then you need to install php5-dev package";
print "You can do it by running 'apt-get install php5-dev' as a root user";
return $this->raiseError("`phpize' failed");
}
// {{{ start of interactive part
$configure_command = "{$dir}/configure";
$configure_options = $pkg->getConfigureOptions();
if ($configure_options) {
foreach ($configure_options as $o) {
$default = array_key_exists('default', $o) ? $o['default'] : null;
list($r) = $this->ui->userDialog('build', array($o['prompt']), array('text'), array($default));
if (substr($o['name'], 0, 5) == 'with-' && ($r == 'yes' || $r == 'autodetect')) {
$configure_command .= " --{$o['name']}";
} else {
$configure_command .= " --{$o['name']}=" . trim($r);
}
}
}
// }}} end of interactive part
//.........这里部分代码省略.........
示例13: _PEAR_Common
/**
* PEAR_Common destructor
*
* @access private
*/
function _PEAR_Common()
{
// doesn't work due to bug #14744
//$tempfiles = $this->_tempfiles;
$tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];
while ($file = array_shift($tempfiles)) {
if (@is_dir($file)) {
System::rm("-rf {$file}");
} elseif (file_exists($file)) {
unlink($file);
}
}
}
示例14: fread
// Zip
$archive->extract(array('add_path' => $_CONF['path'] . 'data/', 'by_name' => $dirname . '/admin/install.php'));
} else {
// Tarball
$archive->extractList(array($dirname . '/admin/install.php'), $_CONF['path'] . 'data/');
}
$plugin_inst = $_CONF['path'] . 'data/' . $dirname . '/admin/install.php';
$fdata = '';
$fhandle = @fopen($plugin_inst, 'r');
if ($fhandle) {
$fdata = fread($fhandle, filesize($plugin_inst));
fclose($fhandle);
}
// Remove the plugin from data/
require_once 'System.php';
@System::rm('-rf ' . $_CONF['path'] . 'data/' . $dirname);
/**
* One time I wanted to install a muffler on my car and
* needed to match up the outside diameter of the car's
* exhaust pipe to the inside diameter of the muffler.
* Unfortunately, when I went to the auto parts store they
* didn't have a coupling adapter that would perfectly
* match the two pipes, only a bunch of smaller adapters.
* I ended up using about 4 small adapters to step down
* one size at a time to the size of the muffler's input.
*
* It's kind of like this regular expression:
*
*/
$fdata = preg_replace('/\\n/', '', $fdata);
$fdata = preg_replace('/ /', '', $fdata);
示例15: plugin_upload
/**
* Handle uploaded plugin
*
* @return string HTML: redirect or main plugin screen + error message
*
*/
function plugin_upload()
{
global $_CONF, $_TABLES;
$retval = '';
$path_admin = $_CONF['path_html'] . substr($_CONF['site_admin_url'], strlen($_CONF['site_url']) + 1) . '/';
$upload_success = false;
// If an error occured while uploading the file.
$error_msg = plugin_getUploadError($_FILES['plugin']);
if (!empty($error_msg)) {
$retval .= plugin_main($error_msg);
} else {
require_once $_CONF['path_system'] . 'classes/unpacker.class.php';
$plugin_file = $_CONF['path_data'] . $_FILES['plugin']['name'];
// Name the plugin file
$archive = new unpacker($_FILES['plugin']['tmp_name'], $_FILES['plugin']['type']);
$tmp = $archive->getlist();
// Grab the contents of the tarball to see what the plugin name is
$dirname = preg_replace('/\\/.*$/', '', $tmp[0]['filename']);
if (empty($dirname)) {
// If $dirname is blank it's probably because the user uploaded a non Tarball file.
$retval = COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=100');
} else {
$pi_did_exist = false;
// plugin directory already existed
$pi_had_entry = false;
// plugin had an entry in the database
$pi_was_enabled = false;
// plugin was enabled
if (file_exists($_CONF['path'] . 'plugins/' . $dirname)) {
$pi_did_exist = true;
// plugin directory already exists
$pstatus = DB_query("SELECT pi_name, pi_enabled FROM {$_TABLES['plugins']} WHERE pi_name = '{$dirname}'");
$A = DB_fetchArray($pstatus);
if (isset($A['pi_name'])) {
$pi_had_entry = true;
$pi_was_enabled = $A['pi_enabled'] == 1;
}
if ($pi_was_enabled) {
// disable temporarily while we move the files around
DB_change($_TABLES['plugins'], 'pi_enabled', 0, 'pi_name', $dirname);
}
require_once 'System.php';
$plugin_dir = $_CONF['path'] . 'plugins/' . $dirname;
if (file_exists($plugin_dir . '.previous')) {
@System::rm('-rf ' . $plugin_dir . '.previous');
}
if (file_exists($plugin_dir)) {
rename($plugin_dir, $plugin_dir . '.previous');
}
$public_dir = $_CONF['path_html'] . $dirname;
if (file_exists($public_dir . '.previous')) {
@System::rm('-rf ' . $public_dir . '.previous');
}
if (file_exists($public_dir)) {
rename($public_dir, $public_dir . '.previous');
}
$admin_dir = $path_admin . 'plugins/' . $dirname;
if (file_exists($admin_dir . '.previous')) {
@System::rm('-rf ' . $admin_dir . '.previous');
}
if (file_exists($admin_dir)) {
rename($admin_dir, $admin_dir . '.previous');
}
}
/**
* Install the plugin
* This doesn't work if the public_html & public_html/admin/plugins directories aren't 777
*/
// Extract the tarball to data so we can get the $pi_name name from admin/install.php
$archive->unpack($_CONF['path'] . 'data/', array($dirname . '/admin/install.php'));
$plugin_inst = $_CONF['path'] . 'data/' . $dirname . '/admin/install.php';
$fdata = '';
$fhandle = @fopen($plugin_inst, 'r');
if ($fhandle) {
$fdata = fread($fhandle, filesize($plugin_inst));
fclose($fhandle);
}
// Remove the plugin from data/
require_once 'System.php';
@System::rm('-rf ' . $_CONF['path'] . 'data/' . $dirname);
/**
* One time I wanted to install a muffler on my car and
* needed to match up the outside diameter of the car's
* exhaust pipe to the inside diameter of the muffler.
* Unfortunately, when I went to the auto parts store they
* didn't have a coupling adapter that would perfectly
* match the two pipes, only a bunch of smaller adapters.
* I ended up using about 4 small adapters to step down
* one size at a time to the size of the muffler's input.
*
* It's kind of like this regular expression:
*
*/
$fdata = preg_replace('/\\n/', '', $fdata);
//.........这里部分代码省略.........