commit ced9eba276d85618d08d5d126a5c6e01a6a7bf89 Author: Jarkko Toivanen Date: Fri Sep 27 05:47:54 2024 +0300 Started code yeaah diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..a5cee70 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/database.db \ No newline at end of file diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..3b6603b --- /dev/null +++ b/.htaccess @@ -0,0 +1,2 @@ +php_flag display_errors on +php_flag html_errors on \ No newline at end of file diff --git a/README.md b/README.md new file mode 100755 index 0000000..6b71c01 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +- Requires `SQLite3` (`sudo apt install php-sqlite3` on Debian) +- API requires mod_rewrite (`sudo a2enmod rewrite`) and configuring `AllowOverride all` for .htaccess + +The icon is from https://www.flaticon.com/authors/smashicons diff --git a/api/.htaccess b/api/.htaccess new file mode 100644 index 0000000..46d7c45 --- /dev/null +++ b/api/.htaccess @@ -0,0 +1,4 @@ +RewriteEngine on +RewriteCond %{HTTP:Authorization} ^(.*) +RewriteRule .* - [e=HTTP_AUTHORIZATION:%1] +RewriteRule ^ index.php \ No newline at end of file diff --git a/api/index.php b/api/index.php new file mode 100644 index 0000000..d0d9a76 --- /dev/null +++ b/api/index.php @@ -0,0 +1,20 @@ + diff --git a/favicon.ico b/favicon.ico new file mode 100755 index 0000000..9f24a77 Binary files /dev/null and b/favicon.ico differ diff --git a/inc/.htaccess b/inc/.htaccess new file mode 100755 index 0000000..ff2beb8 --- /dev/null +++ b/inc/.htaccess @@ -0,0 +1,2 @@ +order deny,allow +deny from all diff --git a/inc/database.php b/inc/database.php new file mode 100755 index 0000000..b946115 --- /dev/null +++ b/inc/database.php @@ -0,0 +1,52 @@ +open('database.db'); + + $sql = " + CREATE TABLE IF NOT EXISTS users ( + ID INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, + HANDLE TEXT NOT NULL UNIQUE, + NAME TEXT NOT NULL, + ABOUT TEXT NOT NULL + ); + + CREATE TABLE IF NOT EXISTS posts ( + ID INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, + TIME INTEGER NOT NULL, + USERID INTEGER NOT NULL, + TEXT TEXT NOT NULL + ); + + INSERT OR IGNORE INTO users (ID, HANDLE, NAME, ABOUT) VALUES ('0', 'SYSTEM', 'SYSTEM', ''); + + "; + + $ret = $this->exec($sql); + + } + + function addUser($handle, $name, $about="") { + $sql = "INSERT INTO users (HANDLE, NAME, ABOUT) VALUES ('$handle', '$name', '$about')"; + $ret = $this->exec($sql); + if(!$ret) { + die($this->lastErrorMsg()); + } + } + + function addPost($contents) { + $userid = 0; + $time = time(); + + $sql = "INSERT INTO posts (TIME, USERID, TEXT) values ('$time', '$userid', '$contents')"; + $ret = $this->exec($sql); + if(!$ret) { + die($this->lastErrorMsg()); + } + } +} +?> diff --git a/index.php b/index.php new file mode 100755 index 0000000..b388092 --- /dev/null +++ b/index.php @@ -0,0 +1,30 @@ + + + + + Snuffler + + +
+
+ + +

Snuffs

+ + + + +lastErrorMsg()); +} +$database->close(); + +?> \ No newline at end of file