diff --git a/data/style/furatalog.lib.php b/data/style/furatalog.lib.php new file mode 100644 index 0000000..a9a16b9 --- /dev/null +++ b/data/style/furatalog.lib.php @@ -0,0 +1,323 @@ +databaseConnection = new mysqli("localhost", "furatalog_usr", "1yRNpaUtXu[cw@-m", "furatalog"); + $_GET["moin"] = "hi"; + $this->secureGET = $_GET; + + foreach ($this->secureGET as $query_string_variable => $value) { + $newValue = str_replace('"', '\"', $value); + $newValue = str_replace("'", "\'", $newValue); + $newValue = str_replace(";", "", $newValue); + $newValue = str_replace("`", "", $newValue); + + $this->secureGET[$query_string_variable] = $newValue; + } + } + + private function getCreatorID($creatorURL) { + $creatorURL = implode('/', array_slice(explode('/', $creatorURL), 0, 3)); + $creatorRequestResult = $this->databaseConnection->query("SELECT * FROM creator WHERE `gumroad_url`='" . $creatorURL . "'"); + + if ($creatorRequestResult->num_rows > 0) { + $creatorID = $creatorRequestResult->fetch_assoc()["id"]; + } else { + $string = file_get_contents($creatorURL); + + $dom = new DomDocument(); + $dom->loadHTML($string); + $finder = new DomXPath($dom); + + $creatorName = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' profile ')]")[0]->childNodes[0]->childNodes[0]->textContent; + $creatorpicture = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' profile ')]")[0]->childNodes[0]->childNodes[0]->childNodes[0]->attributes[1]->textContent; + + $this->databaseConnection->query("INSERT INTO `creator` (`id`, `name`, `pb_url`, `booth_url`, `gumroad_url`, `payhip_url`, `jinxxy_url`) VALUES (NULL, '" . str_replace("'", "\'", $creatorName) . "', '" . $creatorpicture . "', '', '" . $creatorURL . "', '', '')"); + + $creatorResult = $this->databaseConnection->query("SELECT id FROM `creator` WHERE gumroad_url='" . $creatorURL . "'"); + + $creatorID = $creatorResult->fetch_assoc()["id"]; + } + + return (string)$creatorID; + } + + private function getCurrencyID($currencySymbol) { + $result = $this->databaseConnection->query("SELECT id FROM currency WHERE symbol='" . $currencySymbol . "'"); + $currencyID = $result->fetch_assoc()["id"]; + + return (int)$currencyID; + } + + public function getItems($section, $page = 1) { + if (!isset($this->secureGET["s"])) { + $this->secureGET["s"] = ""; + } + + $this->secureGET["s"] = rtrim($this->secureGET["s"]); + $whereRequest = ""; + + + if (isset($this->secureGET["s"])) { + $searchSplitArray = explode(" ", $this->secureGET["s"]); + + foreach ($searchSplitArray as $key => $value) { + $tmpVal = str_replace("'","\'", $value); + + if ($whereRequest != "") { + $whereRequest .= " AND "; + } + + /// WHERE `name` REGEXP '^(?=.*k.*i.*t.*a.*v.*l.*i).*$'; + // this searches for a string if present in a string regardless of the characters between the serached ones + // has to be made for every word and for every column + // change this system to regex with every character being seperated by a .* + + $whereRequest .= "(content.name LIKE '%" . $tmpVal . "%' OR + creator.name LIKE '%" . $tmpVal . "%' + " . ($section==1 ? + " OR species.name LIKE '%" . $tmpVal . "%') " : + ")") . ""; + } + } else { + $whereRequest .= "(content.name LIKE '%%' OR + creator.name LIKE '%%' + " . ($section==1 ? + " OR species.name LIKE '%%') " : + ")") . ""; + } + + $tmp = $this->databaseConnection->query(" + + SELECT + content.id as 'content_id', + content.name as 'content_name', + content.price as 'content_price', + content.rating as 'content_rating', + content.url as 'content_url', + content.image as 'content_image', + + currency.currency as 'currency_currency', + currency.symbol as 'currency_symbol', + `currency`.`font-awesome` as 'currency_fontawesome', + + creator.name as 'creator_name', + creator.pb_url as 'creator_pb_url' + + " . ($section==1?", + species.name as 'species_name'":"") . " + + FROM `content` + JOIN creator ON content.creator_id=creator.id + JOIN currency ON content.currency_id=currency.id + " . ($section==1?" + JOIN content_species ON content.id=content_species.content_id + JOIN species ON content_species.species_id=species.id":"") . " + WHERE + " . $whereRequest . " + + AND (content.section LIKE \"%" . $section . "%\" + " . ((isset($_SESSION["nsfw"]) && $_SESSION["nsfw"]==true) ? '' : 'AND content.nsfw = 0') . ") + + GROUP BY content.id + + ORDER BY content.id DESC + + LIMIT " . ($page - 1) * 40 . ", 40; + + "); + + $total = $this->databaseConnection->query(" + + SELECT + content.id as 'content_id', + content.name as 'content_name', + content.price as 'content_price', + content.rating as 'content_rating', + content.url as 'content_url', + content.image as 'content_image', + + currency.currency as 'currency_currency', + currency.symbol as 'currency_symbol', + `currency`.`font-awesome` as 'currency_fontawesome', + + creator.name as 'creator_name', + creator.pb_url as 'creator_pb_url' + + " . ($section==1?", + species.name as 'species_name'":"") . " + + FROM `content` + JOIN creator ON content.creator_id=creator.id + JOIN currency ON content.currency_id=currency.id + " . ($section==1?" + JOIN content_species ON content.id=content_species.content_id + JOIN species ON content_species.species_id=species.id":"") . " + WHERE + " . $whereRequest . " + + AND (content.section LIKE \"%" . $section . "%\" + " . ((isset($_SESSION["nsfw"]) && $_SESSION["nsfw"]==true) ? '' : 'AND content.nsfw = 0') . ") + GROUP BY content.id + "); + + $this->maxpages = (ceil((int)$total->num_rows / 40)); + + $items = array(); + + while ($row = $tmp->fetch_assoc()) { + $items[] = $row; + } + + return $items; + } + + function printScriptSec() { + $currentpage = (isset($_GET["p"]) ? $_GET["p"] : 1); + $search=isset($_GET["s"]) ? "&s=" . $_GET["s"] : ""; + $nextpage=isset($_GET["p"]) ? $_GET["p"] : 1; + $prevpage=isset($_GET["p"]) ? $_GET["p"] : 1; + + echo " + + + "; + } + + function printItemLists($section) { + echo "