Esempio n. 1
0
    if (!Guardian::happy(1) && Guardian::get('author') !== $post->author) {
        Shield::abort();
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . $post->title . $config->title_separator . $config->manager->title, 'page' => $post, 'cargo' => 'kill.post.php'));
    $G = array('data' => Mecha::A($post));
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        File::open($post->path)->delete();
        // Deleting response(s) ...
        if ($responses = call_user_func('Get::' . $response . 's', 'DESC', 'post:' . $id, 'txt,hold')) {
            foreach ($responses as $v) {
                File::open($v)->delete();
            }
        }
        $P = array('data' => $request);
        include __DIR__ . DS . 'task.kill.substance.php';
        // Deleting custom CSS and JavaScript file of post ...
        File::open(CUSTOM . DS . Date::slug($id) . '.txt')->delete();
        File::open(CUSTOM . DS . Date::slug($id) . '.draft')->delete();
        Weapon::fire(array('on_custom_update', 'on_custom_destruct'), array($G, $P));
        // Deleting custom PHP file of post ...
        File::open(File::D($post->path) . DS . $post->slug . '.php')->delete();
        Notify::success(Config::speak('notify_success_deleted', $post->title));
        Weapon::fire(array('on_' . $segment . '_update', 'on_' . $segment . '_destruct'), array($G, $G));
        Guardian::kick($config->manager->slug . '/' . $segment);
    } else {
        Notify::warning(Config::speak('notify_confirm_delete_', '<strong>' . $post->title . '</strong>'));
        Notify::warning(Config::speak('notify_confirm_delete_page', strtolower($speak->{$segment}), strtolower($speak->{$response . 's'})));
    }
    Shield::lot(array('segment' => $segment))->attach('manager');
});
Esempio n. 2
0
    <?php 
Weapon::fire('SHIPMENT_REGION_TOP');
?>
    <?php 
Weapon::fire('shell_before');
?>
    <?php 
echo Asset::stylesheet(array($config->protocol . ICON_LIBRARY_PATH, 'assets/shell/atom.css', 'assets/shell/layout.css'));
?>
    <?php 
Weapon::fire('shell_after');
?>
  </head>
  <body>
    <?php 
Weapon::fire('cargo_before');
?>
    <div class="blog-wrapper">
      <header class="blog-header">
        <?php 
