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

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

0 Members and 4 Guests are viewing this topic.

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #645 on: July 22, 2010, 10:15:43 PM »
Kalte Dusche und dann sollte es doch klappen mit dem Antworten :D
ben88b@googlemail.com :P

B2t:
Danke dir!

nutzt ja nichts, wenn man 2 minuten später wieder switzt...
was soll ich mit der email?
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #646 on: July 23, 2010, 05:17:59 AM »
Wo du Recht hast, hast du Recht!
Mail = Mir bei Gelegenheit schreiben oder via PN! Würde gerne wissen, was Du mir dazu zusagen hast!

Offline Nosferatu

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Project-Firepower
Re: [Mod] Random image / Zufallsbild
« Reply #647 on: September 30, 2010, 01:54:28 PM »
Hallo,

Edit: sorry didn't work at work. on home browser it works lol

;)
« Last Edit: September 30, 2010, 04:46:21 PM by Nosferatu »

Offline Nosferatu

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Project-Firepower
Re: [Mod] Random image / Zufallsbild
« Reply #648 on: October 07, 2010, 04:05:36 PM »
gibts eine möglichkeit, dass sich das Bild alle "5" sekunden ändern oder ähnliches ?

Offline simpley

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #649 on: October 08, 2010, 12:45:27 PM »
Does this look right ?


<?php
define('ROOT_PATH', './gallery/');
define('SCRIPT_URL', 'http://mydomain.com/gallery/');
include(ROOT_PATH.'config.php');
include(ROOT_PATH.'includes/db_mysql.php');
include(ROOT_PATH.'includes/constants.php');

Offline Nosferatu

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Project-Firepower
Re: [Mod] Random image / Zufallsbild
« Reply #650 on: October 08, 2010, 03:44:37 PM »
yes thats right

Offline simpley

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #651 on: October 08, 2010, 06:00:05 PM »
Thanks for the answer
I wasn't sure if i had got it right, but this is the whole code i have in the random.php file, but it fails to display anything, is there any other files i need to edit. I am using 1.7.7

<?php
define('ROOT_PATH', './gallery/');
define('SCRIPT_URL', 'http://mydomain.com/gallery/');
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)) ? 1 : 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_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'];
$full_src = (is_remote($row['image_media_file'])) ? $row['image_media_file'] : SCRIPT_URL.ROOT_PATH.MEDIA_DIR."/".$cat_id."/".$row['image_media_file'];

print("
document.write('<a href=\"".SCRIPT_URL."details.php?image_id=$image_id\"><img src=\"".$full_src."\" border=\"1\" alt=\"$image_name\"></a>');
");
?>

Offline Nosferatu

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Project-Firepower
Re: [Mod] Random image / Zufallsbild
« Reply #652 on: October 08, 2010, 07:18:29 PM »
your code have to work.

how do you start it ?

if you start it with browser so:

http://www.domain.com/gallery/random.php ?

it don't work!

write a test.php with

<?php
include('gallery/random.php')
?>

and save it under www.domain.com/test.php it work :D

or define('ROOT_PATH', './');

you can use www.domain/gallery/random.php

Offline simpley

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #653 on: October 09, 2010, 02:03:21 PM »
.

I now have random.php file working but i can't get my test.php file to work.

The code in my test.php points to the folder i have the random.php file in, along with the config file.

Any ideas

<?php
include(' gallery/random.php')
?>

UPDATE!

Now I have test.php working correctly but the random.php file does not.

random.php file does not show anything when i directly access it in the browser

to get the test.php to work i have this in my code

<?php
define('ROOT_PATH', './gallery/');
define('SCRIPT_URL', 'http://mydomain.com/gallery/');


AND I removed ROOT_PATH. from this line.


$full_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : SCRIPT_URL.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];


Now that my test.php works, is it possible to create a java script so that i can run  random images on another web site using the test.php genereated images?



« Last Edit: October 10, 2010, 11:51:20 AM by simpley »

Offline simpley

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #654 on: October 10, 2010, 04:09:41 PM »

Latest.

I followed these instructions and now have it working, thanks for this forum and pointing me in the right direction,, thanks again !! :lol:







hi all..
http://www.siteshot.at/nicky.htm

your examples can't work.. if you don' use correct code like descriped in the MOD file..

