Author Topic: Listado de los últimos comentarios de la galería  (Read 4953 times)

0 Members and 1 Guest are viewing this topic.

fasciatus

  • Guest
Listado de los últimos comentarios de la galería
« on: March 12, 2005, 11:02:28 AM »
Estoy buscando algo así! En fin, que cuando un usuario entra, pues que sepa cuáles han sido los últimos comentarios de la galería

Me podéis ayudar en esto?? 
Gracias. :wink:

Offline excitex2

  • Addicted member
  • ******
  • Posts: 1.590
  • He desactivado la galería y el buscador
    • View Profile
Lo importante no es saber,,, lo importante es tener el E-Mail de quien sabe

fasciatus

  • Guest
Re: Listado de los últimos comentarios de la galería
« Reply #2 on: March 16, 2005, 08:22:40 AM »
Pues para resumir el mod, yo he optado por lo siguiente y queda así  http://www.photodigiscoping.com   Gracias al foro!!!:
En index.php
$additional_sql = "";
     $table_fields = $site_db->get_table_fields(USERS_TABLE);
     foreach ($additional_user_fields as $key => $val) {
       if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
         $additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
       }
     }
 if (isset($HTTP_GET_VARS['user_id']) and $HTTP_GET_VARS['user_id'] != ""){
   $add_where = "WHERE c.user_id IN (".$user_id.")";
 }else{
   $add_where = "";
 }
 $sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, c.comment_date".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_lastaction").get_user_table_field(", u.", "user_comments").$additional_sql."
         FROM ".COMMENTS_TABLE." c
         LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
       ".$add_where."
         ORDER BY c.comment_date DESC
       LIMIT 15";
 $result = $site_db->query($sql);
 $comment_row = array();

 while ($row = $site_db->fetch_array($result)) {
   $comment_row[] = $row;
 }
 $site_db->free_result($result);
 $num_comments = sizeof($comment_row);
 if (!$num_comments) {
   $comments_short = "<tr><td class=\"commentrow1\" colspan=\"2\">".$lang['no_comments']."</td></tr>";
 }
 else {
   $comments_short = "";
   for ($i = 0; $i < $num_comments; $i++) {
      $image_id = $comment_row[$i]['image_id'];
      $sql = "SELECT i.image_id, i.cat_id, i.image_name, c.cat_name, i.image_media_file, i.image_thumb_file
            FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
            LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
            WHERE i.image_id = $image_id AND c.cat_id = i.cat_id";
      $image_row = $site_db->query_firstrow($sql);
      $cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;
    if (check_permission("auth_readcomment", $cat_id)){
      $comment_user_name = htmlspecialchars($comment_row[$i]['comment_user_name']);
      $comment_user_info = $lang['userlevel_guest'];
      $comment_user_id = $comment_row[$i]['user_id'];
      $user_row_comment = get_user_info($comment_user_id);
      $comment_user_profile_link = "";
      $comment_user_info = $lang['userlevel_guest'];
       if (!isset($comment_row[$i][$user_table_fields['user_level']]) || (isset($comment_row[$i][$user_table_fields['user_level']]) && $comment_row[$i][$user_table_fields['user_level']] == USER)) {
         $comment_user_info = $lang['userlevel_user'];
       }
       elseif ($comment_row[$i][$user_table_fields['user_level']] == ADMIN) {
         $comment_user_info = $lang['userlevel_admin'];
       }
      if (isset($comment_row[$i][$user_table_fields['user_name']]) && $comment_user_id != GUEST) {
       $comment_user_name = htmlspecialchars($comment_row[$i][$user_table_fields['user_name']]);
       $comment_user_profile_link = !empty($url_show_profile) ? $site_sess->url(preg_replace("/{user_id}/", $comment_user_id, $url_show_profile)) : $site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$comment_user_id);
      }
       $comment_user_profile_link = ($comment_user_profile_link) ? "<a href=\"".$comment_user_profile_link."\">".$comment_user_name."</a>" : $comment_user_name;
      if (!get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 0)) {
       $thumb_file = ICON_PATH."/".get_file_extension($image_row['image_media_file']).".gif";
     }else {
       $thumb_file = get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 1);
     }
     $thumb_info = @getimagesize($thumb_file);
     $width = $thumb_info[0];
     $height = $thumb_info[1];
     $dimension = 80;
     $ratio = $width / $height;
     if ($ratio > 1) {
       $new_width = $dimension;
       $new_height = floor(($dimension/$width) * $height);
     }else {
       $new_width = floor(($dimension/$height) * $width);
       $new_height = $dimension;
     }
     $site_template->register_vars(array(
        "comment_image_thumb" => (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id)) ? "<img src=\"".$thumb_file."\" width=\"".$new_width."\" height=\"".$new_height."\" onClick=\"alert('".$lang['members_only']."');\" border=\"".$config['image_border']."\">" : "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row[$i]['image_id'].((!empty($mode)) ? "&amp;mode=".$mode : ""))."\"><img src=\"".$thumb_file."\" width=\"".$new_width."\" height=\"".$new_height."\" border=\"".$config['image_border']."\"></a>",
       "comment_image_name" => (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id)) ? $image_row['image_name'] : "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row[$i]['image_id'].((!empty($mode)) ? "&amp;mode=".$mode : ""))."\">".$image_row['image_name']."</a>",

       "comment_cat_name" => (!check_permission("auth_viewcat", $cat_id)) ? $image_row['cat_name'] : "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id)."\">".$image_row['cat_name']."</a>",
       "comment_user_name" => $comment_user_profile_link,
       "comment_user_info" => $comment_user_info,
       "comment_headline" => format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
       "comment_text" => format_text($comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
       "comment_date" => format_date($config['date_format']." ".$config['time_format'], $comment_row[$i]['comment_date']),
      ));
      $comments_short .= $site_template->parse_template("comment_short_bit");
    }
   } // end while
 } //end else
 $site_template->register_vars("comments_short", $comments_short);
 unset($comments_short);


En home.html
<table width="150" border="0" cellspacing="0" cellpadding="0">
       <tr><td class="head2" height="20" align="left"><img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />15 Últimos Comentarios</td></tr>
       <tr><td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td></tr>
       <tr><td align="center" class="row1"><br />{comments_short}<br /><br>
       <tr><td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td></tr>
      </table>
Y en comment_short_bit.hmtl
<table valign="top" width="140" border="0" cellspacing="0" cellpadding="1">
   <td class="head1">
      <table width="138" border="0" cellspacing="0" cellpadding="1" bgcolor="#FFFFFF">
         <tr><td width="45%" align="center" class="row3">{comment_image_thumb}</td><td width="55%" align="center" class="row3">{comment_image_name}</td></tr>
         <tr><td colspan="2" align="center" class="row3">{comment_cat_name}<P></td></tr>
         <tr><td colspan="2" align="center" class="row3"><strong>{comment_headline}</strong></td></tr>
         <tr><td colspan="2" align="center" class="row3">{comment_text}<p></td></tr>
         <tr><td colspan="2" align="center" class="row3">Autor: {comment_user_name}</td></tr>
         <tr><td colspan="2" align="center" class="row3">User Rank: {comment_user_info}</td></tr>
         <tr><td colspan="2" align="center" class="row3">Fecha: {comment_date}</td></tr>
      </table>
   </td>
<br>
</table>