diff -urN scuttle-orig/api/posts_add.php scuttle/api/posts_add.php
--- scuttle-orig/api/posts_add.php	2005-03-26 20:11:40.000000000 -0500
+++ scuttle/api/posts_add.php	2005-08-10 18:36:35.136184748 -0400
@@ -28,13 +28,16 @@
 if (isset($_REQUEST['dt']) and (trim($_REQUEST['dt']) != ""))
 	$dt = trim($_REQUEST['dt']);
 else $dt = NULL;
+if (isset($_REQUEST['del']) and (trim($_REQUEST['del']) != ""))
+	$del = trim($_REQUEST['del']);
+else $del = true;
 
 //	Error out if there's no address or tags.
 if (is_null($url) or is_null($tags)) $added = false;
 else {
 	//	We're good with info; now insert it!
 	//	addBookmark($address, $title, $description, $status, $categories, $date = NULL, $fromApi = false)
-	$bId = addBookmark($url, $description, $extended, 0, $tags, NULL, true);
+	$bId = addBookmark($url, $description, $extended, 0, $tags, NULL, true, $del);
 	if ($bId === false) $added = false;
 	else $added = true;
 }
@@ -44,4 +47,4 @@
 echo "<?xml version=\"1.0\" standalone=\"yes\"?>\r\n";
 echo "<result code=\"" . ($added ? "done" : "something went wrong") . "\" />";
 
-?>
\ No newline at end of file
+?>
diff -urN scuttle-orig/bookmarks.php scuttle/bookmarks.php
--- scuttle-orig/bookmarks.php	2005-04-23 21:41:56.000000000 -0400
+++ scuttle/bookmarks.php	2005-08-10 19:31:30.511306633 -0400
@@ -31,6 +31,9 @@
 	$setTitle .= ": ". str_replace('+', ' + ', $cat);
 if ($page)
 	$setTitle .= ": ". $page;
+
+$userInfo = getUserInfo($user);
+
 if (!$cat || is_numeric($cat)) {
 	$page = $cat;
 	$cat = NULL;
@@ -61,7 +64,20 @@
 				loadXMLDoc('<?= $root ?>ajaxGetTitle.php?url=' + input);
 		}
 	}
-	<?php
+
+  <?php 
+    if ($userInfo['delicious_username'] && $userInfo['delicious_password'])
+      echo "
+  function showDelCheck(val) {
+    del = document.getElementById('del');
+    delLabel = document.getElementById('delLabel');
+
+    // toggle visiblity of both elements
+    str = val ? 'none' : 'inline'; 
+    del.style.display = delLabel.style.display = str;
+  }
+  ";
+
 	include("deleteBookmark.inc.php");
 	include("ajax.inc.php");
 	?>
@@ -126,8 +142,9 @@
 			$description = trim($_POST['description']);
 			$status = intval($_POST['status']);
 			$categories = trim($_POST['tags']);
+      $del = trim($_POST['del']);
 			$saved = true;
-			$bId = addBookmark($address, $title, $description, $status, $categories);
+			$bId = addBookmark($address, $title, $description, $status, $categories, NULL, false, $del);
 ?>
 
 <p class="success">Bookmark saved.</p>
@@ -173,11 +190,25 @@
 	<tr valign="top">
 		<th align="left">Privacy</th>
 		<td>
-			<select name="status">
+      <?php
+        if ($userInfo['delicious_username'] && $userInfo['delicious_password']) 
+          $onChange = 'showDelCheck(form.status.value != 0);';
+        else
+          $onChange = '';
+      ?>
+
+			<select onChange='<?= $onChange ?>' name="status">
 				<option value="0">Public</option>
 				<option value="1">Shared with Watch List</option>
 				<option value="2">Private</option>
 			</select>
+      <?php
+        if ($userInfo['delicious_username'] && $userInfo['delicious_password']) {
+          # TODO: this whole checked='1' business should probably be
+          # configurable
+          echo "<input type='checkbox' id='del' name='del' checked='1' /> <label id='delLabel' for='del'>Post to Delicious</label>\n";
+        }
+      ?>
 		</td>
 		<td></td>
 	</tr>
@@ -303,7 +334,6 @@
 	<div id="profile">
 		<ul>
 		<?php
