diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000..59e5fd5 --- /dev/null +++ b/CHANGES @@ -0,0 +1,7 @@ +16.04.2008, Version 0.8.8 beta +- New design. +- Added the possibility to change the public/private status on multiple + bookmarks. +- Added the possibility to mark bookmarks and folders public/private + when importing them. + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..47963f8 --- /dev/null +++ b/INSTALL @@ -0,0 +1 @@ +See http://www.frech.ch/online-bookmarks/installation.php for installation instructions. diff --git a/README b/README new file mode 100644 index 0000000..41c6f80 --- /dev/null +++ b/README @@ -0,0 +1 @@ +See http://www.frech.ch/online-bookmarks/ for documentation. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..8340c15 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.8.8 beta \ No newline at end of file diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..1e8ac20 --- /dev/null +++ b/admin.php @@ -0,0 +1,282 @@ + + + + + + + + +
Admin Page + +
+
+
+ + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + +
+ + + +escape ($new_username), + $mysql->escape ($new_password), + $mysql->escape ($new_admin)); + + if ($mysql->query ($query)) { + $message1 = "User $new_username created."; + } + else { + message ($mysql->error); + } + unset ($new_password, $_POST['new_password']); + } +} +?> + +
+ Create User + +
+ + + + + + + + + + + + + + + + + + + + +
Username: + + +
Password: + + +
Admin: + + +
+ + +
+
+ +
+ + +
+ Delete User + + escape ($existing_user)); + if ($mysql->query ($query)) { + $message2 = "User $existing_user deleted.
"; + } + else { + message ($mysql->error); + } + + $query = sprintf ("DELETE FROM bookmark WHERE md5(user)=md5('%s')", + $mysql->escape ($existing_user)); + if (!$mysql->query ($query)) { + message ($mysql->error); + } + + $query = sprintf ("DELETE FROM folder WHERE md5(user)=md5('%s')", + $mysql->escape ($existing_user)); + if (!$mysql->query ($query)) { + message ($mysql->error); + } + list_users (); + } + else { + ?> + +

Are you sure you want to delete the user and all it's Bookmarks and Folders?

+
" method="POST" name="userdelete"> + + + +
+ + + +
+ + + + + + + +
+
+ query ($query)) { + while ($row = mysql_fetch_object ($mysql->result)) { + echo ''; + if ($row->admin) { + echo " " . $row->username . "
\n"; + } + else { + echo " " . $row->username . "
\n"; + } + } + } + else { + message ($mysql->error); + } + ?> +
+
+ + +
+ +
+ + + +
+ +
+ Version + + + + + + + + + + + +
This Version:
Newest Version available:
+ + + +
+ +
+ + diff --git a/bookmark_add.php b/bookmark_add.php new file mode 100644 index 0000000..e1e99c0 --- /dev/null +++ b/bookmark_add.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/bookmark_delete.php b/bookmark_delete.php new file mode 100644 index 0000000..48e8db4 --- /dev/null +++ b/bookmark_delete.php @@ -0,0 +1,70 @@ +escape ($bmlist), + $mysql->escape ($username)); + if ($mysql->query ($query)) { + echo "Bookmarks successfully deleted
\n"; + echo ''; + } + else { + message ($mysql->error); + } +} +else { + $bmlistq = implode (",", $bmlist); + $query = sprintf ("SELECT title, id, favicon FROM bookmark WHERE id IN (%s) AND user='%s' ORDER BY title", + $mysql->escape ($bmlistq), + $mysql->escape ($username)); + if ($mysql->query ($query)) { + require_once (ABSOLUTE_PATH . "bookmarks.php"); + $query_string = "?bmlist=" . implode ("_", $bmlist) . "&noconfirm=1"; + ?> + +

Delete these Bookmarks?

+
+ + result)) { + array_push ($bookmarks, $row); + } + list_bookmarks ($bookmarks, + false, + false, + $settings['show_bookmark_icon'], + false, + false, + false, + false, + false, + false, + false); + ?> + +
+ +
+
+ + +
+ + error); + } +} + +require_once (ABSOLUTE_PATH . "footer.php"); +?> \ No newline at end of file diff --git a/bookmark_edit.php b/bookmark_edit.php new file mode 100644 index 0000000..44a60bf --- /dev/null +++ b/bookmark_edit.php @@ -0,0 +1,188 @@ + 1) { + # if there is more than one bookmark to edit, we just care about the + # public/private field. + if ( ! isset ($_POST['public'])) { + $qbmlist = implode (",", $bmlist); + $query = sprintf ("SELECT title, id, public, favicon FROM bookmark WHERE id IN (%s) AND user='%s' ORDER BY title", + $mysql->escape ($qbmlist), + $mysql->escape ($username)); + if ($mysql->query ($query)) { + require_once (ABSOLUTE_PATH . "bookmarks.php"); + $query_string = "?bmlist=" . implode ("_", $bmlist); + ?> + +

Change public state:

+
+ + result)) { + array_push ($bookmarks, $row); + } + list_bookmarks ($bookmarks, + false, + false, + $settings['show_bookmark_icon'], + false, + false, + false, + false, + false, + false, + true); + ?> + +
+ +
+
+

+ +

