Exemplo n.º 1
0
 public function testSetArrayOverrideScalar()
 {
     $_GET = array('user' => array('name' => 'John Smith', 'email' => '*****@*****.**'));
     fRequest::set('user[name][first]', 'John');
     $this->assertEquals(array('user' => array('name' => array('first' => 'John'), 'email' => '*****@*****.**')), $_GET);
 }
<?php

$page = 'addcard';
require 'header.php';
if ($user) {
    fSession::destroy();
    fURL::redirect();
}
if (isset($_POST['submit'])) {
    try {
        fRequest::validateCSRFToken($_POST['token']);
        // Strip colons from uid (easier to copy paste from some NFC
        // reader apps).
        fRequest::set('uid', str_replace(':', '', fRequest::get('uid')));
        $validator = new fValidation();
        $validator->addRequiredFields('password', 'email', 'uid');
        $validator->addEmailFields('email');
        $validator->addRegexRule('uid', '#^[0-9a-fA-F]+$#', 'Not in hex format');
        $validator->validate();
        $uid = strtoupper($_POST['uid']);
        if ($uid == '21222324') {
            /* New Visa cards return this, presumably for privacy */
            throw new fValidationException('Non-unique UID. This card cannot be added to the system.');
        }
        // Random IDs are 4 bytes long and start with 0x08
        // http://www.nxp.com/documents/application_note/AN10927.pdf
        if (strlen($uid) === 8 && substr($uid, 0, 2) === "08") {
            throw new fValidationException('ID is randomly generated and will change every time the card is used!');
        }
        if (strlen($uid) === 8 && substr($uid, 0, 2) === "88") {
            throw new fValidationException('Card UID\'s can\'t start with 88');