-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_commentcount.php
65 lines (53 loc) · 2.01 KB
/
get_commentcount.php
1
<?php $time = time();while((time() - $time) < 30) {if(isset($_POST['userid'])){$id=$_POST['userid']; } include("db.php");$com=mysql_query( "SELECT b.adid, f.* FROM `dojoep_messaging_db`.`vivaru_comments` f INNER JOIN `dojoep_newhampshire`.`vivaru_ads` b ON f.object_id = b.adid AND f.deleted != 1 WHERE b.user_id = '".$id."' AND lastbidcheck < created");unset($comments);$comments = array(); $totalcomments = mysql_num_rows($com);$comments['newcomment'] = $totalcomments;$com=mysql_query("SELECT `conversations`.`conversation_id`, `conversations`.`conversation_subject`, MAX(`conversations_messages`.`message_date`) AS `conversation_last_reply`, MAX(`conversations_messages`.`message_date`) > `conversations_members`.`conversation_last_view` AS `conversation_unread` FROM `dojoep_messaging_db`.`conversations` LEFT JOIN `dojoep_messaging_db`.`conversations_messages` ON `conversations`.`conversation_id` = `conversations_messages`.`conversation_id` INNER JOIN `dojoep_messaging_db`.`conversations_members` ON `conversations`.`conversation_id`= `conversations_members`.`conversation_id` WHERE `conversations_members`.`user_id` = '2' AND `conversations_members`.`conversation_deleted` = '0' GROUP BY `conversations`.`conversation_id` ORDER BY `conversation_last_reply` DESC"); unset($tmpmessages); $tmpmessages = array(); unset($messages); $messages = array(); $newmsg = '0'; while (($row = mysql_fetch_assoc($com)) !== false){if ($row['conversation_unread'] == 1) { $tmpmessages[] = array( 'tmpmessages' => ($row['conversation_unread'] == 1), ); } } $messages['newmessage'] = count($tmpmessages); $notify = array_merge($comments, $messages); if(!empty($notify)) { echo json_encode($notify); break; } usleep(9000);}?>