Archive for the "PHP" Tag

Filed in: , ,
Posted On: 2008 / 04 / 27

For my next stuff I needed the Javascript equivalents of PHP functions basename() and dirname(). Nothing genius: PLAIN TEXT JAVASCRIPT: function basename(path) {     return path.replace(/\\/g,'/').replace( /.*\//, '' ); }   function dirname(path) {     return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');; } It obviously supports paths like /home/ozh/stuff.php, http://site.com/file.ext or double backslashed Win32 paths such as C:\\dir\\document.txt. Edit: Mister Ze in comments points out to [...] → Read more

Filed in: , , ,
Posted On: 2008 / 03 / 28

WordPress 2.5 comes with a very handy API that plugin authors should love: shortcodes, ie. BBcode-like tags, that are parsed when found in post contents. The API is very easy to use, and well done enough that it's relatively foolproof. Shortcode types The API allows for all the possible combinations and forms you'd think of: selfclosing or [...] → Read more

PLAIN TEXT PHP: query_posts($query_string.'posts_per_page=-1');        while(have_posts()) {        the_post();        the_time();        the_title(); } This will display the time and title for all your posts. This could result in a very long page, and a more usable way of doing it would be to change the posts_per_page parameter, and add Next and Previous [...] → Read more

Filed in: , , , ,
Posted On: 2007 / 08 / 28

Headbanging link of the day: MetalAd creates a skyscraper-like banner from your heavy metal tastes (as stored by Last.fm). (my metal ad for instance). The generating PHP script is even open-sourced. Share This Related posts Funniest video ever (2) Ban This Artist, Damnit (0) Worst Logos Ever (0) World’s Most Dangerous Roads (0) Wordpress 1.5.2 (0) [...] → Read more

Filed in: , , ,
Posted On: 2007 / 06 / 22

Parse error: syntax error, unexpected T_DEC, expecting T_PAAMAYIM_NEKUDOTAYIM (like here for instance) Seriously, what were PHP coders on, when they decided to implement this kind of error message?? For the record, it just means you're missing a :: somewhere. Share This Related posts www dot googleporn dot com (0) Worst Logos Ever (0) Wordpress 1.5.2 (0) Spam statistics (2) Spam of the [...] → Read more

Filed in: , , , ,
Posted On: 2007 / 06 / 17

This contact form uses a clock captcha, I thought it was a rather fun idea, and anyway a lot less annoying than those barely readable random strings so many sites use. Source code for this clock captcha can be found here (in German, but the PHP code is clean and easily understandable:) Share This Related posts Spam statistics [...] → Read more

Today I felt like tidying a bit Planet Wordpress, an unofficial aggregation of feeds about Wordpress I've been maintaining for about 2 years now. The thing was fetching about 80 feeds, of which about a half were... dead, missing in action, or just inactive. It quickly appeared to me than manually reviewing 80 feeds would be [...] → Read more

Filed in: , , , ,
Posted On: 2007 / 05 / 03

A few days ago, Project Honey Pot introduced a new service : http:BL, a blacklist of all the suspicious IPs they are gathering through all the honey pots, and an API allowing anyone to use this blacklist. Their API is very easy to use, and I believe a number of projects (hint) should use it any [...] → Read more

Filed in: , ,
Posted On: 2006 / 06 / 09

Did you know it ? PHP GD's imagecolorallocate() can only allocate 255 colors in a palette based image created by imagecreate() (no such limitation when you use function imagecreatetruecolors() by the way). This sounds pretty stupid as well as rather undocumented, but anyway, here is a new version of my GD Gradient Fill PHP class, which [...] → Read more

Filed in: , , , ,
Posted On: 2006 / 06 / 01

I thought, and had been told, that using constants instead of variables in PHP was mostly a matter of speed : at run time, the engine replaces every occurrence of a constant with its hard-coded value, making code presumably faster than using variables that must be evaluated each time they are encountered. Or something like [...] → Read more

Close
E-mail It