{"payload":{"allShortcutsEnabled":false,"fileTree":{"modules":{"items":[{"name":"action-hash.php","path":"modules/action-hash.php","contentType":"file"},{"name":"action-protect.php","path":"modules/action-protect.php","contentType":"file"},{"name":"action-random.php","path":"modules/action-random.php","contentType":"file"},{"name":"action-raw.php","path":"modules/action-raw.php","contentType":"file"},{"name":"api-status.php","path":"modules/api-status.php","contentType":"file"},{"name":"extra-sidebar.php","path":"modules/extra-sidebar.php","contentType":"file"},{"name":"feature-comments.php","path":"modules/feature-comments.php","contentType":"file"},{"name":"feature-guiconfig.php","path":"modules/feature-guiconfig.php","contentType":"file"},{"name":"feature-history.php","path":"modules/feature-history.php","contentType":"file"},{"name":"feature-recent-changes.php","path":"modules/feature-recent-changes.php","contentType":"file"},{"name":"feature-redirect.php","path":"modules/feature-redirect.php","contentType":"file"},{"name":"feature-search.php","path":"modules/feature-search.php","contentType":"file"},{"name":"feature-stats.php","path":"modules/feature-stats.php","contentType":"file"},{"name":"feature-upload.php","path":"modules/feature-upload.php","contentType":"file"},{"name":"feature-user-preferences.php","path":"modules/feature-user-preferences.php","contentType":"file"},{"name":"feature-user-table.php","path":"modules/feature-user-table.php","contentType":"file"},{"name":"page-credits.php","path":"modules/page-credits.php","contentType":"file"},{"name":"page-debug-info.php","path":"modules/page-debug-info.php","contentType":"file"},{"name":"page-delete.php","path":"modules/page-delete.php","contentType":"file"},{"name":"page-edit.php","path":"modules/page-edit.php","contentType":"file"},{"name":"page-export.php","path":"modules/page-export.php","contentType":"file"},{"name":"page-help.php","path":"modules/page-help.php","contentType":"file"},{"name":"page-list.php","path":"modules/page-list.php","contentType":"file"},{"name":"page-login.php","path":"modules/page-login.php","contentType":"file"},{"name":"page-logout.php","path":"modules/page-logout.php","contentType":"file"},{"name":"page-move.php","path":"modules/page-move.php","contentType":"file"},{"name":"page-update.php","path":"modules/page-update.php","contentType":"file"},{"name":"page-user-list.php","path":"modules/page-user-list.php","contentType":"file"},{"name":"page-view.php","path":"modules/page-view.php","contentType":"file"},{"name":"parser-default-old.php","path":"modules/parser-default-old.php","contentType":"file"},{"name":"parser-parsedown.php","path":"modules/parser-parsedown.php","contentType":"file"}],"totalCount":31},"":{"items":[{"name":"build","path":"build","contentType":"directory"},{"name":"docs","path":"docs","contentType":"directory"},{"name":"modules","path":"modules","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"Changelog.md","path":"Changelog.md","contentType":"file"},{"name":"Development.md","path":"Development.md","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"Makefile","path":"Makefile","contentType":"file"},{"name":"Module_API_Docs.md","path":"Module_API_Docs.md","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"apidoc.json","path":"apidoc.json","contentType":"file"},{"name":"build.bat","path":"build.bat","contentType":"file"},{"name":"build.php","path":"build.php","contentType":"file"},{"name":"build.sh","path":"build.sh","contentType":"file"},{"name":"core.php","path":"core.php","contentType":"file"},{"name":"download.php","path":"download.php","contentType":"file"},{"name":"logo.png","path":"logo.png","contentType":"file"},{"name":"logo.svg","path":"logo.svg","contentType":"file"},{"name":"module_index.json","path":"module_index.json","contentType":"file"},{"name":"pack.php","path":"pack.php","contentType":"file"},{"name":"peppermint-config-info.php","path":"peppermint-config-info.php","contentType":"file"},{"name":"peppermint.guiconfig.json","path":"peppermint.guiconfig.json","contentType":"file"},{"name":"php_error.php","path":"php_error.php","contentType":"file"},{"name":"phpdoc","path":"phpdoc","contentType":"file"},{"name":"settings.fragment.php","path":"settings.fragment.php","contentType":"file"},{"name":"start-server.bat","path":"start-server.bat","contentType":"file"},{"name":"start-server.sh","path":"start-server.sh","contentType":"file"},{"name":"theme_default.css","path":"theme_default.css","contentType":"file"},{"name":"version","path":"version","contentType":"file"}],"totalCount":30}},"fileTreeProcessingTime":14.483717,"foldersToFetch":[],"repo":{"id":27140639,"defaultBranch":"master","name":"Pepperminty-Wiki","ownerLogin":"sbrl","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2014-11-25T18:47:32.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/9929737?v=4","public":true,"private":false,"isOrgOwned":false},"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"75b6b6c55fa9710d82b6623971581db7c6c5309b","listCacheKey":"v0:1678829400.1231802","canEdit":false,"refType":"tree","currentOid":"75b6b6c55fa9710d82b6623971581db7c6c5309b"},"path":"modules/feature-search.php","currentUser":null,"blob":{"rawLines":[" \"Search\",","\t\"version\" => \"0.6.2\",","\t\"author\" => \"Starbeamrainbowlabs\",","\t\"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.\",","\t\"id\" => \"feature-search\",","\t\"code\" => function() {","\t\tglobal $settings;","\t\t","\t\t/**","\t\t * @api {get} ?action=index&page={pageName} Get an index of words for a given page","\t\t * @apiName SearchIndex","\t\t * @apiGroup Search","\t\t * @apiPermission Anonymous","\t\t * @apiDescription For debugging purposes. Be warned - the format could change at any time!","\t\t * ","\t\t * @apiParam {string}\tpage\tThe page to generate a word index page.","\t\t */","\t\t","\t\t/*","\t\t * ██ ███ ██ ██████ ███████ ██ ██ ","\t\t * ██ ████ ██ ██ ██ ██ ██ ██ ","\t\t * ██ ██ ██ ██ ██ ██ █████ ███ ","\t\t * ██ ██ ██ ██ ██ ██ ██ ██ ██ ","\t\t * ██ ██ ████ ██████ ███████ ██ ██ ","\t\t */","\t\tadd_action(\"index\", function() {","\t\t\tglobal $settings, $env;","\t\t\t","\t\t\t$breakable_chars = \"\\r\\n\\t .,\\\\/!\\\"£$%^&*[]()+`_~#\";","\t\t\t","\t\t\theader(\"content-type: text/plain\");","\t\t\t","\t\t\t$source = file_get_contents(\"$env->storage_prefix$env->page.md\");","\t\t\t","\t\t\t$index = search::index($source);","\t\t\t","\t\t\tvar_dump($env->page);","\t\t\tvar_dump($source);","\t\t\t","\t\t\tvar_dump($index);","\t\t});","\t\t","\t\t/**","\t\t * @api {get} ?action=invindex-rebuild Rebuild the inverted search index from scratch","\t\t * @apiDescription\tCauses the inverted search index to be completely rebuilt from scratch. Can take a while for large wikis!","\t\t * @apiName\t\t\tSearchInvindexRebuild","\t\t * @apiGroup\t\tSearch","\t\t * @apiPermission\tAdmin","\t\t *","\t\t * @apiParam\t{string}\tsecret\t\tOptional. Specify the secret from peppermint.json here in order to rebuild the search index without logging in.","\t\t */","\t\t","\t\t/*","\t\t * ██ ███ ██ ██ ██ ██ ███ ██ ██████ ███████ ██ ██ ","\t\t * ██ ████ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ","\t\t * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████ ███ █████ ","\t\t * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ","\t\t * ██ ██ ████ ████ ██ ██ ████ ██████ ███████ ██ ██ ","\t\t * ","\t\t * ██████ ███████ ██████ ██ ██ ██ ██ ██████ ","\t\t * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ","\t\t * ██████ █████ ██████ ██ ██ ██ ██ ██ ██ ","\t\t * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ","\t\t * ██ ██ ███████ ██████ ██████ ██ ███████ ██████ ","\t\t */","\t\tadd_action(\"invindex-rebuild\", function() {","\t\t\tglobal $env, $settings;","\t\t\tif($env->is_admin ||","\t\t\t\t(","\t\t\t\t\t!empty($_POST[\"secret\"]) &&","\t\t\t\t\t$_POST[\"secret\"] === $settings->secret","\t\t\t\t)","\t\t\t)","\t\t\t\tsearch::rebuild_invindex();","\t\t\telse","\t\t\t{","\t\t\t\thttp_response_code(401);","\t\t\t\texit(page_renderer::render_main(\"Error - Search index regenerator - $settings->sitename\", \"
Error: You aren't allowed to regenerate the search index. Try logging in as an admin, or setting the secret
POST parameter to $settings->sitename's secret - which can be found in $settings->sitename's peppermint.json
file.
You didn't specify any search terms. Try typing some into the box above.
\"));","\t\t\t","\t\t\t$search_start = microtime(true);","\t\t\t","\t\t\t","\t\t\t$time_start = microtime(true);","\t\t\t$invindex = search::load_invindex($paths->searchindex);","\t\t\t$env->perfdata->invindex_decode_time = round((microtime(true) - $time_start)*1000, 3);","\t\t\t","\t\t\t$start = microtime(true);","\t\t\t$results = search::query_invindex($_GET[\"query\"], $invindex);","\t\t\t$resultCount = count($results);","\t\t\t$env->perfdata->invindex_query_time = round((microtime(true) - $time_start)*1000, 3);","\t\t\t","\t\t\theader(\"x-invindex-decode-time: {$env->perfdata->invindex_decode_time}ms\");","\t\t\theader(\"x-invindex-query-time: {$env->perfdata->invindex_query_time}ms\");","\t\t\t","\t\t\tforeach($results as &$result) {","\t\t\t\t$result[\"context\"] = search::extract_context(","\t\t\t\t\t$_GET[\"query\"],","\t\t\t\t\tfile_get_contents($env->storage_prefix . $result[\"pagename\"] . \".md\")","\t\t\t\t);","\t\t\t}","\t\t\t","\t\t\tif(!empty($_GET[\"format\"]) && $_GET[\"format\"] == \"json\") {","\t\t\t\theader(\"content-type: application/json\");","\t\t\t\t$json_results = new stdClass();","\t\t\t\tforeach($results as $result) $json_results->{$result[\"pagename\"]} = $result;","\t\t\t\texit(json_encode($json_results));","\t\t\t}","","\t\t\t$env->perfdata->search_time = round((microtime(true) - $search_start)*1000, 3);","","\t\t\t$title = $_GET[\"query\"] . \" - Search results - $settings->sitename\";","\t\t\t","\t\t\t$content = \"Found $resultCount \" . ($resultCount === 1 ? \"result\" : \"results\") . \" in \" . $env->perfdata->search_time . \"ms. \";","\t\t\t","\t\t\t$query = $_GET[\"query\"];","\t\t\tif(isset($pageindex->$query))","\t\t\t{","\t\t\t\t$content .= \"There's a page on $settings->sitename called $query.\";","\t\t\t}","\t\t\telse","\t\t\t{","\t\t\t\t$content .= \"There isn't a page called $query on $settings->sitename, but you \";","\t\t\t\tif((!$settings->anonedits && !$env->is_logged_in) || !$settings->editing)","\t\t\t\t{","\t\t\t\t\t$content .= \"do not have permission to create it.\";","\t\t\t\t\tif(!$env->is_logged_in)","\t\t\t\t\t{","\t\t\t\t\t\t$content .= \" You could try logging in.\";","\t\t\t\t\t}","\t\t\t\t}","\t\t\t\telse","\t\t\t\t{","\t\t\t\t\t$content .= \"can create it.\";","\t\t\t\t}","\t\t\t}","\t\t\t$content .= \"
\";","\t\t\t","\t\t\tif(module_exists(\"page-list\")) {","\t\t\t\t$nterms = search::tokenize($query);","\t\t\t\t$nterms_regex = implode(\"|\", array_map(function($nterm) {","\t\t\t\t\treturn preg_quote(strtolower(trim($nterm)));","\t\t\t\t}, $nterms));","\t\t\t\t$all_tags = get_all_tags();","\t\t\t\t$matching_tags = [];","\t\t\t\tforeach($all_tags as $tag) {","\t\t\t\t\tif(preg_match(\"/$nterms_regex/i\", trim($tag)) > 0)","\t\t\t\t\t\t$matching_tags[] = $tag;","\t\t\t\t}","\t\t\t\t","\t\t\t\tif(count($matching_tags) > 0) {","\t\t\t\t\t$content .= \"Matching tags:
\";","\t\t\t\t}","\t\t\t}","\t\t\t","\t\t\t$i = 0; // todo use $_GET[\"offset\"] and $_GET[\"result-count\"] or something","\t\t\tforeach($results as $result)","\t\t\t{","\t\t\t\t$link = \"?page=\" . rawurlencode($result[\"pagename\"]);","\t\t\t\t$pagesource = file_get_contents($env->storage_prefix . $result[\"pagename\"] . \".md\");","\t\t\t\t","\t\t\t\t//echo(\"Extracting context for result \" . $result[\"pagename\"] . \".\\n\");","\t\t\t\t$context = $result[\"context\"];","\t\t\t\tif(mb_strlen($context) === 0)","\t\t\t\t\t$context = mb_substr($pagesource, 0, $settings->search_characters_context * 2);","\t\t\t\t//echo(\"'Generated search context for \" . $result[\"pagename\"] . \": $context'\\n\");","\t\t\t\t$context = search::highlight_context(","\t\t\t\t\t$_GET[\"query\"],","\t\t\t\t\tpreg_replace('/page.md\", null, null, null, $settings->search_characters_context * 2));","\t\t\t\t\tif($pageindex->{$env->page}->size > $settings->search_characters_context * 2)","\t\t\t\t\t\t$context .= \"...\";","\t\t\t\t}*/","\t\t\t\t","\t\t\t\t$tag_list = \" \\n\";","\t\t\t\t","\t\t\t\t// Make redirect pages italics","\t\t\t\tif(!empty($pageindex->{$result[\"pagename\"]}->redirect))","\t\t\t\t\t$result[\"pagename\"] = \"{$result[\"pagename\"]}\";","\t\t\t\t","\t\t\t\t// We add 1 to $i here to convert it from an index to a result","\t\t\t\t// number as people expect it to start from 1","\t\t\t\t$content .= \"$context
\\n\";","\t\t\t\t$content .= \"