$cus = count($user_comments); // only 3 comments in the cache foreach ($user_comments as $uc) { if ($c == 0 and $cus > 2) { // do nothing } else { $new_arr[] = (array) $uc; } $c++; } } // if user_comments $c = $new_arr ? count($new_arr) : 0; $new_arr[$c]['CID'] = $cid; $new_arr[$c]['PID'] = $pid; $new_arr[$c]['USERID'] = $userid; $new_arr[$c]['comment'] = $comment; $new_arr[$c]['date'] = $datesub; $profile = _profilenic($new_arr[$c]['USERID']); $new_arr[$c]['profilepic'] = $profile['profilepicture']; $new_arr[$c]['nick'] = $profile['username']; $new_arr[$c]['since'] = _datesince($new_arr[$c]['date']); $new_arr[$c]['comment'] = _getHash($new_arr[$c]['comment']); $data['user_comments'] = $new_arr; $data['comments'] = $num_comments + 1; $data = json_encode($data); file_put_contents($filename, $data); } } echo _getHash($comment);
STemplate::assign('pid', $pid); } else { $error = $lang['138']; } if ($error == "") { if (does_post_exist($pid)) { $query = "SELECT * FROM posts_comments WHERE PID='" . mysql_real_escape_string($pid) . "' ORDER BY CID desc"; $executequery = $conn->execute($query); $parray = $executequery->getarray(); $newArr = sancomment($parray); STemplate::assign('comments', $newArr); STemplate::assign('totComments', count($newArr)); $query = "SELECT A.*, B.username, B.profilepicture FROM posts A, members B WHERE A.PID='" . mysql_real_escape_string($pid) . "' AND A.USERID=B.USERID"; $executequery = $conn->execute($query); $parray = $executequery->getarray(); $titleWithHash = _getHash($parray[0]['story']); if ($parray[0]['profilepicture'] == "") { $parray[0]['profilepicture'] = 'noprofilepicture.jpg'; } STemplate::assign('p', $parray[0]); STemplate::assign('titleWithHash', $titleWithHash); $active = intval($parray[0]['active']); $videourl = trim($parray[0]['url']); $USERID = $parray[0]['USERID']; $category = intval($parray[0]['category']); STemplate::assign('USERID', $USERID); $SID = $_SESSION['USERID']; if ($SID != "" && $USERID != "") { if ($SID == $USERID) { $owner = "1"; STemplate::assign('owner', 1);
function sancomment($data) { $ret = false; if (count($data) < 1) { return false; } $c = 0; foreach ($data as $d) { $ret[$c] = $d; $profile = _profilenic($d['USERID']); $ret[$c]['profilepic'] = $profile['profilepicture']; $ret[$c]['nick'] = $profile['username']; $ret[$c]['since'] = _datesince($d['date']); $ret[$c]['comment'] = _getHash($d['comment']); $c++; } return $ret; }