Fast Weighted Random Choice In PHP

December 10th, 2008

Sometimes you may need to randomly select items from a list so that some items are selected more frequently than others. For example, you might take a list of applications and their download counts, and randomly pick a “featured application” based on the number of downloads. There are several ways to accomplish this in PHP. […]

Continue Reading...

Cross-Domain POST With JavaScript

November 20th, 2008

Normally you can’t send cross-domain requests in JavaScript due to restrictions imposed by the same-origin security policy. There are many clever hacks that circumvent this by using remote script includes (even CSS includes) or proxy scripts, but so far I haven’t seen anything useful for client-side, cross-domain POST requests. However, it turns out you can […]

Continue Reading...

Displaying Recent Posts On a Non-WordPress Page

November 15th, 2008

Listing recent posts on a WordPress page is easy – there are various widgets and theme functions available just for that purpose. But what about a non-WP page, or even a different site? That’s not that hard either – simply grab some posts from the blog’s RSS feed and output them on your page. In […]

Continue Reading...

Parse, Edit And Create Torrent Files With PHP

November 11th, 2008

A .torrent file contains assorted metadata that is stored in a “bencoded dictionary” format. Bencoding is a relatively simple cross-platform encoding used by BitTorrent and a dictionary is basically an associative array. You can find a high-level overview of the file structure here. To open or edit a .torrent file in PHP you can either […]

Continue Reading...

Private Message Sender Script For vBulletin Forums (PHP)

October 9th, 2008

Random script time! Here’s a PHP function that can send messages to any user on a vBulletin forum. I wrote it because somebody asked me if I could help with their code and I figured it would be easier to write it from scratch. Also, I predict it will be useful to more than one […]

Continue Reading...

Finding Interesting Websites via Google Trends/PHP/AJAX

August 11th, 2008

I have created a PHP/JS script that will let you enter a list of sites and use the Google tool to analyze the sites and generate a list of related websites – a kind of recommendation engine. For example, if you enter a webcomic site A you will probably get a list of other webcomics B, C and D that are also enjoyed by people who read webcomic A.

Continue Reading...

WordPress Admin Password Reset Script

July 30th, 2008

There’s a useful script that you can use to reset your WordPress admin password if you have forgotten it and the “normal” password recovery methods – e.g. using the “Lost your password?” link on the login page – don’t seem to work. It’s a standalone script (not a plugin) and doesn’t require you to be […]

Continue Reading...

How To Get Redirect URL In PHP

July 5th, 2008

HTTP redirects usually have the response status 301 or 302 and provide the redirection URL in the “Location” header. I’ve written three complementary PHP functions that you can use to find out where an URL redirects to (based on a helpful thread at WebmasterWorld). You don’t even need CURL for this – fsockopen() will do […]

Continue Reading...

How To Create a MySQL Database In cPanel With PHP

June 24th, 2008

A PHP class that uses cURL to log in to cPanel. Can create MySQL databases and users, add users to databases, list existing databases, and more.

Continue Reading...

TOR : How To Switch To a New Identity Using PHP

June 20th, 2008

A simple PHP function that can make TOR switch to a new identity. The script also supports TOR authentication.

Continue Reading...

RSS Feeds for DeviantART Notifications

June 9th, 2008

I thought it would be handy if I could get the various DA notifications (deviantWATCH, new comments on your deviations, etc) as a RSS feed, so I created a PHP script that can log into a DA account and generate the feed. It creates three feeds – New deviations from your deviantWATCH (with thumbnails!). Messages […]

Continue Reading...

Improved Thread Simulation Class for PHP

May 24th, 2008

Two classes that use asynchronous HTTP POST requests to simulate multithreading (works on Windows, too!). The Thread class simulates a single thread of execution, whereas ThreadManager is an utility class that makes handling multiple threads easier.

Continue Reading...

Building a DeviantArt Recommendation Engine

April 29th, 2008

DeviantArt, with its huge number of artworks and a large userbase, is just the kind of site that could use a good recommendation engine. A recommendation engine is basically a program that analyzes your tastes and recommends some images that you might like. There do not seem to be any official plans to create a recommendation system. So I went ahead and started building my own recommendation engine for DA.

Continue Reading...

Simple Text Summarizer In PHP

April 12th, 2008

I’ve written a simple text summarizer that can find the most important sentences in any given (English) text and produce a summary of the specified length. It would be pretty easy to adapt the PHP script to other languages, too.

Continue Reading...

Scrape Google Blog Search With PHP

March 28th, 2008

I’m currently lacking real “bloggable” ideas, so here’s something simple and hopefully useful – a PHP script to get the blog search results from Google. The script is provided strictly for educational purposes, blah blah blah. And by the way, if you only need the top X results, it would be simpler to use the […]

Continue Reading...

Get Google Image Search Results With PHP

February 28th, 2008

