$SETTINGS['database']['type'], 'database_name' => $SETTINGS['database']['name'], 'server' => $SETTINGS['database']['server'], 'username' => $SETTINGS['database']['user'], 'password' => $SETTINGS['database']['password'], 'charset' => $SETTINGS['database']['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" => $SETTINGS['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";