Files
furatalog-old-web/Insert From Array.php
T

181 lines
5.4 KiB
PHP
Raw 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
$multilineString = "https://nuciboli.gumroad.com/l/bee-hold?layout=discover&recommended_by=search
https://rickyop.gumroad.com/l/fowfoj?layout=discover&recommended_by=search
https://rickyop.gumroad.com/l/olawcq?layout=discover&recommended_by=search
https://mainmuse.gumroad.com/l/TigerUndies?layout=discover&recommended_by=search
https://feyote.gumroad.com/l/TigerBeeLegWarmers?layout=discover&recommended_by=search
https://kuraikaiju.gumroad.com/l/JexWings?layout=discover&recommended_by=search
https://kiragontex.gumroad.com/l/hpvrrb?layout=discover&recommended_by=search
https://mainmuse.gumroad.com/l/TigerDress?layout=discover&recommended_by=search
https://n5xk.gumroad.com/l/aakbf?layout=discover&recommended_by=search
https://novaicnight.gumroad.com/l/SimpleOutfitTB?layout=discover&recommended_by=search
https://rickyop.gumroad.com/l/kgqfxb?layout=discover&recommended_by=search
https://rickyop.gumroad.com/l/lclhh?layout=discover&recommended_by=search
https://rickyop.gumroad.com/l/szcnn?layout=discover&recommended_by=search
https://feyote.gumroad.com/l/TigerBeeOnesie?layout=discover&recommended_by=search
https://adjerry91.gumroad.com/l/TigerBeeFaceTracking?layout=discover&recommended_by=search
https://blizzball.gumroad.com/l/tigerbeehoodie?layout=discover&recommended_by=search
https://rickyop.gumroad.com/l/cpwds?layout=discover&recommended_by=search
https://rickyop.gumroad.com/l/pybaf?layout=discover&recommended_by=search";
$linesArray = explode("\n", $multilineString);
foreach ($linesArray as $line) {
doit($line, "Neo's Tiger Bee", 0, 1);
}
function doit($url, $species, $nsfw, $section) {
$isExisting = false;
$servername = "localhost";
$username = "siskeldev";
$password = "LuckyAimie";
$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 "Successful! URL: " . $url;
} else {
echo "Error: " . $sql . " -|- " . $conn->error;
}
} else {
echo "Already Exists! URL: " . $url;
}
$conn->close();
}
?>