diff --git a/html/index.php b/html/index.php index 87f272de0..d5de46c7a 100755 --- a/html/index.php +++ b/html/index.php @@ -138,6 +138,7 @@ if ($config['page_refresh']) { echo(' + ' . "\n"); } ?> diff --git a/html/js/custom.js b/html/js/custom.js new file mode 100644 index 000000000..c25311b72 --- /dev/null +++ b/html/js/custom.js @@ -0,0 +1,22 @@ +$.extend({ + password: function (length, special) { + var iteration = 0; + var password = ""; + var randomNumber; + if(special == undefined){ + var special = false; + } + while(iteration < length){ + randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33; + if(!special){ + if ((randomNumber >=33) && (randomNumber <=47)) { continue; } + if ((randomNumber >=58) && (randomNumber <=64)) { continue; } + if ((randomNumber >=91) && (randomNumber <=96)) { continue; } + if ((randomNumber >=123) && (randomNumber <=126)) { continue; } + } + iteration++; + password += String.fromCharCode(randomNumber); + } + return password; + } +}); diff --git a/html/pages/api-access.inc.php b/html/pages/api-access.inc.php index 5f1ed58be..c5d3504c8 100644 --- a/html/pages/api-access.inc.php +++ b/html/pages/api-access.inc.php @@ -16,24 +16,105 @@ if ($_SESSION['userlevel'] == '10') { ?> +'); + if($_SESSION['api_token'] === TRUE) + { + echo(" + "); + unset($_SESSION['api_token']); + } +echo(' +
+
+ +
+
+
+
+   +
+
@@ -57,12 +138,12 @@ if ($_SESSION['userlevel'] == '10') $api_disabled = ''; } echo(' - + - + '); } @@ -93,8 +174,51 @@ if ($_SESSION['userlevel'] == '10') }); }); $('#confirm-delete').on('show.bs.modal', function(e) { - $(this).find('.danger').attr('href', $(e.relatedTarget).data('href')); - $('.debug-url').html('Delete URL: ' + $(this).find('.danger').attr('href') + ''); + token_id = $(e.relatedTarget).data('token_id'); + $("#token_id").val(token_id); + event.preventDefault(); + }); + $('#token-removal').click('', function(e) { + event.preventDefault(); + token_id = $("#token_id").val(); + $.ajax({ + type: "POST", + url: "/ajax_form.php", + data: $('form.remove_token_form').serialize() , + success: function(msg){ + $("#thanks").html('
'+msg+'
'); + $("#confirm-delete").modal('hide'); + $("#"+token_id).remove(); + }, + error: function(){ + $("#thanks").html('
An error occurred removing the token.
'); + $("#confirm-delete").modal('hide'); + } + }); + }); + $('#token-create').click('', function(e) { + event.preventDefault(); + $.ajax({ + type: "POST", + url: "/ajax_form.php", + data: $('form.create_token_form').serialize(), + success: function(msg){ + $("#thanks").html('
'+msg+'
'); + $("#create-token").modal('hide'); + if(msg.indexOf("ERROR:") <= -1) { + location.reload(); + } + }, + error: function(){ + $("#thanks").html('
An error occurred removing the token.
'); + $("#create-token").modal('hide'); + } + }); + }); + $('#pass-gen').click('', function(e) { + event.preventDefault(); + token = $.password(32,false); + $('#token').val(token); });
'.$api['username'].' '.$api['token_hash'].' '.$api['description'].' Delete