TTT_Role_Overview/confirm.php

106 lines
2.6 KiB
PHP
Raw Normal View History

<body>
<html>
<?php
2022-04-05 08:19:17 +00:00
2022-04-05 11:51:36 +00:00
function sanitizeMyThings($input)
2022-04-05 08:19:17 +00:00
{
2022-04-05 11:51:36 +00:00
$output = trim($input);
$output = filter_var($input, FILTER_SANITIZE_STRING);
return $output;
2022-04-05 08:19:17 +00:00
}
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
2022-04-05 11:51:36 +00:00
$f_color = sanitizeMyThings($_POST['rolecolor']." ".$_POST['rolemod']."-".$_POST['rolestrength']);
fwrite($rolefile, '$color = "'.$f_color.'";'.PHP_EOL);
# Text Color
2022-04-05 11:51:36 +00:00
$f_tcolor = sanitizeMyThings($_POST['tcolor']);
fwrite($rolefile, '$tcolor = "'.$f_tcolor.'-text";'.PHP_EOL);
#
# BASEINFO
#
#The Name of the Role
2022-04-05 11:51:36 +00:00
$f_name = sanitizeMyThings($_POST['rolename']);
fwrite($rolefile, '$name = "'.$f_name.'";'.PHP_EOL);
#The Description of the Role, HTML conform :)
2022-04-05 11:51:36 +00:00
$f_description = sanitizeMyThings($_POST['roledesc']);
fwrite($rolefile,'$description = "'. $f_description.'";'.PHP_EOL);
#
# TABS
#
#How To play
2022-04-05 11:51:36 +00:00
$f_howtoplay = sanitizeMyThings($_POST['howtoplay']);
fwrite($rolefile, '$howtoplay = "'.sanitizeMyThings($f_howtoplay).'";'.PHP_EOL);
#With what roles does this role play best?
2022-04-05 11:51:36 +00:00
fwrite($rolefile, '$playsbestwith = "<ul>;'.PHP_EOL);
2022-04-05 11:51:36 +00:00
foreach($_POST['goodRoles'] as $selectedOption) {
fwrite($rolefile, '<li>'.sanitizeMyThings($selectedOption).'</li>'.PHP_EOL);
};
2022-04-05 11:51:36 +00:00
fwrite($rolefile, '</ul>";'.PHP_EOL);
#Convars
$f_convars = '$convars = "Normal Role Convars (also found in ULX):
2022-04-05 11:51:36 +00:00
<code>'.sanitizeMyThings($_POST['gconvars']).'</code>
Rolespecific Convars:
2022-04-05 11:51:36 +00:00
<code>'.sanitizeMyThings($_POST['cconvars']).'</code>";';
fwrite($rolefile, $f_convars.PHP_EOL);
#
# Credits
#
#The Steam URL to your addon
2022-04-05 11:51:36 +00:00
$f_steam = sanitizeMyThings($_POST['steam']);
fwrite($rolefile, '$steam = "'.$f_steam.'";'.PHP_EOL);
#The Source URL to your addon
2022-04-05 11:51:36 +00:00
$f_source = sanitizeMyThings($_POST['source']);
fwrite($rolefile, '$source = "'.$f_source.'";'.PHP_EOL);
#Creator of the Addon
2022-04-05 11:51:36 +00:00
$f_author = sanitizeMyThings($_POST['creator']);
fwrite($rolefile, '$author = "'.$f_author.'";'.PHP_EOL);
#Creatorlink
2022-04-05 11:51:36 +00:00
$f_authorurl = sanitizeMyThings($_POST['creatorurl']);
fwrite($rolefile, '$authorurl = "'.$f_authorurl.'";'.PHP_EOL);
# Credittext (can use the above variables)
2022-04-05 11:51:36 +00:00
$f_ctext = sanitizeMyThings($_POST['credits']);
fwrite($rolefile, '$ctext = "'.$f_ctext.'";'.PHP_EOL);
2022-04-05 08:19:17 +00:00
fwrite($rolefile, '?>');
fclose($rolefile);
} else {
echo 'INVALID ROLENAME';
}
?>
</body>
</html>