Exemple #1
0
 public static function protect($value)
 {
     if (!is_string($value)) {
         return $value;
     }
     return Text::parse($value, '->encoded_html');
 }
Exemple #2
0
function do_markdown($content, $results = array())
{
    global $config;
    $results = (object) $results;
    if (!isset($results->content_type) || $results->content_type === 'Markdown' || $results->content_type === 'Markdown Extra') {
        return Text::parse($content, '->html');
    }
    return $content;
}
Exemple #3
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);
 }
Exemple #4
0
function do_facebook_open_graph()
{
    $config = Config::get();
    $T2 = str_repeat(TAB, 2);
    echo O_BEGIN . $T2 . '<!-- Start Facebook Open Graph -->' . NL;
    echo $T2 . '<meta property="og:title" content="' . Text::parse($config->page_title, '->text') . '"' . ES . NL;
    echo $T2 . '<meta property="og:url" content="' . Filter::colon('og:url', $config->url_current) . '"' . ES . NL;
    if (isset($config->{$config->page_type}->description)) {
        $config->description = $config->{$config->page_type}->description;
    }
    echo $T2 . '<meta property="og:description" content="' . Text::parse($config->description, '->text') . '"' . ES . NL;
    if ($config->page_type !== '404' && isset($config->{$config->page_type}->image)) {
        echo $T2 . '<meta property="og:image" content="' . $config->{$config->page_type}->image . '"' . ES . NL;
    } else {
        echo $T2 . '<meta property="og:image" content="' . Filter::colon('favicon:url', $config->url . '/favicon.ico') . '"' . ES . NL;
    }
    echo $T2 . '<meta property="og:site_name" content="' . $config->title . '"' . ES . NL;
    echo $T2 . '<meta property="og:type" content="' . ($config->page_type === 'article' ? 'article' : 'website') . '"' . ES . NL;
    echo $T2 . '<!-- End Facebook Open Graph -->' . O_END;
}
Exemple #5
0
 /**
  * ============================================================
  *  OVERWRITE HTTP URL QUERY
  * ============================================================
  *
  * -- CODE: ---------------------------------------------------
  *
  *    echo HTTP::query('offset', 4);
  *
  * ------------------------------------------------------------
  *
  */
 public static function query($query = null, $value = 1)
 {
     if (is_null($query)) {
         return Config::get('url_query');
     }
     if (func_num_args() === 2) {
         $query = array($query => $value);
     }
     $query = !empty($query) ? array_merge($_GET, $query) : $_GET;
     $results = array();
     foreach ($query as $k => $v) {
         if ($v === false || is_array($v)) {
             // TODO: accept array value
             unset($_GET[$k]);
             continue;
         }
         $value = $v !== true ? '=' . Text::parse(Converter::str($v), '->encoded_url') : "";
         $results[] = $k . $value;
     }
     return !empty($results) ? '?' . implode('&', $results) : "";
 }
function do_twitter_cards()
{
    $config = Config::get();
    $twitter_cards_config = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize();
    $T2 = str_repeat(TAB, 2);
    echo O_BEGIN . $T2 . '<!-- Start Twitter Cards -->' . NL;
    echo $T2 . '<meta name="twitter:card" content="' . (isset($config->{$config->page_type}->image) && $config->{$config->page_type}->image !== Image::placeholder() ? 'summary_large_image' : 'summary') . '"' . ES . NL;
    echo $T2 . '<meta name="twitter:site" content="@' . $twitter_cards_config['twitter_site'] . '"' . ES . NL;
    echo $T2 . '<meta name="twitter:creator" content="@' . $twitter_cards_config['twitter_creator'] . '"' . ES . NL;
    echo $T2 . '<meta name="twitter:title" content="' . Text::parse($config->page_title, '->text') . '"' . ES . NL;
    echo $T2 . '<meta name="twitter:url" content="' . Filter::colon('twitter:url', $config->url_current) . '"' . ES . NL;
    if (isset($config->{$config->page_type}->description)) {
        $config->description = $config->{$config->page_type}->description;
    }
    echo $T2 . '<meta name="twitter:description" content="' . Text::parse($config->description, '->text') . '"' . ES . NL;
    if ($config->page_type !== '404' && isset($config->{$config->page_type}->image)) {
        echo $T2 . '<meta name="twitter:image" content="' . $config->{$config->page_type}->image . '"' . ES . NL;
    } else {
        echo $T2 . '<meta name="twitter:image" content="' . $config->url . '/favicon.ico"' . ES . NL;
    }
    echo $T2 . '<!-- End Twitter Cards -->' . O_END;
}
<?php

