([0-9\.*+A-Za-z]+)<\/em:maxVersion>/', $value, $matches) == 1 && $currentApp !== null){
$currentApp['maxVersion'] = $matches[1];
}
}
$file = implode("\n", $file);
file_put_contents('Releases\\' . SHORT_APP_NAME . '-mozillaAddons\\install.rdf', $file);
if(preg_match('/[A-Za-z]/', $version) === 1){
$officialVersion = false;
} else {
$officialVersion = true;
}
// Do some checks
$stop = false;
if(file_exists('Releases\\' . SHORT_APP_NAME . '-' . $version . '.xpi')){
echo 'This file version already exists. Are you sure you want to overwrite it? Y/N: ';
$response = substr(trim(fgets(STDIN)), 0, 1);
if($response != 'Y' && $response != 'y'){
$stop = true;
} else {
echo "File will be overwritten.\n";
}
}
$file = file_get_contents('Releases\\' . SHORT_APP_NAME . '\\chrome.manifest');
$locales = opendir('Releases\\' . SHORT_APP_NAME . '\\locale\\');
while(!$stop && false !== ($currentlocale = readdir($locales))){
if($currentlocale != '..' && $currentlocale != '.' && strpos($file, $currentlocale) === false){
echo "Locale $currentlocale not found in chrome.manifest.\n";
$stop = true;
}
}
closedir($locales);
if($stop){
shell_exec('cd Releases & rmdir /S /Q ' . SHORT_APP_NAME . ' & rmdir /S /Q ' . SHORT_APP_NAME . '-mozillaAddons');
echo "Build process stopped.\n";
exit;
}
shell_exec(' cd Releases\\' . SHORT_APP_NAME . ' & 7za a -tzip ' . SHORT_APP_NAME . '.jar ' . CONTENT . ' ' . LOCALE . ' ' . SKIN . ' & rmdir /S /Q ' . CONTENT . ' ' . LOCALE . ' ' . SKIN . ' & mkdir chrome & move ' . SHORT_APP_NAME . '.jar chrome\\');
shell_exec(' cd Releases\\' . SHORT_APP_NAME . ' & 7za a -tzip ..\\' . SHORT_APP_NAME . '-' . $version . '.xpi * & cd .. & rmdir /S /Q ' . SHORT_APP_NAME . '');
if($officialVersion){
shell_exec('cd Releases\\' . SHORT_APP_NAME . '-mozillaAddons & 7za a -tzip ..\\' . SHORT_APP_NAME . '-' . $version . '-mozillaAddons.xpi * & cd .. & rmdir /S /Q ' . SHORT_APP_NAME . '-mozillaAddons');
} else {
shell_exec('cd Releases & rmdir /S /Q ' . SHORT_APP_NAME . '-mozillaAddons');
}
shell_exec('copy /Y Releases\\' . SHORT_APP_NAME . '-' . $version . '.xpi Web\\releases\\ ');
if($officialVersion){
$file = '
' . $version . '';
foreach($applications as $index => $value){
$file .= '
' . $value['id'] . '
' . $value['minVersion'] . '
' . $value['maxVersion'] . '
http://' . SHORT_APP_NAME . '.fvds.frih.net/releases/' . SHORT_APP_NAME . '-' . $version . '.xpi
';
}
$file .= '
' . $version . '
http://' . SHORT_APP_NAME . '.fvds.frih.net/releases/' . SHORT_APP_NAME . '-' . $version . '.xpi
';
file_put_contents('Web\update.rdf', $file);
$file = file_get_contents('Web\index.php');
$file = explode("\n", $file);
foreach($file as $index => $value){
if(strpos($value, '') === 0){
$file[$index] = 'Click here to download ' . LONG_APP_NAME . ' v' . $version . '
';
}
}
$file = implode("\n", $file);
file_put_contents('Web\index.php', $file);
echo "Remember to manually:\n\t- Upload index.php, update.rdf and the new release to the web\n\t- Submit the new release to addons.mozilla.org\n\t- Change the version number\n\n";
} else {
echo "Remember to manually:\n\t- Upload the new release to the web\n\t- Change the version number\n\n";
}
?>