Пример #1
0
	$query = 'SELECT b.id as my_id, b.author as me_author, u.username, u.moder, p.closed as post_closed, p.auth, p.views, p.content_flags, p.likes, p.dislikes, CONVERT_TZ(p.created, \'' . $server_tz . '\', \'' . $prop_tz . ':00\') as created, p.subject, p.author, p.status, p.id as id, p.chars, s.last_answered_time  from confa_posts p, confa_posts b, confa_users u, confa_sessions s where s.hash=\'' . $auth_cookie .'\' and s.last_answered_time < p.created and p.parent=b.id and b.author=' . $user_id . ' and p.author=u.id and p.id > ' . $last_answered_id . ' and p.status != 2 order by id desc limit 100';
}
$result = mysql_query($query);
if (!$result) {
    mysql_log(__FILE__, 'query failed ' . mysql_error() . ' QUERY: ' . $query);
    die('Query failed ' );
}

$query = 'UPDATE confa_sessions set last_answered_time=current_timestamp where user_id = ' . $user_id;
$result2 = mysql_query($query);
if (!$result2) {
    mysql_log(__FILE__, 'query failed ' . mysql_error() . ' QUERY: ' . $query);
    die('Query failed ' );
}
*/
$result = get_answered($how_many);
if (!$result) {
    die('Query failed');
}
$num = 1;
$out = '';
if (mysql_num_rows($result) == 0) {
    $max_id = $last_answered_id;
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $id = $row['id'];
    $auth_moder = $row['moder'];
    $subj = $row['subject'];
    $subj = encode_subject($subj);
    $enc_user = htmlentities($row['username'], HTML_ENTITIES, 'UTF-8');
    $enc_user = '******' . $root_dir . $page_byuser . '?author_id=' . $row['author'] . '" target="contents">' . $enc_user . '</a>';
Пример #2
0
             if ($max_id < 0 && !is_null($user_id)) {
                 // 'since last user's check' mode
                 $query2 = "select max(last_bydate_id) as max_id from confa_sessions where user_id=" . $user_id;
                 $result = mysql_query($query2);
                 if ($row = mysql_fetch_assoc($result)) {
                     $max_id = intval($row['max_id']);
                     $query = 'SELECT u.username, u.moder, u.ban_ends, p.auth, p.closed as post_closed, p.views, p.likes, p.dislikes, CONVERT_TZ(p.created, \'' . $server_tz . '\', \'' . $prop_tz . ':00\') as created, p.subject, p.author as author, p.status, p.id as id, p.chars, p.content_flags, p.parent, p.level, p.page, (select count(*) from confa_posts where parent = p.id) as counter from confa_posts p, confa_users u' . ' where p.author=u.id and p.id > ' . $max_id . ' and p.status != 2 order by id desc limit 500';
                 }
             } else {
                 $count = 30;
             }
         }
         $result = mysql_query($query);
         break;
     case 'answered':
         $result = get_answered(is_null($count) ? 0 : $count);
         break;
     case 'mymessages':
         if (is_null($count)) {
             $count = 50;
         }
         $query = 'SELECT u.username, u.moder, p.auth, p.closed as post_closed, CONVERT_TZ(p.created, \'' . $server_tz . '\', \'' . $prop_tz . ':00\') as created, p.subject, p.content_flags, p.views, p.likes, p.dislikes, p.status, p.id as id, p.page, p.parent, p.level, p.chars, (select count(*) from confa_posts where parent = p.id) as counter from confa_posts p, confa_users u where p.author=' . $user_id . ' and p.author=u.id and  p.status != 2 ' . ($max_id > 0 ? ' and p.id <= ' . $max_id : '') . ' order by id desc limit ' . $count;
         $result = mysql_query($query);
         break;
     default:
         $response = new Response();
         $response->setStatusCode(400, 'Error')->sendHeaders();
         $response->setContentType('application/json');
         $response->setJsonContent(array('status' => 'ERROR', 'messages' => array('Invalid parameter value: ' . $mode)));
         return $response;
 }