Example #1
0
 public function createFromFile($file)
 {
     if (File::exist($file)) {
         $this->file = $file;
         list($width, $height, $type) = getimagesize($file);
         $this->type = $type;
         $this->name = mb_substr($file, strrpos($file, '/') + 1, mb_strlen($file, CHARSET), CHARSET);
         $this->dir = mb_substr($file, 0, strrpos($file, '/') + 1, CHARSET);
         switch ($type) {
             case IMAGETYPE_GIF:
                 $image = imagecreatefromgif($file);
                 break;
             case IMAGETYPE_JPEG:
                 $image = imagecreatefromjpeg($file);
                 break;
             case IMAGETYPE_PNG:
                 $image = imagecreatefrompng($file);
                 break;
             case IMAGETYPE_BMP:
                 $image = self::imageCreateFromBMP($file);
                 $this->type = IMAGETYPE_JPEG;
                 break;
         }
         $this->image = $image;
     }
 }
Example #2
0
 public static function path($path, $fallback = false)
 {
     $config = Config::get();
     // External URL, nothing to check!
     if (strpos($path, '://') !== false || strpos($path, '//') === 0) {
         if (strpos($path, $config->url) !== 0) {
             return $path;
         }
     }
     $path = File::path($path);
     // Full path, be quick!
     if (strpos($path, ROOT) === 0) {
         return File::exist($path, $fallback);
     }
     if ($_path = File::exist(SHIELD . DS . $config->shield . DS . ltrim($path, DS))) {
         return $_path;
     } else {
         if ($_path = File::exist(ASSET . DS . ltrim($path, DS))) {
             return $_path;
         } else {
             if ($_path = File::exist(ROOT . DS . ltrim($path, DS))) {
                 return $_path;
             }
         }
     }
     return $fallback;
 }
Example #3
0
 public static function path($path)
 {
     $path = File::path($path);
     if ($_path = File::exist(SHIELD . DS . Config::get('shield') . DS . ltrim($path, DS))) {
         return $_path;
     } else {
         if ($_path = File::exist(ROOT . DS . ltrim($path, DS))) {
             return $_path;
         }
     }
     return $path;
 }
Example #4
0
 public static function info($folder = null, $array = false)
 {
     $config = Config::get();
     $speak = Config::speak();
     // Check whether the localized "about" file is available
     if (!($info = File::exist(PLUGIN . DS . $folder . DS . 'about.' . $config->language . '.txt'))) {
         $info = PLUGIN . DS . $folder . DS . 'about.txt';
     }
     $default = 'Title' . S . ' ' . ucwords(Text::parse($folder, '->text')) . "\n" . 'Author' . S . ' ' . $speak->anon . "\n" . 'URL' . S . ' #' . "\n" . 'Version' . S . ' 0.0.0' . "\n" . "\n" . SEPARATOR . "\n" . "\n" . Config::speak('notify_not_available', $speak->description);
     $info = Text::toPage(File::open($info)->read($default), 'content', 'plugin:');
     return $array ? $info : Mecha::O($info);
 }
Example #5
0
/**
 * Cache Killer
 * ------------
 */
function do_remove_cache()
{
    global $config, $c_cache;
    foreach ($c_cache->path as $path => $expire) {
        $path = str_replace(array('(:any)', '(:num)', '(:all)', '(', ')', '|', '/', ':'), array('*', '[0-9]*', '*', '{', '}', ',', '.', '.'), $path) . '.cache';
        if ($cache = File::exist(CACHE . DS . $path)) {
            File::open($cache)->delete();
        } else {
            foreach (glob(CACHE . DS . $path, GLOB_NOSORT | GLOB_BRACE) as $cache) {
                File::open($cache)->delete();
            }
        }
    }
}
Example #6
0
 /**
  * ============================================================
  *  GET ACCEPTED USER(S) DATA
  * ============================================================
  *
  * -- CODE: ---------------------------------------------------
  *
  *    echo Guardian::ally('mecha');
  *
  * ------------------------------------------------------------
  *
  *    var_dump(Guardian::ally());
  *
  * ------------------------------------------------------------
  *
  */
 public static function ally($user = null, $fallback = false)
 {
     if ($file = File::exist(SYSTEM . DS . 'log' . DS . 'users.txt')) {
         $ally = array();
         foreach (explode("\n", file_get_contents($file)) as $a) {
             // Pattern 1: `username: password (Author Name: status) email@domain.com`
             // Pattern 2: `username: password (Author Name @status) email@domain.com`
             preg_match('#^(.*?)\\:\\s*(.*?)\\s+\\((.*?)(?:\\s*@|\\:\\s*)(pilot|[a-z0-9_.]+)\\)(?:\\s+(.*?))?$#', trim($a), $matches);
             $ally[$matches[1]] = array('password' => $matches[2], 'author' => $matches[3], 'status' => $matches[4], 'email' => isset($matches[5]) && !empty($matches[5]) ? $matches[5] : false);
         }
         if (is_null($user)) {
             return $ally;
         }
         return isset($ally[$user]) ? $ally[$user] : $fallback;
     } else {
         self::abort('Missing <code>users.txt</code> file.');
     }
 }
