当前位置: 首页>>代码示例>>PHP>>正文


PHP Guardian::checkToken方法代码示例

本文整理汇总了PHP中Guardian::checkToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Guardian::checkToken方法的具体用法?PHP Guardian::checkToken怎么用?PHP Guardian::checkToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guardian的用法示例。


在下文中一共展示了Guardian::checkToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

    $info = Shield::info($folder, true);
    if ($path) {
        $path = File::path($path);
        if (!($file = File::exist(SHIELD . DS . $folder . DS . $path))) {
            Shield::abort();
            // File not found!
        }
    } else {
        if (!($file = File::exist(SHIELD . DS . $folder))) {
            Shield::abort();
            // Folder not found!
        }
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . ($path ? File::B($file) : $info['title']) . $config->title_separator . $config->manager->title, 'files' => Get::files(SHIELD . DS . $folder, '*'), 'cargo' => DECK . DS . 'workers' . DS . 'kill.shield.php'));
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        $P = array('data' => array('path' => $file));
        File::open($file)->delete();
        if ($path) {
            Notify::success(Config::speak('notify_file_deleted', '<code>' . File::B($path) . '</code>'));
        } else {
            Notify::success(Config::speak('notify_success_deleted', $speak->shield));
        }
        Weapon::fire('on_shield_update', array($P, $P));
        Weapon::fire('on_shield_destruct', array($P, $P));
        Guardian::kick($config->manager->slug . '/shield' . ($path ? '/' . $folder : ""));
    } else {
        Notify::warning(Config::speak('notify_confirm_delete_', $path ? '<code>' . File::path($path) . '</code>' : '<strong>' . $info['title'] . '</strong>'));
    }
    Shield::lot(array('segment' => 'shield', 'the_shield' => $folder, 'the_name' => $path, 'the_info' => $info))->attach('manager', false);
});
开发者ID:razordaze,项目名称:mecha-cms,代码行数:31,代码来源:route.shield.php

示例2: function

<?php

/**
 * Create New Comment
 * ------------------
 */
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)));
                }
            }
开发者ID:razordaze,项目名称:mecha-cms,代码行数:31,代码来源:task.comment.php

示例3: do_comment_construct

 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 ($fuck = trim($spam)) {
                         if ($request['email'] === $fuck || strpos(strtolower($request['message']), strtolower($fuck)) !== false) {
                             Notify::warning($speak->notify_warning_intruder_detected . ' <strong class="text-error pull-right">' . $fuck . '</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);
                 }
             }
//.........这里部分代码省略.........
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:101,代码来源:__task.comment.php

示例4: function

/**
 * Backup/Restore Manager
 * ----------------------
 */
Route::accept($config->manager->slug . '/(backup|restore)', function ($segment = "") use($config, $speak) {
    if (Guardian::get('status') !== 'pilot') {
        Shield::abort();
    }
    // Remove backup file(s) that is failed to delete
    if ($backup = glob(ROOT . DS . Text::parse($config->title, '->slug') . '_*.zip', GLOB_NOSORT)) {
        foreach ($backup as $back) {
            unlink($back);
        }
    }
    if (isset($_FILES) && !empty($_FILES)) {
        Guardian::checkToken(Request::post('token'));
        $destination = Request::post('destination', ROOT, false);
        $title = Request::post('title', $speak->files, false);
        $task_connect_path = $destination;
        include DECK . DS . 'workers' . DS . 'task.package.1.php';
        if (!Notify::errors()) {
            File::upload($_FILES['file'], $destination, function () use($title) {
                Notify::clear();
                Notify::success(Config::speak('notify_success_uploaded', $title));
            });
            $P = array('data' => $_FILES);
            Weapon::fire('on_restore_construct', array($P, $P));
            $task_connect_kick = 'backup';
            include DECK . DS . 'workers' . DS . 'task.package.2.php';
        } else {
            Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
开发者ID:razordaze,项目名称:mecha-cms,代码行数:31,代码来源:route.backup.php


注:本文中的Guardian::checkToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。