示例#1
0
 /**
  * Is the file name alpha numerical minus the allowed asciis
  */
 private function isAlphaNumerical()
 {
     if (ctype_alnum(str_replace($this->rules['FileName']['allowed'], '', $this->fileName))) {
         return true;
     }
     return false;
 }
示例#2
0
/**
 * Validate user-supplied guid values against expected inputs
 *
 * @since 1.1
 * @param string $guid video identifier
 * @return bool true if passes validation test
 */
function videopress_is_valid_guid($guid)
{
    if (!empty($guid) && strlen($guid) === 8 && ctype_alnum($guid)) {
        return true;
    }
    return false;
}
 function post_xhr()
 {
     if ($this->checkAuth()) {
         $usernameOrEmail = mb_strtolower($_POST['usernameOrEmail']);
         if (mb_strlen($usernameOrEmail) >= 8 && preg_match('/^[a-zA-Z0-9_\\-]+$/', $usernameOrEmail) || filter_var($usernameOrEmail, FILTER_VALIDATE_EMAIL)) {
             $secondFactor = mb_strtolower($_POST['secondFactor']);
             if (ctype_alnum($secondFactor) || empty($secondFactor)) {
                 $answer = mb_strtolower($_POST['answer']);
                 if (mb_strlen($answer) >= 6 || empty($answer)) {
                     $newPassword = $_POST['passwordForgot'];
                     $newRetypedPassword = $_POST['passwordRetypedForgot'];
                     if ($newPassword == $newRetypedPassword) {
                         $userForgot = new AuthUser();
                         $responseArr = $userForgot->forgotPassword($usernameOrEmail, $secondFactor, $answer, $newPassword);
                         if ($responseArr['continue'] == true) {
                             echo json_encode(StatusReturn::S200($responseArr));
                         } else {
                             echo json_encode(StatusReturn::E400('Unknown Error 5'));
                         }
                     } else {
                         echo json_encode(StatusReturn::E400('Unknown Error 4'));
                     }
                 } else {
                     echo json_encode(StatusReturn::E400('Unknown Error'));
                 }
             } else {
                 echo json_encode(StatusReturn::E400('Unknown Error'));
             }
         } else {
             echo json_encode(StatusReturn::E400('Unknown Error'));
         }
     }
 }
示例#4
0
function generate_data_file($filename, $content)
{
    if (!assert(ctype_alnum(str_replace(array('-', '_', '.'), '', $filename)))) {
        return FALSE;
    }
    return file_put_contents(config_path('dataDirectory', $filename), $content, LOCK_EX);
}
 public function validate_bk_username($username)
 {
     if (!ctype_alnum($username)) {
         return array(_t('Your Brightkite username is not valid.', $this->class_name));
     }
     return array();
 }
