Skip to content

Commit f1cae31

Browse files
committed
Mod
1 parent e5fab72 commit f1cae31

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

library/config.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@
620620
// Captcha
621621
// Get a Google reCAPTCHA API Key: https://www.google.com/recaptcha/admin
622622
$bb_cfg['captcha'] = array(
623-
'disabled' => false,
623+
'disabled' => true,
624624
'public_key' => '', // your public key
625625
'secret_key' => '', // your secret key
626626
'theme' => 'light', // light or dark
@@ -638,6 +638,13 @@
638638
'allowed_url' => array($domain_name), // 'allowed.site', 'www.allowed.site'
639639
);
640640

641+
$bb_cfg['ulogin'] = array(
642+
'enabled' => true,
643+
'fields' => 'email,nickname',
644+
'providers' => 'vkontakte,odnoklassniki,mailru,facebook',
645+
'hidden' => 'other'
646+
);
647+
641648
// Local config
642649
if (file_exists(BB_ROOT. '/library/config.local.php'))
643650
{

library/includes/functions.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,4 +2824,41 @@ function bb_captcha ($mode, $callback = '')
28242824
bb_simple_die(__FUNCTION__ .": invalid mode '$mode'");
28252825
}
28262826
return false;
2827+
}
2828+
2829+
/**
2830+
* Заполнить POST из данных uLogin
2831+
*/
2832+
function fill_post_from_ulogin() {
2833+
if (!isset($_POST['token'])) {
2834+
return;
2835+
}
2836+
2837+
$data = file_get_contents('http://ulogin.ru/token.php?token=' . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']);
2838+
$user = json_decode($data, true);
2839+
if (!$user) {
2840+
return;
2841+
}
2842+
2843+
$rand_password = generate_password();
2844+
2845+
$_POST['username'] = $user['nickname'];
2846+
$_POST['user_email'] = $user['email'];
2847+
$_POST['new_pass'] = $rand_password;
2848+
$_POST['cfm_pass'] = $rand_password;
2849+
$_POST['submit'] = 'submit';
2850+
}
2851+
2852+
/**
2853+
* Сгенерировать случайны пароль
2854+
* @param int $length
2855+
* @return string
2856+
*/
2857+
function generate_password($length = 10) {
2858+
$symbols = array_merge(range('a', 'z'), range('A', 'Z'), range(0, 9));
2859+
$result = '';
2860+
for($i = 0; $i < $length; $i++) {
2861+
$result .= $symbols[rand(0, count($symbols) - 1)];
2862+
}
2863+
return $result;
28272864
}

library/includes/ucp/register.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
array_deep($_POST, 'trim');
66

7+
fill_post_from_ulogin();
8+
79
set_die_append_msg();
810

911
if (IS_ADMIN)
@@ -774,6 +776,7 @@
774776

775777
'PR_USER_ID' => $pr_data['user_id'],
776778
'U_RESET_AUTOLOGIN' => LOGIN_URL . "?logout=1&amp;reset_autologin=1&amp;sid={$userdata['session_id']}",
779+
'ULOGIN_REDIRECT_URL' => urlencode('//'.$_SERVER['HTTP_HOST'].'/profile.php?mode=register'),
777780
));
778781

779782
print_page('usercp_register.tpl');

styles/templates/default/usercp_register.tpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ document.write('<input type="hidden" name="user_timezone" value="'+tz+'" />');
6060
<tr>
6161
<td class="row2 small tCenter" colspan="2">{L_ITEMS_REQUIRED}</td>
6262
</tr>
63+
<!-- IF $bb_cfg['ulogin']['enabled'] -->
64+
<tr>
65+
<td class="row2 small tCenter" colspan="2">
66+
<script src="//ulogin.ru/js/ulogin.js"></script>
67+
<div id="uLogin"
68+
data-ulogin="display=small;fields={$bb_cfg['ulogin']['fields']};providers={$bb_cfg['ulogin']['providers']};hidden={$bb_cfg['ulogin']['hidden']};redirect_uri={ULOGIN_REDIRECT_URL}"></div>
69+
</td>
70+
</tr>
71+
<!-- ENDIF -->
6372
<tr>
6473
<td class="prof-title">{L_USERNAME}: *</td>
6574
<td><!-- IF CAN_EDIT_USERNAME --><input id="username" onBlur="ajax.exec({ action: 'user_register', mode: 'check_name', username: $('#username').val()}); return false;" type="text" name="username" size="35" maxlength="25" value="{USERNAME}" /><!-- ELSE --><b>{USERNAME}</b><!-- ENDIF -->

0 commit comments

Comments
 (0)