Code Design Question

Posted on May 6th, 2009 in PHP by Russ

Let’s suppose I’m using a third party API class, oh, I don’t know, let’s say “Facebook.” I’ve got a $facebook=new Facebook; and $facebook->api_client->bar(), et cetera. And suppose, I want to do something with it, but I’m using a class too. Let’s say, I want a class “Pets.” I’ll need to use the facebook class for communicating with the facebook servers and configuring stuff.

Which is the “Best Practice”?

  • extend the facebook class like “class Pets extends Facebook” …
  • use a facebook variable in the Pets class – $pets=new Pets; $pets->fbook =& $facebook;
  • Don’t tie the two objects together

What do you think results in the most clear code?

A Quick Eye on the Referrers

Posted on May 5th, 2009 in Search Engines, Webmastering, system admin by Russ

One of my clients has an extremely busy website. And it’s a popular place for people to show his images and offer a cracked version of his product for sale. We can see them in the apache logs- the referrer shows their domain name. One thing I like to do in order to keep an eye on this is to tail his apache logs and pull out the refer data. I’m using this:

[code]
tail -f access.log | cut -d\ -f9,11 | grep -v (domain name)
[/code]

That’s two spaces after the -d\; the backslash is escaping the space used as the delimiter. You may need different field numbers (9 and 11 are the ones for his combined logs that show the HTTP status code and the referrer). And of course I need to grep out the domain name of his site because it’s all over those lines.

Hope that helps ya.