本文整理汇总了PHP中file::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP file::delete方法的具体用法?PHP file::delete怎么用?PHP file::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* Writes a line in the log file
*
* @param string $line
*/
public function write($line)
{
file::append($this->filepath, date($this->date_format) . ' - ' . $line . "\n");
// If the max size is exceeded
if (file::getSize($this->filepath) >= $this->max_size) {
file::delete($this->filepath . '.' . $this->nb_old_logs);
for ($i = $this->nb_old_logs; $i >= 1; $i--) {
if (file::exists($this->filepath . ($i == 1 ? '' : '.' . ($i - 1)))) {
file::rename($this->filepath . ($i == 1 ? '' : '.' . ($i - 1)), $this->filepath . '.' . $i);
}
}
}
}
示例2: remove
public function remove($id)
{
$file = new file();
$file->find($id);
$file->delete();
try {
unlink('app/' . $this->conf['blog_upload_folder'] . '/' . $file->name);
$this->session->flash($this->l10n->__("Borrado"));
} catch (Exception $e) {
$this->session->flash($this->l10n->__("No se pudo borrar el archivo, comprueba los permisos del directorio"));
}
$this->redirect("files");
}
示例3: deleteIn
function deleteIn($loc)
{
global $db;
$banners = $db->selectObjects('banner_ad', "location_data='" . serialize($loc) . "'");
foreach ($banners as $b) {
$db->delete('banner_click', 'ad_id=' . $b->id);
$file = $db->selectObject('file', 'id=' . $b->file_id);
file::delete($file);
}
if (file_exists(BASE . 'files/bannermodule/' . $loc->src)) {
rmdir(BASE . 'files/bannermodule/' . $loc->src);
}
$db->delete('banner_ad', "location_data='" . serialize($loc) . "'");
}
示例4: clear_directory
private function clear_directory()
{
//上传临时目录
file::delete(FILE_TEMP, true);
//编译、缓存数据、session
$cache_folder_list = array('smarty/compile', 'compile', 'session');
foreach ($cache_folder_list as $cache_folder) {
file::delete(PATH_CACHE . $cache_folder, false);
}
//日志topic->curl,error,exception,mail,memcache,model,mysql,redis,server
$log_folder_list = array('mail', 'mongo', 'run', 'sql', 'run', 'test', 'topic', 'trace', 'visit');
foreach ($log_folder_list as $log_folder) {
file::delete(PATH_LOG . $log_folder, false);
}
}
示例5: delete
public function delete($where)
{
if (!is_array($where)) {
$key = $this->key();
if (empty($where)) {
$where = array($key, '=', $this->{$key});
}
if (is_numeric($where) || is_string($where)) {
$where = array($key, '=', $where);
}
}
$files = $this->db()->select('id,path')->where($where)->getAll();
foreach ($files as $file) {
file::delete(ZOTOP_PATH_ROOT . DS . $file['path']);
}
return $this->db()->where($where)->delete();
}
示例6: run
function run()
{
global $user;
global $layout;
global $DB;
global $website;
$out = '';
$item = new file();
switch ($_REQUEST['act']) {
case 1:
// json retrieval & operations
// json retrieval & operations
case "json":
if ($_REQUEST['op'] == 'upload') {
$tmp_name = $_REQUEST['tmp_name'];
if ($tmp_name == "{{BASE64}}") {
$tmp_name = base64_encode($_REQUEST['name']);
}
$file = file::register_upload($tmp_name, $_REQUEST['name'], $_REQUEST['parent']);
if (!empty($file)) {
echo json_encode(array('id' => $file->id, 'name' => $file->name));
} else {
echo json_encode(false);
}
}
switch ($_REQUEST['op']) {
case 'create_folder':
file::create_folder($_REQUEST['name'], $_REQUEST['mime'], $_REQUEST['parent']);
echo json_encode(true);
break;
case 'edit_folder':
$f = new file();
$f->load(intval($_REQUEST['id']));
$f->name = $_REQUEST['name'];
$f->mime = $_REQUEST['mime'];
$ok = $f->save();
echo json_encode($ok);
break;
case 'edit_file':
$f = new file();
$f->load(intval($_REQUEST['id']));
$f->name = $_REQUEST['name'];
$ok = $f->save();
echo json_encode($ok);
break;
case 'duplicate_file':
//error_reporting(~0);
//ini_set('display_errors', 1);
$status = false;
$f = new file();
$f->load(intval($_REQUEST['id']));
$f->id = 0;
$f->insert();
if (!empty($f->id)) {
$done = copy(NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . intval($_REQUEST['id']), NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $f->id);
$status = "true";
if (!$done) {
$f->delete();
$status = t(56, "Unexpected error");
}
}
echo $status;
break;
case 'move':
if (is_array($_REQUEST['item'])) {
$ok = true;
for ($i = 0; $i < count($_REQUEST['item']); $i++) {
unset($item);
$item = new file();
$item->load($_REQUEST['item'][$i]);
$item->parent = $_REQUEST['folder'];
$ok = $ok & $item->update();
}
echo json_encode($ok ? true : false);
} else {
$item->load($_REQUEST['item']);
$item->parent = $_REQUEST['folder'];
echo json_encode($item->update());
}
break;
case 'delete':
try {
$item->load($_REQUEST['id']);
$status = $item->delete();
echo json_encode($status);
} catch (Exception $e) {
echo $e->getMessage();
}
break;
case 'permissions':
$item->load($_REQUEST['id']);
if (!empty($_POST)) {
$item->access = intval($_POST['access']);
$item->permission = intval($_POST['permission']);
$item->enabled = intval($_POST['enabled']);
$item->groups = $_POST['groups'];
if ($item->access < 3) {
$item->groups = array();
}
$status = $item->save();
//.........这里部分代码省略.........
示例7: clear
function clear($mode = false)
{
//如果文件存在,删除文件
if ($this->is_exist()) {
file::delete($this->file_name);
}
//删除目录
if ($mode && $this->is_exist(false)) {
file::delete($this->save_dir, true);
}
}
示例8: deleteIn
function deleteIn($loc)
{
global $db;
$data = $db->selectObject('swfitem', "location_data='" . serialize($loc) . "'");
if ($data) {
$file = $db->selectObject('file', 'id=' . $data->alt_image_id);
file::delete($file);
$db->delete('file', 'id=' . $file->id);
$file = $db->selectObject('file', 'id=' . $data->swf_id);
file::delete($file);
$db->delete('file', 'id=' . $file->id);
$db->delete('swfitem', 'id=' . $data->id);
}
}
示例9: date
/**
* garbage collection function
*
*/
function _gc()
{
//remove expired file from session folder
$dirHandler = @opendir($this->dir);
$output = '';
$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
$fo = new file();
if ($dirHandler) {
while (false !== ($file = readdir($dirHandler))) {
// This is to preserve the empty index.html and during development - the hidden .svn folder. No need for Chamilo because ajaxfilemanager sessions are disabled
//if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() )
if ($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() && $file != 'index.html' && $file != '.svn') {
$path = $this->dir . $file;
$output .= $path;
//check if this is a expired session file
if (filemtime($path) + $this->lifeTime < time()) {
if ($fo->delete($path)) {
$output .= ' Deleted at ' . date('d/M/Y H:i:s');
} else {
$output .= " Failed at " . date('d/M/Y H:i:s');
}
}
$output .= "\n";
}
}
if ($this->debug) {
$this->_log($output);
}
@closedir($dirHandler);
}
if (CONFIG_SYS_DEMO_ENABLE) {
//remove expired files from uploaded folder
$dirHandler = @opendir(CONFIG_SYS_ROOT_PATH);
$output = '';
$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
$fo = new file();
if ($dirHandler) {
while (false !== ($file = readdir($dirHandler))) {
if ($file != '.' && $file != '..') {
$path = CONFIG_SYS_ROOT_PATH . $file;
$output .= $path;
//check if this is a expired session file
if (filemtime($path) + $this->lifeTime < time()) {
if ($fo->delete($path)) {
$output .= ' Deleted at ' . date('d/M/Y H:i:s');
} else {
$output .= " Failed at " . date('d/M/Y H:i:s');
}
}
$output .= "\n";
}
}
if ($this->debug) {
$this->_log($output);
}
@closedir($dirHandler);
}
}
}
示例10: deleteSessionOzsa
public static function deleteSessionOzsa($name)
{
$name = self::createFileName($name);
$file = self::$sessionFolder . "/" . $name . ".ozsa";
if (file::check($file)) {
file::delete($file);
} else {
return false;
}
}
示例11: delete
/**
* Delete cached value. You cand define what you want.
* If you define nothing, all the cache will be deleted.
*
* @param array $prm Parameter for the cached variable to deleted:
* - string callFrom: Representing CLASS-FUNCTION name of the original calling cache
* - string type: Cache type, could be 'get' or 'start' (optionnal)
* - string id: Cache id (optionnal)
* - array tags: Tags for the id (optionnal)
* @return int|bool Number of cache deleted or false
* @see get, start
*/
public function delete(array $prm = array())
{
if (config::initTab($prm, array('callFrom' => '*', 'type' => '*', 'id' => '*', 'tags' => false, 'request' => array('uri' => false, 'meth' => array())))) {
$file = $this->file($prm);
$file[strlen($file) - 1] = '*';
if (!empty($prm['tags'])) {
for ($i = 0; $i < count($prm['tags']); $i++) {
$file = str_replace(',' . $prm['tags'][$i] . ',', '*,' . $prm['tags'][$i] . ',', $file);
}
}
$files = glob($file);
$nb = 0;
foreach ($files as $f) {
if (file::delete($f)) {
$nb++;
}
}
return $nb;
}
return 0;
}
示例12: deleteIn
function deleteIn($loc)
{
global $db;
$directory = 'files/imagemanagermodule/' . $loc->src;
foreach ($db->selectObjectsIndexedArray("file", "directory='{$directory}'") as $file) {
file::delete($file);
}
rmdir(BASE . $directory);
$db->delete('imagemanageritem', "location_data='" . serialize($loc) . "'");
}
示例13: delete
public function delete()
{
global $DB;
global $website;
global $user;
if ($user->permission("files.delete") == 'false') {
throw new Exception(t(610, "Sorry, you are not allowed to execute this function."));
}
if ($this->type == 'folder') {
$DB->query('SELECT id
FROM nv_files
WHERE parent = ' . intval($this->id) . '
AND website = ' . $website->id);
$all = $DB->result();
for ($i = 0; $i < count($all); $i++) {
unset($tmp);
$tmp = new file();
$tmp->load($all[$i]->id);
$tmp->delete();
}
}
// remove the virtual folder/file and its data
if (!empty($this->id)) {
$DB->execute('DELETE
FROM nv_files
WHERE id = ' . intval($this->id) . '
AND website = ' . $website->id);
if ($DB->get_affected_rows() == 1 && $this->type != 'folder') {
@unlink(NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $this->id);
}
}
return $DB->get_affected_rows();
}
示例14: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$rental = Rental::find(Input::get('id'));
if ($rental) {
file::delete('public/' . $rental->image);
$rental->delete();
return Redirect('admin/rentals')->with('message', 'Rental Deleted');
}
return Redirect('admin/rentals')->with('message', 'Something went wrong, please try again');
}
示例15: exit
# You should have received a copy of the GNU
# General Public License along with Exponent; if
# not, write to:
#
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307 USA
#
# $Id: revert_changes.php,v 1.1 2005/04/18 01:27:23 filetreefrog Exp $
##################################################
if (!defined('PATHOS')) {
exit('');
}
// PERM CHECK
$original = $db->selectObject('imageworkshop_image', 'id=' . $_GET['id']);
if ($original) {
$working = $db->selectObject('imageworkshop_imagetmp', 'original_id=' . $original->id);
if ($working) {
$wfile = $db->selectObject('file', 'id=' . $working->file_id);
if ($wfile) {
file::delete($wfile);
}
$db->delete('file', 'id=' . $wfile->id);
$db->delete('imageworkshop_imagetmp', 'id=' . $working->id);
}
pathos_flow_redirect();
} else {
echo SITE_404_HTML;
}
// END PERM CHECK