php.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. //error_reporting(E_ALL ^ E_NOTICE); //hide notices
  22. error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings
  23. //error_reporting(E_ALL);
  24. //session handling
  25. //start the session
  26. session_start();
  27. //set the last activity time stamp
  28. $_SESSION['session']['last_activity'] = time();
  29. //check whether to timout the session
  30. //if (isset($_SESSION['session']['last_activity']) && (time() - $_SESSION['session']['last_activity'] > 14400)) {
  31. // session_destroy(); // destroy session data in storage
  32. // session_unset(); // unset $_SESSION variable for the runtime
  33. //}
  34. //regenerate sessions to avoid session id attacks such as session fixation
  35. if (!isset($_SESSION['session']['created'])) {
  36. $_SESSION['session']['created'] = time();
  37. } else if (time() - $_SESSION['session']['created'] > 1800) {
  38. // session started more than 30 minutes ago
  39. session_regenerate_id(true); // rotate the session id
  40. $_SESSION['session']['created'] = time(); // update creation time
  41. }
  42. //get the document_root parent directory
  43. $document_root_parent = join(array_slice(explode("\\",realpath($_SERVER["DOCUMENT_ROOT"])),0,-1), '/');
  44. //if magic quotes is enabled remove the slashes
  45. if (get_magic_quotes_gpc()) {
  46. $in = array(&$_GET, &$_POST, &$_REQUEST, &$_COOKIE);
  47. while (list($k,$v) = each($in)) {
  48. foreach ($v as $key => $val) {
  49. if (!is_array($val)) {
  50. $in[$k][$key] = stripslashes($val);
  51. continue;
  52. }
  53. $in[] =& $in[$k][$key];
  54. }
  55. }
  56. unset($in);
  57. }
  58. ?>