本文整理汇总了PHP中Net_URL2类的典型用法代码示例。如果您正苦于以下问题:PHP Net_URL2类的具体用法?PHP Net_URL2怎么用?PHP Net_URL2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Net_URL2类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: init
public function init(array $options)
{
// base url
if (isset($options['baseURL'])) {
$this->baseURL = $options['baseURL'];
} else {
$this->baseURL = 'http://' . $_SERVER['SERVER_NAME'];
}
if (isset($options['ezrpPath'])) {
$this->ezrpPath = $options['ezrpPath'];
}
$this->sessionID = $options['sessionID'];
$verifyURL = new Net_URL2(rtrim($this->baseURL, '/') . $this->ezrpPath);
$verifyURL->setQueryVariable('ezrpd', $this->driver);
$this->verifyURL = $verifyURL->getURL();
}
开发者ID:shupp,项目名称:EZRP,代码行数:16,代码来源:Common.php
示例2: request
/**
* Http request
*
* @param string $method
* @param string $url
* @param array $submit
* @param string $formName
*
* @return HTTP_Request2_Response
*/
public function request($method, $url, array $submit = array(), $formName = 'form')
{
$this->request = new HTTP_Request2();
$url = new Net_URL2($url);
$this->request->setMethod($method);
if ($submit) {
$submit = array_merge(array('_token' => '0dc59902014b6', '_qf__' . $formName => ''), $submit);
}
if ($submit && $method === 'POST') {
$this->request->addPostParameter($submit);
}
if ($submit && $method === 'GET') {
$url->setQueryVariables($submit);
}
$this->request->setUrl($url);
$this->response = $this->request->send();
return $this;
}
开发者ID:ryo88c,项目名称:BEAR.Saturday,代码行数:28,代码来源:Client.php
示例3: devtips_extract
function devtips_extract(DevTip $tip)
{
global $updates_dir;
$assetPath = getFileName($tip->get('date'), $tip->get('title'));
$assetPath = str_replace(".markdown", "", $assetPath);
# create new asset directory based on new filename
if (!file_exists($updates_dir . 'images/' . $assetPath)) {
mkdir($updates_dir . 'images/' . $assetPath);
chmod($updates_dir . 'images/' . $assetPath, 0777);
}
# Download and store each asset
$assets = $tip->get('assets');
$featured = null;
foreach ($assets as $key => $url) {
if (strpos($url, "/sponsor/") !== false) {
continue;
}
$base = new Net_URL2('https://umaar.com/dev-tips/');
$abs = $base->resolve($url);
$dest = $updates_dir . 'images/' . $assetPath . '/' . pathinfo($url)['basename'];
$content = $tip->get('content');
$tip->set('content', str_replace($url, '/web/updates/images/' . $assetPath . '/' . pathinfo($url)['basename'], $content));
if (!$featured) {
$tip->set('featured-image', '/web/updates/images/' . $assetPath . '/' . pathinfo($url)['basename']);
}
if (!file_exists($dest)) {
set_time_limit(0);
$fp = fopen($dest, 'w+');
//This is the file where we save the information
$ch = curl_init(str_replace(" ", "%20", $abs));
//Here is the file we are downloading, replace spaces with %20
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);
// write curl response to file
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
// get curl response
curl_close($ch);
fclose($fp);
// set proper chmod
chmod($dest, 0777);
}
}
}
开发者ID:niallobrien,项目名称:WebFundamentals,代码行数:44,代码来源:devtips.php
示例4: parse
/**
* Parses the config and splits up the port + url
* @return array
*/
public function parse()
{
$proxy = $this->config->getSystemValue('proxy');
$userpasswd = $this->config->getSystemValue('proxyuserpwd');
$result = ['host' => null, 'port' => null, 'user' => null, 'password' => null];
// we need to filter out the port -.-
$url = new \Net_URL2($proxy);
$port = $url->getPort();
$url->setPort(false);
$host = $url->getUrl();
$result['host'] = $host;
$result['port'] = $port;
if ($userpasswd) {
$auth = explode(':', $userpasswd, 2);
$result['user'] = $auth[0];
$result['password'] = $auth[1];
}
return $result;
}
开发者ID:cs-team,项目名称:news,代码行数:23,代码来源:proxyconfigparser.php
示例5: extract
public function extract(\HTTP_Request2_Response $res)
{
$url = $res->getEffectiveUrl();
$base = new \Net_URL2($url);
$sx = simplexml_load_string($res->getBody());
$linkInfos = array();
$alreadySeen = array();
foreach ($sx->entry as $entry) {
$linkTitle = (string) $entry->title;
foreach ($entry->link as $xlink) {
$linkUrl = (string) $base->resolve((string) $xlink['href']);
if (isset($alreadySeen[$linkUrl])) {
continue;
}
if ($xlink['rel'] == 'alternate') {
$linkInfos[] = new LinkInfo($linkUrl, $linkTitle, $url);
}
$alreadySeen[$linkUrl] = true;
}
}
return $linkInfos;
}
开发者ID:cweiske,项目名称:phinde,代码行数:22,代码来源:Atom.php
示例6: __construct
public function __construct($path = '', $defaults = array(), $rules = array())
{
$this->path = '/' . trim(Net_URL2::removeDotSegments($path), '/');
$this->setDefaults($defaults);
$this->setRules($rules);
try {
$this->parsePath();
} catch (Exception $e) {
// The path could not be parsed correctly, treat it as fixed
$this->fixed = true;
$part = self::createPart(Net_URL_Mapper_Part::FIXED, $this->path, $this->path);
$this->parts = array($part);
}
$this->getRequired();
}
开发者ID:4lb0,项目名称:encaminar,代码行数:15,代码来源:Path.php
示例7: __construct
/**
* Constructor
*/
private function __construct()
{
//Load config
$configDir = dirname(dirname(__FILE__)) . '/config';
Config::load(file_exists($configDir . '/config.php') ? require $configDir . '/config.php' : array(), require $configDir . '/defaults.php');
//Generate Current URL taking into account forwarded proto
$url = \Net_URL2::getRequested();
$url->setQuery(false);
$url->setPath(dirname($_SERVER['PHP_SELF']));
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
$url->setScheme($_SERVER['HTTP_X_FORWARDED_PROTO']);
}
$this->url = $url;
$this->path = $this->url->getPath();
// Initialize phpCAS proxy client
$this->casClient = $this->initializeCAS();
}
开发者ID:GlobalTechnology,项目名称:mpd-dashboard-app,代码行数:20,代码来源:ApplicationWrapper.php
示例8: send
/**
* Sends the request and returns the response
*
* @throws HTTP_Request2_Exception
* @return HTTP_Request2_Response
*/
public function send()
{
// Sanity check for URL
if (!$this->url instanceof Net_URL2) {
throw new HTTP_Request2_Exception('No URL given');
} elseif (!$this->url->isAbsolute()) {
throw new HTTP_Request2_Exception('Absolute URL required');
} elseif (!in_array(strtolower($this->url->getScheme()), array('https', 'http'))) {
throw new HTTP_Request2_Exception('Not a HTTP URL');
}
if (empty($this->adapter)) {
$this->setAdapter($this->getConfig('adapter'));
}
// magic_quotes_runtime may break file uploads and chunked response
// processing; see bug #4543
if ($magicQuotes = ini_get('magic_quotes_runtime')) {
ini_set('magic_quotes_runtime', false);
}
// force using single byte encoding if mbstring extension overloads
// strlen() and substr(); see bug #1781, bug #10605
if (extension_loaded('mbstring') && 2 & ini_get('mbstring.func_overload')) {
$oldEncoding = mb_internal_encoding();
mb_internal_encoding('iso-8859-1');
}
try {
$response = $this->adapter->sendRequest($this);
} catch (Exception $e) {
}
// cleanup in either case (poor man's "finally" clause)
if ($magicQuotes) {
ini_set('magic_quotes_runtime', true);
}
if (!empty($oldEncoding)) {
mb_internal_encoding($oldEncoding);
}
// rethrow the exception
if (!empty($e)) {
throw $e;
}
return $response;
}
开发者ID:ahanjir07,项目名称:vivvo-dev,代码行数:47,代码来源:Request2.php
示例9: resolveURI
/**
* Resolve a possibly relative URL against some absolute base URL
* @param string $rel relative or absolute URL
* @param string $base absolute URL
* @return string absolute URL, or original URL if could not be resolved.
*/
function resolveURI($rel, $base)
{
require_once "Net/URL2.php";
try {
$relUrl = new Net_URL2($rel);
if ($relUrl->isAbsolute()) {
return $rel;
}
$baseUrl = new Net_URL2($base);
$absUrl = $baseUrl->resolve($relUrl);
return $absUrl->getURL();
} catch (Exception $e) {
common_log(LOG_WARNING, 'Unable to resolve relative link "' . $rel . '" against base "' . $base . '": ' . $e->getMessage());
return $rel;
}
}
开发者ID:Br3nda,项目名称:StatusNet,代码行数:22,代码来源:feeddiscovery.php
示例10: getNormalizedFileInfo
/**
* @param $path
* @param null $document
* @return array
* @throws \Exception
*/
public static function getNormalizedFileInfo($path, $document = null)
{
if ($document && $document instanceof Model\Document == false) {
throw new \Exception('$document has to be an instance of Document');
}
$fileInfo = array();
$hostUrl = Tool::getHostUrl();
if ($path[0] != '/') {
$fileInfo['fileUrl'] = $hostUrl . $document . "/{$path}";
//relative eg. ../file.css
} else {
$fileInfo['fileUrl'] = $hostUrl . $path;
}
$fileInfo['fileExtension'] = substr($path, strrpos($path, '.') + 1);
$netUrl = new \Net_URL2($fileInfo['fileUrl']);
$fileInfo['fileUrlNormalized'] = $netUrl->getNormalizedURL();
$fileInfo['filePathNormalized'] = PIMCORE_DOCUMENT_ROOT . str_replace($hostUrl, '', $fileInfo['fileUrlNormalized']);
return $fileInfo;
}
开发者ID:sfie,项目名称:pimcore,代码行数:25,代码来源:Mail.php
示例11: handleRedirect
/**
* Handles HTTP redirection
*
* This method will throw an Exception if redirect to a non-HTTP(S) location
* is attempted, also if number of redirects performed already is equal to
* 'max_redirects' configuration parameter.
*
* @param HTTP_Request2 Original request
* @param HTTP_Request2_Response Response containing redirect
* @return HTTP_Request2_Response Response from a new location
* @throws HTTP_Request2_Exception
*/
protected function handleRedirect(HTTP_Request2 $request, HTTP_Request2_Response $response)
{
if (is_null($this->redirectCountdown)) {
$this->redirectCountdown = $request->getConfig('max_redirects');
}
if (0 == $this->redirectCountdown) {
$this->redirectCountdown = null;
// Copying cURL behaviour
throw new HTTP_Request2_MessageException('Maximum (' . $request->getConfig('max_redirects') . ') redirects followed', HTTP_Request2_Exception::TOO_MANY_REDIRECTS);
}
$redirectUrl = new Net_URL2($response->getHeader('location'), array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets')));
// refuse non-HTTP redirect
if ($redirectUrl->isAbsolute() && !in_array($redirectUrl->getScheme(), array('http', 'https'))) {
$this->redirectCountdown = null;
throw new HTTP_Request2_MessageException('Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString(), HTTP_Request2_Exception::NON_HTTP_REDIRECT);
}
// Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30),
// but in practice it is often not
if (!$redirectUrl->isAbsolute()) {
$redirectUrl = $request->getUrl()->resolve($redirectUrl);
}
$redirect = clone $request;
$redirect->setUrl($redirectUrl);
if (303 == $response->getStatus() || !$request->getConfig('strict_redirects') && in_array($response->getStatus(), array(301, 302))) {
$redirect->setMethod(HTTP_Request2::METHOD_GET);
$redirect->setBody('');
}
if (0 < $this->redirectCountdown) {
$this->redirectCountdown--;
}
return $this->sendRequest($redirect);
}
开发者ID:verbazend,项目名称:AWFA,代码行数:44,代码来源:Socket.php
示例12: array
return $http->send();
}
$images = array();
for ($start = 0; $start < 200; $start += 20) {
// echo $start . "\n";
$html = getContents($searchURL, $start)->getBody();
// $html = file_get_contents('images.html');
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate('/html/body//div[@id="ImgCont"]//td//a');
for ($i = 0; $i < $hrefs->length; $i++) {
$url = $hrefs->item($i)->getAttribute('href');
list(, $querystring) = explode('?', $url);
$neturl = new Net_URL2("http://example.com/?{$querystring}");
$vars = $neturl->getQueryVariables();
if (isset($vars['imgurl'])) {
$images[] = $vars['imgurl'];
}
}
}
foreach ($images as $count => $image) {
preg_match_all('/([.][^.]+)$/', $image, $foo);
if (!isset($foo[0][0])) {
continue;
}
$ext = strtolower($foo[0][0]);
$filename = "images/kittens/{$count}{$ext}";
echo $filename . "\n";
try {
开发者ID:shupp,项目名称:bandk,代码行数:31,代码来源:scrape.php
示例13: MakePagination
public function MakePagination($query, $rpp_def = NULL, $location = "DB")
{
$return_set = array();
$this->{$location}->query($query);
// This query should select all needed fields from database
if ((int) $this->_S->Get('rpp') != 0) {
if (isset($_POST['rpp'])) {
if ((int) $_POST['rpp'] == 0) {
$this->_S->Set('rpp', 50);
} else {
$this->_S->Set('rpp', (int) $_POST['rpp']);
}
}
$rpp = (int) $this->_S->Get('rpp');
} else {
$this->_S->Set('rpp', 50);
$rpp = (int) $this->_S->Get('rpp');
}
// http://pear.php.net/package/Net_URL2
$op = new Net_URL2($_SERVER["REQUEST_URI"]);
$op->unsetQueryVariable('cpage');
$op->setQueryVariable('cpage', '');
$str = (string) $op;
if (strpos($str, "search=1")) {
$str = str_replace("search=1", "search=0", $str);
}
$OptionForm = new TForm();
$OptionForm->Action = $str . $this->CurrentPage;
$OptionForm->Name = "paginationform";
$OptionForm->class_name = "pagination_form";
$TSelect = new TForm_TSelect('rpp');
$TSelect->class_name = 'select2';
$TSelect->style = 'width: 60px;';
$OptionForm->Add("SlRPP", $TSelect);
$OptionForm->SlRPP->Label = "Rezultate pe pagina: ";
$OptionForm->SlRPP->label_class = 'inline';
$OptionForm->SlRPP->AddOption('10', '10');
$OptionForm->SlRPP->AddOption('20', '20');
$OptionForm->SlRPP->AddOption('30', '30');
$OptionForm->SlRPP->AddOption('50', '50');
$OptionForm->SlRPP->AddOption('100', '100');
$OptionForm->SlRPP->Value = $rpp;
$OptionForm->SlRPP->Paragraph = false;
$OptionForm->SlRPP->onChange = 'this.form.submit();';
$total_pages = ceil($this->{$location}->numRows() / $rpp);
if (!$this->CurrentPage || $this->CurrentPage <= 0 || $this->CurrentPage > $total_pages) {
$this->CurrentPage = 1;
}
$return_set[1] = " LIMIT " . ($this->CurrentPage - 1) * $rpp . ", " . $rpp;
$TSelect = new TForm_TSelect('pag');
$TSelect->class_name = 'select2';
$TSelect->style = 'width: 60px;';
$OptionForm->Add('SlPag', $TSelect);
for ($i = 1; $i <= $total_pages; $i++) {
$OptionForm->SlPag->AddOption($str . $i, $i);
}
$OptionForm->SlPag->Label = "Afiseaza pagina: ";
$OptionForm->SlPag->label_class = 'inline';
$OptionForm->SlPag->Paragraph = false;
$OptionForm->SlPag->Value = $str . $this->CurrentPage;
$OptionForm->SlPag->onChange = 'pagination_check_link(this.options[this.selectedIndex].value);';
$return_set[2] = "<div class=\"result_pages\">" . $OptionForm->Html() . "";
$ppages = '';
$j = 0;
$nextpage = $pervpage = '';
if ($this->CurrentPage != 1) {
$pervpage = '<li><a href="' . $str . '1"> <i class="icon-double-angle-left"></i></a></li><li><a href="' . $str . ($this->CurrentPage - 1) . '"> <i class="icon-angle-left"></i></a></li>';
} else {
$pervpage = '<li class="disabled"><a href="' . $str . '1"> <i class="icon-double-angle-left"></i></a></li><li class="disabled"><a href="' . $str . ($this->CurrentPage - 1) . '"> <i class="icon-angle-left"></i></a></li>';
}
if ($this->CurrentPage != $total_pages) {
$nextpage = '<li><a href="' . $str . ($this->CurrentPage + 1) . '"><i class="icon-angle-right"></i> </a></li><li><a href="' . $str . $total_pages . '"><i class="icon-double-angle-right"></i> </a></li>';
} else {
$nextpage = '<li class="disabled"><a href="' . $str . ($this->CurrentPage + 1) . '"><i class="icon-angle-right"></i> </a></li><li class="disabled"><a href="' . $str . $total_pages . '"><i class="icon-double-angle-right"></i> </a></li>';
}
for ($i = 0; $i <= $j + 10; $i++) {
if ($this->CurrentPage - 5 + $i > 0 && $this->CurrentPage - 5 + $i <= $total_pages) {
if ($this->CurrentPage == $this->CurrentPage - 5 + $i) {
$ppages .= '<li class="active"><a>' . ($this->CurrentPage - 5 + $i) . '</a></li>';
} else {
$ppages .= '<li><a href="' . $str . ($this->CurrentPage - 5 + $i) . '">' . ($this->CurrentPage - 5 + $i) . '</a></li>';
}
} else {
if ($this->CurrentPage - 5 + $i <= $total_pages) {
$j++;
}
}
}
$return_set[2] .= '<ul class="pagination">';
if ($total_pages > 1) {
$return_set[2] .= $pervpage . $ppages . $nextpage;
} else {
$return_set[2] .= '<li class="active"><a>' . $this->CurrentPage . '</a></li>';
}
$return_set[2] .= '</ul>';
$return_set[2] .= '</div>';
return $return_set;
}
开发者ID:alexchitoraga,项目名称:tunet,代码行数:98,代码来源:Page.class.php
示例14: resolveUrl
public static function resolveUrl($relative_url, $base_url)
{
$base_url = new Net_URL2($base_url);
return $base_url->resolve($relative_url)->getURL();
}
开发者ID:benjaminhawkeslewis,项目名称:SevenLeggedSpider,代码行数:5,代码来源:SevenLeggedSpider.php
示例15: _isAuthenticationURI
/**
* Checks whether the requested URI is the authentication URI or not.
*
* @param string $authenticationURI
* @return boolean
*/
private function _isAuthenticationURI($authenticationURI)
{
$url = new Net_URL2($authenticationURI);
return $this->context->removeProxyPath($url->getPath()) == $this->_scriptName;
}
开发者ID:piece,项目名称:piece-unity-component-authentication,代码行数:11,代码来源:Authentication.php
示例16: get_request
/**
* GET Request
*
* @param $url
* @param $datas
* @return string
*/
public function get_request($url, $datas = array())
{
$body = '';
try {
$url2 = new Net_URL2($url);
foreach ($datas as $key => $val) {
$url2->setQueryVariable($key, mb_convert_encoding($val, $this->response_encoding, 'UTF-8'), true);
}
$this->http->setURL($url2);
$this->http->setMethod(HTTP_Request2::METHOD_GET);
if (!empty($this->cookies)) {
foreach ($this->cookies as $cookie) {
$this->http->addCookie($cookie['name'], $cookie['value']);
}
}
$response = $this->http->send();
if (count($response->getCookies())) {
$this->cookies = $response->getCookies();
}
$body = mb_convert_encoding($response->getBody(), 'UTF-8', $this->response_encoding);
} catch (Exception $e) {
debug($e->getMessage());
}
return $body;
}
开发者ID:nojimage,项目名称:twitter2mixivoice,代码行数:38,代码来源:Client.php
示例17: addNonce
/**
* Adds a nonce to the openid.return_to URL parameter. Only used in OpenID 1.1
*
* @return void
*/
protected function addNonce()
{
$nonce = $this->getNonce()->createNonceAndStore();
$returnToURL = new Net_URL2($this->message->get('openid.return_to'));
$returnToURL->setQueryVariable(OpenID_Nonce::RETURN_TO_NONCE, urlencode($nonce));
$this->message->set('openid.return_to', $returnToURL->getURL());
// Observing
$logMessage = "Nonce: {$nonce}\n";
$logMessage = 'New ReturnTo: ' . $returnToURL->getURL() . "\n";
$logMessage .= 'OP URIs: ' . print_r($this->serviceEndpoint->getURIs(), true);
OpenID::setLastEvent(__METHOD__, $logMessage);
}
开发者ID:shupp,项目名称:openid,代码行数:17,代码来源:Request.php
示例18: getURL
/**
* Returns an absolute URL using Net_URL
*
* @param string $url All/part of a url
* @return string Full url
*/
function getURL($url)
{
include_once 'Net/URL2.php';
$obj = new Net_URL2($url);
return $obj->getURL();
}
开发者ID:phpsource,项目名称:web-pecl,代码行数:12,代码来源:pear-format-html.php
示例19: detect
/**
* Detect service from a short URL
*
* Takes a URL and inpects it to see if there is a service driver that can
* be used to expand it.
*
* @param string $url The short URL to inspect
*
* @return object Instance of {@link Services_ShortURL_Interface}
*/
public static function detect($url)
{
$url = new Net_URL2($url);
$host = $url->getHost();
if (!isset(self::$services[$host])) {
throw new Services_ShortURL_Exception_UnknownService();
}
return self::factory(self::$services[$host]);
}
开发者ID:nyarla,项目名称:fluxflex-rep2ex,代码行数:19,代码来源:ShortURL.php
示例20: get
/**
* Required to request the root i-name (XRI) XRD which will provide an
* error message that the i-name does not exist, or else return a valid
* XRD document containing the i-name's Canonical ID.
*
* @param string $url URI
* @param string $serviceType Optional service type
*
* @return HTTP_Request
* @todo Finish this a bit better using the QXRI rules.
*/
protected function get($url, $serviceType = null)
{
$request = new HTTP_Request2($url, HTTP_Request2::METHOD_GET, $this->getHttpRequestOptions());
$netURL = new Net_URL2($url);
$request->setHeader('Accept', 'application/xrds+xml');
if ($serviceType) {
$netURL->setQueryVariable('_xrd_r', 'application/xrds+xml');
$netURL->setQueryVariable('_xrd_t', $serviceType);
} else {
$netURL->setQueryVariable('_xrd_r', 'application/xrds+xml;sep=false');
}
$request->setURL($netURL->getURL());
try {
return $request->send();
} catch (HTTP_Request2_Exception $e) {
throw new Services_Yadis_Exception('Invalid response to Yadis protocol received: ' . $e->getMessage(), $e->getCode());
}
}
开发者ID:pear,项目名称:services_yadis,代码行数:29,代码来源:Xri.php
注:本文中的Net_URL2类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论