PHP

Decoding gzinflate base54_decode

Some themes add a copyright notice using a technique also seen in hack scripts. They take the PHP code, and the base64 encode it, and gzip it.

Code Is Usually Not Data

One of the big problems with PHP is the include statement. You can include a file. You can define that file at runtime, and alter it during runtime.

AJAX Caching Data with Javascript

Here's a way to cache data on the client side, via javascript. This was tested on Firefox 3.6.3 on Ubuntu.

The idea is to convert your data into Javascript, and then load it with the SCRIPT tag. You then use the Expires HTTP header to tell the client how long to cache the data. Finally, you use some Javascript code to display the data.

CodeIgniter loader class? WTF?

Here is something I can't understand The CodeIgniter Loader class.

It's just weird. When you load a class, it's instantiated and made an attribute of the $this object. That has a real "Javascript" feel to it.

Beyond that, I think class loaders sometimes obfuscate where the included files reside. That might seem okay, or even "cool", but I find it annoying.

What is dirname(__FILE__) about?

The old Slaptech framework had the old PHP includes problem, where one cannot to include() a file relative to the current file.

PHPList Tweak for Plain Text Version of HTML Mail

This small alteration to the PHPList code will produce better line breaks.

sendemaillib.php:

  $text = preg_replace("/<\/p\s*?>/i","<\/p>\n\n",$text);

Keyword Analysis or Discovery (a first try)

I was messing around with some textual analysis, trying to figure out how to do a "related articles" feature in Drupal.

Method Chaining, some opinions

A few years back, method chaining got to be all the rage, and now it's common.

Testing for Hack Scripts, Scan Your Uploads

This was ripped from a patch I made to ZenCart to deal with malicious uploads. It was stripped from a class, and it should probably be worked into pretty much any uploader class.

HPHP: HipHop from Facebook

HPHP Initial Comment
HipHop what you need to know

HPHP appears to be a significant product: a PHP compiler that compiles down to native binaries, saving time and CPU. It produces a monolithic, multithreaded binary.

A nice side effect could be that sites using HPHP would be a harder to hack. For one, you could never upload and execute a PHP script, because PHP is not running on the server.

HipHop leverages a simple fact of PHP-life: most of your code doesn't change. Even in a project with ongoing bugfixes, only a small number of changes are deployed. So, once the app's done and ready to be run full-time, it should really become a compiled application. HipHop is the compiler.

Convert Text to HTML PHP Function

How many times has this wheel been reinvented? According to Google searches, not enough - because I couldn't find a good one. Over the years, I've definitely build this wheel a few times, so, here goes again. This is a lot better than the stock nl2br() function.

The attached code and test files show it off, and only a description follows.

RLIB: report generation engine

Rlib is a report writing engine that takes report specifications in an XML language. It emits reports in several formats including HTML and PDF.

Visit RLIB

I stumbled across RLIB while figuring out how to implement some MS Access report writing features in PHP. MSA users will know what writing a report is, but PHP coders probably don't, so I'll explain.

Inserting Breaks Into a Stream of Values (turning lists into tables)

A couple years back, I used a technique to simplify code that iterates over an array and displays it as a table.

All Your Applications Are Belong to Us

The Glassfish server includes a Ruby and Rails implementation.

There's a Java Python that's well established.

More on Iterators and Iteration

Iterators are one of my favorite language features or design pattern. They're a feature that, when done correctly, basically vanishes.

.

Syndicate content