Version 2
This commit is contained in:
47
pagecontent/action-listAdd.php
Normal file
47
pagecontent/action-listAdd.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user