Handy edit to login > public.php while game is new

General Chat, Comments
Post Reply
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Handy edit to login > public.php while game is new

Post by cbsarge »

For anyone else that doesn't want to have to log in constantly to see if anyone else has logged in this line of code will alert you with an email when someone logs into the game. It will include the user name of the person who logged in.

In the login module edit the public.php file around line 55.

Code: Select all

$_SESSION["userid"] = $result->fields[0];
$_SESSION["username"] = $result->fields[1];
$_SESSION["block"] = $result->fields[2];
$userId = $result->fields[0];
$result->Close();
becomes

Code: Select all

$_SESSION["userid"] = $result->fields[0];
$_SESSION["username"] = $result->fields[1];
$_SESSION["block"] = $result->fields[2];
//added to send email alerts when someone logs in
mail("somemail@somedomain.com","Someone has logged into the game!", $result->fields[1], Translate("The following player has logged into the game:"));
$userId = $result->fields[0];
$result->Close();
Obviously you'll want to substitute your real email address. :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Handy edit to login > public.php while game is new

Post by hallsofvallhalla »

Thanks for sharing!
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: Handy edit to login > public.php while game is new

Post by KyleMassacre »

I like to use Slack so if this script is for a small amount of people (not every player in the game) then you could utilize the Slack API and just send a message to your Slack channel of your choice.
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Re: Handy edit to login > public.php while game is new

Post by cbsarge »

KyleMassacre wrote:I like to use Slack so if this script is for a small amount of people (not every player in the game) then you could utilize the Slack API and just send a message to your Slack channel of your choice.
Hey Kyle! What are you still doing here? :lol:

You can also modify the public.php file in the register module with similar code to be notified when someone registers a new account. This should go around line 107 right below the SendChatLine that also tells you someone joined and before the RunHook.

So this:

Code: Select all

if (function_exists("SendChatLine"))
SendChatLine(Translate("User %s joined the game.", trim($_POST["username"])));
RunHook("after_register.php");
becomes this:

Code: Select all

if (function_exists("SendChatLine"))
SendChatLine(Translate("User %s joined the game.", trim($_POST["username"])));
mail("someone@somedomain.com","Someone has joined the game!", trim($_POST["username"]), Translate("The following player has joined the game:"));
RunHook("after_register.php");
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: Handy edit to login > public.php while game is new

Post by KyleMassacre »

Actually, it would probably be best to add that to a file called after_register.php
KaL
Posts: 344
Joined: Mon Jan 13, 2014 5:44 am

Re: Handy edit to login > public.php while game is new

Post by KaL »

hi guys! i'm glad someone is still working on NWE. if you guys need help on NWE PM me on facebook: SARONN SOM
i can help you with it.
Post Reply

Return to “General”