html.func.php 2.15 KB
<?php
// PHP xml sitemap generator

// this function returns an array containg all emails in the page
function parseEMails($source) {
        $rows = array();
        $ne = preg_match_all("#([_A-Za-z0-9+-+]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#", $source, $res);
        $rows = array_unique($res[0]);
        return $rows;
}

// this function returns a string containing the value of the field of an html tag
function getTagField($tag, $fieldname) {
        $field = "";
        $ttag = substr($tag, 1, strpos($tag, '>') - 1);
        if(($pos = strposi($ttag, $fieldname)) > 0) {
                $tmpfield = substr($ttag, $pos + strlen($fieldname));
                if($tmpfield[0] == '"' || $tmpfield[0] == "'") {
                        if($tmpfield[0] == '"') {
                                $tmpfield = substr($tmpfield, 1);
                                $field = substr($tmpfield, 0, strpos($tmpfield, '"'));
                        }
                        if($tmpfield[0] == "'") {
                                $tmpfield = substr($tmpfield, 1);
                                $field = substr($tmpfield, 0, strpos($tmpfield, "'"));
                        }
                }
                else {
                        if(strpos($tmpfield, ' ') > 0)
                                $field = substr($tmpfield, 0, strpos($tmpfield, ' '));
                        else
                                $field = $tmpfield;
                }
        }
        return $field;
}

// this function returns an array of strings starting with $start and ending with $end
function getTags($source, $start, $end) {
        $tmp = $source;
        for($i = 0; strlen($tmp) > 0; $i++) {
                if(($postagst = strposi($tmp, $start)) == false)
                        break;
                $tmp = substr($tmp, $postagst);
                $postagend = strposi($tmp, $end);
                if($postagend > 0)
                        $tags[$i] = substr($tmp, 0, $postagend + strlen($end));
                else {
                        $tags[$i] = $tmp;
                }
                $tmp = substr($tmp, strlen($tags[$i]));
        }
        return $tags;
}

?>