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

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

0 Members and 1 Guest are viewing this topic.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #420 on: August 07, 2007, 11:45:46 PM »
Ok. I download random.txt file.

This is what need:

Quote
$number = ($total_images > 1) ? mt_rand(0, $total_images - 1) : 0;

after - add:

Quote
$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", a.".$key;
  }
}

Find:

Quote
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments

replace:

Quote
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments" . $additional_sql . "

[ Edit ]
« Last Edit: August 08, 2007, 12:01:28 AM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

computer123

  • Guest
Re: [Mod] Random image / Zufallsbild
« Reply #421 on: August 08, 2007, 01:58:40 AM »
Hello thunderstrike ,

Thank you for your support.

I tried what you said to me but it does not work.

Do you have another solution please?

Cheers

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #422 on: August 08, 2007, 02:31:35 AM »
Quote
I tried what you said to me but it does not work.

What this does not work ? Is say ?
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #423 on: August 13, 2007, 12:50:36 AM »
Nicky dear thank for this mod, would you plz like to tell me how to control thumb size and number of thumbs to show in my other site, Assume my gallery thumb size is 130pixel and i wanna show random.php thumb in 150 pixel in other site.

hi ashfaq,

use width=\"123456\" height=\"123456"\
in
<img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\">
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 thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #424 on: August 13, 2007, 01:21:24 AM »
Oh ! so see the mean now.

Quote
<img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\" width=\"123456\" height=\"123456\">

for:

Quote
$imgtable_width = ceil(intval($config['image_table_width']) / $config['image_cells']);
<img src=\"".$thumb_src."\" border=\"0\" width=\"".$imgtable_width."\" alt=\"$image_name\">

;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline ashfaq

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #425 on: August 29, 2007, 06:08:49 PM »
I have a stupid question, what to put in place here
define('ROOT_PATH', './4images/');

Shoul we have to put our site url here ? like
define('http://www.mydomain.com/');

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #426 on: August 29, 2007, 06:10:17 PM »
Quote
define('ROOT_PATH', './4images/');

After <?php tag at top. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline ashfaq

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #427 on: August 29, 2007, 06:39:22 PM »
Quote
define('ROOT_PATH', './4images/');

After <?php tag at top. ;)

Cant understand, plz explain little bit more, infact i am not good in php so plz help.
you mean put it here
// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
Like
http://www.mydomain.com

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #428 on: August 29, 2007, 06:47:31 PM »
Open PHP file.

Code: [Select]
<?php

add after:

Code: [Select]
define('ROOT_PATH', './4images/');

Easy. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline ashfaq

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #429 on: August 30, 2007, 02:58:43 AM »
Thanks bro for help, plz just give an example by putting domain path, plz

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #430 on: August 30, 2007, 03:03:46 AM »
Domain name - includes/constants.php file - 1st line: SCRIPT_URL (uncomment +  add URL). After, use SCRIPT_URL in ROOT php file. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline ashfaq

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #431 on: August 30, 2007, 04:22:28 AM »
I am totally confused, plz give an example by putting temporary domain like www.mydomain.com in code

I am using this random.php 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/');

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\"><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";
?>

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #432 on: August 30, 2007, 05:34:10 AM »
In includes/constants.php file,

find:

Quote
// define('SCRIPT_URL', 'http://www.yourdomain.com/4images'); //no trailing slash

change:

Quote
define('SCRIPT_URL', 'http://www.yourdomain.com/4images'); //no trailing slash

and change http://www.yourdomain.com/4images for your full URL.

In random.php file,

find:

Quote
define('ROOT_PATH', './4images/');

change:

Quote
define('ROOT_PATH', SCRIPT_URL);
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline ashfaq

  • Full Member
  • ***
  • Posts: 128
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #433 on: August 30, 2007, 11:27:48 AM »
I did the same procedure.
First Open constants.php and put my domain path.
Code: [Select]
// define('SCRIPT_URL', 'http://www.mydomain.com'); //no trailing slash
Then in random.php also change like
Code: [Select]
define('ROOT_PATH', 'http://www.mydomain.com');
After make changes both files i upload constants.php in includes folder and random.php in root path But it is not working.

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [Mod] Random image / Zufallsbild
« Reply #434 on: August 30, 2007, 01:29:27 PM »
ashfaq,

where is your gallery? pls send url
where is random.php saved? send url
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