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 . '&hellip;', 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;
}
function do_response_ping($message, $results = array())
{
    $results = (object) $results;
    if (isset($results->parent) && !is_null($results->parent)) {
        $prefix = File::B(File::D($results->path));
        $name = is_callable('Get::' . $prefix . 'Anchor') ? call_user_func('Get::' . $prefix . 'Anchor', $results->parent)->name : $results->parent;
        $to = '<a href="#' . $prefix . '-' . $results->parent . '">@' . $name . '</a>';
        return strpos($message, '<p>') === 0 ? str_replace('^<p>', '<p>' . $to . ' ', '^' . $message) : $message . '<p>' . $to . '</p>';
    }
    return $message;
}
Example #3
0
 /**
  * ==========================================================
  *  LOADING PLUGIN(S)
  * ==========================================================
  *
  * -- CODE: -------------------------------------------------
  *
  *    $plugins = Plugin::load();
  *
  * ----------------------------------------------------------
  *
  */
 public static function load($cache = true, $name = 'plugins.order.cache')
 {
     if ($cache && ($plugins = File::exist(CACHE . DS . $name))) {
         return File::open($plugins)->unserialize();
     }
     $plugins = array();
     foreach (glob(PLUGIN . DS . '*', GLOB_NOSORT | GLOB_ONLYDIR) as $plugin) {
         $plugin = File::B($plugin);
         $plugins[$plugin] = (double) File::open(PLUGIN . DS . $plugin . DS . '__stack.txt')->read(10);
     }
     asort($plugins);
     File::serialize($plugins)->saveTo(CACHE . DS . $name, 0600);
     return $plugins;
 }
