Archive | August, 2004

Simple Link Checker with PEAR

Posted on 30 August 2004 by Demian Turner

By slightly modifying one of the examples scripts from PEAR’s HTTP_Client package, you have yourself quite a useful link checker script.

Here’s the code:

http://www.phpkitchen.com/viewableCode/linkchecker.phps

To get things to work:

  • install the required classes using the PEAR package manager (if you’re not using this yet slap yourself on the wrist now):

    $ pear install HTTP_Request
    $ pear install HTPP_Client

    If you get an error about missing dependencies, obviously install the dependencies first.

  • change the $url variable to one of your sites you want to check (line 81)
  • load the script in a browser

The concept is simple:

  • Use HTTP_Request to return the html of a given webpage
  • use the extractlinks() function (slightly modified from Snoopy code) to get an array of links from the page
  • use HTTP_Client and a link checker listener (Observer pattern) to iterate through all the links and return the appropriate response code
  • colour code pass/fail responses and update the browser with flush()

Comments (0)

PHP4 and PHP5 in 5 minutes

Posted on 30 August 2004 by Demian Turner

I know this has been covered many times already, but in case this is helpful for anyone, here’s how to get PHP4 and PHP5 running alongside in no time.  It presumes your are running PHP on Windows and that your current PHP4 install is running of Apache 1.3.x:

1. install apache2 via installer
2. download PHP5 zip package and copy php files to C:/php5
3. copy php5ts.dll to C:/Program Files/Apache Group/Apache2/bin
4. copy the following lines into httpd.conf:

LoadModule php5_module “c:/php5/php5apache2.dll”
AddType application/x-httpd-php .php
PHPIniDir “C:/php5”

5. rename php.ini-dist to php.ini and leave it in C:/php5
6. add index.php to the DirectoryIndex directive
7. copy C:/php5/libmysql.dll to C:/WINNT/system32
8. in php.ini, uncomment
  ;extension=php_mysql.dll
making sure that your extension dir is set correctly:
  extension_dir = “C:/php5/ext”

Start Apache2 and you’re in business.  If you want to go back to  PHP4, stop Apache2 and start your old Apache.  If you set the document root the same for both installs, then you can run your old code on PHP5 without any adjustments and see what works ๐Ÿ˜‰

Comments (0)

Born Again PHPkitchen

Posted on 27 August 2004 by Demian Turner

If you’ve noticed a difference in the performance of this website, no, you’re not imagining things. This site and the Seagull project have finally been moved to a better machine, which though approximately the same cost as the last one, seems to be around 10 times quicker.

Hopefully the newfound performance improvements will help make way for more frequent updates. If you have any content you’d like to share with PHP readers then send in your submissions, I’ll accept most things as long as they’re not blatant promotion for commercial software.

Comments (0)

Collaborative Source Software

Posted on 24 August 2004 by Demian Turner

This article presents an approach to combine the best of the open source and proprietary software development worlds

http://www.methodsandtools.com/archive/archive.php?id=11

Comments (0)

addslashes() will never be the same

Posted on 22 August 2004 by Demian Turner

Via Jellybob on #php:

<Noel4DMB> lets say theoreticaly, I wanted to kill someone with a PHP command. what’s the best one to use? str_replace(“gaping_hole”,”heart”,$person); /
<BB[AtWork]> $person->stabinheart($knife)
<TML> Noel4DMB: I’d go with explode()
<Touqen[BX]> Noel4DMB I prefer: $cs =& new Chainsaw(); $person = new Person(); $cs->slice($person);
<BB[AtWork]> nice TML
<Davey> TML: I think implode() would be better, less mess ๐Ÿ™‚
<TML> heh
<TML> Davey: He said the best, not the cleanest
<Touqen[BX]> slice() is nice too
<TML> Although it WOULD be cool to see someone implode
<shadfc> chomp()
<BB[AtWork]> while ($person->stillBreathing()) { $knife->apply($person->GetPart(“chest”)); }
<Davey> implode is definately best ๐Ÿ˜‰
<kuja> woot!
<kuja> ๐Ÿ˜›
<kuja> explode() isn’t so bad either.
<kuja> chown() the mofo.
<Jellybob> $person->removeNode(‘head’);
<Noel4DMB> hmm
<Talisman> reduceToBlobOfNuclearWaste()
<TML> Noel4DMB: How about addslashes()?
<Noel4DMB> hah addslashes
<TML> =)
<TML> Or chunk_split()
<shadfc> might want to do a crack_check() and rob them first though
<Davey> how to fire a BK employer: stripTags($person) ๐Ÿ™‚
<TML> Noel4DMB: How about leak()
<TML> I guess that’d only kill you if you were a spy.
<Jellybob> TML, I dunno, leaking tends to kill most people if they do it long enough
<HolyGoat> or if you intend to keep your pants dry
<Noel4DMB> $noel = addslashes(str_replace($bomb,$stomach,$TML))
<jfarrell[a]> TML, probably, but if you live in the USA the death process would take 20 years
<jfarrell[a]> ๐Ÿ™‚
<Noel4DMB> so if i wrote that correctly, i put a bomb in your stomach and slash the crap out of you
<TML> There’s chop()
<shadfc> does in_array return true of a key contains or equals the search value?
<HolyGoat> and chunk_split()
<Jellybob> TML, what, are you trying to drive yourself insane, causing you to kill your other selves now?
<Noel4DMB> str_repeat(‘stab_jellybob’, 99);

