| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | // TODO: remake according to new design and principles, site setup part leave in admin and remake other functionality move to user part |
|---|
| 4 | |
|---|
| 5 | /*************************************************************************** |
|---|
| 6 | * Dolphin Smart Community Builder |
|---|
| 7 | * ----------------- |
|---|
| 8 | * begin : Mon Mar 23 2006 |
|---|
| 9 | * copyright : (C) 2006 BoonEx Group |
|---|
| 10 | * website : http://www.boonex.com/ |
|---|
| 11 | * This file is part of Dolphin - Smart Community Builder |
|---|
| 12 | * |
|---|
| 13 | * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License. |
|---|
| 14 | * http://creativecommons.org/licenses/by/3.0/ |
|---|
| 15 | * |
|---|
| 16 | * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|---|
| 17 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 18 | * See the Creative Commons Attribution 3.0 License for more details. |
|---|
| 19 | * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin, |
|---|
| 20 | * see license.txt file; if not, write to marketing@boonex.com |
|---|
| 21 | ***************************************************************************/ |
|---|
| 22 | |
|---|
| 23 | require_once( '../inc/header.inc.php' ); |
|---|
| 24 | require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' ); |
|---|
| 25 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' ); |
|---|
| 26 | require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' ); |
|---|
| 27 | require_once( BX_DIRECTORY_PATH_PLUGINS . 'Services_JSON.php' ); |
|---|
| 28 | |
|---|
| 29 | $logged['admin'] = member_auth( 1, true, true ); |
|---|
| 30 | |
|---|
| 31 | $aResult = array(); |
|---|
| 32 | switch($_POST['type']) { |
|---|
| 33 | case 'all': |
|---|
| 34 | //member menu |
|---|
| 35 | bx_import('BxDolMemberMenu'); |
|---|
| 36 | $oMemberMenu = new BxDolMemberMenu(); |
|---|
| 37 | $oMemberMenu -> deleteMemberMenuCaches(); |
|---|
| 38 | |
|---|
| 39 | // page blocks |
|---|
| 40 | bx_import('BxDolPageViewAdmin'); |
|---|
| 41 | $oPageViewCacher = new BxDolPageViewCacher ('', ''); |
|---|
| 42 | $oCachePb = $oPageViewCacher->getBlocksCacheObject (); |
|---|
| 43 | $aResult = clearCacheObject ($oCachePb, 'pb_'); |
|---|
| 44 | if($aResult['code'] != 0) |
|---|
| 45 | break; |
|---|
| 46 | |
|---|
| 47 | // users |
|---|
| 48 | $aResult = clearCache('user', BX_DIRECTORY_PATH_CACHE); |
|---|
| 49 | if($aResult['code'] != 0) |
|---|
| 50 | break; |
|---|
| 51 | |
|---|
| 52 | // DB |
|---|
| 53 | $GLOBALS['MySQL']->oParams->clearCache(); |
|---|
| 54 | $oCacheDb = $GLOBALS['MySQL']->getDbCacheObject(); |
|---|
| 55 | $aResult = clearCacheObject ($oCacheDb, 'db_'); |
|---|
| 56 | if($aResult['code'] != 0) |
|---|
| 57 | break; |
|---|
| 58 | |
|---|
| 59 | // templates |
|---|
| 60 | $oCacheTemplates = $GLOBALS['oSysTemplate']->getTemplatesCacheObject(); |
|---|
| 61 | $aResult = clearCacheObject($oCacheTemplates, $GLOBALS['oSysTemplate']->_sCacheFilePrefix); |
|---|
| 62 | if($aResult['code'] != 0) |
|---|
| 63 | break; |
|---|
| 64 | |
|---|
| 65 | // CSS |
|---|
| 66 | $aResult = clearCache($GLOBALS['oSysTemplate']->_sCssCachePrefix, BX_DIRECTORY_PATH_CACHE_PUBLIC); |
|---|
| 67 | if($aResult['code'] != 0) |
|---|
| 68 | break; |
|---|
| 69 | |
|---|
| 70 | // JS |
|---|
| 71 | $aResult = clearCache($GLOBALS['oSysTemplate']->_sJsCachePrefix, BX_DIRECTORY_PATH_CACHE_PUBLIC); |
|---|
| 72 | break; |
|---|
| 73 | |
|---|
| 74 | case 'pb': |
|---|
| 75 | bx_import('BxDolPageViewAdmin'); |
|---|
| 76 | $oPageViewCacher = new BxDolPageViewCacher ('', ''); |
|---|
| 77 | $oCachePb = $oPageViewCacher->getBlocksCacheObject (); |
|---|
| 78 | $aResult = clearCacheObject ($oCachePb, 'pb_'); |
|---|
| 79 | break; |
|---|
| 80 | |
|---|
| 81 | case 'users': |
|---|
| 82 | //member menu |
|---|
| 83 | bx_import('BxDolMemberMenu'); |
|---|
| 84 | $oMemberMenu = new BxDolMemberMenu(); |
|---|
| 85 | $oMemberMenu -> deleteMemberMenuCaches(); |
|---|
| 86 | |
|---|
| 87 | $aResult = clearCache('user', BX_DIRECTORY_PATH_CACHE); |
|---|
| 88 | break; |
|---|
| 89 | |
|---|
| 90 | case 'db': |
|---|
| 91 | $GLOBALS['MySQL']->oParams->clearCache(); |
|---|
| 92 | $oCacheDb = $GLOBALS['MySQL']->getDbCacheObject(); |
|---|
| 93 | $aResult = clearCacheObject ($oCacheDb, 'db_'); |
|---|
| 94 | break; |
|---|
| 95 | |
|---|
| 96 | case 'template': |
|---|
| 97 | $oCacheTemplates = $GLOBALS['oSysTemplate']->getTemplatesCacheObject(); |
|---|
| 98 | $aResult = clearCacheObject($oCacheTemplates, $GLOBALS['oSysTemplate']->_sCacheFilePrefix); |
|---|
| 99 | break; |
|---|
| 100 | |
|---|
| 101 | case 'js_css': |
|---|
| 102 | $aResult = clearCache($GLOBALS['oSysTemplate']->_sCssCachePrefix, BX_DIRECTORY_PATH_CACHE_PUBLIC); |
|---|
| 103 | if($aResult['code'] == 0) |
|---|
| 104 | $aResult = clearCache($GLOBALS['oSysTemplate']->_sJsCachePrefix, BX_DIRECTORY_PATH_CACHE_PUBLIC); |
|---|
| 105 | break; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | $oJson = new Services_JSON(); |
|---|
| 109 | echo $oJson->encode($aResult); |
|---|
| 110 | exit; |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | function clearCacheObject($oCache, $sPrefix) { |
|---|
| 114 | if (!$oCache->removeAllByPrefix ($sPrefix)) |
|---|
| 115 | return array('code' => 1, 'message' => _t('_adm_txt_dashboard_cache_clean_failed')); |
|---|
| 116 | else |
|---|
| 117 | return array('code' => 0, 'message' => _t('_adm_txt_dashboard_cache_clean_success')); |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | function clearCache($sPrefix, $sPath) { |
|---|
| 121 | $aResult = array('code' => 0, 'message' => _t('_adm_txt_dashboard_cache_clean_success')); |
|---|
| 122 | |
|---|
| 123 | if($rHandler = opendir($sPath)) { |
|---|
| 124 | while(($sFile = readdir($rHandler)) !== false) |
|---|
| 125 | if(substr($sFile, 0, strlen($sPrefix)) == $sPrefix) |
|---|
| 126 | @unlink($sPath . $sFile); |
|---|
| 127 | } |
|---|
| 128 | else |
|---|
| 129 | $aResult = array('code' => 1, 'message' => _t('_adm_txt_dashboard_cache_clean_failed')); |
|---|
| 130 | |
|---|
| 131 | return $aResult; |
|---|
| 132 | } |
|---|
| 133 | ?> |
|---|