[php, js, css] change password is highly nice. checkbox fixes

This commit is contained in:
naumov-socolov 2012-02-03 00:44:02 +03:00
parent d53c7d889b
commit 74c83ed412
16 changed files with 694 additions and 699 deletions

View file

@ -14,7 +14,7 @@ class Captcha
protected $color3 = null; protected $color3 = null;
protected $keyword = ''; protected $keyword = '';
public $key_len = 7; public $key_len = 7;
protected $chars = 'qw1e2r3t4y5u67o8p9as9d38f6g4h3j2k1l3z5x7c8v3b5n781234567890'; protected $chars = 'qw1e2r3ty5u678p97as9d3o87f6gh3j2k73z5x7c8v3b75n77812356789';
public function __construct() public function __construct()
{ {

View file

@ -13,6 +13,7 @@ require_once V_ROOT_DIR . 'core/exceptions/ProtectionException.class.php';
require_once V_ROOT_DIR . 'core/utils/Message.class.php'; require_once V_ROOT_DIR . 'core/utils/Message.class.php';
require_once V_ROOT_DIR . 'core/Request.class.php'; require_once V_ROOT_DIR . 'core/Request.class.php';
require_once V_ROOT_DIR . 'api/AjaxHandler.php'; require_once V_ROOT_DIR . 'api/AjaxHandler.php';
require_once V_ROOT_DIR . 'api/MAIN.class.php';
class ChangePassword class ChangePassword
@ -26,14 +27,14 @@ class ChangePassword
$key = addslashes(htmlspecialchars($_GET['v'])); $key = addslashes(htmlspecialchars($_GET['v']));
$users = Vesta::execute(Vesta::V_LIST_SYS_USERS, 'json'); $cmd = Config::get('sudo_path')." ".Config::get('vesta_functions_path').Vesta::V_LIST_SYS_USERS." 'json'";
exec($cmd, $output, $return);
$users = json_decode(implode('', $output), true);
$email_matched_count = array(); $email_matched_count = array();
/*if (strcmp($real_key, $key_sha1) != 0) { foreach ($users as $username => $user) {
return $this->renderError('Invalid keys');
}*/
foreach ($users['data'] as $username => $user) {
if ($user['RKEY'] == trim($key)) { if ($user['RKEY'] == trim($key)) {
$email_matched_count[] = array_merge(array('USERNAME' => $username), $user); $email_matched_count[] = array_merge(array('USERNAME' => $username), $user);
} }
@ -62,15 +63,19 @@ class ChangePassword
$success = true; $success = true;
foreach ($users as $user) { foreach ($users as $user) {
$rs = Vesta::execute(Vesta::V_CHANGE_SYS_USER_PASSWORD, array('USER' => $user['USERNAME'], $cmd = Config::get('sudo_path')." ".Config::get('vesta_functions_path').Vesta::V_CHANGE_SYS_USER_PASSWORD." ".$user['USERNAME']." ".$_POST['secret_code'];
'PASSWORD' => $_POST['secret_code'])); exec($cmd, $output, $return);
if (!$rs) {
if (!$return) {
$success = false; $success = false;
} }
} }
if (!$success) { if (!$success) {
return $this->showResetForm('Something went wrong. Please contact support.'); $main = new MAIN();
$about = json_decode($main->aboutExecute(), TRUE);
return $this->showResetForm('Something went wrong. Please contact support: '.$about['data']['company_email']);
} }
return $this->showSuccessTpl(); return $this->showSuccessTpl();
@ -78,6 +83,10 @@ class ChangePassword
public function showSuccessTpl() public function showSuccessTpl()
{ {
$main = new MAIN();
$about = json_decode($main->aboutExecute(), TRUE);
$current_year = date("Y");
print <<<HTML print <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
@ -101,7 +110,7 @@ class ChangePassword
<div class="b-auth-form"> <div class="b-auth-form">
<div class="b-auth-form-wrap"> <div class="b-auth-form-wrap">
<img width="72" height="24" alt="" src="/images/vesta-logo-2011-12-14.png" class="vesta-logo"> <img width="72" height="24" alt="" src="/images/vesta-logo-2011-12-14.png" class="vesta-logo">
<span style="color: #5E696B; float: right; margin-top: -48px;">~!:VERSION~!</span> <span style="color: #5E696B; float: right; margin-top: -48px;">{$about['data']['version_name']}</span>
<div class="b-client-title"> <div class="b-client-title">
<span class="client-title-wrap">Control Panel<i class="planets">&nbsp;</i></span> <span class="client-title-wrap">Control Panel<i class="planets">&nbsp;</i></span>
</div> </div>
@ -111,10 +120,10 @@ class ChangePassword
<div class="success-box" id="change-psw-success">Password successfully changed.</div> <div class="success-box" id="change-psw-success">Password successfully changed.</div>
</form> </form>
<p class="forgot-pwd">&nbsp;</p> <p class="forgot-pwd"><a href="/" class="forgot-pwd-url">Back to login?</a></p>
<div class="footnotes cc"> <div class="footnotes cc">
<p class="additional-info">For questions please contact <a href="mailto:info@vestacp.com" class="questions-url">info@vestacp.com</a></p> <p class="additional-info">For questions please contact <a href="mailto:{$about['data']['company_email']}" class="questions-url">{$about['data']['company_email']}</a></p>
<address class="imprint">&copy; 2011 Vesta Control Panel</address> <address class="imprint">&copy; {$current_year} Vesta Control Panel</address>
</div> </div>
</div> </div>
</div> </div>
@ -129,9 +138,14 @@ HTML;
public function showResetForm($error_msg = '') public function showResetForm($error_msg = '')
{ {
if (!empty($error_msg)) { if (!empty($error_msg)) {
$error_msg = '<i>'.$error_msg.'</i>'; $error_msg = '<div class="error-box" id="auth-error">'.$error_msg.'</div>';
} }
$main = new MAIN();
$about = json_decode($main->aboutExecute(), TRUE);
$current_year = date("Y");
print <<<HTML print <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
@ -154,13 +168,15 @@ HTML;
<div id="change-psw-block" class="page2"> <div id="change-psw-block" class="page2">
<div class="b-auth-form"> <div class="b-auth-form">
<div class="b-auth-form-wrap"> <div class="b-auth-form-wrap">
<a href="/">
<img width="72" height="24" alt="" src="/images/vesta-logo-2011-12-14.png" class="vesta-logo"> <img width="72" height="24" alt="" src="/images/vesta-logo-2011-12-14.png" class="vesta-logo">
<span style="color: #5E696B; float: right; margin-top: -48px;">~!:VERSION~!</span> </a>
<span style="color: #5E696B; float: right; margin-top: -48px;">{$about['data']['version_name']}</span>
<div class="b-client-title"> <div class="b-client-title">
<span class="client-title-wrap">Control Panel<i class="planets">&nbsp;</i></span> <span class="client-title-wrap">Control Panel<i class="planets">&nbsp;</i></span>
</div> </div>
<form id="change_psw-form" method="post" action="" class="auth"> <form id="change_psw-form" method="post" action="" class="auth">
<input type="hidden" value="change" name="action"> <input type="hidden" value="change" name="action">
<div class="form-row cc"> <div class="form-row cc">
<label for="password" class="field-label">New Password</label> <label for="password" class="field-label">New Password</label>
@ -171,58 +187,24 @@ HTML;
<label for="confirm_password" class="field-label">ONE MORE TIME</label> <label for="confirm_password" class="field-label">ONE MORE TIME</label>
<input type="password" tabindex="1" id="confirm_password" class="field-text" name="confirm_secret_code"> <input type="password" tabindex="1" id="confirm_password" class="field-text" name="confirm_secret_code">
</div> </div>
{$error_msg}
<div class="form-row cc last-row"> <div class="form-row cc last-row">
<input type="submit" tabindex="4" value="Change Password" class="sumbit-btn"> <input type="submit" tabindex="4" value="Change Password" class="sumbit-btn">
</div> </div>
</form> </form>
<p class="forgot-pwd">&nbsp;</p>
<p class="forgot-pwd"><a href="/" class="forgot-pwd-url">Back to login?</a></p>\
<div class="footnotes cc"> <div class="footnotes cc">
<p class="additional-info">For questions please contact <a href="mailto:info@vestacp.com" class="questions-url">info@vestacp.com</a></p> <p class="additional-info">For questions please contact <a href="mailto:{$about['data']['company_email']}" class="questions-url">{$about['data']['company_email']}</a></p>
<address class="imprint">&copy; 2011 Vesta Control Panel</address> <address class="imprint">&copy; {$current_year} Vesta Control Panel</address>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</body> </body>
</html> </html>
<!--
<center>
vesta password reset form
<hr />
{$error_msg}
<form action="" method="POST">
<table>
<tr>
<td>
<input type="hidden" name="action" value="change" />
<label>Enter secret code:</label>
</td>
<td>
<input type="password" name="secret_code" value="" />
</td>
</tr>
<tr>
<td>
<label>Enter new password:</label>
</td>
<td>
<input type="password" name="confirm_secret_code" value="" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="Apply" />
</td>
</tr>
</table>
</form>
</center> -->
HTML; HTML;
} }
public function renderError($message) public function renderError($message)
@ -232,10 +214,9 @@ HTML;
HTML; HTML;
} }
} }
$changePassword = new ChangePassword(); $changePassword = new ChangePassword();
$changePassword->dispatch(); $changePassword->dispatch();
?> ?>

View file

@ -591,8 +591,8 @@ input::-moz-focus-inner{
} }
.checkbox-selector span.ui-checkbox{ .checkbox-selector span.ui-checkbox{
float:none; float:none;
width:11px; width:10px;
height:11px; height:10px;
margin:2px 2px 0 0; margin:2px 2px 0 0;
/*background:url(../i/checkbox-selector-2012-01-29.png) no-repeat;*/ /*background:url(../i/checkbox-selector-2012-01-29.png) no-repeat;*/
background:url(../images/checkbox-selector-2012-01-31.png) no-repeat; background:url(../images/checkbox-selector-2012-01-31.png) no-repeat;
@ -608,12 +608,16 @@ input::-moz-focus-inner{
} }
.checkbox-selector span.ui-checkbox-hover{ .checkbox-selector span.ui-checkbox-hover{
background-position:0 -20px; background-position:0 -20px;
-moz-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
-webkit-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
} }
.checkbox-selector span.ui-checkbox-state-checked{ .checkbox-selector span.ui-checkbox-state-checked{
background-position:0 -40px; background-position:0 -40px;
} }
.checkbox-selector span.ui-checkbox-state-checked-hover{ .checkbox-selector span.ui-checkbox-state-checked-hover{
background-position:0 -60px; background-position:0 -60px;
-moz-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
-webkit-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
} }
.checkbox-selector .selector-title:hover{ .checkbox-selector .selector-title:hover{
color:#2ea8bd; color:#2ea8bd;
@ -1277,6 +1281,8 @@ input::-moz-focus-inner{
.row-actions-box .check-control:hover{ .row-actions-box .check-control:hover{
cursor:pointer; cursor:pointer;
background-position:0 -89px; background-position:0 -89px;
-moz-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
-webkit-box-shadow:0 0 5px rgba(82, 168, 236, 0.6);
} }
.row-actions-box .row-operations{ .row-actions-box .row-operations{
float:right; float:right;
@ -1681,7 +1687,7 @@ input::-moz-focus-inner{
float:left; float:left;
width:18px; width:18px;
height:18px; height:18px;
margin:6px 0 0; margin:9px 0 0;
/*background:url(../i/checkbox-1.png) no-repeat;*/ /*background:url(../i/checkbox-1.png) no-repeat;*/
/*background:url(../i/form-checkboxes.png) no-repeat;*/ /*background:url(../i/form-checkboxes.png) no-repeat;*/
background:url(../images/checkbox-selector-2012-01-31.png) no-repeat -12px 0; background:url(../images/checkbox-selector-2012-01-31.png) no-repeat -12px 0;
@ -1691,12 +1697,16 @@ input::-moz-focus-inner{
} }
.b-new-entry span.ui-checkbox-hover{ .b-new-entry span.ui-checkbox-hover{
background-position:-12px -20px; background-position:-12px -20px;
-moz-box-shadow:0 0 8px rgba(82, 168, 236, 0.6);
-webkit-box-shadow:0 0 8px rgba(82, 168, 236, 0.6);
} }
.b-new-entry span.ui-checkbox-state-checked{ .b-new-entry span.ui-checkbox-state-checked{
background-position:-12px -40px; background-position:-12px -40px;
} }
.b-new-entry span.ui-checkbox-state-checked-hover{ .b-new-entry span.ui-checkbox-state-checked-hover{
background-position:-12px -60px; background-position:-12px -60px;
-moz-box-shadow:0 0 8px rgba(82, 168, 236, 0.6);
-webkit-box-shadow:0 0 8px rgba(82, 168, 236, 0.6);
} }
.b-new-entry .stats-settings{ .b-new-entry .stats-settings{

View file

@ -275,7 +275,7 @@
<script type="text/javascript" src="js/pages.js"></script> <script type="text/javascript" src="js/pages.js"></script>
<script type="text/javascript" src="js/model.js"></script> <script type="text/javascript" src="js/model.js"></script>
<script type="text/javascript" src="js/core.js"></script> <script type="text/javascript" src="js/core.js"></script>
<script type="text/javascript" src="js/validators.js"></script> <script type="text/javascript" src="js/validators.js"></script>
<script type="text/javascript" src="js/__init__.js"></script> <script type="text/javascript" src="js/__init__.js"></script>
</body> </body>
</html> </html>

View file

@ -143,9 +143,8 @@ App.Actions.reset_batch = function()
App.Actions.do_change_password = function() App.Actions.do_change_password = function()
{ {
var params = { var params = {
email: $('#change-email').val(), login: $('#change-login').val(),
captcha: $('#captcha').val() captcha: $('#captcha').val()
} }
@ -261,11 +260,13 @@ App.Actions.new_entry = function() {
var build_method = App.Env.getWorldName() + '_form'; var build_method = App.Env.getWorldName() + '_form';
var tpl = App.HTML.Build[build_method]({}, form_id); var tpl = App.HTML.Build[build_method]({}, form_id);
var box = $('<div>').html(tpl); var box = $('<div>').html(tpl);
$(box).find('.suspended').addClass('hidden'); $(box).find('.suspended').addClass('hidden');
App.Ref.CONTENT.prepend($(box).html()); App.Ref.CONTENT.prepend($(box).html());
App.Helpers.updateScreen(); App.Helpers.updateScreen();
} }
$('.cust-checkbox').checkBox();
} }
// execute authorisation // execute authorisation
@ -403,6 +404,7 @@ App.Actions.edit = function(evt)
App.Helpers.disableNotEditable(); App.Helpers.disableNotEditable();
App.Helpers.updateScreen(); App.Helpers.updateScreen();
} }
$('.cust-checkbox').checkBox();
} }
// do_cancel_form // do_cancel_form

View file

@ -43,7 +43,7 @@ App.HTML.Build.dns_form = function (options, id) {
tpl.set(':DATE', options.DATE || ''); tpl.set(':DATE', options.DATE || '');
tpl = App.HTML.Build.dns_selects(tpl, options); tpl = App.HTML.Build.dns_selects(tpl, options);
tpl = App.HTML.toggle_suspended_form(tpl, options); tpl = App.HTML.toggle_suspended_form(tpl, options);
return tpl.finalize(); return tpl.finalize();
} }
@ -218,7 +218,6 @@ App.HTML.Build.web_domain_form = function (options, id) {
tpl.set(':DNS_DOMAIN_ALSO', in_edit? 'hidden' : ''); tpl.set(':DNS_DOMAIN_ALSO', in_edit? 'hidden' : '');
return tpl.finalize(); return tpl.finalize();
} }

View file

@ -1,236 +1,236 @@
/*! /*!
* jQuery UI Widget 1.8 * jQuery UI Widget 1.8
* *
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt) * Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses. * and GPL (GPL-LICENSE.txt) licenses.
* *
* http://docs.jquery.com/UI/Widget * http://docs.jquery.com/UI/Widget
*/ */
(function( $ ) { (function( $ ) {
var _remove = $.fn.remove; var _remove = $.fn.remove;
$.fn.remove = function( selector, keepData ) { $.fn.remove = function( selector, keepData ) {
return this.each(function() { return this.each(function() {
if ( !keepData ) { if ( !keepData ) {
if ( !selector || $.filter( selector, [ this ] ).length ) { if ( !selector || $.filter( selector, [ this ] ).length ) {
$( "*", this ).add( this ).each(function() { $( "*", this ).add( this ).each(function() {
$( this ).triggerHandler( "remove" ); $( this ).triggerHandler( "remove" );
}); });
} }
} }
return _remove.call( $(this), selector, keepData ); return _remove.call( $(this), selector, keepData );
}); });
}; };
$.widget = function( name, base, prototype ) { $.widget = function( name, base, prototype ) {
var namespace = name.split( "." )[ 0 ], var namespace = name.split( "." )[ 0 ],
fullName; fullName;
name = name.split( "." )[ 1 ]; name = name.split( "." )[ 1 ];
fullName = namespace + "-" + name; fullName = namespace + "-" + name;
if ( !prototype ) { if ( !prototype ) {
prototype = base; prototype = base;
base = $.Widget; base = $.Widget;
} }
// create selector for plugin // create selector for plugin
$.expr[ ":" ][ fullName ] = function( elem ) { $.expr[ ":" ][ fullName ] = function( elem ) {
return !!$.data( elem, name ); return !!$.data( elem, name );
}; };
$[ namespace ] = $[ namespace ] || {}; $[ namespace ] = $[ namespace ] || {};
$[ namespace ][ name ] = function( options, element ) { $[ namespace ][ name ] = function( options, element ) {
// allow instantiation without initializing for simple inheritance // allow instantiation without initializing for simple inheritance
if ( arguments.length ) { if ( arguments.length ) {
this._createWidget( options, element ); this._createWidget( options, element );
} }
}; };
var basePrototype = new base(); var basePrototype = new base();
// we need to make the options hash a property directly on the new instance // we need to make the options hash a property directly on the new instance
// otherwise we'll modify the options hash on the prototype that we're // otherwise we'll modify the options hash on the prototype that we're
// inheriting from // inheriting from
// $.each( basePrototype, function( key, val ) { // $.each( basePrototype, function( key, val ) {
// if ( $.isPlainObject(val) ) { // if ( $.isPlainObject(val) ) {
// basePrototype[ key ] = $.extend( {}, val ); // basePrototype[ key ] = $.extend( {}, val );
// } // }
// }); // });
basePrototype.options = $.extend( {}, basePrototype.options ); basePrototype.options = $.extend( {}, basePrototype.options );
$[ namespace ][ name ].prototype = $.extend( true, basePrototype, { $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
namespace: namespace, namespace: namespace,
widgetName: name, widgetName: name,
widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name, widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
widgetBaseClass: fullName widgetBaseClass: fullName
}, prototype ); }, prototype );
$.widget.bridge( name, $[ namespace ][ name ] ); $.widget.bridge( name, $[ namespace ][ name ] );
}; };
$.widget.bridge = function( name, object ) { $.widget.bridge = function( name, object ) {
$.fn[ name ] = function( options ) { $.fn[ name ] = function( options ) {
var isMethodCall = typeof options === "string", var isMethodCall = typeof options === "string",
args = Array.prototype.slice.call( arguments, 1 ), args = Array.prototype.slice.call( arguments, 1 ),
returnValue = this; returnValue = this;
// allow multiple hashes to be passed on init // allow multiple hashes to be passed on init
options = !isMethodCall && args.length ? options = !isMethodCall && args.length ?
$.extend.apply( null, [ true, options ].concat(args) ) : $.extend.apply( null, [ true, options ].concat(args) ) :
options; options;
// prevent calls to internal methods // prevent calls to internal methods
if ( isMethodCall && options.substring( 0, 1 ) === "_" ) { if ( isMethodCall && options.substring( 0, 1 ) === "_" ) {
return returnValue; return returnValue;
} }
if ( isMethodCall ) { if ( isMethodCall ) {
this.each(function() { this.each(function() {
var instance = $.data( this, name ), var instance = $.data( this, name ),
methodValue = instance && $.isFunction( instance[options] ) ? methodValue = instance && $.isFunction( instance[options] ) ?
instance[ options ].apply( instance, args ) : instance[ options ].apply( instance, args ) :
instance; instance;
if ( methodValue !== instance && methodValue !== undefined ) { if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue; returnValue = methodValue;
return false; return false;
} }
}); });
} else { } else {
this.each(function() { this.each(function() {
var instance = $.data( this, name ); var instance = $.data( this, name );
if ( instance ) { if ( instance ) {
if ( options ) { if ( options ) {
instance.option( options ); instance.option( options );
} }
instance._init(); instance._init();
} else { } else {
$.data( this, name, new object( options, this ) ); $.data( this, name, new object( options, this ) );
} }
}); });
} }
return returnValue; return returnValue;
}; };
}; };
$.Widget = function( options, element ) { $.Widget = function( options, element ) {
// allow instantiation without initializing for simple inheritance // allow instantiation without initializing for simple inheritance
if ( arguments.length ) { if ( arguments.length ) {
this._createWidget( options, element ); this._createWidget( options, element );
} }
}; };
$.Widget.prototype = { $.Widget.prototype = {
widgetName: "widget", widgetName: "widget",
widgetEventPrefix: "", widgetEventPrefix: "",
options: { options: {
disabled: false disabled: false
}, },
_createWidget: function( options, element ) { _createWidget: function( options, element ) {
// $.widget.bridge stores the plugin instance, but we do it anyway // $.widget.bridge stores the plugin instance, but we do it anyway
// so that it's stored even before the _create function runs // so that it's stored even before the _create function runs
this.element = $( element ).data( this.widgetName, this ); this.element = $( element ).data( this.widgetName, this );
this.options = $.extend( true, {}, this.options = $.extend( true, {},
this.options, this.options,
$.metadata && $.metadata.get( element )[ this.widgetName ], $.metadata && $.metadata.get( element )[ this.widgetName ],
options ); options );
var self = this; var self = this;
this.element.bind( "remove." + this.widgetName, function() { this.element.bind( "remove." + this.widgetName, function() {
self.destroy(); self.destroy();
}); });
this._create(); this._create();
this._init(); this._init();
}, },
_create: function() {}, _create: function() {},
_init: function() {}, _init: function() {},
destroy: function() { destroy: function() {
this.element this.element
.unbind( "." + this.widgetName ) .unbind( "." + this.widgetName )
.removeData( this.widgetName ); .removeData( this.widgetName );
this.widget() this.widget()
.unbind( "." + this.widgetName ) .unbind( "." + this.widgetName )
.removeAttr( "aria-disabled" ) .removeAttr( "aria-disabled" )
.removeClass( .removeClass(
this.widgetBaseClass + "-disabled " + this.widgetBaseClass + "-disabled " +
this.namespace + "-state-disabled" ); this.namespace + "-state-disabled" );
}, },
widget: function() { widget: function() {
return this.element; return this.element;
}, },
option: function( key, value ) { option: function( key, value ) {
var options = key, var options = key,
self = this; self = this;
if ( arguments.length === 0 ) { if ( arguments.length === 0 ) {
// don't return a reference to the internal hash // don't return a reference to the internal hash
return $.extend( {}, self.options ); return $.extend( {}, self.options );
} }
if (typeof key === "string" ) { if (typeof key === "string" ) {
if ( value === undefined ) { if ( value === undefined ) {
return this.options[ key ]; return this.options[ key ];
} }
options = {}; options = {};
options[ key ] = value; options[ key ] = value;
} }
$.each( options, function( key, value ) { $.each( options, function( key, value ) {
self._setOption( key, value ); self._setOption( key, value );
}); });
return self; return self;
}, },
_setOption: function( key, value ) { _setOption: function( key, value ) {
this.options[ key ] = value; this.options[ key ] = value;
if ( key === "disabled" ) { if ( key === "disabled" ) {
this.widget() this.widget()
[ value ? "addClass" : "removeClass"]( [ value ? "addClass" : "removeClass"](
this.widgetBaseClass + "-disabled" + " " + this.widgetBaseClass + "-disabled" + " " +
this.namespace + "-state-disabled" ) this.namespace + "-state-disabled" )
.attr( "aria-disabled", value ); .attr( "aria-disabled", value );
} }
return this; return this;
}, },
enable: function() { enable: function() {
return this._setOption( "disabled", false ); return this._setOption( "disabled", false );
}, },
disable: function() { disable: function() {
return this._setOption( "disabled", true ); return this._setOption( "disabled", true );
}, },
_trigger: function( type, event, data ) { _trigger: function( type, event, data ) {
var callback = this.options[ type ]; var callback = this.options[ type ];
event = $.Event( event ); event = $.Event( event );
event.type = ( type === this.widgetEventPrefix ? event.type = ( type === this.widgetEventPrefix ?
type : type :
this.widgetEventPrefix + type ).toLowerCase(); this.widgetEventPrefix + type ).toLowerCase();
data = data || {}; data = data || {};
// copy original event properties over to the new event // copy original event properties over to the new event
// this would happen if we could call $.event.fix instead of $.Event // this would happen if we could call $.event.fix instead of $.Event
// but we don't have a way to force an event to be fixed multiple times // but we don't have a way to force an event to be fixed multiple times
if ( event.originalEvent ) { if ( event.originalEvent ) {
for ( var i = $.event.props.length, prop; i; ) { for ( var i = $.event.props.length, prop; i; ) {
prop = $.event.props[ --i ]; prop = $.event.props[ --i ];
event[ prop ] = event.originalEvent[ prop ]; event[ prop ] = event.originalEvent[ prop ];
} }
} }
this.element.trigger( event, data ); this.element.trigger( event, data );
return !( $.isFunction(callback) && return !( $.isFunction(callback) &&
callback.call( this.element[0], event, data ) === false || callback.call( this.element[0], event, data ) === false ||
event.isDefaultPrevented() ); event.isDefaultPrevented() );
} }
}; };
})( jQuery ); })( jQuery );

