Example #1
0
    $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));
    Notify::success(Config::speak('notify_success_updated', $speak->shield));
    foreach (glob(LOG . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) {
        File::open($asset_cache)->delete();
    }
    Guardian::kick($config->manager->slug . '/shield/' . $slug);
});
/**
 * Shield Updater (Base)
 * ---------------------
 */
if ($route = Route::is($config->manager->slug . '/shield/(:any)/update')) {
    Weapon::add('routes_before', function () use($config, $speak, $route) {
        if (!Route::accepted($route['path'])) {
            Route::accept($route['path'], function () use($config, $speak, $route) {
                if ($request = Request::post()) {
                    $s = $route['lot'][0];
                    $request = Filter::apply('request:__shield', $request, $s);
                    Guardian::checkToken($request['token']);
                    unset($request['token']);
                    // remove token from request array
                    File::serialize($request)->saveTo(SHIELD . DS . $s . DS . 'states' . DS . 'config.txt', 0600);
                    Notify::success(Config::speak('notify_success_updated', $speak->shield));
                    Guardian::kick(File::D($config->url_current));
                }
            });
        }
    }, 1);
}