Announcement

#1 2003-11-01 13:06:10

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Random Picture

Hi every PhpWebGallery users,

Random Picture is the first official MOD available for PhpWebGallery  :D

Description : enables you to display a random picture from your PhpWebGallery picture database. Just place the file random.php where you want on your website and give the correct information about where to find files of PhpWebGallery. You can also use the content of file random.php and copy it into another PHP web page.

Downloads
- Saturday November 1st, 2003 : release 1.0.0 (for PhpWebGallery 1.3) [zip] [tar.gz]
- Saturday November 6th, 2004 : release 1.0.1 (tested with releases 1.3.1, 1.3.2, 1.3.3 and 1.3.4) [zip] [tar.gz]

Last edited by z0rglub (2004-11-06 15:28:19)

Offline

 

#2 2003-11-01 13:11:11

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Random Picture

As Random picture is the first MOD for PhpWebGallery, I show you how is written the file install.txt (that you can find in the downloadable archive) for release 1.0.0 :

Code:

##############################################################################
## MOD Title: Random picture                                                 #
## MOD Author: z0rglub < pierrick@z0rglub.com > (Pierrick LE GALL)           #
##             http://www.z0rglub.com                                        #
## MOD Description: Display a random picture of the PhpWebGallery database   #
##                  outside the gallery                                      #
## MOD Version: 1.0.0 (works with PhpWebGallery 1.3)                         #
##                                                                           #
## Installation Level: easy                                                  #
## Installation Time: 5 Minutes                                              #
## Files To Edit: random.php                                                 #
## Included Files: random.php                                                #
##############################################################################
## MOD History:                                                              #
##                                                                           #
##   2003-11-01 - Version 1.0.0                                              #
##      - Initial Release :-)                                                #
##                                                                           #
##############################################################################

#
#-----[ COPY ]----------------------------------------------------------------
#
copy random.php TO the directory you want on the same website as PhpWebGallery
#
#-----[ OPEN ]----------------------------------------------------------------
#
random.php
#
#-----[ FIND ]----------------------------------------------------------------
#
define( PREFIX_INCLUDE, '../../devel/' ); // relative path to your gallery
#
#-----[ IN-LINE FIND ]--------------------------------------------------------
#
'../../devel/'
#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------------
# examples : './gallery/', './phpwebgallery/', '../photos/'
'relative/path/to/my/gallery/'
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------------
#
# EoM

This is just an example at the date of 1st of November, release 1.0.0. These instructions may change in next releases of the MOD

Offline

 

#3 2003-11-29 14:04:08

kris
Guest

Re: Random Picture

I have a bug :

Fatal error: Call to undefined function: database_connection() in /htdocs/www/random.php on line 25

 

#4 2003-11-29 14:18:33

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Random Picture

It means that the path given is not correct. The function is in the included file and the included file depends on the path given.

Offline

 

#5 2003-12-12 14:47:02

hama
Member
2003-12-02
27

Re: Random Picture


I've got two questions about this MOD:

I would like to place a random picture of my gallery at the startpage of my website but it should be only one of the thumbnails. Does this MOD work with the big pictures or with the thumbs?  8-O

My website (include startpage, except gallery) is written in html. Is it possible to build in this random.php into the html-startpage? If not, what can I do?  :oops:

Thanks

Offline

 

#6 2004-05-26 11:54:18

Lilian
Member
Paris
2003-09-17
41

Re: Random Picture

I modified the code to works with the version 1.3 :

Code:

<?php
/***************************************************************************
 *                                 random.php                              *
 *                            -------------------                          *
 *   application   : PhpWebGallery 1.3 <http://phpwebgallery.net>          *
 *   author        : Pierrick LE GALL <pierrick@z0rglub.com>               *
 *                                                                         *
 *   $Id: random.php,v 1.1.1.1 2003/11/01 10:31:53 z0rglub Exp $
 *                                                                         *
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation;                                         *
 *                                                                         *
 ***************************************************************************/

//--------------------------------------------------------------- configuration
define( PREFIX_INCLUDE, '../../devel/' ); // relative path to your gallery
define( USER_ID, 2 ); // 2 is the guest, 1 the webmaster
//-------------------------------------------------------------------- includes
include( PREFIX_INCLUDE.'include/functions.inc.php' );
database_connection();
//-------------------------------------------------- configuraiton informations
$query = 'SELECT prefix_thumbnail';
$query.= ' FROM '.PREFIX_TABLE.'config';
$query.= ';';
$row = mysql_fetch_array( mysql_query( $query ) );
$prefix_thumbnail = $row['prefix_thumbnail'];
//----------------------------------------------------------- user informations
$query = 'SELECT status,forbidden_categories';
$query.= ' FROM '.PREFIX_TABLE.'users';
$query.= ' WHERE id = '.USER_ID;
$query.= ';';
$row = mysql_fetch_array( mysql_query( $query ) );
$user_status = $row['status'];
$restricted_cats = $row['forbidden_categories'];
//------------------------------------------------------------- which picture ?
$query = 'SELECT id,file,storage_category_id,tn_ext,category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id = ic.image_id';
if ( count( $restricted_cats ) > 0 )
{
  $query.= ' WHERE category_id NOT IN (';
  $query.= $restricted_cats;
  $query.= ')';
}
$query.= ' ORDER BY RAND()';
$query.= ' LIMIT 0,1';
$query.= ';';

