4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: gti-the-sexy on February 10, 2003, 11:51:47 PM

Title: last commented image listing
Post by: gti-the-sexy on February 10, 2003, 11:51:47 PM
how could we listing images that  had commented (last comment must be in the top.)

like:

last comments:
20:32 - abcd
20:30 - ghyas
19:32 - samet
19:24 - noyut
18:10 - cat
18:09 - dog
17:35 - elps
16:28 - oxxo
16:10 - bayal

with their image details links (hyperlink)
without images, only with image name and their links
for whole 4images (not category by category)
Title: last commented image listing
Post by: V@no on February 11, 2003, 04:16:20 AM
1.
Insert this code in "main" file u want it to be displayed. (index.php ;  categories.php ; details.php ; so on) (if u want use it on any pages, then try add it in /includes/page_header.php )
Code: [Select]
   $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]))."'";
        }
      }
  $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)
          ORDER BY c.comment_date DESC
 LIMIT 14";
  $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
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;
$site_template->register_vars(array(
 "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);


2.
Make new template with name comment_short_bit.html.
u have chose of using those tags:
Code: [Select]
{comment_image_name}
{comment_user_name}
{comment_user_info}
{comment_headline}
{comment_text}
{comment_date}
{comment_cat_name}



3. now insert in the template that belong to the file u edited (index.php -> home.html ; categories.php -> categories.html ; so on)
Code: [Select]
{comments_short}


U can change how many comments u want to display, by changing this number:
Code: [Select]
LIMIT 14";
P.S. links to image details/category/user profile should be automaticaly disabled if u not authorized to view that page.
Title: hi
Post by: Jasondavis on February 11, 2003, 05:11:58 AM
Hi V@no do you have an example of this?
Title: last commented image listing
Post by: V@no on February 11, 2003, 05:17:37 AM
there is nothing to show, because it's all deppence on your comment_short_bit.html template.
each tag will show just a word (image name, user name/level, comment headline, comment text, date) so, it's up to u how u want it to be displayed.
Title: last commented image listing
Post by: Jasondavis on February 11, 2003, 05:48:37 AM
Quote from: V@no
there is nothing to show, because it's all deppence on your comment_short_bit.html template.
each tag will show just a word (image name, user name/level, comment headline, comment text, date) so, it's up to u how u want it to be displayed.



Oh, Im not sure I understand exactly what this does...is this making a list of all the comments in the gallery?
Title: last commented image listing
Post by: V@no on February 11, 2003, 05:53:26 AM
well, almost. its all up to u  :wink:
right now it will show only last 14 comments
so, u can make the template that will show only last 14 comments headers with links to the image it was commented.
so, other words, this script pull out information from database about comments, users who post them, and image that was commented - into those {...} tags. and all u need is include that "information" in templates, where u want it to be displayed.

sorry if its still not clear enough... :?
Title: thanks
Post by: Jasondavis on February 11, 2003, 05:58:31 AM
Makes sense now!...are you using this anywhere on your site?
Title: last commented image listing
Post by: V@no on February 11, 2003, 06:56:49 AM
no, I dont, but here is an example what info it can pull out the db:
http://come.no-ip.com/example.php
Title: last commented image listing
Post by: drhtm on February 12, 2003, 09:28:33 AM
I'm sorry for being such a beginner, but i'm not sure how to install this...I followed your example but nothing shows up...i have over 30 comments.  any ideas...could you explain exactly where to put the codes...thanks.
Title: last commented image listing
Post by: V@no on February 12, 2003, 12:32:23 PM
Quote from: drhtm
I'm sorry for being such a beginner, but i'm not sure how to install this...I followed your example but nothing shows up...i have over 30 comments.  any ideas...could you explain exactly where to put the codes...thanks.

sry, I didnt explain it as for beginner.... :oops:
try to add this code before
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------

there is someone asked how can by clicking on user, also show his comments...
with adding few lines to this code it's possible:
http://come.no-ip.com/example.php?user_id=22
will do the modification this evening  :roll:
Title: last commented image listing
Post by: drhtm on February 12, 2003, 05:32:57 PM
yeah that was me!  i asked that question!

Thanks!
Title: last commented image listing
Post by: V@no on February 14, 2003, 01:50:29 AM
in the code change
Code: [Select]

  $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)
          ORDER BY c.comment_date DESC
        LIMIT 14";
  $result = $site_db->query($sql);
  $comment_row = array();

to this:
Code: [Select]
 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 14";
  $result = $site_db->query($sql);
  $comment_row = array();


after that, u can use in url: user_id=X where X is a user ID  :roll:


also, I add another (simular) MOD:
http://www.4homepages.de/forum/viewtopic.php?t=4131
Title: last commented image listing
Post by: widgit1981 on February 14, 2003, 12:08:26 PM
Hi

I already have the below code in my index.php file how do I add this mod?

Code: [Select]


//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');



Thanks

Steve
HighRez.com
Title: last commented image listing
Post by: V@no on February 14, 2003, 12:14:41 PM
Quote from: V@no
Quote from: drhtm

try to add this code before
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------

Title: last commented image listing
Post by: widgit1981 on February 14, 2003, 12:17:47 PM
That above code is already in my index.php.
Title: last commented image listing
Post by: V@no on February 14, 2003, 12:19:17 PM
no, u add my code, above the code u showed  :roll:  :wink:
Title: last commented image listing
Post by: widgit1981 on February 14, 2003, 12:21:03 PM
What add "another" print out section ?

Thanks

Steve
Title: last commented image listing
Post by: widgit1981 on February 14, 2003, 12:24:10 PM
I tried that and it works YAY! Thank you now I have to implement it somehow into the site without it looking out of place  :P

Thanks

Steve
HighRez.com
Title: last commented image listing
Post by: V@no on February 17, 2003, 05:59:03 PM
Quote from: widgit1981
That above code is already in my index.php.

what about your code in index.php?
just add the code I posted... :roll:
Title: last commented image listing
Post by: Bomba on February 21, 2003, 04:31:36 AM
is it possible to show, when logged in, the last comments made to our images?
Title: last commented image listing
Post by: V@no on February 21, 2003, 05:01:53 AM
Quote from: Bomba
is it possible to show, when logged in, the last comments made to our images?

do u mean, "last comments" for images logged in user uploaded?
Title: last commented image listing
Post by: Bomba on February 21, 2003, 06:00:40 PM
i want the user to be warned when someone comments his images. this warning would appear when the user logs in and should disappear after he reads them.

is it possible?
Title: last commented image listing
Post by: bag53 on February 24, 2003, 04:52:39 AM
Great Mod.

This should get moved to the Mods & Plugins (Publishing & Support) forum, and made sticky.

It might be a little easier to find  :wink: .
Title: last commented image listing
Post by: drhtm on February 24, 2003, 06:21:43 AM
is there a way to add a small 40x40 thumbnail next to the comment list? just to give our users an idea what was commented on...

i'm sure its a minor modification , right?
Title: last commented image listing
Post by: V@no on February 24, 2003, 07:16:58 AM
Quote from: drhtm
is there a way to add a small 40x40 thumbnail next to the comment list? just to give our users an idea what was commented on...

i'm sure its a minor modification , right?

yeah, good idea!  :D
here u go:
1. in the code, change:
Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.image_name, c.cat_nameto this:
Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.image_name, c.cat_name, i.image_media_file, i.image_thumb_file

2. this:
Code: [Select]
     $site_template->register_vars(array(
        "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>",

to this:
Code: [Select]
     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 = 40;
      $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>",

now u can use in template this: {comment_image_thumb}



[EDITED]
Title: last commented image listing
Post by: drhtm on February 24, 2003, 07:18:26 AM
oh thanks... :oops:  :oops:

i have many more ideas...


i can share them if you like ;)
Title: last commented image listing
Post by: drhtm on February 24, 2003, 07:21:08 AM
hmmm....

the 2nd step
Code: [Select]
$site_template->register_vars(array(

is found in seven different places on the orginal code.

can you be a little more specific...thanks
Title: last commented image listing
Post by: V@no on February 24, 2003, 07:28:09 AM
ah, well, I was talking about my code only....
but here is more specific:
Code: [Select]
     $site_template->register_vars(array(
        "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>",
Title: last commented image listing
Post by: bag53 on February 24, 2003, 09:41:44 AM
Ok, I got everything working correctly. I am using this to display the latest comments in the left sidebar (underneath the random picture) and I got my comment_short_bit.html looking decent.

Here is the code if anyone's interested:
Code: [Select]
<table valign="top" width="140" border="0" cellspacing="0" cellpadding="1">
<td class="head1">
<table width="138" border="0" cellspacing="0" cellpadding="1">
<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">Posted By: {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">Date: {comment_date}</td></tr>
</table>
</td>
<br>
</table>


I set the thumbnail to 60 pixels (instead of 40) and put this into home.html underneath the random picture table:
Code: [Select]
<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" />Latest Comments</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>
Title: paging
Post by: mantra on February 27, 2003, 01:22:42 AM
What code to add if I want make paging after the limit comment is over.
Title: Re: paging
Post by: V@no on February 27, 2003, 01:32:06 AM
Quote from: mantra
What code to add if I want make paging after the limit comment is over.

if add paging feature, then this could go to MODs forum as a new MOD  :wink:
its not a very big deal to do, but there are so many little things needs to be done.
sry, dont have time to do so. (geee, cant belive I actualy said that! :? ) Maybe somebody else? ;)
Title: patient
Post by: mantra on February 27, 2003, 01:37:37 AM
Patient  :idea:
Title: last commented image listing
Post by: Ernesto Taseffa on February 27, 2003, 11:46:13 AM
.
Title: last commented image listing
Post by: V@no on February 27, 2003, 02:04:44 PM
Quote from: seffern
V@no,

in your post from 14.2 on page 3, you wrote:

"after that, u can use in url: user_id=X where X is a user ID"

Could you explain that? I just do not know what you mean by this...

Thanks

Dirk

in my post on 12.03 I gave an example for it:
http://come.no-ip.com/example.php?user_id=22
as u can see, I just added user_id=22
Title: last commented image listing
Post by: O.K. on March 04, 2003, 05:20:55 PM
I got an idea. How about making the same thing as...
When someone adds an image, it says 'NEW' for a specified period. I want this feature for new comments. Is it possible?  :roll:
Title: last commented image listing
Post by: vanner on March 15, 2003, 11:04:35 PM
Can someone show me how to replace the NEW images section of the index.php page, and replace it with the last 4 commented images.  I created my album here:

http://vanpham.com/4images/

As you notice, all the last commented images are posting on the bottom of the page...all the way to the bottom!!  I want to make the last 4 commented pictures to be horizontally set across the template under the categories secion (replacing the new images section that is normally there).

You can download the following files I tried to edit here:

http://vanpham.com/files/

I renamed index.php --> index.txt

============
Any help is apprecitated.  I am fairly new to php.
Title: Problem if put in page header
Post by: jengwen on March 16, 2003, 05:59:10 PM
I put this code in my page_header.php and it doesn't work right.  As soon as someone leaves a comment, all the category and image links only bring up that image or the category it is in.  As soon as I removed it from page_header.php everything worked fine again.

I move the code to top.php and index.php and it works fine there.  Must just be an issue with page_header.php.
Title: Error
Post by: Jaap12 on April 22, 2003, 12:21:38 PM
Hey great mod, but i get an error:

Code: [Select]
Fatal error: Call to undefined function: get_user_table_field() in /home/zippie/HTML/index.php on line 131

I running version 1.6 and that's almost the same. I think get_user_table_field must be something else. Maby you can help me? Because i like this mod very very much.
Title: Re: Error
Post by: V@no on April 22, 2003, 12:42:31 PM
Quote from: XippiX
Hey great mod, but i get an error:

Code: [Select]
Fatal error: Call to undefined function: get_user_table_field() in /home/zippie/HTML/index.php on line 131

I running version 1.6 and that's almost the same. I think get_user_table_field must be something else. Maby you can help me? Because i like this mod very very much.


*/me thinking why some people still on outdated software...:? *
just go throu the code and replace all get_user_table_field(", u.", "user_name") with:
, u.user_name

the " u. letter is just an example it might be any others or it might be just missing.
Title: last commented image listing
Post by: Jaap12 on April 22, 2003, 01:17:58 PM
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$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]))."'";
        }
      }
  $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)
          ORDER BY c.comment_date DESC
          LIMIT 14";
  $result = $site_db->query($sql);
  $comment_row = array();
  while ($row = $site_db->fetch_array($result)) {
    $comment_row[] = $row;
  }


