Posted on: 04/13/02 01:04pm
By: Dirk
I've been using Michael De La Rue's Classifads[*1] script to provide classified ads on one of my sites for some time now. Then I thought that this would also make a nice plugin for Geeklog. So I hacked on it long enough until in gave up and integrated nicely into Geeklog.
Please note that this is my first plugin and the integration is not as complete yet, as one might wish. Let me know what you think about it.
The feature list of this plugin is almost identical to the original script by Michael De La Rue:
- Any number of easily configurable categories
- Posters choose how many weeks to display their ad for.
- A "new listings" front page with a drop-down selection of categories to choose from.
- The script uses a combination of IP logging and cookies, so that if visitors have either a static IP address or cookies enabled, they can alter their ad without having to remember a password. Any ads posted by the visitor are
listed with an "alter it" and "delete it" button beneath them.
- If an email address / url is given, the listing will include an EMAIL / SITE link at the bottom. If not, only the Title - Author & Description are shown.
- The script automatically erases expired ads from the database.
Additional features, specific to the Geeklog plugin:
- easy install (you have to copy some files manually, then call an install script that does the rest)
- available in two languages (English and German)
Download here[*2] (21 K
bye, Dirk
First couple of fixes ...
Posted on: 04/13/02 03:42pm
By: Dirk
Okay, the first issues have come up (thanks to toad for the quick feedback). It seems my version of PHP is a bit more fault-tolerant than others ...
If you get "undeclared function" errors, check public_html/index.php
and public_html/updata.php
and remove the dollar signs from these lines:
echo $COM_endBlock();
echo $COM_siteFooter();
While you're at it, add the following line in public_html/index.php
:
$i = "0";
$posti = array (); // this is the line to add
while($ad = mysql_fetch_assoc($query)) {
(that's lines 57-59).
Of course, you could instead just download the updated tarball from the URL provided in the original story.
Sorry about that.
bye, Dirk
Good work, thanks!
Posted on: 04/14/02 07:48am
By: Anonymous (Anonymous)
Good work on this Dirk. I noticed on the submissions that if a user entered a website address without the http:// prefix, like www.usersite.com that my hosted server will for some reason bork the url that is given to the clickable link in the ad. On my site if you dont use the http:// the clickable link url is http://mysite.com/path/to/classifads/. I put a small reminder to users on the submit form this way,
<from /public_html/classifads/index.php approx line 108>
<tr><td><? echo $LANG_CLADS['adsite']; ?> (http://..) :</td><td>
For sure this is not necessary, but it always helps to help your users, plus
it takes care of the "Well, why didn't you tell me?" toad.
How about a PHP Block?
Posted on: 04/14/02 08:35am
By: squatty
Nice work on the classifieds. How about adding a PHP block that would display the most recent posts? I'm working on it myself. I'll post it on GL once all the bugs are worked out.
... and in updata.php, too
Posted on: 04/14/02 10:25am
By: Dirk
Sounds like a good idea. We have these hints in Geeklog whenever you can enter a URL, so we should have them in the plugins, too. I will add this in the next release of the plugin.
BTW, you might want to add this in updata.php, too.
bye, Dirk
Excellent idea!
Posted on: 04/14/02 10:28am
By: Dirk
Thanks, squatty. That will make a nice addition to the plugin and make it integrate further into Geeklog. It should be relatively easy to pull the necessary code from public_html/index.php
. Let me know how you get on with it.
bye, Dirk
Excellent idea!
Posted on: 04/14/02 06:25pm
By: squatty
I just put the finishing touches on the PHP block. It's a bit rough around the edges but I think most GL site owners will find it of value.
I created a separate php file named display_ads.php. You can view the source code here[*3] . Note, the select statement will ONLY display ads submitted within the last 48 hours (at least that's what it's supposed to do
To deploy the block, complete the following:
Download the display_adds.php and save it to your /public_html/classifads directory
Add the following to lib-custom.php:
function phpblock_classifieds()
{
global $_CONF;
$path = $_CONF['path_html'] . "classifads";
include_once($path . "/display_ads.php");
$display = getads();
return $display;
}
You will also notice that I added two links at the bottom of the block. The submit link goes to an additional page I created. I removed the submit logic from the original index.php. This was just a preference of mine. You can see my version of the plug-in at http://www.squatty.com[*4] .
Thanks,
Squatty
Thanks!
Posted on: 04/15/02 01:22pm
By: Dirk
Thanks, squatty! I had to hack it a bit to get it working, though. But it sure is as nice addition to the plugin, so I will add something like this to the next version of the plugin. I also borrowed your "Fields in bold are required" line, if you don't mind ;-)
bye, Dirk
need help
Posted on: 04/15/02 05:11pm
By: Anonymous (toad)
squatty,
had to add,
global $_CONF;
in function getads{}
to get rid of two
Warning: Failed opening 'plugins/classifads/classifads.cfg' for inclusion (include_path='./')
without it.
but still get
Warning: Cannot add header information - headers already sent by (output started at lib-common.php(405) : eval()'d code:10) in path/to//geeklog/public_html/classifads/display_ads.php on line 29
but the block does show
any ideas? toad
need help
Posted on: 04/15/02 06:11pm
By: squatty
Thanks for the heads up on the $_CONF. I made the update on the phps file.
As for the headers already sent warning, I assume this is a being generated by lib-custom.php. I'm reading from the HTTP headers to find the Remote IP address of the user.
I don't seem to have the issue on my site. What versions are you running. Apache, PHP, Geeklog, ect. Not that I would know how to fix it, just curios.
Let me know if you find any additional bugs. This was a quick fix on my part. I'm sure there's plenty of other issues to be found
maybe setting cookies?
Posted on: 04/15/02 06:32pm
By: Anonymous (toad)
I think it may have something to do with
setcookie($_CA_CONF['cookie'], "$rip", $exp);
after the headers have been sent
but what I did in the meantime is borrow
error_reporting(0);
from Dirks' index.php (maybe it was there for a reason?)
and now the message isn't plastered on my page. Don't
know exactly what the effect of that is right now, but I
guess when the thing progesses it will be fixed.
I think so.
Posted on: 04/15/02 06:57pm
By: Anonymous (toad)
I thought a bit and came up with this,
why are you messing with the cookies thing in a block that just displays ads already placed? Couldn't think of a reason so I did this,
// if(isset($HTTP_COOKIE_VARS[$_CA_CONF['cookie']])) {
// $rip = $HTTP_COOKIE_VARS[$_CA_CONF['cookie']];
// }
// else {
// $rip = $REMOTE_ADDR;
// $exp = time() + 3600 * 24 * 7;
// setcookie($_CA_CONF['cookie'], "$rip", $exp);
// }
I also tossed the error_reporting(0) I had put in
and now the block works fine.
I think so.
Posted on: 04/15/02 07:23pm
By: squatty
The cookies are in the script in order to display the "Alter it" and "Delete it" buttons. The plug-in uses similar logic to allow the ad poster the ability to update/delete a previously submitted ad.
I wasn’t going to include this at first but, after further review I thought why not? Ideally, all submission should go through the GL submission process. Meaning, the site admin would approve ads so cookies would become obsolete. Just my 2 cents.
This might be in the works for future releases. Dirk did mention adding more GL integration?
I think so.
Posted on: 04/15/02 07:37pm
By: Anonymous (toad)
The block itself does not do the submit, alter, delete, you
have linked that out to the submit, index page you made.
So the cookie stuff is not required for the display block,
at least not mine. :^) But I'm using the block code, so thanks!
Originally I just had a normal block called Classifieds with just a link to the index.php. Thanks to you the block now has the listing along with the link.
I think I'm stupid
Posted on: 04/15/02 07:43pm
By: Anonymous (toad)
I just relooked at your code and see that
the alter & submit buttons are also in the
block, you don't see them unless you placed
an ad.
I think I'm stupid
Posted on: 04/15/02 08:19pm
By: squatty
Yep, that's why the cookie is set.
I do know this
Posted on: 04/15/02 09:02pm
By: Anonymous (toad)
setting that cookie from within the ads block is what causes the error on my system. with the ads block code out of the box I get the error, with only the set cookie line commented out the error is gone. I think that it has to do with the headers for the page having been sent before the block code wants to set the cookie. So doing cookies from blocks is kinda tricky. I'm not a pro, I'm just speculating on what it seems to me.
Small Update to PHP Block
Posted on: 04/17/02 05:50am
By: squatty
I made a small update to the PHP block. I added a condition to return a "No new ads" in the event of the query result set returning no rows. You can get the update
here[*3] .