Example #4
0
 /**
  * ==========================================================================
  *  GET ALL FILE(S) RECURSIVELY
  * ==========================================================================
  *
  * -- CODE: -----------------------------------------------------------------
  *
  *    $files = Get::files(
  *        'some/path',
  *        'txt',
  *        'ASC',
  *        'update'
  *    );
  *
  *    $files = Get::files(
  *        'some/path',
  *        'gif,jpg,jpeg,png',
  *        'ASC',
  *        'update'
  *    );
  *
  *    $files = Get::files(
  *        'some/path',
  *        'txt',
  *        'ASC',
  *         null,
  *        'key:path' // output only the `path` data
  *    );
  *
  * --------------------------------------------------------------------------
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter  | Type    | Desription
  *  ---------- | ------- | --------------------------------------------------
  *  $folder    | string  | Path to folder of file(s) you want to be listed
  *  $e         | string  | The file extension(s)
  *  $order     | string  | Ascending or descending? ASC/DESC?
  *  $sorter    | string  | The key of array item as sorting reference
  *  $filter    | string  | Filter the resulted array by a keyword
  *  $recursive | boolean | Get file(s) from a folder recursively?
  *  ---------- | ------- | --------------------------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function files($folder = ASSET, $e = '*', $order = 'ASC', $sorter = 'path', $filter = "", $recursive = true)
 {
     $results = array();
     $folder = rtrim(File::path($folder), DS);
     $e = $e ? explode(',', str_replace(' ', "", $e)) : true;
     if ($files = File::explore($folder, $recursive, true, false)) {
         if (strpos($filter, 'key:') === 0) {
             $s = explode(' ', substr($filter, 4), 2);
             $output = $s[0];
             $filter = isset($s[1]) ? $s[1] : "";
             $sorter = null;
         } else {
             $output = null;
         }
         foreach ($files as $k => $v) {
             $_k = File::B($k);
             $_kk = DS . str_replace($folder . DS, "", $k);
             if (!$filter || strpos(File::N($k), $filter) !== false) {
                 if ($v === 1) {
                     if ($e === true || $e === array('*') || Mecha::walk($e)->has(File::E($k))) {
                         $o = File::inspect($k, $output);
                         if (is_null($output)) {
                             $o['is']['hidden'] = strpos($_k, '__') === 0 || strpos($_k, '.') === 0 || strpos($_kk, DS . '__') !== false || strpos($_kk, DS . '.') !== false;
                         }
                         $results[] = $o;
                     }
                 } else {
                     if ($e === true || $e === array('/')) {
                         $results[] = File::inspect($k, $output);
                     }
                 }
             }
         }
         unset($files, $_k, $_kk);
         return !empty($results) ? Mecha::eat($results)->order($order, $sorter)->vomit() : false;
     }
     return false;
 }
Example #5
0
function do_minify($content)
{
    global $config;
    $c_minify = $config->states->{'plugin_' . md5(File::B(__DIR__))};
    $url = $config->protocol . $config->host;
    // Minify HTML
    if (isset($c_minify->html_minify)) {
        Config::set('html_minify', true);
        $content = Converter::detractSkeleton($content);
    }
    // Minify URL
    if (isset($c_minify->url_minify) && Text::check($content)->has('="' . $url)) {
        Config::set('url_minify', true);
        $content = str_replace(array('="' . $url . '"', '="' . $url . '/', '="' . $url . '?', '="' . $url . '#'), array('="/"', '="/', '="?', '="#'), $content);
    }
    // Minify Embedded CSS
    if (isset($c_minify->css_minify)) {
        Config::set('css_minify', true);
        $content = preg_replace_callback('#<style(>| .*?>)([\\s\\S]*?)<\\/style>#i', function ($matches) use($config, $c_minify, $url) {
            $css = Converter::detractShell($matches[2]);
            if (isset($c_minify->url_minify)) {
                $css = preg_replace('#(?<=[\\s:])(src|url)\\(' . preg_quote($url, '/') . '#', '$1(', $css);
            }
            return '<style' . $matches[1] . $css . '</style>';
        }, $content);
    }
    // Minify Embedded JavaScript
    if (isset($c_minify->js_minify)) {
        Config::set('js_minify', true);
        $content = preg_replace_callback('#<script(>| .*?>)([\\s\\S]*?)<\\/script>#i', function ($matches) {
            $js = Converter::detractSword($matches[2]);
            return '<script' . $matches[1] . $js . '</script>';
        }, $content);
    }
    return $content;
}
Example #6
0
 /**
  * ===========================================================================
  *  EXTRACT COMMENT FILE INTO LIST OF COMMENT DATA FROM ITS PATH/ID/TIME/NAME
  * ===========================================================================
  *
  * -- CODE: ------------------------------------------------------------------
  *
  *    var_dump(Get::comment(1399334470));
  *
  * ---------------------------------------------------------------------------
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter  | Type   | Description
  *  ---------- | ------ | ----------------------------------------------------
  *  $reference | string | Comment path, ID, time or name
  *  ---------- | ------ | ----------------------------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function comment($reference, $response_to = ARTICLE, $connector = null)
 {
     $FP = 'comment:';
     $config = Config::get();
     $results = array();
     $path = false;
     if (strpos(ROOT, $reference) === 0) {
         // By comment path
         $path = $reference;
     } else {
         foreach (self::comments(null, 'DESC', 'txt,hold') as $comment) {
             $base = File::B($comment);
             list($_post, $_time, $_parent) = explode('_', $base);
             if (!is_numeric($reference) && (string) File::B($reference) === (string) $base || (int) Date::format($reference, 'U') === (int) Date::format($_time, 'U')) {
                 $path = $comment;
                 $results = self::commentExtract($comment);
                 break;
             }
         }
     }
     if (!$path || !file_exists($path)) {
         return false;
     }
     $results['date'] = self::AMF(Date::extract($results['time']), $FP, 'date');
     $results = $results + Text::toPage(File::open($path)->read(), 'message', 'comment:');
     $results['email'] = Text::parse($results['email'], '->decoded_html');
     $results['permalink'] = '#';
     $posts = glob($response_to . DS . '*.txt', GLOB_NOSORT);
     for ($i = 0, $count = count($posts); $i < $count; ++$i) {
         list($time, $kind, $slug) = explode('_', File::N($posts[$i]), 3);
         if ((int) Date::format($time, 'U') === $results['post']) {
             $results['permalink'] = self::AMF($config->url . (is_null($connector) ? '/' . $config->index->slug . '/' : $connector) . $slug . '#comment-' . $results['id'], $FP, 'permalink');
             break;
         }
     }
     if (!isset($results['url'])) {
         $results['url'] = self::AMF('#', $FP, 'url');
     }
     $fields = self::state_field(rtrim($FP, ':'), null, array(), false);
     $init = array();
     foreach ($fields as $key => $value) {
         $init[$key] = $value['value'];
     }
     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);
     }
     return Mecha::O($results);
 }
<?php

$scopes = Mecha::walk(glob(POST . DS . '*', GLOB_NOSORT | GLOB_ONLYDIR), function ($v) {
    return File::B($v);
});
return array('pass' => array('title' => $speak->password, 'type' => 'text', 'scope' => implode(',', $scopes), 'description' => $speak->plugin_private_post->__description));
Example #8
0
<?php

// The `__launch.php` file will be included only in the backend
Route::accept($config->manager->slug . '/plugin/' . File::B(__DIR__) . '/update', function () use($config, $speak) {
    if (!Guardian::happy()) {
        Shield::abort();
        // [1]
    }
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        // [2]
        File::write('test!')->saveTo(PLUGIN . DS . File::B(__DIR__) . DS . 'states' . DS . 'config.txt', 0600);
        Notify::success(Config::speak('notify_success_updated', array($speak->plugin)));
        // [3]
        Guardian::kick(File::D($config->url_current));
        // [4]
    }
});
Example #9
0
                        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'));
        }
    }
    Shield::lot(array('segment' => $segment))->attach('manager');
});
/**
 * Post Killer
 * -----------
<?php

$brush = Request::get('brush', $x === 'php' ? 'php' : 'generic');
$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);
    }
Example #11
0
echo $messages;
?>
    <?php 
Weapon::fire('tab_content_before', $hooks);
?>
    <div class="tab-content" id="tab-content-1">
      <h3><?php 
echo Config::speak('manager.title_your_', $speak->plugins);
?>
</h3>
      <?php 
if ($folders) {
    ?>
      <?php 
    foreach ($folders as $folder) {
        $folder = File::B($folder->path);
        ?>
      <?php 
        $r = PLUGIN . DS . $folder . DS;
        $c = File::exist($r . 'capture.png');
        ?>
      <?php 
        $page = Plugin::info($folder);
        ?>
      <div class="media<?php 
        if (!$c) {
            ?>
 no-capture<?php 
        }
        ?>
" id="plugin:<?php 
Example #12
0
      <span class="grid span-4">
      <?php 
echo Form::select('language_direction', array('ltr' => 'Left to Right (LTR)', 'rtl' => 'Right to Left (RTL)'), Guardian::wayback('language_direction', $config->language_direction), array('class' => 'select-block'));
?>
      </span>
    </label>
    <label class="grid-group">
      <span class="grid span-2 form-label"><?php 
echo $speak->shield;
?>
</span>
      <span class="grid span-4">
      <?php 
$info = array();
foreach (glob(SHIELD . DS . '*', GLOB_ONLYDIR) as $folder) {
    $s = File::B($folder);
    if (strpos($s, '__') !== 0) {
        $info[$s] = Shield::info($s)->title;
    }
}
echo Form::select('shield', $info, Guardian::wayback('shield', $config->shield), array('class' => 'select-block'));
?>
      </span>
    </label>
    <label class="grid-group">
      <span class="grid span-2 form-label"><?php 
echo $speak->manager->title_per_page;
?>
 (<?php 
echo $speak->all;
?>
Example #13
0
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;
        });
        $P = array('data' => array('files' => $info_path));
        Notify::success(Config::speak('notify_file_deleted', '<code>' . implode('</code>, <code>', $deletes) . '</code>'));
        Weapon::fire(array('on_cache_update', 'on_cache_destruct'), array($P, $P));
        Guardian::kick($config->manager->slug . '/cache/1');
    } else {
        Notify::warning(count($deletes) === 1 ? Config::speak('notify_confirm_delete_', '<code>' . $path . '</code>') : $speak->notify_confirm_delete);
    }
Example #14
0
  <tbody>
    <?php 
if ($files) {
    ?>
    <?php 
    foreach ($files as $file) {
        ?>
    <?php 
        $url = File::url(str_replace($c_path, "", $file->path));
        ?>
    <tr<?php 
        echo Session::get('recent_file_update') === File::B($file->path) ? ' class="active"' : "";
        ?>
>
      <td><?php 
        echo strpos($url, '/') !== false ? Jot::span('fade', File::D($url) . '/') . File::B($url) : $url;
        ?>
</td>
      <td class="td-icon">
      <?php 
        echo isset($c_url_repair) && $c_url_repair !== false ? Jot::a('construct', $c_url_repair . $url, Jot::icon('pencil'), array('title' => $speak->edit)) : Jot::icon('pencil');
        ?>
      </td>
      <td class="td-icon">
      <?php 
        echo isset($c_url_kill) && $c_url_kill !== false ? Jot::a('destruct', $c_url_kill . $url, Jot::icon('times'), array('title' => $speak->delete)) : Jot::icon('times');
        ?>
      </td>
    </tr>
    <?php 
    }
Example #15
0
/**
 * Comment Manager
 * ---------------
 */