Example #7
0
 /**
  * ============================================================
  *  GET ACCEPTED USER(S) DATA
  * ============================================================
  *
  * -- CODE: ---------------------------------------------------
  *
  *    echo Guardian::ally('mecha');
  *
  * ------------------------------------------------------------
  *
  *    var_dump(Guardian::ally());
  *
  * ------------------------------------------------------------
  *
  */
 public static function ally($user = null, $fallback = false)
 {
     if ($file = File::exist(LOG . DS . 'users.txt')) {
         $ally = array();
         foreach (explode("\n", file_get_contents($file)) as $str) {
             $s = trim($str);
             // serialized array
             if (strpos($s, 'a:') === 0) {
                 $s = unserialize($s);
                 // encoded JSON array
             } else {
                 if (strpos($s, '{"') === 0) {
                     $s = json_decode($s, true);
                     // Pattern 1: `user: pass (Author Name: status) email@domain.com`
                     // Pattern 2: `user: pass (Author Name $status) email@domain.com`
                 } else {
                     if (preg_match('#^(.*?)\\:\\s*(.*?)\\s+\\((.*?)(?:\\s*\\$|\\:\\s*)(pilot|[a-z0-9_.]+)\\)(?:\\s+(.*?))?$#', $s, $matches)) {
                         $s = array();
                         $s['user'] = $matches[1];
                         $s['pass'] = $matches[2];
                         $s['name'] = $matches[3];
                         $s['status'] = $matches[4];
                         $s['email'] = isset($matches[5]) && !empty($matches[5]) ? $matches[5] : false;
                     } else {
                         self::abort('Broken <code>' . LOG . DS . 'users.txt</code> format.');
                     }
                 }
             }
             foreach ($s as $k => $v) {
                 $v = Converter::strEval($v);
                 $s[$k . '_raw'] = Filter::colon('user:'******'_raw', $v, $s);
                 $s[$k] = Filter::colon('user:'******'user']] = Filter::apply('user', $s, $s['user']);
         }
         $ally = Filter::apply('users', $ally);
         if (is_null($user)) {
             return $ally;
         }
         return isset($ally[$user]) ? $ally[$user] : $fallback;
     } else {
         self::abort('Missing <code>' . LOG . DS . 'users.txt</code> file.');
     }
 }
Example #8
0
        $speak = Config::speak();
        // refresh ...
    }
    Weapon::fire(array('plugin_before', 'plugin_' . md5($k) . '_before'));
    if ($launch = File::exist($__ . 'launch.php')) {
        if (strpos(File::B($__), '__') === 0) {
            if (Guardian::happy() && $config->page_type === 'manager') {
                include $launch;
                // backend
            }
        } else {
            include $launch;
            // frontend
        }
    }
    if ($launch = File::exist($__ . '__launch.php')) {
        if (Guardian::happy() && $config->page_type === 'manager') {
            include $launch;
            // backend
        }
    }
    Weapon::fire(array('plugin_after', 'plugin_' . md5($k) . '_after'));
}
Weapon::fire('plugins_after');
/**
 * Check the Plugin(s) Order
 * -------------------------
 */
// var_dump($plugins); exit;
/**
 * Loading Menu(s)
Example #9
0
 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', '&lt;img$1&gt;', $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);
                 }
             }
         }
     }
 }
Example #10
0
<?php

/**
 * Login Page
 * ----------
 *
 * [1]. manager/login
 *
 */
Route::accept($config->manager->slug . '/login', function () use($config, $speak) {
    if (!File::exist(File::D(__DIR__) . DS . 'launch.php')) {
        Shield::abort('404-manager');
    }
    if (Guardian::happy()) {
        Guardian::kick($config->manager->slug . '/article');
    }
    Config::set(array('page_title' => $speak->log_in . $config->title_separator . $config->title, 'cargo' => 'cargo.login.php'));
    include __DIR__ . DS . 'cargo.php';
    if ($request = Request::post()) {
        Guardian::authorize()->kick(isset($request['kick']) ? $request['kick'] : $config->manager->slug . '/article');
    }
    Shield::attach('manager-login');
}, 20);
/**
 * Logout Page
 * -----------
 *
 * [1]. manager/logout
 *
 */
