当前位置: 首页>>代码示例>>PHP>>正文


PHP rm函数代码示例

本文整理汇总了PHP中rm函数的典型用法代码示例。如果您正苦于以下问题:PHP rm函数的具体用法?PHP rm怎么用?PHP rm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: logout

 function logout()
 {
     !isset($_SESSION['user']) && exit('Please login!');
     @rm('cache');
     unset($_SESSION['user']);
     echo "<script language=javascript>location.href='index.php';</script>";
 }
开发者ID:BGCX261,项目名称:zhwphp-svn-to-git,代码行数:7,代码来源:indexAction.php

示例2: rm

/**
 * Recursively delete a directory
 *
 * Removes specified directory/files, recursively.
 *
 * @param  string  $target Directory or file to be removed.
 * @return boolean Result of the removal.
 */
function rm($target)
{
    if (is_file($target)) {
        if (is_writable($target)) {
            if (unlink($target)) {
                return true;
            }
        }
        return false;
    }
    if (is_dir($target)) {
        if (is_writable($target)) {
            foreach (new DirectoryIterator($target) as $object) {
                if ($object->isDot()) {
                    unset($object);
                    continue;
                }
                if ($object->isFile()) {
                    rm($object->getPathName());
                } elseif ($object->isDir()) {
                    rm($object->getRealPath());
                }
                unset($object);
            }
            if (rmdir($target)) {
                return true;
            }
        }
        return false;
    }
}
开发者ID:brego,项目名称:prank,代码行数:39,代码来源:filesystem.php

示例3: removeAssets

 /**
  * @FIX file starting with dot no removed
  */
 private function removeAssets()
 {
     function rm($path)
     {
         $end_path = substr($path, strrpos($path, '/'));
         if (!in_array($end_path, array('/', '/.', '/..')) && file_exists($path)) {
             is_file($path) ? unlink($path) : array_map(__FUNCTION__, glob($path . '/{*,.*}', GLOB_BRACE)) == rmdir($path);
         }
     }
     if ($this->assetManager->settings['cache_file']) {
         rm($this->assetManager->settings['cache_file']);
     }
     rm($this->assetPath);
     $this->output->writeln("{$this->assetPath} cleaned");
 }
开发者ID:lalop,项目名称:aphet,代码行数:18,代码来源:DumpCommand.php

示例4: update_domain_dir

/**
 *	Update domain directory for soecified domain 
 *
 *	@param string $did	domain id
 *	@return bool		return TRUE on success, FALSE on failure
 */
function update_domain_dir($did)
{
    global $data, $_SERWEB;
    $domain_dir = $_SERWEB["serwebdir"] . "domains/" . $did . "/";
    $vf = new Version_file($domain_dir . "versions.ini.php");
    /* Open file containing versions of other files
    	   Do not check for errors here - if there will be error in version file, 
    	   the file will be recreated by values in DB
    	 */
    $vf->open();
    $local_versions = $vf->get_all_files();
    /* get versions of files in DB */
    if (false === ($files = $data->get_latest_file_versions($did, null))) {
        return false;
    }
    /* synchronize directory with DB */
    foreach ($files as $file => $f_prop) {
        if ($f_prop['deleted']) {
            /* file should be deleted */
            if (isset($local_versions[$file])) {
                $vf->remove_file($file);
            }
            if (file_exists($domain_dir . $file)) {
                rm($domain_dir . $file);
            }
        } elseif ($f_prop['dir']) {
            /* directory */
            if (!file_exists($domain_dir . $file)) {
                RecursiveMkdir($domain_dir . $file, 0770);
            }
        } elseif (!isset($local_versions[$file]) or !file_exists($domain_dir . $file) or $local_versions[$file] < $f_prop['version']) {
            /* file should be updated/created */
            $ds =& Domain_settings::singleton($did, $file);
            if (false === $ds->update_local_file($f_prop['version'])) {
                return false;
            }
            $vf->set_version($file, $f_prop['version']);
        }
    }
    $vf->close();
    return true;
}
开发者ID:BackupTheBerlios,项目名称:serweb,代码行数:48,代码来源:domain_sync.php