示例#6
0
 /**
  * Creates the required controller specified by the given path of controller names.
  *
  * Controllers are created by providing only the domain name, e.g.
  * "basket" for the Controller_Frontend_Basket_Default or a path of names to
  * retrieve a specific sub-controller if available.
  * Please note, that only the default controllers can be created. If you need
  * a specific implementation, you need to use the factory class of the
  * controller to hand over specifc implementation names.
  *
  * @param MShop_Context_Item_Interface $context Context object required by managers
  * @param string $path Name of the domain (and sub-managers) separated by slashes, e.g "basket"
  * @throws Controller_Frontend_Exception If the given path is invalid or the manager wasn't found
  */
 public static function createController(MShop_Context_Item_Interface $context, $path)
 {
     if (empty($path)) {
         throw new Controller_Frontend_Exception(sprintf('Controller path is empty'));
     }
     $id = (string) $context;
     if (self::$_cache === false || !isset(self::$_controllers[$id][$path])) {
         $parts = explode('/', $path);
         foreach ($parts as $key => $part) {
             if (ctype_alnum($part) === false) {
                 throw new Controller_Frontend_Exception(sprintf('Invalid characters in controller name "%1$s" in "%2$s"', $part, $path));
             }
             $parts[$key] = ucwords($part);
         }
         $factory = 'Controller_Frontend_' . join('_', $parts) . '_Factory';
         if (class_exists($factory) === false) {
             throw new Controller_Frontend_Exception(sprintf('Class "%1$s" not available', $factory));
         }
         $manager = call_user_func_array(array($factory, 'createController'), array($context));
         if ($manager === false) {
             throw new Controller_Frontend_Exception(sprintf('Invalid factory "%1$s"', $factory));
         }
         self::$_controllers[$id][$path] = $manager;
     }
     return self::$_controllers[$id][$path];
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('email', 'email', array('label' => 'Email Of Owner', 'required' => true));
     // The rest of this is duplicated from index\forms\CreateForm
     $builder->add('title', 'text', array('label' => 'Title', 'required' => true, 'max_length' => VARCHAR_COLUMN_LENGTH_USED));
     $builder->add('slug', 'text', array('label' => 'Slug For Web Address', 'required' => true, 'max_length' => VARCHAR_COLUMN_LENGTH_USED));
     $myExtraFieldValidator = function (FormEvent $event) {
         global $CONFIG;
         $form = $event->getForm();
         $myExtraField = $form->get('slug')->getData();
         if (!ctype_alnum($myExtraField) || strlen($myExtraField) < 2) {
             $form['slug']->addError(new FormError("Numbers and letters only, at least 2."));
         } else {
             if (in_array($myExtraField, $CONFIG->siteSlugReserved)) {
                 $form['slug']->addError(new FormError("That is already taken."));
             }
         }
     };
     $builder->addEventListener(FormEvents::POST_BIND, $myExtraFieldValidator);
     $readChoices = array('public' => 'Public, and listed on search engines and our directory', 'protected' => 'Public, but not listed so only people who know about it can find it');
     $builder->add('read', 'choice', array('label' => 'Who can read?', 'required' => true, 'choices' => $readChoices, 'expanded' => true));
     $builder->get('read')->setData('public');
     $writeChoices = array('public' => 'Anyone can add data', 'protected' => 'Only people I say can add data');
     $builder->add('write', 'choice', array('label' => 'Who can write?', 'required' => true, 'choices' => $writeChoices, 'expanded' => true));
     $builder->get('write')->setData('public');
 }
示例#8
0
 /**
  * Creates the required controller specified by the given path of controller names.
  *
  * Controllers are created by providing only the domain name, e.g.
  * "product" for the \Aimeos\Controller\ExtJS\Product\Standard or a path of names to
  * retrieve a specific sub-controller, e.g. "product/type" for the
  * \Aimeos\Controller\ExtJS\Product\Type\Standard controller.
  * Please note, that only the default controllers can be created. If you need
  * a specific implementation, you need to use the factory class of the
  * controller to hand over specifc implementation names.
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Context object required by managers
  * @param string $path Name of the domain (and sub-managers) separated by slashes, e.g "product/list"
  * @throws \Aimeos\Controller\ExtJS\Exception If the given path is invalid or the manager wasn't found
  */
 public static function createController(\Aimeos\MShop\Context\Item\Iface $context, $path)
 {
     $path = strtolower(trim($path, "/ \n\t\r\v"));
     if (empty($path)) {
         throw new \Aimeos\Controller\ExtJS\Exception(sprintf('Controller path is empty'));
     }
     $id = (string) $context;
     if (self::$cache === false || !isset(self::$controllers[$id][$path])) {
         $parts = explode('/', $path);
         foreach ($parts as $key => $part) {
             if (ctype_alnum($part) === false) {
                 throw new \Aimeos\Controller\ExtJS\Exception(sprintf('Invalid controller "%1$s" in "%2$s"', $part, $path));
             }
             $parts[$key] = ucwords($part);
         }
         $factory = '\\Aimeos\\Controller\\ExtJS\\' . join('\\', $parts) . '\\Factory';
         if (class_exists($factory) === false) {
             throw new \Aimeos\Controller\ExtJS\Exception(sprintf('Class "%1$s" not found', $factory));
         }
         $controller = @call_user_func_array(array($factory, 'createController'), array($context));
         if ($controller === false) {
             throw new \Aimeos\Controller\ExtJS\Exception(sprintf('Invalid factory "%1$s"', $factory));
         }
         self::$controllers[$id][$path] = $controller;
     }
     return self::$controllers[$id][$path];
 }
