BxDolInstallerHasher.php 2.0 KB

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