Translation successfully updated. Thanks for your support!"; } else { echo "

Invalid username or password provided! Perhaps you don't have permission to edit this language?

"; } } $lang = $_GET["language"]; function parse_properties($txtProperties) { $result = array(); $lines = explode("\n", $txtProperties); $key = ""; $isWaitingOtherLine = false; foreach ($lines as $i => $line) { if (empty($line) || (!$isWaitingOtherLine && strpos($line, "#") === 0)) continue; $value = ""; if (!$isWaitingOtherLine) { $key = substr($line, 0, strpos($line, '=')); $value = substr($line, strpos($line, '=')+1, strlen($line)); } else { $value .= $line; } /* Check if ends with single '\' */ if (strrpos($value, "\\") === strlen($value)-strlen("\\")) { $value = substr($value,0,strlen($value)-1)."\n"; $isWaitingOtherLine = true; } else { $isWaitingOtherLine = false; } $result[$key] = $value; unset($lines[$i]); } return $result; } $dir = new DirectoryIterator(dirname(__FILE__)); foreach ($dir as $fileinfo) { if (!$fileinfo->isDot()) { $filename = $fileinfo->getFilename(); $arr = explode('.', $filename); $extension = $arr[sizeof($arr)-1]; if($extension == "lang") { $langname = $arr[0]; $strings = parse_properties(file_get_contents($filename)); $sql = 'SELECT * FROM localization WHERE language=?'; $stmt = $con->prepare($sql); $stmt->bindParam(1, $langname); $stmt->execute(); $found = []; while($row = $stmt->fetch()) { $found[$row["key"]] = $row["value"]; } foreach($strings as $key => $value) { if(!array_key_exists($key, $found)) { $sql = 'INSERT INTO localization VALUES(?,?,?,0)'; $stmt = $con->prepare($sql); $stmt->bindParam(1, $key); $stmt->bindParam(2, $value); $stmt->bindParam(3, $langname); $stmt->execute(); } else { $val = $found[$key]; if($val != $value) { $sql = 'UPDATE localization SET value=? WHERE key=? AND language=?'; $stmt = $con->prepare($sql); $stmt->bindParam(1, $value); $stmt->bindParam(2, $key); $stmt->bindParam(3, $langname); $stmt->execute(); } } } } } } $sql = 'SELECT * FROM localization WHERE language="en_US"'; $stmt = $con->prepare($sql); $stmt->execute(); $found = []; while($row = $stmt->fetch()) { $found[$row["key"]] = $row["value"]; } $sql = 'SELECT * FROM localization WHERE language=?'; $stmt = $con->prepare($sql); $stmt->bindParam(1, $lang); $stmt->execute(); $active = []; while($row = $stmt->fetch()) { $active[$row["key"]] = $row["value"]; } echo '

Translate the Replay Mod ('.$lang.')

'; foreach($found as $key => $value) { $val = $value; $highlight = false; if(array_key_exists($key, $active)) { $val = $active[$key]; } else { $highlight = true; } if(isset($_GET[enc($key)])) { $val = $_GET[enc($key)]; } echo ""; echo ''; echo ""; echo ""; } echo '
KeyTranslatedOriginal
$key$value

Username
Password
'; ?>