示例#9
0
 /**
  * Tokenization stream API
  * Get next token
  * Returns null at the end of stream
  *
  * @return Zend_Search_Lucene_Analysis_Token|null
  */
 public function nextToken()
 {
     if ($this->_input === null) {
         return null;
     }
     while ($this->_position < strlen($this->_input)) {
         // skip white space
         while ($this->_position < strlen($this->_input) && !ctype_alnum($this->_input[$this->_position])) {
             $this->_position++;
         }
         $termStartPosition = $this->_position;
         // read token
         while ($this->_position < strlen($this->_input) && ctype_alnum($this->_input[$this->_position])) {
             $this->_position++;
         }
         // Empty token, end of stream.
         if ($this->_position == $termStartPosition) {
             return null;
         }
         $token = new Zend_Search_Lucene_Analysis_Token(substr($this->_input, $termStartPosition, $this->_position - $termStartPosition), $termStartPosition, $this->_position);
         $token = $this->normalize($token);
         if ($token !== null) {
             return $token;
         }
         // Continue if token is skipped
     }
     return null;
 }
示例#10
0
function check_alnum($str, $permit = FALSE)
{
    if ($permit) {
        $str = str_replace($permit, '', $str);
    }
    return ctype_alnum($str);
}
示例#11
0
文件: lib.php 项目: vgrish/xblib
 public static function classPrefix($v = null)
 {
     if (!is_null($v) && ctype_alnum($v)) {
         self::$_classPrefix = $v;
     }
     return self::$_classPrefix;
 }
示例#12
0
 /**
  * 
  * Validates that the value is only letters (upper or lower case) and digits.
  * 
  * @param mixed $value The value to validate.
  * 
  * @return bool True if valid, false if not.
  * 
  */
 public function validateAlnum($value)
 {
     if ($this->_filter->validateBlank($value)) {
         return !$this->_filter->getRequire();
     }
     return ctype_alnum((string) $value);
 }
示例#13
0
 public function isAlnum($par)
 {
     if (ctype_alnum($par)) {
         return true;
     }
     return false;
 }
示例#14
0
 private function renderResult()
 {
     $mat_no = $_POST['mat_no'];
     if (!ctype_alnum($mat_no)) {
         $this->renderError('Matriculation number contains non-alphanumerical characters');
         return;
     }
     $project_id = $_POST['project_id'];
     if (!ctype_digit($project_id)) {
         $this->renderError('Project-id invalid');
         return;
     }
     $pwd = $_POST['password'];
     if (!$pwd) {
         $this->renderError('Password empty');
         return;
     }
     $result_str = 'No results for this combination of matriculation number and password found.';
     if (preg_match(PasswordGenerator::$passwordCharacterRegExp, $pwd)) {
         //If not, we dont query the database, but we won't tell the intruder either
         $db = Database::getInstance();
         $data = $db->getResultDataByMatNo($project_id, $mat_no);
         $crypt = new CryptProxy($data['crypt_module'], $project_id, $data['member_id']);
         $decrypted_result = $crypt->decryptResult($data['result'], $data['crypt_data'], $pwd);
         if ($decrypted_result) {
             $result_str = sprintf('<div class="result">%s</div>', $decrypted_result);
         }
     }
     $this->renderNote($result_str, sprintf('Results for matriculation number %s:', $mat_no));
 }
