initial fixes

make compatible with Debian/Ubuntu php5 settings (<? to <?php)
fix library includes, missing relative paths
fix handling of mail_id, failed on mail_id's that included '_'
check for existence of object members before trying to use them
fixed pagenation query