aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick/server/AdsQueries.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2014-07-25 00:16:47 +0700
committerGravatar Ugnich Anton2014-07-25 00:16:47 +0700
commit13a861563ffead4cadba48e523aad2e5c6beb44c (patch)
tree0f60efcdfc498d631cf1ea782366f4d212238093 /src/com/juick/server/AdsQueries.java
parentb67b2f126af0c410cdb5b1a925d19b5d2cc5b2b2 (diff)
AdsQueries for unauthorized
Diffstat (limited to 'src/com/juick/server/AdsQueries.java')
-rw-r--r--src/com/juick/server/AdsQueries.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/com/juick/server/AdsQueries.java b/src/com/juick/server/AdsQueries.java
index f1b37fb1..0fb4c0a6 100644
--- a/src/com/juick/server/AdsQueries.java
+++ b/src/com/juick/server/AdsQueries.java
@@ -28,7 +28,11 @@ import java.sql.SQLException;
public class AdsQueries {
public static int getAdMID(Connection sql, int uid) {
- return SQLHelpers.getInt(sql, "SELECT message_id FROM ads_messages WHERE message_id NOT IN (SELECT message_id FROM ads_messages_log WHERE user_id=? AND ts>UNIX_TIMESTAMP()-60*60*24 GROUP BY message_id HAVING COUNT(*)>2) ORDER BY RAND() LIMIT 1", uid, 0);
+ if (uid > 0) {
+ return SQLHelpers.getInt(sql, "SELECT message_id FROM ads_messages WHERE message_id NOT IN (SELECT message_id FROM ads_messages_log WHERE user_id=? AND ts>UNIX_TIMESTAMP()-60*60*24 GROUP BY message_id HAVING COUNT(*)>2) ORDER BY RAND() LIMIT 1", uid, 0);
+ } else {
+ return SQLHelpers.getInt(sql, "SELECT message_id FROM ads_messages ORDER BY RAND() LIMIT 1", 0);
+ }
}
public static void logAdMID(Connection sql, int uid, int mid) {