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

Author Topic: [Mod] Random image / Zufallsbild  (Read 869220 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 #225 on: August 21, 2005, 03:38:13 PM »
hallo buzzdee

deine random.php liegt im falschen ordner.sie muss in den hauptordner des blogs kopiert werden ;) nicht in
den theme ordner.
und dieser abschnitt in der random php muss dann wie folgt lauten
define('ROOT_PATH', '../4images/');

hier kannst du es dir ansehen http://maikew.ma.funpic.de/blog/  :wink:

Offline okasa

  • Pre-Newbie
  • Posts: 1
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #226 on: August 26, 2005, 04:14:17 AM »
Quote
:?: 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 use this code to keep them horizonal

  echo "<table border='0' width='133' bgcolor='#FFFFFF' Align=left>\n";
  echo "<TR>\n";
  echo "<TD><a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a></TD>\n";
  echo "</TR>\n";
  echo "<TR>\n";
  echo "<TD bgcolor='#FFFFFF'><b>$image_name</b></TD>\n";
  echo "</TR>\n";
  echo "<TR>\n";
  echo "<TD bgcolor='#FFFFFF'>Comments: $image_comments</TD>\n";
  echo "</TR>\n";
  echo "</table>\n";
Hi I am Taiwanese. My page: http://www.dragonscout.org
(Sorry this page write in Chinese)

Offline rosablasiclub

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #227 on: September 13, 2005, 06:02:33 PM »
It works fine for me - BUT it shows only one "random" pic, always the same  :( After Reloading etc, every time the same pic  :(

I have this problem too, does anyone know why that would be? My code is on here: http://www.dhost.info/rosablasiclub/home.php (it's a test page for a new version right now)

Offline rosablasiclub

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #228 on: September 14, 2005, 10:54:19 PM »
Could someone pleeeease help me with this? I'm done with the rest of the site and I am just waiting for this to be fixed so I can put all of it online.. my random.php code is as follows:

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''../rosablasiclub/archive/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;
}

$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'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

echo 
"<a href=\"".ROOT_PATH."details.php?image_id=$image_id\" target=\"_blank\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"random picture\"></a><br>\n";
?>


Offline D3RB

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #229 on: September 15, 2005, 04:51:01 PM »
hi,
ich bin auch ein großer fan der gallery hochachtung an die macher.

so jetzt zum eigentlichen problem:

ich habe meine hp mit dem clan manager pro gemacht und dort gefällt mir das mit dem potm nicht, weil man dort jedes einzelne bild zuweisen muss was in der box angezeigt werden soll, nun hab ich mir die random.php runtergeladen soweit auch alles umeditiert, sie funzt auch soweit aber wenn ich sie einbinden will dann verzieht mein ganzes style, weiß einer dazu rat? hab mit ifram sowie include gearbeitet

hier meine random.php

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''./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;
}

$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'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

echo 
"<a href=\"".ROOT_PATH."details.php?image_id=$image_id\" target=\"_new\"><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";
?>


aso bevor ich es vergesse das design wird in 2 php dateien gesplittet aus der html

die sich footer und header nennen

hoffe mir kann einer helfen


hier der link

www.ph-multigaming.de.vu

nich wundern ich nutz im moment wieder das potm von dem script

Offline D3RB

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #230 on: September 15, 2005, 11:38:03 PM »
so habs von allein hinbekommen aber andere frage kann man den namen und diesen comments bereich rausnehmen und den hintergrund transparent machen???

Offline rosablasiclub

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #231 on: September 18, 2005, 09:54:03 PM »
Hey um.. not to seem incredibly impatient or anything.. but is anyone ever going to help me?! If you don't know the answer please at least tell me that so I won't be waiting for nothing..

Offline D3RB

  • Pre-Newbie
  • Posts: 3
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #232 on: September 18, 2005, 11:48:35 PM »
sry das ich nochmal nerve :P

wenn es schon nicht transparent geht, würde es dann gehen das ich das hintergundbild dann in der php datei mit eintrage?

das komische ist ja das bei firefox das hintergrundbild angezeigt wird bei dem potm.


hoffe mir kann jetzt einer helfen

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #233 on: October 02, 2005, 12:48:34 PM »
Hi

can this MOD cover my requirements mentioned in the following post?

http://www.4homepages.de/forum/index.php?topic=9774.msg47864#msg47864

Thanks!

Offline marc991

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #234 on: October 26, 2005, 11:58:04 AM »
hi an alle, hi all,

