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(''); }
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())); }
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')); }
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')); }
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(''); } }
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; }
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; }
protected function delete($name, $output) { f::remove($this->root() . DS . $name . '.php'); $output->writeln('<comment>The "' . $name . '" controller has been deleted!</comment>'); $output->writeln(''); }
public static function tearDownAfterClass() { // kill the database f::remove(self::$database); }
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')); }
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')); }
/** * Remove an item from the cache * * @param string $key * @return boolean */ public function remove($key) { return f::remove($this->file($key)); }
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'); } }
<?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;
static function remove($file) { f::remove(self::$file); }
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; } }
public function testRemove() { $this->assertTrue(f::remove(TEST_ROOT_TMP . DS . 'moved.txt')); $this->assertTrue(f::remove(TEST_ROOT_TMP . DS . 'copied.txt')); }
/** * Alternative for delete * * @return boolean */ public function remove() { return f::remove($this->root); }
/** * 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; }