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