4images Forum & Community
4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: swifter_uk on March 18, 2003, 02:38:50 AM
-
I would like to re-display the random image from my gallery on other pages within a: my forum and b: an independant website, is this possible or am I clutching at straws?
Mike
-
Look here http://www.4homepages.de/forum/viewtopic.php?t=1020&start=0
I hope this is what you need.
-
Look here http://www.4homepages.de/forum/viewtopic.php?t=1020&start=0
I hope this is what you need.
Need help with this!
I have downloaded the code:
**/
// http://www.hovegallery.co.uk/Gallery
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)) ? 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_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";
?>
But wherever I try to implement it only so far produces errors or displays the code on the page with no image, what am I missing?
Here is where I want random image to display, somewhere within homepage. http://www.hovedogs.co.uk
-
First of all.......you can only incluse this to a PHP-Page. So if your page is a htm or html .......rename it to *.php and than include.
// http://www.hovegallery.co.uk/Gallery
define('ROOT_PATH', './4images/');
And this is not right. Try this:
define('ROOT_PATH', '../Gallery/');
-
Sorry Jan I must be really dim :cry: I cannot get this to work, I have changed html file to php as you said but all I get displayed is the code i entered in the first place!!!!!!!!
If you can help me where i am going wrong I would apreciate it.
Here is the link where I added the code to test:
http://www.rockysracers.co.uk/Random_image.php
-
Here is the link where I added the code to test:
http://www.rockysracers.co.uk/Random_image.php
I think u forgot add <?php at the beginning of the file.
-
Thanks v@no,
Tried that too, but still cannot make it work, I must be too dumb!! :cry:
Tried loading to another server that I know definately runs php.
http://www.hovedogs.co.uk/Random_image.php but still no joy!!
-
Please post the full code.
-
Please post the full code.
here it is:
<?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. *
* *
*************************************************************************/
// http://www.hovegallery.co.uk/Gallery
define('ROOT_PATH', '../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_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";
?>
-
The code is ok. I have copy this to my folder and open it and it works fine:
http://www.terradreams.de/gallery/random1.php
Try to upload your Random_image.php (like it is) to your Gallery Folder and open it in your browser
http://www.hovedogs.co.uk/Gallery/Random_image.php
If it works, you can include it in every PHP-page on your site.
-
the problem is in define('ROOT_PATH', '../Gallery/');
since u put your random.php file in root dir on your server, u must use just one dot: define('ROOT_PATH', './Gallery/');
two dots (../) means that one dir behind.
-
I think I understand now!!
Will let you know how I get on, thanks for all the help with this...very grateful :D
-
One small question...
now I have it working how do I display this random image on the front of my forum, http://www.hovedogs.co.uk/Owners_Forum
-
then, use ../
-
Sorry I am a total dunce with this. I need something more specific :cry:
-
I don´t know your forum .....but try to include it to a php-file like index.php or header.php
<?php
include("path to your random image.php");
?>
-
All of the forum style sheets are html!! :cry:
-
All of the forum style sheets are html!! :cry:
same as 4images ;)
your forum stile based on templates, that means, that those .html file are generated by php. so u still can try to do so, if your forum support PHP includes in the templates it should work.
-
seems like you like to keep me in suspense, so how can I add it to my homepage if all stylesheets or whatever are html....?
I really need a "dummy's guide", to this as I have no experience with this format.
-
as Neo1 said, try to add into your board template:
<?php
include("path to your random image.php");
?>
if this wont work, then u'll need do some "core" modifications in the board code...
-
I give up!! The code works fine as you can see if you follow the link:
But I can't for love nor money get it to re-display on my Forum homepage via html files, despite trying two different servers.
If anyone is willing to try for me perhaps I can give them Temporary Admin access via PM?
Such a good concept going to waste :cry:
http://www.hovegallery.co.uk/Gallery/Random_image.php
-
I have been told access to php includes on my board is denied for security reasons, shame but at least I know I'm not going mad! 8O