本文整理汇总了PHP中del_file函数的典型用法代码示例。如果您正苦于以下问题:PHP del_file函数的具体用法?PHP del_file怎么用?PHP del_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了del_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: del_file
function del_file($dir, $time, $limit = true)
{
if (file_exists($dir)) {
$open = opendir($dir);
while (($file = readdir($open)) !== false) {
if ($file != '.' && $file != '..') {
$pdir = $dir . $file;
if (is_dir($pdir)) {
del_file($pdir . '/', $time, $limit);
} else {
//if(filemtime($pdir) < $time && !strpos($pdir, '.id') && !strpos($pdir, '.list'))
if (filemtime($pdir) < $time) {
if ($limit) {
if (strpos($pdir, '.mp4')) {
flushMsg($pdir);
unlink($pdir);
//file_put_contents(UPLOAD_DIR . 'clear.list', $pdir, FILE_APPEND);
}
} else {
flushMsg($pdir);
unlink($pdir);
}
}
}
}
}
closedir($open);
} else {
echo "no exists!";
}
}
示例2: delattach
public function delattach()
{
$id = I('get.id');
if (empty($id)) {
return false;
}
$result = del_file($id);
if ($result) {
$this->success('删除成功', U('attach'));
} else {
$this->error(L('_DELETE_FAIL_'));
}
}
示例3: unzip_file
function unzip_file($zipfile, $dest, $entries = array())
{
// delete files if exists;
$dels = array();
foreach ($entries as $entry) {
array_push($dels, $dest . $entry);
}
if (!del_file($dels)) {
return FALSE;
}
// create object
$zip = new ZipArchive();
// open archive
if ($zip->open($zipfile)) {
// extract contents to destination directory
$res = $zip->extractTo($dest, $entries);
// close archive
$zip->close();
if ($res === TRUE) {
return TRUE;
}
}
return FALSE;
}
示例4: closedir
}
closedir($dir);
}
//图片目录转移
$imgpath = str_replace(".htm", "", ROOT_PATH . $postdb[filepath]);
makepath($imgpath);
$dir = opendir($truedir);
while ($file = readdir($dir)) {
if ($file == '.' || $file == '..') {
continue;
}
rename("{$truedir}/{$file}", "{$imgpath}/{$file}");
}
closedir($dir);
//删除临时创建的目录
del_file(dirname(ROOT_PATH . $postdb[filepath]) . "/tmp");
//处理图片路径
$file = read_file(ROOT_PATH . $postdb[filepath]);
$file = preg_replace("/^([^>]+)>(.*)/is", "\\1>\r\n\r\n<!--这一行是系统自动添加的代码,目的是为了处理图片的路径--><base href='{$webdb['www_url']}/" . str_replace(".htm", "/", $postdb[filepath]) . "'>\r\n\r\n\\2", $file);
write_file(ROOT_PATH . $postdb[filepath], $file);
} else {
if (!$postdb[code]) {
showerr("内容不能为空", 1);
}
$postdb[code] = stripslashes($postdb[code]);
if (eregi("(\\.htm|\\.html)\$", $postdb[filepath])) {
write_file(ROOT_PATH . $postdb[filepath], $postdb[code]);
}
if (!is_writable(ROOT_PATH . $postdb[filepath])) {
echo "文件写入失败,请确认目录可写:" . ROOT_PATH . $postdb[filepath];
die;
示例5: mysql_query
$err_msg = "对不起,删除失败,该文件可能不存在,请检查文件名,或者稍后再试!";
}
} else {
$sql = "update files set status = 2, del_time = {$del_time} where fid = '{$fid}'";
}
/*print_r($sql);
exit;*/
$result = mysql_query($sql);
if (!$result) {
$err_msg = "对不起,删除失败,数据库繁忙,请稍后再试!";
} else {
if (mysql_affected_rows() == 0) {
$err_msg = "对不起,删除失败,该文件可能不存在,请检查文件名,或者稍后再试!";
}
}
if (isset($err_msg)) {
//echo $err_msg;
return $err_msg;
}
return true;
}
// 根据用户身份,控制删除 默认值0 普通用户, 1管理员
if (is_string($err_msg = del_file($fid, 1))) {
include "../error/error.php";
exit;
} else {
echo "<script> alert('文件删除成功!'); window.location.href=\"filesys.php\"; </script>";
//echo "<script> alert('文件删除成功!'); history.go(-1); </script>";
// history.go(-1) 不能刷新页面!
exit;
}
示例6: serverDownload
public function serverDownload()
{
$uuid = 'download_' . $this->in['uuid'];
if ($this->in['type'] == 'percent') {
//获取下载进度
//show_json($_SESSION[$uuid]);
if (isset($_SESSION[$uuid])) {
$info = $_SESSION[$uuid];
$result = array('uuid' => $this->in['uuid'], 'length' => (int) $info['length'], 'size' => (int) filesize($info['path']), 'time' => mtime());
show_json($result);
} else {
show_json('', false);
}
} else {
if ($this->in['type'] == 'remove') {
//取消下载;文件被删掉则自动停止
del_file($_SESSION[$uuid]['path']);
unset($_SESSION[$uuid]);
show_json('', false);
}
}
//下载
$save_path = _DIR($this->in['save_path']);
if (!is_writeable($save_path)) {
show_json($this->L['no_permission_write'], false);
}
$url = rawurldecode($this->in['url']);
$header = url_header($url);
if (!$header) {
show_json($this->L['download_error_exists'], false);
}
$save_path = $save_path . urldecode($header['name']);
if (!checkExt($save_path)) {
//不允许的扩展名
$save_path = _DIR($this->in['save_path']) . date() . '.txt';
}
$save_path = get_filename_auto(iconv_system($save_path));
$save_path_temp = $save_path . '.downloading';
session_start();
$_SESSION[$uuid] = array('length' => $header['length'], 'path' => $save_path_temp);
session_write_close();
if (file_download_this($url, $save_path_temp)) {
if (@rename($save_path_temp, $save_path)) {
//下载完后重命名
$name = get_path_this(iconv_app($save_path));
show_json($this->L['download_success'], true, $name);
} else {
show_json($this->L['download_error_create'], false);
}
} else {
show_json($this->L['download_error_create'], false);
}
}
示例7: _remove
function _remove()
{
$file_list = array($this->path_to . '/controller/debug.class.php', $this->path_to . '/lib/class/lessc.inc.class.php', $this->path_to . '/static/style/base.less', $this->path_to . '/static/js/lib/less-1.4.2.min.js', $this->path_to . '/static/js/lib/webuploader/webuploader.js', $this->path_to . '/static/style/skin/common.less', $this->path_to . '/static/js/Gruntfile.js', $this->path_to . '/static/js/package.json', $this->path_to . '/static/js/readme.txt', $this->path_to . '/todo.txt');
$path_list = array($this->path_to . '/data/log', $this->path_to . '/data/thumb', $this->path_to . '/static/js/_dev', $this->path_to . '/static/js/app/update', $this->path_to . '/static/js/node_modules');
foreach ($file_list as $val) {
del_file($val);
}
echo '<br/>1.文件删除完成:';
flush();
mkdir($this->path_to . '/data/User');
foreach ($path_list as $val) {
del_dir($val);
}
echo '<br/>2.文件夹删除完成:';
flush();
$path = $this->path_to . '/static/style/skin/';
$app_theme = array('default', 'metro', 'simple');
$app_less = array('app_code_edit', 'app_desktop', 'app_editor', 'app_explorer', 'app_setting', 'button', 'config', 'dialog', 'filelist', 'right_menu', 'tree');
foreach ($app_theme as $theme) {
foreach ($app_less as $app) {
$temp = $path . $theme . '/' . $app . '.less';
del_file($temp);
}
}
echo '<br/>3.less文件删除完成<hr/>';
flush();
}
示例8: do_delete_html
/**
* 删除静态 do_delete_html
* @param null $path
* @param null $file
*/
function do_delete_html($path = NULL, $file = NULL)
{
if ($path && $file) {
$file = explode(',', $file);
foreach ($file as $v) {
$fileName = HTML_PATH . $path . '/' . $v . '.html';
del_file($fileName);
//删除静态
}
}
}
示例9: mysql_query
exit;
}
mysql_query("DELETE FROM " . TABLE_CLIENT . " WHERE client_id='{$del_client}'") or Error(1, __FILE__, __LINE__);
renew_clients($root_dir);
Header("Location: ?p={$part}&client");
exit;
}
if (@$_FILES["pricefile"]) {
$url = "?p={$part}&card_id={$card_id}";
load_file($file_owner, $card_id, $url);
Header("Location: " . $url);
exit;
}
if (@$delfile) {
$file_id = (int) @$delfile;
del_file($file_id);
Header("Location: " . ADMIN_URL . "?p={$part}&card_id={$card_id}");
exit;
}
if (isset($client)) {
$replace = array();
$data = @unserialize($_SESSION['client_data']);
foreach ($client_arr as $v) {
${$v} = @$data[$v];
}
$sort = isset($sort_arr1[$sort]) ? $sort : 'c.name';
$sortdirect = isset($sort_direct_arr[$sortdirect]) ? $sortdirect : '';
$ord = $sort == 'birthday' ? "YEAR(birthday)=0, {$sort} {$sortdirect}" : "{$sort} {$sortdirect}";
if ($sort == 'birthday_city') {
$ord = "{$sort}='', {$sort} {$sortdirect}";
}
示例10: unlink
global $output_dir;
global $output_thumbs;
if (file_exists($output_dir . $file)) {
if (file_exists($output_thumbs . $file)) {
unlink($output_thumbs . $file);
}
unlink($output_dir . $file);
return "Photo \"" . $file . "\" was deleted.";
} else {
return "Photo \"" . $file . "\" was not found. Perhaps it was already deleted?";
}
}
if (!empty($_POST['files'])) {
$i = 0;
foreach ($_POST['files'] as $file) {
$success = del_file($file);
$i++;
if ($i > 1) {
$success = $i . " photos were deleted.";
}
}
} else {
$error = "No photos selected.";
}
}
if (isset($_POST['submit'])) {
if (strpbrk($_POST['galname'], "\\/?%*:|\"<>") === FALSE) {
$galname = mysql_prep($_POST['galname']);
if (isset($_POST['subgalleries']) && $_POST['subgalleries'] != "") {
$subgalleries = serialize($_POST['subgalleries']);
} else {
示例11: delete_cache_file
function delete_cache_file($fid, $id)
{
del_file(ROOT_PATH . "cache/jsarticle_cache");
del_file(ROOT_PATH . "cache/label_cache");
del_file(ROOT_PATH . "cache/list_cache");
del_file(ROOT_PATH . "cache/bencandy_cache");
del_file(ROOT_PATH . "cache/showsp_cache");
}
示例12: foreach
$styledb[$key] = $value;
}
$show = "<?php\tunset(\$styledb);";
foreach ($styledb as $key => $value) {
$show .= "\n\t\t\$styledb['{$key}']='{$value}';";
}
write_file(ROOT_PATH . "data/style/{$postdb['keywords']}.php", $show . "?>");
write_file(ROOT_PATH . "images/{$postdb['keywords']}/style.css", stripslashes("{$CssCode}"));
jump("修改成功", "index.php?lfj=style&job=editstyle&keywords={$postdb['keywords']}");
} elseif ($action == "deletestyle" && $Apower[style_editstyle]) {
if ($keywords == 'default') {
showmsg("默认的风格不能删除");
}
if ($keywords && unlink(ROOT_PATH . "data/style/{$keywords}.php")) {
del_file(ROOT_PATH . "images/{$keywords}/");
del_file(ROOT_PATH . "template/{$keywords}/");
jump("删除成功", "index.php?lfj=style&job=deletestyle");
} else {
showmsg("删除失败,请确认文件属性可写" . ROOT_PATH . "data/style/{$keywords}.php");
}
} elseif ($job == "deletestyle" && $Apower[style_editstyle]) {
$style_select = select_style('keywords');
hack_admin_tpl('deletestyle');
} elseif ($job == 'edittpl' && ($Apower[style_editstyle] || $Apower[template_list])) {
unset($array, $listdb);
include "./tplname.php";
$keywords || ($keywords = $STYLE);
$style_select = select_style('keywords', $keywords, "index.php?lfj={$lfj}&job={$job}");
$dir = opendir(ROOT_PATH . "template/{$keywords}/");
while ($file = readdir($dir)) {
if (eregi("htm\$", $file)) {
示例13: vthumb
function vthumb($aid)
{
global $db, $pre, $webdb;
$path = ROOT_PATH . "cache/vimg/{$aid}.jpg";
if (file_exists($path) && filesize($path) != 0) {
$vtb[bimg] = $webdb[www_url] . "/cache/vimg/{$aid}.jpg";
} else {
makepath(ROOT_PATH . "cache/vimg/");
if (filesize($path) == 0) {
del_file($path);
}
$vdb = $db->get_one("SELECT R.*,A.* FROM {$pre}article A LEFT JOIN {$pre}reply R ON A.aid=R.aid WHERE A.aid='{$aid}' ORDER BY R.rid ASC LIMIT 1");
preg_match('/\\<embed.+?src="(.+?)".*?>/is', $vdb[content], $embed);
$temp = explode('/', htmlspecialchars($embed[1]));
$host = $temp[2];
switch ($host) {
case "player.56.com":
preg_match("#http://player.56.com/v_(\\w+)#i", $embed[1], $match);
$info = json_decode(vcurl($host, "http://vxml.56.com/json/{$match['1']}/"), true);
if ($info[status] == 1) {
$vtb[bimg] = $info[info][bimg];
write_file($path, vcurl($host, $vtb[bimg]));
} else {
$vtb[bimg] = $webdb[www_url] . '/images/video.jpg';
}
break;
case "player.youku.com":
preg_match("#http://player.youku.com/player.php/sid/(\\w+)/v.swf#i", $embed[1], $match);
$info = json_decode(vcurl($host, "http://v.youku.com/player/getPlayList/VideoIDS/{$match['1']}/"), true);
if (!empty($info[data][0])) {
$vtb[bimg] = $info[data][0][logo];
write_file($path, vcurl($host, $vtb[bimg]));
} else {
$vtb[bimg] = $webdb[www_url] . '/images/video.jpg';
}
break;
case "www.tudou.com":
preg_match("#http://www.tudou.com/(v|l)/([\\w-]+)/#i", $embed[1], $match);
$info = json_decode(vcurl($host, "http://api.tudou.com/v3/gw?method=item.info.get&appKey=myKey&format=json&itemCodes={$match['2']}"), true);
if (!empty($info[multiResult][results][0])) {
$vtb[bimg] = $info[multiResult][results][0][bigPicUrl];
write_file($path, vcurl($host, $vtb[bimg]));
} else {
$vtb[bimg] = $webdb[www_url] . '/images/video.jpg';
}
break;
case "player.video.qiyi.com":
preg_match("#http://player.video.qiyi.com/(\\w+)/(\\d+)/(\\d+)/v_(\\w+).swf#i", $embed[1], $match);
if (!empty($match)) {
$cont = vcurl($host, "http://www.iqiyi.com/v_{$match['4']}.html");
preg_match('/itemprop="image" content="(.*?).jpg"/s', $cont, $info);
if (empty($info)) {
preg_match('/itemprop="thumbnailUrl" content=\'(.*?)\'/s', $cont, $info);
$vtb[bimg] = $info[1];
} else {
$vtb[bimg] = !preg_match("/404/", implode(",", get_headers($vtb[bimg]))) ? $info[1] . "_116_65.jpg" : $info[1] . "_180_101.jpg";
}
write_file($path, vcurl($host, $vtb[bimg]));
} else {
$vtb[bimg] = $webdb[www_url] . '/images/video.jpg';
}
break;
case "player.pps.tv":
preg_match("#http://player.pps.tv/player/sid/(\\w+)/v.swf#i", $embed[1], $match);
if (!empty($match)) {
$cont = vcurl($host, "http://v.pps.tv/play_{$match['1']}.html");
preg_match('/sharepic":"(.*?)","/s', $cont, $info);
if (!empty($info)) {
$vtb[bimg] = stripslashes($info[1]);
write_file($path, vcurl($host, $vtb[bimg]));
} else {
$vtb[bimg] = $webdb[www_url] . '/images/video.jpg';
}
} else {
$vtb[bimg] = $webdb[www_url] . '/images/video.jpg';
}
break;
case "static.video.qq.com":
preg_match("#http://static.video.qq.com/TPout.swf\\?vid=(\\w+)#i", $embed[1], $match);
$vtb[bimg] = "http://vpic.video.qq.com/{$match['1']}_ori_1.jpg";
write_file($path, vcurl($host, $vtb[bimg]));
break;
case "resources.baomihua.com":
preg_match("#http://resources.baomihua.com/(\\d+).swf#i", $embed[1], $match);
$vtb[bimg] = "http://img02.video.baomihua.com/x/{$match['1']}.jpg";
write_file($path, vcurl($host, $vtb[bimg]));
break;
default:
$vtb[host] = $host;
$vtb[bimg] = $webdb[www_url] . '/images/video.jpg';
}
}
return $vtb;
}
示例14: urldecode
$cmd_arg = $_POST['cmd_arg'];
$cmd_data = $_POST['cmd_data'];
$current_path = urldecode($_POST['current_path']);
$selected_file_list = $_POST['selected_file_list'];
switch ($cmd_arg) {
case 1:
//新建文件
create_dir();
break;
case 2:
//新建文件夹
create_file();
break;
case 3:
//删除文件
del_file(iconv('UTF-8', 'GB2312', $current_path . $selected_file_list));
break;
case 4:
//下载文件
download();
break;
case 5:
//重命名
renamefile();
break;
case 6:
//编辑文件
edit_file();
break;
case 10:
//上传文件
示例15: serverDownload
public function serverDownload()
{
if ($_SERVER['HTTP_REFERER'] != $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]) {
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
$uuid = 'download_' . $this->in['uuid'];
if ($this->in['type'] == 'percent') {
//Get the download progress
//show_json($_SESSION[$uuid]);
if (isset($_SESSION[$uuid])) {
$info = $_SESSION[$uuid];
$result = array('uuid' => $this->in['uuid'], 'length' => (int) $info['length'], 'size' => (int) filesize($info['path']), 'time' => mtime());
show_json($result);
} else {
show_json('', false);
}
} else {
if ($this->in['type'] == 'remove') {
//Cancel download; files are deleted automatically stops
del_file($_SESSION[$uuid]['path']);
unset($_SESSION[$uuid]);
show_json('', false);
}
}
//download
$save_path = _DIR($this->in['save_path']);
if (!is_writeable($save_path)) {
show_json($this->L['no_permission_write'], false);
}
$url = rawurldecode($this->in['url']);
$header = url_header($url);
if (!$header) {
show_json($this->L['download_error_exists'], false);
}
$save_path = $save_path . urldecode($header['name']);
if (!checkExt($save_path)) {
//Allowed extension
$save_path = _DIR($this->in['save_path']) . date() . '.txt';
}
$save_path = get_filename_auto(iconv_system($save_path));
$save_path_temp = $save_path . '.downloading';
session_start();
$_SESSION[$uuid] = array('length' => $header['length'], 'path' => $save_path_temp);
session_write_close();
if (file_download_this($url, $save_path_temp)) {
if (@rename($save_path_temp, $save_path)) {
//After downloading rename
$name = get_path_this(iconv_app($save_path));
show_json($this->L['download_success'], true, $name);
} else {
show_json($this->L['download_error_create'], false);
}
} else {
show_json($this->L['download_error_create'], false);
}
}
} else {
header('Location: 403.php');
}
}