1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-27 15:50:15 +02:00

Reorganization of "web" to "min_extras"

This commit is contained in:
Steve Clay
2008-08-30 02:56:07 +00:00
parent 79a4e17fb6
commit 46734e8b8f
88 changed files with 0 additions and 24 deletions

View File

@@ -0,0 +1,32 @@
<?php
if (isset($_FILES['subject']['name'])) {
require '../../min/lib/HTTP/Encoder.php';
$he = new HTTP_Encoder(array(
'content' => file_get_contents($_FILES['subject']['tmp_name'])
,'method' => $_POST['method']
));
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
header("Content-Disposition: attachment; filename=\"{$_FILES['subject']['name']}."
. ($_POST['method'] == 'deflate'
? 'zd'
: ($_POST['method'] == 'gzip'
? 'zg'
: 'zc'
)
) . '"');
$he->encode(9);
echo $he->getContent();
exit();
}
?>
<form enctype="multipart/form-data" action="" method="post">
<p>Encode <input type="file" name="subject" /><br />
as <input type="submit" name="method" value="deflate" />
<input type="submit" name="method" value="gzip" />
<input type="submit" name="method" value="compress" />
</p>
</form>

View File

@@ -0,0 +1,53 @@
<?php
if (isset($_FILES['subject']['name'])
&& preg_match('/\\.(js|css|x?html?)$/', $_FILES['subject']['name'], $m)
) {
ini_set('include_path',
dirname(__FILE__) . '/../../min/lib'
. PATH_SEPARATOR . ini_get('include_path')
);
// eh why not
require 'Minify/HTML.php';
require 'Minify/CSS.php';
require 'Minify/Javascript.php';
$arg2 = null;
switch ($m[1]) {
case 'js':
$type = 'Javascript';
break;
case 'css':
$type = 'CSS';
break;
case 'html': // fallthrough
case 'htm': // fallthrough
case 'xhtml':
$type = 'HTML';
$arg2 = array(
'cssMinifier' => array('Minify_CSS', 'minify')
,'jsMinifier' => array('Minify_Javascript', 'minify')
);
}
$func = array('Minify_' . $type, 'minify');
$out = call_user_func($func, file_get_contents($_FILES['subject']['tmp_name']), $arg2);
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="'
. preg_replace('/\\.(\w+)$/', '.min.$1', $_FILES['subject']['name'])
. '"');
//@unlink($_FILES['subject']['tmp_name']);
echo $out;
exit();
}
?>
<form enctype="multipart/form-data" action="" method="post">
<p>Minify <input type="file" name="subject" /><br />
<input type="submit" name="method" value="Go!" />
</p>
</form>