<?
require ("/home/xxx/public_html/forum/classifieds.inc.php");
function clget_ext( $filename ) {
return substr($filename, strrpos($filename,"."));
}
function clis_image( $filename ) {
$retval = 0;
$mediatypes = array( ".jpg", ".gif", ".png" );
$ext = clget_ext( $filename );
if ( in_array(strtolower($ext), $mediatypes) )
$retval = 1;
return( $retval );
}
$q_switch = "random";
switch ($q_switch) {
case "most_view":
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM cp_products WHERE bigimage != '' ORDER BY views DESC";
break;
case "lastest":
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM cp_products WHERE bigimage != '' ORDER BY date DESC";
break;
case "random":
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM cp_products WHERE bigimage != '' ORDER BY RAND()";
break;
}
$result = mysql_query($query);
echo <<<UBBTPRINT
$tbopen
<tr>
<td class="tdheader" colspan="5" align="center">
Featured Ads
</td>
</tr>
UBBTPRINT;
$counted = 0;
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$product = $line["bigimage"];
$title = $line["title"];
$title = ( strlen($title) > 20 ? substr($title,0,20)."..." : $title );
if ( clis_image($product) ) {
$productlen = strlen($product);
$theext = clget_ext($product);
$product_name = str_replace( $theext, "", $product );
print "<tr><td align="center" class="lighttable" width="20%"><font size="1" face="verdana,arial">";
$temp_user = $line["userid"];
$thumbtag = "{$full_path}{$line['cat']}/{$line['userid']}{$product}";
$mthumb = "<img border="0" src="{$cldata_dir}{$line['cat']}/{$line['userid']}{$product_name}-thumb{$theext}" alt="$thumbtag" />";
print "<a href="{$clurl_path}/showproduct.php?product={$line['id']}">$mthumb</a><br />{$title}</font></td></tr>";
$counted++;
}
if ( $counted == 5 ) break;
}
mysql_free_result($result);
echo <<<UBBTPRINT
$tbclose
<br />
UBBTPRINT;
mysql_select_db('xxx_threadsv7') or die("Could not select database 'database'\n");
?>