diff --git a/.gitignore b/.gitignore
index 3be745b..8c455e8 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,7 @@
+# Installation specific .htaccess and auth passwd file in ajax/
+ajax/.htaccess
+ajax/links.auth
+
# OS generated files
.DS_Store
.DS_Store?
diff --git a/README.md b/README.md
index 89057b7..5fb5f65 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,11 @@
# LinkProvider
-A basic website/service to keep a list of URLs/Links and provide a URL for retrieving the list as a JSON object.
\ No newline at end of file
+A basic website/service to keep a list of URLs/Links and provide a URL for retrieving the list as a JSON object.
+
+## After Installation
+
+- Create a database and maybe user for use by the Link Manager then import the db.sql file.
+- Copy the config-dist.php file to config.php and edit the settings as appropriate.
+- Go into the ajax/ folder.
+ - Add a user with: htpasswd -c links.auth username.
+ - Copy the .htaccess-dist file to .htaccess, then edit the full path to this links.auth file.
diff --git a/ajax/.htaccess-dist b/ajax/.htaccess-dist
new file mode 100644
index 0000000..3f8d9d0
--- /dev/null
+++ b/ajax/.htaccess-dist
@@ -0,0 +1,6 @@
+AuthType Basic
+AuthName "Links"
+AuthUserFile /full/path/to/this/links.auth
+Require valid-user
+
+RedirectMatch 404 links.auth
diff --git a/getlinks/getlinkdata.php b/ajax/getlinkdata.php
similarity index 100%
rename from getlinks/getlinkdata.php
rename to ajax/getlinkdata.php
diff --git a/ajax/index.php b/ajax/index.php
new file mode 100644
index 0000000..fb12e02
--- /dev/null
+++ b/ajax/index.php
@@ -0,0 +1,9 @@
+setURL($url) === false ) {
$data['success'] = false;
- $data['message'] = "Invalid URL! URL cannot be left blank.";
+ $data['message'] = "Invalid URL! URL cannot be left blank and must be well formed.";
pushData();
}
if ( $link->setTitle($title) === false ) {
diff --git a/class_link.php b/class_link.php
index 555b476..a986db6 100755
--- a/class_link.php
+++ b/class_link.php
@@ -56,6 +56,7 @@ class WebLink {
public function setURL($value) {
if ( is_null($value) || ($value == "") ) return false;
+ if ( !filter_var($value, FILTER_VALIDATE_URL) ) return false;
$this->url = $value;
return true;
}
diff --git a/getlinks/index.php b/getlinks/index.php
index 2908ad9..ac09f1f 100755
--- a/getlinks/index.php
+++ b/getlinks/index.php
@@ -16,6 +16,7 @@ foreach ( $links as $link ) {
$row['description_safe'] = $link->getDescription(HTMLSAFE);
$data['links'][] = $row;
}
+$data['canedit'] = $_SESSION['validated'];
pushData($data);
exit();
diff --git a/htmlheader.php b/htmlheader.php
index 60b58bb..d229609 100755
--- a/htmlheader.php
+++ b/htmlheader.php
@@ -35,7 +35,7 @@ echo $extrasheets;
menu
" + link.url_safe + " | "; tabledata += "" + link.title_safe + " | "; tabledata += "" + link.description_safe + " | "; diff --git a/startsession.php b/startsession.php index 38957d1..5455e33 100755 --- a/startsession.php +++ b/startsession.php @@ -6,3 +6,4 @@ if ( php_sapi_name() == "cli" ) exit(); session_name(SESSNAME); session_start(); +if ( !isset($_SESSION['validated']) ) $_SESSION['validated'] = false;