roll your own (sort of)

For some reason the thought of using doesn't appeal to me (maybe it's my super secret pr0n links that I don't want public lol) but I would like to be able to have access my links where ever I am. I've been on the road too many times, trying to get some work done, when I could have used a link or to. So, I thought I'd roll my own since I've got this web space and all. The bookmarklet itself is very easy to understand:

javascript:location.href=' bookmarklet.php?url='+encodeURIComponent(location.href)+'&title=' +encodeURIComponent(document.title)+'&extended=' +escape(document.getSelection())

By setting that code as a link in Firefox I can add any link to my bookmarklet database. The database simply contains a link id number, the date the link was made, the page URL, the page title and if I highlight a bit of text on the page before clicking the bookmarklet - it will include that also. [WARNING]As it is the code does no input checking - that is why the php is put into a 'hidden' directory. It's possible someone could do some crafty SQL tricks. Remember to verify any data before inserting it into your database.[/WARNING] I'm just lazy right now - and no one would ever find the script on my server so there. Anyway, on the server side the code for bookmarklet.php is where all of the 'hard work' takes place. //bookmarklet.php - 11/15/05 - function dbconnect() { global $sqlUsername, $sqlHostname, $sqlPassword, $sqlDatabase; $dbcnx = @mysql_connect($sqlHostname, $sqlUsername, $sqlPassword); if (!$dbcnx) { echo( "Unable to connect to the database server at this time. " ); exit(); } if (! @mysql_select_db( $sqlDatabase ) ) { echo( " Unable to locate the database $string at this time. " ); exit(); } } if (isset($_GET['url']) && isset($_GET['title'])){ dbconnect(); $url = $_GET['url']; $title = $_GET['title']; $extended = $_GET['extended']; //no security - for shame! $do_change = mysql_query("INSERT INTO bookmarklet SET date=NOW(),url='$url',title='$title',extended='$extended'"); ?>

When loaded bookmarklet.php first checks to see if the URL and TITLE variables have been set. If they have the it connects to a MySQL database and inserts our bookmark. Once done it drops back to the you bookmarked. If the URL and TITLE variables aren't set then it simply drops back to the page you bookmarked. Maybe tomorrow I'll go over how to display your new links. yawn G'dnight. edit small opps on the code. It's fixed.