22 preg_match(
'!<title([^>]*)>(.*?)<\/title>!is', $content, $buff);
23 return trim($buff[2]);
32 $content = preg_replace(
'!<title([^>]*)>(.*?)<\/title>!is',
'', $content);
34 $content = preg_replace(
'!<(\/){0,1}meta([^>]*)>!is',
'', $content);
36 preg_match_all(
'!<link([^>]*)>!is', $content, $link_buff);
37 for($i=0;$i<count($link_buff[0]);$i++)
39 $tmp_str = trim($link_buff[0][$i]);
40 if(!$tmp_str)
continue;
41 $header_script .= $tmp_str.
"\n";
44 preg_match_all(
'!<(style|script)(.*?)<\/(style|script)>!is', $content, $script_buff);
45 for($i=0;$i<count($script_buff[0]);$i++)
47 $tmp_str = trim($script_buff[0][$i]);
48 if(!$tmp_str)
continue;
49 $header_script .= $tmp_str.
"\n";
52 return $header_script;
61 preg_match(
'!<body([^>]*)>(.*?)<\/body>!is', $content, $body_buff);
62 $body_script = $body_buff[2];
64 $body_script = preg_replace(
'!<link([^>]*)>!is',
'', $body_script);
65 $body_script = preg_replace(
'!<(style|script)(.*?)<\/(style|script)>!is',
'', $body_script);
74 $url_info = parse_url($path);
75 $host = sprintf(
"%s://%s%s",$url_info[
'scheme'],$url_info[
'host'],$url_info[
'port']?
':'.$url_info[
'port']:
'');
76 $this->host = $host.
'/';
77 $path = $url_info[
'path'];
78 if(substr($path,-1)==
'/') $path = substr($path,-1);
79 $t = explode(
'/',$path);
81 for($i=0,$c=count($t)-1;$i<$c;$i++)
87 $path = $host.
'/'.implode(
'/',$_t);
88 if(substr($path,-1)!=
'/') $path .=
'/';
90 $content = preg_replace_callback(
'/(src=|href=|url\()("|\')?([^"\'\)]+)("|\'\))?/is',array($this,
'_replacePath'),$content);
97 $val = trim($matches[3]);
98 if(preg_match(
'/^(http|https|ftp|telnet|mms|mailto)/i',$val))
return $matches[0];
99 if(substr($val,0,2)==
'./')
101 $path = $this->path.substr($val,2);
103 elseif(substr($val,0,1)==
'/')
105 $path = $this->host.substr($val,1);
109 $path = $this->path.$val;
111 return sprintf(
"%s%s%s%s", $matches[1], $matches[2], $path, $matches[4]);
high class of the module page
replaceSrc($content, $path)
Change the value of src, href in the content.
getTitle($content)
Extract a title.
getHeadScript($content)
Extract header script.
getBodyScript($content)
Extract the contents of the body.