Hello,
I downloaded a php script for translating webpages. It looks like this.
<?php
// edit this line for your domain ex: http://www.domain.com
$myurl = "http://www.domain.com";
// get the url
$path = $_SERVER['REQUEST_URI'];
// split it in pieces
$urlpath = split("/", $path);
// get the language they want
$tlang2 = $urlpath[3];
$gboy = $_POST['gboy'];
// make sure it came from our form if it didn't kill it
if(!$gboy == "") {
echo "NO LEECHING!!!";
exit();
}
// now we have the language they want make it something we can use
if ($tlang2 == "English") { $tlang = "en"; }
if ($tlang2 == "German") { $tlang = "de"; }
if ($tlang2 == "Spanish") { $tlang = "es"; }
if ($tlang2 == "French") { $tlang = "fr"; }
if ($tlang2 == "Italian") { $tlang = "it"; }
if ($tlang2 == "Portuguese") { $tlang = "pt"; }
if ($tlang2 == "Japanese") { $tlang = "ja"; }
if ($tlang2 == "Korean") { $tlang = "ko"; }
if ($tlang2 == "Chinese-Simplified") { $tlang = "zh-CN"; }
// Get the url that they want to translate
$site = $_GET['u'];
// they are playing with the urls here
if (empty($site)) {
$site = "$myurl";
}
$language = $tlang;
if (empty($language)) {
$language = $tlang;
if ($language == "") {
$language = "en";
}
}
$script_url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
// this is the url we need to see stay on our domain
$translated = "http://216.239.39.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en|$tlang&u=$site";
// fix the links to stay on our domain
$data = fopen("$translated", "rb");
$data2 = '';
while (!feof($data)) {
$data2 .= fread($data, 8192); }
// change what we need to
$new_code .= str_replace("http://216.239.39.104/translate_c?hl=en", "$script_url/?$language", $data2);
// get rid of what we don't need
$new_code2 .= str_replace("hl=en", "", $new_code);
$new_code3 .= str_replace("&ie=UTF-8", "", $new_code2);
$new_code4 .= str_replace("&oe=UTF-8", "", $new_code3);
$new_code5 .= str_replace("fr&langpair=en%7Cfr&", "", $new_code4); // done
$new_code6 .= str_replace("es&langpair=en%7Ces&", "", $new_code5); // done
$new_code7 .= str_replace("de&langpair=en%7Cde&", "", $new_code6); // done
$new_code8 .= str_replace("en&langpair=en%7Cen&", "", $new_code7); // done
$new_code9 .= str_replace("it&langpair=en%7Cit&", "", $new_code8); // done
$new_code10 .= str_replace("pt&langpair=en%7Cpt&", "", $new_code9); // done
$new_code11 .= str_replace("ja&ie=UTF-8&oe=UTF-8&langpair=en%7Cja&", "", $new_code10);
$new_code12 .= str_replace("ko&ie=UTF-8&oe=UTF-8&langpair=en%7Cko&", "", $new_code11);
$new_code13 .= str_replace("zh-CN&ie=UTF-8&oe=UTF-8&langpair=en%7Czh-CN&", "", $new_code12);
fclose($data);
echo "<center><a href=\"$myurl\"><FONT SIZE=\"2\">Click Here For English Version</FONT></a></center>";
// display our translated page
echo $new_code13;
?>
The thing is this php is in a extensionless file called language. Along with it came a .htaccess file and a readme file.
The readme goes like this:
Requirements: php enabled server
Edit the value $myurl to match your http://www.domain.com address in the form offered below and the file named "language"
make any subdirectory you want the files in. place the files .htaccess and language in that directory.
Do not add theses files to your root directory.
This script is complient with standards of search engines that follow drop down menus.Your form to add to the site - you can add ther form on any page you want.
<?
// edit this line for your domain ex: http://www.domain.com
$myurl = "http://www.domain.com";
// No need to edit anything else
echo "<font size=\"1\"><B>Select Your language</B></font><BR>
<form name=\"mnfrm\">
<select name=\"tlang\" onChange=location.href=mnfrm.tlang.options[selectedIndex].value>
<option value=\"#\" selected>Choose</option>
<option value=\"$myurl/translate/language/German\">German</option>
<option value=\"$myurl/translate/language/Spanish\">Spanish</option>
<option value=\"$myurl/translate/language/French\">French</option>
<option value=\"$myurl/translate/language/Italian\">Italian</option>
<option value=\"$myurl/translate/language/Portuguese\">Portuguese</option>
<option value=\"$myurl/translate/language/Japanese\">Japanese </option>
<option value=\"$myurl/translate/language/Korean\">Korean</option>
<option value=\"$myurl/translate/language/Chinese-Simplified\">Chinese (Simplified) </option>
</select><BR>
</form>";
?>
I've done as instructed but using the dropdown list from a web page just calls up a page that does not exsist.
I dont understand how the form is linking to the language/php file as there seems to be no reference to it.
The .htaccess file looks like this
<Files language>
ForceType application/x-httpd-php
</Files>
Any help would be much apreciated.
Matt