if ($config->url_current == $config->url) {
    ?>
        <h1 class="blog-title"><?php 
    echo $config->title;
    ?>
</h1>
        <?php 
} else {
    ?>
        <h1 class="blog-title"><a href="<?php 
    echo $config->url;
Esempio n. 3
0
?>
  <?php 
Shield::chunk('comment.form.message');
?>
  <?php 
Weapon::fire('comment_form_textarea_after', $hooks);
?>
  <?php 
Shield::chunk('comment.form.math');
?>
  <div class="grid-group">
    <span class="grid span-1"></span>
    <div class="grid span-5">
      <p>
        <?php 
Weapon::fire('comment_form_button_before', $hooks);
?>
        <?php 
echo Form::button($speak->publish, null, 'submit', null, array('class' => array('btn', 'btn-construct')));
?>
        <?php 
Weapon::fire('comment_form_button_after', $hooks);
?>
      </p>
      <p><?php 
echo $speak->comment_wizard;
?>
</p>
    </div>
  </div>
</form>
Esempio n. 4
0
<?php

/**
 * Shortcode Manager
 * -----------------
 */
Route::accept($config->manager->slug . '/shortcode', function () use($config, $speak) {
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    $shortcodes = Get::state_shortcode(null, array(), false);
    $G = array('data' => $shortcodes);
    Config::set(array('page_title' => $speak->shortcodes . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.shortcode.php'));
    if ($request = Request::post()) {
        $request = Filter::apply('request:__shortcode', $request);
        Guardian::checkToken($request['token']);
        $data = array();
        for ($i = 0, $keys = $request['key'], $count = count($keys); $i < $count; ++$i) {
            if (trim($keys[$i]) !== "") {
                $data[$keys[$i]] = $request['value'][$i];
            }
        }
        $P = array('data' => $data);
        File::serialize($data)->saveTo(STATE . DS . 'shortcode.txt', 0600);
        Notify::success(Config::speak('notify_success_updated', $speak->shortcode));
        Weapon::fire('on_shortcode_update', array($G, $P));
        Guardian::kick($config->url_current);
    }
    Shield::lot(array('segment' => 'shortcode', 'files' => Mecha::O($shortcodes)))->attach('manager');
});
Esempio n. 5
0
        <time datetime="<?php 
        echo $page->date->W3C;
        ?>
"><?php 
        echo $page->date->FORMAT_3;
        ?>
</time>
      </span>
    </div>
    <div class="page-body"><?php 
        echo $page->description;
        ?>
</div>
    <div class="page-footer">
      <?php 
        Weapon::fire('page_footer', array($page));
        ?>
    </div>
  </li>
  <?php 
    }
    ?>
</ol>
<?php 
    include DECK . DS . 'workers' . DS . 'unit.pager.1.php';
} else {
    ?>
<p><?php 
    echo Config::speak('notify_empty', strtolower($speak->pages));
    ?>
</p>
Esempio n. 6
0
    $route_cache = $cache_config['path'][$config->url_path];
} else {
    foreach ($cache_config['path'] as $path => $exp) {
        if (Route::is($path)) {
            $route_cache = $exp;
            break;
        }
    }
}
if ($route_cache !== false) {
    Weapon::add('shield_before', function () use($config, $route_cache) {
        $q = !empty($config->url_query) ? '.' . md5($config->url_query) : "";
        $cache = CACHE . DS . str_replace(array('/', ':'), '.', $config->url_path) . $q . '.cache';
        $time = file_exists($cache) ? filemtime($cache) : false;
        if ($time !== false && ($route_cache === true || time() - $route_cache * 60 * 60 < $time)) {
            $content = file_get_contents($cache);
            if (strpos($content, '<?xml ') === 0 || strpos($content, '</html>') !== false) {
                $content .= '<!-- cached: ' . date('Y-m-d H:i:s', $time) . ' -->';
            }
            $content = Filter::apply('cache:input', $content);
            $content = Filter::apply('cache:output', $content);
            echo $content;
            exit;
        }
        Weapon::add('shield_after', function ($G) use($cache) {
            $G['data']['cache'] = $cache;
            File::write($G['data']['content'])->saveTo($cache);
            Weapon::fire('on_cache_construct', array($G, $G));
        });
    });
}
Esempio n. 7
0
<?php

$custom_ = CUSTOM . DS . Date::format($task_connect_page->date->W3C, 'Y-m-d-H-i-s');
if (file_exists($custom_ . $extension_o)) {
    Weapon::fire('on_custom_update', array($G, $P));
    if (trim(File::open($custom_ . $extension_o)->read()) === "" || trim(File::open($custom_ . $extension_o)->read()) === SEPARATOR || empty($css) && empty($js) || $css === $task_connect_page_css && $js === $task_connect_page_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 {
        Page::content($css)->content($js)->saveTo($custom_ . $extension_o);
        File::open($custom_ . $extension_o)->renameTo(Date::format($date, 'Y-m-d-H-i-s') . $extension);
        Weapon::fire('on_custom_repair', array($G, $P));
    }
} else {
    if (!empty($css) && $css !== $task_connect_page_css || !empty($js) && $js !== $task_connect_page_js) {
        Page::content($css)->content($js)->saveTo(CUSTOM . DS . Date::format($date, 'Y-m-d-H-i-s') . $extension_o);
        Weapon::fire('on_custom_update', array($G, $P));
        Weapon::fire('on_custom_construct', array($G, $P));
    }
}
Esempio n. 8
0
        <a href="<?php 
        echo $response->permalink;
        ?>
" title="<?php 
        echo $speak->permalink;
        ?>
" rel="nofollow" target="_blank">#</a>
      </span>
    </div>
    <div class="page-body"><?php 
        echo $response->message;
        ?>
</div>
    <div class="page-footer">
      <?php 
        Weapon::fire('comment_footer', array($response, $article = false));
        ?>
    </div>
  </li>
  <?php 
    }
    ?>
</ol>
<?php 
    include DECK . DS . 'workers' . DS . 'unit.pager.1.php';
} else {
    ?>
<p><?php 
    echo Config::speak('notify_empty', strtolower($speak->comments));
    ?>
</p>
Esempio n. 9
0
<?php

// Deleting substance(s)
if (isset($task_connect->fields) && is_object($task_connect->fields)) {
    foreach ($task_connect->fields as $field) {
        $file = SUBSTANCE . DS . $field;
        if (file_exists($file) && is_file($file)) {
            File::open($file)->delete();
            Weapon::fire('on_substance_update', array($G, $P));
            Weapon::fire('on_substance_destruct', array($G, $P));
        }
    }
}
Esempio n. 10
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);
        }
    }
});
Esempio n. 11
0
<?php

