php.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //session handling
  22. //start the session
  23. if (function_exists('session_start')) {
  24. if (!isset($_SESSION)) {
  25. session_start();
  26. }
  27. }
  28. //regenerate sessions to avoid session id attacks such as session fixation
  29. if (array_key_exists('security',$_SESSION) && $_SESSION['security']['session_rotate']['boolean'] == "true") {
  30. $_SESSION['session']['last_activity'] = time();
  31. if (!isset($_SESSION['session']['created'])) {
  32. $_SESSION['session']['created'] = time();
  33. } else if (time() - $_SESSION['session']['created'] > 28800) {
  34. // session started more than 8 hours ago
  35. session_regenerate_id(true); // rotate the session id
  36. $_SESSION['session']['created'] = time(); // update creation time
  37. }
  38. }
  39. //get the document_root parent directory
  40. $document_root_parent = join(array_slice(explode("\\",realpath($_SERVER["DOCUMENT_ROOT"])),0,-1), '/');
  41. //if magic quotes is enabled remove the slashes
  42. if (get_magic_quotes_gpc()) {
  43. $in = array(&$_GET, &$_POST, &$_REQUEST, &$_COOKIE);
  44. while (list($k,$v) = each($in)) {
  45. foreach ($v as $key => $val) {
  46. if (!is_array($val)) {
  47. $in[$k][$key] = stripslashes($val);
  48. continue;
  49. }
  50. $in[] =& $in[$k][$key];
  51. }
  52. }
  53. unset($in);
  54. }
  55. ?>