示例5: cleanup_captcha_files

function cleanup_captcha_files()
{
    clearstatcache();
    global $C;
    $dir = opendir($C->TMP_DIR);
    while ($file = readdir($dir)) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        if (preg_match('/^captcha_/i', $C->TMP_DIR . $file)) {
            continue;
        }
        $time = fileatime($C->TMP_DIR . $file);
        if (!$time) {
            continue;
        }
        if ($time < time() - 10 * 60) {
            rm($C->TMP_DIR . $file);
        }
    }
    closedir($dir);
}
开发者ID:essa,项目名称:sharetronix_ja,代码行数:22,代码来源:func_captcha.php

示例6: rm

 /**
  * ------------------------------
  * 删除文件或目录
  * ------------------------------
  * @param  string/array $path 文件或目录路径
  * @return bool
  */
 static function rm($path)
 {
     if (is_string($path)) {
         if (is_file($path)) {
             return unlink($path);
         } else {
             if (is_dir($path)) {
                 $ok = rm("{$path}/*");
                 if (!$ok) {
                     return false;
                 }
                 return rmdir($path);
             } else {
                 $matching = glob($path);
                 if ($matching === false) {
                     trigger_error(sprintf('No files match supplied glob %s', $path), E_USER_WARNING);
                     return false;
                 }
                 $rcs = array_map('rm', $matching);
                 if (in_array(false, $rcs)) {
                     return false;
                 }
             }
         }
     } else {
         if (is_array($path)) {
             $rcs = array_map('rm', $path);
             if (in_array(false, $rcs)) {
                 return false;
             }
         } else {
             trigger_error('Param #1 must be filename or glob pattern, or array of filenames or glob patterns', E_USER_ERROR);
             return false;
         }
     }
     return true;
 }
开发者ID:BGCX261,项目名称:zhwphp-svn-to-git,代码行数:44,代码来源:File.class.php

示例7: index

 function index()
 {
     global $db;
     //转到登陆页面
     if (!isset($_GET['do']) || $_GET['do'] == '') {
         tpl('index');
     } elseif ($_GET['do'] == 'login' && isset($_POST['user'])) {
         $arr = escape($_POST, 'yes');
         strtolower($arr['code']) != $_SESSION['authCode'] && show('登陆失败', '验证码错误', '-1');
         $rs = $db->row_query_one("SELECT `passwd` FROM `user` WHERE `user`='{$arr['user']}'");
         (!isset($rs['passwd']) || $rs['passwd'] != md5($arr['passwd'])) && show('登陆失败', '用户名或密码错误', '-1');
         $_SESSION['user'] = $arr['user'];
         tpl('main');
     }
     //判断是否登陆
     !isset($_SESSION['user']) && exit('Please login!');
     //退出登陆
     if ($_GET['do'] == 'logout') {
         @rm('cache');
         unset($_SESSION['user']);
         echo "<script language=javascript>location.href='index.php';</script>";
     }
     exit;
 }
开发者ID:BGCX261,项目名称:zhwphp-svn-to-git,代码行数:24,代码来源:index.act.php

示例8: system

 function system()
 {
     global $db;
     //判断是否登陆
     !isset($_SESSION['user']) && exit('Please login!');
     if (isset($_GET['do']) && $_GET['do'] == 'optimize') {
         $tables = $db->get_table_names();
         $rs = $db->optimize_table($tables);
         if ($rs) {
             show('优化成功', '数据表优化成功!', '-1');
         } else {
             show('优化失败', '数据表优化失败!', '-1');
         }
     }
     if (isset($_GET['do']) && $_GET['do'] == 'clean') {
         $rs = rm('cache');
         if ($rs) {
             show('清除缓存成功!', '清除缓存成功!', '-1');
         } else {
             show('清除缓存失败!', '清除缓存失败!', '-1');
         }
     }
     tpl('system');
 }
开发者ID:BGCX261,项目名称:zhwphp-svn-to-git,代码行数:24,代码来源:system.act.php