/**
 * Menu Manager
 * ------------
 */
Route::accept($config->manager->slug . '/menu', function () use($config, $speak) {
    if (Guardian::get('status') !== 'pilot') {
        Shield::abort();
    }
    $menus = Get::state_menu();
    Config::set(array('page_title' => $speak->menus . $config->title_separator . $config->manager->title, 'cargo' => DECK . DS . 'workers' . DS . 'cargo.menu.php'));
    $G = array('data' => array('content' => $menus));
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        // Check for invalid input
        if (preg_match('#(^|\\n)(\\t| {1,3})(?:[^ ])#', $request['content'])) {
            Notify::error($speak->notify_invalid_indent_character);
            Guardian::memorize($request);
        }
        $P = array('data' => $request);
        if (!Notify::errors()) {
            File::write($request['content'])->saveTo(STATE . DS . 'menu.txt', 0600);
            Notify::success(Config::speak('notify_success_updated', $speak->menu));
            Weapon::fire('on_menu_update', array($G, $P));
            Guardian::kick($config->url_current);
        }
    }
    Shield::lot(array('segment' => 'menu', 'the_content' => $menus))->attach('manager', false);
});
Esempio n. 12
0
</h3>
      <?php 
$destinations = array(Jot::icon('file-text') . ' ' . $speak->article => ARTICLE, Jot::icon('file') . ' ' . $speak->page => PAGE, Jot::icon('magnet') . ' ' . $speak->extend => EXTEND, Jot::icon('comments') . ' ' . $speak->comment => COMMENT, Jot::icon('cogs') . ' ' . $speak->config => STATE, Jot::icon('briefcase') . ' ' . $speak->asset => ASSET, Jot::icon('shield') . ' ' . $speak->shield => SHIELD, Jot::icon('plug') . ' ' . $speak->plugin => PLUGIN);
?>
      <?php 
foreach ($destinations as $title => $destination) {
    ?>
      <div class="media no-capture">
        <h4 class="media-title"><?php 
    echo $title;
    ?>
</h4>
        <div class="media-content">
          <p><code><?php 
    echo $destination;
    ?>
</code></p>
          <?php 
    echo Jot::uploader($config->manager->slug . '/backup', 'zip', array('destination' => $destination, 'title' => trim(strip_tags($title))));
    ?>
        </div>
      </div>
      <?php 
}
?>
    </div>
    <?php 
Weapon::fire('tab_content_after', $hooks);
?>
  </div>
</div>
Esempio n. 13
0
echo '<link>' . $config->url . '/</link>';
echo '<description>' . $config->description . '</description>';
echo '<lastBuildDate>' . Date::format(time(), 'r') . '</lastBuildDate>';
echo '<atom:link rel="self" href="' . $config->url_current . '"/>';
echo $config->offset > 1 ? '<atom:link rel="previous" href="' . Filter::colon('feed:url', $url_base . '/' . ($config->offset - 1)) . '"/>' : "";
echo $config->offset < ceil($config->total_articles / $rss_limit) ? '<atom:link rel="next" href="' . Filter::colon('feed:url', $url_base . '/' . ($config->offset + 1)) . '"/>' : "";
Weapon::fire('rss_meta');
if (!empty($bucket)) {
    foreach ($bucket as $i => $item) {
        $title = strip_tags($item->title);
        $description = $item->description;
        $kind = Mecha::A($item->kind);
        echo '<item>';
        echo '<title><![CDATA[' . $title . ']]></title>';
        echo '<link>' . $item->url . '</link>';
        echo '<description><![CDATA[' . $description . ']]></description>';
        echo '<pubDate>' . Date::format($item->time, 'r') . '</pubDate>';
        echo '<guid>' . $item->url . '</guid>';
        if (!empty($kind)) {
            foreach ($kind as $k) {
                $tag = Get::articleTag($k);
                echo '<category domain="' . Filter::colon('tag:url', $config->url . '/' . $config->tag->slug . '/' . $tag->slug) . '">' . $tag->name . '</category>';
            }
        }
        echo '<source url="' . $item->url . '"><![CDATA[' . $config->title . ': ' . $title . ']]></source>';
        Weapon::fire('rss_item', array($item, $i));
        echo '</item>';
    }
}
echo '</channel>';
echo '</rss>';
Esempio n. 14
0
<?php