+ + +
+ + error); + } + } + else { + $bmlist = implode (",", $bmlist); + $query = sprintf ("UPDATE bookmark SET public='%d' + WHERE id IN (%s) + AND user='%s'", + $mysql->escape ($post_public), + $mysql->escape ($bmlist), + $mysql->escape ($username)); + if ($mysql->query ($query)) { + echo "Bookmark successfully updated
\n"; + echo ''; + } + else { + message ($mysql->error); + } + } + +} +else if (count ($bmlist) < 1) { + message ("No Bookmark to edit."); +} +else if ($post_title == "" || $post_url == "" || $post_icon) { + $query = sprintf ("SELECT title, url, description, childof, id, favicon, public + FROM bookmark + WHERE id='%d' + AND user='%s' + AND deleted != '1'", + $mysql->escape ($bmlist[0]), + $mysql->escape ($username)); + if ($mysql->query ($query)) { + if (mysql_num_rows ($mysql->result) != 1) { + message ("No Bookmark to edit"); + } + else { + $row = mysql_fetch_object ($mysql->result); + require_once (ABSOLUTE_PATH . "folders.php"); + $tree = & new folder; + $query_string = "?expand=" . implode(",", $tree->get_path_to_root ($row->childof)) . "&folderid=" . $row->childof; + $path = $tree->print_path ($row->childof); + if ($post_icon && $settings['show_bookmark_icon']) { + if (isset ($row->favicon)) { + @unlink ($row->favicon); + } + require_once (ABSOLUTE_PATH . "favicon.php"); + $favicon = & new favicon ($post_url); + if (isset ($favicon->favicon)) { + $icon = ''; + $query = sprintf ("UPDATE bookmark SET favicon='%s' WHERE user='%s' AND id='%d'", + $mysql->escape ($favicon->favicon), + $mysql->escape ($username), + $mysql->escape ($bmlist[0])); + if (!$mysql->query ($query)) { + message ($mysql->error); + } + } + else { + $icon = $bookmark_image; + } + } + else if ($row->favicon && is_file ($row->favicon)) { + $icon = ''; + } + else { + $icon = $bookmark_image; + } + } + } + else { + message ($mysql->error); + } + +?> + +

Edit Bookmark

+
+

Title
+

+

URL
+ +

Description
+

+

Select/Change folder
+ +

+

Tags
+

+ + + + Public public ? "checked" : "";?>> +
+ + +escape ($post_title), + $mysql->escape ($post_url), + $mysql->escape ($post_description), + $mysql->escape ($post_childof), + $mysql->escape ($post_public), + $mysql->escape ($bmlist[0]), + $mysql->escape ($username)); + if ($mysql->query ($query)) { + echo "Bookmark successfully updated
\n"; + echo ''; + } + else { + message ($mysql->error); + } +} + +require_once (ABSOLUTE_PATH . "footer.php"); +?> diff --git a/bookmark_move.php b/bookmark_move.php new file mode 100644 index 0000000..0c84c79 --- /dev/null +++ b/bookmark_move.php @@ -0,0 +1,56 @@ + + +

Move bookmarks to:

+
+ +
+ + make_tree (0); + $tree->print_tree (); + ?> + +
+
+ + + + + +
+ + + + escape ($folderid), + $mysql->escape (implode (",", $bmlist)), + $mysql->escape ($username)); + + if ($mysql->query ($query)) { + echo "Bookmarks moved
\n"; + echo ''; + } + else { + message ($mysql->error); + } +} + +require_once (ABSOLUTE_PATH . "footer.php"); +?> \ No newline at end of file diff --git a/bookmark_new.php b/bookmark_new.php new file mode 100644 index 0000000..fc008f2 --- /dev/null +++ b/bookmark_new.php @@ -0,0 +1,122 @@ +get_path_to_root ($post_childof)) . "&folderid=" . $post_childof; + +if ($post_title == '' || $post_url == '') { + $path = $tree->print_path ($folderid); + if ($post_title != '') { + $title = $post_title; + } + else { + $title = $get_title; + } + if ($post_url != '') { + $url = $post_url; + } + else if ($get_url != '') { + $url = $get_url; + } + else { + $url = 'http://'; + } + if (strtolower (basename ($_SERVER['SCRIPT_NAME'])) == 'bookmark_add.php') { + $js_onclick = 'history.back()'; + } + else { + $js_onclick = 'self.close()'; + } + +?> + +

New Bookmark

+
+

Title
+

+

Homepage
+

+

Description
+

+

Select/Change folder
+ +

+

Tags
+

+ + + Public > +
+ + +escape ($username), + $mysql->escape ($post_title), + $mysql->escape ($post_url), + $mysql->escape ($post_description), + $mysql->escape ($post_childof), + $mysql->escape ($post_public)); + + if ($mysql->query ($query)) { + echo "Bookmark successfully created
\n"; + $bm_id = mysql_insert_id (); + } + else { + message ($mysql->error); + } + unset ($_SESSION['title'], $_SESSION['url']); + + # safing the favicon in a separate second step is done because + # we want to make sure the bookmark is safed in any case. the + # favicon is not that important. + if ($settings['show_bookmark_icon']) { + require_once (ABSOLUTE_PATH . "favicon.php"); + $favicon = & new favicon ($post_url); + if (isset ($favicon->favicon)) { + $query = sprintf ("UPDATE bookmark set favicon='%s' WHERE user='%s' AND id='%d'", + $mysql->escape ($favicon->favicon), + $mysql->escape ($username), + $mysql->escape ($bm_id)); + $mysql->query ($query); + $icon = ''; + } + else { + $icon = $bookmark_image; + } + } + + if (strtolower (basename ($_SERVER['SCRIPT_NAME'])) == "bookmark_add.php") { + echo 'Back to '.$icon.' '.$post_title.'
' . "\n"; + echo 'Open '.$folder_opened.' folder containing new Bookmark
' . "\n"; + } + else { + echo ''; + # I know, the following is ugly, but I found no other way to do. + # When creating a bookmark out of the personal toolbar, there is no + # window.opener that can be closed. Thus javascript exits with an error + # without finishing itself (self.close()). + echo ''; + } +} +require_once (ABSOLUTE_PATH . "footer.php"); +?> \ No newline at end of file diff --git a/bookmarks.php b/bookmarks.php new file mode 100644 index 0000000..5bd900b --- /dev/null +++ b/bookmarks.php @@ -0,0 +1,138 @@ +' . "\n"; + echo '' . "\n"; + + foreach ($bookmarks as $value) { + echo '' . "\n"; + + # the folders, only needed when searching for bookmarks + if ($show_folder) { + if ($value['fid'] == null) { + $value['name'] = $settings['root_folder_name']; + $value['fid'] = 0; + } + if ($value['fpublic']) { + $folder_image = $folder_opened_public; + } + else { + $folder_image = $folder_opened; + } + $expand = $tree->get_path_to_root ($value['fid']); + echo '\n"; + } + + if ($show_checkbox){ + # the checkbox, needed in any case + echo '\n"; + } + + # the bookmark image if configured to be displayed + if ($show_icon){ + echo '\n"; + } + + # the link if configured to be displayed + echo '\n"; + + if ($show_date) { + echo '\n"; + } + + + if ($show_share) { + echo '\n"; + } + + + # the edit column if configured to be displayed + if ($show_edit) { + echo '\n"; + } + + # the move column if configured to be displayed + if ($show_move) { + echo '\n"; + } + + # the delete column if configured to be displayed + if ($show_delete) { + echo '\n"; + } + + echo "\n"; + } + echo "
'; + echo ''; + echo $folder_image . " " . $value['name'] . ""; + echo "'; + echo ''; + echo "'; + if ($value['favicon'] && is_file ($value['favicon'])) { + echo ''; + } + else { + echo $bookmark_image; + } + echo "'; + + if ($settings['open_new_window']) { + $target = ' target="_blank"'; + } + else { + $target = null; + } + + if ($show_link){ + $link = '' . $value['title'] . ""; + } + else { + $link = $value['title']; + } + echo '
' . $link . "
\n"; + + # the description if configured to be displayed and if not empty + # thanks to Tim Hogan + # also display the public status here + if ($show_desc && $value['description'] != "") { + echo '
' . $value['description'] . "
\n"; + } + echo "
'; + echo '
'. date ($date_formats[$settings['date_format']], $value['timestamp']) .'
'; + echo "
'; + $share = $value['public'] ? 'public' : 'private'; + echo '
'.$share.'
'; + echo "
'; + echo ''; + echo sprintf ($edit_image, "Edit"); + echo "'; + echo ''; + echo sprintf ($move_image, "Move"); + echo "'; + echo ''; + echo sprintf ($delete_image, "Delete"); + echo "
\n"; +} + +?> diff --git a/export.php b/export.php new file mode 100644 index 0000000..dbbf4ba --- /dev/null +++ b/export.php @@ -0,0 +1,326 @@ + + + + + + + + +
Export Bookmarks + +
+
+
+ + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + +
+ Export Bookmarks to Browser: + + +
Character encoding + +
+ Folder to export: + +
+ + make_tree (0); + $tree->print_tree (); + ?> + +
+
+ + + + +
+
+ +
+ +\n"; + echo "Bookmarks\n"; + echo "

Bookmarks

\n"; + echo "

\n"; + $export = & new export; + $export->make_tree ($folderid); + echo "

\n"; + } + else if ($browser == "opera") { + echo "Opera Hotlist version 2.0\n"; + echo "Options: encoding = utf8, version=3\n\n"; + $export = & new export; + $export->make_tree ($folderid); + } +} + +class export { + function export () { + # collect the folder data + require_once (ABSOLUTE_PATH . "folders.php"); + $this->tree = & new folder; + $this->tree->folders[0] = array ('id' => 0, 'childof' => null, 'name' => $GLOBALS['settings']['root_folder_name']); + + global $username, $mysql; + $this->browser = $GLOBALS['browser']; + + $this->counter = 0; + + # work around PHP < 5 problem + # http://bugs.php.net/bug.php?id=25670 + if (intval(str_replace('.', '', phpversion())) < 500) { + $this->charset = 'iso-8859-1'; + } + else { + $this->charset = set_post_charset (); + } + + # collect the bookmark data + $query = sprintf ("SELECT title, url, description, childof, id + FROM bookmark + WHERE user='%s' + AND deleted!='1'", + $mysql->escape ($username)); + + if ($mysql->query ($query)) { + while ($row = mysql_fetch_assoc ($mysql->result)) { + if (!isset ($this->bookmarks[$row['childof']])) { + $this->bookmarks[$row['childof']] = array (); + } + array_push ($this->bookmarks[$row['childof']], $row); + } + } + else { + message ($mysql->error); + } + } + + function make_tree ($id) { + if (isset ($this->tree->children[$id])) { + $this->counter++; + foreach ($this->tree->children[$id] as $value) { + $this->print_folder ($value); + $this->make_tree ($value); + $this->print_folder_close (); + } + $this->counter--; + } + $this->print_bookmarks ($id); + } + + + function print_folder ($folderid) { + $spacer = str_repeat (" ", $this->counter); + $foldername = html_entity_decode ($this->tree->folders[$folderid]['name'], ENT_QUOTES, $this->charset); + if ($this->browser == "netscape") { + echo $spacer . "

" . $foldername . "

\n"; + echo $spacer . "

\n"; + } + else if ($this->browser == "IE") { + echo $spacer . '

' . $foldername . "

\n"; + echo $spacer . "

\n"; + } + else if ($this->browser == "opera") { + echo "\n#FOLDER\n"; + echo "\tNAME=" . $foldername . "\n"; + } + } + + function print_folder_close () { + $spacer = str_repeat (" ", $this->counter); + if ($this->browser == "netscape" || $this->browser == "IE"){ + echo $spacer . "

\n"; + } + else if ($this->browser == "opera"){ + echo "\n-\n"; + } + } + + function print_bookmarks ($folderid) { + $spacer = str_repeat (" ", $this->counter); + if (isset ($this->bookmarks[$folderid])) { + foreach ($this->bookmarks[$folderid] as $value) { + $url = html_entity_decode ($value['url'], ENT_QUOTES, $this->charset); + $title = html_entity_decode ($value['title'], ENT_QUOTES, $this->charset); + if ($value['description'] != '') { + $description = html_entity_decode ($value['description'], ENT_QUOTES, $this->charset); + } + else { + $description = ''; + } + + if ($this->browser == 'netscape') { + echo $spacer . '

' . $title . "\n"; + if ($description != '') { + echo $spacer . '
' . $description . "\n"; + } + } + else if ($this->browser == 'IE') { + echo $spacer . '
' . $title . "\n"; + # unfortunately description for bookmarks in MS Internet Explorer is not supported. + # thats why we just ignore the output of the description here. + } + else if ($this->browser == 'opera') { + echo "\n#URL\n"; + echo "\tNAME=" . $title . "\n"; + echo "\tURL=" . $url . "\n"; + if ($description != "") { + # opera cannot handle the \r\n character, so we fix this. + $description = str_replace ("\r\n", " ", $description); + echo "\tDESCRIPTION=" . $description . "\n"; + } + } + } + } + } +} + +?> diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..8b9106c Binary files /dev/null and b/favicon.ico differ diff --git a/favicon.php b/favicon.php new file mode 100644 index 0000000..d9da61a --- /dev/null +++ b/favicon.php @@ -0,0 +1,200 @@ +parsed_url = $this->return_parse_url ($url)) { + if ($this->favicon_url = $this->get_favicon_url ()) { + $this->icon_name = rand () . basename ($this->favicon_url); + if ($this->get_favicon_image ()) { + $this->convert_favicon (); + } + } + } + } + } + ### + ### check the image type and convert & resize it if required + ### returns the absolute path of the (converted) .png file + ### + function convert_favicon () { + + global $convert, $identify; + + $tmp_file = "./favicons/" . $this->icon_name; + # find out file type + if (@exec ("$identify $tmp_file", $output)) { + $ident = explode (" ", $output[0]); + if (count ($output) > 1) { + $file_to_convert = $ident[0]; + } + else { + $file_to_convert = $tmp_file; + } + + # convert image in any case to 16x16 and .png + system ("$convert $file_to_convert -resize 16x16 $tmp_file.png"); + $this->favicon = $tmp_file . ".png"; + @unlink ($tmp_file); + return true; + } + else { + @unlink ($tmp_file); + return false; + } + } + + ### + ### download and save favicon + ### + function get_favicon_image () { + //Selbstgebastelte, IIS-kompatible Version von Arne Haak (www.arnehaak.de) + # HTTP-Url auswerten + $httpparsed = $this->return_parse_url ($this->favicon_url); + + //HTTP-Request-Header erzeugen + $httprequest = "GET ".$httpparsed['path']." HTTP/1.0\r\n". + "Accept: */*\r\n". + "Accept-Language: en\r\n". + "Accept-Encoding: identity\r\n". + "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n". + "Host: ".$httpparsed['host']."\r\n". + "Connection: close\r\n\r\n"; + + //Verbindung aufbauen und Request abschicken + if ($httphandle = fsockopen($httpparsed['host'],$httpparsed['port'])) { + fputs($httphandle, $httprequest); + + //Daten runterladen solange vorhanden + $answerdata = null; + do { + $answerdata .= fread($httphandle, 1024); + } while (feof($httphandle) != true); + + // Verbindung schliessen + fclose ($httphandle); + + //Header finden und abtrennen + $finalposi = strpos($answerdata, "\r\n\r\n") + 4; //Position des ersten Bytes nach dem Header bestimmen + $finalfile = substr($answerdata, $finalposi, strlen($answerdata) - $finalposi); //Header abschneiden + + //Datei abspeichern + if ($fp = @fopen("./favicons/" . $this->icon_name, "w")) { + fwrite($fp, $finalfile); + fclose($fp); + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + ### + ### checks for the existence of a favicon on a remote server + ### and returns the url if one exist + ### + function get_favicon_url () { + global $timeout; + # search for favicon in document root first + if ($socket = @fsockopen ($this->parsed_url['host'], $this->parsed_url['port'], $errno, $errstr, $timeout)) { + fwrite ($socket, "HEAD /favicon.ico HTTP/1.0\r\nHost: " . $this->parsed_url['host'] . "\r\n\r\n"); + $http_response = fgets ($socket, 22); + fclose ($socket); + if (ereg ("200 OK", $http_response)) { + #echo "favicon found in document root\n"; + return $this->parsed_url['scheme'] . "://" . $this->parsed_url['host'] . ":" . $this->parsed_url['port'] . "/favicon.ico"; + } + else { + # if favicon was not found in document root, search in html header for it + if ($socket = @fsockopen ($this->parsed_url['host'], $this->parsed_url['port'], $errno, $errstr, $timeout)) { + fwrite ($socket, "GET " . $this->parsed_url['path'] . " HTTP/1.0\r\nHost: " . $this->parsed_url['host'] . "\r\n\r\n"); + while (!feof ($socket)) { + $html = fgets ($socket, 1024); + if ($html == null) { + return false; + } + + # we only want to search in HTML documents + if (preg_match ('/.*Content-Type:.*/si', $html, $contenttype)) { + if ( ! preg_match ('/text\/html/si', $contenttype[0])) { + return false; + } + } + + if (preg_match ('/]+rel="(?:shortcut )?icon".*>/si', $html, $tag)) { + #echo "found favicon in html header\n"; + if (preg_match ('/]+href="([^"]+)".*>/si', $tag[0], $location)) { + # the favicon location is an url + if (substr($location[1], 0, 7) == 'http://') { + $favicon = $location[1]; + } + # the favicon location is an absolute path + else if (substr ($location[1], 0, 1) == '/') { + $favicon = $this->parsed_url['scheme'] . '://' . $this->parsed_url['host'] . ":" . $this->parsed_url['port'] . $location[1]; + } + # else the path can only be something useless + # or a relative path, looking like this. + # ./path/to/favicon.ico + # path/to/favicon.ico + else { + # The location we called is either a file or a directory. + # We have to guess. We assume it is a directory if there is a trailing slash + if (substr ($this->parsed_url['path'], strlen($this->parsed_url['path'])-1) == "/") { + $favicon = $this->parsed_url['scheme'] . '://' . $this->parsed_url['host'] . ":" . $this->parsed_url['port'] . $this->parsed_url['path'] . $location[1]; + } + else { + $favicon = $this->parsed_url['scheme'] . '://' . $this->parsed_url['host'] . ":" . $this->parsed_url['port'] . dirname ($this->parsed_url['path']) . '/' . $location[1]; + } + } + return $favicon; + } + } + else if (preg_match ('/.*<\/head.*>/si', $html)) { + #echo "html header end found, giving up\n"; + return false; + } + } + fclose ($socket); + } + } + } + return false; + } + + ### + ### returns an array with parts of the given url + ### + function return_parse_url ($url) { + if ($parsed = @parse_url ($url)) { + if (!isset ($parsed['scheme']) || $parsed['scheme'] == "") { + $parsed['scheme'] = "http"; + } + else if ($parsed['scheme'] != "http") { + return false; + } + if (!isset ($parsed['host']) || $parsed['host'] == "") { + return false; + } + if (!isset ($parsed['port']) || $parsed['port'] == "") { + $parsed['port'] = 80; + } + if (!isset ($parsed['path']) || $parsed['path'] == "") { + $parsed['path'] = "/"; + } + return ($parsed); + } + else { + return false; + } + } +} + +?> diff --git a/folder_delete.php b/folder_delete.php new file mode 100644 index 0000000..d43fb09 --- /dev/null +++ b/folder_delete.php @@ -0,0 +1,112 @@ +get_children ($folderid); + + # we need $parent_folders for javascript code below. + $parent_folders = $tree->get_path_to_root ($folderid); + if (count ($parent_folders) > 1) { + $parent_folder = $parent_folders[1]; + } + else { + $parent_folder = 0; + } + + array_push ($tree->get_children, $folderid); + $folders = implode (",", $tree->get_children); + # first delete all subfolders + $query = sprintf ("DELETE FROM folder WHERE childof IN (%s) AND user='%s'", + $mysql->escape ($folders), + $mysql->escape ($username)); + if (!$mysql->query ($query)) { + message ($mysql->error); + } + + # of course, we want to delete all bookmarks as well + $query = sprintf ("DELETE FROM bookmark WHERE childof IN (%s) AND user='%s'", + $mysql->escape ($folders), + $mysql->escape ($username)); + if (!$mysql->query ($query)) { + message ($mysql->error); + } + + # now delete the folder itself + $query = sprintf ("DELETE FROM folder WHERE id=%d AND user='%s'", + $mysql->escape ($folderid), + $mysql->escape ($username)); + if (!$mysql->query ($query)) { + message ($mysql->error); + } + + ?> + + + + escape ($folderid), + $mysql->escape ($username)); + + if ($mysql->query ($query)) { + if (mysql_num_rows ($mysql->result) == 0){ + message ("Folder does not exist"); + } + $row = mysql_fetch_object ($mysql->result); + ?> + +

