PHP: Dump _ALL_ the data to the browser

Sometimes its useful to show data received / processed through PHP in the browser for debugging purposes. Yes you can use Firebug or some of those fancy debugging classes, but maybe you just want to view that damn array quickly 🙂 Use this: function dumpMe($arr) { echo str_replace(array(“\n”, ‘ ‘), array(‘ ‘, ‘ ‘), print_r($arr, true)) . ‘ ‘; }  

PHPs http_response_code – 5.3 compatibility snippet

The Api of PHP just rocks, easy to use for the things you need. Sometime compatibility is an issue though. Many webhosters didn’t upgrade yet from 5.3 to anything reasonable, so I might as well keep this snippet here for future reference: if (!function_exists(‘http_response_code’)) { function http_response_code($newcode = NULL) { static $code = 200; if ($newcode !== NULL) { header(‘X-PHP-Response-Code: ‘ . $newcode, true, $newcode); if (!headers_sent()) { $code = $newcode; } } return $code; } }  

Format a PHP Timestamp to Mysql Datetime/Timestamp

Useful when converting between those two formats often: function formatDateMysql($timestamp = false) { if ($timestamp === false) { $timestamp = time(); } return date(‘Y-m-d H:i:s’, $timestamp); } in the other direction you can use the mighty strtotime function, o god I love PHP so much <3 (Yes Java, your Date object is a mess!)

Better SPAM protection with Postfix

In order to use RBL lists on your postfix setup to block spam replace this line in main.cf: smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf   with: smtpd_sender_restrictions = reject_rbl_client sbl-xbl.spamhaus.org, reject_rbl_client cbl.abuseat.org, reject_non_fqdn_sender, reject_unknown_sender_domain, check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf   You can copy and paste the line with any ISPConfig setup. If you don’t use mysql to authenticate your users then you might need to adapt parts of this setting.

Degeneration der Spieleindustrie

Seit Farmville auf Facebook haben Spiele mit der Pay2Win (oder auch Free2Play gennant) einen regelrechten Boom hingelegt. Man wird durch einen stetigen Fluss an Lob und ErfolgsgefĂĽhle dazu getrieben, weiter in ein Spiel mit echtem Geld zu investieren. Als erstes weit verbreitetes Spiel hat dies vor einigen Jahren Farmville gemacht. Durch geschicktes einsetzen von Sperrzeiten, welche mit Spielwährungen verkĂĽrzt oder gar entfernt werden konnten, schaffte man Reize Geld auszugeben. Dies war erstmalig so Erfolgreich, weil man ja bekanntlich “mit seinen Freunden gemeinsam” gespielt hat und somit des Nachbars Neid einen noch mehr befriedigt hat. Durch die Umwandlung von echtem Geld in Spielgeld den Bezug zur Wertigkeit. Dies haben bereits viele andere Anbieter von digitalen GĂĽtern kapiert, wie etwa Microsoft in deren Xbox Universum. Vor allem junge Leute sind durch Virtuelle Währungen eher dazu verleitet dieses auszugeben. Am Ende des Tages ist es der Spieler der draufzahlt. Waren Spiele frĂĽher noch durch deren Spielkomplexität und nicht durch deren Aussehen erfolgreich, reicht es heute einen Vogel nur einfaches Clicken/BerĂĽhren fliegen zu lassen. Verglichen mit Spielen wie Eve Online oder den frĂĽhen RPG Spielen, sind die heutigen neuen Spiele darauf optimiert, ein stetiges GefĂĽhl von Erfolg zu vermitteln.    Was erzielt man mit […]

PHP: File uploads fail without any error

When handling uploads with PHP often it can happen, that the $_FILES array is simply empty. This can occur when one of the following things is true: Check php.ini for file_uploads = On, post_max_size, and upload_max_file_size. Make sure you’re editing the correct php.ini – use phpinfo() to verify your settings. Make sure your FORM tag has the enctype=”multipart/form-data” attribute. Do not use javascript to disable your form file input field on form submission! Make sure your directory has read+write permissions set for the tmp and upload directories. Make sure your FORM tag has method=”POST”. GET requests do not support multipart/form-data uploads. Make sure your file destination and tmp/upload directories do not have spaces in them. Make sure all FORMs on your page have /FORM close tags. Make sure your file input tag has a NAME attribute. An ID attribute is NOT sufficient! ID attributes are for use in the DOM, not for POST payloads. Your /tmp folder is full Hope this helps!