euh what do you mean?

Code: [Select]
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."


change in what? in this? , u.user_name
if yes, can you give an example? plz?  :oops:
Title: Re: Error
Post by: V@no on April 24, 2003, 01:20:16 AM
I already gave u an example:
Quote from: V@no

just go throu the code and replace all get_user_table_field(", u.", "user_name") with:
, u.user_name

the " u. letter is just an example it might be any others or it might be just missing.

in that example was user_name .
Title: last commented image listing
Post by: jackie911 on May 11, 2003, 09:47:09 AM
After I add the following MOD to page_header.php, I chick to any pic on my site.  It will appear with same pics.  I'm not sure what the problems, please help me.

 :cry:
Jackie

my site ==> http://album.barndisco.com


Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$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 14";  
  $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 = 40;
      $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);
Title: last commented image listing
Post by: V@no on May 11, 2003, 02:37:48 PM
Quote from: jackie911
After I add the following MOD to page_header.php, I chick to any pic on my site.  It will appear with same pics.  I'm not sure what the problems, please help me.

sorry, I have no idea what are u talking about...and what is that code? whatever it is, it is wrong... :?
Title: last commented image listing
Post by: jackie911 on May 11, 2003, 04:10:51 PM
Please try to access to my site and chick any pics for testing........Then you will get the problems.