示例9: while

            $db2->query('UPDATE posts_pr SET mentioned=mentioned-1 WHERE id="' . $tmp->post_id . '" LIMIT 1');
        }
        $res = $db2->query('SELECT id, comment_id FROM posts_comments_mentioned WHERE user_id="' . $this->user->id . '" ');
        while ($tmp = $db2->fetch_object($res)) {
            $db2->query('DELETE FROM posts_comments_mentioned WHERE id="' . $tmp->id . '" LIMIT 1');
            $db2->query('UPDATE posts_comments SET mentioned=mentioned-1 WHERE id="' . $tmp->comment_id . '" LIMIT 1');
        }
        $res = $db2->query('SELECT id, comment_id FROM posts_pr_comments_mentioned WHERE user_id="' . $this->user->id . '" ');
        while ($tmp = $db2->fetch_object($res)) {
            $db2->query('DELETE FROM posts_pr_comments_mentioned WHERE id="' . $tmp->id . '" LIMIT 1');
            $db2->query('UPDATE posts_pr_comments SET mentioned=mentioned-1 WHERE id="' . $tmp->comment_id . '" LIMIT 1');
        }
        $res = $db2->query('SELECT id FROM users_rssfeeds WHERE user_id="' . $this->user->id . '" ');
        while ($tmp = $db2->fetch_object($res)) {
            $db2->query('DELETE FROM users_rssfeeds_posts WHERE rssfeed_id="' . $tmp->id . '" ');
        }
        $db2->query('DELETE FROM users_rssfeeds WHERE user_id="' . $this->user->id . '" ');
        $this->network->get_user_by_id($this->user->id, TRUE);
        $this->network->get_user_by_username($this->user->info->username, TRUE);
        $this->network->get_user_by_email($this->user->info->email, TRUE);
        if ($this->user->info->avatar != $C->DEF_AVATAR_USER) {
            rm($C->IMG_DIR . 'avatars/' . $this->user->info->avatar);
            rm($C->IMG_DIR . 'avatars/thumbs1/' . $this->user->info->avatar);
            rm($C->IMG_DIR . 'avatars/thumbs2/' . $this->user->info->avatar);
            rm($C->IMG_DIR . 'avatars/thumbs3/' . $this->user->info->avatar);
        }
        $this->user->logout();
        $this->redirect($C->SITE_URL);
    }
}
$this->load_template('settings_delaccount.php');
开发者ID:chaobj001,项目名称:tt,代码行数:31,代码来源:settings_delaccount.php

示例10: str_replace

             if (!store($user)) {
                 $result['success'] = false;
                 $result['msg'] = "Error : Unable to store user";
                 $result['id'] = $_POST['id'];
             } else {
                 $result['success'] = true;
             }
         }
     } else {
         $result['success'] = false;
         $result['msg'] = "Error : no user given.";
     }
     break;
 case 'rmUser':
     $id = str_replace(' ', '', $_GET['name']);
     if (!rm($id)) {
         $result['success'] = false;
         $result['msg'] = "Error : Unable to remove user";
         $result['id'] = $id;
     } else {
         $result['success'] = true;
     }
     break;
     /**/
 /**/
 case 'get':
     //TODO : utiliser call_user_func au lieu du tableau degeu
     if ($_GET['id'] == NULL) {
         $result['success'] = false;
         $result['msg'] = "Error : no user id given.";
     } else {
开发者ID:Uinelj,项目名称:rpgmanager-server,代码行数:31,代码来源:action.php

示例11: load

    if ($fhs[$val]->okay()) {
        $file = $fhs[$val]->get('file_' . $val);
        load('core/zip');
        $zip = new zip($file);
        if ($zip->extract(ROOT . 'cache/tmp/' . $dirs[$k] . '/')) {
            $nameZip = $_FILES['file_' . $val]['name'];
            if (is_dir(ROOT . $dirs[$k] . '/' . $nameZip)) {
                $error = new Error();
                $error->add_error(translate('file_already_exists'), ERROR_PAGE, __FILE__, __LINE__);
            } else {
                if (($dirDbFile = ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip . 'db/db.sql') && is_file($dirDbFile)) {
                    $bdd->extract_files($dirDbFile);
                }
                #rm( ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip . 'db/' );
                rename(ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip, ROOT . $dirs[$k] . '/' . $nameZip);
                rm(ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip);
                $error = new Error();
                $error->add_error(translate('file_success'), ERROR_PAGE, __FILE__, __LINE__);
            }
        } else {
            $error = new Error();
            $error->add_error(translate('file_fail'), ERROR_PAGE, __FILE__, __LINE__);
        }
    }
}
tpl_begin();
?>
<p><?php 
echo translate('help_message');
?>
</p>
开发者ID:xtrem-creative,项目名称:legacy_php-framework,代码行数:31,代码来源:paquets.php

