I'm playing around with Google Gears, doing data imports, and generally playing around. I'm quite visiually oriented, so I need to SEE that the data has been added to a table. For my conventional PHP / MySQL apps, I usually use phpMyAdmin or the MySQL query browser, but for Gears developmen, which uses SQLite, I needed to use something else.
I'm playing around with Google Gears, particularly the database part, just to see what it's usefull for, and if I can use it in an app I'm working on. At some point I realised that I will need to import data at some point. Here's how I did it:
I want to generate CSS on the fly for a personal project. I'm doing this by redirect all requests for files that does not exist to index.php, and then, if the request is for a stylesheet, index.php generates it.
To identify a request for a stylesheet, we need to parse the Accept header in the HTTP Request. I've grouped all the functions together in a Parser class.
This function retrieves the header, and then determines the mime type, precedence, and tokens for each type given. It's then sorted according to RFC 2616 specifications.
In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php.