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


PHP URL::parse方法代码示例

本文整理汇总了PHP中URL::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::parse方法的具体用法?PHP URL::parse怎么用?PHP URL::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在URL的用法示例。


在下文中一共展示了URL::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 protected function parse($iri)
 {
     if (!is_array($iri)) {
         if ($iri == null) {
             $iri = array();
         } else {
             if (!($iri = URL::parse($iri))) {
                 return null;
             }
             if (!isset($iri['host'])) {
                 $iri['host'] = $this->clusterName;
             }
         }
     }
     if (!isset($iri['scheme']) || !strlen($iri['scheme'])) {
         $iri['scheme'] = 'cluster';
     }
     if (!isset($iri['host']) || !strlen($iri['host'])) {
         $iri['host'] = $this->clusterName;
     }
     if (!isset($iri['path'])) {
         $iri['path'] = '/';
     }
     if (!isset($iri['pathcomp'])) {
         $iri['pathcomp'] = array();
         $x = explode('/', $iri['path']);
         foreach ($x as $p) {
             if (!strlen($p)) {
                 continue;
             }
             $iri['pathcomp'][] = $p;
         }
     }
     return $iri;
 }
开发者ID:nexgenta,项目名称:cluster,代码行数:35,代码来源:clusterfs.php

示例2: __construct

 public function __construct($reqUrl, $params)
 {
     if ($reqUrl instanceof URL) {
         $this->reqUrl = $reqUrl;
     } else {
         $this->reqUrl = URL::parse($reqUrl);
     }
     $this->params = $params;
 }
开发者ID:tniessen,项目名称:tinyIt,代码行数:9,代码来源:Router.php

示例3: parse_url

/**
 * Providing the standard PHP interface.
 *
 * Mostly compatible to {@link http://php.net/manual/en/function.parse-url.php \parse_url()}
 *
 * The 2nd parameter which can be provided in the original php function can't
 * be supported here, because there are no constants for the additional values.
 *
 * As this function wants to be compatible to {@link http://php.net/manual/en/function.parse-url.php \parse_url()}
 * it returns <tt>false</tt> (instead of throwing exceptions) in case of
 * failiures.
 *
 * @return array|boolean
 * @param $url string
 * @author akrys
 */
function parse_url($url)
{
    try {
        $obj = new URL($url);
        return $obj->parse();
    } catch (\Exception $e) {
        //some error handling one could think of.
        //for simple dev purposes, a simple var_dump should be enough
        //		print $e->getMessage();
        //		var_dump($e->getTraceAsString());
    }
    return false;
}
开发者ID:akrys,项目名称:extended-parse-url,代码行数:29,代码来源:extended_parse_url.php

示例4: execute

 /**
  * 执行路由
  *
  * @param string $controller 控制器
  * @param string $action 方法
  */
 public function execute($controller = null, $action = null)
 {
     #解析链接
     if (is_null($controller)) {
         $url = URL::parse();
     } else {
         if (is_null($action)) {
             $action = 'index';
         }
         $url = URL::parseController($controller, $action);
     }
     App::setController($url->getController());
     App::setAction($url->getAction());
     $this->invoke($url);
 }
开发者ID:qazzhoubin,项目名称:emptyphp,代码行数:21,代码来源:Route.php

示例5: save_mainmenu

 public function save_mainmenu($form)
 {
     $base_url = Site::get_url('habari', true);
     $start_url = $form->mainmenus->value;
     /* Strip out the base URL from the requested URL */
     /* but only if the base URL isn't / */
     if ('/' != $base_url) {
         $start_url = str_replace($base_url, '', $start_url);
     }
     /* Trim off any leading or trailing slashes */
     $start_url = trim($start_url, '/');
     /* Remove the querystring from the URL */
     if (strpos($start_url, '?') !== FALSE) {
         list($start_url, $query_string) = explode('?', $start_url);
     }
     /* Allow plugins to rewrite the stub before it's passed through the rules */
     $start_url = Plugins::filter('rewrite_request', $start_url);
     $stub = $start_url;
     /* Grab the URL filtering rules from DB */
     $matched_rule = URL::parse($stub);
     if ($matched_rule === FALSE) {
         print 'error, cant find rule';
         // error!!!!
     }
     /* Return $_GET values to their proper place */
     $args = array();
     if (!empty($query_string)) {
         parse_str($query_string, $args);
     }
     $rule = $matched_rule->name;
     $args = array_merge($matched_rule->named_arg_values, $args);
     if (User::identify()->can('super_user') && $form->affect_all->value == true) {
         foreach (Users::get_all() as $user) {
             $user->info->admindetour_real = array('rule' => $rule, 'args' => $args);
             $user->update();
         }
     } else {
         User::identify()->info->admindetour_real = array('rule' => $rule, 'args' => $args);
     }
     $_POST[$form->mainmenus->field] = URL::get($rule, $args);
     $form->save();
 }
