From c87f86f04e507e2861f856fc37e38fa5403a78f2 Mon Sep 17 00:00:00 2001 From: Mahmood - Zer0xFF <5013823+Zer0xFF@users.noreply.github.com> Date: Sun, 24 Jun 2018 19:17:47 +0300 Subject: [PATCH 01/57] API limited based on IP address --- API/include/APIAccessDB.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/API/include/APIAccessDB.class.php b/API/include/APIAccessDB.class.php index c9b1ef6..f7dc110 100644 --- a/API/include/APIAccessDB.class.php +++ b/API/include/APIAccessDB.class.php @@ -29,9 +29,10 @@ function GetUserAllowanceByAPIKey($key) $dbh = $this->database->dbh; $sth = $dbh->prepare("Select APIU.*, AA.monthly_allowance, sum(AMC.count) as count FROM apiusers APIU LEFT JOIN api_allowance_level AA ON AA.id = APIU.api_allowance_level_id - LEFT JOIN api_month_counter AMC ON AMC.apiusers_id = APIU.id AND AMC.date >= APIU.last_refresh_date AND AMC.is_extra = 0 + LEFT JOIN api_month_counter AMC ON AMC.IP = INET6_ATON(:IP) AND AMC.apiusers_id = APIU.id AND AMC.date >= APIU.last_refresh_date AND AMC.is_extra = 0 WHERE apikey=:apikey GROUP BY APIU.id;"); $sth->bindValue(':apikey', $key, PDO::PARAM_STR); + $sth->bindValue(':IP', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR); if($sth->execute()) { @@ -59,11 +60,12 @@ function countAPIRequest($User, $update_refresh_date, $is_extra) $sth->bindValue(':id', $User->id, PDO::PARAM_INT); $sth->execute(); } - $sth = $dbh->prepare("INSERT INTO api_month_counter (apiusers_id, count, is_extra, date) - VALUES (:id, 1, :is_extra, :date) ON DUPLICATE KEY UPDATE count = count + 1;"); + $sth = $dbh->prepare("INSERT INTO api_month_counter (apiusers_id, count, is_extra, date, IP) + VALUES (:id, 1, :is_extra, :date, INET6_ATON(:IP)) ON DUPLICATE KEY UPDATE count = count + 1;"); $sth->bindValue(':date', date('Y-m-d')); $sth->bindValue(':id', $User->id, PDO::PARAM_INT); $sth->bindValue(':is_extra', $is_extra, PDO::PARAM_INT); + $sth->bindValue(':IP', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR); $sth->execute(); $dbh->commit(); } From d82de23cd9a98678f258e23bdbcb61d2b3a5d972 Mon Sep 17 00:00:00 2001 From: Mahmood - Zer0xFF <5013823+Zer0xFF@users.noreply.github.com> Date: Sun, 24 Jun 2018 19:35:27 +0300 Subject: [PATCH 02/57] Change the way front page recently released images are displayed --- website/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/index.php b/website/index.php index d92f4cb..5f31a06 100755 --- a/website/index.php +++ b/website/index.php @@ -58,8 +58,8 @@