4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: joecks on February 21, 2003, 06:48:49 PM

Title: Random pictures
Post by: joecks on February 21, 2003, 06:48:49 PM
Hi all,

Is it possible to add a section "random Images" on the index page, below or above the new pictures ? and a section "most popular" ???

I have that option in photopost pro, but this program is not working when safe mode is on  :cry: (shame for a $149 product !) , thats why is use the great free program 4images now.

Great Program!

Grtx,

Joecks
Title: Random pictures
Post by: SLL on February 21, 2003, 10:34:52 PM
"random picture" is already there by default, the "most popular" you can find in the this forum, in mod's section (photo of the day)
Title: Random pictures
Post by: joecks on February 22, 2003, 09:26:32 AM
I know there is a random picture, but i want to know if it is posible to ad random pictures on the index page below or above the new images, not just 1 random picture but as many as the new pictures..

same for the most popular pictures.

for a example see this featured site of photopost, http://www.spymac.com/gallery/

than you see what i mean.

Thanx

Carlo
Title: Random pictures
Post by: SLL on February 22, 2003, 11:55:08 AM
if you mean showing random pics at any page, not inside 4images - this mod you also can find in mod's section of this forum
Title: Random pictures
Post by: V@no on February 22, 2003, 01:52:15 PM
Open index.php
Find:
Code: [Select]
$site_template->register_vars("new_images", $new_images);
unset($new_images);

Add after:

Version A (without cache, images will be randomize on each visit, each page refresh)
//------------------------------------
//------- Random Images --------------
//------------------------------------
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT $num_new_images";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
  $random_images .= "</td></tr></table>";
}
else  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    show_image($image_row);
    $random_images .= $site_template->parse_template("thumbnail_bit");
    $random_images .= "\n</td>\n";
    $count++;
    if ($count == $config['image_cells']) {
      $random_images .= "</tr>\n";
      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {
        $random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $random_images .= "</tr>\n";
    }
  }
  $random_images .= "</table>\n";
} // end else


$site_template->register_vars("random_images", $random_images);
unset($random_images);

//----- End Random Images---------

Version B (with cache, images will be randomize once each hour, time controlled by $cache_time on top of the code.)
//------------------------------------
//------- Random Images --------------
//------------------------------------
$cache_time = 3600; //3600sek = 1hour

$cache_enable_old = $cache_enable;
$cache_enable = true;
$cache_id_rand = create_cache_id(
  'page.rand',
  array(
    $user_info[$user_table_fields['user_id']],
    isset($user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 0, 8) : 0,
    $config['template_dir'],
    $config['language_dir']
  )
);
if (!$random_images = get_cache_file($cache_id_rand, $cache_time))
{
  // Always append session id if cache is enabled
  $old_session_mode = $site_sess->mode;
  $site_sess->mode = 'get';
  $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
          ORDER BY RAND()
          LIMIT $num_new_images";
  // end new
  $result = $site_db->query($sql);
  $num_rows = $site_db->get_numrows($result);
  
  if (!$num_rows)  {
    $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  //  $random_images .= $lang['no_new_images'];
    $random_images .= "</td></tr></table>";
  }
  else  {
    $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
    $count = 0;
    $bgcounter = 0;
    while ($image_row = $site_db->fetch_array($result)){
      if ($count == 0) {
        $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
        $random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
      }
      $random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
  
      show_image($image_row);
      $random_images .= $site_template->parse_template("thumbnail_bit");
      $random_images .= "\n</td>\n";
      $count++;
      if ($count == $config['image_cells']) {
        $random_images .= "</tr>\n";
        $count = 0;
      }
    } // end while
  
    if ($count > 0)  {
      $leftover = ($config['image_cells'] - $count);
      if ($leftover >= 1) {
        for ($f = 0; $f < $leftover; $f++) {
          $random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
        }
        $random_images .= "</tr>\n";
      }
    }
    $random_images .= "</table>\n";
  } // end else
  $site_sess->mode = $old_session_mode;
  save_cache_file($cache_id_rand, $random_images);
}
$cache_enable = $cache_enable_old;
$site_template->register_vars("random_images", $random_images);
unset($random_images);

//----- End Random Images---------



Now, in home.html template add {random_images}
Title: Random pictures
Post by: SLL on February 22, 2003, 04:44:43 PM
ah.. that's what he wanted  :roll:
Title: Random pictures
Post by: Chris on February 22, 2003, 04:57:13 PM
Quote from: V@no
Now, in home.html template add {random_images}

:lol:

V@no I should hire you to finish the rest of the coding for my web site so I can get back to photography !
Title: Random pictures
Post by: joecks on February 22, 2003, 05:34:03 PM
:D Thank you very much v@no, it works... great!!!

Only one question left  :oops:

How do you put the title "random Images" above the random images.

I hope it is no stupid question.... .

Greetings Joecks
Title: Random pictures
Post by: V@no on February 22, 2003, 05:51:05 PM
Quote from: joecks
:D Thank you very much v@no, it works... great!!!
Only one question left  :oops:
How do you put the title "random Images" above the random images.
I hope it is no stupid question.... .
Greetings Joecks

I the code I posted, change:
Code: [Select]
$site_template->register_vars("random_images", $random_images);
unset($random_images);

to this:
Code: [Select]
$site_template->register_vars(array(
"random_images" => $random_images,
"lang_random_images" => $lang['random_images']
));
unset($random_images);


Then, open /lang/<yourlanguage>/main.php
and at the end of the file, just before ?> add this:
Code: [Select]
$lang['random_images'] = "Random Images";
now u can use this tag in the template: {lang_random_images}
Title: Random pictures
Post by: joecks on February 22, 2003, 05:58:45 PM
@ V@no ,

You are the best !!!

Now it works great !!

Greetings

Carlo
Title: Random pictures
Post by: uny on February 24, 2003, 03:41:48 PM
cool..that's what I want too, thanks V@no
Title: Random pictures
Post by: Bomba on March 09, 2003, 08:49:05 PM
i used this code and it works just great
but there's something that i would like to change, if possible.

with this code it shows the same number of random images as the new images, but i would like to show only 6 random images.

my index shows 2 rows of new images (12 new images) and for the random images i just want 1 row (6 images)


thanks
Title: Random pictures
Post by: V@no on March 09, 2003, 09:33:52 PM
Quote from: Bomba
with this code it shows the same number of random images as the new images, but i would like to show only 6 random images.

my index shows 2 rows of new images (12 new images) and for the random images i just want 1 row (6 images)

on top of the code I posted (before/above the code), add this line:
Code: [Select]
$num_new_images = $config['image_cells'];
Title: Random pictures
Post by: Bomba on March 09, 2003, 10:33:51 PM
thanks :)

that was just what i wanted
Title: Random pictures
Post by: Kamui on March 12, 2003, 05:35:33 PM
hi. i wannit to show 15 images in 3 lines, thus 5 per line. howa do this?
thx
Title: Re: Random pictures
Post by: nikolas22t on July 06, 2005, 01:14:37 PM
Is there any way to change it to have 2 rows of 4 pictures and
of course the 3 new pictures?

or put two variables for rows to cells in order to add as many you want?
Title: Re: Random pictures
Post by: Lunique on August 20, 2005, 06:52:05 PM
I have to more questions:

Is it possible to get the same for the categories?
Is it possible that only the pictures are shown and not "image name", "new", "user name" or else?

would be sooo great if you could help me!

hugs Luna
Title: Re: Random pictures
Post by: donpedro on August 30, 2005, 07:23:16 PM
Hi,

can anyone tell me if it works in 4images 1.6 too ?

regards
dp
Title: Re: Random pictures
Post by: Michael on September 23, 2005, 09:32:22 PM
Hallo,

kann man die Zufallsbilder nach Hits oder Votes anzeigen lassen?
Title: Re: Random pictures
Post by: Michael on September 24, 2005, 12:23:19 AM
Nun hab ich zu mindestens herausgefunden wie man mehrere Zellen einbindet.

suche in includes/page_header.php nach
Code: [Select]
$random_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image();
$site_template->register_vars("random_image", $random_image);
unset($random_image);

ersetzte es dann gegen:
Code: [Select]
$random_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image();
$random_image2 = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image();
$site_template->register_vars("random_image", $random_image);
$site_template->register_vars("random_image2", $random_image2);
unset($random_image);
unset($random_image2);

füge dann folgendes unter Venos Random Images in der Index.php hinzu:
Code: [Select]
//------------------------------------
//------- Random Images_2 --------------
//------------------------------------
$num_new_images = $config['image_cells'];
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
       ORDER BY RAND()
       LIMIT $num_new_images";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
 $random_images_2 = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images_2 .= $lang['no_new_images'];
 $random_images_2 .= "</td></tr></table>";
}
else  {
 $random_images_2 = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
 $count = 0;
 $bgcounter = 0;
 while ($image_row = $site_db->fetch_array($result)){
   if ($count == 0) {
     $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
     $random_images_2 .= "<tr class=\"imagerow".$row_bg_number."\">\n";
   }
   $random_images_2 .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

   show_image($image_row);
   $random_images_2 .= $site_template->parse_template("thumbnail_bit");
   $random_images_2 .= "\n</td>\n";
   $count++;
   if ($count == $config['image_cells']) {
     $random_images_2 .= "</tr>\n";
     $count = 0;
   }
 } // end while

 if ($count > 0)  {
   $leftover = ($config['image_cells'] - $count);
   if ($leftover >= 1) {
     for ($f = 0; $f < $leftover; $f++) {
       $random_images_2 .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
     }
     $random_images_2 .= "</tr>\n";
   }
 }
 $random_images_2 .= "</table>\n";
} // end else


$site_template->register_vars("random_images_2", $random_images_2);
unset($random_images_2);

//----- End Random Images_2---------

in der home.html {random_images_2} entsprechend einbinden

Das ganze kann man beliebig verlängern  :)
Title: Re: Random pictures
Post by: donpedro on September 25, 2005, 01:21:02 AM
Hi Michael,

sieht gut aus, was Du da so machst !

dp
Title: Re: Random pictures
Post by: Michael on September 25, 2005, 11:50:17 AM
Danke  :D

Nun weiß ich aber immer noch nicht wie ich die Random Bilder aus bestimmten Kategorien auslesen lasse.
Hatte schon folgende Idee, leider funktioniert es nicht.
AND i.cat_id IN (xx, xx, xx)
Title: Re: Random pictures
Post by: GeXX on September 27, 2005, 10:06:28 AM
Maybe this will help:

Vielleicht hilft Dir das ja ein wenig weiter:

http://www.4homepages.de/forum/index.php?topic=9774.0
Title: Re: Random pictures
Post by: GeXX on September 27, 2005, 01:26:41 PM
try this:

Code: [Select]
$cat_in = array(2,7,8,11,12,15,16,18); //list of category ids // *** TO FILTER RANDOM IMAGES ***

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").") AND i.cat_id IN (".implode(", ", $cat_in).")
       ORDER BY RAND()
       LIMIT $num_new_images";
Title: Re: Random pictures
Post by: Michael on September 27, 2005, 02:52:09 PM
Vielen Dank, das klappte auf Anhieb  :D

Schön wäre es wenn nun nur noch Bilder aus den erwählten Kategorien erscheinen würden die mindestens 9 Punkte haben,
also eine Selektierung nach Bewertungen.


 
Title: Re: Random pictures
Post by: GeXX on September 27, 2005, 03:53:37 PM
just add to the line

Code: [Select]
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").") AND i.cat_id IN (".implode(", ", $cat_in).")
this:
Code: [Select]
AND i.image_votes > 8
thats all...

by the way: your site looks nice!
Title: Re: Random pictures
Post by: Michael on September 27, 2005, 04:22:30 PM
super great  :D

and
Code: [Select]
i.image_rating > 7  is for rating   :mrgreen:

1000x thanks
Title: Re: Random pictures
Post by: TIMT on December 11, 2005, 11:52:52 PM
how can I show the pictures whitout the name of the photagrapher and without the name of the picture? I want to show just the image.

Title: Re: Random pictures
Post by: Acidgod on December 12, 2005, 12:07:28 AM
You must edit the random_image.html ...(o:
Title: Re: Random pictures
Post by: TIMT on December 12, 2005, 07:28:38 PM
Can I have a second random_image.html? For the random image shown on each site, the layout is ok (user- and imagename). Only the random images on my entrance-site should be displayed without user- / imagename.

Thanks!
Title: Re: Random pictures
Post by: TIMT on January 08, 2006, 12:02:55 AM
Hi Gexx, Hi Michael

where do I have to implement the following code?

Code: [Select]
$cat_in = array(2,7,8,11,12,15,16,18); //list of category ids // *** TO FILTER RANDOM IMAGES ***

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").") AND i.cat_id IN (".implode(", ", $cat_in).")
       ORDER BY RAND()
       LIMIT $num_new_images";

