Skip to content

Username, password, data dir settable in config. #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
config.php
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HTML5 Notepad App
by Kaspars Dambis
http://konstruktors.com

## Installation

* Copy files up
* Make a data dir for notebook pages to go into
* Copy config-example.php to config.php
* Edit config.php

14 changes: 0 additions & 14 deletions README.txt

This file was deleted.

8 changes: 8 additions & 0 deletions config-example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
// Example config.php
// Copy this file to config.php to take effect

$username = "demo";
$password = "demo";
$data_dir = "entries"
?>
23 changes: 14 additions & 9 deletions sync.php
Original file line number Diff line number Diff line change
@@ -2,14 +2,19 @@

error_reporting(E_ERROR);

define('DATA_DIR', 'entries'); // use this to protect files from being publicly viewable
define("USERNAME", 'demo');
define('PASSWORD', 'demo');

if (($_SERVER['PHP_AUTH_USER'] !== USERNAME) || ($_SERVER['PHP_AUTH_PW'] !== PASSWORD)) {
header('WWW-Authenticate: Basic realm="Cloud Notes"');
header('HTTP/1.0 401 Unauthorized');
exit;
// if config file exists then load it
if(file_exists('config.php')) {
require_once('config.php');
}

define('DATA_DIR', isset($data_dir) ? $data_dir : 'entries'); // use this to protect files from being publicly viewable

if (isset($username) && isset($password)) {
if (($_SERVER['PHP_AUTH_USER'] !== $username) || ($_SERVER['PHP_AUTH_PW'] !== $password)) {
header('WWW-Authenticate: Basic realm="Cloud Notes"');
header('HTTP/1.0 401 Unauthorized');
exit;
}
}

header('Content-type: application/json; charset=utf-8');
@@ -136,4 +141,4 @@ function get_entries() {
return json_encode($entries);
}

?>
?>