示例#1
0
 public function testGet()
 {
     //Data
     $formKey = 'test_from_key';
     //Verification
     $this->cookieManagerMock->expects($this->once())->method('getCookie')->with(\Magento\Framework\App\PageCache\FormKey::COOKIE_NAME)->will($this->returnValue($formKey));
     $this->assertEquals($formKey, $this->formKey->get());
 }
示例#2
0
<?php

/** New User Creation Page Presents form to user with Checksum */
session_start();
/* includes PHP functions, activates myAutoLoader*/
include 'functions.php';
spl_autoload_register('my_autoLoader');
$lock = new LockoutCheck();
$locked = $lock->getLockout();
$lock = null;
$status = false;
$key = new FormKey();
if (isset($_SESSION['formKey']) && isset($_POST['formKey'])) {
    $keyConfirmed = $key->confirmKey();
    //
    $login = new UserManagement();
    $status = $login->loginUser($_POST['username'], $_POST['password']);
    $login = null;
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
示例#3
0
<?php

/** New User Creation Page Presents form to user with Checksum */
session_start();
/* includes PHP functions, activates myAutoLoader*/
include 'functions.php';
spl_autoload_register('my_autoLoader');
$key = new FormKey();
/*Validates form keys*/
$newU = false;
if (isset($_SESSION['formKey']) && isset($_POST['formKey'])) {
    if ($key->confirmKey()) {
        /* Begins Validation loop */
        $create = new UserManagement();
        $newU = $create->setNewUser($_POST['username'], $_POST['password'], $_POST['passwordConf'], $_POST['email']);
        if (!$newU) {
            $createErrors = $create->getErrorCode();
        }
        $create = null;
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap 101 Template</title>
示例#4
0
 public function validate($storeDataInSession = true)
 {
     $isValid = true;
     $this->errorMessage = $this->beforeErrorMessages;
     // automatically validate form key
     $formKey = new FormKey();
     if (isset($this->data['formKey']) && !$formKey->isValid()) {
         $this->addErrorMessage('Form Key', 'was missing or incorrect. Please try again');
         $isValid = false;
     } else {
         // process all rules
         foreach ($this->rules as $name => $rules) {
             $rules = explode('|', $rules);
             $display = $name;
             if (isset($this->display[$name])) {
                 $display = $this->display[$name];
             }
             $value = '';
             if (isset($this->data[$name])) {
                 $value = $this->data[$name];
             }
             if (($key = array_search('optional', $rules)) !== false) {
                 if ($value === '') {
                     // this field is optional and it has no value, so the
                     // validation is complete
                     continue;
                 }
                 unset($rules[$key]);
                 // no need to check optional again
             }
             $isFieldValid = true;
             foreach ($rules as $rule) {
                 $parameters = array();
                 if (($left = strpos($rule, '[')) !== false) {
                     $right = strrpos($rule, ']');
                     $parameters = trim(substr($rule, $left + 1, $right - $left - 1));
                     // range rules require two parameters
                     if (strpos(strtolower($rule), 'range') !== false) {
                         $parameters = explode(',', $parameters);
                     } else {
                         $parameters = array($parameters);
                     }
                     foreach ($parameters as $key => $parameter) {
                         $parameters[$key] = trim($parameter);
                     }
                     $rule = substr($rule, 0, $left);
                 }
                 $parameters[] = $display;
                 $parameters[] = $value;
                 $method = "{$rule}Callback";
                 if (call_user_func_array(array($this, $method), $parameters) === false) {
                     $isFieldValid = false;
                 }
             }
             $isValid = $isValid && $isFieldValid;
         }
     }
     $this->errorMessage .= $this->afterErrorMessages;
     if (!$isValid && $storeDataInSession === true) {
         $this->storeFormData($this->data);
         $this->storeErrorMessage($this->errorMessage);
     }
     return $isValid;
 }
示例#5
0
 public function formKey()
 {
     $formKey = new FormKey();
     echo $formKey->outputKey();
 }