</script>
</head>
<body>

<p>You may use this tool to create a Firefox extension (.xpi) from a greasemonkey script.</p>
<p>Type in the appropriate details below, you may leave the default random GUID if you do not have one, or replace it with your own value, which you should definitely do for upgrades to an existing extension.</p>
<p>When pasting in the script, include the <tt>==UserScript==</tt> block, as the compiler reads data from there (name, description, includes/excludes).</p>

<form method='post' target='builder'>
<table width='100%'>
<col width='20%' />
<col width='80%' />
<tr>
	<td>GUID:</td>
	<td><input type='text' name='guid' value='<?php 
    echo genGUID();
    ?>
' /></td>
</tr>
<tr>
	<td>Creator name:</td>
	<td><input type='text' name='creator' /></td>
</tr>
<tr>
	<td>Extension home page:</td>
	<td><input type='text' name='homepage' /></td>
</tr>
<tr>
	<td>Extension version:</td>
	<td><input type='text' name='version' /></td>
</tr>
$short_name = $argv[2];
$version = $argv[3];
$package_mode = $argv[4];
$templates_compile_dir = $argv[5];
//debug
echo "Compiling the files located in " . $input_dir . "/" . $short_name . ".\n";
echo "Attempting to package version " . $version . " in " . $package_mode . " mode.\n\n";
include_once $input_dir . "/" . $short_name . "/config.inc.php";
include_once "inc/functions.inc.php";
error_reporting(E_ALL);
//undo magic quotes if necessary
if (get_magic_quotes_gpc()) {
    $GMSC = array_map('stripslashes', $GMSC);
}
//build data .. start from include
$data = array('guid' => genGUID(), 'name' => 'Compiled User Scripts', 'shortname' => '', 'description' => '', 'creator' => 'Anonymous', 'homepage' => '', 'version' => $version, 'minVersion' => '1.5', 'maxVersion' => '3.0.*', 'updateURL' => '', 'icon' => false, 'tabs' => array("General"), 'helpMsg' => '');
foreach (array('guid', 'name', 'description', 'creator', 'homepage', 'minVersion', 'maxVersion', 'updateURL', 'helpMsg') as $k) {
    if (!empty($GMSC[$k])) {
        $data[$k] = $GMSC[$k];
    }
}
echo "Extension Name: " . $data['name'] . "\n";
echo "Extension Description: " . $data['description'] . "\n\n";
//load user scripts into data
$workingdir = $input_dir . "/" . $short_name . "/";
$GMSC['workingdir'] = $workingdir;
if (file_exists($GMSC['workingdir'] . 'icon.png')) {
    $data['icon'] = true;
}
$dirhandle = opendir($GMSC['workingdir'] . 'user_scripts');
while (false !== ($file = readdir($dirhandle))) {