Gallery Block for my phpBB portal Gallery Block for my phpBB portal
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Gallery Block for my phpBB portal

Started by DaMysterious, November 01, 2003, 06:11:29 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

DaMysterious

On my phpBB portal I like to have a CPG-Gallery Block like on my nuked site. How to realise this. Something I tryed the last days does'nt work, also ssi.php wil not work for me when including any code from example.php into my portal.tpl. Problem seems to be the *.tpl from the phpBB templates. My phpBB and coppermine databases are locatet in different bases, I know that I have to call the CPG database first but have no idea as I'm not very good in programming php. Anyone a hint how to create/realise a new/random picblock on my phpBB frontpage?
DaMysterious.

Zarsky

you could try this terribly written code I hacked up on the old board...I still use it and it works for me...

Original thread:
http://coppermine.sourceforge.net/oldboard/viewtopic.php?t=1106&highlight=random

my latest code:

<?php 

//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 

$copperminepath '/photo_album';  //***YOU MUST CHANGE THIS*** 

//This connects to the mysql DB 
//***change username and password below*** 

$MZrandompic = @mysql_connect('localhost''user''passwd'); //***YOU MUST CHANGE THIS*** 

if (!$MZrandompic) { 
echo( 
'<p>Unable to connect to the ' 
'database server at this time.</p>' ); 
exit(); 


//select photo DB 
//***YOU MUST CHANGE THIS*** 

if (! @mysql_select_db('coppermine_database') ) {
die( 
'<p>Unable to locate the picture ' 
'database at this time.</p>' ); 


//This gets a random picture record from the database and 
//the picture's location and displays it 

$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY RAND() LIMIT 0,1"); 
if (!
$MZresult) { 
die(
'<p>Error performing query: ' mysql_error() . 
'</p>'); 


while ( 
$MZrow mysql_fetch_array($MZresult) ) { 

$albumid $MZrow['aid'];  //This gets the picture's associated album name 
$pos $MZrow['pid'];      //This finds the picture's coppermine location

echo('<P ALIGN=center>'); 

echo(
'<a target = "_new" href="' $copperminepath '/displayimage.php?album=' $albumid 
'&pos=-' $pos '">'); //make thumbnail clickable 

echo('<IMG SRC="' $copperminepath '/albums/');           //append base dir structure 
echo($MZrow['filepath'].thumb_.$MZrow['filename'] .
     
'" alt=' $MZrow['filename'] . ' ''border=0>' '</a>'); //outputs path from /userspics 


//This displays the picture's album name and 
//links it to the coppermine album 

$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'"); 
if (!
$MZalbumresult) { 
die(
'<p>Error performing query: ' mysql_error() . 
'</p>'); 


while ( 
$MZalbumname mysql_fetch_array($MZalbumresult) ) { 
//echo('<FONT SIZE=2>'); 
echo('<P ALIGN=center>'); 

echo(
'<a href="' $copperminepath 
'/thumbnails.php?album=' $albumid '">' 
$MZalbumname['title'] . '</a>' '</p>'); 


if (! @
mysql_select_db('main_website_DB') ) { 
die( 
'<p>Unable to reload the main website ' 
'database at this time.</p>' ); 


?>
Read the Online DOCs, FAQ, and SEARCH the board BEFORE posting questions for help.

DaMysterious

Quote from: "zarsky99"you could try this terribly written code I hacked up on the old board...I still use it and it works for me...

Original thread:
http://coppermine.sourceforge.net/oldboard/viewtopic.php?t=1106&highlight=random

my latest code:


Cooooool it works. Thanks Zarsky99! Do you have any suggestion how to place the tumbs (I wil show 4-6) in a row? Now they are displayed in a culumn. Next question, how to filter out some specific groups (porn)?
DaMysterious.

Inertia

I have a really silly question - but I am struggling with this! It's exactly what I am looking for.

My forum - http://www.alucinae.com/dystopia (phpbb)

I don't use a portal, but I do have a side nav bar, where I really want to display the latest image.

I have tried ssi.php and couldn't get it to work. I thought I'd try this script, and on its own it works great. However, how do I place this script into the TPL file where my side nav is?

If you take a look at the site now - you'll see i have a section for "the galleries" - it is supposed to display the images there.

Any help would be great!

DaMysterious

Quote from: "Inertia"I have a really silly question - but I am struggling with this! It's exactly what I am looking for.

My forum - http://www.alucinae.com/dystopia (phpbb)

I don't use a portal, but I do have a side nav bar, where I really want to display the latest image.

I have tried ssi.php and couldn't get it to work. I thought I'd try this script, and on its own it works great. However, how do I place this script into the TPL file where my side nav is?

If you take a look at the site now - you'll see i have a section for "the galleries" - it is supposed to display the images there.

Any help would be great!


Ok here we go:

In your case create a file e.g 'gallery_side_random_block.php' in you coppermine dir, put the code below in it and change the path to your '/gallery' and correct the connection to your mySql database, further you could change the number of dispayed thumbs with 'LIMIT 0,4' on row 30 to the amount you like. Now there are random 4 thumbs vertically displayed.


<?php  

//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 

$copperminepath '/gallery';  //***YOU MUST CHANGE THIS*** 

//This connects to the mysql DB 
//***change username and password below*** 

$MZrandompic = @mysql_connect('localhost''root'''); //***YOU MUST CHANGE THIS*** 

if (!$MZrandompic) {  
echo( 
'<p>Unable to connect to the ' .  
'database server at this time.</p>' );  
exit();  
}  

//select photo DB 
//***YOU MUST CHANGE THIS*** 

if (! @mysql_select_db('coppermine') ) { 
die( 
'<p>Unable to locate the picture ' .  
'database at this time.</p>' );  
}  

//This gets a random picture record from the database and 
//the picture's location and displays it 

$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY RAND() LIMIT 0,4");  
if (!
$MZresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'</p>');  
}  

while ( 
$MZrow mysql_fetch_array($MZresult) ) {  

// $albumid = $MZrow['aid'];  //This gets the picture's associated album name 
$pos $MZrow['pid'];      //This finds the picture's coppermine location 

echo('<P ALIGN=center>');  

echo(
'<a target = "_new" href="' $copperminepath '/displayimage.php?album=' $albumid .  
'&pos=-' $pos '">'); //make thumbnail clickable 

echo('<IMG SRC="' $copperminepath '/albums/');           //append base dir structure 
echo($MZrow['filepath'].thumb_.$MZrow['filename'] . 
     
'" alt=' $MZrow['filename'] . ' ''border=0 width=80 height=50>' '</a>'); //outputs path from /userspics 
}  

//This displays the picture's album name and 
//links it to the coppermine album 

$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");  
if (!
$MZalbumresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'</p>');  
}  

while ( 
$MZalbumname mysql_fetch_array($MZalbumresult) ) {  
echo(
'<FONT SIZE=1>'); 
echo(
'<P ALIGN=center>');  

echo(
'<a href="' $copperminepath .  
'/thumbnails.php?album=' $albumid '">' .  
$MZalbumname['title'] . '</a>' '</p>');  
}  

if (! @
mysql_select_db('coppermine') ) {  
die( 
'<p>Unable to reload the main website ' .  
'database at this time.</p>' );  
}  

?>



Go to your sidenav.tpl and add the code below to your table/block 'my gallery' section (change to he right path).


<?php include("/inetpub/coppermine/gallery_side_random_block.php");>


Note: Normally a php-call wil not run from any .tpl inside phpBB so you have to look for the 'eXtreme Styles mod' from Vjacheslav Trushkin

Have success.


For other codefreaks I change the code from zarsky99 to a set of different center-blocks to use within *.tpl they all display horizontally.

1) gallery_center_newest_block.php

<?php  

//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 

$copperminepath '/gallery';  //***YOU MUST CHANGE THIS*** 

//This connects to the mysql DB 
//***change username and password below*** 

$MZrandompic = @mysql_connect('localhost''root'''); //***YOU MUST CHANGE THIS*** 

if (!$MZrandompic) {  
echo( 
'<p>Unable to connect to the ' .  
'database server at this time.</p>' );  
exit();  
}  

//select photo DB 
//***YOU MUST CHANGE THIS*** 

if (! @mysql_select_db('coppermine') ) { 
die( 
'<p>Unable to locate the picture ' .  
'database at this time.</p>' );  
}  

//This gets a random picture record from the database and 
//the picture's location and displays it 

$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY pid DESC LIMIT 0,6");  
if (!
$MZresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'</p>');  
}  

while ( 
$MZrow mysql_fetch_array($MZresult) ) {  

// $albumid = $MZrow['aid'];  //This gets the picture's associated album name 
$pos $MZrow['pid'];      //This finds the picture's coppermine location 

// echo('<P ALIGN=center>');  

echo('<a target = "_new" href="' $copperminepath '/displayimage.php?album=' $albumid .  
'&pos=-' $pos '">'); //make thumbnail clickable 

echo('<IMG SRC="' $copperminepath '/albums/');           //append base dir structure 
echo($MZrow['filepath'].thumb_.$MZrow['filename'] . 
     
'" alt=' $MZrow['filename'] . ' ''border=0 width=60 height=50>' '</a> &nbsp;&nbsp;'); //outputs path from /userspics 
}  

//This displays the picture's album name and 
//links it to the coppermine album 

$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");  
if (!
$MZalbumresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'</p>');  
}  

while ( 
$MZalbumname mysql_fetch_array($MZalbumresult) ) {  
echo(
'<FONT SIZE=1>'); 
echo(
'<P ALIGN=center>');  

echo(
'<a href="' $copperminepath .  
'/thumbnails.php?album=' $albumid '">' .  
$MZalbumname['title'] . '</a>' '</p>');  
}  

if (! @
mysql_select_db('coppermine') ) {  
die( 
'<p>Unable to reload the main website ' .  
'database at this time.</p>' );  
}  

?>



2) gallery_center_random_block.php

<?php  

//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 

$copperminepath '/gallery';  //***YOU MUST CHANGE THIS*** 

//This connects to the mysql DB 
//***change username and password below*** 

$MZrandompic = @mysql_connect('localhost''root'''); //***YOU MUST CHANGE THIS*** 

if (!$MZrandompic) {  
echo( 
'<p>Unable to connect to the ' .  
'database server at this time.</p>' );  
exit();  
}  

//select photo DB 
//***YOU MUST CHANGE THIS*** 

if (! @mysql_select_db('coppermine') ) { 
die( 
'<p>Unable to locate the picture ' .  
'database at this time.</p>' );  
}  

//This gets a random picture record from the database and 
//the picture's location and displays it 

$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY RAND() LIMIT 0,6");  
if (!
$MZresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'</p>');  
}  

