}
}
-function blackout_addon_admin(App $a, &$o) {
+function blackout_addon_admin(App $a, string &$o)
+{
$mystart = DI::config()->get('blackout','begindate');
if (! is_string($mystart)) { $mystart = 'YYYY-MM-DD hh:mm'; }
$myend = DI::config()->get('blackout','enddate');
'$aboutredirect' => DI::l10n()->t("<strong>Note</strong>: The redirect will be active from the moment you press the submit button. Users currently logged in will <strong>not</strong> be thrown out but can't login again after logging out while the blackout is still in place."),
]);
}
-function blackout_addon_admin_post (App $a) {
- $begindate = trim($_POST['startdate']);
- $enddate = trim($_POST['enddate']);
- $url = trim($_POST['rurl']);
- DI::config()->set('blackout','begindate',$begindate);
- DI::config()->set('blackout','enddate',$enddate);
- DI::config()->set('blackout','url',$url);
+
+function blackout_addon_admin_post (App $a)
+{
+ DI::config()->set('blackout', 'begindate', trim($_POST['startdate']));
+ DI::config()->set('blackout', 'enddate', trim($_POST['enddate']));
+ DI::config()->set('blackout', 'url', trim($_POST['rurl']));
}
Hook::register('init_1', __FILE__, 'blockbot_init_1');
}
-function blockbot_addon_admin(App $a, &$o)
+function blockbot_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/blockbot/');
* handles the post request from the admin panel
*
* @param App $a
- *
* @return void
*/
function cookienotice_addon_admin_post(App $a)
}
}
-function curweather_addon_admin(App $a, &$o)
+function curweather_addon_admin(App $a, string &$o)
{
if (!$a->isSiteAdmin()) {
return;
Hook::register('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
}
-function geocoordinates_resolve_item(&$item)
+function geocoordinates_resolve_item(array &$item)
{
- if((!$item["coord"]) || ($item["location"]))
+ if ((!$item['coord']) || ($item['location'])) {
return;
+ }
- $key = DI::config()->get("geocoordinates", "api_key");
- if ($key == "")
+ $key = DI::config()->get('geocoordinates', 'api_key');
+ if ($key == '') {
return;
+ }
- $language = DI::config()->get("geocoordinates", "language");
- if ($language == "")
- $language = "de";
+ $language = DI::config()->get('geocoordinates', 'language');
+ if ($language == '') {
+ $language = 'de';
+ }
- $coords = explode(' ',$item["coord"]);
+ $coords = explode(' ', $item['coord']);
- if (count($coords) < 2)
+ if (count($coords) < 2) {
return;
+ }
$coords[0] = round($coords[0], 5);
$coords[1] = round($coords[1], 5);
- $result = DI::cache()->get("geocoordinates:".$language.":".$coords[0]."-".$coords[1]);
+ $result = DI::cache()->get('geocoordinates:' . $language . ':' . $coords[0] . '-' . $coords[1]);
if (!is_null($result)) {
- $item["location"] = $result;
+ $item['location'] = $result;
return;
}
- $s = DI::httpClient()->fetch("https://api.opencagedata.com/geocode/v1/json?q=" . $coords[0] . "," . $coords[1] . "&key=" . $key . "&language=" . $language);
+ $s = DI::httpClient()->fetch('https://api.opencagedata.com/geocode/v1/json?q=' . $coords[0] . ',' . $coords[1] . '&key=' . $key . '&language=' . $language);
if (!$s) {
- Logger::info("API could not be queried");
+ Logger::info('API could not be queried');
return;
}
$data = json_decode($s);
- if ($data->status->code != "200") {
- Logger::info("API returned error ".$data->status->code." ".$data->status->message);
+ if ($data->status->code != '200') {
+ Logger::info('API returned error ' . $data->status->code . ' ' . $data->status->message);
return;
}
if (($data->total_results == 0) || (count($data->results) == 0)) {
- Logger::info("No results found for coordinates ".$item["coord"]);
+ Logger::info('No results found for coordinates ' . $item['coord']);
return;
}
- $item["location"] = $data->results[0]->formatted;
+ $item['location'] = $data->results[0]->formatted;
- Logger::info("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"]);
+ Logger::info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']);
- if ($item["location"] != "")
- DI::cache()->set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);
+ if ($item['location'] != '') {
+ DI::cache()->set('geocoordinates:' . $language.':' . $coords[0] . '-' . $coords[1], $item['location']);
+ }
}
function geocoordinates_post_hook(App $a, &$item)
geocoordinates_resolve_item($item);
}
-function geocoordinates_addon_admin(App $a, &$o)
+function geocoordinates_addon_admin(App $a, string &$o)
{
-
- $t = Renderer::getMarkupTemplate("admin.tpl", "addon/geocoordinates/");
+ $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/geocoordinates/');
$o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),
function geocoordinates_addon_admin_post(App $a)
{
- $api_key = trim($_POST['api_key'] ?? '');
- DI::config()->set('geocoordinates', 'api_key', $api_key);
-
- $language = trim($_POST['language'] ?? '');
- DI::config()->set('geocoordinates', 'language', $language);
+ DI::config()->set('geocoordinates', 'api_key', trim($_POST['api_key'] ?? ''));
+ DI::config()->set('geocoordinates', 'language', trim($_POST['language'] ?? ''));
}
/**
* Display admin settings for this addon
*/
-function gravatar_addon_admin (App $a, &$o)
+function gravatar_addon_admin (App $a, string &$o)
{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/gravatar/" );
{
BaseModule::checkFormSecurityToken('gravatarsave');
- $default_avatar = trim($_POST['avatar'] ?? 'identicon');
- $rating = trim($_POST['rating'] ?? 'g');
- DI::config()->set('gravatar', 'default_avatar', $default_avatar);
- DI::config()->set('gravatar', 'rating', $rating);
+ DI::config()->set('gravatar', 'default_avatar', trim($_POST['avatar'] ?? 'identicon'));
+ DI::config()->set('gravatar', 'rating', $rating = trim($_POST['rating'] ?? 'g'));
}
function impressum_footer(App $a, string &$body)
{
- $text = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum','footer_text')));
+ $text = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'footer_text')));
if ($text != '') {
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/impressum/impressum.css" media="all" />';
function impressum_addon_admin_post (App $a)
{
- $owner = trim($_POST['owner'] ?? '');
- $ownerprofile = trim($_POST['ownerprofile'] ?? '');
- $postal = trim($_POST['postal'] ?? '');
- $notes = trim($_POST['notes'] ?? '');
- $email = trim($_POST['email'] ?? '');
- $footer_text = trim($_POST['footer_text'] ?? '');
-
- DI::config()->set('impressum', 'owner', strip_tags($owner));
- DI::config()->set('impressum', 'ownerprofile', strip_tags($ownerprofile));
- DI::config()->set('impressum', 'postal', strip_tags($postal));
- DI::config()->set('impressum', 'email', strip_tags($email));
- DI::config()->set('impressum', 'notes', strip_tags($notes));
- DI::config()->set('impressum', 'footer_text', strip_tags($footer_text));
+ DI::config()->set('impressum', 'owner', strip_tags(trim($_POST['owner'] ?? '')));
+ DI::config()->set('impressum', 'ownerprofile', strip_tags(trim($_POST['ownerprofile'] ?? '')));
+ DI::config()->set('impressum', 'postal', strip_tags(trim($_POST['postal'] ?? '')));
+ DI::config()->set('impressum', 'email', strip_tags(trim($_POST['notes'] ?? '')));
+ DI::config()->set('impressum', 'notes', strip_tags(trim($_POST['email'] ?? '')));
+ DI::config()->set('impressum', 'footer_text', strip_tags(trim($_POST['footer_text'] ?? '')));
}
-function impressum_addon_admin (App $a, &$o)
+function impressum_addon_admin (App $a, string &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/impressum/' );
$o = Renderer::replaceMacros($t, [
DI::config()->set('irc', 'sitechats', trim($_POST['sitechats']));
}
}
-function irc_addon_admin (App $a, &$o) {
+function irc_addon_admin (App $a, string &$o) {
$sitechats = DI::config()->get('irc', 'sitechats'); /* popular channels */
$autochans = DI::config()->get('irc', 'autochans'); /* auto connect chans */
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/irc/' );
];
}
-function keycloakpassword_addon_admin(App $a, &$o)
+function keycloakpassword_addon_admin(App $a, string &$o)
{
$form =
keycloakpassword_admin_input(
/**
* Display admin settings for this addon
*/
-function libravatar_addon_admin(App $a, &$o)
+function libravatar_addon_admin(App $a, string &$o)
{
- $t = Renderer::getMarkupTemplate("admin.tpl", "addon/libravatar");
+ $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/libravatar');
$default_avatar = DI::config()->get('libravatar', 'default_avatar', 'identicon');
*/
function libravatar_addon_admin_post(App $a)
{
- $default_avatar = trim($_POST['avatar'] ?? 'identicon');
- DI::config()->set('libravatar', 'default_avatar', $default_avatar);
+ DI::config()->set('libravatar', 'default_avatar', trim($_POST['avatar'] ?? 'identicon'));
}
$frommail = DI::config()->get('mailstream', 'frommail');
$template = Renderer::getMarkupTemplate('admin.tpl', 'addon/mailstream/');
$config = ['frommail',
- DI::l10n()->t('From Address'),
- $frommail,
- DI::l10n()->t('Email address that stream items will appear to be from.')];
+ DI::l10n()->t('From Address'),
+ $frommail,
+ DI::l10n()->t('Email address that stream items will appear to be from.')];
$o .= Renderer::replaceMacros($template, [
- '$frommail' => $config,
- '$submit' => DI::l10n()->t('Save Settings')]);
+ '$frommail' => $config,
+ '$submit' => DI::l10n()->t('Save Settings')
+ ]);
}
/**
*
* @return string the created message ID
*/
-function mailstream_generate_id($uri)
+function mailstream_generate_id(string $uri): string
{
$host = DI::baseUrl()->getHostname();
$resource = hash('md5', $uri);
return $message_id;
}
-function mailstream_send_hook(App $a, $data)
+function mailstream_send_hook(App $a, array $data)
{
$criteria = array('uid' => $data['uid'], 'contact-id' => $data['contact-id'], 'uri' => $data['uri']);
$item = Post::selectFirst([], $criteria);
*
* @param App $a App object (unused)
* @param array $item content of the item (may or may not already be stored in the item table)
+ * @return void
*/
-function mailstream_post_hook(App $a, &$item)
+function mailstream_post_hook(App $a, array &$item)
{
mailstream_check_version();
$message_id = mailstream_generate_id($item['uri']);
- $send_hook_data = array('uid' => $item['uid'],
- 'contact-id' => $item['contact-id'],
- 'uri' => $item['uri'],
- 'message_id' => $message_id,
- 'tries' => 0);
+ $send_hook_data = [
+ 'uid' => $item['uid'],
+ 'contact-id' => $item['contact-id'],
+ 'uri' => $item['uri'],
+ 'message_id' => $message_id,
+ 'tries' => 0,
+ ];
Hook::fork(PRIORITY_LOW, 'mailstream_send_hook', $send_hook_data);
}
*
* @return array new value of the attachments table (results are also stored in the reference parameter)
*/
-function mailstream_do_images(&$item, &$attachments)
+function mailstream_do_images(arrat &$item, array &$attachments)
{
if (!DI::pConfig()->get($item['uid'], 'mailstream', 'attachimg')) {
return;
}
+
$attachments = [];
+
preg_match_all("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", $item["body"], $matches1);
preg_match_all("/\[img\](.*?)\[\/img\]/ism", $item["body"], $matches2);
preg_match_all("/\[img\=([^\]]*)\]([^[]*)\[\/img\]/ism", $item["body"], $matches3);
+
foreach (array_merge($matches1[3], $matches2[1], $matches3[1]) as $url) {
$components = parse_url($url);
+
if (!$components) {
continue;
}
+
$cookiejar = tempnam(System::getTempPath(), 'cookiejar-mailstream-');
$curlResult = DI::httpClient()->fetchFull($url, HttpClientAccept::DEFAULT, 0, $cookiejar);
$attachments[$url] = [
'data' => $curlResult->getBody(),
- 'guid' => hash("crc32", $url),
+ 'guid' => hash('crc32', $url),
'filename' => basename($components['path']),
'type' => $curlResult->getContentType()
];
continue;
}
}
+
return $attachments;
}
*
* @return string sender suitable for use in the email
*/
-function mailstream_sender($item)
+function mailstream_sender(array $item): string
{
$contact = Contact::getById($item['contact-id']);
if (DBA::isResult($contact)) {
*
* @return string plaintext subject line
*/
-function mailstream_decode_subject($subject)
+function mailstream_decode_subject(string $subject): string
{
$html = BBCode::convert($subject);
if (!$html) {
return $notags;
}
$nocodes = preg_replace_callback("/(&#[0-9]+;)/", function ($m) {
- return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
+ return mb_convert_encoding($m[1], 'UTF-8', 'HTML-ENTITIES');
}, $noentity);
if (!$nocodes) {
return $noentity;
*
* @return string subject line suitable for use in the email
*/
-function mailstream_subject($item)
+function mailstream_subject(array $item): string
{
if ($item['title']) {
return mailstream_decode_subject($item['title']);
*
* @return bool True if this message has been completed. False if it should be retried.
*/
-function mailstream_send($message_id, $item, $user)
+function mailstream_send(string $message_id, array $item, array $user): bool
{
if (!is_array($item)) {
Logger::error('mailstream_send item is empty', ['message_id' => $message_id]);
- return;
+ return false;
}
if (!$item['visible']) {
'user email' => $user['email']]);
return true;
}
- require_once(dirname(__file__).'/phpmailer/class.phpmailer.php');
+
+ require_once (dirname(__file__) . '/phpmailer/class.phpmailer.php');
$attachments = [];
mailstream_do_images($item, $attachments);
$frommail = DI::config()->get('mailstream', 'frommail');
- if ($frommail == "") {
+ if ($frommail == '') {
$frommail = 'friendica@localhost.local';
}
$address = DI::pConfig()->get($item['uid'], 'mailstream', 'address');
if (!$address) {
$address = $user['email'];
}
- $mail = new PHPmailer;
+ $mail = new PHPmailer();
try {
$mail->XMailer = 'Friendica Mailstream Addon';
$mail->SetFrom($frommail, mailstream_sender($item));
*
* @param string $text text to word wrap - modified in-place
*/
-function mailstream_html_wrap(&$text)
+function mailstream_html_wrap(string &$text): string
{
$lines = str_split($text, 200);
for ($i = 0; $i < count($lines); $i++) {
* Process data submitted to user's mailstream features form
* @param App $a
* @param array $post POST data
+ * @return void
*/
function mailstream_addon_settings_post(App $a, array $post)
{
];
}
-function mathjax_footer(App $a, string &$b)
+function mathjax_footer(App $a, string &$body)
{
// if the visitor of the page is not a local_user, use MathJax
// otherwise check the users settings.
function newmemberwidget_addon_admin_post(App $a)
{
- $ft = (!empty($_POST['freetext']) ? trim($_POST['freetext']) : "");
- $lsn = trim($_POST['localsupportname'] ?? '');
- $gs = intval($_POST['linkglobalsupport']);
- $ls = intval($_POST['linklocalsupport']);
- DI::config()->set('newmemberwidget', 'freetext', trim($ft));
- DI::config()->set('newmemberwidget', 'linkglobalsupport', $gs);
- DI::config()->set('newmemberwidget', 'linklocalsupport', $ls);
- DI::config()->set('newmemberwidget', 'localsupport', trim($lsn));
+ DI::config()->set('newmemberwidget', 'freetext', (!empty($_POST['freetext']) ? trim($_POST['freetext']) : ""));
+ DI::config()->set('newmemberwidget', 'linkglobalsupport', intval($_POST['linkglobalsupport']));
+ DI::config()->set('newmemberwidget', 'linklocalsupport', intval($_POST['linklocalsupport']));
+ DI::config()->set('newmemberwidget', 'localsupport', trim($_POST['localsupportname'] ?? ''));
}
-function newmemberwidget_addon_admin(App $a, &$o)
+function newmemberwidget_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/newmemberwidget');
+
$o = Renderer::replaceMacros($t, [
- '$submit' => DI::l10n()->t('Save Settings'),
- '$freetext' => [ "freetext", DI::l10n()->t("Message"), DI::config()->get("newmemberwidget", "freetext"), DI::l10n()->t("Your message for new members. You can use bbcode here.")],
- '$linkglobalsupport' => [ "linkglobalsupport", DI::l10n()->t('Add a link to global support forum'), DI::config()->get('newmemberwidget', 'linkglobalsupport'), DI::l10n()->t('Should a link to the global support forum be displayed?')." (<a href='https://forum.friendi.ca/profile/helpers'>@helpers</a>)"],
- '$linklocalsupport' => [ "linklocalsupport", DI::l10n()->t('Add a link to the local support forum'), DI::config()->get('newmemberwidget', 'linklocalsupport'), DI::l10n()->t('If you have a local support forum and want to have a link displayed in the widget, check this box.')],
- '$localsupportname' => [ "localsupportname", DI::l10n()->t('Name of the local support group'), DI::config()->get('newmemberwidget', 'localsupport'), DI::l10n()->t('If you checked the above, specify the <em>nickname</em> of the local support group here (i.e. helpers)')],
+ '$submit' => DI::l10n()->t('Save Settings'),
+ '$freetext' => ["freetext", DI::l10n()->t("Message"), DI::config()->get("newmemberwidget", "freetext"), DI::l10n()->t("Your message for new members. You can use bbcode here.")],
+ '$linkglobalsupport' => ["linkglobalsupport", DI::l10n()->t('Add a link to global support forum'), DI::config()->get('newmemberwidget', 'linkglobalsupport'), DI::l10n()->t('Should a link to the global support forum be displayed?')." (<a href='https://forum.friendi.ca/profile/helpers'>@helpers</a>)"],
+ '$linklocalsupport' => ["linklocalsupport", DI::l10n()->t('Add a link to the local support forum'), DI::config()->get('newmemberwidget', 'linklocalsupport'), DI::l10n()->t('If you have a local support forum and want to have a link displayed in the widget, check this box.')],
+ '$localsupportname' => ["localsupportname", DI::l10n()->t('Name of the local support group'), DI::config()->get('newmemberwidget', 'localsupport'), DI::l10n()->t('If you checked the above, specify the <em>nickname</em> of the local support group here (i.e. helpers)')],
]);
}
*/
function nitter_addon_admin_post(App $a)
{
- $nitterserver = rtrim(trim($_POST['nitterserver']),'/');
- DI::config()->set('nitter', 'server', $nitterserver);
+ DI::config()->set('nitter', 'server', rtrim(trim($_POST['nitterserver']), '/'));
}
/* Hook into the admin settings to let the admin choose a
* nitter server to use for the replacement.
*/
-function nitter_addon_admin(App $a, &$o)
+function nitter_addon_admin(App $a, string &$o)
{
$nitterserver = DI::config()->get('nitter', 'server');
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/nitter/');
/*
* replace "twitter.com" with "nitter.net"
*/
-function nitter_render(App $a, &$o)
+function nitter_render(App $a, array &$b)
{
// this needs to be a system setting
$replaced = false;
$nitter = DI::config()->get('nitter', 'server', 'https://nitter.net');
- if (strstr($o['html'], 'https://mobile.twitter.com')) {
- $o['html'] = str_replace('https://mobile.twitter.com', $nitter, $o['html']);
+ if (strstr($b['html'], 'https://mobile.twitter.com')) {
+ $b['html'] = str_replace('https://mobile.twitter.com', $nitter, $b['html']);
$replaced = true;
}
- if (strstr($o['html'], 'https://twitter.com')) {
- $o['html'] = str_replace('https://twitter.com', $nitter, $o['html']);
+ if (strstr($b['html'], 'https://twitter.com')) {
+ $b['html'] = str_replace('https://twitter.com', $nitter, $b['html']);
$replaced = true;
}
if ($replaced) {
- $o['html'] .= '<hr><p>' . DI::l10n()->t('In an attempt to protect your privacy, links to Twitter in this posting were replaced by links to the Nitter instance at %s', $nitter) . '</p>';
+ $b['html'] .= '<hr><p>' . DI::l10n()->t('In an attempt to protect your privacy, links to Twitter in this posting were replaced by links to the Nitter instance at %s', $nitter) . '</p>';
}
}
Hook::register('post_remote', 'addon/nominatim/nominatim.php', 'nominatim_post_hook');
}
-function nominatim_resolve_item(&$item)
+function nominatim_resolve_item(array &$item)
{
if(empty($item['coord']) || !empty($item['location'])) {
return;
}
}
-function nominatim_post_hook(App $a, &$item)
+function nominatim_post_hook(App $a, array &$item)
{
nominatim_resolve_item($item);
}
-function nominatim_addon_admin(App $a, &$o)
+function nominatim_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/nominatim/');
function nominatim_addon_admin_post(App $a)
{
- $language = !empty($_POST['language']) ? trim($_POST['language']) : '';
- DI::config()->set('nominatim', 'language', $language);
+ DI::config()->set('nominatim', 'language', (!empty($_POST['language']) ? trim($_POST['language']) : ''));
}
*/
function notifyall_module() {}
-function notifyall_addon_admin(App $a, &$o)
+function notifyall_addon_admin(App $a, string &$o)
{
$o = '<div></div> <a href="' . DI::baseUrl()->get() . '/notifyall">' . DI::l10n()->t('Send email to all members') . '</a></br/>';
}
$nomserver = OSM_NOM;
}
- if ($item['coord'] != "") {
+ if ($item['coord'] != '') {
$coords = explode(' ', $item['coord']);
if (count($coords) > 1) {
$lat = urlencode(round($coords[0], 5));
$target = $nomserver.'?q='.urlencode($item['location']);
}
- if ($item['location'] != "") {
+ if ($item['location'] != '') {
$title = $item['location'];
} else {
$title = $item['coord'];
}
- $item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
+ $item['html'] = '<a target="map" title="' . $title . '" href= "' . $target . '">' . $title . '</a>';
}
function openstreetmap_get_coordinates(App $a, array &$b)
$args = '?q=' . urlencode($b['location']) . '&format=json';
- $cachekey = "openstreetmap:" . $b['location'];
+ $cachekey = 'openstreetmap:' . $b['location'];
$j = DI::cache()->get($cachekey);
if (is_null($j)) {
Logger::debug('generate_map: ' . $b['html']);
}
-function openstreetmap_addon_admin(App $a, &$o)
+function openstreetmap_addon_admin(App $a, string &$o)
{
- $t = Renderer::getMarkupTemplate("admin.tpl", "addon/openstreetmap/");
+ $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/openstreetmap/');
$tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS);
$nomserver = DI::config()->get('openstreetmap', 'nomserver', OSM_NOM);
$zoom = DI::config()->get('openstreetmap', 'zoom', OSM_ZOOM);
function openstreetmap_addon_admin_post(App $a)
{
- $urltms = ($_POST['tmsserver'] ?? '') ?: OSM_TMS;
- $urlnom = ($_POST['nomserver'] ?? '') ?: OSM_NOM;
- $zoom = ($_POST['zoom'] ?? '') ?: OSM_ZOOM;
- $marker = ($_POST['marker'] ?? '') ?: OSM_MARKER;
-
- DI::config()->set('openstreetmap', 'tmsserver', $urltms);
- DI::config()->set('openstreetmap', 'nomserver', $urlnom);
- DI::config()->set('openstreetmap', 'zoom', $zoom);
- DI::config()->set('openstreetmap', 'marker', $marker);
+ DI::config()->set('openstreetmap', 'tmsserver', ($_POST['tmsserver'] ?? '') ?: OSM_TMS);
+ DI::config()->set('openstreetmap', 'nomserver', ($_POST['nomserver'] ?? '') ?: OSM_NOM);
+ DI::config()->set('openstreetmap', 'zoom', ($_POST['zoom'] ?? '') ?: OSM_ZOOM);
+ DI::config()->set('openstreetmap', 'marker', ($_POST['marker'] ?? '') ?: OSM_MARKER);
}
function pageheader_fetch(App $a, string &$b)
{
- if(file_exists('pageheader.html')){
+ if (file_exists('pageheader.html')) {
$s = file_get_contents('pageheader.html');
} else {
$s = DI::config()->get('pageheader', 'text');
}
DI::page()->registerStylesheet(__DIR__ .'/pageheader.css');
-
- if ($s) {
- $b .= '<div class="pageheader">' . $s . '</div>';
- }
+
+ if ($s) {
+ $b .= '<div class="pageheader">' . $s . '</div>';
+ }
}
$b .= "</div>";
}
}
-function piwik_addon_admin (App $a, &$o) {
+function piwik_addon_admin (App $a, string &$o)
+{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/piwik/" );
+
$o = Renderer::replaceMacros( $t, [
'$submit' => DI::l10n()->t('Save Settings'),
'$piwikbaseurl' => ['baseurl', DI::l10n()->t('Matomo (Piwik) Base URL'), DI::config()->get('piwik','baseurl' ), DI::l10n()->t('Absolute path to your Matomo (Piwik) installation. (without protocol (http/s), with trailing slash)')],
'$async' => ['async', DI::l10n()->t('Asynchronous tracking'), DI::config()->get('piwik','async' ), ''],
]);
}
-function piwik_addon_admin_post (App $a) {
- $url = trim($_POST['baseurl'] ?? '');
- $id = trim($_POST['siteid'] ?? '');
- $optout = trim($_POST['optout'] ?? '');
- $async = trim($_POST['async'] ?? '');
- DI::config()->set('piwik', 'baseurl', $url);
- DI::config()->set('piwik', 'siteid', $id);
- DI::config()->set('piwik', 'optout', $optout);
- DI::config()->set('piwik', 'async', $async);
+
+function piwik_addon_admin_post(App $a)
+{
+ DI::config()->set('piwik', 'baseurl', trim($_POST['baseurl'] ?? ''));
+ DI::config()->set('piwik', 'siteid', trim($_POST['siteid'] ?? ''));
+ DI::config()->set('piwik', 'optout', trim($_POST['optout'] ?? ''));
+ DI::config()->set('piwik', 'async', trim($_POST['async'] ?? ''));
}
function public_server_addon_admin_post(App $a)
{
BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons/publicserver', 'publicserver');
- $expiredays = trim($_POST['expiredays'] ?? '');
- $expireposts = trim($_POST['expireposts'] ?? '');
- $nologin = trim($_POST['nologin'] ?? '');
- $flagusers = trim($_POST['flagusers'] ?? '');
- $flagposts = trim($_POST['flagposts'] ?? '');
- $flagpostsexpire = trim($_POST['flagpostsexpire'] ?? '');
- DI::config()->set('public_server', 'expiredays', $expiredays);
- DI::config()->set('public_server', 'expireposts', $expireposts);
- DI::config()->set('public_server', 'nologin', $nologin);
- DI::config()->set('public_server', 'flagusers', $flagusers);
- DI::config()->set('public_server', 'flagposts', $flagposts);
- DI::config()->set('public_server', 'flagpostsexpire', $flagpostsexpire);
+
+ DI::config()->set('public_server', 'expiredays', trim($_POST['expiredays'] ?? ''));
+ DI::config()->set('public_server', 'expireposts', trim($_POST['expireposts'] ?? ''));
+ DI::config()->set('public_server', 'nologin', trim($_POST['nologin'] ?? ''));
+ DI::config()->set('public_server', 'flagusers', trim($_POST['flagusers'] ?? ''));
+ DI::config()->set('public_server', 'flagposts', trim($_POST['flagposts'] ?? ''));
+ DI::config()->set('public_server', 'flagpostsexpire', trim($_POST['flagpostsexpire'] ?? ''));
}
-function public_server_addon_admin(App $a, &$o)
+function public_server_addon_admin(App $a, string &$o)
{
- $token = BaseModule::getFormSecurityToken("publicserver");
- $t = Renderer::getMarkupTemplate("admin.tpl", "addon/public_server");
+ $token = BaseModule::getFormSecurityToken('publicserver');
+ $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/public_server');
$o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),
'$form_security_token' => $token,
'$infotext' => DI::l10n()->t('Set any of these options to 0 to deactivate it.'),
- '$expiredays' => ["expiredays","Expire Days", intval(DI::config()->get('public_server', 'expiredays')), "When an account is created on the site, it is given a hard "],
+ '$expiredays' => ["expiredays", "Expire Days", intval(DI::config()->get('public_server', 'expiredays')), "When an account is created on the site, it is given a hard "],
'$expireposts' => ["expireposts", "Expire Posts", intval(DI::config()->get('public_server', 'expireposts')), "Set the default days for posts to expire here"],
'$nologin' => ["nologin", "No Login", intval(DI::config()->get('public_server', 'nologin')), "Remove users who have never logged in after nologin days "],
'$flagusers' => ["flagusers", "Flag users", intval(DI::config()->get('public_server', 'flagusers')), "Remove users who last logged in over flagusers days ago"],
Hook::register('footer' , __FILE__, 'qcomment_footer');
}
-function qcomment_footer(App $a, string &$b)
+function qcomment_footer(App $a, string &$body)
{
DI::page()->registerFooterScript('addon/qcomment/qcomment.js');
}
];
}
-function qcomment_addon_settings_post(App $a, array &$b)
+function qcomment_addon_settings_post(App $a, array &$body)
{
if (!local_user()) {
return;
{
}
-function rendertime_addon_admin(App $a, &$o)
+function rendertime_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/rendertime/");
* @param App $a
* @param string $o
*/
-function rendertime_page_end(App $a, &$o)
+function rendertime_page_end(App $a, string &$o)
{
-
$profiler = DI::profiler();
$duration = microtime(true) - $profiler->get('start');
{
}
-function saml_init($a)
+function saml_init(App $a)
{
if (DI::args()->getArgc() < 2) {
return;
Hook::register('footer', __FILE__, 'saml_footer');
}
-function saml_head(App $a, string &$b)
+function saml_head(App $a, string &$body)
{
DI::page()->registerStylesheet(__DIR__ . '/saml.css');
}
-function saml_footer(App $a, string &$b)
+function saml_footer(App $a, string &$body)
{
$fragment = addslashes(BBCode::convert(DI::config()->get('saml', 'settings_statement')));
- $b .= <<<EOL
+ $body .= <<<EOL
<script>
var target=$("#settings-nickname-desc");
if (target.length) { target.append("<p>$fragment</p>"); }
exit();
}
-function saml_sso_reply($a)
+function saml_sso_reply(App $a)
{
$auth = new \OneLogin\Saml2\Auth(saml_settings());
$requestID = null;
];
}
-function saml_addon_admin(App $a, &$o)
+function saml_addon_admin(App $a, string &$o)
{
$form =
saml_input(
Hook::register('addon_settings_post', __FILE__, 'showmore_dyn_settings_post');
}
-function showmore_dyn_head(App $a, string &$b)
+function showmore_dyn_head(App $a, string &$body)
{
DI::page()->registerStylesheet(__DIR__ . '/showmore_dyn.css');
}
-function showmore_dyn_footer(App $a, string &$b)
+function showmore_dyn_footer(App $a, string &$body)
{
DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js');
}
$sites = DI::config()->set('statusnet', 'sites', $sites);
}
-function statusnet_addon_admin(App $a, &$o)
+function statusnet_addon_admin(App $a, string &$o)
{
$sites = DI::config()->get('statusnet', 'sites');
$sitesform = [];
return $o;
}
-function tumblr_addon_admin(App $a, &$o)
+function tumblr_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/tumblr/" );
function tumblr_addon_admin_post(App $a)
{
- $consumer_key = trim($_POST['consumer_key'] ?? '');
- $consumer_secret = trim($_POST['consumer_secret'] ?? '');
-
- DI::config()->set('tumblr', 'consumer_key',$consumer_key);
- DI::config()->set('tumblr', 'consumer_secret',$consumer_secret);
+ DI::config()->set('tumblr', 'consumer_key', trim($_POST['consumer_key'] ?? ''));
+ DI::config()->set('tumblr', 'consumer_secret', trim($_POST['consumer_secret'] ?? ''));
}
function tumblr_connect(App $a)
// The callback URL is the script that gets called after the user authenticates with tumblr
// In this example, it would be the included callback.php
- $callback_url = DI::baseUrl()->get()."/tumblr/callback";
+ $callback_url = DI::baseUrl()->get() . '/tumblr/callback';
// Let's begin. First we need a Request Token. The request token is required to send the user
// to Tumblr's login page.
}
// What's next? Now that we have an Access Token and Secret, we can make an API call.
- DI::pConfig()->set(local_user(), "tumblr", "oauth_token", $access_token['oauth_token']);
- DI::pConfig()->set(local_user(), "tumblr", "oauth_token_secret", $access_token['oauth_token_secret']);
+ DI::pConfig()->set(local_user(), 'tumblr', 'oauth_token', $access_token['oauth_token']);
+ DI::pConfig()->set(local_user(), 'tumblr', 'oauth_token_secret', $access_token['oauth_token_secret']);
$o = DI::l10n()->t("You are now authenticated to tumblr.");
$o .= '<br /><a href="' . DI::baseUrl()->get() . '/settings/connectors">' . DI::l10n()->t("return to the connector page") . '</a>';
function twitter_addon_admin_post(App $a)
{
- $consumerkey = trim($_POST['consumerkey'] ?? '');
- $consumersecret = trim($_POST['consumersecret'] ?? '');
- DI::config()->set('twitter', 'consumerkey', $consumerkey);
- DI::config()->set('twitter', 'consumersecret', $consumersecret);
+ DI::config()->set('twitter', 'consumerkey', trim($_POST['consumerkey'] ?? ''));
+ DI::config()->set('twitter', 'consumersecret', trim($_POST['consumersecret'] ?? ''));
}
-function twitter_addon_admin(App $a, &$o)
+function twitter_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/twitter/');
use Friendica\Core\Hook;
use Friendica\DI;
-function viewsrc_install() {
+function viewsrc_install()
+{
Hook::register('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
Hook::register('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end');
}
-function viewsrc_page_end(App $a, &$o){
+function viewsrc_page_end(App $a, string &$o)
+{
DI::page()['htmlhead'] .= <<< EOS
<script>
$(function(){
$b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . DI::l10n()->t('WebRTC Videochat') . '</a></div>';
}
-function webrtc_addon_admin (App $a, &$o)
+function webrtc_addon_admin (App $a, string &$o)
{
- $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/webrtc/" );
- $o = Renderer::replaceMacros( $t, [
- '$submit' => DI::l10n()->t('Save Settings'),
- '$webrtcurl' => ['webrtcurl', DI::l10n()->t('WebRTC Base URL'), DI::config()->get('webrtc','webrtcurl' ), DI::l10n()->t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')],
+ $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/webrtc/' );
+ $o = Renderer::replaceMacros($t, [
+ '$submit' => DI::l10n()->t('Save Settings'),
+ '$webrtcurl' => [
+ 'webrtcurl',
+ DI::l10n()->t('WebRTC Base URL'),
+ DI::config()->get('webrtc','webrtcurl' ),
+ DI::l10n()->t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .'),
+ ],
]);
}
function webrtc_addon_admin_post (App $a)
{
- $url = trim($_POST['webrtcurl'] ?? '');
- DI::config()->set('webrtc', 'webrtcurl', $url);
+ DI::config()->set('webrtc', 'webrtcurl', trim($_POST['webrtcurl'] ?? ''));
}
/**
*/
function webrtc_module() {}
-function webrtc_content(App $a)
+function webrtc_content(App $a): string
{
$o = '';