Example #1
0
function proxify_css($css)
{
    $css = proxify_inline_css($css);
    preg_match_all("#@import\\s*(?:\"([^\">]*)\"?|'([^'>]*)'?)([^;]*)(;|\$)#i", $css, $matches, PREG_SET_ORDER);
    for ($i = 0, $count = count($matches); $i < $count; ++$i) {
        $delim = '"';
        $url = $matches[$i][2];
        if (isset($matches[$i][3])) {
            $delim = "'";
            $url = $matches[$i][3];
        }
        $css = str_replace($matches[$i][0], '@import ' . $delim . proxify_css_url($matches[$i][1]) . $delim . (isset($matches[$i][4]) ? $matches[$i][4] : ''), $css);
    }
    return $css;
}
Example #2
0
 for ($i = 0, $count_i = count($matches); $i < $count_i; ++$i) {
     $_response_body = str_replace($matches[$i][0], $matches[$i][1] . proxify_css($matches[$i][2]) . $matches[$i][3], $_response_body);
 }
 preg_match_all("#<\\s*([a-zA-Z\\?-]+)([^>]+)>#S", $_response_body, $matches);
 for ($i = 0, $count_i = count($matches[0]); $i < $count_i; ++$i) {
     if (!preg_match_all("#([a-zA-Z\\-\\/]+)\\s*(?:=\\s*(?:\"([^\">]*)\"?|'([^'>]*)'?|([^'\"\\s]*)))?#S", $matches[2][$i], $m, PREG_SET_ORDER)) {
         continue;
     }
     $rebuild = false;
     $extra_html = $temp = '';
     $attrs = array();
     for ($j = 0, $count_j = count($m); $j < $count_j; $attrs[strtolower($m[$j][1])] = isset($m[$j][4]) ? $m[$j][4] : (isset($m[$j][3]) ? $m[$j][3] : (isset($m[$j][2]) ? $m[$j][2] : false)), ++$j) {
     }
     if (isset($attrs['style'])) {
         $rebuild = true;
         $attrs['style'] = proxify_inline_css($attrs['style']);
     }
     $tag = strtolower($matches[1][$i]);
     if (isset($tags[$tag])) {
         switch ($tag) {
             case 'a':
                 if (isset($attrs['href'])) {
                     $rebuild = true;
                     $attrs['href'] = complete_url($attrs['href']);
                 }
                 break;
             case 'img':
                 if (isset($attrs['src'])) {
                     $rebuild = true;
                     $attrs['src'] = complete_url($attrs['src']);
                 }