diff --git a/tkr/bootstrap.php b/tkr/bootstrap.php
index 0f46872..b5c2aa1 100644
--- a/tkr/bootstrap.php
+++ b/tkr/bootstrap.php
@@ -39,6 +39,8 @@ function confirm_setup(): void {
username TEXT NOT NULL,
display_name TEXT NOT NULL,
password_hash TEXT NOT NULL,
+ about TEXT NULL,
+ website TEXT NULL,
mood TEXT NULL
)");
diff --git a/tkr/lib/emoji.php b/tkr/lib/emoji.php
index 7cb450f..d91d467 100644
--- a/tkr/lib/emoji.php
+++ b/tkr/lib/emoji.php
@@ -3,7 +3,6 @@ function get_emojis_with_labels(): array {
return [
'faces' => [
['๐', 'grinning face'],
- ['๐', 'grinning face with big eyes'],
['๐', 'grinning face with smiling eyes'],
['๐', 'beaming face with smiling eyes'],
['๐', 'grinning squinting face'],
@@ -26,41 +25,31 @@ function get_emojis_with_labels(): array {
['๐', 'winking face with tongue'],
['๐', 'squinting face with tongue'],
['๐คช', 'zany face'],
- ['๐คจ', 'face with raised eyebrow'],
+ ['๐ฆธ', 'superhero'],
+ ['๐ฆน', 'supervillain'],
+ ['๐ง', 'mage'],
+ ['๐ง', 'vampire'],
+ ['๐ง', 'zombie'],
+ ['๐ง', 'genie'],
],
'gestures' => [
['๐', 'waving hand'],
- ['๐ค', 'raised back of hand'],
- ['๐๏ธ', 'hand with fingers splayed'],
- ['โ', 'raised hand'],
['๐', 'vulcan salute'],
['๐', 'OK hand'],
['๐ค', 'pinched fingers'],
- ['๐ค', 'pinching hand'],
['โ๏ธ', 'victory hand'],
['๐ค', 'crossed fingers'],
['๐ค', 'love-you gesture'],
['๐ค', 'sign of the horns'],
['๐ค', 'call me hand'],
- ['๐', 'backhand index pointing left'],
- ['๐', 'backhand index pointing right'],
- ['๐', 'backhand index pointing up'],
- ['๐', 'middle finger'],
- ['๐', 'backhand index pointing down'],
- ['โ๏ธ', 'index pointing up'],
['๐', 'thumbs up'],
['๐', 'thumbs down'],
['โ', 'raised fist'],
['๐', 'oncoming fist'],
- ['๐ค', 'left-facing fist'],
- ['๐ค', 'right-facing fist'],
],
'nature' => [
['โ๏ธ', 'sun'],
- ['๐ค๏ธ', 'sun behind small cloud'],
['โ
', 'sun behind cloud'],
- ['๐ฅ๏ธ', 'sun behind large cloud'],
- ['๐ฆ๏ธ', 'sun behind rain cloud'],
['๐ง๏ธ', 'cloud with rain'],
['๐จ๏ธ', 'cloud with snow'],
['โ๏ธ', 'snowflake'],
@@ -72,14 +61,9 @@ function get_emojis_with_labels(): array {
['๐', 'water wave'],
['๐ซ๏ธ', 'fog'],
['๐ฌ๏ธ', 'wind face'],
- ['๐', 'leaf fluttering in wind'],
['๐', 'fallen leaf'],
- ['๐', 'maple leaf'],
- ['๐พ', 'sheaf of rice'],
['๐ต', 'cactus'],
['๐ด', 'palm tree'],
- ['๐ณ', 'deciduous tree'],
- ['๐ฒ', 'evergreen tree'],
['๐ธ', 'cherry blossom'],
],
'animals' => [
@@ -98,45 +82,14 @@ function get_emojis_with_labels(): array {
['๐ท', 'pig face'],
['๐ธ', 'frog face'],
['๐ต', 'monkey face'],
- ['๐', 'see-no-evil monkey'],
- ['๐', 'hear-no-evil monkey'],
- ['๐', 'speak-no-evil monkey'],
['๐', 'chicken'],
['๐ง', 'penguin'],
['๐ฆ', 'bird'],
- ['๐ค', 'baby chick'],
['๐ฃ', 'hatching chick'],
['๐บ', 'wolf face'],
['๐ฆ', 'unicorn face'],
],
- 'people' => [
- ['๐ง', 'person'],
- ['๐ฉ', 'woman'],
- ['๐จ', 'man'],
- ['๐ถ', 'baby'],
- ['๐ง', 'girl'],
- ['๐ฆ', 'boy'],
- ['๐ง', 'child'],
- ['๐ต', 'older woman'],
- ['๐ด', 'older man'],
- ['๐ง', 'older adult'],
- ['๐ฒ', 'person with skullcap'],
- ['๐ง', 'woman with headscarf'],
- ['๐ณ', 'person wearing turban'],
- ['๐ฎ', 'police officer'],
- ['๐ต๏ธ', 'detective'],
- ['๐ท', 'construction worker'],
- ['๐', 'guard'],
- ['๐ธ', 'princess'],
- ['๐คด', 'prince'],
- ['๐ฆธ', 'superhero'],
- ['๐ฆน', 'supervillain'],
- ['๐ง', 'mage'],
- ['๐ง', 'vampire'],
- ['๐ง', 'zombie'],
- ['๐ง', 'genie'],
- ],
- 'emotions' => [
+ 'hearts' => [
['โค๏ธ', 'red heart'],
['๐งก', 'orange heart'],
['๐', 'yellow heart'],
@@ -155,49 +108,32 @@ function get_emojis_with_labels(): array {
['๐', 'heart with ribbon'],
['๐', 'broken heart'],
['โฃ๏ธ', 'heart exclamation'],
- ['๐', 'heart decoration'],
- ['๐ค', 'zzz'],
- ['๐คฏ', 'exploding head'],
- ['๐ฑ', 'face screaming in fear'],
- ['๐ฅต', 'hot face'],
- ['๐ฅถ', 'cold face'],
- ['๐คฌ', 'face with symbols on mouth'],
],
'activities' => [
['๐ด', 'person biking'],
['๐ต', 'person mountain biking'],
['๐', 'person running'],
- ['๐โโ๏ธ', 'woman running'],
['๐๏ธ', 'person lifting weights'],
['๐', 'person swimming'],
['๐', 'person surfing'],
['๐ฃ', 'person rowing boat'],
- ['๐คฝ', 'person playing water polo'],
- ['๐คพ', 'person playing handball'],
- ['โน๏ธ', 'person bouncing ball'],
['๐คธ', 'person cartwheeling'],
['๐ง', 'person in lotus position'],
- ['๐', 'horse racing'],
['๐ง', 'person climbing'],
['๐๏ธ', 'camping'],
['๐ฃ', 'fishing pole'],
- ['โบ', 'tent'],
['๐ฟ', 'skis'],
['๐', 'snowboarder'],
['๐น', 'skateboard'],
- ['๐ผ', 'roller skate'],
['๐งบ', 'basket'],
['๐ฏ', 'bullseye'],
- ['๐๏ธ', 'person golfing'],
],
'hobbies' => [
['๐', 'books'],
['๐', 'open book'],
['๐ง', 'headphone'],
['๐ต', 'musical note'],
- ['๐ถ', 'musical notes'],
['๐ค', 'microphone'],
- ['๐ผ', 'musical score'],
['๐ท', 'saxophone'],
['๐ธ', 'guitar'],
['๐น', 'musical keyboard'],
@@ -205,71 +141,14 @@ function get_emojis_with_labels(): array {
['๐ป', 'violin'],
['๐ช', 'banjo'],
['โ๏ธ', 'writing hand'],
- ['๐๏ธ', 'pen'],
['๐', 'memo'],
['๐ท', 'camera'],
- ['๐ธ', 'camera with flash'],
['๐จ', 'artist palette'],
['๐งต', 'thread'],
['๐งถ', 'yarn'],
['๐ชก', 'sewing needle'],
['๐น', 'video camera'],
['๐ฌ', 'clapper board'],
- ['๐งฉ', 'puzzle piece'],
- ],
- 'tech' => [
- ['๐ป', 'laptop'],
- ['๐ฅ๏ธ', 'desktop computer'],
- ['๐จ๏ธ', 'printer'],
- ['๐ฑ๏ธ', 'computer mouse'],
- ['โจ๏ธ', 'keyboard'],
- ['๐ฑ', 'mobile phone'],
- ['๐ฒ', 'mobile phone with arrow'],
- ['๐', 'telephone receiver'],
- ['โ๏ธ', 'telephone'],
- ['๐', 'pager'],
- ['๐ ', 'fax machine'],
- ['๐', 'battery'],
- ['๐', 'electric plug'],
- ['๐ฝ', 'computer disk'],
- ['๐พ', 'floppy disk'],
- ['๐ฟ', 'optical disk'],
- ['๐', 'dvd'],
- ['๐งฎ', 'abacus'],
- ['๐น๏ธ', 'joystick'],
- ['๐ก', 'satellite antenna'],
- ['๐', 'magnifying glass tilted left'],
- ['๐', 'magnifying glass tilted right'],
- ['๐งญ', 'compass'],
- ['๐', 'bar chart'],
- ['๐', 'chart increasing'],
- ],
- 'travel' => [
- ['โ๏ธ', 'airplane'],
- ['๐ซ', 'airplane departure'],
- ['๐ฌ', 'airplane arrival'],
- ['๐', 'automobile'],
- ['๐', 'taxi'],
- ['๐', 'sport utility vehicle'],
- ['๐', 'bus'],
- ['๐', 'trolleybus'],
- ['๐๏ธ', 'racing car'],
- ['๐', 'police car'],
- ['๐', 'ambulance'],
- ['๐', 'fire engine'],
- ['๐', 'minibus'],
- ['๐ป', 'pickup truck'],
- ['๐', 'delivery truck'],
- ['๐', 'articulated lorry'],
- ['๐', 'tractor'],
- ['๐ฒ', 'bicycle'],
- ['๐ด', 'kick scooter'],
- ['๐จ', 'police car light'],
- ['โต', 'sailboat'],
- ['๐ค', 'speedboat'],
- ['๐ณ๏ธ', 'passenger ship'],
- ['โด๏ธ', 'ferry'],
- ['๐', 'helicopter'],
],
'food' => [
['๐', 'red apple'],
@@ -294,10 +173,34 @@ function get_emojis_with_labels(): array {
['๐', 'hamburger'],
['๐', 'french fries'],
['๐ญ', 'hot dog'],
- ['๐ฅช', 'sandwich'],
- ['๐ฎ', 'taco'],
['๐ฃ', 'sushi'],
],
+ 'vibes' => [
+ ['๐ค', 'zzz'],
+ ['๐คฏ', 'exploding head'],
+ ['๐ฑ', 'face screaming in fear'],
+ ['๐ฅต', 'hot face'],
+ ['๐ฅถ', 'cold face'],
+ ['๐คฌ', 'face with symbols on mouth'],
+ ['๐คจ', 'face with raised eyebrow'],
+ ],
+ 'tech' => [
+ ['๐ป', 'laptop'],
+ ['๐', 'telephone receiver'],
+ ['๐', 'battery'],
+ ['๐ฟ', 'optical disk'],
+ ['๐น๏ธ', 'joystick'],
+ ['๐', 'magnifying glass tilted left'],
+ ['๐', 'chart increasing'],
+ ],
+ 'travel' => [
+ ['โ๏ธ', 'airplane'],
+ ['๐', 'automobile'],
+ ['๐', 'taxi'],
+ ['๐ฒ', 'bicycle'],
+ ['๐ด', 'kick scooter'],
+ ['โต', 'sailboat'],
+ ],
//'custom' => get_user_emojis($db),
];
diff --git a/tkr/lib/mood.php b/tkr/lib/mood.php
index 193b5d2..3b13b1e 100644
--- a/tkr/lib/mood.php
+++ b/tkr/lib/mood.php
@@ -1,34 +1,28 @@
prepare("SELECT mood FROM user WHERE username=?");
- $stmt->execute([$_SESSION['username']]);
- $row = $stmt->fetch();
-
- return $row['mood'];
-}
-
function save_mood(string $mood): void {
$config = Config::load();
- $db = get_db();
+ $user = User::load();
+ //$db = get_db();
- $stmt = $db->prepare("UPDATE user SET mood=? WHERE username=?");
- $stmt->execute([$mood, $_SESSION['username']]);
+ //$stmt = $db->prepare("UPDATE user SET mood=? WHERE username=?");
+ //$stmt->execute([$mood, $_SESSION['username']]);
+ $user->mood = $mood;
+ $user = $user->save();
header("Location: $config->basePath");
exit;
}
function render_emoji_tabs(): string {
+ $user = User::load();
$emoji_groups = get_emojis_with_labels();
- $selected_emoji = get_mood();
+ $selected_emoji = $user->mood;
ob_start();
?>
diff --git a/tkr/lib/ticks.php b/tkr/lib/ticks.php
index d7b8886..5e84713 100644
--- a/tkr/lib/ticks.php
+++ b/tkr/lib/ticks.php
@@ -1,20 +1,6 @@
"\'()]+)~i',
- fn($matches) => '' . $matches[1] . '',
- $safe
- );
-
- return $safe;
-}
-
function save_tick(string $tick): void {
// build the tick path and filename from the current time
$date = new DateTime();
diff --git a/tkr/lib/user.php b/tkr/lib/user.php
index cfa0379..e490dd0 100644
--- a/tkr/lib/user.php
+++ b/tkr/lib/user.php
@@ -9,6 +9,8 @@ class User {
// properties
public string $username;
public string $displayName;
+ public string $about;
+ public string $website;
public string $mood;
// load user settings from sqlite database
@@ -16,13 +18,15 @@ class User {
$db = get_db();
// There's only ever one user. I'm just leaning into that.
- $stmt = $db->query("SELECT username, display_name, mood FROM user WHERE id=1");
+ $stmt = $db->query("SELECT username, display_name, about, website, mood FROM user WHERE id=1");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$u = new self();
if ($row) {
$u->username = $row['username'];
$u->displayName = $row['display_name'];
+ $u->about = $row['about'] ?? '';
+ $u->website = $row['website'] ?? '';
$u->mood = $row['mood'];
}
@@ -32,8 +36,8 @@ class User {
public function save(): self {
$db = get_db();
- $stmt = $db->prepare("UPDATE user SET username=?, display_name=?, mood=? WHERE id=1");
- $stmt->execute([$this->username, $this->displayName, $this->mood]);
+ $stmt = $db->prepare("UPDATE user SET username=?, display_name=?, about=?, website=?, mood=? WHERE id=1");
+ $stmt->execute([$this->username, $this->displayName, $this->about, $this->website, $this->mood]);
return self::load();
}
diff --git a/tkr/lib/util.php b/tkr/lib/util.php
new file mode 100644
index 0000000..db95f59
--- /dev/null
+++ b/tkr/lib/util.php
@@ -0,0 +1,15 @@
+"\'()]+)~i',
+ fn($matches) => '' . $matches[1] . '',
+ $safe
+ );
+
+ return $safe;
+}
diff --git a/tkr/public/admin.php b/tkr/public/admin.php
index 6ad61de..1f8c011 100644
--- a/tkr/public/admin.php
+++ b/tkr/public/admin.php
@@ -22,6 +22,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// User profile
$username = trim($_POST['username'] ?? '');
$displayName = trim($_POST['display_name'] ?? '');
+ $about = trim($_POST['about'] ?? '');
+ $website = trim($_POST['website'] ?? '');
+
// Site settings
$siteTitle = trim($_POST['site_title']) ?? '';
$siteDescription = trim($_POST['site_description']) ?? '';
@@ -40,6 +43,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!$displayName) {
$errors[] = "Display name is required.";
}
+ // Make sure the website looks like a URL and starts with a protocol
+ if ($website) {
+ if (!filter_var($website, FILTER_VALIDATE_URL)) {
+ $errors[] = "Please enter a valid URL (including http:// or https://).";
+ } elseif (!preg_match('/^https?:\/\//i', $website)) {
+ $errors[] = "URL must start with http:// or https://.";
+ }
+ }
+
// Validate site settings
if (!$siteTitle) {
@@ -71,6 +83,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Update user profile
$user->username = $username;
$user->displayName = $displayName;
+ $user->about = $about;
+ $user->website = $website;
// Save user profile and reload user from database
$user = $user->save();
@@ -101,6 +115,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+
+