Needs some validation fixing but then it works!

This commit is contained in:
Jesse James Isler 2022-04-04 16:38:47 +02:00
parent 561850c399
commit 53dd162e91
2 changed files with 39 additions and 25 deletions

View File

@ -1,25 +1,26 @@
<body> <body>
<html> <html>
<?php <?php
if (preg_match('/^[\/\w\-. ]+$/', $_POST['rolename'])){ if (preg_match('/^[\/\w\-. ]+$/', $_POST['rolename'].'.php')){
echo 'VALID FILENAME'; echo 'VALID FILENAME';
$language = $_POST['language']; $language = $_POST['language'];
$rolefile = "roles/".$language."/".$_POST['rolename'].".php"; $rolefile = fopen("roles/".$language."/".$_POST['rolename'].".php", "w");
fopen($rolefile, "w");
#Initialisation
fwrite($rolefile, '<?php'.PHP_EOL);
# #
# COLORS # COLORS
# #
# Text Color
$f_tcolor = $_POST['textcol'];
fwrite($rolefile, $f_tcolor);
# This is the color defined by https://materializecss.com/color.html # This is the color defined by https://materializecss.com/color.html
$f_color = $_POST['rolecolor']." ".$_POST['rolestrength']."-".$_POST['rolemod']; $f_color = $_POST['rolecolor']." ".$_POST['rolestrength']."-".$_POST['rolemod'];
fwrite($rolefile, $f_color); fwrite($rolefile, '$color = "'.$f_color.'"'.PHP_EOL);
# Text Color
$f_tcolor = $_POST['tcolor'];
fwrite($rolefile, '$tcolor = '.$f_tcolor.PHP_EOL);
# #
@ -28,10 +29,11 @@ if (preg_match('/^[\/\w\-. ]+$/', $_POST['rolename'])){
#The Name of the Role #The Name of the Role
$f_name = $_POST['rolename']; $f_name = $_POST['rolename'];
fwrite($rolefile, $f_name); fwrite($rolefile, '$name = '.$f_name.PHP_EOL);
#The Description of the Role, HTML conform :) #The Description of the Role, HTML conform :)
$f_description = $_POST['roledesc']; $f_description = $_POST['roledesc'];
fwrite($rolefile, $f_description); fwrite($rolefile,'$description = '. $f_description.PHP_EOL);
@ -42,14 +44,15 @@ if (preg_match('/^[\/\w\-. ]+$/', $_POST['rolename'])){
#How To play #How To play
$f_howtoplay = $_POST['howtoplay']; $f_howtoplay = $_POST['howtoplay'];
fwrite($rolefile, $f_howtoplay); fwrite($rolefile, '$howtoplay = '.$f_howtoplay.PHP_EOL);
#With what roles does this role play best? #With what roles does this role play best?
fwrite($rolefile, '$playsbestwith = "<ul>'); fwrite($rolefile, '$playsbestwith = "<ul>'.PHP_EOL);
foreach($_POST['goodRoles'] as $selectedOption) { foreach($_POST['goodRoles'] as $selectedOption) {
fwrite($rolefile, '<li>'.$selectedOption.'</li>'); fwrite($rolefile, '<li>'.$selectedOption.'</li>'.PHP_EOL);
}; };
fwrite($rolefile, '<</ul>"'); fwrite($rolefile, '</ul>;"'.PHP_EOL);
#Convars #Convars
@ -59,7 +62,7 @@ if (preg_match('/^[\/\w\-. ]+$/', $_POST['rolename'])){
Rolespecific Convars: Rolespecific Convars:
<code>'.$_POST['cconvars'].'</code>"'; <code>'.$_POST['cconvars'].'</code>"';
fwrite($rolefile, $f_convars); fwrite($rolefile, $f_convars.PHP_EOL);
# #
@ -68,21 +71,22 @@ if (preg_match('/^[\/\w\-. ]+$/', $_POST['rolename'])){
#The Steam URL to your addon #The Steam URL to your addon
$f_steam = $_POST['steam']; $f_steam = $_POST['steam'];
fwrite($rolefile, $f_steam); fwrite($rolefile, '$steam = '.$f_steam.PHP_EOL);
#The Source URL to your addon #The Source URL to your addon
$f_source = $_POST['source']; $f_source = $_POST['source'];
fwrite($rolefile, $f_source); fwrite($rolefile, '$source = '.$f_source.PHP_EOL);
#Creator of the Addon #Creator of the Addon
$f_author = $_POST['']; $f_author = $_POST['creator'];
fwrite($rolefile, $f_author); fwrite($rolefile, '$author = '.$f_author.PHP_EOL);
#Creatorlink #Creatorlink
$f_authorurl = $_POST['']; $f_authorurl = $_POST['creatorurl'];
fwrite($rolefile, $f_authorurl); fwrite($rolefile, '$authorurl = '.$f_authorurl.PHP_EOL);
# Credittext (can use the above variables) # Credittext (can use the above variables)
$f_ctext = $_POST['credits']; $f_ctext = $_POST['credits'];
fwrite($rolefile, $f_ctext); fwrite($rolefile, '$ctext = '.$f_ctext);
fwrite($rolefile, PHP_EOL.'?>');
fclose($rolefile); fclose($rolefile);
} else { } else {
echo 'INVALID ROLENAME'; echo 'INVALID ROLENAME';

View File

@ -88,7 +88,7 @@
<label>Select Strength</label> <label>Select Strength</label>
</div> </div>
<div class="input-field col s3"> <div class="input-field col s3">
<select id="tcolor" name="textcol" onchange="updateCard()"> <select id="tcolor" name="tcolor" onchange="updateCard()">
<option value="" disabled selected>Textcolor</option> <option value="" disabled selected>Textcolor</option>
<option value="black-text">Black</option> <option value="black-text">Black</option>
<option value="white-text">White</option> <option value="white-text">White</option>
@ -104,7 +104,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="input-field col s12"> <div class="input-field col s12">
<select id="goodRoles" name="goodRoles" onchange="updateCard()" multiple> <select id="goodRoles" name="goodRoles[]" onchange="updateCard()" multiple="multiple">
<option value="" disabled> Choose your option </option> <option value="" disabled> Choose your option </option>
<?php <?php
$files = glob("roles/en/*.php"); $files = glob("roles/en/*.php");
@ -131,6 +131,16 @@
<label for="convars">Paste your role specific convars</label> <label for="convars">Paste your role specific convars</label>
</div> </div>
</div> </div>
<div class="row">
<div class="input-field col s6">
<input name="creator" id="creator" type="text" onkeyup="updateCard()">
<label for="creator">Steam Creator</label>
</div>
<div class="input-field col s6">
<input name="creatorurl" id="creatorurl" type="text" onkeyup="updateCard()">
<label for="creatorurl">Steeam Creator Link</label>
</div>
</div>
<div class="row"> <div class="row">
<div class="input-field col s12"> <div class="input-field col s12">
<textarea id="credits" name="credits" onkeyup="updateCard()" class="materialize-textarea"></textarea> <textarea id="credits" name="credits" onkeyup="updateCard()" class="materialize-textarea"></textarea>