Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
Florine W. Dekker | d7c2658ba6 | |
Florine W. Dekker | 2daa74b319 |
|
@ -12,6 +12,7 @@ This tool regularly checks if people are still alive according to Wikipedia, and
|
|||
* PHP 8.1+ (i.e. `apt install php php-cgi`) (compiled with Argon2 support)
|
||||
* [PHP cURL](https://www.php.net/manual/en/book.curl.php) (i.e. `apt install php-curl`)
|
||||
* [PHP DOM](https://www.php.net/manual/en/book.dom.php) (i.e. `apt install php-dom`)
|
||||
* [PHP mbstring](https://www.php.net/manual/en/book.mbstring.php) (i.e. `apt install php-mbstring`)
|
||||
* [PHP SQLite 3](https://www.php.net/manual/en/book.sqlite3.php) (i.e. `apt install php-sqlite3`)
|
||||
* [composer](https://getcomposer.org/) (make sure `composer.phar` is on your path)
|
||||
* [npm](https://www.npmjs.com/)
|
||||
|
@ -94,12 +95,12 @@ Inside the installation directory, create `config.ini.php` and use it to overrid
|
|||
Make sure only the user that runs PHP can read/write `config.ini.php`.
|
||||
|
||||
### Cron jobs
|
||||
You should run the `process-email-queue` and `update-all-trackings` actions regularly;
|
||||
You should run the `process-email-queue` and `update-trackings` actions regularly;
|
||||
recommended is every minute and every five minutes, respectively.
|
||||
For example, you can add the following lines to your crontab (e.g. using `sudo -u www crontab -e`):
|
||||
```
|
||||
* * * * * cd /var/www/death-notifier && php /var/www/death-notifier/api.php action=process-email-queue password=secret_password
|
||||
*/5 * * * * cd /var/www/death-notifier && php /var/www/death-notifier/api.php action=update-all-trackings password=secret_password
|
||||
*/5 * * * * cd /var/www/death-notifier && php /var/www/death-notifier/api.php action=update-trackings password=secret_password
|
||||
```
|
||||
Replace `secret_password` with the password you configured in `config.ini.php`.
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "fwdekker/death-notifier",
|
||||
"description": "Get notified when a famous person dies.",
|
||||
"version": "1.2.0", "_comment_version": "Also update version in `package.json`!",
|
||||
"version": "1.3.0", "_comment_version": "Also update version in `package.json`!",
|
||||
"type": "project",
|
||||
"license": "MIT",
|
||||
"homepage": "https://git.fwdekker.com/tools/death-notifier",
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "death-notifier",
|
||||
"version": "1.2.0", "_comment_version": "Also update version in `composer.json`!",
|
||||
"version": "1.3.0", "_comment_version": "Also update version in `composer.json`!",
|
||||
"description": "Get notified when a famous person dies.",
|
||||
"author": "Florine W. Dekker",
|
||||
"browser": "dist/bundle.js",
|
||||
|
|
|
@ -1,40 +1,37 @@
|
|||
;<?php exit(); ?>
|
||||
|
||||
[admin]
|
||||
# PHC formatted hash of password to use the CLI of `api.php`. If set to its default value, or if empty, the CLI is
|
||||
# disabled.
|
||||
cli_password = REPLACE THIS WITH A SECRET VALUE
|
||||
# PHC-formatted hash of password for the CLI of `api.php`. You can create one using PHP's `password_hash`. Escaping
|
||||
# dollar symbols is optional. If set to its default value, or if empty, the CLI is disabled.
|
||||
cli_password = "REPLACE THIS WITH A SECRET VALUE"
|
||||
|
||||
[database]
|
||||
# File to store SQLite database in. The default value assumes that you have configured your server to hide files
|
||||
# starting with a `.`.
|
||||
filename = .death-notifier.db
|
||||
# File to store SQLite database in.
|
||||
filename = ".death-notifier.db"
|
||||
|
||||
[logger]
|
||||
# File to store general logs in. The default value assumes that you have configured your server to hide files starting
|
||||
# with a `.`.
|
||||
filename = .death-notifier.log
|
||||
# File to store general logs in.
|
||||
filename = ".death-notifier.log"
|
||||
# Log level for general log events. See https://seldaek.github.io/monolog/doc/01-usage.html#log-levels
|
||||
level = 250
|
||||
|
||||
[logger_db]
|
||||
# File to store database logs in. The default value assumes that you have configured your server to hide files starting
|
||||
# with a `.`.
|
||||
filename = .death-notifier.db.log
|
||||
# File to store database logs in.
|
||||
filename = ".death-notifier.db.log"
|
||||
# Log level for database log events. See https://seldaek.github.io/monolog/doc/01-usage.html#log-levels
|
||||
level = 250
|
||||
|
||||
[mail]
|
||||
# Host name of SMTP server to send mail through.
|
||||
host = TODO
|
||||
host = "TODO"
|
||||
# Port of SMTP server to send mail through.
|
||||
port = TODO
|
||||
# Username to authenticate with at SMTP server.
|
||||
username = TODO
|
||||
username = "TODO"
|
||||
# Password to authenticate with at SMTP server.
|
||||
password = TODO
|
||||
password = "TODO"
|
||||
# Name to show to recipient.
|
||||
from_name = TODO
|
||||
from_name = "TODO"
|
||||
|
||||
[security]
|
||||
# `true` if and only if insecure file permissions for config files should be tolerated.
|
||||
|
@ -42,8 +39,13 @@ allow_config_insecure_permissions = false
|
|||
|
||||
[server]
|
||||
# The path to the directory containing the site's main page.
|
||||
base_path = https://example.com/death-notifier/
|
||||
base_path = "https://example.com/death-notifier/"
|
||||
# The path at which users can report bugs, or an empty string if there is no such path.
|
||||
issue_path =
|
||||
issue_path = ""
|
||||
# The message to display at the top of all pages. A blank string hides the message.
|
||||
global_message =
|
||||
global_message = ""
|
||||
|
||||
[wikipedia]
|
||||
# Contact information to include in requests to Wikipedia's API. Typically a URL and an email address separated by a
|
||||
# semicolon. See also https://www.mediawiki.org/wiki/API:Etiquette.
|
||||
user_agent_contact = "https://example.com/death-notifier; name@example.com"
|
||||
|
|
|
@ -89,7 +89,7 @@ class ProcessEmailQueueAction extends Action
|
|||
$mailer->SMTPKeepAlive = true;
|
||||
$mailer->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||||
$mailer->Host = $config["host"];
|
||||
$mailer->Port = $config["port"];
|
||||
$mailer->Port = intval($config["port"]);
|
||||
$mailer->Username = $config["username"];
|
||||
$mailer->Password = $config["password"];
|
||||
try {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace com\fwdekker\deathnotifier\wikipedia;
|
||||
|
||||
use com\fwdekker\deathnotifier\LoggerUtil;
|
||||
use com\fwdekker\deathnotifier\Config;
|
||||
use com\fwdekker\deathnotifier\Util;
|
||||
use JsonException;
|
||||
|
||||
|
@ -19,9 +19,7 @@ class Wikipedia
|
|||
/**
|
||||
* The user agent used to represent the death notifier to Wikipedia.
|
||||
*/
|
||||
private const USER_AGENT =
|
||||
"death-notifier/%%VERSION_NUMBER%% " .
|
||||
"(https://git.fwdekker.com/tools/death-notifier; florine@fwdekker.com)";
|
||||
private const USER_AGENT_FORMAT = "death-notifier/%%VERSION_NUMBER%% (%1\$s) %2\$s";
|
||||
/**
|
||||
* Number of articles to query per query.
|
||||
*/
|
||||
|
@ -48,10 +46,13 @@ class Wikipedia
|
|||
*/
|
||||
private function api_fetch(array $params): mixed
|
||||
{
|
||||
$curl_version = curl_version()["version"] ?? "unknown";
|
||||
$user_agent = sprintf(self::USER_AGENT_FORMAT, Config::get("wikipedia")["user_agent_contact"], $curl_version);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_URL, self::API_URL . http_build_query($params));
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, self::USER_AGENT);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
|
||||
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
|
Loading…
Reference in New Issue