This code was inserted to includes/page_header.php.

 :cry:
Title: last commented image listing
Post by: V@no on May 11, 2003, 05:02:04 PM
Quote from: jackie911
Please try to access to my site and chick any pics for testing........Then you will get the problems.

sorry, but I have to wait about 3-4 min untill your site opens for me...its very slow...

Quote from: jackie911
This code was inserted to includes/page_header.php.

is there any particulary reasons u inserted into page__header.php???? 8O
Title: last commented image listing
Post by: jackie911 on May 11, 2003, 05:10:49 PM
Nothing........

Quote

is there any particulary reasons u inserted into page__header.php???? 8O
Title: last commented image listing
Post by: V@no on May 11, 2003, 05:17:06 PM
sorry, didnt mean to be rude ;)
but, this should be inserted into page_header.php only if u want show your last comments on all/any pages, otherwise, u should use it only in the files u want it to be showed.
Title: last commented image listing
Post by: Bomba on May 18, 2003, 09:29:48 PM
Can i insert this in index.php and then show in a new template?
i would call it using this for ex.
Code: [Select]
index.php?template=comments

and how can i make paging of this? my site has many comments and i would like to have a limit of 20 per page, for example, and have paging below it.
also i would like to know how can i insert this pagin in this mod
http://4homepages.de/forum/viewtopic.php?t=4131


