PDA

View Full Version : Integrating classifieds question


jtorral
April 22nd, 2006, 07:42 PM
I run a forum with vbportal for a front end.
www.rangefinderforum.com

i would like to be able to show recent ads in the forum or on the front page. I could create a block for recent ads but how would I show them? Any ideas?

Chuck S
April 23rd, 2006, 10:00 AM
Our classifieds software has an inc_ads.php file. You could setup a center block in vbportal and include the file and echo the variable $classifiedsfeature to show the block.

jtorral
April 23rd, 2006, 10:56 AM
chuck, thanks for the heads up.

It partialy works. It shows the block with a title of "Featured Ads" but no pictures or content.

Chuck S
April 23rd, 2006, 11:03 AM
Remove this line in the file


if ( $ViewPerm[$pcat] == 1 ) continue;

jtorral
April 23rd, 2006, 11:15 AM
does not exist anywhere. i just did a

grep -i "Content visible" *.php

and nothing.

I also did from pp root

find . -depth -exec grep -i "content visible" /dev/null {} \;

Chuck S
April 23rd, 2006, 06:59 PM
You sure you are looking in our inc_ads.php file. That line explicitly does exist at line 110 of that file.

jtorral
April 23rd, 2006, 07:04 PM
below is line 110 and then some. look at the last line. its my vi info

while (list($pid,$puser,$puserid,$pcat,$ptitle,$product,$views) = mysql_fetch_row($result)) {

if ( $ViewPerm[$pcat] == 1 ) continue;

if ( cl_is_image($product) ) {
$temp_user = $puserid;
$productlen = strlen($product);
$theext = cl_get_ext($product);
$product_name = str_replace( $theext, "", $product );


$thumbtag = "{$cldata_dir}{$pcat}/thumbs/{$product}";
$image_stats = getimagesize( $thumbtag );
$width = $image_stats[0];
$height = $image_stats[1];

if ( $height > $width )
@
"inc_ads.php" 200 lines --55%-- 110,1 56%

Chuck S
April 23rd, 2006, 07:25 PM
Line 110 of our supported file in the download of classifieds is the line meantioned however the line I am telling you to remove is right there in your file although possibly line 113 of your file. You see it above remove the line.


if ( $ViewPerm[$pcat] == 1 ) continue;

jtorral
April 23rd, 2006, 07:28 PM
I just downloaded this the other day. would you like to log in?

Chuck S
April 23rd, 2006, 07:33 PM
Line 110 is the line I have posted in this thread. Just remove the line if you want to run this block in vbportal. The block works as supported on the vbulletin forumhome as coded. To use in vbportal though you need to remove the viewperm line

jtorral
April 23rd, 2006, 07:38 PM
chuck. I have just unzipped the zipfile again. looking at inc_ads.php there is no line that says.

Content visible to verified customers only.

Are you sure you dont want to look. you dont need to fix anything, just see for yourself.

JT

jtorral
April 23rd, 2006, 07:42 PM
here is the entire content of inc_ads.php straight from the zip file.


<?php
//////////////////////////// COPYRIGHT NOTICE ///////////////////////////////////
// This script is part of PhotoPost Classifieds PHP, a software application by //
// All Enthusiast, Inc. Use of any kind of part or all of this //
// script or modification of this script requires a license from All //
// Enthusiast, Inc. Use or modification of this script without a license //
// constitutes Software Piracy and will result in legal action from All //
// Enthusiast, Inc. All rights reserved. //
// http://www.photopost.com legal@photopost.com //
// Contributing Developers: Michael Pierce (mpdev.net) //
// Charles Scannell (omegatron@comcast.net) //
// //
// PhotoPost Classifieds Copyright 2006, All Enthusiast, Inc. //
////////////////////////////////////////////////////////////////////////////

require "config-intc.php";

// If you have placed PhotoPost Classifieds into a seperate database, you will need to
// uncomment these lines to connect to the PhotoPost Classifieds database. It is suggested
// that you install PP into the same database as vB for better performance.
//
// If you use the same userid/password to access both databases, you don't need to
// uncomment the mysql_connect - this is only if you require different ids to access
// the PhotoPost Classifieds database.
//
//$link = mysql_connect ("localhost", "user", "password") or die('I cannot connect to the database.');
//mysql_select_db ("pp_database")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 = "latest";

// == 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 FROM {$pp_db_prefix}categories");

$ViewPerm = array();
while ( list( $catugid, $ugnoview ) = 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 ) {
$ViewPerm[$catugid]=0;
}
}
}

function cl_get_ext( $filename ) {
return substr($filename, strrpos($filename,"."));
}

function cl_is_image( $filename ) {
$retval = 0;

$mediatypes = array( ".jpg", ".gif", ".png", ".bmp" );
$ext = cl_get_ext( $filename );

if ( in_array(strtolower($ext), $mediatypes) )
$retval = 1;

return( $retval );
}

//
// Featured Photos Code
// Follow down to End Feature Photos Code
//

switch ($q_switch) {
case "most_view":
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM {$pp_db_prefix}products WHERE bigimage != '' AND approved = 1 ORDER BY views DESC";
break;
case "latest":
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM {$pp_db_prefix}products WHERE bigimage != '' AND approved = 1 ORDER BY date DESC";
break;
case "random":
$query = "SELECT id,user,userid,cat,title,bigimage,views FROM {$pp_db_prefix}products WHERE bigimage != '' AND approved = 1 ORDER BY RAND()";
break;
}
$result = mysql_query($query);

$counted = 0; $countcol = 0; $featured = "";

