<?php
if (!defined('IN_OELOVE')) {
    exit('OElove[OEPHP] Access Denied');
}
/**
 * Copyright (C) OELOVE Co.,Ltd. All rights reserved.
 * <E-Mail��phpcoo@qq.com>
 * Url http://www.phpcoo.com
 *     http://www.oelove.com
 * Update 2014.09.05
 */
function smarty_modifier_shorturl($url){
	$shorturl = "";
	if (function_exists('curl_init')) {
		$ch = @curl_init();
		curl_setopt($ch, CURLOPT_URL, "http://dwz.cn/create.php");
		curl_setopt($ch,CURLOPT_POST, true);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
		$data = array('url'=>$url);
		curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
		$strRes = curl_exec($ch);
		curl_close($ch);
		if (!empty($strRes)) {
			$arrResponse = @json_decode($strRes, true);
			$shorturl = @$arrResponse['tinyurl'];
		}
	}
	if (empty($shorturl)) {
		$shorturl = $url;
	}
	return $shorturl;
}

?>