Author Topic: [Mod] Random Pic in vBulletin - Update: 25.01.2008  (Read 57793 times)

0 Members and 1 Guest are viewing this topic.

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
[Mod] Random Pic in vBulletin - Update: 25.01.2008
« on: August 31, 2002, 10:34:00 PM »
Update: 25.01.2008
vBulletin Version 3.6.8 and 4images 1.7.4

 :flag-en:
NOTE: this mod will work ONLY if your 4images mysql tables are in SAME  DATABASE like vBulletin.
 :flag-de:
ACHTUNG: dieser mod funktioniert NUR wenn 4images mysql tabellen in GLEICHER DATENBANK sind wie die von vBulletin.

1.)
 :flag-en: open
 :flag-de: öffne
vBulletin global.php (  :flag-en: not /  :flag-de: nicht admin/global.php)

 :flag-en: search  :flag-de: suche
Code: [Select]
?>

 :flag-en: add before  :flag-de: vordem füge dies
Code: [Select]
// 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.4 & vBulletin 3.6.8                    *
 *                                                                        *
 *    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->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->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 = "<a href=\"".SCRIPT_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br /><smallfont>Image Name: $image_name<br />Comments: $image_comments</smallfont>\n";
// HAVE FUN
// END RANDOM PIC MOD

1.a)
 :flag-en: if you want to use it with more than one pic the use this code
 :flag-de: wenn du es mit mehr bildern benutzen willst benutzen diesen code
Code: [Select]
// 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.4 & vBulletin 3.6.8                    *
 *                                                                        *
 *    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;
}

// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images = 3;

// In following query CHANGE 4images table PREFIX if it doesn't match (Standard "4images_")!
$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
        ORDER BY RAND()
        LIMIT $num_images";

$result = $db->query($sql);

$randompic = "<table><tr>\n";  // START NEW TABLE
while ($row = $db->fetch_array($result)){
  $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 .=  "<td><a href=\"".SCRIPT_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\" title=\"$image_name\"></a><br /><smallfont>Image Name: $image_name<br />Comments: $image_comments</smallfont></td>\n";
}
$randompic .= "</tr></table>\n"; // END OF NEW TABLE
// HAVE FUN
// END RANDOM PIC MOD


2.)
 :flag-en: in mod self change  :flag-de: im mod selbst ändere

// Set here the URL to your 4images Gallery. WITH trailing slash!
// Set here your THUMBNAIL directory. Normally no need to change. WITHOUT trailing slash!
// In following queries CHANGE 4images table PREFIX if it doesn't match (Standard "4images_")!

3.)
 :flag-en: now you can use $randompic in every VB template
 :flag-de: jetzt kannst du $randompic in jedem VB template benützen

3.a)
 :flag-en:
if you want to have the random pic only on your vB main page, then put the code into index.php & template forumhome. (don't use it in global.php!)
 :flag-de:
wennst willst das zufallsbild nur auf der vB startseite erscheint, dann füge den code nur in der index.php & template forumhome. (benutze es dann nicht in der global.php!)


 :flag-en: that's it.... have fun
 :flag-de: das ist alles.... viel spass
« Last Edit: January 25, 2008, 04:31:03 PM by Nicky »
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 X-Fan

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.comixfan.com/xfan/
[Mod] Random Pic in vBulletin
« Reply #1 on: September 01, 2002, 10:20:21 AM »
Will this also work with vBulletin 2.2.5 or 2.2.6?
Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k

Offline goyo

  • Newbie
  • *
  • Posts: 18
    • View Profile
[Mod] Random Pic in vBulletin
« Reply #2 on: September 01, 2002, 11:00:38 AM »
Quote from: X-Fan
Will this also work with vBulletin 2.2.5 or 2.2.6?


 Yes It works...   :)

Offline X-Fan

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.comixfan.com/xfan/
[Mod] Random Pic in vBulletin
« Reply #3 on: September 01, 2002, 03:27:03 PM »
Okay, great!

Now, another question: would it be possible to do this for the vbPortals front end add-on for vBulletin?  I'd like to be able to include a random image in a side block on my site's vbPortals front page.
Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
[Mod] Random Pic in vBulletin
« Reply #4 on: September 01, 2002, 07:04:22 PM »
sorry.
i don't have vbPortal.
i can try if you send it to me: nicky@nicky.net
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 Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
[Mod] Random Pic in vBulletin
« Reply #5 on: September 01, 2002, 08:38:27 PM »
woooooow

