Files
furatalog-web/admin/redirectFromJinxxy.php
T

194 lines
6.7 KiB
PHP

<?php
session_start();
if (isset($_SESSION["tmpdata"])) {
$_POST["data"] = $_SESSION["tmpdata"];
unset($_SESSION["tmpdata"]);
}
if (!isset($_SESSION["login"]) && $_SESSION["login"] != "true-as-hell") {
$_SESSION["tmpdata"] = $_POST["data"];
header("Location: login.php?ref=redirectFromJinxxy");
die();
}
$creator_name;
$creator_pb;
$creator_jinxxyURL;
$content_name;
$content_price;
$content_rating;
$content_creator_id;
$content_currency_id;
$content_url;
$content_image;
$userData;
$productData;
$data = json_decode($_POST["data"]);
$apolloState = $data->props->pageProps->__APOLLO_STATE__;
$rootData = $data->props->pageProps->__APOLLO_STATE__->ROOT_QUERY;
// getting the product data
foreach ($rootData as $key => $value) {
if (strpos($key, 'product') !== false) {
$temp = $value->__ref;
foreach ($apolloState as $key => $value) {
if (strpos($key, $temp) !== false) {
$productData = $value;
}
}
}
}
// getting the user data
foreach ($apolloState as $key => $value) {
if (strpos($key, $productData->user->__ref) !== false) {
$userData = $value;
}
}
// getting user profilePicture
foreach ($apolloState as $key => $value) {
if (strpos($key, $userData->profile_image->__ref) !== false) {
$creator_pb = $value->url;
}
}
foreach ($apolloState as $key => $value) {
if (strpos($key, $productData->cover->__ref) !== false) {
$content_image = $value->url;
}
}
// set creator name
$creator_name = $userData->name;
// set creator jinxxy url
$creator_jinxxyURL = "https://jinxxy.com/" . $userData->username;
// set content name
$content_name = $productData->name;
// set content price
$content_price = $productData->base_price;
// set procuct url
$content_url = "https://jinxxy.com/" . $data->props->pageProps->username . "/" . $data->props->pageProps->url_slug;
// set no rating
$content_rating = "null";
// currency type
$currency_currency = strtolower($productData->currency_code);
$databaseConnection = new mysqli("localhost", "furatalog_usr", "1yRNpaUtXu[cw@-m", "furatalog");
$result = $databaseConnection->query("SELECT * FROM `currency` WHERE currency=\"" . $currency_currency . "\";");
$content_currency_id = $result->fetch_assoc()["id"];
$result2 = $databaseConnection->query("SELECT * FROM `creator` WHERE jinxxy_url=\"" . $creator_jinxxyURL . "\";");
if ($result2->num_rows > 0) {
$content_creator_id = $result2->fetch_assoc()["id"];
} else {
$content_creator_id = "";
}
/*
echo '<br><span style="font-family: consolas">Creator Name </span>' . $creator_name;
echo '<br><span style="font-family: consolas">Creator PB </span>' . $creator_pb;
echo '<br><span style="font-family: consolas">Creator JinxxyURL </span>' . $creator_jinxxyURL;
echo '<br>';
echo '<br>';
echo '<br>';
echo '<br><span style="font-family: consolas">Content Name </span>' . $content_name;
echo '<br><span style="font-family: consolas">Content Price </span>' . $content_price;
echo '<br><span style="font-family: consolas">Content Rating </span>' . $content_rating;
echo '<br>';
echo '<br><span style="font-family: consolas">Content CreatorID </span>' . $content_creator_id;
echo '<br><span style="font-family: consolas">Content CurrencyID </span>' . $content_currency_id;
echo '<br>';
echo '<br><span style="font-family: consolas">Content URL </span>' . $content_url;
echo '<br><span style="font-family: consolas">Content Image </span>' . $content_image;
echo '<br>';
echo '<br><span style="font-family: consolas">Currency Code </span>' . $currency_currency;
*/
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php echo file_get_contents("/var/www/furatalog-cdn/mainHead.html"); ?>
<title>Insert From Jinxxy - Admin Panel - Furatalog.xyz</title>
</head>
<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>
<input type="text" name="content_name" value="<?php echo $content_name; ?>"><br>
<input type="text" name="content_price" value="<?php echo $content_price; ?>"><br>
<input type="text" name="content_rating" value="<?php echo $content_rating; ?>"><br>
<input type="text" name="content_creator_id" value="<?php echo $content_creator_id; ?>"><br>
<input type="text" name="content_currency_id" value="<?php echo $content_currency_id; ?>"><br>
<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;" value="props">
<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(' ');
if (resultInput.value == "" || resultInput.value == " ") {
resultInput.value = "props";
}
}
// Add event listeners to all checkboxes
checkboxes.forEach(checkbox => {
checkbox.addEventListener('change', updateResult); // Listen for 'change' event
});
</script>
</body>
</html>