本文整理汇总了PHP中rmdir_r函数的典型用法代码示例。如果您正苦于以下问题:PHP rmdir_r函数的具体用法?PHP rmdir_r怎么用?PHP rmdir_r使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rmdir_r函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rmdir_r
function rmdir_r($path)
{
if (!is_dir($path)) {
return false;
}
if (!preg_match("/\\/\$/", $path)) {
$path .= '/';
}
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
if (is_dir($path . $file)) {
rmdir_r($path . $file);
} else {
if (is_file($path . $file)) {
unlink($path . $file);
}
}
}
closedir($dh);
rmdir($path);
return true;
}
示例2: plug_erase
function plug_erase($del, $dir)
{
//$del='';
//$dir='';
if ($_SESSION['auth'] < 6) {
return 'no';
}
echo $del . '-' . $dir . '-';
if ($del) {
unlink($del);
} elseif ($dir && strpos($dir, '/') != false) {
rmdir_r($dir);
}
//$func='rmdir_r';
//$r=explore($dir); explode_dir($r,$dir,$func?$func:"removef"); p($r);
//walk_dir($dir,"removef");
//rmdir($dir);
//chmod($dir,0777);
if ($del) {
return $del;
}
if ($dir) {
return $dir;
}
return lkc('', '/plug/erase.php?del=', 'del file');
}
示例3: ifrgz
function ifrgz($dr)
{
$r = explore($dr);
$f = 'users/public/ifr' . date('ymd') . '.tar';
if (!is_file($f)) {
$ret = plugin('tar', $f, $dr);
}
rmdir_r($dr);
return $ret;
}
示例4: rmdir_r
function rmdir_r($dir, $DeleteMe = TRUE)
{
if (!($dh = @opendir($dir))) {
return;
}
while (false !== ($obj = readdir($dh))) {
if ($obj == '.' || $obj == '..') {
continue;
}
if (!@unlink($dir . '/' . $obj)) {
rmdir_r($dir . '/' . $obj, true);
}
}
closedir($dh);
if ($DeleteMe) {
@rmdir($dir);
}
}
示例5: delj
function delj($p, $o, $res)
{
$f = ajxg($res);
if (!auth(7)) {
return 'no';
}
if ($p == 'file') {
if (is_file($f)) {
unlink($f);
} else {
return 'error';
}
}
if ($p == 'dir' && $f && strpos($f, '/') != false) {
echo $f;
if (is_dir($f)) {
rmdir_r($f);
} else {
return 'error';
}
}
return btn('txtyl', $p . ' ' . $f . ': deleted');
}
示例6: db_delete_where
/**
* Delete those users from the database which corresponds to the given condition or to the given ids array
* Note: the delete cascade arrays are handled!
*
* @param string the name of this class
* Note: This is required until min phpversion will be 5.3. Since PHP 5.3 we can use static::function_name to achieve late static bindings
* @param string where condition
* @param array object ids
* @return mixed # of rows affected or false if error
*/
static function db_delete_where($class_name, $sql_where, $object_ids = NULL, $params = NULL)
{
global $DB;
$DB->begin();
if (!empty($sql_where)) {
$object_ids = $DB->get_col('SELECT user_ID FROM T_users WHERE ' . $sql_where);
}
if (!$object_ids) {
// There is no user to delete
$DB->commit();
return;
}
// Delete orphan threads per users
$result = delete_orphan_threads($object_ids);
// Remove deleted user(s) from posts where it was as last edit user
$user_ids = implode(',', $object_ids);
$result = $result && $DB->query('UPDATE T_items__item
SET post_lastedit_user_ID = NULL
WHERE post_lastedit_user_ID IN ( ' . $user_ids . ' )') !== false;
$result = $result && $DB->query('UPDATE T_items__version
SET iver_edit_user_ID = NULL
WHERE iver_edit_user_ID IN ( ' . $user_ids . ' )') !== false;
// Remove this user from links where it was as last edit user
$result = $result && $DB->query('UPDATE T_links
SET link_lastedit_user_ID = NULL
WHERE link_lastedit_user_ID IN ( ' . $user_ids . ' )') !== false;
if ($result) {
// Delete the user(s) with all of the cascade objects
$params['use_transaction'] = false;
// no need to start a new transaction
$result = parent::db_delete_where($class_name, $sql_where, $object_ids, $params);
}
if ($result !== false) {
// delete the users' media folders recursively, for all deleted users
$FileRootCache =& get_FileRootCache();
foreach ($object_ids as $user_ID) {
if ($root_directory = $FileRootCache->get_root_dir('user', $user_ID)) {
// Delete the folder only when it is detected:
rmdir_r($root_directory);
}
}
}
$result !== false ? $DB->commit() : $DB->rollback();
return $result;
}
示例7: pbm_process_messages
/**
* Read messages from server and create posts
*
* @param resource $mbox created by pbm_connect() (by reference)
* @param integer the number of messages to process
* @return boolean true on success
*/
function pbm_process_messages(&$mbox, $limit)
{
global $Settings;
global $pbm_item_files, $pbm_messages, $pbm_items, $post_cntr, $del_cntr, $is_cron_mode;
// No execution time limit
set_max_execution_time(0);
// Are we in test mode?
$test_mode_on = $Settings->get('eblog_test_mode');
$post_cntr = 0;
$del_cntr = 0;
for ($index = 1; $index <= $limit; $index++) {
pbm_msg('<hr /><h3>Processing message #' . $index . ':</h3>');
$strbody = '';
$hasAttachment = false;
$hasRelated = false;
$pbm_item_files = array();
// reset the value for each new Item
// Save email to hard drive, otherwise attachments may take a lot of RAM
if (!($tmpMIME = tempnam(sys_get_temp_dir(), 'b2evoMail'))) {
pbm_msg(T_('Could not create temporary file.'), true);
continue;
}
imap_savebody($mbox, $tmpMIME, $index);
// Create random temp directory for message parts
$tmpDirMIME = pbm_tempdir(sys_get_temp_dir(), 'b2evo_');
$mimeParser = new mime_parser_class();
$mimeParser->mbox = 0;
// Set to 0 for parsing a single message file
$mimeParser->decode_headers = 1;
$mimeParser->ignore_syntax_errors = 1;
$mimeParser->extract_addresses = 0;
$MIMEparameters = array('File' => $tmpMIME, 'SaveBody' => $tmpDirMIME, 'SkipBody' => 1);
if (!$mimeParser->Decode($MIMEparameters, $decodedMIME)) {
pbm_msg(sprintf('MIME message decoding error: %s at position %d.', $mimeParser->error, $mimeParser->error_position), true);
rmdir_r($tmpDirMIME);
unlink($tmpMIME);
continue;
} else {
pbm_msg('MIME message decoding successful');
if (!$mimeParser->Analyze($decodedMIME[0], $parsedMIME)) {
pbm_msg(sprintf('MIME message analyse error: %s', $mimeParser->error), true);
rmdir_r($tmpDirMIME);
unlink($tmpMIME);
continue;
}
// Get message $subject and $post_date from headers (by reference)
if (!pbm_process_header($parsedMIME, $subject, $post_date)) {
// Couldn't process message headers
rmdir_r($tmpDirMIME);
unlink($tmpMIME);
continue;
}
// TODO: handle type == "message" recursively
// sam2kb> For some reason imap_qprint() demages HTML text... needs more testing
if ($parsedMIME['Type'] == 'html') {
// Mail is HTML
if ($Settings->get('eblog_html_enabled')) {
// HTML posting enabled
pbm_msg('HTML message part saved as ' . $parsedMIME['DataFile']);
$html_body = file_get_contents($parsedMIME['DataFile']);
}
foreach ($parsedMIME['Alternative'] as $alternative) {
// First try to get HTML alternative (when possible)
if ($alternative['Type'] == 'html' && $Settings->get('eblog_html_enabled')) {
// HTML text
pbm_msg('HTML alternative message part saved as ' . $alternative['DataFile']);
// sam2kb> TODO: we may need to use $html_body here instead
$strbody = file_get_contents($alternative['DataFile']);
break;
// stop after first alternative
} elseif ($alternative['Type'] == 'text') {
// Plain text
pbm_msg('Text alternative message part saved as ' . $alternative['DataFile']);
$strbody = imap_qprint(file_get_contents($alternative['DataFile']));
break;
// stop after first alternative
}
}
} elseif ($parsedMIME['Type'] == 'text') {
// Mail is plain text
pbm_msg('Plain-text message part saved as ' . $parsedMIME['DataFile']);
$strbody = imap_qprint(file_get_contents($parsedMIME['DataFile']));
}
// Check for attachments
if (!empty($parsedMIME['Attachments'])) {
$hasAttachment = true;
foreach ($parsedMIME['Attachments'] as $file) {
pbm_msg('Attachment: ' . $file['FileName'] . ' stored as ' . $file['DataFile']);
}
}
// Check for inline images
if (!empty($parsedMIME['Related'])) {
$hasRelated = true;
//.........这里部分代码省略.........
示例8: dre_process_messages
/**
* Read messages from server and save returned emails into DB
*
* @param resource $mbox created by dre_connect() (by reference)
* @param integer the number of messages to process
* @return boolean true on success
*/
function dre_process_messages(&$mbox, $limit)
{
//return; // Exit, in development...
global $Settings;
global $dre_messages, $dre_emails, $email_cntr, $del_cntr, $is_cron_mode;
// No execution time limit
set_max_execution_time(0);
$email_cntr = 0;
$del_cntr = 0;
for ($index = 1; $index <= $limit; $index++) {
dre_msg('<hr /><h3>Processing message #' . $index . ':</h3>');
$strbody = '';
$hasAttachment = false;
$hasRelated = false;
// Save email to hard drive, otherwise attachments may take a lot of RAM
if (!($tmpMIME = tempnam(sys_get_temp_dir(), 'b2evoMail'))) {
dre_msg(T_('Could not create temporary file.'), true);
continue;
}
imap_savebody($mbox, $tmpMIME, $index);
// Create random temp directory for message parts
$tmpDirMIME = dre_tempdir(sys_get_temp_dir(), 'b2evo_');
$mimeParser = new mime_parser_class();
$mimeParser->mbox = 0;
// Set to 0 for parsing a single message file
$mimeParser->decode_headers = 1;
$mimeParser->ignore_syntax_errors = 1;
$mimeParser->extract_addresses = 0;
$MIMEparameters = array('File' => $tmpMIME, 'SaveBody' => $tmpDirMIME, 'SkipBody' => 1);
if (!$mimeParser->Decode($MIMEparameters, $decodedMIME)) {
dre_msg(sprintf('MIME message decoding error: %s at position %d.', $mimeParser->error, $mimeParser->error_position), true);
rmdir_r($tmpDirMIME);
unlink($tmpMIME);
continue;
} else {
dre_msg('MIME message decoding successful');
if (!$mimeParser->Analyze($decodedMIME[0], $parsedMIME)) {
dre_msg(sprintf('MIME message analyse error: %s', $mimeParser->error), true);
rmdir_r($tmpDirMIME);
unlink($tmpMIME);
continue;
}
// Get message $subject and $post_date from headers (by reference)
if (!dre_process_header($parsedMIME, $subject, $post_date)) {
// Couldn't process message headers
rmdir_r($tmpDirMIME);
unlink($tmpMIME);
continue;
}
// TODO: handle type == "message" recursively
// sam2kb> For some reason imap_qprint() demages HTML text... needs more testing
if ($parsedMIME['Type'] == 'html') {
// Mail is HTML
dre_msg('HTML message part saved as ' . $parsedMIME['DataFile']);
$html_body = file_get_contents($parsedMIME['DataFile']);
foreach ($parsedMIME['Alternative'] as $alternative) {
// First try to get HTML alternative (when possible)
if ($alternative['Type'] == 'html') {
// HTML text
dre_msg('HTML alternative message part saved as ' . $alternative['DataFile']);
// sam2kb> TODO: we may need to use $html_body here instead
$strbody = file_get_contents($alternative['DataFile']);
break;
// stop after first alternative
} elseif ($alternative['Type'] == 'text') {
// Plain text
dre_msg('Text alternative message part saved as ' . $alternative['DataFile']);
$strbody = imap_qprint(file_get_contents($alternative['DataFile']));
break;
// stop after first alternative
}
}
} elseif ($parsedMIME['Type'] == 'text') {
// Mail is plain text
dre_msg('Plain-text message part saved as ' . $parsedMIME['DataFile']);
$strbody = imap_qprint(file_get_contents($parsedMIME['DataFile']));
} elseif ($parsedMIME['Type'] == 'delivery-status') {
// Mail is delivery-status
$strbody = '';
foreach ($decodedMIME[0]['Parts'] as $part) {
$strbody .= imap_qprint(file_get_contents($part['BodyFile']));
}
}
if (count($mimeParser->warnings) > 0) {
dre_msg(sprintf('<h4>%d warnings during decode:</h4>', count($mimeParser->warnings)));
foreach ($mimeParser->warnings as $k => $v) {
dre_msg('Warning: ' . $v . ' at position ' . $k);
}
}
}
unlink($tmpMIME);
if (empty($html_body)) {
// Plain text message
//.........这里部分代码省略.........
示例9: CleanUpAfterUpload
public function CleanUpAfterUpload()
{
fwrite($this->logger , "Cleaning up after upload\n");
$dataFolderPath = $this->baseFolderPath.$this->layerName;
unlink($this->zipFile);
rmdir_r($dataFolderPath);
fclose($this->logger);
}
示例10: rmdir_r
function rmdir_r($path)
{
if (is_dir($path)) {
foreach (glob($path . "/*") as $file) {
if ($file != "." && $file != "..") {
if (is_dir($file)) {
rmdir_r($file);
} else {
if (!unlink($file)) {
return FALSE;
}
}
}
}
if (rmdir($path)) {
return TRUE;
}
}
return FALSE;
}
示例11: rmdir_r
/**
* rmdir_r - Remove a directory and all it's contents.
*
* @param mixed $dir
*/
function rmdir_r($dir)
{
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file) {
is_dir("{$dir}/{$file}") ? rmdir_r("{$dir}/{$file}") : unlink("{$dir}/{$file}");
}
return rmdir($dir);
}
示例12: dbdelete
/**
* Delete user and dependencies from database
*
* Includes WAY TOO MANY requests because we try to be compatible with MySQL 3.23, bleh!
*
* @param Log Log object where output gets added (by reference).
*/
function dbdelete(&$Log)
{
global $DB, $Plugins;
if ($this->ID == 0) {
debug_die('Non persistant object cannot be deleted!');
}
$deltype = param('deltype', 'string', '');
// spammer
$DB->begin();
if ($deltype == 'spammer') {
// If we delete user as spammer we should delete private messaged of this user
$this->delete_messages();
} else {
// If we delete user as not spammer we keep his comments as from anonymous user
// Transform registered user comments to unregistered:
$ret = $DB->query('UPDATE T_comments
SET comment_author_ID = NULL,
comment_author = ' . $DB->quote($this->get('preferredname')) . ',
comment_author_email = ' . $DB->quote($this->get('email')) . ',
comment_author_url = ' . $DB->quote($this->get('url')) . '
WHERE comment_author_ID = ' . $this->ID);
if (is_a($Log, 'log')) {
$Log->add('Transforming user\'s comments to unregistered comments... ' . sprintf('(%d rows)', $ret), 'note');
}
}
// Get list of posts that are going to be deleted (3.23)
$post_list = implode(',', $DB->get_col('
SELECT post_ID
FROM T_items__item
WHERE post_creator_user_ID = ' . $this->ID));
if (!empty($post_list)) {
// Delete comments
$ret = $DB->query("DELETE FROM T_comments\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE comment_post_ID IN ({$post_list})");
if (is_a($Log, 'log')) {
$Log->add(sprintf('Deleted %d comments on user\'s posts.', $ret), 'note');
}
// Delete post extracats
$ret = $DB->query("DELETE FROM T_postcats\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE postcat_post_ID IN ({$post_list})");
if (is_a($Log, 'log')) {
$Log->add(sprintf('Deleted %d extracats of user\'s posts\'.', $ret));
// TODO: geeky wording.
}
// Posts will we auto-deleted by parent method
} else {
// no posts
if (is_a($Log, 'log')) {
$Log->add('No posts to delete.', 'note');
}
}
// Get list of sessions that are going to be deleted
$sessions_SQL = new SQL();
$sessions_SQL->SELECT('sess_ID');
$sessions_SQL->FROM('T_sessions');
$sessions_SQL->WHERE('sess_user_ID = ' . $this->ID);
$sessions_list = $DB->get_col($sessions_SQL->get());
if (!empty($sessions_list)) {
// Delete all hit logs of this user
$DB->query('DELETE FROM T_hitlog
WHERE hit_sess_ID IN ( ' . $DB->quote($sessions_list) . ' )');
}
// delete user involved ophan threads
delete_orphan_threads($this->ID);
// Remove this user from posts where it was as last edit user
$DB->query('UPDATE T_items__item
SET post_lastedit_user_ID = NULL
WHERE post_lastedit_user_ID = ' . $this->ID);
$DB->query('UPDATE T_items__version
SET iver_edit_user_ID = NULL
WHERE iver_edit_user_ID = ' . $this->ID);
// Remove this user from links where it was as last edit user
$DB->query('UPDATE T_links
SET link_lastedit_user_ID = NULL
WHERE link_lastedit_user_ID = ' . $this->ID);
// remember ID, because parent method resets it to 0
$old_ID = $this->ID;
$old_email = $this->get('email');
// Delete main object:
if (!parent::dbdelete()) {
$DB->rollback();
$Log->add('User has not been deleted.', 'error');
return false;
}
// user was deleted, also delete this user's media folder recursively
$FileRootCache =& get_FileRootCache();
$root_directory = $FileRootCache->get_root_dir('user', $old_ID);
rmdir_r($root_directory);
if ($deltype == 'spammer') {
// User was deleted as spammer, we should mark email of this user as 'Spammer'
load_class('tools/model/_emailblocked.class.php', 'EmailBlocked');
$EmailBlockedCache =& get_EmailBlockedCache();
$EmailBlocked =& $EmailBlockedCache->get_by_name($old_email, false, false);
if (!$EmailBlocked) {
// Create new record in the T_email_blocked table
//.........这里部分代码省略.........
示例13: json_encode
break;
case "chmod_directory":
if ($directory && $_POST['permissions']) {
if (chmod($directory, octdec(0 . $_POST['permissions']))) {
print json_encode(array('success' => true, 'message' => 'Directory chmod\'d successfully'));
} else {
print json_encode(array('success' => false, 'message' => 'Could not chmod ' . $directory));
}
} else {
print json_encode(array('success' => false, 'message' => 'Could not chmod ' . $directory));
}
exit;
break;
case "delete_directory":
if ($_POST['directory'] && $directory != DIRECTORY && stristr($directory, DIRECTORY)) {
if (rmdir_r($directory)) {
print json_encode(array('success' => true, 'message' => 'Directory deleted successfully'));
} else {
print json_encode(array('success' => false, 'message' => 'Could not delete ' . $directory));
}
} else {
print json_encode(array('success' => false, 'message' => 'Could not delete ' . $directory));
}
exit;
break;
case "create_temp_image":
if ($_POST['image']) {
// Create a temp image copy of the image we are trying to edit
$temp_image = str_replace(basename($_POST['image']), '_fm_' . basename($_POST['image']), $_POST['image']);
if (copy(DIRECTORY . $_POST['image'], DIRECTORY . $temp_image)) {
list($width, $height) = getimagesize(DIRECTORY . $temp_image);
示例14: rm_cache
/**
* Delete cache for a file
*/
function rm_cache()
{
global $Messages;
// Remove cached elts for teh current file:
$ads_filecache = $this->get_ads_evocache(false);
if ($ads_filecache[0] == '!') {
// This creates unwanted noise
// $Messages->add( 'Cannot remove .evocache for file. - '.$ads_filecache, 'error' );
} else {
rmdir_r($ads_filecache);
// In case cache is now empty, delete the folder:
$adp_evocache = $this->_dir . '.evocache';
@rmdir($adp_evocache);
}
}
示例15: memorize_param
$action = 'start';
break;
// Stop an upgrade from SVN
} else {
// Use only correct revision
$phpsvnclient->setVersion($svn_revision);
}
}
$repository_version = $phpsvnclient->getVersion();
$upgrade_name = 'export_svn_' . $repository_version;
memorize_param('upd_name', 'string', '', $upgrade_name);
$upgrade_folder = $upgrade_path . $upgrade_name;
if ($action == 'force_export_svn' && file_exists($upgrade_folder)) {
// The exported folder already exists
// Try to delete previous package
if (!rmdir_r($upgrade_folder)) {
echo '<p class="red">' . sprintf(T_('Unable to delete previous exported package %s before forcing the export.'), '<b>' . $upgrade_folder . '</b>') . '</p>';
}
evo_flush();
}
if (file_exists($upgrade_folder)) {
// Current version already is downloaded
echo '<p class="green">' . sprintf(T_('Revision %s has already been downloaded. Using: %s'), $repository_version, $upgrade_folder);
$revision_is_exported = true;
} else {
// Download files
echo '<p>' . sprintf(T_('Downloading package to «<strong>%s</strong>»...'), $upgrade_folder);
evo_flush();
// Export all files in temp folder for following coping
$svn_result = $phpsvnclient->checkOut($svn_folder, $upgrade_folder, false, true);
echo '</p>';