I show about 12 different random image. But very often the same pictures is shown twice. I have more then 600 images in the database. So the chance to display the same pictures twice should not very high.

Thanks for helping me.
Title: Re: Random pictures
Post by: TIMT on January 12, 2006, 12:03:55 AM
Please, anybody here who can help me??

Thanks a lot!
Title: Re: Random pictures
Post by: Michael on January 14, 2006, 07:05:45 PM
Hallo,

index.php

Code: [Select]
//------------------------------------
//------- Random Images --------------
//------------------------------------
$num_new_images = $config['image_cells'];
$cat_in = array(33,32,34,35,36,37,38,4); //list of category ids // *** TO FILTER RANDOM IMAGES ***

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.image_rating > 8.5 AND i.image_votes > 1 AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").") AND i.cat_id IN (".implode(", ",$cat_in).")
       ORDER BY RAND()
       LIMIT $num_new_images";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
 $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
 $random_images .= "</td></tr></table>";
}
else  {
 $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
 $count = 0;
 $bgcounter = 0;
 while ($image_row = $site_db->fetch_array($result)){
   if ($count == 0) {
     $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
     $random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
   }
   $random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

   show_image($image_row);
   $random_images .= $site_template->parse_template("thumbnail_bit");
   $random_images .= "\n</td>\n";
   $count++;
   if ($count == $config['image_cells']) {
     $random_images .= "</tr>\n";
     $count = 0;
   }
 } // end while

 if ($count > 0)  {
   $leftover = ($config['image_cells'] - $count);
   if ($leftover >= 1) {
     for ($f = 0; $f < $leftover; $f++) {
       $random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
     }
     $random_images .= "</tr>\n";
   }
 }
 $random_images .= "</table>\n";
} // end else


$site_template->register_vars("random_images", $random_images);
unset($random_images);

die in Klammern stehenden Zahlen entsprechend den eigenen Cat Id's, die angezeigft werden sollen, austauschen

$cat_in = array(33,32,34,35,36,37,38,4);  //list of category ids // *** TO FILTER RANDOM IMAGES ***

hier wird die Mindestbewertung eingestellt, es werden nur Bilder angezeigt die mindestens 8,5 Punkte haben!
Den Wert entsprechend tauschen.

WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.image_rating > 8.5 AND i.image_votes > 1 AND i.cat_id IN (".get_auth_cat_sql


Ich hoffe es hilft Dir weiter  :D
Title: Re: Random pictures
Post by: glitzer on February 05, 2006, 01:59:20 PM
How can i put it in other html sites..perhaps in the lightbox.html?

Greez
Title: Re: Random pictures
Post by: Brainwrek on July 05, 2006, 07:03:10 AM
I absolutely love this mod!  Thanks to everyone who has worked to build and support it.

I have a seemingly simple question about how to include random images on details.php.  I already have it working on index.php and categories.php, but details.php is giving me trouble.  Here's the code I've pasted into details.php:
Code: [Select]
//------------------------------------
//------- Random Images --------------
//------------------------------------
$num_new_images = 10;
$cat_in = array(119,112); //list of category ids // *** TO FILTER RANDOM IMAGES ***

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").") AND i.cat_id IN (".implode(", ",$cat_in).")
       ORDER BY RAND()
       LIMIT $num_new_images";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
$random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
$random_images .= "</td></tr></table>";
}
else  {
$random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
$count = 0;
$bgcounter = 0;
while ($image_row = $site_db->fetch_array($result)){
   if ($count == 0) {
     $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
     $random_images .= "<tr class=\"row1\">\n";
   }
   $random_images .= "<td width=\"".$imgtable_width."\">\n";

   show_image($image_row);
   $random_images .= $site_template->parse_template("thumbnail_bit");
   $random_images .= "\n</td>\n";
   $count++;
   if ($count == $config['image_cells']) {
     $random_images .= "</tr>\n";
     $count = 0;
   }
} // end while

if ($count > 0)  {
   $leftover = ($config['image_cells'] - $count);
   if ($leftover >= 1) {
     for ($f = 0; $f < $leftover; $f++) {
       $random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
     }
     $random_images .= "</tr>\n";
   }
}
$random_images .= "</table>\n";
} // end else


$site_template->register_vars("random_images", $random_images);
unset($random_images);
The problem is that the code randomizes all the photos and then displays the wrong primary image... {image}.  The random pics show up just perfectly, but the {image} is also randomized.

I'm a total PHP hack (very dangerous)  8O, and I've tried many things to fix it, but without any luck so far.

Any ideas how to make this mod compatible with details.php?
Title: Re: Random pictures
Post by: unite on July 07, 2006, 08:12:03 AM
I have a question, I installed this mod on my site and it works well. The only thing I noticed is the area where is says (random Image) does not look like the box above it where it says (new Images) its a little different in size. Did I miss something or is this how its supposed to be?

www.vistawallpapers.ws
Title: Re: Random pictures
Post by: Brainwrek on July 08, 2006, 03:53:52 PM
I have a question, I installed this mod on my site and it works well. The only thing I noticed is the area where is says (random Image) does not look like the box above it where it says (new Images) its a little different in size. Did I miss something or is this how its supposed to be?

www.vistawallpapers.ws
Your NEW IMAGES table looks like this:
Code: [Select]
   
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="head1" valign="top">New images</td>
</tr>
</table>

Your RANDOM IMAGES is wedged between table tags, like this:
Code: [Select]
</td>
</tr>
</table>
Random Images
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr class="imagerow1">
<td width="34%" valign="top">
Construct your RANDOM IMAGES table the same way you did the NEW IMAGES table and you'll be set.

=========
NOW... Can anyone help me with my question above?  I really need to display random images in display.php without randomizing the main image.  Please...  :)
Title: Re: Random pictures
Post by: unite on July 08, 2006, 06:04:14 PM
Ok I have tried everything to get this to work lol. I am not that great at coding can some one help me fix these tables
Title: Re: Random pictures
Post by: Brainwrek on July 11, 2006, 02:39:12 AM
Ok I have tried everything to get this to work lol. I am not that great at coding can some one help me fix these tables
Follow the KISS rule on this.  You're making it too hard.  :)  The *easiest* way to do what you want is simply edit your home.html template.  Insert something like this right after your New Images table in home.html:
Code: [Select]

<br />
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
  <tr>
    <td>   
       <table width="100%"  border="0" align="center" cellpadding="4" cellspacing="0">
        <tr>
          <td class="head1">Random Pictures</td>
        </tr>
       </table>
    </td>
  </tr>
  <tr>
    <td>
      <table width="100%"  border="0" cellspacing="0" cellpadding="4">
        <tr>
          <td>{random_images}</td>
        </tr>
        </table>
     </td>
    </tr>
</table>
You will have to tweak the padding and spacing and width settings to fit perfectly, but if you're trying to accomplish this by editing index.php, you're making it too hard.   :wink:
Title: Re: Random pictures
Post by: Brainwrek on July 11, 2006, 02:42:37 AM
Can someone please help me figure out how to make this work in details.php?

See my post above.  I can't figure out how to randomize the pics without randomizing the main photo on the page.   :?

Thanks guys.
Title: Re: Random pictures
Post by: BartAfterDark on January 03, 2007, 08:15:55 PM
I tried this mod but it gives me this error:

An unexpected error occured. Please try again later.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/beta/public_html/includes/db_mysql.php on line 116

And as soon as I remove the code V@NO posted the error is gone. What could be the problem (I use 4Images 1.7.4)
Title: Re: Random pictures
Post by: BartAfterDark on January 03, 2007, 09:06:56 PM
aha. The problem was
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c

FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

( ) was missing :) Now I only got one problem, how can I get it on 2 rows ?
Title: Re: Random pictures
Post by: unite on February 13, 2007, 10:51:30 PM
I just set up a new site using the latest code. www.militarywallpaper.us and I have a older site vistawallpapers.com

This code works great on vistawallpaper site but if you look at militarywallpaper.us you will see the (random image) box does not display Random Images like the box above it.

Here is the code on the Home.html
         <table width="450" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <tr>
                           <td class="head1" valign="top">{lang_random_images}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                     <tr>
                      <td class="head1">{random_images}</td>
                    </tr>
                     </table>
                  <br />
 Same code as on Vista site that works fine. I'm at a loss any help would be great.
Title: Re: Random pictures
Post by: Jacob on March 17, 2007, 03:31:34 PM
Can somebody please update this hack to use on 4images 1.7.4??

Please........  :roll: :roll:

Ok did it :) Tested on v1.7.4
Insert this code (edited as above) instead of the one suggested by vano at page 1
Code: [Select]
//------------------------------------
//------- Random Images --------------
//------------------------------------
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT $num_new_images";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
  $random_images .= "</td></tr></table>";
}
else  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    show_image($image_row);
    $random_images .= $site_template->parse_template("thumbnail_bit");
    $random_images .= "\n</td>\n";
    $count++;
    if ($count == $config['image_cells']) {
      $random_images .= "</tr>\n";
      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {
        $random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $random_images .= "</tr>\n";
    }
  }
  $random_images .= "</table>\n";
} // end else


$site_template->register_vars("random_images", $random_images);
unset($random_images);

//----- End Random Images---------

To control no. of random images to display, insert this (as suggested by vano) on the top of above code:
Code: [Select]
$num_new_images = 12;You can change 12 to any no. of random images to display.

Title: Re: Random pictures
Post by: quartz on March 18, 2007, 03:21:15 PM
thanks Jacob its works perfectly.
Title: Re: Random pictures
Post by: son_gokou on May 20, 2007, 03:49:56 PM
How can i show random images on details.php using 1.7.2 ?
Title: Re: Random pictures
Post by: manurom on May 20, 2007, 06:27:26 PM
Hello;
@ son_gokou: I understood you wanted to have a few random images when displaying another one in details. Am I right? :?:

Sorry; it's my fault.
I did not test completely.
Title: Re: Random pictures
Post by: son_gokou on May 20, 2007, 07:02:42 PM
That's exactly that :) Thanks

But i have a problem. When I did what you told me, the image doesn´t appear. It appears 404 file not found.
Title: Re: Random pictures
Post by: son_gokou on May 23, 2007, 08:33:44 PM
No problem.
But do you know already?
Title: Re: Random pictures
Post by: ashfaq on July 17, 2007, 11:47:07 AM
HOW to show only 4 random wallpaper thumbs from whole gallery on home, categories and details pages ?
One more thing how to add new pages, i mean contact form, privacy policy, disclaimer ...
Plz help i will be very thankfull to you.
Title: Re: Random pictures
Post by: athar on July 24, 2007, 05:31:11 PM
well i need help related to random images inside categories.


how we can function to show all images as random ,  inside  a main category means it should include the sub categories too. automaticaly

Code: [Select]
$cat_in = array(5); //list of category ids // *** TO FILTER RANDOM IMAGES ***

for example i have given 5 as category id so it should automatically consider and add sub categories for this main category and show random images from them on category page as well.

and one more thing that what should we do so that in

$cat_in = array( some variable )


the values of specific category be stored in a variable "some variable" like 5,6,7,9,78,55 etc   5 is the main and test 6,7,9,78,55 are its sub categories.

kindly help plz

Title: Re: Random pictures
Post by: Jacob on July 26, 2007, 06:14:22 AM
Hello friends,


Can you please suggest me how to exclude some categories in this code to show in random images table?
Title: Re: Random pictures
Post by: sydawn on July 29, 2007, 11:45:30 AM
Hello

I have tried all variations of the code in this thread to get ranodm images on my details.php page and I get either:

An unexpected error occured. Please try again later.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/beta/public_html/includes/db_mysql.php on line 116

(and I put the brackets) or it shows the page without errors but showing no thumbs at all

HELP me please.

thank you
Title: Re: Random pictures
Post by: sydawn on August 01, 2007, 08:05:40 AM
this is sad, noone to reply...

Maybe if it goes to the paid section someone might reply  :(
Title: Re: Random pictures
Post by: thunderstrike on August 01, 2007, 01:47:57 PM
Quote
Can you please suggest me how to exclude some categories in this code to show in random images table?

From FAQs, it shows WHERE cat_id IN. Simple change for: WHERE cat_id NOT IN. From (...), replace '...' with not want IDs. :)
Title: Re: Random pictures
Post by: thunderstrike on August 01, 2007, 01:51:10 PM
Quote
An unexpected error occured. Please try again later.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/beta/public_html/includes/db_mysql.php on line 116