while (list($pid,$puser,$puserid,$pcat,$ptitle,$product,$views) = mysql_fetch_row($result)) {

if ( $ViewPerm[$pcat] == 1 ) continue;

if ( cl_is_image($product) ) {
$temp_user = $puserid;
$productlen = strlen($product);
$theext = cl_get_ext($product);
$product_name = str_replace( $theext, "", $product );

$thumbtag = "{$cldata_dir}{$pcat}/thumbs/{$product}";
$image_stats = getimagesize( $thumbtag );
$width = $image_stats[0];
$height = $image_stats[1];

if ( $height > $width )
$mthumb = "<img src=\"{$class_path}/images/overlay-roundp.gif\" height=\"105\" width=\"81\" border=\"0\" alt=\"\" />";
else
$mthumb = "<img src=\"{$class_path}/images/overlay-round.gif\" height=\"81\" width=\"105\" border=\"0\" alt=\"\" />";

// One box for each feature
$featured .= <<<PPPRINT
<td align="center" class="alt1">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="background: url({$cldata_dir}/{$pcat}/thumbs/{$product}); background-position: 50% 40%; background-color: #000000; background-repeat: no-repeat; background-position: center;"><a href="{$class_path}/showproduct.php?product={$pid}">$mthumb</a></td>
</tr>
</table>
<font size="1" face="verdana,arial">{$ptitle}<br />by {$puser}</font>
</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 ) {
$featured .= <<<PPPRINT
</tr>
<tr>
PPPRINT;
$countcol = 0;
}
}
@mysql_free_result($result);


// First part is for the featured products


$classifiedsfeature = <<<PPPRINT
<table class="tborder" cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
<tr>
<td>
<table cellpadding="$stylevar[cellpadding]" cellspacing="1" border="0" width="100%">
<thead>
<tr>
<td class="tcat" colspan="$columns" align="center">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('featurepal3');"><img id="collapseimg_featurepal3" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_featurepal3].gif" alt="" border="0" /></a>
Featured Ads
</td>
</tr>
</thead>
<tbody id="collapseobj_featurepal3" style="$vbcollapse[collapseobj_featurepal3]">
<tr>
$featured
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<br />

PPPRINT;

//
// End Featured Ads Code
//

// If you use PhotoPost in a seperate database from vB, you'll need to reselect the vB database!
//mysql_select_db ("vb_database");


PLEASE DO NOT POST OUR CODE TO THE OPEN PUBLIC -- I have wrapped it in a code tag for you

Chuck S
April 23rd, 2006, 07:42 PM
Your not seeing the code I am posting because your not a verified customer hense your not looking for the correct line in the file since you can not see what I am posting. Read this thread to verify yourself

http://www.photopost.com/forum/announcement.php?f=64

Frank Woolf
April 24th, 2006, 02:01 AM
Hi Chuck,

I have been trying to get this working for a while. I am using vbPortal and have deleted the line as per your instructions.

I used the following code in the vbPortal module:
echo require "../classifieds/inc_ads.php";

When I preview I get these errors:
Content
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/asia/public_html/classifieds/inc_ads.php on line 56

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/asia/public_html/classifieds/inc_ads.php on line 108
1

Frank Woolf
April 24th, 2006, 05:26 AM
Tried lots of variations including this one:
@include('/home/asia/public_html/classifieds/inc_ads.php');
print $classifiedfeature;

This does not return errors but dose not show anything on the page either.

If I remove the @ I get errors.

I just discovered that adding an s to make it $classifiedsfeature makes the module header show up on the page but there is no content

Chuck S
April 24th, 2006, 08:21 AM
If you get mysql errors your issue is this as noted in the instructions for applying the inc_ads.php hack.


If you have PhotoPost and vB in different databases, you'll need to scroll to the script and uncomment the mysql_select_db() command (on line 26) and insert your Classifieds database name and uncomment the mysql_select_db on line 310 and add your vB3 database in quotes. If your username password is different to connect to the databases then you will need to uncomment the $link statement and fill in the proper variables for the host username and password to access the photopost database

Frank Woolf
April 24th, 2006, 09:30 PM
Sorry I should have mentioned that vbPortal, vBulletin and PPClassifieds are all using the same database with vbp_ vp_ and pp_ prefixes.

My test page (link below) shows all is working together including skins but I can't get the ads from PPClassifieds to show (at the bottom of the page).
http://www.asia-classifieds.com/modules.php?s=&file=index&name=test

jtorral
April 24th, 2006, 09:49 PM
comment out this line of code.

if ( $ViewPerm[$pcat] == 1 ) continue;

Frank Woolf
April 24th, 2006, 10:47 PM
Thanks but I already took out the line as per Chuck's advice earlier in this thread.

I looked at your site and was going to ask how you did it but removing the line of code did not solve the problem for me.

Frank Woolf
April 24th, 2006, 11:36 PM
It might help to see what the errors are if I take out the @

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/asia/public_html/classifieds/inc_ads.php on line 56

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/asia/public_html/classifieds/inc_ads.php on line 108

Frank Woolf
April 24th, 2006, 11:49 PM
Sorry duplicate post

Frank Woolf
April 24th, 2006, 11:53 PM
I just editing inc_ads.php to add the DB info just in case it would help. It did!

Just a comment - In Chuck's instructions above he says "and uncomment the mysql_select_db on line 310 and add your vB3 database in quotes"

There are only 193 lines in my inc_ads.php file!

Anyway it is working now. Thanks

Chuck S
April 25th, 2006, 09:25 AM
Just uncomment and fill out the $link line and mysql_select_db lines