D: hier ist der Zufallsbild MOD für extra seiten ausserhalb ihrer Gallerie:
E: here the Random image MOD for extra sites outside your Gallery:

http://www.nicky.net/4images/random.txt

D: speichere den inhalt als random.php
E: save the content as random.php

D: random.php wurde mit folgenden befehl in die random_mod.php inkludiert
E: random.php was included into the random_mod.php site

D: mit
E: with
Code: [Select]
<?php
 
include("./random.php");
?>


D: viel spass
E: have fun

p.s.:
D: vielen dank an JAN der 99% der arbeit geleistet hat ;)
E: many thanks to JAN who maked 99% of this mod ;)


Hallo, habe gerade nach einer Möglichkeit gesucht ein Zufallsbild in meine Seite einzubauen. Habe als Random.php gespeichert und Hochgeladen aber irgendwie weiß ich nicht wo ich die random_mod.php hernehmen soll und wie ich die sachen dann auf meiner Page auf der Linken Seite einfüge. Bin ein neuling in sachen php aber hoffe das mir jemand weiterhelfen kann. Des weiteren möchte ich die Galerie per iframe einbinden. Das klappt auch aber ich muß dann scrollen nachdem ich ein Bild angeklickt habe. Wie mache ich dieses bündig? Danke für eure Hilfe im vorraus. Marc

Offline terk

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #235 on: October 26, 2005, 09:16:00 PM »
Hi!

I've looked through all this topic, but didn't manage to fix my issue. It's all in this:

Quote
Security violationSecurity violation
Fatal error: Cannot instantiate non-existent class: db in /home/166413/http/foto/random.php on line 34

this is my code in random.php:

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''http://www.ipoding.ru/foto/');

include(
'http://www.ipoding.ru/foto/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";
}
?>


Password and user name of the db are typed in correctly....

I have no idea what to fix. Please help me!

My 4images: http://www.ipoding.ru/foto/index.php   ----- don't get shocked, it's all in Russian

Offline Maweryk

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #236 on: October 26, 2005, 09:22:49 PM »
Try this:

Code: [Select]
// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH', '/usr/local/httpd/htdocs/.../foto/');

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

Good luck!

Markus

Offline terk

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #237 on: October 26, 2005, 10:57:03 PM »
Try this:

Code: [Select]
// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH', '/usr/local/httpd/htdocs/.../foto/');

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

Good luck!

Markus


Now i get this:

Quote
Warning: main(): open_basedir restriction in effect. File(/usr/local/httpd/htdocs/.../foto/config.php) is not within the allowed path(s): (/home/166413) in /home/166413/http/foto/random.php on line 30

Warning: main(/usr/local/httpd/htdocs/.../foto/config.php): failed to open stream: Not owner in /home/166413/http/foto/random.php on line 30

Warning: main(): open_basedir restriction in effect. File(/usr/local/httpd/htdocs/.../foto/config.php) is not within the allowed path(s): (/home/166413) in /home/166413/http/foto/random.php on line 30

Warning: main(/usr/local/httpd/htdocs/.../foto/config.php): failed to open stream: Not owner in /home/166413/http/foto/random.php on line 30

Warning: main(): Failed opening '/usr/local/httpd/htdocs/.../foto/config.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/166413/http/foto/random.php on line 30

Warning: main(): open_basedir restriction in effect. File(/usr/local/httpd/htdocs/.../foto/includes/db_mysql.php) is not within the allowed path(s): (/home/166413) in /home/166413/http/foto/random.php on line 31

Warning: main(/usr/local/httpd/htdocs/.../foto/includes/db_mysql.php): failed to open stream: Not owner in /home/166413/http/foto/random.php on line 31

Warning: main(): open_basedir restriction in effect. File(/usr/local/httpd/htdocs/.../foto/includes/db_mysql.php) is not within the allowed path(s): (/home/166413) in /home/166413/http/foto/random.php on line 31

Warning: main(/usr/local/httpd/htdocs/.../foto/includes/db_mysql.php): failed to open stream: Not owner in /home/166413/http/foto/random.php on line 31

Warning: main(): Failed opening '/usr/local/httpd/htdocs/.../foto/includes/db_mysql.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/166413/http/foto/random.php on line 31

Warning: main(): open_basedir restriction in effect. File(/usr/local/httpd/htdocs/.../foto/includes/constants.php) is not within the allowed path(s): (/home/166413) in /home/166413/http/foto/random.php on line 32

Warning: main(/usr/local/httpd/htdocs/.../foto/includes/constants.php): failed to open stream: Not owner in /home/166413/http/foto/random.php on line 32

