Author |
Message |
izone
Involved


Joined: Sep 07, 2004
Posts: 354
Location: Sweden
|
Posted:
Sat Jul 30, 2005 2:59 pm |
|
Hi
I have integrated 4Images Gallery with PhpNuke so it works as a module for Nuke.
I was looking for a side block to show the random pictures from this gallery. And I found this one at their site.
You have to put a file by name random.php on site (mine is in root) and call it from a block. Code for this block is:
Code:
<?php
if ( !defined('BLOCK_FILE') ) {
Header("Location: index.php");
die();
}
$content = "<center>";
ob_start();
include 'random.php';
$content .= ob_get_contents().$content;
ob_end_clean();
?>
|
and the random.php file is:
Code:
<?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', './modules/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=\"modules.php?name=Gallery&file=details&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";
?>
|
So to my problem:
when I put this block on the right side of my site it works great. but the Gallery wont works!
and when I put it on the left side I get an Sql error on this block which is:
Quote: |
DB Error: Bad SQL Query: SELECT COUNT(*) as total_images FROM 4images_images a, _bbcategories b WHERE a.image_active=1 AND a.cat_id = b.cat_id AND b.auth_viewcat=0 AND b.auth_viewimage=0
Table 'XXXX_nuke75._bbcategories' doesn't exist
DB Error: Bad SQL Query: SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments FROM 4images_images a, _bbcategories b WHERE a.image_active=1 AND a.cat_id = b.cat_id AND b.auth_viewcat=0 AND b.auth_viewimage=0 LIMIT 0, 1
Table 'XXXX_nuke75._bbcategories' doesn't exist
|
But the gallery works fine in this case!
What is wrong? Please help.
Best Regards. |
|
|
|
 |
hitwalker
Sells PC To Pay For Divorce

Joined:
Posts: 5661
|
Posted:
Sat Jul 30, 2005 6:54 pm |
|
well ive read their site and another one had the same problem,or was that you?
Any way...if your using a simple folder where your images are you can simple use a random image block...that should also solve your problem...
A example would be..
Code:
<?
$content="";
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
// $whereimgs has to be in the Domain (like localhost area)
// or put ../ in front of folder name
$whereimgs = "images/";
mt_srand((double)microtime()*1000000);
$imgs = dir($whereimgs);
while ($file = $imgs->read()) {
if (eregi("gif", $file) || eregi("jpg", $file)) {
$imglist .= "$file ";
}
}
closedir($imgs->handle);
$imglist = explode(" ", $imglist);
$a = sizeof($imglist)-2;
$random = mt_rand(0, $a);
$image = $imglist[$random];
$asin = explode(".", $image);
$content = "";
$content .= "<center><a href=\"modules.php?name=4images\">";
$content .= "<img src=\"".$whereimgs."/$image\" border=\"0\" width=\"120\" alt=\"\"></a><br><br>";
$content .= "Click image</center>";
?>
|
|
|
|
|
 |
izone

|
Posted:
Sun Jul 31, 2005 5:33 am |
|
hitwalker, Thanks a lot.
I will give it a try and come back with answer.
No it was not me. I have tried to get some other answer from them but nobody answer to questions there!
I hope Raven could have a 4images forum too so people could get answers!
Thanks for quick reply. |
|
|
|
 |
hitwalker

|
Posted:
Sun Jul 31, 2005 6:20 am |
|
sure try it,...as for the support...yeah thats terrible.
but that goes for a lot of sites...  |
|
|
|
 |
izone

|
Posted:
Sun Jul 31, 2005 11:06 am |
|
well, it didn't work.
I think it is because of this part:
Code:
// $whereimgs has to be in the Domain (like localhost area)
// or put ../ in front of folder name
$whereimgs = "images/";
|
It can only take pictures or thumbnails from one catalog. As you know there is a catalog for each category there.
So back to my first post here. Why is it like this? I mean why the block works when it is in one side and not works when it is in another side??
regards |
|
|
|
 |
hitwalker

|
Posted:
Sun Jul 31, 2005 11:26 am |
|
That can have a few reasons.
Im not to familiar with that stuff but i can imagine it can have a conflict ..
Try to switch the block on the left or right,... |
|
|
|
 |
izone

|
Posted:
Sun Jul 31, 2005 2:11 pm |
|
Quote: |
So to my problem:
when I put this block on the right side of my site it works great. but the Gallery wont works!
and when I put it on the left side I get an Sql error on this block which is:
Quote:
DB Error: Bad SQL Query: SELECT COUNT(*) as total_images FROM 4images_images a, _bbcategories b WHERE a.image_active=1 AND a.cat_id = b.cat_id AND b.auth_viewcat=0 AND b.auth_viewimage=0
Table 'XXXX_nuke75._bbcategories' doesn't exist
DB Error: Bad SQL Query: SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments FROM 4images_images a, _bbcategories b WHERE a.image_active=1 AND a.cat_id = b.cat_id AND b.auth_viewcat=0 AND b.auth_viewimage=0 LIMIT 0, 1
Table 'XXXX_nuke75._bbcategories' doesn't exist
But the gallery works fine in this case!
|
I did it but it doesn't works on the left side. |
|
|
|
 |
hitwalker

|
Posted:
Sun Jul 31, 2005 2:13 pm |
|
well i dont know if that works on your server but look at your error_log.
and see if it says anything on this.. |
|
|
|
 |
izone

|
Posted:
Sun Jul 31, 2005 2:56 pm |
|
No hitwalker, nothing about this block is there!
I have playing with that block again moving it to center or left but still same reault.
I hope Raven or somebody else could help me with this.
Thank you for all help hitwalker,
 |
|
|
|
 |
izone

|
Posted:
Mon Aug 01, 2005 6:29 am |
|
I found the problem!!!!
when Raven's block-ForumsCollapsing.php is active and I put the block above on the left side I get those db error. But when block-ForumsCollapsing.php is not active it works great.
The question is why?
How can I have both of them active?? |
|
|
|
 |
hitwalker

|
Posted:
Mon Aug 01, 2005 6:32 am |
|
i dont know,i cannot use his forum block either cause it has a conflict with my helpdesk that also uses some javscripting.
thats where it goes wrong. |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Mon Aug 01, 2005 10:57 pm |
|
Sorry for the late reply here - been pretty busy. Normally when this happens there are a couple of probabilities. One could be a variable naming clash and the blocks get confused about who's on first. That's usually the case. The other conflict is coordinating multiple window.onload= actions. |
|
|
|
 |
izone

|
Posted:
Tue Aug 02, 2005 2:31 am |
|
Raven, Thank you for helping.
I know about coordinating multiple window.onload= actions. I hade problem with this before and solve it. Before I installing this Random-block my Shoutbox block and your ForumsCollapsing-block worked great together. The only problem was window.onload= action. For this I moved it from Forum-block to js file for Shoutbox in the root so it worked.
But about the variable naming clash, how can I solv that. Is there an easy way? Your Forum block is unactive know and shoutbox dosn't works know.
I know that you are very busy, but I appreciate if you could help me with this when you have more time. No hurry.
Thanks. |
|
|
|
 |
Raven

|
Posted:
Tue Aug 02, 2005 5:10 am |
|
The only way to solve it is to eyeball it. Look for variables named the same and then change one or the other. If the random block is small enough, just rename all of the variables by adding a prefix or suffix to all, as in var would become RB_var or varRB. |
|
|
|
 |
|