-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtranslate.php
More file actions
22 lines (18 loc) · 965 Bytes
/
translate.php
File metadata and controls
22 lines (18 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
if (!(isset($_GET['fromLang']))) die('NO FROM LANG'); else $langFrom = $_GET['fromLang'];
if (!(isset($_GET['toLang']))) die('NO TO LANG'); else $langTo = $_GET['toLang'];
if (!(isset($_GET['text']))) die('NO TEXT'); else $text = json_decode($_GET['text'], 1);
if (!($text)) die('TEXT INVALID');
$output = '';
$mysqli = new mysqli('origin.najemi.cz', 'czechify_bot', 'eitY8H1YWEskGTsW', 'czechify');
foreach ($text as $t) {
$t = $mysqli->escape_string($t);
$langTo = $mysqli->escape_string($langTo);
$langFrom = $mysqli->escape_string($langFrom);
$query = $mysqli->query("SELECT `word_target` FROM `bot_translate_data` WHERE `base_language` = '$langFrom' AND `target_language` = '$langTo' AND `word_base` = '$t'");
if (!($query)) die('QUERY FAILED!');
$found = '';
while ($row = $query->fetch_assoc()) $found = $row['word_target'];
if ($found) $output .= $found; else $output .= $t;
}
echo str_replace('\n', "\n", $output);