[2.0.17] Email Admin on ACP Login

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
4
33%
Very Good
1
8%
Good
2
17%
Fair
1
8%
Poor
4
33%
 
Total votes: 12

Extensions Robot
Extensions Robot
Extensions Robot
Posts: 28596
Joined: Sat Aug 16, 2003 7:36 am

[2.0.17] Email Admin on ACP Login

Post by Extensions Robot »

MOD Name: Email Admin on ACP Login
Author: The Defpom
MOD Description: Adds a feature so that if the ACP is accessed it emails the admin.


MOD Version: 1.1.3 (Updated 08/16/05)

Download File: Email_Admin_On_ACP_Login113.zip
mods overview page: View
File Size: 3070 Bytes

Security Score: 0
Last edited by Extensions Robot on Mon Apr 30, 2007 12:27 am, edited 1 time in total.
(this is a non-active account manager for the phpBB Extension Customisations Team)
Manipe
Former Team Member
Posts: 1146
Joined: Thu Jul 22, 2004 6:30 pm
Location: Éire
Contact:

Post by Manipe »

MOD Validated/Released

Notes:
If your Admin Control Panel is hacked by another user, this MOD sends you (The Admin) an e-mail with the hacker's username, user id and IP address.
My MODs: [ Topics a user has started ] , [ Profile views ] , [ Colour on poll results ] , [ Topic posters ] , [ Add number to PM ] , [ Default avatar ] , [ View category name ] , [ Null vote ] , [ Forum description in viewforum ] , [ Resync forum ids ] , [ View PM while replying ] , [ Quick poll insert ] , [ Limit login attempts ] , [ Track PMs ]

www.ManipeF1.com
AbelaJohnB
Former Team Member
Posts: 5674
Joined: Fri Jul 06, 2001 11:56 pm

Post by AbelaJohnB »

hey Defpm,


Might I suggest the use of another sprintf() function within:

Code: Select all

$emailer->set_subject($lang['ACP_Login']);

and include:

Code: Select all

$board_config['sitename']

Some of us have more than one forum installed ;)



Additionally, I show an error while installing this MOD. A missing close-bracket within line:

Code: Select all

$emailer->assign_vars(array....
I tried it twice and it was present both times. MOD validator might want to give this another try ;)


Proper syntax should be:

Code: Select all

	$emailer->assign_vars(
                            array(
                                'USERNAME' => $userdata['username'],
                                'USERID' => $userdata['user_id'],
                                'USERIP' => decode_ip($user_ip),
                                'TIME' => sprintf(
                                                    $lang['Current_time'], 
                                                    create_date(
                                                                $board_config['default_dateformat'], 
                                                                time(), $board_config['board_timezone']
                                                                )
                                                )
                                )
                        );
rather than:

