diff --git a/cron.php b/cron.php new file mode 100644 index 0000000..101ef2f --- /dev/null +++ b/cron.php @@ -0,0 +1,65 @@ + DB_TYPE, + 'database_name' => DB_NAME, + 'server' => DB_SERVER, + 'username' => DB_USER, + 'password' => DB_PASS, + 'charset' => DB_CHARSET + ]); +} catch (Exception $ex) { + echo "Database error: $ex\n"; + exit(1); +} + +$reminders = $database->select('reminders', [ + 'reminderid (id)', + 'noteid', + 'when' + ], [ + 'when[<]' => date("Y-m-d H:i:s", strtotime("now + 15 minutes")) + ]); + +echo "Start sending " . count($reminders) . " reminder notifications...\n"; + +$deleteids = []; +$linelimit = 3; + +foreach ($reminders as $r) { + $note = Note::loadNote($r['noteid']); + $lines = explode("\n", $note->getText(), $linelimit); + if (count($lines) == $linelimit) { + array_pop($lines); + $lines[] = $Strings->build("Open {app} to read more", ["app" => SITE_TITLE], false); + } + $content = implode("\n", $lines); + Notifications::add($note->getOwner(), $Strings->get("Note Reminder", false), $content); + $deleteids[] = $r['id']; +} + +echo "Sent " . count($reminders) . " notifications.\n"; + +$deleted = $database->delete('reminders', ['reminderid' => $deleteids]); + +echo "Outdated reminder cleanup complete: " . $deleted->rowCount() . " records removed.\n"; diff --git a/database.mwb b/database.mwb index 63811fd..b331540 100644 Binary files a/database.mwb and b/database.mwb differ diff --git a/langs/en/notes.json b/langs/en/notes.json index a145157..f7a2caf 100644 --- a/langs/en/notes.json +++ b/langs/en/notes.json @@ -21,5 +21,7 @@ "Office": "Office", "Download (Text)": "Download (Text)", "Download (HTML)": "Download (HTML)", - "Download (Office)": "Download (Office)" + "Download (Office)": "Download (Office)", + "Note Reminder": "Note Reminder", + "Open {app} to read more": "Open {app} to read more" } diff --git a/settings.template.php b/settings.template.php index 020d77b..8aa4762 100644 --- a/settings.template.php +++ b/settings.template.php @@ -43,7 +43,7 @@ define("CAPTCHA_ENABLED", FALSE); define('CAPTCHA_SERVER', 'https://captcheck.netsyms.com'); // See lang folder for language options -define('LANGUAGE', "en_us"); +define('LANGUAGE', "en"); define("FOOTER_TEXT", "");