View file

@ -1,75 +1,75 @@
/** /**
* @author trixta * @author trixta
*/ */
(function($){ (function($){
$.userMode = (function(){ $.userMode = (function(){
var userBg, var userBg,
timer, timer,
testDiv, testDiv,
boundEvents = 0; boundEvents = 0;
function testBg(){ function testBg(){
testDiv = testDiv || $('<div></div>').css({position: 'absolute', left: '-999em', top: '-999px', width: '0px', height: '0px'}).appendTo('body'); testDiv = testDiv || $('<div></div>').css({position: 'absolute', left: '-999em', top: '-999px', width: '0px', height: '0px'}).appendTo('body');
var black = $.curCSS( testDiv.css({backgroundColor: '#000000'})[0], 'backgroundColor', true), var black = $.curCSS( testDiv.css({backgroundColor: '#000000'})[0], 'backgroundColor', true),
white = $.curCSS( testDiv.css({backgroundColor: '#ffffff'})[0], 'backgroundColor', true), white = $.curCSS( testDiv.css({backgroundColor: '#ffffff'})[0], 'backgroundColor', true),
newBgStatus = (black === white || white === 'transparent'); newBgStatus = (black === white || white === 'transparent');
if(newBgStatus != userBg){ if(newBgStatus != userBg){
userBg = newBgStatus; userBg = newBgStatus;
$.event.trigger('_internalusermode'); $.event.trigger('_internalusermode');
} }
return userBg; return userBg;
} }
function init(){ function init(){
testBg(); testBg();
timer = setInterval(testBg, 3000); timer = setInterval(testBg, 3000);
} }
function stop(){ function stop(){
clearInterval(timer); clearInterval(timer);
testDiv.remove(); testDiv.remove();
testDiv = null; testDiv = null;
} }
$.event.special.usermode = { $.event.special.usermode = {
setup: function(){ setup: function(){
(!boundEvents && init()); (!boundEvents && init());
boundEvents++; boundEvents++;
var jElem = $(this) var jElem = $(this)
.bind('_internalusermode', $.event.special.usermode.handler); .bind('_internalusermode', $.event.special.usermode.handler);
//always trigger //always trigger
setTimeout(function(){ setTimeout(function(){
jElem.triggerHandler('_internalusermode'); jElem.triggerHandler('_internalusermode');
}, 1); }, 1);
return true; return true;
}, },
teardown: function(){ teardown: function(){
boundEvents--; boundEvents--;
(!boundEvents && stop()); (!boundEvents && stop());
$(this).unbind('_internalusermode', $.event.special.usermode.handler); $(this).unbind('_internalusermode', $.event.special.usermode.handler);
return true; return true;
}, },
handler: function(e){ handler: function(e){
e.type = 'usermode'; e.type = 'usermode';
e.disabled = !userBg; e.disabled = !userBg;
e.enabled = userBg; e.enabled = userBg;
return jQuery.event.handle.apply(this, arguments); return jQuery.event.handle.apply(this, arguments);
} }
}; };
return { return {
get: testBg get: testBg
}; };
})(); })();
$.fn.userMode = function(fn){ $.fn.userMode = function(fn){
return this[(fn) ? 'bind' : 'trigger']('usermode', fn); return this[(fn) ? 'bind' : 'trigger']('usermode', fn);
}; };
$(function(){ $(function(){
$('html').userMode(function(e){ $('html').userMode(function(e){
$('html')[e.enabled ? 'addClass' : 'removeClass']('hcm'); $('html')[e.enabled ? 'addClass' : 'removeClass']('hcm');
}); });
}); });
})(jQuery); })(jQuery);

