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...

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...

Plugin Updater 2.1

April 21st, 2008

Here’s another upgrade for the One Click Plugin Updater. Now with even more potentially deadly features!
What’s New
Global update notices (≥ WP 2.5)
Displays an update notification bar on all admin pages when there are new plugin updates available. The update notice will list all available upgrades and include a link to perform them all [...]

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...

One Click Updater Plugin 2.0

April 6th, 2008

This version of the WordPress plugin has a lot of new features, and, quite probably, a lot of new bugs, too. In fact, it’s so experimental it even glows in the dark
The plugin, which I’ve alternatively called “One Click Updater” and “Single Click Updater” in the past (no doubt to confuse everyone, including [...]

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 Blogsearch’s [...]

Continue Reading...

Free Tools for Natural Language Processing

March 13th, 2008

I’ve compiled a list of various Python modules and functions that I found most useful in certain Natural Language Processing tasks. For easier skimming, the list is grouped by NLP task, such as tokenization and tagging.

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...

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...

Search The Current Site - A Firefox Extension

December 1st, 2007

There are lots of search engine plugins for Firefox, and it’s easy to make a simple search plugin for your own site. That’s why it came as a bit of a surprise that I couldn’t find any search engine plugins for searching the currently open site. So I created one. Download it here.

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...

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...

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 approach is [...]

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 and the framework [...]

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...

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...

Obscure CreateRemoteThread Problem

August 30th, 2007

Yesterday I spent several hours trying to finally figure out why my wsTaskborg application failed to work when run run in a second session on the same PC. That is, when you first log on - using whichever account you have - it works fine. If you then use “fast user switching” and log on [...]

Continue Reading...

PHP Multithreading - Faking It

August 20th, 2007

PHP doesn’t really support multi-threading per se but there are ways to do “fake” multithreading. Here’s one I saw in the PHPClasses.org newsletter - Multi-thread Simulation.
Note that this class is intedend for use on a webserver, as opposed to running PHP scripts from a command line (or similar). Check the end of this post for [...]

Continue Reading...

How To Force File Download With PHP

August 12th, 2007

Say you want a PHP script that will make the browser to download a file instead of opening it. This is useful for common filetypes that would normally be displayed in a browser, like .html, images, PDFs and .doc files.
You can find a lot of scripts that do this on the web but one thing [...]

Continue Reading...

WordPress Killed My Code

August 2nd, 2007

…but that’s okay - WP-Syntax resurrected it.
After looking at one of my earlier posts I noticed that all the backslashes were gone from my code examples, most notably my regular expressions. I had the code wrapped in <pre></pre> tags. As some searching revealed, this seems to be a recurrent bug in WordPress 2.2.1 (I upgraded [...]

Continue Reading...

How To Check If Page Exists With CURL

August 2nd, 2007

Here’s a relatively simple PHP function that will check if an URL really leads to a valid page (as opposed to generating “404 Not Found” or some other kind of error). It uses the CURL library - if your server doesn’t have it installed, see “Alternatives” at the end of this post. This script may [...]

Continue Reading...

How To Read/Write Icons With PHP

July 30th, 2007

I discovered this interesting PHP class today that can be used to process all kinds of .ico files in PHP.
Features

Read/write icon files.
Extract individual icons from a multi-icon file as GD icon resources.
Add new icons to an .ico file.
Supports all icon image sizes, bit depths and transparency.

You can find the source code on PHPClasses.org (you’ll need [...]

Continue Reading...

A Silly Way To Get Backlinks

July 22nd, 2007

The 3 Easy Steps

Create an application
It doesn’t have to be anything special. One way is to find a free screensaver builder and use a bunch of royalty-free photos to make your own slideshow screensaver. Make the application freeware - it’s easier and faster. If you actually create something worthy, you might set up a vendor [...]

Continue Reading...

Concurrent Processing And PHP+MySQL, And Challenges Abound

July 19th, 2007

What would you do if you wanted to run several instances of a PHP script that each work on a portion of a MySQL table, without interfering with each other and trying to grab the same rows? I don’t know the correct answer to this, but here’s what I did. It’s a rant, yeah.

Continue Reading...

How To Extract All URLs From A Page Using PHP

July 16th, 2007

A PHP function that extracts all URLs from a page and another one that translates a relative URL to absolute URL. Originally I wrote this for a crawler script.

Continue Reading...

Logging In With CURL and PHP

July 7th, 2007

This is an example of how you can use CURL to “log in” and retrieve some protected info. I’ve showed the somewhat extreme case where you need to maintain cookies, spoof HTTP referer and use SSL. The example page used here is ClickBank - one of the largest digital product retailers. I’ve tried to comment [...]

Continue Reading...