[ Index ]

PHP Cross Reference of phpBB-3.3.7-deutsch

title

Body

[close]

/includes/ -> functions_compatibility.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  /**
  15  * @ignore
  16  */
  17  if (!defined('IN_PHPBB'))
  18  {
  19      exit;
  20  }
  21  
  22  /**
  23  * Get user avatar
  24  *
  25  * @deprecated 3.1.0-a1 (To be removed: 4.0.0)
  26  *
  27  * @param string $avatar Users assigned avatar name
  28  * @param int $avatar_type Type of avatar
  29  * @param string $avatar_width Width of users avatar
  30  * @param string $avatar_height Height of users avatar
  31  * @param string $alt Optional language string for alt tag within image, can be a language key or text
  32  * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
  33  * @param bool $lazy If true, will be lazy loaded (requires JS)
  34  *
  35  * @return string Avatar image
  36  */
  37  function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false, $lazy = false)
  38  {
  39      // map arguments to new function phpbb_get_avatar()
  40      $row = array(
  41          'avatar'        => $avatar,
  42          'avatar_type'    => $avatar_type,
  43          'avatar_width'    => $avatar_width,
  44          'avatar_height'    => $avatar_height,
  45      );
  46  
  47      return phpbb_get_avatar($row, $alt, $ignore_config, $lazy);
  48  }
  49  
  50  /**
  51  * Hash the password
  52  *
  53  * @deprecated 3.1.0-a2 (To be removed: 4.0.0)
  54  *
  55  * @param string $password Password to be hashed
  56  *
  57  * @return string|bool Password hash or false if something went wrong during hashing
  58  */
  59  function phpbb_hash($password)
  60  {
  61      global $phpbb_container;
  62  
  63      /* @var $passwords_manager \phpbb\passwords\manager */
  64      $passwords_manager = $phpbb_container->get('passwords.manager');
  65      return $passwords_manager->hash($password);
  66  }
  67  
  68  /**
  69  * Check for correct password
  70  *
  71  * @deprecated 3.1.0-a2 (To be removed: 4.0.0)
  72  *
  73  * @param string $password The password in plain text
  74  * @param string $hash The stored password hash
  75  *
  76  * @return bool Returns true if the password is correct, false if not.
  77  */
  78  function phpbb_check_hash($password, $hash)
  79  {
  80      global $phpbb_container;
  81  
  82      /* @var $passwords_manager \phpbb\passwords\manager */
  83      $passwords_manager = $phpbb_container->get('passwords.manager');
  84      return $passwords_manager->check($password, $hash);
  85  }
  86  
  87  /**
  88  * Eliminates useless . and .. components from specified path.
  89  *
  90  * Deprecated, use filesystem class instead
  91  *
  92  * @param string $path Path to clean
  93  * @return string Cleaned path
  94  *
  95  * @deprecated 3.1.0 (To be removed: 4.0.0)
  96  */
  97  function phpbb_clean_path($path)
  98  {
  99      global $phpbb_path_helper, $phpbb_container;
 100  
 101      if (!$phpbb_path_helper && $phpbb_container)
 102      {
 103          /* @var $phpbb_path_helper \phpbb\path_helper */
 104          $phpbb_path_helper = $phpbb_container->get('path_helper');
 105      }
 106      else if (!$phpbb_path_helper)
 107      {
 108          global $phpbb_root_path, $phpEx;
 109  
 110          // The container is not yet loaded, use a new instance
 111          if (!class_exists('\phpbb\path_helper'))
 112          {
 113              require($phpbb_root_path . 'phpbb/path_helper.' . $phpEx);
 114          }
 115  
 116          $request = new phpbb\request\request();
 117          $phpbb_path_helper = new phpbb\path_helper(
 118              new phpbb\symfony_request(
 119                  $request
 120              ),
 121              new phpbb\filesystem\filesystem(),
 122              $request,
 123              $phpbb_root_path,
 124              $phpEx
 125          );
 126      }
 127  
 128      return $phpbb_path_helper->clean_path($path);
 129  }
 130  
 131  /**
 132  * Pick a timezone
 133  *
 134  * @param    string        $default            A timezone to select
 135  * @param    boolean        $truncate            Shall we truncate the options text
 136  *
 137  * @return        string        Returns the options for timezone selector only
 138  *
 139  * @deprecated 3.1.0 (To be removed: 4.0.0)
 140  */
 141  function tz_select($default = '', $truncate = false)
 142  {
 143      global $template, $user;
 144  
 145      return phpbb_timezone_select($template, $user, $default, $truncate);
 146  }
 147  
 148  /**
 149  * Cache moderators. Called whenever permissions are changed
 150  * via admin_permissions. Changes of usernames and group names
 151  * must be carried through for the moderators table.
 152  *
 153  * @deprecated 3.1.0 (To be removed: 4.0.0)
 154  * @return null
 155  */
 156  function cache_moderators()
 157  {
 158      global $db, $cache, $auth;
 159      return phpbb_cache_moderators($db, $cache, $auth);
 160  }
 161  
 162  /**
 163  * Removes moderators and administrators from foe lists.
 164  *
 165  * @deprecated 3.1.0 (To be removed: 4.0.0)
 166  * @param array|bool $group_id If an array, remove all members of this group from foe lists, or false to ignore
 167  * @param array|bool $user_id If an array, remove this user from foe lists, or false to ignore
 168  * @return null
 169  */
 170  function update_foes($group_id = false, $user_id = false)
 171  {
 172      global $db, $auth;
 173      return phpbb_update_foes($db, $auth, $group_id, $user_id);
 174  }
 175  
 176  /**
 177  * Get user rank title and image
 178  *
 179  * @param int $user_rank the current stored users rank id
 180  * @param int $user_posts the users number of posts
 181  * @param string &$rank_title the rank title will be stored here after execution
 182  * @param string &$rank_img the rank image as full img tag is stored here after execution
 183  * @param string &$rank_img_src the rank image source is stored here after execution
 184  *
 185  * @deprecated 3.1.0-RC5 (To be removed: 4.0.0)
 186  *
 187  * Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false
 188  */
 189  function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
 190  {
 191      global $phpbb_root_path, $phpEx;
 192      if (!function_exists('phpbb_get_user_rank'))
 193      {
 194          include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
 195      }
 196  
 197      $rank_data = phpbb_get_user_rank(array('user_rank' => $user_rank), $user_posts);
 198      $rank_title = $rank_data['title'];
 199      $rank_img = $rank_data['img'];
 200      $rank_img_src = $rank_data['img_src'];
 201  }
 202  
 203  /**
 204   * Retrieve contents from remotely stored file
 205   *
 206   * @deprecated    3.1.2    Use file_downloader instead
 207   */
 208  function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 6)
 209  {
 210      global $phpbb_container;
 211  
 212      // Get file downloader and assign $errstr and $errno
 213      /* @var $file_downloader \phpbb\file_downloader */
 214      $file_downloader = $phpbb_container->get('file_downloader');
 215  
 216      $file_data = $file_downloader->get($host, $directory, $filename, $port, $timeout);
 217      $errstr = $file_downloader->get_error_string();
 218      $errno = $file_downloader->get_error_number();
 219  
 220      return $file_data;
 221  }
 222  
 223  /**
 224   * Add log entry
 225   *
 226   * string    $mode                The mode defines which log_type is used and from which log the entry is retrieved
 227   * int        $forum_id            Mode 'mod' ONLY: forum id of the related item, NOT INCLUDED otherwise
 228   * int        $topic_id            Mode 'mod' ONLY: topic id of the related item, NOT INCLUDED otherwise
 229   * int        $reportee_id        Mode 'user' ONLY: user id of the reportee, NOT INCLUDED otherwise
 230   * string    $log_operation        Name of the operation
 231   * array    $additional_data    More arguments can be added, depending on the log_type
 232   *
 233   * @return    int|bool        Returns the log_id, if the entry was added to the database, false otherwise.
 234   *
 235   * @deprecated    3.1.0 (To be removed: 4.0.0)
 236   */
 237  function add_log()
 238  {
 239      global $phpbb_log, $user;
 240  
 241      $args = func_get_args();
 242      $mode = array_shift($args);
 243  
 244      // This looks kind of dirty, but add_log has some additional data before the log_operation
 245      $additional_data = array();
 246      switch ($mode)
 247      {
 248          case 'admin':
 249          case 'critical':
 250              break;
 251          case 'mod':
 252              $additional_data['forum_id'] = array_shift($args);
 253              $additional_data['topic_id'] = array_shift($args);
 254              break;
 255          case 'user':
 256              $additional_data['reportee_id'] = array_shift($args);
 257              break;
 258      }
 259  
 260      $log_operation = array_shift($args);
 261      $additional_data = array_merge($additional_data, $args);
 262  
 263      $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id'];
 264      $user_ip = (empty($user->ip)) ? '' : $user->ip;
 265  
 266      return $phpbb_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data);
 267  }
 268  
 269  /**
 270   * Sets a configuration option's value.
 271   *
 272   * Please note that this function does not update the is_dynamic value for
 273   * an already existing config option.
 274   *
 275   * @param string $config_name   The configuration option's name
 276   * @param string $config_value  New configuration value
 277   * @param bool   $is_dynamic    Whether this variable should be cached (false) or
 278   *                              if it changes too frequently (true) to be
 279   *                              efficiently cached.
 280   *
 281   * @return null
 282   *
 283   * @deprecated 3.1.0 (To be removed: 4.0.0)
 284   */
 285  function set_config($config_name, $config_value, $is_dynamic = false, \phpbb\config\config $set_config = null)
 286  {
 287      static $config = null;
 288  
 289      if ($set_config !== null)
 290      {
 291          $config = $set_config;
 292  
 293          if (empty($config_name))
 294          {
 295              return;
 296          }
 297      }
 298  
 299      $config->set($config_name, $config_value, !$is_dynamic);
 300  }
 301  
 302  /**
 303   * Increments an integer config value directly in the database.
 304   *
 305   * @param string $config_name   The configuration option's name
 306   * @param int    $increment     Amount to increment by
 307   * @param bool   $is_dynamic    Whether this variable should be cached (false) or
 308   *                              if it changes too frequently (true) to be
 309   *                              efficiently cached.
 310   *
 311   * @return null
 312   *
 313   * @deprecated 3.1.0 (To be removed: 4.0.0)
 314   */
 315  function set_config_count($config_name, $increment, $is_dynamic = false, \phpbb\config\config $set_config = null)
 316  {
 317      static $config = null;
 318      if ($set_config !== null)
 319      {
 320          $config = $set_config;
 321          if (empty($config_name))
 322          {
 323              return;
 324          }
 325      }
 326      $config->increment($config_name, $increment, !$is_dynamic);
 327  }
 328  
 329  /**
 330   * Wrapper function of \phpbb\request\request::variable which exists for backwards compatability.
 331   * See {@link \phpbb\request\request_interface::variable \phpbb\request\request_interface::variable} for
 332   * documentation of this function's use.
 333   *
 334   * @deprecated 3.1.0 (To be removed: 4.0.0)
 335   * @param    mixed            $var_name    The form variable's name from which data shall be retrieved.
 336   *                                         If the value is an array this may be an array of indizes which will give
 337   *                                         direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a")
 338   *                                         then specifying array("var", 1) as the name will return "a".
 339   *                                         If you pass an instance of {@link \phpbb\request\request_interface phpbb_request_interface}
 340   *                                         as this parameter it will overwrite the current request class instance. If you do
 341   *                                         not do so, it will create its own instance (but leave superglobals enabled).
 342   * @param    mixed            $default    A default value that is returned if the variable was not set.
 343   *                                         This function will always return a value of the same type as the default.
 344   * @param    bool            $multibyte    If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters
 345   *                                        Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
 346   * @param    bool            $cookie        This param is mapped to \phpbb\request\request_interface::COOKIE as the last param for
 347   *                                         \phpbb\request\request_interface::variable for backwards compatability reasons.
 348   * @param    \phpbb\request\request_interface|null|false    $request
 349   *                                         If an instance of \phpbb\request\request_interface is given the instance is stored in
 350   *                                        a static variable and used for all further calls where this parameters is null. Until
 351   *                                        the function is called with an instance it automatically creates a new \phpbb\request\request
 352   *                                        instance on every call. By passing false this per-call instantiation can be restored
 353   *                                        after having passed in a \phpbb\request\request_interface instance.
 354   *
 355   * @return    mixed    The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
 356   *                     the same as that of $default. If the variable is not set $default is returned.
 357   */
 358  function request_var($var_name, $default, $multibyte = false, $cookie = false, $request = null)
 359  {
 360      // This is all just an ugly hack to add "Dependency Injection" to a function
 361      // the only real code is the function call which maps this function to a method.
 362      static $static_request = null;
 363      if ($request instanceof \phpbb\request\request_interface)
 364      {
 365          $static_request = $request;
 366          if (empty($var_name))
 367          {
 368              return;
 369          }
 370      }
 371      else if ($request === false)
 372      {
 373          $static_request = null;
 374          if (empty($var_name))
 375          {
 376              return;
 377          }
 378      }
 379      $tmp_request = $static_request;
 380      // no request class set, create a temporary one ourselves to keep backwards compatibility
 381      if ($tmp_request === null)
 382      {
 383          // false param: enable super globals, so the created request class does not
 384          // make super globals inaccessible everywhere outside this function.
 385          $tmp_request = new \phpbb\request\request(new \phpbb\request\type_cast_helper(), false);
 386      }
 387      return $tmp_request->variable($var_name, $default, $multibyte, ($cookie) ? \phpbb\request\request_interface::COOKIE : \phpbb\request\request_interface::REQUEST);
 388  }
 389  
 390  /**
 391   * Get tables of a database
 392   *
 393   * @deprecated 3.1.0 (To be removed: 4.0.0)
 394   */
 395  function get_tables($db)
 396  {
 397      $db_tools_factory = new \phpbb\db\tools\factory();
 398      $db_tools = $db_tools_factory->get($db);
 399  
 400      return $db_tools->sql_list_tables();
 401  }
 402  
 403  /**
 404   * Global function for chmodding directories and files for internal use
 405   *
 406   * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions.
 407   * The function determines owner and group from common.php file and sets the same to the provided file.
 408   * The function uses bit fields to build the permissions.
 409   * The function sets the appropiate execute bit on directories.
 410   *
 411   * Supported constants representing bit fields are:
 412   *
 413   * CHMOD_ALL - all permissions (7)
 414   * CHMOD_READ - read permission (4)
 415   * CHMOD_WRITE - write permission (2)
 416   * CHMOD_EXECUTE - execute permission (1)
 417   *
 418   * NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions.
 419   *
 420   * @param string    $filename    The file/directory to be chmodded
 421   * @param int    $perms        Permissions to set
 422   *
 423   * @return bool    true on success, otherwise false
 424   *
 425   * @deprecated 3.2.0-dev    use \phpbb\filesystem\filesystem::phpbb_chmod() instead
 426   */
 427  function phpbb_chmod($filename, $perms = CHMOD_READ)
 428  {
 429      global $phpbb_filesystem;
 430  
 431      try
 432      {
 433          $phpbb_filesystem->phpbb_chmod($filename, $perms);
 434      }
 435      catch (\phpbb\filesystem\exception\filesystem_exception $e)
 436      {
 437          return false;
 438      }
 439  
 440      return true;
 441  }
 442  
 443  /**
 444   * Test if a file/directory is writable
 445   *
 446   * This function calls the native is_writable() when not running under
 447   * Windows and it is not disabled.
 448   *
 449   * @param string $file Path to perform write test on
 450   * @return bool True when the path is writable, otherwise false.
 451   *
 452   * @deprecated 3.2.0-dev    use \phpbb\filesystem\filesystem::is_writable() instead
 453   */
 454  function phpbb_is_writable($file)
 455  {
 456      global $phpbb_filesystem;
 457  
 458      return $phpbb_filesystem->is_writable($file);
 459  }
 460  
 461  /**
 462   * Checks if a path ($path) is absolute or relative
 463   *
 464   * @param string $path Path to check absoluteness of
 465   * @return boolean
 466   *
 467   * @deprecated 3.2.0-dev    use \phpbb\filesystem\filesystem::is_absolute_path() instead
 468   */
 469  function phpbb_is_absolute($path)
 470  {
 471      global $phpbb_filesystem;
 472  
 473      return $phpbb_filesystem->is_absolute_path($path);
 474  }
 475  
 476  /**
 477   * A wrapper for realpath
 478   *
 479   * @deprecated 3.2.0-dev    use \phpbb\filesystem\filesystem::realpath() instead
 480   */
 481  function phpbb_realpath($path)
 482  {
 483      global $phpbb_filesystem;
 484  
 485      return $phpbb_filesystem->realpath($path);
 486  }
 487  
 488  /**
 489   * Determine which plural form we should use.
 490   * For some languages this is not as simple as for English.
 491   *
 492   * @param    int            $rule    ID of the plural rule we want to use, see https://area51.phpbb.com/docs/dev/3.3.x/language/plurals.html
 493   * @param    int|float    $number    The number we want to get the plural case for. Float numbers are floored.
 494   * @return    int        The plural-case we need to use for the number plural-rule combination
 495   *
 496   * @deprecated 3.2.0-dev (To be removed: 4.0.0)
 497   */
 498  function phpbb_get_plural_form($rule, $number)
 499  {
 500      global $phpbb_container;
 501  
 502      /** @var \phpbb\language\language $language */
 503      $language = $phpbb_container->get('language');
 504      return $language->get_plural_form($number, $rule);
 505  }
 506  
 507  /**
 508  * @return bool Always true
 509  * @deprecated 3.2.0-dev
 510  */
 511  function phpbb_pcre_utf8_support()
 512  {
 513      return true;
 514  }
 515  
 516  /**
 517   * Casts a variable to the given type.
 518   *
 519   * @deprecated 3.1 (To be removed 4.0.0)
 520   */
 521  function set_var(&$result, $var, $type, $multibyte = false)
 522  {
 523      // no need for dependency injection here, if you have the object, call the method yourself!
 524      $type_cast_helper = new \phpbb\request\type_cast_helper();
 525      $type_cast_helper->set_var($result, $var, $type, $multibyte);
 526  }
 527  
 528  /**
 529   * Delete Attachments
 530   *
 531   * @deprecated 3.2.0-a1 (To be removed: 4.0.0)
 532   *
 533   * @param string $mode can be: post|message|topic|attach|user
 534   * @param mixed $ids can be: post_ids, message_ids, topic_ids, attach_ids, user_ids
 535   * @param bool $resync set this to false if you are deleting posts or topics
 536   */
 537  function delete_attachments($mode, $ids, $resync = true)
 538  {
 539      global $phpbb_container;
 540  
 541      /** @var \phpbb\attachment\manager $attachment_manager */
 542      $attachment_manager = $phpbb_container->get('attachment.manager');
 543      $num_deleted = $attachment_manager->delete($mode, $ids, $resync);
 544  
 545      unset($attachment_manager);
 546  
 547      return $num_deleted;
 548  }
 549  
 550  /**
 551   * Delete attached file
 552   *
 553   * @deprecated 3.2.0-a1 (To be removed: 4.0.0)
 554   */
 555  function phpbb_unlink($filename, $mode = 'file', $entry_removed = false)
 556  {
 557      global $phpbb_container;
 558  
 559      /** @var \phpbb\attachment\manager $attachment_manager */
 560      $attachment_manager = $phpbb_container->get('attachment.manager');
 561      $unlink = $attachment_manager->unlink($filename, $mode, $entry_removed);
 562      unset($attachment_manager);
 563  
 564      return $unlink;
 565  }
 566  
 567  /**
 568   * Display reasons
 569   *
 570   * @deprecated 3.2.0-dev (To be removed: 4.0.0)
 571   */
 572  function display_reasons($reason_id = 0)
 573  {
 574      global $phpbb_container;
 575  
 576      $phpbb_container->get('phpbb.report.report_reason_list_provider')->display_reasons($reason_id);
 577  }
 578  
 579  /**
 580   * Upload Attachment - filedata is generated here
 581   * Uses upload class
 582   *
 583   * @deprecated 3.2.0-a1 (To be removed: 4.0.0)
 584   *
 585   * @param string            $form_name        The form name of the file upload input
 586   * @param int            $forum_id        The id of the forum
 587   * @param bool            $local            Whether the file is local or not
 588   * @param string            $local_storage    The path to the local file
 589   * @param bool            $is_message        Whether it is a PM or not
 590   * @param array            $local_filedata    A filespec object created for the local file
 591   *
 592   * @return array File data array
 593   */
 594  function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false)
 595  {
 596      global $phpbb_container;
 597  
 598      /** @var \phpbb\attachment\manager $attachment_manager */
 599      $attachment_manager = $phpbb_container->get('attachment.manager');
 600      $file = $attachment_manager->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata);
 601      unset($attachment_manager);
 602  
 603      return $file;
 604  }
 605  
 606  /**
 607  * Wrapper for php's checkdnsrr function.
 608  *
 609  * @param string $host    Fully-Qualified Domain Name
 610  * @param string $type    Resource record type to lookup
 611  *                        Supported types are: MX (default), A, AAAA, NS, TXT, CNAME
 612  *                        Other types may work or may not work
 613  *
 614  * @return mixed        true if entry found,
 615  *                    false if entry not found,
 616  *                    null if this function is not supported by this environment
 617  *
 618  * Since null can also be returned, you probably want to compare the result
 619  * with === true or === false,
 620  *
 621  * @deprecated 3.3.0-b2 (To be removed: 4.0.0)
 622  */
 623  function phpbb_checkdnsrr($host, $type = 'MX')
 624  {
 625      return checkdnsrr($host, $type);
 626  }
 627  
 628  /*
 629   * Wrapper for inet_ntop()
 630   *
 631   * Converts a packed internet address to a human readable representation
 632   * inet_ntop() is supported by PHP since 5.1.0, since 5.3.0 also on Windows.
 633   *
 634   * @param string $in_addr    A 32bit IPv4, or 128bit IPv6 address.
 635   *
 636   * @return mixed        false on failure,
 637   *                    string otherwise
 638    *
 639   * @deprecated 3.3.0-b2 (To be removed: 4.0.0)
 640   */
 641  function phpbb_inet_ntop($in_addr)
 642  {
 643      return inet_ntop($in_addr);
 644  }
 645  
 646  /**
 647   * Wrapper for inet_pton()
 648   *
 649   * Converts a human readable IP address to its packed in_addr representation
 650   * inet_pton() is supported by PHP since 5.1.0, since 5.3.0 also on Windows.
 651   *
 652   * @param string $address    A human readable IPv4 or IPv6 address.
 653   *
 654   * @return mixed        false if address is invalid,
 655   *                    in_addr representation of the given address otherwise (string)
 656   *
 657   * @deprecated 3.3.0-b2 (To be removed: 4.0.0)
 658   */
 659  function phpbb_inet_pton($address)
 660  {
 661      return inet_pton($address);
 662  }
 663  
 664  /**
 665   * Hashes an email address to a big integer
 666   *
 667   * @param string $email        Email address
 668   *
 669   * @return string            Unsigned Big Integer
 670   *
 671   * @deprecated 3.3.0-b2 (To be removed: 4.0.0)
 672   */
 673  function phpbb_email_hash($email)
 674  {
 675      return sprintf('%u', crc32(strtolower($email))) . strlen($email);
 676  }
 677  
 678  /**
 679   * Load the autoloaders added by the extensions.
 680   *
 681   * @param string $phpbb_root_path Path to the phpbb root directory.
 682   */
 683  function phpbb_load_extensions_autoloaders($phpbb_root_path)
 684  {
 685      $iterator = new \RecursiveIteratorIterator(
 686          new \phpbb\recursive_dot_prefix_filter_iterator(
 687              new \RecursiveDirectoryIterator(
 688                  $phpbb_root_path . 'ext/',
 689                  \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS
 690              )
 691          ),
 692          \RecursiveIteratorIterator::SELF_FIRST
 693      );
 694      $iterator->setMaxDepth(2);
 695  
 696      foreach ($iterator as $file_info)
 697      {
 698          if ($file_info->getFilename() === 'vendor' && $iterator->getDepth() === 2)
 699          {
 700              $filename = $file_info->getRealPath() . '/autoload.php';
 701              if (file_exists($filename))
 702              {
 703                  require $filename;
 704              }
 705          }
 706      }
 707  }
 708  
 709  /**
 710  * Login using http authenticate.
 711  *
 712  * @param array    $param        Parameter array, see $param_defaults array.
 713  *
 714  * @return null
 715  *
 716  * @deprecated 3.2.10 (To be removed 4.0.0)
 717  */
 718  function phpbb_http_login($param)
 719  {
 720      global $auth, $user, $request;
 721      global $config;
 722  
 723      $param_defaults = array(
 724          'auth_message'    => '',
 725  
 726          'autologin'        => false,
 727          'viewonline'    => true,
 728          'admin'            => false,
 729      );
 730  
 731      // Overwrite default values with passed values
 732      $param = array_merge($param_defaults, $param);
 733  
 734      // User is already logged in
 735      // We will not overwrite his session
 736      if (!empty($user->data['is_registered']))
 737      {
 738          return;
 739      }
 740  
 741      // $_SERVER keys to check
 742      $username_keys = array(
 743          'PHP_AUTH_USER',
 744          'Authorization',
 745          'REMOTE_USER', 'REDIRECT_REMOTE_USER',
 746          'HTTP_AUTHORIZATION', 'REDIRECT_HTTP_AUTHORIZATION',
 747          'REMOTE_AUTHORIZATION', 'REDIRECT_REMOTE_AUTHORIZATION',
 748          'AUTH_USER',
 749      );
 750  
 751      $password_keys = array(
 752          'PHP_AUTH_PW',
 753          'REMOTE_PASSWORD',
 754          'AUTH_PASSWORD',
 755      );
 756  
 757      $username = null;
 758      foreach ($username_keys as $k)
 759      {
 760          if ($request->is_set($k, \phpbb\request\request_interface::SERVER))
 761          {
 762              $username = htmlspecialchars_decode($request->server($k), ENT_COMPAT);
 763              break;
 764          }
 765      }
 766  
 767      $password = null;
 768      foreach ($password_keys as $k)
 769      {
 770          if ($request->is_set($k, \phpbb\request\request_interface::SERVER))
 771          {
 772              $password = htmlspecialchars_decode($request->server($k), ENT_COMPAT);
 773              break;
 774          }
 775      }
 776  
 777      // Decode encoded information (IIS, CGI, FastCGI etc.)
 778      if (!is_null($username) && is_null($password) && strpos($username, 'Basic ') === 0)
 779      {
 780          list($username, $password) = explode(':', base64_decode(substr($username, 6)), 2);
 781      }
 782  
 783      if (!is_null($username) && !is_null($password))
 784      {
 785          set_var($username, $username, 'string', true);
 786          set_var($password, $password, 'string', true);
 787  
 788          $auth_result = $auth->login($username, $password, $param['autologin'], $param['viewonline'], $param['admin']);
 789  
 790          if ($auth_result['status'] == LOGIN_SUCCESS)
 791          {
 792              return;
 793          }
 794          else if ($auth_result['status'] == LOGIN_ERROR_ATTEMPTS)
 795          {
 796              send_status_line(401, 'Unauthorized');
 797  
 798              trigger_error('NOT_AUTHORISED');
 799          }
 800      }
 801  
 802      // Prepend sitename to auth_message
 803      $param['auth_message'] = ($param['auth_message'] === '') ? $config['sitename'] : $config['sitename'] . ' - ' . $param['auth_message'];
 804  
 805      // We should probably filter out non-ASCII characters - RFC2616
 806      $param['auth_message'] = preg_replace('/[\x80-\xFF]/', '?', $param['auth_message']);
 807  
 808      header('WWW-Authenticate: Basic realm="' . $param['auth_message'] . '"');
 809      send_status_line(401, 'Unauthorized');
 810  
 811      trigger_error('NOT_AUTHORISED');
 812  }
 813  
 814  /**
 815  * Converts query string (GET) parameters in request into hidden fields.
 816  *
 817  * Useful for forwarding GET parameters when submitting forms with GET method.
 818  *
 819  * It is possible to omit some of the GET parameters, which is useful if
 820  * they are specified in the form being submitted.
 821  *
 822  * sid is always omitted.
 823  *
 824  * @param \phpbb\request\request $request Request object
 825  * @param array $exclude A list of variable names that should not be forwarded
 826  * @return string HTML with hidden fields
 827  *
 828  * @deprecated 3.2.10 (To be removed 4.0.0)
 829  */
 830  function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
 831  {
 832      $names = $request->variable_names(\phpbb\request\request_interface::GET);
 833      $hidden = '';
 834      foreach ($names as $name)
 835      {
 836          // Sessions are dealt with elsewhere, omit sid always
 837          if ($name == 'sid')
 838          {
 839              continue;
 840          }
 841  
 842          // Omit any additional parameters requested
 843          if (!empty($exclude) && in_array($name, $exclude))
 844          {
 845              continue;
 846          }
 847  
 848          $escaped_name = phpbb_quoteattr($name);
 849  
 850          // Note: we might retrieve the variable from POST or cookies
 851          // here. To avoid exposing cookies, skip variables that are
 852          // overwritten somewhere other than GET entirely.
 853          $value = $request->variable($name, '', true);
 854          $get_value = $request->variable($name, '', true, \phpbb\request\request_interface::GET);
 855          if ($value === $get_value)
 856          {
 857              $escaped_value = phpbb_quoteattr($value);
 858              $hidden .= "<input type='hidden' name=$escaped_name value=$escaped_value />";
 859          }
 860      }
 861      return $hidden;
 862  }
 863  
 864  /**
 865  * Delete all PM(s) for a given user and delete the ones without references
 866  *
 867  * @param    int        $user_id    ID of the user whose private messages we want to delete
 868  *
 869  * @return    boolean        False if there were no pms found, true otherwise.
 870  *
 871  * @deprecated 3.2.10 (To be removed 4.0.0)
 872  */
 873  function phpbb_delete_user_pms($user_id)
 874  {
 875      $user_id = (int) $user_id;
 876  
 877      if (!$user_id)
 878      {
 879          return false;
 880      }
 881  
 882      return phpbb_delete_users_pms(array($user_id));
 883  }


Generated: Thu Mar 24 21:31:15 2022 Cross-referenced by PHPXref 0.7.1