diff --git a/admin/login.php b/admin/login.php index f164cb9..a8a085b 100755 --- a/admin/login.php +++ b/admin/login.php @@ -92,6 +92,7 @@ if(isset($_GET['checkPassword'])) if (password_verify($_POST['pw'], $db->data[0]['pass'])) { echo 'success'; + $_SESSION['sudomode'] = time(); } else { @@ -108,4 +109,24 @@ if(isset($_GET['checkPassword'])) { echo 'login first.'; } +} + +// Check if the user already entered his password +if (isset($_GET['checkSudo'])) +{ + if(is_loggedin()) + { + // Check if the user entered his password less then 10 minutes ago + if (isset($_SESSION['sudomode']) && $_SESSION['sudomode'] >= (time() - 600)) + { + echo 'true'; + } else + { + echo 'false'; + } + } + else + { + echo 'login first.'; + } } \ No newline at end of file diff --git a/inc/footer.php b/inc/footer.php index 3955728..de38c92 100755 --- a/inc/footer.php +++ b/inc/footer.php @@ -141,36 +141,46 @@ if (!isset($_GET['direct'])) //Confirm user password if (needsPwConfirm) { - $('#showMsg').html(''); - $('#content').append('

get('legitimate_text')?>

get('legitimate_abort')?>

'); - $('#password_legitimate').focus(); - $(".overlay").fadeIn(250); + // check if the user already entered his password + $.get('login.php?checkSudo', function( data ) { + if (data == 'false'){ + $('#showMsg').html(''); + $('#content').append('

get('legitimate_text')?>

get('legitimate_abort')?>

'); + $('#password_legitimate').focus(); + $(".overlay").fadeIn(250); - $('#legitimateSmbt').click(function () { - $.ajax({ - url: 'login.php?checkPassword', - type: 'POST', - cache: false, - data: 'pw=' + $('#password_legitimate').val(), - success: function (result) { // On success, display a message... - if (result == 'success') { - closeW(); + $('#legitimateSmbt').click(function () { + $.ajax({ + url: 'login.php?checkPassword', + type: 'POST', + cache: false, + data: 'pw=' + $('#password_legitimate').val(), + success: function (result) { // On success, display a message... + if (result == 'success') { + closeW(); - //Send the request - if (!isAjax) { - sendPost(ctx, requestData); + //Send the request + if (!isAjax) { + sendPost(ctx, requestData); + } + } else if (result == 'fail') { + $('#sendMsg').html('

get('legitimate_fail')?>

'); + } else { + $('#sendMsg').html('

get('legitimate_error')?>

'); + } + }, + error: function (xhr, status, error) { + console.log(status, error); + showMsg('get('legitimate_error')?>'); } - } else if (result == 'fail') { - $('#sendMsg').html('

get('legitimate_fail')?>

'); - } else { - $('#sendMsg').html('

get('legitimate_error')?>

'); - } - }, - error: function (xhr, status, error) { - console.log(status, error); - showMsg('get('legitimate_error')?>'); + }); + }); + } else { + //Send the request + if (!isAjax) { + sendPost(ctx, requestData); } - }); + } }); } else { if (!isAjax) {