Code: Select all

	$emailer->assign_vars(
                            array(
                                'USERNAME' => $userdata['username'],
                                'USERID' => $userdata['user_id'],
                                'USERIP' => decode_ip($user_ip),
                                'TIME' => sprintf(
                                                    $lang['Current_time'], 
                                                    create_date(
                                                                $board_config['default_dateformat'], 
                                                                time(), $board_config['board_timezone']
                                                                )
                                                )
                        );



Lastly, for me it sends out three emails rather than one!


If you ask me, this part is totally wrong:

Code: Select all

# 
#---[ FIND ]------------------------------------------------- 
# 
// 
// Generate relevant output
//

# 
#---[ BEFORE, ADD ]--------------------------------------- 
# 
....
I would suggest:

Code: Select all

# 
#---[ FIND ]------------------------------------------------- 
# 
if( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'left' )
{

# 
#---[ AFTER, ADD ]--------------------------------------- 
# 
...

Just might be me and mine... but this is what I'd suggest to fix this possible error.
kukacomone
Registered User
Posts: 55
Joined: Wed Jul 14, 2004 10:30 pm

Post by kukacomone »

AbelaJohnB thanx for the modify, the original mod doesnt work.
»»EDDY««
Registered User
Posts: 220
Joined: Mon Jun 02, 2003 10:14 am
Location: Poland/Slupsk
Contact:

Post by »»EDDY«« »

So how should it be it to work?
Make a Tiny URL in excellent domain heh.pl


cooling system & water cooling
AbelaJohnB
Former Team Member
Posts: 5674
Joined: Fri Jul 06, 2001 11:56 pm

Post by AbelaJohnB »

kukacomone wrote: AbelaJohnB thanx for the modify, the original mod doesnt work.



Yep! This is obviously a case where the MOD author just threw it into EasyMOD and went "yep, it installs okie, we'll let it through".... without ever checking it.... :roll:
deny
Registered User
Posts: 565
Joined: Wed May 14, 2003 9:14 am
Location: Find-Ip-Address.org
Contact:

Post by deny »

Wonder how this mod could be approved from phpBB team if does not works!? 8O
And then isn't better to make this mod not public available before all errors are fixed and mod works as it is supposed to be.
Just suggestion.
User avatar
The Defpom
Registered User
Posts: 101
Joined: Sat Aug 21, 2004 11:58 pm
Location: New Zealand
Contact:

Post by The Defpom »

Why are you guys suddenly slamming stuff, the mod does work, and it obviously worked for the MOD team as well, otherwise they would not have validated the mod, plus other users have successfully installed it.

instead of complaining and making accussations, how about you give me some information, to try and work out why it does not work for you, what problems are you having, is it not installing, is it not operating ?

Did you follow the instrustions fully ?, it will only email the admin if a user OTHER than the admin accesses the ACP, so if you expect an email if you login you WONT GET ONE, UNLESS, you set the user ID to "0" (Zero) so it emails on ALL accesses.

If you have installed it and you do not get an email check a couple of things, try changing the ID number in the file to be 0, that way it will email even when a real admin accesses it.

Does your forum use the php mail funtin or does it use SMTP ?

Come on guys, play nice, I did this MOD to help people out, I could have just kept it to myself, and not let anyone else benifit, but I thought it would be a worthwhile addition to improve the security.
User avatar
The Defpom
Registered User
Posts: 101
Joined: Sat Aug 21, 2004 11:58 pm
Location: New Zealand
Contact:

Post by The Defpom »

AbelaJohnB wrote: hey Defpm,


Might I suggest the use of another sprintf() function within:


Thank you for your suggestions and findings, i will look into it, I dont know why this stuf wasn't picked up before when it was in beta, a bit strange, especially with it being validated by the MOD team too, as I mentioned I have it on my forum and it is working perfectly.

Anyway, thanks and I will get onto the problems you found.
User avatar
The Defpom
Registered User
Posts: 101
Joined: Sat Aug 21, 2004 11:58 pm
Location: New Zealand
Contact:

Post by The Defpom »

OK people, here is the full MOD, with the fixes required, I have installed this over my existing version on my forum, and it DOES work.

Code: Select all

##############################################################
## MOD Title:   Email Admin on ACP Login
## MOD Author:  The Defpom < > (Scott Gausden) http://www.radiomods.co.nz
## MOD Description:  Adds a feature so that if the ACP is accessed it emails the admin.
## MOD Version: 1.0.2
##
## Installation Level: Easy
## Installation Time:  1 Minutes
## Files To Edit:	2
##			admin/index.php
##          language/lang_english/lang_main.php
##
## Included Files: 1
##          language/lang_english/email/admin_acp_login.tpl
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
##############################################################
## Author Notes: Works with Easymod !!
## 
## This mod will add a a feature so that if the ACP is accessed by someone other than the main admin it emails the admin to let them know !
## It includes the persons user name, user ID, IP Address and time accessed.
##
## NOTE: it is neccesary to set the required ADMIN user ID in the code below (x2), the default ID is "2", so if the main admin has a different user id
## change the code to the same ID.
##
##
## This MOD can be seen in action on my forum: http://www.radiomods.co.nz/forum/
## 
############################################################## 
## MOD History: 
##

## 04/29/05 - 1.0.2
##	    - Minor code changes (added missing bracket, added sitename to email, fixed multiple emails)
## 04/13/05 - 1.0.1
##	    - Minor code fix
## 04/02/05 - 1.0.0
##	    - Submitted for release
## 03/23/05 - 0.1.1
##	    - First Version
## 
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################
# 
#---[ COPY ]------------------------------------------------ 
# 
copy language/lang_english/email/admin_acp_login.tpl to language/lang_english/email/admin_acp_login.tpl


# 
#---[ OPEN ]------------------------------------------------ 
# 
admin/index.php

# 
#---[ FIND ]------------------------------------------------- 
# 
if( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'left' )
{

# 
#---[ AFTER, ADD ]--------------------------------------- 
# 

// 
//send e-mail to admin on ACP access
//

// The first line below sets the admin account user id, if the ACP is accessed by a different ID it will activate the email feature.
// The default is ID 2 (main ADMIN), if the main admin has a different ID number enter it instead of 2 ie for ID 3 use $userdata['user_id'] != 3
// You will also need to enter the correct admin user ID on the 5th line down (if it is not "2") otherwise it wont email the right person !
// if you want to be emailed for all ACP accesses change code to read: $userdata['user_id'] != 0

if( $userdata['user_id'] != 2 ) //User ID of Admin, checks if the user ID is NOT admin user id, if true it runs the statement.
      {
      include($phpbb_root_path . 'includes/emailer.'.$phpEx);
      $emailer = new emailer($board_config['smtp_delivery']);
       $sql = 'SELECT user_email FROM ' . USERS_TABLE . ' WHERE user_id = 2'; //User ID of Admin, you will need to change this if the admins user id is not "2"
				if( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, 'Could not select Administrators', '', __LINE__, __FILE__, $sql);
				}

				while ($row = $db->sql_fetchrow($result))
				{

					$emailer->from($board_config['board_email']);
					$emailer->replyto($board_config['board_email']);
					$emailer->email_address(trim($row['user_email']));
					$emailer->use_template('admin_acp_login');
					$emailer->set_subject($lang['ACP_Login']);
					$emailer->assign_vars(array(
						'USERNAME' => $userdata['username'],
						'USERID' => $userdata['user_id'],
						'USERIP' => decode_ip($user_ip),
						'SITENAME' => $board_config['sitename'],
                        'TIME' => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])))
					);
				}
		$db->sql_freeresult($result);
     $emailer->send();
     $emailer->reset();
     }
     
