From 5ccbc098785a955319c731e53950f57bb4b151e5 Mon Sep 17 00:00:00 2001 From: Vasily Komrakov Date: Mon, 17 Aug 2015 03:20:43 +0300 Subject: [PATCH 1/2] fixed links in bbcode --- library/includes/bbcode.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/library/includes/bbcode.php b/library/includes/bbcode.php index 6e5cfe97e..f804c8d45 100644 --- a/library/includes/bbcode.php +++ b/library/includes/bbcode.php @@ -699,21 +699,31 @@ class bbcode { global $bb_cfg; - $url = trim($m[1]); - $url_name = (isset($m[2])) ? trim($m[2]) : $url; + //TODO: Refactoring. When will use DI. + $uri = new \Zend\Uri\Uri(trim($m[1])); - if (!preg_match("#^https?://#isu", $url) && !preg_match("/^#/", $url)) $url = 'http://' . $url; + if ($uri->isValid()) { - if (in_array(parse_url($url, PHP_URL_HOST), $bb_cfg['nofollow']['allowed_url']) || $bb_cfg['nofollow']['disabled']) - { - $link = "$url_name"; - } - else - { - $link = "$url_name"; + $title = isset($m[2]) && !empty(trim($m[2])) ? $m[2] : $uri->toString(); + + $attributes = [ + 'class' => 'postLink', + 'href' => $uri->toString(), + 'title' => $uri->toString() + ]; + + if (in_array($uri->getHost(), $bb_cfg['nofollow']['allowed_url']) || $bb_cfg['nofollow']['disabled']) { + $attributes['rel'] = 'nofollow'; + } + + foreach ($attributes as $key => $value) { + $attributes[$key] = $key . "=\"" . $value . "\""; + } + + return ''.$title.''; } - return $link; + return $m[2]; } /** From d67390571a02a0ad795e1cc48a3ebd6b96b5964f Mon Sep 17 00:00:00 2001 From: Vasily Komrakov Date: Tue, 1 Sep 2015 22:58:23 +0300 Subject: [PATCH 2/2] init composer --- .gitignore | 4 +++- composer.json | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 composer.json diff --git a/.gitignore b/.gitignore index 5ebd83e36..a4af5757a 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,6 @@ $RECYCLE.BIN/ .Spotlight-V100 .Trashes *.orig -*.rej \ No newline at end of file +*.rej + +/vendor/ diff --git a/composer.json b/composer.json new file mode 100644 index 000000000..da6b2a613 --- /dev/null +++ b/composer.json @@ -0,0 +1,7 @@ +{ + "name": "diolektor/torrentpier", + "description": "Fork TorrentPier. Web torrent tracker.", + "type": "project", + "minimum-stability": "dev", + "require": {} +}