Added a login and finished the filewriter

This commit is contained in:
Jesse James Isler 2022-04-04 12:55:53 +02:00
parent 4a7b238a1b
commit 7f3816f372
4 changed files with 148 additions and 35 deletions

93
confirm.php Normal file
View File

@ -0,0 +1,93 @@
<body>
<html>
<?php
if (preg_match('/^[\/\w\-. ]+$/', $_POST['rolename'])){
echo 'VALID FILENAME';
$language = $_POST['language'];
$rolefile = "roles/".$language."/".$_POST['rolename'].".php";
fopen($rolefile, "w");
#
# COLORS
#
# Text Color
$f_tcolor = $_POST['textcol'];
fwrite($rolefile, $f_tcolor);
# This is the color defined by https://materializecss.com/color.html
$f_color = $_POST['rolecolor']." ".$_POST['rolestrength']."-".$_POST['rolemod'];
fwrite($rolefile, $f_color);
#
# BASEINFO
#
#The Name of the Role
$f_name = $_POST['rolename'];
fwrite($rolefile, $f_name);
#The Description of the Role, HTML conform :)
$f_description = $_POST['roledesc'];
fwrite($rolefile, $f_description);
#
# TABS
#
#How To play
$f_howtoplay = $_POST['howtoplay'];
fwrite($rolefile, $f_howtoplay);
#With what roles does this role play best?
fwrite($rolefile, '$playsbestwith = "<ul>');
foreach($_POST['goodRol es'] as $selectedOption) {
fwrite($rolefile, '<li>'.$selectedOption.'</li>');
};
fwrite($rolefile, '<</ul>"');
#Convars
$f_convars = '$convars = "Normal Role Convars (also found in ULX):
<code>'.$_POST['gconvars'].'</code>
Rolespecific Convars:
<code>'.$_POST['cconvars'].'</code>"';
fwrite($rolefile, $f_convars);
#
# Credits
#
#The Steam URL to your addon
$f_steam = $_POST['steam'];
fwrite($rolefile, $f_steam);
#The Source URL to your addon
$f_source = $_POST['source'];
fwrite($rolefile, $f_source);
#Creator of the Addon
$f_author = $_POST[''];
fwrite($rolefile, $f_author);
#Creatorlink
$f_authorurl = $_POST[''];
fwrite($rolefile, $f_authorurl);
# Credittext (can use the above variables)
$f_ctext = $_POST['credits'];
fwrite($rolefile, $f_ctext);
fclose($rolefile);
} else {
echo 'INVALID ROLENAME';
}
?>
</body>
</html>

View File