//
//end send e-mail to admin
//


# 
#---[ OPEN ]------------------------------------------------ 
# 
language/lang_english/lang_main.php

# 
#---[ FIND ]------------------------------------------------- 
# 
//
// That's all, Folks!
// -------------------------------------------------

# 
#---[ BEFORE, ADD ]--------------------------------------- 
# 

// Email Admin on ACP Login
$lang['ACP_Login'] = 'Someone just accessed the admin control panel !!';


 
# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM
Also you will need to alter the language/lang_english/subSilver/email/admin_acp_login.tpl to read this instead:

Code: Select all

Charset: iso-8859-1
  


This is an automated message, {TIME}

Urgent Warning !!
======================================================

A user named: {USERNAME}

With a user ID of: {USERID})

And with the IP Address of: {USERIP}

Just accessed the Admin Control Panel !!!

{SITENAME} should be checked for problems.

=====================================================
I hope that this fixes the problems you guys have had.
AbelaJohnB
Former Team Member
Posts: 5674
Joined: Fri Jul 06, 2001 11:56 pm

Post by AbelaJohnB »

The Defpom wrote: Why are you guys suddenly slamming stuff, the mod does work...


Scott,

I was beyond helpfull... I spent a good 15-20 minutes trying to figure out what the hell was wrong with this mod. Time *I* shouldn't have to spend on it! If it's publically released it should work.. I shouldn't have to fix it!
The Defpom wrote: it obviously worked for the MOD team as well


Umm, it obviously didn't! If it had, you wouldn't have had to release a new version to fix an obvious error, nor would I have had to spent the time fixing it! We aren't "slamming" you, we are "slamming" the validation process!

The Defpom wrote: plus other users have successfully installed it.


Oh, please, show me anybody that installed the version released and had it work! I'd like to see the server that allows a php error to actually parse, rather by-pass, the error!
The Defpom wrote: instead of complaining and making accussations, how about you give me some information, to try and work out why it does not work for you


Hmm, perhaps I already did. Oh, and your welcome!
The Defpom wrote: Did you follow the instrustions fully


