Exemple #1
0
$sOutput = $sInput;
echo "Reading: " . $sInputFile . "\n";
// Strip "Source" version tags
if (in_array("--strip-Source", $_SERVER["argv"])) {
    echo "Stripping 'Source' code\n";
    $sOutput = fStripTags($sOutput, "Source");
}
// Strip "Debug" version tags
if (in_array("--strip-Debug", $_SERVER["argv"])) {
    echo "Stripping 'Debug' code\n";
    $sOutput = fStripTags($sOutput, "Debug");
}
// Strip "Guard" version tags
if (in_array("--strip-Guard", $_SERVER["argv"])) {
    echo "Stripping 'Guard' code\n";
    $sOutput = fStripTags($sOutput, "Guard");
}
if (in_array("--obfuscate", $_SERVER["argv"])) {
    $oCompiler = new cJSCompiler();
    $oCompiler->keyword = "ampled";
    $oCompiler->readFromString($sOutput);
    echo "Obfuscating contents\n";
    $oCompiler->addOmmitArray(array("http://www.w3.org/2000/svg", "http://www.w3.org/1999/xhtml", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "http://www.amplesdk.com/ns/aml", "http://www.w3.org/1999/XSL/Transform", "http://www.w3.org/1999/xlink", "http://www.w3.org/2000/xmlns/", "http://www.w3.org/2001/XInclude", "http://www.w3.org/2001/xml-events", "http://www.w3.org/2008/SMIL30/", "http://www.w3.org/XML/1998/namespace"));
    //
    $oCompiler->stripComments();
    $oCompiler->stripSpaces();
    $oCompiler->obfuscateStrings();
    $oCompiler->obfuscateVariables();
    $oCompiler->obfuscatePrivates();
    $oCompiler->obfuscate();
    $sOutput = $oCompiler->getOutput();
Exemple #2
0
<?php

if (isset($_GET["path"])) {
    $path = $_GET["path"];
    $prod = isset($_GET["prod"]) && $_GET["prod"] == "true";
    // Read files
    $output = fAssemble($path . ".files");
    $output = fStripTags($output, "Source");
    if ($prod) {
        $output = fStripTags($output, "Debug");
        $output = fStripTags($output, "Guard");
    }
    header("Content-type: application/javascript");
    echo "" . "(function(){" . $output . "})()" . "";
} else {
    echo "GET path parameter missing.";
}
function fStripTags($sInput, $sTagName)
{
    return preg_replace('/\\/\\/\\->' . $sTagName . '.+\\/\\/<\\-' . $sTagName . '/Us', "", $sInput);
}
function fAssemble($descriptor)
{
    $files = file($descriptor);
    $output = "";
    for ($n = 0; $n < count($files); $n++) {
        if (($file = trim($files[$n])) != "" && substr($file, 0, 1) != "#") {
            $file = fResolveUri($file, $descriptor);
            if (preg_match("/\\.files\$/", $file, $match)) {
                $source .= fAssemble($file);
            } else {
Exemple #3
0
	$sOutputFile	= $_SERVER["argv"][2];

	$sInput		= join('', file($sInputFile));
	$sOutput	= $sInput;

	echo "Reading: " . $sInputFile . "\n";

	// Strip "Source" version tags
	if (in_array("--strip-Source", $_SERVER["argv"])) {
		echo "Stripping 'Source' code\n";
		$sOutput	= fStripTags($sOutput, "Source");
	}
	// Strip "Debug" version tags
	if (in_array("--strip-Debug", $_SERVER["argv"])) {
		echo "Stripping 'Debug' code\n";
		$sOutput	= fStripTags($sOutput, "Debug");
	}

	if (in_array("--obfuscate", $_SERVER["argv"])) {

		$oCompiler	= new cJSCompiler;
		$oCompiler->keyword	= "ampled";
		$oCompiler->readFromString($sOutput);

		echo "Obfuscating contents\n";

		//
		$oCompiler->stripComments();
		$oCompiler->stripSpaces();

		$oCompiler->obfuscateStrings();