$result = mysql_query( $query );
$row = mysql_fetch_array( $result );

// create directory where the thumbnail can be found
$site_url = get_site_url( $row['storage_category_id'] );
if ( $site_url == './galleries/' ) $site_url = '../../../photos/galleries/';
$cat_directory = $site_url.get_local_dir( $row['storage_category_id'] );
// file to display
$file = get_filename_wo_extension( $row['file'] );
// URL of the thumbnail
$thumb_url = $cat_directory.'thumbnail/';
$thumb_url.= $prefix_thumbnail.$file.'.'.$row['tn_ext'];
// link to the gallery
$thumb_link = PREFIX_INCLUDE.'picture.php';
$thumb_link.= '?cat='.$row['category_id'];
$thumb_link.= '&amp;image_id='.$row['id'];
//------------------------------------------------------------- display picture
echo '<a href="'.$thumb_link.'">';
echo '<img src="'.$thumb_url.'" alt="" style="border:none;" />';
echo '</a>';
?>

Offline

 

#7 2004-07-11 16:36:09

Vlad
Guest

Re: Random Picture

My structure's :

Code:

.
|- gallery
|    |- include
|    |- admin
|    |- ...
|    `- random.php
`- index.php

in index.php:

Code:

include("gallery/random.php");

what PREFIX_INCLUDE i must set?

 

#8 2004-07-11 17:45:59

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Random Picture

Vlad wrote:

what PREFIX_INCLUDE i must set?

./gallery/

Offline

 

#9 2004-07-11 20:35:36

Vlad
Guest

Re: Random Picture

z0rglub wrote:

Vlad wrote:

what PREFIX_INCLUDE i must set?

./gallery/

Thanks!

 

#10 2004-07-24 22:30:48

www.animabusca.uni.cc
Guest

Re: Random Picture

Fatal error: Cannot redeclare validate_mail_address() (previously declared in \include\functions_user.inc.php:7)

 

#11 2004-08-30 13:42:35

Zudomon
Member
2004-06-28
24

Re: Random Picture

I can't get even a error to pop in
define( PREFIX_INCLUDE, '../../devel/' ); // relative path to your gallery
I have a folder called Galleries and with in that folder PHPWebGallery is were the galleries for PHPWebGallery is at so my prefix would be?
./Galleries/galleries/ ? is that right?

Last edited by Zudomon (2004-08-30 13:43:05)

Offline

 

#12 2004-10-28 09:47:31

vidman
Member
Vidman.ca
2004-10-24
5

Re: Random Picture

Using the modified code Lilian supplied:

define( PREFIX_INCLUDE, './' );

Upload random.php to the same directory category.php occupies

Offline

 

#13 2004-11-05 01:37:32

JBlade00
Guest

Re: Random Picture

I'm getting this message:

Warning: main(./gallery/include/functions.inc.php): failed to open stream: No such file or directory in /home/httpd/vhosts/wsudl.com/httpdocs/gallery/random.php on line 24

Warning: main(): Failed opening './gallery/include/functions.inc.php' for inclusion (include_path=''.'') in /home/httpd/vhosts/wsudl.com/httpdocs/gallery/random.php on line 24

Fatal error: Call to undefined function: database_connection() in /home/httpd/vhosts/wsudl.com/httpdocs/gallery/random.php on line 25

Can anyone help me?

http://www.wsudl.com/gallery/random.php

Thanks,
~Jon

 

#14 2004-11-05 01:40:39

JBlade00
Guest

Re: Random Picture

correction... i changed it to ./ instead of ./gallery/

and now i'm getting this message:

Fatal error: Call to undefined function: get_all_restrictions() in /home/httpd/vhosts/wsudl.com/httpdocs/gallery/random.php on line 39

Help?

~Jon

 

#15 2004-11-06 15:30:07

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Random Picture

JBlade00 wrote:

Fatal error: Call to undefined function: get_all_restrictions() in /home/httpd/vhosts/wsudl.com/httpdocs/gallery/random.php on line 39

I've created release 1.0.1 of this MOD to comply with releases 1.3.1 to 1.3.4. It should work (I've tested)

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact