Classifieds IIP Pal Version 1.0 - 02/06/2005 5:03 PM
Okay someone asked for it so here is a Photopost Classifieds Pal for IIP to display your Photopost classifieds ads on IIP for UBBThreads.
<?
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 );
}
//
// Featured Products Code
// Follow down to End Feature Products Code
//
// which type of images do you want to show
$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;
//IF YOUR THREADS DATABASE IS DIFFERENT THEN CLASSIFIEDS THEN UNCOMMENT THIS LINE AND PLACE YOUR DATABASE NAME BELOW FOR THREADS
mysql_select_db('xxx_threadsv7') or die("Could not select database 'database'\n");
?>
<?
//You must change these values in order to run this script
$clurl_path = "http://www.mysite.com/classifieds/"; //URL of your photopost installation is, where the index.php is (with / at end)
$cldata_dir = "http://www.mysite.com/classifieds/data/"; //URL of your photo dir where those jpeg stored (with / at end)
// configure your database settings
$clhost = "localhost"; //Server Name
$cluser = "myusername";; //Username
$clpassword = "mypassword"; //Password
$cldatabase = "xxx_ppclassifieds"; //Reviewpost database name or forum database name
//Your reviewpost table prefix enter it below
$Globals['cl_db_prefix'] = "cp_";
// Connecting, selecting database
$cllink = mysql_connect ("$clhost", "$cluser", "$clpassword") or die ('I cannot connect to the database.');
mysql_select_db ("$cldatabase")or die("Could not select database");
?>
/* PHP CODE HERE, IF NECESSARY */
/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF
Body of the custom box here
EOF;
/* DO NOT CHANGE THE LINE ABOVE */