<?php

namespace Controller;

class Admin {

    function __construct() {

    }

    function menu() {
        return '<a class="action" href="#">clear cache</a>';
    }
    
    function index() {
        //        return $this->menu();
        return $this->clear_cache();
    }

    function clear_cache() {
        $CI = new \Modules\CachedImage("rsc/img/default.png");
        $cache_dir = $CI->cache_dir;

        $ls = scandir($cache_dir);
        $count = 0;
        foreach($ls as $file) {
            if(!strncmp(".",$file,1)) continue;
            unlink($cache_dir."".$file);
            $count++;
        }
        return "erased $count files<br>";
    }
}
