www/adiumxtras.com 54:95a9b885f583: currentUID is a function, no...

commits at adium.im commits at adium.im
Fri Feb 27 08:26:22 UTC 2015


details:	http://hg.adium.im/www/adiumxtras.com/rev/95a9b885f583
revision:	54:95a9b885f583
branch:		adiumxtras.com
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Fri Feb 27 09:26:13 2015 +0100

currentUID is a function, not a variable. Also removed some now redundant checks.

diffs (92 lines):

diff -r 125992583755 -r 95a9b885f583 xtras.php
--- a/xtras.php	Fri Feb 27 09:21:17 2015 +0100
+++ b/xtras.php	Fri Feb 27 09:26:13 2015 +0100
@@ -72,7 +72,7 @@
 
 				$akismet = NULL;
 
-				if ($currentUID && $_POST['xtra_id'] && $_POST['comment']) {
+				if (currentUID() && $_POST['xtra_id'] && $_POST['comment']) {
 					$sql->query("SELECT users.username, users.email, users.website FROM users WHERE users.user_id = '%d'", currentUID());
 
 					$user = $sql->fetch_assoc();
@@ -90,50 +90,39 @@
 						
 				if($akismet && ($akismet->errorsExist() || !$akismet->isSpam())) {
 
-					if ($_POST['comment'] && $_POST['xtra_id']) {
-						if (currentUID()) {
+					$sql->query("INSERT INTO comments (xtra_id, parent_id, comment, user_id, posted) VALUES ('%d', '%d', '%s', '%d', NOW())", intval($_POST['xtra_id']), intval($_POST['parent_id']), strip_tags($_POST['comment']), currentUID());
+					$newCommentID = $sql->insert_id();
+				
+					// Email the author about the new comment.
+					$sql->query("SELECT xtras.title, users.username, users.email FROM xtras, users WHERE xtras.user_id=users.user_id AND xtras.xtra_id='%d'", intval($_POST['xtra_id']));
+					$emailInfo = $sql->fetch_assoc();
+					$message = sprintf("%s\n\nA new comment has been added to one of your xtras.\n\n", $emailInfo['username']);
+					$message .= sprintf("*******************\n%s\n<http://adiumxtras.com/index.php?a=xtras&xtra_id=%d#c%d>\n*******************\n\n", $emailInfo['title'], $_POST['xtra_id'], $newCommentID);
+					$message .= sprintf("Comment by: %s\n\nComment:\n\n%s", $_COOKIE['xtras_user'], $_POST['comment']);
+					
+					mail($emailInfo['email'], "New Comment on Xtras", $message, "From: xtras at adiumxtras.com");
+				
+					if ($_POST['parent_id']) {
+						$emails = array();
+						$sql->query("SELECT comments.*, users.* FROM comments, users WHERE comments.comment_id IN (%s) AND users.user_id = comments.user_id", implode(",", commentsWithParent(intval($_POST['parent_id']))));
+						while ($row = $sql->fetch_assoc()) {
+							if ($row['email'] == $emailInfo['email'] || $row['comment_id'] == $newCommentID)
+								continue;
+							$emails[] = $row['email'];
+						}
 
-							$sql->query("INSERT INTO comments (xtra_id, parent_id, comment, user_id, posted) VALUES ('%d', '%d', '%s', '%d', NOW())", intval($_POST['xtra_id']), intval($_POST['parent_id']), strip_tags($_POST['comment']), currentUID());
-							$newCommentID = $sql->insert_id();
+						$emails = array_unique($emails);
 						
-							// Email the author about the new comment.
-							$sql->query("SELECT xtras.title, users.username, users.email FROM xtras, users WHERE xtras.user_id=users.user_id AND xtras.xtra_id='%d'", intval($_POST['xtra_id']));
-							$emailInfo = $sql->fetch_assoc();
-							$message = sprintf("%s\n\nA new comment has been added to one of your xtras.\n\n", $emailInfo['username']);
+						foreach ($emails as $email) {
+							$message = sprintf("Hello:\n\nA new comment has been added to a comment thread that you are participating in:\n\n");
 							$message .= sprintf("*******************\n%s\n<http://adiumxtras.com/index.php?a=xtras&xtra_id=%d#c%d>\n*******************\n\n", $emailInfo['title'], $_POST['xtra_id'], $newCommentID);
-							$message .= sprintf("Comment by: %s\n\nComment:\n\n%s", $_COOKIE['xtras_user'], $_POST['comment']);
-							
-							mail($emailInfo['email'], "New Comment on Xtras", $message, "From: xtras at adiumxtras.com");
-						
-							if ($_POST['parent_id']) {
-								$emails = array();
-								$sql->query("SELECT comments.*, users.* FROM comments, users WHERE comments.comment_id IN (%s) AND users.user_id = comments.user_id", implode(",", commentsWithParent(intval($_POST['parent_id']))));
-								while ($row = $sql->fetch_assoc()) {
-									if ($row['email'] == $emailInfo['email'] || $row['comment_id'] == $newCommentID)
-										continue;
-									$emails[] = $row['email'];
-								}
-		
-								$emails = array_unique($emails);
-								
-								foreach ($emails as $email) {
-									$message = sprintf("Hello:\n\nA new comment has been added to a comment thread that you are participating in:\n\n");
-									$message .= sprintf("*******************\n%s\n<http://adiumxtras.com/index.php?a=xtras&xtra_id=%d#c%d>\n*******************\n\n", $emailInfo['title'], $_POST['xtra_id'], $newCommentID);
-									$message .= sprintf("Comment by: %s\n\nComment:\n\n%s", $_COOKIE['xtrauser'], $_POST['comment']);
-									mail($email, "New Comment on Xtras Thread", $message, "From: xtras at adiumxtras.com");
-								}
-							}
-											
-							// Send the person back to whence-forth they came.					
-							header(sprintf("Location: index.php?a=xtras&xtra_id=%d", $_POST['xtra_id']));
-						} else {
-							// There was code in the old version for anonymous posting.
-							// I'm totally not replicating it.
-							$smarty->assign("message", "Somehow you submitted the form without logging in. That's neat. But, first, you must login.");
-							$smarty->display("loginForm.tpl");
+							$message .= sprintf("Comment by: %s\n\nComment:\n\n%s", $_COOKIE['xtrauser'], $_POST['comment']);
+							mail($email, "New Comment on Xtras Thread", $message, "From: xtras at adiumxtras.com");
 						}
-					} else
-						header(sprintf("Location: index.php?a=xtras&xtra_id=%d", $_POST['xtra_id']));
+					}
+									
+					// Send the person back to whence-forth they came.					
+					header(sprintf("Location: index.php?a=xtras&xtra_id=%d", $_POST['xtra_id']));
 					break;
 				}
 			} // intentional fallthrough, they failed the captcha or the akismet test, but let's be nice and allow them to try again




More information about the commits mailing list