Warning: main(): open_basedir restriction in effect. File(/usr/local/httpd/htdocs/.../foto/includes/constants.php) is not within the allowed path(s): (/home/166413) in /home/166413/http/foto/random.php on line 32

Warning: main(/usr/local/httpd/htdocs/.../foto/includes/constants.php): failed to open stream: Not owner in /home/166413/http/foto/random.php on line 32

Warning: main(): Failed opening '/usr/local/httpd/htdocs/.../foto/includes/constants.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/166413/http/foto/random.php on line 32

Fatal error: Cannot instantiate non-existent class: db in /home/166413/http/foto/random.php on line 34

even if I remove ' :
Code: [Select]
define(ROOT_PATH, '/usr/local/httpd/htdocs/.../foto/');
still same  :(


if I change  it to
Code: [Select]
define(ROOT_PATH.'/usr/local/httpd/htdocs/.../foto/');
I get:
Quote
Warning: Wrong parameter count for define() in /home/166413/http/foto/random.php on line 28

Warning: main(ROOT_PATHconfig.php): failed to open stream: No such file or directory in /home/166413/http/foto/random.php on line 30

Warning: main(ROOT_PATHconfig.php): failed to open stream: No such file or directory in /home/166413/http/foto/random.php on line 30

Warning: main(): Failed opening 'ROOT_PATHconfig.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/166413/http/foto/random.php on line 30

Warning: main(ROOT_PATHincludes/db_mysql.php): failed to open stream: No such file or directory in /home/166413/http/foto/random.php on line 31

Warning: main(ROOT_PATHincludes/db_mysql.php): failed to open stream: No such file or directory in /home/166413/http/foto/random.php on line 31

Warning: main(): Failed opening 'ROOT_PATHincludes/db_mysql.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/166413/http/foto/random.php on line 31

Warning: main(ROOT_PATHincludes/constants.php): failed to open stream: No such file or directory in /home/166413/http/foto/random.php on line 32

Warning: main(ROOT_PATHincludes/constants.php): failed to open stream: No such file or directory in /home/166413/http/foto/random.php on line 32

Warning: main(): Failed opening 'ROOT_PATHincludes/constants.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/166413/http/foto/random.php on line 32

Fatal error: Cannot instantiate non-existent class: db in /home/166413/http/foto/random.php on line 34


 :( :( :(

Offline Maweryk

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #238 on: October 26, 2005, 11:11:47 PM »
Sorry, the ... stand for the Rest of your Home-Path

i.e. /usr/local/httpd/htdocs/.../Foto/ or /home/166413/http/foto ;)

Cheers,

Markus

My random_more.php without comments and image name:

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''/usr/local/httpd/htdocs/.../4images/');
define('YOUR_URL''http://www.4imagesurl.de/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 5;

$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);

echo 
'<table><tr>'
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'] : YOUR_URL.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file']; 

echo 
'<td>'
echo 
"&nbsp;<a target=\"_top\" href=\"".YOUR_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a>\n"
echo 
'</td>'

echo 
'</tr></table>'


?>


Offline terk

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #239 on: October 27, 2005, 05:49:56 AM »
Thx. I returned to the first error I recieved.

Quote
Security violationSecurity violation
Fatal error: Cannot instantiate non-existent class: db in /home/166413/http/foto/random.php on line 34

As I think, line 34 requires new Db class:
Code: [Select]
$site_db = new Db($db_host, $db_user, $db_password, $db_name);
So the problem migth be in /includes/db_mysql.php ?
Here is my code:
Code: [Select]
?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: db_mysql.php                                         *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.1                                                *
 *                                                                        *
 *    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.                              *
 *                                                                        *
 *************************************************************************/
if (!defined('ROOT_PATH')) {
  die("Security violation");
}

class Db {
  var $no_error = 0;
  var $connection;
  var $query_id = 0;
  var $query_count = 0;
  var $query_time = 0;
  var $query_array = array();
  var $table_fields = array();

  function Db($db_host, $db_user, $db_password = "", $db_name = "", $db_pconnect = 0) {
    $connect_handle = ($db_pconnect) ? "mysql_pconnect" : "mysql_connect";
    if (!$this->connection = $connect_handle($db_host, $db_user, $db_password)) {
      $this->error("Could not connect to the database server ($db_host, $db_user).", 1);
    }
    if ($db_name != "") {
      if (!@mysql_select_db($db_name)) {
        @mysql_close($this->connection);
        $this->error("Could not select database ($db_name).", 1);
      }
    }
    return $this->connection;
  }

  function close() {
    if ($this->connection) {
      if ($this->query_id) {
        @mysql_free_result($this->query_id);
      }
      return @mysql_close($this->connection);
    }
    else {
      return false;
    }
  }

  function query($query = "") {
    unset($this->query_id);
    if ($query != "") {
      if ((defined("PRINT_QUERIES") && PRINT_QUERIES == 1) || (defined("PRINT_STATS") && PRINT_STATS == 1)) {
        $startsqltime = explode(" ", microtime());
      }
      if (!$this->query_id = @mysql_query($query, $this->connection)) {
        $this->error("<b>Bad SQL Query</b>: ".htmlentities($query)."<br /><b>".mysql_error()."</b>");
      }
      if ((defined("PRINT_QUERIES") && PRINT_QUERIES == 1) || (defined("PRINT_STATS") && PRINT_STATS == 1)) {
        $endsqltime = explode(" ", microtime());
        $totalsqltime = round($endsqltime[0]-$startsqltime[0]+$endsqltime[1]-$startsqltime[1],3);
        $this->query_time += $totalsqltime;
        $this->query_count++;
      }
      if (defined("PRINT_QUERIES") && PRINT_QUERIES == 1) {
        $query_stats = htmlentities($query);
        $query_stats .= "<br><b>Querytime:</b> ".$totalsqltime;
        $this->query_array[] = $query_stats;
      }
      return $this->query_id;
    }
  }

  function fetch_array($query_id = -1, $assoc = 0) {
    if ($query_id != -1) {
      $this->query_id = $query_id;
    }
    if ($this->query_id) {
      return ($assoc) ? mysql_fetch_assoc($this->query_id) : mysql_fetch_array($this->query_id);
    }
  }

  function free_result($query_id = -1) {
    if ($query_id != -1) {
      $this->query_id = $query_id;
    }
    return @mysql_free_result($this->query_id);
  }

  function query_firstrow($query = "") {
    if ($query != "") {
      $this->query($query);
    }
    $result = $this->fetch_array($this->query_id);
    $this->free_result();
    return $result;
  }

  function get_numrows($query_id = -1) {
    if ($query_id != -1) {
      $this->query_id = $query_id;
    }
    return mysql_num_rows($this->query_id);
  }

  function get_insert_id() {
    return ($this->connection) ? @mysql_insert_id($this->connection) : 0;
  }
 
  function get_next_id($column = "", $table = "") {
    if (!empty($column) && !empty($table)) {
      $sql = "SELECT MAX($column) AS max_id
              FROM $table";
      $row = $this->query_firstrow($sql);
      return (($row['max_id'] + 1) > 0) ? $row['max_id'] + 1 : 1;
    }
    else {
      return NULL;
    }
  }

  function get_numfields($query_id = -1) {
    if ($query_id != -1) {
      $this->query_id = $query_id;
    }
    return @mysql_num_fields($this->query_id);
  }

  function get_fieldname($query_id = -1, $offset) {
    if ($query_id != -1) {
      $this->query_id = $query_id;
    }
    return @mysql_field_name($this->query_id, $offset);
  }

  function get_fieldtype($query_id = -1, $offset) {
    if ($query_id != -1) {
      $this->query_id = $query_id;
    }
    return @mysql_field_type($this->query_id, $offset);
  }

  function affected_rows() {
    return ($this->connection) ? @mysql_affected_rows($this->connection) : 0;
  }

  function is_empty($query = "") {
    if ($query != "") {
      $this->query($query);
    }
    return (!mysql_num_rows($this->query_id)) ? 1 : 0;
  }

  function not_empty($query = "") {
    if ($query != "") {
      $this->query($query);
    }
    return (!mysql_num_rows($this->query_id)) ? 0 : 1;
  }
 
  function get_table_fields($table) {
    if (!empty($this->table_fields[$table])) {
      return $this->table_fields[$table];
    }
    $this->table_fields[$table] = array();
    $result = $this->query("SHOW FIELDS FROM $table");
    while ($row = $this->fetch_array($result)) {
      $this->table_fields[$table][$row['Field']] = $row['Type'];
    }
    return $this->table_fields[$table];
  }

  function error($errmsg, $halt = 0) {
    if (!$this->no_error) {
      echo "<br /><font color='#FF0000'><b>DB Error</b></font>: ".$errmsg."<br />";
      if ($halt) {
        exit;
      }
    }
  }
} // end of class
?>

Maweryk, maybe you can post yours db_mysql.php?