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 :  /home/pathumthani_integration/p_sdoc/plugins/content/google/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/pathumthani_integration/p_sdoc/plugins/content/google/standard.php
<?php

require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_google'.DS.'helpers'.DS.'configuration.php');

global $mainframe;
$document =& JFactory::getDocument();

//split language tag up so I can decide how google should be displayed
$lang =& JFactory::getLanguage();
$lang_tag = $lang->getTag();
$current_language = split('-',$lang_tag);
$current_language = $current_language[0];
$direction_language = $current_language . '_' . strtoupper($current_language);

$route_counter = 0;
for ($i=0, $n=count( $google ); $i < $n; $i++){
	$row1 = &$google[$i];
	if($row1->assign_routeplanning){
		$route_counter++;
		$latlng = $row1->lat . "," . $row1->long;
	}
}

//api key
$split_homepage = explode(",",$homepage_url_temp);
$split_api = explode(",",$google_api_temp);
$curr_homepage = str_replace("www.","",$_SERVER['SERVER_NAME']);
$counter = 0;
foreach ($split_homepage as $homepage){ 
	$uri = trim($homepage);
	$u =& JURI::getInstance( $uri );
	$temp_homepage = str_replace("www.","",$u->getHost());
	
	if ($temp_homepage==$curr_homepage) {
		$google_api = $split_api[$counter];
		break;
	}
	$counter++;
}

//google params
$width = $google_params->width;
if(!$width){$width='100%';}
$height = $google_params->height;
if(!$height){$height='400px';}
$zoomlevel = $google_params->zoomlevel;
if(!$zoomlevel){$zoomlevel=7;}
$routing = $google_params->routing;
if(!$routing){$routing=0;}
$setcenter = $google_params->setcenter;
if(!$setcenter){$setcenter="7,6";}
$maptype = $google_params->maptype;
if($maptype=='normal' || $maptype==''){
	$maptype='G_NORMAL_MAP';
}elseif ($maptype=='satellite'){
	$maptype='G_SATELLITE_MAP';	
}elseif ($maptype=='hybrid'){
	$maptype='G_HYBRID_MAP';
}elseif ($maptype=='terrain'){
	$maptype='G_PHYSICAL_MAP';
}

static $HeaderAdded;
if(!$HeaderAdded) {
	$HeaderAdded=1;	
	
	$header .= '
window.addEvent(\'load\', function() {
	load();
});
	
window.addEvent(\'onunload\', function(){
	GUnload();
});

var marker;
var overlayInstance = null;
var map;
var info = [];
var gmarkers = [];
var htmls = [];
var i = 0;

function load() {
	if (GBrowserIsCompatible()) { 
	  	map = new GMap2(document.getElementById("googlemap"));
		map.setCenter(new GLatLng('.$setcenter.'), '.$zoomlevel.');
        map.setUIToDefault();
		map.setMapType('.$maptype.'); 
   	';
	$header .='
		var baseIcon = new GIcon();
		baseIcon.shadow = "'.JURI::base().'components/com_google/icons/map_shadow.png";
		baseIcon.shadowSize = new GSize(35, 45);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);
		baseIcon.infoShadowAnchor = new GPoint(18, 25);

		function createMarker(point, tekst, type, index) {

		  var icon = new GIcon(baseIcon);
		  icon.image =  "'.JURI::base().'components/com_google/icons/"+type;
		  var marker = new GMarker(point, icon);
			
		  GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(tekst);
		  });

		  gmarkers[i] = marker;
		  info[i] = tekst;
		  i++;
		  return marker;
		}

	';
		
	//Google indhold
	for ($i=0, $n=count( $google ); $i < $n; $i++)	{
		$row = $google[$i];
		 // $txt = JFilterOutput::cleanText($row->txt);
		$txt = str_replace(chr(13),'<br />',$row->txt);
		$txt = str_replace(chr(10),'',$txt);
		$txt = str_replace(chr(34),chr(39),$txt);
		$google_html = "<div class='google_html'>";
		$google_html = $google_html .  "<b>" .$row->name . "</b>";
		if($row->picture){
			$imgSizeInfo=getimagesize('images/google/'.$row->picture);
			$google_html = $google_html .  "<br /><br />" ."<img src='".JURI::root()."images/google/".$row->picture."' border='0' width='".$imgSizeInfo[0]."' height='".$imgSizeInfo[1]."'/>";
		}
		if($row->address || $row->zipcode || $row->town)
		{
			$google_html = $google_html .  "<br /><br /><strong>". JText::_( 'GOOGLE_ADDRESS') ."</strong><br />" .$row->address;
			$google_html = $google_html .  "<br />" .$row->zipcode;
			$google_html = $google_html .  " -- " .$row->town;
		}
		if($txt){$google_html = $google_html .  "<br /><br /><strong>". JText::_( 'GOOGLE_DESCRIPTION') ."</strong><br />".$txt;}
		
		$google_html = $google_html . "</div>";
		
		$header .='
		var point = new GLatLng("'.$row->lat.'","'.$row->long.'");
		map.addOverlay(createMarker(point,"'.$google_html.'","'.$row->icon_type.'"));
		';
		
	}

	$header .= '	
		
	}
}
';

