/**
  * @return bool
  * @param string $s_input
  * @param string[] field names $a_keys
  * @desc Test whether a short URL is already taken by another page
  */
 public function Test($s_input, $a_keys)
 {
     $short_url = new ShortUrl($s_input);
     $short_url->SetFormat($this->object_with_short_url->GetShortUrlFormat());
     $short_url->SetParameterValuesFromObject($this->object_with_short_url);
     $manager = new ShortUrlManager($this->GetSiteSettings(), $this->GetDataConnection());
     $taken = $manager->IsUrlTaken($short_url);
     unset($manager);
     return !$taken;
 }
 public function testGetHashByUrl()
 {
     $url = 'http://www.zurmo.com';
     try {
         ShortUrl::getHashByUrl($url);
         $this->assertTrue(false);
     } catch (NotFoundException $exception) {
         $this->assertTrue(true);
     }
     $shortUrl = new ShortUrl();
     $shortUrl->hash = 'abcdefghij';
     $shortUrl->url = $url;
     $shortUrl->save();
     $hash = ShortUrl::getHashByUrl($url);
     $this->assertEquals('abcdefghij', $hash);
     ShortUrl::deleteAll();
 }
 public function testSuperUserAllDefaultControllerActions()
 {
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $hash = ShortUrl::resolveHashByUrl('http://www.zurmo.com');
     $this->setGetArray(array('hash' => $hash));
     $url = $this->runControllerWithRedirectExceptionAndGetUrl('zurmo/shortUrl/redirect/');
     $this->assertEquals('http://www.zurmo.com', $url);
 }
 public function actionRedirect($hash)
 {
     assert('is_string($hash)');
     try {
         $url = ShortUrl::getUrlByHash($hash);
         $this->redirect($url);
     } catch (NotFoundException $exception) {
         throw new CHttpException(404, Zurmo::t('ZurmoModule', 'The specified hash cannot be found.'));
     }
 }
 public function expand($shortcode)
 {
     // remove the 1 we added when we created it
     $index = ShortUrl::decode($shortcode) - 1;
     if ($index == -1) {
         return NULL;
     }
     $urls = $this->storage->getYAML('urls');
     $url_data =& $urls[$index];
     $url_data['clicks']++;
     $this->storage->putYAML('urls', $urls);
     return $url_data['url'];
 }
示例#6
0
<?php

