function weldOverview2PNG($url_overview, $url_extent, $filename)
 {
     if (!$url_overview || $url_overview == "") {
         $e = new mb_exception("weldOverview2PNG: no maprequests delivered");
     }
     $url = $url_overview;
     $obj1 = new stripRequest($url);
     $width = $obj1->get("width");
     $height = $obj1->get("height");
     /*
     $e = new mb_exception("--------overview-----------------");
     $e = new mb_exception("-----width ".$width." / height: ".$height."--------------------");
     $e = new mb_exception("url_overview: ".$url_overview);
     $e = new mb_exception("url_extent: ".$url_extent);
     */
     $image = imagecreatetruecolor($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     ImageFilledRectangle($image, 0, 0, $width, $height, $white);
     //overview
     $obj = new stripRequest($url_overview);
     $xurl_overview = $obj->setPNG();
     $xurl_overview = $obj->encodeGET();
     $img = $this->loadpng($xurl_overview);
     if ($img != false) {
         imagecopy($image, $img, 0, 0, 0, 0, $width, $height);
     } else {
         $e = new mb_exception("weldMaps2PNG: unable to load image: " . $url_overview);
     }
     // rectangle - position of the map in the overview
     $objx = new stripRequest($url_extent);
     $ex_width = $objx->get("width");
     $ex_height = $objx->get("height");
     $extent = explode(",", $objx->get("BBOX"));
     $lowerleft = $this->makeRealWorld2mapPos($url_overview, round($extent[0]), round($extent[1]));
     $upperright = $this->makeRealWorld2mapPos($url_overview, $extent[2], $extent[3]);
     /*
     $e = new mb_exception("ex_width: " .$ex_width);
     $e = new mb_exception("ex_height: " . $ex_height);
     $e = new mb_exception("bbox:".$extent[0]."--".$extent[1]."--".$extent[2]."--------".$extent[3]);
     $e = new mb_exception("ll: " . $lowerleft[0]." / ".$lowerleft[1]);
     $e = new mb_exception("ur: " . $upperright[0]." / ".$upperright[1]);
     */
     $lowerleft[0] = round($lowerleft[0]);
     $lowerleft[1] = round($lowerleft[1]);
     $upperright[0] = round($upperright[0]);
     $upperright[1] = round($upperright[1]);
     $red = ImageColorAllocate($image, 255, 0, 0);
     imageline($image, $lowerleft[0], $upperright[1], $upperright[0], $upperright[1], $red);
     imageline($image, $upperright[0], $upperright[1], $upperright[0], $lowerleft[1], $red);
     imageline($image, $upperright[0], $lowerleft[1], $lowerleft[0], $lowerleft[1], $red);
     imageline($image, $lowerleft[0], $lowerleft[1], $lowerleft[0], $upperright[1], $red);
     // black frame - size of the overview
     $black = ImageColorAllocate($image, 0, 0, 0);
     imageline($image, 0, 0, $width - 1, 0, $black);
     imageline($image, $width - 1, 0, $width - 1, $height - 1, $black);
     imageline($image, $width - 1, $height - 1, 0, $height - 1, $black);
     imageline($image, 0, $height - 1, 0, 0, $black);
     imagepng($image, $filename);
     imagedestroy($image);
 }
 function weldMaps2PNG($urls, $filename, $encode = true)
 {
     if (!$urls || $urls == "") {
         $e = new mb_exception("weldMaps2PNG: no maprequests delivered");
     }
     $url = explode("___", $urls);
     $obj1 = new stripRequest($url[0]);
     $width = $obj1->get("width");
     $height = $obj1->get("height");
     $image = imagecreatetruecolor($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     ImageFilledRectangle($image, 0, 0, $width, $height, $white);
     for ($i = 0; $i < count($url); $i++) {
         $obj = new stripRequest($url[$i]);
         $url[$i] = $obj->setPNG();
         $url[$i] = $obj->encodeGET($encode);
         $img = $this->loadpng($url[$i]);
         if ($img != false) {
             imagecopy($image, $img, 0, 0, 0, 0, $width, $height);
             @imagedestroy($img);
         } else {
             $e = new mb_exception("weldMaps2PNG: unable to load image: " . $url[$i]);
         }
     }
     imagepng($image, $filename);
     imagedestroy($image);
 }
 /**
  * Constructor, assumes you pass over two parameters: the first is a string with
  * different maprequests, each seperated by three underscores (___).
  *
  * Iteratively calls a method to generate temporary images which are welded together at once.
  * The generated image is saved to the filesystem under the name
  * passed over as second parameter to the constructor.
  *
  * @param <string> the maprequests seperated by three underscores
  */
 function weldMaps2PNG($urls, $filename)
 {
     if (!$urls || $urls == "") {
         $e = new mb_exception("weldMaps2PNG: no maprequests delivered");
     }
     // getting the array of urls
     $url = explode("___", $urls);
     // make url parameters accessible
     $obj1 = new stripRequest($url[0]);
     $width = $obj1->get("width");
     $height = $obj1->get("height");
     // create output image
     $image = imagecreatetruecolor($width, $height);
     // assign a white background color
     $white = ImageColorAllocate($image, 255, 255, 255);
     ImageFilledRectangle($image, 0, 0, $width, $height, $white);
     // iterate over each request
     for ($i = 0; $i < count($url); $i++) {
         $obj = new stripRequest($url[$i]);
         //            $url[$i] = $obj->setPNG();
         $url[$i] = $obj->encodeGET();
         // get temporary image for this URL
         $img = $this->loadpng($url[$i]);
         if ($img != false) {
             // copy temporary image over already assigned images
             imagecopy($image, $img, 0, 0, 0, 0, $width, $height);
             imagedestroy($img);
         } else {
             $e = new mb_exception("weldMaps2PNG: unable to copy image: " . $url[$i]);
         }
     }
     // output the image to the filesystem
     /**
      * @todo different outputs?
      */
     imagepng($image, $filename);
     imagedestroy($image);
 }
 function getImage($imageTyp_imp, $outputKind = '')
 {
     $imageTyp = "";
     $imageTyp = $imageTyp_imp;
     if ($imageTyp == 'jpg') {
         $imageTyp = 'jpeg';
     }
     if (!$this->urls || $this->urls == "") {
         $e = new mb_exception("weldMaps2Image: no maprequests delivered");
     }
     $obj1 = new stripRequest($this->urls[0]);
     $width = $obj1->get("width");
     $height = $obj1->get("height");
     $wms_srs = $obj1->get("srs");
     $wms_bbox = $obj1->get("bbox");
     $wms_format = $obj1->getFormat();
     $image = imagecreatetruecolor($width, $height);
     $white = ImageColorAllocate($image, 255, 255, 255);
     ImageFilledRectangle($image, 0, 0, $width, $height, $white);
     for ($i = 0; $i < count($this->urls); $i++) {
         $obj = new stripRequest($this->urls[$i]);
         if ($imageTyp == 'geotiff') {
             $this->urls[$i] = $obj->setFormat($wms_format);
         } else {
             $this->urls[$i] = $obj->setFormat($imageTyp);
         }
         $this->urls[$i] = $obj->encodeGET();
         $img = $this->loadImage($this->urls[$i]);
         if ($img != false) {
             imagecopy($image, $img, 0, 0, 0, 0, $width, $height);
         } else {
             $e = new mb_exception("weldMaps2Image: unable to load image: " . $this->urls[$i]);
         }
     }
     $filename = $this->array_file['dir'] . "/";
     $timestamp = time();
     $filenameOnly = $this->array_file['filename'] . md5($timestamp);
     if ($imageTyp == 'png') {
         $filenameOnly .= '.png';
         $filename .= $filenameOnly;
         imagepng($image, $filename);
         $this->downloadLink($filenameOnly);
     } else {
         if ($imageTyp == 'jpeg') {
             $filenameOnly .= '.jpeg';
             $filename .= $filenameOnly;
             imagejpeg($image, $filename);
             $this->downloadLink($filenameOnly);
         } else {
             if ($imageTyp == 'geotiff') {
                 $filenameOnly .= '.' . $wms_format;
                 $filename .= $filenameOnly;
                 if ($wms_format == 'png') {
                     imagepng($image, $filename);
                 } else {
                     if ($wms_format == 'jpeg') {
                         imagejpeg($image, $filename);
                     } else {
                         $e = new mb_exception("weldMaps2Image: unable to generate temp-Image for getiff: " . $filename);
                     }
                 }
                 // gdal_translate...
                 $wms_bbox = str_replace(',', ' ', $wms_bbox);
                 $filename_tif = str_replace($wms_format, 'tif', $filenameOnly);
                 $tmp_dir = $this->array_file['dir'] . "/";
                 $array_bbox = explode(" ", $wms_bbox);
                 $wms_bbox = $array_bbox[0] . " " . $array_bbox[3] . " " . $array_bbox[2] . " " . $array_bbox[1];
                 /*
                  * @security_patch exec done
                  * Added escapeshellcmd()
                  */
                 $cmd = "gdal_translate -a_srs " . $wms_srs . " -a_ullr " . $wms_bbox . " " . $tmp_dir . $filenameOnly . " " . $tmp_dir . $filename_tif;
                 exec(escapeshellcmd($cmd));
                 $this->downloadLink($filename_tif);
             } else {
             }
         }
     }
 }
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once dirname(__FILE__) . "/../php/mb_validateSession.php";
require_once dirname(__FILE__) . "/../classes/class_stripRequest.php";
require_once dirname(__FILE__) . "/../classes/class_connector.php";
if ($_GET["url"]) {
    $mr = new stripRequest(urldecode($_GET["url"]));
} else {
    $mr = new stripRequest($_POST["url"]);
}
$nmr = $mr->encodeGET();
$isOwsproxyRequest = mb_strpos($nmr, OWSPROXY) === 0;
if ($isOwsproxyRequest) {
    header("Location: " . $nmr);
} else {
    $x = new connector($nmr);
    if (empty($x->file)) {
        //close window if featureInfo has no result
        //echo "<body onLoad=\"javascript:window.close()\">";
        echo "";
    } else {
        // Uebergabe von MB Nutzername/Passwort fuer ALB-Auskunft - rw.
        $pattern = "/(.*?)(name\\s?=\\s?[\"|\\']usr[\"|\\'] \\s*value\\s?=\\s?[\"|\\'][a-zA-Z0-9_*]+[\"|\\'])(.*?)/";
        $content = $x->file;
        $newString = "\$1 name='usr' value='" . $_SESSION['mb_user_name'] . "'\$3";
        $content = preg_replace($pattern, $newString, $content);