thanks
Title: last commented image listing
Post by: LoOpP on May 19, 2003, 02:14:17 PM
is it possible to make that users can choose how many last commted images they want to see??

thx for help

tobi
Title: last commented image listing
Post by: LoOpP on May 20, 2003, 08:52:03 AM
no idea?
Title: last commented image listing
Post by: Bomba on May 20, 2003, 03:33:49 PM
i added code to my index.php and finished the "comment_short_bit.html" and then i add the
Code: [Select]
{comments_short} in a new template called comments.html

now when i go to "index.php?template=comments" nothing shows

should i insert the code in page_header?
if so, where should it be?

thanks
Title: last commented image listing
Post by: Bomba on May 24, 2003, 02:12:14 AM
i add the code in page_header.php and it shows last commented pics, but when i click in any thumb, it goes always to same picture, and this happen in all files (index.php, categories.php, ...)

here's the page_header.php code:
Code: [Select]
//--- End Photo Of The Day ----------------------------

$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]))."'";
        }
      }
  $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)
          ORDER BY c.comment_date DESC
          LIMIT 30";
  $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 = 120;
      $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);
//-----------------------------------------------------
//--- Set Paging Vars ---------------------------------
//-----------------------------------------------------


any ideia what could possible be wrong?
thanks
Title: Comments on a new template with paging
Post by: Art1977 on May 26, 2003, 06:39:10 PM
I have greatet a new link in user box called last comments .

