Skip to content

Commit 74c83ed

Browse files
[php, js, css] change password is highly nice. checkbox fixes
1 parent d53c7d8 commit 74c83ed

16 files changed

+694
-699
lines changed

web/captcha.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Captcha
1414
protected $color3 = null;
1515
protected $keyword = '';
1616
public $key_len = 7;
17-
protected $chars = 'qw1e2r3t4y5u67o8p9as9d38f6g4h3j2k1l3z5x7c8v3b5n781234567890';
17+
protected $chars = 'qw1e2r3ty5u678p97as9d3o87f6gh3j2k73z5x7c8v3b75n77812356789';
1818

1919
public function __construct()
2020
{

web/change_password.php

Lines changed: 41 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
require_once V_ROOT_DIR . 'core/utils/Message.class.php';
1414
require_once V_ROOT_DIR . 'core/Request.class.php';
1515
require_once V_ROOT_DIR . 'api/AjaxHandler.php';
16+
require_once V_ROOT_DIR . 'api/MAIN.class.php';
1617

1718

1819
class ChangePassword
@@ -26,14 +27,14 @@ public function dispatch()
2627

2728
$key = addslashes(htmlspecialchars($_GET['v']));
2829

29-
$users = Vesta::execute(Vesta::V_LIST_SYS_USERS, 'json');
30+
$cmd = Config::get('sudo_path')." ".Config::get('vesta_functions_path').Vesta::V_LIST_SYS_USERS." 'json'";
31+
exec($cmd, $output, $return);
32+
33+
$users = json_decode(implode('', $output), true);
34+
3035
$email_matched_count = array();
3136

32-
/*if (strcmp($real_key, $key_sha1) != 0) {
33-
return $this->renderError('Invalid keys');
34-
}*/
35-
36-
foreach ($users['data'] as $username => $user) {
37+
foreach ($users as $username => $user) {
3738
if ($user['RKEY'] == trim($key)) {
3839
$email_matched_count[] = array_merge(array('USERNAME' => $username), $user);
3940
}
@@ -62,22 +63,30 @@ protected function doChangePassword($users)
6263

6364
$success = true;
6465
foreach ($users as $user) {
65-
$rs = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $user['USERNAME'],
66-
'PASSWORD' => $_POST['secret_code']));
67-
if (!$rs) {
66+
$cmd = Config::get('sudo_path')." ".Config::get('vesta_functions_path').Vesta::V_CHANGE_SYS_USER_PASSWORD." ".$user['USERNAME']." ".$_POST['secret_code'];
67+
exec($cmd, $output, $return);
68+
69+
if (!$return) {
6870
$success = false;
6971
}
7072
}
7173

7274
if (!$success) {
73-
return $this->showResetForm('Something went wrong. Please contact support.');
75+
$main = new MAIN();
76+
$about = json_decode($main->aboutExecute(), TRUE);
77+
78+
return $this->showResetForm('Something went wrong. Please contact support: '.$about['data']['company_email']);
7479
}
7580

7681
return $this->showSuccessTpl();
7782
}
7883

7984
public function showSuccessTpl()
8085
{
86+
$main = new MAIN();
87+
$about = json_decode($main->aboutExecute(), TRUE);
88+
$current_year = date("Y");
89+
8190
print <<<HTML
8291
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
8392
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
@@ -101,7 +110,7 @@ public function showSuccessTpl()
101110
<div class="b-auth-form">
102111
<div class="b-auth-form-wrap">
103112
<img width="72" height="24" alt="" src="/images/vesta-logo-2011-12-14.png" class="vesta-logo">
104-
<span style="color: #5E696B; float: right; margin-top: -48px;">~!:VERSION~!</span>
113+
<span style="color: #5E696B; float: right; margin-top: -48px;">{$about['data']['version_name']}</span>
105114
<div class="b-client-title">
106115
<span class="client-title-wrap">Control Panel<i class="planets">&nbsp;</i></span>
107116
</div>
@@ -111,10 +120,10 @@ public function showSuccessTpl()
111120
<div class="success-box" id="change-psw-success">Password successfully changed.</div>
112121
113122
</form>
114-
<p class="forgot-pwd">&nbsp;</p>
123+
<p class="forgot-pwd"><a href="/" class="forgot-pwd-url">Back to login?</a></p>
115124
<div class="footnotes cc">
116-
<p class="additional-info">For questions please contact <a href="mailto:info@vestacp.com" class="questions-url">info@vestacp.com</a></p>
117-
<address class="imprint">&copy; 2011 Vesta Control Panel</address>
125+
<p class="additional-info">For questions please contact <a href="mailto:{$about['data']['company_email']}" class="questions-url">{$about['data']['company_email']}</a></p>
126+
<address class="imprint">&copy; {$current_year} Vesta Control Panel</address>
118127
</div>
119128
</div>
120129
</div>
@@ -129,9 +138,14 @@ public function showSuccessTpl()
129138
public function showResetForm($error_msg = '')
130139
{
131140
if (!empty($error_msg)) {
132-
$error_msg = '<i>'.$error_msg.'</i>';
141+
$error_msg = '<div class="error-box" id="auth-error">'.$error_msg.'</div>';
133142
}
134-
143+
144+
$main = new MAIN();
145+
$about = json_decode($main->aboutExecute(), TRUE);
146+
147+
$current_year = date("Y");
148+
135149
print <<<HTML
136150
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
137151
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
@@ -154,13 +168,15 @@ public function showResetForm($error_msg = '')
154168
<div id="change-psw-block" class="page2">
155169
<div class="b-auth-form">
156170
<div class="b-auth-form-wrap">
171+
<a href="/">
157172
<img width="72" height="24" alt="" src="/images/vesta-logo-2011-12-14.png" class="vesta-logo">
158-
<span style="color: #5E696B; float: right; margin-top: -48px;">~!:VERSION~!</span>
173+
</a>
174+
<span style="color: #5E696B; float: right; margin-top: -48px;">{$about['data']['version_name']}</span>
159175
<div class="b-client-title">
160176
<span class="client-title-wrap">Control Panel<i class="planets">&nbsp;</i></span>
161177
</div>
162178
<form id="change_psw-form" method="post" action="" class="auth">
163-
<input type="hidden" value="change" name="action">
179+
<input type="hidden" value="change" name="action">
164180
165181
<div class="form-row cc">
166182
<label for="password" class="field-label">New Password</label>
@@ -171,58 +187,24 @@ public function showResetForm($error_msg = '')
171187
<label for="confirm_password" class="field-label">ONE MORE TIME</label>
172188
<input type="password" tabindex="1" id="confirm_password" class="field-text" name="confirm_secret_code">
173189
</div>
174-
190+
{$error_msg}
175191
<div class="form-row cc last-row">
176192
<input type="submit" tabindex="4" value="Change Password" class="sumbit-btn">
177193
</div>
178194
</form>
179-
<p class="forgot-pwd">&nbsp;</p>
195+
196+
<p class="forgot-pwd"><a href="/" class="forgot-pwd-url">Back to login?</a></p>\
197+
180198
<div class="footnotes cc">
181-
<p class="additional-info">For questions please contact <a href="mailto:info@vestacp.com" class="questions-url">info@vestacp.com</a></p>
182-
<address class="imprint">&copy; 2011 Vesta Control Panel</address>
199+
<p class="additional-info">For questions please contact <a href="mailto:{$about['data']['company_email']}" class="questions-url">{$about['data']['company_email']}</a></p>
200+
<address class="imprint">&copy; {$current_year} Vesta Control Panel</address>
183201
</div>
184202
</div>
185203
</div>
186204
</div>
187205
</body>
188206
</html>
189-
190-
<!--
191-
192-
<center>
193-
vesta password reset form
194-
<hr />
195-
{$error_msg}
196-
<form action="" method="POST">
197-
<table>
198-
<tr>
199-
<td>
200-
<input type="hidden" name="action" value="change" />
201-
<label>Enter secret code:</label>
202-
</td>
203-
<td>
204-
<input type="password" name="secret_code" value="" />
205-
</td>
206-
</tr>
207-
<tr>
208-
<td>
209-
<label>Enter new password:</label>
210-
</td>
211-
<td>
212-
<input type="password" name="confirm_secret_code" value="" />
213-
</td>
214-
</tr>
215-
<tr>
216-
<td colspan="2">
217-
<input type="submit" name="Apply" />
218-
</td>
219-
</tr>
220-
</table>
221-
</form>
222-
</center> -->
223-
224207
HTML;
225-
226208
}
227209

228210
public function renderError($message)
@@ -232,10 +214,9 @@ public function renderError($message)
232214
HTML;
233215

234216
}
235-
236217
}
237218

