PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/public/codeCore/Classes/php/Security.php

https://github.com/IAmCorbin/MooKit
PHP | 44 lines | 21 code | 0 blank | 23 comment | 3 complexity | 23c10bb2ed8b7baf46330fe1be23e480 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * contains Security Class
  4. * @package MooKit
  5. */
  6. /**
  7. * Security Class
  8. *
  9. * a static class for checking user session credentials
  10. *
  11. * @author Corbin Tarrant
  12. * @copyright March 15th, 2010
  13. * @link http://www.IAmCorbin.net
  14. * @package MooKit
  15. */
  16. class Security {
  17. /**
  18. * Security Check
  19. * $returns int user's current access_level
  20. **/
  21. public static function clearance() {
  22. if(!isset($_SESSION['auth'])) {
  23. $_SESSION['auth'] = 0;
  24. $_SESSION['access_level'] = 0;
  25. return false;
  26. }
  27. //check for authorization, ip address and valid user
  28. if( $_SESSION['auth'] === 1 && Security::checkUser() )
  29. return $_SESSION['access_level'];
  30. else
  31. return false;
  32. }
  33. /**
  34. * Validate IP
  35. */
  36. public static function checkIP() {
  37. return ($_SESSION['ip'] === $_SERVER['REMOTE_ADDR'] ? true : false);
  38. }
  39. /** Validate User */
  40. public static function checkUser() {
  41. return isset($_SESSION['alias']);
  42. }
  43. }
  44. ?>