Route::accept(array($config->manager->slug . '/comment', $config->manager->slug . '/comment/(:num)'), function ($offset = 1) use($config, $speak) {
    if (Guardian::get('status') !== 'pilot') {
        Shield::abort();
    }
    $offset = (int) $offset;
    File::write($config->total_comments_backend)->saveTo(SYSTEM . DS . 'log' . DS . 'comments.total.log', 0600);
    if ($files = Get::comments(null, 'DESC', 'txt,hold')) {
        $comments = array();
        $comments_id = array();
        foreach ($files as $file) {
            $parts = explode('_', File::B($file));
            $comments_id[] = $parts[1];
        }
        rsort($comments_id);
        foreach (Mecha::eat($comments_id)->chunk($offset, $config->manager->per_page)->vomit() as $comment) {
            $comments[] = Get::comment($comment);
        }
        unset($comments_id, $files);
    } else {
        $comments = false;
    }
    Config::set(array('page_title' => $speak->comments . $config->title_separator . $config->manager->title, 'offset' => $offset, 'responses' => $comments, 'pagination' => Navigator::extract(Get::comments(null, 'DESC', 'txt,hold'), $offset, $config->manager->per_page, $config->manager->slug . '/comment'), 'cargo' => DECK . DS . 'workers' . DS . 'cargo.comment.php'));
    Shield::lot('segment', 'comment')->attach('manager', false);
});
/**
 * Comment Repair
Example #16
0
        // Check for empty message content
        if (trim($message) === "") {
            Notify::error(Config::speak('notify_error_empty_field', $speak->message));
            Guardian::memorize($request);
        }
        $P = array('data' => $request);
        if (!Notify::errors()) {
            $header = array('Name' => $name, 'Email' => $email, 'URL' => $url, 'Status' => $request['status'], 'Content Type' => Request::post('content_type', 'HTML'), 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false);
            $_ = RESPONSE . DS . $segment . DS . Date::slug($request['post']) . '_' . Date::slug($rid) . '_' . ($request['parent'] ? Date::slug($request['parent']) : '0000-00-00-00-00-00') . $extension;
            // Ignite
            if (!$id) {
                Page::header($header)->content($message)->saveTo($_);
                // Repair
            } else {
                Page::open($response->path)->header($header)->content($message)->save();
                File::open($response->path)->renameTo(File::B($_));
            }
            Notify::success(Config::speak('notify_success_' . ($id ? 'updated' : 'created'), $speak->{$segment}) . ($extension === '.txt' ? ' <a class="pull-right" href="' . call_user_func('Get::' . $post . 'Anchor', $request['post'])->url . '#' . $segment . '-' . $rid . '" 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:' . $rid . $config->url_query);
        }
    }
    Shield::lot(array('segment' => array($segment, $post)))->attach('manager');
});
/**
 * Response Killer
 * ---------------
 */
