/** * Filters an asset after it has been loaded. * * @param \Assetic\Asset\AssetInterface $asset * @return void */ public function filterLoad(AssetInterface $asset) { $max_nesting_level = ini_get('xdebug.max_nesting_level'); $memory_limit = ini_get('memory_limit'); if ($max_nesting_level && $max_nesting_level < 200) { ini_set('xdebug.max_nesting_level', 200); } if ($memory_limit && $memory_limit < 256) { ini_set('memory_limit', '256M'); } $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); $dirs = array(); $lc = new \Less_Parser(array('compress' => true)); if ($root && $path) { $dirs[] = dirname($root . '/' . $path); } foreach ($this->loadPaths as $loadPath) { $dirs[] = $loadPath; } $lc->SetImportDirs($dirs); $url = parse_url($this->getRequest()->getUriForPath('')); $absolutePath = str_replace(public_path(), '', $root); if (isset($url['path'])) { $absolutePath = $url['path'] . $absolutePath; } $lc->parseFile($root . '/' . $path, $absolutePath); $asset->setContent($lc->getCss()); }
/** * @param mixed $in */ public function __construct($in = null) { $fields = array('to', 'cc', 'bcc', 'message', 'body', 'subject'); if (is_string($in)) { if (($pos = strpos($in, '?')) !== false) { parse_str(substr($in, $pos + 1), $this->args); $this->args['to'] = substr($in, 0, $pos); } else { $this->args['to'] = $in; } } elseif ($in instanceof Horde_Variables) { foreach ($fields as $val) { if (isset($in->{$val})) { $this->args[$val] = $in->{$val}; } } } elseif (is_array($in)) { $this->args = $in; } if (isset($this->args['to']) && strpos($this->args['to'], 'mailto:') === 0) { $mailto = @parse_url($this->args['to']); if (is_array($mailto)) { $this->args['to'] = isset($mailto['path']) ? $mailto['path'] : ''; if (!empty($mailto['query'])) { parse_str($mailto['query'], $vals); foreach ($fields as $val) { if (isset($vals[$val])) { $this->args[$val] = $vals[$val]; } } } } } }
function getdata($style, $parameter) { $array = array(); foreach ($parameter as $key => $value) { if (is_array($value)) { $parameter[$key] = implode(',', $value); } } $parameter['clientid'] = $this->blockdata['clientid']; $parameter['op'] = 'getdata'; $parameter['charset'] = CHARSET; $parameter['version'] = $this->blockdata['version']; $xmlurl = $this->blockdata['url']; $parse = parse_url($xmlurl); if (!empty($parse['host'])) { define('IN_ADMINCP', true); require_once libfile('function/importdata'); $importtxt = @dfsockopen($xmlurl, 0, create_sign_url($parameter, $this->blockdata['key'], $this->blockdata['signtype'])); } else { $importtxt = @file_get_contents($xmlurl); } if ($importtxt) { require libfile('class/xml'); $array = xml2array($importtxt); } $idtype = 'xml_' . $this->blockdata['id']; foreach ($array['data'] as $key => $value) { $value['idtype'] = $idtype; $array['data'][$key] = $value; } if (empty($array['data'])) { $array['data'] = null; } return $array; }
/** * 全局安全过滤函数 * 支持SQL注入和跨站脚本攻击 */ function global_filter() { //APP,ACT 分别为控制器和控制器方法 $params = array(APP, ACT); foreach ($params as $k => $v) { if (!preg_match("/^[a-zA-Z0-9_-]+\$/", $v)) { header_status_404(); } } $arrStr = array('%0d%0a', "'", '<', '>', '$', 'script', 'document', 'eval', 'atestu', 'select', 'insert?into', 'delete?from'); global_inject_input($_SERVER['HTTP_REFERER'], $arrStr, true); global_inject_input($_SERVER['HTTP_USER_AGENT'], $arrStr, true); global_inject_input($_SERVER['HTTP_ACCEPT_LANGUAGE'], $arrStr, true); global_inject_input($_GET, array_merge($arrStr, array('"')), true); //global_inject_input($_COOKIE, array_merge($arrStr, array('"', '&')), true); //cookie会有对url的记录(pGClX_last_url)。去掉对&的判断 global_inject_input($_COOKIE, array_merge($arrStr, array('"')), true); global_inject_input($_SERVER, array('%0d%0a'), true); //处理跨域POST提交问题 if ($_SERVER['REQUEST_METHOD'] == 'POST') { //处理客户端POST请求处理没有HTTP_REFERER参数问题 if (isset($_SERVER['HTTP_REFERER'])) { $url = parse_url($_SERVER['HTTP_REFERER']); $referer_host = !empty($url['port']) && $url['port'] != '80' ? $url['host'] . ':' . $url['port'] : $url['host']; if ($referer_host != $_SERVER['HTTP_HOST']) { header_status_404(); } } } global_inject_input($_POST, array('%0d%0a')); global_inject_input($_REQUEST, array('%0d%0a')); }
/** * Retourne le lien absolu */ function get_absolute_link($relative_link, $url) { /* return if already absolute URL */ if (parse_url($relative_link, PHP_URL_SCHEME) != '') { return $relative_link; } /* queries and anchors */ if ($relative_link[0] == '#' || $relative_link[0] == '?') { return $url . $relative_link; } /* parse base URL and convert to local variables: $scheme, $host, $path */ extract(parse_url($url)); /* remove non-directory element from path */ $path = preg_replace('#/[^/]*$#', '', $path); /* destroy path if relative url points to root */ if ($relative_link[0] == '/') { $path = ''; } /* dirty absolute URL */ $abs = $host . $path . '/' . $relative_link; /* replace '//' or '/./' or '/foo/../' with '/' */ $re = array('#(/\\.?/)#', '#/(?!\\.\\.)[^/]+/\\.\\./#'); for ($n = 1; $n > 0; $abs = preg_replace($re, '/', $abs, -1, $n)) { } /* absolute URL is ready! */ return $scheme . '://' . $abs; }
/** * This function handles the actual redirection to the target. */ function cap_redirect_short_urls() { global $post; if (is_singular('cap_short_urls')) { // Check for the existance of legacy url information. Lead with that if present. if (get_post_meta($post->ID, 'legacy_url_redirect_target', true)) { $legacy_url = get_post_meta($post->ID, 'legacy_url_redirect_target', true); // Let's get the actual domain from the legacy url... $parse = parse_url($legacy_url); $domain = $parse['host']; // ... if it is thinkprogress.org then proceed with idenfication of the post targeted. Otherwise just do a straight up redirect. if ('thinkprogress.org' === $domain || 'www.thinkprogress.org' === $domain) { // We could probably just get away with passing the old url in however... we want to make sure that if in the future the target posts permalink is changed then this short url will still work. So to that end we're going to use url_to_postid() to get the ID of the target post to past into get_permalink(). $post_id = url_to_postid($legacy_url); $target = get_permalink($post_id); // This will add the ID of the short url post to the target post so that the get_shortlink function will work. It will only do so once bc it checks for unique existence. add_post_meta($post_id, 'post_short_url_target', '' . $post->ID . '', true); } else { $target = $legacy_url; } } elseif (get_post_meta($post->ID, 'url_redirect_target', true)) { $target = get_post_meta($post->ID, 'url_redirect_target', true); } elseif (get_post_meta($post->ID, 'post_redirect_target', true)) { $target = get_permalink(get_post_meta($post->ID, 'post_redirect_target', true)); } else { $target = get_bloginfo('url'); } wp_redirect($target); exit; echo '<!--Short URL Away-->'; } }
/** * Gets current URI without provided query parameters * * @param array $removeParameters * * @return string */ public function getCurrentUri(array $removeParameters = array()) { if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $protocol = 'https://'; } else { $protocol = 'http://'; } $currentUri = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $parts = parse_url($currentUri); $port = isset($parts['port']) && ($protocol === 'http://' && $parts['port'] !== 80 || $protocol === 'https://' && $parts['port'] !== 443) ? ':' . $parts['port'] : ''; if (empty($parts['query'])) { $query = ''; } elseif (count($removeParameters) === 0) { $query = '?' . $parts['query']; } else { $queryParameters = array(); foreach ($this->parseHttpQuery($parts['query']) as $key => $value) { if (!in_array($key, $removeParameters)) { $queryParameters[$key] = $value; } } if (count($queryParameters) > 0) { $query = '?' . http_build_query($queryParameters, null, '&'); } else { $query = ''; } } return $protocol . $parts['host'] . $port . $parts['path'] . $query; }
/** * {@inheritDoc} */ public function getContent($url) { $info = parse_url($url); $hostname = $info['host']; $port = isset($info['port']) ? $info['port'] : 80; $path = isset($info['path']) ? $info['path'] : '/'; $socketHandle = $this->createSocket($hostname, $port, 30); if (!fwrite($socketHandle, $this->buildHttpRequest($path, $hostname))) { throw new ExtensionNotLoadedException('Could not send the request'); } $httpResponse = $this->getParsedHttpResponse($socketHandle); if ($httpResponse['headers']['status'] === 301 && isset($httpResponse['headers']['location'])) { if (--$this->redirectsRemaining) { return $this->getContent($httpResponse['headers']['location']); } else { throw new HttpException('Too Many Redirects'); } } else { $this->redirectsRemaining = self::MAX_REDIRECTS; } if ($httpResponse['headers']['status'] !== 200) { throw new HttpException(sprintf('The server return a %s status.', $httpResponse['headers']['status'])); } return $httpResponse['content']; }
/** {@inheritDoc} */ public function getPath() { if (!($requestPath = $this->getServerVar("REQUEST_URI")) && !($requestPath = $this->getServerVar("ORIG_PATH_INFO"))) { $requestPath = $this->getIisRequestUri(); } return "/" . trim(rawurldecode(strval(parse_url($requestPath, PHP_URL_PATH))), "/"); }
public function prepareExtract() { $request_uri = isset($_GET['REQUEST_URI']) ? $_GET['REQUEST_URI'] : (isset($_POST['REQUEST_URI']) ? $_POST['REQUEST_URI'] : (isset($_ENV['REQUEST_URI']) ? $_ENV['REQUEST_URI'] : getenv("REQUEST_URI"))); if (substr($request_uri, 0, 1) != "/") { $request_uri = "/" . $request_uri; } $request_uri = trim($request_uri); $url = "http" . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? "s" : "") . "://" . getenv("HTTP_HOST") . $request_uri; // parse entire url $parsed_url = @parse_url($url); // validate query parameter if (is_array($parsed_url) && array_key_exists('query', $parsed_url) && $parsed_url['query']) { $parsed_query_arr = null; parse_str($parsed_url['query'], $parsed_query_arr); $_GET = $parsed_query_arr ? $parsed_query_arr : array(); } // superglobal arrays $superglobals = array("_COOKIE" => $_COOKIE, "_GET" => $_GET, "_POST" => $_POST, "_FILES" => $_FILES, "_ENV" => $_ENV, "_SERVER" => $_SERVER); // set default // merge superglobals arrays foreach ($superglobals as $key => $super_array) { // set internal data from superglobal arrays $this->{$key} = self::prepareSuperglobal($super_array); } return false; }
function readUrl($url) { var_dump($url); die; $urldata = parse_url($url); if (isset($urldata['host'])) { if ($this->host and $this->host != $urldata['host']) { return false; } $this->protocol = $urldata['scheme']; $this->host = $urldata['host']; $this->path = $urldata['path']; return $url; } if (preg_match('#^/#', $url)) { $this->path = $urldata['path']; return $this->protocol . '://' . $this->host . $url; } else { if (preg_match('#/$#', $this->path)) { return $this->protocol . '://' . $this->host . $this->path . $url; } else { if (strrpos($this->path, '/') !== false) { return $this->protocol . '://' . $this->host . substr($this->path, 0, strrpos($this->path, '/') + 1) . $url; } else { return $this->protocol . '://' . $this->host . '/' . $url; } } } }
function displayTemplateCallback($hookName, $args) { $templateMgr =& $args[0]; $template =& $args[1]; if ($template != 'article/article.tpl') { return false; } // Determine the query terms to use. $queryVariableNames = array('q', 'p', 'ask', 'searchfor', 'key', 'query', 'search', 'keyword', 'keywords', 'qry', 'searchitem', 'kwd', 'recherche', 'search_text', 'search_term', 'term', 'terms', 'qq', 'qry_str', 'qu', 's', 'k', 't', 'va'); $this->queryTerms = array(); if (($referer = getenv('HTTP_REFERER')) == '') { return false; } $urlParts = parse_url($referer); if (!isset($urlParts['query'])) { return false; } $queryArray = explode('&', $urlParts['query']); foreach ($queryArray as $var) { $varArray = explode('=', $var); if (in_array($varArray[0], $queryVariableNames) && !empty($varArray[1])) { $this->queryTerms += $this->parse_quote_string($varArray[1]); } } if (empty($this->queryTerms)) { return false; } $templateMgr->addStylesheet(Request::getBaseUrl() . '/' . $this->getPluginPath() . '/sehl.css'); $templateMgr->register_outputfilter(array(&$this, 'outputFilter')); return false; }
function artxUrlToHref($url) { $result = ''; $p = parse_url($url); if (isset($p['scheme']) && isset($p['host'])) { $result = $p['scheme'] . '://'; if (isset($p['user'])) { $result .= $p['user']; if (isset($p['pass'])) { $result .= ':' . $p['pass']; } $result .= '@'; } $result .= $p['host']; if (isset($p['port'])) { $result .= ':' . $p['port']; } if (!isset($p['path'])) { $result .= '/'; } } if (isset($p['path'])) { $result .= $p['path']; } if (isset($p['query'])) { $result .= '?' . str_replace('&', '&', $p['query']); } if (isset($p['fragment'])) { $result .= '#' . $p['fragment']; } return $result; }
/** * generates a url to the current page * @param boolean $dropqs [description] * @return string [description] */ public static function php_self($dropqs = true) { // figure out what the protocol is $protocol = 'http'; if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') { $protocol = 'https'; } elseif (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') { $protocol = 'https'; } // figure out what the server name is $serverName = empty($_SERVER['SERVER_NAME']) ? 'localhost' : $_SERVER['SERVER_NAME']; // figure out what the port is $port = empty($_SERVER['SERVER_PORT']) ? 80 : $_SERVER['SERVER_PORT']; // build the uri $url = sprintf('%s://%s%s', $protocol, $serverName, $_SERVER['REQUEST_URI']); $parts = parse_url($url); $port = $port; $scheme = $parts['scheme']; $host = $parts['host']; $path = @$parts['path']; $qs = @$parts['query']; $port or $port = $scheme == 'https' ? '443' : '80'; if ($scheme == 'https' && $port != '443' || $scheme == 'http' && $port != '80') { $host = "{$host}:{$port}"; } $url = $scheme . '://' . $host . $path; if (!$dropqs) { return "{$url}?{$qs}"; } else { return $url; } }
private function _init_env() { error_reporting(E_ERROR); define('MAGIC_QUOTES_GPC', function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()); // ' " \ NULL 等字符转义 当magic_quotes_gpc=On的时候,函数get_magic_quotes_gpc()就会返回1 define('GZIP', function_exists('ob_gzhandler')); // ob 缓存压缩输出 if (function_exists('date_default_timezone_set')) { @date_default_timezone_set('Etc/GMT-8'); //东八区 北京时间 } define('TIMESTAMP', time()); if (!defined('BLOG_FUNCTION') && !@(include BLOG_ROOT . '/source/functions.php')) { exit('functions.php is missing'); } define('IS_ROBOT', checkrobot()); global $_B; $_B = array('uid' => 0, 'username' => '', 'groupid' => 0, 'timestamp' => TIMESTAMP, 'clientip' => $this->_get_client_ip(), 'mobile' => '', 'agent' => '', 'admin' => 0); checkmobile(); $_B['PHP_SELF'] = bhtmlspecialchars($this->_get_script_url()); $_B['basefilename'] = basename($_B['PHP_SELF']); $sitepath = substr($_B['PHP_SELF'], 0, strrpos($_B['PHP_SELF'], '/')); $_B['siteurl'] = bhtmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . $sitepath . '/'); getReferer(); $url = parse_url($_B['siteurl']); $_B['siteroot'] = isset($url['path']) ? $url['path'] : ''; $_B['siteport'] = empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']; $this->b =& $_B; }
/** * Constructor. * * @param string $url HTTP url to SOAP endpoint. * * @access public */ function SOAP_Transport_TCP($url, $encoding = SOAP_DEFAULT_ENCODING) { parent::SOAP_Base_Object('TCP'); $this->urlparts = @parse_url($url); $this->url = $url; $this->encoding = $encoding; }
function SpamCheckDNSBL($bl, $link) { $obj = new DNSBL(); $obj->setWhiteList($obj->getConfig(CONFIG_SPAM_WL_SKIP_DOMAIN)); if (empty($bl) || !is_array($bl)) { $obj->setBlockList($obj->getConfig(CONFIG_SPAM_BLOCKLIST, 'HOST')); } else { $obj->setBlockList($bl); } $obj->setMyNetList($obj->getConfig(CONFIG_SPAM_WL_PRIVATE_NET, 'HOST')); $hosts = !is_array($link) ? array($link) : $link; $i = 0; foreach ($hosts as $host) { $url = parse_url($host); $domain = empty($url['host']) ? $host : $url['host']; $obj->setName($domain); if ($obj->isListed()) { return true; } if (SPAM_MAX_COUNTER == 0) { continue; } $i++; if ($i > SPAM_MAX_COUNTER) { return false; } } return false; }
/** * Get contact information * @since 2.6.1 * @access public */ public function additional_info() { $contact_info = explode(',', $this->args['additional_info']); $output = '<div id="gmw-sl-additional-info-wrapper-' . $this->args['element_id'] . '" class="gmw-sl-additional-info-wrapper gmw-sl-' . $this->args['item_type'] . '-additional-info-wrapper">'; $this->item_info->address = !empty($this->item_info->formatted_address) ? $this->item_info->formatted_address : $this->item_info->address; $output .= '<ul>'; foreach ($contact_info as $info) { $label = !empty($this->labels[$info . '_label']) ? $this->labels[$info . '_label'] : $info; if ($info == 'website' && !empty($this->item_info->website)) { $url = parse_url($this->item_info->website); if (empty($url['scheme'])) { $url['scheme'] = 'http'; } $scheme = $url['scheme'] . '://'; $path = str_replace($scheme, '', $this->item_info->website); $website = '<a href="' . $scheme . $path . '" title="' . $path . '" target="_blank">' . $path . '</a>'; $output .= "<li class=\"gmw-{$info} {$info}\"><span class=\"label\">{$label}</span>: "; $output .= !empty($this->item_info->{$info}) ? $website : $this->labels['na']; $output .= '</li>'; } elseif ($info == 'email' && !empty($this->item_info->email)) { $output .= "<li class=\"gmw-{$info} {$info}\"><span class=\"label\">{$label}</span>: "; $output .= !empty($this->item_info->{$info}) ? "<a href=\"mailto:{$this->item_info->email}\">{$this->item_info->email}</a>" : $this->labels['na']; $output .= '</li>'; } else { $output .= "<li class=\"gmw-{$info} {$info}\"><i class=\"fa fa-{$label}\"></i><span class=\"label\">{$label}</span>: "; $output .= !empty($this->item_info->{$info}) ? $this->item_info->{$info} : $this->labels['na']; $output .= '</li>'; } } $output .= '</li>'; $output .= '</div>'; return apply_filters('gmw_sl_additional_info', $output, $this->args, $this->item_info, $this->user_position); }
/** * Get stored cookies for a url. * * Finds matching stored cookies and returns a simple array * of name => value * * @param string $url The url to find cookies for. * @return array */ public function get($url) { $path = parse_url($url, PHP_URL_PATH) ?: '/'; $host = parse_url($url, PHP_URL_HOST); $scheme = parse_url($url, PHP_URL_SCHEME); $out = []; foreach ($this->_cookies as $cookie) { if ($scheme === 'http' && !empty($cookie['secure'])) { continue; } if (strpos($path, $cookie['path']) !== 0) { continue; } $leadingDot = $cookie['domain'][0] === '.'; if (!$leadingDot && $host !== $cookie['domain']) { continue; } if ($leadingDot) { $pattern = '/' . preg_quote(substr($cookie['domain'], 1), '/') . '$/'; if (!preg_match($pattern, $host)) { continue; } } $out[$cookie['name']] = $cookie['value']; } return $out; }
public function create(\Request $request) { $data = Request::json()->all(); $issue_service = new IssueService(app(ConfigurationInterface::class)); $url_parts = parse_url($data['worklog']['self']); $uri = $url_parts['path']; $regex = '~^/rest/api/./issue/(?P<issue_id>.*?)/(?P<ignore>.*?)/?$~'; $matched = preg_match($regex, $uri, $matches); if (!$matched) { return null; } $issue = $issue_service->get($matches['issue_id']); $project_key = $issue->fields->project->key; $project = Project::whereJiraKey($project_key)->first(); $employee = Staff::whereUserName($data['worklog']['author']['name'])->first(); //return $project; $time_spent = $data['worklog']['timeSpentSeconds']; $started = $data['worklog']['started']; $timelog_jira_id = $data['worklog']['id']; $timelog = Timelog::whereJiraId($timelog_jira_id)->first(); if ($timelog == null) { $timelog = new Timelog(); } $timelog->project_id = $project->id; $timelog->staff_id = $employee->id; $timelog->started = $started; $timelog->time_spent = $time_spent; $timelog->jira_id = $timelog_jira_id; $timelog->save(); //debugInfo($timelog); return $timelog; }
/** * {@inheritdoc} */ protected function getMiddleware(Application $app) { $pipe = new MiddlewarePipe(); $path = parse_url($app->url(), PHP_URL_PATH); $errorDir = __DIR__ . '/../../error'; if (!$app->isInstalled()) { $app->register('Flarum\\Install\\InstallServiceProvider'); $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\StartSession')); $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', ['routes' => $app->make('flarum.install.routes')])); $pipe->pipe($path, new HandleErrors($errorDir, true)); } elseif ($app->isUpToDate() && !$app->isDownForMaintenance()) { $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\ParseJsonBody')); $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\StartSession')); $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\RememberFromCookie')); $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\AuthenticateWithSession')); $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\SetLocale')); event(new ConfigureMiddleware($pipe, $path, $this)); $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', ['routes' => $app->make('flarum.forum.routes')])); $pipe->pipe($path, new HandleErrors($errorDir, $app->inDebugMode())); } else { $pipe->pipe($path, function () use($errorDir) { return new HtmlResponse(file_get_contents($errorDir . '/503.html', 503)); }); } return $pipe; }
function relocate($referer, $page, $msg, $id) { include CONFIG . "config.php"; // Break URL into an array $parts = parse_url($referer); $referer = $parts['query']; // Remove $msg=X from query string $pattern = array("/[0-9]/", "/&msg=/"); $referer = preg_replace($pattern, "", $referer); // Remove $id=X from query string $pattern = array("/[0-9]/", "/&id=/"); $referer = preg_replace($pattern, "", $referer); // Remove $pg=X from query string and add back in if ($page != "default") { $pattern = array("/[0-9]/", "/&pg=/"); $referer = str_replace($pattern, "", $referer); $referer .= "&pg=" . $page; } $pattern = array('\'', '"'); $referer = str_replace($pattern, "", $referer); $referer = stripslashes($referer); // Reconstruct the URL $output = $base_url . "index.php?" . $referer; return $output; }
/** * Return the parsed URL. * * @return array|null */ public function parsed() { if ($url = $this->object->getValue()) { return parse_url($url); } return null; }
/** * url 为服务的url地址 * query 为请求串 */ private function sock_post($url, $query) { $data = ""; $info = parse_url($url); $fp = fsockopen($info["host"], 80, $errno, $errstr, 30); if (!$fp) { return $data; } $head = "POST " . $info['path'] . " HTTP/1.0\r\n"; $head .= "Host: " . $info['host'] . "\r\n"; $head .= "Referer: http://" . $info['host'] . $info['path'] . "\r\n"; $head .= "Content-type: application/x-www-form-urlencoded\r\n"; $head .= "Content-Length: " . strlen(trim($query)) . "\r\n"; $head .= "\r\n"; $head .= trim($query); $write = fputs($fp, $head); $header = ""; while ($str = trim(fgets($fp, 4096))) { $header .= $str; } while (!feof($fp)) { $data .= fgets($fp, 4096); } return $data; }
function pushMobileNotification($msg, $displayname, $channel, $senderid) { global $pushAPIKey; global $notificationName; global $cookiefile; $msg = checkEmoji($msg); if (CROSS_DOMAIN == 1) { $host = parse_url(BASE_URL); $hostname = $host['host'] ? $host['host'] : array_shift(explode('/', $host['path'], 2)); } else { $hostname = $_SERVER['HTTP_HOST']; } /********************************** SETUP **********************************/ $key = $pushAPIKey; $channel = $hostname . '' . $channel; $message = $displayname . ': ' . $msg; $title = $notificationName; $vibrate = true; $sound = 'default'; $icon = 'push_appicon_29da38bf54'; $to_ids = "everyone"; $json = '{"badge":"1","alert":"' . $message . '","title":"' . $title . '","vibrate":' . $vibrate . ',"sound":"' . $sound . '","icon": "' . $icon . '", "id":"' . $senderid . '" ,"name":"' . $displayname . '", "type":"chatbox"}'; if (!isset($_SESSION['cometchat']['pushNotificationSessionid'])) { loginPushNotification(); } /********************************** SEND PUSH **********************************/ $url = "https://api.cloud.appcelerator.com/v1/push_notification/notify.json?key=" . $key; $params = "channel=" . $channel . "&payload=" . $json . "&to_ids={$to_ids}"; $response = checkcURL(0, $url, $params, 1, $cookiefile); }
function postContent() { if (!($user = \Idno\Core\site()->session()->currentUser())) { $this->setResponse(403); echo 'You must be logged in to approve IndieAuth requests.'; exit; } $me = $this->getInput('me'); $client_id = $this->getInput('client_id'); $redirect_uri = $this->getInput('redirect_uri'); $state = $this->getInput('state'); $scope = $this->getInput('scope'); if (!empty($me) && parse_url($me, PHP_URL_HOST) == parse_url($user->getURL(), PHP_URL_HOST)) { $indieauth_codes = $user->indieauth_codes; if (empty($indieauth_codes)) { $indieauth_codes = array(); } $code = md5(rand(0, 99999) . time() . $user->getUUID() . $client_id . $state . rand(0, 999999)); $indieauth_codes[$code] = array('me' => $me, 'redirect_uri' => $redirect_uri, 'scope' => $scope, 'state' => $state, 'client_id' => $client_id, 'issued_at' => time(), 'nonce' => mt_rand(1000000, pow(2, 30))); $user->indieauth_codes = $indieauth_codes; $user->save(); if (strpos($redirect_uri, '?') === false) { $redirect_uri .= '?'; } else { $redirect_uri .= '&'; } $redirect_uri .= http_build_query(array('code' => $code, 'state' => $state, 'me' => $me)); $this->forward($redirect_uri); } }
function __construct($server, $path = false, $port = false, $timeout = 15) { if (!$path) { // Assume we have been given a URL instead $bits = parse_url($server); $this->scheme = $bits['scheme']; $this->server = $bits['host']; $this->port = isset($bits['port']) ? $bits['port'] : $port; $this->path = !empty($bits['path']) ? $bits['path'] : '/'; // Make absolutely sure we have a path if (!$this->path) { $this->path = '/'; } if (!empty($bits['query'])) { $this->path .= '?' . $bits['query']; } } else { $this->scheme = 'http'; $this->server = $server; $this->path = $path; $this->port = $port; } $this->useragent = 'The Incutio XML-RPC PHP Library'; $this->timeout = $timeout; }
/** * Add the S3 Authorization signature to the request headers * * @param string $method * @param string $path * @param array &$headers * @return string */ public function generateSignature($method, $path, &$headers) { if (!is_array($headers)) { $headers = array($headers); } $type = $md5 = $date = ''; // Search for the Content-type, Content-MD5 and Date headers foreach ($headers as $key => $val) { if (strcasecmp($key, 'content-type') == 0) { $type = $val; } else { if (strcasecmp($key, 'content-md5') == 0) { $md5 = $val; } else { if (strcasecmp($key, 'date') == 0) { $date = $val; } } } } // If we have an x-amz-date header, use that instead of the normal Date if (isset($headers['x-amz-date']) && isset($date)) { $date = ''; } $sig_str = "{$method}\n{$md5}\n{$type}\n{$date}\n"; // For x-amz- headers, combine like keys, lowercase them, sort them // alphabetically and remove excess spaces around values $amz_headers = array(); foreach ($headers as $key => $val) { $key = strtolower($key); if (substr($key, 0, 6) == 'x-amz-') { if (is_array($val)) { $amz_headers[$key] = $val; } else { $amz_headers[$key][] = preg_replace('/\\s+/', ' ', $val); } } } if (!empty($amz_headers)) { ksort($amz_headers); foreach ($amz_headers as $key => $val) { $sig_str .= $key . ':' . implode(',', $val) . "\n"; } } $sig_str .= '/' . parse_url($path, PHP_URL_PATH); if (strpos($path, '?location') !== false) { $sig_str .= '?location'; } else { if (strpos($path, '?acl') !== false) { $sig_str .= '?acl'; } else { if (strpos($path, '?torrent') !== false) { $sig_str .= '?torrent'; } } } $signature = base64_encode(Crypt\Hmac::compute($this->_secretKey, 'sha1', utf8_encode($sig_str), Crypt\Hmac::BINARY)); $headers['Authorization'] = 'AWS ' . $this->_accessKey . ':' . $signature; return $sig_str; }
protected function __construct($config) { if (count($config["db"]) != 4) { throw new \Exception("Le nombre d'arguments n'est pas valable!"); } spl_autoload_register(array(__CLASS__, 'autoload')); self::$config = $config; self::$database = new Core\Db\ConnectPDO(self::$config["db"]); self::$baseUrl = rtrim(dirname($_SERVER['PHP_SELF']), '/.\\'); $route = isset($_GET["r"]) ? $_GET["r"] : $_SERVER["REQUEST_URI"]; $url = parse_url($route); $path = preg_replace('/^' . preg_quote(self::$baseUrl, '/') . '\\//', "", $url["path"]); $query = @$url["query"]; $method = $_SERVER['REQUEST_METHOD']; $request = new Core\Http\Request($method, $path, $query); $dispatcher = new Core\Http\Dispatcher(); try { $dispatcher->handle($request); } catch (Exception $e) { $code = '404'; header($_SERVER["SERVER_PROTOCOL"] . " " . $code); $request = new Core\Http\Request('GET', 'Site/error', 'code=' . $code . '&message=' . $e->getMessage()); $dispatcher->handle($request); } }