$bucket = array();
if ($config->total_pages > 0) {
    foreach (Get::pages() as $page) {
        list($time, $kind, $slug) = explode('_', File::N($page), 3);
        $bucket[] = (object) array('url' => $config->url . '/' . $slug, 'date' => Date::format($time, 'c'), 'changefreq' => 'weekly', 'priority' => (string) '0.5');
    }
}
if ($config->total_articles > 0) {
    foreach (Get::articles() as $article) {
        list($time, $kind, $slug) = explode('_', File::N($article), 3);
        $bucket[] = (object) array('url' => $config->url . '/' . $config->index->slug . '/' . $slug, 'date' => Date::format($time, 'c'), 'changefreq' => 'weekly', 'priority' => (string) '1.0');
    }
}
echo '<?xml version="1.0" encoding="UTF-8" ?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if (!empty($bucket)) {
    foreach ($bucket as $i => $item) {
        echo '<url>';
        echo '<loc>' . $item->url . '</loc>';
        echo '<lastmod>' . $item->date . '</lastmod>';
        echo '<changefreq>' . $item->changefreq . '</changefreq>';
        echo '<priority>' . $item->priority . '</priority>';
        Weapon::fire('sitemap_item', array($item, $i));
        echo '</url>';
    }
}
echo '</urlset>';
Esempio n. 15
0
 /**
  * ==========================================================
  *  RENDER A SHIELD CHUNK
  * ==========================================================
  *
  * -- CODE: -------------------------------------------------
  *
  *    Shield::chunk('header');
  *
  * ----------------------------------------------------------
  *
  *    Shield::chunk('header', array('title' => 'Yo!'));
  *
  * ----------------------------------------------------------
  *
  */
 public static function chunk($name, $fallback = false, $buffer = true)
 {
     $path__ = File::path($name);
     $G = array('data' => array('name' => $name));
     if (is_array($fallback)) {
         self::$lot = array_merge(self::$lot, $fallback);
         $fallback = false;
     }
     $path__ = Filter::apply('chunk:path', self::path($path__, $fallback));
     $G['data']['lot'] = self::$lot;
     $G['data']['path'] = $path__;
     $out = "";
     if ($path__) {
         // Begin chunk
         Weapon::fire('chunk_lot_before', array($G, $G));
         extract(Filter::apply('chunk:lot', self::$lot));
         Weapon::fire('chunk_lot_after', array($G, $G));
         Weapon::fire('chunk_before', array($G, $G));
         if ($buffer) {
             ob_start(function ($content) use($path__, &$out) {
                 $content = Filter::apply('chunk:input', $content, $path__);
                 $out = Filter::apply('chunk:output', $content, $path__);
                 return $out;
             });
             require $path__;
             ob_end_flush();
         } else {
             require $path__;
         }
         $G['data']['content'] = $out;
         // End chunk
         Weapon::fire('chunk_after', array($G, $G));
     }
 }
Esempio n. 16
0
                // 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)
 * ---------------
 */
