diff --git a/addcomment.php b/addcomment.php
index f6bb4c1..12f6db9 100644
--- a/addcomment.php
+++ b/addcomment.php
@@ -1,31 +1,42 @@
+/********************************/
+/* code to submit a new comment */
+/********************************/
+# APPLICATION ENVIRONMENT
include("path.php");
require(BASE."include/"."incl.php");
require(BASE."include/"."application.php");
-
-
-if(!$appId) {
- errorpage('Internal Database Access Error');
- exit;
-}
-
-if(!$versionId) {
- $versionId = 0;
-}
-
-if(!$thread) {
- $thread = 0;
-}
-
-opendb();
-
-
-if($body)
+// you must be logged in to submit comments
+if(!loggedin())
+{
+ unset($_REQUEST['body']);
+ apidb_header("Please login");
+ echo "To submit a comment for an application you must be logged in. Please login now or create a new account.","\n";
+}
+
+if(!isset($_REQUEST['appId']))
+{
+ errorpage('Internal Database Access Error');
+ exit;
+}
+
+if(!$_REQUEST['versionId'])
+{
+ $versionId = 0;
+}
+
+if(!$_REQUEST['thread'])
+{
+ $thread = 0;
+}
+
+############################
+# ADDS COMMENT TO DATABASE #
+############################
+if($_REQUEST[body])
{
- // add comment to db
-
$hostname = get_remote();
$subject = strip_tags($subject);
@@ -33,7 +44,7 @@ if($body)
$body1 = mysql_escape_string($body);
// get current userid
- $userId = (loggedin()) ? $_SESSION['current']->userid : 0;
+ $userId = $_SESSION['current']->userid;
$result = mysql_query("INSERT INTO appComments VALUES (NOW(), null, $thread, ".
"$appId, $versionId, $userId, '$hostname', '$subject', ".
@@ -74,7 +85,7 @@ if($body)
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
$ms = APPDB_ROOT."appview.php?appId=$appId&versionId=$versionId"."\n";
$ms .= "\n";
- $ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." added comment to ".$fullAppName."\n";
+ $ms .= $_SESSION['current']->username." added comment to ".$fullAppName."\n";
$ms .= "\n";
$ms .= "Subject: ".$subject."\n";
$ms .= "\n";
@@ -83,7 +94,6 @@ if($body)
$ms .= STANDARD_NOTIFY_FOOTER;
mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
-
} else
{
$email = "no one";
@@ -94,56 +104,61 @@ if($body)
redirect(apidb_fullurl("appview.php?appId=$appId&versionId=$versionId"));
}
}
-else
+
+################################
+# USER WANTS TO SUBMIT COMMENT #
+################################
+else if(loggedin())
{
+ apidb_header("Add Comment");
- apidb_header("Add Comment");
+ $mesTitle = "Post New Comment";
- $mesTitle = "Post New Comment";
-
- if($thread)
- {
- $result = mysql_query("SELECT * FROM appComments WHERE commentId = $thread");
- $ob = mysql_fetch_object($result);
- if($ob)
- {
- $mesTitle = "Replying To ... $ob->subject\n";
- $originator = $ob->userId;
- echo html_frame_start($ob->subject,500);
- echo htmlify_urls($ob->body), "
\n";
- echo html_frame_end();
- }
- }
-
- echo "
\n"; + } - apidb_footer(); + echo ""; } - +?> + +
+ + +apidb_footer(); ?>