Files
vokspace/pagecontent/action-listAdd.php
2026-01-02 21:08:58 +01:00

48 lines
1.3 KiB
PHP

<?php
// Nutzereingabe wird geholt
$listname = iconv('UTF-8','ASCII//TRANSLIT',addslashes(htmlentities(substr($_POST["listname"], 0, 30), ENT_QUOTES, 'UTF-8')));
// Testen, ob leer
if($listname == '' )
{
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;
}
// Testen ob die ID schon vorhanden ist.
// WICHTIG: Die ID einer Liste darf ***insgesamt*** nur ein Mal vorhanden sein! Sie ist nicht auf die Benutzer-ID bezogen!
$sql = "SELECT `id` FROM `VokabelBox2Content` WHERE `id` = '$id' AND `type` = 'list'";
$result_articles = $conn->query($sql);
if(mysqli_num_rows($result_articles))
{
die();
}
// Pfad wird gesetzt
$path = "$userid/" . $lang . "/";
$sql = "SELECT `id` FROM `VokabelBox2Content` WHERE `path` LIKE '$userid/%' AND `type` = 'list'";
$result_articles = $conn->query($sql);
$statLIST = mysqli_num_rows($result_articles);
if($statLIST > '500') {
die();
}
//Neue Liste wird in die Datenbank geladen
$conn->query("INSERT INTO `VokabelBox2Content`(`id`, `path`, `value`, `type`) VALUES ('$id','$path','$listname','list')");
// JS darf fortfahren
echo "true";
?>