本文整理汇总了PHP中parseUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP parseUrl函数的具体用法?PHP parseUrl怎么用?PHP parseUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postRequest
function postRequest($url, $data)
{
$url = parseUrl($url);
$eol = "\r\n";
$headers = "POST " . $url['path'] . " HTTP/1.1" . $eol . "Host: " . $url['host'] . ":" . $url['port'] . $eol . "Referer: " . $url['protocol'] . $url['host'] . ":" . $url['port'] . $url['path'] . $eol . "Content-Type: application/x-www-form-urlencoded" . $eol . "Content-Length: " . strlen($data) . $eol . $eol . $data;
return makeRequest($url, $headers);
}
示例2: filter
public function filter(array &$data)
{
$data['createdTime'] = date('c', $data['createdTime']);
if (isset($data['thumb']) && !empty($data['thumb'])) {
$data['thumb'] = parseUrl($data['thumb']);
$data['originalThumb'] = parseUrl($data['originalThumb']);
}
if (isset($data['detail_thumb']) && !empty($data['detail_thumb'])) {
$data['detail_thumb'] = parseUrl($data['detail_thumb']);
$data['detail_originalThumb'] = parseUrl($data['detail_originalThumb']);
}
if (isset($data['carousel01_thumb']) && !empty($data['carousel01_thumb'])) {
$data['carousel01_thumb'] = parseUrl($data['carousel01_thumb']);
$data['carousel01_originalThumb'] = parseUrl($data['carousel01_originalThumb']);
}
if (isset($data['carousel02_thumb']) && !empty($data['carousel02_thumb'])) {
$data['carousel02_thumb'] = parseUrl($data['carousel02_thumb']);
$data['carousel02_originalThumb'] = parseUrl($data['carousel02_originalThumb']);
}
if (isset($data['carousel03_thumb']) && !empty($data['carousel02_thumb'])) {
$data['carousel03_thumb'] = parseUrl($data['carousel03_thumb']);
$data['carousel03_originalThumb'] = parseUrl($data['carousel03_originalThumb']);
}
return $data;
}
示例3: getRequest
function getRequest($url)
{
$url = parseUrl($url);
$eol = "\r\n";
$headers = "GET " . $url['path'] . "?" . $url['query'] . " HTTP/1.1" . $eol . "Host: " . $url['host'] . ":" . $url['port'] . $eol . "Connection: close" . $eol . $eol;
return makeRequest($url, $headers);
}
示例4: getContent
/**
* Get HTML content
* failed first time would try to convert URL to fetch content
* @param $url
* @return string|false
*/
function getContent($url)
{
$content = @file_get_contents($url);
if (strlen($content) < 100) {
$content = @file_get_contents(parseUrl($url));
}
return $content;
}
示例5: link
/**
* LINK()
*
* Cria uma âncora HTML automaticamente.
*
* @param string $linkText Texto a ser mostrado na tela.
* @param mixed $linkDestination Endereço de envio (string ou array).
* @param array $options Opções extras de amostragem e configuração.
* @return bool
*/
public function link($linkText, $linkDestination, array $options = array())
{
$inlineProperties = "";
/*
* Opções reservadas. Todas $options serão elementos inline da tag,
* exceto os índices abaixo.
*/
$reservedOptions = array('current_if');
/*
* current_if
* Caso o usuário deseje configurar automaticamente uma classe 'current'
* para links, caso seja o endereço atual
*/
if (!empty($options['current_if']) || in_array('current_if', $options) || in_array('current_controller', $options)) {
if (in_array('current_if', $options)) {
$options['current_if'] = $linkDestination;
}
if (in_array('current_controller', $options)) {
$parsedUrl = parseUrl($linkDestination);
$options['current_if'] = $parsedUrl['controller'];
}
$wanted = parseUrl($options['current_if']);
$current = false;
if ($this->params['controller'] == $wanted['controller']) {
if (empty($wanted['action']) || $wanted['action'] == $this->params['action']) {
$current = true;
}
}
if ($current) {
if (!empty($options['class'])) {
$options['class'] .= ' current';
} else {
$options['class'] = 'current';
}
}
}
/**
* Analisa cada valor de $options
*/
foreach ($options as $chave => $valor) {
if (is_numeric($chave)) {
continue;
}
if (!in_array($chave, $reservedOptions)) {
$inlineProperties .= ' ' . $chave . '="' . $valor . '"';
}
}
return '<a href="' . translateUrl($linkDestination) . '" ' . $inlineProperties . '>' . $linkText . '</a>';
}
示例6: init
/**
* Initialize a fsock session.
*
* @return Recipe_HTTP_Session_Fsock
*/
protected function init()
{
// Split the url
$this->parsedURL = parseUrl($this->webpage);
if (empty($this->parsedURL["host"])) {
throw new Recipe_Exception_Generic("The supplied url is not valid.");
}
if (empty($this->parsedURL["port"])) {
$this->parsedURL["port"] = 80;
}
if (empty($this->parsedURL["path"])) {
$this->parsedURL["path"] = "/";
}
if (!empty($this->parsedURL["query"])) {
$this->parsedURL["path"] .= "?" . $this->parsedURL["query"];
} else {
if (count($this->getGetArgs()) > 0) {
$this->parsedURL["path"] .= "?" . $this->getGetArgs(false);
}
}
$this->resource = fsockopen($this->parsedURL["host"], $this->parsedURL["port"], $this->errorNo, $this->error, self::TIMEOUT);
if (!$this->resource) {
throw new Recipe_Exception_Generic("Connection faild via fsock request: (" . $this->errorNo . ") " . $this->error);
}
@stream_set_timeout($this->resource, self::TIMEOUT);
Hook::event("HttpRequestInitFirst", array($this));
// Set headers
$headers[] = $this->getRequestType() . " " . $this->parsedURL["path"] . " HTTP/1.1";
$headers[] = "Host: " . $this->parsedURL["host"];
$headers[] = "Connection: Close";
$headers[] = "\r\n";
$headers = implode("\r\n", $headers);
$body = "";
if ($this->getRequestType() == "POST" && count($this->getPostArgs()) > 0) {
$body = $this->getPostArgs(false);
}
// Send request
if (!@fwrite($this->resource, $headers . $body)) {
throw new Recipe_Exception_Generic("Couldn't send request.");
}
// Read response
while (!feof($this->resource)) {
$this->response .= fgets($this->resource, 12800);
}
$this->response = explode("\r\n\r\n", $this->response, 2);
$this->response = $this->response[1];
Hook::event("HttpRequestInitLast", array($this));
return $this;
}
示例7: FT_load
function FT_load()
{
$config = (require_once PATH_APPLICATION . '/config/init.php');
autoDeleteFile();
$arrayUrl = parseUrl();
if (!empty($_SESSION['name'])) {
process();
} else {
if (!empty($_COOKIE['name'])) {
$_SESSION['name'] = $_COOKIE['name'];
$_SESSION['id'] = $_COOKIE['id'];
$_SESSION['avatar'] = $_COOKIE['avatar'];
} else {
if ($arrayUrl[0] == 'user' && $arrayUrl[1] == 'login') {
$controllerObject = new User_Controller();
$controllerObject->login();
} else {
headerUrl('/user/login');
}
}
}
}
示例8: U
//.........这里部分代码省略.........
$url = trim($url, $depr);
$path = explode($depr, $url);
$var = array();
$var[C('VAR_ACTION')] = !empty($path) ? array_pop($path) : ACTION_NAME;
$var[C('VAR_MODULE')] = !empty($path) ? array_pop($path) : MODULE_NAME;
if (C('URL_CASE_INSENSITIVE')) {
$var[C('VAR_MODULE')] = parse_name($var[C('VAR_MODULE')]);
}
if (!C('APP_SUB_DOMAIN_DEPLOY') && C('APP_GROUP_LIST')) {
if (!empty($path)) {
$group = array_pop($path);
$var[C('VAR_GROUP')] = $group;
} else {
if (GROUP_NAME != C('DEFAULT_GROUP')) {
$var[C('VAR_GROUP')] = GROUP_NAME;
}
}
if (C('URL_CASE_INSENSITIVE') && isset($var[C('VAR_GROUP')])) {
$var[C('VAR_GROUP')] = strtolower($var[C('VAR_GROUP')]);
}
}
}
}
$flag = true;
if (C('URL_MODEL') == 0) {
// 普通模式URL转换
$ap = pathinfo(__APP__);
if ($ap['extension'] != 'php') {
//临时解决
$url = __APP__ . '/?' . http_build_query(array_reverse($var));
} else {
$url = __APP__ . '?' . http_build_query(array_reverse($var));
}
if (!empty($vars)) {
$vars = urldecode(http_build_query($vars));
$url .= '&' . $vars;
}
$flag = false;
}
if (C('URL_MODEL') == 2) {
$routes = C('URL_ROUTE_RULES');
if (false === strpos('/', $url)) {
$url = implode($depr, array_reverse($var));
}
$_url = array_merge(parseUrl($url), $vars);
foreach ($routes as $rule => $r_route) {
$r_route = str_replace('/', $depr, $r_route);
$_route = parseUrl(str_replace(':', '~', $r_route));
if (url_compare($_url, $_route)) {
break;
}
}
if (url_compare($_url, $_route)) {
foreach ($_route as $key => $val) {
if ($key == 'm' || $key == 'a') {
continue;
}
if (preg_match("/~/", $val)) {
$rule = preg_replace("/(\\(\\\\[\\w]\\+\\))/", $_url[$key], $rule, 1);
}
}
//去掉最后的"/"
$url = __APP__ . '/' . ltrim(rtrim(trim($rule, '/'), '$'), '^');
$url = str_replace('\\', '', $url);
$flag = false;
}
}
if ($flag) {
// PATHINFO模式或者兼容URL模式
if (isset($route)) {
$url = __APP__ . '/' . rtrim($url, $depr);
} else {
$url = __APP__ . '/' . implode($depr, array_reverse($var));
}
if (!empty($vars)) {
// 添加参数
foreach ($vars as $var => $val) {
$url .= $depr . $var . $depr . $val;
}
}
if ($suffix) {
$suffix = $suffix === true ? C('URL_HTML_SUFFIX') : $suffix;
if ($pos = strpos($suffix, '|')) {
$suffix = substr($suffix, 0, $pos);
}
if ($suffix && $url[1]) {
$url .= '.' . ltrim($suffix, '.');
}
}
}
if ($domain) {
$url = (is_ssl() ? 'https://' : 'http://') . $domain . $url;
}
if ($redirect) {
// 直接跳转URL
redirect($url);
} else {
return $url;
}
}
示例9: dispatch
function dispatch($config)
{
if (empty($config)) {
throw new Exception('Need a configuration file to dispatch application.');
}
$domain = getBaseDomain($config);
if (empty($domain)) {
return render($config, 'views/errors/500.php', ['message' => 'Unable to identify request domain.']);
}
$url = assembleUrl($domain);
$tokens = parseUrl($url);
if (empty($tokens)) {
return render($config, 'views/errors/500.php', ['message' => 'Unable to process request.']);
}
/**
* We're just concerned with the path.
**/
$controller = '';
$routeParameters = [];
if (!isset($tokens['path']) || empty($tokens['path'])) {
/**
* Use the default controller instead.
**/
$controller = findDefaultController($config);
if (empty($controller)) {
return render($config, 'views/errors/404.php', ['message' => 'No fallback controller to load.']);
}
$action = findDefaultControllerAction($config);
} else {
$route = $tokens['path'];
$routeTokens = explode('/', $route);
foreach ($routeTokens as $index => $value) {
if (empty($value)) {
unset($routeTokens[$index]);
}
}
$routeTokens = array_values($routeTokens);
$controller = $routeTokens[0];
if (1 == count($routeTokens)) {
$action = findDefaultControllerAction($config);
} else {
$action = $routeTokens[1];
}
if (2 < count($routeTokens)) {
$configRoutes = getConfigRoute($config);
if (empty($configRoutes)) {
/**
* Just discard the given parameters.
**/
unset($routeTokens);
}
$routeParameters = extractRouteParameters($configRoutes, $routeTokens);
}
}
$result = loadController($config, $controller);
if (false === $result['status']) {
return render($config, 'views/errors/404.php', ['message' => $result['message']]);
}
$controllerFile = $result['controller'];
require $controllerFile;
$controllerAction = normalizeAction($action);
if (!function_exists($controllerAction)) {
return render($config, 'views/errors/404.php', ['message' => 'Default controller action is not found.']);
}
$result = $controllerAction($config, $routeParameters);
if (false === $result['status']) {
return render($config, 'views/errors/500.php', ['message' => $result['message']]);
}
/**
* View directory should be in structure: views/<controller-name>/<action-name>.php
**/
$viewFile = 'views' . DIRECTORY_SEPARATOR . $controller . DIRECTORY_SEPARATOR . $action . '.php';
unset($result['status'], $result['message']);
$viewRender = render($config, $viewFile, $result);
if (false === $viewRender) {
render($config, 'views/errors/500.php', ['message' => 'View template not found.']);
}
}
示例10: parseUrl
<?php
// require_once("vendor/jpgraph/jpgraph/lib/JpGraph/src")
require_once "function.php";
parseUrl();
function parseUrl()
{
// print_r ($_GET);
// $relation[] = checkRelation();
// var_dump($relation);
if (array_key_exists('graph', $_GET)) {
switch ($_GET['graph']) {
case 'graph1':
//$_GET['research'] = 'stat-1';
//drawGraph1();
//dependingDefenition();
drawGraph($_GET['tableName']);
break;
//default: {echo "error"; break; }
}
}
if (array_key_exists('data', $_GET)) {
switch ($_GET['data']) {
case 'insertGraphics':
insertGraphics();
break;
case 'showTable':
showTableDependings($_GET['research']);
break;
//default: {echo "error"; break; }
}
示例11: translateText
function translateText(&$body, $wrap_at, $charset)
{
global $where, $what;
/* from searching */
global $color;
/* color theme */
// require_once(SM_PATH . 'functions/url_parser.php');
$body_ary = explode("\n", $body);
for ($i = 0; $i < count($body_ary); $i++) {
$line = rtrim($body_ary[$i], "\r");
if (strlen($line) - 2 >= $wrap_at) {
sqWordWrap($line, $wrap_at, $charset);
}
$line = charset_decode($charset, $line);
$line = str_replace("\t", ' ', $line);
parseUrl($line);
$quotes = 0;
$pos = 0;
$j = strlen($line);
while ($pos < $j) {
if ($line[$pos] == ' ') {
$pos++;
} else {
if (strpos($line, '>', $pos) === $pos) {
$pos += 4;
$quotes++;
} else {
break;
}
}
}
if ($quotes % 2) {
$line = '<span class="quote1">' . $line . '</span>';
} elseif ($quotes) {
$line = '<span class="quote2">' . $line . '</span>';
}
$body_ary[$i] = $line;
}
$body = '<pre>' . implode("\n", $body_ary) . '</pre>';
}
示例12: array_merge
<?php
// benötigte Funktionen werden eingebunden
require_once APP_PATH . 'model/createUrl.php';
require_once APP_PATH . 'model/parseUrl.php';
// Das $_GET array mit den Daten aus der URL kombinieren,
// $_GET für Formulardaten, gehen sonst verloren
// $_SERVER['REQUEST_URI'] entspricht der Action (Seite die angeklickt wurde)
// entspricht im alten Format: ?action=irgendwas
// die URL in GET PARAMETER umwandeln
// array_merge führt ein oder mehrere Arrays zusammen
// parseUrl request seo-freundlich umformen
$_GET = array_merge($_GET, parseUrl($_SERVER['REQUEST_URI']));
// NORMAL ROUTING
// wenn action fehlt (keine Seite angeklickt (Startseite) oder initialier Aufruf der Seite)
if (!isset($_GET['action']) || strlen($_GET['action']) == 0) {
// einen sinnvollen Standardwert vergeben
// bzw. in diesem Fall IMMER die Startseite anzeigen
$action = 'start';
$url = createUrl(array('action' => 'home'));
header('Location: ' . $url);
// handle search request and redirect to search result page
} else {
$action = $_GET['action'];
if (isset($_GET['do'])) {
$do = $_GET['do'];
}
if (isset($_GET['detail'])) {
$detail = $_GET['detail'];
}
}
示例13: array
$fields[] = 'id';
$fields[] = 'title';
$fields[] = 'categoryId';
$fields[] = 'userId';
//添加报名人数
$ArticleService = ServiceKernel::instance()->createService('Article.ArticleService');
$parts = array();
$parts[] = 'id';
$parts[] = 'title';
$parts[] = 'categoryId';
$parts[] = 'enroll';
$parts[] = 'detail_thumb';
$parts[] = 'detail_originalThumb';
$parts[] = 'activity_type';
if (!empty($articles)) {
foreach ($articles as $key => $article) {
$temp_count = $ArticleService->getArticleLikesCountByArticleId($article['id']);
$article['enroll'] = $temp_count;
$article['detail_thumb'] = parseUrl($article['detail_thumb']);
$article['detail_originalThumb'] = parseUrl($article['detail_originalThumb']);
$articles[$key] = ArrayToolkit::parts($article, $parts);
}
}
}
}
$data = array();
$data['articles'] = $articles;
$data['count'] = count($articles);
return $data;
});
return $api;
示例14: exit
exit(0);
}
// Delay between connections
if (is_numeric($dbc) || $dbc != "" || !empty($dbc)) {
} else {
// error
echo " [!] ERROR: Delay between connections is invalid. Default is 0.5 seconds. \n";
exit(0);
}
} else {
// display help
displayHelp();
exit(0);
}
// parse target url return a parsed array
$target_url = parseUrl($target_url);
// check if query empty or not empty
$request_url = checkQuery($target_url);
if ($k == "y") {
// check if server supports keep-alive make sure its a parsed target url
$keepAlive = keepAlive($target_url);
// Switch to check results if server keeps alive
switch ($keepAlive) {
case "NO:KEEP-ALIVE":
$mpc = 1;
break;
case "KEEP-ALIVE":
$mpc = 100;
break;
}
}
示例15: urlsMatch
public static function urlsMatch($url1, $url2)
{
$u1 = parseUrl($url1);
$u2 = parseUrl($url2);
foreach (array_merge(array_keys($u1), array_keys($u2)) as $component) {
if (!array_key_exists($component, $u1) or !array_key_exists($component, $u1)) {
return false;
}
if ($u1[$component] != $u2[$component]) {
return false;
}
}
return true;
}