return array(0 => array('name' => $speak->untagged, 'slug' => Text::parse($speak->untagged, '->slug'), 'description' => ""));
Exemple #8
0
 public static function DS($text)
 {
     return str_replace(Text::parse(SEPARATOR, '->ascii'), SEPARATOR, $text);
 }
$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>';
Exemple #10
0
            $info_path[] = $_path;
            File::open($_path)->delete();
        }
        $P = array('data' => array('files' => $info_path));
        Notify::success(Config::speak('notify_' . $is_folder_or_file . '_deleted', '<code>' . implode('</code>, <code>', $deletes) . '</code>'));
        Weapon::fire('on_asset_update', array($P, $P));
        Weapon::fire('on_asset_destruct', array($P, $P));
        Guardian::kick($config->manager->slug . '/asset/1' . $p);
    } else {
        Notify::warning(count($deletes) === 1 ? Config::speak('notify_confirm_delete_', '<code>' . File::path($name) . '</code>') : $speak->notify_confirm_delete);
    }
    Shield::lot('segment', 'asset')->attach('manager', false);
});
/**
 * Multiple Asset Killer
 * ---------------------
 */
Route::accept($config->manager->slug . '/asset/kill', function ($path = "") use($config, $speak) {
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        if (!isset($request['selected'])) {
            Notify::error($speak->notify_error_no_files_selected);
            Guardian::kick($config->manager->slug . '/asset/1');
        }
        $files = array();
        foreach ($request['selected'] as $file) {
            $files[] = str_replace('%2F', '/', Text::parse($file, '->encoded_url'));
        }
        Guardian::kick($config->manager->slug . '/asset/kill/files:' . implode(';', $files));
    }
});
?>
</span>
        <span class="grid span-5">
        <?php 
echo Form::text('title', Guardian::wayback('title', $default->title), $speak->manager->placeholder_title, array('class' => 'input-block'));
?>
        </span>
      </label>
      <label class="grid-group">
        <span class="grid span-1 form-label"><?php 
echo $speak->slug;
?>
</span>
        <span class="grid span-5">
        <?php 
echo Form::text('slug', Guardian::wayback('slug', $default->slug), Text::parse($speak->manager->placeholder_title, '->slug'), array('class' => 'input-block'));
?>
        </span>
      </label>
      <?php 
include 'unit.composer.1.php';
?>
      <label class="grid-group">
        <span class="grid span-1 form-label"><?php 
echo $speak->description;
?>
</span>
        <span class="grid span-5">
        <?php 
echo Form::textarea('description', Guardian::wayback('description', $default->description), Config::speak('manager.placeholder_description_', strtolower($speak->article)), array('class' => 'textarea-block'));
?>
Exemple #12
0
            $field = Request::post('fields', array());
            include DECK . DS . 'workers' . DS . 'task.field.1.php';
            // Temporarily disallow image(s) in comment to prevent XSS
            $message = strip_tags($message, '<br><img>' . ($parser === 'HTML' ? '<a><abbr><b><blockquote><code><del><dfn><em><i><ins><p><pre><span><strong><sub><sup><time><u><var>' : ""));
            $message = preg_replace('#(\\!\\[.*?\\]\\(.*?\\))#', '`$1`', $message);
            $message = preg_replace('#<img(\\s[^<>]*?)>#', '&lt;img$1&gt;', $message);
            Page::header(array('Name' => $name, 'Email' => $email, 'URL' => $url, 'Status' => Guardian::happy() ? 'pilot' : 'passenger', 'Content Type' => $parser, 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false, 'UA' => Get::UA(), 'IP' => Get::IP()))->content($message)->saveTo(RESPONSE . DS . $post . '_' . Date::format($id, 'Y-m-d-H-i-s') . '_' . ($parent ? Date::format($parent, 'Y-m-d-H-i-s') : '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('on_comment_update', array($P, $P));
            Weapon::fire('on_comment_construct', array($P, $P));
            if ($config->comment_notification_email) {
                $mail = '<p>' . Config::speak('comment_notification', $article->url . '#' . sprintf($comment_id, Date::format($id, 'U'))) . '</p>';
                $mail .= '<p><strong>' . $name . ':</strong></p>';
                $mail .= $parser !== 'HTML' ? Text::parse($message, '->html') : $message;
                $mail .= '<p>' . Date::format($id, 'Y/m/d H:i:s') . '</p>';
                // Sending email notification ...
                if (!Guardian::happy()) {
                    if (Notify::send($request['email'], $config->author_email, $speak->comment_notification_subject, $mail, 'comment:')) {
                        Weapon::fire('on_comment_notification_construct', array($request, $config->author_email, $speak->comment_notification_subject, $mail));
                    }
                }
            }
            Guardian::kick($config->url_current . (!Guardian::happy() && $config->comment_moderation ? '#' . $comment_form_id : '#' . sprintf($comment_id, Date::format($id, 'U'))));
        } else {
            Guardian::kick($config->url_current . '#' . $comment_form_id);
        }
    }
});
Exemple #13
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);
 }
