--- /dev/null
+#!/bin/sh
+
+HTTP_COOKIE='id=____________'
+mkdir -p 'users/____________'
+. ./index.cgi >&-
+
+seq=$(date +%s)
+seqid(){
+ { printf "$(
+ while [ -n "$seq" -a "${seq}" -gt 0 ]; do
+ # ^^ double condition seems necessary in dash
+ # (possibly due to faulty result caching?)
+ printf \\%o $((seq % 256))
+ seq=$((seq / 256))
+ done
+ )" | tac
+ head -c5 /dev/urandom
+ } \
+ | uuencode -m - \
+ | sed -n '2{y;+/;:_;;p}'
+}
+
+
+import="$1"
+order=1000
+BDB="users/$(genid)"
+
+mkdir -p "${BDB}/favicons"
+
+while read l; do
+ case "$l" in
+ folder=*)
+ fid="$(seqid)"
+ name="$(QUERY_STRING="$l" GET folder)"
+ file="${BDB}/${fid}.bm"
+ printf '%s\t%s\t%s\n' "$fid" "$(HTML "$name")" "$order" >"$file"
+ order="$(($order + 1000))"
+ seq=$(($seq + 1))
+ printf 'Setting up Folder: %s\n' "$name"
+ ;;
+ title=*)
+ title="$(QUERY_STRING="$l" GET title)"
+ ;;
+ content=*)
+ uri="$(QUERY_STRING="$l" GET content |head -n1)"
+ if [ -f "$file" -a -n "$title" ]; then
+ bid=$(seqid)
+ printf '%s\t%s\t%s\n' "$bid" "$(HTML "$title")" "$uri" >>"$file"
+ getFavicon "$uri" "$bid" &
+ seq=$(($seq + 1))
+ printf 'Added record "%s" to %s\n' "$title" "$file"
+ fi
+ ;;
+ esac
+done <"$import"
+
+printf 'Finished import to collection: %s\n' "${BDB##*/}"