there are too many changes for vb to have vbportal running..
you did it allready..

try to add this code to vbportal index.php or vbp_includes.php
and the $randompic into correct template..
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 Elanor

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://4visions.net
[Mod] Random Pic in vBulletin
« Reply #6 on: September 25, 2002, 05:23:15 AM »
Works like a charm =) Great Add on

Offline X-Fan

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.comixfan.com/xfan/
[Mod] Random Pic in vBulletin
« Reply #7 on: September 28, 2002, 06:13:13 PM »
How would I get the code to extract the category name for the random image chosen and display it as a link to the category underneath the random image's name?
Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k

Offline Quackie

  • Pre-Newbie
  • Posts: 9
    • View Profile
[Mod] Random Pic in vBulletin
« Reply #8 on: September 29, 2002, 06:30:21 PM »
I also tried to get the random pics work as a block in vbPortals. I followed instructions as Jan said, but I still don't get it work.  

So after I added the php code into the index.php of the vbPortal, where do i use the variable $randompic in? Should I go to vbPortal admin and add a PHP script block and put that variable in there?

Anyone here success in put the random pic in vbportal block, could u please help me?

Thanks

Offline X-Fan

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.comixfan.com/xfan/
[Mod] Random Pic in vBulletin
« Reply #9 on: October 02, 2002, 08:53:08 AM »
Okay I tried adding the code to index.php and putting $randompic in a new side block on vbPortal but that didn't work, so I made a new PHP side block, included the entire code from the random_for_VB.txt file, and added echo $randompic; at the end but that only resulted in a parse error.

EDIT: The parse error is on the last line of the code...


$randompic 
"<a href=\"".SCRIPT_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br /><smallfont>Image Name: $image_name<br />Comments: $image_comments</smallfont>\n";


I'd really prefer to have the random image come up on my site's vbPortal front page, rather than the front page of the forums, but how can I do it?

And just to reask, how would I get the code to extract the category name for the random image chosen and display it as a link to the category underneath the random image's name?
Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
[Mod] Random Pic in vBulletin
« Reply #10 on: October 02, 2002, 12:53:22 PM »
sorry...

but i have no time to hack now my vb

to display category name
change query:
Code: [Select]

$sql = "SELECT 4images_images.image_id,4images_images.cat_id,4images_images.image_name,4images_categories.cat_name

after
Code: [Select]

$image_comments = $row['image_comments'];

add this
Code: [Select]

$cat_name = $row['cat_name'];

now add $cat_name anywhere at "$randompic="

or replace the "$randompic =":
to
Code: [Select]

$randompic = "<a href=\"".SCRIPT_URL."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br /><smallfont>Image Name: $image_name<br />Comments: $image_comments<br /><a href=\"".SCRIPT_URL."categories.php?cat_id=$cat_id\">".$cat_name."</a></smallfont>\n";


[EDIT:]
@X-Fan,

send me the file where you put the randompic code: nicky@nicky.net
i will look on it...
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 X-Fan

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.comixfan.com/xfan/
[Mod] Random Pic in vBulletin
« Reply #11 on: October 03, 2002, 05:31:56 PM »
Okay, some progress with getting a random pic in a side block on vbPortal.

What I did was to paste the code from the above text file into a php file (with <?php at the start and ?> at the end) and then uploaded it to my vbPortal includes directory.

I then created a new PHP block and edited the URL line to point to the php file in the includes directory.

The only problem with that is that the echo command has the image displayed right at the top of every vbPortals page above the header.  Now my question is how do I get it to display in the specified side block and only on the main vbPortal page, rather than above the header on every page?
Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
[Mod] Random Pic in vBulletin
« Reply #12 on: October 03, 2002, 05:43:26 PM »
i would try:

Code: [Select]

echo "<table><tr><td>$randompic</td></tr></table>";
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 X-Fan

  • Full Member
  • ***
  • Posts: 117
    • View Profile
    • http://www.comixfan.com/xfan/
[Mod] Random Pic in vBulletin
« Reply #13 on: October 03, 2002, 05:51:55 PM »
Quote from: Nicky
i would try:

Code: [Select]

echo "<table><tr><td>$randompic</td></tr></table>";


Wouldn't that just put it in a table at the top of the page above the header?
Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
[Mod] Random Pic in vBulletin
« Reply #14 on: October 03, 2002, 10:34:36 PM »
eric,

i don't know, just try it...
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