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

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

0 Members and 2 Guests are viewing this topic.

Offline manica

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #165 on: February 16, 2003, 08:50:53 PM »
Habe das mal eingebunden aber kriege da nur folgenden Fehler.


DB Error: Bad SQL Query: SELECT COUNT(*) as total_images FROM 4images_images a, hexboardcategories b WHERE a.image_active=1 AND a.cat_id = b.cat_id AND b.auth_viewcat=0 AND b.auth_viewimage=0
Unknown column 'b.auth_viewcat' in 'where clause'

DB Error: Bad SQL Query: SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments FROM 4images_images a, hexboardcategories b WHERE a.image_active=1 AND a.cat_id = b.cat_id AND b.auth_viewcat=0 AND b.auth_viewimage=0 LIMIT 0, 1
Unknown column 'b.auth_viewcat' in 'where clause'


Wobei hexbioardcategorie eun Table vom phpbb ist und nicht von 4images.

Offline Clow Read

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • http://vectorcandy.com
Re: [Mod] Random image / Zufallsbild
« Reply #166 on: February 24, 2003, 01:40:54 AM »
could someone help me modify this mod to view only new images from a certain category using V@no's code...

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/'); // change this to your 4images dir. 
include(ROOT_PATH.'config.php'); 
include(
ROOT_PATH.'includes/db_mysql.php'); 
include(
ROOT_PATH.'includes/constants.php'); 
define('ICON_PATH'ROOT_PATH.TEMPLATE_DIR."/default/icons/"); // path to your template icons. 
$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

