Universal-Bypass/.build.php

64 lines
1.2 KiB
PHP
Raw Normal View History

2018-11-09 15:00:05 +01:00
<?php
2018-12-05 09:04:17 +01:00
if(file_exists("Universal Bypass.zip"))
2018-11-09 15:00:05 +01:00
{
2018-12-05 09:04:17 +01:00
unlink("Universal Bypass.zip");
2018-11-09 15:00:05 +01:00
}
2018-11-11 15:54:54 +01:00
if(file_exists("Universal Bypass for Firefox.zip"))
{
unlink("Universal Bypass for Firefox.zip");
}
2018-11-09 15:00:05 +01:00
echo "Indexing...\n";
$index = [];
function recursivelyIndex($dir)
{
global $index;
foreach(scandir($dir) as $f)
{
2018-11-26 20:21:16 +01:00
if(substr($f, 0, 1) != ".")
2018-11-09 15:00:05 +01:00
{
2018-11-26 20:21:16 +01:00
$fn = $dir."/".$f;
if(is_dir($fn))
{
recursivelyIndex($fn);
}
else
{
array_push($index, substr($fn, 2));
}
2018-11-09 15:00:05 +01:00
}
}
}
recursivelyIndex(".");
2018-11-11 15:54:54 +01:00
echo "Building...\n";
function createZip($file)
2018-11-09 15:00:05 +01:00
{
2018-11-11 15:54:54 +01:00
$zip = new ZipArchive();
$zip->open($file, ZipArchive::CREATE + ZipArchive::EXCL + ZipArchive::CHECKCONS) or die("Failed to create {$file}.\n");
return $zip;
2018-11-09 15:00:05 +01:00
}
2018-12-05 09:04:17 +01:00
$build = createZip("Universal Bypass.zip");
2018-11-11 15:54:54 +01:00
$firefox = createZip("Universal Bypass for Firefox.zip");
2018-11-09 15:00:05 +01:00
foreach($index as $fn)
{
2019-01-15 02:42:23 +01:00
if($fn == "README.md")
2018-11-11 15:54:54 +01:00
{
2019-01-15 02:42:23 +01:00
continue;
}
if($fn == "manifest.json")
{
$json = json_decode(file_get_contents($fn), true);
unset($json["web_accessible_resources"]);
2019-02-04 00:57:29 +01:00
$json["incognito"] = "split";
2019-01-15 02:42:23 +01:00
$build->addFromString($fn, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
else
{
$build->addFile($fn, $fn);
2018-11-09 15:00:05 +01:00
}
2019-02-04 00:57:29 +01:00
$firefox->addFile($fn, $fn);
2018-11-09 15:00:05 +01:00
}
2018-12-05 09:04:17 +01:00
$build->close();
2018-11-11 15:54:54 +01:00
$firefox->close();