コード例 #1
0
ファイル: route.page.php プロジェクト: razordaze/mecha-cms
            } else {
                Page::open($page->path)->header($header)->content($content)->save();
                File::open($page->path)->renameTo(Date::format($date, 'Y-m-d-H-i-s') . '__' . $slug . $extension);
                include DECK . DS . 'workers' . DS . 'task.custom.1.php';
                if ($page->slug !== $slug && ($php_file = File::exist(File::D($page->path) . DS . $page->slug . '.php'))) {
                    File::open($php_file)->renameTo($slug . '.php');
                }
                Notify::success(Config::speak('notify_success_updated', $title) . ($extension === '.txt' ? ' <a class="pull-right" href="' . $config->url . '/' . $slug . '" target="_blank"><i class="fa fa-eye"></i> ' . $speak->view . '</a>' : ""));
                Weapon::fire('on_page_update', array($G, $P));
                Weapon::fire('on_page_repair', array($G, $P));
                Guardian::kick($config->manager->slug . '/page/repair/id:' . Date::format($date, 'U'));
            }
        }
    }
    Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
        echo Asset::javascript('manager/assets/sword/editor.compose.js', "", 'sword/editor.compose.min.js');
    }, 11);
    Shield::lot(array('segment' => 'page', 'default' => $page))->attach('manager', false);
});
/**
 * Page Killer
 * -----------
 */
Route::accept($config->manager->slug . '/page/kill/id:(:num)', function ($id = "") use($config, $speak) {
    if (!($page = Get::page($id, array('comments')))) {
        Shield::abort();
    }
    if (Guardian::get('status') !== 'pilot' && Guardian::get('author') !== $page->author) {
        Shield::abort();
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . $page->title . $config->title_separator . $config->manager->title, 'page' => $page, 'cargo' => DECK . DS . 'workers' . DS . 'kill.page.php'));
コード例 #2
0
ファイル: launch.php プロジェクト: razordaze/mecha-cms
<?php

Weapon::add('meta', function () {
    $config = Config::get();
    $indent = str_repeat(TAB, 2);
    echo $indent . '<!-- Start Facebook Open Graph -->' . NL;
    echo $indent . '<meta property="og:title" content="' . strip_tags($config->page_title) . '"' . ES . NL;
    echo $indent . '<meta property="og:type" content="' . ($config->page_type == 'article' ? 'article' : 'website') . '"' . ES . NL;
    echo $indent . '<meta property="og:url" content="' . $config->url_current . '"' . ES . NL;
    if (isset($config->article->image)) {
        echo $indent . '<meta property="og:image" content="' . $config->article->image . '"' . ES . NL;
    } else {
        if (isset($config->page->image)) {
            echo $indent . '<meta property="og:image" content="' . $config->page->image . '"' . ES . NL;
        }
    }
    echo $indent . '<meta property="og:site_name" content="' . $config->title . '"' . ES . NL;
    if (isset($config->article->description)) {
        echo $indent . '<meta property="og:description" content="' . strip_tags($config->article->description) . '"' . ES . NL;
    } else {
        if (isset($config->page->description)) {
            echo $indent . '<meta property="og:description" content="' . strip_tags($config->page->description) . '"' . ES . NL;
        } else {
            echo $indent . '<meta property="og:description" content="' . strip_tags($config->description) . '"' . ES . NL;
        }
    }
    echo $indent . '<!-- End Facebook Open Graph -->' . NL;
}, 11);
コード例 #3
0
ファイル: launch.php プロジェクト: AdeHaze/mecha-cms
            $text_kill = Config::speak('manager._this_', array($speak->delete, $text));
            $bars[$text] = array('icon' => 'plus', 'url' => $config->manager->slug . '/' . $type . '/ignite', 'description' => Config::speak('manager.title_new_', $text), 'stack' => 9.029999999999999);
            $bars[$speak->edit] = array('icon' => 'pencil', 'url' => $config->manager->slug . '/' . $type . '/repair/id:' . $id, 'description' => $text_repair, 'stack' => 9.039999999999999);
            $bars[$speak->delete] = array('icon' => 'times', 'url' => $config->manager->slug . '/' . $type . '/kill/id:' . $id, 'description' => $text_kill, 'stack' => 9.050000000000001);
        } else {
            $link = Cell::a($config->manager->slug . '/article/ignite', Config::speak('manager.title_new_', $speak->article));
            $link .= ' &middot; ';
            $link .= Cell::a($config->manager->slug . '/page/ignite', Config::speak('manager.title_new_', $speak->page));
            $bars[$speak->add] = array('icon' => 'plus', 'url' => $config->manager->slug . '/article/ignite', 'description' => $link, 'stack' => 9.029999999999999);
        }
        Config::merge('manager_menu', $menus);
        Config::merge('manager_bar', $bars);
    });
}
// Loading frontend task(s) and route(s)
Weapon::add('routes_before', function () use($config, $speak) {
    require __DIR__ . DS . 'workers' . DS . 'task.comment.ignite.php';
    require __DIR__ . DS . 'workers' . DS . 'route.login.php';
});
// Add log in/out link in shield footer
function do_footer_manager_link($content, $path)
{
    global $config, $speak;
    if (File::N($path) === 'block.footer.bar') {
        $s = Guardian::happy() ? '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/logout') . '" rel="nofollow">' . $speak->log_out . '</a>' : '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/login') . '" rel="nofollow">' . $speak->log_in . '</a>';
        return str_replace('<div class="blog-footer-right">', '<div class="blog-footer-right">' . $s, $content);
    }
    return $content;
}
// Apply `do_footer_manager_link` filter
Filter::add('chunk:output', 'do_footer_manager_link');
コード例 #4
0
                        $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);
                    }
                }
            }
        }
    }
}
Weapon::add('shield_before', 'do_comment_construct', 1);
コード例 #5
0
ファイル: launch.php プロジェクト: AdeHaze/mecha-cms
<?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));
        }
    }
});
コード例 #6
0
ファイル: route.comment.php プロジェクト: yiannisSt/mecha-cms
<?php

