1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

Download extra files in the pseudo-module_register(), and then pack 'em in the packer

This commit is contained in:
Starbeamrainbowlabs 2019-03-02 13:32:12 +00:00
parent 501d6a1c9c
commit d6c56feb1d
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
5 changed files with 100 additions and 86 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
_docpress/ _docpress/
build/* build/
!build/index.php !build/index.php
# Include the README # Include the README

View file

@ -21,24 +21,38 @@ $module_index = [];
// Defined just in case a module needs to reference them when we require() them // Defined just in case a module needs to reference them when we require() them
// to gain information // to gain information
$env = $paths = new stdClass(); $env = $paths = new stdClass();
$paths->extra_data_directory = "._extra_data"; $paths->extra_data_directory = "build/._extra_data";
function register_module($settings) function register_module($settings)
{ {
global $module_index; global $module_index, $paths;
// If the optional flag isn't set, then we should set it to false. // Prepare any extra files
if(!isset($settings["optional"]) || !is_bool($settings["optional"])) if(!file_exists($paths->extra_data_directory))
$settings["optional"] = false; mkdir($paths->extra_data_directory, 0750);
foreach($settings["extra_data"] ?? [] as $filename => $file_def) {
$destination_filename = "$paths->extra_data_directory/{$settings["id"]}/$filename";
if(!file_exists(dirname($destination_filename)))
mkdir(dirname($destination_filename), 0750, true);
$source = fopen($file_def, "r");
$destination = fopen($destination_filename, "w");
stream_copy_to_stream($source, $destination);
fclose($source);
fclose($destination);
}
$newmodule = [ $newmodule = [
"id" => $settings["id"],
"name" => $settings["name"], "name" => $settings["name"],
"version" => $settings["version"], "version" => $settings["version"],
"author" => $settings["author"], "author" => $settings["author"],
"description" => $settings["description"], "description" => $settings["description"],
"id" => $settings["id"],
"lastupdate" => filemtime("modules/" . $settings["id"] . ".php"), "lastupdate" => filemtime("modules/" . $settings["id"] . ".php"),
"optional" => $settings["optional"], // May not be set. Defaults to false
"optional" => $settings["optional"] ?? false,
"extra_data" => $settings["extra_data"] ?? [] "extra_data" => $settings["extra_data"] ?? []
]; ];
$module_index[] = $newmodule; $module_index[] = $newmodule;

View file

@ -1,321 +1,321 @@
[ [
{ {
"id": "action-hash",
"name": "Password hashing action", "name": "Password hashing action",
"version": "0.7", "version": "0.7",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a utility action (that anyone can use) called hash that hashes a given string. Useful when changing a user's password.", "description": "Adds a utility action (that anyone can use) called hash that hashes a given string. Useful when changing a user's password.",
"id": "action-hash",
"lastupdate": 1549840565, "lastupdate": 1549840565,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "action-protect",
"name": "Page protection", "name": "Page protection",
"version": "0.2", "version": "0.2",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Exposes Pepperminty Wiki's new page protection mechanism and makes the protect button in the 'More...' menu on the top bar work.", "description": "Exposes Pepperminty Wiki's new page protection mechanism and makes the protect button in the 'More...' menu on the top bar work.",
"id": "action-protect",
"lastupdate": 1465751051, "lastupdate": 1465751051,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "action-random",
"name": "Random Page", "name": "Random Page",
"version": "0.3", "version": "0.3",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds an action called 'random' that redirects you to a random page.", "description": "Adds an action called 'random' that redirects you to a random page.",
"id": "action-random",
"lastupdate": 1530448215, "lastupdate": 1530448215,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "action-raw",
"name": "Raw page source", "name": "Raw page source",
"version": "0.7", "version": "0.7",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a 'raw' action that shows you the raw source of a page.", "description": "Adds a 'raw' action that shows you the raw source of a page.",
"id": "action-raw",
"lastupdate": 1507993763, "lastupdate": 1507993763,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "api-status",
"name": "API status", "name": "API status",
"version": "0.1", "version": "0.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Provides a basic JSON status action that provides a few useful bits of information for API consumption.", "description": "Provides a basic JSON status action that provides a few useful bits of information for API consumption.",
"id": "api-status",
"lastupdate": 1530565418, "lastupdate": 1530565418,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "extra-sidebar",
"name": "Sidebar", "name": "Sidebar",
"version": "0.3.1", "version": "0.3.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a sidebar to the left hand side of every page. Add '$settings->sidebar_show = true;' to your configuration, or append '&sidebar=yes' to the url to enable. Adding to the url sets a cookie to remember your setting.", "description": "Adds a sidebar to the left hand side of every page. Add '$settings->sidebar_show = true;' to your configuration, or append '&sidebar=yes' to the url to enable. Adding to the url sets a cookie to remember your setting.",
"id": "extra-sidebar",
"lastupdate": 1505768813, "lastupdate": 1505768813,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-comments",
"name": "Page Comments", "name": "Page Comments",
"version": "0.3.2", "version": "0.3.2",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds threaded comments to the bottom of every page.", "description": "Adds threaded comments to the bottom of every page.",
"id": "feature-comments",
"lastupdate": 1549840530, "lastupdate": 1549840530,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-guiconfig",
"name": "Settings GUI", "name": "Settings GUI",
"version": "0.1.3", "version": "0.1.3",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "The module everyone has been waiting for! Adds a web based gui that lets mods change the wiki settings.", "description": "The module everyone has been waiting for! Adds a web based gui that lets mods change the wiki settings.",
"id": "feature-guiconfig",
"lastupdate": 1548629209, "lastupdate": 1548629209,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-history",
"name": "Page History", "name": "Page History",
"version": "0.4.1", "version": "0.4.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds the ability to keep unlimited page history, limited only by your disk space. Note that this doesn't store file history (yet). Currently depends on feature-recent-changes for rendering of the history page.", "description": "Adds the ability to keep unlimited page history, limited only by your disk space. Note that this doesn't store file history (yet). Currently depends on feature-recent-changes for rendering of the history page.",
"id": "feature-history",
"lastupdate": 1541003921, "lastupdate": 1541003921,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-interwiki-links",
"name": "Interwiki links", "name": "Interwiki links",
"version": "0.1.1", "version": "0.1.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds interwiki link support. Set the interwiki_index_location setting at an index file to activate support.", "description": "Adds interwiki link support. Set the interwiki_index_location setting at an index file to activate support.",
"id": "feature-interwiki-links",
"lastupdate": 1549840688, "lastupdate": 1549840688,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-recent-changes",
"name": "Recent Changes", "name": "Recent Changes",
"version": "0.5", "version": "0.5",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds recent changes. Access through the 'recent-changes' action.", "description": "Adds recent changes. Access through the 'recent-changes' action.",
"id": "feature-recent-changes",
"lastupdate": 1549840473, "lastupdate": 1549840473,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-redirect",
"name": "Redirect pages", "name": "Redirect pages",
"version": "0.3.1", "version": "0.3.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds support for redirect pages. Uses the same syntax that Mediawiki does.", "description": "Adds support for redirect pages. Uses the same syntax that Mediawiki does.",
"id": "feature-redirect",
"lastupdate": 1549840590, "lastupdate": 1549840590,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-search",
"name": "Search", "name": "Search",
"version": "0.7", "version": "0.7",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.", "description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
"id": "feature-search",
"lastupdate": 1549840628, "lastupdate": 1549840628,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-stats",
"name": "Statistics", "name": "Statistics",
"version": "0.2", "version": "0.2",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.", "description": "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.",
"id": "feature-stats",
"lastupdate": 1530614499, "lastupdate": 1530614499,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-upload",
"name": "Uploader", "name": "Uploader",
"version": "0.5.14", "version": "0.5.14",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.", "description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.",
"id": "feature-upload",
"lastupdate": 1548629209, "lastupdate": 1548629209,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-user-preferences",
"name": "User Preferences", "name": "User Preferences",
"version": "0.3.3", "version": "0.3.3",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a user preferences page, letting people do things like change their email address and password.", "description": "Adds a user preferences page, letting people do things like change their email address and password.",
"id": "feature-user-preferences",
"lastupdate": 1526035213, "lastupdate": 1526035213,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "feature-user-table",
"name": "User Organiser", "name": "User Organiser",
"version": "0.1", "version": "0.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a organiser page that lets moderators (or better) control the reegistered user accounts, and perform adminstrative actions such as password resets, and adding \/ removing accounts.", "description": "Adds a organiser page that lets moderators (or better) control the reegistered user accounts, and perform adminstrative actions such as password resets, and adding \/ removing accounts.",
"id": "feature-user-table",
"lastupdate": 1526423111, "lastupdate": 1526423111,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-credits",
"name": "Credits", "name": "Credits",
"version": "0.7.9", "version": "0.7.9",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds the credits page. You *must* have this module :D", "description": "Adds the credits page. You *must* have this module :D",
"id": "page-credits",
"lastupdate": 1540998605, "lastupdate": 1540998605,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-debug-info",
"name": "Debug Information", "name": "Debug Information",
"version": "0.1.1", "version": "0.1.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a debug action for administrator use only that collects a load of useful information to make reporting bugs easier.", "description": "Adds a debug action for administrator use only that collects a load of useful information to make reporting bugs easier.",
"id": "page-debug-info",
"lastupdate": 1524415876, "lastupdate": 1524415876,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-delete",
"name": "Page deleter", "name": "Page deleter",
"version": "0.10", "version": "0.10",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds an action to allow administrators to delete pages.", "description": "Adds an action to allow administrators to delete pages.",
"id": "page-delete",
"lastupdate": 1501009581, "lastupdate": 1501009581,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-edit",
"name": "Page editor", "name": "Page editor",
"version": "0.17.3", "version": "0.17.3",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", "description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id": "page-edit",
"lastupdate": 1548629209, "lastupdate": 1548629209,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-export",
"name": "Export", "name": "Export",
"version": "0.5", "version": "0.5",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a page that you can use to export your wiki as a .zip file. Uses $settings->export_only_allow_admins, which controls whether only admins are allowed to export the wiki.", "description": "Adds a page that you can use to export your wiki as a .zip file. Uses $settings->export_only_allow_admins, which controls whether only admins are allowed to export the wiki.",
"id": "page-export",
"lastupdate": 1548970758, "lastupdate": 1548970758,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-help",
"name": "Help page", "name": "Help page",
"version": "0.9.3", "version": "0.9.3",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a rather useful help page. Access through the 'help' action. This module also exposes help content added to Pepperminty Wiki's inbuilt invisible help section system.", "description": "Adds a rather useful help page. Access through the 'help' action. This module also exposes help content added to Pepperminty Wiki's inbuilt invisible help section system.",
"id": "page-help",
"lastupdate": 1492433537, "lastupdate": 1492433537,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-list",
"name": "Page list", "name": "Page list",
"version": "0.11", "version": "0.11",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a page that lists all the pages in the index along with their metadata.", "description": "Adds a page that lists all the pages in the index along with their metadata.",
"id": "page-list",
"lastupdate": 1548364613, "lastupdate": 1548364613,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-login",
"name": "Login", "name": "Login",
"version": "0.9.2", "version": "0.9.2",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a pair of actions (login and checklogin) that allow users to login. You need this one if you want your users to be able to login.", "description": "Adds a pair of actions (login and checklogin) that allow users to login. You need this one if you want your users to be able to login.",
"id": "page-login",
"lastupdate": 1540050129, "lastupdate": 1540050129,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-logout",
"name": "Logout", "name": "Logout",
"version": "0.6.1", "version": "0.6.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds an action to let users user out. For security reasons it is wise to add this module since logging in automatically opens a session that is valid for 30 days.", "description": "Adds an action to let users user out. For security reasons it is wise to add this module since logging in automatically opens a session that is valid for 30 days.",
"id": "page-logout",
"lastupdate": 1526034779, "lastupdate": 1526034779,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-move",
"name": "Page mover", "name": "Page mover",
"version": "0.9.3", "version": "0.9.3",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds an action to allow administrators to move pages.", "description": "Adds an action to allow administrators to move pages.",
"id": "page-move",
"lastupdate": 1521408303, "lastupdate": 1521408303,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-update",
"name": "Update", "name": "Update",
"version": "0.6.2", "version": "0.6.2",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds an update page that downloads the latest stable version of Pepperminty Wiki. This module is currently outdated as it doesn't save your module preferences.", "description": "Adds an update page that downloads the latest stable version of Pepperminty Wiki. This module is currently outdated as it doesn't save your module preferences.",
"id": "page-update",
"lastupdate": 1476906745, "lastupdate": 1476906745,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-user-list",
"name": "User list", "name": "User list",
"version": "0.1", "version": "0.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a 'user-list' action that generates a list of users. Supports json output with 'format=json' in the queyr string.", "description": "Adds a 'user-list' action that generates a list of users. Supports json output with 'format=json' in the queyr string.",
"id": "page-user-list",
"lastupdate": 1487454626, "lastupdate": 1487454626,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "page-view",
"name": "Page viewer", "name": "Page viewer",
"version": "0.16.7", "version": "0.16.7",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Allows you to view pages. You really should include this one.", "description": "Allows you to view pages. You really should include this one.",
"id": "page-view",
"lastupdate": 1548884009, "lastupdate": 1548884009,
"optional": false, "optional": false,
"extra_data": null "extra_data": []
}, },
{ {
"id": "parser-default-old",
"name": "Old Default Parser", "name": "Old Default Parser",
"version": "0.10.1", "version": "0.10.1",
"author": "Johnny Broadway & Starbeamrainbowlabs", "author": "Johnny Broadway & Starbeamrainbowlabs",
"description": "The *old* default parser for Pepperminty Wiki. Based on Johnny Broadway's Slimdown (with more than a few modifications). This parser's features are documented in the help page. Superceded by a customised extension of parsedown extra.", "description": "The *old* default parser for Pepperminty Wiki. Based on Johnny Broadway's Slimdown (with more than a few modifications). This parser's features are documented in the help page. Superceded by a customised extension of parsedown extra.",
"id": "parser-default-old",
"lastupdate": 1549839049, "lastupdate": 1549839049,
"optional": true, "optional": true,
"extra_data": null "extra_data": []
}, },
{ {
"id": "parser-parsedown",
"name": "Parsedown", "name": "Parsedown",
"version": "0.10", "version": "0.10",
"author": "Emanuil Rusev & Starbeamrainbowlabs", "author": "Emanuil Rusev & Starbeamrainbowlabs",
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.", "description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
"id": "parser-parsedown", "lastupdate": 1551533295,
"lastupdate": 1551211981,
"optional": false, "optional": false,
"extra_data": { "extra_data": {
"Parsedown.php": "https:\/\/raw.githubusercontent.com\/erusev\/parsedown\/819c68899d593503180ed79ef4be5a4dcd8c5f92\/Parsedown.php", "Parsedown.php": "https:\/\/raw.githubusercontent.com\/erusev\/parsedown\/819c68899d593503180ed79ef4be5a4dcd8c5f92\/Parsedown.php",

View file

@ -215,8 +215,8 @@ register_module([
} }
]); ]);
require_once("$paths->extra_data_directory/Parsedown.php"); require_once("$paths->extra_data_directory/parser-parsedown/Parsedown.php");
require_once("$paths->extra_data_directory/ParsedownExtra.php"); require_once("$paths->extra_data_directory/parser-parsedown/ParsedownExtra.php");
/** /**
* Attempts to 'auto-correct' a page name by trying different capitalisation * Attempts to 'auto-correct' a page name by trying different capitalisation

View file

@ -4,14 +4,14 @@
* Logs a string to stdout, but only on the CLI. * Logs a string to stdout, but only on the CLI.
* @param string $line The line to log. * @param string $line The line to log.
*/ */
function log(string $line) { function log_str(string $line) {
if(php_sapi_name() == "cli") if(php_sapi_name() == "cli")
echo($line); echo($line);
//else error_log($line); //else error_log($line);
} }
log("*** Beginning main build sequence ***\n"); log_str("*** Beginning main build sequence ***\n");
log("Reading in module index...\n"); log_str("Reading in module index...\n");
$module_index = json_decode(file_get_contents("module_index.json")); $module_index = json_decode(file_get_contents("module_index.json"));
$module_list = []; $module_list = [];
@ -37,7 +37,7 @@ if(php_sapi_name() != "cli") {
header("content-disposition: attachment; filename=\"index.php\""); header("content-disposition: attachment; filename=\"index.php\"");
} }
log("Reading in core files...\n"); log_str("Reading in core files...\n");
// We trim from the end here because of the __halt_compiler() directive // We trim from the end here because of the __halt_compiler() directive
$core = rtrim(file_get_contents("core.php")); $core = rtrim(file_get_contents("core.php"));
@ -76,11 +76,11 @@ foreach($module_list as $module)
{ {
if($module->id == "") continue; if($module->id == "") continue;
log("[$i / $module_list_count] Adding $module->id \r"); log_str("[$i / $module_list_count] Adding $module->id \r");
$module_filepath = "modules/" . preg_replace("[^a-zA-Z0-9\-]", "", $module->id) . ".php"; $module_filepath = "modules/" . preg_replace("[^a-zA-Z0-9\-]", "", $module->id) . ".php";
//log("id: $module->id | filepath: $module_filepath\n"); //log_str("id: $module->id | filepath: $module_filepath\n");
if(!file_exists($module_filepath)) { if(!file_exists($module_filepath)) {
http_response_code(400); http_response_code(400);
@ -101,27 +101,27 @@ foreach($module_list as $module)
foreach($module->extra_data as $filepath_pack => $extra_data_item) { foreach($module->extra_data as $filepath_pack => $extra_data_item) {
if(is_string($extra_data_item)) { if(is_string($extra_data_item)) {
// TODO: Test whether this works for urls. If not, then we'll need to implement a workaround // TODO: Test whether this works for urls. If not, then we'll need to implement a workaround
$extra_data_archive->addFile($extra_data_item, "$module->id/$filepath_pack"); $extra_data_archive->addFile("$paths->extra_data_directory/$module->id/$filepath_pack", "$module->id/$filepath_pack");
} }
} }
$i++; $i++;
} }
log("\n"); log_str("\n");
$archive_stream = fopen("php://fd/$archive_file_descriptor", "r"); $archive_stream = fopen("php://fd/$archive_file_descriptor", "r");
$output_stream = null; $output_stream = null;
if(php_sapi_name() == "cli") { if(php_sapi_name() == "cli") {
if(file_exists("build/index.php")) { if(file_exists("build/index.php")) {
log("index.php already exists in the build folder, exiting\n"); log_str("index.php already exists in the build folder, exiting\n");
exit(1); exit(1);
} }
log("Done. Saving to disk..."); log_str("Done. Saving to disk...");
$output_stream = fopen("build/index.php", "w"); $output_stream = fopen("build/index.php", "w");
log("complete!\n"); log_str("complete!\n");
log("*** Build completed! ***\n"); log_str("*** Build completed! ***\n");
} }
else { else {
$output_stream = fopen("php://output", "w"); $output_stream = fopen("php://output", "w");