# Bookmark site



## russ1162 (Feb 12, 2002)

How do i add a bookmarks script to my website www.rn1162.com


----------



## colinsp (Sep 5, 2007)

Do you have a script? Or do you want suggestions for one? Or what?


----------



## russ1162 (Feb 12, 2002)

I would like suggestions on how to start one of my own. Just to bookmark my links online instead of computer or else where .


----------



## colinsp (Sep 5, 2007)

You need to give us a bit more information of exactly how you want to do this.

Do you want to share bookmarks between different computer? Do you want a webpage you host yourself? Do you want a webpage on some sort of service that stores your bookmarks for you?

Clearly define what you want to do and then maybe we can suggest something.


----------



## russ1162 (Feb 12, 2002)

colin,

I want to put this service on rn1162.com for just myself to use. If I would to publicly show the page I could then. Host my own bookmarks to keep track of my stuff. 

Thanks,
Russ


----------



## colinsp (Sep 5, 2007)

Which browser do you use? That depends on the answer.

If Firefox for instance you can select Bookmarks > Show All Bookmarks > Import and Backup > Export Bookmarks to HTML. This will create an html file that you can then upload to your site.

Other browsers have similar export features but without knowing which you are using .....

Firefox has a Sync setting which allows you to sync your bookmarks across multiple computers which I use rather than putting them up on the internet.


----------



## russ1162 (Feb 12, 2002)

I would like to use multiple browsers, across multiple computers to do this. So that when i am on a public computer I can just drop by a page an add the link. 

Thanks,

Russ


----------



## colinsp (Sep 5, 2007)

This is what I asked earlier to fully specify what you want. 

This will probably have to be a bespoke application with an input form for new sites, it will probably need a database as you will want to store the urls by group of similar type.

I am not aware of anything that will do this. Try having a look at Hotscripts to see if there is something that will do this for you BUT fully specify what you want to do before you go looking so that you know if a pre-written script will do all that you want.


----------



## russ1162 (Feb 12, 2002)

I want a site that does this on my own homepage. http://www.mybookmarks.com/public/russ1162


----------



## JiminSA (Dec 15, 2011)

Are you looking for something like this - it may fit the bill.


----------



## russ1162 (Feb 12, 2002)

JiminSA,

Will an app like this work on a flash drive.
http://bkm.sourceforge.net/en/index.html

Russ


----------



## JiminSA (Dec 15, 2011)

I don't see why not. It seems completely self-contained - i.e. it doesn't appear to use OS dependent folders et cetera - it uses a python db.
Were you looking for portability?


----------



## russ1162 (Feb 12, 2002)

JiminSA,

I am looking for portability too. Well i just think some of the one you could buy my work better but i do not know which ones.
Plus there might be some good free ones that I do not know about.

Thanks,

russ


----------



## JiminSA (Dec 15, 2011)

Russ, I've had a good Google around and have not been able to find a script that really fits what you want to do.
So, I had a little time on my hands and have written what I think you are looking for.
It requires you to change your .html landing page (i.e. the page where you want to show your bookmarks) to a .php file and inserting some code into it as follows:-
In the head section insert the following:-

```
<!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
```
This, because I've written it using bootstrap styling.
Next we need to insert a side panel to display your bookmarks. So insert the following within your body section:-

```
<div class="container">
	<div class="span2"> <!-- Sidebar content -->
		<h3>Bookmarks</h3>
<?php
	$filename = 'bkm_data.txt';

	if(file_exists($filename))
	{
		$data = unserialize(file_get_contents("bkm_data.txt")); // Unserializes the file's contents, thereby turning itself into an array. 
		if (!empty($data))
		{
			foreach($data as $key => $val) 
			{ // Iterates through the array 
				echo '<button type="button" class="btn btn-link"><a href="'.$val.'" target="_blank">'.$key.'</button><br />'; // Writes an href button for each key. 
			} 
		}
	}
?>				
	</div> <!-- END Sidebar content -->
</div>
```
Right, now for the bookmark creation program itself ...
Copy and paste the following into a Notepad++ page (or whatever editor you use) and save it as a .php file in the same folder as your landing page (in which we just inserted the above code) which you'll remember (I called mine 'booker.php')