示例12: delete_this_post

 public function delete_this_post()
 {
     global $C;
     if (!$this->if_can_delete()) {
         return FALSE;
     }
     if ($this->is_system_post) {
         if ($this->post_type == 'private' && $this->post_to_user->id == $this->user->id) {
             $this->db2->query('DELETE FROM posts_pr WHERE id="' . $this->post_id . '" LIMIT 1', FALSE);
             $this->error = TRUE;
             return TRUE;
         }
         if ($this->post_type == 'public' && $this->post_group) {
             $this->db2->query('DELETE FROM post_userbox WHERE post_id="' . $this->post_id . '" ', FALSE);
             $this->db2->query('DELETE FROM post_userbox_feeds WHERE post_id="' . $this->post_id . '" ', FALSE);
             $this->db2->query('DELETE FROM posts WHERE id="' . $this->post_id . '" LIMIT 1', FALSE);
             $this->error = TRUE;
             return TRUE;
         }
         if ($this->post_type == 'public' && !$this->post_group) {
             $this->db2->query('DELETE FROM post_userbox WHERE user_id="' . $this->user->id . '" AND post_id="' . $this->post_id . '" LIMIT 1', FALSE);
             $this->db2->query('DELETE FROM post_userbox_feeds WHERE user_id="' . $this->user->id . '" AND post_id="' . $this->post_id . '" LIMIT 1', FALSE);
             $r = $this->db2->query('SELECT user_id FROM post_userbox WHERE post_id="' . $this->post_id . '" LIMIT 1', FALSE);
             if (0 == $this->db2->num_rows($r)) {
                 $r = $this->db2->query('SELECT user_id FROM post_userbox_feeds WHERE post_id="' . $this->post_id . '" LIMIT 1', FALSE);
                 if (0 == $this->db2->num_rows($r)) {
                     $this->db2->query('DELETE FROM posts WHERE id="' . $this->post_id . '" LIMIT 1', FALSE);
                 }
             }
             $this->error = TRUE;
             return TRUE;
         }
         if ($this->user->is_network_admin) {
             if ($this->post_type == 'public') {
                 $this->db2->query('DELETE FROM post_userbox WHERE post_id="' . $this->post_id . '" ', FALSE);
                 $this->db2->query('DELETE FROM post_userbox_feeds WHERE post_id="' . $this->post_id . '" ', FALSE);
             }
             $this->db2->query('DELETE FROM ' . ($this->post_type == 'private' ? 'posts_pr' : 'posts') . ' WHERE id="' . $this->post_id . '" LIMIT 1', FALSE);
             $this->error = TRUE;
             return TRUE;
         }
     }
     if ($this->post_type == 'private' && $this->post_to_user->id == $this->user->id) {
         $this->fave_post(FALSE);
         $this->db2->query('UPDATE posts_pr SET is_recp_del=1 WHERE id="' . $this->post_id . '" LIMIT 1');
         $this->error = TRUE;
         return TRUE;
     }
     foreach ($this->post_comments as $c) {
         $c->delete_this_comment();
     }
     if ($this->post_type == 'public') {
         $this->db2->query('DELETE FROM post_userbox WHERE post_id="' . $this->post_id . '" ', FALSE);
         $this->db2->query('DELETE FROM post_userbox_feeds WHERE post_id="' . $this->post_id . '" ', FALSE);
     }
     $this->db2->query('DELETE FROM post_favs WHERE post_type="' . $this->post_type . '" AND post_id="' . $this->post_id . '" ', FALSE);
     $this->db2->query('DELETE FROM ' . ($this->post_type == 'private' ? 'posts_pr_mentioned' : 'posts_mentioned') . ' WHERE post_id="' . $this->post_id . '" ', FALSE);
     $this->db2->query('DELETE FROM ' . ($this->post_type == 'private' ? 'posts_pr' : 'posts') . ' WHERE id="' . $this->post_id . '" LIMIT 1', FALSE);
     $this->db2->query('DELETE FROM ' . ($this->post_type == 'private' ? 'posts_pr_comments_watch' : 'posts_comments_watch') . ' WHERE post_id="' . $this->post_id . '" ', FALSE);
     $this->db2->query('DELETE FROM ' . ($this->post_type == 'private' ? 'posts_pr_attachments' : 'posts_attachments') . ' WHERE post_id="' . $this->post_id . '" ', FALSE);
     $at_dir = $C->IMG_DIR . 'attachments/' . $this->network->id . '/';
     foreach ($this->post_attached as $tp => $at) {
         foreach ($at as $k => $v) {
             if (substr($k, 0, 5) != 'file_') {
                 continue;
             }
             rm($at_dir . $v);
         }
     }
     if ($this->post_type == 'public') {
         $this->db2->query('UPDATE users SET num_posts=num_posts-1 WHERE id="' . $this->post_user->id . '" LIMIT 1');
         if ($this->post_group) {
             $this->db2->query('UPDATE groups SET num_posts=num_posts-1 WHERE id="' . $this->post_group->id . '" LIMIT 1');
         }
     }
     $this->error = TRUE;
     return TRUE;
 }
