[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

User avatar
The Defpom
Registered User
Posts: 101
Joined: Sat Aug 21, 2004 11:58 pm
Location: New Zealand
Contact:

Post by The Defpom »

Kalipo wrote:
Kalipo wrote:
The time now is May 01 2005


No time specified in the email, just the date.


1 Perfect install. Am I the only one with this bug?


Is this with the modified one you did for the MCP ? or doesn't it matter which ?

When I tested my one it gave : The time now is Sun 1st May, 2005, 10:55

So I think the problem MAY be with your forums date setting.
User avatar
Kalipo
Registered User
Posts: 551
Joined: Mon Dec 08, 2003 1:47 pm

Post by Kalipo »

So I think the problem MAY be with your forums date setting.


Uh, funny you mention that :x
User avatar
The Defpom
Registered User
Posts: 101
Joined: Sat Aug 21, 2004 11:58 pm
Location: New Zealand
Contact:

Post by The Defpom »

The normal format as set in the ACP Configuration panel would be:

d M Y H:i

which is: day month year hours:minutes

Check that your ACP panel is set to also include hours and minutes, a give away COULD be if it is displayed correctly on the header of your forum, BUT, that display is also controlled by your profiles date format setting.

Let me know how you get on.
User avatar
Kalipo
Registered User
Posts: 551
Joined: Mon Dec 08, 2003 1:47 pm

Post by Kalipo »

When I change $board_config['board_timezone'] to $userdata['user_timezone'], it works fine. Only problem is it's pulling the User's config.

It's got to be the board config. I'll get it going.
AbelaJohnB
Former Team Member
Posts: 5674
Joined: Fri Jul 06, 2001 11:56 pm

Post by AbelaJohnB »

Kalipo,

With the MOD already installed, try making these changes:


FIND

Code: Select all

$sql = 'SELECT user_email FROM ' . USERS_TABLE . ' WHERE user_id = 2';
REPLACE WITH:

Code: Select all

$sql = 'SELECT user_email, user_timezone, user_dateformat FROM ' . USERS_TABLE . ' WHERE user_id = 2';

FIND:

Code: Select all

create_date( 
$board_config['default_dateformat'], 
time(), 
$board_config['board_timezone']
)
and REPLACE WITH:

Code: Select all

create_date( 
$row['user_dateformat'], 
time(), 
$row['user_timezone']
)

This method, to me, makes a lot more sense. :mrgreen:
User avatar
The Defpom
Registered User
Posts: 101
Joined: Sat Aug 21, 2004 11:58 pm
Location: New Zealand
Contact:

Post by The Defpom »

Good idea, that way it is based on the admins time zone instead of the boards time zone.
User avatar
Kalipo
Registered User
Posts: 551
Joined: Mon Dec 08, 2003 1:47 pm

Post by Kalipo »

Yeah, way cleaner.

At first glance, the ONLY problem that could arise from it is if user_id = 2 has a jacked up dateformat (i.e. d M Y or D M d, Y) where the time isn't specified.

I can't see why it wouldn't be included (or why someone would want it that way) but eh, to each their own I guess :?

Added it, worked perfectly. Again, as long as user_id = 2 has the time included in his/her dateformat, it'll work just peachy.

John, I may not always agree with you & may not like some things you say (or how you say it), but it'll be a cold day in hell when you hear me say (er, rather see me type) that you don't know what you're doing.

May you have many wives & no alimony in your years ahead.
Teletran One
Registered User
Posts: 149
Joined: Thu Apr 14, 2005 11:31 pm
Location: Canada
Contact:

Post by Teletran One »

So, uh, are there any changes to the overall code since last night? :?
User avatar
Kalipo
Registered User
Posts: 551
Joined: Mon Dec 08, 2003 1:47 pm

Post by Kalipo »

I hope you don't mind Scott, all I'm doing is changing what John noted (not touching the changelog or any other part of the MOD) :D

This includes the timezone & dateformat based off of user_id = 2 instead of the board configuration.

Ensure in the profile of user_id = 2 (main admin) that the Date Format displays one of the following (in bold)...

d M Y H:i (1 Jan 2005 14:00--24 hour config)

or

D M d, Y g:i a (Mon Jan 1, 2005 2:00 pm--12 hour config w/day)

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, user_timezone, user_dateformat 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($row['user_dateformat'], time(), $row['user_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.

=====================================================
User avatar
guten targ
Registered User
Posts: 17
Joined: Thu Jan 22, 2004 7:56 pm
Location: Auckland, New Zealand
Contact:

Post by guten targ »

Thanks defpom, nice mod and cheers for the code fixes JohnA/Kalipo, it works brilliantly, not a bad mod to have so cheers gentlemen.
User avatar
The Defpom
Registered User
Posts: 101
Joined: Sat Aug 21, 2004 11:58 pm
Location: New Zealand
Contact:

Post by The Defpom »

WOW, you must be just up the road, I am in Auckland as well.... ( well, in Franklin to be more precise).
User avatar
guten targ
Registered User
Posts: 17
Joined: Thu Jan 22, 2004 7:56 pm
Location: Auckland, New Zealand
Contact:

Post by guten targ »

Penrose I call home old chap and yeah..just up the road a ways :wink:

I've been trying to hack this to email a second admin..all I've managed to do is screw things up, but I haven't given up yet and I find trying to figure it out a bit of a thrill :lol:
AbelaJohnB
Former Team Member
Posts: 5674
Joined: Fri Jul 06, 2001 11:56 pm

Post by AbelaJohnB »

guten targ,

Are you wanting to send it to ALL administrators, or just two very specific people?

It would be a lot better to have this script reworked to send to ADMIN rather than user_id = 2,14


Let us know what you are doing, in details, and we'll see what we can do to aid.

So, have you had your cup or Noni yet today ;)
IRCNetworkz.com
Registered User
Posts: 2
Joined: Mon Apr 25, 2005 1:29 am
Location: Australia
Contact:

Post by IRCNetworkz.com »

hey ius there a way to Add 2 User IDS? like emm I got to main admins on my site and if would be great if they could email both and if it detects both of us a main admins is there a way?
------------------------------
IRCNetworkz
www.ircnetworkz.com
--------------------------------
chesster
Registered User
Posts: 37
Joined: Tue Apr 05, 2005 3:25 am

Post by chesster »

Is there anyway to see this mod works? or do i have to wait until a hacker whose userid is not 2 to comes in?

I commented out "if(userid != 2)" so that all accesses to ACP result in an email notification, but so far I haven't received any email whenever I access ACP. (I'm using 2.0.13). Any reason?
Post Reply

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