4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 19, 2018, 11:15:06 PM

Login with username, password and session length
Search:     Advanced search
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Releases & Support) (Moderators: mawenzi, Rembrandt)
| | |-+  [Mod] Random Pic in vBulletin - Update: 25.01.2008
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 3 » »» Print
This topic has not yet been rated!
Author Topic: [Mod] Random Pic in vBulletin - Update: 25.01.2008  (Read 45748 times)
Nicky
Administrator
4images Guru
*****
Offline Offline

Posts: 3195

Thank You
-Given: 26
-Receive: 57


View Profile
« on: August 31, 2002, 10:34:00 PM »

Update: 25.01.2008
vBulletin Version 3.6.8 and 4images 1.7.4

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

1.)
 English open
 Deutsch öffne
vBulletin global.php (  English not /  Deutsch nicht admin/global.php)

 English search  Deutsch suche

 English add before  Deutsch vordem füge dies
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 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)
 English if you want to use it with more than one pic the use this code
 Deutsch wenn du es mit mehr bildern benutzen willst benutzen diesen code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 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.)
 English in mod self change  Deutsch 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.)
 English now you can use $randompic in every VB template
 Deutsch jetzt kannst du $randompic in jedem VB template benützen

3.a)
 English
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!)
 Deutsch
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!)


 English that's it.... have fun
 Deutsch das ist alles.... viel spass
« Last Edit: January 25, 2008, 04:31:03 PM by Nicky » Logged

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
X-Fan
Full Member
***
Offline Offline

Posts: 117

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #1 on: September 01, 2002, 10:20:21 AM »

Will this also work with vBulletin 2.2.5 or 2.2.6?
Logged

Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k
goyo
Newbie
*
Offline Offline

Posts: 18

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #2 on: September 01, 2002, 11:00:38 AM »

Quote from: X-Fan   [Expand]
Will this also work with vBulletin 2.2.5 or 2.2.6?


 Yes It works...   Smile
Logged
X-Fan
Full Member
***
Offline Offline

Posts: 117

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« 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.
Logged

Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k
Nicky
Administrator
4images Guru
*****
Offline Offline

Posts: 3195

Thank You
-Given: 26
-Receive: 57


View Profile
« 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
Logged

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
Nicky
Administrator
4images Guru
*****
Offline Offline

Posts: 3195

Thank You
-Given: 26
-Receive: 57


View Profile
« 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..
Logged

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
Elanor
Newbie
*
Offline Offline

Posts: 13

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #6 on: September 25, 2002, 05:23:15 AM »

Works like a charm =) Great Add on
Logged

X-Fan
Full Member
***
Offline Offline

Posts: 117

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« 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?
Logged

Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k
Quackie
Pre-Newbie

Offline Offline

Posts: 9

Thank You
-Given: 0
-Receive: 0


View Profile
« 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
Logged
X-Fan
Full Member
***
Offline Offline

Posts: 117

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« 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...

1
2

$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?
Logged

Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k
Nicky
Administrator
4images Guru
*****
Offline Offline

Posts: 3195

Thank You
-Given: 26
-Receive: 57


View Profile
« 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:
1
2

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

after
1
2

$image_comments = $row['image_comments'];

add this
1
2

$cat_name = $row['cat_name'];

now add $cat_name anywhere at "$randompic="

or replace the "$randompic =":
to
1
2

$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...
Logged

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
X-Fan
Full Member
***
Offline Offline

Posts: 117

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« 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?
Logged

Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k
Nicky
Administrator
4images Guru
*****
Offline Offline

Posts: 3195

Thank You
-Given: 26
-Receive: 57


View Profile
« Reply #12 on: October 03, 2002, 05:43:26 PM »

i would try:

1
2

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

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
X-Fan
Full Member
***
Offline Offline

Posts: 117

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #13 on: October 03, 2002, 05:51:55 PM »

Quote from: Nicky   [Expand]
i would try:

1
2

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?
Logged

Eric J. Moreels
ComiX-Fan Editor-in-Chief
e-mail: webmaster@comixfan.cjb.net
Web: http://www.comixfan.com/xfan
AIM: XFan2k
Nicky
Administrator
4images Guru
*****
Offline Offline

Posts: 3195

Thank You
-Given: 26
-Receive: 57


View Profile
« Reply #14 on: October 03, 2002, 10:34:36 PM »

eric,

i don't know, just try it...
Logged

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
Pages: [1] 2 3 » »» Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.14 seconds with 19 queries.