Gallery Block for my phpBB portal - Page 2 Gallery Block for my phpBB portal - Page 2
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

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 1 Guest are viewing this topic.

apassio

I have implemented the code in http://forum.coppermine-gallery.net/index.php?topic=1196.msg6902#msg6902, see www.dophan.com.

However, I read and did notice that some random pictures coming up also belong to other users who have registered on my site (so also private pictures). This confirms that all pictures in the database are viewable by this script.

How can I limit the random showing to public albums only?

Thanks


Joachim Müller

The hack you refer to is based on ssi.php (a mod I built a long time ago) that doesn't take permissions into account (that's why I recommend not using it any longer, nor use any mods that are based on it). There's no easy fix - if you have privacy concerns, just don't use the hack, sorry.

Joachim

P.S. Any reason for posting a new thread instead of replying to the one you're refering to? Probably not, that's why I merged them.

cjaiz

I took the code that you have here and modified it a little.

1.  It looks for a random Album and it only will display albums that are available to everyone.
2. I have included variables at the start of the code to turn items on and off the variable will let you do the following:
       center phot (on/off)
       display random albums with random pictures (This only displays public albums)
       display random photo's (this will show all public and private files)
       you can link to the album itself or go to the index.php file to display all albums
       I have an include that pulls info from config.inc.php
     


<?php 
//
// Change the path to the location of your config.inc.php file
// example this is how my system is setup for the file structure
// /public_html/scripts/cpg131/include/config.inc.php
// the gallery_block.php is located in ths scripts directory
// if you place the script in the Copermine directory the line would look like this
// include ('include/config.inc.php');
// Hope this helps you out with the file name

include ('cpg131/include/config.inc.php');

// 
//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 
// *** example 
// *** http://www.yourdomain.com/scripts/cpg131/index.php is how you start your Photo Gallery
// ** then toy would put the folowinf in here /scripts/cpg131
//

$copperminepath '/scripts/cpg131';  //***YOU MUST CHANGE THIS*** 

//
// Set up version of Copermine for gallery_block
// you can find out the info in the include/config.inc.php
// check the line labeled $CONFIG['TABLE_PREFIX'] =                "get this info"
// once you have this the 
//
// Set center Var 
// Set Display Album Name above Photo
// 0 = no 
// 1 = yes 
//

$centvar "1"// This Variable sets the photo to Center
$albname "0"// This Variable sets the Album Name to appear above the Photo

//
// 0 = random album (this will only display albums that are viewable to the Everybody (Public Photo's)
// 1 = Random Pictures (This will display any file that has been approved Private or Public)
//
 
$allphoto "0"// This Variable set to choose Random Albmus or just Random Pictures 

//
// *************************************************************************
// DO NOT CHANGE ANYTHING BELOW THOS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
// *************************************************************************
//

//
// This sets variables from the config.inc.php file
//

$dbalbum "albums";
$dbpictures "pictures";

$cpgver_album $CONFIG['TABLE_PREFIX'].$dbalbum ;
$cpgver_pictures $CONFIG['TABLE_PREFIX'].$dbpictures ;
$host $CONFIG['dbserver'];
$username $CONFIG['dbuser'];
$userpass $CONFIG['dbpass'];
$cpgdb $CONFIG['dbname'];

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

$MZrandompic = @mysql_connect("$host""$username""$userpass"); //***YOU MUST CHANGE THIS*** 

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


// 
//select photo DB 
// 

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


//
// Select Databases to use
//

if ($allphoto == "0") {

$query1 "SELECT * FROM .$cpgver_album WHERE visibility = 0 ORDER BY RAND() LIMIT 0,1"
$result1 mysql_query($query1) or die("Query failed : " mysql_error()); 

//
// Assign Var from sql data base's 
//

while ($newarray mysql_fetch_array($result1)) {
$aid $newarray['aid'];
$title $newarray['title'];
if ($centvar == "1") echo ("<center>");
if ($albname == "1") {
echo ("<a target '_blank' href= '$copperminepath/thumbnails.php?album=$aid'>$title </a><br>");
if ($centvar == "1") echo ("</center>");
}
}
}
if (
$allphoto == "0") {
$query2 "SELECT * FROM .$cpgver_pictures WHERE aid = '$aid' ORDER BY RAND() LIMIT 0,1"
$result2 mysql_query($query2) or die("Query failed : " mysql_error()); 
}

if (
$allphoto == "1") {
$query2 "SELECT * FROM .$cpgver_pictures WHERE approved = 'YES' ORDER BY RAND() LIMIT 0,1"
$result2 mysql_query($query2) or die("Query failed : " mysql_error()); 
}