This opens a new template which shows the last comments .....
But the paging function doesent work and i want the comments like V@no
in a table form like the thumbnail gallery ......

here is my code in the php file :

<?php
$templates_used = 'whos_online,comment_short_bit,last_comments,commentsperpage_dropdown_form';
$main_template = 'last_comments';

define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('GET_USER_ONLINE', 1);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
if (isset($HTTP_GET_VARS['template']) || isset($HTTP_POST_VARS['template'])) {
  $template = (isset($HTTP_GET_VARS['template'])) ? stripslashes(trim($HTTP_GET_VARS['template'])) : stripslashes(trim($HTTP_POST_VARS['template']));
  if (!file_exists(TEMPLATE_PATH."/".$template.".".$site_template->template_extension)) {
    $template = "";
  }
  else {
    $main_template = $template;
  }
}
else {
  $template = "";
}
include(ROOT_PATH.'includes/page_header.php');


//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].get_category_path($cat_id)."</span>";



//-----------------------------------------------------
//--- Letzte Kommentare
//-----------------------------------------------------
 
if (isset($HTTP_POST_VARS['commentsetperpage']) || isset($HTTP_GET_VARS['commentsetperpage'])) {
  $commentsetperpage = (intval($HTTP_POST_VARS['commentsetperpage']) ) ? intval($HTTP_POST_VARS['commentsetperpage']) : intval($HTTP_GET_VARS['commentsetperpage']);
  if ($commentsetperpage) {
    $site_sess->set_session_var("commentperpage", $commentsetperpage);
    $session_info['commentperpage'] = $commentsetperpage;
  }
}

if (isset($session_info['commentperpage'])) {
  $commentperpage = $session_info['commentperpage'];
}
else {
  $commentperpage = 5;
}
$commentsperpage_dropdown = "\n<select name=\"commentsetperpage\" onchange=\"if (this.options[this.selectedIndex].value != 0){ forms['commentsperpage'].submit() }\" class=\"select\">\n";
    for($i = 1; $i <= 15; $i++) {
      $setvalue = 1 * $i;
      $commentsperpage_dropdown .= "<option value=\"".$setvalue."\"";
        if ($setvalue == $commentperpage) {
        $commentsperpage_dropdown .= " selected=\"selected\"";
      }
      $commentsperpage_dropdown .= ">";
      $commentsperpage_dropdown .= $setvalue;
      $commentsperpage_dropdown .= "</option>\n";
    }
    $commentsperpage_dropdown .= "</select>\n";

    $site_template->register_vars("commentsperpage_dropdown", $commentsperpage_dropdown);
    $commentsperpage_dropdown_form = $site_template->parse_template("commentsperpage_dropdown_form");
    $site_template->register_vars("commentsperpage_dropdown_form", $commentsperpage_dropdown_form);
      $sql = "SELECT COUNT(image_id) AS comments
      FROM ".COMMENTS_TABLE."
      WHERE image_id = $image_id";
    $result = $site_db->query_firstrow($sql);
    $site_db->free_result();
    $num_comments = $result['comments'];
    if ($action == "postcomment") {
        $page = ceil($num_comments / $commentperpage);
    }
    $num_rows_all = (isset($num_comments)) ? $num_comments : 0;
    $link_arg = $site_sess->url(ROOT_PATH."details.php?image_id=$image_id");
    include(ROOT_PATH.'includes/paging.php');
    $getpaging = new Paging($page, $commentperpage, $num_rows_all, $link_arg, $lang['comment_stats'], "comments");
    $offset = $getpaging->get_offset();
    $site_template->register_vars(array(
      "paging" => $getpaging->get_paging(),
      "paging_stats" => ($num_comments) ? $getpaging->get_paging_stats() : ""
    ));            

