X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fregister.php;h=4c4fcc2af12e7b980bcc3a7b4ec6c658ab87c7f1;hb=ed6ada0da571ac88b039a162601ac172c3680710;hp=b162f62beb35bb949db4cb15f7ace2bd42d4f36f;hpb=93bc29a711637c84a4ffc380078277de89af4e6d;p=friendica.git
diff --git a/mod/register.php b/mod/register.php
index b162f62beb..4c4fcc2af1 100644
--- a/mod/register.php
+++ b/mod/register.php
@@ -1,5 +1,9 @@
UTC_TIMESTAMP - INTERVAL 1 day");
if($r && $r[0]['total'] >= $max_dailies) {
return;
@@ -21,7 +25,7 @@ function register_post(&$a) {
switch($a->config['register_policy']) {
-
+
case REGISTER_OPEN:
$blocked = 0;
$verified = 1;
@@ -43,9 +47,13 @@ function register_post(&$a) {
break;
}
- require_once('include/user.php');
- $result = create_user($_POST);
+ $arr = $_POST;
+
+ $arr['blocked'] = $blocked;
+ $arr['verified'] = $verified;
+
+ $result = create_user($arr);
if(! $result['success']) {
notice($result['message']);
@@ -53,7 +61,7 @@ function register_post(&$a) {
}
$user = $result['user'];
-
+
if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
$url = $a->get_baseurl() . '/profile/' . $user['nickname'];
proc_run('php',"include/directory.php","$url");
@@ -71,29 +79,31 @@ function register_post(&$a) {
set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
}
- $email_tpl = get_intltext_template("register_open_eml.tpl");
- $email_tpl = replace_macros($email_tpl, array(
- '$sitename' => $a->config['sitename'],
- '$siteurl' => $a->get_baseurl(),
- '$username' => $user['username'],
- '$email' => $user['email'],
- '$password' => $result['password'],
- '$uid' => $user['uid'] ));
-
- $res = mail($user['email'], sprintf(t('Registration details for %s'), $a->config['sitename']),
- $email_tpl,
- 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
- . 'Content-type: text/plain; charset=UTF-8' . "\n"
- . 'Content-transfer-encoding: 8bit' );
-
-
- if($res) {
- info( t('Registration successful. Please check your email for further instructions.') . EOL ) ;
+ // Only send a password mail when the password wasn't manually provided
+ if (!x($_POST,'password1') OR !x($_POST,'confirm')) {
+ $res = send_register_open_eml(
+ $user['email'],
+ $a->config['sitename'],
+ $a->get_baseurl(),
+ $user['username'],
+ $result['password']);
+
+ if($res) {
+ info( t('Registration successful. Please check your email for further instructions.') . EOL ) ;
+ goaway(z_root());
+ } else {
+ notice(
+ sprintf(
+ t('Failed to send email message. Here your accout details:
login: %s
password: %s
You can change your password after login.'),
+ $user['email'],
+ $result['password']
+ ). EOL
+ );
+ }
+ } else {
+ info( t('Registration successful.') . EOL ) ;
goaway(z_root());
}
- else {
- notice( t('Failed to send email message. Here is the message that failed.') . $email_tpl . EOL );
- }
}
elseif($a->config['register_policy'] == REGISTER_APPROVE) {
if(! strlen($a->config['admin_email'])) {
@@ -110,43 +120,40 @@ function register_post(&$a) {
dbesc($lang)
);
- $r = q("SELECT `language` FROM `user` WHERE `email` = '%s' LIMIT 1",
- dbesc($a->config['admin_email'])
- );
- if(count($r))
- push_lang($r[0]['language']);
- else
- push_lang('en');
-
+ // invite system
if($using_invites && $invite_id) {
q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
}
- $email_tpl = get_intltext_template("register_verify_eml.tpl");
- $email_tpl = replace_macros($email_tpl, array(
- '$sitename' => $a->config['sitename'],
- '$siteurl' => $a->get_baseurl(),
- '$username' => $user['username'],
- '$email' => $user['email'],
- '$password' => $result['password'],
- '$uid' => $user['uid'],
- '$hash' => $hash
- ));
-
- $res = mail($a->config['admin_email'], sprintf(t('Registration request at %s'), $a->config['sitename']),
- $email_tpl,
- 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
- . 'Content-type: text/plain; charset=UTF-8' . "\n"
- . 'Content-transfer-encoding: 8bit' );
-
- pop_lang();
-
- if($res) {
- info( t('Your registration is pending approval by the site owner.') . EOL ) ;
- goaway(z_root());
+ // send email to admins
+ $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
+ $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
+ $admin_mail_list
+ );
+
+
+ foreach ($adminlist as $admin) {
+ notification(array(
+ 'type' => NOTIFY_SYSTEM,
+ 'event' => 'SYSTEM_REGISTER_REQUEST',
+ 'source_name' => $user['username'],
+ 'source_mail' => $user['email'],
+ 'source_nick' => $user['nickname'],
+ 'source_link' => $a->get_baseurl()."/admin/users/",
+ 'link' => $a->get_baseurl()."/admin/users/",
+ 'source_photo' => $a->get_baseurl() . "/photo/avatar/".$user['uid'].".jpg",
+ 'to_email' => $admin['email'],
+ 'uid' => $admin['uid'],
+ 'language' => ($admin['language']?$admin['language']:'en'))
+ );
}
+
+ info( t('Your registration is pending approval by the site owner.') . EOL ) ;
+ goaway(z_root());
+
+
}
return;
@@ -177,7 +184,7 @@ function register_content(&$a) {
}
$max_dailies = intval(get_config('system','max_daily_registrations'));
- if($max_dailes) {
+ if($max_dailies) {
$r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
if($r && $r[0]['total'] >= $max_dailies) {
logger('max daily registrations exceeded.');
@@ -188,6 +195,8 @@ function register_content(&$a) {
if(x($_SESSION,'theme'))
unset($_SESSION['theme']);
+ if(x($_SESSION,'mobile-theme'))
+ unset($_SESSION['mobile-theme']);
$username = ((x($_POST,'username')) ? $_POST['username'] : ((x($_GET,'username')) ? $_GET['username'] : ''));
@@ -227,10 +236,12 @@ function register_content(&$a) {
'$yes_selected' => ' checked="checked" ',
'$no_selected' => '',
'$str_yes' => t('Yes'),
- '$str_no' => t('No')
+ '$str_no' => t('No'),
));
}
+ $r = q("SELECT count(*) AS `contacts` FROM `contact`");
+ $passwords = !$r[0]["contacts"];
$license = '';
@@ -240,6 +251,8 @@ function register_content(&$a) {
call_hooks('register_form',$arr);
+ $o = $arr['template'];
+
$o = replace_macros($o, array(
'$oidhtml' => $oidhtml,
'$invitations' => get_config('system','invitation_only'),
@@ -249,15 +262,18 @@ function register_content(&$a) {
'$realpeople' => $realpeople,
'$regtitle' => t('Registration'),
'$registertext' =>((x($a->config,'register_text'))
- ? '