0byt3m1n1
Path:
/
home
/
kassiope
/
www
/
lib
/
class
/
[
Home
]
File: minifier.php
<?php /* * JS and CSS Minifier * version: 1.0 (2013-08-26) * * This document is licensed as free software under the terms of the * MIT License: http://www.opensource.org/licenses/mit-license.php * * Toni Almeida wrote this plugin, which proclaims: * "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK." * * This plugin uses online webservices from javascript-minifier.com and cssminifier.com * This services are property of Andy Chilton, http://chilts.org/ * * Copyrighted 2013 by Toni Almeida, promatik. */ function minifyJS($arr){ minify($arr, 'https://javascript-minifier.com/raw'); } function minifyCSS($arr){ minify($arr, 'https://cssminifier.com/raw'); } function minify($arr, $url) { global $dirroot,$wwwroot; foreach ($arr as $key => $value) { //echo $value; if(!file_exists($value)) { $handler = fopen($value, 'w') or die("File <a href='" . $value . "'>" . $value . "</a> error!<br />"); fwrite($handler, getMinified($url, file_get_contents($key))); fclose($handler); //echo "File <a href='" . $value . "'>" . $value . "</a> done!<br />"; } echo '<script type="text/javascript" src="'.str_replace($dirroot,$wwwroot,$value).'"></script>'; } } function getMinified($url, $content) { $postdata = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query( array('input' => $content) ) ) ); return file_get_contents($url, false, stream_context_create($postdata)); } ?>