From aeeaabb22e87b605d8a11660e50d6e9e02595ef6 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 6 Jun 2016 12:12:25 +0100 Subject: [PATCH] allow both http: and mailto: contact links --- core/util.inc.php | 25 +++++++++++++++++++++++++ ext/home/main.php | 2 +- ext/home/theme.php | 2 +- ext/ipban/main.php | 2 +- themes/danbooru/layout.class.php | 4 ++-- themes/danbooru2/layout.class.php | 4 ++-- themes/default/layout.class.php | 4 ++-- themes/futaba/layout.class.php | 4 ++-- themes/lite/layout.class.php | 4 ++-- themes/material/layout.class.php | 4 ++-- themes/warm/layout.class.php | 4 ++-- 11 files changed, 42 insertions(+), 17 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index 11aa9ae0..c6450997 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -591,6 +591,31 @@ function zglob($pattern) { } } +/** + * Gets contact link as mailto: or http: + */ +function contact_link() { + global $config; + $text = $config->get_string('contact_link'); + if( + startsWith($text, "http:") || + startsWith($text, "https:") || + startsWith($text, "mailto:") + ) { + return $text; + } + + if(strpos($text, "@")) { + return "mailto:$text"; + } + + if(strpos($text, "/")) { + return "http://$text"; + } + + return $text; +} + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * CAPTCHA abstraction * diff --git a/ext/home/main.php b/ext/home/main.php index fb1269db..566c1d6e 100644 --- a/ext/home/main.php +++ b/ext/home/main.php @@ -49,7 +49,7 @@ class Home extends Extension { global $config; $base_href = get_base_href(); $sitename = $config->get_string('title'); - $contact_link = $config->get_string('contact_link'); + $contact_link = contact_link(); $counter_dir = $config->get_string('home_counter', 'default'); $total = Image::count_images(); diff --git a/ext/home/theme.php b/ext/home/theme.php index e34b8ca4..6c51c73d 100644 --- a/ext/home/theme.php +++ b/ext/home/theme.php @@ -37,7 +37,7 @@ EOD $main_links_html = empty($main_links) ? "" : ""; $message_html = empty($main_text) ? "" : "
$main_text
"; $counter_html = empty($counter_text) ? "" : "
$counter_text
"; - $contact_link = empty($contact_link) ? "" : "
Contact –"; + $contact_link = empty($contact_link) ? "" : "
Contact –"; $search_html = "