pull.php refactoring & Bugfixing

I refactored the pull.php and introduces the pdo extension for the sql queries, added comments and more debug output.

I tested the script both with mysql and pgsql database and it is doing fine.

i optimized the update code and removed uneccesary cUrl to reduce load.