$post = 'article';
$response = 'comment';
Weapon::add('tab_content_1_before', function ($page, $segment) use($config, $speak) {
    include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'response' . DS . 'post.php';
}, 0.9);
Weapon::add('tab_content_1_before', function ($page, $segment) use($config, $speak) {
    include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'response' . DS . 'status.php';
}, 3.1);
Weapon::add('tab_content_1_before', function ($page, $segment) use($config, $speak) {
    include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'response' . DS . 'parent.php';
}, 5.1);
require __DIR__ . DS . 'route.response.php';
コード例 #7
0
<?php

Weapon::add('shield_before', function () {
    $config = Config::get();
    if ($config->comments->allow) {
        $comment_service_config = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize();
        Config::set('plugins.comment_service_config', $comment_service_config);
        $active = $comment_service_config['service'];
        if ($s = Config::get($config->page_type)) {
            $active = isset($s->fields->comment_service) && trim($s->fields->comment_service) !== "" ? $s->fields->comment_service : $active;
        }
        if ($launch = File::exist(__DIR__ . DS . 'workers' . DS . $active . DS . 'launch.php')) {
            require $launch;
        }
        Filter::add('chunk:path', function ($path) use($active) {
            if ($active !== 0 && File::N($path) === 'comments') {
                return __DIR__ . DS . 'workers' . DS . $active . DS . 'comments.php';
            }
            return $path;
        });
    }
});
コード例 #8
0
ファイル: __launch.php プロジェクト: AdeHaze/mecha-cms
 * --------------
 */
