BxDolStudioDashboard.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  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 DolphinStudio Dolphin Studio
  7. * @{
  8. */
  9. defined('BX_DOL') or die('hack attempt');
  10. bx_import('BxTemplStudioPage');
  11. bx_import('BxDolStudioStoreQuery');
  12. class BxDolStudioDashboard extends BxTemplStudioPage {
  13. function __construct() {
  14. parent::BxTemplStudioPage('dashboard');
  15. //--- Check actions ---//
  16. if(($sAction = bx_get('dbd_action')) !== false) {
  17. $sAction = bx_process_input($sAction);
  18. $aResult = array('code' => 1, 'message' => _t('_adm_err_cannot_process_action'));
  19. switch($sAction) {
  20. case 'check_update_script':
  21. $aResult = array();
  22. $sContent = bx_file_get_contents(BX_DOL_URL_ROOT . 'get_rss_feed.php?ID=boonex_version&member=0');
  23. if(empty($sContent))
  24. break;
  25. bx_import('BxDolXmlParser');
  26. $aContent = BxDolXmlParser::getInstance()->getTags($sContent, 'dolphin', 0);
  27. if(empty($aContent) || !is_array($aContent) || empty($aContent['value']))
  28. break;
  29. $sVersionAvl = $aContent['value'];
  30. $sVersionCur = BxDolDb::getInstance()->getParam('sys_version');
  31. if(version_compare($sVersionCur, $sVersionAvl) == -1)
  32. $aResult = array('version' => $sVersionAvl);
  33. break;
  34. /*
  35. case 'action_name':
  36. $aResult = array();
  37. break;
  38. */
  39. }
  40. if(!empty($aResult['message'])) {
  41. bx_import('BxDolStudioTemplate');
  42. $aResult['message'] = BxDolStudioTemplate::getInstance()->parseHtmlByName('page_action_result.html', array('content' => $aResult['message']));
  43. bx_import('BxTemplStudioFunctions');
  44. $aResult['message'] = BxTemplStudioFunctions::getInstance()->transBox('', $aResult['message']);
  45. }
  46. $oJson = new Services_JSON();
  47. echo $oJson->encode($aResult);
  48. exit;
  49. }
  50. }
  51. protected function loadBlocks() {
  52. $aNames = array('versions', 'space');
  53. $aBlocks = array();
  54. foreach($aNames as $sName)
  55. $aBlocks[$sName] = array(
  56. 'caption' => '_adm_block_cpt_' . $sName,
  57. 'actions' => array(),
  58. 'items' => ''
  59. );
  60. return $aBlocks;
  61. }
  62. protected function getDbSize() {
  63. $iTotalSize = 0;
  64. $oDb = BxDolDb::getInstance();
  65. $aTables = $oDb->getAll('SHOW TABLE STATUS');
  66. foreach($aTables as $aTable)
  67. $iTotalSize += $aTable['Data_length'] + $aTable['Index_length'];
  68. return $iTotalSize;
  69. }
  70. protected function getFolderSize($sPath) {
  71. $iTotalSize = 0;
  72. $aFiles = scandir($sPath);
  73. $sPath = rtrim($sPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
  74. foreach($aFiles as $sFile) {
  75. if(is_dir($sPath . $sFile))
  76. if($sFile != '.' && $sFile != '..')
  77. $iTotalSize += $this->getFolderSize($sPath . $sFile);
  78. else
  79. $iTotalSize += filesize($sPath . $sFile);
  80. }
  81. return $iTotalSize;
  82. }
  83. }
  84. /** @} */