actually delete old file
[KiwiIRC.git] / assets.php
1 <?php
2
3 function auto_load($class){
4 try {
5 $file = str_replace('_', '/', strtolower($class));
6 $path = 'libs/'.$file.'.php';
7
8 if (file_exists($path)){
9 require $path;
10 return true;
11 }
12
13 return false;
14 }catch (Exception $e){
15 // Err...
16 }
17 }
18 spl_autoload_register('auto_load');
19
20
21
22 define('CACHE_DIR', './cache/');
23
24 function cacheReadfile($file){
25 if(file_exists(CACHE_DIR.$file)){
26 readfile(CACHE_DIR.$file);
27 exit;
28 }
29 }
30
31 function writeToCache($file, $data){
32 file_put_contents(CACHE_DIR.$file, $data);
33 }
34
35
36
37 if(isset($_GET['js'])){
38 $files = explode(',', $_GET['js']);
39 arsort($files);
40
41 $cache_filename = 'js';
42 foreach($files as $file) $cache_filename .= '_'.$file;
43 cacheReadfile($cache_filename);
44
45 $js = '';
46 foreach($files as $file){
47 $js .= JSMin::minify(file_get_contents("js/$file.js"));
48 }
49 //writeToCache($cache_filename, $js);
50 echo $js;
51 }
52
53