TYPO3 CMS  TYPO3_8-7
Evaluator.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 class Evaluator
21 {
29  protected $mode = null;
30 
37  public function returnFieldJS()
38  {
39  return 'return value;';
40  }
41 
50  public function evaluateFieldValue($value, $is_in, &$set)
51  {
53  if ($isEnabled) {
54  $isMD5 = preg_match('/[0-9abcdef]{32,32}/', $value);
55  $hashingMethod = substr($value, 0, 2);
56  $isDeprecatedSaltedHash = ($hashingMethod === 'C$' || $hashingMethod === 'M$');
58  $objInstanceSaltedPW = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(null, $this->mode);
59  if ($isMD5) {
60  $set = true;
61  $value = 'M' . $objInstanceSaltedPW->getHashedPassword($value);
62  } else {
63  // Determine method used for the (possibly) salted hashed password
64  $tempValue = $isDeprecatedSaltedHash ? substr($value, 1) : $value;
65  $tempObjInstanceSaltedPW = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance($tempValue);
66  if (!is_object($tempObjInstanceSaltedPW)) {
67  $set = true;
68  $value = $objInstanceSaltedPW->getHashedPassword($value);
69  }
70  }
71  }
72  return $value;
73  }
74 }
static getSaltingInstance($saltedHash='', $mode=TYPO3_MODE)
Definition: SaltFactory.php:83