 |
 |
 |
 |
Registered: 05/17/12
Posts: 3
|
|
|
 |
 |
 |
 |
|
 |
 |
 |
 |
|
Express Hosting
"We are the official hosting company of UBB.threads. Ask us about our free migration services to migrate your UBB.threads installation."
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#1416 - 07/19/06 12:55 PM
Re: Problem with custom Portal boxes
[Re: Rick]
|
journeyman
|
Registered: 06/06/06
Posts: 95
Loc: Germany
|
|
<?php
<a href="http://www.ubbcentral.com">UBBCentral Webseite</a>
<br>
<a href="http://www.ubbcentral.com/order.php?product=UBB.threads">Preise / Bestellen</a>
<br>
<a href="http://www.infopop.com/members/members.php">UBB-Central Members Area</a>
?>
|
|
Top
|
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#1490 - 07/20/06 03:54 AM
Re: Problem with custom Portal boxes
[Re: Rick]
|
old hand
|
Registered: 06/05/06
Posts: 1142
Loc: Berlin, Germany
|
|
I try to convert a old pal box from threads6 IIP to UBB7 but encounter some trouble. The Box should pull pictures from my PhotoPost gallery and look like this:
require_once("/home/.../photopost.inc.php");
$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 );
}
$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\" />";
$featured .= <<<PPPRINT
<tr align="center"><td align="center" class="alt-1">
<a href="{$url_path}showphoto.php?photo={$pid}">$mthumb</a>
<br />by {$puser}
</td></tr>
PPPRINT;
$counted++;
}
if ( $counted == 5 ) break;
}
mysql_free_result($result);
echo <<<PPPRINT
$tbopen
<tr>
<td class="tdheader" colspan="5" align="center">
Featured Photos
</td>
</tr>
$featured
$tbclose<br />
PPPRINT;
mysql_select_db ("name of uub7 database")or die("Could not select database");
This script generate the output itself and I don't know how to split it to a php part and a output part. While playing with it I get some results but not as it should. The main problem seems to me, that I hafe to switch back to the ubb7 database after I do the selects from the photo database. This doesn't work as it should. Can you try to explain how this works in ubb7 as example for complex pal boxes?
|
|
Top
|
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#1539 - 07/20/06 02:53 PM
Re: Problem with custom Portal boxes
[Re: Zarzal]
|
old hand
|
Registered: 06/05/06
Posts: 1142
Loc: Berlin, Germany
|
|
Its done. If yo like, here the code for the PhotoPost Feature Box:
require_once("/your/path/to/photopost.inc.php");
$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 );
}
$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\" />";
$featured .= <<<PPPRINT
<tr align="center"><td align="center" class="alt-1">
<a href="{$url_path}showphoto.php?photo={$pid}">$mthumb</a>
<br />by {$puser}
</td></tr>
PPPRINT;
$counted++;
}
if ( $counted == 5 ) break;
}
mysql_free_result($result);
mysql_select_db ("dbname")or die("Could not select database");
$body = <<<PPPRINT
$featured
PPPRINT;
|
|
Top
|
|
|
|
|
 |
 |
 |
 |
|
|