$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]))."'";
        }
      }
  $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)
          ORDER BY c.comment_date DESC
          LIMIT $offset, $commentperpage";
  $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);

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
Title: Re: Comments on a new template with paging
Post by: V@no on May 26, 2003, 07:54:13 PM
Quote from: Art1977
But the paging function doesent work

please be more specific what exacly doesnt work? do u get error messages or it just doesnt show?
did u add in your template {paging} tag?
Title: Yes
Post by: Art1977 on May 26, 2003, 09:36:15 PM
I hope this would explain my problem ....

http://www.4homepages.de/forum/viewtopic.php?p=25407#25407

there are my files last_comments.php and last_comments.html

i wanted to fit your code you posted in this thread to my needs.

you can also look on my page under http://www.dmack.de.vu under party-pics ....if u register and press the "letzte kommentare" in the user box u will see the last comments but u can´t chose how much comments u want to see..... and i want those comments in a table like the thumbnails in a gallery...

thx for our fast answer

Art
Title: last commented image listing
Post by: Bomba on May 27, 2003, 01:30:36 PM
im sorry for insist
but i really need this mod :( i have more than 1000 comments made and about 90 per day ...

this would be the solution or, another way to do it would be shown last comments made to images in their owner profiles...
none of this is possible?

i've posted my problem 3 posts above. thanks in advance
Title: last commented image listing
Post by: V@no on May 27, 2003, 01:41:38 PM
what tag do u se to open a picture? ( {...} )
Title: The only problem is the paging is not shown in my template
Post by: Art1977 on May 27, 2003, 01:55:21 PM
The only problem is the paging is not shown in my template

I open the page wiht the link "letzte kommentare" in the user box .

There the last comments are shown .....
If i change the number of comments on the details site......
this affects the number of comments on my "last_comments" site
but i could not change the number directly on my template site ,because the dropdown menu is not shown on my new template ......

do u have an idea why ? my code is posted here :

http://www.4homepages.de/forum/viewtopic.php?p=25407#25407
Title: last commented image listing
Post by: Bomba on May 27, 2003, 01:57:13 PM
in that new template that this mod tells to creat "coment_short_bit.html"
i use

{comment_image_name}
{comment_cat_name}

and
{comment_image_thumb}


is this what u asked?  :roll:
lol... were u talking to me?  :oops:
Title: sorry
Post by: Art1977 on May 27, 2003, 02:02:46 PM
i would ask v@no

but it´s ok ! LOL
Title: last commented image listing
Post by: V@no on May 27, 2003, 02:17:48 PM
Quote from: Bomba
is this what u asked?  :roll:
lol... were u talking to me?  :oops:

yes ;)
well, I've gotta try it myself, then I might find out how it works...but for now, here is my example.php file:
http://come.no-ip.com/example.phps
maybe u can figure something out ;)

@Art1977:
I'm not sure what could be wrong, can I see it in action?
Title: last commented image listing
Post by: Bomba on May 27, 2003, 02:26:06 PM
thanks mate! :D

i've seen your code and that's the code of index.php right?
i inserted the code in page_header because i don't want to show last comments in home.html, i want to have new template just for that
i created comments.html where i'd put {comments_short}

but this example of yours its different, it uses a new php file? how can i create this example.php? just copying index.php code?
maybe it would work, dunno

it's so sad to be a newbie :(  
:wink:
Title: hi
Post by: Art1977 on May 27, 2003, 02:39:28 PM
i created a new php file last_comments.php

i copied the code of index.php in this file.
an modified it thats all

then i added in the user box a new link "letzte kommentare"
this links opens the last_comments.php file , that was all
but i have some problems with the layout and with the paging
the code ...

also the code has a lot of lines which are not needed
Title: thx v@no
Post by: Art1977 on May 28, 2003, 02:57:42 AM
@vano

under
http://mitglied.lycos.de/brkcrew/4images1.7/4images/last_comments.php

u will see what i mean

now i would the last comments displayed like the categories ........


