Skip to content

Commit

Permalink
feature 563: send an email to admin when new user registers (optional)
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@1566 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rvelices committed Oct 19, 2006
1 parent af621d4 commit 2a8b727
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/config_default.inc.php
Expand Up @@ -501,6 +501,9 @@
// nbm_treatment_timeout_default is used by default
$conf['nbm_treatment_timeout_default'] = 20;

// Send an email to the webmaster when a new user registers
$conf['email_admin_on_new_user']=false;

// +-----------------------------------------------------------------------+
// | Set default admin layout |
// +-----------------------------------------------------------------------+
Expand Down
15 changes: 15 additions & 0 deletions include/functions_url.inc.php
Expand Up @@ -51,6 +51,21 @@ function get_root_url()
}
}

/**
* returns the url of the current host (e.g. http://www.toto.com )
* TODO: if required by someone, treat https case
*/
function get_host_url()
{
$url = "http://";
$url .= $_SERVER['HTTP_HOST'];
if ($_SERVER['SERVER_PORT']!=80)
{
$url .= ':'.$_SERVER['SERVER_PORT'];
}
return $url;
}

/**
* adds one or more _GET style parameters to an url
* example: add_url_params('/x', array('a'=>'b')) returns /x?a=b
Expand Down
21 changes: 21 additions & 0 deletions register.php
Expand Up @@ -48,6 +48,27 @@
if (count($errors) == 0)
{
$user_id = get_userid($_POST['login']);
log_user( $user_id, false);

if ($conf['email_admin_on_new_user'])
{
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
$username = $_POST['login'];
$admin_url = get_host_url().cookie_path()
.'admin.php?page=user_list&username='.$username;

$content =
'User: '.$username."\n"
.'Mail: '.$_POST['mail_address']."\n"
.'IP: '.$_SERVER['REMOTE_ADDR']."\n"
.'Browser: '.$_SERVER['HTTP_USER_AGENT']."\n\n"
.l10n('admin').': '.$admin_url;

pwg_mail( get_webmaster_mail_address(), '',
'PWG '.l10n('register_title').' '.$username,
$content
);
}
redirect(make_index_url());
}
}
Expand Down

0 comments on commit 2a8b727

Please sign in to comment.