remove() static public method

Deletes a file
static public remove ( string $file ) : boolean
$file string The path for the file
return boolean
Example #1
0
 protected function delete($name, $output)
 {
     if ($file = f::resolve($this->root() . DS . $name, ['yaml', 'yml', 'php'])) {
         f::remove($file);
     }
     $output->writeln('<comment>The "' . $name . '" blueprint has been deleted!</comment>');
     $output->writeln('');
 }
Example #2
0
 public function testRebuild()
 {
     $a = $this->library->create('test');
     $b = $this->library->create('test');
     // delete the index
     f::remove($this->library->root() . DS . 'library.sqlite');
     $this->library->rebuild();
     $this->assertEquals(2, $this->library->count());
     $this->assertInstanceOf('Library\\Item', $this->library->find($b->id()));
 }
Example #3
0
 public function delete($username)
 {
     $user = $this->user($username);
     if (!$user) {
         return response::error(l('users.avatar.delete.error.missing'));
     }
     if ($avatar = $user->avatar()) {
         if (f::remove($avatar->root())) {
             return response::success(l('users.avatar.delete.success'));
         }
     }
     return response::error(l('users.avatar.delete.error'));
 }
Example #4
0
 public function delete($username)
 {
     $user = $this->user($username);
     if (!$user) {
         return response::error(l('users.avatar.delete.error.missing'));
     }
     if (!site()->user()->isAdmin() and !$user->isCurrent()) {
         return response::error('You are not allowed to delete the avatar of this user');
     }
     if ($avatar = $user->avatar()) {
         if (f::remove($avatar->root())) {
             return response::success(l('users.avatar.delete.success'));
         }
     }
     return response::error(l('users.avatar.delete.error'));
 }
Example #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->isInstalled() === false) {
         throw new RuntimeException('Invalid Kirby installation');
     }
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion('<info>Do you really want to uninstall Kirby? (y/n)</info>' . PHP_EOL . 'leave blank to cancel: ', false);
     if ($helper->ask($input, $output, $question)) {
         // load kirby
         $this->bootstrap();
         f::remove($this->dir() . DS . 'index.php');
         f::remove($this->dir() . DS . '.htaccess');
         f::remove($this->dir() . DS . '.gitignore');
         f::remove($this->dir() . DS . 'license.md');
         f::remove($this->dir() . DS . 'readme.md');
         dir::remove($this->dir() . DS . 'kirby');
         dir::remove($this->dir() . DS . 'panel');
         dir::remove($this->dir() . DS . 'thumbs');
         $output->writeln('<comment>Kirby has been uninstalled!</comment>');
         $output->writeln('');
     }
 }
Example #6
0
 public function delete()
 {
     // delete the meta file
     f::remove($this->textfile());
     if (!f::remove($this->root())) {
         throw new Exception('The file could not be deleted');
     }
     cache::flush();
     return true;
 }
Example #7
0
 public function delete()
 {
     foreach ($this->site->languages() as $lang) {
         // delete the meta file for each language
         f::remove($this->textfile($lang->code()));
     }
     parent::delete();
     return true;
 }
Example #8
0
 protected function delete($name, $output)
 {
     f::remove($this->root() . DS . $name . '.php');
     $output->writeln('<comment>The "' . $name . '" controller has been deleted!</comment>');
     $output->writeln('');
 }
Example #9
0
 public static function tearDownAfterClass()
 {
     // kill the database
     f::remove(self::$database);
 }
Example #10
0
 static function deleteFile()
 {
     global $page;
     $filename = get('filename');
     $file = $page->files()->find($filename);
     if (!$file) {
         return array('status' => 'error', 'msg' => l::get('files.delete.errors.notfound'));
     }
     if (!f::remove($file->root())) {
         return array('status' => 'error', 'msg' => l::get('files.delete.errors.permissions'));
     }
     self::killCache();
     return array('status' => 'success', 'msg' => l::get('files.delete.success'));
 }
