--- shorturl.module	2010-08-17 19:16:09.000000000 -0400
+++ shorturlPatched.module	2010-11-04 18:55:14.000000000 -0400
@@ -19,15 +19,20 @@ function shorturl_init() {
   if (!empty($token)) {
     $indx = shorturl_decode_url($token);
     if (is_numeric($indx)) {
-      $orig_url = db_result(db_query('SELECT orig_url FROM {shorturl_link} WHERE lid=%d ', $indx));
+      $urlObj = db_fetch_object(db_query('SELECT orig_url, onetime FROM {shorturl_link} WHERE lid=%d ', $indx));
     }
 
+    $orig_url = $urlObj->orig_url;
     if (!empty($orig_url)) {
       if (stripos($orig_url, 'http') === FALSE && 
           stripos($orig_url, 'https') === FALSE) {
         $orig_url = url($orig_url, array('absolute'=>TRUE)); //Let drupal make relative URLs absolute
       }
       
+      // Remove onetime link
+      if (!empty($urlObj->onetime))
+        db_query('DELETE FROM {shorturl_link} WHERE lid=%d', $indx);
+
       drupal_goto($orig_url,  $query = NULL, $fragment = NULL, $http_response_code = 301);
       exit();      
     }
@@ -68,17 +73,20 @@ function shorturl_menu() {
 *
 * @param $long_url
 *   the original URL
+*   
 *
 * @param $full_url
 *   return full URL with the domain set in the admin settings or the domain of the Drupal installation if 
 *   the former is empty. FALSE by default.
+* @param $one_time
+*   generate one time link which will be removed once used
 *
 * @return shortened URI token or full shortened URL
 *
 */
-function shorturl_shorten ($long_url, $full_url = FALSE) {
+function shorturl_shorten ($long_url, $full_url = FALSE, $one_time = 0) {
 
-  $token = _shorturl_get_token($long_url);
+  $token = _shorturl_get_token($long_url, $one_time);
   
   if ($full_url) {
     
@@ -119,10 +127,13 @@ function shorturl_default_domain() {
 * @param $long_url
 *   the original URL
 *
+* @param $one_time
+*   generate one time link which will be removed once used
+*
 * @return short URL token.
 *
 */
-function _shorturl_get_token($long_url) {
+function _shorturl_get_token($long_url, $one_time = 0) {
 
 	//-- Let modules alter original URL if/as necessary
 	$hook = 'shorturl_originalurl_alter';
@@ -150,6 +161,7 @@ function _shorturl_get_token($long_url) 
   $link->orig_url = $long_url; 
   $link->created = (int)time();
   $link->remote_ip = $remote_ip;
+  $link->onetime = $one_time;
   
   $last_id = db_result(db_query('SELECT max(lid) FROM {shorturl_link}'));
   if ($last_id < SHORTURL_START_FROM) {$last_id = SHORTURL_START_FROM;}
@@ -175,7 +187,7 @@ function _shorturl_get_token($long_url) 
     // Make sure nobody inserted a record with this $lid, while we were checking other stuff    
     else {
       $link->lid = $last_id;
-      $status = @drupal_write_record('shorturl_link', $link);
+      $status = @db_query('INSERT INTO {shorturl_link} VALUES(%d, "%s", %d, "%s", %d)', $link->lid, $link->orig_url, $link->created, $link->remote_ip, $link->onetime);
       if (!$status) {
         $found_vacant = FALSE;
         $last_id++;
@@ -212,7 +224,6 @@ function shorturl_check_availability($to
   return TRUE;
 }
 
-
 function shorturl_reserved_tokens() {
   $reserved_settings = variable_get('shorturl_reserved_tokens', array());
   
