diff --git a/.gitignore b/.gitignore index f0d96d2..c6f017f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.vscode/sftp.json \ No newline at end of file +.vscode/sftp.json +.DS_STORE \ No newline at end of file diff --git a/database/getMarketplaceIcons.php b/database/getMarketplaceIcons.php index 11ecde0..7798a5f 100644 --- a/database/getMarketplaceIcons.php +++ b/database/getMarketplaceIcons.php @@ -5,12 +5,15 @@ checkClientDatabaseVersion(); $conn = newConnection(); $post = getPostData(); +$userId = (int)$post['userId'] ?? 0; $sortBy = (int)$post['sortBy'] ?? 2; -$priceRangeEnabled = (bool)$post['priceRangeEnabled'] ?? false; +$priceRangeEnabled = isset($post['priceRangeEnabled']) ? (string)$post['priceRangeEnabled'] == 'False' ? false : true : false; $priceRangeMin = (int)$post['priceRangeMin'] ?? 10; $priceRangeMax = (int)$post['priceRangeMax'] ?? 250; -$searchForEnabled = (bool)$post['searchForEnabled'] ?? false; +$searchForEnabled = isset($post['searchForEnabled']) ? (string)$post['searchForEnabled'] == 'False' ? false : true : false; $searchForValue = (string)$post['searchForValue'] ?? ''; +$onlyShowEnabled = isset($post['onlyShowEnabled']) ? (string)$post['onlyShowEnabled'] == 'False' ? false : true : false; +$onlyShowValue = (string)$post['onlyShowValue'] ?? ''; $where = ["u.banned = 0", "(c.state = 1 OR c.state = 2)"]; $params = []; @@ -35,6 +38,18 @@ if ($searchForEnabled && $searchForValue !== '') { $types .= "s"; } +if ($onlyShowEnabled) { + if ($onlyShowValue === '0') { + $where[] = "c.userId = ?"; + $params[] = $userId; + $types .= "i"; + } elseif ($onlyShowValue === '1') { + $where[] = "c.userId != ?"; + $params[] = $userId; + $types .= "i"; + } +} + $sql = " SELECT c.data, u.username, u.id, c.price, c.name, c.uuid, c.state FROM marketplaceicons c