function 
get_file_extension($file_name) { 
 
ereg("(.+)\.(.+)"basename($file_name), $regs); 
 return 
strtolower($regs[2]); 

function 
check_thumb_type($file_name) { 
 return (
preg_match('#(gif|jpg|jpeg|png)$#is'$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_media_file, 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_extention get_file_extension($row['image_media_file']); 
$image_id $row['image_id']; 
$cat_id $row['cat_id']; 
$image_name $row['image_name']; 
$image_comments $row['image_comments']; 

if (empty(
$row['image_thumb_file'])) { 
 
$thumb_src ICON_PATH."/".$image_extention.".gif"

else { 
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file']; 

if (!
check_thumb_type($image_extention)) { 
 
 $full_src ICON_PATH."/".$image_extention.".gif"

else { 
 
 $full_src = (is_remote($row['image_media_file'])) ? $row['image_media_file'] : ROOT_PATH.MEDIA_DIR."/".$cat_id."/".$row['image_media_file']; 

$full_src_link ROOT_PATH."details.php?image_id=$image_id"
?>

thnx ^_~
« Last Edit: March 28, 2006, 03:41:47 PM by V@no »

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 #167 on: February 24, 2003, 02:20:24 AM »
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) fur    *
*  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/'); // change this to your 4images dir.
include(ROOT_PATH.'global.php');
$new_cutoff time() - 60 60 24 $config['new_cutoff'];
$sql "SELECT IF(a.image_date >= $new_cutoff,RAND()+1,1) as random_no, a.image_id, a.cat_id, a.image_name, a.image_active, a.image_media_file, a.image_thumb_file, a.image_comments, a.user_id
        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 random_no DESC, RAND()
        LIMIT 1"
;
$row $site_db->query_firstrow($sql);
$image_extention get_file_extension($row['image_media_file']);
$image_id $row['image_id'];
$cat_id $row['cat_id'];
$image_name $row['image_name'];
$image_comments $row['image_comments'];

if (empty(
$row['image_thumb_file'])) {
$thumb_src ICON_PATH."/".$image_extention.".gif";
}
else {
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
}
if (!
check_thumb_type($image_extention)) {
 
 $full_src ICON_PATH."/".$image_extention.".gif";
}
else {
 
 $full_src = (is_remote($row['image_media_file'])) ? $row['image_media_file'] : ROOT_PATH.MEDIA_DIR."/".$cat_id."/".$row['image_media_file'];
}
$full_src_link ROOT_PATH."details.php?image_id=$image_id";
?>

it will chose an image from new images, but if there is no new images, it will chose random from whole gallery.
« Last Edit: March 28, 2006, 03:41:37 PM by V@no »
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 Chris72

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #168 on: February 27, 2003, 02:37:12 AM »
Erst einmal Kompliment für das tolle Script, das im grossen und ganzen auch toll läuft. Allerdings habe ich ein Problem, was zwar nicht am Script liegt, aber vielleicht fällt jemanden eine Lösung ein:

Ich würde gerne das Zufallsbild gerne in mein Guestbook (MySQL/PHP) integrieren, allerdings lassen die Templates keinen PHP-Code zu :cry: Gibt es vielleicht einen Trick wie man trotzdem das Zufallsbild integrieren könnte? Bisher habe ich leider noch keine Lösung gefunden....

Offline fabulous

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • http://www.foto-fish.de
Re: [Mod] Random image / Zufallsbild
« Reply #169 on: February 27, 2003, 08:27:55 PM »
hi.

the script v@no posted was exactly was i was trying to find in this board here. i would like to get a random foto, but not out of the whole gallery but only the new ones. so i thought v@nos code was right but when i uploaded that php page and started it in my browser, the only source code it created was:
Code: [Select]
<html><body></body></html>
i changed the 4images path to the same i used in the original random php script.
still the same error.
see it here on this page:
http://www.odd-fish.de/randomnew.php

original random script:
http://www.odd-fish.de/random.php

anyone an idea ?

cheers, fab

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 #170 on: February 28, 2003, 12:02:39 AM »
Quote from: fabulous
hi.

the script v@no posted was exactly was i was trying to find in this board here. i would like to get a random foto, but not out of the whole gallery but only the new ones. so i thought v@nos code was right but when i uploaded that php page and started it in my browser, the only source code it created was:
Code: [Select]
<html><body></body></html>
i changed the 4images path to the same i used in the original random php script.
still the same error.
see it here on this page:
http://www.odd-fish.de/randomnew.php

original random script:
http://www.odd-fish.de/random.php

anyone an idea ?

cheers, fab


my code works different way then original.
read here how to use it:
http://4homepages.de/forum/viewtopic.php?p=12102#12102

P.S. u can not use it from .html page, only from .php
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 ruck

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • http://tttb.net/
Re: [Mod] Random image / Zufallsbild
« Reply #171 on: February 28, 2003, 08:23:55 AM »
I've tried this mod and it works fine except when there isn't a thumbnail it doesn't seem to display anything at all, not even the default image. Anyway to get it to do that?

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 #172 on: February 28, 2003, 09:42:30 AM »
Quote from: ruck
I've tried this mod and it works fine except when there isn't a thumbnail it doesn't seem to display anything at all, not even the default image. Anyway to get it to do that?

if you would read through the whole posts in this thread, u'd found your answer.  :roll:
btw, I posted in my previous replay the link to it  :roll:
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 fabulous

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • http://www.foto-fish.de
Re: [Mod] Random image / Zufallsbild
« Reply #173 on: February 28, 2003, 09:44:37 AM »
works perfect now, thx a lot V@no !!!   :D  :D

Offline ruck

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • http://tttb.net/
Re: [Mod] Random image / Zufallsbild
« Reply #174 on: March 08, 2003, 11:57:11 PM »
Okay, sorry V@no. I got it working now and it displays the default image now. :) Thanks for that.

Is there any way to display multiple random images with your script? Sorry if this has already been answered. I tried to find it in the thread but it's very long and gets confusing because I only speak English.

Offline Amosnet

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • Bilder verkaufen
Re: [Mod] Random image / Zufallsbild
« Reply #175 on: March 10, 2003, 10:30:12 PM »
Was hat Matthias 70 hier geändert damit es läuft.
Ich will den Kategorienamen anzeigen lassen!!!!

Quote from: Matthias70
Hier ein Versuch die random.php mit Hits und Bewertung zu ergänzen.
Funktioniert nicht ;-(

Code: [Select]
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$image_hits = $row['image_hits'];
$image_rating = $row['image_rating'];
$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<br>\n";
echo "Hits: $image_hits<br>\n";
echo "Bewertung: $image_rating<br>\n";
?>


Wer hat einen Lösungsvorschlag?
Matthias
I love 4images! http://www.fotos-verkaufen.de Fotos verkaufen online Tips und Tricks und http://www.fotoskaufen.de

Offline Amosnet

  • Full Member
  • ***
  • Posts: 104
    • View Profile
    • Bilder verkaufen
Re: [Mod] Random image / Zufallsbild
« Reply #176 on: March 10, 2003, 11:38:43 PM »
Man muss unter:

Code: [Select]
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, b.cat_name

Anfügen:
Code: [Select]
b.cat_name

dann ein bischen weiter unten:
Code: [Select]

$cat_name = $row['cat_name'];

Und das ist dann die Ausgabe:
Code: [Select]

echo "Kategorie:<br><a href=\"".ROOT_PATH."categories.php?cat_id=$cat_id\">\n";
echo "$cat_name<br></a>\n";
[/code]
I love 4images! http://www.fotos-verkaufen.de Fotos verkaufen online Tips und Tricks und http://www.fotoskaufen.de

Offline PREACHER

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • http://www.desktopart.de
Re: [Mod] Random image / Zufallsbild
« Reply #177 on: March 23, 2003, 12:52:42 PM »
Ich hätte da mal ne frage ist es möglich die Random funktion in script mit den neuen Bildern zu verbinden wenn ja wie?  :?:
Schreibfehler sind beabsichtigt und dienen der allgemeinen Belustigung.

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 #178 on: March 23, 2003, 01:21:44 PM »
Quote from: PREACHER
Ich hätte da mal ne frage ist es möglich die Random funktion in script mit den neuen Bildern zu verbinden wenn ja wie?  :?:

sorry if  I missaderstud u ;)
http://4homepages.de/forum/viewtopic.php?p=17715#17715
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 FreDyz

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #179 on: March 28, 2003, 06:18:19 PM »
Thanks for this MOD, it works fine! :)

I would want to know if it would be possible that the MOD shows a  random image of a certain member , or the last image added to the gallery (globally or the last image added by a certain member).

I think that this is possible with mySQL queries but I dont know anything of mySQL.

Anybody can help me?

Thanks