To this from 1st page:

Quote
if ($num_rows <= 0)  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
  $random_images .= "</td></tr></table>";
}
elseif ($num_rows > 0)  {

Title: Re: Random pictures
Post by: sydawn on August 01, 2007, 10:17:24 PM
Hello there

Thanx for the reply. Now let me get this straight, I put Vano`code into my details.php and change the part you have highligted? Is this correct?

thanking you in advance
Title: Re: Random pictures
Post by: thunderstrike on August 01, 2007, 11:24:14 PM
Yes, this is right.
Title: Re: Random pictures
Post by: sydawn on August 02, 2007, 12:08:47 PM
Hi

Thanx for the suggestion =but the problem is still there. This is what I have:


unset($random_cat_image);

//------------------------------------
//------- Random Images --------------
//------------------------------------
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT $num_new_images";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if ($num_rows <= 0)  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
  $random_images .= "</td></tr></table>";
}
elseif ($num_rows > 0)  {

  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    show_image($image_row);
    $random_images .= $site_template->parse_template("thumbnail_bit");
    $random_images .= "\n</td>\n";
    $count++;
    if ($count == $config['image_cells']) {
      $random_images .= "</tr>\n";
      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {
        $random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $random_images .= "</tr>\n";
    }
  }
  $random_images .= "</table>\n";
} // end else


$site_template->register_vars("random_images", $random_images);
unset($random_images);

//----- End Random Images---------
Title: Re: Random pictures
Post by: thunderstrike on August 02, 2007, 12:31:16 PM
Please ... no need post all line ... no use for one thing (random image). Future, with attachment / bbcode ...

Change like this in details.php file:

Quote
//------------------------------------
//------- Random Images --------------
//------------------------------------
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

(highlighted)

Should work.
Title: Re: Random pictures
Post by: sydawn on August 02, 2007, 01:56:51 PM
Hello

sorry for that...

I keep getting:

An unexpected error occured. Please try again later.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\videohold\includes\db_mysql.php on line 116

Anywhere else?
Title: Re: Random pictures
Post by: thunderstrike on August 02, 2007, 01:57:58 PM
Is happen only that page ?
Title: Re: Random pictures
Post by: sydawn on August 02, 2007, 02:19:48 PM
Hello

Yes, only that page, on the home page it works fine but I dont need it there
Title: Re: Random pictures
Post by: thunderstrike on August 02, 2007, 03:28:00 PM
Can say if cat ID on cat table have it too on image table ? (All of them same) . Random SQL query say i.cat_id = c.cat_id.
Title: Re: Random pictures
Post by: sydawn on August 02, 2007, 04:26:21 PM
Hello

I am not quite sure I understand what you are saying, is that in reference to Categories?
Title: Re: Random pictures
Post by: thunderstrike on August 02, 2007, 04:36:10 PM
CATEGORIES_TABLE - > cat_id
IMAGES_TABLE - > cat_id

have all match cat_id with both table ?

Random SQL query say in code - > i.cat_id = c.cat_id two of cat_id must match same (CATEGORIES_TABLE + IMAGES_TABLE).
Title: Re: Random pictures
Post by: sydawn on August 02, 2007, 05:37:04 PM
Hi

I put that in the SQL query, the tables I got from my Phpmyadmin and are below

http://66.79.166.100/image%20cat.JPG (http://66.79.166.100/image%20cat.JPG)

http://66.79.166.100/cat%20cat.JPG (http://66.79.166.100/cat%20cat.JPG)

I really appreciate you helping me out, Im proficient on most things but SQL etc just gets to me  :(
Title: Re: Random pictures
Post by: thunderstrike on August 02, 2007, 05:41:32 PM
Good but select structure. Just left - Browse and post screenshots another.  :mrgreen:

Get there good. Keep at it. :)
Title: Re: Random pictures
Post by: sydawn on August 02, 2007, 06:15:06 PM
Hmmmm

Ok, these are the views from the browse of the tables:

http://66.79.166.100/image.htm (http://66.79.166.100/image.htm)

http://66.79.166.100/category.htm (http://66.79.166.100/category.htm)

 :?

Title: Re: Random pictures
Post by: thunderstrike on August 02, 2007, 09:59:26 PM
See 4 activate cats (1,2,3,4) but rest in IMAGES_TABLE compare CATEGORIES_TABLE not there. All image activate. Good. ;)

This MOD check permission for view cats. Do you perm the cats too from ACP ? Can be prob if no.
Title: Re: Random pictures
Post by: sydawn on August 02, 2007, 11:19:38 PM
Hi

Yes in ACP the categories are permitted  (in Category settings correct)

I am getting annoyed with this package, so I may just go back to Joomla, not your fault, but its an important part, Joomla I can set this type of thing up in 5 mins no problems.

 :cry:
Title: Re: Random pictures
Post by: thunderstrike on August 02, 2007, 11:50:49 PM
Ok so change:

Quote
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat", $cat_id).")
Title: Re: Random pictures
Post by: sydawn on August 03, 2007, 12:40:53 AM
Thanx

I changed that and the problem is still there  :cry:
Title: Re: Random pictures
Post by: thunderstrike on August 03, 2007, 12:45:40 AM
Just see thing:

Quote
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat", $cat_id).")

replace:

Quote
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND (i.cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN")."))

know not much for this MOD but hope works.
Title: Re: Random pictures
Post by: sydawn on August 03, 2007, 12:52:25 AM
Hello

Alas...no joy...What I will do is start again on a fresh install, there are ALOT of mods on this one. Is it working for you at the moment?
Title: Re: Random pictures
Post by: thunderstrike on August 03, 2007, 01:12:19 AM
Quote
Is it working for you at the moment?

Not install for me. Try on fresh ?
Title: Re: Random pictures
Post by: sydawn on August 03, 2007, 01:41:32 PM
Hello

Did a fresh install and get this:

http://66.79.166.100/raw.JPG (http://66.79.166.100/raw.JPG)

All my files are media files, does that have anything 2 do with it?

Anyhow, the problem is here




Code: [Select]
$num_new_images = $config['image_cells'];

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND (i.cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN")."))
       ORDER BY RAND()
       LIMIT $num_new_images";

Almost done I hope  :D
Title: Re: Random pictures
Post by: thunderstrike on August 03, 2007, 01:59:29 PM
Quote
All my files are media files, does that have anything 2 do with it?

This happend when upload image from ACP - > add images. Possible add image in thumbnail to media (accident). ;)
Title: Re: Random pictures
Post by: sydawn on August 03, 2007, 03:20:39 PM
Hello

No, even doing it manually or adding into folder and then saying check new images, it adds them all fine, but when it comes to the detail page it has that 404 message.

The problem seems to be in the WHERE.... line
Title: Re: Random pictures
Post by: thunderstrike on August 03, 2007, 05:15:06 PM
404 error page not WHERE - it mean page not found ... server return error ...
Title: Re: Random pictures
Post by: sydawn on August 03, 2007, 05:43:41 PM
Well,

If I put what you suggested earliar:
Code: [Select]
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat", $cat_id).")

Then the video plays but the SAME error code comes and NO thumbnails appear.
Title: Re: Random pictures
Post by: thunderstrike on August 03, 2007, 08:33:31 PM
Have .htaccess file from media ? If so, could not load for this . . .
Title: Re: Random pictures
Post by: ashfaq on September 04, 2007, 04:44:33 AM
I am using this mod but it shows random thumbnails only on home page and didnt show on categories or any other page, plz tell me how to show random thumbnails on category pages also ?

Check it here: www.deskbeauty.com (http://www.deskbeauty.com)
Title: Re: Random pictures
Post by: Mr_LovaLove on September 05, 2007, 02:33:50 PM
@ashfaq

i dont know if its correct to add the random in the details.html O_o

i checked ur site

seems u designed to not have the random

anyway, i didnt get ur question correctly

but u can take the image code lang and the thumb and  put anywhere  u want

ex:

for me {random_cat_image}

if you dont have it

plz try search engine for this fourm


search: {random_cat_image}

you will find it ! or use words

hope this help  you to get the differences between site random and cat random

Title: Re: Random pictures
Post by: ashfaq on September 05, 2007, 05:28:24 PM
I have sloved everything but this random images are not showing on details page.
Title: Re: Random pictures
Post by: skidpics on September 26, 2007, 05:27:04 AM
Quote from: Bomba
with this code it shows the same number of random images as the new images, but i would like to show only 6 random images.

my index shows 2 rows of new images (12 new images) and for the random images i just want 1 row (6 images)
on top of the code I posted (before/above the code), add this line:
Code: [Select]
$num_new_images = $config['image_cells'];
Where do we edit to show lets say 20 random images? 
Title: Re: Random pictures
Post by: skidpics on October 05, 2007, 04:15:35 PM
How would you include it into the home.html calling it via a require?

I like to my addons to be included, rather than copy / pasted into the template files.  This makes it easier to keep up with.

I am having a bit of a problem getting the random block to work like this.

Here is what I have in a random_image.php file:

Quote
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="head1">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
 <tr>
  <td class="head1" valign="top">{lang_random_image}</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="head1">{random_images}</td>
</tr>
 </table>

Here is how I am trying to call it in the home.html template page: 

Quote
<?php
 require "{template_url}/addons/random_image.php";
?>


The code works if I paste it directly, but calling it as 'require' does not.. I want it working more like a 'plugin' style, to keep the code clean..
Title: Re: Random pictures
Post by: thunderstrike on October 05, 2007, 08:55:24 PM
Quote
The code works if I paste it directly, but calling it as 'require' does not.. I want it working more like a 'plugin' style, to keep the code clean..

You no can include PHP file in HTML template if EXEC_PHP_CODE is off from includes/constants.php file. If want it clean, no include PHP file in HTML - include PHP with PHP and register in HTML + parse. ;)
Title: Re: Random pictures
Post by: ashfaq on October 22, 2007, 03:35:37 AM
This mod works but it also randomize category title, check my site http://www.deskbeauty.com
You told to put this code just on index.php but i put that code also on categories.php to show random thumbs on categories and it works great but it also randomize the category title, plz tell me how to solve this problem ? that it randomize thumbnails but not category title.
 I have also attached my category.php
Title: Re: Random pictures
Post by: ashfaq on October 24, 2007, 03:35:22 AM
This mod works but it also randomize category title, check my site http://www.deskbeauty.com
You told to put this code just on index.php but i put that code also on categories.php to show random thumbs on categories and it works great but it also randomize the category title, plz tell me how to solve this problem ? that it randomize thumbnails but not category title.
 I have also attached my category.php

Will anyone plz help ?
Title: Re: Random pictures
Post by: glitzer on November 18, 2007, 09:37:41 AM
Hi
 a simply question for php coder:
what i have to change..to show the random_image2 vertically? (only the random_image2)

can somebody help me?
I Think i have to recode the lines of:

//------------------------------------
//------- Random Images_2 --------------
//------------------------------------
$num_new_images = $config['image_cells'];
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
       ORDER BY RAND()
       LIMIT $num_new_images";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
$random_images_2 = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images_2 .= $lang['no_new_images'];
$random_images_2 .= "</td></tr></table>";
}
else  {
$random_images_2 = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
$count = 0;
$bgcounter = 0;
while ($image_row = $site_db->fetch_array($result)){
   if ($count == 0) {
     $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
     $random_images_2 .= "<tr class=\"imagerow".$row_bg_number."\">\n";
   }
   $random_images_2 .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

   show_image($image_row);
   $random_images_2 .= $site_template->parse_template("thumbnail_bit");
   $random_images_2 .= "\n</td>\n";
   $count++;
   if ($count == $config['image_cells']) {
     $random_images_2 .= "</tr>\n";
     $count = 0;
   }
} // end while

if ($count > 0)  {
   $leftover = ($config['image_cells'] - $count);
   if ($leftover >= 1) {
     for ($f = 0; $f < $leftover; $f++) {
       $random_images_2 .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
     }
     $random_images_2 .= "</tr>\n";
   }
}
$random_images_2 .= "</table>\n";
} // end else


$site_template->register_vars("random_images_2", $random_images_2);
unset($random_images_2);

please help ,-)

thanks
glitzer
Title: Re: Random pictures
Post by: glitzer on November 22, 2007, 01:22:30 PM
Any Ideas?  8O
Title: Re: Random pictures
Post by: Nicky on November 22, 2007, 02:02:58 PM
glitzer,

i posted it for you (rightnow deleted from wrong thread)


glitzer,

probiere es so
Code: [Select]
//------------------------------------
//------- Random Images_2 --------------
//------------------------------------
$num_new_images = $config['image_cells'];
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
       ORDER BY RAND()
       LIMIT $num_new_images";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
$random_images_2 = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  $random_images_2 .= $lang['no_new_images'];
$random_images_2 .= "</td></tr></table>";
}
else  {
$random_images_2 = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
$count = 0;
$bgcounter = 0;
while ($image_row = $site_db->fetch_array($result)){
   if ($count == 0) {
     $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
     $random_images_2 .= "<tr class=\"imagerow".$row_bg_number."\"><td width=\"".$imgtable_width."\" valign=\"top\">\n";
   }

   show_image($image_row);
   $random_images_2 .= $site_template->parse_template("thumbnail_bit");
   $random_images_2 .= "\n</td></tr>\n";
//   $count++;
//   if ($count == $config['image_cells']) {
//     $random_images_2 .= "</tr>\n";
//     $count = 0;
//   }
} // end while

if ($count > 0)  {
   $leftover = ($config['image_cells'] - $count);
   if ($leftover >= 1) {
     for ($f = 0; $f < $leftover; $f++) {
       $random_images_2 .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
     }
     $random_images_2 .= "</tr>\n";
   }
}
$random_images_2 .= "</table>\n";
} // end else


$site_template->register_vars("random_images_2", $random_images_2);
unset($random_images_2);

and please in the future do not crosspost your questions.
Title: Re: Random pictures
Post by: glitzer on November 22, 2007, 10:40:27 PM
vielen dank nicky!
deine erste antwort hab ich nie gesehen!
bin froh es nun zu haben
schönen abend
glitzer
Title: Re: Random pictures
Post by: ashfaq on November 23, 2007, 02:12:11 AM
This mod works but it also randomize category title, check my site http://www.deskbeauty.com
You told to put this code just on index.php but i put that code also on categories.php to show random thumbs on categories and it works great but it also randomize the category title, plz tell me how to solve this problem ? that it randomize thumbnails but not category title.
 I have also attached my category.php

Nicky dear will you plz help me ?
Title: Re: Random pictures
Post by: Nicky on November 23, 2007, 08:31:48 AM
hi,

"dear" is only the word for my wife  :mrgreen: (just joking)

pls test the attached file
Title: Re: Random pictures
Post by: myr2904 on November 26, 2007, 04:54:37 PM
Just see thing:

Quote
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat", $cat_id).")

replace:

Quote
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND (i.cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN")."))

know not much for this MOD but hope works.

I have the same problem in details.php
Doesn't show any random image but show this message:
Code: [Select]
An unexpected error occured. Please try again later.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /includes/db_mysql.php on line 116
 
Can anyone to solve the problem for details.php
Title: Re: Random pictures
Post by: myr2904 on November 26, 2007, 06:03:28 PM
please post if someone know to sole this mod
Title: Re: Random pictures
Post by: ashfaq on December 02, 2007, 02:15:13 AM
hi,

"dear" is only the word for my wife  :mrgreen: (just joking)

pls test the attached file

Thanks Nicky Dear ( as brothers are also dear ones for all people including wifes  :D )
I have checked your categories.php file and its working man, really i am very happy, Thanks.
will you plz tell me what was the problem ?
Title: Re: Random pictures
Post by: Nicky on December 09, 2007, 07:42:35 PM
Thanks Nicky Dear ( as brothers are also dear ones for all people including wifes  :D )
I have checked your categories.php file and its working man, really i am very happy, Thanks.
will you plz tell me what was the problem ?

hi ashfaq,

it was only placed into wrong area.
Title: Re: Random pictures
Post by: shadowhunter on March 25, 2008, 02:24:50 PM
Hallo

Was muss ich machen, wenn ich diesen MOD Random images nicht mit der index.php ausführen möchte, sondern auf einer einzelnen Seite in der 4images-Galerie?
Bis jetzt zeigt diese Seite (images_random.php) nur ein Bild an und auch nicht korrekt (d.h. nicht mit der Vorlage von "thumbnail_bit", sondern nur das Bild und Name alleine).
Was muss ich noch ändern, dass diese Seite so funktioniert (siehe Anhang!)?
Ich möchte mehrere Bilder auf einer Seite haben (eingestellt auf 18 in der Anhang-Datei).

Könnte mir bitte jemand weiterhelfen...
Danke.
Gruss
Title: Re: Random pictures
Post by: shadowhunter on May 03, 2008, 02:31:10 PM
Hallo!

Ich möchte unbedingt eine ganze Seite in 4images-Galerie mit Zufallsbilder haben.
Könnte bitte mir jemand helfen?
Genauer dazu habe ich bereits in der Antwort #100 geschrieben.
Wenn ich den selben Code in der index.php Seite integriere, dann funktioniert alles perfekt!
Wo liegt hier den Fehler bei meinem Code? Ich verstehe nicht warum es nicht funktioniert. Komme nicht mehr weiter.
Ich wäre euch seeehhr dankbar! 1000x Danke im Voraus!

Grüsse & schönes Weekend Jones
Title: Re: Random pictures
Post by: hakeemwafa on June 26, 2008, 08:01:58 AM
hi how are u i hope u fine and good can u help me plz iam put random images to index but it is working when iam refresh it then next iamges is come how can i stop it to one iamge i thing in  new iamges this is my site
www.hakeemwafa.com/card

and this is mail index.php file code
........................................................................
Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: index.php                                            *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    * 
 *              Web: http://www.4homepages.de                             * 
 *    Scriptversion: 1.7.6                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

$templates_used 'home,category_bit,whos_online,thumbnail_bit';
$main_template 'home';

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'])) ? get_basefile(stripslashes($HTTP_GET_VARS['template'])) : get_basefile(stripslashes($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');

if (!empty(
$template)) {
  
$clickstream "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].str_replace("_"" "ucfirst($template));
  
$site_template->register_vars("clickstream"$clickstream);
  
$site_template->print_template($site_template->parse_template($main_template));
  include(
ROOT_PATH.'includes/page_footer.php');
}

$cache_id create_cache_id(
  
'page.index',
  array(
    
$user_info[$user_table_fields['user_id']],
    isset(
$user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 08) : 0,
    
$config['template_dir'],
    
$config['language_dir']
  )
);

if (!
$cache_page_index || !$content get_cache_file($cache_id)) {
// Always append session id if cache is enabled
if ($cache_page_index) {
  
$old_session_mode $site_sess->mode;
  
$site_sess->mode 'get';
}

ob_start();

//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
$categories get_categories(0);
if (!
$categories)  {
  
$categories $lang['no_categories'];
}
$site_template->register_vars("categories"$categories);
unset(
$categories);

//-----------------------------------------------------
//--- Show New Images ---------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"has_rss"   => true,
  
"rss_title" => "RSS Feed: ".format_text($config['site_name'], 2)." (".str_replace(':'''$lang['new_images']).")",
  
"rss_url"   => $script_url."/rss.php?action=images"
));

$imgtable_width ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((
substr($config['image_table_width'], -1)) == "%") {
  
$imgtable_width .= "%";
}

$additional_sql "";
if (!empty(
$additional_image_fields)) {
  foreach (
$additional_image_fields as $key => $val) {
    
$additional_sql .= ", i.".$key;
  }
}

$num_new_images $config['image_cells'];
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT 
$num_new_images";
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$new_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
$new_images .= $lang['no_new_images'];
  
$new_images .= "</td></tr></table>";
}
else  {
  
$new_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  
$count 0;
  
$bgcounter 0;
  while (
$image_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$new_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    
show_image($image_row);
    
$new_images .= $site_template->parse_template("thumbnail_bit");
    
$new_images .= "\n</td>\n";
    
$count++;
    if (
$count == $config['image_cells']) {
      
$new_images .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['image_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$new_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      
$new_images .= "</tr>\n";
    }
  }
  
$new_images .= "</table>\n";
// end else

$site_template->register_vars("new_images"$new_images);
unset(
$new_images);
//------------------------------------
//------- Random Images --------------
//------------------------------------
$num_new_images $config['image_cells'];

$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_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_active = 1 AND c.cat_id = i.cat_id AND (i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewimage""NOTIN").", ".get_auth_cat_sql("auth_viewcat""NOTIN")."))
       ORDER BY RAND()
       LIMIT 
$num_new_images";
// end new
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
 
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
 
$random_images .= "</td></tr></table>";
}
else  {
 
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
 
$count 0;
 
$bgcounter 0;
 while (
$image_row $site_db->fetch_array($result)){
   if (
$count == 0) {
     
$row_bg_number = ($bgcounter++ % == 0) ? 2;
     
$random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
   }
   
$random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

   
show_image($image_row);
   
$random_images .= $site_template->parse_template("thumbnail_bit");
   
$random_images .= "\n</td>\n";
   
$count++;
   if (
$count == $config['image_cells']) {
     
$random_images .= "</tr>\n";
     
$count 0;
   }
 } 
// end while

 
if ($count 0)  {
   
$leftover = ($config['image_cells'] - $count);
   if (
$leftover >= 1) {
     for (
$f 0$f $leftover$f++) {
       
$random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
     }
     
$random_images .= "</tr>\n";
   }
 }
 
$random_images .= "</table>\n";
// end else


$site_template->register_vars("random_images"$random_images);
unset(
$random_images);

//----- End Random Images---------

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream
));
$site_template->print_template($site_template->parse_template($main_template));

$content ob_get_contents();
ob_end_clean();

if (
$cache_page_index) {
  
// Reset session mode
  
$site_sess->mode $old_session_mode;

  
save_cache_file($cache_id$content);
}

// end if get_cache_file()

echo $content;

include(
ROOT_PATH.'includes/page_footer.php');
?>

...................................................................................
and this is my home.html file code cun u help me plz

..........................................................................................
Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>PanjshirTv Greeting Card</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="container">
  <div id="head">
    <div id="menu">
      <ul>
        <li><a href="http://www.panjshirtv.com"> Home </a></li>
        <li><a href="http://www.panjshirtv.com/history/HISTORY.html"> History </a><a href="http://www.panjshirtv.com/Articles/articles.htm.HTML"> Article </a><a href="http://www.panjshirtv.com/sheer/sheer.htm" target="_self"> Poetry </a><a href="http://64.38.18.6/v11/index.asp?Site=eimstalk_kohsaar"> Voice Chat </a><a href="http://www.hakeemwafa.com/card"> Greeting   Card </a><a href="http://www.panjshirtv.com/panjshirtv 04-2008/video.htm"> Video </a><a href="http://www.panjshirtv.com/Jokes/Joke.HTML"> Jokes </a><a href="http://www.panjshirtv.com/panjshirtv 04-2008/khabar.htm"> News </a><a href="#"></a></li>
        <li><a href="#"></a></li>
        <li></li>
      </ul>
    </div>
  </div>
  <div id="main">
    <div id="content">
      <div class="left">
        <table width="710" height="30" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td><img src="{template_url}/images/spacer.gif" width="4" height="4" alt="" />{clickstream}</td>
            <td align="right"><a href="{url_top_images}"><b>{lang_top_images}</b></a>&nbsp; <a href="{url_new_images}"><b>{lang_new_images}</b></a>&nbsp; </td>
          </tr>
        </table>
        <div class="blogitem">
          <table width="678" height="317" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="692" class="bordercolor"><table width="678" border="0" cellspacing="1" cellpadding="0">
                  <tr>
                    <td width="676" class="tablebgcolor"><table width="675" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="150" height="265" valign="top" class="row2"><table width="150" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td class="head2" height="20"><img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_registered_user}</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">{user_box}</td>
                              </tr>
                              <tr>
                                <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                              </tr>
                            </table>
                            {if random_image}
                            <table width="150" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td class="head2" height="20"><img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_random_image}</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 />
                                  {random_image} <br />
                                  <br />
                                </td>
                              </tr>
                              <tr>
                                <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                              </tr>
                            </table>
                            {endif random_image} </td>
                          <td width="1" class="bordercolor" valign="top"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                          <td width="450" valign="top"><br />
                              <span class="title">{site_name}</span> <br />
                              <hr size="1" />
                            {if categories}
                            <table width="507" border="0" cellspacing="0" cellpadding="1">
                              <tr>
                                <td class="head1"><table width="109%" height="43" border="0" cellpadding="3" cellspacing="0">
                                  <tr>
                                    <td class="head1" valign="top">{lang_categories}</td>
                                  </tr>
                                  <tr>
                                    <td class="row2" valign="top">{categories}</td>
                                  </tr>
                                </table></td>
                              </tr>
                            </table>
                            <br />
                            {endif categories}{lang_site_stats}<br />
                            <br />
                            {if msg}<b>{msg}</b><br />
                            <br />
                            {endif msg} <br />
                            <br />
                            <br />
                            <br />
                            <br />
                            <table width="515" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td class="head1"><table width="102%" border="0" cellspacing="0" cellpadding="4">
                                  <tr>
                                   {random_images}
                                    <td class="head1" valign="top">{lang_new_images}</td>
                                  </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td class="head1">{new_images}</td>
                              </tr>
                            </table></td>
                        </tr>
                    </table></td>
                  </tr>
              </table></td>
            </tr>
          </table>
          <p><br />
            <br />
            <br />
            <br />
          </p>
          <div class="clearer">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td>{category_dropdown_form}</td>
                  <td align="right">{setperpage_dropdown_form}</td>
                </tr>
            </table>
            <br />
            <br />
          </div>
        </div>
        </div>
      <div class="clearer"><span></span></div>
    </div>
  </div>
</div>
<div class="foot">
  <p>&copy; Panjshirtv.com  |  Designed by <a rel="nofollow" target="_blank" href="#">MObeenwafa</a></p>
</div>
</body>
</html>
.........................................................................
Title: Re: Random pictures
Post by: Nicky on June 26, 2008, 08:38:46 AM
hi, 1st at all.

add 4images copyright back to your site asap.
you are already warned about that!

than we will talk about your issue.

thank you!
Title: Re: Random pictures
Post by: metal_brain on October 09, 2008, 11:27:38 AM
Hi all
I'm using 4images 1.7.6
i've tried using V@no's code with details.php
it shows what i want which is great but when i click on the thumb it takes me to a totally different picture!
if i go to index & click on the thumbs in a different category it always take me to a different cat & different pic
here's my details.php code
i'd appreciate any help
Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: details.php                                          *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.6                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) fr weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

$main_template 'details';

define('GET_CACHES'1);
define('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$user_access get_permission();
include(
ROOT_PATH.'includes/page_header.php');

if (!
$image_id) {
    
redirect($url);
}

$additional_sql "";
if (!empty(
$additional_image_fields)) {
  foreach (
$additional_image_fields as $key => $val) {
    
$additional_sql .= ", i.".$key;
  }
}

$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name").get_user_table_field(", u.""user_email")."
        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 i.image_active = 1 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;
$is_image_owner = ($image_row['user_id'] > USER_AWAITING && $user_info['user_id'] == $image_row['user_id']) ? 0;

if (!
check_permission("auth_viewcat"$cat_id) || !check_permission("auth_viewimage"$cat_id) || !$image_row) {
  
redirect($url);
}

$random_cat_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" get_random_image($cat_id);
$site_template->register_vars("random_cat_image"$random_cat_image);
unset(
$random_cat_image);

//-----------------------------------------------------
//--- Show Image --------------------------------------
//-----------------------------------------------------
$image_allow_comments = (check_permission("auth_readcomment"$cat_id)) ? $image_row['image_allow_comments'] : 0;
$image_name format_text($image_row['image_name'], 2);
show_image($image_row$mode01);

$in_mode 0;

$sql "";
if (
$mode == "lightbox") {
  if (!empty(
$user_info['lightbox_image_ids'])) {
    
$image_id_sql str_replace(" "", "trim($user_info['lightbox_image_ids']));
    
$sql "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
            FROM "
.IMAGES_TABLE."
            WHERE image_active = 1 AND image_id IN (
$image_id_sql) AND (cat_id NOT IN (".get_auth_cat_sql("auth_viewimage""NOTIN").", ".get_auth_cat_sql("auth_viewcat""NOTIN")."))
            ORDER BY "
.$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
    
$in_mode 1;
  }
}
elseif (
$mode == "search") {
  if (!isset(
$session_info['searchid']) || empty($session_info['searchid'])) {
    
$session_info['search_id'] = $site_sess->get_session_var("search_id");
  }

  if (!empty(
$session_info['search_id'])) {
    
$search_id unserialize($session_info['search_id']);
  }

  
$sql_where_query "";

  if (!empty(
$search_id['image_ids'])) {
    
$sql_where_query .= "AND image_id IN (".$search_id['image_ids'].") ";
  }

  if (!empty(
$search_id['user_ids'])) {
    
$sql_where_query .= "AND user_id IN (".$search_id['user_ids'].") ";
  }

  if (!empty(
$search_id['search_new_images']) && $search_id['search_new_images'] == 1) {
    
$new_cutoff time() - 60 60 24 $config['new_cutoff'];
    
$sql_where_query .= "AND image_date >= $new_cutoff ";
  }

  if (!empty(
$search_id['search_cat']) && $search_id['search_cat'] != 0) {
    
$cat_id_sql 0;
    if (
check_permission("auth_viewcat"$search_id['search_cat'])) {
      
$sub_cat_ids get_subcat_ids($search_id['search_cat'], $search_id['search_cat'], $cat_parent_cache);
      
$cat_id_sql .= ", ".$search_id['search_cat'];
      if (!empty(
$sub_cat_ids[$search_id['search_cat']])) {
        foreach (
$sub_cat_ids[$search_id['search_cat']] as $val) {
          if (
check_permission("auth_viewcat"$val)) {
            
$cat_id_sql .= ", ".$val;
          }
        }
      }
    }
    
$cat_id_sql $cat_id_sql !== "AND cat_id IN ($cat_id_sql)" "";
  }
  else {
    
$cat_id_sql get_auth_cat_sql("auth_viewcat""NOTIN");
    
$cat_id_sql $cat_id_sql !== "AND cat_id NOT IN (".$cat_id_sql.")" "";
  }

  if (!empty(
$sql_where_query)) {
    
$sql "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
            FROM "
.IMAGES_TABLE."
            WHERE image_active = 1
            
$sql_where_query
            
$cat_id_sql
            ORDER BY "
.$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
    
$in_mode 1;
  }
}
if (!
$in_mode || empty($sql)) {
  
$sql "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
          FROM "
.IMAGES_TABLE."
          WHERE image_active = 1 AND cat_id = 
$cat_id
          ORDER BY "
.$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
}
$result $site_db->query($sql);

$image_id_cache = array();
$next_prev_cache = array();
$break 0;
$prev_id 0;
while(
$row $site_db->fetch_array($result)) {
  
$image_id_cache[] = $row['image_id'];
  
$next_prev_cache[$row['image_id']] = $row;
  if (
$break) {
    break;
  }
  if (
$prev_id == $image_id) {
    
$break 1;
  }
  
$prev_id $row['image_id'];
}
$image_number_total $site_db->get_numrows($result);
$site_db->free_result();

if (!
function_exists("array_search")) {
  function 
array_search($needle$haystack) {
    
$match false;
    foreach (
$haystack as $key => $value) {
      if (
$value == $needle) {
        
$match $key;
      }
    }
    return 
$match;
  }
}

$act_key array_search($image_id$image_id_cache);
$next_image_id = (isset($image_id_cache[$act_key 1])) ? $image_id_cache[$act_key 1] : 0;
$prev_image_id = (isset($image_id_cache[$act_key 1])) ? $image_id_cache[$act_key 1] : 0;
$cat_url "";
if (
$cur_page 1){
  
$cat_url "&amp;".URL_PAGE."=".$cur_page;
}
$site_template->register_vars(array(
    
"image_number" => $act_key+1,
    
"image_number_total" => $image_number_total
));
unset(
$image_id_cache);

// Get next and previous image
if (!empty($next_prev_cache[$next_image_id])) {
  
$next_image_name format_text($next_prev_cache[$next_image_id]['image_name'], 2);
  
$next_image_url $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&amp;mode=".$mode ""));
  if (!
get_file_path($next_prev_cache[$next_image_id]['image_media_file'], "media"$next_prev_cache[$next_image_id]['cat_id'], 00)) {
    
$next_image_file ICON_PATH."/404.gif";
  }
  else {
    
$next_image_file get_file_path($next_prev_cache[$next_image_id]['image_media_file'], "media"$next_prev_cache[$next_image_id]['cat_id'], 01);
  }
  if (!
get_file_path($next_prev_cache[$next_image_id]['image_thumb_file'], "thumb"$next_prev_cache[$next_image_id]['cat_id'], 00)) {
    
$next_thumb_file ICON_PATH."/".get_file_extension($next_prev_cache[$next_image_id]['image_media_file']).".gif";
  }
  else {
    
$next_thumb_file get_file_path($next_prev_cache[$next_image_id]['image_thumb_file'], "thumb"$next_prev_cache[$next_image_id]['cat_id'], 01);
  }
}
else {
  
$next_image_name REPLACE_EMPTY;
  
$next_image_url REPLACE_EMPTY;
  
$next_image_file REPLACE_EMPTY;
  
$next_thumb_file REPLACE_EMPTY;
}

if (!empty(
$next_prev_cache[$prev_image_id])) {
  
$prev_image_name format_text($next_prev_cache[$prev_image_id]['image_name'], 2);
  
$prev_image_url $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&amp;mode=".$mode ""));
  if (!
get_file_path($next_prev_cache[$prev_image_id]['image_media_file'], "media"$next_prev_cache[$prev_image_id]['cat_id'], 00)) {
    
$prev_image_file ICON_PATH."/404.gif";
  }
  else {
    
$prev_image_file get_file_path($next_prev_cache[$prev_image_id]['image_media_file'], "media"$next_prev_cache[$prev_image_id]['cat_id'], 01);
  }
  if (!
get_file_path($next_prev_cache[$prev_image_id]['image_thumb_file'], "thumb"$next_prev_cache[$prev_image_id]['cat_id'], 00)) {
    
$prev_thumb_file ICON_PATH."/".get_file_extension($next_prev_cache[$prev_image_id]['image_media_file']).".gif";
  }
  else {
    
$prev_thumb_file get_file_path($next_prev_cache[$prev_image_id]['image_thumb_file'], "thumb"$next_prev_cache[$prev_image_id]['cat_id'], 01);
  }
}
else {
  
$prev_image_name REPLACE_EMPTY;
  
$prev_image_url REPLACE_EMPTY;
  
$prev_image_file REPLACE_EMPTY;
  
$prev_thumb_file REPLACE_EMPTY;
}

$site_template->register_vars(array(
  
"next_image_id" => $next_image_id,
  
"next_image_name" => $next_image_name,
  
"next_image_url" => $next_image_url,
  
"next_image_file" => $next_image_file,
  
"next_thumb_file" => $next_thumb_file,
  
"prev_image_id" => $prev_image_id,
  
"prev_image_name" => $prev_image_name,
  
"prev_image_url" => $prev_image_url,
  
"prev_image_file" => $prev_image_file,
  
"prev_thumb_file" => $prev_thumb_file
));
unset(
$next_prev_cache);

//-----------------------------------------------------
//--- Save Comment ------------------------------------
//-----------------------------------------------------
$error 0;
if (
$action == "postcomment" && isset($HTTP_POST_VARS[URL_ID])) {
  
$id intval($HTTP_POST_VARS[URL_ID]);
  
$sql "SELECT cat_id, image_allow_comments
          FROM "
.IMAGES_TABLE."
          WHERE image_id = 
$id";
  
$row $site_db->query_firstrow($sql);

  if (
$row['image_allow_comments'] == || !check_permission("auth_postcomment"$row['cat_id']) || !$row) {
    
$msg $lang['comments_deactivated'];
  }
  else {
    
$user_name un_htmlspecialchars(trim($HTTP_POST_VARS['user_name']));
    
$comment_headline un_htmlspecialchars(trim($HTTP_POST_VARS['comment_headline']));
    
$comment_text un_htmlspecialchars(trim($HTTP_POST_VARS['comment_text']));

    
$captcha = (isset($HTTP_POST_VARS['captcha'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['captcha'])) : "";

    
// Flood Check
    
$sql "SELECT comment_ip, comment_date
            FROM "
.COMMENTS_TABLE."
            WHERE image_id = 
$id
            ORDER BY comment_date DESC
            LIMIT 1"
;
    
$spam_row $site_db->query_firstrow($sql);
    
$spamtime $spam_row['comment_date'] + 180;

    if (
$session_info['session_ip'] == $spam_row['comment_ip'] && time() <= $spamtime && $user_info['user_level'] != ADMIN)  {
      
$msg .= (($msg != "") ? "<br />" "").$lang['spamming'];
      
$error 1;
    }

    
$user_name_field get_user_table_field("""user_name");
    if (!empty(
$user_name_field)) {
      if (
$site_db->not_empty("SELECT $user_name_field FROM ".USERS_TABLE." WHERE $user_name_field = '".strtolower($user_name)."' AND ".get_user_table_field("""user_id")." <> '".$user_info['user_id']."'")) {
        
$msg .= (($msg != "") ? "<br />" "").$lang['username_exists'];
        
$error 1;
      }
    }
    if (
$user_name == "")  {
      
$msg .= (($msg != "") ? "<br />" "").$lang['name_required'];
      
$error 1;
    }
    if (
$comment_headline == "")  {
      
$msg .= (($msg != "") ? "<br />" "").$lang['headline_required'];
      
$error 1;
    }
    if (
$comment_text == "")  {
      
$msg .= (($msg != "") ? "<br />" "").$lang['comment_required'];
      
$error 1;
    }

    if (
$captcha_enable_comments && !captcha_validate($captcha)) {
      
$msg .= (($msg != "") ? "<br />" "").$lang['captcha_required'];
      
$error 1;
    }

    if (!
$error)  {
      
$sql "INSERT INTO ".COMMENTS_TABLE."
              (image_id, user_id, user_name, comment_headline, comment_text, comment_ip, comment_date)
              VALUES
              (
$id, ".$user_info['user_id'].", '$user_name', '$comment_headline', '$comment_text', '".$session_info['session_ip']."', ".time().")";
      
$site_db->query($sql);
      
$commentid $site_db->get_insert_id();
      
update_comment_count($id$user_info['user_id']);
      
$msg $lang['comment_success'];
    }
  }
  unset(
$row);
  unset(
$spam_row);
}

//-----------------------------------------------------
//--- Show Comments -----------------------------------
//-----------------------------------------------------
if ($image_allow_comments == 1) {
  
$site_template->register_vars(array(
      
"has_rss"   => true,
      
"rss_title" => "RSS Feed: ".$image_name." (".str_replace(':'''$lang['comments']).")",
      
"rss_url"   => $script_url."/rss.php?action=comments&amp;".URL_IMAGE_ID."=".$image_id
  
));

  
$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_ip, c.comment_date".get_user_table_field(", u.""user_level").get_user_table_field(", u.""user_name").get_user_table_field(", u.""user_email").get_user_table_field(", u.""user_showemail").get_user_table_field(", u.""user_invisible").get_user_table_field(", u.""user_joindate").get_user_table_field(", u.""user_lastaction").get_user_table_field(", u.""user_comments").get_user_table_field(", u.""user_homepage").get_user_table_field(", u.""user_icq")."
          FROM "
.COMMENTS_TABLE." c
          LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = c.user_id)
          WHERE c.image_id = 
$image_id
          ORDER BY c.comment_date ASC"
;
  
$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 "<tr><td class=\"commentrow1\" colspan=\"2\">".$lang['no_comments']."</td></tr>";
  }
  else {
    
$comments "";
    
$bgcounter 0;
    for (
$i 0$i $num_comments$i++) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;

      
$comment_user_email "";
      
$comment_user_email_save "";
      
$comment_user_mailform_link "";
      
$comment_user_email_button "";
      
$comment_user_homepage_button "";
      
$comment_user_icq_button "";
      
$comment_user_profile_button "";
      
$comment_user_status_img REPLACE_EMPTY;
      
$comment_user_name format_text($comment_row[$i]['comment_user_name'], 2);
      
$comment_user_info $lang['userlevel_guest'];

      
$comment_user_id $comment_row[$i]['user_id'];

      if (isset(
$comment_row[$i][$user_table_fields['user_name']]) && $comment_user_id != GUEST) {
        
$comment_user_name format_text($comment_row[$i][$user_table_fields['user_name']], 2);

        
$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_button "<a href=\"".$comment_user_profile_link."\"><img src=\"".get_gallery_image("profile.gif")."\" border=\"0\" alt=\"".$comment_user_name."\" /></a>";

        
$comment_user_status_img = ($comment_row[$i][$user_table_fields['user_lastaction']] >= (time() - 300) && ((isset($comment_row[$i][$user_table_fields['user_invisible']]) && $comment_row[$i][$user_table_fields['user_invisible']] == 0) || $user_info['user_level'] == ADMIN)) ? "<img src=\"".get_gallery_image("user_online.gif")."\" border=\"0\" alt=\"Online\" />" "<img src=\"".get_gallery_image("user_offline.gif")."\" border=\"0\" alt=\"Offline\" />";

        
$comment_user_homepage = (isset($comment_row[$i][$user_table_fields['user_homepage']])) ? format_url($comment_row[$i][$user_table_fields['user_homepage']]) : "";
        if (!empty(
$comment_user_homepage)) {
          
$comment_user_homepage_button "<a href=\"".$comment_user_homepage."\" target=\"_blank\"><img src=\"".get_gallery_image("homepage.gif")."\" border=\"0\" alt=\"".$comment_user_homepage."\" /></a>";
        }

        
$comment_user_icq = (isset($comment_row[$i][$user_table_fields['user_icq']])) ? format_text($comment_row[$i][$user_table_fields['user_icq']]) : "";
        if (!empty(
$comment_user_icq)) {
          
$comment_user_icq_button "<a href=\"http://www.icq.com/people/about_me.php?uin=".$comment_user_icq."\" target=\"_blank\"><img src=\"http://status.icq.com/online.gif?icq=".$comment_user_icq."&img=5\" width=\"18\" height=\"18\" border=\"0\" alt=\"".$comment_user_icq."\" /></a>";
        }

        if (!empty(
$comment_row[$i][$user_table_fields['user_email']]) && (!isset($comment_row[$i][$user_table_fields['user_showemail']]) || (isset($comment_row[$i][$user_table_fields['user_showemail']]) && $comment_row[$i][$user_table_fields['user_showemail']] == 1))) {
          
$comment_user_email format_text($comment_row[$i][$user_table_fields['user_email']]);
          
$comment_user_email_save format_text(str_replace("@"" at "$comment_row[$i][$user_table_fields['user_email']]));
          if (!empty(
$url_mailform)) {
            
$comment_user_mailform_link $site_sess->url(preg_replace("/{user_id}/"$comment_user_id$url_mailform));
          }
          else {
            
$comment_user_mailform_link $site_sess->url(ROOT_PATH."member.php?action=mailform&amp;".URL_USER_ID."=".$comment_user_id);
          }
          
$comment_user_email_button "<a href=\"".$comment_user_mailform_link."\"><img src=\"".get_gallery_image("email.gif")."\" border=\"0\" alt=\"".$comment_user_email_save."\" /></a>";
        }

        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'];
        }

        
$comment_user_info .= "<br />";
        
$comment_user_info .= (isset($comment_row[$i][$user_table_fields['user_joindate']])) ? "<br />".$lang['join_date']." ".format_date($config['date_format'], $comment_row[$i][$user_table_fields['user_joindate']]) : "";
        
$comment_user_info .= (isset($comment_row[$i][$user_table_fields['user_comments']])) ? "<br />".$lang['comments']." ".$comment_row[$i][$user_table_fields['user_comments']] : "";
      }

      
$comment_user_ip = ($user_info['user_level'] == ADMIN) ? $comment_row[$i]['comment_ip'] : "";

      
$admin_links "";
      if (
$user_info['user_level'] == ADMIN) {
        
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=editcomment&amp;comment_id=".$comment_row[$i]['comment_id']))."\" target=\"_blank\">".$lang['edit']."</a>&nbsp;";
        
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=removecomment&amp;comment_id=".$comment_row[$i]['comment_id']))."\" target=\"_blank\">".$lang['delete']."</a>";
      }
      elseif (
$is_image_owner) {
        
$admin_links .= ($config['user_edit_comments'] != 1) ? "" "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editcomment&amp;".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['edit']."</a>&nbsp;";
        
$admin_links .= ($config['user_delete_comments'] != 1) ? "" "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&amp;".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['delete']."</a>";
      }

      
$site_template->register_vars(array(
        
"comment_id" => $comment_row[$i]['comment_id'],
        
"comment_user_id" => $comment_user_id,
        
"comment_user_status_img" => $comment_user_status_img,
        
"comment_user_name" => $comment_user_name,
        
"comment_user_info" => $comment_user_info,
        
"comment_user_profile_button" => $comment_user_profile_button,
        
"comment_user_email" => $comment_user_email,
        
"comment_user_email_save" => $comment_user_email_save,
        
"comment_user_mailform_link" => $comment_user_mailform_link,
        
"comment_user_email_button" => $comment_user_email_button,
        
"comment_user_homepage_button" => $comment_user_homepage_button,
        
"comment_user_icq_button" => $comment_user_icq_button,
        
"comment_user_ip" => $comment_user_ip,
        
"comment_headline" => format_text($comment_row[$i]['comment_headline'], 0$config['wordwrap_comments'], 00),
        
"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']),
        
"row_bg_number" => $row_bg_number,
        
"admin_links" => $admin_links
      
));
      
$comments .= $site_template->parse_template("comment_bit");
    } 
// end while
  
//end else
  
$site_template->register_vars("comments"$comments);
  unset(
$comments);

  
//-----------------------------------------------------
  //--- BBCode & Form -----------------------------------
  //-----------------------------------------------------
  
$allow_posting check_permission("auth_postcomment"$cat_id);
  
$bbcode "";
  if (
$config['bb_comments'] == && $allow_posting) {
    
$site_template->register_vars(array(
      
"lang_bbcode" => $lang['bbcode'],
      
"lang_tag_prompt" => $lang['tag_prompt'],
      
"lang_link_text_prompt" => $lang['link_text_prompt'],
      
"lang_link_url_prompt" => $lang['link_url_prompt'],
      
"lang_link_email_prompt" => $lang['link_email_prompt'],
      
"lang_list_type_prompt" => $lang['list_type_prompt'],
      
"lang_list_item_prompt" => $lang['list_item_prompt']
    ));
    
$bbcode $site_template->parse_template("bbcode");
  }

  if (!
$allow_posting) {
    
$comment_form "";
  }
  else {
    
$user_name = (isset($HTTP_POST_VARS['user_name']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['user_name'])), 2) : (($user_info['user_level'] != GUEST) ? format_text($user_info['user_name'], 2) : "");
    
$comment_headline = (isset($HTTP_POST_VARS['comment_headline']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_headline'])), 2) : "";
    
$comment_text = (isset($HTTP_POST_VARS['comment_text']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_text'])), 2) : "";

    
$site_template->register_vars(array(
      
"bbcode" => $bbcode,
      
"user_name" => $user_name,
      
"comment_headline" => $comment_headline,
      
"comment_text" => $comment_text,
      
"lang_post_comment" => $lang['post_comment'],
      
"lang_name" => $lang['name'],
      
"lang_headline" => $lang['headline'],
      
"lang_comment" => $lang['comment'],
      
"lang_captcha" => $lang['captcha'],
      
"lang_captcha_desc" => $lang['captcha_desc'],
      
"captcha_comments" => (bool)$captcha_enable_comments
    
));
    
$comment_form $site_template->parse_template("comment_form");
  }
  
$site_template->register_vars("comment_form"$comment_form);
  unset(
$comment_form);
// end if allow_comments

// Admin Links
$admin_links "";
if (
$user_info['user_level'] == ADMIN) {
  
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=editimage&amp;image_id=".$image_id))."\" target=\"_blank\">".$lang['edit']."</a>&nbsp;";
  
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=removeimage&amp;image_id=".$image_id))."\" target=\"_blank\">".$lang['delete']."</a>";
}
elseif (
$is_image_owner) {
  
$admin_links .= ($config['user_edit_image'] != 1) ? "" "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editimage&amp;".URL_IMAGE_ID."=".$image_id)."\">".$lang['edit']."</a>&nbsp;";
  
$admin_links .= ($config['user_delete_image'] != 1) ? "" "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removeimage&amp;".URL_IMAGE_ID."=".$image_id)."\">".$lang['delete']."</a>";
}
$site_template->register_vars("admin_links"$admin_links);

// Update Hits
if ($user_info['user_level'] != ADMIN) {
  
$sql "UPDATE ".IMAGES_TABLE."
          SET image_hits = image_hits + 1
          WHERE image_id = 
$image_id";
  
$site_db->query($sql);
}

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

if (
$mode == "lightbox" && $in_mode) {
  
$page_url "";
 if (
preg_match("/".URL_PAGE."=([0-9]+)/"$url$regs)) {
    if (!empty(
$regs[1]) && $regs[1] != 1) {
      
$page_url "?".URL_PAGE."=".$regs[1];
    }
  }
  
$clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."lightbox.php".$page_url)."\" class=\"clickstream\">".$lang['lightbox']."</a>".$config['category_separator'];
}
elseif (
$mode == "search" && $in_mode) {
  
$page_url "";
  if (
preg_match("/".URL_PAGE."=([0-9]+)/"$url$regs)) {
    if (!empty(
$regs[1]) && $regs[1] != 1) {
      
$page_url "&amp;".URL_PAGE."=".$regs[1];
    }
  }
  
$clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."search.php?show_result=1".$page_url)."\" class=\"clickstream\">".$lang['search']."</a>".$config['category_separator'];
}
else {
  
$clickstream .= get_category_path($cat_id1).$config['category_separator'];
}
$clickstream .= $image_name."</span>";
//------------------------------------
//------- Random Images --------------
//------------------------------------
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN ("
.get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT 6"
;
// end new
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr><td>";
//  $random_images .= $lang['no_new_images'];
  
$random_images .= "</td></tr></table>";
}
else  {
  
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  
$count 0;
  
$bgcounter 0;
  while (
$image_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$random_images .= "<tr>\n";
    }
    
$random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    
show_image($image_row);
    
$random_images .= $site_template->parse_template("malenki");
    
$random_images .= "\n</td>\n";
    
$count++;
    if (
$count == 6) {
      
$random_images .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['image_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      
$random_images .= "</tr>\n";
    }
  }
  
$random_images .= "</table>\n";
// end else


$site_template->register_vars("random_images"$random_images);
unset(
$random_images);

//----- End Random Images---------

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream,
  
"lang_category" => $lang['category'],
  
"lang_added_by" => $lang['added_by'],
  
"lang_description" => $lang['description'],
  
"lang_keywords" => $lang['keywords'],
  
"lang_date" => $lang['date'],
  
"lang_hits" => $lang['hits'],
  
"lang_downloads" => $lang['downloads'],
  
"lang_rating" => $lang['rating'],
  
"lang_votes" => $lang['votes'],
  
"lang_author" => $lang['author'],
  
"lang_comment" => $lang['comment'],
  
"lang_prev_image" => $lang['prev_image'],
  
"lang_next_image" => $lang['next_image'],
  
"lang_file_size" => $lang['file_size']
));
if (isset(
$main_template) && $main_template) {
 
  
$leftside $site_template->parse_template("leftside");
  
$site_template->register_vars(array(

     
"leftside" => $leftside,
  ));

   unset(
$leftside);
}
$site_template->print_template($site_template->parse_template($main_template));
include(
ROOT_PATH.'includes/page_footer.php');
?>
Title: Re: Random pictures
Post by: zibko on October 10, 2008, 12:42:34 AM
I have on my web page 4images in subdirectory /galerija . I wish, that on my main page (/index.php), where are news, text, ... will be shown one random picture from my galery. How can I do this?
Title: Re: Random pictures
Post by: V@no on October 10, 2008, 03:19:50 AM
Welcome to 4images forum.

Did you see the very first message in this topic?


Hi all
I'm using 4images 1.7.6
i've tried using V@no's code with details.php
it shows what i want which is great but when i click on the thumb it takes me to a totally different picture!
if i go to index & click on the thumbs in a different category it always take me to a different cat & different pic

Actually it takes you to the right picture, its just randomizes your details picture...

use this code instead:
//------------------------------------
//------- Random Images --------------
//------------------------------------
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT 6";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr><td>";
//  $random_images .= $lang['no_new_images'];
  $random_images .= "</td></tr></table>";
}
else  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  $image_backup = $site_template->val_cache['image'];
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $random_images .= "<tr>\n";
    }
    $random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    show_image($image_row);
    $random_images .= $site_template->parse_template("malenki");
    $random_images .= "\n</td>\n";
    $count++;
    if ($count == 6) {
      $random_images .= "</tr>\n";
      $count = 0;
    }
  } // end while
  $site_template->val_cache['image'] = $image_backup;
  unset($image_backup);

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {
        $random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $random_images .= "</tr>\n";
    }
  }
  $random_images .= "</table>\n";
} // end else


$site_template->register_vars("random_images", $random_images);
unset($random_images);

//----- End Random Images---------
Title: Re: Random pictures
Post by: metal_brain on October 12, 2008, 07:56:53 AM
Thanks V@no
& hey welcome back to this forum
you are the one :)
Title: Re: Random pictures
Post by: zibko on October 16, 2008, 06:20:16 PM
This not work @V@no

So, my problem is.

I have galery here: http://www.pgd-dvor.si/galerija/

I want that random picture also will be on main page (say on right site) here: http://www.pgd-dvor.si/

I hope you understand what i want.
Title: Re: Random pictures
Post by: olrac on October 18, 2008, 07:43:09 PM
is there any possible that i can put 4 random images? thanks
Title: Re: Random pictures
Post by: crs on October 26, 2008, 01:19:08 PM
Hallo, anscheinend wird das Layout der Zufallsbilder von der .HTML Datei der neuen Bilder bezogen.

Ich möchte bei den Zufallsbildern aber nur den das Bild angezeigt bekommen, ohne Namen etc.
Wie kann ich also eine andere .html Datei für die Zufallsbilder verwenden oder was muss ich verändern?
Title: Re: Random pictures
Post by: Boemmel on November 02, 2008, 02:09:21 AM
ich hätte auch ein anliegen .
Ich hätte gerne nur die "Neue Bilder" als Zufallsbild auf der index-Seite.

Was muss ich dafür ändern ?

Title: Re: Random pictures
Post by: metal_brain on November 05, 2008, 12:02:12 PM
I'm using this code     LINK (http://www.4homepages.de/forum/index.php?topic=4259.msg125393#msg125393)
with a freash clean copy of 4images 1.7.6
it's working fine but i'm noticed that rating stopped working!!!! when i remove the code it works!!!!
so please could u advise
note hat i add the code directly above the Print Out and i use it in details.php

Title: Re: Random pictures
Post by: metal_brain on November 06, 2008, 02:06:11 PM
I'm using this code     LINK (http://www.4homepages.de/forum/index.php?topic=4259.msg125393#msg125393)
with a freash clean copy of 4images 1.7.6
it's working fine but i'm noticed that rating stopped working!!!! when i remove the code it works!!!!
so please could u advise
note hat i add the code directly above the Print Out and i use it in details.php


I have removed the code from details.php and i'm using  the code on page_header.php
the rating & votes are working fine but now another problem appeared on search

this is the error
Code: [Select]
Notice: Undefined variable: additional_sql in /hermes/web05/b1164/pow.txttv/htdocs/includes/page_header.php on line 427when i search the pager header file the line 427 is
Code: [Select]
$sql = "SELECT i.image_id, i.catso any ideas?
thanks

Note: the url is http://www.txttv.tv/search.php (http://www.txttv.tv/search.php)
Title: Re: Random pictures
Post by: metal_brain on November 12, 2008, 10:11:14 AM
I solved it  :D

the code is meant to be used with index.php /home page
i wanted to use it with page_header.php & i was getting errors on search page
so what i did i copied the code that is missing from index.php
& it's working like a charm

here's the code i'm using in pager_header.php before ?>

Thanks vano for ur code & help
Code: [Select]
//------------------------------------
//------- Random Images by v@no --------------
//------------------------------------


$imgtable_width = ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
  $imgtable_width .= "%";
}

$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;
  }
}
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT 6";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr><td>";
//  $random_images .= $lang['no_new_images'];
  $random_images .= "</td></tr></table>";
}
else  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  $image_backup = $site_template->val_cache['image'];
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $random_images .= "<tr>\n";
    }
    $random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    show_image($image_row);
    $random_images .= $site_template->parse_template("thumbnail_bit");
    $random_images .= "\n</td>\n";
    $count++;
    if ($count == 6) {
      $random_images .= "</tr>\n";
      $count = 0;
    }
  } // end while
  $site_template->val_cache['image'] = $image_backup;
  unset($image_backup);

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {
        $random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $random_images .= "</tr>\n";
    }
  }
  $random_images .= "</table>\n";
} // end else


$site_template->register_vars("random_images", $random_images);
unset($random_images);

//----- End Random Images---------
Title: Re: Random pictures
Post by: TaijovuNeji on December 03, 2008, 11:16:21 PM
How can I show the random images vertically? Like this:
IMAGE 1
IMAGE 2
IMAGE 3

Title: Re: Random pictures
Post by: V@no on December 04, 2008, 01:09:19 AM
Welcome to 4images forum.

Use <br />
Title: Re: Random pictures
Post by: TaijovuNeji on December 04, 2008, 02:08:34 AM
Thanks!  :D .. this is a great forum!  :mrgreen:

So.. i know about the <br /> .. but where should I put this tag in this code:

Code: [Select]
//------- Random Images --------------
//------------------------------------
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT $num_new_images";
// end new
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
  $random_images .= "</td></tr></table>";
}
else  {
  $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n ";
    }
    $random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n ";

    show_image($image_row);
    $random_images .= $site_template->parse_template("thumbnail_bit");
    $random_images .= "\n</td>\n ";
    $count++;
    if ($count == $config['image_cells']) {
      $random_images .= "</tr>\n ";
      $count = 0;

    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {
        $random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n ";
      }
      $random_images .= "</tr>\n ";
    }
  }
  $random_images .= "</table>\n ";
} // end else


$site_template->register_vars("random_images", $random_images);
unset($random_images);

//----- End Random Images---------
Title: Re: Random pictures
Post by: V@no on December 04, 2008, 02:55:30 AM
Oh, my bad, I thought this was another topic about random image on external site...

In that code replace
Code: [Select]
    if ($count == $config['image_cells']) {
with:
Code: [Select]
    if ($count == 1) {
Title: Re: Random pictures
Post by: TaijovuNeji on December 04, 2008, 03:15:32 AM
I read the other topic about the <br /> .. but this command is used after this: "echo" and this script don't have "echo" O.o ..

But thanks man .. worked perfectly here what you talked to me.. you are master in php  :D
Title: Re: Random pictures
Post by: TaijovuNeji on December 04, 2008, 03:41:18 AM
One more question: How do I put the image in the center??
This command not works: align="center" .. why? o.O
Title: Re: Random pictures
Post by: V@no on December 04, 2008, 04:26:03 AM
that is something you can do in thumbnail_bit.html template
Title: Re: Random pictures
Post by: TaijovuNeji on January 02, 2009, 07:06:37 PM
But now shows this error message: Parse error: syntax error, unexpected '}' in /home/dungeonm/public_html/galeriadm/includes/template.php(101) : eval()'d code on line 3
Title: Re: Random pictures
Post by: V@no on January 02, 2009, 11:45:50 PM
With the amount of information you've proved the only possible answer you could get is:
that error indicates that you did something wrong in a template file.

if you used PHP code in template, then number of { is mismatched with number of }
Title: Re: Random pictures
Post by: TaijovuNeji on January 11, 2009, 03:57:57 PM
So, you can take a look in de index.php for me?
The code:

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: index.php                                            *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    * 
 *              Web: http://www.4homepages.de                             * 
 *    Scriptversion: 1.7.6                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

$templates_used 'home,category_bit,whos_online,thumbnail_bit';
$main_template 'home';

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'])) ? get_basefile(stripslashes($HTTP_GET_VARS['template'])) : get_basefile(stripslashes($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');

if (!empty(
$template)) {
  
$clickstream "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].str_replace("_"" "ucfirst($template));
  
$site_template->register_vars("clickstream"$clickstream);
  
$site_template->print_template($site_template->parse_template($main_template));
  include(
ROOT_PATH.'includes/page_footer.php');
}

$cache_id create_cache_id(
  
'page.index',
  array(
    
$user_info[$user_table_fields['user_id']],
    isset(
$user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 08) : 0,
    
$config['template_dir'],
    
$config['language_dir']
  )
);

if (!
$cache_page_index || !$content get_cache_file($cache_id)) {
// Always append session id if cache is enabled
if ($cache_page_index) {
  
$old_session_mode $site_sess->mode;
  
$site_sess->mode 'get';
}

ob_start();

//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
$categories get_categories(0);
if (!
$categories)  {
  
$categories $lang['no_categories'];
}
$site_template->register_vars("categories"$categories);
unset(
$categories);

//-----------------------------------------------------
//--- Show New Images ---------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"has_rss"   => true,
  
"rss_title" => "RSS Feed: ".format_text($config['site_name'], 2)." (".str_replace(':'''$lang['new_images']).")",
  
"rss_url"   => $script_url."/rss.php?action=images"
));

$imgtable_width ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((
substr($config['image_table_width'], -1)) == "%") {
  
$imgtable_width .= "%";
}

$additional_sql "";
if (!empty(
$additional_image_fields)) {
  foreach (
$additional_image_fields as $key => $val) {
    
$additional_sql .= ", i.".$key;
  }
}

$num_new_images $config['image_cells'];
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT 
$num_new_images";
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$new_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
$new_images .= $lang['no_new_images'];
  
$new_images .= "</td></tr></table>";
}
else  {
  
$new_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  
$count 0;
  
$bgcounter 0;
  while (
$image_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$new_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    
show_image($image_row);
    
$new_images .= $site_template->parse_template("thumbnail_bit");
    
$new_images .= "\n</td>\n";
    
$count++;
    if (
$count == $config['image_cells']) {
      
$new_images .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['image_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$new_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      
$new_images .= "</tr>\n";
    }
  }
  
$new_images .= "</table>\n";
// end else

$site_template->register_vars("new_images"$new_images);
unset(
$new_images);

//------------------------------------
//------- Random Images --------------
//------------------------------------
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN ("
.get_auth_cat_sql("auth_viewcat").")
        ORDER BY RAND()
        LIMIT 
$num_new_images";
// end new
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
//  $random_images .= $lang['no_new_images'];
  
$random_images .= "</td></tr></table>";
}
else  {
  
$random_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  
$count 0;
  
$bgcounter 0;
  while (
$image_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    
show_image($image_row);
    
$random_images .= $site_template->parse_template("thumbnail_bit");
    
$random_images .= "\n</td>\n";
    
$count++;
    if (
$count == $config['image_cells']) {
      
$random_images .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['image_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      
$random_images .= "</tr>\n";
    }
  }
  
$random_images .= "</table>\n";
// end else


$site_template->register_vars("random_images"$random_images);
unset(
$random_images);

//----- End Random Images---------


//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream
));
$site_template->print_template($site_template->parse_template($main_template));

$content ob_get_contents();
ob_end_clean();

if (
$cache_page_index) {
  
// Reset session mode
  
$site_sess->mode $old_session_mode;

  
save_cache_file($cache_id$content);
}

// end if get_cache_file()

echo $content;

include(
ROOT_PATH.'includes/page_footer.php');
?>
   
What did I do wrong?
Title: Random Images: How to show images from "x" category
Post by: jorge05r on January 14, 2009, 12:29:20 AM
I searched the forum before asking this question but didn't find anything specific.

Here's the site http://itouchwallpapers.com/ , see where I have the random images section?

I have a mod which it shows "random images" but I would like the random images from 2 categories only. How could I make the random images mod show only two specific categories and not from all images/photos from the site?
Title: Re: Random Images: How to show images from "x" category
Post by: V@no on January 14, 2009, 02:23:26 AM
Hello and welcome to 4images forum.

In includes/functions.php find:
Code: [Select]
  if (!empty($random_image_cache[$category_id])) {
Insert above:
Code:  [Select]  [Expand]
  srand((float)microtime() * 1000000);
  $category_id = array_rand(array(1, 2));

Replace numbers 1 and 2 with your category IDs
Title: Re: Random Images: How to show images from "x" category
Post by: jorge05r on January 16, 2009, 10:02:05 PM
Thank you!

Sorry if I didn't explain myself better. I meant the "random images" addon on the center of the page which is currently showing 4 random images (the box below categories) This only worked for the random images box on the left column.

This is the code I used to display "random images on main page" posted by you http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513 (http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513)
Title: Re: Random pictures
Post by: V@no on January 17, 2009, 01:35:28 AM
This is a perfect example, why we are trying encourage people reply to the appropriate topics, instead of starting new ones.

Replace
Code: [Select]
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")

with
Code: [Select]
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (1,2)

P.S.
Topics merged.
Title: Re: Random pictures
Post by: TaijovuNeji on January 19, 2009, 04:57:40 PM
Sorry to boder you.. but can you take a look in my gallery?
The link: www.dungeonmakers.com.br/galeriadm
The random imagens not appear.. why? O.o
Title: Re: Random pictures
Post by: KurtW on January 19, 2009, 05:50:05 PM
Sorry to boder you.. but can you take a look in my gallery?
The link: www.dungeonmakers.com.br/galeriadm
The random imagens not appear.. why? O.o

Hi TaijovuNeji,

do you have read the copyright notice in the footer.html  :?:

Quote
    Please note that the following copyright notice
    MUST be displayed on each and every page output
    by 4images. You may alter the font, colour etc. but
    you CANNOT remove it, nor change it so that it be,
    to all intents and purposes, invisible. The hyperlink
    http://www.4homepages.de must also remain intact.
    These conditions are part of the licence this software
    is released under. See the Licence.txt file for
    more information.


Kurt

Title: Re: Random pictures
Post by: TaijovuNeji on January 22, 2009, 03:44:21 AM
man! O.o .. I didn't read that O.O .. I will put the copyright back.. sorry for this

But anybody can help me?
Title: Re: Random pictures
Post by: yesme on February 18, 2009, 03:38:36 PM
I am so sorry if I have asked the similar question to the rest of 4images users but this thread is too long. After checked one page to one page, and tried the scripts/codes the results seems not right. Now I am getting confused with this thread whether to display random image in the left menu or the main section?

Then I decided to ask you all here,

May I know how to get multiple random images e.g 3 random images in the left menu?

I am using version 1.7.6

p.s I have tried V@no's plugin but didnt work as my imagination.

Thanks.
Title: Re: Random pictures
Post by: V@no on February 18, 2009, 04:24:18 PM
This topic is more about non-4images pages or external sites.
Title: Re: Random pictures
Post by: yesme on February 18, 2009, 04:26:53 PM
I have tried just now with these codes:

Code: [Select]
//-----------------------------------------------------
//--- Random Image ------------------------------------
//-----------------------------------------------------
$random_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image();
$random_image2 = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image();
$site_template->register_vars("random_image", $random_image);
$site_template->register_vars("random_image2", $random_image2);
unset($random_image);
unset($random_image2);

Am I right? Are these codes suppose displays random image at a one time together?
Title: Re: Random pictures
Post by: V@no on February 18, 2009, 04:30:04 PM
it will work but only if it picks two images from two different categories. 4images caches one random image for each category.
Title: Re: Random pictures
Post by: yesme on February 18, 2009, 04:58:17 PM
That's mean my random image on the left side will displays same images at one time?! Erm...that is not good.

Btw, if I am using these codes...

Code: [Select]
$cat_in = array(2,7,8,11,12,15,16,18); //list of category ids // *** TO FILTER RANDOM IMAGES ***
...in index.php would be okay? Because I just need the random images display different images at a one time...Any ideas?
Title: Re: Random pictures
Post by: Eagle Eye on November 23, 2009, 08:06:30 AM
@V@no

Is it possible to mod this code: http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513 (http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513) so that it will only randomize the images once in xx hours?
Title: Re: Random pictures
Post by: GaYan on November 23, 2009, 02:03:56 PM
is it possible to show a random image in a external web site ?  8O
Title: Re: Random pictures
Post by: Rembrandt on November 23, 2009, 02:52:34 PM
is it possible to show a random image in a external web site ?  8O

FAQ --> http://www.4homepages.de/forum/index.php?topic=1020.0

mfg Andi
Title: Re: Random pictures
Post by: Eagle Eye on November 24, 2009, 06:39:34 AM
@V@no

Is it possible to mod this code: http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513 (http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513) so that it will only randomize the images once in xx hours?


Addition: The reason i think this feature would be useful is because on large websites having lots of images and traffic, randomizing the images each time the page loads will have a huge performance degradation on database server and most shared hosting account will not be allowed to use so much server resources.
Title: Re: Random pictures
Post by: V@no on November 24, 2009, 03:07:41 PM
@V@no

Is it possible to mod this code: http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513 (http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513) so that it will only randomize the images once in xx hours?

I've added version B, with cache, in that post
Title: Re: Random pictures
Post by: Eagle Eye on November 26, 2009, 06:33:53 AM
@V@no

Is it possible to mod this code: http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513 (http://www.4homepages.de/forum/index.php?topic=4259.msg17513#msg17513) so that it will only randomize the images once in xx hours?

I've added version B, with cache, in that post

Thanks V@no. This is a great addition to this MOD.

I was looking for a different approach, is it possible to cache just the MySQL query results and not generate an individual home page for every new user.... instead just cache the query and write this results in a cache page and serve the same query results to the template engine/php for every user in that time frame.... so what i mean is there will be only one cache file for all users in that time frame....

thank you very much for looking into this.
Title: Re: Random pictures
Post by: V@no on November 26, 2009, 06:36:42 AM
Your method might conflict with user permissions. What if visitor not supposed to see the cached image?
Title: Re: Random pictures
Post by: GaYan on May 10, 2010, 06:37:49 AM
Hey Guys  8O

Can we select the Random Images from a Selected Category and show it on index page ?
Title: Re: Random pictures
Post by: kangarooms on July 31, 2013, 07:17:09 PM
Ich habe versucht es in meine details.html ein zubauen aber es wird mir nichts angezeigt  :cry:

kann mir wer helfen?
Title: Re: Random pictures
Post by: praveen on September 13, 2013, 11:34:39 AM
Is it possible to show random images from subcategories too?

I have 3 main categories with lots of sub categories.

The main categories do not have any images.  So can the random images be shown from the sub categories?
Title: Re: Random pictures
Post by: wallward on February 09, 2014, 10:12:37 AM
thank you V@no
how to exclude some categories?
for example 3 and 16

//------------------------------------
//------- Random Images --------------
//------------------------------------
$num_new_images = 8;
$cache_time = 360; //3600sek = 1hour
$cache_enable_old = $cache_enable;
$cache_enable = true;
$cache_id_rand = create_cache_id(
  'page.rand',
  array(
    $user_info[$user_table_fields['user_id']],
    isset($user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 0, 8) : 0,
    $config['template_dir'],
    $config['language_dir']
  )
);
if (!$random_images = get_cache_file($cache_id_rand, $cache_time))
{
  // Always append session id if cache is enabled
  $old_session_mode = $site_sess->mode;
  $site_sess->mode = 'get';
  $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_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_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat").")
          ORDER BY RAND()
          LIMIT $num_new_images";
  // end new
  $result = $site_db->query($sql);
  $num_rows = $site_db->get_numrows($result);
 
  if (!$num_rows)  {
    $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  //  $random_images .= $lang['no_new_images'];
    $random_images .= "</td></tr></table>";
  }
  else  {
    $random_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
    $count = 0;
    $bgcounter = 0;
    while ($image_row = $site_db->fetch_array($result)){
      if ($count == 0) {
        $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
        $random_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
      }
      $random_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
 
      show_image($image_row);
      $random_images .= $site_template->parse_template("thumbnail_bit");
      $random_images .= "\n</td>\n";
      $count++;
      if ($count == $config['image_cells']) {
        $random_images .= "</tr>\n";
        $count = 0;
      }
    } // end while
 
    if ($count > 0)  {
      $leftover = ($config['image_cells'] - $count);
      if ($leftover >= 1) {
        for ($f = 0; $f < $leftover; $f++) {
          $random_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
        }
        $random_images .= "</tr>\n";
      }
    }
    $random_images .= "</table>\n";
  } // end else
  $site_sess->mode = $old_session_mode;
  save_cache_file($cache_id_rand, $random_images);
}
$cache_enable = $cache_enable_old;
$site_template->register_vars(array(
"random_images" => $random_images,
"lang_random_images" => $lang['random_images']
));
unset($random_images);

//----- End Random Images---------
//------------ End random Image on home page with cache contorol---------
Title: Re: Random pictures
Post by: Loda on February 09, 2014, 01:54:43 PM
try this in the code:
.....
 WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (3,16) AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat").")
Title: Re: Random pictures
Post by: Geezer on May 11, 2015, 07:42:24 PM
Hallo

gibts solch eine Modifikation auch mit Tageszeit aus nur einer bestimmten Kategorie, zum Beispiel: 6-12 Uhr, 12-18 Uhr, 18-22 Uhr 22-6 Uhr und mit Wochenzeit aus nur einer bestimmten Kategorie (Montag, Dienstag, Mittwoch...... usw.
Title: Re: Random pictures
Post by: bigwave on March 07, 2021, 10:24:47 PM
Hi,

I can't seem to get his on version 1.8, sigh.

I've tried the original from Mr. V@no and the update to 1.4 in reply 43.

The good news is that nothing broke when I published the changes.

I had this working in the non updated version of the website.  I do have Mr. V@ano's brilliant sitemap mod working so I'm disappointed that this mod is unhappy in 1.8.

What I'm trying to achieve is a bunch of random images in a column in a sidebar (which I had before) or anywhere.

Any suggestions will be appreciated.

Thanx,

Brian