while (
$newarray1 mysql_fetch_array($result2)) {
$filepath $newarray1['filepath'];
$filename $newarray1['filename'];
if ($centvar == "1") echo ("<center>");
if ($allphoto == "0") {
echo ("<a target '_blank' href= '$copperminepath/thumbnails.php?album=$aid'>");
echo ("<img border='0' src= '$copperminepath/albums/$filepath/thumb_$filename' > </a>");
} else {
echo ("<a target '_blank' href= '$copperminepath/index.php'>");
echo ("<img border='0' src= '$copperminepath/albums/$filepath/thumb_$filename' > </a>");
}
if ($centvar == "1") echo ("</center>");
}

?>



uk_martin

Apologies for being a bit lost with PHP coding, so to those who know what they are doing this might sound a bit stupid...but...

I like the idea of having a most recent upload block in EXPortal, in the left hand side below the navigation block.

How is the portal_body.tpl edited to include the block?

Is it possible to have 2 - 4 thumbnails in a column down the side of the page rather than just one to represent the most recent (up to) 4 pics uploaded?

I assume that the coding given earlier is for a new PHP file to be created and uploaded in the forums root folder, or am I mistaken? Or is the portal.php file edited to add this code?

I installed coppermine first and then installed phpbb into the Coppermine database. Will this have an effect on any of the coding?

Joachim Müller

please keep in mind that there are only few phpbb experts around here - posting feature requests on what you want to accomplish with a non-coppermine application will probably go un-echoed. Ask this question in another way on the board that deals with phpbb or the mod you're refering to, like this: "How can I add custom php code to portal.php". In the best case, they'll tell you which place the code should go to. Then have a look at the rss feed or random image include mods, and paste the code into the place you have been told to use.

Joachim

cjaiz

I have figured this out if anyone else is intrested I did the following.

1. Installed eXtreme style mod can be found at http://www.phpbb.com/phpBB/viewtopic.php?t=125251 (this lets me place php code in the overall_header.tpl)

2. I wrote a php scripts that will pull photo thumbnails from coppermine I have tested it with 1.3.1 and 1.3.2 Here is the code.


gallery_block.php


<?php 
// 
// Change the path to the location of your config.inc.php file 
// example this is how my system is setup for the file structure 
// /public_html/scripts/cpg131/include/config.inc.php 
// the gallery_block.php is located in ths scripts directory 
// if you place the script in the Copermine directory the line would look like this 
// include ('include/config.inc.php'); 
// Hope this helps you out with the file name 

include ('cpg132/include/config.inc.php'); 

// 
//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 
// *** example 
// *** http://www.yourdomain.com/scripts/cpg131/index.php is how you start your Photo Gallery 
// ** then toy would put the folowinf in here /scripts/cpg131 
// 

$copperminepath '/scripts/cpg132';  //***YOU MUST CHANGE THIS*** 

// 
// Set center Var 
// Set Display Album Name above Photo 
// 0 = no 
// 1 = yes 
// 

$centvar "1"// This Variable sets the photo to Center 
$albname "0"// This Variable sets the Album Name to appear above the Photo 

// 
// 0 = random album (this will only display albums that are viewable to the Everybody (Public Photo's) 
// 1 = Random Pictures (This will display any file that has been approved Private or Public) 
// 
  
$allphoto "0"// This Variable set to choose Random Albmus or just Random Pictures 

// 
// This is to set the Visiabilty for the albums 
// 0 = Public Albums 
// 2 = Registered Users album 
// 

$viz "2"
// 
// ************************************************************************* 
// DO NOT CHANGE ANYTHING BELOW THOS LINE UNLESS YOU KNOW WHAT YOU ARE DOING 
// ************************************************************************* 
// 

// 
// This sets variables from the config.inc.php file 
// 

$dbalbum "albums"
$dbpictures "pictures"

$cpgver_album $CONFIG['TABLE_PREFIX'].$dbalbum 
$cpgver_pictures $CONFIG['TABLE_PREFIX'].$dbpictures 
$host $CONFIG['dbserver']; 
$username $CONFIG['dbuser']; 
$userpass $CONFIG['dbpass']; 
$cpgdb $CONFIG['dbname']; 

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

$MZrandompic = @mysql_connect("$host""$username""$userpass"); //***YOU MUST CHANGE THIS*** 

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


// 
//select photo DB 
// 

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


// 
// Select Databases to use 
// 

