if ($_file !== false) { // Remove empty folder(s) $f = glob(File::D($_file) . DS . '*', GLOB_NOSORT); if (empty($f)) { File::open(File::D($_file))->delete(); } Notify::success(Config::speak('notify_file_deleted', '<code>' . File::B($_file) . '</code>')); } else { Notify::success(Config::speak('notify_success_deleted', $speak->shield)); } Weapon::fire(array('on_shield_update', 'on_shield_destruct'), array($P, $P)); Guardian::kick($config->manager->slug . '/shield' . ($_file !== false ? '/' . $folder : "")); } else { Notify::warning(Config::speak('notify_confirm_delete_', $file !== false ? '<code>' . $path . '</code>' : '<strong>' . $info->title . '</strong>')); } Shield::lot(array('segment' => 'shield', 'folder' => $folder, 'files' => Mecha::O(Get::files(SHIELD . DS . $folder, '*')), 'path' => $path))->attach('manager'); }); /** * Shield Attacher * --------------- */ Route::accept($config->manager->slug . '/shield/(attach|eject)/id:(:any)', function ($path = "", $slug = "") use($config, $speak) { if (!Guardian::happy(1) || !file_exists(SHIELD . DS . $slug)) { Shield::abort(); } $new_config = Get::state_config(); $new_config['shield'] = $path === 'attach' ? $slug : 'normal'; File::serialize($new_config)->saveTo(STATE . DS . 'config.txt', 0600); $G = array('data' => array('id' => $slug, 'action' => $path)); $mode = $path === 'eject' ? 'eject' : 'mount'; Notify::success(Config::speak('notify_success_updated', $speak->shield));
Shield::abort(); } $info = Shield::info($folder, true); if ($path) { $path = File::path($path); if (!($file = File::exist(SHIELD . DS . $folder . DS . $path))) { Shield::abort(); // File not found! } } else { if (!($file = File::exist(SHIELD . DS . $folder))) { Shield::abort(); // Folder not found! } } Config::set(array('page_title' => $speak->deleting . ': ' . ($path ? File::B($file) : $info['title']) . $config->title_separator . $config->manager->title, 'files' => Get::files(SHIELD . DS . $folder, '*'), 'cargo' => DECK . DS . 'workers' . DS . 'kill.shield.php')); if ($request = Request::post()) { Guardian::checkToken($request['token']); $P = array('data' => array('path' => $file)); File::open($file)->delete(); if ($path) { Notify::success(Config::speak('notify_file_deleted', '<code>' . File::B($path) . '</code>')); } else { Notify::success(Config::speak('notify_success_deleted', $speak->shield)); } Weapon::fire('on_shield_update', array($P, $P)); Weapon::fire('on_shield_destruct', array($P, $P)); Guardian::kick($config->manager->slug . '/shield' . ($path ? '/' . $folder : "")); } else { Notify::warning(Config::speak('notify_confirm_delete_', $path ? '<code>' . File::path($path) . '</code>' : '<strong>' . $info['title'] . '</strong>')); }
<?php /** * Cache Manager * ------------- */ Route::accept(array($config->manager->slug . '/cache', $config->manager->slug . '/cache/(:num)'), function ($offset = 1) use($config, $speak) { if (!Guardian::happy(1)) { Shield::abort(); } $filter = Request::get('q', ""); $filter = $filter ? Text::parse($filter, '->safe_file_name') : ""; $files = Get::files(CACHE, '*', 'DESC', 'update', $filter); $files_chunk = Mecha::eat($files)->chunk($offset, $config->per_page * 2)->vomit(); Config::set(array('page_title' => $speak->caches . $config->title_separator . $config->manager->title, 'offset' => $offset, 'pagination' => Navigator::extract($files, $offset, $config->per_page * 2, $config->manager->slug . '/cache'), 'cargo' => 'cargo.cache.php')); Shield::lot(array('segment' => 'cache', 'files' => $files_chunk ? Mecha::O($files_chunk) : false))->attach('manager'); }); /** * Cache Repairer * -------------- */ Route::accept($config->manager->slug . '/cache/repair/(file|files):(:all)', function ($prefix = "", $file = "") use($config, $speak) { if (!Guardian::happy(1)) { Shield::abort(); } $path = File::path($file); if (!($file = File::exist(CACHE . DS . $path))) { Shield::abort(); // File not found! } $G = array('data' => array('path' => $file));