MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /var/www/html/pathumthani_integration/pathumthani_drug/plugins/content/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/pathumthani_integration/pathumthani_drug/plugins/content/googleMaps.lib.php
<?php
/**
* googleMaps.lib
* allows you to include one or more google maps
* right inside Joomla content item or article
* Author: kksou
* Copyright (C) 2006-2008. kksou.com. All Rights Reserved
* Website: http://www.kksou.com/php-gtk2
* v1.5 April 16, 2009
* v1.51 April 30, 2009 added support for mod_googleMaps
* v1.52 May 3, 2009 improved javascript
* v1.53 May 9, 2009 added support for kml files
* v1.54 May 10, 2009 added map control and map type
* v1.55 May 11, 2009 added support for hl and width=100%
* v1.56 May 14, 2009 support for IE; added marker=0
* v1.57 May 21, 2009 added GOverviewMapControl, GScaleControl, GoogleBar
* #map{ overflow:hidden } - prevent Google's copyright tet to flow out of a small map
* v1.58 May 26, 2009 added support for multiple controls
* v1.59 May 27, 2009 streamline entire code for use with googleDirections
added a geodecoder so that user can now specify address instead of latitude and longitude
* v.1.5.10 May 28, 2009 commented $js_var
*/

class Plugin_googleMaps_base {
	function init_google_maps($row, $pluginParams, $is_mod) {
		$param_list = array('api_key', 'width', 'height', 'zoom');
		foreach($param_list as $var) {
			$this->$var = $pluginParams->$var;
		}

		#$regex = "/\{".$this->tag."\s*(.*?)\}/is";
		$regex = "/\{".$this->tag."\s+(.*?)\}/is";
		$contents = $row->text;
		if (preg_match_all( $regex, $contents, $matches, PREG_SET_ORDER )) {
			$count = count( $matches[0] );
			if ($count==0) return true;

			$map_id = 0;
			$is_mod2 = '_plugin';
			$GET_var = "mod_{$this->tag}_id";
			if ($is_mod) {
					if (!isset($_GET[$GET_var]))
					$_GET[$GET_var] = 131;
				$is_mod2 = '_mod';
			}

			$js_var = '';
			$js = '';
			$js2 = '';
			$this->lang = '';
			foreach($matches as $matches2) {
				if ($is_mod) {
					$map_id = $_GET[$GET_var]++;
				}
				#$var = $this->mod.'2'.$map_id;
				#$js_var .= "var {$var};";
				$js .= $this->process($row, $matches2, $map_id);
				#$js2 .= "$var.checkResize();\n";
				if (!$is_mod) ++$map_id;
			}

			$init_script = "<script type=\"text/javascript\">
$js_var
function load_{$this->mod}() {".$js.$js2."}
onload_{$this->mod}(load_{$this->mod});
window.onunload = GUnload;
</script>
";
			$row->text = preg_replace( $regex, '', $row->text );
			$codes = $this->js_lib();
			$codes .= $this->setup_css();
			$codes .= $this->setup_gmap();
			$row->text = $codes.$row->text;
			$row->text .= $init_script;
		}

		return true;
	}

	function process(&$row, $matches, $map_id) {
		$this->process_controls($row, $matches, $map_id);
		$this->process_params($row, $matches, $map_id);
		$js = $this->output_map($row, $matches, $map_id);
		return $js;
	}

