Version 2
This commit is contained in:
51
pagecontent/action-vocAdd.php
Normal file
51
pagecontent/action-vocAdd.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
// Vokabel-Eingabe holen
|
||||
$vokinputtmpleft = iconv('UTF-8','ASCII//TRANSLIT',addslashes(htmlentities(substr($_POST["vokinputtmpleft"], 0, 30), ENT_QUOTES, 'UTF-8')));
|
||||
$vokinputtmpright = iconv('UTF-8','ASCII//TRANSLIT',addslashes(htmlentities(substr($_POST["vokinputtmpright"], 0, 30), ENT_QUOTES, 'UTF-8')));
|
||||
|
||||
// Testen, ob beides ausgefüllt
|
||||
if(empty($vokinputtmpleft) || empty($vokinputtmpright)) {
|
||||
die();
|
||||
}
|
||||
|
||||
// ID wird generiert
|
||||
$id = '';
|
||||
$string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJLKMNOPQRSTUVW0123456789";
|
||||
for ($i = 1; $i <= 8; $i++)
|
||||
{
|
||||
$zufallszahl = rand(0, 62);
|
||||
$zufallszahl = substr($string, $zufallszahl, 1);
|
||||
$id = $id . $zufallszahl;
|
||||
}
|
||||
|
||||
// Teten ob ID bereits IN DIESEM ORDNER vorhanden
|
||||
$sql = "SELECT `id` FROM `VokabelBox2Content` WHERE `id` = '$id' AND `type` = 'voc' AND `path` = '$userid/lang/$list/'";
|
||||
$result_articles = $conn->query($sql);
|
||||
if(mysqli_num_rows($result_articles))
|
||||
{
|
||||
die();
|
||||
}
|
||||
|
||||
// Eingabe wird im JSON-Format gespeichert
|
||||
$value[0]['1'] = $vokinputtmpleft;
|
||||
$value[0]['2'] = $vokinputtmpright;
|
||||
$value[0]['progress'] = "0";
|
||||
$value = json_encode($value);
|
||||
|
||||
$path = "$userid/lang/$list/";
|
||||
|
||||
// Anzahl im Nutzerkonto gespeicherter Vokabeln wird geholt
|
||||
$sql = "SELECT `id` FROM `VokabelBox2Content` WHERE `path` LIKE '$userid/%' AND `type` = 'voc'";
|
||||
$result_articles = $conn->query($sql);
|
||||
$statVOC = mysqli_num_rows($result_articles);
|
||||
|
||||
if($statVOC > '1000') {
|
||||
die();
|
||||
}
|
||||
|
||||
$conn->query("INSERT INTO `VokabelBox2Content`(`id`, `path`, `value`, `type`) VALUES ('$id','$path','$value','voc')");
|
||||
|
||||
print("true");
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user