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

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

0 Members and 1 Guest are viewing this topic.

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: [Mod] Random image / Zufallsbild
« Reply #360 on: January 05, 2007, 09:52:50 AM »
########################################
$sql = "SELECT COUNT(*) as total_images
        FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
        WHERE a.image_active=1
        AND a.cat_id = '80'
        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 = '80'
        AND b.auth_viewcat=".AUTH_ALL."
        AND b.auth_viewimage=".AUTH_ALL."
        LIMIT $number, 1";
$row = $site_db->query_firstrow($sql);
########################################



Replace the 80 with your cat_id... (o:
so it works on my site:
http://www.picsforfree.de/random.php

Offline Ricsca

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #361 on: January 06, 2007, 03:06:12 AM »
I found the problem...
It introduces the id of the specific category and not of the category in general...

How it is possible to make to see more categories? 

Thanks

Offline CeJay

  • Sr. Member
  • ****
  • Posts: 425
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #362 on: January 12, 2007, 12:58:16 AM »
I am using the random_more_pics mod.

What I would like to show along with the name and comments is the rating of the image.
Is this possible? If so what do I need to change?

Sorry if this was already answered in a different language, all i know is english.

Offline CeJay

  • Sr. Member
  • ****
  • Posts: 425
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #363 on: January 12, 2007, 08:33:16 AM »
Not sure if I gave enough info on last post.
Do I need to do something like what was posted in this post on the random_more_pics.php like so?

$image_hits = $row['image_hits'];
$image_rating = $row['image_rating'];
and
echo "Hits: $image_hits<br>\n";
echo "Bewertung: $image_rating<br>\n";

I tried to figure this out before I asked.
If adding ratings is not possible is it possible for hits?

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #364 on: January 12, 2007, 02:07:50 PM »
@ CeJay
... try this ...
Code: [Select]
echo "Hits: ".$image_hits."<br>\n";
echo "Bewertung: ".$image_rating."<br>\n";
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 ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline CeJay

  • Sr. Member
  • ****
  • Posts: 425
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #365 on: January 13, 2007, 12:55:00 AM »
@ CeJay
... try this ...
Code: [Select]
echo "Hits: ".$image_hits."<br>\n";
echo "Bewertung: ".$image_rating."<br>\n";

Ok I added that. Here is what I have on the php:
Code: [Select]
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'];
  $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 "<table border='0' width='213' 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><b>$image_name</b></TD>\n";
  echo "</TR>\n";
  echo "<TR>\n";
  echo "<TD>Comments: $image_comments</TD>\n";
  echo "</TR>\n";
  echo "<TR>\n";
  echo "Hits: ".$image_hits."<br>\n";
  echo "</TR>\n";
  echo "<TR>\n";
  echo "Rating: ".$image_rating."<br>\n";
  echo "</TR>\n";
  echo "</table>\n";

The tables are set to have the rows horizontal so that is why you see that.

I do have the listing for the ratings and hits, however nothing (the count) shows up next to them.
I did double check the images that loaded to see if there was at least hits and there was.

Offline CeJay

  • Sr. Member
  • ****
  • Posts: 425
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #366 on: January 13, 2007, 01:12:55 AM »
Nevermind I got it, something I should have seen from the start   :oops:

I had
Code: [Select]
$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

and needed
Code: [Select]
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.image_hits, a.image_rating
        FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b


@ mawenzi
Thanks for your help, I appreciate it  :!:

Offline wallpapers

  • Full Member
  • ***
  • Posts: 107
    • View Profile
    • Tuned-Cars.Net
Re: [Mod] Random image / Zufallsbild
« Reply #367 on: January 13, 2007, 11:04:06 PM »
Ok this is diffecult to explain for me but i give it a trie.
First it is a good mod :D

My question:
My database have more 4 images tables
So the table database looks like this:
Code: [Select]
  test_4images_categories
  test_4images_comments
  test_4images_groupaccess
  test_4images_groupmatch
  test_4images_groups
  test_4images_images
  test_4images_images_temp
  test_4images_lightboxes
  test_4images_postcards
  test_4images_sessions
  test_4images_sessionvars
  test_4images_settings
  test_4images_users
  test_4images_wordlist
  test_4images_wordmatch
  test2_4images_categories
  test2_4images_comments
  test2_4images_groupaccess
  test2_4images_groupmatch
  test2_4images_groups
  test2_4images_images
  test2_4images_images_temp
  test2_4images_lightboxes
  test2_4images_postcards
  test2_4images_sessions
  test2_4images_sessionvars
  test2_4images_settings
  test2_4images_users
  test2_4images_wordlist
  test2_4images_wordmatch

How can i do so that the random.php randomise all off the images from the different 4images databases.

I hope you will understand my english :roll:



Offline yukino_girl

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #368 on: January 27, 2007, 01:54:32 AM »
how do i get this to work as a module on my vbadvanced homepage? can anyone help me with that?

Offline CeJay

  • Sr. Member
  • ****
  • Posts: 425
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #369 on: January 27, 2007, 08:51:28 AM »
how do i get this to work as a module on my vbadvanced homepage? can anyone help me with that?
I don't know vbadvanced, but if you know where you want the image the put in a tag on the home page
Code: [Select]
<?php
 
include("./random.php");
?>
or create it in iFrame and call the random image in there.

Offline RoadDogg

  • Sr. Member
  • ****
  • Posts: 488
    • View Profile
    • Düsipixel
Re: [Mod] Random image / Zufallsbild
« Reply #370 on: February 05, 2007, 12:22:56 AM »
Ich habe nun schon einiges gelesen und gestet, allerdings wird bei mir das thumbnail nicht angezeigt. Statt der kompletten Bildadresse kommt nur das hier:

http://duesipixel.de/random_full.php

Code: [Select]
<a href="http://duesipixel.de/details.php?image_id=1240"><img src="http://duesipixel.de/data/thumbnails/36/" border="0" alt="Jahresabschluss05 in Speyer"></a><br>
$row['image_thumb_file'] wird nicht umgewandelt?

Hier die random.php

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: random_full.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
define('ROOT_PATH''/home/w11854/web/public_html/newgalerie/');

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

define('SCRIPT_URL''http://duesipixel.de/');

$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 IN (35, 36, 58, 59, 61, 66)
        AND b.cat_id IN (35, 36, 58, 59, 61, 66)
        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, b.cat_name  
        FROM "
.IMAGES_TABLE." a, ".CATEGORIES_TABLE." b 
        WHERE a.image_active=1 
        AND a.cat_id IN (35, 36, 58, 59, 61, 66)
        AND b.cat_id IN (35, 36, 58, 59, 61, 66)
        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'];       
$cat_name $row['cat_name'];
$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=\"$cat_name\"></a><br>\n";
?>

Weiß jemand woran das liegt??
For support requests please don´t forget link to your Gallery/to phpinfo.php
Code: [Select]
<?
phpinfo()
?>
safe_mode must turned OFF
Please check Error Messages

Offline RoadDogg

  • Sr. Member
  • ****
  • Posts: 488
    • View Profile
    • Düsipixel
Re: [Mod] Random image / Zufallsbild
« Reply #371 on: February 08, 2007, 11:22:52 AM »
For all who don´t see an image and source code looks like
<img src="http://.../data/thumbnails/36/" border="0" ...>

this works
http://www.4homepages.de/forum/index.php?topic=1020.msg12102#msg12102
For support requests please don´t forget link to your Gallery/to phpinfo.php
Code: [Select]
<?
phpinfo()
?>
safe_mode must turned OFF
Please check Error Messages

Offline FunnyUser

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #372 on: February 13, 2007, 12:53:30 PM »
Quote
Code: [Select]
$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=2
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."<br>
LIMIT $number, 1";

Also das klappt bei mir wunderbar!
Ich möchte es so: meine Kategorie "Dogs" hat die "ID=1", hat aber mehrere Unterkategorien. Wenn ich nun in meiner "random.php" "AND a.cat_id=1" eingebe, werden wirklich NUR die Dateien aus der direkten Hauptkategorie ausgelesen, aber nicht die aus den Subkategorien.

Wie kann ich es ändern, dass auch die zugehörigen Unterkategorien von "ID=1" ausgelesen werden?


Danke
« Last Edit: February 13, 2007, 01:11:06 PM by FunnyUser »

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #373 on: February 13, 2007, 03:46:12 PM »
... verwende z.B. ...
Code: [Select]
AND a.cat_id IN (1,2,3,4,5,6,7,8,9)
... in der Klammer die Kategorie_IDs aufzählen, die gezeigt werden sollen ...  :wink:
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 ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline alphavto

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • http://www.block-a.de
Re: [Mod] Random image / Zufallsbild
« Reply #374 on: February 21, 2007, 05:25:29 PM »
Mein Provider stellt zum 01. März 2007 auf PHP 5.2.0 um. Die random.php funktioniert bis dato unter PHP 5.1.4.
Ich kann nun testen ob alles mit der neuen PHP-Version klappt.
Einzig das Zufallsbild wird jetzt nicht mehr angezeigt, auch nicht der Bildname und die Comments.
Hab extra nochmal die Datei vom ersten Post genommen, ist das selbe.
Hat schon wer die random.php auf PHP 5.2.0 laufen?

PHP-Info: PHP-Info Version 5.2.0 => leere Ausgabe
PHP-Info: PHP-Info Version 5.1.4 => korrekte Ausgabe
« Last Edit: February 21, 2007, 07:39:30 PM by alphavto »