-		$userInfo = getUserInfo($user);
 		if ($userInfo['name'] != "") {
 		?>
 			<li><?= $userInfo['name'] ?></li>
@@ -402,4 +432,4 @@
 ?>
 
 </body>
-</html>
\ No newline at end of file
+</html>
diff -urN scuttle-orig/delPost.php scuttle/delPost.php
--- scuttle-orig/delPost.php	1969-12-31 19:00:00.000000000 -0500
+++ scuttle/delPost.php	2005-08-10 18:23:28.003309404 -0400
@@ -0,0 +1,50 @@
+<?php
+
+# check to make sure we're running from the command-line
+if (!$_SERVER['argv'] || !$_SERVER['argc'])
+  exit;
+
+# grab ARGC, ARGV, and check them
+list($argc, $argv) = array($_SERVER['argc'], $_SERVER['argv']);
+if ($argc != 7)
+  die("Missing command-line arguments.\n");
+  
+# fork
+$pid = pcntl_fork();
+
+if ($pid == 0) {    # child
+  # detach from terminal, etc
+  if (!posix_setsid())
+    die("posix_setsid() error.\n");
+
+  # close stdin, stdout, and stderr
+  fclose(STDIN);
+  fclose(STDOUT);
+  fclose(STDERR);
+
+  # load includes
+  require './dbconnection.inc.php';
+  require './delicious.inc.php';
+
+  # strip command name from ARGV
+  array_shift($argv);
+  
+  # grab arguments
+  list($sId, $address, $title, $desc, $cats_str, $time) = $argv;
+  
+  # expand category string
+  $categories = array();
+  if ($cats_str)
+    $categories = unserialize($cats_str);
+  
+  # actual call to delicious
+  addDeliciousBookmark($address, $title, $desc, $categories, $time);
+} elseif ($pid > 0) { # parent
+  # reap child (prevent zombies)
+  pcntl_waitpid($pid, $waitpid_status, WNOHANG);
+} else {
+  die("pcntl_fork() error.\n");
+}
+
+exit;
+?>
diff -urN scuttle-orig/delicious.inc.php scuttle/delicious.inc.php
--- scuttle-orig/delicious.inc.php	1969-12-31 19:00:00.000000000 -0500
+++ scuttle/delicious.inc.php	2005-08-10 18:31:22.266617426 -0400
@@ -0,0 +1,59 @@
+<?php
+
+$DELICIOUS_OPTIONS = array(
+  # URL to the delicious add call
+  'add_url'  => 'del.icio.us/api/posts/add',
+);
+
+function addDeliciousBookmark($address, $title, $description, $categories, $time) {
+  global $sId, $DELICIOUS_OPTIONS;
+
+  # check to make sure we have some options
+  if (!isset($sId) || !$DELICIOUS_OPTIONS)
+    return;
+
+  # build query
+  $query = "SELECT delicious_username AS user, 
+                   delicious_password AS pass
+              FROM scUsers
+             WHERE uId = " . intval($sId) . "
+               AND delicious_username != ''
+               AND delicious_password != ''";
+
+  # execute query
+  if (($r = mysql_query($query)) && mysql_num_rows($r) > 0) {
+    # grab the first (only) result
+    $h = mysql_fetch_assoc($r);
+
+    # build delicious URL
+    $delicious_url = ('http://' . 
+      # delicious username and password
+      urlencode($h['user']) . ':' . urlencode($h['pass']) . '@' .
+
+      # base URL for delicious REST interface
+      $DELICIOUS_OPTIONS['add_url'] . '?' . 
+
+      # post URL
+      'url=' . urlencode($address) . '&' .
+    
+      # post title
+      'description=' . urlencode($title) . '&' .
+
+      # post description
+      'extended=' . urlencode($description) . '&' . 
+
+      # post tags
+      'tags=' . urlencode(join(' ', $categories)) . '&' .
+
+      # post timestamp
+      'dt=' . urlencode(gmstrftime('%Y-%m-%dT%H:%M:%SZ', $time))
+    );
+
+    # print out debugging information
+    # echo "DEBUG: fetching '$delicious_url'";
+
+    # make request, ignore response
+    $result = @file_get_contents($delicious_url);
+  }
+}
+?>
diff -urN scuttle-orig/functions.inc.php scuttle/functions.inc.php
--- scuttle-orig/functions.inc.php	2005-04-22 01:04:34.000000000 -0400
+++ scuttle/functions.inc.php	2005-08-10 19:22:12.493497688 -0400
@@ -1,5 +1,12 @@
 <?php
 
+# attempt to chain posts to delicious?
+$USE_DELICIOUS = true;
+
+# path to php command-line interpreter
+$PHP_CLI_PATH = '/usr/bin/php4';
+
+
 function filter($string, $type = NULL) {
 	$string = trim($string);
 	$string = stripslashes($string);
@@ -309,10 +316,10 @@
 	return $tagarray;
 }
 
-function addBookmark($address, $title, $description, $status, $categories, $date = NULL, $fromApi = false) {
+function addBookmark($address, $title, $description, $status, $categories, $date = NULL, $fromApi = false, $post_to_delicious = false) {
 	//	Adds a bookmark to the database; assumes that the DB connection is already up and running.
 	//	Note that date is expected to be a string that's interpretable by strtotime().
-	global $sId, $sName;
+	global $sId, $sName, $USE_DELICIOUS, $PHP_CLI_PATH;
 	//	Make sure that categories is an array of trimmed strings, and that if the categories are
 	//	coming in from an API call to add a bookmark, that underscores are converted into strings.
 	if (!is_array($categories)) {
@@ -355,6 +362,26 @@
 			if (!$result or (mysql_errno() != 0)) return false;
 		}
 	}
+
+  # check for delicious 
+  if ($USE_DELICIOUS && $post_to_delicious && $status == 0) {
+    # define working escape shell arg command (one that won't fuck up
+    # commands with positional parameters)
+    function safe_escapeshellarg($str) {
+      return ($str == '') ? "''" : escapeshellarg($str);
+    }
+
+    # build array of command and command-line arguments
+    $cmd_args = array($PHP_CLI_PATH, './delPost.php', $sId, $address, $title, $description, serialize($categories), $time);
+
+    # serialize and escape command and arguments
+    $cmd = join(' ', array_map('safe_escapeshellarg', $cmd_args));
+
+    # execute command
+    $cmd_result = shell_exec($cmd);
+    # echo "\$cmd = '$cmd': result: $cmd_result";
+  }
+  
 	//	Everything worked out, so return the new bookmark's bId.
 	return $bId;
 }
@@ -412,4 +439,4 @@
 	return true;
 }
 
