diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index cd62aaa78..20999b85b 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -2403,25 +2403,41 @@ class e_parser /** - * Return an Array of all tags found in an HTML document. - * XXX Working on it currently. + * Return an Array of all specific tags found in an HTML document and their attributes. + * @param $html - raw html code + * @param $taglist - comma separated list of tags to search or '*' for all. + * @param $header - if the $html includes the or tags - it should be set to true. */ - public function getTag($html, $tags) + public function getTags($html, $taglist='*', $header = false) { - $doc = $this->domObj; - - $doc->loadHTML($html); - - $html = "".$html.""; - $doc = new DOMDocument(); - $doc->loadHTML($html); - - $tmp = $doc->getElementsByTagName($tag); - foreach($tmp as $k=>$tg) + if($header == false) { - $ret[$tag] = (string) $tg->getAttribute($att); + $html = "".$html.""; + } + + $doc = $this->domObj; + + $doc->loadHTML($html); + + $tg = explode(",", $taglist); + $ret = array(); + + foreach($tg as $find) + { + $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; diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php index d87d36083..089e55250 100644 --- a/e107_handlers/file_class.php +++ b/e107_handlers/file_class.php @@ -268,6 +268,11 @@ class e_file function get_file_info($path_to_file, $imgcheck = true) { $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))) { @@ -300,8 +305,11 @@ class e_file $fp = fopen($path.$local_file, 'w'); // media-directory is the root. $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); curl_close($cp);