PageRenderTime 37ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/system/application/libraries/Statuscheck.php

http://github.com/prashants/webzash
PHP | 94 lines | 77 code | 13 blank | 4 comment | 25 complexity | cd94567243bf56225f609c4a672aaa1c MD5 | raw file
Possible License(s): Apache-2.0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Statuscheck {
  3. var $error_messages = array();
  4. function Statuscheck()
  5. {
  6. $this->error_messages = array();
  7. }
  8. function check_permissions()
  9. {
  10. $CI =& get_instance();
  11. /* Writable check */
  12. $check_path = $CI->config->item('config_path') . "settings/";
  13. if (! is_writable($check_path))
  14. {
  15. $this->error_messages[] = 'Application settings directory "' . $check_path . '" is not writable. You will not able to edit any application related settings.';
  16. }
  17. $check_path = $CI->config->item('config_path') . "accounts/";
  18. if (! is_writable($check_path))
  19. {
  20. $this->error_messages[] = 'Account settings directory "' . $check_path . '" is not writable. You will not able to add or edit any account related settings.';
  21. }
  22. $check_path = $CI->config->item('config_path') . "users/";
  23. if (! is_writable($check_path))
  24. {
  25. $this->error_messages[] = 'User directory "' . $check_path . '" is not writable. You will not able to add or edit any users.';
  26. }
  27. $check_path = $CI->config->item('backup_path');
  28. if (! is_writable($check_path))
  29. {
  30. $this->error_messages[] = 'Backup directory "' . $check_path . '" is not writable. You will not able to save or download any backups.';
  31. }
  32. /* Security checks */
  33. $check_path = $CI->config->item('config_path');
  34. if (substr(symbolic_permissions(fileperms($check_path)), -3, 1) == "r")
  35. {
  36. $this->error_messages[] = 'Security Risk ! The application config directory "' . $check_path . '" is world readable.';
  37. }
  38. if (substr(symbolic_permissions(fileperms($check_path)), -2, 1) == "W")
  39. {
  40. $this->error_messages[] = 'Security Risk ! The application config directory "' . $check_path . '" is world writeable.';
  41. }
  42. $check_path = $CI->config->item('config_path') . "accounts/";
  43. if (substr(symbolic_permissions(fileperms($check_path)), -3, 1) == "r")
  44. {
  45. $this->error_messages[] = 'Security Risk ! The application accounts directory "' . $check_path . '" is world readable.';
  46. }
  47. if (substr(symbolic_permissions(fileperms($check_path)), -2, 1) == "W")
  48. {
  49. $this->error_messages[] = 'Security Risk ! The application accounts directory "' . $check_path . '" is world writeable.';
  50. }
  51. $check_path = $CI->config->item('config_path') . "users/";
  52. if (substr(symbolic_permissions(fileperms($check_path)), -3, 1) == "r")
  53. {
  54. $this->error_messages[] = 'Security Risk ! The users directory "' . $check_path . '" is world readable.';
  55. }
  56. if (substr(symbolic_permissions(fileperms($check_path)), -2, 1) == "W")
  57. {
  58. $this->error_messages[] = 'Security Risk ! The users directory "' . $check_path . '" is world writeable.';
  59. }
  60. $check_path = $CI->config->item('config_path') . "settings/";
  61. if (substr(symbolic_permissions(fileperms($check_path)), -3, 1) == "r")
  62. {
  63. $this->error_messages[] = 'Security Risk ! The application settings directory "' . $check_path . '" is world readable.';
  64. }
  65. if (substr(symbolic_permissions(fileperms($check_path)), -2, 1) == "W")
  66. {
  67. $this->error_messages[] = 'Security Risk ! The application settings directory "' . $check_path . '" is world writeable.';
  68. }
  69. $check_path = $CI->config->item('backup_path');
  70. if (substr(symbolic_permissions(fileperms($check_path)), -3, 1) == "r")
  71. {
  72. $this->error_messages[] = 'Security Risk ! The application backup directory "' . $check_path . '" is world readable.';
  73. }
  74. if (substr(symbolic_permissions(fileperms($check_path)), -2, 1) == "W")
  75. {
  76. $this->error_messages[] = 'Security Risk ! The application backup directory "' . $check_path . '" is world writeable.';
  77. }
  78. }
  79. }
  80. /* End of file Statuscheck.php */
  81. /* Location: ./system/application/libraries/Statuscheck.php */