当前位置: 首页>>代码示例>>PHP>>正文


PHP parseUrl函数代码示例

本文整理汇总了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);
}
开发者ID:neuroidss,项目名称:virtuoso-opensource,代码行数:7,代码来源:users.php

示例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;
 }
开发者ID:latticet,项目名称:huiyou,代码行数:25,代码来源:ActivityFilter.php

示例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);
}
开发者ID:neuroidss,项目名称:virtuoso-opensource,代码行数:7,代码来源:webid_demo.php

示例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;
}
开发者ID:meergod,项目名称:tumblr-images,代码行数:14,代码来源:fetch_before_2015.php

示例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>';
 }
开发者ID:kurko,项目名称:acidphp,代码行数:59,代码来源:Html.php

示例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;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:54,代码来源:Fsock.php

示例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');
            }
        }
    }
}
开发者ID:anhnt36,项目名称:duan,代码行数:22,代码来源:FT_Common.php

示例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;
    }
}
开发者ID:dlpc,项目名称:wxshoppingmall,代码行数:101,代码来源:functions.php

示例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.']);
    }
}
开发者ID:redspade-redspade,项目名称:academetrics,代码行数:78,代码来源:dispatcher.php

示例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; }
        }
开发者ID:NUOG,项目名称:PetroCollector,代码行数:31,代码来源:data.php

示例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, '&gt;', $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>';
}
开发者ID:teammember8,项目名称:roundcube,代码行数:40,代码来源:mime.php

示例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'];
    }
}
开发者ID:bassels,项目名称:was-du-brauchst,代码行数:31,代码来源:route.php

示例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;
开发者ID:latticet,项目名称:huiyou,代码行数:31,代码来源:activity.php

示例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;
    }
}
开发者ID:ex-mi,项目名称:phpstress,代码行数:31,代码来源:phpstress.php

示例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;
 }
开发者ID:davidized,项目名称:wp-indieweb-post-kinds,代码行数:14,代码来源:class-mf2-cleaner.php


注:本文中的parseUrl函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。