本文整理汇总了PHP中curl::getFile方法的典型用法代码示例。如果您正苦于以下问题:PHP curl::getFile方法的具体用法?PHP curl::getFile怎么用?PHP curl::getFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curl
的用法示例。
在下文中一共展示了curl::getFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTitle
function getTitle($url)
{
include '../includes/curl.php';
$newc = new curl();
$fd = $newc->getFile($url);
if ($fd) {
// Get title from title tag
preg_match_all('/<title>(.*)<\\/title>/si', $fd, $matches);
$title = $matches[1][0];
// Get encoding from charset attribute
preg_match_all('/<meta.*charset=([^;"]*)">/i', $fd, $matches);
$encoding = strtoupper($matches[1][0]);
// Convert to UTF-8 from the original encoding
$title = @mb_convert_encoding($title, 'UTF-8', $encoding);
if (strlen($title) > 0) {
return $title;
} else {
// No title, so return filename
$uriparts = explode('/', $url);
$filename = end($uriparts);
unset($uriparts);
return $filename;
}
} else {
return false;
}
}
示例2: add_bookmark
function add_bookmark($uname, $title, $folderid, $url, $description, $tags = "", $newPublic = false, $date = NULL)
{
$resultArr = array();
$resultArr['success'] = false;
include 'conn.php';
require_once dirname(__FILE__) . '/protection.php';
if ($date != "") {
$date = "'{$date}'";
} else {
$date = "now()";
}
// Cut data to respect maximum length
if (!empty($title)) {
$title = substr($title, 0, 100);
}
if (!empty($description)) {
$description = substr($description, 0, 150);
}
//$Query = sprintf("INSERT INTO " . TABLE_PREFIX . "favourites (Name , Title , FolderID , Url , Description, ADD_DATE) " . "values('" . $uname . "', %s,'" . $folderid . "', %s, %s, $date) ", quote_smart($title), quote_smart($url), quote_smart($description));
$Query = "INSERT INTO " . TABLE_PREFIX . "favourites (Name , Title , FolderID , Url , Description, ADD_DATE) values(?, ?, ?, ?, ?, {$date})";
$sth = $dblink->prepare($Query);
$dataBookmark = array($uname, $title, $folderid, $url, $description);
$AffectedRows = $sth->execute($dataBookmark);
$rec_id = $dblink->lastInsertID(TABLE_PREFIX . "favourites", 'ID');
if (PEAR::isError($AffectedRows)) {
$resultArr['success'] = true;
//echo 'ERROR: '. $AffectedRows->getMessage(). ' :: ' . $AffectedRows->getUserInfo();
} else {
$resultArr['success'] = true;
$tags = trim($tags);
if (TAGS && $tags != "") {
require_once dirname(__FILE__) . '/tags_functions.php';
//Remove any commas, dots, quotes, plus signs since the user might use commas to seperate tags rather than spaces
$toRemove = array('"', "'", ",", "+");
$tags = str_replace($toRemove, "", $tags);
$tags = filter($tags);
if ($tags != null && $newPublic) {
// cut tags if too long > 150 chars
$tags = substr($tags, 0, 150);
//Add the tags
addTags($tags);
//Store the tags with the bookmark
storeTags($rec_id, $tags);
}
if (USE_SCREENSHOT && CURL_AVAILABLE) {
require_once dirname(__FILE__) . '/curl.php';
$newc = new curl();
$urlScreenshot = sprintf(SCREENSHOT_URL, $url);
//echo $urlScreenshot;
$fd = $newc->getFile($urlScreenshot);
}
}
}
return $resultArr;
}
示例3: read
} else {
return $this->file_contents;
}
}
function read($ch, $string)
{
$length = strlen($string);
$this->file_contents .= $string;
echo "Received {$length} bytes<br />\n";
return $length;
}
}
if (isset($_GET['url'])) {
$url = $_GET['url'];
$curl = new curl();
$lines = $curl->getFile($url, 1000, 1000);
if ($lines == FALSE) {
print "error";
return array("", "");
}
}
if (isset($_POST['data'])) {
$lines = $_POST['data'];
}
if (isset($lines)) {
$ver = intval($_REQUEST['v']);
header('Content-type: application/xml');
$v4 = stristr($lines, "urn:ietf:params:xml:ns:metalink") !== FALSE;
if ($v4 and $ver == 3) {
$lines = metalink4to3(trim($lines));
} elseif (!$v4 and $ver == 4) {