Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

helper.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 2.67 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  namespace phpbb\passwords;
015   
016  class helper
017  {
018      /**
019      * Get hash settings from combined hash
020      *
021      * @param string $hash Password hash of combined hash
022      *
023      * @return array An array containing the hash settings for the hash
024      *        types in successive order as described by the combined
025      *        password hash or an empty array if hash does not
026      *        properly fit the combined hash format
027      */
028      public function get_combined_hash_settings($hash)
029      {
030          $output = array();
031   
032          preg_match('#^\$([a-zA-Z0-9\\\]*?)\$#', $hash, $match);
033          $hash_settings = substr($hash, strpos($hash, $match[1]) + strlen($match[1]) + 1);
034          $matches = explode('\\', $match[1]);
035          foreach ($matches as $cur_type)
036          {
037              $dollar_position = strpos($hash_settings, '$');
038              $output[] = substr($hash_settings, 0, ($dollar_position != false) ? $dollar_position : strlen($hash_settings));
039              $hash_settings = substr($hash_settings, $dollar_position + 1);
040          }
041   
042          return $output;
043      }
044   
045      /**
046      * Combine hash prefixes, settings, and actual hash
047      *
048      * @param array $data Array containing the keys 'prefix' and 'settings'.
049      *            It will hold the prefixes and settings
050      * @param string $type Data type of the supplied value
051      * @param string $value Value that should be put into the data array
052      *
053      * @return string|null Return complete combined hash if type is neither
054      *            'prefix' nor 'settings', nothing if it is
055      */
056      public function combine_hash_output(&$data, $type, $value)
057      {
058          if ($type == 'prefix')
059          {
060              $data[$type] .= ($data[$type] !== '$') ? '\\' : '';
061              $data[$type] .= str_replace('$', '', $value);
062          }
063          else if ($type == 'settings')
064          {
065              $data[$type] .= ($data[$type] !== '$') ? '$' : '';
066              $data[$type] .= $value;
067          }
068          else
069          {
070              // Return full hash
071              return $data['prefix'] . $data['settings'] . '$' . $value;
072          }
073      }
074   
075      /**
076      * Rebuild hash for hashing functions
077      *
078      * @param string $prefix Hash prefix
079      * @param string $settings Hash settings
080      *
081      * @return string Rebuilt hash for hashing functions
082      */
083      public function rebuild_hash($prefix, $settings)
084      {
085          $rebuilt_hash = $prefix;
086          if (strpos($settings, '\\') !== false)
087          {
088              $settings = str_replace('\\', '$', $settings);
089          }
090          $rebuilt_hash .= $settings;
091          return $rebuilt_hash;
092      }
093   
094      /**
095      * Obtain only the actual hash after the prefixes
096      *
097      * @param string        $hash The full password hash
098      * @return string    Actual hash (incl. settings)
099      */
100      public function obtain_hash_only($hash)
101      {
102          return substr($hash, strripos($hash, '$') + 1);
103      }
104  }
105