Route::accept($config->manager->slug . '/(' . $response . ')/kill/id:(:num)', function ($segment = "", $id = "") use($config, $speak, $post) {
    if (!Guardian::happy(1)) {
        Shield::abort();
Example #17
0
<form class="form-plugin" action="<?php 
echo $config->url_current;
?>
/update" method="post">
  <?php 
echo Form::hidden('token', $token);
?>
  <?php 
$state = PLUGIN . DS . File::B(__DIR__) . DS . 'states' . DS;
$url = File::open($state . 'url.txt')->read();
$abbr = File::open($state . 'abbr.txt')->read();
?>
  <fieldset>
    <legend><?php 
echo $speak->plugin_markdown_title_abbr;
?>
</legend>
    <label class="grid-group">
      <span class="grid span-6">
        <?php 
echo Form::textarea('abbr', $abbr, '*[CMS]: Content Management System', array('class' => array('textarea-block', 'textarea-expand', 'code')));
?>
      </span>
    </label>
  </fieldset>
  <fieldset>
    <legend><?php 
echo $speak->plugin_markdown_title_url;
?>
</legend>
    <label class="grid-group">
Example #18
0
 /**
  * ====================================================================
  *  RENAME A FILE INSIDE A ZIP FILE
  * ====================================================================
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter | Type   | Description
  *  --------- | ------ | ----------------------------------------------
  *  $old      | string | The old name
  *  $new      | string | The new name
  *  --------- | ------ | ----------------------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function renameFile($old, $new = "")
 {
     if (self::$zip->open(self::$open) === true) {
         $old = File::path($old);
         $root = File::D($old) !== "" ? File::D($old) . DS : "";
         self::$zip->renameName($old, $root . File::B($new));
         self::$zip->close();
     }
     return new static();
 }
Example #19
0
 * -----------------
 */
Weapon::fire('plugins_before');
foreach ($plugins = Plugin::load() as $k => $v) {
    $__ = PLUGIN . DS . $k . DS;
    if (!($language = File::exist($__ . 'languages' . DS . $config->language . DS . 'speak.txt'))) {
        $language = $__ . 'languages' . DS . 'en_US' . DS . 'speak.txt';
    }
    if (file_exists($language)) {
        Config::merge('speak', Text::toArray(File::open($language)->read(), S, '  '));
        $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
        }
    }
Example #20
0
     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();
     }
     $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 {
Example #21
0
<?php

// The `__launch.php` file will be included only in the backend
Route::accept($config->manager->slug . '/plugin/' . File::B(__DIR__) . '/update', function () use($config, $speak) {
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        // [2]
        File::write('test!')->saveTo(__DIR__ . DS . 'states' . DS . 'config.txt', 0600);
        Notify::success(Config::speak('notify_success_updated', $speak->plugin));
        // [3]
        Guardian::kick(File::D($config->url_current));
        // [4]
    }
});
      <a class="tab-button active" href="#tab-content-1-1"><?php 
echo Jot::icon('comments-o', 'fw') . ' ' . $speak->activate;
?>
</a>
      <a class="tab-button" href="#tab-content-1-2"><?php 
echo Jot::icon('cogs', 'fw') . ' ' . $speak->configs;
?>
</a>
    </div>
    <div class="tab-content-area">
      <div class="tab-content" id="tab-content-1-1">
        <?php 
$comment_service_config = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize();
$options = array();
foreach (glob(__DIR__ . DS . 'workers' . DS . '*', GLOB_ONLYDIR) as $option) {
    $option = File::B($option);
    $options[$option] = isset($speak->plugin_comment_service->title->{$option}) ? $speak->plugin_comment_service->title->{$option} : Text::parse($option, '->title');
}
?>
        <p><?php 
echo Form::select('service', $options, $comment_service_config['service']);
?>
</p>
      </div>
      <div class="tab-content hidden" id="tab-content-1-2">
        <?php 
foreach (glob(__DIR__ . DS . 'workers' . DS . '*' . DS . 'configurator.php') as $configurator) {
    ?>
        <?php 
    include $configurator;
    ?>
<?php

header('Content-Disposition: attachment; filename=' . File::B($snippet));
echo $content;
ignore_user_abort(true);
exit;
Example #24
0
<?php

$c_comment_notify = $config->states->{'plugin_' . md5(File::B(__DIR__))};
?>
<label class="grid-group">
  <span class="grid span-1 form-label"><?php 
echo $speak->subject;
?>
</span>
  <span class="grid span-5"><?php 
echo Form::text('subject', $c_comment_notify->subject, null, array('class' => 'input-block'));
?>
</span>
</label>
<label class="grid-group">
  <span class="grid span-1 form-label"><?php 
echo $speak->message;
?>
</span>
  <span class="grid span-5"><?php 
echo Form::textarea('message', $c_comment_notify->message, null, array('class' => 'textarea-block'));
?>
</span>
</label>
Example #25
0
 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));
 }