示例#15
0
 /**
  * identify a line as the beginning of a HTML block.
  */
 protected function identifyHtml($line, $lines, $current)
 {
     if ($line[0] !== '<' || isset($line[1]) && $line[1] == ' ') {
         return false;
         // no html tag
     }
     if (strncmp($line, '<!--', 4) === 0) {
         return true;
         // a html comment
     }
     $gtPos = strpos($lines[$current], '>');
     $spacePos = strpos($lines[$current], ' ');
     if ($gtPos === false && $spacePos === false) {
         return false;
         // no html tag
     } elseif ($spacePos === false) {
         $tag = rtrim(substr($line, 1, $gtPos - 1), '/');
     } else {
         $tag = rtrim(substr($line, 1, min($gtPos, $spacePos) - 1), '/');
     }
     if (!ctype_alnum($tag) || in_array(strtolower($tag), $this->inlineHtmlElements)) {
         return false;
         // no html tag or inline html tag
     }
     return true;
 }
示例#16
0
 public static function Get($var)
 {
     if (Validate::issetValidation($var) == true && ctype_alnum($var) && strlen($var) <= 255) {
         return true;
     }
     return false;
 }
示例#17
0
文件: worker.php 项目: inikoo/fact
function get_fork_data($job)
{
    global $mysqli;
    $fork_encrypt_key = md5('huls0fjhslsshskslgjbtqcwijnbxhl2391');
    $fork_raw_data = $job->workload();
    $fork_metadata = json_decode(AESDecryptCtr(base64_decode($fork_raw_data), $fork_encrypt_key, 256), true);
    $fork_key = $fork_metadata['fork_key'];
    $token = $fork_metadata['token'];
    $inikoo_account_code = $fork_metadata['code'];
    if (!ctype_alnum($inikoo_account_code)) {
        print "cant fint account code\n";
        return false;
    }
    include "gearman/conf/dns.{$inikoo_account_code}.php";
    $mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit;
    }
    $mysqli->query("SET NAMES 'utf8'");
    date_default_timezone_set('GMT');
    $mysqli->query("SET time_zone='+0:00'");
    $sql = sprintf("select `Fork Process Data` from `Fork Dimension` where `Fork Key`=%d and `Fork Token`=%s", $fork_key, prepare_mysql($token));
    $res = $mysqli->query($sql);
    if ($row = $res->fetch_assoc()) {
        $fork_data = json_decode($row['Fork Process Data'], true);
        return array('fork_key' => $fork_key, 'inikoo_account_code' => $inikoo_account_code, 'fork_data' => $fork_data);
    } else {
        print "fork data not found";
        return false;
    }
}
示例#18
0
function admin_users_add_edit_form_validate($values)
{
    $errors = array();
    // Required validation.
    $required = array('username', 'password');
    foreach ($required as $input_name) {
        if (trim($values[$input_name]) == '') {
            $errors[] = 'Please enter a value for ' . $input_name . '.';
        }
    }
    // Alpha-numeric validation.
    $alphanumeric = array('username', 'password');
    foreach ($alphanumeric as $input_name) {
        if (trim($values[$input_name]) != '') {
            if (!ctype_alnum($values[$input_name])) {
                $errors[] = 'Please enter only numbers or letters for ' . $input_name . '.';
            }
        }
    }
    // Check uniqueness of username.
    if ($values['uid'] != '') {
        // If it's their own username, it's okay.
        $result = mysql_query("SELECT uid FROM users WHERE username = '******'username']) . "' AND uid != '" . mysql_real_escape_string($values['uid']) . "'");
        if ($row = mysql_fetch_array($result)) {
            $errors[] = 'Sorry, it looks like that username is already in use.';
        }
    }
    return $errors;
}
示例#19
0
 public function password()
 {
     $this->setTemplate('elib:/admin/password.tpl');
     if (isset($_POST['submit'])) {
         $errors = array();
         $old_password = md5(SALT . $_POST['old_password'] . SALT);
         $password1 = $_POST['password1'];
         $password2 = $_POST['password2'];
         $u = Model::load('UserItem');
         $u->id = Session::get('user_id');
         $u->load();
         if ($old_password != $u->password) {
             array_push($errors, 'The existing password you have entered is not correct');
         }
         if ($password1 != $password2) {
             array_push($errors, 'The new password entered does not match the confirmation');
         }
         if (!ctype_alnum($password1) || !ctype_alnum($password2)) {
             array_push($errors, 'Please only use alpha and numeric characters for new passwords');
         }
         if (sizeof($errors) < 1) {
             $u->password = md5(SALT . $password1 . SALT);
             $u->save(Model::getTable('UserItem'), array(), 0);
             $this->redirect('admin');
         } else {
             $this->presenter->assign('error', $errors);
         }
     } elseif (isset($_POST['cancel'])) {
         $this->redirect('admin');
     }
 }
示例#20
0
 /**
  * An extra part to be appended to the filename
  *
  * When a call to remove the cache is included, then all 'secondary' versions of it will be included too
  * 
  * @param string|int $id
  *
  */
 public function setSecondaryID($id)
 {
     if (!ctype_alnum("{$id}")) {
         $id = preg_replace('/[^-+_a-zA-Z0-9]/', '_', $id);
     }
     $this->secondaryID = $id;
 }
示例#21
0
 public static function isValidXMLName($sign)
 {
     if (ctype_alnum($sign) || $sign == ':' || $sign == '-' || $sign == '_') {
         return true;
     }
     return false;
 }
 /**
  * Test to make sure we get a string back with alphanumeric and special charecters
  * @author Chris Kacerguis <*****@*****.**>
  * @return void
  */
 public function testGenerateRandomStringChars()
 {
     $random = new \chriskacerguis\Randomstring\Randomstring();
     $string = $random->generate(11, true);
     $chars = !ctype_alnum($string);
     $this->assertTrue($chars);
 }
示例#23
0
 /**
  * Registers an asset to the current asset manager.
  *
  * @param string         $name  The asset name
  * @param AssetInterface $asset The asset
  *
  * @throws \InvalidArgumentException If tthe asset name is invalid
  */
 public function set($name, AssetInterface $asset)
 {
     if (!ctype_alnum(str_replace('_', '', $name))) {
         throw new \InvalidArgumentException(sprintf('The name "%s" is invalid.', $name));
     }
     $this->assets[$name] = $asset;
 }
 /**
  * determines whether or not
  *
  * @param mixed $subject
  * @return bool
  */
 public function isValid($subject)
 {
     if (is_scalar($subject) === false) {
         return false;
     }
     return ctype_alnum($subject);
 }
示例#25
0
 public function run()
 {
     // Figure out the page controller class to run.
     $controllerClass = $this->http->getRequestFile() . 'Controller';
     if (ctype_alnum($controllerClass) == false) {
         throw new ErrorException("Nom de contrôleur invalide : <strong>{$controllerClass}</strong>");
     }
     // Create the page controller.
     $controller = new $controllerClass();
     /*
      * Select the page controller's HTTP GET or HTTP POST method to run
      * and the HTTP data fields to give to the method.
      */
     if ($this->http->getRequestMethod() == 'GET') {
         $fields = $_GET;
         $method = 'httpGetMethod';
     } else {
         $fields = $_POST;
         $method = 'httpPostMethod';
     }
     if (method_exists($controller, $method) == false) {
         throw new ErrorException('Une requête HTTP ' . $this->http->getRequestMethod() . ' a été effectuée, ' . "mais vous avez oublié la méthode <strong>{$method}</strong> dans le contrôleur " . '<strong>' . get_class($controller) . '</strong>');
     }
     // Run the page controller method and merge all the controllers view variables together.
     $this->viewData['variables'] = array_merge($this->viewData['variables'], (array) $controller->{$method}($this->http, $fields));
 }
示例#26
0
 public function isAlnum($string = '')
 {
     if (!is_string($string)) {
         return Error::set(lang('Error', 'stringParameter', '1.(string)'));
     }
     return ctype_alnum($string);
 }
示例#27
0
 /**
  * {@inheritdoc}
  */
 public function validate($value, Constraint $constraint)
 {
     if (null === $value || '' === $value) {
         return;
     }
     $canonicalize = str_replace(' ', '', $value);
     // the bic must be either 8 or 11 characters long
     if (!in_array(strlen($canonicalize), array(8, 11))) {
         $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->setCode(Bic::INVALID_LENGTH_ERROR)->addViolation();
     }
     // must contain alphanumeric values only
     if (!ctype_alnum($canonicalize)) {
         $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->setCode(Bic::INVALID_CHARACTERS_ERROR)->addViolation();
     }
     // first 4 letters must be alphabetic (bank code)
     if (!ctype_alpha(substr($canonicalize, 0, 4))) {
         $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->setCode(Bic::INVALID_BANK_CODE_ERROR)->addViolation();
     }
     // next 2 letters must be alphabetic (country code)
     if (!ctype_alpha(substr($canonicalize, 4, 2))) {
         $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->setCode(Bic::INVALID_COUNTRY_CODE_ERROR)->addViolation();
     }
     // should contain uppercase characters only
     if (strtoupper($canonicalize) !== $canonicalize) {
         $this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->setCode(Bic::INVALID_CASE_ERROR)->addViolation();
     }
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('title', 'text', array('label' => 'Title', 'required' => true, 'max_length' => VARCHAR_COLUMN_LENGTH_USED, 'attr' => array('autofocus' => 'autofocus')));
     $builder->add('slug', 'text', array('label' => 'Address', 'required' => true, 'max_length' => VARCHAR_COLUMN_LENGTH_USED));
     $myExtraFieldValidator = function (FormEvent $event) {
         global $CONFIG;
         $form = $event->getForm();
         $myExtraField = $form->get('slug')->getData();
         if (!ctype_alnum($myExtraField) || strlen($myExtraField) < 2) {
             $form['slug']->addError(new FormError("Numbers and letters only, at least 2."));
         } else {
             if (in_array($myExtraField, $CONFIG->siteSlugReserved)) {
                 $form['slug']->addError(new FormError("That is already taken."));
                 // The above checks provide a nice error message.
                 // Now let's do a final belt and braces check.
             } else {
                 if (!SiteModel::isSlugValid($myExtraField, $CONFIG)) {
                     $form['slug']->addError(new FormError("That is not allowed."));
                 }
             }
         }
     };
     $builder->addEventListener(FormEvents::POST_BIND, $myExtraFieldValidator);
     $readChoices = array('public' => 'Public, and listed on search engines and our directory', 'protected' => 'Public, but not listed so only people who know about it can find it');
     $builder->add('read', 'choice', array('label' => 'Who can read?', 'required' => true, 'choices' => $readChoices, 'expanded' => true));
     $builder->get('read')->setData('public');
     $writeChoices = array('public' => 'Anyone can add data', 'protected' => 'Only people I say can add data');
     $builder->add('write', 'choice', array('label' => 'Who can write?', 'required' => true, 'choices' => $writeChoices, 'expanded' => true));
     $builder->get('write')->setData('public');
 }
示例#29
0
 /**
  * QueryTokenize constructor needs query string as a parameter.
  *
  * @param string $inputString
  */
 public function __construct($inputString)
 {
     if (!strlen($inputString)) {
         throw new Zend_Search_Lucene_Exception('Cannot tokenize empty query string.');
     }
     $currentToken = '';
     for ($count = 0; $count < strlen($inputString); $count++) {
         if (ctype_alnum($inputString[$count])) {
             $currentToken .= $inputString[$count];
         } else {
             // Previous token is finished
             if (strlen($currentToken)) {
                 $this->_tokens[] = new Zend_Search_Lucene_Search_QueryToken(Zend_Search_Lucene_Search_QueryToken::TOKTYPE_WORD, $currentToken);
                 $currentToken = '';
             }
             if ($inputString[$count] == '+' || $inputString[$count] == '-') {
                 $this->_tokens[] = new Zend_Search_Lucene_Search_QueryToken(Zend_Search_Lucene_Search_QueryToken::TOKTYPE_SIGN, $inputString[$count]);
             } elseif ($inputString[$count] == '(' || $inputString[$count] == ')') {
                 $this->_tokens[] = new Zend_Search_Lucene_Search_QueryToken(Zend_Search_Lucene_Search_QueryToken::TOKTYPE_BRACKET, $inputString[$count]);
             } elseif ($inputString[$count] == ':' && $this->count()) {
                 if ($this->_tokens[count($this->_tokens) - 1]->type == Zend_Search_Lucene_Search_QueryToken::TOKTYPE_WORD) {
                     $this->_tokens[count($this->_tokens) - 1]->type = Zend_Search_Lucene_Search_QueryToken::TOKTYPE_FIELD;
                 }
             }
         }
     }
     if (strlen($currentToken)) {
         $this->_tokens[] = new Zend_Search_Lucene_Search_QueryToken(Zend_Search_Lucene_Search_QueryToken::TOKTYPE_WORD, $currentToken);
     }
 }
 /**
  * @Route("/zarejestruj-się-na-wymarzone-wakacje", name="register")
  */
 public function displayAction(Request $request)
 {
     $session = new Session();
     $conn = $this->get('database_connection');
     $msg = '';
     if ($request->getMethod() == 'POST') {
         $konto = new Konto();
         $login = $request->request->get('login');
         if ($this->getDoctrine()->getRepository('AppBundle:Konto')->findOneByLogin($login) != '') {
             $msg = 'Login już istnieje!';
         } else {
             if (strlen($login) < 3 || strlen($login) > 20) {
                 $msg = "Login musi posiadać od 3 do 20 znaków!";
             } else {
                 if (ctype_alnum($login) == false) {
                     $msg = "Login może składać się tylko z liter i cyfr (bez polskich znaków)";
                 }
             }
         }
         $konto->setLogin($login);
         $haslo = $request->request->get('password');
         if (strlen($haslo) < 6 || strlen($haslo) > 20) {
             $msg = "Hasło musi posiadać od 6 do 20 znaków!";
         }
         $haslo2 = $request->request->get('password2');
         if ($haslo != $haslo2) {
             $msg = 'Podane hasła nie zgadzają się!';
         }
         $haslo_hash = password_hash($haslo, PASSWORD_DEFAULT);
         $konto->setHaslo($haslo_hash);
         $email = $request->request->get('email');
         $emailB = filter_var($email, FILTER_SANITIZE_EMAIL);
         if (filter_var($emailB, FILTER_VALIDATE_EMAIL) == false || $emailB != $email) {
             $msg = "Podaj poprawny adres e-mail!";
         } else {
             if ($this->getDoctrine()->getRepository('AppBundle:Konto')->findOneByEmail($emailB) != '') {
                 $msg = 'Email już istnieje!';
             }
         }
         $konto->setEmail($emailB);
         $imie = $request->request->get('name');
         $konto->setImie($imie);
         $nazwisko = $request->request->get('surname');
         $konto->setNazwisko($nazwisko);
         $pesel = $request->request->get('pesel');
         $konto->setPesel($pesel);
         $checkbox = $request->request->get('regulamin');
         if (isset($checkbox) == false) {
             $msg = 'Musisz zaakceptować Regulamin!';
         }
         if ($msg == '') {
             $konto->setCzyAdmin('0');
             $em = $this->getDoctrine()->getManager();
             $em->persist($konto);
             $em->flush();
             $msg = 'Utworzono konto!';
         }
     }
     return $this->render('default/register.html.twig', array('session' => $session, 'message' => $msg, 'base_dir' => realpath($this->container->getParameter('kernel.root_dir') . '/..')));
 }