while ( 
$MZrow mysql_fetch_array($MZresult) ) {  

// $albumid = $MZrow['aid'];  //This gets the picture's associated album name 
$pos $MZrow['pid'];      //This finds the picture's coppermine location 

// echo('<P ALIGN=center>');  

echo('<a target = "_new" href="' $copperminepath '/displayimage.php?album=' $albumid .  
'&pos=-' $pos '">'); //make thumbnail clickable 

echo('<IMG SRC="' $copperminepath '/albums/');           //append base dir structure 
echo($MZrow['filepath'].thumb_.$MZrow['filename'] . 
     
'" alt=' $MZrow['filename'] . ' ''border=0 width=60 height=50>' '</a> &nbsp;&nbsp;'); //outputs path from /userspics 
}  

//This displays the picture's album name and 
//links it to the coppermine album 

$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");  
if (!
$MZalbumresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'</p>');  
}  

while ( 
$MZalbumname mysql_fetch_array($MZalbumresult) ) {  
echo(
'<FONT SIZE=1>'); 
echo(
'<P ALIGN=center>');  

echo(
'<a href="' $copperminepath .  
'/thumbnails.php?album=' $albumid '">' .  
$MZalbumname['title'] . '</a>' '</p>');  
}  

if (! @
mysql_select_db('coppermine') ) {  
die( 
'<p>Unable to reload the main website ' .  
'database at this time.</p>' );  
}  

