Changeset 179 for trunk/comments.php


Ignore:
Timestamp:
Oct 5, 2003, 3:21:44 PM (21 years ago)
Author:
z0rglub
Message:

Always displays last comments, not only when choosing a number of days (->
use the default)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/comments.php

    r166 r179  
    142142}
    143143$vtp->setVar( $handle, 'back_url', add_session_id( './category.php' ) );
    144 if ( isset( $_GET['last_days'] ) )
     144// 1. retrieving picture ids which have comments recently added
     145$date = date( 'Y-m-d', time() - ( MAX_DAYS*24*60*60 ) );
     146list($year,$month,$day) = explode( '-', $date);
     147$maxtime = mktime( 0,0,0,$month,$day,$year );
     148$query = 'SELECT DISTINCT(ic.image_id) as image_id';
     149$query.= ' FROM '.PREFIX_TABLE.'comments AS c';
     150$query.=     ', '.PREFIX_TABLE.'image_category AS ic';
     151$query.= ' WHERE c.image_id = ic.image_id';
     152$query.= ' AND date > '.$maxtime;
     153// we must not show pictures of a forbidden category
     154$restricted_cats = get_all_restrictions( $user['id'],$user['status'] );
     155if ( count( $restricted_cats ) > 0 )
    145156{
    146   // 1. retrieving picture ids which have comments recently added
    147   $date = date( 'Y-m-d', time() - ( MAX_DAYS*24*60*60 ) );
    148   list($year,$month,$day) = explode( '-', $date);
    149   $maxtime = mktime( 0,0,0,$month,$day,$year );
    150   $query = 'SELECT DISTINCT(ic.image_id) as image_id';
    151   $query.= ' FROM '.PREFIX_TABLE.'comments AS c';
    152   $query.=     ', '.PREFIX_TABLE.'image_category AS ic';
    153   $query.= ' WHERE c.image_id = ic.image_id';
    154   $query.= ' AND date > '.$maxtime;
    155   // we must not show pictures of a forbidden category
    156   $restricted_cats = get_all_restrictions( $user['id'],$user['status'] );
    157   if ( count( $restricted_cats ) > 0 )
    158   {
    159     $query.= ' AND category_id NOT IN (';
    160     foreach ( $restricted_cats as $i => $restricted_cat ) {
    161       if ( $i > 0 ) $query.= ',';
    162       $query.= $restricted_cat;
    163     }
    164     $query.= ')';
     157  $query.= ' AND category_id NOT IN (';
     158  foreach ( $restricted_cats as $i => $restricted_cat ) {
     159    if ( $i > 0 ) $query.= ',';
     160    $query.= $restricted_cat;
    165161  }
    166   $query.= ' ORDER BY ic.image_id DESC';
    167   $query.= ';';
    168   $result = mysql_query( $query );
    169   display_pictures( $result, $maxtime, $restricted_cats );
     162  $query.= ')';
    170163}
     164$query.= ' ORDER BY ic.image_id DESC';
     165$query.= ';';
     166$result = mysql_query( $query );
     167display_pictures( $result, $maxtime, $restricted_cats );
    171168//----------------------------------------------------------- html code display
    172169$code = $vtp->Display( $handle, 0 );
Note: See TracChangeset for help on using the changeset viewer.