Saving properly works, login page updated

merge-requests/62/head
Mike Koch 7 years ago
parent 3a8d69b061
commit 57f9fdec63

@ -3815,7 +3815,7 @@ $modsForHesk_settings = mfh_getSettings();
<input title="LOGIN BACKGROUND COLOR" type="file" name="login-background-image" style="display: inline;vertical-align: bottom" <?php if ($modsForHesk_settings['login_background_type'] == 'color') { echo 'disabled'; } ?>> <input title="LOGIN BACKGROUND COLOR" type="file" name="login-background-image" style="display: inline;vertical-align: bottom" <?php if ($modsForHesk_settings['login_background_type'] == 'color') { echo 'disabled'; } ?>>
<?php if ($modsForHesk_settings['login_background_type'] == 'image'): ?> <?php if ($modsForHesk_settings['login_background_type'] == 'image'): ?>
<br> <br>
<img src="../<?php echo $hesk_settings['cache_dir']; ?>/login-background/<?php echo $modsForHesk_settings['login_background']; ?>" alt="Login Background" height="125" width="125" class="push-down-10"> <img src="../<?php echo $hesk_settings['cache_dir']; ?>/lb_<?php echo $modsForHesk_settings['login_background']; ?>" alt="Login Background" height="125" width="125" class="push-down-10">
<?php endif; ?> <?php endif; ?>
<script type="text/javascript"> <script type="text/javascript">
$('input[name="login-background-color"]').colorpicker({ $('input[name="login-background-color"]').colorpicker({

@ -500,7 +500,7 @@ $set['login_background_type'] = hesk_input(hesk_POST('login-background'));
$changedBackground = false; $changedBackground = false;
if ($set['login_background_type'] == 'color') { if ($set['login_background_type'] == 'color') {
unlink($hesk_settings['cache_dir'] . '/' . $set['login_background']); unlink($hesk_settings['cache_dir'] . '/lb_' . $set['login_background']);
$set['login_background'] = hesk_input(hesk_POST('login-background-color')); $set['login_background'] = hesk_input(hesk_POST('login-background-color'));
if ($set['login_background'] == '') { if ($set['login_background'] == '') {
$set['login_background'] = '#d2d6de'; $set['login_background'] = '#d2d6de';
@ -520,25 +520,22 @@ if ($set['login_background_type'] == 'color') {
if ($file_size > $hesk_settings['attachments']['max_size']) { if ($file_size > $hesk_settings['attachments']['max_size']) {
return hesk_fileError(sprintf($hesklang['file_too_large'], $file_name)); return hesk_fileError(sprintf($hesklang['file_too_large'], $file_name));
} }
$ext = strtolower(strrchr($file_name, "."));
if (file_exists($hesk_settings['cache_dir'] . '/login-background/' . $set['login_background'])) { if (file_exists($hesk_settings['cache_dir'] . '/lb_' . $set['login_background'])) {
unlink($hesk_settings['cache_dir'] . '/login-background/' . $set['login_background']); unlink($hesk_settings['cache_dir'] . '/lb_' . $set['login_background']);
} }
$useChars = 'AEUYBDGHJLMNPQRSTVWXZ123456789'; $saved_name = 'login-background' . $ext;
$tmp = uniqid();
for ($j = 1; $j < 10; $j++) {
$tmp .= $useChars{mt_rand(0, 29)};
}
$file_to_move = $_FILES['login-background-image']['tmp_name']; $file_to_move = $_FILES['login-background-image']['tmp_name'];
if (!move_uploaded_file($file_to_move, dirname(dirname(__FILE__)) . '/' . $hesk_settings['cache_dir'] . '/login-background/' . $file_name)) { if (!move_uploaded_file($file_to_move, dirname(dirname(__FILE__)) . '/' . $hesk_settings['cache_dir'] . '/lb_' . $saved_name)) {
hesk_error($hesklang['cannot_move_tmp']); hesk_error($hesklang['cannot_move_tmp']);
} }
$set['login_background'] = $file_name; $set['login_background'] = $saved_name;
$changedBackground = true; $changedBackground = true;
} }
} }

@ -269,197 +269,200 @@ function print_login()
?> ?>
<div class="login-box"> <div class="login-box">
<div class="login-logo"> <div class="login-box-container">
<?php echo $hesk_settings['hesk_title']; ?> <div class="login-box-background"></div>
</div> <div class="login-box-body">
<div class="login-box-body"> <div class="loginError">
<div class="loginError"> <?php
<?php /* This will handle error, success and notice messages */
/* This will handle error, success and notice messages */ hesk_handle_messages();
hesk_handle_messages(); ?>
?> </div>
</div> <div class="login-logo">
<h4 class="login-box-msg"> <?php echo $hesk_settings['hesk_title']; ?>
<?php echo $hesklang['staff_login_title']; ?> </div>
</h4> <h4 class="login-box-msg">
<form class="form-horizontal" role="form" action="index.php" method="post" name="form1"> <?php echo $hesklang['staff_login_title']; ?>
<?php </h4>
$has_error = ''; <form class="form-horizontal" role="form" action="index.php" method="post" name="form1">
if (in_array('pass',$_SESSION['a_iserror'])) { <?php
$has_error = 'has-error'; $has_error = '';
} if (in_array('pass',$_SESSION['a_iserror'])) {
?> $has_error = 'has-error';
<div class="form-group <?php echo $has_error; ?>"> }
<label for="user" class="col-sm-4 control-label"> ?>
<?php echo $hesklang['username']; ?> <div class="form-group <?php echo $has_error; ?>">
</label> <label for="user" class="col-sm-4 control-label">
<div class="col-sm-8"> <?php echo $hesklang['username']; ?>
</label>
<div class="col-sm-8">
<?php
if (defined('HESK_USER')) {
$savedUser = HESK_USER;
} else {
$savedUser = hesk_htmlspecialchars(hesk_COOKIE('hesk_username'));
}
$is_1 = '';
$is_2 = '';
$is_3 = '';
$remember_user = hesk_POST('remember_user');
if ($hesk_settings['autologin'] && (isset($_COOKIE['hesk_p']) || $remember_user == 'AUTOLOGIN')) {
$is_1 = 'checked';
} elseif (isset($_COOKIE['hesk_username']) || $remember_user == 'JUSTUSER') {
$is_2 = 'checked';
} else {
$is_3 = 'checked';
}
if ($hesk_settings['list_users']) :
$res = hesk_dbQuery("SELECT `user` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `active` = '1' ORDER BY `user` ASC");
?>
<select class="form-control" name="user">
<?php
while ($row = hesk_dbFetchAssoc($res)):
$sel = (strtolower($savedUser) == strtolower($row['user'])) ? 'selected' : '';
?>
<option value="<?php echo $row['user']; ?>" <?php echo $sel; ?>>
<?php echo $row['user']; ?>
</option>
<?php endwhile; ?>
</select>
<?php else: ?>
<input class="form-control" type="text" name="user" size="35"
placeholder="<?php echo htmlspecialchars($hesklang['username']); ?>"
value="<?php echo $savedUser; ?>">
<?php endif; ?>
</div>
</div>
<?php
$has_error = '';
if (in_array('pass',$_SESSION['a_iserror'])) {
$has_error = 'has-error';
}
?>
<div class="form-group <?php echo $has_error; ?>">
<label for="pass" class="col-sm-4 control-label">
<?php echo $hesklang['pass']; ?>
</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="pass" name="pass" size="35" placeholder="<?php echo htmlspecialchars($hesklang['pass']); ?>">
</div>
</div>
<?php
if ($hesk_settings['secimg_use'] == 2)
{
// SPAM prevention verified for this session
if (isset($_SESSION['img_a_verified']))
{
echo '<img src="'.HESK_PATH.'img/success.png" width="16" height="16" border="0" alt="" style="vertical-align:text-bottom" /> '.$hesklang['vrfy'];
}
// Not verified yet, should we use Recaptcha?
elseif ($hesk_settings['recaptcha_use'] == 1)
{
?>
<script type="text/javascript">
var RecaptchaOptions = {
theme : '<?php echo ( isset($_SESSION['a_iserror']) && in_array('mysecnum',$_SESSION['a_iserror']) ) ? 'red' : 'white'; ?>',
custom_translations : {
visual_challenge : "<?php echo hesk_slashJS($hesklang['visual_challenge']); ?>",
audio_challenge : "<?php echo hesk_slashJS($hesklang['audio_challenge']); ?>",
refresh_btn : "<?php echo hesk_slashJS($hesklang['refresh_btn']); ?>",
instructions_visual : "<?php echo hesk_slashJS($hesklang['instructions_visual']); ?>",
instructions_context : "<?php echo hesk_slashJS($hesklang['instructions_context']); ?>",
instructions_audio : "<?php echo hesk_slashJS($hesklang['instructions_audio']); ?>",
help_btn : "<?php echo hesk_slashJS($hesklang['help_btn']); ?>",
play_again : "<?php echo hesk_slashJS($hesklang['play_again']); ?>",
cant_hear_this : "<?php echo hesk_slashJS($hesklang['cant_hear_this']); ?>",
incorrect_try_again : "<?php echo hesk_slashJS($hesklang['incorrect_try_again']); ?>",
image_alt_text : "<?php echo hesk_slashJS($hesklang['image_alt_text']); ?>"
}
};
</script>
<?php <?php
if (defined('HESK_USER')) { require_once(HESK_PATH . 'inc/recaptcha/recaptchalib.php');
$savedUser = HESK_USER; echo '<div class="form-group"><div class="col-md-8 col-md-offset-4">';
} else { echo recaptcha_get_html($hesk_settings['recaptcha_public_key'], null, true);
$savedUser = hesk_htmlspecialchars(hesk_COOKIE('hesk_username')); echo '</div></div>';
} }
// Use reCaptcha API v2?
$is_1 = ''; elseif ($hesk_settings['recaptcha_use'] == 2)
$is_2 = ''; {
$is_3 = ''; ?>
<div class="form-group">
$remember_user = hesk_POST('remember_user'); <div class="col-md-8 col-md-offset-4">
<div class="g-recaptcha" data-sitekey="<?php echo $hesk_settings['recaptcha_public_key']; ?>"></div>
if ($hesk_settings['autologin'] && (isset($_COOKIE['hesk_p']) || $remember_user == 'AUTOLOGIN')) { </div>
$is_1 = 'checked'; </div>
} elseif (isset($_COOKIE['hesk_username']) || $remember_user == 'JUSTUSER') { <?php
$is_2 = 'checked';
} else {
$is_3 = 'checked';
} }
// At least use some basic PHP generated image (better than nothing)
else
{
echo '<div class="form-group"><div class="col-md-8 col-md-offset-4">';
$cls = in_array('mysecnum',$_SESSION['a_iserror']) ? ' class="isError" ' : '';
if ($hesk_settings['list_users']) : echo $hesklang['sec_enter'].'<br><br><img src="'.HESK_PATH.'print_sec_img.php?'.rand(10000,99999).'" width="150" height="40" alt="'.$hesklang['sec_img'].'" title="'.$hesklang['sec_img'].'" border="1" name="secimg" style="vertical-align:text-bottom"> '.
$res = hesk_dbQuery("SELECT `user` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `active` = '1' ORDER BY `user` ASC"); '<a href="javascript:void(0)" onclick="javascript:document.form1.secimg.src=\''.HESK_PATH.'print_sec_img.php?\'+ ( Math.floor((90000)*Math.random()) + 10000);"><img src="'.HESK_PATH.'img/reload.png" height="24" width="24" alt="'.$hesklang['reload'].'" title="'.$hesklang['reload'].'" border="0" style="vertical-align:text-bottom"></a>'.
?> '<br><br><input type="text" name="mysecnum" size="20" maxlength="5" '.$cls.'>';
<select class="form-control" name="user"> echo '</div></div>';
<?php }
while ($row = hesk_dbFetchAssoc($res)): } // End if $hesk_settings['secimg_use'] == 2
$sel = (strtolower($savedUser) == strtolower($row['user'])) ? 'selected' : '';
?>
<option value="<?php echo $row['user']; ?>" <?php echo $sel; ?>>
<?php echo $row['user']; ?>
</option>
<?php endwhile; ?>
</select>
<?php else: ?>
<input class="form-control" type="text" name="user" size="35"
placeholder="<?php echo htmlspecialchars($hesklang['username']); ?>"
value="<?php echo $savedUser; ?>">
<?php endif; ?>
</div>
</div>
<?php
$has_error = '';
if (in_array('pass',$_SESSION['a_iserror'])) {
$has_error = 'has-error';
}
?>
<div class="form-group <?php echo $has_error; ?>">
<label for="pass" class="col-sm-4 control-label">
<?php echo $hesklang['pass']; ?>
</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="pass" name="pass" size="35" placeholder="<?php echo htmlspecialchars($hesklang['pass']); ?>">
</div>
</div>
<?php
if ($hesk_settings['secimg_use'] == 2)
{
// SPAM prevention verified for this session if ($hesk_settings['autologin'])
if (isset($_SESSION['img_a_verified']))
{
echo '<img src="'.HESK_PATH.'img/success.png" width="16" height="16" border="0" alt="" style="vertical-align:text-bottom" /> '.$hesklang['vrfy'];
}
// Not verified yet, should we use Recaptcha?
elseif ($hesk_settings['recaptcha_use'] == 1)
{ {
?> ?>
<script type="text/javascript">
var RecaptchaOptions = {
theme : '<?php echo ( isset($_SESSION['a_iserror']) && in_array('mysecnum',$_SESSION['a_iserror']) ) ? 'red' : 'white'; ?>',
custom_translations : {
visual_challenge : "<?php echo hesk_slashJS($hesklang['visual_challenge']); ?>",
audio_challenge : "<?php echo hesk_slashJS($hesklang['audio_challenge']); ?>",
refresh_btn : "<?php echo hesk_slashJS($hesklang['refresh_btn']); ?>",
instructions_visual : "<?php echo hesk_slashJS($hesklang['instructions_visual']); ?>",
instructions_context : "<?php echo hesk_slashJS($hesklang['instructions_context']); ?>",
instructions_audio : "<?php echo hesk_slashJS($hesklang['instructions_audio']); ?>",
help_btn : "<?php echo hesk_slashJS($hesklang['help_btn']); ?>",
play_again : "<?php echo hesk_slashJS($hesklang['play_again']); ?>",
cant_hear_this : "<?php echo hesk_slashJS($hesklang['cant_hear_this']); ?>",
incorrect_try_again : "<?php echo hesk_slashJS($hesklang['incorrect_try_again']); ?>",
image_alt_text : "<?php echo hesk_slashJS($hesklang['image_alt_text']); ?>"
}
};
</script>
<?php
require_once(HESK_PATH . 'inc/recaptcha/recaptchalib.php');
echo '<div class="form-group"><div class="col-md-8 col-md-offset-4">';
echo recaptcha_get_html($hesk_settings['recaptcha_public_key'], null, true);
echo '</div></div>';
}
// Use reCaptcha API v2?
elseif ($hesk_settings['recaptcha_use'] == 2)
{
?>
<div class="form-group"> <div class="form-group">
<div class="col-md-8 col-md-offset-4"> <div class="col-md-offset-4 col-md-8">
<div class="g-recaptcha" data-sitekey="<?php echo $hesk_settings['recaptcha_public_key']; ?>"></div> <div class="radio">
<label><input type="radio" name="remember_user" value="AUTOLOGIN" <?php echo $is_1; ?>> <?php echo $hesklang['autologin']; ?></label>
</div>
<div class="radio">
<label><input type="radio" name="remember_user" value="JUSTUSER" <?php echo $is_2; ?>> <?php echo $hesklang['just_user']; ?></label>
</div>
<div class="radio">
<label><input type="radio" name="remember_user" value="NOTHANKS" <?php echo $is_3; ?>> <?php echo $hesklang['nothx']; ?></label>
</div>
</div> </div>
</div> </div>
<?php <?php
} }
// At least use some basic PHP generated image (better than nothing)
else else
{ {
echo '<div class="form-group"><div class="col-md-8 col-md-offset-4">'; ?>
$cls = in_array('mysecnum',$_SESSION['a_iserror']) ? ' class="isError" ' : ''; <div class="form-group">
<div class="col-md-offset-4 col-md-8">
echo $hesklang['sec_enter'].'<br><br><img src="'.HESK_PATH.'print_sec_img.php?'.rand(10000,99999).'" width="150" height="40" alt="'.$hesklang['sec_img'].'" title="'.$hesklang['sec_img'].'" border="1" name="secimg" style="vertical-align:text-bottom"> '. <div class="checkbox">
'<a href="javascript:void(0)" onclick="javascript:document.form1.secimg.src=\''.HESK_PATH.'print_sec_img.php?\'+ ( Math.floor((90000)*Math.random()) + 10000);"><img src="'.HESK_PATH.'img/reload.png" height="24" width="24" alt="'.$hesklang['reload'].'" title="'.$hesklang['reload'].'" border="0" style="vertical-align:text-bottom"></a>'. <label><input type="checkbox" name="remember_user" value="JUSTUSER" <?php echo $is_2; ?> /> <?php echo $hesklang['remember_user']; ?></label>
'<br><br><input type="text" name="mysecnum" size="20" maxlength="5" '.$cls.'>'; </div>
echo '</div></div>';
}
} // End if $hesk_settings['secimg_use'] == 2
if ($hesk_settings['autologin'])
{
?>
<div class="form-group">
<div class="col-md-offset-4 col-md-8">
<div class="radio">
<label><input type="radio" name="remember_user" value="AUTOLOGIN" <?php echo $is_1; ?>> <?php echo $hesklang['autologin']; ?></label>
</div>
<div class="radio">
<label><input type="radio" name="remember_user" value="JUSTUSER" <?php echo $is_2; ?>> <?php echo $hesklang['just_user']; ?></label>
</div>
<div class="radio">
<label><input type="radio" name="remember_user" value="NOTHANKS" <?php echo $is_3; ?>> <?php echo $hesklang['nothx']; ?></label>
</div> </div>
</div> </div>
</div> <?php
<?php } // End if $hesk_settings['autologin']
}
else
{
?> ?>
<div class="form-group"> <div class="form-group">
<div class="col-md-offset-4 col-md-8"> <div class="col-md-offset-4 col-md-8">
<div class="checkbox"> <input type="submit" value="<?php echo $hesklang['click_login']; ?>" class="btn btn-default">
<label><input type="checkbox" name="remember_user" value="JUSTUSER" <?php echo $is_2; ?> /> <?php echo $hesklang['remember_user']; ?></label> <input type="hidden" name="a" value="do_login">
</div> <?php
if ( hesk_isREQUEST('goto') && $url=hesk_REQUEST('goto') )
{
echo '<input type="hidden" name="goto" value="'.$url.'">';
}
// Do we allow staff password reset?
if ($hesk_settings['reset_pass'])
{
echo '<br><br><a href="password.php" class="smaller">'.$hesklang['fpass'].'</a>';
}
?>
</div> </div>
</div> </div>
<?php </form>
} // End if $hesk_settings['autologin'] </div>
?>
<div class="form-group">
<div class="col-md-offset-4 col-md-8">
<input type="submit" value="<?php echo $hesklang['click_login']; ?>" class="btn btn-default">
<input type="hidden" name="a" value="do_login">
<?php
if ( hesk_isREQUEST('goto') && $url=hesk_REQUEST('goto') )
{
echo '<input type="hidden" name="goto" value="'.$url.'">';
}
// Do we allow staff password reset?
if ($hesk_settings['reset_pass'])
{
echo '<br><br><a href="password.php" class="smaller">'.$hesklang['fpass'].'</a>';
}
?>
</div>
</div>
</form>
</div> </div>
</div> </div>
<?php <?php

@ -178,8 +178,36 @@ button.dropdown-submit {
min-width: 350px; min-width: 350px;
} }
.login-box-container {
position: relative;
}
.login-box-background {
/* Absolutely position it, but stretch it to all four corners, then put it just behind #search's z-index */
/* background is handled in the header logic */
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 99;
/* Pull the background 70px higher to the same place as #bg's */
/*background-position: center -70px;*/
-webkit-filter: blur(10px);
/*filter: url('/media/blur.svg#blur');*/
filter: blur(10px);
}
.login-box-body { .login-box-body {
position: relative;
box-shadow: 0 0 50px 5px rgba(0,0,0,0.3),
0 0 5px -1px white;
background: rgb(255, 255, 255);
background: rgba(255, 255, 255, .75);
border-radius: 5px; border-radius: 5px;
z-index: 100;
} }
.button-link { .button-link {

@ -90,11 +90,26 @@ $modsForHesk_settings = mfh_getSettings();
color: <?php echo $modsForHesk_settings['questionMarkColor']; ?>; color: <?php echo $modsForHesk_settings['questionMarkColor']; ?>;
} }
<?php if (defined('PAGE_TITLE') && PAGE_TITLE == 'LOGIN'): ?> <?php
if (defined('PAGE_TITLE') && PAGE_TITLE == 'LOGIN'):
if ($modsForHesk_settings['login_background_type'] == 'color'):
?>
body { body {
background: <?php echo $modsForHesk_settings['login_background']; ?>; background: <?php echo $modsForHesk_settings['login_background']; ?>;
} }
<?php endif; ?> <?php else: ?>
body {
background: url('<?php echo HESK_PATH . 'cache/lb_' . $modsForHesk_settings['login_background']; ?>')
no-repeat center center fixed;
background-size: cover;
}
.login-box-background {
background: url('<?php echo HESK_PATH . 'cache/lb_' . $modsForHesk_settings['login_background']; ?>')
no-repeat center center fixed;
background-size: cover;
}
<?php endif; endif; ?>
</style> </style>
<?php <?php

Loading…
Cancel
Save