예제 #1
0
function generateUrl() {
	//$newHost = "https://nowsci.com/s/";
	$host = OCP\Config::getAppValue('shorten', 'host', '');
	$type = OCP\Config::getAppValue('shorten', 'type', '');
	$api = OCP\Config::getAppValue('shorten', 'api', '');
	$curUrl = $_POST['curUrl'];
	$ret = "";
	if (isset($type) && ($type == "" || $type == "internal")) {
		if ($host == "" || startsWith($curUrl, $host)) {
			$ret = $curUrl;
		} else {
			$shortcode = getShortcode($curUrl);
			$newUrl = $host."?".$shortcode;
			$ret = $newUrl;
		}
	} elseif ($type == "googl") {
		if ($api && $api != "") {
			require_once __DIR__ . '/../lib/class.googl.php';
			$googl = new googl($api);
			$short = $googl->s($curUrl);
			$ret = $short;
		} else {
			$ret = $curUrl;
		}
	} else {
		$ret = $curUrl;
	}
	return $ret;
}
예제 #2
0
			} else
				$shortcode = rand_chars(6);
		}
	}
	return $shortcode;
}

$curUrl = $_POST['curUrl'];
if (isset($type) && ($type == "" || $type == "internal")) {
	if ($host == "" || startsWith($curUrl, $host)) {
		echo $curUrl;
	} else {
		$shortcode = getShortcode($curUrl);
		$newUrl = $host."?".$shortcode;
		echo $newUrl;
	}
} elseif ($type == "googl") {
	if ($api && $api != "") {
		require_once __DIR__ . '/../lib/class.googl.php';
		$googl = new googl($api);
		$short = $googl->s($curUrl);
		echo $short;
	} else {
		echo $curUrl;
	}
} else {
	echo $curUrl;
}

?>