function do_private_post($content, $results) { global $config, $speak; $results = Mecha::O($results); $results = $config->is->post ? Get::postHeader($results->path, POST . DS . $config->page_type, '/', $config->page_type . ':') : false; if ($results === false) { return $speak->plugin_private_post->description; } $s = isset($results->fields->pass) ? $results->fields->pass : ""; if (strpos($s, ':') !== false) { $s = explode(':', $s, 2); if (isset($s[1])) { $speak->plugin_private_post->hint = ltrim($s[1]); } // override password hint $s = $s[0]; } $hash = md5($s . PRIVATE_POST_SALT); $html = Notify::read(false) . '<div class="overlay--' . File::B(__DIR__) . '"></div><form class="form--' . File::B(__DIR__) . '" action="' . $config->url . '/' . File::B(__DIR__) . '/do:access" method="post">' . NL; $html .= TAB . Form::hidden('token', Guardian::token()) . NL; $html .= TAB . Form::hidden('_', $hash) . NL; $html .= TAB . Form::hidden('kick', $config->url_current) . NL; $html .= TAB . '<p>' . $speak->plugin_private_post->hint . '</p>' . NL; $html .= TAB . '<p>' . Form::text('access', "", $speak->password . '…', array('autocomplete' => 'off')) . ' ' . Form::button($speak->submit, null, 'submit') . '</p>' . NL; $html .= '</form>' . O_END; if ($results && isset($results->fields->pass) && trim($results->fields->pass) !== "") { if (!Guardian::happy() && Session::get('is_allow_post_access') !== $hash) { return $html; } } return $content; }
public static function __callStatic($kin, $arguments = array()) { $kin = get_called_class() . '::' . $kin; if (!isset(self::$o[$kin])) { Guardian::abort('Method <code>' . $kin . '()</code> does not exist.'); } return call_user_func_array(self::$o[$kin], $arguments); }
public function test_all_false_when_not_logged_in() { $this->assertFalse(Guardian::hasRole('editor')); $this->assertFalse(Guardian::hasAnyRole(['editor'])); $this->assertFalse(Guardian::hasAllRoles(['editor', 'reporter'])); $this->assertFalse(Guardian::hasCapability('create_user')); $this->assertFalse(Guardian::hasAnyCapability(['create_user', 'edit_user'])); $this->assertFalse(Guardian::hasAllCapabilities(['create_user', 'edit_user'])); }
public static function send($from, $to, $subject, $message, $FP = 'common:') { if (trim($to) === "" || !Guardian::check($to, '->email')) { return false; } $header = "MIME-Version: 1.0\n"; $header .= "Content-Type: text/html; charset=ISO-8859-1\n"; $header .= "From: " . $from . "\n"; $header .= "Reply-To: " . $from . "\n"; $header .= "Return-Path: " . $from . "\n"; $header .= "X-Mailer: PHP/" . phpversion(); $header = Filter::apply($FP . 'notification.email.header', $header); $message = Filter::apply($FP . 'notification.email.message', $message); return mail($to, $subject, $message, $header); }
public static function take($files) { if (!extension_loaded('gd')) { Guardian::abort('<a href="http://www.php.net/manual/en/book.image.php" title="PHP – Image Processing and GD" rel="nofollow" target="_blank">PHP GD</a> extension is not installed on your web server.'); } if (is_array($files)) { self::$open = array(); foreach ($files as $file) { self::$open[] = File::path($file); } } else { self::$open = File::path($files); } $file = is_array(self::$open) ? self::$open[0] : self::$open; self::$placeholder = File::D($file) . DS . '__' . File::B($file); self::$original = $file; File::open($file)->copyTo(self::$placeholder); self::gen($file); return new static(); }
echo Form::hidden('token', $token); ?> <?php Weapon::fire('comment_form_input_before', $hooks); ?> <?php Shield::chunk('comment.form.name'); ?> <?php Shield::chunk('comment.form.email'); ?> <?php Shield::chunk('comment.form.url'); ?> <?php echo Form::hidden('parent', Guardian::wayback('parent')); ?> <?php Weapon::fire('comment_form_input_after', $hooks); ?> <?php Weapon::fire('comment_form_textarea_before', $hooks); ?> <?php Shield::chunk('comment.form.message'); ?> <?php Weapon::fire('comment_form_textarea_after', $hooks); ?> <?php Shield::chunk('comment.form.math');
<label class="grid-group"> <span class="grid span-1 form-label"><?php echo $speak->date; ?> </span> <span class="grid span-5"> <?php echo Form::text('date', Request::get('date', Guardian::wayback('date', $page->date->W3C)), date('c'), array('class' => 'input-block')); ?> </span> </label>
<label class="grid-group"> <span class="grid span-1 form-label"><?php echo $speak->key; ?> </span> <span class="grid span-5"> <?php echo Form::text('key', Request::get('key', Guardian::wayback('key', $page->key_raw)), null, array('class' => 'input-block')); ?> </span> </label>
function do_footer_manager_link($content, $path) { global $config, $speak; if (File::N($path) === 'block.footer.bar') { $s = Guardian::happy() ? '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/logout') . '" rel="nofollow">' . $speak->log_out . '</a>' : '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/login') . '" rel="nofollow">' . $speak->log_in . '</a>'; return str_replace('<div class="blog-footer-right">', '<div class="blog-footer-right">' . $s, $content); } return $content; }
<?php /** * Error Log * --------- */ Route::accept($config->manager->slug . '/error', function () use($config, $speak) { Config::set(array('page_title' => $speak->errors . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.error.php')); Shield::lot(array('segment' => 'error', 'content' => File::open(ini_get('error_log'))->read(false)))->attach('manager'); }); /** * Error Log Killer * ---------------- */ Route::accept($config->manager->slug . '/error/kill', function () use($config, $speak) { if (!Guardian::happy(1)) { Shield::abort(); } $errors = LOG . DS . 'errors.log'; $G = array('data' => array('content' => File::open($errors)->read())); File::open($errors)->delete(); Weapon::fire('on_error_destruct', array($G, $G)); Notify::success(Config::speak('notify_success_deleted', $speak->file)); Guardian::kick(File::D($config->url_current)); });
?> " method="post"> <?php echo Form::hidden('token', $token); ?> <?php $e = File::E($path !== false ? $path : ""); $is_text = $path === false || strpos(',' . SCRIPT_EXT . ',', ',' . $e . ',') !== false; $path = File::url($path); ?> <?php if ($is_text && $content !== false) { ?> <p> <?php echo Form::textarea('content', Request::get('content', Guardian::wayback('content', $content)), $speak->manager->placeholder_content, array('class' => array('textarea-block', 'textarea-expand', 'code'))); ?> </p> <?php } ?> <p> <?php echo Form::hidden('name', $path); ?> <?php Weapon::fire('action_before', $hooks); ?> <?php echo Jot::button('action', $is_text ? $speak->update : $speak->rename); ?>
<label class="grid-group"> <span class="grid span-1 form-label"><?php echo $speak->value; ?> </span> <span class="grid span-5"> <?php echo Form::textarea('value', Converter::str(Request::get('value', Guardian::wayback('value', $page->value))), null, array('class' => 'textarea-block')); ?> </span> </label>
<?php if ($package = File::exist($destination . DS . $name)) { if (is_file($package)) { Package::take($package)->extract(); // Extract the ZIP file File::open($package)->delete(); // Delete the ZIP file Config::load(); // Refresh the configuration data ... Guardian::kick(Config::get('manager.slug') . '/' . $segment); } }
$_path = ASSET . DS . $v; File::open($_path)->delete(); return $_path; }); $is_folder_or_file = count($deletes) === 1 && is_dir(ASSET . DS . $deletes[0]) ? 'folder' : 'file'; $P = array('data' => array('files' => $info_path)); Notify::success(Config::speak('notify_' . $is_folder_or_file . '_deleted', '<code>' . implode('</code>, <code>', $deletes) . '</code>')); Weapon::fire(array('on_asset_update', 'on_asset_destruct'), array($P, $P)); Guardian::kick($config->manager->slug . '/asset/1' . str_replace('&', '&', HTTP::query('path', $p))); } else { Notify::warning(count($deletes) === 1 ? Config::speak('notify_confirm_delete_', '<code>' . File::path($name) . '</code>') : $speak->notify_confirm_delete); } Shield::lot(array('segment' => 'asset', 'files' => Mecha::O($deletes)))->attach('manager'); }); /** * Multiple Asset Action * --------------------- */ Route::accept($config->manager->slug . '/asset/do', function ($path = "") use($config, $speak) { if ($request = Request::post()) { Guardian::checkToken($request['token']); if (!isset($request['selected'])) { Notify::error($speak->notify_error_no_files_selected); Guardian::kick($config->manager->slug . '/asset/1'); } $files = Mecha::walk($request['selected'], function ($v) { return str_replace('%2F', '/', Text::parse($v, '->encoded_url')); }); Guardian::kick($config->manager->slug . '/asset/' . $request['action'] . '/files:' . implode(';', $files)); } });
function do_comment_construct() { $config = Config::get(); $speak = Config::speak(); if ($config->page_type === 'article') { $comment_id = 'comment-%d'; // Your comment ID $comment_form_id = 'comment-form'; // Your comment form ID $article = isset($config->article->path) ? $config->article : false; $G = array('data' => array('article' => Mecha::A($article), 'comment_id' => $comment_id, 'comment_form_id' => $comment_form_id)); if ($article !== false && ($request = Request::post())) { if ($task = File::exist(SHIELD . DS . $config->shield . DS . 'workers' . DS . 'task.comment.php')) { require $task; // Custom comment constructor } else { // Check token Guardian::checkToken($request['token'], $article->url . '#' . $comment_form_id); $extension = $config->comments->moderation && !Guardian::happy() ? '.hold' : '.txt'; // Check name if (trim($request['name']) === "") { Notify::error(Config::speak('notify_error_empty_field', $speak->name)); } // Check email if (trim($request['email']) !== "") { if (!Guardian::check($request['email'], '->email')) { Notify::error($speak->notify_invalid_email); } else { // Disallow passenger(s) from entering your email address in the comment email field if (!Guardian::happy() && $request['email'] === $config->author->email) { Notify::warning(Config::speak('notify_warning_forbidden_input', array('<em>' . $request['email'] . '</em>', strtolower($speak->email)))); } } } else { Notify::error(Config::speak('notify_error_empty_field', $speak->email)); } // Check URL if (trim($request['url']) !== "" && !Guardian::check($request['url'], '->url')) { Notify::error($speak->notify_invalid_url); } // Check message if (trim($request['message']) === "") { Notify::error(Config::speak('notify_error_empty_field', $speak->message)); } // Check challenge if (!Guardian::checkMath($request['math'])) { Notify::error($speak->notify_invalid_math_answer); } // Check name length if (Guardian::check($request['name'], '->too_long', 100)) { Notify::error(Config::speak('notify_error_too_long', $speak->name)); } // Check email length if (Guardian::check($request['email'], '->too_long', 100)) { Notify::error(Config::speak('notify_error_too_long', $speak->email)); } // Check URL length if (Guardian::check($request['url'], '->too_long', 100)) { Notify::error(Config::speak('notify_error_too_long', $speak->url)); } // Check message length if (Guardian::check($request['message'], '->too_long', 1700)) { Notify::error(Config::speak('notify_error_too_long', $speak->message)); } // Check for spam keyword(s) in comment $fucking_words = explode(',', $config->keywords_spam); foreach ($fucking_words as $spam) { if ($f**k = trim($spam)) { if ($request['email'] === $f**k || strpos(strtolower($request['message']), strtolower($f**k)) !== false) { Notify::warning($speak->notify_warning_intruder_detected . ' <strong class="text-error pull-right">' . $f**k . '</strong>'); break; } } } if (!Notify::errors()) { $post = Date::slug($article->time); $id = (int) time(); $parent = Request::post('parent'); $P = array('data' => $request); $P['data']['id'] = $id; $name = strip_tags($request['name']); $email = Text::parse($request['email'], '->broken_entity'); $url = isset($request['url']) && trim($request['url']) !== "" ? $request['url'] : false; $parser = strip_tags(Request::post('content_type', $config->html_parser->active)); $message = Text::parse($request['message'], '->text', WISE_CELL . '<img>', false); $field = Request::post('fields', array()); include File::D(__DIR__, 2) . DS . 'task.fields.php'; // Temporarily disallow image(s) in comment to prevent XSS $message = preg_replace('#<img(\\s[^<>]*?)>#i', '<img$1>', $message); Page::header(array('Name' => $name, 'Email' => $email, 'URL' => $url, 'Status' => Guardian::happy() ? 1 : 2, 'Content Type' => $parser, 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false))->content($message)->saveTo(COMMENT . DS . $post . '_' . Date::slug($id) . '_' . ($parent ? Date::slug($parent) : '0000-00-00-00-00-00') . $extension); Notify::success(Config::speak('notify_success_submitted', $speak->comment)); if ($extension === '.hold') { Notify::info($speak->notify_info_comment_moderation); } Weapon::fire(array('on_comment_update', 'on_comment_construct'), array($G, $P)); Guardian::kick($config->url_current . $config->ur_query . (!Guardian::happy() && $config->comments->moderation ? '#' . $comment_form_id : '#' . sprintf($comment_id, Date::format($id, 'U')))); } else { Guardian::kick($config->url_current . $config->url_query . '#' . $comment_form_id); } } } } }
<p> <?php echo Form::textarea('content', Guardian::wayback('content', $the_content), $speak->manager->placeholder_content, array('class' => array('textarea-block', 'textarea-expand', 'code'), 'data-MTE-config' => '{"tabSize":"' . (isset($editor_tab_size) ? $editor_tab_size : TAB) . '"}')); ?> </p> <p> <?php if (isset($action_update) && $action_update !== false) { ?> <?php echo Jot::button('action', $speak->update); ?> <?php } ?> <?php if (isset($action_create) && $action_create !== false) { ?> <?php echo Jot::button('construct', $speak->create); ?> <?php } ?> <?php if (isset($path_destruct) && $path_destruct !== false) { ?> <?php echo Jot::btn('destruct', $speak->delete, $path_destruct); ?> <?php
$info_path[] = $_path; File::open($_path)->delete(); } $P = array('data' => array('files' => $info_path)); Notify::success(Config::speak('notify_' . $is_folder_or_file . '_deleted', '<code>' . implode('</code>, <code>', $deletes) . '</code>')); Weapon::fire('on_asset_update', array($P, $P)); Weapon::fire('on_asset_destruct', array($P, $P)); Guardian::kick($config->manager->slug . '/asset/1' . $p); } else { Notify::warning(count($deletes) === 1 ? Config::speak('notify_confirm_delete_', '<code>' . File::path($name) . '</code>') : $speak->notify_confirm_delete); } Shield::lot('segment', 'asset')->attach('manager', false); }); /** * Multiple Asset Killer * --------------------- */ Route::accept($config->manager->slug . '/asset/kill', function ($path = "") use($config, $speak) { if ($request = Request::post()) { Guardian::checkToken($request['token']); if (!isset($request['selected'])) { Notify::error($speak->notify_error_no_files_selected); Guardian::kick($config->manager->slug . '/asset/1'); } $files = array(); foreach ($request['selected'] as $file) { $files[] = str_replace('%2F', '/', Text::parse($file, '->encoded_url')); } Guardian::kick($config->manager->slug . '/asset/kill/files:' . implode(';', $files)); } });
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)); Weapon::fire(array('on_shield_update', 'on_shield_' . $mode, 'on_shield_' . md5($slug) . '_update', 'on_shield_' . md5($slug) . '_' . $mode), array($G, $G)); foreach (glob(LOG . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) { File::open($asset_cache)->delete(); } Guardian::kick($config->manager->slug . '/shield/' . $slug); });
<?php /** * Shortcode Manager * ----------------- */ Route::accept($config->manager->slug . '/shortcode', function () use($config, $speak) { if (!Guardian::happy(1)) { Shield::abort(); } $shortcodes = Get::state_shortcode(null, array(), false); $G = array('data' => $shortcodes); Config::set(array('page_title' => $speak->shortcodes . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.shortcode.php')); if ($request = Request::post()) { $request = Filter::apply('request:__shortcode', $request); Guardian::checkToken($request['token']); $data = array(); for ($i = 0, $keys = $request['key'], $count = count($keys); $i < $count; ++$i) { if (trim($keys[$i]) !== "") { $data[$keys[$i]] = $request['value'][$i]; } } $P = array('data' => $data); File::serialize($data)->saveTo(STATE . DS . 'shortcode.txt', 0600); Notify::success(Config::speak('notify_success_updated', $speak->shortcode)); Weapon::fire('on_shortcode_update', array($G, $P)); Guardian::kick($config->url_current); } Shield::lot(array('segment' => 'shortcode', 'files' => Mecha::O($shortcodes)))->attach('manager'); });
<?php Weapon::add('on_comment_construct', function ($G, $P) use($config, $speak) { if ($config->is->post && ($post = $G['data'][$config->page_type])) { $c = $config->states->{'plugin_' . md5(File::B(__DIR__))}; $title = $post['title']; $url = $post['url'] . '#' . sprintf($G['data']['comment_id'], Date::format($P['data']['id'], 'U')); $topic = sprintf($c->subject, $title, $url); $parser = Request::post('content_type', $config->html_parser->active); $message = '<blockquote><p>' . sprintf($c->message, $title, $url) . '</p></blockquote>'; $message .= '<h3>' . $P['data']['name'] . '</h3>'; $message .= $parser !== false && $parser !== 'HTML' ? Text::parse($P['data']['message'], '->html') : $P['data']['message']; $message .= '<p>'; $message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/repair/id:' . $P['data']['id'] . '">' . $speak->edit . '</a>'; $message .= ' / '; $message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/kill/id:' . $P['data']['id'] . '">' . $speak->delete . '</a>'; $message .= '</p>'; // Sending email notification ... if (!Guardian::happy() && Notify::send($P['data']['email'], $config->author->email, $topic, $message, 'comment:')) { Weapon::fire('on_comment_notify_construct', array($P, $config->author->email, $topic, $message)); } } });
/** * Static Page * ----------- * * [1]. page-slug * */ Route::accept('(:any)', function ($slug = "") use($config) { if (!($page = Get::page($slug))) { Shield::abort('404-page'); } if ($page->state === 'drafted') { Shield::abort('404-page'); } if (isset($_GET['repair']) && Guardian::happy()) { Guardian::kick($config->manager->slug . '/page/repair/id:' . $page->id); } Filter::add('pager:url', function ($url) { return Filter::apply('page:url', $url); }); Config::set(array('page_title' => $page->title . $config->title_separator . $config->title, 'page' => $page)); Weapon::add('shell_after', function () use($page) { if (isset($page->css) && trim($page->css) !== "") { echo O_BEGIN . $page->css . O_END; } }); Weapon::add('sword_after', function () use($page) { if (isset($page->js) && trim($page->js) !== "") { echo O_BEGIN . $page->js . O_END; } });
<label class="grid-group"> <span class="grid span-1 form-label"><?php echo $speak->email; ?> </span> <span class="grid span-5"><?php echo Form::email('email', Guardian::wayback('email'), null, array('class' => 'input-block')); ?> </span> </label>
<?php return array('timezone' => 'Asia/Jakarta', 'charset' => 'utf-8', 'language' => 'en_US', 'language_direction' => 'ltr', 'shield' => 'normal', 'per_page' => 7, 'email_notification' => true, 'comments' => true, 'comment_moderation' => false, 'comment_notification_email' => true, 'resource_versioning' => true, 'excerpt_length' => 300, 'excerpt_tail' => '…', 'html_minifier' => true, 'html_parser' => HTML_PARSER, 'widget_year_first' => true, 'widget_include_css' => true, 'widget_include_js' => true, 'title' => 'My Awesome Site', 'title_separator' => ' – ', 'slogan' => 'Site slogan goes here.', 'description' => 'Site description goes here.', 'keywords' => 'blog, diary, notes, personal', 'spam_keywords' => "", 'author' => Guardian::get('author'), 'author_profile_url' => "", 'author_email' => Guardian::get('email'), 'index' => array('title' => 'Article', 'slug' => 'article', 'per_page' => 7), 'tag' => array('title' => 'Tagged in %s', 'slug' => 'tag', 'per_page' => 7), 'archive' => array('title' => 'Archive %s', 'slug' => 'archive', 'per_page' => 7), 'search' => array('title' => 'Search Results for “%s”', 'slug' => 'search', 'per_page' => 7), 'manager' => array('title' => 'Manager', 'slug' => 'manager', 'per_page' => 7), 'defaults' => array('article_title' => "", 'article_content' => "", 'article_custom_css' => "<style media=\"screen\">\n\n</style>", 'article_custom_js' => "<script>\n\n</script>", 'page_title' => "", 'page_content' => "", 'page_custom_css' => "<style media=\"screen\">\n\n</style>", 'page_custom_js' => "<script>\n\n</script>"));
<span class="grid span-2 form-label"><?php echo $speak->manager->title_custom_css; ?> </span> <span class="grid span-4"> <?php echo Form::textarea('defaults[' . $page . '_custom_css]', Guardian::wayback('defaults.' . $page . '_custom_css', Config::get('defaults.' . $page . '_custom_css')), null, array('class' => array('textarea-block', 'code'))); ?> </span> </label> <label class="grid-group"> <span class="grid span-2 form-label"><?php echo $speak->manager->title_custom_js; ?> </span> <span class="grid span-4"> <?php echo Form::textarea('defaults[' . $page . '_custom_js]', Guardian::wayback('defaults.' . $page . '_custom_js', Config::get('defaults.' . $page . '_custom_js')), null, array('class' => array('textarea-block', 'code'))); ?> </span> </label> </fieldset> <?php } ?> </fieldset> <p><?php echo Jot::button('action', $speak->update); ?> </p> </form>
/** * Shield Attacher * --------------- */ Route::accept($config->manager->slug . '/shield/(attach|eject)/id:(:any)', function ($path = "", $slug = "") use($config, $speak) { $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)); Weapon::fire('on_shield_update', array($G, $G)); Weapon::fire('on_shield_' . $mode, array($G, $G)); Weapon::fire('on_shield_' . md5($slug) . '_update', array($G, $G)); Weapon::fire('on_shield_' . md5($slug) . '_' . $mode, array($G, $G)); foreach (glob(SYSTEM . DS . 'log' . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) { File::open($asset_cache)->delete(); } Guardian::kick($config->manager->slug . '/shield/' . $slug); }); /** * Shield Backup * ------------- */ Route::accept($config->manager->slug . '/shield/backup/id:(:any)', function ($folder = "") use($config, $speak) { $name = $folder . '.zip'; Package::take(SHIELD . DS . $folder)->pack(ROOT . DS . $name, true); $G = array('data' => array('path' => ROOT . DS . $name, 'file' => ROOT . DS . $name)); Weapon::fire('on_backup_construct', array($G, $G)); Guardian::kick($config->manager->slug . '/backup/send:' . $name); });
/** * ========================================================== * RENDER A PAGE * ========================================================== * * -- CODE: ------------------------------------------------- * * Shield::attach('article'); * * ---------------------------------------------------------- * */ public static function attach($name, $fallback = false, $buffer = true) { $path__ = File::path($name); $s = explode('-', File::N($name), 2); $G = array('data' => array('name' => $name, 'name_base' => $s[0])); if (strpos($path__, ROOT) === 0 && file_exists($path__) && is_file($path__)) { // do nothing ... } else { if ($_path = File::exist(self::path($path__, $fallback))) { $path__ = $_path; } else { if ($_path = File::exist(self::path($s[0], $fallback))) { $path__ = $_path; } else { Guardian::abort(Config::speak('notify_file_not_exist', '<code>' . $path__ . '</code>')); } } } $lot__ = self::cargo(); $path__ = Filter::apply('shield:path', $path__); $G['data']['lot'] = $lot__; $G['data']['path'] = $path__; $G['data']['path_base'] = $s[0]; $out = ""; // Begin shield Weapon::fire('shield_lot_before', array($G, $G)); extract(Filter::apply('shield:lot', $lot__)); Weapon::fire('shield_lot_after', array($G, $G)); Weapon::fire('shield_before', array($G, $G)); if ($buffer) { ob_start(function ($content) use($path__, &$out) { $content = Filter::apply('shield:input', $content, $path__); $out = Filter::apply('shield:output', $content, $path__); return $out; }); require $path__; ob_end_flush(); } else { require $path__; } $G['data']['content'] = $out; // Reset shield lot self::$lot = array(); // End shield Weapon::fire('shield_after', array($G, $G)); exit; }
)</li> <?php } ?> </ul> <?php } ?> </div> <div class="grid span-2"> <h4><i class="fa fa-users"></i> <?php echo $speak->users; ?> </h4> <?php if ($users = Guardian::ally()) { ?> <ul> <?php foreach ($users as $user) { ?> <li><?php echo $user['name']; ?> <i class="fa fa-user<?php echo Mecha::alter($user['status_raw'], array(0 => '-times', 1 => '-md', 2 => "")); ?> "></i></li> <?php } ?>
// force single entityId into an array $array = array($entityId); // update pointer $entityId = $array; } try { $bp = BlueprintReader::read($entitySignature); $dao = new EntityDAO($bp); $failures = 0; foreach ($entityId as $id) { $xmlDelete = $xmlAttempts->addChild("delete"); $xmlDelete->addAttribute("signature", $entitySignature); $xmlDelete->addAttribute("id", $id); try { // Make sure the user has permission to perform this action if (BPConfig::$guardian_enable !== true || Guardian::authorize(Session::user(BPConfig::$guardian_identity_session_key), "DELETE", $bp->getKey(), $id)) { $dao->delete($id); $xmlDelete->addChild("status", "success"); $xmlDelete->addChild("message", "Entity was deleted successfully."); $xmlDelete->addChild("html", "Deleted " . $entitySignature . " with ID#" . $id); } else { Log::warning("* Guardian denied access to delete " . $bp->getKey() . " with ID {$id}"); $failures++; $xmlDelete->addChild("message", "Access denied."); $xmlDelete->addChild("html", "Access to delete " . $entitySignature . " with ID#" . $id . " was denied."); } } catch (Exception $e) { Log::error("* Caught Exception: " . $e->getMessage()); $failures++; $xmlDelete->addChild("status", "error"); $xmlDelete->addChild("message", "Caught Exception: " . htmlentities($e->getMessage()));
<div class="grid-group"> <?php $_ = 'unit:' . time(); ?> <label class="grid span-1 form-label" for="<?php echo $_; ?> "><?php echo $speak->message; ?> </label> <span class="grid span-5"><?php echo Form::textarea('message', Guardian::wayback('message'), null, array('class' => 'textarea-block', 'id' => $_)); ?> </span> </div>
public function postAdd() { $divisions = DBGNDDivisionController::getAllDivision(); $divisionIdA = array(); foreach ($divisions as $division) { $divisionIdA[] = $division->getGrama_niladari_div_no(); } $first_name = Input::get("firstNameText"); $last_name = Input::get("lastNameText"); $email = Input::get("emailText"); $permanent_address = Input::get("addressText"); $password = Input::get("password"); $conform_password = Input::get("confirm_password"); $nic = Input::get("nicText"); $telephone_number = Input::get("telephoneText"); $relation_to_child = Input::get("relationshiptochild"); $religion = Input::get("religionText"); $nationality = Input::get("nationalityText"); $div_val = Input::get("gramaNiladariDivisionNumberText"); $grama_niladry_division_number = $divisionIdA[$div_val]; /*$rules=array('$conform_password' => 'same:$password', ); $validator=Validator::make(Input::all(),$rules); if($validator->fails()) return Redirect::to('/');*/ if (strcmp($conform_password, $password) != 0) { return Redirect::to('guardian')->withInput()->with('error', "Passwords dont match"); } elseif (validationhandler::checkNIC($nic) == false) { return Redirect::to('guardian')->withInput()->with('error', "NIC is invalid"); } elseif (!preg_match("/^[a-zA-Z'-]+\$/", $first_name)) { return Redirect::to('guardian')->withInput()->with('error', "First Name is invalid"); } elseif (!preg_match("/^[a-zA-Z'-]+\$/", $last_name)) { return Redirect::to('guardian')->withInput()->with('error', "Last Name is invalid"); } elseif (!preg_match("/^[a-zA-Z'-]+\$/", $religion)) { return Redirect::to('guardian')->withInput()->with('error', "Religion is invalid"); } elseif (!preg_match("/^[a-zA-Z'-]+\$/", $nationality)) { return Redirect::to('guardian')->withInput()->with('error', "Nationality is invalid"); } elseif (!preg_match("/^[0]{1}[0-9]{9}\$/", $telephone_number)) { return Redirect::to('guardian')->withInput()->with('error', "Telephone Number is invalid"); } else { $guardian = new Guardian(); $guardian->setNic($nic); $guardian->setFirstName($first_name); $guardian->setLastName($last_name); $guardian->setEmail($email); $guardian->setPermanent_address($permanent_address); // $guardian->setPassword(Hash::make($password)); $guardian->setPassword($password); $guardian->setContact_number($telephone_number); $guardian->setRelationship($relation_to_child); $guardian->setReligion($religion); $guardian->setNationality($nationality); $guardian->setGrama_nil_div_no($grama_niladry_division_number); $result = DBGuardianController::addGuardian($guardian); if ($result) { return View::make('G1SAS/AddGuardianSuccessfull'); } else { return "not added successfully"; } } }