Hi Cellarius - sorry, I don't know how I missed your post.
Yes, Photopost Featured Photos on Forumhome - Doh!!! I did warn you I am dim. However , no code resembling yours within it I'm afraid.
Code:
require $vbulletin->options['pppath'].'/config-int.php';
$dbhost = $vbulletin->options['dbhost'];
$dbuser = $vbulletin->options['dbuser'];
$dbpass = $vbulletin->options['dbpass'];
$dbname = $vbulletin->options['db1'];
$link = mysql_connect ("$dbhost", "$dbuser", "$dbpass") or die('I cannot connect to the database.');
mysql_select_db ("$dbname")or die("Could not select photopost database");
// Number of photos to display
$num_display = 4;
// Number of columns (1 for vertical)
$columns = 4;
// which type of images do you want to show (random, most_view, latest)
$q_switch = "random";
// == END CONFIGURATION ==
////////////////////////////////////////////////////////////////////////////
if ( !isset($ViewPerm) )
{
if ( isset($bbuserinfo['usergroupid']) )
{
$mygroups = $bbuserinfo['usergroupid'];
if ( $bbuserinfo['membergroupids'] != "" )
{
$mygroups .= ",".$bbuserinfo['membergroupids'];
}
}
else
{
// vB3.5 uses $vbulletin
$mygroups = $vbulletin->userinfo['usergroupid'];
if ( $vbulletin->userinfo['membergroupids'] != "" )
{
$mygroups .= ",".$vbulletin->userinfo['membergroupids'];
}
}
$grouparr = explode( ",", $mygroups );
$resultb = mysql_query("SELECT id,ugnoview,password FROM {$pp_db_prefix}categories");
$ViewPerm = array();
while ( list( $catugid, $ugnoview, $catugpass ) = mysql_fetch_row($resultb) )
{
$noview=0;
$ViewPerm[$catugid] = 1;
$allnoview = explode( ",", $ugnoview );
foreach ($allnoview as $key)
{
if (in_array($key, $grouparr) )
{
$noview = 1;
}
}
if ( $noview == 0 && $catugpass == "" )
{
$ViewPerm[$catugid]=0;
}
}
}
$resultc = mysql_query("SELECT setting FROM {$pp_db_prefix}settings WHERE id=133");
list( $seotype ) = mysql_fetch_row($resultc);
$resultd = mysql_query("SELECT setting FROM {$pp_db_prefix}settings WHERE id=6");
list( $data_full ) = mysql_fetch_row($resultd);
//
// Featured Photos Code
// Follow down to End Feature Photos Code
//
switch ($q_switch)
{
case "most_view":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.bigimage,p.title,c.catname,c.photos,c.posts
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id = p.cat
WHERE p.storecat = 0 AND p.approved = 1 AND p.ismature = 0
ORDER BY views DESC LIMIT 25";
break;
case "latest":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.bigimage,p.title,c.catname,c.photos,c.posts
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id = p.cat
WHERE p.storecat = 0 AND p.approved = 1 AND p.ismature = 0
ORDER BY date DESC LIMIT 25";
break;
default:
$query = "SELECT p.id,p.user,p.userid,p.cat,p.bigimage,p.title,c.catname,c.photos,c.posts
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id = p.cat
WHERE p.storecat = 0 AND p.approved = 1 AND p.ismature = 0
ORDER BY RAND() LIMIT 25";
}
$result = mysql_query($query) or die(mysql_error());
$counted = 0;
$countcol = 0;
$pppro_imagebits = null;
while (list($pid,$puser,$puserid,$pcat,$photo,$ptitle,$catname,$cphotos,$cposts) = mysql_fetch_row($result))
{
if ( $seotype == "seo" )
{
$seocatname = photourlsafe( $catname );
$ptitle = photourlsafe( $ptitle );
}
if ( photo_is_image($photo)|| photo_is_multimedia($photo) )
{
if ( $ViewPerm[$pcat] == 1 )
{
continue;
}
if ( photo_is_image($photo) )
{
if ( $seotype == "seo" )
{
$plink = "<td><a href=\"{$url_path}/$catname/p{$pid}-{$ptitle}.html\"><img src=\"{$data_dir}/{$pcat}/thumbs/$photo\" border=\"0\" alt=\"\" /></a></td>";
$catlink = "<a href=\"{$url_path}/g{$pcat}-{$seocatname}.html\">$catname</a><br />";
}
else
{
$plink = "<td><a href=\"{$url_path}/showphoto.php?photo={$pid}\"><img src=\"{$data_dir}/{$pcat}/thumbs/$photo\" border=\"0\" alt=\"\" /></a></td>";
$catlink = "<a href=\"{$url_path}/showgallery.php?cat={$pcat}\">$catname</a><br />";
}
}
if ( photo_is_multimedia($photo) )
{
$filenoext = photo_get_filename( $photo );
$mmthumb = "{$data_dir}/$pcat/thumbs/$filenoext.jpg";
$dirthumb = "{$data_full}/$pcat/thumbs/$filenoext.jpg";
if ( !file_exists($dirthumb) )
{
$mmthumb = "{$url_path}/images/video.gif";
}
if ( $seotype == "seo" )
{
$plink = "<td><a href=\"{$url_path}/$catname/p{$pid}-{$ptitle}.html\"><img src=\"{$mmthumb}\" border=\"0\" alt=\"\" /></a></td>";
$catlink = "<a href=\"{$url_path}/g{$pcat}-{$catname}.html\">$catname</a><br />";
}
else
{
$plink = "<td><br /><a href=\"{$url_path}/showphoto.php?photo={$pid}\"><img src=\"{$mmthumb}\" border=\"0\" alt=\"\" /></a></td>";
$catlink = "<a href=\"{$url_path}/showgallery.php?cat={$pcat}\">$catname</a><br />";
}
}
// One box for each feature
$pppro_imagebits .= <<<PPPRINT
<td align="center" class="alt1">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
$plink
</tr>
</table>
<font size="1" face="verdana,arial">by {$puser}<br />
? ? ?<br />
</td>
PPPRINT;
$counted++;
$countcol++;
}
// If we've reached our limit, quit
if ( $counted == $num_display )
{
break;
}
// If we need to end the column, do so.
if ( $countcol == $columns )
{
$pppro_imagebits .= <<<PPPRINT
</tr>
<tr>
PPPRINT;
$countcol = 0;
}
}
@mysql_free_result($result);
$templater = vB_Template::create('forumhome_addon');
$templater->register_page_templates();
$templater->register('pppro_imagebits', $pppro_imagebits);
$template_hook['forumhome_above_forums'] .= $templater->render();