Skip to content

Commit 14262d6

Browse files
committed
Username, password, data dir settable in config.
1 parent 1ae8e85 commit 14262d6

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.DS_Store
2+
config.php

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
HTML5 Notepad App
2+
by Kaspars Dambis
3+
http://konstruktors.com
4+
5+
## Installation
6+
7+
* Copy files up
8+
* Make a data dir for notebook pages to go into
9+
* Copy config-example.php to config.php
10+
* Edit config.php
11+

README.txt

-14
This file was deleted.

config-example.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
// Example config.php
3+
// Copy this file to config.php to take effect
4+
5+
$username = "demo";
6+
$password = "demo";
7+
$data_dir = "entries"
8+
?>

sync.php

+14-9
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
error_reporting(E_ERROR);
44

5-
define('DATA_DIR', 'entries'); // use this to protect files from being publicly viewable
6-
define("USERNAME", 'demo');
7-
define('PASSWORD', 'demo');
8-
9-
if (($_SERVER['PHP_AUTH_USER'] !== USERNAME) || ($_SERVER['PHP_AUTH_PW'] !== PASSWORD)) {
10-
header('WWW-Authenticate: Basic realm="Cloud Notes"');
11-
header('HTTP/1.0 401 Unauthorized');
12-
exit;
5+
// if config file exists then load it
6+
if(file_exists('config.php')) {
7+
require_once('config.php');
8+
}
9+
10+
define('DATA_DIR', isset($data_dir) ? $data_dir : 'entries'); // use this to protect files from being publicly viewable
11+
12+
if (isset($username) && isset($password)) {
13+
if (($_SERVER['PHP_AUTH_USER'] !== $username) || ($_SERVER['PHP_AUTH_PW'] !== $password)) {
14+
header('WWW-Authenticate: Basic realm="Cloud Notes"');
15+
header('HTTP/1.0 401 Unauthorized');
16+
exit;
17+
}
1318
}
1419

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

139-
?>
144+
?>

0 commit comments

Comments
 (0)