TTT_Role_Overview/confirm.php

105 lines
2.5 KiB
PHP

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