?>



gallery_center_toprated_block.php

<?php  

//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 

$copperminepath '/gallery';  //***YOU MUST CHANGE THIS*** 

//This connects to the mysql DB 
//***change username and password below*** 

$MZrandompic = @mysql_connect('localhost''root'''); //***YOU MUST CHANGE THIS*** 

if (!$MZrandompic) {  
echo( 
'<p>Unable to connect to the ' .  
'database server at this time.</p>' );  
exit();  
}  

//select photo DB 
//***YOU MUST CHANGE THIS*** 

if (! @mysql_select_db('coppermine') ) { 
die( 
'<p>Unable to locate the picture ' .  
'database at this time.</p>' );  
}  

//This gets a random picture record from the database and 
//the picture's location and displays it 

$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY pic_rating desc LIMIT 0,6");  
if (!
$MZresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'</p>');  
}  

while ( 
$MZrow mysql_fetch_array($MZresult) ) {  

// $albumid = $MZrow['aid'];  //This gets the picture's associated album name 
$pos $MZrow['pid'];      //This finds the picture's coppermine location 

// echo('<P ALIGN=center>');  

echo('<a target = "_new" href="' $copperminepath '/displayimage.php?album=' $albumid .  
'&pos=-' $pos '">'); //make thumbnail clickable 

echo('<IMG SRC="' $copperminepath '/albums/');           //append base dir structure 
echo($MZrow['filepath'].thumb_.$MZrow['filename'] . 
     
'" alt=' $MZrow['filename'] . ' ''border=0 width=60 height=50>' '</a> &nbsp;&nbsp;'); //outputs path from /userspics 
}  

