"First run wizard", "version" => "0.2.2", "author" => "Starbeamrainbowlabs", "description" => "Displays a special page to aid in setting up a new wiki for the first time.", "id" => "feature-firstrun", "code" => function() { global $settings, $env; // NOTE: We auto-detect pre-existing wikis in 01-settings.fragment.php if(!$settings->firstrun_complete && preg_match("/^firstrun/", $env->action) !== 1) { http_response_code(307); header("location: ?action=firstrun"); exit("Redirecting you to the first-run wizard...."); } /** * @api {get} ?action=firstrun Display the firstrun page * @apiName FirstRun * @apiGroup Settings * @apiPermission Anonymous * */ /* * ███████ ██ ██████ ███████ ████████ ██████ ██ ██ ███ ██ * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ * █████ ██ ██████ ███████ ██ ██████ ██ ██ ██ ██ ██ * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ * ██ ██ ██ ██ ███████ ██ ██ ██ ██████ ██ ████ */ add_action("firstrun", function() { global $settings, $settingsFilename, $version; if($settings->firstrun_complete) { http_response_code(400); exit(page_renderer::render_main("Setup complete - Error - $settings->sitename", "
Oops! Looks like $settings->sitename is already setup and ready to go! Go to the " . htmlentities($settings->defaultpage)." to get started!
")); } if(!module_exists("page-login")) { http_response_code(503); exit(page_renderer::render_main("Build error - Pepperminty Wiki", "The page-login
wasn't included in this build of Pepperminty Wiki, so the first-run installation wizard will not work correctly.
You can still complete the setup manually, however! Once done, set firstrun_complete
in peppermint.json to true
.
Welcome to Pepperminty Wiki.
Fill out the below form to get your wiki up and running!
Optionally, click this link to say hi and let Starbeamrainbowlabs know that you're setting up a new Pepperminty Wiki $version instance.
"; exit(page_renderer::render_main("Welcome! - Pepperminty Wiki", $result)); }); /** * @api {post} ?action=firstrun-complete Complete the first-run wizard. * @apiName FirstRunComplete * @apiGroup Settings * @apiPermission Anonymous * * @apiParam {string} username The username for the first admin account * @apiParam {string} password The password for the first admin account * @apiParam {string} password-again The password repeated for the first admin account * @apiParam {string} email-address The email address for the first admin account * @apiParam {string} wiki-name The name of the wiki. Saved to $settings->sitename * @apiParam {string} data-dir The directory on the server to save the wiki data to. Saved to $settings->data_storage_dir. */ add_action("firstrun-complete", function() { global $version, $commit, $settings; if($settings->firstrun_complete) { http_response_code(400); exit(page_renderer::render_main("Setup complete - Error - $settings->sitename", "Oops! Looks like $settings->sitename is already setup and ready to go! Go to the " . htmlentities($settings->defaultpage)." to get started!
")); } if($_POST["secret"] !== $settings->secret) { http_response_code(401); exit(page_renderer::render_main("Incorrect secret - Pepperminty Wiki", "Oops! That secret was incorrect. Open peppermint.json
that is automatically written to the directory alongside the index.php
that you uploaded to your web server and copy the value of the secret
property into the wiki secret box on the previous page, taking care to avoid copying the quotation marks.
Oops! Looks like you forgot to enter a username. Try going back in your browser and filling one in.
")); } if(empty($_POST["email-address"])) { http_response_code(400); exit(page_renderer::render_main("Missing information - Error - Pepperminty Wiki", "Oops! Looks like you forgot to enter an email address. Try going back in your browser and filling one in.
")); } if(filter_var($_POST["email-address"], FILTER_VALIDATE_EMAIL) === false) { http_response_code(400); exit(page_renderer::render_main("Invalid email address - Error - Pepperminty Wiki", "Oops! Looks like that email address isn't valid. Try going back in your browser and correcting it.
")); } if(empty($_POST["password"]) || empty($_POST["password-again"])) { http_response_code(400); exit(page_renderer::render_main("Missing information - Error - Pepperminty Wiki", "Oops! Looks like you forgot to enter a password. Try going back in your browser and filling one in.
")); } if($_POST["password"] !== $_POST["password-again"]) { http_response_code(422); exit(page_renderer::render_main("Password mismatch - Error - Pepperminty Wiki", "Oops! Looks like the passwords you entered aren't the same. Try going back in your browser and entering it again.
")); } if(empty($_POST["wiki-name"])) { http_response_code(400); exit(page_renderer::render_main("Missing information - Error - Pepperminty Wiki", "Oops! Looks like you forgot to enter a name for your wiki. Try going back in your browser and filling one in.
")); } if(empty($_POST["data-dir"])) { http_response_code(400); exit(page_renderer::render_main("Missing information - Error - Pepperminty Wiki", "Oops! Looks like you forgot to enter a directory on the server to store the wiki's data in. Try going back in your browser and filling one in. Relative paths are ok - the default is .
(i.e. the current directory).
Oops! Pepperminty Wiki was unable to save your settings back to disk. This can happen if Pepperminty Wiki does not have write permissions on it's own directory and the files contained within (except index.php
of course).
Try contacting your server owner and ask them to correct it. If you are the server owner, you may need to run sudo chown -R WEBSERVER_USERNAME:WEBSERVER_USERNAME PATH/TO/WIKI/DIRECTORY
, replacing the bits in UPPERCASE.
Congratulations! You've completed the Pepperminty Wiki setup.
Click here to start using $settings->sitename, your new wiki!
")); }); } ]); function do_system_checks() { $checks = [ function_exists("mb_strpos") ? [true, "php-mbstring is installed"] : [false, "php-mbstring is not installed"], class_exists("Transliterator") && class_exists("Collator") ? [true, "php-intl is installed for item sorting, search indexing, and sending non-utf8 emails"] : [false, "php-intl is not installed (needed for item sorting, search indexing, and sending non-utf8 emails)"] ]; if(module_exists("feature-upload")) { $checks[] = class_exists("Imagick") ? [true, "php-imagick is installed for preview generation"] : [false, "php-imagick is not installed (needed for image preview generation)", "optional"]; $checks[] = function_exists("finfo_file") ? [true, "php-fileinfo is installed for upload file type checking"] : [false, "php-fileinfo is not installed (needed for file type checking on uploads)", "optional"]; } if(module_exists("page-export")) $checks[] = class_exists("ZipArchive") ? [true, "php-zip is installed for compressing exports"] : [false, "php-zip is not install (needed for compressing exports)", "optional"]; if(module_exists("lib-search-engine") or module_exists("feature-search-didyoumean")) $checks[] = extension_loaded("pdo_sqlite") ? [true, "php-sqlite3 is installed for search indexing"] : [false, "php-sqlite3 is not installed (needed for search indexing)", "optional"]; return $checks; }