X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fregister.php;h=81e8c3ad83927c03bd06fdc6a175eadf7d7c6838;hb=9259feec6f4b0a24c15f971a3dc8fa54f4f08141;hp=6bf287d4245b0c70ce12d3395b9f4ad216216d10;hpb=01daaafc92d09f042ae3f881bf97606c449f6d3e;p=friendica.git diff --git a/mod/register.php b/mod/register.php index 6bf287d424..81e8c3ad83 100644 --- a/mod/register.php +++ b/mod/register.php @@ -1,7 +1,11 @@ config['register_policy']) { - + case REGISTER_OPEN: $blocked = 0; $verified = 1; @@ -43,12 +47,12 @@ function register_post(&$a) { break; } - require_once('include/user.php'); $arr = $_POST; $arr['blocked'] = $blocked; $arr['verified'] = $verified; + $arr['language'] = get_browser_language(); $result = create_user($arr); @@ -58,10 +62,10 @@ 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"); + $url = App::get_baseurl() . '/profile/' . $user['nickname']; + proc_run(PRIORITY_LOW, "include/directory.php", $url); } $using_invites = get_config('system','invitation_only'); @@ -76,29 +80,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'], + App::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'])) { @@ -107,50 +113,53 @@ function register_post(&$a) { } $hash = random_string(); - $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language` ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", + $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language`, `note` ) VALUES ( '%s', '%s', %d, '%s', '%s', '%s' ) ", dbesc($hash), dbesc(datetime_convert()), intval($user['uid']), dbesc($result['password']), - dbesc($lang) - ); - - $r = q("SELECT `language` FROM `user` WHERE `email` = '%s' LIMIT 1", - dbesc($a->config['admin_email']) + dbesc($lang), + dbesc($_POST['permonlybox']) ); - 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 + ); + + // send notification to admins + 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' => App::get_baseurl()."/admin/users/", + 'link' => App::get_baseurl()."/admin/users/", + 'source_photo' => App::get_baseurl() . "/photo/avatar/".$user['uid'].".jpg", + 'to_email' => $admin['email'], + 'uid' => $admin['uid'], + 'language' => ($admin['language']?$admin['language']:'en'), + 'show_in_notification_page' => false + )); } + // send notification to the user, that the registration is pending + send_register_pending_eml( + $user['email'], + $a->config['sitename'], + $user['username']); + + info( t('Your registration is pending approval by the site owner.') . EOL ) ; + goaway(z_root()); + } @@ -163,7 +172,7 @@ function register_post(&$a) { if(! function_exists('register_content')) { -function register_content(&$a) { +function register_content(App $a) { // logged in users can register others (people/pages/groups) // even with closed registrations, unless specifically prohibited by site policy. @@ -234,10 +243,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 = ''; @@ -247,24 +258,31 @@ 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'), + '$permonly' => $a->config['register_policy'] == REGISTER_APPROVE, + '$permonlybox' => array('permonlybox', t('Note for the admin'), '', t('Leave a message for the admin, why you want to join this node')), '$invite_desc' => t('Membership on this site is by invitation only.'), '$invite_label' => t('Your invitation ID: '), '$invite_id' => $invite_id, '$realpeople' => $realpeople, '$regtitle' => t('Registration'), '$registertext' =>((x($a->config,'register_text')) - ? '
' . $a->config['register_text'] . '
' + ? bbcode($a->config['register_text']) : "" ), '$fillwith' => $fillwith, '$fillext' => $fillext, '$oidlabel' => $oidlabel, '$openid' => $openid_url, - '$namelabel' => t('Your Full Name ' . "\x28" . 'e.g. Joe Smith' . "\x29" . ': '), + '$namelabel' => t('Your Full Name ' . "\x28" . 'e.g. Joe Smith, real or real-looking' . "\x29" . ': '), '$addrlabel' => t('Your Email Address: '), - '$nickdesc' => t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'nickname@$sitename\'.'), + '$passwords' => $passwords, + '$password1' => array('password1', t('New Password:'), '', t('Leave empty for an auto generated password.')), + '$password2' => array('confirm', t('Confirm:'), '', ''), + '$nickdesc' => str_replace('$sitename',$a->get_hostname(),t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'nickname@$sitename\'.')), '$nicklabel' => t('Choose a nickname: '), '$photo' => $photo, '$publish' => $profile_publish, @@ -273,7 +291,10 @@ function register_content(&$a) { '$email' => $email, '$nickname' => $nickname, '$license' => $license, - '$sitename' => $a->get_hostname() + '$sitename' => $a->get_hostname(), + '$importh' => t('Import'), + '$importt' => t('Import your profile to this friendica instance'), + )); return $o;