about summary refs log tree commit diff stats
path: root/submit.php
diff options
context:
space:
mode:
authorahriman <ahriman@falte.red>2019-04-24 23:36:49 +0000
committerahriman <ahriman@falte.red>2019-04-24 23:36:49 +0000
commitde5fc1d74f6a6206a15db36cb1d4910090eb430f (patch)
treeb100d74e0c09a66eceae9ab924d7b355c4621f2d /submit.php
parent2d69b7e36910c00f8741aae73f9eb7a46a9c804f (diff)
downloadsite-de5fc1d74f6a6206a15db36cb1d4910090eb430f.tar.gz
workaround for checking if user already exists (chroot blocks posix_getpwnam())
Diffstat (limited to 'submit.php')
-rwxr-xr-xsubmit.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/submit.php b/submit.php
index d051936..b5b741b 100755
--- a/submit.php
+++ b/submit.php
@@ -23,7 +23,9 @@
 
 if ($_SERVER["SERVER_NAME"] != "localhost")
 	require_once "ultimate-email/support/smtp.php";
-
+function isTaken($istaken) {
+    return in_array($istaken, file("userlist", FILE_IGNORE_NEW_LINES));
+}
 function forbidden_name($name) {
     return in_array($name, [
         '0x0',
@@ -91,7 +93,7 @@ if (isset($_REQUEST["username"]) && isset($_REQUEST["email"])) {
         $message .= "<li>username too long (32 character max)</li>";
     if (!preg_match('/^[A-Za-z][A-Za-z0-9]{2,31}$/', $name))
         $message .= "<li>username contains invalid characters (lowercase only, must start with a letter)</li>";
-    if (posix_getpwnam($name) || forbidden_name($name))
+    if (isTaken($name) || forbidden_name($name))
         $message .= "<li>sorry, the username $name is unavailable</li>";
 
     // Check the e-mail address.