//This displays the picture's album name and 
//links it to the coppermine album 

$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");  
if (!
$MZalbumresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'</p>');  
}  

while ( 
$MZalbumname mysql_fetch_array($MZalbumresult) ) {  
echo(
'<FONT SIZE=1>'); 
echo(
'<P ALIGN=center>');  

echo(
'<a href="' $copperminepath .  
'/thumbnails.php?album=' $albumid '">' .  
$MZalbumname['title'] . '</a>' '</p>');  
}  

if (! @
mysql_select_db('coppermine') ) {  
die( 
'<p>Unable to reload the main website ' .  
'database at this time.</p>' );  
}  

?>



gallery_center_topview_block.php

<?php  

//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 

$copperminepath '/gallery';  //***YOU MUST CHANGE THIS*** 

//This connects to the mysql DB 
//***change username and password below*** 

$MZrandompic = @mysql_connect('localhost''root'''); //***YOU MUST CHANGE THIS*** 

if (!$MZrandompic) {  
echo( 
'<p>Unable to connect to the ' .  
'database server at this time.</p>' );  
exit();  
}  

//select photo DB 
//***YOU MUST CHANGE THIS*** 

if (! @mysql_select_db('coppermine') ) { 
die( 
'<p>Unable to locate the picture ' .  
'database at this time.</p>' );  
}  

//This gets a random picture record from the database and 
//the picture's location and displays it 

$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY hits desc LIMIT 0,6");  
if (!
$MZresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'</p>');  
}  

while ( 
$MZrow mysql_fetch_array($MZresult) ) {  

// $albumid = $MZrow['aid'];  //This gets the picture's associated album name 
$pos $MZrow['pid'];      //This finds the picture's coppermine location 

// echo('<P ALIGN=center>');  

echo('<a target = "_new" href="' $copperminepath '/displayimage.php?album=' $albumid .  
'&pos=-' $pos '">'); //make thumbnail clickable 

echo('<IMG SRC="' $copperminepath '/albums/');           //append base dir structure 
echo($MZrow['filepath'].thumb_.$MZrow['filename'] . 
     
'" alt=' $MZrow['filename'] . ' ''border=0 width=60 height=50>' '</a> &nbsp;&nbsp;'); //outputs path from /userspics 
}  

//This displays the picture's album name and 
//links it to the coppermine album 

$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");  
if (!
$MZalbumresult) {  
die(
'<p>Error performing query: ' mysql_error() .  
'</p>');  
}  

while ( 
$MZalbumname mysql_fetch_array($MZalbumresult) ) {  
echo(
'<FONT SIZE=1>'); 
echo(
'<P ALIGN=center>');  

echo(
'<a href="' $copperminepath .  
'/thumbnails.php?album=' $albumid '">' .  
$MZalbumname['title'] . '</a>' '</p>');  
}  

if (! @
mysql_select_db('coppermine') ) {  
die( 
'<p>Unable to reload the main website ' .  
'database at this time.</p>' );  
}  

?>

DaMysterious.

Inertia

Thank you so much! I shall give that a try as soon as i get home from work tonight!

-Fingers crossed!-

:)

Zarsky

DaMysterious,

Great addition to my code.  Also...I want to point out to everyone that this code DOES NOT obey permissions set within the gallery.  If I get some time perhaps I will tray to add some permission checking, but I do not think this will be easily accomplished. I was thinking the only way it will work is if you are using some form of BBS integration.  Anyone have any ideas?
Read the Online DOCs, FAQ, and SEARCH the board BEFORE posting questions for help.

Inertia

Thank you thank you so much!

It works great now, especially after I downloaded the X-treme mod.

I actually had the code in the TPL file from yesterday, and after I uploaded the mod, it worked immediately without creating a "file.php". I just have the code right in the main TPL file.

Its exactly what I needed!

Thanks again! :)

TheNakedMan

what if I wanted to have 4-5 random pics like this or newest on the main forum page.  

