Ejemplo n.º 1
0
Archivo: tri.php Proyecto: philum/cms
function interpret_html($v, $X)
{
    $aa = strpos($v, "<");
    $ab = strpos($v, ">");
    //aa_balise
    if ($aa !== false && $ab !== false && $ab > $aa) {
        $before = substr($v, 0, $aa);
        //...<
        $aa_inner = ecart($v, $aa, $ab);
        //<...>
        $aa_end = strpos($aa_inner, " ");
        if ($aa_end !== false) {
            $aa_balise = substr($aa_inner, 0, $aa_end);
        } else {
            $aa_balise = $aa_inner;
        }
    }
    //else $before=$v;
    $ba = strpos($v, '</' . $aa_balise, $ab);
    $bb = strpos($v, ">", $ba);
    //bb_balise
    if ($ba !== false && $bb !== false && $aa_balise != "" && $bb > $ba) {
        $ba = recursearch($v, $ab, $ba, $aa_balise);
        //recursearch
        $bb = strpos($v, ">", $ba);
        $bb_balise = ecart($v, $ba, $bb);
        $balise = ecart($v, $ab, $ba);
    } elseif ($ab !== false) {
        $bb = $ab;
    } else {
        $bb = -1;
    }
    $after = substr($v, $bb + 1);
    //>...
    //ok,go
    $aa_balise = strtolower($aa_balise);
    $bb_balise = strtolower($bb_balise);
    if ($aa_balise == "head" or $aa_balise == "style" or $aa_balise == "script") {
        $balise = "";
    }
    if ($_POST["see"]) {
        static $i;
        $i++;
        echo $i . ' :: ' . $aa_balise . '=>' . $bb_balise . ' - ';
    }
    //itération
    if (strpos($balise, '<') !== false) {
        $balise = interpret_html($balise, $X);
    }
    //""//100909
    if ($X != "ok") {
        //else interdit l'imbrication
        if ($aa_balise == 'pagespeed_iframe') {
            $aa_balise = 'iframe';
        }
        //patch
        $ret = balise_converter($aa_balise, $aa_inner, $bb_balise, $balise);
        if ($ret[1] == $balise) {
            $ret[1] = balise_converter_style($balise, $aa_inner);
        } else {
            $balise = $ret[1];
        }
        $taga .= $ret[0];
        $tagb .= $ret[2];
    }
    //sequential
    if (strpos($after, '<') !== false) {
        $after = interpret_html($after, $X);
    }
    $ret = $before . $taga . $balise . $tagb . $after;
    return $ret;
}
Ejemplo n.º 2
0
Archivo: parse.php Proyecto: philum/cms
function interpret_xml($v)
{
    static $i;
    $i++;
    //static $ret;
    $aa = strpos($v, "<");
    $ab = strpos($v, ">");
    //aa_balise
    if ($aa !== false && $ab !== false && $ab > $aa) {
        $before = substr($v, 0, $aa);
        //...< //htmlentities
        $aa_inner = ecart($v, $aa, $ab);
        //<...>
        $aa_end = strpos($aa_inner, " ");
        if ($aa_end !== false) {
            $aa_balise = substr($aa_inner, 0, $aa_end);
        } else {
            $aa_balise = $aa_inner;
        }
    }
    $ba = strpos($v, '</' . $aa_balise, $ab);
    $bb = strpos($v, ">", $ba);
    //bb_balise
    if ($ba !== false && $bb !== false && $aa_balise != "" && $bb > $ba) {
        $ba = recursearch($v, $ab, $ba, $aa_balise);
        //recursearch
        $bb = strpos($v, ">", $ba);
        if ($bb) {
            $bb_balise = ecart($v, $ba, $bb);
        }
        $balise = ecart($v, $ab, $ba);
    } elseif ($ab !== false) {
        $bb = $ab;
    } else {
        $bb = -1;
    }
    $after = substr($v, $bb + 1);
    //>...
    //ok,go
    $ia = $i;
    $aa_balise = strtolower($aa_balise);
    $bb_balise = strtolower($bb_balise);
    $ret[$ia]['balise'] = $aa_balise;
    $attrb = mk_attrb($aa_inner, ' ', '=');
    if ($attrb) {
        $ret[$ia]['props'] = $attrb;
    }
    //itération
    if (strpos($balise, '<') !== false) {
        $balise = interpret_xml($balise);
    }
    if ($balise) {
        $ret[$ia]['content'] = $balise;
    }
    //sequence
    if (strpos($after, '<') !== false) {
        $retb = interpret_xml($after);
    }
    if ($retb) {
        $ret = array_merge_b($ret, $retb);
    }
    return $ret;
}