Insertion for Jinxxy added

This commit is contained in:
2025-05-29 23:10:56 +02:00
parent 671fb6a0fe
commit 1e33bdcf9b
2 changed files with 173 additions and 0 deletions
+139
View File
@@ -0,0 +1,139 @@
<?php
session_start();
if (!isset($_SESSION["login"]) && $_SESSION["login"] != "true-as-hell") {
header("Location: login.php");
die();
}
$furatalog = new mysqli("localhost", "furatalog_admin_usr", "NR6tLk7c56bPT5[]", "furatalog");
$creator_name = $_POST["creator_name"];
$creator_pb = $_POST["creator_pb"];
$creator_jinxxyURL = $_POST["creator_jinxxyURL"];
$content_name = $_POST["content_name"];
$content_price = $_POST["content_price"];
$content_rating = $_POST["content_rating"];
$content_creator_id = $_POST["content_creator_id"];
$content_currency_id = $_POST["content_currency_id"];
$content_url = $_POST["content_url"];
$content_image = $_POST["content_image"];
$currency_currency = $_POST["currency_currency"];
$creator;
$success = true;
$creatorResult = $furatalog->query("SELECT * FROM `creator` WHERE `jinxxy_url`=\"" . $creator_jinxxyURL . "\";");
if ($creatorResult->num_rows == 0) {
$furatalog->query("INSERT INTO `creator`(`name`, `pb_url`, `jinxxy_url`) VALUES ('" . $creator_name . "','" . $creator_pb . "','" . $creator_jinxxyURL . "')");
$creator = $creatorResult->fetch_assoc();
} else {
$creator = $creatorResult->fetch_assoc();
}
$contentResult = $furatalog->query("SELECT * FROM `content` WHERE `url`=\"" . $content_url . "\";");
if ($contentResult->num_rows == 0) {
try {
$furatalog->query("INSERT INTO `content`(`name`, `price`, `rating`, `creator_id`, `currency_id`, `url`, `image`, `nsfw`, `section`) VALUES
('" . $content_name . "'
,'" . $content_price . "'
,'" . $content_rating . "'
,'" . $creator["id"] . "'
,'" . $content_currency_id . "'
,'" . $content_url . "'
,'" . $content_image . "'
, false
, 1)");
$parsed_url = parse_url($content_url);
$clean_url = $parsed_url['scheme'] . '://' . $parsed_url['host'] . $parsed_url['path'];
$contentResult = $furatalog->query("SELECT * FROM content WHERE url LIKE '%" . $clean_url . "%'");
$contentResultResult = $contentResult->fetch_assoc();
$species = explode(" ", $_POST["species"]);
foreach ($species as $key => $value) {
$speciesResult = $furatalog->query("SELECT * FROM species WHERE tag='" . $value . "'");
$speciesResultResult = $speciesResult->fetch_assoc();
$speciesID = $speciesResultResult["id"];
$furatalog->query("INSERT INTO `content_species` (`content_id`, `species_id`) VALUES ('" . $contentResultResult["id"] . "', '" . $speciesID . "')");
}
} catch (Exception $e) {
echo "
<html>
<head>
<style>
* {
background: darkgray;
color: white;
}
</style>
</head>
<body>
<p style=\"color:lightred\">An Error has Occurred</p>
<div>" . $e . "</div>
</body>
</html>";
$success = false;
}
if ($success) {
echo "<html>
<head>
<style>
* {
background: darkgray;
color: white;
}
</style>
</head>
<body>
<p style=\"color:lightred\">Success</p>
<div>The Item with the following name and url has been added. <br>
Name: " . $content_name . "</div>
</body>
</html>";
}
}
?>
+34
View File
@@ -587,6 +587,18 @@ echo '<br><span style="font-family: consolas">Currency Code </span>' . $cur
<body>
<div class="main">
<form action="insert-jinxxy.php" class="insert" method="post">
<div>
<?php
$furatalog = new mysqli("localhost", "furatalog_admin_usr", "NR6tLk7c56bPT5[]", "furatalog");
$requestSpeciesResult = $furatalog->query("SELECT * FROM `species`");
while ($row = $requestSpeciesResult->fetch_assoc()) {
echo "
<label>
<input type=\"checkbox\" name=\"" . $row["tag"] . "\">" . $row["name"] . "
</label><br>";
}
?>
</div>
<input type="text" name="creator_name" value="<?php echo $creator_name; ?>"><br>
<input type="text" name="creator_pb" value="<?php echo $creator_pb; ?>"><br>
<input type="text" name="creator_jinxxyURL" value="<?php echo $creator_jinxxyURL; ?>"><br>
@@ -598,8 +610,30 @@ echo '<br><span style="font-family: consolas">Currency Code </span>' . $cur
<input type="text" name="content_url" value="<?php echo $content_url; ?>"><br>
<input type="text" name="content_image" value="<?php echo $content_image; ?>"><br>
<input type="text" name="currency_currency" value="<?php echo $currency_currency; ?>"><br>
<input type="text" name="species" id="speciesIncluded" style="display: none;">
<input type="submit" value="Insert">
</form>
</div>
<script>
// Select all checkboxes and the result input field
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
const resultInput = document.getElementById('speciesIncluded');
// Function to update the result input field
function updateResult() {
const selectedNames = Array.from(checkboxes) // Convert NodeList to Array
.filter(checkbox => checkbox.checked) // Filter only checked checkboxes
.map(checkbox => checkbox.name); // Map to their name attributes
// Join the names with a comma and update the result input
resultInput.value = selectedNames.join(' ');
}
// Add event listeners to all checkboxes
checkboxes.forEach(checkbox => {
checkbox.addEventListener('change', updateResult); // Listen for 'change' event
});
</script>
</body>
</html>