开发者ID:habari-extras,项目名称:admindetour,代码行数:42,代码来源:admindetour.plugin.php

示例6: Groups

function Groups()
{
    global $context, $txt, $scripturl, $sourcedir, $user_info, $modSettings;
    // The sub-actions that we can do. Format "Function Name, Mod Bar Index if appropriate".
    $subActions = array('index' => array('GroupList', 'view_groups'), 'members' => array('MembergroupMembers', 'view_groups'), 'requests' => array('GroupRequests', 'group_requests'));
    if (!isset($modSettings['groupColorsInline'])) {
        require_once $sourcedir . '/lib/Subs-Membergroups.php';
        regenerateColorStyle();
    }
    // Default to sub action 'index' or 'settings' depending on permissions.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'index';
    // Get the template stuff up and running.
    loadLanguage('ManageMembers');
    loadLanguage('ModerationCenter');
    if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'admin' || $_REQUEST['action'] === 'groups') {
        loadAdminTemplate('ManageMembergroups');
    }
    // If we can see the moderation center, and this has a mod bar entry, add the mod center bar.
    if ($_REQUEST['action'] != 'moderate' && (allowedTo('access_mod_center') || $user_info['mod_cache']['bq'] != '0=1' || $user_info['mod_cache']['gq'] != '0=1' || allowedTo('manage_membergroups'))) {
        if (isset($_REQUEST['group'])) {
            redirectexit(URL::parse('?action=moderate;area=viewgroups;sa=members;group=' . $_REQUEST['group']));
        } else {
            if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'requests' && isset($_POST[$context['session_var']])) {
                require_once $sourcedir . '/ModerationCenter.php';
                $_GET['area'] = $_REQUEST['sa'] == 'requests' ? 'groups' : 'viewgroups';
                ModerationMain(true);
            } else {
                redirectexit(URL::parse('?action=moderate;area=viewgroups'));
            }
        }
        //require_once($sourcedir . '/ModerationCenter.php');
        //$_GET['area'] = $_REQUEST['sa'] == 'requests' ? 'groups' : 'viewgroups';
        //ModerationMain(true);
    } else {
        isAllowedTo('view_mlist');
        $context['linktree'][] = array('url' => $scripturl . '?action=groups', 'name' => $txt['groups']);
    }
    // Call the actual function.
    $subActions[$_REQUEST['sa']][0]();
}
开发者ID:norv,项目名称:EosAlpha,代码行数:40,代码来源:Groups.php

示例7: processRequest

 public static function processRequest()
 {
     // Make sure that a proper table and lookup key have been provided.
     // If they aren't, this request can be ended.
     if (!static::$table or !static::$lookupKey) {
         return json_encode(["ERROR" => "This API does not have the proper lookup configurations set."]);
     }
     // Get Important Values
     $request = ['method' => $_SERVER['REQUEST_METHOD'], 'class' => get_called_class(), 'url' => URL::parse(), 'headers' => getallheaders(), 'input' => file_get_contents('php://input')];
     $requestMethod = $request['method'];
     $resourcePath = substr($request['url']['path'], strpos($request['url']['path'] . "/", $request['class'] . "/") + strlen($request['class']) + 1);
     // Get the lookup ID to see which record we're attempting to match
     if (!($lookupID = static::extractLookupID($resourcePath))) {
         // This request has no specific resource to point to. There's a good chance that we're attempting
         // to GET data using an advanced search for multiple results. If this is the case, track that behavior.
         if ($requestMethod == "GET") {
             $requestMethod = "GET_SEARCH";
         }
     }
     // Make sure the API Request has proper handling set up
     if (!isset(static::$allowRequests[$requestMethod])) {
         return json_encode(["ERROR" => "The handling of this request method is not set properly."]);
     }
     // Make sure this API is allowed
     if (static::$allowRequests[$requestMethod] == self::CLOSED) {
         return json_encode(["ERROR" => "This API is not accessible using the " . strtoupper($requestMethod) . " method."]);
     }
     // Check if this API requires authentication
     if (static::$allowRequests[$requestMethod] >= self::AUTHENTICATED) {
         // Make sure that the appropriate authentication procedures have been passed
         if (!static::authenticateRequest($request)) {
             return json_encode(["ERROR" => "Unable to access this API: improper authentication used."]);
         }
     }
     // Prepare an empty response
     $response = array();
     // Handle the request
     switch ($requestMethod) {
         case "GET":
             $response = static::getRequest($lookupID, $request);
             break;
         case "GET_SEARCH":
             $response = static::getSearchRequest($request);
             break;
         case "POST":
             $response = static::postRequest($request);
             break;
         case "PUT":
             $response = static::putRequest($lookupID, $request);
             break;
         case "PATCH":
             $response = static::patchRequest($lookupID, $request);
             break;
         case "DELETE":
             $response = static::deleteRequest($lookupID, $request);
             break;
     }
     // Return a serialized response
     return json_encode($response);
 }