-?>
\ No newline at end of file
+?>
diff -urN scuttle-orig/profile.php scuttle/profile.php
--- scuttle-orig/profile.php	2005-04-16 11:03:30.000000000 -0400
+++ scuttle/profile.php	2005-08-10 14:53:50.000000000 -0400
@@ -57,6 +57,8 @@
 	$detMail = trim($_POST['pMail']);
 	$detPage = trim($_POST['pPage']);
 	$detDesc = filter($_POST['pDesc']);
+  $detDelUser = trim($_POST['pDelUser']);
+  $detDelPass = trim($_POST['pDelPass']);
 	if ($detName == "" || $detMail == "") {
 		$error = true;
 		$errorMsg .= '<p class="error">Your name and e-mail address are required and must be completed.</p>';
@@ -80,9 +82,9 @@
 	if (!$error) {
 		$datetime = date('Y-m-d H:i:s', time());
 		if ($detPass != "")
-			$query = "UPDATE scUsers SET uModified = '". $datetime ."', password = '". sha1($detPass) ."', name='". mysql_escape_string($detName) ."', email='". mysql_escape_string($detMail) ."', homepage='". mysql_escape_string($detPage) ."', uContent='". mysql_escape_string($detDesc). "' WHERE username = '". mysql_escape_string($user) ."'";
+			$query = "UPDATE scUsers SET uModified = '". $datetime ."', password = '". sha1($detPass) ."', name='". mysql_escape_string($detName) ."', email='". mysql_escape_string($detMail) ."', homepage='". mysql_escape_string($detPage) ."', uContent='". mysql_escape_string($detDesc). "', delicious_username='" . mysql_escape_string($detDelUser) . "', delicious_password='" . mysql_escape_string($detDelPass) . "' WHERE username = '". mysql_escape_string($user) ."'";
 		else
-			$query = "UPDATE scUsers SET uModified = '". $datetime ."', name='". mysql_escape_string($detName) ."', email='". mysql_escape_string($detMail) ."', homepage='". mysql_escape_string($detPage) ."', uContent='". mysql_escape_string($detDesc). "' WHERE username = '". mysql_escape_string($user) ."'";
+			$query = "UPDATE scUsers SET uModified = '". $datetime ."', name='". mysql_escape_string($detName) ."', email='". mysql_escape_string($detMail) ."', homepage='". mysql_escape_string($detPage) ."', uContent='". mysql_escape_string($detDesc). "', delicious_username='" . mysql_escape_string($detDelUser) . "', delicious_password='" . mysql_escape_string($detDelPass) . "' WHERE username = '". mysql_escape_string($user) ."'";
 		$result = mysql_query($query) or die ("Invalid query");
 ?>
 
@@ -170,6 +172,10 @@
 			<dd><?= date('Y-m-d', strtotime($row['uDatetime'])) ?></dd>
 		<dt>Description</dt>
 			<dd><textarea name="pDesc" cols="75" rows="10"><?= $row['uContent'] ?></textarea></dd>
+    <dt>Delicious Username</dt>
+    <dd><input type="text" name="pDelUser" size="75" value="<?= $row['delicious_username'] ?>" /></dd>
+    <dt>Delicious Password</dt>
+    <dd><input type="password" name="pDelPass" size="75" value="<?= $row['delicious_password'] ?>" /></dd>
 		<?php
 		$watchnames = getWatchNames($user);
 		if ($watchnames) {
@@ -202,4 +208,4 @@
 ?>
 
 </body>
-</html>
\ No newline at end of file
+</html>
diff -urN scuttle-orig/tables.sql scuttle/tables.sql
--- scuttle-orig/tables.sql	2005-04-16 18:20:26.000000000 -0400
+++ scuttle/tables.sql	2005-08-10 19:17:29.251502555 -0400
@@ -55,6 +55,8 @@
   `name` varchar(50) NOT NULL default '',
   `email` varchar(50) NOT NULL default '',
   `homepage` varchar(100) default NULL,
+  `delicious_username` varchar(64) NOT NULL DEFAULT '',
+  `delicious_password` varchar(64) NOT NULL DEFAULT '',
   `uContent` text,
   PRIMARY KEY  (`uId`)
-) TYPE=MyISAM PACK_KEYS=0;
\ No newline at end of file
+) TYPE=MyISAM PACK_KEYS=0;