Exemple #14
0
    ?>
  <?php 
} else {
    ?>
  <p><?php 
    echo Config::speak('notify_not_available', $speak->config);
    ?>
</p>
  <?php 
}
?>
  </div>
  <div class="tab-content hidden" id="tab-content-2">
    <p class="about-author">
    <?php 
echo Cell::strong($speak->author . ':') . ' ' . Text::parse($file->author, '->encoded_html');
if (isset($file->url) && $file->url !== '#') {
    ?>
 <?php 
    echo Cell::a($file->url, Jot::icon('external-link-square'), '_blank', array('class' => array('about-url', 'help'), 'title' => $speak->link, 'rel' => 'nofollow'));
    ?>
    <?php 
}
?>
    </p>
    <h3 class="about-title"><?php 
echo $file->title;
if (isset($file->version)) {
    ?>
 <code class="about-version"><?php 
    echo $file->version;
Exemple #15
0
<?php

$hooks = array($files, $segment);
echo $messages;
if ($files) {
    ?>
<ul>
  <?php 
    foreach ($files as $file) {
        ?>
  <li><?php 
        echo ASSET . DS . File::path(Text::parse($file, '->decoded_url'));
        ?>
</li>
  <?php 
    }
    ?>
</ul>
<?php 
}
?>
<form class="form-kill form-asset" id="form-kill" action="<?php 
echo $config->url_current . str_replace('&', '&amp;', $config->url_query);
?>
" method="post">
  <?php 
Weapon::fire('action_before', $hooks);
?>
  <?php 
echo Jot::button('action', $speak->yes);
?>
Exemple #16
0
 sort($kind);
 // Check for duplicate slug, except for the current old slug.
 // Allow user(s) to change their post slug, but make sure they
 // do not type the slug of another post.
 if (trim($slug) !== "" && $slug !== $post->slug && ($files = call_user_func('Get::' . $segment . 's', 'DESC', "", 'txt,draft,archive'))) {
     if (strpos(implode('%', $files), '_' . $slug . '.') !== false) {
         Notify::error(Config::speak('notify_error_slug_exist', $slug));
         Guardian::memorize($request);
     }
     unset($files);
 }
 $P = array('data' => $request);
 if (!Notify::errors()) {
     include __DIR__ . DS . 'task.ignite.substance.php';
     include __DIR__ . DS . 'task.fields.php';
     $header = array('Title' => $title, 'Link' => $link, 'Description' => trim($description) !== "" ? Text::parse(trim($description), '->encoded_json') : false, 'Author' => $author, 'Content Type' => Request::post('content_type', 'HTML'), 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false);
     $_ = POST . DS . $segment . DS . Date::slug($date) . '_' . implode(',', $kind) . '_' . $slug . $extension;
     // Ignite
     if (!$id) {
         Page::header($header)->content($content)->saveTo($_);
         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);
             Weapon::fire(array('on_custom_update', 'on_custom_construct'), array($G, $P));
         }
         // Repair
     } else {
         Page::header($header)->content($content)->saveTo($post->path);
         File::open($post->path)->renameTo(File::B($_));
         $custom_ = CUSTOM . DS . Date::slug($post->date->W3C);
         if (file_exists($custom_ . $extension_o)) {
             Weapon::fire('on_custom_update', array($G, $P));
Exemple #17
0
            }
        }
        // Check for duplicate slug
        foreach (array_count_values($request['slug']) as $slug => $count) {
            if (trim($slug) !== "" && $count > 1) {
                Notify::error(Config::speak('notify_invalid_duplicate', strtolower($speak->slug)));
                break;
            }
        }
        if (!Notify::errors()) {
            $data = array();
            $keys = $request['id'];
            for ($i = 0, $count = count($keys); $i < $count; ++$i) {
                if (trim($request['name'][$i]) !== "" && trim($request['id'][$i]) !== "" && is_numeric($request['id'][$i])) {
                    $slug = trim($request['slug'][$i]) !== "" ? $request['slug'][$i] : $request['name'][$i];
                    $data[$i] = array('id' => (int) $keys[$i], 'name' => $request['name'][$i], 'slug' => Text::parse($slug, '->slug'), 'description' => $request['description'][$i]);
                }
            }
            $P = array('data' => $data);
            File::serialize($data)->saveTo(STATE . DS . 'tag.txt', 0600);
            Notify::success(Config::speak('notify_success_updated', $speak->tags));
            Weapon::fire('on_tag_update', array($G, $P));
        }
        Guardian::kick($config->url_current);
    }
    Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
        echo '<script>