View file

@ -1,276 +1,276 @@
/** /**
* @author alexander.farkas * @author alexander.farkas
* @version 1.4.3 * @version 1.4.3
*/ */
(function($){ (function($){
var supportsValidity; var supportsValidity;
(function(){ (function(){
if(!$.prop || supportsValidity){return;} if(!$.prop || supportsValidity){return;}
var supportTest = function(){ var supportTest = function(){
supportsValidity = !!$('<input />').prop('validity'); supportsValidity = !!$('<input />').prop('validity');
}; };
supportTest(); supportTest();
$(supportTest); $(supportTest);
})(); })();
$.widget('ui.checkBox', { $.widget('ui.checkBox', {
options: { options: {
hideInput: true, hideInput: true,
addVisualElement: true, addVisualElement: true,
addLabel: true addLabel: true
}, },
_create: function(){ _create: function(){
var that = this, var that = this,
opts = this.options opts = this.options
; ;
if(!this.element.is(':radio,:checkbox')){ if(!this.element.is(':radio,:checkbox')){
if(this.element[0].elements && $.nodeName(this.element[0], 'form')){ if(this.element[0].elements && $.nodeName(this.element[0], 'form')){
$(this.element[0].elements).filter(':radio,:checkbox').checkBox(opts); $(this.element[0].elements).filter(':radio,:checkbox').checkBox(opts);
} }
return false; return false;
} }
this._proxiedReflectUI = $.proxy(this, 'reflectUI'); this._proxiedReflectUI = $.proxy(this, 'reflectUI');
this.labels = $([]); this.labels = $([]);
this.checkedStatus = false; this.checkedStatus = false;
this.disabledStatus = false; this.disabledStatus = false;
this.hoverStatus = false; this.hoverStatus = false;
this.inputType = this.element[0].type; this.inputType = this.element[0].type;
this.radio = this.inputType == 'radio'; this.radio = this.inputType == 'radio';
this.visualElement = $([]); this.visualElement = $([]);
if (opts.hideInput) { if (opts.hideInput) {
this.element.addClass('ui-helper-hidden-accessible'); this.element.addClass('ui-helper-hidden-accessible');
if(opts.addVisualElement){ if(opts.addVisualElement){
this.visualElement = $('<span />') this.visualElement = $('<span />')
.addClass('ui-'+this.inputType) .addClass('ui-'+this.inputType)
; ;
this.element.after(this.visualElement[0]); this.element.after(this.visualElement[0]);
} }
} }
if(opts.addLabel){ if(opts.addLabel){
var id = this.element[0].id; var id = this.element[0].id;
if(id){ if(id){
this.labels = $('label[for="' + id + '"]', this.element[0].form || this.element[0].ownerDocument).add(this.element.parent('label')); this.labels = $('label[for="' + id + '"]', this.element[0].form || this.element[0].ownerDocument).add(this.element.parent('label'));
} }
if(!this.labels[0]){ if(!this.labels[0]){
this.labels = this.element.closest('label', this.element[0].form); this.labels = this.element.closest('label', this.element[0].form);
} }
this.labels.addClass(this.radio ? 'ui-radio' : 'ui-checkbox'); this.labels.addClass(this.radio ? 'ui-radio' : 'ui-checkbox');
} }
this.visualGroup = this.visualElement.add(this.labels); this.visualGroup = this.visualElement.add(this.labels);
this._addEvents(); this._addEvents();
this.initialized = true; this.initialized = true;
this.reflectUI({type: 'initialreflect'}); this.reflectUI({type: 'initialreflect'});
return undefined; return undefined;
}, },
_addEvents: function(){ _addEvents: function(){
var that = this, var that = this,
opts = this.options, opts = this.options,
toggleHover = function(e){ toggleHover = function(e){
if(that.disabledStatus){ if(that.disabledStatus){
return false; return false;
} }
that.hover = (e.type == 'focus' || e.type == 'mouseenter'); that.hover = (e.type == 'focus' || e.type == 'mouseenter');
if(e.type == 'focus'){ if(e.type == 'focus'){
that.visualGroup.addClass(that.inputType +'-focused'); that.visualGroup.addClass(that.inputType +'-focused');
} else if(e.type == 'blur'){ } else if(e.type == 'blur'){
that.visualGroup.removeClass(that.inputType +'-focused'); that.visualGroup.removeClass(that.inputType +'-focused');
} }
that._changeStateClassChain(); that._changeStateClassChain();
return undefined; return undefined;
} }
; ;
this.element this.element
.bind('click.checkBox invalid.checkBox', this._proxiedReflectUI) .bind('click.checkBox invalid.checkBox', this._proxiedReflectUI)
.bind('focus.checkBox blur.checkBox', toggleHover) .bind('focus.checkBox blur.checkBox', toggleHover)
; ;
if (opts.hideInput){ if (opts.hideInput){
this.element this.element
.bind('usermode', function(e){ .bind('usermode', function(e){
(e.enabled && (e.enabled &&
that.destroy.call(that, true)); that.destroy.call(that, true));
}) })
; ;
} }
if(opts.addVisualElement){ if(opts.addVisualElement){
this.visualElement this.visualElement
.bind('click.checkBox', function(e){ .bind('click.checkBox', function(e){
that.element[0].click(); that.element[0].click();
return false; return false;
}) })
; ;
} }
this.visualGroup.bind('mouseenter.checkBox mouseleave.checkBox', toggleHover); this.visualGroup.bind('mouseenter.checkBox mouseleave.checkBox', toggleHover);
}, },
_changeStateClassChain: function(){ _changeStateClassChain: function(){
var allElements = this.labels.add(this.visualElement), var allElements = this.labels.add(this.visualElement),
stateClass = '', stateClass = '',
baseClass = 'ui-'+ this.inputType baseClass = 'ui-'+ this.inputType
; ;
if(this.checkedStatus){ if(this.checkedStatus){
stateClass += '-checked'; stateClass += '-checked';
allElements.addClass(baseClass+'-checked'); allElements.addClass(baseClass+'-checked');
} else { } else {
allElements.removeClass(baseClass+'-checked'); allElements.removeClass(baseClass+'-checked');
} }
if(this.disabledStatus){ if(this.disabledStatus){
stateClass += '-disabled'; stateClass += '-disabled';
allElements.addClass(baseClass+'-disabled'); allElements.addClass(baseClass+'-disabled');
} else { } else {
allElements.removeClass(baseClass+'-disabled'); allElements.removeClass(baseClass+'-disabled');
} }
if(this.hover){ if(this.hover){
stateClass += '-hover'; stateClass += '-hover';
allElements.addClass(baseClass+'-hover'); allElements.addClass(baseClass+'-hover');
} else { } else {
allElements.removeClass(baseClass+'-hover'); allElements.removeClass(baseClass+'-hover');
} }
baseClass += '-state'; baseClass += '-state';
if(stateClass){ if(stateClass){
stateClass = baseClass + stateClass; stateClass = baseClass + stateClass;
} }
function switchStateClass(){ function switchStateClass(){
var classes = this.className.split(' '), var classes = this.className.split(' '),
found = false; found = false;
$.each(classes, function(i, classN){ $.each(classes, function(i, classN){
if(classN.indexOf(baseClass) === 0){ if(classN.indexOf(baseClass) === 0){
found = true; found = true;
classes[i] = stateClass; classes[i] = stateClass;
return false; return false;
} }
return undefined; return undefined;
}); });
if(!found){ if(!found){
classes.push(stateClass); classes.push(stateClass);
} }
this.className = classes.join(' '); this.className = classes.join(' ');
} }
this.visualGroup.each(switchStateClass); this.visualGroup.each(switchStateClass);
}, },
destroy: function(onlyCss){ destroy: function(onlyCss){
this.element.removeClass('ui-helper-hidden-accessible'); this.element.removeClass('ui-helper-hidden-accessible');
this.visualElement.addClass('ui-helper-hidden'); this.visualElement.addClass('ui-helper-hidden');
if (!onlyCss) { if (!onlyCss) {
var o = this.options; var o = this.options;
this.element.unbind('.checkBox'); this.element.unbind('.checkBox');
this.visualElement.remove(); this.visualElement.remove();
this.labels this.labels
.unbind('.checkBox') .unbind('.checkBox')
.removeClass('ui-state-hover ui-state-checked ui-state-disabled') .removeClass('ui-state-hover ui-state-checked ui-state-disabled')
; ;
} }
}, },
disable: function(status){ disable: function(status){
if(status === undefined){ if(status === undefined){
status = true; status = true;
} }
this.element[0].disabled = status; this.element[0].disabled = status;
this.reflectUI({type: 'manuallydisabled'}); this.reflectUI({type: 'manuallydisabled'});
}, },
enable: function(){ enable: function(){
this.element[0].disabled = false; this.element[0].disabled = false;
this.reflectUI({type: 'manuallyenabled'}); this.reflectUI({type: 'manuallyenabled'});
}, },
toggle: function(e){ toggle: function(e){
this.changeCheckStatus(!(this.element.is(':checked')), e); this.changeCheckStatus(!(this.element.is(':checked')), e);
}, },
changeCheckStatus: function(status, e){ changeCheckStatus: function(status, e){
if(e && e.type == 'click' && this.element[0].disabled){ if(e && e.type == 'click' && this.element[0].disabled){
return false; return false;
} }
this.element[0].checked = !!status; this.element[0].checked = !!status;
this.reflectUI(e || { this.reflectUI(e || {
type: 'changecheckstatus' type: 'changecheckstatus'
}); });
return undefined; return undefined;
}, },
propagate: function(n, e, _noGroupReflect){ propagate: function(n, e, _noGroupReflect){
if(!e || e.type != 'initialreflect'){ if(!e || e.type != 'initialreflect'){
if (this.radio && !_noGroupReflect) { if (this.radio && !_noGroupReflect) {
var elem = this.element[0]; var elem = this.element[0];
//dynamic //dynamic
$('[name="'+ elem.name +'"]', elem.form || elem.ownerDocument).checkBox('reflectUI', e, true); $('[name="'+ elem.name +'"]', elem.form || elem.ownerDocument).checkBox('reflectUI', e, true);
} }
return this._trigger(n, e, { return this._trigger(n, e, {
options: this.options, options: this.options,
checked: this.checkedStatus, checked: this.checkedStatus,
labels: this.labels, labels: this.labels,
disabled: this.disabledStatus disabled: this.disabledStatus
}); });
} }
return undefined; return undefined;
}, },
changeValidityState: function(){ changeValidityState: function(){
if(supportsValidity){ if(supportsValidity){
this.visualGroup[ !this.element.prop('willValidate') || (this.element.prop('validity') || {valid: true}).valid ? 'removeClass' : 'addClass' ](this.inputType +'-invalid'); this.visualGroup[ !this.element.prop('willValidate') || (this.element.prop('validity') || {valid: true}).valid ? 'removeClass' : 'addClass' ](this.inputType +'-invalid');
} }
}, },
reflectUI: function(e){ reflectUI: function(e){
var oldChecked = this.checkedStatus, var oldChecked = this.checkedStatus,
oldDisabledStatus = this.disabledStatus oldDisabledStatus = this.disabledStatus
; ;
this.disabledStatus = this.element.is(':disabled'); this.disabledStatus = this.element.is(':disabled');
this.checkedStatus = this.element.is(':checked'); this.checkedStatus = this.element.is(':checked');
if(!e || e.type !== 'initialreflect'){ if(!e || e.type !== 'initialreflect'){
this.changeValidityState(); this.changeValidityState();
} }
if (this.disabledStatus != oldDisabledStatus || this.checkedStatus !== oldChecked) { if (this.disabledStatus != oldDisabledStatus || this.checkedStatus !== oldChecked) {
this._changeStateClassChain(); this._changeStateClassChain();
(this.disabledStatus != oldDisabledStatus && (this.disabledStatus != oldDisabledStatus &&
this.propagate('disabledchange', e)); this.propagate('disabledchange', e));
(this.checkedStatus !== oldChecked && (this.checkedStatus !== oldChecked &&
this.propagate('change', e)); this.propagate('change', e));
} }
} }
}); });
if($.propHooks){ if($.propHooks){
$.each({checked: 'changeCheckStatus', disabled: 'disable'}, function(name, fn){ $.each({checked: 'changeCheckStatus', disabled: 'disable'}, function(name, fn){
//be hook friendly //be hook friendly
if(!$.propHooks[name]){ if(!$.propHooks[name]){
$.propHooks[name] = {}; $.propHooks[name] = {};
} }
var oldSetHook = $.propHooks[name].set; var oldSetHook = $.propHooks[name].set;
$.propHooks[name].set = function(elem, value){ $.propHooks[name].set = function(elem, value){
var widget = $.data(elem, 'checkBox'); var widget = $.data(elem, 'checkBox');
if(widget){ if(widget){
widget[fn](!!value); widget[fn](!!value);
} }
return oldSetHook && oldSetHook(elem, value) ; return oldSetHook && oldSetHook(elem, value) ;
}; };
}); });
} }
})(jQuery); })(jQuery);