开发者ID:SkysteedDevelopment,项目名称:Deity,代码行数:60,代码来源:Model_Utilities.php

示例8: xmlrpc_pingback__ping

 /**
  * Receive a Pingback via XMLRPC
  * @param array $params An array of XMLRPC parameters from the remote call
  * @return string The success state of the pingback
  */
 public function xmlrpc_pingback__ping($params)
 {
     try {
         list($source_uri, $target_uri) = $params;
         // This should really be done by an Habari core function
         $target_parse = InputFilter::parse_url($target_uri);
         $target_stub = $target_parse['path'];
         $base_url = Site::get_path('base', TRUE);
         if ('/' != $base_url) {
             $target_stub = str_replace($base_url, '', $target_stub);
         }
         $target_stub = trim($target_stub, '/');
         if (strpos($target_stub, '?') !== FALSE) {
             list($target_stub, $query_string) = explode('?', $target_stub);
         }
         // Can this be used as a target?
         $target_slug = URL::parse($target_stub)->named_arg_values['slug'];
         if ($target_slug === FALSE) {
             throw new XMLRPCException(33);
         }
         // Does the target exist?
         $target_post = Post::get(array('slug' => $target_slug));
         if ($target_post === FALSE) {
             throw new XMLRPCException(32);
         }
         // Is comment allowed?
         if ($target_post->info->comments_disabled) {
             throw new XMLRPCException(33);
         }
         // Is this Pingback already registered?
         if (Comments::get(array('post_id' => $target_post->id, 'url' => $source_uri, 'type' => Comment::PINGBACK))->count() > 0) {
             throw new XMLRPCException(48);
         }
         // Retrieve source contents
         $rr = new RemoteRequest($source_uri);
         $rr->execute();
         if (!$rr->executed()) {
             throw new XMLRPCException(16);
         }
         $source_contents = $rr->get_response_body();
         // encoding is converted into internal encoding.
         // @todo check BOM at beginning of file before checking for a charset attribute
         $habari_encoding = MultiByte::hab_encoding();
         if (preg_match("/<meta[^>]+charset=([A-Za-z0-9\\-\\_]+)/i", $source_contents, $matches) !== FALSE && strtolower($habari_encoding) != strtolower($matches[1])) {
             $ret = MultiByte::convert_encoding($source_contents, $habari_encoding, $matches[1]);
             if ($ret !== FALSE) {
                 $source_contents = $ret;
             }
         }
         // Find the page's title
         preg_match('/<title>(.*)<\\/title>/is', $source_contents, $matches);
         $source_title = $matches[1];
         // Find the reciprocal links and their context
         preg_match('/<body[^>]*>(.+)<\\/body>/is', $source_contents, $matches);
         $source_contents_filtered = preg_replace('/\\s{2,}/is', ' ', strip_tags($matches[1], '<a>'));
         if (!preg_match('%.{0,100}?<a[^>]*?href\\s*=\\s*("|\'|)' . $target_uri . '\\1[^>]*?' . '>(.+?)</a>.{0,100}%s', $source_contents_filtered, $source_excerpt)) {
             throw new XMLRPCException(17);
         }
         /** Sanitize Data */
         $source_excerpt = '...' . InputFilter::filter($source_excerpt[0]) . '...';
         $source_title = InputFilter::filter($source_title);
         $source_uri = InputFilter::filter($source_uri);
         /* Sanitize the URL */
         if (!empty($source_uri)) {
             $parsed = InputFilter::parse_url($source_uri);
             if ($parsed['is_relative']) {
                 // guess if they meant to use an absolute link
                 $parsed = InputFilter::parse_url('http://' . $source_uri);
                 if (!$parsed['is_error']) {
                     $source_uri = InputFilter::glue_url($parsed);
                 } else {
                     // disallow relative URLs
                     $source_uri = '';
                 }
             }
             if ($parsed['is_pseudo'] || $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') {
                 // allow only http(s) URLs
                 $source_uri = '';
             } else {
                 // reconstruct the URL from the error-tolerant parsing
                 // http:moeffju.net/blog/ -> http://moeffju.net/blog/
                 $source_uri = InputFilter::glue_url($parsed);
             }
         }
         // Add a new pingback comment
         $pingback = new Comment(array('post_id' => $target_post->id, 'name' => $source_title, 'email' => '', 'url' => $source_uri, 'ip' => sprintf("%u", ip2long($_SERVER['REMOTE_ADDR'])), 'content' => $source_excerpt, 'status' => Comment::STATUS_UNAPPROVED, 'date' => HabariDateTime::date_create(), 'type' => Comment::PINGBACK));
         $pingback->insert();
         // Respond to the Pingback
         return 'The pingback has been registered';
     } catch (XMLRPCException $e) {
         $e->output_fault_xml();
     }
 }
