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


PHP Csrf::verify方法代码示例

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


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

示例1: update

 public static function update()
 {
     // verify Csrf token
     if (Csrf::verify(Input::post('token')) === false) {
         Notifications::set('error', 'Invalid token');
         return false;
     }
     $post = Input::post(array('sitename', 'description', 'theme', 'twitter', 'home_page', 'posts_page', 'auto_published_comments', 'posts_per_page'));
     $errors = array();
     if (empty($post['sitename'])) {
         $errors[] = Lang::line('metadata.missing_sitename', 'You need a site sitename');
     }
     if (empty($post['description'])) {
         $errors[] = Lang::line('metadata.missing_sitedescription', 'You need a site description');
     }
     if (empty($post['theme'])) {
         $errors[] = Lang::line('metadata.missing_theme', 'You need a theme');
     }
     // auto publish comments
     $post['auto_published_comments'] = $post['auto_published_comments'] ? 1 : 0;
     // format posts per page, must be a whole number above 1 defaults to 10 if a invalid number is entered
     $post['posts_per_page'] = ($posts_per_page = intval($post['posts_per_page'])) > 0 ? $posts_per_page : 10;
     if (count($errors)) {
         Notifications::set('error', $errors);
         return false;
     }
     foreach ($post as $key => $value) {
         Db::update('meta', array('value' => $value), array('key' => $key));
     }
     Notifications::set('success', Lang::line('metadata.meta_success_updated', 'Your metadata has been updated'));
     return true;
 }
开发者ID:nathggns,项目名称:anchor-cms,代码行数:32,代码来源:metadata.php

示例2: add

 public static function add()
 {
     // verify Csrf token
     if (Csrf::verify(Input::post('token')) === false) {
         Notifications::set('error', 'Invalid token');
         return false;
     }
     $post = Input::post(array('slug', 'name', 'title', 'content', 'redirect', 'status'));
     $errors = array();
     if (empty($post['name'])) {
         $errors[] = Lang::line('pages.missing_name', 'Please enter a name');
     }
     if (empty($post['title'])) {
         $errors[] = Lang::line('pages.missing_title', 'Please enter a title');
     }
     // check for duplicate slug
     $sql = "select id from pages where slug = ?";
     if (Db::row($sql, array($post['slug']))) {
         $errors[] = Lang::line('pages.duplicate_slug', 'A pages with the same slug already exists, please change your page slug.');
     }
     if (count($errors)) {
         Notifications::set('error', $errors);
         return false;
     }
     if (empty($post['slug'])) {
         $post['slug'] = $post['name'];
     }
     $post['slug'] = Str::slug($post['slug']);
     Db::insert('pages', $post);
     Notifications::set('success', Lang::line('pages.page_success_created', 'Your new page has been added'));
     return true;
 }
开发者ID:nathggns,项目名称:anchor-cms,代码行数:32,代码来源:pages.php

示例3: add

 public static function add()
 {
     // verify Csrf token
     if (Csrf::verify(Input::post('token')) === false) {
         Notifications::set('error', 'Invalid token');
         return false;
     }
     $post = Input::post(array('title', 'slug', 'created', 'description', 'html', 'css', 'js', 'status', 'field', 'comments'));
     $errors = array();
     $post['created'] = strtotime($post['created']);
     if ($post['created'] === false) {
         $errors[] = Lang::line('posts.invalid_date', 'Please enter a valid date');
     }
     if (empty($post['title'])) {
         $errors[] = Lang::line('posts.missing_title', 'Please enter a title');
     }
     if (empty($post['description'])) {
         $errors[] = Lang::line('posts.missing_description', 'Please enter a description');
     }
     if (empty($post['html'])) {
         $errors[] = Lang::line('posts.missing_html', 'Please enter your html');
     }
     // use title as fallback
     if (empty($post['slug'])) {
         $post['slug'] = $post['title'];
     }
     // format slug
     $post['slug'] = Str::slug($post['slug']);
     // check for duplicate slug
     $sql = "select id from posts where slug = ?";
     if (Db::row($sql, array($post['slug']))) {
         $errors[] = Lang::line('posts.duplicate_slug', 'A post with the same slug already exists, please change your post slug.');
     }
     if (count($errors)) {
         Notifications::set('error', $errors);
         return false;
     }
     $custom = array();
     if (is_array($post['field'])) {
         foreach ($post['field'] as $keylabel => $value) {
             list($key, $label) = explode(':', $keylabel);
             $custom[$key] = array('label' => $label, 'value' => $value);
         }
     }
     // remove from update
     unset($post['field']);
     $post['custom_fields'] = json_encode($custom);
     // set author
     $user = Users::authed();
     $post['author'] = $user->id;
     Db::insert('posts', $post);
     Notifications::set('success', Lang::line('posts.post_success_created', 'Your new post has been added'));
     return true;
 }
开发者ID:nathggns,项目名称:anchor-cms,代码行数:54,代码来源:posts.php

示例4: add

 public static function add()
 {
     // verify Csrf token
     if (Csrf::verify(Input::post('token')) === false) {
         Notifications::set('error', 'Invalid token');
         return false;
     }
     $post = Input::post(array('username', 'password', 'email', 'real_name', 'bio', 'status', 'role'));
     $errors = array();
     if (empty($post['username'])) {
         $errors[] = Lang::line('users.missing_username', 'Please enter a username');
     } else {
         if (static::find(array('username' => $post['username']))) {
             $errors[] = Lang::line('users.username_exists', 'Username is already being used');
         }
     }
     if (empty($post['password'])) {
         $errors[] = Lang::line('users.missing_password', 'Please enter a password');
     }
     if (filter_var($post['email'], FILTER_VALIDATE_EMAIL) === false) {
         $errors[] = Lang::line('users.invalid_email', 'Please enter a valid email address');
     }
     if (empty($post['real_name'])) {
         $errors[] = Lang::line('users.missing_name', 'Please enter a display name');
     }
     if (count($errors)) {
         Notifications::set('error', $errors);
         return false;
     }
     // encrypt password
     $post['password'] = Hash::make($post['password']);
     // format email
     $post['email'] = strtolower(trim($post['email']));
     // strip tags on real_name (http://osvdb.org/show/osvdb/79659)
     $post['real_name'] = strip_tags($post['real_name']);
     // add record
     Db::insert('users', $post);
     Notifications::set('success', Lang::line('users.user_success_created', 'A new user has been added'));
     return true;
 }
开发者ID:nathggns,项目名称:anchor-cms,代码行数:40,代码来源:users.php


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