curl: bugfixes and implementation of the php5 functions