// Add default article footer link(s)
Weapon::add('article_footer', function ($article) use($config, $speak) {
    $e = File::E($article->path);
    $comments = count(glob(COMMENT . DS . Date::slug($article->id) . '_*_*.{txt,hold}', GLOB_NOSORT | GLOB_BRACE));
    $t = Jot::icon('comments') . ' ' . $comments;
    $tt = array('title' => $comments . ' ' . ($comments === 1 ? $speak->comment : $speak->comments));
    $comments = ($e === 'draft' || $comments === 0 ? Cell::span($t, $tt) : Cell::a($config->manager->slug . '/comment?filter=post%3A' . $article->id, $t, null, $tt)) . ' &middot; ';
    $status = Mecha::alter($e, array('draft' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->draft) . ' &middot; ', 'archive' => Jot::span('info', Jot::icon('history') . ' ' . $speak->archive) . ' &middot; '), "");
    echo $comments . $status . Cell::a($config->manager->slug . '/article/repair/id:' . $article->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/article/kill/id:' . $article->id, $speak->delete);
}, 20);
// Add default page footer link(s)
Weapon::add('page_footer', function ($page) use($config, $speak) {
    $status = Mecha::alter(File::E($page->path), array('draft' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->draft) . ' &middot; ', 'archive' => Jot::span('info', Jot::icon('history') . ' ' . $speak->archive) . ' &middot; '), "");
    echo $status . Cell::a($config->manager->slug . '/page/repair/id:' . $page->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/page/kill/id:' . $page->id, $speak->delete);
}, 20);
/**
 * Backend Route(s)
 * ----------------
 *
 * Load the routes.
 *
 */
Weapon::add('plugins_after', function () use($config, $speak, $segment) {
    // loading cargo ...
    require __DIR__ . DS . 'workers' . DS . 'cargo.php';
    if ($detour = File::exist(__DIR__ . DS . 'workers' . DS . 'route.' . $segment . '.php')) {
        require $detour;
    }
}, 1);
コード例 #9
0
ファイル: route.shield.php プロジェクト: AdeHaze/mecha-cms
    $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));
    Notify::success(Config::speak('notify_success_updated', $speak->shield));
    foreach (glob(LOG . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) {
        File::open($asset_cache)->delete();
    }
    Guardian::kick($config->manager->slug . '/shield/' . $slug);
});
/**
 * Shield Updater (Base)
 * ---------------------
 */
if ($route = Route::is($config->manager->slug . '/shield/(:any)/update')) {
    Weapon::add('routes_before', function () use($config, $speak, $route) {
        if (!Route::accepted($route['path'])) {
            Route::accept($route['path'], function () use($config, $speak, $route) {
                if ($request = Request::post()) {
                    $s = $route['lot'][0];
                    $request = Filter::apply('request:__shield', $request, $s);
                    Guardian::checkToken($request['token']);
                    unset($request['token']);
                    // remove token from request array
                    File::serialize($request)->saveTo(SHIELD . DS . $s . DS . 'states' . DS . 'config.txt', 0600);
                    Notify::success(Config::speak('notify_success_updated', $speak->shield));
                    Guardian::kick(File::D($config->url_current));
                }
            });
        }
    }, 1);
}
コード例 #10
0
ファイル: launch.php プロジェクト: AdeHaze/mecha-cms
<?php

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;
}
Weapon::add('meta', 'do_facebook_open_graph', 11);
コード例 #11
0
ファイル: __launch.php プロジェクト: AdeHaze/mecha-cms
        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);
コード例 #12
0
ファイル: launch.php プロジェクト: yiannisSt/mecha-cms
<?php

Weapon::add('meta', function () {
    $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:type" content="' . ($config->page_type === 'article' ? 'article' : 'website') . '"' . ES . NL;
    echo $T2 . '<meta property="og:url" content="' . Filter::colon('og:url', $config->url_current) . '"' . 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;
    }
    echo $T2 . '<meta property="og:site_name" content="' . $config->title . '"' . 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;
    echo $T2 . '<!-- End Facebook Open Graph -->' . O_END;
}, 11);
コード例 #13
0
ファイル: route.plugin.php プロジェクト: yiannisSt/mecha-cms
<?php

// Refresh plugin(s) order cache on every update event
Weapon::add('on_plugin_update', function () {
    Plugin::reload();
});
/**
 * Plugin Manager
 * --------------
 */