?>
  </div>
  <div class="grid span-2">
    <h4><i class="fa fa-comments"></i> <?php 
echo $speak->responses;
?>
</h4>
    <?php 
if ($responses = glob(RESPONSE . DS . '*', GLOB_ONLYDIR)) {
    ?>
    <ul>
      <?php 
    foreach ($responses as $response) {
        ?>
      <?php 
        $s = File::B($response);
        ?>
      <li><?php 
        echo Cell::a($config->manager->slug . '/' . $s, isset($speak->{$s}) ? $speak->{$s} : Text::parse($s, '->title'), null, array('data-tooltip' => Text::parse(count(glob($response . DS . '*.txt', GLOB_NOSORT)) . ' ' . $speak->approved . ', ' . count(glob($response . DS . '*.hold', GLOB_NOSORT)) . ' ' . $speak->pending, '->text')));
        ?>
 (<?php 
        echo count(glob($response . DS . '*.*', GLOB_NOSORT));
        ?>
)</li>
      <?php 
    }
    ?>
    </ul>
    <?php 
}
?>
Example #27
0
            Shield::abort();
            // File not found!
        }
    } else {
        if (!($file = File::exist(SHIELD . DS . $folder))) {
            Shield::abort();
            // Folder not found!
        }
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . ($path ? File::B($file) : $info['title']) . $config->title_separator . $config->manager->title, 'files' => Get::files(SHIELD . DS . $folder, '*'), 'cargo' => DECK . DS . 'workers' . DS . 'kill.shield.php'));
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        $P = array('data' => array('path' => $file));
        File::open($file)->delete();
        if ($path) {
            Notify::success(Config::speak('notify_file_deleted', '<code>' . File::B($path) . '</code>'));
        } else {
            Notify::success(Config::speak('notify_success_deleted', $speak->shield));
        }
        Weapon::fire('on_shield_update', array($P, $P));
        Weapon::fire('on_shield_destruct', array($P, $P));
        Guardian::kick($config->manager->slug . '/shield' . ($path ? '/' . $folder : ""));
    } else {
        Notify::warning(Config::speak('notify_confirm_delete_', $path ? '<code>' . File::path($path) . '</code>' : '<strong>' . $info['title'] . '</strong>'));
    }
    Shield::lot(array('segment' => 'shield', 'the_shield' => $folder, 'the_name' => $path, 'the_info' => $info))->attach('manager', false);
});
/**
 * Shield Attacher
 * ---------------
 */
