@@ -5,15 +5,15 @@ |
||
5 | 5 | <h3>Вход</h3> |
6 | 6 | <div class="form-group"> |
7 | 7 | <?php |
8 | - $socials = Users\Social::getList(['where' => ['active', 1]]); |
|
9 | - if ($socials) { |
|
8 | + $socials = Users\Social::getList(['where' => ['active', 1]]); |
|
9 | + if ($socials) { |
|
10 | 10 | echo 'Войти через: '; |
11 | 11 | foreach (Users\Social::getList(['where' => ['active', 1]]) as $social) { |
12 | - $text = $social->image ? '<img src ="' . Statics::file($social->image->path) . '">' : $social->name(); |
|
13 | - echo "<a href = '/users/social/auth/{$social->code}'>{$text}</a> "; |
|
12 | + $text = $social->image ? '<img src ="' . Statics::file($social->image->path) . '">' : $social->name(); |
|
13 | + echo "<a href = '/users/social/auth/{$social->code}'>{$text}</a> "; |
|
14 | 14 | } |
15 | - } |
|
16 | - ?> |
|
15 | + } |
|
16 | + ?> |
|
17 | 17 | </div> |
18 | 18 | <form action = '' method = 'POST' > |
19 | 19 | <div class ='row'> |
@@ -9,7 +9,7 @@ |
||
9 | 9 | if ($socials) { |
10 | 10 | echo 'Войти через: '; |
11 | 11 | foreach (Users\Social::getList(['where' => ['active', 1]]) as $social) { |
12 | - $text = $social->image ? '<img src ="' . Statics::file($social->image->path) . '">' : $social->name(); |
|
12 | + $text = $social->image ? '<img src ="'.Statics::file($social->image->path).'">' : $social->name(); |
|
13 | 13 | echo "<a href = '/users/social/auth/{$social->code}'>{$text}</a> "; |
14 | 14 | } |
15 | 15 | } |
@@ -10,96 +10,96 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class UsersController extends Controller { |
12 | 12 | |
13 | - public function indexAction() { |
|
13 | + public function indexAction() { |
|
14 | 14 | Tools::redirect('/users/cabinet/profile'); |
15 | - } |
|
15 | + } |
|
16 | 16 | |
17 | - public function cabinetAction($activeSection = '') { |
|
17 | + public function cabinetAction($activeSection = '') { |
|
18 | 18 | $bread = []; |
19 | 19 | |
20 | 20 | $sections = $this->module->getSnippets('cabinetSection'); |
21 | 21 | if (!empty($sections[$activeSection]['name'])) { |
22 | - $this->view->setTitle($sections[$activeSection]['name'] . ' - Личный кабинет'); |
|
23 | - $bread[] = ['text' => 'Личный кабинет', 'href' => '/users/cabinet']; |
|
24 | - $bread[] = ['text' => $sections[$activeSection]['name']]; |
|
22 | + $this->view->setTitle($sections[$activeSection]['name'] . ' - Личный кабинет'); |
|
23 | + $bread[] = ['text' => 'Личный кабинет', 'href' => '/users/cabinet']; |
|
24 | + $bread[] = ['text' => $sections[$activeSection]['name']]; |
|
25 | 25 | } else { |
26 | - $this->view->setTitle('Личный кабинет'); |
|
27 | - $bread[] = ['text' => 'Личный кабинет']; |
|
26 | + $this->view->setTitle('Личный кабинет'); |
|
27 | + $bread[] = ['text' => 'Личный кабинет']; |
|
28 | 28 | } |
29 | 29 | $this->view->page(['data' => compact('widgets', 'sections', 'activeSection', 'bread')]); |
30 | - } |
|
30 | + } |
|
31 | 31 | |
32 | - public function loginAction() { |
|
32 | + public function loginAction() { |
|
33 | 33 | $this->view->setTitle('Авторизация'); |
34 | 34 | $bread = []; |
35 | 35 | $bread[] = ['text' => 'Авторизация']; |
36 | 36 | $this->view->page(['data' => compact('bread')]); |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - public function passreAction() { |
|
39 | + public function passreAction() { |
|
40 | 40 | $this->view->setTitle('Восстановление пароля'); |
41 | 41 | $bread = []; |
42 | 42 | $bread[] = ['text' => 'Восстановление пароля']; |
43 | 43 | $this->view->page(['data' => compact('bread')]); |
44 | - } |
|
44 | + } |
|
45 | 45 | |
46 | - public function registrationAction() { |
|
46 | + public function registrationAction() { |
|
47 | 47 | $this->view->setTitle('Регистрация'); |
48 | 48 | if (Users\User::$cur->user_id) { |
49 | - Tools::redirect('/', 'Вы уже зарегистрированы'); |
|
49 | + Tools::redirect('/', 'Вы уже зарегистрированы'); |
|
50 | 50 | } |
51 | 51 | if (!empty($_POST)) { |
52 | - $error = false; |
|
53 | - if ($this->Recaptcha) { |
|
52 | + $error = false; |
|
53 | + if ($this->Recaptcha) { |
|
54 | 54 | $response = $this->Recaptcha->check($_POST['g-recaptcha-response']); |
55 | 55 | if ($response) { |
56 | - if (!$response->success) { |
|
56 | + if (!$response->success) { |
|
57 | 57 | Msg::add('Вы не прошли проверку на робота', 'danger'); |
58 | 58 | $error = true; |
59 | - } |
|
59 | + } |
|
60 | 60 | } else { |
61 | - Msg::add('Произошла ошибка, попробуйте ещё раз'); |
|
62 | - $error = true; |
|
61 | + Msg::add('Произошла ошибка, попробуйте ещё раз'); |
|
62 | + $error = true; |
|
63 | + } |
|
63 | 64 | } |
64 | - } |
|
65 | - if (!$error) { |
|
65 | + if (!$error) { |
|
66 | 66 | if ($this->Users->registration($_POST)) { |
67 | - Tools::redirect('/'); |
|
67 | + Tools::redirect('/'); |
|
68 | + } |
|
68 | 69 | } |
69 | - } |
|
70 | 70 | } |
71 | 71 | $this->view->setTitle('Регистрация'); |
72 | 72 | $bread = []; |
73 | 73 | $bread[] = ['text' => 'Регистрация']; |
74 | 74 | $this->view->page(['data' => compact('bread')]); |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | - public function activationAction($userId = 0, $hash = '') { |
|
77 | + public function activationAction($userId = 0, $hash = '') { |
|
78 | 78 | $user = \Users\User::get((int) $userId); |
79 | 79 | if (!$user || !$hash || $user->activation !== (string) $hash) { |
80 | - Tools::redirect('/', 'Во время активации произошли ошибки', 'danger'); |
|
80 | + Tools::redirect('/', 'Во время активации произошли ошибки', 'danger'); |
|
81 | 81 | } |
82 | 82 | $user->activation = ''; |
83 | 83 | $user->save(); |
84 | 84 | Inji::$inst->event('Users-completeActivation', $user); |
85 | 85 | Tools::redirect('/', 'Вы успешно активировали ваш аккаунт', 'success'); |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - public function attachEmailAction() { |
|
88 | + public function attachEmailAction() { |
|
89 | 89 | if (Users\User::$cur->mail) { |
90 | - Tools::redirect('/', 'К вашему аккаунту уже привязан E-Mail'); |
|
90 | + Tools::redirect('/', 'К вашему аккаунту уже привязан E-Mail'); |
|
91 | 91 | } |
92 | 92 | if (!empty($_POST['mail'])) { |
93 | - $user_mail = trim($_POST['mail']); |
|
94 | - if (!filter_var($user_mail, FILTER_VALIDATE_EMAIL)) { |
|
93 | + $user_mail = trim($_POST['mail']); |
|
94 | + if (!filter_var($user_mail, FILTER_VALIDATE_EMAIL)) { |
|
95 | 95 | Msg::add('Вы ввели не корректный E-mail', 'danger'); |
96 | - } else { |
|
96 | + } else { |
|
97 | 97 | $user = Users\User::get($user_mail, 'mail'); |
98 | 98 | if ($user && $user->id != Users\User::$cur->id) { |
99 | - Msg::add('Данный E-mail уже привязан к другому аккаунту', 'danger'); |
|
99 | + Msg::add('Данный E-mail уже привязан к другому аккаунту', 'danger'); |
|
100 | 100 | } else { |
101 | - Users\User::$cur->mail = $user_mail; |
|
102 | - if (!empty($this->module->config['needActivation'])) { |
|
101 | + Users\User::$cur->mail = $user_mail; |
|
102 | + if (!empty($this->module->config['needActivation'])) { |
|
103 | 103 | Users\User::$cur->activation = Tools::randomString(); |
104 | 104 | $from = 'noreply@' . INJI_DOMAIN_NAME; |
105 | 105 | $to = $user_mail; |
@@ -107,24 +107,24 @@ discard block |
||
107 | 107 | $text = 'Для активации вашего аккаунта перейдите по ссылке <a href = "http://' . INJI_DOMAIN_NAME . '/users/activation/' . Users\User::$cur->id . '/' . Users\User::$cur->activation . '">http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/users/activation/' . Users\User::$cur->id . '/' . Users\User::$cur->activation . '</a>'; |
108 | 108 | Tools::sendMail($from, $to, $subject, $text); |
109 | 109 | Msg::add('На указанный почтовый ящик была выслана ваша ссылка для подтверждения E-Mail', 'success'); |
110 | - } else { |
|
110 | + } else { |
|
111 | 111 | Msg::add('Вы успешно привязали E-Mail к своему аккаунту', 'success'); |
112 | - } |
|
113 | - Users\User::$cur->save(); |
|
114 | - Tools::redirect('/'); |
|
112 | + } |
|
113 | + Users\User::$cur->save(); |
|
114 | + Tools::redirect('/'); |
|
115 | + } |
|
115 | 116 | } |
116 | - } |
|
117 | 117 | } |
118 | 118 | $this->view->page(); |
119 | - } |
|
119 | + } |
|
120 | 120 | |
121 | - public function resendActivationAction($userId = 0) { |
|
121 | + public function resendActivationAction($userId = 0) { |
|
122 | 122 | $user = \Users\User::get((int) $userId); |
123 | 123 | if (!$user) { |
124 | - Tools::redirect('/', 'Не указан пользователь', 'danger'); |
|
124 | + Tools::redirect('/', 'Не указан пользователь', 'danger'); |
|
125 | 125 | } |
126 | 126 | if (!$user->activation) { |
127 | - Tools::redirect('/', 'Пользователь уже активирован'); |
|
127 | + Tools::redirect('/', 'Пользователь уже активирован'); |
|
128 | 128 | } |
129 | 129 | $from = 'noreply@' . INJI_DOMAIN_NAME; |
130 | 130 | $to = $user->mail; |
@@ -132,21 +132,21 @@ discard block |
||
132 | 132 | $text = 'Для активации вашего аккаунта перейдите по ссылке <a href = "http://' . INJI_DOMAIN_NAME . '/users/activation/' . $user->id . '/' . $user->activation . '">http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/users/activation/' . $user->id . '/' . $user->activation . '</a>'; |
133 | 133 | Tools::sendMail($from, $to, $subject, $text); |
134 | 134 | Tools::redirect('/', 'На указанный почтовый ящик была выслана ваша ссылка для подтверждения E-Mail', 'success'); |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | - public function getPartnerInfoAction($userId = 0) { |
|
137 | + public function getPartnerInfoAction($userId = 0) { |
|
138 | 138 | $userId = (int) $userId; |
139 | 139 | $result = new \Server\Result(); |
140 | 140 | if (!$userId) { |
141 | - $result->success = FALSE; |
|
142 | - $result->content = 'Не указан пользователь'; |
|
143 | - $result->send(); |
|
141 | + $result->success = FALSE; |
|
142 | + $result->content = 'Не указан пользователь'; |
|
143 | + $result->send(); |
|
144 | 144 | } |
145 | 145 | $partners = App::$cur->users->getUserPartners(Users\User::$cur, 8); |
146 | 146 | if (empty($partners['users'][$userId])) { |
147 | - $result->success = FALSE; |
|
148 | - $result->content = 'Этот пользователь не находится в вашей структуре'; |
|
149 | - $result->send(); |
|
147 | + $result->success = FALSE; |
|
148 | + $result->content = 'Этот пользователь не находится в вашей структуре'; |
|
149 | + $result->send(); |
|
150 | 150 | } |
151 | 151 | $user = $partners['users'][$userId]; |
152 | 152 | ob_start(); |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | 'event' => 'Событие' |
162 | 162 | ]; |
163 | 163 | foreach ($rewards as $reward) { |
164 | - foreach ($reward->conditions as $condition) { |
|
164 | + foreach ($reward->conditions as $condition) { |
|
165 | 165 | $complete = $condition->checkComplete($userId); |
166 | 166 | ?> |
167 | 167 | <h5 class="<?= $complete ? 'text-success' : 'text-danger'; ?>"><?= $condition->name(); ?></h5> |
168 | 168 | <ul> |
169 | 169 | <?php |
170 | - foreach ($condition->items as $item) { |
|
170 | + foreach ($condition->items as $item) { |
|
171 | 171 | $itemComplete = $item->checkComplete($userId); |
172 | 172 | switch ($item->type) { |
173 | - case 'event': |
|
173 | + case 'event': |
|
174 | 174 | $name = \Events\Event::get($item->value, 'event')->name(); |
175 | 175 | break; |
176 | 176 | } |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | <b class="<?= $itemComplete ? 'text-success' : 'text-danger'; ?>"><?= $name; ?> <?= $item->recivedCount($userId); ?></b>/<?= $item->count; ?> <br /> |
180 | 180 | </li> |
181 | 181 | <?php |
182 | - } |
|
183 | - ?> |
|
182 | + } |
|
183 | + ?> |
|
184 | 184 | </ul> |
185 | 185 | <?php |
186 | - } |
|
186 | + } |
|
187 | 187 | } |
188 | 188 | $result->content = ob_get_contents(); |
189 | 189 | ob_end_clean(); |
190 | 190 | $result->send(); |
191 | - } |
|
191 | + } |
|
192 | 192 | |
193 | 193 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | $sections = $this->module->getSnippets('cabinetSection'); |
21 | 21 | if (!empty($sections[$activeSection]['name'])) { |
22 | - $this->view->setTitle($sections[$activeSection]['name'] . ' - Личный кабинет'); |
|
22 | + $this->view->setTitle($sections[$activeSection]['name'].' - Личный кабинет'); |
|
23 | 23 | $bread[] = ['text' => 'Личный кабинет', 'href' => '/users/cabinet']; |
24 | 24 | $bread[] = ['text' => $sections[$activeSection]['name']]; |
25 | 25 | } else { |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | Users\User::$cur->mail = $user_mail; |
102 | 102 | if (!empty($this->module->config['needActivation'])) { |
103 | 103 | Users\User::$cur->activation = Tools::randomString(); |
104 | - $from = 'noreply@' . INJI_DOMAIN_NAME; |
|
104 | + $from = 'noreply@'.INJI_DOMAIN_NAME; |
|
105 | 105 | $to = $user_mail; |
106 | - $subject = 'Активация аккаунта на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME); |
|
107 | - $text = 'Для активации вашего аккаунта перейдите по ссылке <a href = "http://' . INJI_DOMAIN_NAME . '/users/activation/' . Users\User::$cur->id . '/' . Users\User::$cur->activation . '">http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/users/activation/' . Users\User::$cur->id . '/' . Users\User::$cur->activation . '</a>'; |
|
106 | + $subject = 'Активация аккаунта на сайте '.idn_to_utf8(INJI_DOMAIN_NAME); |
|
107 | + $text = 'Для активации вашего аккаунта перейдите по ссылке <a href = "http://'.INJI_DOMAIN_NAME.'/users/activation/'.Users\User::$cur->id.'/'.Users\User::$cur->activation.'">http://'.idn_to_utf8(INJI_DOMAIN_NAME).'/users/activation/'.Users\User::$cur->id.'/'.Users\User::$cur->activation.'</a>'; |
|
108 | 108 | Tools::sendMail($from, $to, $subject, $text); |
109 | 109 | Msg::add('На указанный почтовый ящик была выслана ваша ссылка для подтверждения E-Mail', 'success'); |
110 | 110 | } else { |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | if (!$user->activation) { |
127 | 127 | Tools::redirect('/', 'Пользователь уже активирован'); |
128 | 128 | } |
129 | - $from = 'noreply@' . INJI_DOMAIN_NAME; |
|
129 | + $from = 'noreply@'.INJI_DOMAIN_NAME; |
|
130 | 130 | $to = $user->mail; |
131 | - $subject = 'Активация аккаунта на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME); |
|
132 | - $text = 'Для активации вашего аккаунта перейдите по ссылке <a href = "http://' . INJI_DOMAIN_NAME . '/users/activation/' . $user->id . '/' . $user->activation . '">http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/users/activation/' . $user->id . '/' . $user->activation . '</a>'; |
|
131 | + $subject = 'Активация аккаунта на сайте '.idn_to_utf8(INJI_DOMAIN_NAME); |
|
132 | + $text = 'Для активации вашего аккаунта перейдите по ссылке <a href = "http://'.INJI_DOMAIN_NAME.'/users/activation/'.$user->id.'/'.$user->activation.'">http://'.idn_to_utf8(INJI_DOMAIN_NAME).'/users/activation/'.$user->id.'/'.$user->activation.'</a>'; |
|
133 | 133 | Tools::sendMail($from, $to, $subject, $text); |
134 | 134 | Tools::redirect('/', 'На указанный почтовый ящик была выслана ваша ссылка для подтверждения E-Mail', 'success'); |
135 | 135 | } |
@@ -13,20 +13,20 @@ discard block |
||
13 | 13 | |
14 | 14 | class Vk extends \Users\SocialHelper { |
15 | 15 | |
16 | - public static function auth() { |
|
16 | + public static function auth() { |
|
17 | 17 | $config = static::getConfig(); |
18 | 18 | if (empty($_GET['code']) && empty($_GET['error'])) { |
19 | - $query = [ |
|
20 | - 'client_id' => $config['appId'], |
|
21 | - 'scope' => 'email', |
|
22 | - 'response_type' => 'code', |
|
23 | - 'display' => 'page', |
|
24 | - 'redirect_uri' => 'http://' . INJI_DOMAIN_NAME . '/users/social/auth/vk' |
|
25 | - ]; |
|
26 | - \Tools::redirect("https://oauth.vk.com/authorize?" . http_build_query($query)); |
|
19 | + $query = [ |
|
20 | + 'client_id' => $config['appId'], |
|
21 | + 'scope' => 'email', |
|
22 | + 'response_type' => 'code', |
|
23 | + 'display' => 'page', |
|
24 | + 'redirect_uri' => 'http://' . INJI_DOMAIN_NAME . '/users/social/auth/vk' |
|
25 | + ]; |
|
26 | + \Tools::redirect("https://oauth.vk.com/authorize?" . http_build_query($query)); |
|
27 | 27 | } |
28 | 28 | if (empty($_GET['code']) && !empty($_GET['error'])) { |
29 | - \Tools::redirect('/', 'Произошла ошибка во время авторизации через соц. сеть: ' . $_GET['error_description']); |
|
29 | + \Tools::redirect('/', 'Произошла ошибка во время авторизации через соц. сеть: ' . $_GET['error_description']); |
|
30 | 30 | } |
31 | 31 | $query = [ |
32 | 32 | 'client_id' => $config['appId'], |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | ]; |
37 | 37 | $result = @file_get_contents("https://oauth.vk.com/access_token?" . http_build_query($query)); |
38 | 38 | if ($result === false) { |
39 | - \Tools::redirect('/', 'Во время авторизации произошли ошибки', 'danger'); |
|
39 | + \Tools::redirect('/', 'Во время авторизации произошли ошибки', 'danger'); |
|
40 | 40 | } |
41 | 41 | $result = json_decode($result, true); |
42 | 42 | if (empty($result['user_id'])) { |
43 | - \Tools::redirect('/', 'Во время авторизации произошли ошибки', 'danger'); |
|
43 | + \Tools::redirect('/', 'Во время авторизации произошли ошибки', 'danger'); |
|
44 | 44 | } |
45 | 45 | $userQuery = [ |
46 | 46 | 'user_id' => $result['user_id'], |
@@ -49,94 +49,94 @@ discard block |
||
49 | 49 | ]; |
50 | 50 | $userResult = @file_get_contents("https://api.vk.com/method/users.get?" . http_build_query($userQuery)); |
51 | 51 | if (!$userResult) { |
52 | - \Tools::redirect('/', 'Во время авторизации произошли ошибки', 'danger'); |
|
52 | + \Tools::redirect('/', 'Во время авторизации произошли ошибки', 'danger'); |
|
53 | 53 | } |
54 | 54 | $userDetail = json_decode($userResult, true); |
55 | 55 | if (empty($userDetail['response'][0])) { |
56 | - \Tools::redirect('/', 'Во время авторизации произошли ошибки', 'danger'); |
|
56 | + \Tools::redirect('/', 'Во время авторизации произошли ошибки', 'danger'); |
|
57 | 57 | } |
58 | 58 | $social = static::getObject(); |
59 | 59 | $userSocial = \Users\User\Social::get([['uid', $result['user_id']], ['social_id', $social->id]]); |
60 | 60 | if ($userSocial && $userSocial->user) { |
61 | - \App::$cur->users->newSession($userSocial->user); |
|
62 | - if (!empty(\App::$cur->users->config['loginUrl'][\App::$cur->type])) { |
|
61 | + \App::$cur->users->newSession($userSocial->user); |
|
62 | + if (!empty(\App::$cur->users->config['loginUrl'][\App::$cur->type])) { |
|
63 | 63 | \Tools::redirect(\App::$cur->users->config['loginUrl'][\App::$cur->type]); |
64 | - } |
|
64 | + } |
|
65 | 65 | } else { |
66 | - if ($userSocial && !$userSocial->user) { |
|
66 | + if ($userSocial && !$userSocial->user) { |
|
67 | 67 | $userSocial->delete(); |
68 | - } |
|
69 | - if (!\Users\User::$cur->id) { |
|
68 | + } |
|
69 | + if (!\Users\User::$cur->id) { |
|
70 | 70 | $user = false; |
71 | 71 | if (!empty($result['email'])) { |
72 | - $user = \Users\User::get($result['email'], 'mail'); |
|
72 | + $user = \Users\User::get($result['email'], 'mail'); |
|
73 | 73 | } |
74 | 74 | if (!$user) { |
75 | - $user = new \Users\User(); |
|
76 | - $user->group_id = 2; |
|
77 | - $user->role_id = 2; |
|
78 | - if (!empty($result['email'])) { |
|
75 | + $user = new \Users\User(); |
|
76 | + $user->group_id = 2; |
|
77 | + $user->role_id = 2; |
|
78 | + if (!empty($result['email'])) { |
|
79 | 79 | $user->login = $user->mail = $result['email']; |
80 | - } |
|
81 | - $invite_code = (!empty($_POST['invite_code']) ? $_POST['invite_code'] : ((!empty($_COOKIE['invite_code']) ? $_COOKIE['invite_code'] : ((!empty($_GET['invite_code']) ? $_GET['invite_code'] : ''))))); |
|
82 | - if (!empty($invite_code)) { |
|
80 | + } |
|
81 | + $invite_code = (!empty($_POST['invite_code']) ? $_POST['invite_code'] : ((!empty($_COOKIE['invite_code']) ? $_COOKIE['invite_code'] : ((!empty($_GET['invite_code']) ? $_GET['invite_code'] : ''))))); |
|
82 | + if (!empty($invite_code)) { |
|
83 | 83 | $invite = \Users\User\Invite::get($invite_code, 'code'); |
84 | 84 | $inveiteError = false; |
85 | 85 | if (!$invite) { |
86 | - Msg::add('Такой код пришлашения не найден', 'danger'); |
|
87 | - $inveiteError = true; |
|
86 | + Msg::add('Такой код пришлашения не найден', 'danger'); |
|
87 | + $inveiteError = true; |
|
88 | 88 | } |
89 | 89 | if ($invite->limit && !($invite->limit - $invite->count)) { |
90 | - Msg::add('Лимит приглашений для данного кода исчерпан', 'danger'); |
|
91 | - $inveiteError = true; |
|
90 | + Msg::add('Лимит приглашений для данного кода исчерпан', 'danger'); |
|
91 | + $inveiteError = true; |
|
92 | 92 | } |
93 | 93 | if (!$inveiteError) { |
94 | - $user->parent_id = $invite->user_id; |
|
95 | - $invite->count++; |
|
96 | - $invite->save(); |
|
94 | + $user->parent_id = $invite->user_id; |
|
95 | + $invite->count++; |
|
96 | + $invite->save(); |
|
97 | + } |
|
97 | 98 | } |
98 | - } |
|
99 | - if (!$user->parent_id && !empty(\App::$cur->Users->config['defaultPartner'])) { |
|
99 | + if (!$user->parent_id && !empty(\App::$cur->Users->config['defaultPartner'])) { |
|
100 | 100 | $user->parent_id = \App::$cur->Users->config['defaultPartner']; |
101 | - } |
|
102 | - $user->save(); |
|
103 | - $userInfo = new \Users\User\Info(); |
|
104 | - $userInfo->user_id = $user->id; |
|
105 | - $userInfo->save(); |
|
101 | + } |
|
102 | + $user->save(); |
|
103 | + $userInfo = new \Users\User\Info(); |
|
104 | + $userInfo->user_id = $user->id; |
|
105 | + $userInfo->save(); |
|
106 | 106 | } |
107 | - } else { |
|
107 | + } else { |
|
108 | 108 | $user = \Users\User::$cur; |
109 | - } |
|
110 | - if (!$user->info->photo_file_id && !empty($userDetail['response'][0]['photo_max_orig'])) { |
|
109 | + } |
|
110 | + if (!$user->info->photo_file_id && !empty($userDetail['response'][0]['photo_max_orig'])) { |
|
111 | 111 | $user->info->photo_file_id = \App::$cur->files->uploadFromUrl($userDetail['response'][0]['photo_max_orig']); |
112 | - } |
|
113 | - if (!$user->info->first_name && !empty($userDetail['response'][0]['first_name'])) { |
|
112 | + } |
|
113 | + if (!$user->info->first_name && !empty($userDetail['response'][0]['first_name'])) { |
|
114 | 114 | $user->info->first_name = $userDetail['response'][0]['first_name']; |
115 | - } |
|
116 | - if (!$user->info->last_name && !empty($userDetail['response'][0]['last_name'])) { |
|
115 | + } |
|
116 | + if (!$user->info->last_name && !empty($userDetail['response'][0]['last_name'])) { |
|
117 | 117 | $user->info->last_name = $userDetail['response'][0]['last_name']; |
118 | - } |
|
119 | - if (!$user->info->city && !empty($userDetail['response'][0]['home_town'])) { |
|
118 | + } |
|
119 | + if (!$user->info->city && !empty($userDetail['response'][0]['home_town'])) { |
|
120 | 120 | $user->info->city = $userDetail['response'][0]['home_town']; |
121 | - } |
|
122 | - if (!$user->info->sex && !empty($userDetail['response'][0]['sex'])) { |
|
121 | + } |
|
122 | + if (!$user->info->sex && !empty($userDetail['response'][0]['sex'])) { |
|
123 | 123 | $user->info->sex = $userDetail['response'][0]['sex'] == 2 ? 1 : ($userDetail['response'][0]['sex'] == 1 ? 2 : 0); |
124 | - } |
|
125 | - if ($user->info->bday == '0000-00-00' && !empty($userDetail['response'][0]['bdate'])) { |
|
124 | + } |
|
125 | + if ($user->info->bday == '0000-00-00' && !empty($userDetail['response'][0]['bdate'])) { |
|
126 | 126 | $user->info->bday = substr_count($userDetail['response'][0]['bdate'], '.') == 2 ? \DateTime::createFromFormat('d.m.Y', $userDetail['response'][0]['bdate'])->format('Y-m-d') : (substr_count($userDetail['response'][0]['bdate'], '.') == 1 ? \DateTime::createFromFormat('d.m', $userDetail['response'][0]['bdate'])->format('Y-m-1') : '0000-00-00'); |
127 | - } |
|
128 | - $user->info->save(); |
|
129 | - $userSocial = new \Users\User\Social(); |
|
130 | - $userSocial->uid = $result['user_id']; |
|
131 | - $userSocial->social_id = $social->id; |
|
132 | - $userSocial->user_id = $user->id; |
|
133 | - $userSocial->save(); |
|
134 | - \App::$cur->users->newSession($user); |
|
135 | - \Tools::redirect(\App::$cur->users->config['loginUrl'][\App::$cur->type], 'Вы успешно зарегистрировались через ВКонтакте', 'success'); |
|
127 | + } |
|
128 | + $user->info->save(); |
|
129 | + $userSocial = new \Users\User\Social(); |
|
130 | + $userSocial->uid = $result['user_id']; |
|
131 | + $userSocial->social_id = $social->id; |
|
132 | + $userSocial->user_id = $user->id; |
|
133 | + $userSocial->save(); |
|
134 | + \App::$cur->users->newSession($user); |
|
135 | + \Tools::redirect(\App::$cur->users->config['loginUrl'][\App::$cur->type], 'Вы успешно зарегистрировались через ВКонтакте', 'success'); |
|
136 | + } |
|
136 | 137 | } |
137 | - } |
|
138 | 138 | |
139 | - public static function checkAppAccess() { |
|
139 | + public static function checkAppAccess() { |
|
140 | 140 | $viewer_id = filter_input(INPUT_GET, 'viewer_id', FILTER_SANITIZE_NUMBER_INT); |
141 | 141 | $get_auth_key = filter_input(INPUT_GET, 'auth_key', FILTER_SANITIZE_STRING); |
142 | 142 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $auth_key = md5($config['appId'] . '_' . $viewer_id . '_' . $config['secret']); |
146 | 146 | |
147 | 147 | if ($auth_key !== $get_auth_key) { |
148 | - return FALSE; |
|
148 | + return FALSE; |
|
149 | 149 | } |
150 | 150 | $userQuery = [ |
151 | 151 | 'user_id' => $viewer_id, |
@@ -157,25 +157,25 @@ discard block |
||
157 | 157 | |
158 | 158 | $socUser = \Users\User\Social::get([['social_id', $object->pk()], ['uid', $viewer_id]]); |
159 | 159 | if (!$socUser) { |
160 | - $user = new \Users\User(); |
|
161 | - $user->login = $userResult['response'][0]['domain']; |
|
162 | - $user->save(); |
|
163 | - $info = new \Users\User\Info(); |
|
164 | - $info->user_id = $user->id; |
|
165 | - $info->sex = $userResult['response'][0]['sex'] == 2 ? 1 : ($userResult['response'][0]['sex'] == 1 ? 2 : 0); |
|
166 | - $info->first_name = $userResult['response'][0]['first_name']; |
|
167 | - $info->last_name = $userResult['response'][0]['last_name']; |
|
168 | - $info->photo_file_id = \App::$cur->files->uploadFromUrl($userResult['response'][0]['photo_200_orig'], ['accept_group' => 'image']); |
|
169 | - $info->save(); |
|
170 | - $social = new \Users\User\Social(); |
|
171 | - $social->user_id = $user->id; |
|
172 | - $social->social_id = 1; |
|
173 | - $social->uid = $userResult['response'][0]['uid']; |
|
174 | - $social->save(); |
|
160 | + $user = new \Users\User(); |
|
161 | + $user->login = $userResult['response'][0]['domain']; |
|
162 | + $user->save(); |
|
163 | + $info = new \Users\User\Info(); |
|
164 | + $info->user_id = $user->id; |
|
165 | + $info->sex = $userResult['response'][0]['sex'] == 2 ? 1 : ($userResult['response'][0]['sex'] == 1 ? 2 : 0); |
|
166 | + $info->first_name = $userResult['response'][0]['first_name']; |
|
167 | + $info->last_name = $userResult['response'][0]['last_name']; |
|
168 | + $info->photo_file_id = \App::$cur->files->uploadFromUrl($userResult['response'][0]['photo_200_orig'], ['accept_group' => 'image']); |
|
169 | + $info->save(); |
|
170 | + $social = new \Users\User\Social(); |
|
171 | + $social->user_id = $user->id; |
|
172 | + $social->social_id = 1; |
|
173 | + $social->uid = $userResult['response'][0]['uid']; |
|
174 | + $social->save(); |
|
175 | 175 | } else { |
176 | - $user = $socUser->user; |
|
176 | + $user = $socUser->user; |
|
177 | 177 | } |
178 | 178 | return $user; |
179 | - } |
|
179 | + } |
|
180 | 180 | |
181 | 181 | } |
@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | 'scope' => 'email', |
22 | 22 | 'response_type' => 'code', |
23 | 23 | 'display' => 'page', |
24 | - 'redirect_uri' => 'http://' . INJI_DOMAIN_NAME . '/users/social/auth/vk' |
|
24 | + 'redirect_uri' => 'http://'.INJI_DOMAIN_NAME.'/users/social/auth/vk' |
|
25 | 25 | ]; |
26 | - \Tools::redirect("https://oauth.vk.com/authorize?" . http_build_query($query)); |
|
26 | + \Tools::redirect("https://oauth.vk.com/authorize?".http_build_query($query)); |
|
27 | 27 | } |
28 | 28 | if (empty($_GET['code']) && !empty($_GET['error'])) { |
29 | - \Tools::redirect('/', 'Произошла ошибка во время авторизации через соц. сеть: ' . $_GET['error_description']); |
|
29 | + \Tools::redirect('/', 'Произошла ошибка во время авторизации через соц. сеть: '.$_GET['error_description']); |
|
30 | 30 | } |
31 | 31 | $query = [ |
32 | 32 | 'client_id' => $config['appId'], |
33 | 33 | 'client_secret' => $config['secret'], |
34 | 34 | 'code' => $_GET['code'], |
35 | - 'redirect_uri' => 'http://' . INJI_DOMAIN_NAME . '/users/social/auth/vk' |
|
35 | + 'redirect_uri' => 'http://'.INJI_DOMAIN_NAME.'/users/social/auth/vk' |
|
36 | 36 | ]; |
37 | - $result = @file_get_contents("https://oauth.vk.com/access_token?" . http_build_query($query)); |
|
37 | + $result = @file_get_contents("https://oauth.vk.com/access_token?".http_build_query($query)); |
|
38 | 38 | if ($result === false) { |
39 | 39 | \Tools::redirect('/', 'Во время авторизации произошли ошибки', 'danger'); |
40 | 40 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'fields' => 'sex, bdate, photo_max_orig, home_town', |
48 | 48 | 'access_token' => $result['access_token'] |
49 | 49 | ]; |
50 | - $userResult = @file_get_contents("https://api.vk.com/method/users.get?" . http_build_query($userQuery)); |
|
50 | + $userResult = @file_get_contents("https://api.vk.com/method/users.get?".http_build_query($userQuery)); |
|
51 | 51 | if (!$userResult) { |
52 | 52 | \Tools::redirect('/', 'Во время авторизации произошли ошибки', 'danger'); |
53 | 53 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | $config = static::getConfig(); |
144 | 144 | |
145 | - $auth_key = md5($config['appId'] . '_' . $viewer_id . '_' . $config['secret']); |
|
145 | + $auth_key = md5($config['appId'].'_'.$viewer_id.'_'.$config['secret']); |
|
146 | 146 | |
147 | 147 | if ($auth_key !== $get_auth_key) { |
148 | 148 | return FALSE; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | 'fields' => 'photo_medium,nickname, domain, sex, bdate, city, country, timezone, photo_50, photo_100, photo_200_orig, has_mobile, contacts, education, online, relation, last_seen, status, can_write_private_message, can_see_all_posts, can_post, universities', |
153 | 153 | 'access_token' => filter_input(INPUT_GET, 'access_token', FILTER_SANITIZE_STRING) |
154 | 154 | ]; |
155 | - $userResult = json_decode(@file_get_contents("https://api.vk.com/method/users.get?" . http_build_query($userQuery)), true); |
|
155 | + $userResult = json_decode(@file_get_contents("https://api.vk.com/method/users.get?".http_build_query($userQuery)), true); |
|
156 | 156 | $object = static::getObject(); |
157 | 157 | |
158 | 158 | $socUser = \Users\User\Social::get([['social_id', $object->pk()], ['uid', $viewer_id]]); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | class Twitter extends \Users\SocialHelper { |
15 | 15 | |
16 | - private static function requestToken() { |
|
16 | + private static function requestToken() { |
|
17 | 17 | $config = static::getConfig(); |
18 | 18 | $oauthNonce = md5(uniqid(rand(), true)); |
19 | 19 | $oauthTimestamp = time(); |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | $response = file_get_contents($url); |
40 | 40 | parse_str($response, $result); |
41 | 41 | return $result; |
42 | - } |
|
42 | + } |
|
43 | 43 | |
44 | - private static function verify() { |
|
44 | + private static function verify() { |
|
45 | 45 | $config = static::getConfig(); |
46 | 46 | $oauthNonce = md5(uniqid(rand(), true)); |
47 | 47 | $oauthTimestamp = time(); |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | $response = file_get_contents($url); |
77 | 77 | parse_str($response, $result); |
78 | 78 | return $result; |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - private static function getInfo($result) { |
|
81 | + private static function getInfo($result) { |
|
82 | 82 | $config = static::getConfig(); |
83 | 83 | $oauth_nonce = md5(uniqid(rand(), true)); |
84 | 84 | $oauth_timestamp = time(); |
@@ -114,82 +114,82 @@ discard block |
||
114 | 114 | $response = file_get_contents($url); |
115 | 115 | |
116 | 116 | return json_decode($response, true); |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | - public static function auth() { |
|
119 | + public static function auth() { |
|
120 | 120 | $config = static::getConfig(); |
121 | 121 | if (empty($_GET['oauth_verifier']) || empty($_SESSION['oauth_token_secret'])) { |
122 | - $tokens = self::requestToken(); |
|
123 | - $_SESSION['oauth_token_secret'] = $tokens['oauth_token_secret']; |
|
124 | - \Tools::redirect("https://api.twitter.com/oauth/authorize?oauth_token={$tokens['oauth_token']}"); |
|
122 | + $tokens = self::requestToken(); |
|
123 | + $_SESSION['oauth_token_secret'] = $tokens['oauth_token_secret']; |
|
124 | + \Tools::redirect("https://api.twitter.com/oauth/authorize?oauth_token={$tokens['oauth_token']}"); |
|
125 | 125 | } |
126 | 126 | $verify = static::verify(); |
127 | 127 | |
128 | 128 | if (!$verify['user_id']) { |
129 | - \Tools::redirect('/', 'Не удалось авторизоваться через twitter'); |
|
129 | + \Tools::redirect('/', 'Не удалось авторизоваться через twitter'); |
|
130 | 130 | } |
131 | 131 | $userDetail = static::getInfo($verify); |
132 | 132 | |
133 | 133 | $social = static::getObject(); |
134 | 134 | $userSocial = \Users\User\Social::get([['uid', $userDetail['id']], ['social_id', $social->id]]); |
135 | 135 | if ($userSocial && $userSocial->user) { |
136 | - \App::$cur->users->newSession($userSocial->user); |
|
137 | - if (!empty(\App::$cur->users->config['loginUrl'][\App::$cur->type])) { |
|
136 | + \App::$cur->users->newSession($userSocial->user); |
|
137 | + if (!empty(\App::$cur->users->config['loginUrl'][\App::$cur->type])) { |
|
138 | 138 | \Tools::redirect(\App::$cur->users->config['loginUrl'][\App::$cur->type]); |
139 | - } |
|
139 | + } |
|
140 | 140 | } else { |
141 | - if ($userSocial && !$userSocial->user) { |
|
141 | + if ($userSocial && !$userSocial->user) { |
|
142 | 142 | $userSocial->delete(); |
143 | - } |
|
144 | - if (!\Users\User::$cur->id) { |
|
143 | + } |
|
144 | + if (!\Users\User::$cur->id) { |
|
145 | 145 | $user = new \Users\User(); |
146 | 146 | $user->group_id = 2; |
147 | 147 | $user->role_id = 2; |
148 | 148 | $invite_code = (!empty($_POST['invite_code']) ? $_POST['invite_code'] : ((!empty($_COOKIE['invite_code']) ? $_COOKIE['invite_code'] : ((!empty($_GET['invite_code']) ? $_GET['invite_code'] : ''))))); |
149 | 149 | if (!empty($invite_code)) { |
150 | - $invite = \Users\User\Invite::get($invite_code, 'code'); |
|
151 | - $inveiteError = false; |
|
152 | - if (!$invite) { |
|
150 | + $invite = \Users\User\Invite::get($invite_code, 'code'); |
|
151 | + $inveiteError = false; |
|
152 | + if (!$invite) { |
|
153 | 153 | Msg::add('Такой код пришлашения не найден', 'danger'); |
154 | 154 | $inveiteError = true; |
155 | - } |
|
156 | - if ($invite->limit && !($invite->limit - $invite->count)) { |
|
155 | + } |
|
156 | + if ($invite->limit && !($invite->limit - $invite->count)) { |
|
157 | 157 | Msg::add('Лимит приглашений для данного кода исчерпан', 'danger'); |
158 | 158 | $inveiteError = true; |
159 | - } |
|
160 | - if (!$inveiteError) { |
|
159 | + } |
|
160 | + if (!$inveiteError) { |
|
161 | 161 | $user->parent_id = $invite->user_id; |
162 | 162 | $invite->count++; |
163 | 163 | $invite->save(); |
164 | - } |
|
164 | + } |
|
165 | 165 | } |
166 | 166 | if (!$user->parent_id && !empty(\App::$cur->Users->config['defaultPartner'])) { |
167 | - $user->parent_id = \App::$cur->Users->config['defaultPartner']; |
|
167 | + $user->parent_id = \App::$cur->Users->config['defaultPartner']; |
|
168 | 168 | } |
169 | 169 | $user->save(); |
170 | 170 | $userInfo = new \Users\User\Info(); |
171 | 171 | $userInfo->user_id = $user->id; |
172 | 172 | $userInfo->save(); |
173 | - } else { |
|
173 | + } else { |
|
174 | 174 | $user = \Users\User::$cur; |
175 | - } |
|
176 | - $name = explode(' ', $userDetail['name']); |
|
177 | - $user->info->first_name = $name[0]; |
|
178 | - $user->info->last_name = $name[1]; |
|
179 | - $user->info->city = $userDetail['location']; |
|
180 | - $user->info->save(); |
|
181 | - $userSocial = new \Users\User\Social(); |
|
182 | - $userSocial->uid = $userDetail['id']; |
|
183 | - $userSocial->social_id = $social->id; |
|
184 | - $userSocial->user_id = $user->id; |
|
185 | - $userSocial->save(); |
|
186 | - \App::$cur->users->newSession($user); |
|
187 | - if (!empty(\App::$cur->users->config['loginUrl'][\App::$cur->type])) { |
|
175 | + } |
|
176 | + $name = explode(' ', $userDetail['name']); |
|
177 | + $user->info->first_name = $name[0]; |
|
178 | + $user->info->last_name = $name[1]; |
|
179 | + $user->info->city = $userDetail['location']; |
|
180 | + $user->info->save(); |
|
181 | + $userSocial = new \Users\User\Social(); |
|
182 | + $userSocial->uid = $userDetail['id']; |
|
183 | + $userSocial->social_id = $social->id; |
|
184 | + $userSocial->user_id = $user->id; |
|
185 | + $userSocial->save(); |
|
186 | + \App::$cur->users->newSession($user); |
|
187 | + if (!empty(\App::$cur->users->config['loginUrl'][\App::$cur->type])) { |
|
188 | 188 | \Tools::redirect(\App::$cur->users->config['loginUrl'][\App::$cur->type], 'Вы успешно зарегистрировались через Twitter', 'success'); |
189 | - } else { |
|
189 | + } else { |
|
190 | 190 | \Tools::redirect('/users/cabinet/profile', 'Вы успешно зарегистрировались через Twitter', 'success'); |
191 | - } |
|
191 | + } |
|
192 | + } |
|
192 | 193 | } |
193 | - } |
|
194 | 194 | |
195 | 195 | } |
@@ -19,22 +19,22 @@ discard block |
||
19 | 19 | $oauthTimestamp = time(); |
20 | 20 | //string |
21 | 21 | $oauth_base_text = "GET&"; |
22 | - $oauth_base_text .= urlencode('https://api.twitter.com/oauth/request_token') . "&"; |
|
23 | - $oauth_base_text .= urlencode("oauth_callback=" . urlencode('http://' . INJI_DOMAIN_NAME . '/users/social/auth/twitter') . "&"); |
|
24 | - $oauth_base_text .= urlencode("oauth_consumer_key=" . $config['consumer_key'] . "&"); |
|
25 | - $oauth_base_text .= urlencode("oauth_nonce=" . $oauthNonce . "&"); |
|
22 | + $oauth_base_text .= urlencode('https://api.twitter.com/oauth/request_token')."&"; |
|
23 | + $oauth_base_text .= urlencode("oauth_callback=".urlencode('http://'.INJI_DOMAIN_NAME.'/users/social/auth/twitter')."&"); |
|
24 | + $oauth_base_text .= urlencode("oauth_consumer_key=".$config['consumer_key']."&"); |
|
25 | + $oauth_base_text .= urlencode("oauth_nonce=".$oauthNonce."&"); |
|
26 | 26 | $oauth_base_text .= urlencode("oauth_signature_method=HMAC-SHA1&"); |
27 | - $oauth_base_text .= urlencode("oauth_timestamp=" . $oauthTimestamp . "&"); |
|
27 | + $oauth_base_text .= urlencode("oauth_timestamp=".$oauthTimestamp."&"); |
|
28 | 28 | $oauth_base_text .= urlencode("oauth_version=1.0"); |
29 | - $oauthSignature = base64_encode(hash_hmac("sha1", $oauth_base_text, $config['consumer_secret'] . "&", true)); |
|
29 | + $oauthSignature = base64_encode(hash_hmac("sha1", $oauth_base_text, $config['consumer_secret']."&", true)); |
|
30 | 30 | //request |
31 | 31 | $url = 'https://api.twitter.com/oauth/request_token'; |
32 | - $url .= '?oauth_callback=' . urlencode('http://' . INJI_DOMAIN_NAME . '/users/social/auth/twitter'); |
|
33 | - $url .= '&oauth_consumer_key=' . $config['consumer_key']; |
|
34 | - $url .= '&oauth_nonce=' . $oauthNonce; |
|
35 | - $url .= '&oauth_signature=' . urlencode($oauthSignature); |
|
32 | + $url .= '?oauth_callback='.urlencode('http://'.INJI_DOMAIN_NAME.'/users/social/auth/twitter'); |
|
33 | + $url .= '&oauth_consumer_key='.$config['consumer_key']; |
|
34 | + $url .= '&oauth_nonce='.$oauthNonce; |
|
35 | + $url .= '&oauth_signature='.urlencode($oauthSignature); |
|
36 | 36 | $url .= '&oauth_signature_method=HMAC-SHA1'; |
37 | - $url .= '&oauth_timestamp=' . $oauthTimestamp; |
|
37 | + $url .= '&oauth_timestamp='.$oauthTimestamp; |
|
38 | 38 | $url .= '&oauth_version=1.0'; |
39 | 39 | $response = file_get_contents($url); |
40 | 40 | parse_str($response, $result); |
@@ -50,26 +50,26 @@ discard block |
||
50 | 50 | $oauth_token_secret = $_SESSION['oauth_token_secret']; |
51 | 51 | //string |
52 | 52 | $oauth_base_text = "GET&"; |
53 | - $oauth_base_text .= urlencode('https://api.twitter.com/oauth/access_token') . "&"; |
|
54 | - $oauth_base_text .= urlencode("oauth_consumer_key=" . $config['consumer_key'] . "&"); |
|
55 | - $oauth_base_text .= urlencode("oauth_nonce=" . $oauthNonce . "&"); |
|
53 | + $oauth_base_text .= urlencode('https://api.twitter.com/oauth/access_token')."&"; |
|
54 | + $oauth_base_text .= urlencode("oauth_consumer_key=".$config['consumer_key']."&"); |
|
55 | + $oauth_base_text .= urlencode("oauth_nonce=".$oauthNonce."&"); |
|
56 | 56 | $oauth_base_text .= urlencode("oauth_signature_method=HMAC-SHA1&"); |
57 | - $oauth_base_text .= urlencode("oauth_token=" . $oauth_token . "&"); |
|
58 | - $oauth_base_text .= urlencode("oauth_timestamp=" . $oauthTimestamp . "&"); |
|
59 | - $oauth_base_text .= urlencode("oauth_verifier=" . $oauth_verifier . "&"); |
|
57 | + $oauth_base_text .= urlencode("oauth_token=".$oauth_token."&"); |
|
58 | + $oauth_base_text .= urlencode("oauth_timestamp=".$oauthTimestamp."&"); |
|
59 | + $oauth_base_text .= urlencode("oauth_verifier=".$oauth_verifier."&"); |
|
60 | 60 | $oauth_base_text .= urlencode("oauth_version=1.0"); |
61 | 61 | |
62 | - $key = $config['consumer_secret'] . "&" . $oauth_token_secret; |
|
62 | + $key = $config['consumer_secret']."&".$oauth_token_secret; |
|
63 | 63 | //request |
64 | 64 | $oauth_signature = base64_encode(hash_hmac("sha1", $oauth_base_text, $key, true)); |
65 | 65 | $url = 'https://api.twitter.com/oauth/access_token'; |
66 | - $url .= '?oauth_nonce=' . $oauthNonce; |
|
66 | + $url .= '?oauth_nonce='.$oauthNonce; |
|
67 | 67 | $url .= '&oauth_signature_method=HMAC-SHA1'; |
68 | - $url .= '&oauth_timestamp=' . $oauthTimestamp; |
|
69 | - $url .= '&oauth_consumer_key=' . $config['consumer_key']; |
|
70 | - $url .= '&oauth_token=' . urlencode($oauth_token); |
|
71 | - $url .= '&oauth_verifier=' . urlencode($oauth_verifier); |
|
72 | - $url .= '&oauth_signature=' . urlencode($oauth_signature); |
|
68 | + $url .= '&oauth_timestamp='.$oauthTimestamp; |
|
69 | + $url .= '&oauth_consumer_key='.$config['consumer_key']; |
|
70 | + $url .= '&oauth_token='.urlencode($oauth_token); |
|
71 | + $url .= '&oauth_verifier='.urlencode($oauth_verifier); |
|
72 | + $url .= '&oauth_signature='.urlencode($oauth_signature); |
|
73 | 73 | $url .= '&oauth_version=1.0'; |
74 | 74 | |
75 | 75 | |
@@ -88,28 +88,28 @@ discard block |
||
88 | 88 | $screen_name = $result['screen_name']; |
89 | 89 | |
90 | 90 | $oauth_base_text = "GET&"; |
91 | - $oauth_base_text .= urlencode('https://api.twitter.com/1.1/users/show.json') . '&'; |
|
92 | - $oauth_base_text .= urlencode('oauth_consumer_key=' . $config['consumer_key'] . '&'); |
|
93 | - $oauth_base_text .= urlencode('oauth_nonce=' . $oauth_nonce . '&'); |
|
91 | + $oauth_base_text .= urlencode('https://api.twitter.com/1.1/users/show.json').'&'; |
|
92 | + $oauth_base_text .= urlencode('oauth_consumer_key='.$config['consumer_key'].'&'); |
|
93 | + $oauth_base_text .= urlencode('oauth_nonce='.$oauth_nonce.'&'); |
|
94 | 94 | $oauth_base_text .= urlencode('oauth_signature_method=HMAC-SHA1&'); |
95 | - $oauth_base_text .= urlencode('oauth_timestamp=' . $oauth_timestamp . "&"); |
|
96 | - $oauth_base_text .= urlencode('oauth_token=' . $oauth_token . "&"); |
|
95 | + $oauth_base_text .= urlencode('oauth_timestamp='.$oauth_timestamp."&"); |
|
96 | + $oauth_base_text .= urlencode('oauth_token='.$oauth_token."&"); |
|
97 | 97 | $oauth_base_text .= urlencode('oauth_version=1.0&'); |
98 | - $oauth_base_text .= urlencode('screen_name=' . $screen_name); |
|
98 | + $oauth_base_text .= urlencode('screen_name='.$screen_name); |
|
99 | 99 | |
100 | - $key = $config['consumer_secret'] . '&' . $oauth_token_secret; |
|
100 | + $key = $config['consumer_secret'].'&'.$oauth_token_secret; |
|
101 | 101 | $signature = base64_encode(hash_hmac("sha1", $oauth_base_text, $key, true)); |
102 | 102 | |
103 | 103 | |
104 | 104 | $url = 'https://api.twitter.com/1.1/users/show.json'; |
105 | - $url .= '?oauth_consumer_key=' . $config['consumer_key']; |
|
106 | - $url .= '&oauth_nonce=' . $oauth_nonce; |
|
107 | - $url .= '&oauth_signature=' . urlencode($signature); |
|
105 | + $url .= '?oauth_consumer_key='.$config['consumer_key']; |
|
106 | + $url .= '&oauth_nonce='.$oauth_nonce; |
|
107 | + $url .= '&oauth_signature='.urlencode($signature); |
|
108 | 108 | $url .= '&oauth_signature_method=HMAC-SHA1'; |
109 | - $url .= '&oauth_timestamp=' . $oauth_timestamp; |
|
110 | - $url .= '&oauth_token=' . urlencode($oauth_token); |
|
109 | + $url .= '&oauth_timestamp='.$oauth_timestamp; |
|
110 | + $url .= '&oauth_token='.urlencode($oauth_token); |
|
111 | 111 | $url .= '&oauth_version=1.0'; |
112 | - $url .= '&screen_name=' . $screen_name; |
|
112 | + $url .= '&screen_name='.$screen_name; |
|
113 | 113 | |
114 | 114 | $response = file_get_contents($url); |
115 | 115 |
@@ -9,16 +9,16 @@ |
||
9 | 9 | 'value' => !empty($options['value']) ? addcslashes($options['value'], "'") : (!empty($form->userDataTree[$name]) ? addcslashes($form->userDataTree[$name], "'") : '') |
10 | 10 | ]; |
11 | 11 | if (!empty($options['disabled'])) { |
12 | - $attributes['disabled'] = 'disabled'; |
|
12 | + $attributes['disabled'] = 'disabled'; |
|
13 | 13 | } |
14 | 14 | if (!empty($options['placeholder'])) { |
15 | - $attributes['placeholder'] = $options['placeholder']; |
|
15 | + $attributes['placeholder'] = $options['placeholder']; |
|
16 | 16 | } |
17 | 17 | if (!empty($options['checked'])) { |
18 | - $attributes['checked'] = 'checked'; |
|
18 | + $attributes['checked'] = 'checked'; |
|
19 | 19 | } |
20 | 20 | if (!empty($options['attributes'])) { |
21 | - $attributes = array_merge($attributes, $options['attributes']); |
|
21 | + $attributes = array_merge($attributes, $options['attributes']); |
|
22 | 22 | } |
23 | 23 | echo Html::el('input', $attributes, '', null); |
24 | 24 | echo!empty($options['helpText']) ? "<div class='help-block'>{$options['helpText']}</div>" : ''; |