From 2acf82b4e00579d8609333790057e210d89a5dc8 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 28 Aug 2021 00:49:26 +0200 Subject: [PATCH] fix local service --- inc/class.kutrl.php | 2 +- inc/index.link.php | 2 +- inc/lib.kutrl.srv.php | 8 +++++++- inc/services/class.local.service.php | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/inc/class.kutrl.php b/inc/class.kutrl.php index b227a66..209f8c5 100644 --- a/inc/class.kutrl.php +++ b/inc/class.kutrl.php @@ -25,7 +25,7 @@ class kUtRL if (empty($list)) { return []; } - $service = []; + $services = []; foreach($list as $k => $callback) { try { list($service_id,$service_class) = call_user_func($callback); diff --git a/inc/index.link.php b/inc/index.link.php index 1283dc9..fa74c5a 100644 --- a/inc/index.link.php +++ b/inc/index.link.php @@ -118,7 +118,7 @@ if (null === $kut) { form::field('custom', 50, 32, '') . '

' . '

' . __('Only if you want a custom short link.') . '

'; - if ($s_admin_service == 'local') { + if ($kut->admin_service == 'local') { echo '

' . __('You can use "bob!!" if you want a semi-custom link, it starts with "bob" and "!!" will be replaced by an increment value.') . '

'; diff --git a/inc/lib.kutrl.srv.php b/inc/lib.kutrl.srv.php index c529e81..7cd92d1 100644 --- a/inc/lib.kutrl.srv.php +++ b/inc/lib.kutrl.srv.php @@ -57,6 +57,12 @@ class kutrlService # Magic get for config values public function __get($k) + { + return $this->get($k); + } + + # get config value + public function get($k) { return isset($this->config[$k]) ? $this->config[$k] : null; } @@ -103,7 +109,7 @@ class kutrlService # Test if an url is long enoutgh public function isLongerUrl($url) { - return ((integer) $this->url_min_len >= $url); + return (strlen($url) >= (integer) $this->url_min_len); } # Test if an url protocol (eg: http://) is allowed diff --git a/inc/services/class.local.service.php b/inc/services/class.local.service.php index 6334a32..7354b91 100644 --- a/inc/services/class.local.service.php +++ b/inc/services/class.local.service.php @@ -100,7 +100,8 @@ class localKutrlService extends kutrlService public function testService() { - if (!empty($this->allow_protocols)) + $ap = $this->allow_protocols; + if (!empty($ap)) { return true; }