	function process_controls(&$row, $matches, $map_id) {
		$this->lat = 0;
		$this->long = 0;
		$description = '';
		$this->startzoom = $this->zoom;
		$this->description = '';
		$this->width = $this->width;
		$this->height = $this->height;
		$this->control = '';
		$this->maptype = '';
		$this->kml = '';
		$this->marker = 1;
		$this->addscale = '';
		$this->addr = '';

		if (preg_match('/lat=([\+\-]?[0-9\.]+)/', $matches[1], $matches2)) $this->lat = $matches2[1];
		if (preg_match('/long=([\+\-]?[0-9\.]+)/', $matches[1], $matches2)) $this->long = $matches2[1];
		if (preg_match('/zoom=(\d+)/', $matches[1], $matches2)) $this->startzoom = $matches2[1];
		if (preg_match('/width=(\d+%?)/', $matches[1], $matches2)) $this->width = $matches2[1];
		if (preg_match('/height=(\d+)/', $matches[1], $matches2)) $this->height = $matches2[1];

		# added on 090510
		if (preg_match('/control=([^\s]+)/', $matches[1], $matches2)) $this->control = $matches2[1];
		if (preg_match('/maptype=([^\s]+)/', $matches[1], $matches2)) $this->maptype = $matches2[1];
		if (preg_match('/lang=([^\s]+)/', $matches[1], $matches2)) $this->lang = $matches2[1];
		if (preg_match('/marker=([^\s]+)/', $matches[1], $matches2)) $this->marker = $matches2[1];
		if (preg_match('/addoverview=([^\s]+)/', $matches[1], $matches2)) $this->addoverview = $matches2[1];
		if (preg_match('/addscale=([^\s]+)/', $matches[1], $matches2)) $this->addscale = $matches2[1];
		if (preg_match('/addgoogle=([^\s]+)/', $matches[1], $matches2)) $this->addgoogle = $matches2[1];

		# added on 090509
		if (preg_match('/kml=([^\s]+)/', $matches[1], $matches2)) $this->kml = $matches2[1];

		if (preg_match('/description="([^"]+)"/', $this->fix_str2($matches[1]), $matches2)) $description = $this->fix_str2($matches2[1]);
		if (preg_match('/label="([^"]+)"/', $this->fix_str2($matches[1]), $matches2)) $description = $this->fix_str2($matches2[1]);
		$description = $this->fix_str2($description);
		$description = str_replace('~', '<br />', $description);
		$description = str_replace("'", '\\'."'", $description);
		$description = str_replace("\r\n", "\n", $description);
		$description = str_replace("\n", '<br />', $description);
		$this->description = $description;

		# added on 090528
		if (preg_match('/addr="([^"]+)"/', $this->fix_str2($matches[1]), $matches2)) $this->addr = $this->fix_str2($matches2[1]);

		if ($this->startzoom<1 || $this->startzoom>18) $this->startzoom = 15;
		if ($this->height<10 || $this->height>4096) $this->height = 480;
	}

	function process_params(&$row, $matches, $map_id) {
	}

	function fix_str2($str) {
		#$str = str_replace('<br>', "\n", $str);
		#$str = str_replace('<br />', "\n", $str);
		#$str = str_replace('<p>', "\n", $str);
		#$str = str_replace('</p>', "\n", $str);
		$str = str_replace('&#39;', "'", $str);
		$str = str_replace('&quot;', '"', $str);
		$str = str_replace('&lt;', '<', $str);
		$str = str_replace('&gt;', '>', $str);
		$str = str_replace('&amp;', '&', $str);
		$str = str_replace('&nbsp;', ' ', $str);
		return $str;
	}

	function fix_str3($str) {
		$str = str_replace('~', '@', $str);
		$str = str_replace('<br>', " ", $str);
		$str = str_replace('<br />', " ", $str);
		$str = str_replace('<p>', " ", $str);
		$str = str_replace('</p>', " ", $str);
		$str = str_replace('&nbsp;', ' ', $str);
		$str = str_replace("\n", " ", $str);
		$str = str_replace("\r", "", $str);
		return $str;
	}

	function js_lib() {
		$js = "\n<script type=\"text/javascript\">
function onload_{$this->mod}(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {window.onload = func;} else {
    window.onload = function() {if (oldonload){oldonload();}func();}
  }
}
function format_{$this->mod}(map, control, maptype, show_marker, addoverview, addscale, addgoogle) {
	if (control!='') {
	    var controls = control.split('|');
	    for (i=0; i<controls.length; ++i) {eval('map.addControl(new '+controls[i]+'());');}
	}
	if (maptype!='') {eval('map.setMapType('+maptype+');');}
	if (control=='' && maptype=='') {map.setUIToDefault();}
	if (addoverview=='1') map.addControl(new GOverviewMapControl());
	if (addscale=='1') map.addControl(new GScaleControl());
	if (addgoogle=='1') map.enableGoogleBar();
}
</script>
";
		return $js;
	}

	function setup_css() {
		$output = '';
		return $output;
	}

