<?php include '../includes/connect_to_db.php'; generate_lang_file('play', 'en'); //if(isset($_GET['type'])) function generate_lang_file($type, $lang) { //echo $_GET['type']; //$type = $_GET['type']; $request = mysql_query("SELECT * FROM tbl_translations WHERE t_type='{$type}' AND t_lang='{$lang}'"); $file_contents = "<?php\r\n"; while ($rows = mysql_fetch_array($request)) { $file_contents .= 'define("' . $rows['t_key'] . '", \'' . $rows['t_value'] . '\');'; $file_contents .= "\r\n"; } $file_contents .= "?>"; echo $file_contents; $filename = "{$lang}/{$type}.php"; echo $filename; $fH = fopen($filename, 'w') or die("can't open file"); fwrite($fH, $file_contents); fclose($fH); }
echo '<span style="width:200px;display:inline-block;">' . $rows['t_key'] . ': </span><input type="text" name="val" value="' . $rows['t_value'] . '">'; echo '<input type="hidden" name="lang" value="' . $lang . '">'; echo '<input type="submit" name="action" value="Save">'; echo "</form>"; } if ($_POST['action'] == 'Add') { //echo $_POST['newkey']; $nkey = $_POST['newkey']; $ntype = $_POST['newtype']; $nval = $_POST['newvalue']; for ($i = 0; $i < count($langs); $i++) { $nlang = $langs[$i]; mysql_query("INSERT INTO tbl_translations (t_key, t_type, t_value, t_lang) VALUES ('{$nkey}', '{$ntype}', '{$nval}', '{$nlang}')"); //echo 'mysql_query("INSERT INTO tbl_translations (t_key, t_type, t_value, t_lang) VALUES (\''.$nkey.'\', \''.$ntype.'\', \''.$nval.'\', \''.$nlang.'\')");<br>'; } } if ($_POST['action'] == 'Generate') { generate_lang_file($type, $lang); } if ($_POST['action'] == 'New') { new_lang($_POST['newlang']); } } ?> <form method="post" action="manage_translations.php"> <select name="type"> <option value="play">Play</option> <option value="delete">Delete</option> </select> <select name="lang">