@ -28,20 +28,20 @@
<div class="row">
<div class="col s6">
<div class="card-panel white">
<form>
<form method="post" action="/confirm.php">
<div class="row">
<div class="input-field col s3">
<input id="name" type="text" onkeyup="updateCard()">
<input id="name" type="text" name="rolename" onkeyup="updateCard()">
<label for="name">Rolename</label>
</div>
<div class="input-field col s9">
<input id="description" type="text" onkeyup="updateCard()">
<input id="description" type="text" name="roledesc" onkeyup="updateCard()">
<label for="description">Roledescription</label>
</div>
</div>
<div class="row">
<div class="input-field col s3">
<select id="rolecolor" onchange="updateCard()">
<select id="rolecolor" name="rolecolor" onchange="updateCard()">
<option value="" disabled selected>Color</option>
<option value="red">Red</option>
<option value="pink">Pink</option>
@ -69,7 +69,7 @@
<label>Select color</label>
</div>
<div class="input-field col s3">
<select id="modifier" onchange="updateCard()">
<select id="modifier" name="rolemod" onchange="updateCard()">
<option value="" selected>None</option>
<option value="lighten">Lighten</option>
<option value="darken">Darken</option>
@ -78,7 +78,7 @@
<label>Select Modifier</label>
</div>
<div class="input-field col s3">
<select id="strength" onchange="updateCard()">
<select id="strength" name="rolestrength" onchange="updateCard()">
<option value="" selected>No Strength</option>
<option value="1">1</option>
<option value="2">2</option>
@ -88,7 +88,7 @@
<label>Select Strength</label>
</div>
<div class="input-field col s3">
<select id="tcolor" onchange="updateCard()">
<select id="tcolor" name="textcol" onchange="updateCard()">
<option value="" disabled selected>Textcolor</option>
<option value="black-text">Black</option>
<option value="white-text">White</option>
@ -98,13 +98,13 @@
</div>
<div class="row">
<div class="input-field col s12">
<textarea id="howtoplay" onkeyup="updateCard()" class="materialize-textarea"></textarea>
<textarea id="howtoplay" name="howtoplay" onkeyup="updateCard()" class="materialize-textarea"></textarea>
<label for="howtoplay">Text to describe how to play</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<select id="goodRoles" onchange="updateCard()" multiple>
<select id="goodRoles" name="goodRoles" onchange="updateCard()" multiple>
<option value="" disabled> Choose your option </option>
<?php
$files = glob("roles/en/*.php");
@ -123,33 +123,42 @@
</div>
<div class="row">
<div class="input-field col s6">
<textarea id="gconvars" onkeyup="updateCard()" class="materialize-textarea"></textarea>
<textarea id="gconvars" name="gconvars" onkeyup="updateCard()" class="materialize-textarea"></textarea>
<label for="convars">Paste your general convars</label>
</div>
<div class="input-field col s6">
<textarea id="cconvars" onkeyup="updateCard()" class="materialize-textarea"></textarea>
<textarea id="cconvars" name="cconvars" onkeyup="updateCard()" class="materialize-textarea"></textarea>
<label for="convars">Paste your role specific convars</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<textarea id="credits" onkeyup="updateCard()" class="materialize-textarea"></textarea>
<textarea id="credits" name="credits" onkeyup="updateCard()" class="materialize-textarea"></textarea>
<label for="credits">Drop your credits here!</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input id="steam" type="text" onkeyup="updateCard()">
<input name="steam" id="steam" type="text" onkeyup="updateCard()">
<label for="steam">Steamlink</label>
</div>
<div class="input-field col s6">
<input id="source" type="text" onkeyup="updateCard()">
<input name="source" id="source" type="text" onkeyup="updateCard()">
<label for="source">Sourcelink</label>
</div>
</div>
<div class="row">
<div class="input-field col s9">
<select id="language" name="language">
<option value="en" selected>English</option>
<option value="ch">Schwiizerdütsch</option>
<option value="de">Deutsch</option>
</select>
</div>
<button class="btn waves-effect waves-light col s3" type="submit" value="Submit" name="action">Submit <i class="material-icons right">send</i>
</button>
</div>
</form>
<button class="btn waves-effect waves-light" type="submit" name="action">Submit <i class="material-icons right">send</i>
</button>
</div>
</div>
<!-- Cardpreview -->
@ -208,9 +217,9 @@
</div>
<div class="center collapsible-body">
<span>
<a id="steamurl" href="">Steam Workshop</a>
<a id="steamurl">Steam Workshop</a>
<br>
<a id="githuburl" href="">Github Source</a>
<a id="githuburl">Github Source</a>
</div>
</span>
</li>
@ -290,19 +299,13 @@
document.getElementById("rcvars").innerHTML = document.getElementById("cconvars").value;
}
function updateSteam() {
document.getElementById("steamurl").setAttribute(href, document.getElementById("steam").value);
document.getElementById("steamurl").setAttribute("href", document.getElementById("steam").value);
}
function updateSource() {
document.getElementById("githuburl").setAttribute(href, document.getElementById("source").value);
document.getElementById("githuburl").setAttribute("href", document.getElementById("source").value);
}
</script>
<!-- Start Tab init -->
<script>
$(document).ready(function() {
$('select').formSelect();
@ -310,7 +313,7 @@
M.updateTextFields();
});
</script>
<!-- End Tab init -->
<!--JavaScript at end of body for optimized loading-->
<script type="text/javascript" src="js/materialize.min.js"></script>
</body>

View File

@ -236,6 +236,7 @@
function closeToasts() {
setCookie('loading','true', 1);
M.Toast.dismissAll()
$('.tap-target').tapTarget('open');
}
function openCookies() {
@ -244,28 +245,21 @@
$(document).ready(function(){
$('.collapsible').collapsible();
// $('.tabs').tabs();
$('.sidenav').sidenav();
$('.tap-target').tapTarget();
// Only show the Menu informer once
var x = getCookie('loading');
if (x) {} else {
$('.tap-target').tapTarget('open');
// Cookie warn
M.toast({html: "By using my page you accept our cookies! <button class='btn-flat waves-effect waves-light toast-action' onclick='closeToasts()'>I don't care</button> <button onclick='openCookies()' class='btn-flat waves-effect waves-light toast-action''>What cookies?</button>", displayLength: "9999999999999999999999999999999"})
}
});
</script>
<!-- End Tab init -->
<!--JavaScript at end of body for optimized loading-->
<script type="text/javascript" src="js/materialize.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
</body>
</html>

23
login.php Normal file
View File

@ -0,0 +1,23 @@
<?php
$user = $_POST['user'];
$pass = $_POST['pass'];
if($user == "admin"
&& $pass == "soup")
{
include("create.php");
}
else
{
if(isset($_POST))
{
echo '
<form method="POST" action="login.php">
User <input type="text" name="user"></input><br/>
Pass <input type="password" name="pass"></input><br/>
<input type="submit" name="submit" value="Go"></input>
</form>
';
}
}
?>