Exemple #1
0
#$recent = $db->get_results( "SELECT * FROM support_threads $where ORDER BY dt DESC LIMIT $offset, 20" );
// this query is uuugly but it works - it's called a group-wise maximum query.
// it finds the threads with the highest message_ids (i.e. the threads that have most recently been replied to)
$query = "FROM {$db->threads} INNER JOIN {$db->messages} ON {$db->messages}.thread_id={$db->threads}.thread_id {$where} AND {$db->messages}.message_id=(SELECT MAX(m2.message_id) FROM {$db->messages} m2 WHERE m2.thread_id={$db->threads}.thread_id) ORDER BY {$db->messages}.dt DESC";
$recent = $db->get_results("SELECT *, {$db->threads}.email as t_email {$query} LIMIT {$offset}, 20");
if (!empty($db->last_error)) {
    var_dump($db->last_error, $db->last_query);
}
$i = 0;
$total = $db->get_var("SELECT COUNT(*) {$query}");
foreach ((array) $recent as $t) {
    $class = $i % 2 ? ' class="alt"' : '';
    $excerpt = '';
    $parts = mime_split($t->content);
    if ($part = find_first_part($parts)) {
        $excerpt = substr(message_meat($part->content), 0, 300);
    }
    echo "<tr {$class} id='tr{$t->thread_id}'>\r\n\t<td><input type='checkbox' name='thread_ids[]' value='{$t->thread_id}' class='mcheck' id='mcheck{$t->thread_id}' /></td>\r\n\t<td><a href='index.php?email={$t->email}'>{$t->t_email}</a></td><td><a title='" . htmlspecialchars($excerpt, ENT_QUOTES) . "' href='thread.php?t={$t->thread_id}&amp;replies={$t->messages}'>" . htmlspecialchars($t->subject ? mime_header_decode($t->subject) : '-') . "</a></td>\r\n\t<td>" . thread_tags($t->thread_id) . "</td>\r\n\t<td>" . short_time_diff($t->dt) . "</td>\r\n\t<td>{$t->messages}</td>\r\n\t</tr>";
    ++$i;
}
?>

<tr>
<td colspan="2">
<label>With checked:</label>
<input type="submit" name="status-close" value="Close" class="enablewhenselected" />
</td>
<td colspan="3" align="right">
<?php 
$page_links = paginate_links(array('base' => add_query_arg('apage', '%#%'), 'total' => ceil($total / 20), 'current' => $page));
if ($page_links) {
Exemple #2
0
     $part = find_first_part($parts, 'text/plain');
     $message_text = trim($part->content);
     // some autoresponders include a blank text/plain part
     if (!$message_text) {
         $part = find_first_part($parts, 'text/html');
         $message_text = trim(strip_tags($part->content));
     }
 } else {
     $message_text = trim($m->content);
 }
 $html_message = htmlspecialchars($message_text);
 $html_message = preg_replace("|(-- \n.*)\$|s", '<span class="sig">$1</span>', $html_message);
 $html_message = nl2br($html_message);
 $html_message = make_clickable($html_message);
 $html_message = preg_replace('|href="(http://[^"]+)"|', 'href="http://hiderefer.com/?$1"', $html_message);
 $meat = htmlspecialchars(message_meat($message_text));
 if ($i == 1) {
     echo "<input class='lastclicked' value='{$m->message_id}' type='hidden' />";
     $the_user = $db->get_row("SELECT * FROM {$db->users} WHERE user_email='{$m->email}' LIMIT 1");
     if ($the_user) {
         echo "<input class='user_id' value='{$the_user->ID}' type='hidden' />";
     }
 }
 if ($m->from_user_id) {
     $u = get_user($m->from_user_id);
     $avatar = get_avatar($u->user_email, 48);
     $staff_reply = "Staff reply by {$u->display_name}<br />";
 } else {
     $avatar = get_avatar($m->email, 48);
     $staff_reply = '';
 }