ROOT != ROOT_PATH  :roll:  :lol: :P 8)

use EXACT following code:


<?php
define
('ROOT_PATH''./');
define('SCRIPT_URL''http://gallery.rammstein-europe.com/');
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_media_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'];
$full_src = (is_remote($row['image_media_file'])) ? $row['image_media_file'] : SCRIPT_URL.ROOT_PATH.MEDIA_DIR."/".$cat_id."/".$row['image_media_file'];

print(
"
document.write('<a href=\""
.SCRIPT_URL."details.php?image_id=$image_id\"><img src=\"".$full_src."\" border=\"1\" alt=\"$image_name\"></a>');
"
);
?>


Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <meta name="generator" content="PSPad editor, www.pspad.com">
  <title></title>
  </head>
  <body>
LOL

<SCRIPT language='JavaScript'  src='http://gallery.rammstein-europe.com/random.php'></SCRIPT>
  </body>
</html>

[EDIT by V@no]
corrected index.html to avoid confusion ;) their original code was correct.


Offline www.ul-piloten.de

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Das Portal für Ultraleicht Piloten
Re: [Mod] Random image / Zufallsbild
« Reply #655 on: November 20, 2010, 10:14:13 AM »
Hallo zusammen,

bei mir werden die Umlaute leider nicht korrekt (als Kästchen) angezeigt.
Ich probiere jetzt schon seit Stunden herum, finde aber leider keine Lösung.
Bin in dem Themen auch nicht so fit  :cry:

Ich hoffe das mir jemand von Euch helfen kann.

Besten Gruß
Michael

UL-Piloten.de // Das Portal für Ultraleicht - Piloten und Interessierte

Offline Nosferatu

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Project-Firepower
Re: [Mod] Random image / Zufallsbild
« Reply #656 on: November 25, 2010, 05:19:54 PM »
da bist du aber hier im falschen bereicht ?

Umlaut probleme hab ich in letzter zeit auch ab und zu liegt daran, dass Browser eventuell nicht auf UTF-8 umgestellt ist bzw wenn UTF 8 eingestellt ist homepage vieleicht nicht auf UTF-8 lauft ^^ dadurch kommen umlaut fehler.

Offline nfdieter

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
    • Unser kleiner Zoo
Re: [Mod] Random image / Zufallsbild
« Reply #657 on: December 16, 2010, 05:54:27 PM »
Moin,

wie kann man die random.php so umbauen, das sie nicht "random", sondern alle Thumbs einer Kategorie anzeigt?

Habe das testweise mal auf http://www.unser-kleiner-zoo.eu/wordpress/testseite2/ und http://www.unser-kleiner-zoo.eu/wordpress/testseite/ probiert, aber wenn ich alle Thumbs (oder auch weniger) einsetze, werden viele doppelt gezeigt...

Hatte deshalb die Anzeige von den vorhandenen 20 auf 15 reduziert, trotzdem werden doppelte angezeigt.

Gruß Dieter

jetzt unter http://www.unser-kleiner-zoo.eu/wordpress/pony-frieda-ist-wieder-da/ zu sehen!
« Last Edit: December 19, 2010, 08:14:23 AM by nfdieter »

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #658 on: December 17, 2010, 10:53:18 PM »
Moin,

wie kann man die random.php so umbauen, das sie nicht "random", sondern alle Thumbs einer Kategorie anzeigt?

Habe das testweise mal auf http://www.unser-kleiner-zoo.eu/wordpress/testseite2/ und http://www.unser-kleiner-zoo.eu/wordpress/testseite/ probiert, aber wenn ich alle Thumbs (oder auch weniger) einsetze, werden viele doppelt gezeigt...

Hatte deshalb die Anzeige von den vorhandenen 20 auf 15 reduziert, trotzdem werden doppelte angezeigt.

Gruß Dieter

hi Dieter,

poste dein code, mal sehen.
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline nfdieter

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
    • Unser kleiner Zoo
Re: [Mod] Random image / Zufallsbild
« Reply #659 on: December 18, 2010, 08:32:44 AM »
Moin Nicky,


hi Dieter,

poste dein code, mal sehen.

<?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''../fotos/');



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 15;

$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 = 61
        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\" target=\"_new\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a>&nbsp;\n";

 
  
}
?>


Gruß Dieter