Files

195 lines
5.5 KiB
PHP
Raw Permalink Normal View History

2025-05-20 12:36:47 +02:00
<head>
<style>
@font-face{
font-family: rubik;
src: url(https://mfgames.net/assets/Rubik-VariableFont_wght.ttf);
}
* {
font-family: rubik;
}
input {
color: white;
background-color: #2e2e2e;
border: none;
font-size: 20px;
margin: 3px;
padding: 5px;
border-radius: 5px;
}
button {
color: white;
background-color: #3e3e3e;
border: none;
font-size: 20px;
margin: 3px;
padding: 5px 10px;
border-radius: 10px;
}
</style>
</head>
<?php
/*$_POST["url"] = "https://polycrow.gumroad.com/l/airhocks";
$_POST["species"] = "Rexouium Novabeast";
$_POST["nsfw"] = 0;
$_GET["section"] = 1;*/
$url = $_POST["url"];
$species = $_POST["species"];
$nsfw = $_POST["nsfw"];
$section = $_GET["section"];
$isExisting = false;
if (isset($_POST["url"]) && isset($_POST["species"]) && isset($_POST["nsfw"])) {
//if (true) {
$servername = "localhost";
$username = "database_access";
$password = "DataAccess1.";
$dbname = "avali_shop";
if (str_contains($url, '?')) {
$url = substr($url, 0, strpos($url, "?"));
}
$string = file_get_contents($url);
$dom = new DomDocument();
$dom->loadHTML($string);
$finder = new DomXPath($dom);
$content = $finder->query("//*[contains(concat(' ', normalize-space(@data-component-name), ' '), ' ProductPage ')]")[0]->textContent;
$content = json_decode($content);
$c = $content->product;
$currency = "{
\"usd\": \"$\",
\"eur\": \"\",
\"crc\": \"\",
\"gbp\": \"£\",
\"ils\": \"\",
\"inr\": \"\",
\"jpy\": \"¥\",
\"krw\": \"\",
\"ngn\": \"\",
\"php\": \"\",
\"pln\": \"\",
\"pyg\": \"\",
\"thb\": \"฿\",
\"uah\": \"\",
\"vnd\": \"\",
\"aud\": \"A\$\",
\"cad\": \"CAD\$\"
}";
$currency = json_decode($currency);
$currencyOutput = $c->currency_code;
if ($c->thumbnail_url == null) {
$thumbnailURL = $c->covers[0]->url;
} else $thumbnailURL = $c->thumbnail_url;
$rating = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' rating-average ')]")[0]->textContent;
if ($rating == null || $rating == "" || $rating == " ") $rating = "None";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
$failed = true;
}
$c->name = str_replace("'","\'",str_replace("`","\`",str_replace('"','\"',$c->name)));
$c->seller->name = str_replace("'","\'",str_replace("`","\`",str_replace('"','\"',$c->seller->name)));
$species = str_replace("'","\'",str_replace("`","\`",str_replace('"','\"',$species)));
$sql2 = "SELECT * FROM `content` WHERE
name LIKE \"%" . $c->name . "%\" AND
url_link LIKE \"%" . $url . "%\" AND
url_image LIKE \"%" . $thumbnailURL . "%\" AND
creator LIKE \"%" . $c->seller->name . "%\";";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
$isExisting = true;
} else {
$isExisting = false;
}
$sql = "INSERT INTO content (
`name`,
`price`,
`currency`,
`url_link`,
`url_image`,
`creator`,
`rating`,
`species`,
`nsfw`,
`section`
)
VALUES (
'" . $c->name . "',
'" . $c->price_cents . "',
'" . $currency->$currencyOutput . "',
'" . $url . "',
'" . $thumbnailURL . "',
'" . $c->seller->name . "',
'" . $rating . "',
'" . $species . "',
'" . $nsfw . "',
" . $section . "
)";
if ($isExisting == false) {
if ($conn->query($sql) === TRUE) {
echo "<a style=\"color: green;\">Successful !</a>";
} else {
$errormsg = "<a style=\"color: red;\">Error: " . $sql . "<br>" . $conn->error . "</a>";
$failed = true;
}
} else {
echo "<a style=\"color: orange;\">Already Exists!</a>";
}
$conn->close();
}
?>
<body style="background-color: #1e1e1e; color: white">
<form action="AutoInsertData.php?section=<?php echo $section; ?>" method="post">
<label for="url">URL:</label><br>
<input type="text" id="url" name="url" style="width:100%"><br>
<label for="species">Species:</label><br>
<input type="text" id="species" name="species" style="width:100%"><br>
<label for="nsfw">NSFW:</label><br>
<input type="text" id="nsfw" name="nsfw" value="0" style="width:100%">
<button type="submit">Submit</button>
</form>
<br>
<br>
<?php
echo "
'" . $c->name . "', <br>
'" . ($c->price_cents / 100) . "', <br>
'" . $currency->$currencyOutput . "', <br>
'" . $url . "', <br>
'" . $thumbnailURL . "', <br>
'" . $c->seller->name . "', <br>
'" . $rating . "', <br>
'" . $species . "',<br>
'" . $nsfw . "'";
?>