开发者ID:anupom,项目名称:my-blog,代码行数:98,代码来源:pingback.plugin.php

示例9: assert

assert('URL::join_ext(array("/file", ".txt")) == "/file.txt"');
assert('URL::join_ext("some", "path", "to", "/file", ".tar.gz") == "some/path/to/file.tar.gz"');
assert('URL::join_ext("file/", ".txt") == "file/.txt"');
/* Test URL::parse and URL::unparse */
$url = 'http://www.example.com/some/page?foo=3&foo=bar&baz=foo;';
$x = URL::parse($url);
list($base, $args) = $x;
assert('$base === "http://www.example.com/some/page"');
assert('is_assoc_array($args)');
assert('count($args) == 2');
assert('array_has_key($args, "foo")');
assert('$args["foo"] === "bar"');
$url = 'page.php?foo=3&bar=123';
$x = URL::parse($url);
list($base, $args) = $x;
assert('is_assoc_array($args)');
assert('count($args) == 2');
assert('array_has_key($args, "foo")');
assert('$args["foo"] === "3"');
assert('array_has_key($args, "bar")');
assert('$args["bar"] === "123"');
$url = 'http://example.com/some/page.php?foo=3&bar=123';
$x = URL::parse($url);
list($base, $args) = $x;
$y = URL::unparse($base, $args);
assert('$y === $url');
$url = '/some/page.php';
$x = URL::parse($url);
list($base, $args) = $x;
$y = URL::unparse($base, $args);
assert('$y === $url');
开发者ID:jijkoun,项目名称:ssscrape,代码行数:31,代码来源:url.test.php