Route::accept(array($config->manager->slug . '/plugin', $config->manager->slug . '/plugin/(:num)'), function ($offset = 1) use($config, $speak) {
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    $offset = (int) $offset;
    $destination = PLUGIN;
    if (isset($_FILES) && !empty($_FILES)) {
        Guardian::checkToken(Request::post('token'));
        include __DIR__ . DS . 'task.ignite.package.php';
        if (!Notify::errors()) {
            File::upload($_FILES['file'], $destination, function () use($speak) {
                Notify::clear();
                Notify::success(Config::speak('notify_success_uploaded', $speak->plugin));
            });
            if ($package = File::exist($destination . DS . $name)) {
                if (is_file($package)) {
                    Package::take($package)->extract();
                    // Extract the ZIP file
                    File::open($package)->delete();
                    // Delete the ZIP file
                    $P = array('data' => $_FILES);
コード例 #14
0
        $c->html_parser = (object) array('type' => array('HTML' => 'HTML'), 'active' => $c->html_parser);
    }
    $menus = Get::state_menu(null, false);
    if (!isset($menus['navigation'])) {
        $menus['navigation'] = $menus;
        File::serialize($menus)->saveTo(STATE . DS . 'menu.txt', 0600);
    }
    if ($tag = Get::state_tag(null, false)) {
        if (isset($tag[0]['id'])) {
            $tags = array();
            foreach ($tag as $t) {
                $tags[$t['id']] = array('name' => $t['name'], 'slug' => $t['slug'], 'description' => $t['description'], 'scope' => 'article');
            }
            File::serialize($tags)->saveTo(STATE . DS . 'tag.txt', 0600);
        }
    }
    if (is_string($c->author)) {
        $c->author = (object) array('name' => $c->author, 'email' => $c->author_email, 'url' => $c->author_profile_url);
        if ($c->page_type === 'manager') {
            Notify::info('<strong>1.2.0</strong> &mdash; In your <a href="' . $c->url . '/' . $c->manager->slug . '/shield">shield</a> files, change all <code>$c->author</code> data to <code>$c->author->name</code>, <code>$c->author_email</code> data to <code>$c->author->email</code> and <code>$c->author_profile_url</code> data to <code>$c->author->url</code>. Then go to the <a href="' . $c->url . '/' . $c->manager->slug . '/config">configuration manager page</a> to kill this message by pressing the <strong>Update</strong> button.');
        }
    }
    Config::set(Mecha::A($c));
    $config = $c;
}, 1);
Weapon::add('on_config_update', function () {
    // Self destruct ...
    File::open(__FILE__)->delete();
    Notify::clear();
    Notify::success(Config::speak('notify_success_updated', Config::speak('config')));
});
コード例 #15
0
ファイル: launch.php プロジェクト: yiannisSt/mecha-cms
<?php

if ($config->url_path === $config->manager->slug . '/article/ignite' || $config->url_path === $config->manager->slug . '/page/ignite' || $config->url_path === $config->manager->slug . '/comment/ignite' || strpos($config->url_path, $config->manager->slug . '/article/repair/id:') === 0 || strpos($config->url_path, $config->manager->slug . '/page/repair/id:') === 0 || strpos($config->url_path, $config->manager->slug . '/comment/repair/id:') === 0) {
    Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
        echo Asset::javascript(__DIR__ . DS . 'assets' . DS . 'sword' . DS . 'preview.js');
    });
    Weapon::add('tab_content_2_before', function ($page, $segment) use($config, $speak) {
        if (!is_array($segment)) {
            include __DIR__ . DS . 'workers' . DS . 'unit' . DS . 'form' . DS . '..._preview.php';
        }
    }, 0.9);
    Weapon::add('tab_content_after', function ($page, $segment) use($config, $speak) {
        include __DIR__ . DS . 'workers' . DS . 'unit' . DS . 'tab' . DS . 'content' . DS . 'preview.php';
    });
    Weapon::add('tab_button_after', function ($page, $segment) use($config, $speak) {
        include __DIR__ . DS . 'workers' . DS . 'unit' . DS . 'tab' . DS . 'button' . DS . 'preview.php';
    });
}
コード例 #16
0
ファイル: weapon.php プロジェクト: yiannisSt/mecha-cms
<?php

// Forget all memor(y|ies) on page visit ...
// Clear all notif(y|ies) on page visit ...
Weapon::add('shield_after', function () {
    Guardian::forget();
    Notify::clear();
});
コード例 #17
0
ファイル: route.page.php プロジェクト: yiannisSt/mecha-cms
<?php

$post = 'page';
$response = 'comment';
// Repair
if (strpos($config->url_path, '/id:') !== false) {
    Weapon::add('tab_button_before', function ($page, $segment) use($config, $speak) {
        include __DIR__ . DS . 'unit' . DS . 'tab' . DS . 'button' . DS . 'new.php';
    }, 0.9);
    Weapon::add('tab_content_1_before', function ($page, $segment) use($config, $speak) {
        include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'date.hidden.php';
    }, 0.9);
}
// You can't use index, tag, archive, search, manager and feed slug URL for page(s)
if ($slug = Request::post('slug')) {
    $s = array($config->index->slug => 1, $config->tag->slug => 1, $config->archive->slug => 1, $config->search->slug => 1, $config->manager->slug => 1, 'feed' => 1);
    if (isset($s[$slug])) {
        Notify::error(Config::speak('notify_error_slug_exist', $slug));
    }
}
require __DIR__ . DS . 'route.post.php';
コード例 #18
0
ファイル: route.response.php プロジェクト: AdeHaze/mecha-cms
    Config::set(array('page_title' => $speak->{$segment . 's'} . $config->title_separator . $config->manager->title, 'pages' => $responses, 'offset' => $offset, 'pagination' => Navigator::extract($files, $offset, $config->manager->per_page, $config->manager->slug . '/' . $segment), 'cargo' => 'cargo.response.php'));
    Shield::lot(array('segment' => array($segment, $post)))->attach('manager');
});
/**
 * Response Repairer/Igniter
 * -------------------------
 */
