BxDolInstallerHasher.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Dolphin Core
  7. * @{
  8. */
  9. define('BX_SYSTEM_MODULE_ID', 0);
  10. bx_import('BxDolInstallerUtils');
  11. /**
  12. * Functions for hashing system files.
  13. * Hashing functions for module file are in @see BxDolInstallerUtils class.
  14. */
  15. class BxDolInstallerHasher extends BxDolInstallerUtils
  16. {
  17. protected $_aSystemFiles = array(
  18. // slash at the end is necessary for directories
  19. 'inc/',
  20. 'modules/base/',
  21. 'periodic/',
  22. 'studio/',
  23. 'template/',
  24. 'cmts.php',
  25. 'conn.php',
  26. 'get_rss_feed.php',
  27. 'grid.php',
  28. 'gzip_loader.php',
  29. 'image_transcoder.php',
  30. 'index.php',
  31. 'logout.php',
  32. 'member.php',
  33. 'menu.php',
  34. 'page.php',
  35. 'searchKeyword.php',
  36. 'searchKeywordContent.php',
  37. 'splash.php',
  38. 'storage.php',
  39. 'storage_uploader.php',
  40. 'vote.php',
  41. 'modules/index.php',
  42. 'README.md',
  43. 'license.txt',
  44. );
  45. public function getSystemFilesHash ()
  46. {
  47. $this->_aNonHashableFiles = array(
  48. 'inc/header.inc.php',
  49. );
  50. $aFilesHashed = array();
  51. foreach ($this->_aSystemFiles as $sFile)
  52. $this->hashFiles(BX_DIRECTORY_PATH_ROOT . $sFile, $aFilesHashed);
  53. return $aFilesHashed;
  54. }
  55. public function hashSystemFiles()
  56. {
  57. $aFiles = $this->getSystemFilesHash ();
  58. if (!$aFiles)
  59. return false;
  60. $oDb = bx_instance('BxDolStudioInstallerQuery');
  61. foreach($aFiles as $aFile)
  62. $oDb->insertModuleTrack(BX_SYSTEM_MODULE_ID, $aFile);
  63. return true;
  64. }
  65. public function checkSystemFilesHash (&$fChangedFilesPercent)
  66. {
  67. $aFiles = $this->getSystemFilesHash ();
  68. list($aFilesChanged, $fChangedFilesPercent) = $this->hashCheck($aFiles, BX_SYSTEM_MODULE_ID);
  69. return $aFilesChanged;
  70. }
  71. }
  72. /** @} */