```
<?php
	session_start();
	$array = array(); 

	if(isset($_POST['Name']) && $_POST['Name'] != "")
	{
		$name = htmlspecialchars($_POST['Name'], ENT_QUOTES);
		$url = htmlspecialchars($_POST['URL'], ENT_QUOTES);
		
		$filename = 'bkm_data.txt';
		if(file_exists($filename))
		{
			$array = unserialize(file_get_contents("bkm_data.txt")); // Unserializes the file's contents, thereby turning itself into an array. 
		}
		
		$array[$name] = $url;
		ksort($array);
		$res = fopen("bkm_data.txt","r+"); // Opens a resource 
		$string = serialize($array); // Sets a variable to identify the serialized array 
		$write = fwrite($res,$string); // Writes it to the file 
		@fclose($res); 
	}
	//unset($array[$name]);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="CMS to create Bookmarks">
    <meta name="author" content="Jim Ord">
    <link rel="icon" href="favicon.ico">

    <title>Bookmarker</title>

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
	<div class="container">
		<div class="row">
			<div class="span12"> <!-- form content -->
				<h3>Add a Bookmark</h3>
				<form name="Bookmark" action="" method="post">
					<label>Bookmark Name <input type="text" id="Bookmark" name="Name" required="required" /></label>
					<label>Bookmark URL <input type="text" id="Bookmark" name="URL" placeholder="http://" required="required" /></label>
					<button type="submit" class="btn btn-default">Submit</button>
				</form>
			</div> <!-- END form content -->
			<div class="span2"> <!-- Sidebar content -->
				<h3>Bookmarks</h3>
<?php
	$filename = 'bkm_data.txt';

	if(file_exists($filename))
	{
		$data = unserialize(file_get_contents("bkm_data.txt")); // Unserializes the file's contents, thereby turning itself into an array. 
		if (!empty($data))
		{
			foreach($data as $key => $val) 
			{ // Iterates through the array 
				echo '<button type="button" class="btn btn-link"><a href="'.$val.'" target="_blank">'.$key.'</button><br />'; // Writes an href button for each key. 
			} 
		}
	}
?>				
			</div> <!-- END Sidebar content -->
		</div>
	</div>
</body>
</html>
```
Finally, you need to create an empty .txt file - called bkm_data.txt (you can use MSNotepad or whatever to do this) and save it in the same folder as your landing page.
OK, upload that lot to your server, and then create a url to the above program (e.g. http://yoursite.com/booker.php) and start creating your bookmarks - enjoy
FYI...
I have not used a database per se, to hold your bookmarks (it's such a small load), but as you've probably seen, I am using a .txt file which I serialize and unserialize accordingly. It's a handy alternative to a db IMHO
Take a peek at the attachment to see how it looks ...


----------



## JiminSA (Dec 15, 2011)

See it in action here. Would you like a delete function?


----------



## russ1162 (Feb 12, 2002)

JiminSA,
I will take a look at this when i get some more time.

Thanks,

Russ


----------



## russ1162 (Feb 12, 2002)

JiminSA,

Here is the link but i can not get the page to work right yet.

http://rn1162.com/bookmarks.php

Please can you help me with that. Plus can I get http:// as a value instead of gray text.

Thanks,

Russ


----------



## JiminSA (Dec 15, 2011)

> Finally, you need to create an empty .txt file - called bkm_data.txt


Did you do this?
AND simply add value="http://" within the input statement and remove the placeholder="http://"


----------



## russ1162 (Feb 12, 2002)

JiminSA,

Why can't I use the file after I created bkm_data.txt ?

Here is the link: http://rn1162.com/bookmarks.php

Thanks,
Russ


----------



## JiminSA (Dec 15, 2011)

> Warning: fopen(bkm_data.txt) [function.fopen]: failed to open stream: Permission denied in D:\Hosting\5711000\html\bookmarks.php on line 18


I'll need to see the full script please Russ - php included ...


----------



## russ1162 (Feb 12, 2002)

JiminSA,
Here is what i have in the bookmarks.php file.



> <?php
> session_start();
> $array = array();
> 
> ...


here is the link again:

http://www.rn1162.com/bookmarks.php

Thanks,

Russ


----------



## JiminSA (Dec 15, 2011)

We need to check the file permissions on bkm_data.txt. If you are using Filezilla just right click on the file on the server and set the permissions to at least '604'.


----------



## russ1162 (Feb 12, 2002)

JiminSA,

I do not have permission to change file permissions on godaddy at all.

What can i do now ? Plus godaddys economy package is $3.99 a month . That is where I would be able to change permissions. Is there any other suggestions ?

Thanks,
Russ


----------



## JiminSA (Dec 15, 2011)

> I do not have permission to change file permissions on godaddy at all.


No problem, I don't think that the file permissions are the problem. If you can change the relative address of the file to an absolute hyperlink address it should solve it - i.e. if you change this line

```
$filename = 'bkm_data.txt';
```
 to

```
$filename = 'http://www.rn1162.com/bkm_data.txt';
```
 it should sort the problem (i.e change from a relative address to an absolute hyperlink address).
It seems that Godaddy has kept your local addressing (D://) when creating the 'online' address
(BTW, you can change file permission in Windows Explorer thus)


----------



## russ1162 (Feb 12, 2002)

JiminSA,

this is my script now.



> <?php
> session_start();
> $array = array();
> 
> ...


Thanks

Russ


----------



## JiminSA (Dec 15, 2011)

Sorry my bad, but you must replace "bkm_data.txt" with $filename in ALL your open and unserialize statements.


----------



## russ1162 (Feb 12, 2002)

JiminSA,

What do i do now ?



> <?php
> session_start();
> $array = array();
> 
> ...


The website address again is: http://www.rn1162.com/bookmarks.php

Thanks,
Russ


----------



## JiminSA (Dec 15, 2011)

Get Godaddy to give you write permissions for the bookmark file or find a host who will ... 'cos that's all that's stopping the script from working.
After a little research, I discovered this forum thread (it's for aspx, but the principle applies also to php) which kinda explains things! Godaddy have a medium trust policy which disallows writes. There seems to be a solution in the very last post of that forum thread, which we would have to adapt for php.
But before going along that path,, get in touch with Godaddy support and ask them if they can enable write permissions on a new directory within your root folder and if they can, then put bkm_data.txt in there and change your $filename = "http://........" to $filename = "Actual New Directory Name/bkm_data.txt"
BTW - my bad (again - we live and learn), but one cannot use absolute hyperlink addressing for file operations.


----------



## russ1162 (Feb 12, 2002)

JiminSA,

Do you know of any other cheap hosting providers or other ways to host this file?

Thanks,
Russ


----------



## JiminSA (Dec 15, 2011)

These guys have been established as free hosting providers for a number of years and I have inquired about write permissions on files - will let you know if they can provide ...


----------



## russ1162 (Feb 12, 2002)

JiminSA,

I would still like to pay godaddy for the domain registration but just move the web hosting over there.

Can you plus contact me through private messing to let me know more info?

Thanks,

Russ


----------



## JiminSA (Dec 15, 2011)

If you use 000webhost.com, you do not need to register a domain at all. But if you have (e.g. with Godaddy) simply go to 'ORDER NOW' and insert that registered domain name in the first box. Then complete boxes 3-6 and the Captcha, submit and you're away!
BTW there are no Trust Policy restrictions on 000webhost.com, so the script will work.


----------

