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


PHP Func::isWhatBlog方法代码示例

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


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

示例1: getRemoteFeed

		function getRemoteFeed($url, $depth=0) {
			global $db;
			if($depth>3) {
				return array(2, null, null);
			}
			requireComponent('LZ.PHP.HTTPRequest');
			$request = new HTTPRequest();
			$xml = $request->getPage($url);
			if (empty($xml)) {
				return array(2, null, null);
			}
			$feed = array('xmlURL' => $url);
			
			$encoding = '';
			if (preg_match('/^<\?xml[^<]*\s+encoding=["\']?([\w-]+)["\']?/', $xml, $matches))
				$encoding = $matches[1];
			if (strcasecmp($encoding, 'utf-8') != 0) {
				$xml = UTF8::bring($xml, $encoding);
				$xml = preg_replace('/^(<\?xml[^<]*\s+encoding=)["\']?[\w-]+["\']?/', '$1"utf-8"', $xml, 1);
			}

			if(preg_match_all('/<meta[ \t].*?http-equiv\s*=\s*[\'"]?refresh.*?>/i', $xml, $matches)) { // 야후코리아 때문 ..
				foreach($matches[0] as $link) {
					$attributes = func::getAttributesFromString($link);
					if (isset($attributes['content'])) {
						$attributes = explode(';', $attributes['content']);
						$contentURL = substr($attributes[1],4);
						if(substr($contentURL,0,7) == 'http://') {
							$url = $contentURL;
						} else {
							$url = func::unionAddress($url,$contentURL);
						}
						if(!empty($url)) {
							return Feed::getRemoteFeed($url, ++$depth);
						}
					}
				}
			}

			$xmls = new XMLStruct();
			if (!$xmls->open($xml)) {
				if(preg_match_all('/<link .*?rel\s*=\s*[\'"]?alternate.*?>/i', $xml, $matches)) {
					foreach($matches[0] as $link) {
						$attributes = func::getAttributesFromString($link);
						if (isset($attributes['href'])) {
							$urlInfo = parse_url($url);
							$rssInfo = parse_url($attributes['href']);
							$rssURL = false;
							if (isset($rssInfo['scheme']) && $rssInfo['scheme'] == 'http')
								$rssURL = $attributes['href'];
							else if (isset($rssInfo['path'])) {
								if ($rssInfo['path']{0} == '/')
									$rssURL = "{$urlInfo['scheme']}://{$urlInfo['host']}{$rssInfo['path']}";							
								else
									$rssURL = "{$urlInfo['scheme']}://{$urlInfo['host']}".(isset($urlInfo['path']) ? rtrim($urlInfo['path'], '/') : '').'/'.$rssInfo['path'];
							}
							if ($rssURL && $url != $rssURL)
								return Feed::getRemoteFeed($rssURL);
						}
					}
				}		
				return array(3, null, null);
			}

			$xmlType = '';
			$feed['blogTool'] = Func::isWhatBlog($url);
			if ($xmls->getAttribute('/rss', 'version')) {	
				$xmlType = 'rss';
				$feed['blogURL'] = $xmls->getValue('/rss/channel/link');
				$feed['title'] = $xmls->getValue('/rss/channel/title');
				$feed['description'] = $xmls->getValue('/rss/channel/description');
				if (Validator::language($xmls->getValue('/rss/channel/language')))
					$feed['language'] = $xmls->getValue('/rss/channel/language');
				else if (Validator::language($xmls->getValue('/rss/channel/dc:language')))
					$feed['language'] = $xmls->getValue('/rss/channel/dc:language');
				else
					$feed['language'] = 'en-US';
				$feed['modified'] = gmmktime();
				$feed['logo'] = $xmls->getValue('/rss/channel/image/url');
			} else if ($xmls->doesExist('/feed')) {
				$xmlType = 'atom';
				$feed['blogURL'] = $xmls->getAttribute('/feed/link', 'href');
				$feed['title'] = $xmls->getValue('/feed/title');
				if (!$feed['description'] = $xmls->getValue('/feed/tagline'))
					$feed['description'] = $xmls->getValue('/feed/subtitle');
				if (Validator::language($xmls->getAttribute('/feed', 'xml:lang')))
					$feed['language'] = $xmls->getAttribute('/feed', 'xml:lang');
				else
					$feed['language'] = 'en-US';
				$feed['modified'] = gmmktime();
			} else if ($xmls->getAttribute('/rdf:RDF', 'xmlns')) {
				$xmlType = 'rss';
				if ($xmls->getAttribute('/rdf:RDF/channel/link', 'href'))
					$feed['blogURL'] = $xmls->getAttribute('/rdf:RDF/channel/link', 'href');
				else if ($xmls->getValue('/rdf:RDF/channel/link'))
					$feed['blogURL'] = $xmls->getValue('/rdf:RDF/channel/link');
				else
					$feed['blogURL'] = '';
				$feed['title'] = $xmls->getValue('/rdf:RDF/channel/title');
				$feed['description'] = $xmls->getValue('/rdf:RDF/channel/description');
//.........这里部分代码省略.........
开发者ID:ncloud,项目名称:bloglounge,代码行数:101,代码来源:LZ.PHP.Feeder.php


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