Example #11
0
 static function deleteFile()
 {
     global $page;
     $filename = get('filename');
     $file = $page->files()->find($filename);
     if (!$file) {
         return array('status' => 'error', 'msg' => l::get('files.delete.errors.notfound'));
     }
     if (!f::remove($file->root())) {
         return array('status' => 'error', 'msg' => l::get('files.delete.errors.permissions'));
     }
     // remove the meta file
     $meta = dirname($file->root()) . '/' . $file->filename() . '.' . c::get('content.file.extension', 'txt');
     f::remove($meta);
     if (c::get('lang.support')) {
         // delete each translated meta file
         foreach (c::get('lang.available') as $lang) {
             $meta = dirname($file->root()) . '/' . $file->filename() . '.' . $lang . '.' . c::get('content.file.extension', 'txt');
             f::remove($meta);
         }
     }
     self::killCache();
     return array('status' => 'success', 'msg' => l::get('files.delete.success'));
 }
Example #12
0
 /**
  * Remove an item from the cache
  *
  * @param string $key
  * @return boolean
  */
 public function remove($key)
 {
     return f::remove($this->file($key));
 }
Example #13
0
 public function detach($filename)
 {
     $filename = f::safeName($filename);
     if ($filename == 'item.yaml') {
         throw new Exception('The item.yaml file cannot be removed');
     }
     if (!f::remove($this->root() . DS . $filename)) {
         throw new Exception('The file cannot be removed');
     }
 }
Example #14
0
<?php

/* print_r($_POST);
print_r($_FILES);
die(); */
require_once dirname(__FILE__) . '/libs/secure_upload.php';
require_once dirname(__FILE__) . '/libs/smush.php';
$options = array('field' => 'uploads', 'path' => dirname(__FILE__) . '/demo/img');
$r = secure_upload($options);
if ($r['success']) {
    foreach ($r['success'] as $k => $file) {
        $o = smush_file($options['path'] . '/' . str_replace('..', '.', $file['filename']));
        f::remove($options['path'] . '/' . str_replace('..', '.', $file['filename']));
        if ($o && !$o['error']) {
            $r['success'][$k]['filename'] = $file['filename'] . ' - optimized :' . $o['percent'] . '%';
        } else {
            $r['success'][$k]['filename'] = $file['filename'] . ' - ' . print_r($o, true);
        }
    }
}
echo json_encode($r);
die;
Example #15
0
 static function remove($file)
 {
     f::remove(self::$file);
 }
Example #16
0
 public function delete()
 {
     if ($avatar = $this->avatar()) {
         $avatar->delete();
     }
     if (!f::remove($this->file())) {
         throw new Exception('The account could not be deleted');
     } else {
         return true;
     }
 }
Example #17
0
 public function testRemove()
 {
     $this->assertTrue(f::remove(TEST_ROOT_TMP . DS . 'moved.txt'));
     $this->assertTrue(f::remove(TEST_ROOT_TMP . DS . 'copied.txt'));
 }
Example #18
0
 /**
  * Alternative for delete
  *
  * @return boolean
  */
 public function remove()
 {
     return f::remove($this->root);
 }
Example #19
0
 /**
  * Zip a directory 
  * 
  * @param string $dir path to the directory
  * @param string $to path to the zip file
  * @return boolean
  */
 public static function zip($dir, $to)
 {
     if (!class_exists('ZipArchive')) {
         throw new Exception('The ZipArchive class is not available');
     }
     if (!is_dir($dir)) {
         return false;
     }
     $zip = new ZipArchive();
     // remove any existing zip
     f::remove($to);
     if ($zip->open($to, ZipArchive::CREATE) === false) {
         return false;
     }
     $dirs = new RecursiveDirectoryIterator($dir);
     $files = new RecursiveIteratorIterator($dirs, RecursiveIteratorIterator::LEAVES_ONLY);
     foreach ($files as $name => $file) {
         if ($file->isDir()) {
             continue;
         }
         // Get real and relative path for current file
         $filePath = $file->getRealPath();
         $relativePath = substr($filePath, strlen($dir) + 1);
         // Add current file to archive
         $zip->addFile($filePath, $relativePath);
     }
     $zip->close();
     return true;
 }