/* fics_addplayer.c * */ /* icds - Internet Checkers and Draughts Server Copyright (c) 1997 by Michael Rohrer fics - An internet chess server. Copyright (C) 1994 Richard V. Nash This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ /* Revision history: name email yy/mm/dd Change Richard Nash 94/03/07 Created */ /* This is basically a copy of fics_addplayer that has been modified * slightly so it can be used within the checkers server. */ #include "stdinclude.h" #include "common.h" #include "utils.h" #include "playerdb.h" #include "command.h" #include "addplayer.h" /* extern time_t time(); extern int printf(); */ #if 0 PRIVATE void usage(char *progname) { fprintf(stderr, "Usage: %s [-l] [-n] UserName FullName EmailAddress\n", progname); exit(1); } /* Parameters */ int local = 1; char *funame = NULL, *fname = NULL, *email = NULL; #define PASSLEN 4 #endif PUBLIC int server_addplayer(char *username, char *email, char *fullname) { int i; int p; char password[PASSLEN + 1]; char salt[3]; char text[2048]; #if 0 for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { case 'l': local = 1; break; case 'n': local = 0; break; default: usage(argv[0]); break; } } else { if (!funame) funame = argv[i]; else if (!fname) fname = argv[i]; else if (!email) email = argv[i]; else usage(argv[0]); } } if (!funame || !fname || !email) usage(argv[0]); #endif /* Add the player here */ if (strlen(username) >= MAX_LOGIN_NAME) { fprintf(stderr, "Player name is too long\n"); return (0); } if (strlen(username) < 3) { fprintf(stderr, "Player name is too short\n"); return(0); } if (!alphastring(username)) { fprintf(stderr, "Illegal characters in player name. Only A-Za-z allowed.\n"); return(0); } /* loon: see if we can deliver mail to this email address. */ /* printf("Verifying email address %s...\n", email); if (check_emailaddr(email)) { fprintf(stderr, "The email address %s looks bad.\n", email); return(0); } */ /* if (local) iamserver = 0; else iamserver = 1; */ /* if (hostinfo_init()) { if (iamserver) { fprintf(stderr, "Can't read from hostinfo file.\n"); fprintf(stderr, "Remember you need -l for local.\n"); return(1); } else { } } */ player_init(0); srand(time(0)); p = player_new(); if (!player_read(p, username)) { fprintf(stderr, "%s already exists.\n", username); return(0); } parray[p].name = strdup(username); parray[p].login = strdup(username); stolower(parray[p].login); parray[p].fullName = strdup(fullname); parray[p].emailAddress = strdup(email); for (i = 0; i < PASSLEN; i++) { password[i] = 'a' + rand() % 26; } password[i] = '\0'; salt[0] = 'a' + rand() % 26; salt[1] = 'a' + rand() % 26; salt[2] = '\0'; parray[p].passwd = strdup(crypt(password, salt)); parray[p].registered = 1; parray[p].rated = 1; parray[p].refresh = 0; player_save(p); /* printf("Added player account: >%s< >%s< >%s< >%s<\n", funame, fname, email, password); */ sprintf(text, "\nYour player account has been created.\n\n" "Login Name: %s\nFull Name: %s\nEmail Address: %s\nInitial Password: %s\n\n" "If any of this information is incorrect, please contact the administrator\n" "to get it corrected.\n\n" "You may change your password with the password command on the the server.\n" "\nPlease be advised that if this is an unauthorized duplicate account for\n" "you, by using it you take the risk of being banned from accessing this\n" "chess server.\n\nTo connect to the server and use this account:\n\n" " telnet %s 4444\n\nand enter your handle name and password.\n\n" "When you connect, you might want to read the \'help begin\' file. This\n" "will give you a list of commands you will most likely use and some basic\n" "server information to help you get started quicker. The help files\n" "are available on site http://infinity.digital-web.net/~lionman/help\n" "The server home page is http://infinity.digital-web.net/~lionman/checkers.html\n" "Information about the server can be found there.\n\n" "Regards,\n\nThe ICDS admins\n", username, fullname, email, password, fics_hostname); mail_string_to_address(email, "ICDS Account Created", text); return(0); }