From: RouL Date: Sat, 16 Jul 2011 17:44:31 +0000 (+0200) Subject: Added ApcCacheSource to the CacheListPage X-Git-Tag: 2.0.0_Beta_1~2005^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9f7c32a24436e947375f74c6faabd52f635ac28e;p=GitHub%2FWoltLab%2FWCF.git Added ApcCacheSource to the CacheListPage --- diff --git a/wcfsetup/install/files/acp/templates/cacheList.tpl b/wcfsetup/install/files/acp/templates/cacheList.tpl index 9722809832..bf0342c6f3 100644 --- a/wcfsetup/install/files/acp/templates/cacheList.tpl +++ b/wcfsetup/install/files/acp/templates/cacheList.tpl @@ -1,90 +1,94 @@ -{include file='header'} - -
- -
-

{lang}wcf.acp.cache.list{/lang}

-
-
- -{if $cleared} -

{lang}wcf.acp.cache.clear.success{/lang}

-{/if} - -
- {lang}wcf.acp.cache.data{/lang} - -
-

{lang}wcf.acp.cache.data.source{/lang}

-

{$cacheData.source}

-
- {if $cacheData.version} -
-

{lang}wcf.acp.cache.data.version{/lang}

-

{$cacheData.version}

-
- {/if} -
-

{lang}wcf.acp.cache.data.size{/lang}

-

{@$cacheData.size|filesize}

-
-
-

{lang}wcf.acp.cache.data.files{/lang}

-

{#$cacheData.files}

-
- - {if $additionalFields|isset}{@$additionalFields}{/if} -
- -
-
- -
-
- -{foreach from=$caches key=cache item=files} - {if $files|count} -
-
-
- -
-
-

{$cache} ({#$files|count})

-
-
-
-
- - - - - - - - - - - {foreach from=$files item=file} - - - - - - - {/foreach} - -
{lang}wcf.acp.cache.list.name{/lang}
{lang}wcf.acp.cache.list.size{/lang}
{lang}wcf.acp.cache.list.mtime{/lang}
{lang}wcf.acp.cache.list.perm{/lang}
{$file.filename}{@$file.filesize|filesize}{if $file.mtime > 1}{@$file.mtime|time}{/if}{@$file.perm}
-
- - {/if} -{/foreach} - -{include file='footer'} +{include file='header'} + +
+ +
+

{lang}wcf.acp.cache.list{/lang}

+
+
+ +{if $cleared} +

{lang}wcf.acp.cache.clear.success{/lang}

+{/if} + +
+ {lang}wcf.acp.cache.data{/lang} + +
+

{lang}wcf.acp.cache.data.source{/lang}

+

{$cacheData.source}

+
+ {if $cacheData.version} +
+

{lang}wcf.acp.cache.data.version{/lang}

+

{$cacheData.version}

+
+ {/if} +
+

{lang}wcf.acp.cache.data.size{/lang}

+

{@$cacheData.size|filesize}

+
+
+

{lang}wcf.acp.cache.data.files{/lang}

+

{#$cacheData.files}

+
+ + {if $additionalFields|isset}{@$additionalFields}{/if} +
+ +
+
+ +
+
+ +{foreach from=$caches key=cache item=files} + {if $files|count} +
+
+
+ +
+
+

{$cache} ({#$files|count})

+
+
+
+
+ + + + + + + {if $files.0.perm|isset} + + {/if} + + + + {foreach from=$files item=file} + + + + + {if $file.perm|isset} + + {/if} + + {/foreach} + +
{lang}wcf.acp.cache.list.name{/lang}
{lang}wcf.acp.cache.list.size{/lang}
{lang}wcf.acp.cache.list.mtime{/lang}
{lang}wcf.acp.cache.list.perm{/lang}
{$file.filename}{@$file.filesize|filesize}{if $file.mtime > 1}{@$file.mtime|time}{/if}{@$file.perm}
+
+ + {/if} +{/foreach} + +{include file='footer'} diff --git a/wcfsetup/install/files/lib/acp/page/CacheListPage.class.php b/wcfsetup/install/files/lib/acp/page/CacheListPage.class.php index 07c9f59894..333b3ad508 100755 --- a/wcfsetup/install/files/lib/acp/page/CacheListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/CacheListPage.class.php @@ -114,6 +114,50 @@ class CacheListPage extends AbstractPage { $this->cacheData['files'] = $stats['curr_items']; $this->cacheData['size'] = $stats['bytes']; } + // apc + else if ($this->cacheData['source'] == 'wcf\system\cache\source\ApcCacheSource') { + // set version + $this->cacheData['version'] = phpversion('apc'); + + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("packageID IN (?)", array(PackageDependencyHandler::getDependencies())); + $conditions->add("standalone = ?", array(1)); + + // get package dirs + $sql = "SELECT packageDir, packageName, instanceNo + FROM wcf".WCF_N."_package + ".$conditions; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + $pattern = array(); + $packageNames = array(); + while ($row = $statement->fetchArray()) { + $packagePath = FileUtil::getRealPath(WCF_DIR.$row['packageDir']).'cache/'; + $packageNames[$packagePath] = $row['packageName'].' #'.$row['instanceNo']; + } + + $apcinfo = apc_cache_info('user'); + $cacheList = $apcinfo['cache_list']; + foreach ($cacheList as $cache) { + $cachePath = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(dirname($cache['info']))); + if (isset($packageNames[$cachePath])) { + // Use the pacakgeName + the instance number, because pathes could confuse the administrator. + // He could think this is a file cache. If instanceName would be unique, we could use it instead. + $packageName = $packageNames[$cachePath]; + if (!isset($this->caches[$packageName])) $this->caches[$packageName] = array(); + + // get additional cache information + $this->caches[$packageName][] = array( + 'filename' => basename($cache['info'], '.php'), + 'filesize' => $cache['mem_size'], + 'mtime' => $cache['mtime'], + ); + + $this->cacheData['files']++; + $this->cacheData['size'] += $cache['mem_size']; + } + } + } } /**