View file

@ -44,20 +44,22 @@ App.Templates.html = {
'<div id="change-psw-block" class="page2">\ '<div id="change-psw-block" class="page2">\
<div class="b-auth-form">\ <div class="b-auth-form">\
<div class="b-auth-form-wrap">\ <div class="b-auth-form-wrap">\
<a href="/">\
<img width="72" height="24" alt="" src="~!:LOGO_URL~!" class="vesta-logo">\ <img width="72" height="24" alt="" src="~!:LOGO_URL~!" class="vesta-logo">\
</a>\
<span style="color: #5E696B; float: right; margin-top: -48px;">~!:VERSION~!</span>\ <span style="color: #5E696B; float: right; margin-top: -48px;">~!:VERSION~!</span>\
<div class="b-client-title">\ <div class="b-client-title">\
<span class="client-title-wrap">~!:PRODUCT_NAME~!<i class="planets">&nbsp;</i></span>\ <span class="client-title-wrap">~!:PRODUCT_NAME~!<i class="planets">&nbsp;</i></span>\
</div>\ </div>\
<form id="change_psw-form" method="post" action="#" class="auth">\ <form id="change_psw-form" method="post" action="#" class="auth">\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="change-email" class="field-label">Email</label>\ <label for="change-login" class="field-label">Login</label>\
<input type="text" tabindex="1" id="change-email" class="field-text">\ <input type="text" tabindex="1" id="change-login" class="field-text">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="captcha" class="field-label">Captcha</label>\ <label for="captcha" class="field-label">Captcha</label>\
<label class="captcha"><img id="captcha-img" width="127px;" src="~!:CAPTCHA_URL~!" style="cursor: pointer; float: left; margin-top: -7px; padding-left: 20px;" onClick="this.src = \'~!:CAPTCHA_URL_2~!?\'+Math.floor(Math.random() * 9999)"/></label>\ <label class="captcha"><img id="captcha-img" width="127px;" src="~!:CAPTCHA_URL~!" style="cursor: pointer; float: left; margin-top: -7px; padding-left: 20px;" onClick="this.src = \'~!:CAPTCHA_URL_2~!?\'+Math.floor(Math.random() * 9999)"/></label>\
<input type="text" id="captcha" class="field-text" style="margin-left: 11px; width: 132px; margin-bottom: 27px;">\ <input type="text" id="captcha" tabindex=2 class="field-text" style="margin-left: 11px; width: 132px; margin-bottom: 27px;">\
</div>\ </div>\
<div id="change-psw-success" class="success-box hidden"></div>\ <div id="change-psw-success" class="success-box hidden"></div>\
<div id="change-psw-error" class="error-box hidden"></div>\ <div id="change-psw-error" class="error-box hidden"></div>\
@ -65,7 +67,7 @@ App.Templates.html = {
<div class="b-remember">\ <div class="b-remember">\
<span class="remember-me">&nbsp;</span>\ <span class="remember-me">&nbsp;</span>\
</div>\ </div>\
<input type="submit" tabindex="4" value="Send confirmation" class="sumbit-btn do_action_do_change_password">\ <input type="submit" tabindex="3" value="Send confirmation" class="sumbit-btn do_action_do_change_password">\
</div>\ </div>\
</form>\ </form>\
<p class="forgot-pwd"><a href="#" class="forgot-pwd-url do_action_back_to_login">Back to login?</a></p>\ <p class="forgot-pwd"><a href="#" class="forgot-pwd-url do_action_back_to_login">Back to login?</a></p>\
@ -80,7 +82,9 @@ App.Templates.html = {
login: ['<div id="auth-block" class="page2">\ login: ['<div id="auth-block" class="page2">\
<div class="b-auth-form">\ <div class="b-auth-form">\
<div class="b-auth-form-wrap">\ <div class="b-auth-form-wrap">\
<a href="/">\
<img width="72" height="24" alt="" src="~!:LOGO_URL~!" class="vesta-logo">\ <img width="72" height="24" alt="" src="~!:LOGO_URL~!" class="vesta-logo">\
</a>\
<span style="color: #5E696B; float: right; margin-top: -48px;">~!:VERSION~!</span>\ <span style="color: #5E696B; float: right; margin-top: -48px;">~!:VERSION~!</span>\
<div class="b-client-title">\ <div class="b-client-title">\
<span class="client-title-wrap">~!:PRODUCT_NAME~!<i class="planets">&nbsp;</i></span>\ <span class="client-title-wrap">~!:PRODUCT_NAME~!<i class="planets">&nbsp;</i></span>\

View file

@ -1,3 +1,3 @@
$(document).ready(function(){ $(document).ready(function(){
$('.cust-checkbox').checkBox(); $('.cust-checkbox').checkBox();
}); });

View file

@ -126,18 +126,18 @@ App.Templates.html = {
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<input type="hidden" value="~!:DATE~!" name="DATE">\ <input type="hidden" value="~!:DATE~!" name="DATE">\
<label for="#" class="field-label">Domain:</label>\ <label for="dns-domain" class="field-label"><span class="mandatory">Domain:</span></label>\
<input type="text" name="DNS_DOMAIN" value="~!:DNS_DOMAIN~!" class="text-field rule-required rule-domain">\ <input type="text" id="dns-domain" name="DNS_DOMAIN" value="~!:DNS_DOMAIN~!" class="text-field rule-required rule-domain">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">IP:</label>\ <label for="ip" class="field-label"><span class="mandatory">IP:</span></label>\
<div class="autocomplete-box">\ <div class="autocomplete-box">\
<input type="text" name="IP" value="~!:IP~!" class="text-field rule-required rule-ip">\ <input type="text" id="ip" name="IP" value="~!:IP~!" class="text-field rule-required rule-ip">\
<i class="arrow">&nbsp;</i>\ <i class="arrow">&nbsp;</i>\
</div>\ </div>\
</div>\ </div>\
<div class="form-row dns-template-box cc">\ <div class="form-row dns-template-box cc">\
<label for="#" class="field-label">Template:</label>\ <label for="selecttemplate" class="field-label">Template:</label>\
<span class="select" id="selecttemplate">~!:TPL_DEFAULT_VALUE~! t </span>\ <span class="select" id="selecttemplate">~!:TPL_DEFAULT_VALUE~! t </span>\
<select name="TPL" class="styled tpl-item">\ <select name="TPL" class="styled tpl-item">\
~!:TPL~!\ ~!:TPL~!\
@ -149,8 +149,8 @@ App.Templates.html = {
<input type="text" value="~!:TTL~!" name="TTL" class="text-field ttl-field rule-required rule-numeric">\ <input type="text" value="~!:TTL~!" name="TTL" class="text-field ttl-field rule-required rule-numeric">\
</div>\ </div>\
<div class="form-row cc">\ <div class="form-row cc">\
<label for="#" class="field-label">SOA:</label>\ <label for="soa" class="field-label"><span class="mandatory">SOA:</span></label>\
<input type="text" value="~!:SOA~!" name="SOA" class="text-field rule-required rule-ns">\ <input type="text" value="~!:SOA~!" id="soa" name="SOA" class="text-field rule-required rule-ns">\
</div -->\ </div -->\
<div class="form-row suspended cc">\ <div class="form-row suspended cc">\
<label for="#" class="field-label">Suspended:</label>\ <label for="#" class="field-label">Suspended:</label>\
@ -584,8 +584,8 @@ App.Templates.html = {
<span class="prop-value">~!:SHELL~!</span>\ <span class="prop-value">~!:SHELL~!</span>\
</span>\ </span>\
<span class="prop-box backups-box">\ <span class="prop-box backups-box">\
<span class="prop-title">backups:</span>\ <span class="prop-title">backup retention:</span>\
<span class="prop-value">retention ~!:BACKUPS~!</span>\ <span class="prop-value">~!:BACKUPS~!</span>\
</span>\ </div>\ </span>\ </div>\
</div><!-- // .row-details -->\ </div><!-- // .row-details -->\
</div>'] </div>']

View file

@ -1,3 +1,4 @@
<? <?php
phpinfo(); echo "<pre>\n";
?> exec('sudo /usr/local/vesta/bin/v_list_users json', $out);
print_r($out);

View file

@ -44,26 +44,26 @@ class MAIN extends AjaxHandler
return $this->reply(false, null, 'Captcha is invalid '); return $this->reply(false, null, 'Captcha is invalid ');
} }
$users = Vesta::execute(Vesta::V_LIST_SYS_USERS, 'json'); $cmd = Config::get('sudo_path')." ".Config::get('vesta_functions_path').Vesta::V_LIST_SYS_USERS." 'json'";
$email_matched_count = array(); exec($cmd, $output, $return);
if (!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$request->getParameter('email'))) { $users = json_decode(implode('', $output), true);
return $this->reply(false, null, 'Email is invalid');
} $login_matched_count = array();
foreach ($users['data'] as $user) { foreach ($users as $user => $data) {
if ($user['CONTACT'] == trim($request->getParameter('email'))) { if ($user == trim($request->getParameter('login'))) {
$email_matched_count[] = $user; $login_matched_count[$user] = $data;
} }
} }
if (empty($email_matched_count)) { if (empty($login_matched_count)) {
return $this->reply(false, null, 'There is no such user.'); return $this->reply(false, null, 'There is no such user.');
} }
foreach ($email_matched_count as $reset_user) { foreach ($login_matched_count as $reset_user => $data) {
$secret_key = $reset_user['RKEY']; $secret_key = $data['RKEY'];
$reset_link = 'https://'.$_SERVER['HTTP_HOST'].'/change_password.php?v='.$secret_key; $reset_link = 'https://'.$_SERVER['HTTP_HOST'].'/change_password.php?v='.$secret_key;
$mail_body = <<<MAIL $mail_body = <<<MAIL
@ -73,7 +73,7 @@ class MAIN extends AjaxHandler
</a> </a>
<div style="font-family:'Helvetica Neue', Arial, Helvetica, sans-serif;font-size:13px;margin:14px"> <div style="font-family:'Helvetica Neue', Arial, Helvetica, sans-serif;font-size:13px;margin:14px">
<h2 style="font-family:'Helvetica Neue', Arial, Helvetica, sans-serif;margin:0 0 16px;font-size:18px;font-weight:normal"> <h2 style="font-family:'Helvetica Neue', Arial, Helvetica, sans-serif;margin:0 0 16px;font-size:18px;font-weight:normal">
Vesta received a request to reset the password for your account {$reset_user['FNAME']} {$reset_user['LNAME']}? Vesta received a request to reset the password for your account {$data['FNAME']} {$data['LNAME']}?
</h2> </h2>
<p> <p>
If you want to reset your password, click on the link below (or copy and paste the URL into your browser):<br> If you want to reset your password, click on the link below (or copy and paste the URL into your browser):<br>
@ -94,9 +94,9 @@ class MAIN extends AjaxHandler
</div> </div>
MAIL; MAIL;
$headers = 'MIME-Version: 1.0' . "\n"; $headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\n";
$to = $request->getParameter('email'); $to = $data['CONTACT'];
$subject = 'Reset your Vesta password'; $subject = 'Reset your Vesta password';
$message = $mail_body; $message = $mail_body;
mail($to, $subject, $message, $headers); mail($to, $subject, $message, $headers);

View file

@ -208,7 +208,7 @@ class Vesta
} }
else { else {
$result['data'] = json_decode(implode('', $output), true); $result['data'] = json_decode(implode('', $output), true);
} }
return $result; return $result;
} }

View file

@ -61,14 +61,12 @@ class VestaSession
public function getUserRole() public function getUserRole()
{ {
// if (isset($_SESSION['user'])) { if($_SESSION['user'] == 'vesta'){
if($_SESSION['user'] == 'vesta'){ return Vesta::ADMIN;
return Vesta::ADMIN; }
} else{
else{ return Vesta::USER;
return Vesta::USER; }
}
// }
print json_encode(array('result' => "NOT_AUTHORISED")); print json_encode(array('result' => "NOT_AUTHORISED"));
exit; exit;