238219
$changePassword = new ChangePassword();
239220
$changePassword->dispatch();
240221

241-
?>
222+
?>

web/css/main.css

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,8 @@ input::-moz-focus-inner{
591591
}
592592
.checkbox-selector span.ui-checkbox{
593593
float:none;
594-
width:11px;
595-
height:11px;
594+
width:10px;
595+
height:10px;
596596
margin:2px 2px 0 0;
597597
/*background:url(../i/checkbox-selector-2012-01-29.png) no-repeat;*/
598598
background:url(../images/checkbox-selector-2012-01-31.png) no-repeat;
@@ -608,12 +608,16 @@ input::-moz-focus-inner{
608608
}
609609
.checkbox-selector span.ui-checkbox-hover{
610610
background-position:0 -20px;
611+
-moz-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
612+
-webkit-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
611613
}
612614
.checkbox-selector span.ui-checkbox-state-checked{
613615
background-position:0 -40px;
614616
}
615617
.checkbox-selector span.ui-checkbox-state-checked-hover{
616618
background-position:0 -60px;
619+
-moz-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
620+
-webkit-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
617621
}
618622
.checkbox-selector .selector-title:hover{
619623
color:#2ea8bd;
@@ -1277,6 +1281,8 @@ input::-moz-focus-inner{
12771281
.row-actions-box .check-control:hover{
12781282
cursor:pointer;
12791283
background-position:0 -89px;
1284+
-moz-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
1285+
-webkit-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
12801286
}
12811287
.row-actions-box .row-operations{
12821288
float:right;
@@ -1681,7 +1687,7 @@ input::-moz-focus-inner{
16811687
float:left;
16821688
width:18px;
16831689
height:18px;
1684-
margin:6px 0 0;
1690+
margin:9px 0 0;
16851691
/*background:url(../i/checkbox-1.png) no-repeat;*/
16861692
/*background:url(../i/form-checkboxes.png) no-repeat;*/
16871693
background:url(../images/checkbox-selector-2012-01-31.png) no-repeat -12px 0;
@@ -1691,12 +1697,16 @@ input::-moz-focus-inner{
16911697
}
16921698
.b-new-entry span.ui-checkbox-hover{
16931699
background-position:-12px -20px;
1700+
-moz-box-shadow:0 0 8px rgba(82, 168, 236, 0.6);
1701+
-webkit-box-shadow:0 0 8px rgba(82, 168, 236, 0.6);
16941702
}
16951703
.b-new-entry span.ui-checkbox-state-checked{
16961704
background-position:-12px -40px;
16971705
}
16981706
.b-new-entry span.ui-checkbox-state-checked-hover{
16991707
background-position:-12px -60px;
1708+
-moz-box-shadow:0 0 8px rgba(82, 168, 236, 0.6);
1709+
-webkit-box-shadow:0 0 8px rgba(82, 168, 236, 0.6);
17001710
}
17011711

17021712
.b-new-entry .stats-settings{

web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ <h1 class="logo"><a href="/">Vesta panel <span>&nbsp;</span></a></h1>
275275
<script type="text/javascript" src="js/pages.js"></script>
276276
<script type="text/javascript" src="js/model.js"></script>
277277
<script type="text/javascript" src="js/core.js"></script>
278-
<script type="text/javascript" src="js/validators.js"></script>
278+
<script type="text/javascript" src="js/validators.js"></script>
279279
<script type="text/javascript" src="js/__init__.js"></script>
280280
</body>
281281
</html>

web/js/actions.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@ App.Actions.reset_batch = function()
143143

144144
App.Actions.do_change_password = function()
145145
{
146-
147146
var params = {
148-
email: $('#change-email').val(),
147+
login: $('#change-login').val(),
149148
captcha: $('#captcha').val()
150149
}
151150

@@ -261,11 +260,13 @@ App.Actions.new_entry = function() {
261260
var build_method = App.Env.getWorldName() + '_form';
262261
var tpl = App.HTML.Build[build_method]({}, form_id);
263262
var box = $('<div>').html(tpl);
263+
264264
$(box).find('.suspended').addClass('hidden');
265265
App.Ref.CONTENT.prepend($(box).html());
266266

267267
App.Helpers.updateScreen();
268268
}
269+
$('.cust-checkbox').checkBox();
269270
}
270271

271272
// execute authorisation
@@ -403,6 +404,7 @@ App.Actions.edit = function(evt)
403404
App.Helpers.disableNotEditable();
404405
App.Helpers.updateScreen();
405406
}
407+
$('.cust-checkbox').checkBox();
406408
}
407409

408410
// do_cancel_form

web/js/html.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ App.HTML.Build.dns_form = function (options, id) {
4343
tpl.set(':DATE', options.DATE || '');
4444
tpl = App.HTML.Build.dns_selects(tpl, options);
4545
tpl = App.HTML.toggle_suspended_form(tpl, options);
46-
46+
4747
return tpl.finalize();
4848
}
4949

@@ -218,7 +218,6 @@ App.HTML.Build.web_domain_form = function (options, id) {
218218

219219
tpl.set(':DNS_DOMAIN_ALSO', in_edit? 'hidden' : '');
220220

221-
222221
return tpl.finalize();
223222
}
224223

0 commit comments

Comments
 (0)