foreach (Get::state_menu() as $key => $value) {
    Menu::add($key, $value);
}
/**
 * Handle Shortcode(s) in Content
 * ------------------------------
Esempio n. 17
0
<header class="post-header">
  <?php 
Shield::chunk('page.title.404');
?>
  <?php 
if (Weapon::exist('page_header')) {
    ?>
  <div><?php 
    Weapon::fire('page_header', array($page));
    ?>
</div>
  <?php 
}
?>
</header>
Esempio n. 18
0
<?php

$bucket = array();
$url_base = $config->url . '/feed/json';
$json_order = strtoupper(Request::get('order', 'DESC'));
$json_filter = Request::get('filter', "");
$json_limit = Request::get('chunk', 25);
if ($pages = Mecha::eat(Get::articles($json_order, $json_filter))->chunk($config->offset, $json_limit)->vomit()) {
    foreach ($pages as $path) {
        $bucket[] = Get::articleHeader($path);
    }
}
$json = array('meta' => array('generator' => 'Mecha ' . MECHA_VERSION, 'title' => $config->title, 'slogan' => $config->slogan, 'url' => array('home' => $config->url, 'previous' => $config->offset > 1 ? Filter::colon('feed:url', $url_base . '/' . ($config->offset - 1)) : null, 'next' => $config->offset < ceil($config->total_articles / $json_limit) ? Filter::colon('feed:url', $url_base . '/' . ($config->offset + 1)) : null), 'description' => $config->description, 'update' => date('c'), 'author' => (array) $config->author, 'offset' => $config->offset, 'total' => $config->total_articles, 'tags' => Get::articleTags()), 'item' => null);
if (!empty($bucket)) {
    $json['item'] = array();
    foreach ($bucket as $i => $item) {
        $json['item'][$i] = array('title' => $item->title, 'url' => $item->url, 'date' => $item->date->W3C, 'update' => Date::format($item->update, 'c'), 'id' => $item->id, 'description' => $item->description, 'kind' => Mecha::A($item->kind));
        Weapon::fire('json_item', array(&$json['item'][$i], $item, $i));
    }
}
Weapon::fire('json_meta', array(&$json['meta']));
echo (isset($_GET['callback']) ? $_GET['callback'] . '(' : "") . json_encode($json) . (isset($_GET['callback']) ? ');' : "");
Esempio n. 19
0
<?php

foreach ($field as $k => $v) {
    $f = $v['type'] === 'file' || $v['type'] === 'f';
    // Remove asset field value and data
    if (isset($v['remove']) && $f) {
        File::open(SUBSTANCE . DS . $v['remove'])->delete();
        Weapon::fire(array('on_substance_update', 'on_substance_destruct'), array($G, $P));
        Notify::success(Config::speak('notify_file_deleted', '<code>' . $v['remove'] . '</code>'));
        unset($field[$k]);
    }
    // Remove empty field value
    if (!isset($v['value']) || $v['value'] === "") {
        unset($field[$k]);
    } else {
        $e = File::E($v['value']);
        if (!file_exists(SUBSTANCE . DS . $e . DS . $v['value']) && $f) {
            unset($field[$k]);
        } else {
            $field[$k] = $v['value'];
        }
    }
}
Esempio n. 20
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);
                 }
             }
         }
     }
 }
Esempio n. 21
0
        }
    }
    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 {
        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);
Esempio n. 22
0
        } 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, 'cargo' => 'kill.asset.php'));
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        $info_path = Mecha::walk($deletes, function ($v) {
            $_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);
Esempio n. 23
0
<?php

/**
 * Error Log
 * ---------
 */
Route::accept($config->manager->slug . '/error', function () use($config, $speak) {
    Config::set(array('page_title' => $speak->errors . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.error.php'));
    Shield::lot(array('segment' => 'error', 'content' => File::open(ini_get('error_log'))->read(false)))->attach('manager');
});
/**
 * Error Log Killer
 * ----------------
 */
Route::accept($config->manager->slug . '/error/kill', function () use($config, $speak) {
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    $errors = LOG . DS . 'errors.log';
    $G = array('data' => array('content' => File::open($errors)->read()));
    File::open($errors)->delete();
    Weapon::fire('on_error_destruct', array($G, $G));
    Notify::success(Config::speak('notify_success_deleted', $speak->file));
    Guardian::kick(File::D($config->url_current));
});
Esempio n. 24
0
            Notify::success(Config::speak('notify_file_deleted', '<code>' . File::B($_file) . '</code>'));
        } else {
            Notify::success(Config::speak('notify_success_deleted', $speak->shield));
        }
        Weapon::fire(array('on_shield_update', 'on_shield_destruct'), array($P, $P));
        Guardian::kick($config->manager->slug . '/shield' . ($_file !== false ? '/' . $folder : ""));
    } else {
        Notify::warning(Config::speak('notify_confirm_delete_', $file !== false ? '<code>' . $path . '</code>' : '<strong>' . $info->title . '</strong>'));
    }
    Shield::lot(array('segment' => 'shield', 'folder' => $folder, 'files' => Mecha::O(Get::files(SHIELD . DS . $folder, '*')), 'path' => $path))->attach('manager');
});
/**
 * Shield Attacher
 * ---------------
 */