require 'include/shorturl.class.php';
$option = (include 'config.php');
$sourceurl = trim(urldecode($_POST['url']));
$url = trim($_POST['shorturl']);
$shorturl = trim($_POST['shorturl']);
if ($url) {
    $murl = new ShortUrl($option);
    if (!empty($url) && !preg_match("/^http\\:\\/\\/" . $option['domain'] . "/is", $url)) {
        $url = "http://" . $option['domain'] . "/" . $url;
    }
    $oldurl = $murl->get($url);
    if (empty($sourceurl)) {
        if (!$oldurl) {
            $msg = 'This shorturl does not exist!';
        } else {
            $sourceurl = $oldurl;
        }
    } else {
        if ($oldurl) {
            if ($oldurl != $sourceurl) {
                $re = $murl->edit($sourceurl, $url);
            }
            $msg = 'Change success';
        } else {
            $msg = 'This shorturl does not exist, please generate one first!';
        }
    }
} else {
    if ($_POST) {
 private function make_short_url($redirect_url)
 {
     $ShortUrl_obj = new ShortUrl();
     $short_url = $ShortUrl_obj->make_short_url($redirect_url);
     return $short_url;
 }
 /**
  * Suggests a short URL to use to view the club
  *
  * @param int $i_preference
  * @return string
  */
 public function SuggestShortUrl($i_preference = 1)
 {
     $url = strtolower(html_entity_decode($this->GetName()));
     # Remove punctuation
     $url = preg_replace('/[^a-z ]/i', '', $url);
     # Remove noise words
     $url = trim(preg_replace(array('/\\bstoolball\\b/i', '/\\bclub\\b/i', '/\\bladies\\b/i', '/\\bmixed\\b/i', '/\\bsports\\b/i'), '', $url));
     if ($this->GetTypeOfClub() == Club::SCHOOL) {
         $url = "school/{$url}";
         $suffix_if_duplicate = 'school';
     } else {
         $suffix_if_duplicate = 'club';
     }
     # Apply preference
     if ($i_preference > 1) {
         $url = ShortUrl::SuggestShortUrl($url, $i_preference, 1, $suffix_if_duplicate);
     }
     # Remove spaces
     $url = str_replace(' ', '-', $url);
     return $url;
 }
示例#9
0
<?php

require_once "../includes/config.php";
$shortUrl = new ShortUrl();
try {
    $url = $shortUrl->shortCodeToUrl($_GET['q']);
    header("Location: " . $url);
} catch (Exception $e) {
    echo "<h3>Error!</h3>", $e;
    exit;
}
示例#10
0
 public static function createShortUrl($url)
 {
     assert('is_string($url)');
     $hash = ShortUrl::resolveHashByUrl($url);
     return Yii::app()->createAbsoluteUrl('zurmo/shortUrl/redirect/', array('hash' => $hash));
 }
<?php

require_once "../include/config.php";
require_once "../include/ShortUrl.php";
if (empty($_GET["c"])) {
    header("Location: shorten.html");
    exit;
}
$code = $_GET["c"];
try {
    $pdo = new PDO(DB_PDODRIVER . ":host=" . DB_HOST . ";dbname=" . DB_DATABASE, DB_USERNAME, DB_PASSWORD);
} catch (\PDOException $e) {
    header("Location: error.html");
    exit;
}
$shortUrl = new ShortUrl($pdo);
try {
    $url = $shortUrl->shortCodeToUrl($code);
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: " . $url);
} catch (\Exception $e) {
    print_r($e);
    header("Location: error.html");
    exit;
}
示例#12
0
<?php

require 'include/shorturl.class.php';
$option = (include 'config.php');
$sourceurl = trim(urldecode($_POST['url']));
$shorturl = '';
if ($sourceurl) {
    $murl = new ShortUrl($option);
    $url = trim($_POST['shorturl']);
    $msg = '';
    if (!empty($url) && !preg_match("/^http\\:\\/\\/" . $option['domain'] . "/is", $url)) {
        if (!preg_match("/^[A-Za-z0-9]{4,12}\$/", $url)) {
            if (strlen($url) > 12) {
                $msg = '亲,我是短地址,太长了我受不哦,长度不要超过12';
            } elseif (strlen($url) < 4) {
                $msg = '亲,我只是名叫短地址,但太短小我不接受哟,长度不要小于4';
            } else {
                $msg = '亲,短地址只允许26个英文字母或数字组合哦。';
            }
        }
        $url = "http://" . $option['domain'] . "/" . $url;
    }
    if ($msg == '') {
        $re = $murl->set($sourceurl, $url);
        if (preg_match("/^http\\:\\/\\/" . $option['domain'] . "/", $re)) {
            $shorturl = str_replace("http://" . $option['domain'] . "/", '', $re);
            $msg = '生成结果:' . $re . ' <br/><img src="qrcode.php?url=' . $re . '" />';
        } else {
            $shorturl = trim($_POST['shorturl']);
            $msg = '亲,你来迟了,此短地址已有所属';
        }
示例#13
0
 /**
  * shortens a valid url and returns a short url
  *
  * @param   string $pUrl
  * @return  string
  * @throws  ModelException
  */
 public static function shortenUrl($pUrl)
 {
     $lUrl = urldecode($pUrl);
     $lUrl = str_replace(" ", "+", $lUrl);
     if (!UrlUtils::isUrlValid($lUrl)) {
         throw new ModelException("invalid url");
     }
     if ($lShortUrl = self::getByUrl($lUrl)) {
         return $lShortUrl->getShortedUrl();
     } else {
         $lShortUrl = new ShortUrl();
         $lShortUrl->setUrl($lUrl);
         $lShortUrl->save();
         return $lShortUrl->getShortedUrl();
     }
 }
示例#14
0
 /**
  * test bad url throw exception
  *
  * @expectedException ShortUrlException
  */
 public function testNotAValidUrl()
 {
     $this->setExpectedException('ShortUrlException');
     $this->assertFalse($this->ShortUrl->getShortUrl('bogus-string'));
     // make sure bad url fails
 }
示例#15
0
<?php

require_once "includes/config.php";
if (@$_POST['action'] == 'short_url') {
    $shortUrl = new ShortUrl();
    try {
        $code = $shortUrl->convertUrlToShortCode($_POST['long_url']);
        include "templates/view.php";
        echo '<b>Short URL: </b><p><a target="_blank" href="' . URL . '/redirect/?q=' . $code . '">' . URL . '/redirect/q=' . $code . '</a></p>';
    } catch (Exception $e) {
        echo "<h3>Error!</h3>", $e;
        exit;
    }
}
 /**
  * Generate a short URL for an object if none exists
  *
  * @param IHasShortUrl $object
  * @param bool $b_regenerate
  * @return ShortUrl
  */
 public function EnsureShortUrl(IHasShortUrl $object, $b_regenerate = false)
 {
     if (!$object->GetShortUrl() or $b_regenerate) {
         $i_preference = 0;
         $current_url = $object->GetShortUrl();
         $object->SetShortUrl('');
         do {
             $i_preference++;
             $object->SetShortUrl($object->SuggestShortUrl($i_preference));
             if ($b_regenerate and $object->GetShortUrl() == $current_url) {
                 return;
             }
             # if regenerating, it's ok to keep the current URL if it's still appropriate
         } while ($this->IsUrlTaken($object->GetShortUrl()));
     }
     # Now add the new version, but if this is a new item there's a problem.
     # This method is run before adding the new item to the database, so that we
     # can write the item's short URL to the database at the same time as the
     # rest of the item. But that means the item doesn't have an id yet, and
     # generally we want to use the id. So, return the ShortUrl object so that it
     # can be updated after the item has been inserted into the database.
     $short_url = new ShortUrl($object->GetShortUrl());
     $short_url->SetFormat($object->GetShortUrlFormat());
     # Use instance, not static, method so object has a chance to customise format
     $short_url->SetParameterValuesFromObject($object);
     return $short_url;
 }
示例#17
0
function twitter_dialog($link, $text)
{
    if (mb_strlen($text, 'utf-8') > 140) {
        $key = create_snippet($link, $text);
        $shorturl = new ShortUrl();
        $snippet_url = $shorturl->create(get_self_url_prefix() . '/snippet.php?key=' . $key, 'isgd');
        $tweet = truncate_string($text, 90) . " {$snippet_url}";
    } else {
        $tweet = $text;
    }
    $counter = 140 - mb_strlen($tweet, 'utf-8');
    ?>
		<div id="infoBoxTitle"><?php 
    echo __("Send Tweet");
    ?>
</div>
		<div class="infoBoxContents">
			<div id="mini-notice" style='display : none'>&nbsp;</div>
	
			<form id="new_tweet_form" onsubmit="return false;">
	
			<input type="hidden" name="op" value="send-tweet"/>

			<div class="dlgSec"><?php 
    echo __("Your tweet:");
    ?>
</div>

			<textarea onkeyup="tweet_update_counter(this)" name="text" class="tweet-text"><?php 
    echo $tweet;
    ?>
</textarea><p>

			<?php 
    if ($snippet_url) {
        ?>

			<div class="dlgSec"><?php 
        echo __("Full IRC snippet:");
        ?>
</div>
			<textarea disabled="1" class="tweet-snippet"><?php 
        echo $text;
        ?>
</textarea><p>

			<?php 
    }
    ?>

			<div class="dlgButtons">
				<div style='float : left'>
					<input id="tweet-dlg-counter" disabled="1" name="counter" value="<?php 
    echo $counter;
    ?>
">
				</div>
				<button type="submit" onclick="tweet_selection_do()"><?php 
    echo __('Tweet this!');
    ?>
</button>
				<button type="submit" onclick="close_infobox()"><?php 
    echo __('Cancel');
    ?>
</button></div>
			</div>
	
			</form>
	
		</div>
	
		<?php 
}
示例#18
0
 private function notifyTwitter($item)
 {
     // Get twitter credentials
     $username = $this->_properties->getProperty('twitter_username');
     $password = $this->_properties->getProperty('twitter_password');
     $has_preamble = $this->_properties->getProperty('preamble', true);
     // Get item
     $preamble = $has_preamble ? $item->getPreamble() : "";
     $title = $preamble . $item->getTitle();
     // Assemble tweet depending on type
     if ($item->getType() == SourceItem::STATUS_TYPE && strlen($title) < 140) {
         $tweet = $title;
     } else {
         $users = new Users();
         $shortUrl = new ShortUrl();
         $url = $users->getUrl($this->_application->user->id, "s/" . $shortUrl->shorten($item->getSlug()));
         if (strlen($title) + strlen($url) > 140) {
             $tweet = substr($title, 0, 140 - strlen($url) - 5) . "... {$url}";
         } else {
             $tweet = "{$title} {$url}";
         }
     }
     try {
         $twitter = new Stuffpress_Services_Twitter($username, $password);
         $twitter->sendTweet($tweet);
     } catch (Exception $e) {
         //
     }
 }
 /**
  * Suggests a short URL to use to view the team
  *
  * @param int $i_preference
  * @return string
  */
 public function SuggestShortUrl($i_preference = 1)
 {
     # Base the short URL on the team name
     $s_url = strtolower(html_entity_decode($this->GetName()));
     # Remove punctuation
     $s_url = preg_replace('/[^a-z0-9 ]/i', '', $s_url);
     # Remove noise words
     $s_url = preg_replace(array('/\\bstoolball\\b/i', '/\\bclub\\b/i', '/\\bladies\\b/i', '/\\bmixed\\b/i', '/\\bsports\\b/i'), '', $s_url);
     # Apply preference
     if ($i_preference == 2) {
         # Append player type
         $s_url .= strtolower(html_entity_decode(PlayerType::Text($this->GetPlayerType())));
         $s_url = preg_replace('/[^a-z0-9 ]/i', '', $s_url);
     } else {
         if ($i_preference > 2) {
             $s_url = ShortUrl::SuggestShortUrl($s_url, $i_preference, 2, 'team');
         }
     }
     # Remove spaces
     $s_url = str_replace(' ', '-', trim($s_url));
     return $this->GetShortUrlPrefix() . $s_url;
 }
示例#20
0
	private function notifyTwitter($item) {		
		// Get twitter consumer tokens and user secrets
		$consumer_key = $this->_config->twitter->consumer_key;
		$consumer_secret = $this->_config->twitter->consumer_secret;
		$oauth_token = $this->_properties->getProperty('twitter_oauth_token');
		$oauth_token_secret = $this->_properties->getProperty('twitter_oauth_token_secret');
		
		if (!$consumer_key || !$consumer_secret || !$oauth_token || !$oauth_token_secret) {
			$this->addErrorMessage("Missing twitter OAuth credentials to continue");
		}

		// Should we append a text before the tweet ?
		$has_preamble   = $this->_properties->getProperty('preamble', true);		
		
		// Get item
		$preamble	= $has_preamble ? $item->getPreamble() : "";
		$title		= $preamble . $item->getTitle();
		
		// Assemble tweet depending on type
		if (($item->getType() == SourceItem::STATUS_TYPE ) && strlen($title) < 140) {
			$tweet = $title;
		} else {
			$users  = new Users();
			$shortUrl = new ShortUrl(); 
			$url = $users->getUrl($this->_application->user->id, "s/" . $shortUrl->shorten($item->getSlug()));
			if (strlen($title) + strlen($url) > 140) {
				$tweet = substr($title, 0, 140 - strlen($url) - 5) . "... $url"; 
			} else {
				$tweet 	= "$title $url";	
			}
		}

		try {
			$connection = new TwitterOAuth_Client($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
			$response = $connection->post('statuses/update', array('status' => $tweet));
			if (isset($response->error)) {
				$this->addErrorMessage("Failed posting to Twitter with error " . $response->error);
			}			
		} catch (Exception $e) {
			$this->addErrorMessage("Failed posting to Twitter with unknwon error");
		}
	}
<?php

require_once "../include/config.php";
require_once "../include/ShortUrl.php";
if ($_SERVER["REQUEST_METHOD"] != "POST" || empty($_POST["url"])) {
    header("Location: shorten.html");
    exit;
}
try {
    $pdo = new PDO(DB_PDODRIVER . ":host=" . DB_HOST . ";dbname=" . DB_DATABASE, DB_USERNAME, DB_PASSWORD);
} catch (\PDOException $e) {
    header("Location: error.html");
    exit;
}
$shortUrl = new ShortUrl($pdo);
try {
    $code = $shortUrl->urlToShortCode($_POST["url"]);
} catch (\Exception $e) {
    header("Location: error.html");
    exit;
}
$url = SHORTURL_PREFIX . $code;
echo <<<ENDHTML
<html>
 <head>
  <title>URL Shortener</title>
 </head>
 <body>
  <p><strong>Short URL:</strong> <a href="{$url}">{$url}</a></p>
 </body>
</html>
 public function run()
 {
     ShortUrl::deleteOld();
     return true;
 }
示例#23
0
<?php

require 'include/shorturl.class.php';
$option = (include 'config.php');
$act = $_GET['a'];
$murl = new ShortUrl($option);
switch ($act) {
    case 'count':
        $url = $_GET['url'];
        if (!preg_match("/^http\\:\\/\\/" . $option['domain'] . "/is", $url)) {
            $url = "http://" . $option['domain'] . "/" . $url;
        }
        $count = $murl->getsum($url);
        if ($count) {
            die(strval($count));
        } else {
            die('0');
        }
        break;
    case 'edit':
        $surl = $_GET['source'];
        $url = $_GET['url'];
        $re = $murl->edit($surl, $url);
        if ($re) {
            die(strval($re));
        } else {
            die('0');
        }
        break;
    case 'set':
        $surl = $_GET['source'];
示例#24
0
<?php

require_once "include/config.php";
require_once "include/ShortUrl.php";
require_once "include/Database.php";
$db = Database::getInstance();
$pdo = $db->getConnection();
$shortUrl = new ShortUrl($pdo);
$url = SHORTURL_PREFIX;
if ($shortUrl->validateUrlFormat($_POST["url"]) == true) {
    $code = $shortUrl->urlToShortCode($_POST["url"]);
} else {
    $url .= "invalid";
    header("Location: " . $url);
}
try {
    header("Location: " . $url);
} catch (Exception $e) {
    header("Location: error.html");
    exit;
}
示例#25
0
<?php

require 'include/shorturl.class.php';
$option = (include 'config.php');
$url = trim($_GET['s'], '/');
if ($url) {
    $murl = new ShortUrl($option);
    if (!preg_match("/^http\\:\\/\\/" . $option['domain'] . "/si", $url)) {
        $url = "http://" . $option['domain'] . "/" . $url;
    }
    $result = $murl->get($url);
    if ($result) {
        header('Location: ' . $result);
    } else {
        header("HTTP/1.1 404 Not Found");
        echo '404 page not found!';
    }
} else {
    header("HTTP/1.1 404 Not Found");
    echo '404 page not found!';
}
 /**
  * Suggests a short URL to use to view the player
  *
  * @param int $i_preference
  * @return string
  */
 public function SuggestShortUrl($i_preference = 1)
 {
     $s_url = strtolower(html_entity_decode($this->GetName()));
     # Remove punctuation, add dashes
     $s_url = preg_replace('/[^a-z0-9- ]/i', '', $s_url);
     $s_url = str_replace(' ', '-', $s_url);
     $s_url = rtrim($s_url, "-");
     # Add team as prefix
     if ($this->team->GetShortUrl()) {
         $s_url = $this->team->GetShortUrl() . "/" . $s_url;
     }
     # Apply preference
     if ($i_preference > 1) {
         $s_url = ShortUrl::SuggestShortUrl($s_url, $i_preference, 1, "-player", true);
     }
     return $s_url;
 }
示例#27
0
	protected function updateTwitter($items) {
		// Get the user
		$users = new Users();
		$shortUrl = new ShortUrl(); 
		$user  = $users->getUser($this->getUserID());
		
		// Get twitter consumer tokens and user secrets
		$config = Zend_Registry::get("configuration");
		$consumer_key = $config->twitter->consumer_key;
		$consumer_secret = $config->twitter->consumer_secret;
		
		// Get twitter credentials
		$properties = new Properties(array(Properties::KEY => $user->id));
		$auth	    = $properties->getProperty('twitter_auth');
		$services   = $properties->getProperty('twitter_services');
		$oauth_token = $properties->getProperty('twitter_oauth_token');
		$oauth_token_secret = $properties->getProperty('twitter_oauth_token_secret');
		
		if (!$consumer_key || !$consumer_secret || !$oauth_token || !$oauth_token_secret) {
			return;
		}
		
		$has_preamble   = $properties->getProperty('preamble', true);
		
		// Return if not all conditions are met
		if (!$auth || !in_array($this->getID(), unserialize($services))) {
			return;
		}
		
		// Get an item
		$count		= count($items);
		$data		= new Data();
		$source_id	= $this->_source['id'];
					
		if ($count <= 3) {
			foreach($items as $id) {
				$item		= $data->getItem($source_id, $id);
				$title		= strip_tags($item->getTitle());
				$service	= $this->getServiceName();
				
				if (($item->getType() == SourceItem::STATUS_TYPE ) && strlen($title) < 140) {
					$tweet = $title;
				} 
				else {
					$preamble = $has_preamble ? $item->getPreamble() : "";
					$tweet	  = $preamble . $title;
					$url = $users->getUrl($user->id, "s/" . $shortUrl->shorten($item->getSlug()));
					if (strlen($tweet) + strlen($url) > 140) {
						$tweet = substr($tweet, 0, 140 - strlen($url) - 5) . "... $url"; 
					} else {
						$tweet 	= "$tweet $url";	
					}
				}
				
				try {
					$connection = new TwitterOAuth_Client($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
					$response = $connection->post('statuses/update', array('status' => $tweet));	
				} catch (Exception $e) {}
			}
		} else {
			$url = $users->getUrl($user->id);
			$tweet  = sprintf($this->_update_tweet, $count, $url);
			try {
				$twitter = new Stuffpress_Services_Twitter($username, $password);
				$twitter->sendTweet($tweet);
			} catch (Exception $e) {}			
			}
	}
示例#28
0
<?php

require_once "include/config.php";
require_once "include/ShortUrl.php";
require_once "include/Database.php";
$db = Database::getInstance();
$pdo = $db->getConnection();
$shortUrl = new ShortUrl($pdo);
$all_urls = $shortUrl->getAllUrlsFromDb();
$message = "";
if (!empty($_GET)) {
    $code = array_keys($_GET);
    if (isset($code[0]) && $code[0] != 'invalid') {
        $url = $shortUrl->shortCodeToUrl($code[0], true);
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: " . $url);
    } else {
        if ($code[0] == 'invalid') {
            $message = "Please enter a valid url";
        }
    }
}
?>
<html>
    <head>
        <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
        <title>URL Shortener</title>
        <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css" type="text/css"/>
    </head>
    <body role='document'>
        <nav class='navbar navbar-inverse navbar-fixed-top'></nav>
示例#29
0
文件: Api.php 项目: wayhood/wxpay
 /**
  * 
  * 转换短链接
  * 该接口主要用于扫码原生支付模式一中的二维码链接转成短链接(weixin:///s/XXXXXX),
  * 减小二维码数据量,提升扫描速度和精确度。
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param ShortUrl $inputObj
  * @param int $timeOut
  * @throws Exception
  * @return 成功时返回,其他抛异常
  */
 public static function shorturl($inputObj, $timeOut = 6)
 {
     $url = "https://api.mch.weixin.qq.com/tools/shorturl";
     //检测必填参数
     if (!$inputObj->IsLong_urlSet()) {
         throw new Exception("需要转换的URL,签名用原串,传输需URL encode!");
     }
     $inputObj->SetAppid(Config::APPID);
     //公众账号ID
     $inputObj->SetMch_id(Config::MCHID);
     //商户号
     $inputObj->SetNonce_str(self::getNonceStr());
     //随机字符串
     $inputObj->SetSign();
     //签名
     $xml = $inputObj->ToXml();
     $startTimeStamp = self::getMillisecond();
     //请求开始时间
     $response = self::postXmlCurl($xml, $url, false, $timeOut);
     $result = Results::Init($response);
     self::reportCostTime($url, $startTimeStamp, $result);
     //上报请求花费时间
     return $result;
 }
 /**
  * Suggests a short URL to use to view the competition
  *
  * @param int $i_preference
  * @return string
  */
 public function SuggestShortUrl($i_preference = 1)
 {
     $s_url = strtolower(html_entity_decode($this->GetName()));
     # Remove punctuation
     $s_url = preg_replace('/[^a-z ]/i', '', $s_url);
     # Remove noise words
     $s_url = preg_replace(array('/\\bstoolball\\b/i', '/\\bleague\\b/i', '/\\bladies\\b/i', '/\\bmixed\\b/i', '/\\bdistrict\\b/i', '/\\bthe\\b/i', '/\\band\\b/i', '/\\bin\\b/i', '/\\bwith\\b/i', '/\\bassociation\\b/i', '/\\bdivision\\b/i', '/\\bcounty\\b/i', '/\\bfriendlies\\b/i'), '', $s_url);
     # Apply preference
     if ($i_preference == 2) {
         # Append player type
         $s_url .= strtolower(html_entity_decode(PlayerType::Text($this->GetPlayerType())));
         $s_url = preg_replace('/[^a-z0-9 ]/i', '', $s_url);
     } else {
         if ($i_preference > 2) {
             $s_url = ShortUrl::SuggestShortUrl($s_url, $i_preference, 2);
         }
     }
     # Remove spaces
     $s_url = str_replace(' ', '', $s_url);
     return $s_url;
 }