	function gmap_code() {
		$js = "\n<script type=\"text/javascript\">
function init_{$this->mod}_gmap(id, addr, centerLatitude, centerLongitude, startZoom, description, kml, control, maptype, show_marker, addoverview, addscale, addgoogle) {
     if (addr!='') {
 		geocoder = new GClientGeocoder();
	    geocoder.getLatLng(addr, function(pt) {
	    	if (pt == null) {
         var mapdiv = document.getElementById(\"{$this->mod}_gmap\"+id);
        mapdiv.innerHTML = '<p style=\"background:#ffff00\">Google cannot find the address you specified: <b>'+addr+'</b><br />Please double check your address.</p><ul><li>Please make sure you enter the full address in double quotes.</li><li>For countries other than US, please do not forget to enter the country name.</li></ul><p>Click here for <a href=\"http://gmaps-samples.googlecode.com/svn/trunk/mapcoverage_filtered.html\">full list of supported countries</a>.</p>';
    } else {
		display_{$this->mod}_gmap(id, pt.lat(), pt.lng(), startZoom, description, kml, control, maptype, show_marker, addoverview, addscale, addgoogle);
    }
	    });
	} else {
	     display_{$this->mod}_gmap(id, centerLatitude, centerLongitude, startZoom, description, kml, control, maptype, show_marker, addoverview, addscale, addgoogle);
	}
}

function display_{$this->mod}_gmap(id, centerLatitude, centerLongitude, startZoom, description, kml, control, maptype, show_marker, addoverview, addscale, addgoogle) {
    var mapdiv = document.getElementById(\"{$this->mod}_gmap\"+id);
	if (GBrowserIsCompatible()) {
		var map = new GMap2(mapdiv);
		map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
		if (kml!='') {
		    var gx = new GGeoXml(kml);
		    map.addOverlay(gx);
		} else {
			if (show_marker) {
				var marker = new GMarker(new GLatLng(centerLatitude, centerLongitude));
				if (description!='') {GEvent.addListener(marker, 'click', function() {marker.openInfoWindowHtml(description);});}
				map.addOverlay(marker);
			}
		}
		format_{$this->mod}(map, control, maptype, show_marker, addoverview, addscale, addgoogle);
	} else {
	    mapdiv.innerHTML = 'Sorry, your browser is not compatible with Google Maps.';
	}
}

</script>
";

		return $js;
	}

}

class Plugin_googleMaps extends Plugin_googleMaps_base {

	function Plugin_googleMaps( &$row, $pluginParams, $is_mod=0 ) {
		$this->mod = 'gmap';
		$this->tag = 'googleMaps';
		$this->addoverview = 1;
		$this->addgoogle = 1;
		$this->init_google_maps($row, $pluginParams, $is_mod);
	}

	function output_map(&$row, $matches, $map_id) {
		if (preg_match('/(\d+)%/', $this->width, $matches3)) {
			if ($matches3[1]<1 || $matches3[1]>100) $this->width = '100%';
		} elseif ($this->width<10 || $this->width>4096) $this->width = 640;
		#if ($lat!='' && $long!='')
		if (preg_match('/%/', $this->width)) $width2 = $this->width;
		else $width2 =  $this->width.'px';

		$output = "\n<div id=\"{$this->mod}_gmap{$map_id}\" style=\"width: {$width2}; height: {$this->height}px\"></div>\n";
		$output .= "<div style=\"width: {$width2};\"><p align=\"right\" style=\"padding:0 0 0 0;margin:0 0 0 0\"><a href=\"http://www.kksou.com/php-gtk2/Joomla-Gadgets/googleMaps-plugin.php\" style=\"color:#aaa;text-decoration: none;font-family:Tahoma, Arial, Helvetica, sans-serif;font-size:7pt;font-weight: normal;\">Powered by JoomlaGadgets</a></p></div>\n";
		$row->text = str_replace($matches[0], $output, $row->text);

		#$js = "gmap2{$map_id} = init_gmap('$map_id', '$this->addr', $this->lat, $this->long, $this->startzoom, '$this->description', '$this->kml', '$this->control', '$this->maptype', $this->marker, '$this->addoverview', '$this->addscale', '$this->addgoogle');\n";
		$js = "init_{$this->mod}_gmap('$map_id', '$this->addr', $this->lat, $this->long, $this->startzoom, '$this->description', '$this->kml', '$this->control', '$this->maptype', $this->marker, '$this->addoverview', '$this->addscale', '$this->addgoogle');\n";
		return $js;
	}

	function setup_gmap() {
		$output = "\n\n<!-- \nPowered by Joomla Gadgets from kksou.com
http://www.kksou.com/php-gtk2/Joomla-Gadgets/googleMaps-plugin.php
-->\n\n";

		$lang = '';
		if ($this->lang!='') $lang = "&amp;hl=".$this->lang;
		$output .= "\n<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=$this->api_key".$lang."\" type=\"text/javascript\"></script>";

		$output .= $this->gmap_code();
		return $output;
	}

}

?>

Anon7 - 2021