1 | <?php |
---|
2 | /** |
---|
3 | * Wipe-Cache is a small cache wiping application for online usage. |
---|
4 | * For convenience it is displayed in the style of the website |
---|
5 | **/ |
---|
6 | $seiten_id = 'wipe-cache'; |
---|
7 | $version = '$Id$'; |
---|
8 | $titel = 'Wipe Cache'; |
---|
9 | $dynamischer_inhalt = true; |
---|
10 | |
---|
11 | require "technikum29.php"; |
---|
12 | ?> |
---|
13 | <h2>Cache leeren</h2> |
---|
14 | |
---|
15 | <?php |
---|
16 | |
---|
17 | if(isset($_GET['wipe'])) { |
---|
18 | $command = "rm -r $cache_dir/* 2>&1"; |
---|
19 | print "<h3>Cache-Leerung</h3>"; |
---|
20 | print shell_exec($command); |
---|
21 | print "Fertig"; |
---|
22 | print "<h3>Erneut Cache leeren?</h3>"; |
---|
23 | } |
---|
24 | ?> |
---|
25 | |
---|
26 | <p>Auf diesem Server (<?php echo $_SERVER['SERVER_NAME']; ?>) sind im Verzeichnis |
---|
27 | <tt><?=$cache_dir ?></tt> derzeit <b><?php echo getFileCount($cache_dir); ?> Dateien</b> |
---|
28 | gecacht.</p> |
---|
29 | |
---|
30 | <form method="get"> |
---|
31 | <input type="submit" value="Cache leeren" name="wipe"> |
---|
32 | <input type="submit" value="Anzeige aktualisieren" name="just-aktualisieren"> |
---|
33 | </form> |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | <h3>Details</h3> |
---|
38 | |
---|
39 | <p>Die technikum29-Website wird seit Version 6 mit PHP und einem mehrstufigen |
---|
40 | Cache-System unterstützt, sodass Seiten nur bei Änderungen gecacht werden müssen. |
---|
41 | Zur Verfikation, ob der Cache einer Seite invalide ist, werden dabei durch die |
---|
42 | t29Cache-Klasse verschiedenste Dateien überprüft. Für diese Seite sind das etwa |
---|
43 | folgende Dateien: |
---|
44 | |
---|
45 | <table class="t29-details"> |
---|
46 | <tr><th>Datei<th>Letzte Änderung |
---|
47 | <?php |
---|
48 | foreach($page_cache->test_files as $file) { |
---|
49 | print "<tr><td class='left'><tt>$file</tt><td>".date ("F d Y H:i:s", filemtime($file)); |
---|
50 | } |
---|
51 | ?> |
---|
52 | </table> |
---|
53 | |
---|
54 | <?php |
---|
55 | // lib: |
---|
56 | |
---|
57 | // http://stackoverflow.com/questions/640931/recursively-counting-files-with-php |
---|
58 | function getFileCount($path) { |
---|
59 | $size = 0; |
---|
60 | $ignore = array('.','..','.svn'); |
---|
61 | $files = scandir($path); |
---|
62 | foreach($files as $t) { |
---|
63 | if(in_array($t, $ignore)) continue; |
---|
64 | if (is_dir(rtrim($path, '/') . '/' . $t)) { |
---|
65 | $size += getFileCount(rtrim($path, '/') . '/' . $t); |
---|
66 | } else { |
---|
67 | $size++; |
---|
68 | } |
---|
69 | } |
---|
70 | return $size; |
---|
71 | } |
---|