Showing posts with label PHP's Built In Server. Show all posts
Showing posts with label PHP's Built In Server. Show all posts

Turn PHP Built in Web Server into a Proxy

PHPMonkey? I wanted to use PHP to alter web pages and http traffic, so I downloaded many scripts that said they were PHP proxy. I didn't find any that really worked, they all just fetched the page, mangled all the links, and puked it back at me. I couldn't log in to any website, and if the site I was visiting used javascript to inject links, scripts, and all sorts of other dynamic content these so called proxies failed horribly. So, I figured I'd try writing one myself, and I've come up with something that works.

Autoindex for PHP Built in Web Server

Today, while working on the Atropa Toolbox, I wanted an autoindexing option for the PHP built in webserver like the Apache HTTP server has. By default the PHP server was giving me 404 errors whenever I would request a directory that didn't have an index.php file in it. The documentation said that the PHP command line web server would recognize index.html files but that didn't appear to be working for me. There wasn't a chance I was going to create hundreds of index.php files just to be able to navigate through directories on my server, so I wrote a router script to automatically generate a hyperlinked list of files and directories when I reach a folder that doesn't have an index.php or index.html file. The router recognizes index.html and will redirect the browser to it if present. While it isn't as fancy as the autoindexing options on the Apache server, it gets the job done. I can now click on the names of files and folders and make my way through the filesystem on the PHP commandline webserver. If you would like a copy of the router I'll post the code below. Any updates I make to this basic router will be incorporated into the Atropa Toolbox currently hosted on google code.

PHP's Built In Server: Super Fun Basic Example

PHP's Built In Server: Super Fun Basic Example


So I'm half asleep at 8 p.m. Surfing the net and typing and
probably dreaming of inebriated ducks gleefully flapping
Poised and paddling in slanted lines across the swamp
Inside my head

Wait...