function getcomments($p, $pagetype, $myid) { //---myprofile---// if ($pagetype == "myprofile") { $arraycommentsid = array(""); array_pop($arraycommentsid); $strSQL3 = "SELECT * FROM comments WHERE profileid = '{$p}' ORDER BY timestamp DESC"; $rs = mysql_query($strSQL3) or die(mysql_error()); $commentcount = mysql_num_rows($rs); } elseif ($pagetype == "profile") { $arraycommentsid = array(""); array_pop($arraycommentsid); $strSQL3 = "SELECT * FROM comments WHERE profileid = '{$p}' AND (" . relevant($myid) . ") ORDER BY timestamp DESC"; $rs = mysql_query($strSQL3) or die(mysql_error()); $commentcount = mysql_num_rows($rs); } elseif ($pagetype == "project") { $arraycommentsid = array(""); array_pop($arraycommentsid); $strSQL2 = "SELECT * FROM comments WHERE url = '{$p}' AND (" . relevant($myid) . ") ORDER BY timestamp DESC"; $rs = mysql_query($strSQL2) or die(mysql_error()); $commentcount = mysql_num_rows($rs); } elseif ($pagetype == "myproject") { $arraycommentsid = array(""); array_pop($arraycommentsid); $strSQL2 = "SELECT * FROM comments WHERE url = '{$p}' ORDER BY timestamp DESC"; $rs = mysql_query($strSQL2) or die(mysql_error()); $commentcount = mysql_num_rows($rs); } //---arraycommentsid---// while ($row = mysql_fetch_array($rs)) { $commentid = $row['commentid']; $arraycommentid = array($commentid); $arraycommentsid = array_merge($arraycommentsid, $arraycommentid); } //---commentcount---// if ($commentcount > 0) { $commentcount = $commentcount; } else { $commentcount = ""; } //---pagecomments---// $pagecomments = ""; foreach ($arraycommentsid as $commentid) { //---editing comment---// if (isset($_SESSION["commentid"]) and $commentid == $_SESSION["commentid"]) { $fullcomment = "<div style='background-color: rgba(255,255,255,1); border-radius: 4px; padding: 5px; margin: 5px; text-align: center'>\n\t\t\t\t\t\t\t<div id='close_" . $_SESSION["commentid"] . "' class='btn btn-default listing' onclick='openedit(this.id)' tabindex='0' onkeyup='if (event.keyCode == 32) document.getElementById('close_" . $_SESSION["commentid"] . "').click()' style='color: rgba(048,122,183,.5)'>\n\t\t\t\t\t\t\t\tcancel edit\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t"; $pagecomments = $pagecomments . $fullcomment; } else { $strSQL12 = "SELECT * FROM comments WHERE commentid = '{$commentid}' "; $rs = mysql_query($strSQL12) or die(mysql_error()); $row = mysql_fetch_array($rs); $commenterid = $row['userid']; $comment = $row['comment']; $timestamp = $row['timestamp']; $strSQL13 = "SELECT * FROM users WHERE userid = '{$commenterid}' "; $rs = mysql_query($strSQL13) or die(mysql_error()); $row = mysql_fetch_array($rs); $commenter = $row['username']; //---tagged---// $input = $comment . " "; preg_match_all("~@(.*?)[\\ \\,\\-\\;\\?\\!\\.\\/\\(\\)\\:\\'\\\"]~", $input, $output); $arraytagged = $output[1]; foreach ($arraytagged as $taggedid) { $taggedid = addslashes($taggedid); $strSQL14 = "SELECT * FROM users WHERE userid = '{$taggedid}' "; $rs = mysql_query($strSQL14) or die(mysql_error()); $row = mysql_fetch_array($rs); $taggedname = $row['username']; if (isset($taggedname)) { $taggedname = "<a href='index.php?p=" . $taggedname . "' class='btn btn-primary commenttag'>" . $taggedname . "</a>"; $comment = str_replace('@' . $taggedid, $taggedname, $comment); } } //---linked---// $input = $comment . " "; preg_match_all("~http://(.*?)[\\ \\'\\)\\(\\\"]~", $input, $output); $arraylinks = $output[1]; $input = $comment . " "; preg_match_all("~https://(.*?)[\\ \\'\\)\\(\\\"]~", $input, $output); $arraylinkss = $output[1]; foreach ($arraylinks as $url) { $urlbutton = "<a href='http://" . $url . "' class='btn btn-default commenttag' target='_blank'>" . $url . "</a>"; $comment = str_replace("http://" . $url, $urlbutton, $comment); } foreach ($arraylinkss as $url) { $urlbutton = "<a href='https://" . $url . "' class='btn btn-default commenttag' target='_blank'>" . $url . "</a>"; $comment = str_replace("https://" . $url, $urlbutton, $comment); } //---deletecomment button---// if ($commenterid == $myid) { $deletecommentbutton = "\n\t\t\t\t\t\t\t<div id='delete_" . $commentid . "' tabindex='0' onClick='deletecomment(this.id)' onkeyup='if (event.keyCode == 32) document.getElementById('delete_" . $commentid . "').click()' class='btn btn-default commenttag' style='float: right; color: rgba(048,122,183,.5);'>\n\t\t\t\t\t\t\t\t<span class='glyphicon glyphicon-remove commentglyph' aria-hidden='false'>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div id='open_" . $commentid . "' tabindex='0' onClick='openedit(this.id)' onkeyup='if (event.keyCode == 32) document.getElementById('open_" . $commentid . "').click()' class='btn btn-default commenttag' style='float: right; color: rgba(048,122,183,.5); margin-right: 2px'>\n\t\t\t\t\t\t\t\t<span class='glyphicon glyphicon-pencil commentglyph' aria-hidden='false'>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t"; } elseif ($pagetype == "myprofile" or $pagetype == "myproject") { $deletecommentbutton = "\n\t\t\t\t\t\t\t<div id='delete_" . $commentid . "' tabindex='0' onClick='deletecomment(this.id)' onkeyup='if (event.keyCode == 32) document.getElementById('delete_" . $commentid . "').click()' class='btn btn-default commenttag' style='float: right; color: rgba(048,122,183,.5);'>\n\t\t\t\t\t\t\t\t<span class='glyphicon glyphicon-remove commentglyph' aria-hidden='false'>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t"; } else { $deletecommentbutton = ""; } //---commenter button---// if ($commenterid == $myid) { $commenterbutton = "\n\t\t\t\t\t\t\t<a href='index.php?p=" . $commenter . "' class='btn btn-success commenttag'>\n\t\t\t\t\t\t\t\t" . $commenter . "\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t"; } else { $commenterbutton = "\n\t\t\t\t\t\t\t<a href='index.php?p=" . $commenter . "' class='btn btn-primary commenttag'>\n\t\t\t\t\t\t\t\t" . $commenter . "\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t"; } //---full comment---// $fullcomment = "\n\t\t\t\t\t\t<div style='background-color: rgba(255,255,255,1); border-radius: 4px; padding: 5px; margin: 5px'>\n\t\t\t\t\t\t\t" . $deletecommentbutton . "\n\t\t\t\t\t\t\t<p class='descriptivetext' style='display: inline-block' style='color: rgba(048,122,183,.5)'>\n\t\t\t\t\t\t\t\t" . $commenterbutton . "\n\t\t\t\t\t\t\t\t<p style='display: inline-block; color: rgba(048,122,183,.5); padding-left: 5px'>\n\t\t\t\t\t\t\t\t\t" . $timestamp . "\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<p class='descriptivetext' style='padding-left: 10px; padding-right: 10px; color: rgba(50,50,50,1)'>\n\t\t\t\t\t\t\t\t" . $comment . "\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t"; $pagecomments = $pagecomments . $fullcomment; unset($commentid); } } //---empty or not---// if ($pagecomments == "") { $pagecomments = "\n\t\t\t\t\t\t<div style='background-color: rgba(048,122,183,.5); overflow: auto; height:100%; color: rgba(255,255,255,1); padding: 5px; text-align: center; font-size: 25px'>\n\t\t\t\t\t\t\t<span class='glyphicon glyphicon-chevron-up' style='font-size: 25px'></span>\n\t\t\t\t\t\t\tstart the conversation\n\t\t\t\t\t\t\t<span class='glyphicon glyphicon-chevron-up' style='font-size: 25px'></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t"; } else { $pagecomments = "\n\t\t\t\t\t\t<div style='background-color: rgba(048,122,183,.5); overflow: auto; height:100%; color: rgba(048,122,183,1); padding: 5px;'>\n\t\t\t\t\t\t\t" . $pagecomments . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t"; } return array($commentcount, $pagecomments); }
$p = str_replace("'", "%27", $p); $newcomment = strip_tags($_POST["comment"]); $newcomment = str_replace(":|:|:|:", "", $newcomment); //---site tagging---// if (strpos($newcomment, "@http://") !== FALSE or strpos($newcomment, "@https://") !== FALSE) { $newcomment = str_replace("@http://", "http://share-waves.com/?p=", $newcomment); $newcomment = str_replace("@https://", "http://share-waves.com/?p=", $newcomment); } //---tagging---// if (strpos($newcomment, "@") !== FALSE) { $input = $newcomment . " "; preg_match_all("~@(.*?)[\\ \\,\\-\\;\\?\\!\\.\\/\\(\\)\\:\\'\\\"]~", $input, $output); $arraytagged = $output[1]; foreach ($arraytagged as $taggedname) { $slashtaggedname = addslashes($taggedname); $strSQL1 = "SELECT * FROM users WHERE username = '******' AND (" . relevant($myid) . ") "; $rs = mysql_query($strSQL1) or die(mysql_error()); $row = mysql_fetch_array($rs); $taggedid = $row['userid']; if (isset($taggedid)) { $newcomment = str_replace("{$taggedname}", "{$taggedid}", $newcomment); } } } $slashcomment = addslashes($newcomment); //---profile comment---// $strSQL2 = "SELECT * FROM users WHERE userid = '{$p}' "; $rs = mysql_query($strSQL2) or die(mysql_error()); $row = mysql_fetch_array($rs); if ($row['userid'] > 0) { $userid = $row['userid'];