Route::accept(array($config->manager->slug . '/(' . $response . ')/ignite', $config->manager->slug . '/(' . $response . ')/repair/id:(:num)'), function ($segment = "", $id = false) use($config, $speak, $post) {
    $units = array('name', 'email', 'url', 'message', 'content_type');
    foreach ($units as $k => $v) {
        Weapon::add('tab_content_1_before', function ($page, $segment) use($config, $speak, $v) {
            include __DIR__ . DS . 'unit' . DS . 'form' . DS . $v . '.php';
        }, $k + 1);
    }
    Weapon::add('tab_content_2_before', function ($page, $segment) use($config, $speak) {
        $segment = $segment[0];
        include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'fields[].php';
    }, 1);
    File::write($config->{'__total_' . $segment . 's'})->saveTo(LOG . DS . $segment . 's.total.log', 0600);
    if ($id && ($response = call_user_func('Get::' . $segment, $id, array('message')))) {
        if (!Guardian::happy(1)) {
            Shield::abort();
        }
        $title = $speak->editing . ': ' . ($response->permalink !== '#' ? Cell::a($response->permalink, $speak->{$segment}, true) : $speak->{$segment}) . $config->title_separator . $config->manager->title;
    } else {
        if ($id !== false) {
            Shield::abort();
            // File not found!
        }
        $response = Mecha::O(array('id' => "", 'path' => "", 'post' => "", 'parent' => "", 'state' => 'pending', 'date' => array('W3C' => ""), 'name_raw' => Guardian::get('author'), 'email' => Guardian::get('email'), 'url_raw' => "", 'status_raw' => Guardian::get('status_raw'), 'content_type_raw' => $config->html_parser->active, 'fields_raw' => array(), 'message_raw' => ""));
        $title = Config::speak('manager.title_new_', $speak->{$segment}) . $config->title_separator . $config->manager->title;
    }
コード例 #19
0
ファイル: task.comment.php プロジェクト: razordaze/mecha-cms
Weapon::add('shield_before', function () use($config, $speak) {
    $comment_id = 'comment-%d';
    // Your comment ID
    $comment_form_id = 'comment-form';
    // Your comment form ID
    $article = isset(Config::get('article')->path) ? Get::article(Config::get('article')->path) : false;
    if ($article && $config->page_type === 'article' && Request::method('post')) {
        $request = Request::post();
        // Check token
        Guardian::checkToken($request['token'], $config->url_current . '#' . $comment_form_id);
        $extension = $config->comment_moderation && !Guardian::happy() ? '.hold' : '.txt';
        // Check name
        if (trim($request['name']) === "") {
            Notify::error(Config::speak('notify_error_empty_field', $speak->comment_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', '<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->comment_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->comment_name));
        }
        // Check email length
        if (Guardian::check($request['email'], '->too_long', 100)) {
            Notify::error(Config::speak('notify_error_too_long', $speak->comment_email));
        }
        // Check URL length
        if (Guardian::check($request['url'], '->too_long', 100)) {
            Notify::error(Config::speak('notify_error_too_long', $speak->comment_url));
        }
        // Check message length
        if (Guardian::check($request['message'], '->too_long', 1700)) {
            Notify::error(Config::speak('notify_error_too_long', $speak->comment_message));
        }
        // Check for spam keyword(s) in comment
        $fucking_words = explode(',', $config->spam_keywords);
        foreach ($fucking_words as $spam) {
            $f**k = trim($spam);
            if ($f**k !== "") {
                if ($request['email'] === $f**k || $f**k !== 'N/A' && Get::IP() === $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::format($article->time, 'Y-m-d-H-i-s');
            $id = (int) time();
            $parent = Request::post('parent');
            $P = array('data' => $request);
            $name = strip_tags($request['name']);
            $email = Text::parse($request['email'], '->broken_entity');
            $url = isset($request['url']) ? $request['url'] : false;
            $parser = strip_tags(Request::post('content_type', $config->html_parser));
            $message = $request['message'];
            $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);
        }
    }
});
コード例 #20
0
<?php

// include once ...
if (!Config::get('__js_google_plusone_1', false)) {
    Weapon::add('meta', function () {
        echo Asset::javascript('https://apis.google.com/js/plusone.js');
    }, 30);
    Config::set('__js_google_plusone_1', true);
}
コード例 #21
0
ファイル: ignite.php プロジェクト: yiannisSt/mecha-cms
Weapon::add('meta', 'do_meta_3', 30);
Weapon::add('SHIPMENT_REGION_TOP', function () {
    Weapon::fire('meta');
}, 10);
/**
 * Inject Widget's CSS and JavaScript
 * ----------------------------------
 */
if ($config->widget_include_css) {
    Weapon::add('shell_before', function () {
        echo Asset::stylesheet(SHIELD . DS . 'widgets.css', "", 'shell/widgets.min.css');
    });
}
if ($config->widget_include_js) {
    Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
        echo Asset::javascript(SHIELD . DS . 'widgets.js', "", 'sword/widgets.min.js');
    });
}
/**
 * Loading Plugin(s)
 * -----------------
 */
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();
コード例 #22
0
     global $config, $speak, $parent;
     $s = Asset::loaded($config->protocol . ICON_LIBRARY_PATH) ? '<i class="fa fa-times-circle"></i> ' : "";
     echo '&#32;<a href="' . $post->url . '" class="btn btn-reject btn-reject-reply"' . ($parent === false ? ' style="display:none;"' : "") . '>' . $s . $speak->cancel . '</a>';
 }
 Weapon::add('comment_footer', 'do_response_reply', 20.1);
 Weapon::add('comment_form_button_after', 'do_response_reply_x');
 Weapon::add('shell_before', 'do_response_reply_css');
 Weapon::add('SHIPMENT_REGION_BOTTOM', 'do_response_reply_js');
 // No JavaScript
 if ($parent !== false) {
     Guardian::memorize('parent', $parent);
     if ($response = Get::commentAnchor($parent)) {
         Weapon::add('chunk_before', function ($G) use($speak, $parent, $response) {
             if (File::N($G['data']['path']) === 'comment.form') {
                 $prefix = File::B(File::D($response->path));
                 $to = Config::speak($prefix . '_reply_to_', Cell::a('#' . $prefix . '-' . $parent, $response->name));
                 echo Cell::h4($to);
             }
         });
     }
 }
 // Error
 if ($s = Request::post('parent', false)) {
     Filter::add('guardian:kick', function ($url) use($config, $s) {
         if (!Notify::errors()) {
             return $url;
         }
         $ss = explode('#', $url, 2);
         return $config->url_current . HTTP::query('reply', $s) . '#' . $ss[1];
     });
 }