if ($allphoto == "0") { 

$query1 "SELECT * FROM .$cpgver_album WHERE visibility = '$viz' ORDER BY RAND() LIMIT 0,1"
$result1 mysql_query($query1) or die("Query failed : " mysql_error()); 

// 
// Assign Var from sql data base's 
// 

while ($newarray mysql_fetch_array($result1)) { 
   
$aid $newarray['aid']; 
   
$title $newarray['title']; 
   if (
$centvar == "1") echo ("<center>"); 
   if (
$albname == "1") { 
   echo (
"<a target '_blank' href= '$copperminepath/thumbnails.php?album=$aid'>$title </a><br>"); 
   if (
$centvar == "1") echo ("</center>"); 
   } 


if (
$allphoto == "0") { 
$query2 "SELECT * FROM .$cpgver_pictures WHERE aid = '$aid' ORDER BY RAND() LIMIT 0,1"
$result2 mysql_query($query2) or die("Query failed : " mysql_error()); 


if (
$allphoto == "1") { 
$query2 "SELECT * FROM .$cpgver_pictures WHERE approved = 'YES' ORDER BY RAND() LIMIT 0,1"
$result2 mysql_query($query2) or die("Query failed : " mysql_error()); 


while (
$newarray1 mysql_fetch_array($result2)) { 
   
$filepath $newarray1['filepath']; 
   
$filename $newarray1['filename']; 
   if (
$centvar == "1") echo ("<center>"); 
   if (
$allphoto == "0") { 
   echo (
"<a target '_blank' href= '$copperminepath/thumbnails.php?album=$aid'>"); 
   echo (
"<img border='0' src= '$copperminepath/albums/$filepath/thumb_$filename' > </a>"); 
   } else { 
   echo (
"<a target '_blank' href= '$copperminepath/index.php'>"); 
   echo (
"<img border='0' src= '$copperminepath/albums/$filepath/thumb_$filename' > </a>"); 
   } 
   if (
$centvar == "1") echo ("</center>"); 
   } 

?>





3. Then edited the overall_header.tpl file in phpBB Template directory with this code at the end of the script.



<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td width="20%"><?php 
include ('/home/location_of_the_script/public_html/scripts/gallery_block.php'); 
?>
</td>
    <td width="20%"><?php 
include ('/home/location_of_the_script/public_html/scripts/gallery_block.php'); 
?>
</td>
    <td width="20%"><?php 
include ('/home/location_of_the_script/public_html/scripts/gallery_block.php'); 
?>
</td>
    <td width="20%"><?php 
include ('/home/location_of_the_script/gallery_block.php'); 
?>
</td>
    <td width="20%"><?php 
include ('/home/location_of_the_script/gallery_block.php'); 
?>
</td>
  </tr>
</table>



you will need to replace /home/location_of_the_script/gallery_block.php with the location of the gallery_block.php script

I have optons added to the galley_block.php file so you can display all photo's and once clicked on it will take you to the copermine main page or you can select random albums based on the vis of the directory example if you only want to display albums that are public you need to set the $viz var to 0 and registered albums to 2 also you can display the album name above the photo. if you select random albums if you click on the photo it will take you to that album in copermine. there are other options in the script and it is comented so you can turn them on or off if you like. The script will also pull the database name username and password from copermine so you do not have to look this info up.

Hope this helps some people out I wrote this because I want to add a gallery to my phpbb with more features then smartor photo gallery and not to have to buy photopost.

uk_martin

Thanks for this, but I got the following error:

QuoteWarning: main(cpg132/include/config.inc.php): failed to open stream: No such file or directory in /home/ukmartin/public_html/forums/gallery_block.php on line 11

Warning: main(cpg132/include/config.inc.php): failed to open stream: No such file or directory in /home/ukmartin/public_html/forums/gallery_block.php on line 11

Warning: main(): Failed opening 'cpg132/include/config.inc.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php:/usr/local/cpanel/Cpanel') in /home/ukmartin/public_html/forums/gallery_block.php on line 11

Unable to locate the picture database at this time.

I created the GALLERY_BLOCK.PHP file as per your code, and put it in the root of the forum folder of www.ukmartin.com

I amended the OVERALL_HEADER.PHP file with this code, which reflects the paths to my files:

Quote<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
 <tr>
   <td width="20%"><?php
include ('/home/ukmartin/public_html/forums/gallery_block.php');
?></td>
   <td width="20%"><?php
include ('/home/ukmartin/public_html/forums/gallery_block.php');
?></td>
   <td width="20%"><?php
include ('/home/ukmartin/public_html/forums/gallery_block.php');
?></td>
   <td width="20%"><?php
include ('/home/ukmartin/public_html/forums/gallery_block.php');
?></td>
   <td width="20%"><?php
include ('/home/ukmartin/public_html/forums/gallery_block.php');
?></td>
 </tr>
</table>

Can you tell me where Ihave gone wrong?

Also, is it possible for something similar to be created to act as a block down the side of EZ Portal, (presumably needing the PORTAL_BODY.TPL file modding) so that some thumbnails (max width 125px each) can appear in a column down the side of the page?

Thanks

Martin

cjaiz

#27
Hello,

The error you are getting is a path issue error.  I looked at you website and you will need to edit line 11 on the gallery_block.php if I am not mastaken you will need to change the line to read as followed


include ('../coppermine/include/config.inc.php');


and also change the following code also in the gallery_block.php


$copperminepath = '/scripts/cpg132';  //***YOU MUST CHANGE THIS***


to the following:


$copperminepath = '/coppermine';  //***YOU MUST CHANGE THIS***


you can try this and let me know but I think this will solve the problem with the error you are getting if not let me know if you got it working or not.

Thank you and good luck.

richards

#28
[edit GauGau]nested quotes removed to make this thread more readible[/edit]
Quote from: DaMysterious on November 09, 2003, 11:38:14 PM...
man i have tried to get this to work so many times. Is there anyone to break this down for me? Where exactly to put ther username and password and stuff like that.

cynikalsam

I've been using the gallery_center_newest_block.php code on my phpbb index for a few weeks, and it works great. Right now i am in the process of re-designing the profile_viewbody.tpl, and i had an idea i was hoping one of you could help me with.

Since i have coppermine and phpbb integrated, each user has their own gallery. I think it would be cool to put a block of latest images (from their gallery only) on their profile. So, my latest uploads would appear on my profile, and your latest uploads would appear on your profile.

Would anyone know how to modify the code to accomplish this?  ???

Nibbler

You are using an absolute server path to the file. Use either a relative path ie. gallery/gallery_block.php or a full server path.

TexAcoon

In my code below, for some reason it will not show up on my portal at http://www.amadistrictii.org

<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catHead" align="center" height="20"><span class="genmed"><b>RANDOM PHOTOS</b>
</span></td></tr>
<tr>
<td class="row1" align="center"><span class="genmed" style="line-height=150%">
<?php include('/home/dwebmaster/domains/amadistrictii.org/public_html/amad2/gallery/gallery_block.php')?>
</span></td>
</tr>
</table>
<br />


However, making up a fake page called "port.php" at: http://www.amadistrictii.org/amad2/templates/subSilver/port.php  it works fine...
My gallery block is located at: http://www.amadistrictii.org/amad2/gallery/gallery_block.php

Any ideas as to why it does not post itself on the portal page? .. Thanks!

lsd_se

Quote from: cjaiz on September 17, 2004, 07:01:51 AM
I took the code that you have here and modified it a little.

1.  It looks for a random Album and it only will display albums that are available to everyone.
2. I have included variables at the start of the code to turn items on and off the variable will let you do the following:
        center phot (on/off)
        display random albums with random pictures (This only displays public albums)
        display random photo's (this will show all public and private files)
        you can link to the album itself or go to the index.php file to display all albums
        I have an include that pulls info from config.inc.php
       


<?php 
//
// Change the path to the location of your config.inc.php file
// example this is how my system is setup for the file structure
// /public_html/scripts/cpg131/include/config.inc.php
// the gallery_block.php is located in ths scripts directory
// if you place the script in the Copermine directory the line would look like this
// include ('include/config.inc.php');
// Hope this helps you out with the file name

include ('cpg131/include/config.inc.php');

// 
//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 
// *** example 
// *** http://www.yourdomain.com/scripts/cpg131/index.php is how you start your Photo Gallery
// ** then toy would put the folowinf in here /scripts/cpg131
//

$copperminepath '/scripts/cpg131';  //***YOU MUST CHANGE THIS*** 

//
// Set up version of Copermine for gallery_block
// you can find out the info in the include/config.inc.php
// check the line labeled $CONFIG['TABLE_PREFIX'] =                "get this info"
// once you have this the 
//
// Set center Var 
// Set Display Album Name above Photo
// 0 = no 
// 1 = yes 
//

$centvar "1"// This Variable sets the photo to Center
$albname "0"// This Variable sets the Album Name to appear above the Photo

//
// 0 = random album (this will only display albums that are viewable to the Everybody (Public Photo's)
// 1 = Random Pictures (This will display any file that has been approved Private or Public)
//
 
$allphoto "0"// This Variable set to choose Random Albmus or just Random Pictures 

//
// *************************************************************************
// DO NOT CHANGE ANYTHING BELOW THOS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
// *************************************************************************
//

//
// This sets variables from the config.inc.php file
//

$dbalbum "albums";
$dbpictures "pictures";

$cpgver_album $CONFIG['TABLE_PREFIX'].$dbalbum ;
$cpgver_pictures $CONFIG['TABLE_PREFIX'].$dbpictures ;
$host $CONFIG['dbserver'];
$username $CONFIG['dbuser'];
$userpass $CONFIG['dbpass'];
$cpgdb $CONFIG['dbname'];

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

$MZrandompic = @mysql_connect("$host""$username""$userpass"); //***YOU MUST CHANGE THIS*** 

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


// 
//select photo DB 
// 

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


//
// Select Databases to use
//

if ($allphoto == "0") {

$query1 "SELECT * FROM .$cpgver_album WHERE visibility = 0 ORDER BY RAND() LIMIT 0,1"
$result1 mysql_query($query1) or die("Query failed : " mysql_error()); 

//
// Assign Var from sql data base's 
//

while ($newarray mysql_fetch_array($result1)) {
$aid $newarray['aid'];
$title $newarray['title'];
if ($centvar == "1") echo ("<center>");
if ($albname == "1") {
echo ("<a target '_blank' href= '$copperminepath/thumbnails.php?album=$aid'>$title </a><br>");
if ($centvar == "1") echo ("</center>");
}
}
}
if (
$allphoto == "0") {
$query2 "SELECT * FROM .$cpgver_pictures WHERE aid = '$aid' ORDER BY RAND() LIMIT 0,1"
$result2 mysql_query($query2) or die("Query failed : " mysql_error()); 
}

if (
$allphoto == "1") {
$query2 "SELECT * FROM .$cpgver_pictures WHERE approved = 'YES' ORDER BY RAND() LIMIT 0,1"
$result2 mysql_query($query2) or die("Query failed : " mysql_error()); 
}

while (
$newarray1 mysql_fetch_array($result2)) {
$filepath $newarray1['filepath'];
$filename $newarray1['filename'];
if ($centvar == "1") echo ("<center>");
if ($allphoto == "0") {
echo ("<a target '_blank' href= '$copperminepath/thumbnails.php?album=$aid'>");
echo ("<img border='0' src= '$copperminepath/albums/$filepath/thumb_$filename' > </a>");
} else {
echo ("<a target '_blank' href= '$copperminepath/index.php'>");
echo ("<img border='0' src= '$copperminepath/albums/$filepath/thumb_$filename' > </a>");
}
if ($centvar == "1") echo ("</center>");
}

?>




where would I put this coding?
Thanks!

vuud


Hello,

Has anyone tried just implementing copperminefetch to do this?  I am not sure if it would work, but I don't see why it would not.  It only takes like three lines of php to implement.  If anyone has tried it and could not make it work, please let me know. 

http://cpmfetch.fistfullofcode.com or the thread in the mods forum here. 

If you do try it, go with the latest dev version (its gonna be stable by the end of March.

Vuud
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

Horizon

Error performing query: Table 'foto.cpg11d_pictures' doesn't exist
Where is the problem? ::)

Nibbler

Change cpg11d_ to the actual prefix you chose during installation.

ISBB

How hard would it be to do a SINGLE Random image in Smartors Portal... I only want one maybe 2 at the most... i was looking at VUUD's Fetch thing and was wondering how well that would work w/ the portal.. and being able to change the layout of the pictures would be cool too but im just simply looking for one..
Its gaurunteed.. until it breaks

Lifted trucks are like boob jobs, no matter what size shape or dimension they are always fun to look at.

Texan78

I have smartors now for my phpBB Plus and im getting rid of it for a block that will complement my coppermine gallery. I have the script for it if anyone can help me with putting a block on my portal for my cpg.

Texan78

Ok im getting this error when trying the first code listed in this thread. What am i missing?

Error performing query: Table 'texascam_gallery.cpg11d_pictures' doesn't exist

Texan78

Ok have thinking for some time i figured out that the 'texascam_gallery.cpg11d_pictures'  was a table in my DB i just changed it to 'texascam_gallery.cpg132_pictures'  to match my DB. Now when i click on the Album link on the block it takes me to a solid white screen with one picture on it and the catagory below it and then this message:

"Unable to reload the main website database at this time."

Also it doesnt show a random pic in the block. Now im stuck and dont know where to go from here. Any help would be great.