1) { $sql = " SELECT id FROM bookmarks WHERE hash = '$hash' ORDER BY id ASC"; $result = mysql_query($sql) or die($sql.mysql_error()); $row = mysql_fetch_assoc($result); //skip the first bookmark while ($row = mysql_fetch_assoc($result)) { if (!$row['id']) die('error - no id found for dupe bookmark'); $sql = " DELETE FROM bookmarks WHERE id = $row[id] LIMIT 1"; mysql_query($sql.mysql_error()); $sql = " DELETE FROM bookmarks_tags WHERE bookmark_id = $row[id] LIMIT 1000"; mysql_query($sql.mysql_error()); } return true; } //end delete dupe return false; } } class Delimages { public $images = array(); public function getLastImages($number = 100) { $sql = " SELECT link, title, author, tags, bookmarks.id as id FROM images, bookmarks, locations WHERE images.bookmark_id = bookmarks.id AND locations.id = bookmarks.url_id AND locations.created = bookmarks.imported AND images.id > ".($this->numImages() - 100)." ORDER BY bookmarks.id DESC"; $result = mysql_query($sql) or die($sql.mysql_error()); while ($row = mysql_fetch_assoc($result)) { $this->images[] = $row; } } private function getTagId($tag) { $sql = " SELECT id FROM tags WHERE name = '".mysql_real_escape_string($tag)."'"; $result = mysql_query($sql) or die($sql.mysql_error()); $row = mysql_fetch_assoc($result); return $row['id']; } public function getLastImagesForTag($tag) { $sql = " SELECT link, title, author, tags, bookmarks.id as id FROM images, bookmarks, locations, bookmarks_tags WHERE images.bookmark_id = bookmarks.id AND locations.id = bookmarks.url_id AND locations.created = bookmarks.imported AND bookmarks_tags.bookmark_id = bookmarks.id AND images.id > ".($this->numImages() - 9000)." AND tag_id = ".$this->getTagId($tag)." ORDER BY bookmarks.id DESC LIMIT 100"; $result = mysql_query($sql) or die($sql.mysql_error()); while ($row = mysql_fetch_assoc($result)) { $this->images[] = $row; } } public function getLastImagesForUser($user) { $sql = " SELECT link, title, author, tags, bookmarks.id as id, hash FROM images, bookmarks WHERE images.bookmark_id = bookmarks.id AND author = '".mysql_real_escape_string($user)."' ORDER BY bookmarks.id DESC"; $result = mysql_query($sql) or die($sql.mysql_error()); while ($row = mysql_fetch_assoc($result)) { BookmarkUtils::dupecheck($row['hash']); $this->images[] = $row; } } protected static function numImages() { $sql = " SELECT COUNT(*) AS numImages FROM images"; $result = mysql_query($sql) or die($sql.mysql_error()); $row = mysql_fetch_assoc($result); return $row['numImages']; } } class BookmarksRenderer { public $bookmarks = array(); public function renderImages() { header('Content-Type: text/html; charset=utf-8'); $this->renderImagesHtmlHeader(); foreach ($this->bookmarks as $image) { echo "
This is a view of images from del.icio.us. You can filter by a tag, or by a del.icio.us username.
for more structured image feeds, check out bozpages.