Comments (0)

Running a Successful Open Source Project

Posted on 22 August 2004 by Demian Turner

Detected in the blogosphere earlier this week, just got time to read Running a Successful Open Source Project.  The article rates a 4.2 out of 5 (Sophisticated) so if you don’t  let a bit strong (but sophisticated) language get in  your way, there are definitely some good tips here.

I was tempted to put a bit of a marketing page at the Seagull wikiWhy A Framework Might Be Of Interest To You.  You can never be sure who still needs to be convinced that using a framework has any advantages over coding a project from start to finish every time.  Did I catch the main points?

Comments (0)

Clean up your Act with a Roomba

Posted on 16 August 2004 by Demian Turner

Required reading here.

Comments (0)

URL Validation

Posted on 15 August 2004 by Demian Turner

Hi, I am doing an URL validator. It needs to be the best URL validator I ever made – and it is already quite functional.

Validating URLs with PHP

I’d be very happy if you’d go there and try to break it and tell me what went wrong if you do break it.

In return you are free to copy the code for your own use.

Usage is very simple, you construct an array with some key/value pairs – look in the source for which value pairs you can use.

Here’s an example from my testapp

    /* Make the options */
    $options['AssumeProtocol'] = @ $slcAssumeProt;

    $options['AllowBracks'] = isset($chkAllowBracks);

    @ $chkProthttp ?  $options['AllowedProtocols'][] = 'http' : '';
    @ $chkProthttps ? $options['AllowedProtocols'][] = 'https' : '';
    @ $chkProtmailto ? $options['AllowedProtocols'][] = 'mailto' : '';
    @ $chkProtnews ? $options['AllowedProtocols'][] = 'news' : '';
    @ $chkProtnntp ? $options['AllowedProtocols'][] = 'nntp' : '';
    @ $chkProtgopher ? $options['AllowedProtocols'][] = 'gopher' : '';
    @ $chkProttelnet ? $options['AllowedProtocols'][] = 'telnet' : '';
    @ $chkProtfile ? $options['AllowedProtocols'][] = 'file' : '';

    $options['Require']['Protocol'] = $chkReqProtocol ? true : false;
    $options['Require']['User'] = $chkReqUser ? true : false;
    $options['Require']['Password'] = $chkReqPassword ? true : false;
    $options['Require']['Server'] = $chkReqServer ? true : false;
    $options['Require']['Resource'] = $chkReqResource ? true : false;
    $options['Require']['TLD'] = $chkReqTLD ? true : false;
    $options['Require']['Port'] = $chkReqPort ? true : false;
    $options['Require']['QueryString'] = $chkReqQueryString ? true : false;
    $options['Require']['Anchor'] = $chkReqAnchor ? true : false;

EWValidator :: _ValURL($URL, $options)

Comments (1)

Is Google Dancing?

Posted on 11 August 2004 by Demian Turner

You can now find out with this class published at phpclasses today.

This class is meant to query different Google servers and analyse the results to determine if their search index is being updated. This index update is also known as Google Dance.

This class checks whether Google is dancing making three types of tests: counting the number of links pointing to a set of domains, counting the number of indexed pages of a set of domains, counting the number of results of a given search query words.

The class repeats the tests on several alternative servers and compares the results to return an index that is related with evidence that Google is updating their index.

Comments (0)

PHP and SOAP documentation

Posted on 10 August 2004 by Demian Turner

Some of the best documentation on using SOAP with PHP is quite well hidden.  If you like the convenience of using PEAR packages you should check out these docs (download zip).

Also, a good article out a few days ago on using Services_Google, the PEAR package for using the Google API.

Anyone using Overture’s DTC Advertiser Web Service?  They have made the unusual choice of offering a web service with no SOAP API.

Comments (0)

Categories

Books

Demian Turner's currently-reading book recommendations, reviews, favorite quotes, book clubs, book trivia, book lists

Facebook