Route::accept($config->manager->slug . '/logout', function () use($config, $speak) {
<?php

Weapon::add('shield_before', function () {
    $config = Config::get();
    if ($config->comments->allow) {
        $comment_service_config = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize();
        Config::set('plugins.comment_service_config', $comment_service_config);
        $active = $comment_service_config['service'];
        if ($s = Config::get($config->page_type)) {
            $active = isset($s->fields->comment_service) && trim($s->fields->comment_service) !== "" ? $s->fields->comment_service : $active;
        }
        if ($launch = File::exist(__DIR__ . DS . 'workers' . DS . $active . DS . 'launch.php')) {
            require $launch;
        }
        Filter::add('chunk:path', function ($path) use($active) {
            if ($active !== 0 && File::N($path) === 'comments') {
                return __DIR__ . DS . 'workers' . DS . $active . DS . 'comments.php';
            }
            return $path;
        });
    }
});
Example #12
0
 /**
  * ==========================================================================
  *  EXTRACT PAGE FILE INTO LIST OF PAGE DATA FROM ITS PATH/SLUG/ID
  * ==========================================================================
  *
  * -- CODE: -----------------------------------------------------------------
  *
  *    var_dump(Get::page('about'));
  *
  * --------------------------------------------------------------------------
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter  | Type   | Description
  *  ---------- | ------ | ---------------------------------------------------
  *  $reference | mixed  | Slug, ID, path or array of `Get::pageExtract()`
  *  $excludes  | array  | Exclude some field(s) from result(s)
  *  $folder    | string | Folder of the page(s)
  *  $connector | string | Path connector for page URL
  *  $FP        | string | Filter prefix for `Text::toPage()`
  *  ---------- | ------ | ---------------------------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function page($reference, $excludes = array(), $folder = PAGE, $connector = '/', $FP = 'page:')
 {
     $config = Config::get();
     $speak = Config::speak();
     $excludes = array_flip($excludes);
     $results = false;
     // From `Get::pageExtract()`
     if (is_array($reference)) {
         $results = $reference;
     } else {
         // By path => `cabinet\pages\0000-00-00-00-00-00_1,2,3_page-slug.txt`
         if (strpos($reference, $folder) === 0) {
             $results = self::pageExtract($reference, $FP);
         } else {
             // By slug => `page-slug` or by ID => 12345
             $results = self::pageExtract(self::pagePath($reference, $folder), $FP);
         }
     }
     if (!$results || !file_exists($results['path'])) {
         return false;
     }
     /**
      * RULES: Do not do any tags looping, content Markdown-ing
      * and external file requesting if it has been marked as
      * the excluded field(s). For better performance.
      */
     $results = $results + Text::toPage(File::open($results['path'])->read(), isset($excludes['content']) ? false : 'content', $FP);
     $content = isset($results['content_raw']) ? $results['content_raw'] : "";
     $time = str_replace(array(' ', ':'), '-', $results['time']);
     $extension = File::E($results['path']);
     if ($php_file = File::exist(File::D($results['path']) . DS . $results['slug'] . '.php')) {
         ob_start();
         include $php_file;
         $results['content'] = ob_get_clean();
     }
     $results['date'] = self::AMF(Date::extract($results['time']), $FP, 'date');
     $results['url'] = self::AMF($config->url . $connector . $results['slug'], $FP, 'url');
     $results['link'] = "";
     $results['excerpt'] = "";
     if (!isset($results['author'])) {
         $results['author'] = self::AMF($config->author, $FP, 'author');
     }
     if (!isset($results['description'])) {
         $summary = Converter::curt($content, $config->excerpt_length, $config->excerpt_tail);
         $results['description'] = self::AMF($summary, $FP, 'description');
     }
     $content_test = isset($excludes['content']) && strpos($content, '<!--') !== false ? Text::toPage(Text::ES($content), 'content', $FP) : $results;
     $content_test = $content_test['content'];
     $content_test = is_array($content_test) ? implode("", $content_test) : $content_test;
     // Redirect 301 with `<!-- kick: "http://example.com" -->`
     if (strpos($content_test, '<!-- kick:') !== false && $config->page_type === rtrim($FP, ':')) {
         preg_match('#<!-- kick\\: *([\'"]?)(.*?)\\1 -->#', $content_test, $matches);
         Guardian::kick($matches[2]);
     }
     // External link with `<!-- link: "http://example.com" -->`
     if (strpos($content_test, '<!-- link:') !== false) {
         preg_match('#<!-- link\\: *([\'"]?)(.*?)\\1 -->#', $content_test, $matches);
         $results['link'] = $matches[2];
         $results['content'] = preg_replace('#<!-- link\\:.*? -->#', "", $results['content']);
     }
     // Manual post excerpt with `<!-- cut+ "Read More" -->`
     if (strpos($content_test, '<!-- cut+ ') !== false) {
         preg_match('#<!-- cut\\+( +([\'"]?)(.*?)\\2)? -->#', $content_test, $matches);
         $more = !empty($matches[3]) ? $matches[3] : $speak->read_more;
         $content_test = preg_replace('#<!-- cut\\+( +(.*?))? -->#', '<p><a class="fi-link" href="' . $results['url'] . '#read-more:' . $results['id'] . '">' . $more . '</a></p><!-- cut -->', $content_test);
     }
     // ... or `<!-- cut -->`
     if (strpos($content_test, '<!-- cut -->') !== false) {
         $parts = explode('<!-- cut -->', $content_test, 2);
         $results['excerpt'] = self::AMF(trim($parts[0]), $FP, 'excerpt');
         $results['content'] = preg_replace('#<p><a class="fi-link" href=".*?">.*?<\\/a><\\/p>#', "", trim($parts[0])) . NL . NL . '<span class="fi" id="read-more:' . $results['id'] . '" aria-hidden="true"></span>' . NL . NL . trim($parts[1]);
     }
     if (!isset($excludes['tags'])) {
         $tags = array();
         foreach ($results['kind'] as $id) {
             $tags[] = self::rawTag($id);
         }
         $results['tags'] = self::AMF(Mecha::eat($tags)->order('ASC', 'name')->vomit(), $FP, 'tags');
     }
     if (!isset($excludes['css']) || !isset($excludes['js'])) {
         if ($file = File::exist(CUSTOM . DS . $time . '.' . $extension)) {
             $custom = explode(SEPARATOR, File::open($file)->read());
             $css = isset($custom[0]) ? Text::DS(trim($custom[0])) : "";
             $js = isset($custom[1]) ? Text::DS(trim($custom[1])) : "";
             /**
              * CSS
              * ---
              *
              * css_raw
              * page:css_raw
              * custom:css_raw
              *
              * shortcode
              * page:shortcode
              * custom:shortcode
              *
              * css
              * page:css
              * custom:css
              *
              */
             $css = self::AMF($css, $FP, 'css_raw');
             $results['css_raw'] = Filter::apply('custom:css_raw', $css);
             $css = self::AMF($css, $FP, 'shortcode');
             $css = Filter::apply('custom:shortcode', $css);
             $css = self::AMF($css, $FP, 'css');
             $results['css'] = Filter::apply('custom:css', $css);
             /**
              * JS
              * --
              *
              * js_raw
              * page:js_raw
              * custom:js_raw
              *
              * shortcode
              * page:shortcode
              * custom:shortcode
              *
              * js
              * page:js
              * custom:js
              *
              */
             $js = self::AMF($js, $FP, 'js_raw');
             $results['js_raw'] = Filter::apply('custom:js_raw', $js);
             $js = self::AMF($js, $FP, 'shortcode');
             $js = Filter::apply('custom:shortcode', $js);
             $js = self::AMF($js, $FP, 'js');
             $results['js'] = Filter::apply('custom:js', $js);
         } else {
             $results['css'] = $results['js'] = $results['css_raw'] = $results['js_raw'] = "";
         }
         $custom = $results['css'] . $results['js'];
     } else {
         $custom = "";
     }
     $results['images'] = self::AMF(self::imagesURL($results['content'] . $custom), $FP, 'images');
     $results['image'] = self::AMF(isset($results['images'][0]) ? $results['images'][0] : Image::placeholder(), $FP, 'image');
     $comments = self::comments($results['id'], 'ASC', Guardian::happy() ? 'txt,hold' : 'txt');
     $results['total_comments'] = self::AMF($comments !== false ? count($comments) : 0, $FP, 'total_comments');
     $results['total_comments_text'] = self::AMF($results['total_comments'] . ' ' . ($results['total_comments'] === 1 ? $speak->comment : $speak->comments), $FP, 'total_comments_text');
     if (!isset($excludes['comments'])) {
         if ($comments) {
             $results['comments'] = array();
             foreach ($comments as $comment) {
                 $results['comments'][] = self::comment($comment);
             }
             $results['comments'] = self::AMF($results['comments'], $FP, 'comments');
         }
     }
     unset($comments);
     /**
      * Custom Field(s)
      * ---------------
      */
     if (!isset($excludes['fields'])) {
         /**
          * Initialize custom field(s) with the default value(s) so that
          * user(s) don't have to write `isset()` function multiple time(s)
          * just to prevent error message(s) because of the object key(s)
          * that is not available in the old post(s).
          */
         $fields = self::state_field(rtrim($FP, ':'), null, array(), false);
         $init = array();
         foreach ($fields as $key => $value) {
             $init[$key] = $value['value'];
         }
         /**
          * Start re-writing ...
          */
         if (isset($results['fields']) && is_array($results['fields'])) {
             foreach ($results['fields'] as $key => $value) {
                 if (is_array($value) && isset($value['type'])) {
                     // <= 1.1.3
                     $value = isset($value['value']) ? $value['value'] : false;
                 }
                 $init[$key] = self::AMF($value, $FP, 'fields.' . $key);
             }
         }
         $results['fields'] = $init;
         unset($fields, $init);
     }
     /**
      * Exclude some field(s) from result(s)
      */
     foreach ($results as $key => $value) {
         if (isset($excludes[$key])) {
             unset($results[$key]);
         }
     }
     return Mecha::O($results);
 }
 /**
  * Apply the Revcheck tools recursively on all lang
  *
  * @param $path    The directory from which we start.
  * @param $revType Can be 'new' when we start a new revcheck with a clean database or 'update' when we revcheck just one folder (and all is sub-folders). Default to 'new'
  * @param $revLang The lang we want to apply the recheck. By default, it's 'all' lang available.
  * @return Nothing.
  */
 public function applyRevCheck($path = '/', $revType = 'new', $revLang = 'all')
 {
     $am = AccountManager::getInstance();
     $appConf = $am->appConf;
     $project = $am->project;
     if ($dh = @opendir($appConf[$project]['vcs.path'] . 'en' . $path)) {
         $dirs = array();
         $files = array();
         while (($name = readdir($dh)) !== false) {
             if ($name == '.' || $name == '..') {
                 continue;
             }
             $file = new File('en', $path . $name);
             if (!$this->needParsing($file)) {
                 continue;
             }
             if ($file->isDir) {
                 $dirs[] = $file;
             } elseif ($file->isFile) {
                 $files[] = $file;
             }
         }
         closedir($dh);
         foreach ($files as $f) {
             $en_size = intval(filesize($f->full_path) / 1024);
             $en_date = filemtime($f->full_path);
             $infoEN = $f->getInfo();
             $en_revision = $infoEN['rev'] == 'NULL' ? 'NULL' : $infoEN['rev'];
             $xmlid = $infoEN['xmlid'] == 'NULL' ? 'NULL' : $infoEN['xmlid'];
             $tmp = explode('/', $f->path);
             // Only for Php project
             if ($project == 'PHP') {
                 $check_doc = new ToolsCheckDoc();
                 $ToolsCheckDocResult = $check_doc->checkDoc($infoEN['content'], $f->path);
             } else {
                 $ToolsCheckDocResult['check_oldstyle'] = 'NULL';
                 $ToolsCheckDocResult['check_undoc'] = 'NULL';
                 $ToolsCheckDocResult['check_roleerror'] = 'NULL';
                 $ToolsCheckDocResult['check_badorder'] = 'NULL';
                 $ToolsCheckDocResult['check_noseealso'] = 'NULL';
                 $ToolsCheckDocResult['check_noreturnvalues'] = 'NULL';
                 $ToolsCheckDocResult['check_noparameters'] = 'NULL';
                 $ToolsCheckDocResult['check_noexamples'] = 'NULL';
                 $ToolsCheckDocResult['check_noerrors'] = 'NULL';
             }
             // If the type of this revcheck is an update, we start to remove all reference to this file from...
             if ($revType == 'update') {
                 //... table `files`
                 $query = 'DELETE FROM `files`
                          WHERE `project`="%s" AND
                                `lang`="en" AND
                                `path`="%s" AND
                                `name`="%s"';
                 $params = array($am->project, $f->path, $f->name);
                 $this->conn->query($query, $params);
                 //... table `errorfiles`
                 $query = 'DELETE FROM `errorfiles`
                          WHERE `project`="%s" AND
                                `lang`="en" AND
                                `path`="%s" AND
                                `name`="%s"';
                 $params = array($am->project, $f->path, $f->name);
                 $this->conn->query($query, $params);
             }
             // Sql insert.
             $query = 'INSERT INTO `files` (`project`, `lang`, `xmlid`, `path`, `name`, `revision`, `size`, `mdate`, `maintainer`, `status`, `check_oldstyle`,  `check_undoc`, `check_roleerror`, `check_badorder`, `check_noseealso`, `check_noreturnvalues`, `check_noparameters`, `check_noexamples`, `check_noerrors`)
                     VALUES ("%s", "en", "%s", "%s", "%s", "%s", "%s", "%s", NULL, NULL, "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")';
             $params = array($am->project, $xmlid, $f->path, $f->name, $en_revision, $en_size, $en_date, $ToolsCheckDocResult['check_oldstyle'], $ToolsCheckDocResult['check_undoc'], $ToolsCheckDocResult['check_roleerror'], $ToolsCheckDocResult['check_badorder'], $ToolsCheckDocResult['check_noseealso'], $ToolsCheckDocResult['check_noreturnvalues'], $ToolsCheckDocResult['check_noparameters'], $ToolsCheckDocResult['check_noexamples'], $ToolsCheckDocResult['check_noerrors']);
             $this->conn->query($query, $params);
             /*
             $error = new ToolsError();
             $error->setParams($infoEN['content'], '', 'en', $f->path, $f->name, '');
             $error->run();
             $error->saveError();
             */
             if ($revType == 'update') {
                 // If we are in update, we have 2 case. $revLang can be en or LANG.
                 // If revLang is en, we must re-check all available language to reflect changes.
                 if ($revLang == 'en') {
                     $ExistingLanguage = $this->getExistingLanguage();
                 } else {
                     $ExistingLanguage[] = array("code" => $revLang);
                 }
             } else {
                 // If this is not an update, we check all languages
                 $ExistingLanguage = $this->getExistingLanguage();
             }
             foreach ($ExistingLanguage as $lang) {
                 $lang = $lang["code"];
                 // We skip en language
                 if ($lang == 'en') {
                     continue;
                 }
                 $lang_file = new File($lang, $f->path . $f->name);
                 // If the type of this revcheck is an update, we start be delete all reference to this file in table...
                 if ($revType == 'update') {
                     // ... `file`
                     $query = 'DELETE FROM `files`
                              WHERE `project`="%s" AND
                                    `lang`="%s" AND
                                    `path`="%s" AND
                                    `name`="%s"';
                     $params = array($project, $lang, $lang_file->path, $lang_file->name);
                     $this->conn->query($query, $params);
                     //... table `errorfiles`
                     $query = 'DELETE FROM `errorfiles`
                              WHERE `project`="%s" AND
                                    `lang`="%s" AND
                                    `path`="%s" AND
                                    `name`="%s"';
                     $params = array($project, $lang, $lang_file->path, $lang_file->name);
                     $this->conn->query($query, $params);
                 }
                 if ($lang_file->exist()) {
                     // Initial revcheck method
                     $size = intval(filesize($lang_file->full_path) / 1024);
                     $date = filemtime($lang_file->full_path);
                     $size_diff = $en_size - $size;
                     $date_diff = intval((time() - $en_date) / 86400) - intval((time() - $date) / 86400);
                     $infoLANG = $lang_file->getInfo();
                     $revision = $infoLANG['en-rev'] == 'NULL' ? 'NULL' : $infoLANG['en-rev'];
                     $maintainer = $infoLANG['maintainer'] == 'NULL' ? 'NULL' : $infoLANG['maintainer'];
                     $status = $infoLANG['status'] == 'NULL' ? 'NULL' : $infoLANG['status'];
                     $xmlid = $infoLANG['xmlid'] == 'NULL' ? 'NULL' : $infoLANG['xmlid'];
                     $reviewed = $infoLANG['reviewed'] == 'NULL' ? 'NULL' : $infoLANG['reviewed'];
                     $reviewed_maintainer = $infoLANG['reviewed_maintainer'] == 'NULL' ? 'NULL' : $infoLANG['reviewed_maintainer'];
                     $query = 'INSERT INTO `files` (`project`, `lang`, `xmlid`, `path`, `name`, `revision`, `en_revision`, `reviewed`, `reviewed_maintainer`, `size`, `size_diff`, `mdate`, `mdate_diff`, `maintainer`, `status`)
                             VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")';
                     $params = array($project, $lang, $xmlid, $lang_file->path, $lang_file->name, $revision, $en_revision, $reviewed, $reviewed_maintainer, $size, $size_diff, $date, $date_diff, $maintainer, $status);
                     $this->conn->query($query, $params);
                     /*
                     // Check for error in this file ONLY if this file is uptodate
                     
                     if ($revision == $en_revision &&  $revision != 0 ) {
                         $error = new ToolsError();
                         $error->setParams(
                             $infoEN['content'], $infoLANG['content'],
                             $lang, $lang_file->path, $lang_file->name, $maintainer
                         );
                         $error->run();
                         $error->saveError();
                     }
                     */
                 } else {
                     $query = 'INSERT INTO `files` (`project`, `lang`, `path`, `name`, `size`)
                             VALUES ("%s", "%s", "%s", "%s", "%s")';
                     $params = array($project, $lang, $lang_file->path, $lang_file->name, $en_size);
                     $this->conn->query($query, $params);
                 }
             }
         }
         foreach ($dirs as $d) {
             $this->applyRevCheck($d->path, $revType, $revLang);
         }
     }
 }
<?php

$attr = ' alt="" width="60" height="60"';
if ($avatar = File::exist(ASSET . DS . '__avatar' . DS . '60x60' . DS . md5($comment->email) . '.png')) {
    echo Asset::image($avatar, $attr);
} elseif ($avatar = File::exist(ASSET . DS . '__avatar' . DS . md5($comment->email) . '.png')) {
    echo Asset::image($avatar, $attr);
} else {
    echo Asset::image($config->protocol . 'www.gravatar.com/avatar/' . md5($comment->email) . '?s=60&amp;d=monsterid', $attr);
}
Example #15
0
 /**
  * ====================================================================
  *  ADD A FILE TO A ZIP FILE
  * ====================================================================
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter    | Type   | Description
  *  ------------ | ------ | -------------------------------------------
  *  $path        | string | File to be added into the ZIP file
  *  $destination | string | File location path in the ZIP file
  *  ------------ | ------ | -------------------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function addFile($file, $destination = null)
 {
     if (self::$zip->open(self::$open) === true) {
         // Handling for `Package::take('file.zip')->addFile('test.txt')`
         if (strpos($file, DS) === false) {
             $file = File::D(self::$open) . DS . $file;
         }
         if (File::exist($file)) {
             if (is_null($destination)) {
                 $destination = File::B($file);
             }
             self::$zip->addFile($file, $destination);
         }
         self::$zip->close();
     }
     return new static();
 }
Example #16
0
                $curt = Converter::curt($page->content);
            }
            ?>
          <p><?php 
            echo $curt;
            ?>
</p>
          <p>
            <?php 
            Weapon::fire('action_before', array($page, $segment));
            ?>
            <?php 
            echo Jot::btn('construct.small:cog', $speak->manage, $config->manager->slug . '/shield/' . $folder);
            ?>
 <?php 
            if (File::exist($r . 'manager.php')) {
                echo Jot::btn('action.small:shield', $speak->attach, $config->manager->slug . '/shield/attach/id:' . $folder);
                ?>
 <?php 
            }
            echo Jot::btn('destruct.small:times-circle', $speak->delete, $config->manager->slug . '/shield/kill/id:' . $folder);
            ?>
            <?php 
            Weapon::fire('action_after', array($page, $segment));
            ?>
          </p>
        </div>
      </div>
      <?php 
        }
        ?>
Example #17
0
 /**
  * ==========================================================
  *  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;
 }
 /**
  * Add a new folder
  *
  */
 public function addNewFolder()
 {
     $am = AccountManager::getInstance();
     if (!$am->isLogged()) {
         return JsonResponseBuilder::failure();
     }
     if (!$am->isGlobalAdmin() && !$am->isLangAdmin()) {
         return JsonResponseBuilder::failure();
     }
     $project = $am->project;
     $appConf = $am->appConf;
     $parentFolder = $this->getRequestVariable('parentFolder');
     $newFolderName = $this->getRequestVariable('newFolderName');
     if (strlen($newFolderName) < 1) {
         return JsonResponseBuilder::failure();
     }
     // Don't allow to add a new folder into root system
     if ($parentFolder == "/") {
         return JsonResponseBuilder::failure();
     }
     $t = explode("/", $parentFolder);
     $fileLang = $t[1];
     array_shift($t);
     // skip the first witch is empty
     array_shift($t);
     // skip the second witch is the lang
     $filePath = "/" . implode("/", $t) . $newFolderName;
     $file = new File($fileLang, $filePath);
     // We test if this folder not already exist
     if ($file->exist()) {
         return JsonResponseBuilder::failure(array('type' => 'folder_already_exist'));
     }
     if ($file->createFolder()) {
         return JsonResponseBuilder::success();
     } else {
         return JsonResponseBuilder::failure();
     }
 }
Example #19
0
 private static function __fields(&$results, $FP)
 {
     // Initialize custom field(s) with the default value(s) so that
     // user(s) don't have to write `isset()` function multiple time(s)
     // just to prevent error message(s) because of the object key(s)
     // that is not available in the old post(s).
     $fields = self::state_field(null, array(), true, rtrim($FP, ':'));
     foreach ($fields as $k => $v) {
         $s = isset($results['fields'][$k]) && trim($results['fields'][$k]) !== "" ? $results['fields'][$k] : "";
         if ($s === "") {
             // For `option` field type, the first option will be used as the default value
             if ($v['type'] === 'option' || $v['type'] === 'o') {
                 $vv = array_keys(Converter::toArray($v['value']));
                 if (isset($v['placeholder']) && trim($v['placeholder']) !== "") {
                     // do nothing ...
                 } else {
                     $s = isset($vv[0]) ? $vv[0] : "";
                 }
                 // For `boolean` field type, empty value is equal to `false`
             } else {
                 if ($v['type'] === 'boolean' || $v['type'] === 'b') {
                     $s = false;
                 }
             }
         } else {
             // For `file` field type, the original custom field value is used to limit the file extension
             // So we have to check the existence of the file first. If it does not exist, then it may be
             // contained with the file extension(s), not with a file name
             if ($v['type'] === 'file' || $v['type'] === 'f') {
                 $e = File::E($s, false);
                 $s = $e !== false ? File::exist(SUBSTANCE . DS . $e . DS . $s, "") : "";
             }
         }
         $results['fields'][$k] = $s;
     }
     unset($fields, $s);
 }
Example #20
0
 /**
  * Find file extesion among allowed file extensions
  * @param string $imagesPath
  * @param string $originalFileName
  * @return bool|string
  */
 protected static function findFileExtension($imagesPath, $originalFileName)
 {
     $ext = false;
     foreach (array_unique(self::$contentTypeToExtension) as $testExt) {
         if (File::exist(rtrim($imagesPath, '\\/') . DIRECTORY_SEPARATOR . $originalFileName . '.' . $testExt)) {
             $ext = $testExt;
             break;
         }
     }
     return $ext;
 }
Example #21
0
<?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);
    }
}
Example #22
0
        }
    }
    Shield::lot(array('segment' => 'shield', 'folder' => $folder, 'path' => $path, 'content' => $content))->attach('manager');
});
/**
 * Shield Killer
 * -------------
 */
