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


PHP security::get_token方法代码示例

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


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

示例1: forgot

 public function forgot()
 {
     $content = '';
     $token_handler = new security();
     $token_handler->set_token();
     $token = $token_handler->get_token();
     $register_form = "\n        <form action='?controller=users&action=reset' method='post'>\n          Username: <input type='text' name='username' placeholder='ex: john' autofocus>\n            <br>\n          email: <input type='text' name='email'>\n          <br><br>\n          <input type='submit' value='reset'>\n          <input type='hidden' value='{$token}' name='token'>\n        </form>\n\n        ";
     $content .= $register_form;
     $output['content'] = $content;
     $output['page'] = 'views/forgot.php';
     return $output;
 }
开发者ID:dagasaga,项目名称:css,代码行数:12,代码来源:usersController.php

示例2: login

 public function login()
 {
     // 1st time (&submit is not set) or error=true - just show form and/or error message
     // 2nd time (&submit==yes) - check
     // if ok, redirect to home
     // if not, set $content to error message and just show form again
     if (!isset($_SESSION['log'])) {
         $_SESSION['log'] = new timestamp("login");
     }
     $content = "";
     $output['page'] = 'views/login/index.php';
     //$header = 'CSS AEC-Foyer Lataste ADTJK System V2.0';
     $token_handler = new security();
     $token_handler->set_token();
     $token = $token_handler->get_token();
     $login_form = "\n        <form action='?controller=login&action=submit' method='post'>\n          Username: <input type='text' name='username' placeholder='ex: john' autofocus>\n            <br>\n          Password: <input type='password' name='password'>\n          <br><br>\n          <input type='submit' value='login'>\n          <input type='hidden' value='{$token}' name='token'>\n        </form>\n\n        ";
     $current_year = date("Y");
     $footer = "CSS AEC-Foyer Lataste ADTJK Copyright {$current_year} All Rights Reserved - Webmaster: ivan.bragatto@gmail.com";
     // $output ['header']     = $header;
     $output['login_form'] = $login_form;
     $output['content'] = $content;
     $output['footer'] = $footer;
     return $output;
 }
开发者ID:dagasaga,项目名称:css,代码行数:24,代码来源:loginController.php

示例3: set_top_form

 public function set_top_form($top_form)
 {
     //  form: add record form on top: field names, field labels, drop_down menu name (from previous $drop_down set method)
     //  follows the $main_table columns order
     // Also, set_drop_down method does not 'select' value retrieved from DB.
     //
     $html = "<tr>";
     $html .= "<form action='{$top_form['action']}' method='{$top_form['method']}' id='{$top_form['id']}'>";
     $i = 0;
     $autofocus = '';
     foreach ($top_form['elements'] as $key => $bla) {
         //echo 'key: '.$key.'<br>';
         foreach ($bla as $key2 => $key3) {
             $i++;
             // $key2: value position inside numbered array
             //echo '.....key2:'.$key2.'<br>';
             //echo '.....key3:'.$key3.'<br>';
             $value = '';
             switch ($key2) {
                 case 'text':
                     if ($i == 1) {
                         $autofocus = 'autofocus';
                     }
                     if (isset($this->form_values)) {
                         $value = $this->form_values[$key3];
                     }
                     $html .= '<td>' . "<div " . $top_form['div'] . ">";
                     $html .= "<input type='text' name='{$key3}' value='{$value}' {$autofocus}>";
                     $html .= "</td></div>";
                     $i++;
                     break;
                 case 'date':
                     if ($i == 1) {
                         $autofocus = 'autofocus';
                     }
                     if (isset($this->form_values)) {
                         $value = $this->form_values[$key3];
                     }
                     $html .= '<td>' . "<div " . $top_form['div'] . ">";
                     $html .= "<input type='date' name='{$key3}' value='{$value}' {$autofocus}>";
                     $html .= "</td></div>";
                     $i++;
                     break;
                 case 'drop_down':
                     $html .= '<td>' . "<div " . $top_form['div'] . ">";
                     $html .= $this->drop_down[$key3];
                     $html .= "</td></div>";
                     break;
                 case 'submit':
                     $html .= "<td><div ";
                     if (isset($top_form['div_button'])) {
                         $html .= $top_form['div_button'];
                     } else {
                         $html .= $top_form['div'];
                     }
                     $html .= ">";
                     $html .= "<input type='submit' value='{$key3}'>";
                     $html .= "</td></div>";
                     break;
                 case 'check_box':
                     // check_box works just like drop_down; needs a proper function to pre make html
                     $html .= '<td>' . "<div " . $top_form['div'] . ">";
                     $html .= $this->check_box[$key3];
                     $html .= "</td></div>";
                     break;
                 case 'label':
                     $html .= '<td>' . "<div " . $top_form['div'] . ">";
                     $html .= $this->form_values[$key3];
                     $html .= "</td></div>";
                     break;
                 case 'hidden':
                     foreach ($key3 as $hidden_name => $hidden_value) {
                         $html .= "<input type='hidden' name='{$hidden_name}' value='{$hidden_value}'>";
                     }
                     break;
                 default:
                     $html .= '<td></td>';
                     break;
             }
         }
     }
     // TODO: insert token check here
     if (!isset($this->token)) {
         $token_handler = new security();
         $token_handler->set_token();
         $this->token = $token_handler->get_token();
     }
     //echo $_SESSION['token'];
     //die();
     // TODO: troubleshoot: if multiple forms at the same time, token check might fail since each form
     // will have produced its own token, but only one will be checked - make an array of tokens then iterate?
     $html .= "<input type='hidden' name='token' value = '{$this->token}'>";
     $html .= "</form>";
     if (isset($_GET['id'])) {
         $id = $_GET['id'];
     }
     if (isset($top_form['action_links'])) {
         $action_links = $top_form['action_links'];
         $html .= "<td><div class='small_link_button'>";
         foreach ($action_links as $row) {
//.........这里部分代码省略.........
开发者ID:dagasaga,项目名称:css,代码行数:101,代码来源:simple_table_ops.php


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