feat: forward certtest and pw to new next.js projects
This commit is contained in:
parent
6891eb0eab
commit
e73f94b9f3
|
@ -1,3 +0,0 @@
|
|||
.fullwidth {width:100%;}
|
||||
.titlecenter {width:100%;text-align:center;}
|
||||
.certdt {display:inline-block;padding:1rem;border:1px solid #555;border-radius:0.3rem;margin:0.5rem;cursor:pointer;}
|
9578
pw/dict.txt
9578
pw/dict.txt
File diff suppressed because it is too large
Load Diff
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
class PasswordGenerator
|
||||
{
|
||||
protected static $numLines = -1;
|
||||
protected static $file = __DIR__ . '/dict.txt';
|
||||
|
||||
public static function generate($delimiter = '', $setCase = false, $num = 4, $addNumber = false)
|
||||
{
|
||||
$num = self::limitNumber($num);
|
||||
|
||||
$words = array();
|
||||
$dbfile = new SplFileObject(self::$file);
|
||||
if(self::$numLines < 0) {
|
||||
$dbfile->seek($dbfile->getSize());
|
||||
self::$numLines = $dbfile->key();
|
||||
}
|
||||
for ($i = 0; $i < $num; $i++) {
|
||||
if($addNumber && $i == ($num-1)) {
|
||||
$words[] = (string)random_int(1,9);
|
||||
}
|
||||
$lineNumber = random_int(0, self::$numLines);
|
||||
$dbfile->seek($lineNumber);
|
||||
if($setCase) {
|
||||
$words[] = ucfirst(trim($dbfile->current()));
|
||||
} else {
|
||||
$words[] = trim($dbfile->current());
|
||||
}
|
||||
}
|
||||
return implode((string) $delimiter, $words);
|
||||
}
|
||||
|
||||
private static function limitNumber($num) {
|
||||
if($num < 1) {
|
||||
return 1;
|
||||
} else if($num > 8) {
|
||||
return 8;
|
||||
}
|
||||
return $num;
|
||||
}
|
||||
|
||||
}
|
27
pw/genpw.php
27
pw/genpw.php
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
include_once($_SERVER['DOCUMENT_ROOT'].'/inc/origin.class.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'].'/inc/config.php');
|
||||
include_once($_SERVER['DOCUMENT_ROOT'].'/inc/funcs.php');
|
||||
|
||||
originHelper\origin::check($config['allowed-origins']);
|
||||
|
||||
include_once('generator.php');
|
||||
|
||||
$ret = [];
|
||||
|
||||
//get input parameters
|
||||
$numWords = apiFuncs\getNumParam('w',4,8,1);
|
||||
$delim = apiFuncs\getpost('d','-');
|
||||
$case = apiFuncs\getNumParam('c',1,1,0);
|
||||
$addNumber = apiFuncs\getNumParam('n',1,1,0);
|
||||
$numPasswords = apiFuncs\getNumParam('num',5,20,1);
|
||||
|
||||
for($i=0;$i<$numPasswords;$i++) {
|
||||
array_push($ret,PasswordGenerator::generate($delim,$case,$numWords, $addNumber));
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
echo json_encode($ret);
|
||||
|
||||
?>
|
|
@ -1,75 +1,9 @@
|
|||
<!doctype html>
|
||||
<html lang="de">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Passwort generieren</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="description" content="password generator" />
|
||||
<link rel="stylesheet" href="//gma.name/css/bootstrap.darkly.v520.min.css">
|
||||
<link rel="stylesheet" href="//gma.name/fonts/fa5.min.css">
|
||||
<style>.pntr{cursor:pointer;}</style>
|
||||
<meta http-equiv="refresh" content="0; url='https://gma.name/pw/'" />
|
||||
</head>
|
||||
<body lang='en'>
|
||||
<div class="container">
|
||||
<nav class="navbar navbar-expand navbar-expand-lg navbar-dark bg-primary">
|
||||
<div class="container-fluid justify-content-start">
|
||||
<a class="navbar-brand" href="https://gma.name/">gma.name</a>
|
||||
<span class="navbar-text mx-auto">Passwortgenerator <small>nach Correct-Horse-Battery-Staple (<a href="https://www.xkcd.com/936/" title="xkcd comic" target="_blank">xkcd</a>)</small></span>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<form id="form" class="mt-2">
|
||||
<div class="row mb-2">
|
||||
<label for="numPwd" class="col-sm-2 col-form-label">Anzahl Passwörter</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="number" class="form-control" name="num" id="numPwd" placeholder="Anzahl" value="5" min="1" max="20" autofocus>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<label for="numWord" class="col-sm-2 col-form-label">Anzahl Wörter</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="number" class="form-control" name="w" id="numWord" placeholder="Anzahl" value="3" min="1" max="8">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<label for="delim" class="col-sm-2 col-form-label">Delimiter</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="d" id="delim" placeholder="Delimiter" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<label for="case" class="col-sm-2 col-form-label">Gross- und Kleinbuchstaben</label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="c" id="case">
|
||||
<option value="0">Nein</option>
|
||||
<option value="1" selected>Ja</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<label for="withNumber" class="col-sm-2 col-form-label">Zahl anhängen</label>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="n" id="withNumber">
|
||||
<option value="0">Nein</option>
|
||||
<option value="1" selected>Ja</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-2 col-form-label"></div>
|
||||
<div class="col-sm-10">
|
||||
<button type="button" id="goBtn" class="btn btn-primary" onclick="go();">Generieren</button>
|
||||
<button type="button" id="clearBtn" class="btn btn-info" onclick="$('#output').empty();">Ausgabe Löschen</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">Ausgabe</div>
|
||||
<div class="card-body" id="output"></div>
|
||||
<div class="card-footer text-muted">Symbole: <div class="badge text-bg-info">Anzahl Zeichen</div> <div class="badge text-bg-warning">Passwort enthält y oder z (Problem bei englischer Tastaturbelegung)</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="//gma.name/js/jquery.v360.min.js"></script>
|
||||
<script src="//api.mayer.life/pw/script.js"></script>
|
||||
<body style="background-color:black;color:white;">
|
||||
<p>Weiterleitung <a href="https://gma.name/pw/">zum Passwortgenerator</a>.</p>
|
||||
</body>
|
||||
</html>
|
129
pw/script.js
129
pw/script.js
|
@ -1,129 +0,0 @@
|
|||
/*
|
||||
script for https://api.mayer.life/pw/
|
||||
(c) 2018 by Gottfried Mayer
|
||||
*/
|
||||
/*global $*/
|
||||
|
||||
window.isSending = false;
|
||||
|
||||
$(document).ready(function(){
|
||||
const fnc = function(e) {
|
||||
if(e.keyCode==13) {
|
||||
go();
|
||||
}
|
||||
};
|
||||
$('#numWord').keypress(fnc);
|
||||
$('#numPwd').keypress(fnc);
|
||||
$('#delim').keypress(fnc);
|
||||
});
|
||||
|
||||
function getAndClearOutput() {
|
||||
let output = document.getElementById("output");
|
||||
while (output.firstChild) {
|
||||
output.removeChild(output.lastChild);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function go() {
|
||||
if(window.isSending) {
|
||||
console.log("Warte auf vorherige Antwort, ignoriere...");
|
||||
return;
|
||||
}
|
||||
window.isSending = true;
|
||||
updateButton();
|
||||
let params = $("#form").serialize();
|
||||
$.getJSON("https://api.mayer.life/pw/genpw.php",params, function(data) {
|
||||
let lst = getAndClearOutput();
|
||||
let ul = document.createElement("ul");
|
||||
ul.className = "list-group list-group-flush";
|
||||
|
||||
$.each(data, function(i, item) {
|
||||
let li = document.createElement("li");
|
||||
li.className = "list-group-item font-monospace";
|
||||
|
||||
let badge = document.createElement("span");
|
||||
if (item.search(new RegExp("[yz]","i")) !== -1) {
|
||||
badge.className = "badge ms-2 text-bg-warning user-select-none";
|
||||
} else {
|
||||
badge.className = "badge ms-2 text-bg-info user-select-none";
|
||||
}
|
||||
badge.innerText = item.length;
|
||||
|
||||
let copybtn = document.createElement("i");
|
||||
copybtn.className = "fas fa-copy text-muted me-2 pntr";
|
||||
|
||||
li.append(copybtn);
|
||||
li.append(item);
|
||||
li.append(badge);
|
||||
li.setAttribute('data-pwd', item);
|
||||
li.onclick = listClicked;
|
||||
ul.append(li);
|
||||
|
||||
});
|
||||
lst.append(ul);
|
||||
}).fail(function(xhr,status,err){
|
||||
let output = getAndClearOutput();
|
||||
let msg = document.createElement("code");
|
||||
msg.innerText = "Ein Fehler ist aufgetreten. Versuche es nochmal...";
|
||||
output.append(msg);
|
||||
}).always(function(){
|
||||
window.isSending = false;
|
||||
updateButton();
|
||||
});
|
||||
}
|
||||
function updateButton() {
|
||||
let btn = document.getElementById("goBtn");
|
||||
if(window.isSending) {
|
||||
btn.classList.remove("btn-primary");
|
||||
btn.classList.add("disabled");
|
||||
} else {
|
||||
btn.classList.remove("disabled");
|
||||
btn.classList.add("btn-primary");
|
||||
}
|
||||
}
|
||||
|
||||
function listClicked(e) {
|
||||
e = e || window.event;
|
||||
let targ = e.target || e.srcElement;
|
||||
if(targ.nodeType == 3) { targ = targ.parentNode; }
|
||||
if(!targ.hasAttribute('data-pwd')) { targ = targ.parentNode; }
|
||||
if(targ.hasAttribute('data-pwd')) {
|
||||
let pwd = targ.getAttribute('data-pwd');
|
||||
copyTextToClipboard(pwd, targ);
|
||||
}
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
function copyTextToClipboard(text, elem) {
|
||||
let resetFnc = function() {
|
||||
elem.classList.remove('text-warning');
|
||||
elem.classList.remove('text-success');
|
||||
}
|
||||
let setFnc = function(ok) {
|
||||
if(ok) {
|
||||
elem.classList.add('text-success');
|
||||
elem.setAttribute('style','border-left:2px solid var(--bs-pink);');
|
||||
} else {
|
||||
elem.classList.add('text-warning');
|
||||
}
|
||||
setTimeout(resetFnc, 2000);
|
||||
}
|
||||
|
||||
let textArea = document.createElement("textarea");
|
||||
textArea.style="position:fixed;top:0;left:0;width=2em;height=2em;padding=0;border=none;outline=none;boxShadow=none;background=transparent;";
|
||||
textArea.value = text;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
|
||||
let successful = false;
|
||||
try {
|
||||
successful = document.execCommand('copy');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
document.body.removeChild(textArea);
|
||||
setFnc(successful);
|
||||
return successful;
|
||||
}
|
Loading…
Reference in New Issue