<?php
/**
* Website: http://sourceforge.net/projects/simplehtmldom/
* Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/)
* Contributions by:
* Yousuke Kumakura (Attribute filters)
* Vadim Voituk (Negative indexes supports of "find" method)
* Antcs (Constructor with automatically load contents either text or file/url)
*
* all affected sections have comments starting with "PaperG"
*
* Paperg - Added case insensitive testing of the value of the selector.
* Paperg - Added tag_start for the starting index of tags - NOTE: This works but not accurately.
* This tag_start gets counted AFTER \r\n have been crushed out, and after the remove_noice calls so it will not reflect the REAL position of the tag in the source,
* it will almost always be smaller by some amount.
* We use this to determine how far into the file the tag in question is. This "percentage will never be accurate as the $dom->size is the "real" number of bytes the dom was created from.
* but for most purposes, it's a really good estimation.
* Paperg - Added the forceTagsClosed to the dom constructor. Forcing tags closed is great for malformed html, but it CAN lead to parsing errors.
* Allow the user to tell us how much they trust the html.
* Paperg add the text and plaintext to the selectors for the find syntax. plaintext implies text in the innertext of a node. text implies that the tag is a text node.
* This allows for us to find tags based on the text they contain.
* Create find_ancestor_tag to see if a tag is - at any level - inside of another specific tag.
* Paperg: added parse_charset so that we know about the character set of the source document.
* NOTE: If the user's system has a routine called get_last_retrieve_url_contents_content_type availalbe, we will assume it's returning the content-type header from the
* last transfer or curl_exec, and we will parse that and use it in preference to any other method of charset detection.
*
* Found infinite loop in the case of broken html in restore_noise. Rewrote to protect from that.
* PaperG (John Schlick) Added get_display_size for "IMG" tags.
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @author S.C. Chen <me578022@gmail.com>
* @author John Schlick
* @author Rus Carroll
* @version 1.5 ($Rev: 196 $)
* @package PlaceLocalInclude
* @subpackage simple_html_dom
*/
/**
* All of the Defines for the classes below.
* @author S.C. Chen <me578022@gmail.com>
*/
define('HDOM_TYPE_ELEMENT', 1);
define('HDOM_TYPE_COMMENT', 2);
define('HDOM_TYPE_TEXT', 3);
define('HDOM_TYPE_ENDTAG', 4);
define('HDOM_TYPE_ROOT', 5);
define('HDOM_TYPE_UNKNOWN', 6);
define('HDOM_QUOTE_DOUBLE', 0);
define('HDOM_QUOTE_SINGLE', 1);
define('HDOM_QUOTE_NO', 3);
define('HDOM_INFO_BEGIN', 0);
define('HDOM_INFO_END', 1);
define('HDOM_INFO_QUOTE', 2);
define('HDOM_INFO_SPACE', 3);
define('HDOM_INFO_TEXT', 4);
define('HDOM_INFO_INNER', 5);
define('HDOM_INFO_OUTER', 6);
define('HDOM_INFO_ENDSPACE',7);
define('DEFAULT_TARGET_CHARSET', 'UTF-8');
define('DEFAULT_BR_TEXT', "\r\n");
define('DEFAULT_SPAN_TEXT', " ");
if (!defined('MAX_FILE_SIZE')) {
define('MAX_FILE_SIZE', 600000);
}
// helper functions
// -----------------------------------------------------------------------------
// get html dom from file
// $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
{
// We DO force the tags to be terminated.
$dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
do {
$repeat = false;
if ($context!==NULL)
{
// Test if "Accept-Encoding: gzip" has been set in $context
$params = stream_context_get_params($context);
if (isset($params['options']['http']['header']) && preg_match('/gzip/', $params['options']['http']['header']) !== false)
{
$contents = file_get_contents('compress.zlib://'.$url, $use_include_path, $context, $offset);
}
else
{
$contents = file_get_contents($url, $use_include_path, $context, $offset);
}
}
else
{
$contents = file_get_contents($url, $use_include_path, NULL, $offset);
}
// test if the URL doesn't return a 200 status
if (isset($http_response_header) && strpos($http_response_header[0], '200') === false) {
// has a 301 redirect header been sent?
$pattern = "/^Location:\s*(.*)$/i";
$location_headers = preg_grep($pattern, $http_response_header);
if (!empty($location_headers) && preg_match($pattern, array_values($location_headers)[0], $matches)) {
// set the URL to that returned via the redirect header and repeat this loop
$url = $matches[1];
$repeat = true;
}
}
} while ($repeat);
// stop processing if the header isn't a good responce
if (isset($http_response_header) && strpos($http_response_header[0], '200') === false)
{
return false;
}
// stop processing if the contents are too big
if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
{
return false;
}
// The second parameter can force the selectors to all be lowercase.
$dom->load($contents, $lowercase, $stripRN);
return $dom;
}
// get html dom from string
function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
{
$dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
if (empty($str) || strlen($str) > MAX_FILE_SIZE)
{
$dom->clear();
return false;
}
$dom->load($str, $lowercase, $stripRN);
return $dom;
}
// dump html dom tree
function dump_html_tree($node, $show_attr=true, $deep=0)
{
$node->dump($node);
}
/**
* simple html dom node
* PaperG - added ability for "find" routine to lowercase the value of the selector.
* PaperG - added $tag_start to track the start position of the tag in the total byte index
*
* @package PlaceLocalInclude
*/
class simple_html_dom_node
{
public $nodetype = HDOM_TYPE_TEXT;
public $tag = 'text';
public $attr = array();
public $children = array();
public $nodes = array();
public $parent = null;
// The "info" array - see HDOM_INFO_... for what each element contains.
public $_ = array();
public $tag_start = 0;
private $dom = null;
function __construct($dom)
{
$this->dom = $dom;
$dom->nodes[] = $this;
}
function __destruct()
{
$this->clear();
}
function __toString()
{
return $this->outertext();
}
// clean up memory due to php5 circular references memory leak...
function clear()
{
$this->dom = null;
$this->nodes = null;
$this->parent = null;
$this->children = null;
}
// dump node's tree
function dump($show_attr=true, $deep=0)
{
$lead = str_repeat(' ', $deep);
echo $lead.$this->tag;
if ($show_attr && count($this->attr)>0)
{
echo '(';
foreach ($this->attr as $k=>$v)
echo "[$k]=>\"".$this->$k.'", ';
echo ')';
}
echo "\n";
if ($this->nodes)
{
foreach ($this->nodes as $c)
{
$c->dump($show_attr, $deep+1);
}
}
}
// Debugging function to dump a single dom node with a bunch of information about it.
function dump_node($echo=true)
{
$string = $this->tag;
if (count($this->attr)>0)
{
$s
没有合适的资源?快使用搜索试试~ 我知道了~
多功能自适应影视源码+自动采集+虚拟主机也能用
共1293个文件
gif:437个
png:271个
js:210个
需积分: 10 1 下载量 105 浏览量
2022-04-19
00:09:29
上传
评论
收藏 19.62MB ZIP 举报
温馨提示
运行环境:数据库+伪静态,。 自适应PC+WEB,。 带后台,后台地址:你的域名/admin/,。 语言:php,。 php版本:4.6以上的语言,。 其他语言:html+css+js等语言,。 注意事项:要把index.php,index.html,index.htm设为网站首页。 已修复部分问题。 SEO优化处理。
资源详情
资源评论
资源推荐
收起资源包目录
多功能自适应影视源码+自动采集+虚拟主机也能用 (1293个子文件)
web.config 8KB
web.config 8KB
bootstrap.min.css 135KB
layui.css 68KB
layui.css 68KB
iconfont.css 45KB
DPlayer.min.css 45KB
ueditor.css 44KB
ueditor.min.css 34KB
mytheme-ui.css 32KB
layui.css 31KB
mytheme-font.css 30KB
admin.css 22KB
default.css 21KB
video-js.css 21KB
image.css 19KB
video.css 15KB
attachment.css 15KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
video-js.min.css 11KB
index.css 11KB
layui.mobile.css 10KB
layui.mobile.css 10KB
base.css 10KB
mytheme-site.css 9KB
mytheme-site1.css 9KB
reg_style.css 9KB
admin.css 8KB
reg_style.css 8KB
laydate.css 8KB
layui.mobile.css 8KB
install.css 8KB
laydate.css 7KB
laydate.css 7KB
shCoreDefault.css 7KB
mytheme-color.css 7KB
mytheme-color3.css 7KB
mytheme-color2.css 7KB
mytheme-color1.css 6KB
layer.css 5KB
layer.css 5KB
layer.css 5KB
layer.css 5KB
cropper.css 5KB
mytheme-color2.css 4KB
mytheme-color1.css 4KB
mytheme-color1.css 4KB
mytheme-color2.css 4KB
mytheme-color3.css 4KB
mytheme-color3.css 4KB
mytheme-color.css 4KB
mytheme-color.css 4KB
install2.css 4KB
iconfont.css 4KB
scrawl.css 4KB
qq.css 3KB
codemirror.css 3KB
charts.css 3KB
background.css 2KB
tb-box.css 2KB
simple.css 2KB
jquery.Jcrop.min.css 2KB
emotion.css 2KB
dialogbase.css 2KB
style.css 2KB
music.css 2KB
mytheme-share.css 2KB
font.css 1KB
edittable.css 1KB
code.css 1KB
code.css 1KB
code.css 1KB
template.css 1KB
prettify.css 973B
qwss.css 766B
webuploader.css 515B
hlstyle.css 491B
webuploader.css 447B
help.css 395B
iframe.css 42B
fontawesome-webfont.eot 162KB
fontawesome-webfont.eot 162KB
iconfont.eot 52KB
iconfont.eot 40KB
iconfont.eot 40KB
iconfont.eot 34KB
iconfont.eot 23KB
iconfont.eot 23KB
icomoon.eot 7KB
iconfont.eot 5KB
vjs.eot 3KB
UEditorSnapscreen.exe 508KB
fdfe381d5b404897b3e36a198a24c4c0 12KB
Zza9TH.gif 1.53MB
ZzaitA.gif 1.17MB
共 1293 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
qq_35373754
- 粉丝: 17
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0