开发者ID:essa,项目名称:sharetronix_ja,代码行数:78,代码来源:class_post.php

示例13: session_start

****************************************************************************/
session_start();
$save_dir = 'tmp/sess_' . session_id() . '/';
//clean up, remove files belonging to expired session
$sessions = array();
$handle = opendir(session_save_path());
while (false !== ($file = readdir($handle))) {
    if ($file != '.' && $file != '..') {
        $sessions[] = $file;
    }
}
closedir($handle);
$handle = opendir('tmp/');
while (false !== ($dir = readdir($handle))) {
    if ($dir != '.' && $dir != '..' && !in_array($dir, $sessions)) {
        rm("tmp/{$dir}/");
    }
}
closedir($handle);
// removes non-empty dir
function rm($dir)
{
    $handle = opendir($dir);
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' && $file != '..') {
            unlink("{$dir}/{$file}");
        }
    }
    closedir($handle);
    rmdir($dir);
}
开发者ID:vojtajina,项目名称:sitellite,代码行数:31,代码来源:txt2mid.php

示例14: recursiveRemoveDirectory

 public function recursiveRemoveDirectory($dir)
 {
     $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
     $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($files as $file) {
         if ($file->getFilename() === '.' || $file->getFilename() === '..') {
             continue;
         }
         if ($file->isDir()) {
             rmdir($file->getRealPath());
         } else {
             rm($file->getRealPath());
         }
     }
     if ($dir != $this->path) {
         rmdir($dir);
     }
 }
开发者ID:saviobosco,项目名称:lobby,代码行数:18,代码来源:class.site.php

示例15: createDataContainer

 /** Create the data container from the image name
  * @param string $imageName
  */
 public function createDataContainer($imageName)
 {
     $directory = dirname($imageName);
     $filename = basename($imageName);
     list($root, $ext) = explode('.', basename($filename));
     $root = $root . '_zdata';
     //$this->_vSaveToLocation =  "./".$this->_dir."zoom/".$root;
     //If the paths already exist, an image is being re-processed, clean up for it.
     if (is_dir($this->_vSaveToLocation)) {
         $rm_err = rm($this->_vSaveToLocation);
     }
     //Make the directory
     mkdir($this->_vSaveToLocation);
     //Change the permissions
     chmod($this->_vSaveToLocation, $this->_dirmode);
     chgrp($this->_vSaveToLocation, $this->_filegroup);
 }
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:20,代码来源:FileProcessor.php


注:本文中的rm函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。