Changeset 1189 in t29-www


Ignore:
Timestamp:
Mar 30, 2017, 11:02:21 AM (7 years ago)
Author:
sven
Message:

Wipe-Cache: Funktioniert jetzt auch auf Windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/wipe-cache.php

    r353 r1189  
    1616
    1717if(isset($_GET['wipe'])) {
    18         $command = "rm -r $cache_dir/* 2>&1";
    1918        print "<h3>Cache-Leerung</h3>";
    20         print shell_exec($command);
     19        rrmdir_sub($cache_dir);
    2120        print "Fertig";
    2221        print "<h3>Erneut Cache leeren?</h3>";
     
    3534
    3635
    37 <h3>Details</h3>
     36<h3>Zum Cache-System</h3>
    3837
    3938<p>Die technikum29-Website wird seit Version 6 mit PHP und einem mehrstufigen
     
    4746<?php
    4847foreach($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));
     48        print "<tr><td class='left'><tt>$file</tt><td>".(file_exists($file) ?
     49                date ("F d Y H:i:s", filemtime($file))
     50        :       "<i>does not exist</i>");
    5051}
    5152?>
    5253</table>
     54
     55<h3>Im Cache befindliche Dateien</h3>
     56<?php
     57$all_cache_files = getDirContents($cache_dir);
     58?>
     59
     60<p>Im <a href="/shared/cache">t29-Cache</a> auf diesem Host (<tt><?php print $host; ?></tt>)
     61befinden sich derzeit folgende
     62<strong><?php print count($all_cache_files); ?> Dateien und Ordner</strong>:</p>
     63
     64<table class="t29-details">
     65<tr><th>Datei<th>Letzte Änderung
     66<?php
     67foreach($all_cache_files as $file) {
     68        print "<tr><td class='left'><tt>$file</tt><td>".(file_exists($file) ?
     69                date ("F d Y H:i:s", filemtime($file))
     70        :       "<i>does not exist</i>");
     71}
     72?>
     73</table>
     74<?php>
    5375
    5476<?php
     
    7092    return $size;
    7193}
     94
     95// Delete from $path, including $path, using an recursive iterator
     96function rrmdir($path) {
     97        if(is_file($path)) {
     98                unlink($path);
     99                return;
     100        }
     101
     102        $i = new DirectoryIterator($path);
     103        foreach($i as $f) {
     104                if($f->isFile()) {
     105                        unlink($f->getRealPath());
     106                } else if(!$f->isDot() && $f->isDir()) {
     107                        rrmdir($f->getRealPath());
     108                }
     109        }
     110        rmdir($path);
     111}
     112
     113// delete everything *below* path, but keep $path
     114function rrmdir_sub($path) {
     115        array_map('rrmdir', glob("$path/*"));
     116#       print "Would delete:<pre> ";
     117#       var_dump(glob("$path/*"));
     118}
     119
     120// get a list of all files below $dir, recursively.
     121function getDirContents($dir, &$results = array()){
     122    $files = scandir($dir);
     123
     124    foreach($files as $key => $value){
     125        $path = realpath($dir.DIRECTORY_SEPARATOR.$value);
     126        if(!is_dir($path)) {
     127            $results[] = $path;
     128        } else if($value != "." && $value != "..") {
     129            getDirContents($path, $results);
     130            $results[] = $path;
     131        }
     132    }
     133
     134    return $results;
     135}
Note: See TracChangeset for help on using the changeset viewer.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License