diff --git a/clientpack.php b/clientpack.php index c5bbdf6..b3a2671 100644 --- a/clientpack.php +++ b/clientpack.php @@ -30,21 +30,18 @@ if (is_dir('clientpack')) { // Embed css into HTML file -$css_file = file_get_contents('clientpack/dcwebui.min.css'); - $html_content = file_get_contents('clientpack/index.htm'); -$html_content = preg_replace('~]+dcwebui.css[^>]*>~', '', $html_content); + +$html_content = preg_replace_callback('~]+dcwebui.css[^>]*>~', function() { return ''; }, $html_content); // Embed JS into HTML file -$js_file = file_get_contents('clientpack/dcwebui.min.js'); -$html_content = preg_replace('~]+dcwebui.js[^>]*>~', '', $html_content); +$html_content = preg_replace_callback('~]+dcwebui.js[^>]*>~', function() { return ''; }, $html_content); // Embed socketio into HTML file -$SIO_NAME = 'socket.io-1.7.2.js'; -$sio_file = file_get_contents('clientpack/'.$SIO_NAME); -$html_content = preg_replace('~]+'.$SIO_NAME.'[^>]*>~', '', $html_content); +define('SIO_NAME', 'socket.io-1.7.2.js'); +$html_content = preg_replace_callback('~]+'.SIO_NAME.'[^>]*>~', function() { return ''; }, $html_content); // Minify the combined file @@ -55,5 +52,5 @@ file_put_contents('clientpack/index.htm', $html_content); // Clean up files `rm clientpack/{index.htm,dcwebui{.min,}.js,dcwebui{.min,}.css}`; -unlink('clientpack/'.$SIO_NAME); +unlink('clientpack/'.SIO_NAME); rename('clientpack/index.min.htm', 'clientpack/index.htm');