Google Image Search doesn’t get as much time in the spotlight as the “normal” Web Search, but it’s still useful for things like finding suitable illustrations for an article (Flickr also comes to mind). Whatever you use it for, you can often get results faster with a bit of automation. Here’s a simple PHP script that can parse and return the results of any Image Search query. For education purposes only.

Continue Reading...

Random Person Name Generator

February 7th, 2008

I decided to put a person name database I found to good use and make a person name generator. Here it is! The generator uses Markov chains. Most of the source code is available for download.

Continue Reading...

Extracting The Main Content From a Webpage

January 25th, 2008

I’ve created a PHP class that can extract the main content parts from a HTML page, stripping away superfluous components like JavaScript blocks, menus, advertisements and so on. The script isn’t 100% effective, but good enough for many practical purposes. It can also serve as a starting point for more complex systems.

Continue Reading...

Raw HTML Plugin for WordPress

December 13th, 2007

Recently I needed to put some style definitions and a JavaScript function in a post on another blog that I have. I wasted several hours trying to do this, because WordPress insisted on putting backslashes in front of my apostrophes, inserting superfluous <p> or <br /> tags in place of newlines, and generally breaking my HTML in various horrible ways.

In the end I decided to just go and write a plugin that would let me put any code or script in my posts and display it to the visitor unmodified.

Continue Reading...

Detect Users Accessing Your Site Via a Proxy

November 23rd, 2007

The are many reasons why someone might want to detect if users are accessing their site via a proxy. For one, all spammers use proxies. Proxies can also be used to cheat voting systems, create multiple accounts when only one account is allowed or make it appear like the user is browsing from a different […]

Continue Reading...

Comment Spam Down By 96% – It’s Simple

November 17th, 2007

For months I’ve been getting dozens of spam comments, sometimes over a hundred per day. Most of them are caught by Akismet, which is great. The problem is that with high numbers of spam comments it’s virtually impossible to look through the spam filter logs and de-spam false positives. The bandwidth and processing power wasted […]

Continue Reading...

Make A WordPress Plugin Now! – Plugin Generators of Doom

November 10th, 2007

I’ve been following WP plugin development-related news for a week or two now, and I’ve noticed something that could make creating a plugin easier – plugin generators. These tools can create a handy template for your new plugin so you don’t need to start completely from scratch; you still need to know (at least) PHP to make your plugin do anything useful, though. In this post I’ll review three WordPress plugin generators I’ve come across.

Continue Reading...

See Which Plugins Have Update Notifications Enabled

November 7th, 2007

I’ve added a new feature to my single-click WorPress plugin updater – now you can see which of your plugins are checked for updates. Those plugins that have update notifications enabled will be marked by a golden bar-thingy in the “Plugins” tab. This is useful to see which plugins will notify you when an update […]

Continue Reading...

Single Click Plugin Updater WordPress Plugin

October 19th, 2007

This plugin extends the plugin update notification feature introduced in WordPress 2.3 by adding an “update automatically” link to update notifications. When you click the link, the new version of the corresponding plugin is downloaded and installed automatically. It also lets you know which plugins have update notifications enabled. Update 06.04.2008 : Version 2.0.1 with […]

Continue Reading...

How To Run A PHP Script In The Background

October 16th, 2007

If you have a PHP script that takes a while to execute (for example, long database operations or file format conversions), you might want to run it in the background so that the rest of your page still loads fast. In this post I’ll describe two ways to do this. Launching a background process One […]

Continue Reading...

Broken Link Checker Plugin 0.2 Update

October 13th, 2007

The Broken Link Checker WordPress plugin has been updated to version 0.2! Here’s what’s new – Link checking algorithm has been improved and shouldn’t generate false warnings anymore. Links that are discovered to not work will be re-checked again a few minutes later. This is useful if the link only appeared to be broken due […]

Continue Reading...

PHP Frameworks Are Evil

October 10th, 2007

Shoot Yourself in The Foot More Efficiently If you’re unfamiliar with how frameworks function, trying to use a framework for a new project will bring trouble. With all the complexities frameworks bring, new bugs will come, too. Besides, small one-man projects typically don’t require a framework. MVC Isn’t A Framework-exclusive Feature See the bare-bones MVC […]

Continue Reading...

How To *Really* Upload Files With PHP

October 8th, 2007

I’ve noticed that whenever I search for a “php upload script” or “how to upload files”, the first page of Gogle results is full of pages that tell you how to handle file uploads = letting users to upload something to your server. But what if you actually want to create a PHP script that […]

Continue Reading...

See The Most Dugg Sites

October 3rd, 2007

I’ve created an online tool that displays the sites that received the most votes (diggs) during the last 7 days. Features The classic Top 10 list. The huge Top 100 list. Sites ranked by the total number of diggs received on all stories submitted in the last 7 days. Click the “Popular stories” column heading […]

Continue Reading...

Checking If Page Contains a Link In PHP

September 25th, 2007

Sometimes it is necessary to verify that a page really contains a specific link. This is usually done when checking for a reciprocal link in link exchange scripts.

Continue Reading...