示例10: getScheme

 static function getScheme($url)
 {
     $components = URL::parse($url);
     return $components[2];
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:5,代码来源:URL.class.php

示例11: str_replace

$randSalt = str_replace('$', '', $randSalt);
// Prepare POST Values: make sure that every $_POST value has a default value provided.
$_POST['site-salt'] = isset($_POST['site-salt']) ? Sanitize::text($_POST['site-salt']) : $randSalt;
$_POST['site-handle'] = isset($_POST['site-handle']) ? Sanitize::variable($_POST['site-handle']) : "";
$_POST['site-url'] = isset($_POST['site-url']) ? Sanitize::variable($_POST['site-url'], ":/.") : $_SERVER['SERVER_NAME'];
$_POST['site-name'] = isset($_POST['site-name']) ? Sanitize::text($_POST['site-name']) : "";
$_POST['site-domain'] = isset($_POST['site-domain']) ? Sanitize::variable($_POST['site-domain'], ":/.") : "";
$_POST['site-database-name'] = isset($_POST['site-database-name']) ? Sanitize::variable($_POST['site-database-name']) : "";
// Run the Form
if (Form::submitted("install-app-config")) {
    // Check if all of the input you sent is valid:
    Validate::variable("Site Handle", $_POST['site-handle'], 3, 22);
    Validate::safeword("Site Name", $_POST['site-name'], 3, 42);
    Validate::url("URL", $_POST['site-url'], 3, 64);
    // Parse the URL input
    $siteURL = URL::parse($_POST['site-url']);
    if (Validate::pass()) {
        // Make sure the site handle isn't taken
        $packet = array("site-handle" => $_POST['site-handle'], "uni-handle" => $ownerHandle, "site-name" => $_POST['site-name'], "site-url" => $siteURL['full']);
        // Call UniFaction's API to register a site with the system
        // If the site fails to register, it will provide an alert explaining why
        $response = API_Connect::call(URL::unifaction_com() . "/api/RegisterSiteHandle", $packet);
        if ($response) {
            // If the database users are provided and there is a database name that we can create, build config settings
            $siteTheme = "default";
            $siteThemeStyle = "default";
            $buildApp = '<?php

// Site-Wide Salt
define("SITE_SALT", "' . $_POST['site-salt'] . '");
开发者ID:SkysteedDevelopment,项目名称:Deity,代码行数:30,代码来源:config-app.php

示例12: xmlrpc_pingback__ping

	/**
	 * Receive a Pingback via XMLRPC
	 * @param array $params An array of XMLRPC parameters from the remote call
	 * @return string The success state of the pingback
	 */
	public function xmlrpc_pingback__ping( $params )
	{
		try {
			list( $source_uri, $target_uri )= $params;

			// This should really be done by an Habari core function
			$target_parse = InputFilter::parse_url( $target_uri );
			$target_stub = $target_parse['path'];
			$base_url = Site::get_path( 'base', true );

			if ( '/' != $base_url) {
				$target_stub = str_replace( $base_url, '', $target_stub );
			}

			$target_stub = trim( $target_stub, '/' );

			if ( strpos( $target_stub, '?' ) !== false ) {
				list( $target_stub, $query_string )= explode( '?', $target_stub );
			}

			// Can this be used as a target?
			$target_slug = URL::parse( $target_stub )->named_arg_values['slug'];

			if ( $target_slug === false ) {
				throw new XMLRPCException( 33 );
			}

			// Does the target exist?
			$target_post = Post::get( array( 'slug' => $target_slug ) );

			if ( $target_post === false ) {
				throw new XMLRPCException( 32 );
			}

			// Is comment allowed?
			if ( $target_post->info->comments_disabled ) {
				throw new XMLRPCException( 33 );
			}

			// Is this Pingback already registered?
			if ( Comments::get( array( 'post_id' => $target_post->id, 'url' => $source_uri, 'type' => Comment::PINGBACK ) )->count() > 0 ) {
				throw new XMLRPCException( 48 );
			}

			// Retrieve source contents
			try {
				$rr = new RemoteRequest( $source_uri );
				$rr->execute();
				if ( ! $rr->executed() ) {
					throw new XMLRPCException( 16 );
				}
				$source_contents = $rr->get_response_body();
				$headers = $rr->get_response_headers();
			}
			catch ( XMLRPCException $e ) {
				// catch our special type of exception and re-throw it
				throw $e;
			}
			catch ( Exception $e ) {
				throw new XMLRPCException( -32300 );
			}

			// Encoding is converted into internal encoding.
			// First, detect the source string's encoding
			$habari_encoding = strtoupper( MultiByte::hab_encoding() );
			$source_encoding = 'Windows-1252';
			// Is the charset in the headers?
			if ( isset( $headers['Content-Type'] ) && strpos( $headers['Content-Type'], 'charset' ) !== false ) {
				// This regex should be changed to meet the HTTP spec at some point
				if ( preg_match("/charset[\x09\x0A\x0C\x0D\x20]*=[\x09\x0A\x0C\x0D\x20]*('?)([A-Za-z0-9\-\_]+)\1/i", $headers['Content-Type'], $matches ) ) {
					$source_encoding = strtoupper( $matches[2] );
				}
			}
			// Can we tell the charset from the stream itself?
			else if ( ( $enc = MultiByte::detect_bom_encoding( $source_contents ) ) !== false ) {
				$source_encoding = $enc;
			}
			// Is the charset in a meta tag?
			else if ( preg_match( "/<meta[^>]+charset[\x09\x0A\x0C\x0D\x20]*=[\x09\x0A\x0C\x0D\x20]*([\"']?)([A-Za-z0-9\-\_]+)\1/i", $source_contents, $matches ) ) {
				$source_encoding = strtoupper( $matches[2] );
				if (in_array($source_encoding, array("UTF-16", "UTF-16BE", "UTF-16LE"))) {
					$source_encoding = "UTF-8";
				}
			}
			// Then, convert the string
			$ret = MultiByte::convert_encoding( $source_contents, $habari_encoding, $source_encoding );
			if ( $ret !== false ) {
				$source_contents = $ret;
			}

			// Find the page's title
			preg_match( '/<title>(.*)<\/title>/is', $source_contents, $matches );
			$source_title = $matches[1];

			// Find the reciprocal links and their context
//.........这里部分代码省略.........
开发者ID:rynodivino,项目名称:system,代码行数:101,代码来源:pingback.plugin.php

示例13: query

 public static function query($url = null)
 {
     $URL = new URL($url);
     $URL->parse();
     return $URL->query;
 }
开发者ID:rayful,项目名称:url,代码行数:6,代码来源:URL.php

示例14: GetMcard

function GetMcard()
{
    global $memberContext, $context, $txt, $user_info;
    $is_xmlreq = $_REQUEST['action'] == 'xmlhttp' ? true : false;
    if (!$is_xmlreq) {
        redirectexit();
    }
    // this isn't supposed to be called normally
    if (!isset($_REQUEST['u'])) {
        AjaxErrorMsg($txt['no_access'], $txt['error_occured']);
    }
    $uid = intval($_REQUEST['u']);
    if (allowedTo('profile_view_any') && $uid) {
        //loadTemplate('MemberCard');
        EoS_Smarty::loadTemplate('membercard');
        loadMemberData($uid, false, 'profile');
        loadMemberContext($uid);
        loadLanguage('Profile');
        loadLanguage('Ratings');
        $context['member'] = $memberContext[$uid];
        if (!empty($context['member']['gender']['name'])) {
            $context['member']['loc'][0] = $context['member']['gender']['image'] . $context['member']['gender']['name'];
        }
        if (isset($context['member']['birth_date']) && !empty($context['member']['birth_date'])) {
            list($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d');
            $datearray = getdate(forum_time());
            if ($birth_year > 5) {
                $context['member']['loc'][1] = $datearray['year'] - $birth_year - ($datearray['mon'] > $birth_month || $datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day ? 0 : 1);
            }
        }
        if (!empty($context['member']['location'])) {
            $context['member']['loc'][2] = 'from ' . $context['member']['location'];
        }
        $context['can_send_pm'] = allowedTo('pm_send') && $uid != $user_info['id'];
        $context['pm_contact_link'] = $context['can_send_pm'] ? URL::parse('?action=pm;sa=send;u=' . $context['member']['id']) : '';
    } else {
        AjaxErrorMsg($txt['no_access'], $txt['error_occured']);
    }
}
开发者ID:norv,项目名称:EosAlpha,代码行数:39,代码来源:Xml.php

示例15: parse_request

 /**
  * Parses the requested URL.  Automatically
  * translates URLs coming in from mod_rewrite and parses
  * out any action and parameters in the slug.
  */
 public static function parse_request()
 {
     /* Local scope variable caching */
     $controller = Controller::instance();
     /* Grab the base URL from the Site class */
     $controller->base_url = Site::get_path('base', true);
     /* Start with the entire URL coming from web server... */
     $start_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['SCRIPT_NAME'] . (isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '') . (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '' ? '?' . $_SERVER['QUERY_STRING'] : '');
     /* Strip out the base URL from the requested URL */
     /* but only if the base URL isn't / */
     if ('/' != $controller->base_url) {
         $start_url = str_replace($controller->base_url, '', $start_url);
     }
     // undo &amp;s
     $start_url = str_replace('&amp;', '&', $start_url);
     /* Trim off any leading or trailing slashes */
     $start_url = trim($start_url, '/');
     /* Allow plugins to rewrite the stub before it's passed through the rules */
     $start_url = Plugins::filter('rewrite_request', $start_url);
     $controller->stub = $start_url;
     /* Grab the URL filtering rules from DB */
     $matched_rule = URL::parse($controller->stub);
     if ($matched_rule === FALSE) {
         $matched_rule = URL::set_404();
     }
     /* OK, we have a matching rule.  Set the action and create a handler */
     $controller->action = $matched_rule->action;
     $controller->handler = new $matched_rule->handler();
     /* Insert the regexed submatches as the named parameters */
     $controller->handler->handler_vars['entire_match'] = $matched_rule->entire_match;
     // The entire matched string is returned at index 0
     foreach ($matched_rule->named_arg_values as $named_arg_key => $named_arg_value) {
         $controller->handler->handler_vars[$named_arg_key] = $named_arg_value;
     }
     /* Also, we musn't forget to add the GET and POST vars into the action's settings array */
     $handler_vars = new SuperGlobal($controller->handler->handler_vars);
     $handler_vars = $handler_vars->merge($_GET, $_POST);
     $controller->handler->handler_vars = $handler_vars;
     return true;
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:45,代码来源:controller.php


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