PDA

View Full Version : Random Image from 4images


y2krazy
07-05-2004, 02:02 PM
This will add a random image module to your CMPS index page. All credit is given to Nicky from the 4homepages.de forums for the code.

The original hack can be found here:

http://www.4homepages.de/forum/viewtopic.php?t=1688

[1] Open your global.php(vBulletin) file and do the following modification:

Find:

// check for IP ban on user
verify_ip_ban();
Add below:

// START RANDOM PIC MOD
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: none *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* MOD for 4images 1.7 & vBulletin 2.2.7 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* 4images ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (http://www.4homepages.de/4images/lizenz.php) für *
* weitere Informationen. *
* --------------------------------------------------------------- *
* 4images is NOT freeware! Please read the Copyright Notice *
* (http://www.4homepages.de/4images/lizenz_e.php) for further *
* information. *
* *
*************************************************************************/

// Set here the URL to your 4images Gallery. WITH trailing slash!
define('SCRIPT_URL', 'http://YOUR-URL-TO/4images/');

// Set here your THUMBNAIL directory. Normally no need to change. WITHOUT trailing slash!
define('THUMB_DIR', 'data/thumbnails');

function is_remote($file_name) {
return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
}

// In following queries CHANGE 4images table PREFIX if it doesn't match (Standard "4images_")!
$sql = "SELECT COUNT(*) AS total_images
FROM 4images_images
LEFT JOIN 4images_categories ON (4images_images.cat_id=4images_categories.cat_id)
WHERE 4images_images.image_active=1
AND 4images_categories.auth_viewcat=0
AND 4images_categories.auth_viewimage=0";
$row = $DB_site->query_first($sql);
$total_images = $row['total_images'];

mt_srand((double)microtime() * 1000000);
$number = ($total_images > 1) ? mt_rand(0, $total_images - 1) : 0;

$sql = "SELECT 4images_images.image_id,4images_images.cat_id,4images_images.image_name,
4images_images.image_active,4images_images.image_thumb_file,4images_images.image _comments
FROM 4images_images
LEFT JOIN 4images_categories ON (4images_images.cat_id=4images_categories.cat_id)
WHERE 4images_images.image_active=1
AND 4images_categories.auth_viewcat=0
AND 4images_categories.auth_viewimage=0
LIMIT $number, 1";
$row = $DB_site->query_first($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'] : SCRIPT_URL.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];

$randompic = "<center><a href=\"".SCRIPT_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"><br /><br /><smallfont><b>$image_name</b></a><br />$image_comments Comments</smallfont></center>\n";
// HAVE FUN
// END RANDOM PIC MOD
[2] In the AdminCP, go to the Add Module option.

[3] Still in your AdminCP, go to Styles & Templates > Style Manager > Add a new template and call it "adv_portal_gallerypic".

Insert this code into the template:

<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td class="tcat"><span class="smallfont"><strong>$vba_options[portal_blockbullet] <a href="http://YOUR-URL-TO/4images/">Random Gallery Pic</a></strong></span></td>
</tr>
<tr>
<td class="$getbgrow" width="100%"><span class="smallfont">$randompic</span></td>
</tr>
</table>
<br />
Now save the template!

[4] Still in your AdminCP, go to vBa CMPS > Add Module

- Module Title: Random Gallery Pic
- Module Identifier: Leave this empty
- OR Template to Include - gallerypic
- Activate this module and then select the column you want it to appear in.
- Save.

y2krazy
07-08-2004, 02:27 PM
Has anyone found this useful?

Also, a demo can be found here:

http://www.wickedart.org/home.php

-y2k-

Our Sponsors
 

Zachariah
07-12-2004, 11:11 AM
gana try it out in a few days - Thanks

Vilandra
07-17-2004, 12:15 AM
Exactly what I was looking for and works great - thanks! :D

Our Sponsors
 

juanchi
07-21-2004, 10:34 AM
Great hack but I wonder If I can choose thumbnails from a specific category or subcategory?

y2krazy
07-22-2004, 03:29 AM
Not sure. Like I stated in the initial post, "All credit is given to Nicky from the 4homepages.de forums for the code." I did not write the code, I only utilized it for displaying a random image from the 4images section. I'm sure with further coding that it would be possible, but that is beyond my abilities. ;)

Wordplay
10-11-2004, 06:52 AM
can't get it to work, i keep getting this error:

Database error in vBulletin 3.0.3:

Invalid SQL: SELECT 4images_images.image_id,4images_images.cat_id,4ima ges_images.image_name,
4images_images.image_active,4images_images.image_t humb_file,4images_images.image_comments
FROM 4images_images
LEFT JOIN 4images_categories ON (4images_images.cat_id=4images_categories.cat_id)
WHERE 4images_images.image_active=1
AND 4images_categories.auth_viewcat=0
AND 4images_categories.auth_viewimage=0
LIMIT 35, 1
mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '.image_name,
4images_images.image_active,4image

mysql error number: 1064

Wordplay
10-11-2004, 07:00 AM
ah got it.... but why were there spaces in the code you gave and nobody else had errors with it... might want to edit that it says "4ima ges" and "t humb_file".

MorrisMcD
10-11-2004, 10:50 PM
// In following queries CHANGE 4images table PREFIX if it doesn't match (Standard "4images_")

Does this mean if I named my module, template or images folder different??

I am getting an error too.. I also didnt do anything with thumbnails.. I left that alone.. But the folder I have it as http://www.url/images/shopimages instead of what default would be I guess http://forums.url/4images

cartman
03-21-2005, 09:29 PM
great hack - worked great but had to remove the spaces from the code, just like WordPlay

see it here.... http://www.gpcricket.com.au

mholtum
03-22-2005, 12:36 AM
// In following queries CHANGE 4images table PREFIX if it doesn't match (Standard "4images_")

Does this mean if I named my module, template or images folder different??

I am getting an error too.. I also didnt do anything with thumbnails.. I left that alone.. But the folder I have it as http://www.url/images/shopimages instead of what default would be I guess http://forums.url/4images
It has to do with the table prefix. It should match if you left it at default when installing 4images.. I get the same error

midnightwalker
04-27-2005, 03:16 PM
it didn't work :( didn't see any thumbnail but the header

midnightwalker
04-27-2005, 03:40 PM
I can call "echo $randompic;" in global.php file and it works fine. However, when I put "echo $randompic" in the template file that seems don't work :( Someone please help

azef
05-22-2005, 11:08 AM
؟؟؟؟؟؟؟؟؟؟؟؟

WarriorDL
05-25-2005, 03:15 PM
Thumbnail portion = noshow.

vBadvanced CMPS v1.0.1
vBulletin 3.0.7
4Images 1.7.1

kfa
07-25-2005, 10:27 PM
it didn't work

=====

Database error in vBulletin 3.0.7:

Invalid SQL: SELECT 4images_images.image_id,4images_images.cat_id,4ima ges_images.image_name,
4images_images.image_active,4images_images.image_t humb_file,4images_images.image_comments
FROM 4images_images
LEFT JOIN 4images_categories ON (4images_images.cat_id=4images_categories.cat_id)
WHERE 4images_images.image_active=1
AND 4images_categories.auth_viewcat=0
AND 4images_categories.auth_viewimage=0
LIMIT 35, 1
mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '.image_name,
4images_images.image_active,4image

mysql error number: 1064

VVIper
10-05-2005, 04:14 AM
I get this error

Fatal error: Call to a member function on a non-object in C:\Inetpub\wwwroot\www.mysite.com\forum\global.php on line 726

My database resides in the forum database what should the code read to change this?

cartman
12-10-2005, 06:55 PM
Great hack but I wonder If I can choose thumbnails from a specific category or subcategory?

me too!!! I've got a hidden image category within my 4images gallery (future images to be published for a competition) but unfortunately they've been found to be popping up in the random image module for all users

does anyone know how to exclude a specific category/subcategory? any help would be greatly appreciated

website in question is www.gpcricket.com.au

VVIper
04-07-2006, 07:51 PM
not working no errors just no picture any ideas?