diff --git a/controllers/IndexController.php b/controllers/IndexController.php index 4485832..01d5b24 100644 --- a/controllers/IndexController.php +++ b/controllers/IndexController.php @@ -217,7 +217,11 @@ class IndexController extends Controller } $url .= ']'; - $shortUrl = ShortUrl::addNew('https://wikipoints.ru'.$url); + $shortUrl = ShortUrl::model()->getAll(array('where' => '`url` LIKE :url', 'limit' => 1), array('url' => $url)); + + if (!$shortUrl || $shortUrl->isEmpty()) { + $shortUrl = ShortUrl::addNew($url); + } print 'https://wikipoints.ru/s/'.x62::encode($shortUrl->id); }