Displaying posts tagged: php

PHP Polygon Clipper using the Sutherland-Hodgman algorithm

No Comments
I wrote this recently and thought it might be useful to someone:

Building PHP's Debian package nightmare

No Comments
I just tried to compile the Debian PHP packages, so I could make some minor tweaks to the source, to fix a bug I'm hopefully going to document shortly. This turned out to be very problematic, mainly due to the testing phase! To build the Debian packages you typically do the following: mkdir php cd php ...

PHP Destructor objects

No Comments
PHP's lack of a finally keyword is apalling, and even though there seems to be some hacks around it, I have come up with own today. I'm following the C++ concept of allocating objects on the stack, and letting them cleanup any resources when the stack is rolled back. Take an example. I am creating some ...

SQLSTATE[HY000]: General error: 2053

No Comments
I encountered the following odd exception: PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2053 ' in /home/bramp/my.php:29 Stack trace: #0 /home/bramp/my.php(29): PDOStatement->fetch(2) Searching on Google didn't reveal much help, but I eventually figure out the root cause. Spot the mistake: ... $sql = 'SELECT TRIGGER_NAME, TRIGGER_GROUP, JOB_NAME FROM QRTZ_TRIGGERS'; $sth = $dbh->prepare($sql) ...

MD5 Digest Authorisation in SIP with PHP

No Comments
Today I needed to work out the MD5 Digest hash for SIP authorisation. A quick search on Google revealed instructions on how to generate the hash, and then I made this simple PHP script. <?php $username = '1234'; $realm = 'asterisk'; $password = 'PASSWORD'; $uri = 'sip:1.2.3.4'; $nonce = 'abcdef01'; $str1 = md5("$username:$realm:$password"); $str2 = md5("REGISTER:$uri"); ...