Route::accept(array($config->manager->slug . '/shield/kill/id:(:any)', $config->manager->slug . '/shield/(:any)/kill/file:(:all)'), function ($folder = false, $file = false) use($config, $speak) {
    if (!Guardian::happy(1) || $folder === "") {
        Shield::abort();
    }
    $info = Shield::info($folder);
    $path = $file !== false ? File::path($file) : false;
    if ($file !== false) {
        if (!($_file = File::exist(SHIELD . DS . $folder . DS . $path))) {
            Shield::abort();
            // File not found!
        }
    } else {
        if (!($_file = Shield::exist($folder))) {
            Shield::abort();
            // Folder not found!
        }
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . ($file !== false ? File::B($file) : $info->title) . $config->title_separator . $config->manager->title, 'page' => $info, 'cargo' => 'kill.shield.php'));
    if ($request = Request::post()) {
        $request = Filter::apply('request:__shield', $request, $folder, $file);
        Guardian::checkToken($request['token']);
        $P = array('data' => array('path' => $_file));
        File::open($_file)->delete();
 $request = Request::post();
 $id = time();
 Guardian::checkToken($request['token']);
 if (trim($request['name']) === "") {
     $request['name'] = $id . '.txt';
     // empty file name
 }
 $_path = Text::parse(sprintf($request['name'], $id), '->safe_path_name');
 $e = File::E($_path, false);
 if ($e !== 'txt' && $e !== 'php') {
     $e = 'txt';
     $_path .= '.txt';
 }
 $_path_ = File::path($_path);
 $file = ASSET . DS . '__snippet' . DS . $e . DS . $_path;
 if (File::exist($file)) {
     // file already exists
     Notify::error(Config::speak('notify_file_exist', '<code>' . $_path_ . '</code>'));
 }
 if (trim($request['content']) === "") {
     // empty file content
     Notify::error($speak->notify_error_content_empty);
 }
 if (!Notify::errors()) {
     $recent = array_slice(File::open(CACHE . DS . 'plugin.snippet.cache')->unserialize(), 0, $config->per_page);
     File::serialize(array_merge(array($_path), $recent))->saveTo(CACHE . DS . 'plugin.snippet.cache', 0600);
     $url = $config->manager->slug . '/asset/repair/file:__snippet/' . $e . '/' . File::url($_path) . '?path=' . urlencode(rtrim('__snippet/' . $e . '/' . File::D(File::url($_path)), '/'));
     File::write($request['content'])->saveTo($file, 0600);
     Notify::success(Config::speak('notify_file_created', '<code>' . $_path_ . '</code>' . (!isset($request['redirect']) ? ' <a class="pull-right" href="' . $config->url . '/' . $url . '" target="_blank">' . Jot::icon('pencil') . ' ' . $speak->edit . '</a>' : "")));
     Notify::info('<strong>' . $speak->shortcode . ':</strong> <code>{{' . ($e === 'php' ? 'include' : 'print') . ':' . str_replace('.' . $e . X, "", File::url($_path) . X) . '}}</code>');
     Guardian::kick(isset($request['redirect']) ? $url : File::D($config->url_current));
Example #24
0
    }
    Shield::lot(array('segment' => 'cache', 'path' => $path, 'content' => File::open($file)->read()))->attach('manager');
});
/**
 * Cache Killer
 * ------------
 */
