rendered paste body<?phprequire('config.php');include('include/functions.php');include('include/chk_login.php');$uname = ($_SESSION['uname']);$cfg_file = $_GET['cfg_file'];$game = $_GET['game'];$mod = $_GET['mod'];$submit = $_POST['submit'];$file = $_POST['file'];$title = "Editing $cfg_file";include('header.php');$file_list = "cfg_files.list"; #get_game_home() lives in functions.php $game_home = get_game_home($game);if($mod !== '') { $game_home = "$game_home/$mod"; }if ($submit == "") {?><form method=POST action="cfg_edit.php"> <input type="hidden" name="file" value="<?php echo "$game_home/$cfg_file";?>"> <textarea name="new_config" cols="75" rows="30"><?php readmapcyclenobr("$game_home/$cfg_file")?></textarea> <br> <input type="submit" name="submit" value="Save Config"> <?php #include('../footer.php'); } else { $new_config = $_POST['new_config']; $filename = "$game_home/$file";// Let's make sure the file exists and is writable first.if (is_writable("$filename")) { //Make backup the original first if (!copy("$filename","$filename.bak")) { echo "Unable to backup the file before writing"; exit(); } if (!$handle = fopen($filename, 'w')) { echo "Cannot open file ($filename)"; exit(); } echo "Putting a lock on the file...<br>"; flock($handle, LOCK_EX); echo "<b>Writing out new config file...</b><br>"; $newconfig2 = str_replace('\"', '"', $new_config); fwrite($handle, $newconfig2); echo "Unlocking the file...<br>"; flock($handle, LOCK_UN); log_agent("$uname manually edited $filename"); echo "Success, wrote the new entries to file <b>($filename)</b>"; fclose($handle); } else { echo "The file $filename is not writable"; log_agent("$uname cannot write to edited $filename - not writable by webserver"); } echo "<br>"; #include('../footer.php'); } ?>