<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 } ?> </ul> <?php } ?> </div> </div> <div class="grid-group"> <div class="grid span-2"> <h4>Recently Updated</h4> <p>Nothing.</p>
?> </th> </tr> </thead> <tbody> <tr> <td><?php echo $file->title; ?> </td> <td><code><?php echo $id; ?> </code></td> <?php $s = Mecha::alter($file->type, array('text' => $speak->text, 'boolean' => $speak->boolean, 'option' => $speak->option, 'file' => $speak->file, 'composer' => $speak->composer, 'editor' => $speak->editor, 't' => $speak->text, 'b' => $speak->boolean, 'o' => $speak->option, 'f' => $speak->file, 'c' => $speak->composer, 'e' => $speak->editor), $speak->summary); ?> <td><?php echo Jot::em('info', $s); ?> </td> <td><?php echo isset($file->scope) ? str_replace(',', '/', $file->scope) : '<em>' . $speak->all . '</em>'; ?> </td> </tr> </tbody> </table> <form class="form-kill form-field" id="form-kill" action="<?php echo $config->url_current; ?>
public static function merge($path, $name = null, $addon = "", $call = null) { $path = is_string($path) && strpos($path, ';') !== false ? explode(';', $path) : (array) $path; $the_path = ASSET . DS . File::path($name); $the_path_log = SYSTEM . DS . 'log' . DS . 'asset.' . str_replace(array(ASSET . DS, DS), array("", '__'), $the_path) . '.log'; $is_valid = true; if (!file_exists($the_path_log)) { $is_valid = false; } else { $the_path_time = explode("\n", file_get_contents($the_path_log)); if (count($the_path_time) !== count($path)) { $is_valid = false; } else { foreach ($the_path_time as $i => $time) { $p = self::path($path[$i]); if (!file_exists($p) || (int) filemtime($p) !== (int) $time) { $is_valid = false; break; } } } } $time = ""; $content = ""; $e = File::E($name); if (!file_exists($the_path) || !$is_valid) { if (Text::check($e)->in(array('gif', 'jpeg', 'jpg', 'png'))) { foreach ($path as $p) { if (!self::ignored($p)) { $p = self::path($p); if (file_exists($p)) { $time .= filemtime($p) . "\n"; } } } File::write(trim($time))->saveTo($the_path_log); Image::take($path)->merge()->saveTo($the_path); } else { foreach ($path as $p) { if (!self::ignored($p)) { $p = self::path($p); if (file_exists($p)) { $time .= filemtime($p) . "\n"; $c = file_get_contents($p); if (strpos(File::B($p), '.min.') === false) { if (strpos(File::B($the_path), '.min.css') !== false) { $content .= Converter::detractShell($c) . "\n"; } else { if (strpos(File::B($the_path), '.min.js') !== false) { $content .= Converter::detractSword($c) . "\n"; } else { $content .= $c . "\n\n"; } } } else { $content .= $c . "\n\n"; } } } } File::write(trim($time))->saveTo($the_path_log); File::write(trim($content))->saveTo($the_path); } } if (is_null($call)) { $call = Mecha::alter($e, array('css' => 'stylesheet', 'js' => 'javascript', 'gif' => 'image', 'jpeg' => 'image', 'jpg' => 'image', 'png' => 'image')); } return call_user_func_array('self::' . $call, array($the_path, $addon)); }
// include once ... } }, 20); Weapon::add('SHIPMENT_REGION_BOTTOM', function () use($config) { Session::kill('recent_item_update'); $path = __DIR__ . DS . 'assets' . DS . 'sword' . DS; echo Asset::javascript(array($path . 'ajax.js', $path . 'row.js', $path . 'slug.js', $path . 'upload.js', $path . 'tab.js', $path . 'toggle.js', $path . 'modal.js', $path . 'tooltip.js', $path . 'sortable.js', $path . 'accordion.js', SHIELD . DS . $config->shield . DS . 'assets' . DS . 'sword' . DS . 'manager.js'), "", 'sword/manager.min.js'); }, 1); /** * Footer Link(s) * -------------- */ if ($config->page_type === 'manager' || $config->is->post) { // Add default comment footer link(s) Weapon::add('comment_footer', function ($comment, $article) use($config, $speak) { $status = Mecha::alter(File::E($comment->path), array('hold' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->pending) . ' · '), ""); echo $status . Cell::a($config->manager->slug . '/comment/repair/id:' . $comment->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/comment/kill/id:' . $comment->id, $speak->delete); }, 20); } /** * Widget Manager Menu(s) and Bar(s) * --------------------------------- * * [1]. Config::merge('manager_menu', array()); * [2]. Config::merge('manager_bar', array()); * */ Weapon::add('shield_before', function () { $config = Config::get(); $speak = Config::speak(); $total = $config->__total_comments;
* =================================================================== * APPLY FILTER WITH PREFIX * =================================================================== * * -- CODE: ---------------------------------------------------------- * * Filter::colon('page:title', $content); * * // is equal to ... * * Filter::apply(array('page:title', 'title'), $content); * * ------------------------------------------------------------------- * */ Filter::plug('colon', function ($name, $value) { $arguments = func_get_args(); if (strpos($name, ':') !== false) { $s = explode(':', $name, 2); $arguments[0] = array($name, $s[1]); } return call_user_func_array('Filter::apply', $arguments); }); // Set response, comment and user `status` as `pilot`, `passenger` and `intruder` Filter::add(array('response:status', 'comment:status', 'user:status'), function ($status) { return Mecha::alter($status, array(0 => 'intruder', 1 => 'pilot', 2 => 'passenger')); }, 1); // Decode the obfuscated `email` value Filter::add(array('response:email', 'comment:email', 'user:email'), function ($data) { return Text::parse($data, '->decoded_html'); }, 1);
/** * ==================================================================== * CONVERT STRING OF VALUE INTO THEIR APPROPRIATE TYPE/FORMAT * ==================================================================== * * -- CODE: ----------------------------------------------------------- * * var_dump(Converter::strEval('1234')); * * -------------------------------------------------------------------- * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Parameter | Type | Description * --------- | ------- | --------------------------------------------- * $input | mixed | String or array of string to be converted * $NRT | boolean | Translate `\n`, `\r` and `\t` ? * --------- | ------- | --------------------------------------------- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * */ public static function strEval($input, $NRT = true) { $results = $input; if (is_string($input) && preg_match('#^(TRUE|FALSE|NULL|true|false|null|yes|no|on|off|ok|okay)$#', $input, $matches)) { $results = Mecha::alter($matches[1], array('TRUE' => TRUE, 'FALSE' => FALSE, 'NULL' => NULL, 'true' => true, 'false' => false, 'null' => null, 'yes' => true, 'no' => false, 'on' => true, 'off' => false, 'ok' => true, 'okay' => true)); } else { if (is_string($input)) { if (!is_null(json_decode($input, true))) { $results = self::strEval(json_decode($input, true), $NRT); } else { $results = $NRT ? self::NRT_decode($input) : $input; } } else { if (is_numeric($input)) { $results = strpos($input, '.') !== false ? (double) $input : (int) $input; } else { if (is_array($input) || is_object($input)) { $results = array(); foreach ($input as $key => $value) { $results[$key] = self::strEval($value, $NRT); } } } } } return $results; }
/** * ========================================================================== * GET LIST OF RESPONSE DETAIL(S) * ========================================================================== * * -- CODE: ----------------------------------------------------------------- * * var_dump(Get::responseExtract($input)); * * -------------------------------------------------------------------------- * */ public static function responseExtract($input, $FP = 'response:') { if (!$input) { return false; } $e = File::E($input); $update = File::T($input); $update_date = !is_null($update) ? date('Y-m-d H:i:s', $update) : null; list($post, $id, $parent) = explode('_', File::N($input), 3); return array('path' => Filter::colon($FP . 'path', $input, $input), 'time' => Filter::colon($FP . 'time', Date::format($id), $input), 'update_raw' => Filter::colon($FP . 'update_raw', $update, $input), 'update' => Filter::colon($FP . 'update', $update_date, $input), 'post' => Filter::colon($FP . 'post', (int) Date::format($post, 'U'), $input), 'id' => Filter::colon($FP . 'id', (int) Date::format($id, 'U'), $input), 'parent' => Filter::colon($FP . 'parent', $parent === '0000-00-00-00-00-00' ? null : (int) Date::format($parent, 'U'), $input), 'state' => Filter::colon($FP . 'state', Mecha::alter($e, array('txt' => 'approved', 'hold' => 'pending')), $input)); }
/** * ==================================================================== * CONVERT STRING OF VALUE INTO THEIR APPROPRIATE TYPE/FORMAT * ==================================================================== * * -- CODE: ----------------------------------------------------------- * * var_dump(Converter::strEval('1234')); * * -------------------------------------------------------------------- * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Parameter | Type | Description * --------- | ------- | --------------------------------------------- * $input | mixed | String or array of string to be converted * $NRT | boolean | Translate `\n`, `\r` and `\t` ? * --------- | ------- | --------------------------------------------- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * */ public static function strEval($input, $NRT = true) { if (is_numeric($input)) { $input = strpos($input, '.') !== false ? (double) $input : (int) $input; } else { if (is_string($input)) { if ((strpos($input, '[') === 0 || strpos($input, '{"') === 0 || strpos($input, '"') === 0) && !is_null(json_decode($input, true))) { $input = json_decode($input, true); if (is_array($input)) { $input = self::strEval($input, $NRT); } } else { $input = Mecha::alter($input, array('TRUE' => true, 'FALSE' => false, 'NULL' => null, 'true' => true, 'false' => false, 'null' => null, 'yes' => true, 'no' => false, 'on' => true, 'off' => false), $NRT ? self::DW($input) : $input); } } else { if (is_array($input) || is_object($input)) { foreach ($input as &$v) { $v = self::strEval($v, $NRT); } unset($v); } } } return $input; }
* -------------- */ if ($config->page_type === 'manager') { // Add default article footer link(s) Weapon::add('article_footer', function ($article) use($config, $speak) { $status = Mecha::alter(File::E($article->path), array('draft' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->draft) . ' · ', 'archive' => Jot::span('info', Jot::icon('history') . ' ' . $speak->archive) . ' · '), ""); echo $status . Cell::a($config->manager->slug . '/article/repair/id:' . $article->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/article/kill/id:' . $article->id, $speak->delete); }, 20); // Add default page footer link(s) Weapon::add('page_footer', function ($page) use($config, $speak) { $status = Mecha::alter(File::E($page->path), array('draft' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->draft) . ' · ', 'archive' => Jot::span('info', Jot::icon('history') . ' ' . $speak->archive) . ' · '), ""); echo $status . Cell::a($config->manager->slug . '/page/repair/id:' . $page->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/page/kill/id:' . $page->id, $speak->delete); }, 20); // Add default comment footer link(s) Weapon::add('comment_footer', function ($comment, $article) use($config, $speak) { $status = Mecha::alter($comment->state, array('pending' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->pending) . ' · '), ""); echo $status . Cell::a($config->manager->slug . '/comment/repair/id:' . $comment->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/comment/kill/id:' . $comment->id, $speak->delete); }, 20); } /** * Widget Manager Menu(s) * ---------------------- */ Weapon::add('shield_before', function () { $config = Config::get(); $speak = Config::speak(); $total = $config->total_comments_backend; $destination = SYSTEM . DS . 'log' . DS . 'comments.total.log'; if ($file = File::exist($destination)) { $old = (int) File::open($file)->read(); $total = $total > $old ? $total - $old : 0;
* Footer Link(s) * -------------- */ // Add default article footer link(s) Weapon::add('article_footer', function ($article) use($config, $speak) { $e = File::E($article->path); $comments = count(glob(COMMENT . DS . Date::slug($article->id) . '_*_*.{txt,hold}', GLOB_NOSORT | GLOB_BRACE)); $t = Jot::icon('comments') . ' ' . $comments; $tt = array('title' => $comments . ' ' . ($comments === 1 ? $speak->comment : $speak->comments)); $comments = ($e === 'draft' || $comments === 0 ? Cell::span($t, $tt) : Cell::a($config->manager->slug . '/comment?filter=post%3A' . $article->id, $t, null, $tt)) . ' · '; $status = Mecha::alter($e, array('draft' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->draft) . ' · ', 'archive' => Jot::span('info', Jot::icon('history') . ' ' . $speak->archive) . ' · '), ""); echo $comments . $status . Cell::a($config->manager->slug . '/article/repair/id:' . $article->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/article/kill/id:' . $article->id, $speak->delete); }, 20); // Add default page footer link(s) Weapon::add('page_footer', function ($page) use($config, $speak) { $status = Mecha::alter(File::E($page->path), array('draft' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->draft) . ' · ', 'archive' => Jot::span('info', Jot::icon('history') . ' ' . $speak->archive) . ' · '), ""); echo $status . Cell::a($config->manager->slug . '/page/repair/id:' . $page->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/page/kill/id:' . $page->id, $speak->delete); }, 20); /** * Backend Route(s) * ---------------- * * Load the routes. * */ Weapon::add('plugins_after', function () use($config, $speak, $segment) { // loading cargo ... require __DIR__ . DS . 'workers' . DS . 'cargo.php'; if ($detour = File::exist(__DIR__ . DS . 'workers' . DS . 'route.' . $segment . '.php')) { require $detour; }
if ($icon !== "") { $text = Jot::icon($icon) . ' ' . $text; } if (!isset($attr['class'])) { $attr['class'] = array(); } $s = is_string($name) ? explode(':', $name, 2) : array(null, null); $attr['class'] = array_merge(array('btn btn-' . str_replace('.', ' btn-', $kind[0])), (array) $attr['class']); $attr['disabled'] = strpos($kind[0], '.disabled') !== false ? true : null; return Form::button($text, $s[0], isset($s[1]) ? $s[1] : null, $type, $attr, $indent); }); // `<a class="btn">` Jot::add('btn', function ($kind = 'default', $text = "", $href = null, $attr = array(), $indent = 0) { $kind = explode(':', $kind); $k = explode('.', trim($kind[0], '.')); $icon = count($kind) === 1 ? Mecha::alter($k[0], array('action' => 'check-circle', 'accept' => 'check-circle', 'begin' => 'plus-circle', 'construct' => 'check-circle', 'danger' => 'times-circle', 'destruct' => 'times-circle', 'error' => 'exclamation-circle', 'reject' => 'times-circle'), "") : $kind[1]; if ($icon !== "") { $text = Jot::icon($icon) . ' ' . $text; } if (!isset($attr['class'])) { $attr['class'] = array(); } $active = strpos($kind[0], '.disabled') === false; $attr['href'] = $active ? Converter::url($href) : null; $attr['class'] = array_merge(array('btn btn-' . str_replace('.', ' btn-', $kind[0])), (array) $attr['class']); return Cell::unit($active ? 'a' : 'span', $text, $attr, $indent); }); // `<b|em|i|span|strong class="text-error">` foreach (array('b', 'em', 'i', 'span', 'strong') as $tag) { Jot::add($tag, function ($kind = 'default', $text = "", $attr = array(), $indent = 0) use($tag) { if (!isset($attr['class'])) {
foreach ($files as $key => $value) { ?> <?php if (isset($fields_o[$key])) { ?> <tr> <td><?php echo $value->title; ?> </td> <td><?php echo $key; ?> </td> <?php $s = Mecha::alter($value->type[0], array('t' => 'Text', 'b' => 'Boolean', 'o' => 'Option', 'f' => 'File', 'c' => 'Composer', 'e' => 'Editor'), 'Summary'); ?> <td><?php echo Jot::em('info', $s); ?> </td> <td class="td-icon"> <?php echo Jot::a('construct', $config->manager->slug . '/field/repair/key:' . $key, Jot::icon('pencil'), array('title' => $speak->edit)); ?> </td> <td class="td-icon"> <?php echo Jot::a('destruct', $config->manager->slug . '/field/kill/key:' . $key, Jot::icon('times'), array('title' => $speak->delete)); ?> </td>
echo Session::get('recent_file_update') === File::B($file->path) ? ' class="active"' : ""; ?> > <td class="td-icon"><?php echo Form::checkbox('selected[]', $url); ?> </td> <td class="td-collapse"><time datetime="<?php echo Date::format($file->update_raw, 'c'); ?> "><?php echo str_replace('-', '/', $file->update); ?> </time></td> <?php $n = Jot::icon(is_file($file->path) ? 'file-' . Mecha::alter(File::E($file->path), array('xls' => 'excel-o', 'xlsx' => 'excel-o', 'doc' => 'word-o', 'docx' => 'word-o', 'ppt' => 'powerpoint-o', 'pptx' => 'powerpoint-o', 'pdf' => 'pdf-o', 'gz' => 'archive-o', 'iso' => 'archive-o', 'rar' => 'archive-o', 'tar' => 'archive-o', 'zip' => 'archive-o', 'zipx' => 'archive-o', 'bmp' => 'image-o', 'gif' => 'image-o', 'ico' => 'image-o', 'jpeg' => 'image-o', 'jpg' => 'image-o', 'png' => 'image-o', 'txt' => 'text-o', 'log' => 'text-o', 'mp3' => 'audio-o', 'ogg' => 'audio-o', 'wav' => 'audio-o', 'mkv' => 'video-o', 'flv' => 'video-o', 'avi' => 'video-o', 'mov' => 'video-o', 'mp4' => 'video-o', '3gp' => 'video-o', 'css' => 'code-o', 'js' => 'code-o', 'json' => 'code-o', 'jsonp' => 'code-o', 'htm' => 'code-o', 'html' => 'code-o', 'php' => 'code-o', 'xml' => 'code-o'), 'o') : 'folder') . ' ' . File::B($url); ?> <td> <?php if (is_dir($file->path)) { ?> <a href="<?php echo $config->url . '/' . $c_url . '/1?path=' . Text::parse(ltrim($q_path . '/' . File::B($url), '/'), '->encoded_url'); ?> " title="<?php echo $speak->enter; ?> …"><?php echo $n; ?> </a>
public static function merge($path, $name = null, $addon = "", $call = null) { $the_path = strpos($name, ROOT) === 0 ? File::path($name) : ASSET . DS . File::path($name); $the_log = LOG . DS . 'asset.' . str_replace(array(ASSET . DS, DS), array("", '__'), $the_path) . '.log'; $is_valid = true; if (!file_exists($the_log)) { $is_valid = false; } else { $the_time = explode("\n", file_get_contents($the_log)); if (count($the_time) !== count($path)) { $is_valid = false; } else { foreach ($the_time as $i => $unix) { $p = self::path($path[$i]); if (!file_exists($p) || (int) filemtime($p) !== (int) $unix) { $is_valid = false; break; } } } } $unix = ""; $content = ""; $e = File::E($name); if (!file_exists($the_path) || !$is_valid) { if (Text::check($e)->in(array('gif', 'jpeg', 'jpg', 'png'))) { foreach ($path as &$p) { $p = Filter::colon('asset:source', $p); if (!self::ignored($p) && ($p = Filter::colon('asset:path', self::path($p, false)))) { $unix .= filemtime($p) . "\n"; } } File::write(trim($unix))->saveTo($the_log); Image::take($path)->merge()->saveTo($the_path); } else { foreach ($path as $p) { $p = Filter::colon('asset:source', $p); if (!self::ignored($p) && ($p = Filter::colon('asset:path', self::path($p, false)))) { $unix .= filemtime($p) . "\n"; $c = Filter::apply('asset:input', file_get_contents($p) . "\n", $p); if (strpos(File::B($p), '.min.') === false) { if (strpos(File::B($the_path), '.min.css') !== false) { $c = Converter::detractShell($c); } else { if (strpos(File::B($the_path), '.min.js') !== false) { $c = Converter::detractSword($c); } else { $c = $c . "\n"; } } $content .= Filter::apply('asset:output', $c, $p); } else { $content .= Filter::apply('asset:output', $c . "\n", $p); } } } File::write(trim($unix))->saveTo($the_log); File::write(trim($content))->saveTo($the_path); } } if (is_null($call)) { $call = Mecha::alter($e, array('css' => 'stylesheet', 'js' => 'javascript', 'gif' => 'image', 'jpeg' => 'image', 'jpg' => 'image', 'png' => 'image')); } return call_user_func('self::' . $call, $the_path, $addon); }
<?php Route::accept('s/(print|include)(:|/)(:all)', function ($x = "", $o = ':', $path = "") use($config, $speak) { $path = ltrim(File::path($path), DS); $get = Request::get(); $x = Mecha::alter($x, array('print' => 'txt', 'include' => 'php')); // Disallow path traversal if (strpos(DS . $path . DS, DS . '..' . DS) !== false) { Shield::abort(); } // File not found if (!($snippet = File::exist(ASSET . DS . '__snippet' . DS . $x . DS . $path . '.' . $x))) { Shield::abort(); } $content = File::open($snippet)->read(); // Allow to run `printf` in snippet content for `txt` file if ($x === 'txt') { $lot = isset($get['lot']) ? explode(',', $get['lot']) : false; if ($lot !== false && strpos($content, '%') !== false) { // `http://stackoverflow.com/a/2053931` if (preg_match_all('#%(?:(\\d+)[$])?[-+]?(?:[ 0]|[\'].)?(?:[-]?\\d+)?(?:[.]\\d+)?[%bcdeEfFgGosuxX]#', $content, $matches)) { $lot = Mecha::walk($lot, function ($v) { return str_replace(',', ',', $v); }); if (count($lot) >= count(array_unique($matches[1]))) { $content = vsprintf($content, $lot); } } } } // Apply `do_snippet` filter if available