(function($, base) {
    base.add(\'on_row_increase\', function() {
        $(\'input[name="id[]"]\').last().val(parseInt($(\'input[name="id[]"]\').last().closest(\'tr\').prev().find(\'input[name="id[]"]\').val(), 10) + 1 || "");
        $(\'input[name="name[]"]\').each(function() {
Exemple #18
0
<?php 
if ($page->css) {
    ?>
<pre><code><?php 
    echo substr(Text::parse($page->css, '->encoded_html'), 0, $config->excerpt->length);
    if (strlen($page->css) > $config->excerpt->length) {
        echo $config->excerpt->suffix;
    }
    ?>
</code></pre>
<?php 
}
if ($page->js) {
    ?>
<pre><code><?php 
    echo substr(Text::parse($page->js, '->encoded_html'), 0, $config->excerpt->length);
    if (strlen($page->js) > $config->excerpt->length) {
        echo $config->excerpt->suffix;
    }
    ?>
</code></pre>
<?php 
}
?>
<form class="form-kill form-<?php 
echo $segment;
?>
" id="form-kill" action="<?php 
echo $config->url_current . $config->url_query;
?>
" method="post">
    $htaccess = ASSET . DS . '__snippet' . DS . '.htaccess';
    if (!File::exist($htaccess)) {
        File::write('deny from all')->saveTo($htaccess, 0600);
    }
    Config::set(array('page_title' => $speak->snippets . $config->title_separator . $config->manager->title, 'cargo' => __DIR__ . DS . 'cargo.snippet.php'));
    Shield::lot(array('segment' => 'snippet'))->attach('manager');
});
Route::post($config->manager->slug . '/snippet/ignite', function () use($config, $speak) {
    $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);
    }
Exemple #20
0
<?php

Weapon::add('on_comment_construct', function ($G, $P) use($config, $speak) {
    if ($config->is->post && ($post = $G['data'][$config->page_type])) {
        $c = $config->states->{'plugin_' . md5(File::B(__DIR__))};
        $title = $post['title'];
        $url = $post['url'] . '#' . sprintf($G['data']['comment_id'], Date::format($P['data']['id'], 'U'));
        $topic = sprintf($c->subject, $title, $url);
        $parser = Request::post('content_type', $config->html_parser->active);
        $message = '<blockquote><p>' . sprintf($c->message, $title, $url) . '</p></blockquote>';
        $message .= '<h3>' . $P['data']['name'] . '</h3>';
        $message .= $parser !== false && $parser !== 'HTML' ? Text::parse($P['data']['message'], '->html') : $P['data']['message'];
        $message .= '<p>';
        $message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/repair/id:' . $P['data']['id'] . '">' . $speak->edit . '</a>';
        $message .= ' / ';
        $message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/kill/id:' . $P['data']['id'] . '">' . $speak->delete . '</a>';
        $message .= '</p>';
        // Sending email notification ...
        if (!Guardian::happy() && Notify::send($P['data']['email'], $config->author->email, $topic, $message, 'comment:')) {
            Weapon::fire('on_comment_notify_construct', array($P, $config->author->email, $topic, $message));
        }
    }
});
Exemple #21
0
     $path = $content = $_file = false;
     $title = $speak->creating . ': ' . $speak->shield . $config->title_separator . $config->manager->title;
 } else {
     $path = File::path($file);
     if (!($_file = File::exist($_folder . DS . $path))) {
         Shield::abort();
         // File not found!
     }
     $content = File::open($_file)->read();
     $title = $speak->editing . ': ' . File::B($file) . $config->title_separator . $config->manager->title;
 }
 $G = array('data' => array('path' => $_file, 'name' => $path, 'content' => $content));
 Config::set(array('page_title' => $title, 'cargo' => 'repair.shield.php'));
 if ($request = Request::post()) {
     Guardian::checkToken($request['token']);
     $name = Text::parse(File::path($request['name']), '->safe_path_name');
     if (trim($request['name']) === "") {
         Notify::error(Config::speak('notify_error_empty_field', $speak->name));
     } else {
         if ($path !== $name && File::exist($_folder . DS . $name)) {
             Notify::error(Config::speak('notify_file_exist', '<code>' . $name . '</code>'));
         }
         if (($e = File::E($name)) !== "") {
             if (strpos(',' . SCRIPT_EXT . ',', ',' . $e . ',') === false) {
                 Notify::error(Config::speak('notify_error_file_extension', $e));
             }
         } else {
             // Missing file extension
             Notify::error($speak->notify_error_file_extension_missing);
         }
     }
Exemple #22
0
 /**
  * ==========================================================
  *  GET SHIELD INFO
  * ==========================================================
  *
  * -- CODE: -------------------------------------------------
  *
  *    var_dump(Shield::info('normal'));
  *
  * ----------------------------------------------------------
  *
  */
 public static function info($folder = null, $array = false)
 {
     $config = Config::get();
     $speak = Config::speak();
     if (is_null($folder)) {
         $folder = $config->shield;
     }
     // Check whether the localized "about" file is available
     if (!($info = File::exist(SHIELD . DS . $folder . DS . 'about.' . $config->language . '.txt'))) {
         $info = SHIELD . DS . $folder . DS . 'about.txt';
     }
     $d = 'Title' . S . ' ' . Text::parse($folder, '->title') . "\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($d), 'content', 'shield:', array('id' => File::exist(SHIELD . DS . $folder) ? $folder : false));
     return $array ? $info : Mecha::O($info);
 }
Exemple #23
0
 * ===================================================================
 *  APPLY FILTER WITH PREFIX
 * ===================================================================
 *
 * -- CODE: ----------------------------------------------------------
 *
 *    Filter::colon('page:title', $content);
 *
 *    // is equal to ...
 *
 *    Filter::apply(array('page:title', 'title'), $content);
 *
 * -------------------------------------------------------------------
 *
 */
Filter::plug('colon', function ($name, $value) {
    $arguments = func_get_args();
    if (strpos($name, ':') !== false) {
        $s = explode(':', $name, 2);
        $arguments[0] = array($name, $s[1]);
    }
    return call_user_func_array('Filter::apply', $arguments);
});
// Set response, comment and user `status` as `pilot`, `passenger` and `intruder`
Filter::add(array('response:status', 'comment:status', 'user:status'), function ($status) {
    return Mecha::alter($status, array(0 => 'intruder', 1 => 'pilot', 2 => 'passenger'));
}, 1);
// Decode the obfuscated `email` value
Filter::add(array('response:email', 'comment:email', 'user:email'), function ($data) {
    return Text::parse($data, '->decoded_html');
}, 1);
Exemple #24
0
  <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">
      <span class="grid span-6">
        <?php 
echo Form::textarea('url', $url, '[' . Text::parse($config->title, '->slug') . ']: &lt;' . $config->url . '&gt; &quot;' . Text::parse($config->title, '->encoded_html') . '&quot;', array('class' => array('textarea-block', 'textarea-expand', 'code')));
?>
      </span>
    </label>
  </fieldset>
  <p><?php 
echo Jot::button('action', $speak->update);
?>
</p>
</form>
Exemple #25
0
 public static function upload($file, $destination = ROOT, $callback = null)
 {
     $config = Config::get();
     $speak = Config::speak();
     $destination = self::path($destination);
     $errors = Mecha::A($speak->notify_file);
     // Create a safe file name
     $file['name'] = Text::parse($file['name'], '->safe_file_name');
     $extension = self::E($file['name']);
     // Something goes wrong
     if ($file['error'] > 0 && isset($errors[$file['error']])) {
         Notify::error($errors[$file['error']]);
     } else {
         // Destination not found
         if (!file_exists($destination)) {
             self::pocket($destination);
         }
         // Unknown file type
         if (!isset($file['type']) || empty($file['type'])) {
             Notify::error($speak->notify_error_file_type_unknown);
         }
         // Bad file extension
         $extension_allow = ',' . implode(',', self::$config['file_extension_allow']) . ',';
         if (strpos($extension_allow, ',' . $extension . ',') === false) {
             Notify::error(Config::speak('notify_error_file_extension', $extension));
         }
         // Too small
         if ($file['size'] < self::$config['file_size_min_allow']) {
             Notify::error(Config::speak('notify_error_file_size_min', self::size(self::$config['file_size_min_allow'], 'KB')));
         }
         // Too large
         if ($file['size'] > self::$config['file_size_max_allow']) {
             Notify::error(Config::speak('notify_error_file_size_max', self::size(self::$config['file_size_max_allow'], 'KB')));
         }
     }
     if (!Notify::errors()) {
         // Move the uploaded file to the destination folder
         if (!file_exists($destination . DS . $file['name'])) {
             move_uploaded_file($file['tmp_name'], $destination . DS . $file['name']);
         } else {
             Notify::error(Config::speak('notify_file_exist', '<code>' . $file['name'] . '</code>'));
         }
         if (!Notify::errors()) {
             // Create public asset link to show on file uploaded
             $link = self::url($destination) . '/' . $file['name'];
             Notify::success(Config::speak('notify_file_uploaded', '<code>' . $file['name'] . '</code>'));
             self::$open = $destination . DS . $file['name'];
             if (is_callable($callback)) {
                 call_user_func($callback, $file['name'], $file['type'], $file['size'], $link);
             }
         }
         return new static();
     }
     return false;
 }
Exemple #26
0
function do_meta_2()
{
    $config = Config::get();
    $html = Cell::title(Text::parse($config->page_title, '->text'), array(), 2) . NL;
    $html .= Cell::__('[if IE]>' . Cell::script($config->protocol . 'html5shiv.googlecode.com/svn/trunk/html5.js') . '<![endif]', 2, "") . NL;
    echo Filter::apply('meta', $html, 2);
}
Exemple #27
0
        Shield::attach('index-search');
    } else {
        $_404 = (object) array('title' => $title, 'content' => $speak->notify_error_not_found);
        Config::set(array('page_title' => $title . $config->title_separator . $config->title, 'search_query' => $query, 'offset' => $offset, 'article' => $_404, 'page' => $_404));
        Session::kill('search.query');
        Session::kill('search.results');
        Shield::abort('404-search');
    }
}, 60);
/**
 * Ignite Search ...
 * -----------------
 */
