use Friendica\Core\L10n;
use Friendica\Util\DateTimeFormat;
-function public_server_install() {
+function public_server_install()
+{
Addon::registerHook('register_account', 'addon/public_server/public_server.php', 'public_server_register_account');
Addon::registerHook('cron', 'addon/public_server/public_server.php', 'public_server_cron');
Addon::registerHook('enotify', 'addon/public_server/public_server.php', 'public_server_enotify');
Addon::registerHook('logged_in', 'addon/public_server/public_server.php', 'public_server_login');
}
-function public_server_uninstall() {
+function public_server_uninstall()
+{
Addon::unregisterHook('register_account', 'addon/public_server/public_server.php', 'public_server_register_account');
Addon::unregisterHook('cron', 'addon/public_server/public_server.php', 'public_server_cron');
Addon::unregisterHook('enotify', 'addon/public_server/public_server.php', 'public_server_enotify');
Addon::unregisterHook('logged_in', 'addon/public_server/public_server.php', 'public_server_login');
}
-function public_server_register_account($a, $b) {
+function public_server_register_account($a, $b)
+{
$uid = $b;
$days = Config::get('public_server', 'expiredays');
dba::update('user', $fields, ['uid' => $uid]);
}
-function public_server_cron($a, $b) {
+function public_server_cron($a, $b)
+{
logger("public_server: cron start");
require_once('include/enotify.php');
- $r = q("select * FROM `user` WHERE `account_expires_on` < UTC_TIMESTAMP() + INTERVAL 5 DAY AND
+ $r = q("SELECT * FROM `user` WHERE `account_expires_on` < UTC_TIMESTAMP() + INTERVAL 5 DAY AND
`account_expires_on` > '%s' AND
- expire_notification_sent <= '%s'",
+ `expire_notification_sent` <= '%s'",
dbesc(NULL_DATE), dbesc(NULL_DATE));
if (DBM::is_result($r)) {
$nologin = Config::get('public_server', 'nologin', false);
if ($nologin) {
- $r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND login_date <= '%s' AND `register_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s'",
+ $r = q("SELECT `uid` FROM `user` WHERE NOT `account_expired` AND `login_date` <= '%s' AND `register_date` < UTC_TIMESTAMP() - INTERVAL %d DAY AND `account_expires_on` <= '%s'",
dbesc(NULL_DATE), intval($nologin), dbesc(NULL_DATE));
if (DBM::is_result($r)) {
foreach ($r as $rr) {
logger("public_server: cron end");
}
-function public_server_enotify(&$a, &$b) {
+function public_server_enotify(&$a, &$b)
+{
if (x($b, 'params') && $b['params']['type'] == NOTIFY_SYSTEM
&& x($b['params'], 'system_type') && $b['params']['system_type'] === 'public_server_expire') {
$b['itemlink'] = $a->get_baseurl();
}
}
-function public_server_login($a, $b) {
+function public_server_login($a, $b)
+{
$days = Config::get('public_server', 'expiredays');
if (!$days) {
return;
dba::update('user', $fields, $condition);
}
-function public_server_addon_admin_post (&$a) {
+function public_server_addon_admin_post(&$a)
+{
check_form_security_token_redirectOnErr('/admin/addons/publicserver', 'publicserver');
$expiredays = (x($_POST, 'expiredays') ? notags(trim($_POST['expiredays'])) : '');
$expireposts = (x($_POST, 'expireposts') ? notags(trim($_POST['expireposts'])) : '');
info(L10n::t('Settings saved').EOL);
}
-function public_server_addon_admin (&$a, &$o) {
+function public_server_addon_admin(&$a, &$o)
+{
$token = get_form_security_token("publicserver");
$t = get_markup_template("admin.tpl", "addon/public_server");
$o = replace_macros($t, [