if($routing==1){	
	
$header .='
	
function resetmap() {
	document.getElementById("directions").innerHTML = "";
	document.getElementById("direction_feedback").innerHTML = "";	
}

//route
var geocoder;
function map_start() {
	var map;
	var gdir = null;
	var geocoder = null;
	var addressMarker;
	
	var from_address = document.getElementById("from_address").value;
	var from_zipcode = document.getElementById("from_zipcode").value;
	var from_town = document.getElementById("from_town").value;
	var to_address = document.getElementById("to_address").value;
	
	var from_start = "";
	if(from_address=="'.JText::_( 'GOOGLE_INPUT_FIELDSET').'") from_address="";
	if(from_zipcode=="'.JText::_( 'GOOGLE_INPUT_FIELDSET_AREA').'") from_zipcode="";
	if(from_town=="'.JText::_( 'GOOGLE_INPUT_FIELDSET_TOWN').'") from_town="";
	if(from_address) from_start = from_address + ","+"";
	if(from_zipcode) from_start += from_zipcode+ ","+"";
	if(from_town) from_start += from_town;

	function initialize() {
	  if (GBrowserIsCompatible()) {

		map = new GMap2(document.getElementById("googlemap"));
        map.setUIToDefault();
		
		gdir = new GDirections(map, document.getElementById("directions"));
		GEvent.addListener(gdir, "load", onGDirectionsLoad);
		GEvent.addListener(gdir, "error", handleErrors);
		setDirections(from_start, to_address, "'.$direction_language.'");
	  }
	}

	function setDirections(fromAddress, toAddress, locale) {
	  gdir.load("from: " + fromAddress + " to: " + toAddress,{ "locale": locale });
	}

	function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS){
			alert("'.JText::_( 'GOOGLE_INITIALIZE_ERROR1').'");
			load();
	   }else{
			alert("'.JText::_( 'GOOGLE_INITIALIZE_ERROR2').'");
			load();
		}
	}
	
	function onGDirectionsLoad(){
	';
	 $header .= 'document.getElementById("direction_feedback").innerHTML= "<input type=\"button\" value=\"'.JText::_( 'GOOGLE_DIRECTION_PRINT').'\" onClick=\"printSpecial()\" class=\"print_btn\"/>"+"<a href=\"javascript: load();resetmap();\" id=\"direction_started\">'.JText::_( 'GOOGLE_DIRECTION_FEEDBACK').'</a>";';

	 $header .='
	 document.getElementById("directions").innerHTML = "";
	}

	initialize();		
}

//print
var gAutoPrint = false;
function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = "<HTML>\n<HEAD>\n";
		html += "\n</HE" + "AD>\n<BODY>\n";
		var printReadyElem = document.getElementById("directions");
		if (printReadyElem != null)
		{		
				html += "<button onclick=window.print()>'.JText::_( 'GOOGLE_DIRECTION_PRINT').'</button><br /><br/>";
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
		html += "\n</BO" + "DY>\n</HT" + "ML>";
		var printWin = window.open("","printSpecial", "width = 600");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("'.JText::_( 'GOOGLE_DIRECTION_OK').'");
	}
}
	
';
}


$document->addscript("http://maps.google.com/maps?file=api&amp;v=2&amp;hl=$current_language&amp;key=$google_api");

$document->addScriptDeclaration($header);
$document->addStyleSheet(JURI::root().'components'.DS.'com_google'.DS.'css'.DS.'google.css');

}
			
$html = '<div id="googlemap" style="width: '.$width.'; height: '.$height.'; clear: both;"></div>';

if ($routing==1) :

$html .= ' 	
		<fieldset id="google_select">
		<legend>'.JText::_( 'GOOGLE_ROUTEPLANNING').'</legend>
		<form action="" onsubmit="map_start(); return false" method="post">  
		';
$html .= "<label>".JText::_( 'GOOGLE_FROM')."</label>";
$html .= "<input type='text' name='from_address' id='from_address' value='".JText::_( 'GOOGLE_INPUT_FIELDSET')."' onfocus=\"if (this.value=='".JText::_( 'GOOGLE_INPUT_FIELDSET')."') {this.value='';}\" onblur=\"if (this.value=='') {this.value='". JText::_( 'GOOGLE_INPUT_FIELDSET')."';}\" />"; 
	
$html .= "<input type='text' name='from_zipcode' id='from_zipcode' value='".JText::_( 'GOOGLE_INPUT_FIELDSET_AREA')."' onfocus=\"if (this.value=='".JText::_( 'GOOGLE_INPUT_FIELDSET_AREA')."') {this.value='';}\" onblur=\"if (this.value=='') {this.value='". JText::_( 'GOOGLE_INPUT_FIELDSET_AREA')."';}\" />"; 
	
$html .= "<input type='text' name='from_town' id='from_town' value='".JText::_( 'GOOGLE_INPUT_FIELDSET_TOWN')."' onfocus=\"if (this.value=='".JText::_( 'GOOGLE_INPUT_FIELDSET_TOWN')."') {this.value='';}\" onblur=\"if (this.value=='') {this.value='". JText::_( 'GOOGLE_INPUT_FIELDSET_TOWN')."';}\" />"; 
	
                
if($route_counter>1){ 
$html .= "<label>".JText::_( 'GOOGLE_TILL')."</label>";		
$html .= ' 	
		<select name="to_address" id="to_address">
        <option value="0">'.JText::_( 'GOOGLE_SELECT_VALUE').'</option>
		';
		for ($i=0, $n=count( $google ); $i < $n; $i++){
			$row2 = &$google[$i];
			if($row2->assign_routeplanning){
				$html .= "<option value=\"$row2->lat,$row2->long\">$row2->name</option>";
			}
		}

$html .= '</select>';
		
}else{ 
        
$html .= '<input type="hidden" name="to_address" id="to_address" value="'.$latlng.'" />';
}
$html .= ' 
		<label></label>
		 <input type="submit" value="'.JText::_( 'GOOGLE_SELECT_BUTTON').'" class="btn" />
         </form>
         </fieldset> 
		 <div class="clear"></div>
       ';
     
$html .= "<div id='directions' style='width:$width;height: auto;'></div>"; 
$html .= "<div id='direction_feedback'></div>";

endif; 

return $html;	
?>

Anon7 - 2021