Delete this Folder?

+

public ? $folder_opened_public : $folder_opened; echo " " . $row->name; ?>

+ +
" method="POST" name="fdelete"> + + +
+ + error); + } +} + +require_once (ABSOLUTE_PATH . "footer.php"); +?> \ No newline at end of file diff --git a/folder_edit.php b/folder_edit.php new file mode 100644 index 0000000..ba1f8c0 --- /dev/null +++ b/folder_edit.php @@ -0,0 +1,104 @@ +escape ($folderid), + $mysql->escape ($username)); + + if ($mysql->query ($query)) { + if (mysql_num_rows ($mysql->result) == 1) { + $row = mysql_fetch_object ($mysql->result); + } + else { + message ("No Folder to edit."); + } + } + else { + message ($mysql->error); + } + ?> + +

Edit Folder

+
+

public ? $folder_opened_public : $folder_opened; ?>

+

public) {echo "checked";} ?>> Public

+

Inherit Public Status to all Subfolders and Bookmarks

+ + +
+ + + escape ($foldername), + $mysql->escape ($public), + $mysql->escape ($folderid), + $mysql->escape ($username)); + + if ($mysql->query ($query)) { + if ($inherit) { + require_once (ABSOLUTE_PATH . "folders.php"); + $tree = & new folder; + $tree->get_children ($folderid); + if (count ($tree->get_children) > 0) { + $sub_folders = implode (",", $tree->get_children); + + # set subfolders to public + $query = sprintf ("UPDATE folder SET public='%d' WHERE id IN (%s) AND user='%s'", + $mysql->escape ($public), + $mysql->escape ($sub_folders), + $mysql->escape ($username)); + if (! $mysql->query ($query)) { + message ($mysql->error); + } + + $sub_folders .= "," . $folderid; + # set bookmarks to public as well + $query = sprintf ("UPDATE bookmark SET public='%d' WHERE childof IN (%s) AND user='%s'", + $mysql->escape ($public), + $mysql->escape ($sub_folders), + $mysql->escape ($username)); + if ($mysql->query ($query)) { + echo ''; + } + else { + message ($mysql->error); + } + } + else { + $query = sprintf ("UPDATE bookmark SET public='%d' WHERE childof='%d' AND user='%s'", + $mysql->escape ($public), + $mysql->escape ($folderid), + $mysql->escape ($username)); + if ($mysql->query ($query)) { + echo ''; + } + else { + message ($mysql->error); + } + } + } + echo ''; + } + else { + message ($mysql->error); + } +} + +require_once (ABSOLUTE_PATH . "footer.php"); +?> diff --git a/folder_move.php b/folder_move.php new file mode 100644 index 0000000..789db3f --- /dev/null +++ b/folder_move.php @@ -0,0 +1,60 @@ +get_path_to_root ($folderid); + +if ($sourcefolder == "") { + ?> + +

Move Folder

+
" method="POST" id="fmove"> + +
+ + make_tree (0); + $tree->print_tree (); + ?> + +
+
+ + + + + +
+ + + + self.close();'; +} +else if (in_array ($sourcefolder, $parents)){ + message ("A folder cannot be moved to one of its own subfolders"); +} +else if ($sourcefolder != "" && $sourcefolder != $folderid){ + $query = sprintf ("UPDATE folder SET childof='%d' WHERE id='%d' AND user='%s'", + $mysql->escape ($folderid), + $mysql->escape ($sourcefolder), + $mysql->escape ($username)); + + if ($mysql->query ($query)) { + echo "Folder moved
\n"; + echo ''; + } + else { + message ($mysql->error); + } +} +require_once (ABSOLUTE_PATH . "footer.php"); +?> diff --git a/folder_new.php b/folder_new.php new file mode 100644 index 0000000..97f4341 --- /dev/null +++ b/folder_new.php @@ -0,0 +1,41 @@ + + +

New Folder

+
+

+

Public

+ + +
+ + + escape ($folderid), + $mysql->escape ($foldername), + $mysql->escape ($public), + $mysql->escape ($username)); + if ($mysql->query ($query)) { + echo "Folder successfully created
\n"; + echo ''; + } + else { + message ($mysql->error); + } +} + +require_once (ABSOLUTE_PATH . "footer.php"); +?> \ No newline at end of file diff --git a/folders.php b/folders.php new file mode 100644 index 0000000..6e87cc2 --- /dev/null +++ b/folders.php @@ -0,0 +1,312 @@ +username = $GLOBALS['username']; + $this->folderid = $GLOBALS['folderid']; + $this->folders = array (); + $this->tree = array (); + $this->get_children = array (); + $this->level = 0; + $this->foreign_username = false; + $this->expand = $GLOBALS['expand']; + + if ($user) { + $this->get_shared_data ($user); + } + else { + $this->get_user_data (); + } + + if ($settings['simple_tree_mode']) { + $this->expand = $this->get_path_to_root ($this->folderid); + } + + # searching for invalid folderid in GET variable + if ( ! array_key_exists ($this->folderid, $this->folders)) { + $this->folderid = 0; + } + + # searching for invalid expand entries + foreach ($this->expand as $key => $value) { + if (! array_key_exists ($value, $this->folders)) { + unset ($this->expand[$key]); + } + } + } + + function get_user_data () { + global $mysql; + $query = sprintf ("SELECT id, childof, name, public FROM folder WHERE user='%s' AND deleted!='1' ORDER BY name", + $mysql->escape ($_SESSION['username'])); + if ($mysql->query ($query)) { + while ($row = mysql_fetch_assoc ($mysql->result)) { + $this->folders[$row['id']] = $row; + if (!isset ($this->children[$row['childof']])) { + $this->children[$row['childof']] = array (); + } + array_push ($this->children[$row['childof']], $row['id']); + } + } + else { + message ($mysql->error); + } + } + + function get_shared_data ($username) { + global $mysql; + + # does the user exist in the database? + if (check_username ($username)) { + $this->foreign_username = $username; + } + else { + $this->foreign_username = $GLOBALS['username']; + } + + # get all shared folders for the given user + $query = "SELECT id, childof, name, public FROM folder WHERE public='1' AND deleted!='1'AND user='$this->foreign_username' ORDER BY 'name'"; + if ($mysql->query ($query)) { + # make two arrays: + # 1) $children containing arrays with children. the keys of these arrays are the id's of the parents + # 2) $folders containing arrays with folder settings (id, childof, name, public) + $shared_children = array (); + while ($row = mysql_fetch_assoc ($mysql->result)) { + $this->folders[$row['id']] = $row; + if (!isset ($this->children[$row['childof']])) { + $this->children[$row['childof']] = array (); + } + array_push ($this->children[$row['childof']], $row['id']); + array_push ($shared_children, $row['id']); + } + + $this->children[0] = array (); + # the childof fields of each folder with no parent is being set to 0, so it becomes a child of the root folder + foreach ($this->folders as $value) { + if (in_array ($value['childof'], $shared_children)) { + continue; + } + else { + array_push ($this->children[0], $value['id']); + $this->folders[$value['id']]['childof'] = 0; + } + } + } + else { + message ($mysql->error); + } + } + + + # assembles the tree + function make_tree ($id) { + if (isset ($this->children)){ + $this->level++; + if (isset ($this->children[$id])) { + foreach ($this->children[$id] as $value) { + array_push ($this->tree, array ( + 'level' => $this->level, + 'id' => $value, + 'name' => $this->folders[$value]['name'], + 'public' => $this->folders[$value]['public'], + )); + # check for children + $symbol = &$this->tree[count ($this->tree) - 1]['symbol']; + if (isset ($this->children[$value])) { + if (in_array ($value, $this->expand)) { + $symbol = 'minus'; + $this->make_tree ($value); + } + else { + $symbol = 'plus'; + } + } + else { + $symbol = ''; + } + } + } + $this->level--; + } + } + + # draws the tree + function print_tree () { + global $settings, $folder_opened, $folder_closed, $folder_opened_public, $folder_closed_public, $plus, $minus, $neutral; + + # depending on whom's bookmarks are being displayed, we set some variables differently + if ($this->foreign_username) { + $root_folder_name = $this->foreign_username . "'s Bookmarks"; + $user_var = "&user=$this->foreign_username"; + } + else { + $root_folder_name = $settings['root_folder_name']; + $user_var = ""; + } + + $root_folder = array ( + 'level' => 0, + 'id' => 0, + 'name' => $root_folder_name, + 'symbol' => null, + 'public' => 0, + ); + array_unshift ($this->tree, $root_folder); + + foreach ($this->tree as $key => $value) { + # this is the begining of the line that shows a folder + # with the symbol (plus, minus or neutral) + $spacer = '
'; + echo $spacer; + + if ($value['id'] == $this->folderid) { + $folder_name = '' . $value['name'] . ''; + if (!$this->foreign_username && $value['public']) { + $folder_image = $folder_opened_public; + } + else { + $folder_image = $folder_opened; + } + } + else { + $folder_name = $value['name']; + if (!$this->foreign_username && $value['public']) { + $folder_image = $folder_closed_public; + } + else { + $folder_image = $folder_closed; + } + } + + if ($key > 5) { + $ankor = "#" . $this->tree[$key - 5]['id']; + } + else { + $ankor = ""; + } + + if ($value['symbol'] == "plus" || $value['symbol'] == "minus") { + if ($value['symbol'] == "plus") { + $symbol = $plus; + $expand_s = $this->add_to_expand_list ($value['id']); + if ($settings['fast_folder_plus']) { + $expand_f = $expand_s; + } + else { + $expand_f = $this->expand; + } + } + else if ($value['symbol'] == "minus") { + $symbol = $minus; + $expand_s = $this->remove_from_expand_list ($value['id']); + if ($settings['fast_folder_minus'] && $value['id'] == $this->folderid) { + $expand_f = $expand_s; + } + else { + $expand_f = $this->expand; + } + } + if ($settings['fast_symbol']) { + $folderid = $value['id']; + } + else { + $folderid = $this->folderid; + } + # this prints the symbol (plus or minus) with its appropriate link + echo '' . $symbol . ''; + } + else { + $symbol = $neutral; + $expand_f = $this->expand; + echo $symbol; + } + + # this prints the folder name with its appropriate link + echo '' . $folder_image . " " . $folder_name . ''; + # and this is the end of the line + echo "
\n"; + } + } + + ### + ### removes a value from the expand list + ### + function remove_from_expand_list ($id){ + $expand = $this->expand; + foreach ($expand as $key => $value) { + if ($value == $id) { + unset ($expand[$key]); + } + } + return $expand; + } + + ### + ### adds a value to the expand list + ### + function add_to_expand_list ($id){ + $expand = $this->expand; + array_push ($expand, $id); + return $expand; + } + + ### + ### returns an array containing all folder id's from + ### a given folder up to the root folder + ### + function get_path_to_root ($id) { + $path = array (); + while ($id > 0) { + array_push ($path, $id); + if (!isset ($this->folders[$id])) { + #echo "Folder Nr. $id does not have a parent"; + return array (); + } + else { + $id = $this->folders[$id]['childof']; + } + } + return $path; + } + + ### + ### prints a path + ### + function print_path ($id) { + global $settings; + $parents = $this->get_path_to_root ($id); + $parents = array_reverse ($parents); + # the following if condition has been disabled. could be enabled to + # allow the "show_root_folder" function. + #if ($GLOBALS['show_root_folder']){ + $path = $GLOBALS['delimiter'] . $settings['root_folder_name']; + #} + foreach ($parents as $value) { + $path .= $GLOBALS['delimiter'] . $this->folders[$value]['name']; + } + return $path; + } + + ### + ### returns an array containing all folder id's that + ### are children from a given folder + ### + function get_children ($id) { + if (isset ($this->children[$id])) { + foreach ($this->children[$id] as $value) { + array_push ($this->get_children, $value); + $this->get_children ($value); + } + } + } +} + +?> diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..27af208 --- /dev/null +++ b/footer.php @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/header.php b/header.php new file mode 100644 index 0000000..7a1473a --- /dev/null +++ b/header.php @@ -0,0 +1,50 @@ +install Online-Bookmarks.'); +} +else { + require_once (ABSOLUTE_PATH . "config/config.php"); +} +require_once (ABSOLUTE_PATH . "lib/mysql.php"); +$mysql = & new mysql; +require_once (ABSOLUTE_PATH . "lib/auth.php"); +$auth = & new Auth; +require_once (ABSOLUTE_PATH . "lib/lib.php"); +require_once (ABSOLUTE_PATH . "lib/login.php"); + +?> + + + + + Online-Bookmarks + + + + + + + + + +display_login_form (); + require_once (ABSOLUTE_PATH . "footer.php"); +} + +?> diff --git a/import.php b/import.php new file mode 100644 index 0000000..d14d145 --- /dev/null +++ b/import.php @@ -0,0 +1,359 @@ + + + + + + + + +
Import Bookmarks + +
+
+
+ + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ from Browser: + + +
+ select File: + + +
Character encoding: + +
Make them: + +
+ Destination Folder: + +
+ + make_tree (0); + $tree->print_tree (); + ?> + +
+
+

+ + + +
+
+
+ + import_opera (); + } + else if ($_POST['browser'] == "netscape") { + $import->import_netscape (); + } + echo "$import->count_folders folders and $import->count_bookmarks bookmarks imported.
\n"; + echo 'My Bookmarks'; +} + +?> + +
+ +fp = fopen ($_FILES['importfile']['tmp_name'], "r"); + if ($this->fp == null){ + message ("Failed to open file"); + } + + $this->charset = set_post_charset (); + $this->public = set_post_bool_var ("public", false); + + $this->count_folders = 0; + $this->count_bookmarks = 0; + + $this->username = $GLOBALS['username']; + $this->parent_folder = $GLOBALS['parentfolder']; + $this->current_folder = $this->parent_folder; + + $this->folder_depth = array (); + + $this->mysql = $GLOBALS['mysql']; + + } + + function import_opera () { + while (!feof ($this->fp)) { + $line = trim (fgets ($this->fp, 4096)); + + # a folder has been found + if ($line == "#FOLDER") { + $item = "Folder"; + } + # a bookmark has been found + else if ($line == "#URL") { + $item = "Bookmark"; + } + # if a line starts with NAME= ... + else if (substr ($line, 0, strlen("NAME=")) == "NAME=") { + $line = substr ($line, strlen ("NAME=")); + # ... depending on the value of "$item" we assign the name to + # either folder or bookmark. + if ($item == "Folder") { + $this->name_folder = input_validation ($line, $this->charset); + } + else if ($item == "Bookmark") { + $this->name_bookmark = input_validation ($line, $this->charset); + } + } + # only bookmarks can have a description or/and an url. + else if (substr ($line, 0, strlen ("DESCRIPTION=")) == "DESCRIPTION=") { + $this->description = substr (input_validation ($line, $this->charset), strlen ("DESCRIPTION=")); + } + else if (substr ($line, 0, strlen ("URL=")) == "URL="){ + $this->url = substr (input_validation ($line, $this->charset), strlen ("URL=")); + } + # process the corresponding item, if there is an empty line found + else if ($line == "") { + if (isset ($item) && $item == "Folder") { + $this->folder_new (); + unset ($item); + } + else if (isset ($item) && $item == "Bookmark") { + $this->bookmark_new (); + unset ($item); + } + } + # this indicates, that the folder is being closed + else if ($line == "-") { + $this->folder_close (); + } + } + } + + function import_netscape () { + while (!feof ($this->fp)){ + $line = trim (fgets ($this->fp)); + + # a folder has been found + if (ereg ("
name_folder = input_validation (ereg_replace ("^( *
<[^>]*>)([^<]*)(.*)", "\\2", $line), $this->charset); + $this->folder_new (); + } + # a bookmark has been found + else if (ereg("
name_bookmark = input_validation (ereg_replace ("^( *
<[^>]*>)([^<]*)(.*)", "\\2", $line), $this->charset); + $this->url = input_validation (ereg_replace ("([^H]*HREF=\")([^\"]*)(\".*)", "\\2", $line), $this->charset); + $this->bookmark_new (); + $insert_id = mysql_insert_id (); + } + # this is a description. it is only being saved + # if a bookmark has been saved previously + else if (ereg("
*", $line)) { + if (isset ($insert_id)) { + $this->description = input_validation (ereg_replace ("^( *
)(.*)", "\\2", $line), $this->charset); + $query = sprintf ("UPDATE bookmark SET description='%s' WHERE id='%d' and user='%s'", + $this->mysql->escape ($this->description), + $this->mysql->escape ($insert_id), + $this->mysql->escape ($this->username)); + + @$this->mysql->query ($query); + unset ($this->description); + unset ($insert_id); + } + } + # this indicates, that the folder is being closed + else if ($line == "

") { + $this->folder_close (); + } + } + } + + function folder_new () { + if (!isset ($this->name_folder)) { + $this->name_folder == ""; + } + $query = sprintf ("INSERT INTO folder (childof, name, user, public) values ('%d', '%s', '%s', '%d')", + $this->mysql->escape ($this->current_folder), + $this->mysql->escape ($this->name_folder), + $this->mysql->escape ($this->username), + $this->mysql->escape ($this->public)); + + if ($this->mysql->query ($query)) { + $this->current_folder = mysql_insert_id (); + array_push ($this->folder_depth, $this->current_folder); + unset ($this->name_folder); + $this->count_folders++; + } + else { + message ($this->mysql->error); + } + } + + function bookmark_new () { + if (!isset ($this->name_bookmark)) { + $this->name_bookmark = ""; + } + if (!isset ($this->url)) { + $this->url = ""; + } + if (!isset ($this->description)) { + $this->description = ""; + } + $query = sprintf ("INSERT INTO bookmark (user, title, url, description, childof, public) + values ('%s', '%s', '%s', '%s', '%d', '%d')", + $this->mysql->escape ($this->username), + $this->mysql->escape ($this->name_bookmark), + $this->mysql->escape ($this->url), + $this->mysql->escape ($this->description), + $this->mysql->escape ($this->current_folder), + $this->mysql->escape ($this->public)); + + if ($this->mysql->query ($query)) { + unset ($this->name_bookmark, $this->url, $this->description); + $this->count_bookmarks++; + } + else { + message ($this->mysql->error); + } + } + + function folder_close () { + if (count ($this->folder_depth) <= 1) { + $this->folder_depth = array (); + $this->current_folder = $this->parent_folder; + } + else{ + # remove the last folder from the folder history + unset ($this->folder_depth[count ($this->folder_depth) - 1]); + $this->folder_depth = array_values ($this->folder_depth); + # set the last folder to the current folder + $this->current_folder = $this->folder_depth[count ($this->folder_depth) - 1]; + } + } +} + +require_once (ABSOLUTE_PATH . "footer.php"); +?> diff --git a/index.php b/index.php new file mode 100644 index 0000000..ffc01ae --- /dev/null +++ b/index.php @@ -0,0 +1,226 @@ + + + + + + + + + + + +
Online-Bookmarks of + +
+
+
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + +
+ + +
+ + escape ($username), + $mysql->escape ($search), + $mysql->escape ($search), + $mysql->escape ($search)); + + if ($mysql->query ($query)) { + $bookmarks = array (); + while ($row = mysql_fetch_assoc ($mysql->result)) { + array_push ($bookmarks, $row); + } + if (count ($bookmarks) > 0) { + require_once (ABSOLUTE_PATH . "bookmarks.php"); + list_bookmarks ($bookmarks, + true, + true, + $settings['show_bookmark_icon'], + true, + $settings['show_bookmark_description'], + $settings['show_column_date'], + $settings['show_column_edit'], + $settings['show_column_move'], + $settings['show_column_delete'], + true); + } + else { + echo '
No Bookmarks found matching ' . $search . '.
'; + } + } + else { + message ($mysql->error); + } + + ?> + +
+
+
+ make_tree (0); + $tree->print_tree (); + ?> +
+
+
+ + escape ($username), + $mysql->escape ($folderid)); + + if ($mysql->query ($query)) { + $bookmarks = array (); + while ($row = mysql_fetch_assoc ($mysql->result)) { + array_push ($bookmarks, $row); + } + list_bookmarks ($bookmarks, + true, + false, + $settings['show_bookmark_icon'], + true, + $settings['show_bookmark_description'], + $settings['show_column_date'], + $settings['show_column_edit'], + $settings['show_column_move'], + $settings['show_column_delete'], + $settings['show_public']); + } + else { + message ($mysql->error); + } + ?> + +
+
+ + diff --git a/register.php b/register.php new file mode 100644 index 0000000..f0eb1c2 --- /dev/null +++ b/register.php @@ -0,0 +1,164 @@ +$username is an already registered user. Choose another one.'."\n"; + $username = false; + } + else { + $username = $reg_username; + } + } + else { + echo '

Please enter a Username.
'."\n"; + $username = false; + } + + if (isset ($_POST['reg_password1']) && $_POST['reg_password1'] != "" && + isset ($_POST['reg_password2']) && $_POST['reg_password2'] != "") { + if (md5 ($_POST['reg_password1']) != md5 ($_POST['reg_password2'])) { + echo '
Passwords do not match.
'."\n"; + $password = false; + } + else { + $password = md5 ($_POST['reg_password1']); + } + } + else { + echo '
Please fill out both password fields.
'."\n"; + $password = false; + } + + if ($reg_email != '') { + if (preg_match ('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $reg_email)) { + $query = "SELECT COUNT(*) AS result FROM user WHERE email='$reg_email'"; + if ($mysql->query ($query)) { + if (mysql_result ($result, 0) > 0) { + echo '
A User Account with this email address aready exists.
'."\n"; + $email = false; + } + else { + $email = $reg_email; + } + } + else { + $email = false; + message ($mysql->error); + } + } + else { + echo '
Email address is invalid.
'."\n"; + $email = false; + } + } + else { + echo '
Please enter a valid email address.
'."\n"; + $email = false; + } + + + if ($username && $password && $email) { + $query = " INSERT INTO user + (username, password, email, active) + VALUES + ('$username', md5('$password'), '$email', '0')"; + + if (mysql_query ("$query")) { + # dieser key wird als username und secret md5 hash an den + # user geschickt und für die verifikation der registrierung gebraucht. + $key = md5 ($username . $secret); + + $headers = "From: noreply@yourdomain.com\r\n" . + $subject = 'Your registration at yourdomain.com'; + $message = "Hi $username,\r\n\r\n"; + $message .= "This email confirms the creation of your Online-Bookmarks user account. "; + $message .= "Your username is '$username'. For security reasons your password is not "; + $message .= "included in this email. To activate your account, visit the following URL:\r\n\r\n"; + $message .= "http://www.yourdomain.com/register.php?confirm=$key\r\n\r\n"; + $message .= "In case of complications regarding this user account registration, "; + $message .= "please contact support@yourdomain.com\r\n\r\n"; + $message .= "With kind regards, your yourdomain.com Team"; + + mail($email, $subject, $message, $headers); + + echo " you have been successfully registered. + Read your email and click the link to activate your account."; + } + else { + echo mysql_error (); + } + } + else { + display_register_form (); + } +} +else if ($confirm != '' && strlen ($confirm) === 32) { + $query = "SELECT username FROM user WHERE MD5(CONCAT(username,'$secret'))='$confirm' AND active='0'"; + $result = mysql_query ("$query"); + if (mysql_num_rows ($result) == 1) { + # the registration confirmation was successufull, + # thus we can enable the useraccount in the database. + $username = mysql_result ($result, 0); + $query = "UPDATE user SET active='1' WHERE username='$username' AND active='0'"; + if (mysql_query ($query)) { + echo "You are now registered. Happy bookmarking!"; + } + } + else { + display_register_form (); + } +} +else { + display_register_additional_text (); + display_register_form (); +} + +function display_register_form () { +?> + +
" name="loginform"> + + + + + + + + + + + + + + + + + + + + + +
Username:
Password:
Password Verification:
Email Address:
+
+ + +

Please provide the information bellow to register.

+ +

If you are already a registered user, you can log in here.

+ diff --git a/select_folder.php b/select_folder.php new file mode 100644 index 0000000..1a11b5d --- /dev/null +++ b/select_folder.php @@ -0,0 +1,26 @@ + + +

Select Folder

+ +
+ + make_tree (0); + $tree->print_tree (); + $path = $tree->print_path ($folderid); + ?> + +
+
+ + + + + diff --git a/settings.php b/settings.php new file mode 100644 index 0000000..f3dd9b8 --- /dev/null +++ b/settings.php @@ -0,0 +1,368 @@ + set_post_foldername ("settings_root_folder_name"), + 'column_width_folder' => check_num_var ("settings_column_width_folder"), + 'column_width_bookmark' => check_num_var ("settings_column_width_bookmark"), + 'table_height' => check_num_var ("settings_table_height"), + 'confirm_delete' => set_post_bool_var ("settings_confirm_delete", false), + 'open_new_window' => set_post_bool_var ("settings_open_new_window", false), + 'show_bookmark_description' => set_post_bool_var ("settings_show_bookmark_description", false), + 'show_bookmark_icon' => set_post_bool_var ("settings_show_bookmark_icon", false), + 'show_column_date' => set_post_bool_var ("settings_show_column_date", false), + 'date_format' => check_date_format (), + 'show_column_edit' => set_post_bool_var ("settings_show_column_edit", false), + 'show_column_move' => set_post_bool_var ("settings_show_column_move", false), + 'show_column_delete' => set_post_bool_var ("settings_show_column_delete", false), + 'fast_folder_minus' => set_post_bool_var ("settings_fast_folder_minus", false), + 'fast_folder_plus' => set_post_bool_var ("settings_fast_folder_plus", false), + 'fast_symbol' => set_post_bool_var ("settings_fast_symbol", false), + 'simple_tree_mode' => set_post_bool_var ("settings_simple_tree_mode", false), + 'show_public' => set_post_bool_var ("settings_show_public", false), + ); + + $query = sprintf ("UPDATE user SET + root_folder_name ='%s', + column_width_folder ='%d', + column_width_bookmark ='%d', + table_height ='%d', + confirm_delete ='%d', + open_new_window ='%d', + show_bookmark_description ='%d', + show_bookmark_icon ='%d', + show_column_date ='%d', + date_format ='%s', + show_column_edit ='%d', + show_column_move ='%d', + show_column_delete ='%d', + fast_folder_minus ='%d', + fast_folder_plus ='%d', + fast_symbol ='%d', + simple_tree_mode ='%d', + show_public ='%d' + WHERE username='%s'", + + $mysql->escape ($settings['root_folder_name']), + $settings['column_width_folder'], + $settings['column_width_bookmark'], + $settings['table_height'], + $settings['confirm_delete'], + $settings['open_new_window'], + $settings['show_bookmark_description'], + $settings['show_bookmark_icon'], + $settings['show_column_date'], + $mysql->escape ($settings['date_format']), + $settings['show_column_edit'], + $settings['show_column_move'], + $settings['show_column_delete'], + $settings['fast_folder_minus'], + $settings['fast_folder_plus'], + $settings['fast_symbol'], + $settings['simple_tree_mode'], + $settings['show_public'], + $mysql->escape ($username)); + + if ($mysql->query ($query)) { + $message = "Settings applied."; + } + else { + message ($mysql->error); + } +} + +# I really don't feel like putting these very specific function into lib.php... +function check_num_var ($varname) { + if (!is_numeric ($_POST[$varname])) { + return 280; + } + else if ($_POST[$varname] == 0 && $varname == "settings_column_width_bookmark") { + return 0; + } + else if ($_POST[$varname] < 100) { + return 100; + } + else if ($_POST[$varname] > 800) { + return 800; + } + else { + return $_POST[$varname]; + } +} + +function check_date_format () { + global $date_formats; + $date_format = set_post_num_var ('settings_date_format'); + + if ($date_format < 0 || $date_format > count ($date_formats)) { + return 0; + } + else { + return $date_format; + } +} + +?> + + + + + + + +
My Settings + +
+
+
+ + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name of the root folder + +
The width in pixels of the folder column
100 - 800 pixel
+ +
The width in pixels of the bookmark column
100 - 800 pixel or 0 for 100%
+ +
The height in pixels of the main table
100 - 800 pixel
+ +
Confirm deletions of bookmarks an folders + > +
Open a new window when clicking a bookmark + > +
Show the bookmarks description in the overview + > +
Enable favicon support: + > +
Show the column with the change date: + > +
Date format: + +
Show the private/public column: private + > +
Show the column to edit a bookmark: + > +
Show the column to move a bookmark: + > +
Show the column to delete a bookmark: + > +
Collapse tree when clicking on folder icon: + > +
Expand tree when clicking on folder icon: + > +
Select folder when clicking on plus/minus symbol + > +
Allways open just one tree + > +
+ +
+
+
+ +

+ You can add a button to your browsers "Link Bar" or "Hotlist" so that any homepage + can be bookmarked with one click. Title and URL of the current homepage are being preset. + Basically you can make Online-Bookmarks behave in two different ways showing its + dialog. Either a new window pops up or it shows it in the same window. +

+

+ To show the Online-Bookmarks dialog in a new window, drag this link to the + Link Bar.
+ + + bookmark +
+

+

+ To open the Online-Bookmarks dialog in the same window, drag this link to the + Link Bar.
+ + bookmark +
+

+

+ Note that if your browser has a Popup Blocker enabled you might experience difficulties using + the upper link. +

+
+ +
+ + diff --git a/shared.php b/shared.php new file mode 100644 index 0000000..30b02f7 --- /dev/null +++ b/shared.php @@ -0,0 +1,168 @@ + + + + + + + + +
Shared Bookmarks + +
+
+
+ + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + +
+
+ + make_tree (0); + $tree->print_tree (); + ?> + +
+
+
+ + escape ($user), + $mysql->escape ($folderid)); + + if ($mysql->query ($query)) { + $bookmarks = array (); + while ($row = mysql_fetch_assoc ($mysql->result)) { + array_push ($bookmarks, $row); + } + list_bookmarks ($bookmarks, + false, + false, + $settings['show_bookmark_icon'], + true, + $settings['show_bookmark_description'], + $settings['show_column_date'], + false, + false, + false, + false); + } + else { + message ($mysql->error); + } + ?> + + +
+
+ +query ($query)) { + echo '
' . "\n"; + while ($row = mysql_fetch_object ($mysql->result)) { + echo '

' . $row->user . "
\n"; + echo "Shares $row->folders Folders and $row->bookmarks Bookmarks

\n"; + } + echo "
"; + } + else { + message ($mysql->error); + } +} +?> + +
+ + diff --git a/sidebar.php b/sidebar.php new file mode 100644 index 0000000..5f85385 --- /dev/null +++ b/sidebar.php @@ -0,0 +1,156 @@ +tree = & new folder; + $this->tree->folders[0] = array ('id' => 0, 'childof' => null, 'name' => $GLOBALS['settings']['root_folder_name']); + + global $username, $mysql; + + $this->counter = 0; + + # collect the bookmark data + $query = sprintf ("SELECT title, url, description, childof, id, favicon + FROM bookmark + WHERE user='%s' + AND deleted!='1' ORDER BY title", + $mysql->escape ($username)); + + if ($mysql->query ($query)) { + while ($row = mysql_fetch_assoc ($mysql->result)) { + if (!isset ($this->bookmarks[$row['childof']])) { + $this->bookmarks[$row['childof']] = array (); + } + array_push ($this->bookmarks[$row['childof']], $row); + } + } + else { + message ($mysql->error); + } + } + + function make_tree ($folderid) { + if (isset ($this->tree->children[$folderid])) { + $this->counter++; + foreach ($this->tree->children[$folderid] as $value) { + $this->print_folder ($value); + $this->make_tree ($value); + $this->print_folder_close ($value); + } + $this->counter--; + } + $this->print_bookmarks ($folderid); + } + + function print_folder ($folderid) { + echo str_repeat (" ", $this->counter) . '
  • ' . $this->tree->folders[$folderid]['name'] . "\n"; + if (isset ($this->tree->children[$folderid]) || isset ($this->bookmarks[$folderid])) { + echo str_repeat (" ", $this->counter + 1) . "\n"; + } + echo str_repeat (" ", $this->counter) . "
  • \n"; + } + + function print_bookmarks ($folderid) { + $spacer = str_repeat (" ", $this->counter); + if (isset ($this->bookmarks[$folderid])) { + foreach ($this->bookmarks[$folderid] as $value) { + if ($value['favicon'] && is_file ($value['favicon'])) { + $icon = ''; + } + else { + $icon = ''; + } + echo $spacer . '
  • ' . $icon . " " . $value['title'] . "
  • \n"; + } + } + } +} + +?> + + + + + + + Online-Bookmarks + + + + + + + + + +

    Back to Online-Bookmarks

    + +' . "\n"; +$sidebar->make_tree (0); +echo "\n"; + +require_once (ABSOLUTE_PATH . "footer.php"); +?> diff --git a/style.css b/style.css new file mode 100644 index 0000000..7ae8b87 --- /dev/null +++ b/style.css @@ -0,0 +1,176 @@ +body,input,textarea,option { + font-family:verdana; + color:#555555; + font-size:10pt; +} +table { + border:0px solid black; + vertical-align:top; +} +td { + border:0px solid black; + vertical-align:top; + padding:3px; +} +img { + border: 0px solid #FFFFFF; + vertical-align:middle; + margin: 0px; +} +fieldset { + padding: 10px; + margin: 10px; +} +a { + color:#555555; + text-decoration:none; +} + +/* The Links */ +a.f { + color:#555555; + text-decoration:none; +} +a:hover.f { + color:#000000; + text-decoration:none; +} +a:visited { + text-decoration:none; +} +a:active { + text-decoration:none; +} +a:hover { + color:#AE1A1A; + text-decoration:underline; +} + + +input.invisible { + visibility:hidden; + background-color:#FFFFFF; + border:1px solid #FFFFFF; + font:1pt Verdana; + color:#FFFFFF; +} +p.title { + font-weight:bold; +} + + +/* + This is for the caption table +*/ +table.caption { + border: 1px solid black; + width: 100%; + margin-top: 10px; + background-image:url(./images/background.jpg); + background-repeat:no-repeat; + padding: 5px; + background-color:#DADADA; +} +td.captionright { + text-align: right; + width: 400px; + white-space:nowrap; +} +span.caption { + white-space:nowrap; + font-size:16pt; + font-weight: bold; + padding: 10px; + vertical-align:middle; +} + +/* + This is for the main table content +*/ +table.main { + width: 100%; + margin-top: 10px; + border-collapse: collapse; +} +td.main1{ + width: 150px; +} +td.main2,img.main2 { + width: 10px; +} +td.main3{ + border: 1px solid black; +} +td.main4{ + border: 1px solid black; + width: 100%; +} + +/* + This is for the menu table +*/ +table.menu { + border: 1px solid black; + background-color:#DADADA; + width: 150px; + border-collapse: collapse; + margin: 0px; +} +th.menuhead { + background-color:#969696; + border-bottom: 1px solid black; + padding: 5px; + text-align: left; + margin: 0px; +} +td.menu { + padding: 5px; + margin: 0px; +} + + +/* + This is for the folders +*/ +span.active { + background-color:#C1D2EE; + border:1px #316AC5 solid; + color:#000000; + padding:1px; +} + +/* + This is for the Bookmarks +*/ +div.description { + padding: 2px; +} +td.ten { + width: 10px; +} +div.private { + background-color: #E7FBE9; + color: #177F23; + text-align: center; +} +div.public { + background-color: #F9E7E9; + color: #E42037; + text-align: center; +} +div.private,div.public,div.description,div.date,div.footer { + font-size: smaller; + font-style: italic; +} +div.date { + white-space:nowrap; +} +span.private { + background-color: #E7FBE9; + color: #177F23; + font-size: smaller; + font-style: italic; +} +.sh:hover { + background-color: #E8E6E6; +}