From ff60870b577e4ed604cbefd096ad454cbde55157 Mon Sep 17 00:00:00 2001 From: sostler Date: Wed, 7 Apr 2010 13:24:51 -0400 Subject: Updated email server pw --- src/email.clj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/email.clj b/src/email.clj index 2fd22e1..dbe60ea 100644 --- a/src/email.clj +++ b/src/email.clj @@ -56,14 +56,14 @@ (defn dump-mail [to subject text] (base-mail :user "info@dump.fm" - :password "dumprulez7" - :host "smtpout.secureserver.net" - :port 25 - :ssl false - :to to - :subject subject - :text text - :mime (classify-mimetype text))) + :password "UHR4Moghu5a2" + :host "smtpout.secureserver.net" + :port 25 + :ssl false + :to to + :subject subject + :text text + :mime (classify-mimetype text))) (defn send-registration-email ([nick email] (send-registration-email nick email "welcome")) -- cgit v1.2.3-70-g09d2 From 01837cab6e5e7377d6c66a5f7cbc876a3944d9fa Mon Sep 17 00:00:00 2001 From: sostler Date: Thu, 8 Apr 2010 03:12:23 -0400 Subject: Consolidated directory listing query --- src/site.clj | 67 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/site.clj b/src/site.clj index ef4e773..e3830c0 100755 --- a/src/site.clj +++ b/src/site.clj @@ -396,44 +396,43 @@ (def *run-update-directory* true) (def *update-directory-sleep* (minutes 15)) -(defn directory-search [offset] - (let [directory @*directory-listing* - users (subvec directory - (min (count directory) - (* offset *per-directory-page*)) - (min (count directory) - (* (inc offset) *per-directory-page*))) - user-ids (apply str (interpose ", " (map #(%1 :user_id) users))) - qry (str "SELECT u.user_id, u.nick, u.avatar, m.content, m.message_id - FROM users u, messages m - WHERE u.user_id in (" user-ids ") - AND m.user_id = u.user_id - AND m.message_id = (SELECT message_id FROM messages - WHERE user_id = u.user_id - AND room_id = 1 - AND is_image = true - ORDER BY created_on DESC LIMIT 1)")] - (when (> (count user-ids) 0) - (let [res (do-select [qry]) - keys (map :user_id res) - res-dict (zipmap keys res)] - (map (fn [u] - (let [u-id (u :user_id)] - (process-directory-listing (merge u (res-dict u-id))))) - users))))) - +(def *directory-update-query* " +SELECT m.user_id, + u.nick, + u.avatar, + message_id, + m.created_on, + msg_count, + content +FROM (SELECT user_id, + created_on, + message_id, + content, + MAX(created_on) OVER (PARTITION BY user_id) max_created_on, + COUNT(*) OVER (PARTITION BY user_id) msg_count + FROM messages + WHERE room_id = 1 + AND is_image = true) AS m, + users u +WHERE m.created_on = max_created_on + AND m.user_id = u.user_id +ORDER BY msg_count DESC") + (defn update-directory! [] - (let [qry "SELECT u.user_id, COUNT(m) as cnt - FROM users u, messages m - WHERE u.user_id = m.user_id - AND m.room_id = 1 - AND m.is_image = true - GROUP BY u.user_id - ORDER BY COUNT(m) DESC" - res (vec (do-select [qry]))] + (let [res (vec (do-select [*directory-update-query*]))] (dosync (ref-set *directory-listing* res)) res)) +(defn directory-search [offset] + (let [directory @*directory-listing* + users (subvec directory + (min (count directory) + (* offset *per-directory-page*)) + (min (count directory) + (* (inc offset) *per-directory-page*)))] + (when (> (count users) 0) + (map process-directory-listing users)))) + (defn update-directory-agent-func [x] (update-directory!) (Thread/sleep *update-directory-sleep*) -- cgit v1.2.3-70-g09d2 From 060d0a20fa9d8e1e0c9f9cb5218ef37b46015301 Mon Sep 17 00:00:00 2001 From: sostler Date: Thu, 8 Apr 2010 05:04:06 -0400 Subject: Added case-insensitive username registration; double pw --- src/site.clj | 4 +-- static/js/register.js | 91 +++------------------------------------------------ static/register.html | 7 ++-- 3 files changed, 12 insertions(+), 90 deletions(-) (limited to 'src') diff --git a/src/site.clj b/src/site.clj index e3830c0..b5b4eb8 100755 --- a/src/site.clj +++ b/src/site.clj @@ -105,8 +105,8 @@ (not (re-matches nick-regex n)) "NICK_INVALID_CHARS")) (defn fetch-nick [nick] - (let [query "SELECT * FROM users WHERE nick = ? LIMIT 1"] - (first (do-select [query nick])))) + (let [query "SELECT * FROM users WHERE LOWER(nick) = ? LIMIT 1"] + (first (do-select [query (s/lower-case nick)])))) (defn authorize-nick-hash [nick hash] (let [db-user (fetch-nick nick)] diff --git a/static/js/register.js b/static/js/register.js index 31d32e5..30e221f 100755 --- a/static/js/register.js +++ b/static/js/register.js @@ -1,94 +1,24 @@ -function validateNick(n) { - if (n.length <= 2) { - return "BAD_NICK_LENGTH"; - } -} - - -function submitRegistration() { - var nick = $('#nickInput').val(); - var email = $('#emailInput').val(); - var password = $('#passwordInput').val() || "";function validateNick(n) { - if (n.length <= 2) { - return "BAD_NICK_LENGTH"; - } -} - - function submitRegistration() { var nick = $('#nickInput').val(); var email = $('#emailInput').val(); var password = $('#passwordInput').val() || ""; - + var password2 = $('#passwordInput2').val() || ""; if (nick.length < 3 || nick.length > 12) { alert("Nicks must be between 3 and 12 characters long."); return; - } else if (password.length < 5) { - alert("Password must be at least 5 characters long."); - return; } - - - var hash = hex_sha1(nick + '$' + password + '$dumpfm'); - var onSuccess = function() { - if (typeof pageTracker !== 'undefined') { - pageTracker._trackEvent('User', 'Register', nick); - } - location.href = "/"; - }; - - var onError = function(resp) { - var respText = resp.responseText ? resp.responseText.trim() : false; - if (respText == 'NICK_TAKEN') { - alert("That nick is already taken! Please choose another."); - } else if (respText == 'NICK_INVALID_CHARS') { - alert("Nicks can only contain letters and numbers."); - } else { - alert("Unable to register!"); - } - }; - - $.ajax({ - type: 'POST', - timeout: 5000, - url: 'submit-registration', - data: {'nick': nick, 'email': email, 'hash': hash }, - cache: false, - dataType: 'json', - success: onSuccess, - error: onError - - }); -} - -function initRegister() { - $('#submit').click(submitRegistration); -} - -function handleMsgError(resp) { - var respText = resp.responseText ? resp.responseText.trim() : false; - if (respText == 'UNKNOWN_USER') { - alert("Can't send message! Please login."); - } else if (respText) { - alert("Cannot send message! (" + respText + ")"); - } else { - alert("Cannot send message!"); + if (password != password2) { + alert("Passwords must match!"); + return; } -} - - if (nick.length < 3 || nick.length > 12) { - alert("Nicks must be between 3 and 12 characters long."); - return; - } else if (password.length < 5) { + if (password.length < 5) { alert("Password must be at least 5 characters long."); return; } - - var hash = hex_sha1(nick + '$' + password + '$dumpfm'); var onSuccess = function() { if (typeof pageTracker !== 'undefined') { @@ -123,15 +53,4 @@ function handleMsgError(resp) { function initRegister() { $('#submit').click(submitRegistration); -} - -function handleMsgError(resp) { - var respText = resp.responseText ? resp.responseText.trim() : false; - if (respText == 'UNKNOWN_USER') { - alert("Can't send message! Please login."); - } else if (respText) { - alert("Cannot send message! (" + respText + ")"); - } else { - alert("Cannot send message!"); - } } \ No newline at end of file diff --git a/static/register.html b/static/register.html index a758e66..f7c7163 100644 --- a/static/register.html +++ b/static/register.html @@ -39,13 +39,16 @@
password - + +
+ repeat password + +

email

-


-- cgit v1.2.3-70-g09d2 From cfc2525c124d23ff4b76dff03bca005c1d7ba17a Mon Sep 17 00:00:00 2001 From: dumpfmprod Date: Thu, 8 Apr 2010 05:09:09 -0400 Subject: Revert "Consolidated directory listing query" This reverts commit 01837cab6e5e7377d6c66a5f7cbc876a3944d9fa. --- src/site.clj | 67 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/site.clj b/src/site.clj index e3830c0..ef4e773 100755 --- a/src/site.clj +++ b/src/site.clj @@ -396,43 +396,44 @@ (def *run-update-directory* true) (def *update-directory-sleep* (minutes 15)) -(def *directory-update-query* " -SELECT m.user_id, - u.nick, - u.avatar, - message_id, - m.created_on, - msg_count, - content -FROM (SELECT user_id, - created_on, - message_id, - content, - MAX(created_on) OVER (PARTITION BY user_id) max_created_on, - COUNT(*) OVER (PARTITION BY user_id) msg_count - FROM messages - WHERE room_id = 1 - AND is_image = true) AS m, - users u -WHERE m.created_on = max_created_on - AND m.user_id = u.user_id -ORDER BY msg_count DESC") - +(defn directory-search [offset] + (let [directory @*directory-listing* + users (subvec directory + (min (count directory) + (* offset *per-directory-page*)) + (min (count directory) + (* (inc offset) *per-directory-page*))) + user-ids (apply str (interpose ", " (map #(%1 :user_id) users))) + qry (str "SELECT u.user_id, u.nick, u.avatar, m.content, m.message_id + FROM users u, messages m + WHERE u.user_id in (" user-ids ") + AND m.user_id = u.user_id + AND m.message_id = (SELECT message_id FROM messages + WHERE user_id = u.user_id + AND room_id = 1 + AND is_image = true + ORDER BY created_on DESC LIMIT 1)")] + (when (> (count user-ids) 0) + (let [res (do-select [qry]) + keys (map :user_id res) + res-dict (zipmap keys res)] + (map (fn [u] + (let [u-id (u :user_id)] + (process-directory-listing (merge u (res-dict u-id))))) + users))))) + (defn update-directory! [] - (let [res (vec (do-select [*directory-update-query*]))] + (let [qry "SELECT u.user_id, COUNT(m) as cnt + FROM users u, messages m + WHERE u.user_id = m.user_id + AND m.room_id = 1 + AND m.is_image = true + GROUP BY u.user_id + ORDER BY COUNT(m) DESC" + res (vec (do-select [qry]))] (dosync (ref-set *directory-listing* res)) res)) -(defn directory-search [offset] - (let [directory @*directory-listing* - users (subvec directory - (min (count directory) - (* offset *per-directory-page*)) - (min (count directory) - (* (inc offset) *per-directory-page*)))] - (when (> (count users) 0) - (map process-directory-listing users)))) - (defn update-directory-agent-func [x] (update-directory!) (Thread/sleep *update-directory-sleep*) -- cgit v1.2.3-70-g09d2 From 3bc6dfdbb08028fae24b17ad07d6ccbb06e809cb Mon Sep 17 00:00:00 2001 From: dumpfmprod Date: Thu, 8 Apr 2010 05:27:40 -0400 Subject: Remove check for username caps, added tim banner --- src/site.clj | 4 +-- static/css/header.css | 6 +++++ static/img/wherestim.gif | Bin 0 -> 1702 bytes template/banner.st | 65 +++++++++++++++++++++++++---------------------- 4 files changed, 42 insertions(+), 33 deletions(-) create mode 100644 static/img/wherestim.gif (limited to 'src') diff --git a/src/site.clj b/src/site.clj index 43bbe7e..ef4e773 100755 --- a/src/site.clj +++ b/src/site.clj @@ -105,8 +105,8 @@ (not (re-matches nick-regex n)) "NICK_INVALID_CHARS")) (defn fetch-nick [nick] - (let [query "SELECT * FROM users WHERE LOWER(nick) = ? LIMIT 1"] - (first (do-select [query (s/lower-case nick)])))) + (let [query "SELECT * FROM users WHERE nick = ? LIMIT 1"] + (first (do-select [query nick])))) (defn authorize-nick-hash [nick hash] (let [db-user (fetch-nick nick)] diff --git a/static/css/header.css b/static/css/header.css index 2e6a3e6..42f4b26 100755 --- a/static/css/header.css +++ b/static/css/header.css @@ -34,6 +34,12 @@ margin-right:80%; color: #fff; } +#wherestim{ +position:absolute; +top:-10; +left:390; +} + #header7{ background-image:url(/static/img/dblue2.png); background-attachment:inherit; diff --git a/static/img/wherestim.gif b/static/img/wherestim.gif new file mode 100644 index 0000000..011bbdc Binary files /dev/null and b/static/img/wherestim.gif differ diff --git a/template/banner.st b/template/banner.st index 02613c6..6d99d8b 100755 --- a/template/banner.st +++ b/template/banner.st @@ -1,33 +1,34 @@ -
-
-
- -
-
- -
-
-
- $if(user_nick)$ - +
+
+ +
+
+ +
+
+ + + + $endif$ +
+ +
+
@@ -36,12 +37,14 @@
- $if(isadmin)$ - - $endif$ -
+ + + $if(isadmin)$ + + $endif$ +
$if(user_nick)$ Logout $else$ $form_login()$ $endif$
-- cgit v1.2.3-70-g09d2 From 956291711de6afb17137160a67ac710be0ace1e1 Mon Sep 17 00:00:00 2001 From: sostler Date: Thu, 8 Apr 2010 05:33:14 -0400 Subject: Re-added case-insensitive nick check --- src/site.clj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/site.clj b/src/site.clj index ef4e773..3a59264 100755 --- a/src/site.clj +++ b/src/site.clj @@ -104,6 +104,10 @@ (< (count n) 3) "NICK_TOO_SHORT" (not (re-matches nick-regex n)) "NICK_INVALID_CHARS")) +(defn check-nick [nick] + (let [query "SELECT * FROM users WHERE LOWER(nick) = ? LIMIT 1"] + (> (count (do-select [query (s/lower-case nick)])) 0))) + (defn fetch-nick [nick] (let [query "SELECT * FROM users WHERE nick = ? LIMIT 1"] (first (do-select [query nick])))) @@ -328,7 +332,7 @@ hash (params :hash) invalid-nick-reason (is-invalid-nick? nick)] (cond invalid-nick-reason (resp-error invalid-nick-reason) - (fetch-nick nick) (resp-error "NICK_TAKEN") + (check-nick nick) (resp-error "NICK_TAKEN") :else (with-connection *db* (insert-values :users [:nick :hash :email] -- cgit v1.2.3-70-g09d2