diff --git a/build/index.php b/build/index.php index c54d361..3e67f81 100644 --- a/build/index.php +++ b/build/index.php @@ -131,6 +131,8 @@ $guiConfig = <<<'GUICONFIG' "index.php?action=help" ] ]}, + "comment_max_length": {"type": "number", "description": "The maximum allowed length, in characters, for comments", "default": 5000 }, + "comment_min_length": {"type": "number", "description": "The minimum allowed length, in characters, for comments", "default": 10 }, "upload_enabled": {"type": "checkbox", "description": "Whether to allow uploads to the server.", "default": true}, "upload_allowed_file_types": {"type": "array", "description": "An array of mime types that are allowed to be uploaded.", "default": [ "image/jpeg", @@ -257,6 +259,7 @@ main:not(.printable) { padding: 2rem 2rem 0.5rem 2rem; background: #faf8fb; box- blockquote { padding-left: 1em; border-left: 0.2em solid #442772; border-radius: 0.2rem; } +a { cursor: pointer;; } a.redlink:link { color: rgb(230, 7, 7); } a.redlink:visited { color: rgb(130, 15, 15); /*#8b1a1a*/ } @@ -622,6 +625,8 @@ function makepathsafe($string) $string = preg_replace("/[?%*:|\"><()\\[\\]]/i", "", $string); // Collapse multiple dots into a single dot $string = preg_replace("/\.+/", ".", $string); + // Don't allow slashes at the beginning + $string = ltrim($string, "\\/"); return $string; } @@ -937,6 +942,53 @@ function extract_user_from_userpage($userPagename) { return $matches[1]; } +/** + * Sends a plain text email to a user, replacing {username} with the specified username. + * @param string $username The username to send the email to. + * @param string $subject The subject of the email. + * @param string $body The body of the email. + * @return boolean Whether the email was sent successfully or not. Currently, this may fail if the user doesn't have a registered email address. + */ +function email_user($username, $subject, $body) +{ + global $version, $settings; + + // If the user doesn't have an email address, then we can't email them :P + if(empty($settings->users->{$username}->emailAddress)) + return false; + + $subject = str_replace("{username}", $username, $subject); + $body = str_replace("{username}", $username, $body); + + $headers = [ + "content-type" => "text/plain", + "x-mailer" => "$settings->sitename Pepperminty-Wiki/$version PHP/" . phpversion(), + "reply-to" => "$settings->admindetails_name <$settings->admindetails_email>" + ]; + $compiled_headers = ""; + foreach($headers as $header => $value) + $compiled_headers .= "$header: $value\r\n"; + + mail($settings->users->{$username->emailAddress}, $subject, $body, $compiled_headers, "-t"); + return true; +} +/** + * Sends a plain text email to a list of users, replacing {username} with each user's name. + * @param string[] $usernames A list of usernames to email. + * @param string $subject The subject of the email. + * @param string $body The body of the email. + * @return integer The number of emails sent successfully. + */ +function email_users($usernames, $subject, $body) +{ + $emailsSent = 0; + foreach($usernames as $username) + { + $emailsSent += email_user($username, $subject, $body) ? 1 : 0; + } + return $emailsSent; +} + /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// @@ -1201,7 +1253,7 @@ class page_renderer
{content}
- + {extra}