Cleanup of comment page.
[Assignment-Trapper.git] / line_comment.php
blob33df533dd7e2a553a7f634b7ff829355264338fc
1 <?php
3 include_once("auth_root.php");
5 //if($role != 0) { die("Account \"".$user_name."\" Is Not Authorized To View This Page.<br><br>This Event Will Be Logged And Reported."); }
7 if (!$_GET["file_id"]) { die("No File ID Sent"); }
8 if (!$_GET["line_num"]) { die("No Line Number Sent"); }
9 if (!$_GET["comment"]) { die("No Comment Sent"); }
10 if ($_GET["comment"] == "") { die("Comment of Zero Length Cannot Be Posted"); }
12 $_GET["file_id"] = mysql_real_escape_string($_GET["file_id"]);
13 $_GET["line_num"] = mysql_real_escape_string($_GET["line_num"]);
15 // comments are being sent with double quotes on each end... remove them
16 $comment = substr($_GET[comment], 1, -1);
18 $comment = mysql_real_escape_string($comment);
20 //TODO: Verify that this file belongs to user if role not root...
23 // insert comment contents into DB
24 $sql = 'insert into filecom values ("", '.$_GET["file_id"].','.$_GET["line_num"].','.$user_id.',"'.$comment.'",NOW())';
26 //echo $sql;
28 $result = mysql_query($sql);
30 if (!$result) { die("SQL ERROR: File Comment Insert"); }
32 $html = '';
33 $html .= "<img src='gfx/down_arrow.png'>";
34 $html .= "<span class=line_comment_txt>".$comment."</span>";
35 $html .= "<span class=line_comment_name>".$user_name."</span>";
36 $html .= "<span class=line_comment_time>Just Now</span>";
38 echo $html;