Route::accept($config->search->slug, function () use($config) {
    if ($q = strip_tags(Request::post('q', ""))) {
        Guardian::kick($config->search->slug . '/' . Text::parse($q, '->encoded_url'));
    }
    Guardian::kick();
}, 61);
/**
 * Article Page
 * ------------
 *
 * [1]. article/article-slug
 *
 */
Route::accept($config->index->slug . '/(:any)', function ($slug = "") use($config, $speak) {
    if (!($article = Get::article($slug))) {
        Shield::abort('404-article');
    }
    if ($article->state === 'drafted') {
 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);
                 }
             }
         }
     }
 }
    <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 
}
?>
  </div>
  <div class="grid span-2">
    <h4><i class="fa fa-users"></i> <?php 
Exemple #30
0
            $_path = ASSET . DS . $v;
            File::open($_path)->delete();
            return $_path;
        });
        $is_folder_or_file = count($deletes) === 1 && is_dir(ASSET . DS . $deletes[0]) ? 'folder' : 'file';
        $P = array('data' => array('files' => $info_path));
        Notify::success(Config::speak('notify_' . $is_folder_or_file . '_deleted', '<code>' . implode('</code>, <code>', $deletes) . '</code>'));
        Weapon::fire(array('on_asset_update', 'on_asset_destruct'), array($P, $P));
        Guardian::kick($config->manager->slug . '/asset/1' . str_replace('&', '&amp;', HTTP::query('path', $p)));
    } else {
        Notify::warning(count($deletes) === 1 ? Config::speak('notify_confirm_delete_', '<code>' . File::path($name) . '</code>') : $speak->notify_confirm_delete);
    }
    Shield::lot(array('segment' => 'asset', 'files' => Mecha::O($deletes)))->attach('manager');
});
/**
 * Multiple Asset Action
 * ---------------------
 */
Route::accept($config->manager->slug . '/asset/do', function ($path = "") use($config, $speak) {
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        if (!isset($request['selected'])) {
            Notify::error($speak->notify_error_no_files_selected);
            Guardian::kick($config->manager->slug . '/asset/1');
        }
        $files = Mecha::walk($request['selected'], function ($v) {
            return str_replace('%2F', '/', Text::parse($v, '->encoded_url'));
        });
        Guardian::kick($config->manager->slug . '/asset/' . $request['action'] . '/files:' . implode(';', $files));
    }
});