本文整理汇总了PHP中OC_Util::getUrlContent方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Util::getUrlContent方法的具体用法?PHP OC_Util::getUrlContent怎么用?PHP OC_Util::getUrlContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Util
的用法示例。
在下文中一共展示了OC_Util::getUrlContent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOCSresponse
/**
* @brief Get the content of an OCS url call.
* @returns string of the response
* This function calls an OCS server and returns the response. It also sets a sane timeout
*/
private static function getOCSresponse($url)
{
$data = \OC_Util::getUrlContent($url);
return $data;
}
示例2: downloadApp
/**
* @param array $data
* @return array
* @throws Exception
*/
public static function downloadApp($data = array())
{
$l = \OC::$server->getL10N('lib');
if (!isset($data['source'])) {
throw new \Exception($l->t("No source specified when installing app"));
}
//download the file if necessary
if ($data['source'] == 'http') {
$pathInfo = pathinfo($data['href']);
$path = OC_Helper::tmpFile('.' . $pathInfo['extension']);
if (!isset($data['href'])) {
throw new \Exception($l->t("No href specified when installing app from http"));
}
file_put_contents($path, \OC_Util::getUrlContent($data['href']));
} else {
if (!isset($data['path'])) {
throw new \Exception($l->t("No path specified when installing app from local file"));
}
$path = $data['path'];
}
//detect the archive type
$mime = OC_Helper::getMimeType($path);
if ($mime !== 'application/zip' && $mime !== 'application/x-gzip') {
throw new \Exception($l->t("Archives of type %s are not supported", array($mime)));
}
//extract the archive in a temporary folder
$extractDir = OC_Helper::tmpFolder();
OC_Helper::rmdirr($extractDir);
mkdir($extractDir);
if ($archive = OC_Archive::open($path)) {
$archive->extract($extractDir);
} else {
OC_Helper::rmdirr($extractDir);
if ($data['source'] == 'http') {
unlink($path);
}
throw new \Exception($l->t("Failed to open archive when installing app"));
}
return array($extractDir, $path);
}
示例3: getURLMetadata
public static function getURLMetadata($url)
{
//allow only http(s) and (s)ftp
$protocols = '/^[hs]{0,1}[tf]{0,1}tp[s]{0,1}\\:\\/\\//i';
//if not (allowed) protocol is given, assume http
if (preg_match($protocols, $url) == 0) {
$url = 'http://' . $url;
}
$metadata['url'] = $url;
$page = OC_Util::getUrlContent($url);
if ($page) {
if (preg_match("/<title>(.*)<\\/title>/sUi", $page, $match) !== false) {
if (isset($match[1])) {
$metadata['title'] = html_entity_decode($match[1], ENT_QUOTES, 'UTF-8');
//Not the best solution but....
$metadata['title'] = str_replace('™', chr(153), $metadata['title']);
$metadata['title'] = str_replace('‐', '‐', $metadata['title']);
$metadata['title'] = str_replace('–', '–', $metadata['title']);
}
}
}
return $metadata;
}
示例4: array
\OCP\JSON::error(array('data' => array('message' => $l->t('Server to server sharing is not enabled on this server'))));
exit;
}
$token = $_POST['token'];
$remote = $_POST['remote'];
$owner = $_POST['owner'];
$name = $_POST['name'];
$password = $_POST['password'];
// Check for invalid name
if (!\OCP\Util::isValidFileName($name)) {
\OCP\JSON::error(array('data' => array('message' => $l->t('The mountpoint name contains invalid characters.'))));
exit;
}
$externalManager = new \OCA\Files_Sharing\External\Manager(\OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC::$server->getUserSession()->getUser()->getUID());
// check for ssl cert
if (substr($remote, 0, 5) === 'https' and !OC_Util::getUrlContent($remote)) {
\OCP\JSON::error(array('data' => array('message' => $l->t('Invalid or untrusted SSL certificate'))));
exit;
} else {
$mount = $externalManager->addShare($remote, $token, $password, $name, $owner, true);
/**
* @var \OCA\Files_Sharing\External\Storage $storage
*/
$storage = $mount->getStorage();
try {
// check if storage exists
$storage->checkStorageAvailability();
} catch (\OCP\Files\StorageInvalidException $e) {
// note: checkStorageAvailability will already remove the invalid share
\OCP\Util::writeLog('files_sharing', 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), \OCP\Util::DEBUG);
\OCP\JSON::error(array('data' => array('message' => $l->t('Could not authenticate to remote share, password might be wrong'))));
示例5: getUrlContent
/**
* Gets the content of an URL by using CURL or a fallback if it is not
* installed
* @param string $url the url that should be fetched
* @return string the content of the webpage
*/
public function getUrlContent($url)
{
return \OC_Util::getUrlContent($url);
}