コード例 #23
0
<?php

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;
}
Weapon::add('meta', 'do_twitter_cards', 11);
コード例 #24
0
ファイル: route.tag.php プロジェクト: razordaze/mecha-cms
        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>';
    }, 11);
    Shield::lot('segment', 'tag')->attach('manager', false);
});
コード例 #25
0
ファイル: launch.php プロジェクト: yiannisSt/mecha-cms
    $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));
        });
    });
}
コード例 #26
0
<?php

if ($segment === 'asset' && strpos(Request::get('path', ""), '__snippet/') === 0) {
    Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
        echo '<script>!function(e,t,a){function n(e){var n=t.createElement("a"),l=e.getElementsByTagName("a")[0],r=l?l.href:!1;r&&!r.match(/[?&]path=/)&&r.match(/\\/__snippet\\/(txt|php)\\//)&&(r=r.replace(RegExp("^"+a.url.url+"\\/lot\\/assets\\/__snippet\\/((?:txt|php)\\/.*?)\\.[a-z]+$"),a.url.url+"/s/:$1"),r=r.replace(/:txt\\//,"print:"),r=r.replace(/:php\\//,"include:"),n.innerHTML=\'<i class="fa fa-share-alt"></i>\',n.href=r,n.target="_blank",e.appendChild(t.createTextNode(" ")),e.appendChild(n))}if("asset"===a.segment){var l=t.getElementsByClassName("form-asset");if(l){var r=l[0].getElementsByTagName("table");if(r){var s=r[0].getElementsByTagName("tr");if(s)for(var p=0,i=s.length;i>p;++p)n(s[p].children[2])}}}}(window,document,DASHBOARD);</script>';
    });
}
コード例 #27
0
ファイル: launch.php プロジェクト: yiannisSt/mecha-cms
    }
    if (isset($_GET['repair']) && Guardian::happy()) {
        Guardian::kick($config->manager->slug . '/page/repair/id:' . $page->id);
    }
    Filter::add('pager:url', function ($url) {
        return Filter::apply('page:url', $url);
    });
    Config::set(array('page_title' => $page->title . $config->title_separator . $config->title, 'page' => $page));
    Weapon::add('shell_after', function () use($page) {
        if (isset($page->css) && trim($page->css) !== "") {
            echo O_BEGIN . $page->css . O_END;
        }
    });
    Weapon::add('sword_after', function () use($page) {
        if (isset($page->js) && trim($page->js) !== "") {
            echo O_BEGIN . $page->js . O_END;
        }
    });
    Shield::attach('page-' . $slug);
}, 100);
/**
 * Home Page
 * ---------
 *
 * [1]. /
 *
 */
