Show sourcecode
The following files exists in this folder. Click to view.
create-user.php
index.php
initialize-db.php
insert.php
insert_page.php
test.php
translate.php
insert.php
37 lines ASCII Windows (CRLF)
<?php
include "../include.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
session_start();
$words = explode("\n", trim($_POST["words"]));
$lang = $_POST["lang"];
foreach ($words as $word) {
$word = trim(strtolower($word));
$translations = get_predefined_translation($word);
if ($translations == null || count($translations) == 0)
continue;
try {
quick_statment("INSERT INTO word (word) VALUES (?)", "s", $word);
} catch (Exception $e) {
// word already exists (just add new translation)
echo 2;
continue;
}
$wordId = quick_statment("SELECT id FROM word WHERE word=?", "s", $word)->fetch_assoc()["id"];
$userId = user_id();
echo $word;
var_dump($translations);
foreach ($translations as $translation) {
quick_statment("INSERT INTO translation (translation, word_id) VALUES(?, ?)", "si", $translation, $wordId);
$translationId = quick_statment("SELECT id FROM translation WHERE translation=?", "s", $translation)->fetch_assoc()["id"];
quick_statment("INSERT INTO translation_settings (translation_id, user_id, disabled, priority) VALUES(?, ?, false, false)", "ii", $translationId, $userId);
}
}
}
include "insert_page.php";