]> 91.132.146.200 Git - dolphin.git/commitdiff
little bookmakr system
authorroot <root@debian.(none)>
Fri, 19 Nov 2010 21:08:40 +0000 (22:08 +0100)
committerroot <root@debian.(none)>
Fri, 19 Nov 2010 21:08:40 +0000 (22:08 +0100)
bookmarks/README [new file with mode: 0644]
bookmarks/config.php [new file with mode: 0644]
bookmarks/db_structure.sql [new file with mode: 0644]
bookmarks/edit.png [new file with mode: 0644]
bookmarks/index.php [new file with mode: 0644]

diff --git a/bookmarks/README b/bookmarks/README
new file mode 100644 (file)
index 0000000..0eaf9f6
--- /dev/null
@@ -0,0 +1,12 @@
+A simple Script to manage your Bookmarks without any third-party hoster eg. xmarks, apple etc.
+
+All you need is this script a MySQL Database and one table in it.
+
+Create your own subdomain and protect it with the htaccess file and your can now access and manage
+your Bookmarks everywhere.
+
+Independent to a browser or location.
+
+AND your data is where YOU know. Not in a cloud without security. You control it and decide where and who has access.
+
+copyright 2010 Johannes 'Banana' Keßler
diff --git a/bookmarks/config.php b/bookmarks/config.php
new file mode 100644 (file)
index 0000000..de91638
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+/**
+ * database configuration file
+ * alter to reflect your DB settings
+ */
+define('DB_HOST','localhost');
+define('DB_NAME','bookmarks');
+define('DB_USER','user');
+define('DB_PASS','test');
+?>
diff --git a/bookmarks/db_structure.sql b/bookmarks/db_structure.sql
new file mode 100644 (file)
index 0000000..d010c50
--- /dev/null
@@ -0,0 +1,9 @@
+CREATE TABLE `bookmarks` (
+  `id` int(10) NOT NULL AUTO_INCREMENT,
+  `category` varchar(128) DEFAULT NULL,
+  `title` varchar(128) DEFAULT NULL,
+  `link` varchar(255) DEFAULT NULL,
+  `date_added` int(10) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `link` (`link`)
+) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
diff --git a/bookmarks/edit.png b/bookmarks/edit.png
new file mode 100644 (file)
index 0000000..f4232c6
Binary files /dev/null and b/bookmarks/edit.png differ
diff --git a/bookmarks/index.php b/bookmarks/index.php
new file mode 100644 (file)
index 0000000..c855926
--- /dev/null
@@ -0,0 +1,116 @@
+<?php
+/**
+ * boomark management
+ */
+
+/**
+ * display any error we have
+ */
+ini_set('error_reporting',-1);
+ini_set('display_errors',true);
+
+# load the config file
+require('./config.php');
+# db connection
+$db_con = mysql_connect(DB_HOST,DB_USER,DB_PASS) OR die('Can not connect to SQL server');
+$db_sel = mysql_select_db(DB_NAME,$db_con) OR die('Can not select database');
+
+# process the add
+if(isset($_POST['sub']['submitNew'])) {
+       $link = trim($_POST['new']['link']);
+       $title = trim($_POST['new']['title']);
+       $cat = trim($_POST['new']['category']);
+       if(!empty($link) && !empty($title) && !empty($cat)) {
+               $query = mysql_query("INSERT INTO `bookmarks` 
+                                                               SET `category` = '".mysql_escape_string($cat)."',
+                                                                       `title` = '".mysql_escape_string($title)."',
+                                                                       `link` = '".mysql_escape_string($link)."',
+                                                                       `date_added` = '".time()."'");
+               if($query !== false) {
+                       header("Location: index.php");
+               }
+               else {
+                       echo "not saved";
+               }
+       }
+}
+elseif(isset($_POST['sub']['submitEdit']) && isset($_GET['edit']) && !empty($_GET['edit'])) {
+# process edit
+       $link = trim($_POST['new']['link']);
+       $title = trim($_POST['new']['title']);
+       $cat = trim($_POST['new']['category']);
+       if(!empty($link) && !empty($title) && !empty($cat)) {
+               $query = mysql_query("UPDATE `bookmarks` 
+                                                               SET `category` = '".mysql_escape_string($cat)."',
+                                                                       `title` = '".mysql_escape_string($title)."',
+                                                                       `link` = '".mysql_escape_string($link)."'
+                                                               WHERE `id` = '".mysql_escape_string($_GET['edit'])."'");
+               if($query !== false) {
+                       header("Location: index.php");
+               }
+               else {
+                       echo "not saved";
+               } 
+       }
+}
+
+# get the bookmarks
+$bookmarks = array();
+$query = mysql_query('SELECT * FROM `bookmarks` ORDER BY `category`,`title`');
+if(mysql_num_rows($query) > 0) {
+       while($result = mysql_fetch_assoc($query)) {
+               $bookmarks[$result['id']] = $result;
+       }
+}
+?>
+<html>
+       <head>
+               <title>Bookmarks for myself</title>
+               <style type="text/css">
+                       img {
+                               border: 0;
+                               padding: 0;
+                               margin: 0;
+                       }
+               </style>
+       </head>
+       <body>
+       <?php if(isset($_GET['edit']) && !empty($_GET['edit'])) { ?>
+       <form method="post" action="">
+               Link:<br />
+               <input type="text" name="new[link]" size="60" value="<?php echo $bookmarks[$_GET['edit']]['link']; ?>" /><br />
+               Titel:<br />
+               <input type="text" name="new[title]" value="<?php echo $bookmarks[$_GET['edit']]['title']; ?>" size="60" /><br />
+               Kategorie:<br />
+               <input type="text" name="new[category]" value="<?php echo $bookmarks[$_GET['edit']]['category']; ?>" size="60" /><br />
+               <button type="submit" title="Speichern" name="sub[submitEdit]">Speichern</button>
+       </form>
+       <?php } else { ?>
+       <form method="post" action="">
+               Link:<br />
+               <input type="text" name="new[link]" size="60" value="" /><br />
+               Titel:<br />
+               <input type="text" name="new[title]" value="" size="60" /><br />
+               Kategorie:<br />
+               <input type="text" name="new[category]" value="" size="60" /><br />
+               <button type="submit" title="Speichern" name="sub[submitNew]">Speichern</button>
+       </form>
+       <?php
+       }
+       # display the bookmark
+       if(!empty($bookmarks)) {
+               $cat = false;
+               foreach($bookmarks as $entry) {
+                       if($cat != $entry['category']) {
+                               if(!empty($cat)) echo '</ul>';
+                               echo '<h2>'.$entry['category'].'</h2>';
+                               echo '<ul>';
+                               $cat = $entry['category'];
+                       }
+                       echo '<li><a href="'.$entry['link'].'">'.$entry['title'].'</a> | <a href="index.php?edit='.$entry['id'].'" title="edit"><img src="edit.png" width="16" alt="edit" /></a></li>';
+               }
+               echo '</ul>';
+       }
+?>
+       </body>
+</html>