Route::accept($config->manager->slug . '/cache/kill/(file|files):(:all)', function ($prefix = "", $file = "") use($config, $speak) {
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    $path = File::path($file);
    if (strpos($path, ';') !== false) {
        $deletes = explode(';', $path);
    } else {
        if (!File::exist(CACHE . DS . $path)) {
            Shield::abort();
            // File not found!
        } else {
            $deletes = array($path);
        }
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . (count($deletes) === 1 ? File::B($path) : $speak->caches) . $config->title_separator . $config->manager->title, 'cargo' => 'kill.cache.php'));
    if ($request = Request::post()) {
        $request = Filter::apply('request:__cache', $request, $file);
        Guardian::checkToken($request['token']);
        $info_path = Mecha::walk($deletes, function ($v) {
            $_path = CACHE . DS . $v;
            File::open($_path)->delete();
            return $_path;
        });
Example #25
0
});
/**
 * Asset Killer
 * ------------
 */
Route::accept($config->manager->slug . '/asset/kill/(file|files):(:all)', function ($path = "", $name = "") use($config, $speak) {
    if (Guardian::get('status') !== 'pilot') {
        Shield::abort();
    }
    $name = File::path($name);
    $p = Request::get('path');
    $p = $p ? '?path=' . urlencode($p) : "";
    if (strpos($name, ';') !== false) {
        $deletes = explode(';', $name);
    } else {
        if (!File::exist(ASSET . DS . $name)) {
            Shield::abort();
            // File not found!
        } else {
            $deletes = array($name);
        }
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . (count($deletes) === 1 ? File::B($name) : $speak->assets) . $config->title_separator . $config->manager->title, 'files' => $deletes, 'cargo' => DECK . DS . 'workers' . DS . 'kill.asset.php'));
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        $info_path = array();
        $is_folder_or_file = count($deletes) === 1 && is_dir(ASSET . DS . $deletes[0]) ? 'folder' : 'file';
        foreach ($deletes as $file_to_delete) {
            $_path = ASSET . DS . $file_to_delete;
            $info_path[] = $_path;
            File::open($_path)->delete();
Example #26
0
 // Side Menu
 $menus = array($speak->article => array('icon' => 'file-text', 'url' => $config->manager->slug . '/article', 'stack' => 9.01), $speak->page => array('icon' => 'file', 'url' => $config->manager->slug . '/page', 'stack' => 9.02), $speak->tag => array('icon' => 'tags', 'url' => $config->manager->slug . '/tag', 'stack' => 9.039999999999999), $speak->asset => array('icon' => 'briefcase', 'url' => $config->manager->slug . '/asset', 'stack' => 9.06));
 // Top Menu
 $bars = array($speak->user => array('icon' => 'user', 'description' => Guardian::get('author'), 'stack' => 9), $speak->log_out => array('icon' => 'sign-out', 'url' => $config->manager->slug . '/logout', 'description' => $speak->log_out, 'stack' => 30));
 // only for `pilot`
 if (Guardian::happy(1)) {
     $menus[$speak->config] = array('icon' => 'cogs', 'url' => $config->manager->slug . '/config', 'stack' => 9);
     $menus[$speak->comment] = array('icon' => 'comments', 'url' => $config->manager->slug . '/comment', 'count' => $total, 'stack' => 9.029999999999999);
     $menus[$speak->menu] = array('icon' => 'bars', 'url' => $config->manager->slug . '/menu', 'stack' => 9.050000000000001);
     $menus[$speak->field] = array('icon' => 'th-list', 'url' => $config->manager->slug . '/field', 'stack' => 9.07);
     $menus[$speak->shortcode] = array('icon' => 'coffee', 'url' => $config->manager->slug . '/shortcode', 'stack' => 9.08);
     $menus[$speak->shield] = array('icon' => 'shield', 'url' => $config->manager->slug . '/shield', 'stack' => 9.09);
     $menus[$speak->plugin] = array('icon' => 'plug', 'url' => $config->manager->slug . '/plugin', 'stack' => 9.1);
     $menus[$speak->cache] = array('icon' => 'clock-o', 'url' => $config->manager->slug . '/cache', 'stack' => 9.109999999999999);
     $bars[$speak->config] = array('icon' => 'cog', 'url' => $config->manager->slug . '/config', 'stack' => 9.01);
     if ($errors = File::exist(ini_get('error_log'))) {
         $total = 0;
         if (filesize($errors) > MAX_ERROR_FILE_SIZE) {
             File::open($errors)->delete();
             $total = '&infin;';
         }
         foreach (explode("\n", File::open($errors)->read()) as $message) {
             if (trim($message) !== "") {
                 $total++;
             }
         }
         $menus[$speak->error] = array('icon' => 'exclamation-triangle', 'url' => $config->manager->slug . '/error', 'count' => $total, 'stack' => 9.130000000000001);
     }
 }
 if ($config->page_type !== '404' && $config->is->post) {
     $type = $config->page_type;
$brush = Text::parse($brush, '->text');
if (is_numeric($brush) && $brush <= 0) {
    $brush = false;
}
$_ = File::D(__DIR__) . DS . 'assets' . DS;
echo '<!DOCTYPE html>' . NL;
echo '<html dir="ltr">' . NL;
echo TAB . '<head>' . NL;
echo str_repeat(TAB, 2) . '<meta charset="' . $config->charset . '">' . NL;
echo str_repeat(TAB, 2) . '<title>' . File::B($snippet) . '</title>' . NL;
echo str_repeat(TAB, 2) . '<link href="' . Filter::colon('favicon:url', $config->url . '/favicon.ico') . '" rel="shortcut icon" type="image/x-icon">' . NL;
echo str_repeat(TAB, 2) . Asset::stylesheet(array($_ . 'shell' . DS . 'page.min.css', $_ . 'shell' . DS . 'brush.min.css'));
echo TAB . '</head>' . NL;
echo TAB . '<body>' . NL;
echo str_repeat(TAB, 2) . '<pre><code' . ($brush !== false ? ' data-language="' . $brush . '"' : "") . '>';
echo Filter::colon('snippet:content_raw', Text::parse($content, '->encoded_html'), $snippet);
echo '</code></pre>' . NL;
echo str_repeat(TAB, 2) . '<div>' . NL;
echo str_repeat(TAB, 3) . '<strong><a href="' . $config->url . '" title="' . $speak->home . '">' . $config->title . '</a></strong>' . NL;
echo str_repeat(TAB, 3) . '<a href="?raw=1" target="_blank">' . $speak->plugin_snippet_share_title_raw . '</a>' . NL;
echo str_repeat(TAB, 3) . '<a href="?file=1">' . $speak->download . '</a>' . NL;
echo str_repeat(TAB, 2) . '</div>' . NL;
echo str_repeat(TAB, 2) . Asset::javascript(array($_ . 'sword' . DS . 'brush.min.js', $_ . 'sword' . DS . 'brush.line.min.js'));
if ($brush !== false) {
    echo str_repeat(TAB, 2) . Asset::javascript($_ . 'sword' . DS . 'brush' . DS . 'generic.min.js');
    if ($brush !== 'generic' && ($f = File::exist($_ . 'sword' . DS . 'brush' . DS . $brush . '.min.js'))) {
        echo str_repeat(TAB, 2) . Asset::javascript($f);
    }
}
echo TAB . '</body>' . NL;
echo '</html>';
Example #28
0
             if (trim(File::open($custom_ . $extension_o)->read()) === "" || trim(File::open($custom_ . $extension_o)->read()) === SEPARATOR || empty($css) && empty($js) || $css === $config->defaults->{$segment . '_css'} && $js === $config->defaults->{$segment . '_js'}) {
                 // Always delete empty custom CSS and JavaScript file(s) ...
                 File::open($custom_ . $extension_o)->delete();
                 Weapon::fire('on_custom_destruct', array($G, $P));
             } else {
                 File::write(Converter::ES($css) . "\n\n" . SEPARATOR . "\n\n" . Converter::ES($js))->saveTo($custom_ . $extension_o);
                 File::open($custom_ . $extension_o)->renameTo(Date::slug($date) . $extension);
                 Weapon::fire('on_custom_repair', array($G, $P));
             }
         } else {
             if (!empty($css) && $css !== $config->defaults->{$segment . '_css'} || !empty($js) && $js !== $config->defaults->{$segment . '_js'}) {
                 File::write(Converter::ES($css) . "\n\n" . SEPARATOR . "\n\n" . Converter::ES($js))->saveTo(CUSTOM . DS . Date::slug($date) . $extension_o);
                 Weapon::fire(array('on_custom_update', 'on_custom_construct'), array($G, $P));
             }
         }
         if ($post->slug !== $slug && ($php_file = File::exist(File::D($post->path) . DS . $post->slug . '.php'))) {
             File::open($php_file)->renameTo($slug . '.php');
         }
         // Rename all response file(s) related to post if post date has been changed
         if ((string) $date !== (string) $post->date->W3C && ($responses = call_user_func('Get::' . $response . 's', 'DESC', 'post:' . $id, 'txt,hold'))) {
             foreach ($responses as $v) {
                 $parts = explode('_', File::B($v));
                 $parts[0] = Date::slug($date);
                 File::open($v)->renameTo(implode('_', $parts));
             }
         }
     }
     Notify::success(Config::speak('notify_success_' . ($id ? 'updated' : 'created'), $title) . ($extension === '.txt' ? ' <a class="pull-right" href="' . call_user_func('Get::' . $segment . 'Anchor', $_)->url . '" target="_blank"><i class="fa fa-eye"></i> ' . $speak->view . '</a>' : ""));
     Weapon::fire(array('on_' . $segment . '_update', 'on_' . $segment . '_' . ($id ? 'repair' : 'construct')), array($G, $P));
     Guardian::kick($config->manager->slug . '/' . $segment . '/repair/id:' . Date::format($date, 'U'));
 }
Example #29
0
 * Shield Killer
 * -------------
 */
Route::accept(array($config->manager->slug . '/shield/kill/id:(:any)', $config->manager->slug . '/shield/(:any)/kill/file:(:all)'), function ($folder = "", $path = false) use($config, $speak) {
    if (Guardian::get('status') !== 'pilot' || $folder === "") {
        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));
Example #30
0
<?php

// First installation ...
if ($installer = File::exist(ROOT . DS . 'install.php')) {
    Config::load();
    Guardian::kick(File::url($installer));
}