Example #28
0
        }
        unset($request['content']);
        // Remove content from request array
        $request['path'] = $results;
        File::serialize($request)->saveTo(__DIR__ . DS . 'states' . DS . 'config.txt', 0600);
        Notify::success(Config::speak('notify_success_updated', $speak->plugin));
        Guardian::kick(File::D($config->url_current));
    }
});
/**
 * 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();
            }
        }
    }
}
$hooks = Mecha::walk(glob(POST . DS . '*', GLOB_NOSORT | GLOB_ONLYDIR), function ($v) {
    return 'on_' . File::B($v) . '_update';
});
Weapon::add($hooks, 'do_remove_cache', 10);
Example #29
0
<?php

$c_editor = $config->states->{'plugin_' . md5(File::B(__DIR__))};
?>
<div class="p">
  <?php 
foreach ($speak->MTE->buttons as $k => $v) {
    ?>
  <?php 
    if (Text::check($k)->in(array('yes', 'no', 'ok', 'cancel', 'open', 'close'))) {
        continue;
    }
    ?>
  <div><?php 
    echo Form::checkbox('buttons[' . $k . ']', 1, isset($c_editor->buttons->{$k}), sprintf($speak->manager->title_show__button, $v));
    ?>
</div>
  <?php 
}
?>
</div>
<p><?php 
echo Jot::button('action', $speak->update);
?>
</p>
Example #30
0
<div class="grid-group">
  <span class="grid span-1 form-label"><?php 
echo $speak->settings;
?>
</span>
  <div class="grid span-5">
  <?php 
$c_minify = $config->states->{'plugin_' . md5(File::B(__DIR__))};
foreach ($speak->plugin_minify->title as $k => $v) {
    echo '<div>' . Form::checkbox($k, 1, isset($c_minify->{$k}), $v) . '</div>';
}
?>
  </div>
</div>