[ String(elfurl), String(title) ] * Returns the simple link from a call to elfurl and the title of that page. * * Example usage: * * $result = elfurl($_REQUEST['url']); * $href = $result[0]; * $title = $result[1]; */ function tinyurl($url, $useTitle=TRUE) { if (!$url || $url == '') return 0; // // Get the link // $s = doPost('http://tinyurl.com/create.php','url',$url); // //
http://tinyurl.com/zg43m // if (preg_match('/(http:\/\/tinyurl.com\/\w+)<\/b>/',$s,$part)); $href = $part[1]; return elfurlRest($href,$url,$useTitle); } function doPost($req,$key,$val) { $postargs = $key . '=' . urlencode($val); $session = curl_init($req); curl_setopt ($session, CURLOPT_POST, true); curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); curl_close($session); return $response; } /** * String(URL), boolean -> [ String(elfurl), String(title) ] * Returns the simple link from a call to elfurl and the title of that page. * * Example usage: * * $result = elfurl($_REQUEST['url']); * $href = $result[0]; * $title = $result[1]; */ function elfurl($url, $useTitle=TRUE) { if (!$url || $url == '') return 0; // // Get the link // $s = doPost('http://elfurl.com/create','elfurl[url]',$url); // //Your elfin size URL is: // http://elfurl.com/tzoxw
// if (preg_match('/Your elfin size URL is: .*<\/a><\/h2>/',$s,$part)); $href = $part[1]; return elfurlRest($href,$url,$useTitle); } function elfurlRest($href,$url,$useTitle) { if ($useTitle) { $req = $url; $s = file_get_contents($req); preg_match("/
(.*)<\/title>/", $s, $part); $title = $part[1]; } else { $title = ''; } $result = array($href, $title); return $result; } /** * String(URL), boolean -> [ String(elfurl), String(title) ] * Returns the simple link from a call to elfurl and the title of that page. * * Example usage: * * $result = elfurl($_REQUEST['url']); * $href = $result[0]; * $title = $result[1]; */ function elfurlOld($url, $useTitle=true) { if ($url == '') return ""; // // Get the link // $req = "http://elfURL.com/create.php?url=" . urlencode($url); $fp = fopen($req, 'r'); $s = ""; while (!feof($fp)) {$s .= @fgets($fp,4096);} preg_match("/href=\"visit.php\?id=(\w+)\"/", $s, $part); $href = "http://elfurl.com/" . $part[1]; if ($useTitle) { // // Get the title // $req = $url; $fp = fopen($req, 'r'); $s = ""; while (!feof($fp)) {$s .= @fgets($fp,4096);} preg_match("/ (.*)<\/title>/", $s, $part); $title = $part[1]; } else { $title = ''; } $result = array($href, $title); return $result; } ?>