The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

cmd_die.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #include "inspircd.h"
00015 #include "configreader.h"
00016 #include "users.h"
00017 #include "commands/cmd_die.h"
00018 #include "exitcodes.h"
00019 
00020 extern "C" DllExport command_t* init_command(InspIRCd* Instance)
00021 {
00022         return new cmd_die(Instance);
00023 }
00024 
00027 CmdResult cmd_die::Handle (const char** parameters, int pcnt, userrec *user)
00028 {
00029         if (!strcmp(parameters[0],ServerInstance->Config->diepass))
00030         {
00031                 std::string diebuf = std::string("*** DIE command from ") + user->nick + "!" + user->ident + "@" + user->dhost + ". Terminating in " + ConvToStr(ServerInstance->Config->DieDelay) + " seconds.";
00032                 ServerInstance->Log(SPARSE, diebuf);
00033                 ServerInstance->SendError(diebuf);
00034                 
00035                 if (ServerInstance->Config->DieDelay)
00036                         sleep(ServerInstance->Config->DieDelay);
00037 
00038                 InspIRCd::Exit(EXIT_STATUS_DIE);
00039         }
00040         else
00041         {
00042                 ServerInstance->Log(SPARSE, "Failed /DIE command from %s!%s@%s", user->nick, user->ident, user->host);
00043                 ServerInstance->WriteOpers("*** Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host);
00044                 return CMD_FAILURE;
00045         }
00046         return CMD_SUCCESS;
00047 }