• [Mod] Random image / Zufallsbild 5 0 5 1
Currently:  

Author Topic: [Mod] Random image / Zufallsbild  (Read 868981 times)

0 Members and 3 Guests are viewing this topic.

Offline maikew

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • MW PhotoWorks & Templates
Re: [Mod] Random image / Zufallsbild
« Reply #210 on: June 26, 2005, 04:55:36 PM »
Hello,

It works perfectly, but i want to show more than 1 random picture.
I would like to show 4 or 5 different random pictures next to each other

Can anybody help me??
Thanx a lot

this is my random_morepics.php .mod created by nicky

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

// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH''../4images/');

include(
ROOT_PATH.'config.php');
include(
ROOT_PATH.'includes/db_mysql.php');
include(
ROOT_PATH.'includes/constants.php');

$site_db = new Db($db_host$db_user$db_password$db_name);
function 
is_remote($file_name) {
  return (
preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i'$file_name)) ? 0;
}

// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images 4;

$sql "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments 
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b 
        WHERE a.image_active=1 
        AND a.cat_id = b.cat_id 
        AND b.auth_viewcat="
.AUTH_ALL.
        AND b.auth_viewimage="
.AUTH_ALL.
        ORDER BY RAND() 
        LIMIT 
$num_images";
$result $site_db->query($sql);

while (
$row $site_db->fetch_array($result)){
  
$image_id $row['image_id'];
  
$cat_id $row['cat_id'];
  
$image_name $row['image_name'];
  
$image_comments $row['image_comments'];
  
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

  echo 
"<a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";
  echo 
"<b>$image_name</b><br>\n";
  echo 
"Comments: $image_comments<hr>\n";
}
?>

Offline Loet

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #211 on: July 17, 2005, 09:55:07 PM »
Thank you for the Code.

I display 4random  images and want to show this images in horizontal form. Now I have it in vertical direction.

What must i do?

 :?: Anyone with the solution to show them horizontal (in a table) instead of vertical?
Looked in the code of 4images to figure out how it creates e.g. the thumbnails in a table but did not get me anywhere. :(



Loet van Oostende

Offline fotograf74

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #212 on: July 19, 2005, 06:30:04 PM »
I have another question. I write it here, because I didn´t find any similiar topic.

I want to integrate the pictures from the "Categories" in another Website with a other domain.


How can I realize this?

Offline fiskedagboken

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Megapixeln
Re: [Mod] Random image / Zufallsbild
« Reply #213 on: July 20, 2005, 02:21:48 PM »
Thank you for the Code.

I display 4random  images and want to show this images in horizontal form. Now I have it in vertical direction.

What must i do?

 :?: Anyone with the solution to show them horizontal (in a table) instead of vertical?
Looked in the code of 4images to figure out how it creates e.g. the thumbnails in a table but did not get me anywhere. :(





I don´t know wich random.php u are using, but the originial has an echo command with a <br> tag  in the end. I have´nt test this mod yet, but it might work if u remove that tag.

(  echo "<a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";    )


ALWAYS backup your file first, I might be totaly wrong.

Offline Loet

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #214 on: July 21, 2005, 12:38:18 AM »
Thanks,

A simple solution, did not see it myself.
It does not create a table but I think I can do something with it...

Loet
Loet van Oostende

Offline mister pink

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #215 on: July 23, 2005, 03:14:43 PM »
hello

i'm sorry if this question has allready been posted (and answer .. ) but after many reshearch i don't find it (or if it will be answered in german .. i don't understand it .. orry)

I would like mke change to get a random image from the entire site enven if i'm in categorie and sub categorie
Cause i'm making a photo gallery with 2 others people .. and i would alow thier pic being display in the random box even if user is surfing in my cat

thx for all (and sorry for my crappy english)

*solve .. by changing 2 lines un categorie.html .. sorry  :mrgreen:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] Random image / Zufallsbild
« Reply #216 on: July 23, 2005, 07:37:20 PM »
this question has nothing to do with the mod (if I understood you correctly). All u need to do is replace any {random_cat_image} tags in the templates with {random_image}
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline IceS

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #217 on: July 24, 2005, 10:50:27 PM »
Wenn ich die Rendem.php aufrufe bekomme ich nur eine Fehlermeldung:

Fatal error: Cannot instantiate non-existent class: db in /usr/export/www/hosting/ices/random.php on line 34

Bitte helft mir

Offline GreekGoddess

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #218 on: August 04, 2005, 07:19:05 AM »
Ok I am browsing through this thread for hours and I a meither blind or too tired so forgive me.

my random.php is located in http://www.irishbreen.com/

my gallery in http://www.irishbreen.com/photos/

My random.php code is this

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

// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH''./photos/');

include(
ROOT_PATH.'config.php');
include(
ROOT_PATH.'includes/db_mysql.php');
include(
ROOT_PATH.'includes/constants.php');
define('SCRIPT_URL''http://www.irishbreen.com/photos/');
$site_db = new Db($db_host$db_user$db_password$db_name);
function 
is_remote($file_name) {
  return (
preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i'$file_name)) ? 0;
}

$sql "SELECT COUNT(*) as total_images
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b 
        WHERE a.image_active=1 
        AND a.cat_id = b.cat_id 
        AND b.auth_viewcat="
.AUTH_ALL.
        AND b.auth_viewimage="
.AUTH_ALL."
        "
;
$row $site_db->query_firstrow($sql);
$total_images $row['total_images'];

mt_srand((double)microtime() * 1000000);
$number = ($total_images 1) ? mt_rand(0$total_images 1) : 0;

$sql "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments 
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b 
        WHERE a.image_active=1 
        AND a.cat_id = b.cat_id 
        AND b.auth_viewcat="
.AUTH_ALL.
        AND b.auth_viewimage="
.AUTH_ALL.
        LIMIT 
$number, 1";
$row $site_db->query_firstrow($sql);
$image_id $row['image_id'];
$cat_id $row['cat_id'];
$image_name $row['image_name'];
$image_comments $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : SCRIPT_URL.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

echo 
"<a href=\"".SCRIPT_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";
echo 
"<b>$image_name</b><br>\n";
echo 
"Comments: $image_comments<br>\n";
?>



but when I click on random.php it shows red X's and the source code I get is
Code: [Select]
<a href="http://www.irishbreen.com/photos/details.php?image_id="><img src="http://www.irishbreen.com/photos/data/thumbnails//" border="0" alt=""></a><br>
<b></b><br>
Comments: <br>

it seems that it cant find the image_id for some reason. Any ideas ?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] Random image / Zufallsbild
« Reply #219 on: August 04, 2005, 08:05:11 AM »
that's because u cant see any images if u are not logged in (visiting as a guest)
you'll need either remove completly two instances of these two lines:
Code: [Select]
        AND b.auth_viewcat=".AUTH_ALL."
        AND b.auth_viewimage=".AUTH_ALL."
or replace them with:
Code: [Select]
        AND b.auth_viewcat<".AUTH_ADMIN."
        AND b.auth_viewimage<".AUTH_ADMIN."
The first variant will not check any permissions of the categories and second will not show images from categories where only admin is allowed to see.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline GreekGoddess

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #220 on: August 04, 2005, 08:56:43 AM »
thanks V@no that worked liek a charm!!!

Offline Honey

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • http://avatar-world.nm.ru
Re: [Mod] Random image / Zufallsbild
« Reply #221 on: August 05, 2005, 11:54:06 PM »
How I can make it work? I have this thing on my index page -

Code: [Select]
Warning: main(http://gilmore-girls.frihost.net/www/gallery/http://gilmore-girls.frihost.net/www/gallery/config.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/aalia/public_html/random.php on line 30

Warning: main(): Failed opening 'http://gilmore-girls.frihost.net/www/gallery/http://gilmore-girls.frihost.net/www/gallery/config.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/aalia/public_html/random.php on line 30

Warning: main(http://gilmore-girls.frihost.net/www/gallery/http://gilmore-girls.frihost.net/www/gallery/includes/db_mysql.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/aalia/public_html/random.php on line 31

Warning: main(): Failed opening 'http://gilmore-girls.frihost.net/www/gallery/http://gilmore-girls.frihost.net/www/gallery/includes/db_mysql.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/aalia/public_html/random.php on line 31

Warning: main(http://gilmore-girls.frihost.net/www/gallery/http://gilmore-girls.frihost.net/www/gallery/includes/constants.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/aalia/public_html/random.php on line 32

Warning: main(): Failed opening 'http://gilmore-girls.frihost.net/www/gallery/http://gilmore-girls.frihost.net/www/gallery/includes/constants.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/aalia/public_html/random.php on line 32

Fatal error: Cannot instantiate non-existent class: db in /home/aalia/public_html/random.php on line 34

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] Random image / Zufallsbild
« Reply #222 on: August 06, 2005, 04:11:34 AM »
the root path u specifyed doesnt look as a correct path:
Quote
http://gilmore-girls.frihost.net/www/gallery/http://gilmore-girls.frihost.net/www/gallery/
its not internet path, its RELATIVE (./ and/or ../) type of path
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Colourconcept

  • Pre-Newbie
  • Posts: 1
    • View Profile
    • Colourconcept
Re: [Mod] Random image / Zufallsbild
« Reply #223 on: August 10, 2005, 08:08:49 AM »
Moin,
dann will ich mich auch mal in diesen Mega-Thread reinhängen, der verdammt schwer zu verfolgen ist...  :roll:

Vorab vielen Dank an Nicky für die Mod-Datei. Ist genaus das, was ich gesucht habe. Leider bekomme ich das Teil aber nicht so recht zum laufen.

Die random.php liegt auf meiner HP im Hauptverzeichnis. Wenn ich sie direkt über die URL aufrufe, bekomme ich das Zufallsbild auch angezeigt.
Die 4images-Galerie liegt in einem Ordner im Hauptverzeichnis meiner HP. Der Pfad in der random.php ist daher wie folgt definiert:

Quote
// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH', './4images/');

include(ROOT_PATH.'config.php');
include(ROOT_PATH.'includes/db_mysql.php');
include(ROOT_PATH.'includes/constants.php');
define('SCRIPT_URL', 'http://www.Colourconcept.net/4images/');

Die zweite Pfadbeschreibung die hier im Thread auftaucht, habe ich also auch schon integriert. Auf meiner Postnuke-Seite möchte ich das Zufallsbild in einem Block am rechten Seitenrand anzeigen. Ich habe daher dort einen php-Block generiert und die random.php mit dem folgenden Befehl eingebunden:

Quote
include("random.php");

Leider führt das aber nicht zum gewünschten Ergebnis. Es wird nichts angezeigt :( Ändere ich etwas in der random.php oder im include-Befehl, bekomme ich allerdings sofort Fehlermeldungen. Hat jemand 'ne Idee, wo mein Problem liegt?

Besten Dank vorab
Gruß
Ulli

Offline Buzzdee

  • Pre-Newbie
  • Posts: 1
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #224 on: August 12, 2005, 04:04:50 PM »
Hallo,

also, ich würde das random_mod auch gerne nutzen, habe dabei folgende Probleme:

Einbindung mit include in sidebar.php (www.one-brain-cellers.de/wordpress/wp-content/themes/rin/sidebar.php)  :
Warning: main() [function.main]: open_basedir restriction in effect. File(/usr/lib/php/random.php) is not within the allowed path(s): (/home/www/htdocs/one-brain-cellers.de/.) in /home/www/htdocs/one-brain-cellers.de/wordpress/wp-content/themes/rin/sidebar.php on line 32

Warning: main(random.php) [function.main]: failed to create stream: Operation not permitted in /home/www/htdocs/one-brain-cellers.de/wordpress/wp-content/themes/rin/sidebar.php on line 32

Warning: main() [function.main]: Failed opening 'random.php' for inclusion (include_path='.:/usr/lib/php') in /home/www/htdocs/one-brain-cellers.de/wordpress/wp-content/themes/rin/sidebar.php on line 32

Einbindung mit iFrame:
Security violationSecurity violation
Fatal error: Cannot instantiate non-existent class:db in /home/www/htdocs/one-brain-cellers.de/wordpress/wp-content/themes/rin/random.php on line 35


random.php :
Code: [Select]
define('ROOT_PATH', 'http://www.one-brain-cellers.de/4images/');
include(ROOT_PATH.'config.php');
include(ROOT_PATH.'includes/db_mysql.php');
include(ROOT_PATH.'includes/constants.php');
define('SCRIPT_URL', 'http://www.one-brain-cellers.de/4images/');
.
.
.
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : SCRIPT_URL.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
echo "<a href=\"".SCRIPT_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";?>

random.php liegt auf www.one-brain-cellers.de/wordpress/wp-content/themes/rin/
4images auf www.one-brain-cellers.de/4images

Das mit dem include-Befehl scheint ein Problem mit meinem Webspace zu sein, das funktioniert generell nicht. Auch die hier vorgestellte Java Variante funktioniert nicht (passiert garnichts).

Kann mir jemand bitte helfen?

Liebe Grüße
Buzzdee