Php only serving one page at a time [fix!]

No Comments

After years of confusion I finally found the solution to why php was only serving one page at a time.

When you execute session_start() the session array for that user gets locked to prevent concurrent write errors. Until the script finishes or you run session_write_close() any other script that tries to access that session will stall.

So, the fix is to run session_write_close() after you are done writing session data but before anything time consuming (large shell_exec()s, sql querys, downloads).

SFSU Opera Gala: Papageno Papagena Duet

No Comments

Last Friday I performed the Papageno Papagena Duet in San Francisco State’s Opera Gala. Papagena is sung by my friend Sanja Wetzel and the whole ordeal was staged by Alissa Deeter. Video:

papagena/papageno duet from die zauberflöte from sanjwich on Vimeo.

Your Debut Album (Automated)

3 Comments

The internet has spawned a hilarious method for determining Your Debut Album and the results are surprisingly hilarious. It works like this:

1 – Go to http://en.wikipedia.org/wiki/Special:Random
The first random Wikipedia article you get is the name of your band.

2 – Go to Random quotations: http://www.quotationspage.com/random.php3
The last four words of the very last quote of the page is the title of your first album.

If you want to do this again, you’ll hit refresh to generate new quotes, because clicking the quotes link again will just give you the same quotes over and over again.

3 – Go to flickr’s “explore the last seven days” http://www.flickr.com/explore/interesting/7days/
Third picture, no matter what it is, will be your album cover.

Put it all together, that’s your debut album.

I found this very funny, so I wrote a quick and dirty script to automate the process, and I must say, seeing an actual image of the album only makes it funnier. Have your debut album automatically generated here. Be patient though, it takes a second to get all the data and put it together. The images are fully bookmarkable/shareable and you can simply hit refresh to get a new one!

Let me know what you think in the comments.

PHP: Avatar Hack

2 Comments

I am a member of a web forum which allows you to use an Avatar image of your choice. You simply give them the url of the image. The ability of php to generate images lead me to try to come up with ways to take advantage of this system.

My first attempt at a dynamically generated avatar was thwarted by the sites form verification. It rejected my avatar because it pointed to a .php file instead of an image file. To get around this, I created a directory called:

/avatar.jpg

that contained an index.php file. Therefore when a user requests:

http://www.classicalcode.com/avatar.jpg

the server resolves that to:

http://www.classicalcode.com/avatar.jpg/index.php

and that script generates an image which it then returns with .jpg headers.

Now that the image is dynamically generated, the question is: what can the script do? Currently it logs ip addresses, browsers and operating systems, does a google image search, finds a random image for a search term, and displays that image along with the users ip and the total times that the avatar has been requested. The source code can be found here: avatar_source.txt