[7.0] [Beta] PhotoPost featured photos pal - 07/30/2006 10:36 AM
This code is for the pal boxes in Threads7 (beta1). It pull 5 pictures (default random) from the PhotoPost database and display them in pal box.
You need to set the database names according to your setup. The script switch the database to make selects from the PhotoPost db and then switch back to Threads database. You need set the cache time (I use 5 minutes) and always build off ind the Threads7 control panel.
This script works without a PhotoPost Threads7 integration. It just take the pictures from the db.
The original is from Omegatron/Chuck S. for Threads 6.5x
You need to set the database names according to your setup. The script switch the database to make selects from the PhotoPost db and then switch back to Threads database. You need set the cache time (I use 5 minutes) and always build off ind the Threads7 control panel.
This script works without a PhotoPost Threads7 integration. It just take the pictures from the db.
The original is from Omegatron/Chuck S. for Threads 6.5x
PHP Code
// This script should pull 5 random pictures from
// PhotoPost and display it.
// Please modify the two lines with the databse
// connection to your settings.
//
// The base idea for this script comes from Chuck S. */
// Set it up to your path settings !
require_once("/home/..../ubbthreads/photopost.inc.php");
// Set this to your PhotoPost db prefix. Default is pp_
$pp_db_prefix = "pp_";
function pp_get_ext( $filename ) {
return substr($filename, strrpos($filename,"."));
}
function pp_is_image( $filename ) {
$retval = 0;
$mediatypes = array( ".jpg", ".gif", ".png", ".bmp" );
$ext = pp_get_ext( $filename );
if ( in_array(strtolower($ext), $mediatypes) )
$retval = 1;
return( $retval );
}
//
// Featured Photos Code
// Follow down to End Feature Photos Code
//
// which type of images do you want to show
$q_switch = "random";
switch ($q_switch) {
case "most_view":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY c.views DESC";
break;
case "lastest":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY date DESC";
break;
case "random":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY RAND()";
break;
}
$result = mysql_query($query);
$counted = 0; $featured = "";
while ( list($pid, $puser, $puserid, $pcat, $ptitle, $photo, $pviews) = mysql_fetch_array($result)) {
if ( pp_is_image($photo) ) {
$photolen = strlen($photo);
$theext = pp_get_ext($photo);
$photo_name = str_replace( $theext, "", $photo );
$temp_user = $line['userid'];
$thumbtag = "{$full_path}{$pcat}/thumbs/{$photo}";
$mthumb = "<img border="0" src="{$data_dir}{$pcat}/thumbs/{$photo}" alt="$thumbtag" />";
// One box for each feature
$featured .= <<<PPPRINT
<tr align="center"><td align="center" class="alt-1">
<a href="{$url_path}showphoto.php?photo={$pid}">$mthumb</a>
by {$puser}
</td></tr>
PPPRINT;
$counted++;
}
if ( $counted == 5 ) break;
}
mysql_free_result($result);
// change the dbname to your ubb7 database name
// we need to switch back to Threads7 database
mysql_select_db ("dbname")or die("Could not select database");
$body = <<<PPPRINT
$featured
PPPRINT;