<?php

    $url=$_GET['url'];

    if($url==""){

        $url='http://idegeo.geoint.mx/ms/territoriospeninsula';

        $page_O = file_get_contents($url);
        $page_O_C = str_replace('="/', '="'.parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).'/', $page_O);
        $page_O_C_C = str_replace('url(/', 'url('.parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).'/', $page_O_C);

        $page_O_C_C = str_replace('http://idegeo.geoint.mx/ms/territoriospeninsula/category/', 'http://mid.geoint.mx/downloads/sse.php?url=http://idegeo.geoint.mx/ms/territoriospeninsula/category/', $page_O_C_C);
        $page_O_C_C = str_replace('http://idegeo.geoint.mx//fonts', '//fonts', $page_O_C_C);
        
        $page_O_C_C_E = explode("<!-- main -->", $page_O_C_C);
        $page_O_C_C_E_E = explode("<!-- section -->", $page_O_C_C_E[1]);

            echo $page_O_C_C_E_E[0];

    }else if (strpos($url, 'category') !== false){

        $page_O = file_get_contents($url);
        $page_O_C = str_replace('="/', '="'.parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).'/', $page_O);
        $page_O_C_C = str_replace('url(/', 'url('.parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).'/', $page_O_C);

        //$page_O_C_C = str_replace('http://idegeo.geoint.mx/ms/territoriospeninsula/narrative/', 'http://mid.geoint.mx/downloads/sse.php?url=http://idegeo.geoint.mx/ms/territoriospeninsula/narrative/', $page_O_C_C);
            $page_O_C_C = str_replace('href="http://idegeo.geoint.mx/ms/territoriospeninsula/narrative/', 'target= href="http://idegeo.geoint.mx/ms/territoriospeninsula/narrative/', $page_O_C_C);
            $page_O_C_C = str_replace('target=', 'target="_blank"', $page_O_C_C);
        $page_O_C_C = str_replace('http://idegeo.geoint.mx//fonts', '//fonts', $page_O_C_C);

        $page_O_C_C_E = explode('<div id="main-content">', $page_O_C_C);
        $page_O_C_C_E_E = explode("<!--end builder template-->", $page_O_C_C_E[1]);

            echo '<div id="main-content">';
            echo $page_O_C_C_E_E[0];

    }else if (strpos($url, 'narrative') !== false){


        $page_O = file_get_contents($url);
        $page_O_C = str_replace('="/', '="'.parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).'/', $page_O);
        $page_O_C_C = str_replace('url(/', 'url('.parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).'/', $page_O_C);

        $page_O_C_C = str_replace('http://idegeo.geoint.mx//fonts', '//fonts', $page_O_C_C);


        $page_O_C_C = str_replace('<section id="admin" style="', '<section id="admin" style="display:none;', $page_O_C_C);

        
        echo $page_O_C_C;


    }

?>