Current File : //etc/zpanel/panel/modules/mysql_users/module.zpm |
<style>
#register .short{
font-weight:bold;
color:#FF0000;
font-size:larger;
}
#register .weak{
font-weight:bold;
color:orange;
font-size:larger;
}
#register .good{
font-weight:bold;
color:#2D98F3;
font-size:larger;
}
#register .strong{
font-weight:bold;
color: limegreen;
font-size:larger;
}
</style>
<style>
.helpicon {
display: block;
float: right;
border: 1px solid #ccc;
background-color: #f3f3f3;
padding: 5px 10px;
font-size: 12px;
margin-top:-80px;
margin-right:6px;
-webkit-box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
-moz-box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
-webkit-box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
-moz-box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
}
</style>
<div class="zmodule_content panel" id="zmodule_header_<@ ModuleName @>">
<div class="panel-heading">
<img src="<@ ModuleIcon @>" width="35" height="35" border="0" alt="<@ ModuleName @>">
<div class="zmodule_title">
<@ ModuleName @>
</div>
<div class="zmodule_desc" id="zmodule_desc_<@ ModuleName @>"><@ ModuleDesc @></div>
</div>
<div class="helpicon">
<a href="<@ helpicon @>" target="_blank"><img src="etc/styles/CstyleX-master/images/help.png" style="float:left;" ><span style="float:left;margin-top:8px;font-weight:bold;font-size:12px;" >Video Tutorial</span></a>
</div>
<@ Result @>
<% if isDeleteUser %>
<div class="zform_wrapper alert alert-danger">
<h2><: Delete User :>: <@ EditCurrentUserName @> ?</h2>
<p><: Please confirm that you want to delete this MySQL user. :></p>
<form action="./?module=mysql_users&action=ConfirmDeleteUser" method="post">
<table class="none" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" align="right">
<input type="hidden" name="inDelete" value="<@ EditCurrentUserID @>">
<button class="button-loader delete btn btn-danger" type="submit" ><: Delete :></button>
<button class="button-loader btn btn-default" type="button" onclick="window.location.href='./?module=mysql_users';return false;"><: Cancel :></button>
</td>
</tr>
</table>
<@ CSFR_Tag @>
</form>
</div>
<% endif %>
<% if isRemoveDb %>
<div class="zform_wrapper alert alert-danger">
<h2><: Remove Database :>: <@ ManageUserDatabaseName @> ?</h2>
<p><: Please confirm that you want to remove the database from this MySQL user. :></p>
<form action="./?module=mysql_users&action=ConfirmRemoveDb" method="post">
<table class="none" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" align="right">
<input type="hidden" name="inUser" value="<@ ManageUserName @>">
<input type="hidden" name="inRemoveDb" value="<@ RemoveDbId @>">
<button class="button-loader delete btn btn-danger" type="submit" ><: Delete :></button>
<button class="button-loader btn btn-default" type="button" onclick="window.location.href='./?module=mysql_users';return false;"><: Cancel :></button>
</td>
</tr>
</table>
<@ CSFR_Tag @>
</form>
</div>
<% endif %>
<% if isManageUser %>
<h2><: Manage User Privileges :></h2>
<h4>User : <@ ManageUserName @> </h4>
<h4>Database : <@ ManageUserDatabaseName @> </h4>
<@ ManagePrivileges @>
<% endif %>
<% if isEditUser %>
<div class="zgrid_wrapper">
<h2><: Databases for user :>: <@ EditCurrentUserName @></h2>
<% if UserDatabaseList %>
<form action="./?module=mysql_users&action=RemoveDB" method="post">
<table class="table table-striped">
<tr>
<th><: Database name :></th>
<th><: Manage users :></th>
</tr>
<% loop UserDatabaseList %>
<tr>
<td><& mmdbname &></td>
<td><button class="button-loader btn btn-default" type="submit" name="inManage_<& mmid &>" id="inManage_<& mmid &>" value="<& mmid &>"><: Manage Privileges :></button><button class="button-loader delete btn btn-danger" type="submit" name="inRemove_<& mmid &>" id="inRemove_<& mmid &>" value="<& mmid &>"><: Remove database :></button></td>
</tr>
<% endloop %>
<input type="hidden" name="inUser" value="<@ EditCurrentUserID @>">
</table>
<@ CSFR_Tag @>
</form>
<% else %>
<: This user currently has no databases. Assign a database using the form below. :>
<% endif %>
<p> </p>
<h2><: Add Database :></h2>
<form action="./?module=mysql_users&action=AddDB" method="post">
<table class="table table-striped">
<tr>
<th nowrap="nowrap"><: Database :>:</th>
<td width="150px">
<select name="inDatabase" id="inDatabase">
<option value="" selected="selected">-- Select a database --</option>
<% if DatabaseList %>
<% loop DatabaseList %>
<option value="<& mysqlid &>"><& mysqlname &></option>
<% endloop %>
<% endif %>
</select>
</td>
<td>
<input type="hidden" name="inUser" value="<@ EditCurrentUserID @>">
<button class="button-loader btn btn-primary" type="submit" ><: Add Database :></button>
</td>
</tr>
</table>
<@ CSFR_Tag @>
</form>
<p> </p>
<h2><: Reset Password :></h2>
<form action="./?module=mysql_users&action=ResetPW" method="post" id="register">
<table class="zform">
<tr>
<th nowrap="nowrap"><: Password :>:</th>
<td width="150px">
<input type="text" name="inResetPW" id="<@ CurrentID @>" value="">
</td>
<td>
<input type="hidden" name="inUser" value="<@ EditCurrentUserID @>">
<button class="button-loader btn btn-primary" id="pwdstr" type="submit" ><: Save :></button></td>
<td> <button class="button-loader btn btn-default" type="button" onclick="window.location.href='./?module=mysql_users';return false;"><: Cancel :></button>
</td>
</tr>
<tr>
<th></th>
<td><span id="result"></span></td>
<td><a href="#" class="link-password" id="generate"><@ GeneratePass @></a></td>
<td></td>
</tr>
</table>
<@ CSFR_Tag @>
</form>
<% if currentnote %>
<p><b>Note : </b>Characters needed for password length : 9 with atleast 1 uppercase,lowercase,special character,number.</p>
<% endif %>
</div>
<% endif %>
<div class="zgrid_wrapper">
<h2><: Current MySQL® Users :></h2>
<% if UserList %>
<form action="./?module=mysql_users&action=EditUser" method="post">
<table class="table table-striped">
<tr>
<th><: User name :></th>
<th><: Access :></th>
<th><: Databases :></th>
<th><: Password :></th>
<th></th>
</tr>
<% loop UserList %>
<tr>
<td><& username &></td>
<td><& accesshtml &></td>
<td><& totaldb &></td>
<td><& dbpassword &></td>
<td>
<button class="button-loader btn btn-default" type="submit" name="inEdit_<& userid &>" id="inEdit_<& userid &>" value="<& userid &>"><: Edit :></button><button class="button-loader delete btn btn-danger" type="submit" name="inDelete_<& userid &>" id="inDelete_<& userid &>" value="<& userid &>"><: Delete :></button>
</td>
</tr>
<% endloop %>
</table>
<@ CSFR_Tag @>
</form>
<% else %>
<: You have no MySQL® users at this time. Create a user using the form below. :>
<% endif %>
</div>
<% if isCreateUser %>
<div class="zform_wrapper">
<table class="none" width="100%" cellborder="0" cellspacing="0">
<tr valign="top">
<td>
<h2><: Create a new MySQL® User :></h2>
<form action="./?module=mysql_users&action=CreateUser" method="post">
<table class="table table-striped">
<tr>
<th nowrap="nowrap"><: User name :>:</th>
<td nowrap="nowrap"><@ CurrentUserName @><input type="text" size="30" name="inUserName" id="inUserName" />
<input type="hidden" name="inprefix" value="<@ CurrentUserName @>" />
</td>
</tr>
<tr>
<th nowrap="nowrap"><: Map Database :>:</th>
<td>
<select name="inDatabase" id="inDatabase">
<option value="" selected="selected">-- Select a database --</option>
<% if DatabaseList %>
<% loop DatabaseList %>
<option value="<& mysqlid &>"><& mysqlname &></option>
<% endloop %>
<% endif %>
</select>
</td>
</tr>
<tr>
<th nowrap="nowrap"><: Remote Access :>:</th>
<td><input name="inAccess" type="radio" id="inAccess" value="1" onclick="hide_div('showaccess');" CHECKED /> <: Allow from localhost IP :></td>
</tr>
<tr>
<th> </th>
<td><input name="inAccess" type="radio" id="inAccess" value="2" onclick="show_div('showaccess');" /> <: Only from single IP :></td>
</tr>
<tr>
<th> </th>
<td>
<div id="showaccess" style="display:none;">
<input type="text" size="30" name="inAccessIP" id="inAccessIP" />
</div>
</td>
</tr>
<tr>
</table>
<@ ManagePrivileges @>
<td align="right"><@ MysqlUsagepChart @></td>
</tr>
<tr>
<th colspan="2" align="left">
<button class="button-loader btn btn-primary" type="submit" ><: Create :></button>
</th>
</tr>
<@ CSFR_Tag @>
</form>
<% if currentnote %>
<p><b>Note : </b>Characters needed for password length : 9 with atleast 1 uppercase,lowercase,special character,number.</p>
<% endif %>
</td>
</tr></table>
</div>
<% endif %>
</div>
<script type="text/javascript">
<!--
function show_div(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
}
//-->
</script>
<script type="text/javascript">
<!--
function hide_div(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
}
//-->
</script>
<script type="text/JavaScript">
$.extend({
password: function (length, special) {
var iteration = 0;
var password = "";
var specials = '!@#$&*_';
var lowercase = 'abcdefghijklmnopqrstuvwxyz';
var uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var numbers = '0123456789';
var all = specials + lowercase + uppercase + numbers;
String.prototype.pick = function(min, max) {
var n, chars = '';
if (typeof max === 'undefined') {
n = min;
} else {
n = min + Math.floor(Math.random() * (max - min));
}
for (var i = 0; i < n; i++) {
chars += this.charAt(Math.floor(Math.random() * this.length));
}
return chars;
};
// Credit to @Christoph: http://stackoverflow.com/a/962890/464744
String.prototype.shuffle = function() {
var array = this.split('');
var tmp, current, top = array.length;
if (top) while (--top) {
current = Math.floor(Math.random() * (top + 1));
tmp = array[current];
array[current] = array[top];
array[top] = tmp;
}
return array.join('');
};
var password = (specials.pick(1) + lowercase.pick(1) + uppercase.pick(1) + numbers.pick(1) + all.pick(5)).shuffle();
return password;
}
});
$(document).ready(function() {
});
</script>
<script>
/*
jQuery document ready.
*/
$(document).ready(function()
{
/*
assigning keyup event to password field
so everytime user type code will execute
*/
$('.link-password').click(function(e){
linkId = $(this).attr('id');
if (linkId == 'generate'){
password = $.password(9,false);
$('#input-password').val(password);
$('#result').html(checkStrength($('#input-password').val()));
}
e.preventDefault();
});
if($('#input-password').val().length ==0){
$('#pwdstr').attr('disabled', 'disabled');
}
$('#input-password').keyup(function()
{
$('#result').html(checkStrength($('#input-password').val()))
})
/*
checkStrength is function which will do the
main password strength checking for us
*/
function checkStrength(password)
{
//initial strength
var strength = 0
//if the password length is less than 6, return message.
if (password.length < 6) {
$('#result').removeClass();
$('#result').addClass('short');
$('#pwdstr').attr('disabled','disabled');
return 'Too short';
}
//length is ok, lets continue.
//if length is 8 characters or more, increase strength value
//if (password.length > 7) strength += 1
//if password contains both lower and uppercase characters, increase strength value
//if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) strength += 1
//if it has numbers and characters, increase strength value
//if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) strength += 1
//if it has one special character, increase strength value
//if (password.match(/([!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
//if it has two special characters, increase strength value
//if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
if(password.match(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{9,}$/))
strength = 9
//now we have calculated strength value, we can return messages
//if value is less than 2
if (strength <2 )
{
$('#result').removeClass();
$('#result').addClass('weak');
$('#pwdstr').attr('disabled','disabled');
return 'Weak'
}
else if (strength >= 9 )
{
$('#result').removeClass();
$('#result').addClass('strong');
// $("#pwdstr").show();
$('#pwdstr').removeAttr('disabled');
return 'Strong'
}
else
{
$('#result').removeClass();
$('#result').addClass('strong');
// $("#pwdstr").show();
$('#pwdstr').removeAttr('disabled');
return 'Strong'
}
}
});
function checkUncheckAll() {
var inputs = document.querySelectorAll('.privil_right');
var check_uncheck = document.getElementById('all_privi').checked;
for (var i = 0; i < inputs.length; i++) {
inputs[i].checked = check_uncheck;
}
}
function checkAnyone() {
var inputs = document.querySelectorAll('.privil_right');
//var check_uncheck = document.getElementById('all_privi').checked;
for (var i = 0; i < inputs.length; i++) {
if(inputs[i].checked== false)
{
document.getElementById('all_privi').checked = false;
}
}
}
(function() {
url = window.location.href;
var name = "show";
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
var results = regex ? regex.exec(url) : "";
results = results ? decodeURIComponent(results[2].replace(/\+/g, " ")) : "";
if(results =="Manage") {
document.getElementById('sub_priv').style.display = "";
} else {
document.getElementById('sub_priv').style.display = "none";
}
var inputs = document.querySelectorAll('.privil_right');
document.getElementById('all_privi').checked = true;
for (var i = 0; i < inputs.length; i++) {
if(inputs[i].checked== false)
{
document.getElementById('all_privi').checked = false;
}
}
})();
</script>