Route::accept('/', function () use($config, $excludes) {
    Session::kill('search.query');
    Session::kill('search.results');
    $s = Get::articles();
コード例 #28
0
ファイル: route.post.php プロジェクト: yiannisSt/mecha-cms
         include __DIR__ . DS . 'unit' . DS . 'form' . DS . $v . '.php';
     }, $k + 1);
 }
 $units = array('css', 'js');
 foreach ($units as $k => $v) {
     Weapon::add('tab_content_2_before', function ($page, $segment) use($config, $speak, $v) {
         include __DIR__ . DS . 'unit' . DS . 'form' . DS . $v . '.php';
     }, $k + 1);
 }
 Weapon::add('tab_content_3_before', function ($page, $segment) use($config, $speak) {
     include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'fields[].php';
 }, 1);
 // Ignite
 if (strpos($config->url_path, '/id:') === false) {
     Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
         echo '<script>(function($){$.slug(\'title\',\'slug\',\'-\')})(DASHBOARD.$);</script>';
     }, 11);
 }
 if ($id && ($post = call_user_func('Get::' . $segment, $id, array('content', 'excerpt', 'tags')))) {
     $extension_o = '.' . File::E($post->path);
     if (!Guardian::happy(1) && Guardian::get('author') !== $post->author) {
         Shield::abort();
     }
     if (!File::exist(CUSTOM . DS . Date::slug($post->date->unix) . $extension_o)) {
         $post->css_raw = $config->defaults->{$segment . '_css'};
         $post->js_raw = $config->defaults->{$segment . '_js'};
     }
     $title = $speak->editing . ': ' . ($post->state !== 'drafted' ? Cell::a($post->url, $post->title, true) : $post->title) . $config->title_separator . $config->manager->title;
 } else {
     if ($id !== false) {
         Shield::abort();
コード例 #29
0
ファイル: route.shield.php プロジェクト: razordaze/mecha-cms
        include DECK . DS . 'workers' . DS . 'task.package.1.php';
        if (!Notify::errors()) {
            File::upload($_FILES['file'], SHIELD, function () use($speak) {
                Notify::clear();
                Notify::success(Config::speak('notify_success_uploaded', $speak->shield));
            });
            $P = array('data' => $_FILES);
            Weapon::fire('on_shield_update', array($P, $P));
            Weapon::fire('on_shield_construct', array($P, $P));
            $task_connect_kick = 'shield';
            include DECK . DS . 'workers' . DS . 'task.package.2.php';
        } else {
            Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
                echo '<script>
(function($) {
    $(\'.tab-area .tab[href$="#tab-content-2"]\').trigger("click");
})(window.Zepto || window.jQuery);
</script>';
            }, 11);
        }
    }
    Config::set(array('page_title' => $speak->shields . $config->title_separator . $config->manager->title, 'files' => Get::files(SHIELD . DS . $folder, SCRIPT_EXT, 'ASC', 'name'), 'cargo' => DECK . DS . 'workers' . DS . 'cargo.shield.php'));
    $the_shields = glob(SHIELD . DS . '*', GLOB_NOSORT | GLOB_ONLYDIR);
    sort($the_shields);
    Shield::lot(array('segment' => 'shield', 'the_shield_info' => Shield::info($folder, true), 'the_shield_folder' => $folder, 'the_shield_folders' => $the_shields))->attach('manager', false);
});
/**
 * Shield Igniter
 * --------------
 */
