mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 21:57:51 +02:00
parser and file-class fixes
This commit is contained in:
@@ -2403,25 +2403,41 @@ class e_parser
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an Array of all tags found in an HTML document.
|
* Return an Array of all specific tags found in an HTML document and their attributes.
|
||||||
* XXX Working on it currently.
|
* @param $html - raw html code
|
||||||
|
* @param $taglist - comma separated list of tags to search or '*' for all.
|
||||||
|
* @param $header - if the $html includes the <html> <head> or <body> tags - it should be set to true.
|
||||||
*/
|
*/
|
||||||
public function getTag($html, $tags)
|
public function getTags($html, $taglist='*', $header = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if($header == false)
|
||||||
|
{
|
||||||
|
$html = "<html><body>".$html."</body></html>";
|
||||||
|
}
|
||||||
|
|
||||||
$doc = $this->domObj;
|
$doc = $this->domObj;
|
||||||
|
|
||||||
$doc->loadHTML($html);
|
$doc->loadHTML($html);
|
||||||
|
|
||||||
$html = "<html><body>".$html."</body></html>";
|
$tg = explode(",", $taglist);
|
||||||
$doc = new DOMDocument();
|
$ret = array();
|
||||||
$doc->loadHTML($html);
|
|
||||||
|
|
||||||
$tmp = $doc->getElementsByTagName($tag);
|
foreach($tg as $find)
|
||||||
|
|
||||||
foreach($tmp as $k=>$tg)
|
|
||||||
{
|
{
|
||||||
$ret[$tag] = (string) $tg->getAttribute($att);
|
$tmp = $doc->getElementsByTagName($find);
|
||||||
|
|
||||||
|
foreach($tmp as $k=>$node)
|
||||||
|
{
|
||||||
|
$tag = $node->nodeName;
|
||||||
|
|
||||||
|
foreach ($node->attributes as $attr)
|
||||||
|
{
|
||||||
|
$name = $attr->nodeName;
|
||||||
|
$value = $attr->nodeValue;
|
||||||
|
$ret[$tag][$k][$name] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
@@ -269,6 +269,11 @@ class e_file
|
|||||||
{
|
{
|
||||||
$finfo = array();
|
$finfo = array();
|
||||||
|
|
||||||
|
if(filesize($path_to_file) < 2) // Don't try and read 0 byte files.
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if($imgcheck && ($tmp = getimagesize($path_to_file)))
|
if($imgcheck && ($tmp = getimagesize($path_to_file)))
|
||||||
{
|
{
|
||||||
$finfo['img-width'] = $tmp[0];
|
$finfo['img-width'] = $tmp[0];
|
||||||
@@ -300,7 +305,10 @@ class e_file
|
|||||||
$fp = fopen($path.$local_file, 'w'); // media-directory is the root.
|
$fp = fopen($path.$local_file, 'w'); // media-directory is the root.
|
||||||
|
|
||||||
$cp = curl_init($remote_url);
|
$cp = curl_init($remote_url);
|
||||||
curl_setopt($cp, CURLOPT_FILE, $fp);
|
curl_setopt($cp, CURLOPT_FILE, $fp);
|
||||||
|
curl_setopt($cp, CURLOPT_HEADER, 0);
|
||||||
|
curl_setopt($cp, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
|
||||||
|
curl_setopt($cp, CURLOPT_COOKIEFILE, e_SYSTEM.'cookies.txt');
|
||||||
|
|
||||||
$buffer = curl_exec($cp);
|
$buffer = curl_exec($cp);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user