]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/nickserv.c
Last patch caused a bug removing warn. fixed it here.
[irc/evilnet/x3.git] / src / nickserv.c
index 173fca320df762ec2e3d38c823c994d95ce332e7..8dc1c4a00383db274e97b691e33f19abee69f134 100644 (file)
@@ -1,7 +1,7 @@
 /* nickserv.c - Nick/authentication service
  * Copyright 2000-2004 srvx Development Team
  *
- * This file is part of srvx.
+ * This file is part of x3.
  *
  * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -185,29 +185,30 @@ static const struct message_entry msgtab[] = {
     { "NSMSG_TITLE_INVALID", "Titles cannot contain any dots; please choose another." },
     { "NSMSG_TITLE_TRUNCATED", "That title combined with the user's account name would result in a truncated host; please choose a shorter title." },
     { "NSMSG_FAKEHOST_INVALID", "Fake hosts must be shorter than %d characters and cannot start with a dot." },
-    { "NSMSG_HANDLEINFO_ON", "Account information for $b%s$b:" },
-    { "NSMSG_HANDLEINFO_ID", "  Account ID: %lu" },
-    { "NSMSG_HANDLEINFO_REGGED", "  Registered on: %s" },
-    { "NSMSG_HANDLEINFO_LASTSEEN", "  Last seen: %s" },
-    { "NSMSG_HANDLEINFO_LASTSEEN_NOW", "  Last seen: Right now!" },
-    { "NSMSG_HANDLEINFO_VACATION", "  On vacation." },
-    { "NSMSG_HANDLEINFO_EMAIL_ADDR", "  Email address: %s" },
-    { "NSMSG_HANDLEINFO_COOKIE_ACTIVATION", "  Cookie: There is currently an activation cookie issued for this account" },
-    { "NSMSG_HANDLEINFO_COOKIE_PASSWORD", "  Cookie: There is currently a password change cookie issued for this account" },
-    { "NSMSG_HANDLEINFO_COOKIE_EMAIL", "  Cookie: There is currently an email change cookie issued for this account" },
-    { "NSMSG_HANDLEINFO_COOKIE_ALLOWAUTH", "  Cookie: There is currently an allowauth cookie issued for this account" },
-    { "NSMSG_HANDLEINFO_COOKIE_UNKNOWN", "  Cookie: There is currently an unknown cookie issued for this account" },
-    { "NSMSG_HANDLEINFO_INFOLINE", "  Infoline: %s" },
-    { "NSMSG_HANDLEINFO_FLAGS", "  Flags: %s" },
-    { "NSMSG_HANDLEINFO_EPITHET", "  Epithet: %s" },
-    { "NSMSG_HANDLEINFO_FAKEHOST", "  Fake host: %s" },
-    { "NSMSG_HANDLEINFO_LAST_HOST", "  Last quit hostmask: %s" },
-    { "NSMSG_HANDLEINFO_LAST_HOST_UNKNOWN", "  Last quit hostmask: Unknown" },
-    { "NSMSG_HANDLEINFO_NICKS", "  Nickname(s): %s" },
-    { "NSMSG_HANDLEINFO_MASKS", "  Hostmask(s): %s" },
-    { "NSMSG_HANDLEINFO_CHANNELS", "  Channel(s): %s" },
-    { "NSMSG_HANDLEINFO_CURRENT", "  Current nickname(s): %s" },
-    { "NSMSG_HANDLEINFO_DNR", "  Do-not-register (by %s): %s" },
+    { "NSMSG_HANDLEINFO_ON", "$bAccount Information for %s$b" },
+    { "NSMSG_HANDLEINFO_END", "----------End of Account Info-----------" },
+    { "NSMSG_HANDLEINFO_ID", "Account ID: %lu" },
+    { "NSMSG_HANDLEINFO_REGGED", "Registered on: %s" },
+    { "NSMSG_HANDLEINFO_LASTSEEN", "Last seen: %s" },
+    { "NSMSG_HANDLEINFO_LASTSEEN_NOW", "Last seen: Right now!" },
+    { "NSMSG_HANDLEINFO_VACATION", "On vacation." },
+    { "NSMSG_HANDLEINFO_EMAIL_ADDR", "Email address: %s" },
+    { "NSMSG_HANDLEINFO_COOKIE_ACTIVATION", "Cookie: There is currently an activation cookie issued for this account" },
+    { "NSMSG_HANDLEINFO_COOKIE_PASSWORD", "Cookie: There is currently a password change cookie issued for this account" },
+    { "NSMSG_HANDLEINFO_COOKIE_EMAIL", "Cookie: There is currently an email change cookie issued for this account" },
+    { "NSMSG_HANDLEINFO_COOKIE_ALLOWAUTH", "Cookie: There is currently an allowauth cookie issued for this account" },
+    { "NSMSG_HANDLEINFO_COOKIE_UNKNOWN", "Cookie: There is currently an unknown cookie issued for this account" },
+    { "NSMSG_HANDLEINFO_INFOLINE", "Infoline: %s" },
+    { "NSMSG_HANDLEINFO_FLAGS", "Flags: %s" },
+    { "NSMSG_HANDLEINFO_EPITHET", "Epithet: %s" },
+    { "NSMSG_HANDLEINFO_FAKEHOST", "Fake host: %s" },
+    { "NSMSG_HANDLEINFO_LAST_HOST", "Last quit hostmask: %s" },
+    { "NSMSG_HANDLEINFO_LAST_HOST_UNKNOWN", "Last quit hostmask: Unknown" },
+    { "NSMSG_HANDLEINFO_NICKS", "Nickname(s): %s" },
+    { "NSMSG_HANDLEINFO_MASKS", "Hostmask(s): %s" },
+    { "NSMSG_HANDLEINFO_CHANNELS", "Channel(s): %s" },
+    { "NSMSG_HANDLEINFO_CURRENT", "Current nickname(s): %s" },
+    { "NSMSG_HANDLEINFO_DNR", "Do-not-register (by %s): %s" },
     { "NSMSG_USERINFO_AUTHED_AS", "$b%s$b is authenticated to account $b%s$b." },
     { "NSMSG_USERINFO_NOT_AUTHED", "$b%s$b is not authenticated to any account." },
     { "NSMSG_NICKINFO_OWNER", "Nick $b%s$b is owned by account $b%s$b." },
@@ -309,7 +310,7 @@ static const struct message_entry msgtab[] = {
         "This email has been sent to verify that this email address belongs to the person who tried to register an account on %1$s.  Your cookie is:\n"
         "%2$s\n"
         "To verify your email address and complete the account registration, visit the following URL:\n"
-        "http://www.afternet.org/play/index.php?option=com_registration&task=activate&username=%5$s&cookie=%2$s\n"
+        "http://www.afternet.org/index.php?option=com_registration&task=activate&username=%5$s&cookie=%2$s\n"
         "\n"
         "If you did NOT request this account, you do not need to do anything.\n"
         "Please contact the %1$s staff if you have questions, and be sure to check our website." },
@@ -323,7 +324,7 @@ static const struct message_entry msgtab[] = {
     { "NSEMAIL_PASSWORD_CHANGE_BODY_WEB", 
         "This email has been sent to verify that you wish to change the password on your account %5$s.  Your cookie is %2$s.\n"
         "To complete the password change, click the following URL:\n"
-        "http://www.afternet.org/play/index.php?option=com_registration&task=passcookie&username=%5$s&cookie=%2$s\n"
+        "http://www.afternet.org/index.php?option=com_registration&task=passcookie&username=%5$s&cookie=%2$s\n"
         "If you did NOT request your password to be changed, you do not need to do anything.\n"
         "Please contact the %1$s staff if you have questions." },
     { "NSEMAIL_EMAIL_CHANGE_SUBJECT", "Email address change verification for %s" },
@@ -1036,6 +1037,27 @@ nickserv_bake_cookie(struct handle_cookie *cookie)
     timeq_add(cookie->expires, nickserv_free_cookie, cookie);
 }
 
+/* Contributed by the great sneep of afternet ;) */
+/* Since this gets used in a URL, we want to avoid stuff that confuses
+ * email clients such as ] and ?. a-z, 0-9 only.
+ */
+void genpass(char *str, int len)
+{
+        int i = 0;
+        char c = 0;
+
+        for(i = 0; i < len; i++)
+        {
+                do
+                {
+                        c = (char)((float)rand() / (float)RAND_MAX * (float)256);
+                } while(!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')));
+                str[i] = c;
+        }
+        str[i] = '\0';
+        return;
+}
+
 static void
 nickserv_make_cookie(struct userNode *user, struct handle_info *hi, enum cookie_type type, const char *cookie_data, int weblink)
 {
@@ -1053,9 +1075,14 @@ nickserv_make_cookie(struct userNode *user, struct handle_info *hi, enum cookie_
     cookie->hi = hi;
     cookie->type = type;
     cookie->data = cookie_data ? strdup(cookie_data) : NULL;
+
     cookie->expires = now + nickserv_conf.cookie_timeout;
-    inttobase64(cookie->cookie, rand(), 5);
-    inttobase64(cookie->cookie+5, rand(), 5);
+    /* Adding dedicated password gen function for more control -Rubin */
+    genpass(cookie->cookie, 10);
+    /*
+     *inttobase64(cookie->cookie, rand(), 5);
+     *inttobase64(cookie->cookie+5, rand(), 5);
+     */
 
     netname = nickserv_conf.network_name;
     subject[0] = 0;
@@ -1358,6 +1385,7 @@ static NICKSERV_FUNC(cmd_handleinfo)
 
     nsmsg_none = handle_find_message(hi, "MSG_NONE");
     reply("NSMSG_HANDLEINFO_ON", hi->handle);
+    reply("MSG_BAR");
 #ifdef WITH_PROTOCOL_BAHAMUT
     reply("NSMSG_HANDLEINFO_ID", hi->id);
 #endif
@@ -1484,7 +1512,7 @@ static NICKSERV_FUNC(cmd_handleinfo)
            }
             if (IsUserSuspended(channel))
                 buff[pos++] = '-';
-            pos += sprintf(buff+pos, "%d:%s ", channel->access, name);
+            pos += sprintf(buff+pos, "%s:%s ", user_level_name_from_level(channel->access), name);
            if (next == NULL) {
              print_chans_buff:
                buff[pos-1] = 0;
@@ -1514,6 +1542,7 @@ static NICKSERV_FUNC(cmd_handleinfo)
        }
     }
 
+    reply("NSMSG_HANDLEINFO_END");
     return 1;
 }