Route::accept($config->manager->slug . '/shield/(:any)/ignite', function ($folder = "") use($config, $speak) {
コード例 #30
0
ファイル: __launch.php プロジェクト: yiannisSt/mecha-cms
// Add default article footer link(s)
Weapon::add('article_footer', function ($article) use($config, $speak) {
    $e = File::E($article->path);
    $comments = count(glob(COMMENT . DS . Date::slug($article->id) . '_*_*.{txt,hold}', GLOB_NOSORT | GLOB_BRACE));
    $t = Jot::icon('comments') . ' ' . $comments;
    $tt = array('title' => $comments . ' ' . ($comments === 1 ? $speak->comment : $speak->comments));
    $comments = ($e === 'draft' || $comments === 0 ? Cell::span($t, $tt) : Cell::a($config->manager->slug . '/comment?filter=post%3A' . $article->id, $t, null, $tt)) . ' &middot; ';
    $status = Mecha::alter($e, array('draft' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->draft) . ' &middot; ', 'archive' => Jot::span('info', Jot::icon('history') . ' ' . $speak->archive) . ' &middot; '), "");
    echo $comments . $status . Cell::a($config->manager->slug . '/article/repair/id:' . $article->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/article/kill/id:' . $article->id, $speak->delete);
}, 20);
// Add default page footer link(s)
Weapon::add('page_footer', function ($page) use($config, $speak) {
    $status = Mecha::alter(File::E($page->path), array('draft' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->draft) . ' &middot; ', 'archive' => Jot::span('info', Jot::icon('history') . ' ' . $speak->archive) . ' &middot; '), "");
    echo $status . Cell::a($config->manager->slug . '/page/repair/id:' . $page->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/page/kill/id:' . $page->id, $speak->delete);
}, 20);
/**
 * Backend Route(s)
 * ----------------
 *
 * Load the routes.
 *
 */
Weapon::add('routes_before', function () use($config, $speak, $segment) {
    // loading cargo ...
    if ($config->page_type === 'manager') {
        require __DIR__ . DS . 'workers' . DS . 'cargo.php';
    }
    if ($detour = File::exist(__DIR__ . DS . 'workers' . DS . 'route.' . $segment . '.php')) {
        require $detour;
    }
});