Route::accept($config->manager->slug . '/shield/(attach|eject)/id:(:any)', function ($path = "", $slug = "") use($config, $speak) {
    if (!Guardian::happy(1) || !file_exists(SHIELD . DS . $slug)) {
        Shield::abort();
    }
    $new_config = Get::state_config();
    $new_config['shield'] = $path === 'attach' ? $slug : 'normal';
    File::serialize($new_config)->saveTo(STATE . DS . 'config.txt', 0600);
    $G = array('data' => array('id' => $slug, 'action' => $path));
    $mode = $path === 'eject' ? 'eject' : 'mount';
    Notify::success(Config::speak('notify_success_updated', $speak->shield));
    Weapon::fire(array('on_shield_update', 'on_shield_' . $mode, 'on_shield_' . md5($slug) . '_update', 'on_shield_' . md5($slug) . '_' . $mode), array($G, $G));
    foreach (glob(LOG . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) {
        File::open($asset_cache)->delete();
    }
    Guardian::kick($config->manager->slug . '/shield/' . $slug);
});
Esempio n. 25
0
    if ($articles = Mecha::eat($s)->chunk(1, $config->index->per_page)->vomit()) {
        $articles = Mecha::walk($articles, function ($path) use($excludes) {
            return Get::article($path, $excludes);
        });
    } else {
        $articles = false;
    }
    Filter::add('pager:url', function ($url) {
        return Filter::apply('index:url', $url);
    });
    Config::set(array('articles' => $articles, 'pagination' => Navigator::extract($s, 1, $config->index->per_page, $config->index->slug)));
    Shield::attach('page-home');
}, 110);
/**
 * Route Hook: after
 * -----------------
 */
Weapon::fire('routes_after');
/**
 * Do Routing
 * ----------
 */
Route::execute();
/**
 * 404 Page
 * --------
 *
 * Fallback to 404 page if nothing matched.
 *
 */
Shield::abort();
Esempio n. 26
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));
        }
    }
});
Esempio n. 27
0
/**
 * Shield Attacher
 * ---------------
 */
Route::accept($config->manager->slug . '/shield/(attach|eject)/id:(:any)', function ($path = "", $slug = "") use($config, $speak) {
    $new_config = Get::state_config();
    $new_config['shield'] = $path === 'attach' ? $slug : 'normal';
    File::serialize($new_config)->saveTo(STATE . DS . 'config.txt', 0600);
    $G = array('data' => array('id' => $slug, 'action' => $path));
    $mode = $path === 'eject' ? 'eject' : 'mount';
    Notify::success(Config::speak('notify_success_updated', $speak->shield));
    Weapon::fire('on_shield_update', array($G, $G));
    Weapon::fire('on_shield_' . $mode, array($G, $G));
    Weapon::fire('on_shield_' . md5($slug) . '_update', array($G, $G));
    Weapon::fire('on_shield_' . md5($slug) . '_' . $mode, array($G, $G));
    foreach (glob(SYSTEM . DS . 'log' . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) {
        File::open($asset_cache)->delete();
    }
    Guardian::kick($config->manager->slug . '/shield/' . $slug);
});
/**
 * Shield Backup
 * -------------
 */
Route::accept($config->manager->slug . '/shield/backup/id:(:any)', function ($folder = "") use($config, $speak) {
    $name = $folder . '.zip';
    Package::take(SHIELD . DS . $folder)->pack(ROOT . DS . $name, true);
    $G = array('data' => array('path' => ROOT . DS . $name, 'file' => ROOT . DS . $name));
    Weapon::fire('on_backup_construct', array($G, $G));
    Guardian::kick($config->manager->slug . '/backup/send:' . $name);
});
Esempio n. 28
0
<?php

if (Weapon::exist('article_footer')) {
    ?>
<div><?php 
    Weapon::fire('article_footer', array($article));
    ?>
</div>
<?php 
}
Esempio n. 29
0
      <td><?php 
echo Jot::em('info', $s);
?>
</td>
      <td><?php 
echo isset($file->scope) ? str_replace(',', '/', $file->scope) : '<em>' . $speak->all . '</em>';
?>
</td>
    </tr>
  </tbody>
</table>
<form class="form-kill form-field" id="form-kill" action="<?php 
echo $config->url_current;
?>
" method="post">
  <?php 
Weapon::fire('action_before', $hooks);
?>
  <?php 
echo Jot::button('action', $speak->yes);
?>
  <?php 
echo Jot::btn('reject', $speak->no, $config->manager->slug . '/field/repair/key:' . $id);
?>
  <?php 
Weapon::fire('action_after', $hooks);
?>
  <?php 
echo Form::hidden('token', $token);
?>
</form>
Esempio n. 30
0
                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() {
            $.slug($(this), $(this).parent().next().find(\'input\'), \'-\');
        });
    });
    base.fire(\'on_row_increase\');
})(window.Zepto || window.jQuery, DASHBOARD);
</script>';