con->escape($_POST['str'])); $hash = empty($_POST['custom']) ? null : $_POST['custom']; if (empty($url)) throw new Exception(__('There is nothing to shorten.')); if (!$kut->testService()) throw new Exception(__('Service is not well configured.')); if (null !== $hash && !$kut->allow_custom_hash) throw new Exception(__('This service does not allowed custom hash.')); if (!$kut->isValidUrl($url)) throw new Exception(__('This link is not a valid URL.')); if (!$kut->isLongerUrl($url)) throw new Exception(__('This link is too short.')); if (!$kut->isProtocolUrl($url)) throw new Exception(__('This type of link is not allowed.')); if (!$kut->allow_external_url && !$kut->isBlogUrl($url)) throw new Exception(__('Short links are limited to this blog URL.')); if ($kut->isServiceUrl($url)) throw new Exception(__('This link is already a short link.')); if (null !== $hash && false !== ($rs = $kut->isKnowHash($hash))) throw new Exception(__('This custom short url is already taken.')); if (false !== ($rs = $kut->isKnowUrl($url))) { $url = $rs->url; $new_url = $kut->url_base.$rs->hash; $msg = '
'; } else { if (false === ($rs = $kut->hash($url,$hash))) { if ($kut->error->flag()) { throw new Exception($kut->error->toHTML()); } throw new Exception(__('Failed to create short link. This could be caused by a service failure.')); } else { $url = $rs->url; $new_url = $kut->url_base.$rs->hash; $msg = ' '; # ex: Send new url to messengers if (!empty($rs)) { $core->callBehavior('adminAfterKutrlCreate',$core,$rs,__('New short URL')); } } } } catch (Exception $e) { $core->error->add($e->getMessage()); } } echo ''.__('You must set an admin service.').'
'; } else { echo ' '; } dcPage::helpBlock('kUtRL'); echo $footer.''; ?>