What would I change?
Are you naked?  More importantly, do you want to be?

Valerie

Hi, I was wondering how the password & username are protected from being seen in these files. (I'm learning - but my knowledge is still limited.)

 These codes really looks like what I want. They work fine in regular php files, correct? What if I want to put more than one random pic on my main page but keep them in a scroll box so they only take up a certain amount of room on the page - just set a basic scroll box around it? My memory isn't the best - anyone mind slapping that code here for reference? (Just asking)

Also, is there a way to control the thumbnail size that shows up with this code? Thank you!

Joachim Müller

Passwords are not stored within files, but in the mySQL db, no need to worry about that.

GauGau

gmarik

How much this is phpBB revelant and could it be suded with some modificatoins over vBulletin 3.0? Ady idea?!  :shock:

DesiFlavour

Hey guys, excellent feature!

Ive managed to get that page working fine, only problem now is how do i place it on the portal.

I would if possble like to replace it with the top announcement table in the middle of the portal as it displays 5 most recent ones which is abit too many anyway.

If not then can you tell me how i can just plce the random pic table just below the welcome table in the middle.

As in what code do i need to include in the portal_body.tpl or portal.php.

I've got a rough idea so if you can just guide be please  :)

Thank you, would very much appreciate your help!  :)

laziale4ever

Thanks guys for the great feature..

I just made a tiny addition to the newest pics.. when you require the admin approval for some uploads.. So, it wont display pictures before approving them.

in the original code:

$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY pid DESC LIMIT 0,6");  

my edited code:

$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures WHERE approved = 'YES' ORDER BY pid DESC LIMIT 0,6");  

r4merlin

QuoteHey guys, excellent feature!

Ive managed to get that page working fine, only problem now is how do i place it on the portal.

I would if possble like to replace it with the top announcement table in the middle of the portal as it displays 5 most recent ones which is abit too many anyway.

If not then can you tell me how i can just plce the random pic table just below the welcome table in the middle.

As in what code do i need to include in the portal_body.tpl or portal.php.

I've got a rough idea so if you can just guide be please  

Thank you, would very much appreciate your help!

Same where could you explain that  part of it

sdalgleish

I've just been playing with this.  I had a little trouble getting it started because it kept telling me that 'thumb_' was not a defined constant.  The solution is to:

Replace
echo('<IMG SRC="' . $copperminepath . '/albums/');           //append base dir structure
echo($MZrow['filepath'].thumb_.$MZrow['filename'] .
     '" alt=' . $MZrow['filename'] . ' '. 'border=0>' . '</a>'); //outputs path from /userspics


with
echo('<IMG SRC="' . $copperminepath . '/albums/');           //append base dir structure
echo($MZrow['filepath']. 'thumb_' .$MZrow['filename'] .
     '" alt=' . $MZrow['filename'] . ' '. 'border=0 align=center>' . '</a>'); //outputs path from /userspics


All that is changed is putting single quote (') around the word thumb_ so that it's a string and not a constant.  Seems to work for me now.  Hope that's useful to someone.

Nice mod zarsky99 - I like it!

futtlui

just a question: i'm new to this portal stuff but i'd like to have one soon for my phpbb.
of course it should include a block with pictures of my existing coppermine gallery.

Does it matter, which portal i choose?
About which one are you talking about in this thread?
Smartor's ezPortal? AWSW's Portal? Another one?

BTW I don't want to use nuke or one of these big cms-things.

TIA
futtlui

aem

I tried this script and when i run it it went to a page with this

QuoteUnable to connect to the database server at this time.

What could i be doing wrong?

DaMysterious

Quote from: futtlui on April 15, 2004, 09:15:53 PM
just a question: i'm new to this portal stuff but i'd like to have one soon for my phpbb.
of course it should include a block with pictures of my existing coppermine gallery.

Does it matter, which portal i choose?
About which one are you talking about in this thread?
Smartor's ezPortal? AWSW's Portal? Another one?

BTW I don't want to use nuke or one of these big cms-things.

TIA
futtlui

I did talk about Smartor's EZ-Portal. But the codes should work in other evironments also.
DaMysterious.

evildave

First post....

My site is not a phpBB portal just a standard php site. I just wanted to say thanks. I've been looking for a hack like this. I have coppermine installed on a different server then my website and this hack works great  :)

I'm just getting started with my site but heres the link if you want to check it out.
site: http://evildave.jaywebdesigns.com

Thanks again.