This repository has been archived by the owner on Jul 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbx_reset_admin.php
181 lines (162 loc) · 6.99 KB
/
bx_reset_admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?define("NOT_CHECK_PERMISSIONS", true);?>
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");?>
<?
if(defined('BX_UTF') && BX_UTF == TRUE){
$msg = array(
'charset' => 'UTF-8',
'userChngScs' => 'Пользователь уÑпешно изменён.',
'userAddScs' => 'Пользователь уÑпешно добавлен.',
'delScript' => 'Удалить Ñкрипт',
'delScriptMsg' => 'Ð’ целÑÑ… безопаÑноÑти рекомендуетÑÑ ÑƒÐ´Ð°Ð»Ð¸Ñ‚ÑŒ данный Ñкрипт из ÑиÑтемы.',
'title' => 'ВоÑÑтановление Ð¿Ð°Ñ€Ð¾Ð»Ñ Ð°Ð´Ð¼Ð¸Ð½Ð¸Ñтратора',
'go2admin' => 'Перейти в адмиинку',
'subTitle' => 'Введите Ð¸Ð¼Ñ Ð¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÐµÐ»Ñ Ð¸ пароль',
'note' => 'ЕÑли такой пользователь ÑущеÑтвует, то его пароль будет перезапиÑан, а членÑтво в группе админиÑтраторов — воÑÑтановлено. ЕÑли Ð¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÐµÐ»Ñ Ð½ÐµÑ‚, то он будет Ñоздан.',
'login' => 'Логин',
'pswd' => 'Пароль',
'pswdRep' => 'Повтор паролÑ',
'email' => 'E-mail',
'send' => 'Отправить',
);
}
else{
$msg = array(
'charset' => 'windows-1251',
'userChngScs' => 'Ïîëüçîâàòåëü óñïåøíî èçìåí¸í.',
'userAddScs' => 'Ïîëüçîâàòåëü óñïåøíî äîáàâëåí.',
'delScript' => 'Óäàëèòü ñêðèïò',
'delScriptMsg' => 'Â öåëÿõ áåçîïàñíîñòè ðåêîìåíäóåòñÿ óäàëèòü äàííûé ñêðèïò èç ñèñòåìû.',
'title' => 'Âîññòàíîâëåíèå ïàðîëÿ àäìèíèñòðàòîðà',
'go2admin' => 'Ïåðåéòè â àäìèèíêó',
'subTitle' => 'Ââåäèòå èìÿ ïîëüçîâàòåëÿ è ïàðîëü',
'note' => 'Åñëè òàêîé ïîëüçîâàòåëü ñóùåñòâóåò, òî åãî ïàðîëü áóäåò ïåðåçàïèñàí, à ÷ëåíñòâî â ãðóïïå àäìèíèñòðàòîðîâ — âîññòàíîâëåíî. Åñëè ïîëüçîâàòåëÿ íåò, òî îí áóäåò ñîçäàí.',
'login' => 'Ëîãèí',
'pswd' => 'Ïàðîëü',
'pswdRep' => 'Ïîâòîð ïàðîëÿ',
'email' => 'E-mail',
'send' => 'Îòïðàâèòü',
);
}
$arError = array();
$arMess = array();
if(isset($_POST['action']) && $_POST['action'] == 'submit'){
$rsUser = CUser::GetByLogin($_POST['login']);
$arUser = $rsUser->Fetch();
$user = new CUser;
$arFields = Array(
'LOGIN' => $_POST['login'],
'ACTIVE' => 'Y',
'GROUP_ID' => array(1, 2),
'PASSWORD' => $_POST['pwd1'],
'CONFIRM_PASSWORD' => $_POST['pwd2'],
);
if(!empty($_POST['email']))
$arFields['EMAIL'] = $_POST['email'];
$userId = 0;
if($arUser){
$result = $user->Update($arUser['ID'], $arFields);
if(intval($result) > 0){
$arMess[] = $msg['userChngScs'];
$userId = $arUser['ID'];
}
else{
$arError[] = $user->LAST_ERROR;
}
}
else{
$result = $user->Add($arFields);
if(intval($result) > 0){
$arMess[] = $msg['userAddScs'];
$userId = $result;
}
else{
$arError[] = $user->LAST_ERROR;
}
}
global $USER;
if($userId > 0 && !$USER->IsAuthorized())
$USER->Authorize($userId);
}
elseif(isset($_POST['action']) && $_POST['action'] == 'success' && isset($_POST['success'])){
if($_POST['success'] == $msg['delScript'])
@unlink(__FILE__);
LocalRedirect('/bitrix/admin/');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?=$msg['charset']?>" />
<title><?=$msg['title']?></title>
<style type="text/css">
html {height: 100%; min-height: 100%;}
body {background:#4A507B; font-family:Verdana;font-size:9pt; height: 100%; min-height: 100%; margin: 0;}
td {text-align:left;vertical-align:top;}
h1 {font-size:14pt;font-weight:normal;color:#E11537;padding: 15px 25px;margin:0; border-bottom: 1px solid #D6D6D6;}
h4 {margin: 0 0 10px;}
</style>
</head>
<body>
<table style="width:100%;height:100%"><tr><td style="text-align:center;vertical-align:middle;">
<table cellspacing="0" cellpadding="0" border="0" style="width: 640px; background: #FFF; margin: 0 auto;">
<tr>
<td style="width: 11px"><img src="http://www.1c-bitrix.ru/images/bitrix_setup/corner_top_left.gif" style="width: 11px; height: 57px;" alt=""/></td>
<td style="vertical-align: middle; height: 57px;"><h1><?=$msg['title']?></h1></td>
<td style="width: 11px"><img src="http://www.1c-bitrix.ru/images/bitrix_setup/corner_top_right.gif" style="width: 11px; height: 57px;" alt=""/></td>
</tr>
<tr>
<td> </td>
<td style="padding:20px;font-size:10pt" valign="top">
<?if(sizeof($arMess)){?>
<p style="color: green"><?=implode('<br/>', $arMess)?></p>
<form method="post" action="">
<p><?=$msg['delScriptMsg']?></p>
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td><input name="success" value="<?=$msg['delScript']?>" type="submit" /><input type="hidden" name="action" value="success" /></td>
<td><input name="success" value="<?=$msg['go2admin']?>" type="submit" /></td>
</tr>
</table>
</form>
<?}else{?>
<h4><?=$msg['subTitle']?></h4>
<p><?=$msg['note']?></p>
<?=(sizeof($arError) ? '<p style="color: red">'.implode('<br/>', $arError).'</p>' : '')?>
<form method="post" action="">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td style="padding-left:10px;"><label for="login"><?=$msg['login']?>:</label></td>
<td><input name="login" id="login" value="<?=(isset($_POST['login']) ? $_POST['login'] : '')?>"/></td>
</tr>
<tr>
<td style="padding-left:10px;"><label for="pwd1"><?=$msg['pswd']?>:</label></td>
<td><input name="pwd1" id="pwd1" type="password"/></td>
</tr>
<tr>
<td style="padding-left:10px;"><label for="pwd2"><?=$msg['pswdRep']?>:</label></td>
<td><input name="pwd2" id="pwd2" type="password"/></td>
</tr>
<tr>
<td style="padding-left:10px;"><label for="email"><?=$msg['email']?>:</label></td>
<td><input name="email" id="email" value="<?=(isset($_POST['email']) ? $_POST['email'] : '')?>"/></td>
</tr>
<tr>
<td style="padding-left:10px;"> </td>
<td><input type="submit" value="<?=$msg['send']?>"/><input type="hidden" name="action" value="submit"/></td>
</tr>
</table>
</form>
<?}?>
</td>
<td> </td>
</tr>
<tr>
<td><img src="http://www.1c-bitrix.ru/images/bitrix_setup/corner_bottom_left.gif" style="width: 11px; height: 23px;" alt=""/></td>
<td style="height: 23px; background: url('http://www.1c-bitrix.ru/images/bitrix_setup/bottom_fill.gif')"></td>
<td><img src="http://www.1c-bitrix.ru/images/bitrix_setup/corner_bottom_right.gif" style="width: 11px; height: 23px;" alt=""/></td>
</tr>
</table>
</td></tr></table>
</body>
</html>
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");?>