I'm about the last person that needs a lecture about "follow the instrustions fully", so please :roll:


The Defpom wrote: Did you follow the instrustions fully ?, it will only email the admin if a user OTHER than the admin accesses the ACP, so if you expect an email if you login you WONT GET ONE, UNLESS, you set the user ID to "0" (Zero) so it emails on ALL accesses.


What the hell does that have to do with anything? Not a single post above had ANYTHING to do with this.
The Defpom wrote: Does your forum use the php mail funtin or does it use SMTP ?


Again, what does that have to do with anything? Not a single post above had ANYTHING to do with this.

The Defpom wrote: Come on guys, play nice, I did this MOD to help people out


Where above is anybody not being nice to you? Hmm, let me see.... ah, yeah, nowhere!

Oh, and if what I did above was not "help people out", I'm not sure what is.



Ok, all that said... I'll move on to something productive.... :mrgreen:

I think you totally mis-understood my comment/suggestion about the sprintf() function.

The idea was to have the name of the forum/site within the "subject" of the email, not the body ;)

That would be the nicest feature that I can think of, for a next version :D


Lastly, thanks for the updated version!

(...oh, and thanks for the credit in your latest version for the code I provided...)
User avatar
The Defpom
Registered User
Posts: 101
Joined: Sat Aug 21, 2004 11:58 pm
Location: New Zealand
Contact:

Post by The Defpom »

I was not trying to start an argument, so sorry if it appeared that way !

I agree, the mod should have worked, first time, being a released version.

I know that others have used it, BUT it may be that the missing bracket error appeared in a later revision, and got somehow got missed.

I added the update because it obviously needed it, because of an error that had crept in, again, I say that the version I have on my forum works, and others were using it as well, BUT they would have been an earlier verison, I think that the error occured because of a validation issue which I had to fix, where I removed some code from the MOD.

My comments about following the instructions were targeted at the other people that posted here, indicating that the mod didn't work, I wanted to try and find out if it was some other issue.

I added the sitename because you asked for it, and I agree it was a good idea, I used the template so people can easily change it if needed, rather than hard coding it in.

If only I had this much feedback when it was posted in the BETA forum !

Thank you for finding the causes of the problems, and the suggested fixes, which were bang on, moving the code segment fixed the triple email issue, you obviously know your stuff.
AbelaJohnB
Former Team Member
Posts: 5674
Joined: Fri Jul 06, 2001 11:56 pm

Post by AbelaJohnB »

The Defpom wrote: I was not trying to start an argument, so sorry if it appeared that way


Not a problem. I just don't like being corrected when I shouldn't be getting corrected.
The Defpom wrote: If only I had this much feedback when it was posted in the BETA forum !


Yeah. I always had the same problem. I think most people (like myself, now) don't deal with mods until they are "officially" released. At that point I take a look at them. Beta's go through too many changes for me to look at them.
The Defpom wrote: Thank you for finding the causes of the problems, and the suggested fixes, which were bang on, moving the code segment fixed the triple email issue, you obviously know your stuff.


You are most welcome. Yeah, that 3-email thing had me going crazy for about 10 minutes. I'm not 100% positive placing it where I did was the best method either... it worked, but I'm not sure it's the _best_ method. I didn't put that much thought into it, I just wanted to quick-fix it.

What is also strange is the time it takes for the email to process. It seems like it take ~5 seconds, which is way longer than it should. Might need to benchmark this and see what the hold-up is on my end.
User avatar
The Defpom
Registered User
Posts: 101
Joined: Sat Aug 21, 2004 11:58 pm
Location: New Zealand
Contact:

Post by The Defpom »

Once I see a few posts here about successfull installations I will resubmit this version for release to replace V 1.0.1.
AbelaJohnB
Former Team Member
Posts: 5674
Joined: Fri Jul 06, 2001 11:56 pm

Post by AbelaJohnB »

Oh, hey, check out how the Registration Email handles sprintf() to pass the board_name in the email that is sent out for registration confirmation!

Just dawned on me to refer you there to check out the code, as it does what I'm thinking.
Post Reply

Return to “[2.0.x] MOD Database Releases”