Wednesday, June 29, 2005

Is PHP staying the language I want to work with?

While some of the core PHP internals already see theirself that there's something wrong with the so-called generic way ZE2 looks up classes, many stolidly ignore the claims of PHP users...


Look at this MARC Thread and that MARC Thread.


Now something to laugh (or cry) at


WTF?

Friday, June 10, 2005

Gadget 1.1.0

I just came along to release the Gadget Web Development Kit 1.1.0


List of changes:


Improvements:



  • vastly enhanced and simplified Gadget_Formatter::quoteText()

  • simplified Gadget_Template_Action class layout and loading

  • added Gadget_Template_Action_function

  • refactored Gadget_Tree_Search and companions

  • Gadget_Tree::fputs() now attempts to create the destination directory

  • Gadget_Uploads nameToSafe() and nameToUniq() now return the new names

  • Gadget_Upload::nameToSafe() now allows hyphens

  • Gadget_Widget::load() now uses readfile() instead of include() if template won't be rendered

  • added no_prefetching option to Gadget_Service_Security


Bug Fixes:



  • Gadget_Mail::deleteMail() deleted the mail after moving it to the Trash folder

  • Gadget_Tree::fromNode() was not really returning a refernce to the node

  • Gadget_Template_Compiler did an additional save of XML parsed template data

  • Gadget_Template_Action_while was infunctional

  • Gadget_Tree_XML::toFile() added an additional XML declaration

  • Gadget_Service_Mailaccount didn't properly act upon errors

  • Gadget_Search_Fulltext wrongly calculated expiration

  • Gadget_Temaplate_XmlParser put phpized code for comparison of form option element hooks into template


Yeah - I kow - still no website...

Tuesday, June 7, 2005

HttpRequestPool in PECL::HTTP

I just checked in a first working version of HttpRequestPool into CVS.
It's curl_multi that's doing its job underneath and is used tp send several HttpRequests at once.



<?php

$urls
= array(
'http://www.php.net/',
'http://pear.php.net/',
'http://pecl.php.net/'
);

$pool = new HttpRequestPool;
foreach (
$urls as $url) {
$pool->attach(new HttpRequest($url, HTTP_METH_HEAD));
}

try {
$pool->send();
foreach (
$pool as $r) {
$status = $r->getResponseCode();
printf("%-20s is %sn",
$r->getUrl(),
$status == 200 ? "ALIVE" : "NOT OK ($status)"
);
}
} catch (
HttpException $ex) {
echo
$ex;
}
?>

Sunday, June 5, 2005

mod_domaintree

Friday evening I put together a tiny Apache2 module simliar to mod_vhost_alias or mod_vd. mod_domaintree maps host names to a filesystem tree. While mod_vhost_alias and mod_vd seem to be more flexible, they seem less useful to me.


mod_vhost_alias lets you define very precisely which part of the host name maps to which directory but adds odd underscores if the part (number) of the hostname does not exist.


mod_vd lets you define the numerical amount of host name parts to strip.


But I don't want to strip always one part of the host name like "www" - I just want to strip the first part of the host name (i.e. www) if it occurs in the sent hostname.


If you want to try it out, there's nothing more to do then (w)getting it and running



sudo /usr/sbin/apxs2 -a -i -c mod_domaintree.c


Sample Configuration:



DomainTreeEnabled On
DomainTreeMaxdepth 25
DomainTreeStripWWW On
DomainTreePrefix /sites
DomainTreeSuffix /html

Mapped Hosts: (accepting "www" as prefix if DomainTreeStripWWW is enabled)



  • company.co.at

  • sub1.company.co.at

  • sub2.company.co.at

  • organisation.or.at

  • example.at

  • example.com


Resulting Filesystem Tree:



/sites
+- /at
| +- /co
| | +- /company
| | +- /html
| | +- /sub1
| | | +- /html
| | +- /sub2
| | +- /html
| +- /or
| | +- /organisation
| | +- /html
| +- /example
| +- /html
+- /com
+- /example
+- /html

PS: I was very suprised how easy it is to build a simple module for Apache (if you have some templates to look at though). :)