but if i copy the part of the code from categories and change it
i always get 9 times the same comment
what u see is the backup before i changed the code ......
the ftp is down at the moment so i can´t upload the file
maybe u have an idea how i could display the comments like the thumbs on the categories site ....
Title: last commented image listing
Post by: Bomba on June 04, 2003, 06:00:04 PM
well everything is now working perfectly, with paging and everything :)
i just would like to have bellow the thumbnail the {user_name} that owns the pic, but if i insert the same tag as in details.html it shows allways the same username, and its always the user that has the #id of the # comments per page.

how can i add user_image tag in this mod?
thanks
Title: last commented image listing
Post by: helluvaguy on June 06, 2003, 04:19:16 PM
Quote from: V@no
...but for now, here is my example.php file:
http://come.no-ip.com/example.phps

I'm using your file but all text is displayed bold. I tried to find where you set that but couldn't find it. Could you help me?
Title: last commented image listing
Post by: kaisuny on June 16, 2003, 12:34:51 PM
It's a great mod. Follow your instruction, I could list some comments info. on he left side under  detail.php mode..

But how can I make them displaying in a horizontal order instead of a verticle one.. I prefer  them to be displaed in the center under the big random photo. Would  it be possible to enlighten me, please?


Thanks
Title: Re: thx v@no
Post by: rene on April 13, 2005, 10:54:07 PM
maybe u have an idea how i could display the comments like the thumbs on the categories site ....

