1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-25 05:22:59 +00:00

Set user agent string when making requests

This commit is contained in:
Starbeamrainbowlabs 2019-08-26 15:27:24 +01:00
parent 26c3a4d0a2
commit c96e3108aa
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
5 changed files with 25 additions and 16 deletions

View file

@ -18,6 +18,9 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Vastly improved search engine performance - Vastly improved search engine performance
- A new SQLite-based index format is now used, so search indexes will need to be rebuilt (migrating would probably take longer than a rebuild :-/) - A new SQLite-based index format is now used, so search indexes will need to be rebuilt (migrating would probably take longer than a rebuild :-/)
- New search query syntax - New search query syntax
- When making remote requests, Pepperminty Wiki will now correctly set the user agent string
- The server's `expose_php` setting is respected - if it's disabled, then the PHP version will not be exposed.
- Pepperminty Wiki _shouldn't_ make remote requests without you asking it to - see above and the theme gallery
## v0.19 ## v0.19

View file

@ -66,3 +66,8 @@ $paths->upload_file_prefix = "Files/";
// Create the cache directory if it doesn't exist // Create the cache directory if it doesn't exist
if(!is_dir($paths->cache_directory)) if(!is_dir($paths->cache_directory))
mkdir($paths->cache_directory, 0700); mkdir($paths->cache_directory, 0700);
// Set the user agent string
$php_version = ini_get("expose_php") == "1" ? "PHP/".phpversion() : "PHP";
ini_set("user_agent", "$php_version (".PHP_SAPI."; ".PHP_OS." ".php_uname("m")."; ".(PHP_INT_SIZE*8)." bits; rv:$version) Pepperminty-Wiki/$version-".substr($commit, 0, 7));
unset($php_version);

View file

@ -75,7 +75,7 @@
"version": "0.1", "version": "0.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Displays a special page to aid in setting up a new wiki for the first time.", "description": "Displays a special page to aid in setting up a new wiki for the first time.",
"lastupdate": 1557611471, "lastupdate": 1566827225,
"optional": false, "optional": false,
"extra_data": [] "extra_data": []
}, },
@ -154,8 +154,8 @@
"name": "Theme Gallery", "name": "Theme Gallery",
"version": "0.1", "version": "0.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a theme gallery page and optional automatic theme updates.", "description": "Adds a theme gallery page and optional automatic theme updates. Contacts a remote server, where IP addresses are stored in automatic server logs for security and attack mitigation purposes.",
"lastupdate": 1566733743, "lastupdate": 1566828460,
"optional": false, "optional": false,
"extra_data": [] "extra_data": []
}, },

View file

@ -64,11 +64,12 @@ register_module([
} }
// TODO: Check the environment here first // TODO: Check the environment here first
// - Make sure peppermint.json isn't accessible
// - Check for required modules? // - Check for required modules?
// TODO: Add a button to skip the firstrun wizard & do your own manual setup // TODO: Add a button to skip the firstrun wizard & do your own manual setup
// TODO: Add option to configure theme auto-update here - make sure it doesn't do anything until configuration it complete!
$result = "<h1>Welcome!</h1> $result = "<h1>Welcome!</h1>
<p>Welcome to Pepperminty Wiki.</p> <p>Welcome to Pepperminty Wiki.</p>
<p>Fill out the below form to get your wiki up and running!</p> <p>Fill out the below form to get your wiki up and running!</p>

View file

@ -3,7 +3,7 @@ register_module([
"name" => "Theme Gallery", "name" => "Theme Gallery",
"version" => "0.1", "version" => "0.1",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Adds a theme gallery page and optional automatic theme updates.", "description" => "Adds a theme gallery page and optional automatic theme updates. Contacts a remote server, where IP addresses are stored in automatic server logs for security and attack mitigation purposes.",
"id" => "feature-theme-gallery", "id" => "feature-theme-gallery",
"code" => function() { "code" => function() {
global $settings; global $settings;
@ -28,11 +28,11 @@ register_module([
} }
foreach($next_obj as $theme) { foreach($next_obj as $theme) {
$theme["index_url"] = $url; $theme->index_url = $url;
$theme["root"] = dirname($url) . "/{$theme["id"]}"; $theme->root = dirname($url) . "/{$theme->id}";
$theme["url"] = "{$theme["root"]}/theme.css"; $theme->url = "{$theme->root}/theme.css";
$theme["preview_large"] = "{$theme["root"]}/preview_large.png"; $theme->preview_large = "{$theme->root}/preview_large.png";
$theme["preview_small"] = "{$theme["root"]}/preview_small.png"; $theme->preview_small = "{$theme->root}/preview_small.png";
$themes_available[] = $theme; $themes_available[] = $theme;
} }
} }
@ -41,16 +41,16 @@ register_module([
<div class='grid theme-list'>\n"; <div class='grid theme-list'>\n";
foreach($themes_available as $theme) { foreach($themes_available as $theme) {
$content .= "<div class='theme-item'> $content .= "<div class='theme-item'>
<input type='radio' id='" . htmlentities($theme["id"]) . "' name='theme-selector' value='" . htmlentities($theme["id"]) . "' /><br /> <a href='" . htmlentities($theme->preview_large) . "'><img src='" . htmlentities($theme->preview_small) . "' title='Click to enlarge.' /></a>
<a href='" . htmlentities($theme["preview_large"]) . "'><img src='" . htmlentities($theme["preview_small"]) . "' title='Click to enlarge.' /></a> <input type='radio' id='" . htmlentities($theme->id) . "' name='theme-selector' value='" . htmlentities($theme->id) . "' />
<label for='" . htmlentities($theme["id"]) . "'>" . htmlentities($theme["name"]) . "</label> <label for='" . htmlentities($theme->id) . "'>" . htmlentities($theme->name) . "</label>
<p>" . str_replace("\n", "</p>\n<p>", htmlentities($theme["description"])) . "</p> <p>" . str_replace("\n", "</p>\n<p>", htmlentities($theme->description)) . "</p>
<p>By <a href='" . htmlentities($theme["author_link"]) . "'>" . htmlentities($theme["author"]) . "</a> (<a href='" . htmlentities($theme["url"]) . "'>View CSS</a>, <a href='" . htmlentities($theme["index_url"]) . "'>View Index</a>) <p>By <a href='" . htmlentities($theme->author_link) . "'>" . htmlentities($theme->author) . "</a> (<a href='" . htmlentities($theme->url) . "'>View CSS</a>, <a href='" . htmlentities($theme->index_url) . "'>View Index</a>)
</div>"; </div>";
} }
$content .= "</div>"; $content .= "</div>";
exit(page_renderer::render_main("Theme Gallery - $settings->sitename", "")); exit(page_renderer::render_main("Theme Gallery - $settings->sitename", "$content"));
}); });