insert {comment_image_thumb} in your comment_short_bit.html --> template
Title: Re: last commented image listing
Post by: Art1977 on April 14, 2005, 03:21:08 PM
Thx i already included everything.
Title: Re: last commented image listing
Post by: msummo on April 15, 2005, 07:11:47 PM
is paging now working? i want this feature but i can't get it working by myself
Title: Re: last commented image listing
Post by: universal on April 24, 2005, 10:04:10 AM
So... again me :)
A little question.
I made a modification to my member_profile.html template, I had inserted this into a table:
Code: [Select]
<a href="last.php?user_id={user_id}">20 last comments</a>
Looks that everything must work, it works but not with every member.
If member have no comments a link didn`t work try: http://www.pramoga.net/member.php?action=showprofile&user_id=2359
When I click "20 paskutiniu komentaru" link redirects to: http://www.pramoga.net/member.php&user_id=2359

How to solve this?
Title: Re: last commented image listing
Post by: universal on April 24, 2005, 10:39:51 AM
Uch one more problem, I think big, and why problems are always with me?  :?

Whent I add this:
Code: [Select]
$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 14";
 $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 = 100;
     $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);

To my page_header.php
All links of images goes to last commented image. How can it be?
I had to comment this code and everything works now...
Title: Re: last commented image listing
Post by: fotograf74 on June 03, 2005, 02:33:51 PM
Is it possible to integrate the last Comments in a other page outside from 4images, like a phpbb Forum?
Title: Re: last commented image listing
Post by: Smart on June 11, 2005, 03:03:26 PM
Hallo

Da mein englisch leiter grotten schlecht ist verstehe ich hier fast nix deswegen schreibe ich auf deutsch und würde mich sehr über eine deutsche antwort freuen :)

habe folgendes problem habe den comment Mod mit thumbnails eingebaut nach kleines problemen am anfang ging es danach super einfach :) ich habe jetzt nur folgendes problem sobald ich ein kommentar abgebe werde ich jedes mal zu dem Bild wo ich das kommentar abgegeben habe geleitet auch wenn ich auf andere bilder klicke werde immer zu dem einen geschikt.

währe cool wenn mir hier einer helfen könnte.

MFG
Title: Re: last commented image listing
Post by: mag on June 14, 2005, 08:48:57 AM
P.S. links to image details/category/user profile should be automaticaly disabled if u not authorized to view that page.

how can i change it to see it for all?

i have installed the mod with 4i 1.7.1 and with thumbs, but i see only the gif pic ? ca anyone help me
Title: Re: last commented image listing
Post by: WhiteRabbit on September 01, 2005, 04:12:14 PM
Hello people.

Excelent mod. I have it working rigth out of the box.

But I want to ask you V@no... how do you make comments appear one aside the other? (in the example that you leave on the first page). I examined the code of that page, but I don't see anything out-of-common. I did a short_comment_bit.html where each comment is a separate table (as your example), but there in no way to make it appear as your layout. In my case, it always "renders" one  underneath the other, as if it put a
Code: [Select]
<br /> at the end of each table.

My (test) short_comment_bit.html
Code: [Select]
<table border="0" cellpadding="0" cellspacing="0" align="center">
 <tr>
  <TD valign="middle">
   <table border="0" cellpadding="0" cellspacing="5" class="bgcolor" align="left">
    <tr>
     <td>
      <table border="0" cellpadding="0" cellspacing="0" class="bordercolor">
       <tr>
        <td>
         <table border="0" cellpadding="3" cellspacing="1" width="100%">
          <tr>
           <TD width="100" height="50" align="center" colspan="2" class="catbgcolor">
            {comment_image_thumb}
           </td>
          </tr>
         </table>
        </td>
       </tr>
      </table>
     </td>
    </tr>
   </table>
  </td>
 </tr>
</table>

And the part of my "last.php" where {comment short} goes:

Code: [Select]
                  <span class="title">{site_name} - Últimos comentarios</span><br />
                  <hr size="1" />
                  <table width="100%" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="3">
                          <tr>
                            <td class="head1" valign="top">Últimos 15 comentarios</td>
                          </tr>
                          <tr>
                            <td class="row2" valign="top"> {comments_short} </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>

It's the same layout as the main.php, but I did leave only the comments inside the main row (where categories, new images and stats goes).

Thanks in advance.
Best regards.
WR.
Title: Re: last commented image listing
Post by: WhiteRabbit on September 03, 2005, 07:35:36 PM
sorry for asking... it was very obvious...

I have to use {br} tag inside short_comment_bit.html...

Thanks again for this excelent mod.
Title: Re: last commented image listing
Post by: hyde101 on September 28, 2005, 06:18:15 AM
Is there a way to implement
"My Comments" link?

I will add that link to userloginform and userlogininfo boxes (active & inactive, depending on logged in state)

so they can click on that my comments link, and that will show them not only thier comments, but the images they commented as a link so they can check each image they made a comment about..
Title: Re: last commented image listing
Post by: ededi on April 29, 2008, 04:34:35 AM
hello , i have installed this mod but now shows on homepage ; no comments for this image ( before it showd only one thumbnail for all last 4 comments so i deleted this image and now says it hasnt comment for this image )

i have code below i page_header.php

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$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]))."'";
        }
      }
  $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)
          ORDER BY c.comment_date DESC
       LIMIT 4";
  $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 = 60;
      $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);
Title: Re: last commented image listing
Post by: Pumaaa on December 21, 2008, 01:23:34 PM
Hallo,

ich bekomme nach der Installation folgende Fehlermeldung:

DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.image_name, c.cat_name FROM galerie_images i, galerie_categories c LEFT JOIN galerie_users u ON (u.user_id = i.user_id) WHERE i.image_id = 127 AND c.cat_id = i.cat_id
Unknown column 'i.user_id' in 'on clause'

Woran liegt das? :(
Title: Re: last commented image listing
Post by: V@no on December 21, 2008, 10:51:59 PM
re-do step 1
Title: Re: last commented image listing
Post by: 4ella on May 31, 2009, 12:02:39 AM
Very good Mod too V@no , I think that this Mod needs shortened comment_text like last comments Mod has , but in sidebar I think it is an necessity , I had to remove the comment_text from templates because some comments are really very long , is it hard to implement it ? I was trying to take an inspiration from last comments Mod , but I will remain a newbie forever  :(

This is your complete (with thumbs and user link) 1.7.6 fully working code in my index.php above the PRINT

Code: [Select]
$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]))."'";
        }
      }
  $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)
          ORDER BY c.comment_date DESC
  LIMIT 14";
  $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 = 60;
      $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=\"0".$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=\"0".$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);

This is the 2 parts of code from last comments ( was trying to play around with it to implement that to the code above (changed $text for $comment_text but nothing happened-:):
Code: [Select]
$text_len = 200; //max lenght of the text to show (bbcode and html are counted too)
Code: [Select]
$text = $row['comment_text'];
  if (strlen($text) > $text_len)
  {
    $text = substr($text, 0, $text_len)." ...";
  }