$lang = $_REQUEST['lang']; $url = $_REQUEST['url']; $args = ""; if( isset( $_SERVER['argv'][0] ) ) $args = $_SERVER['argv'][0]; $args = str_replace( 'lang='.$lang.'&url='.$url, '', $args ); if( $args != '') $args = substr_replace( $args, '?', 0, 1); $args = str_replace( '&', '%26', $args); if(!$lang){ print "

window.location.href='http://".$_SERVER["HTTP_HOST"]."'"; exit; } include_once("../websitetranslator/function.php"); include_once('../websitetranslator/cache-script.php'); $cache_active = true; $cache_folder = 'cache/'; $cache_time = 2628000;// 31536000 a year, 2628000 a month, 606462 a week, 86400 a day, 60 = 1 minute $permissions = substr(sprintf('%o', fileperms($cache_folder)), -3); $page = ''; $page_post = ''; $translator = ''; //Read the permissions on the cache folder and verify that the minimum rights are in place. if( substr( $permissions, 0, 1 ) < 7 || substr( $permissions, 1, 1 ) < 5 || substr( $permissions, 2, 1 ) < 5 ) { //Otherwise, set the proper rights. $permissionChanged = chmod( $cache_folder, 0755 ); //If the permissions were not set, advise the user to change them manually. if( !$permissionChanged ) die("

Error: Set your folder '".$cache_folder."' permissions to: '755'. "); } $site_url = $_SERVER["HTTP_HOST"]; $full_url = "http://".$site_url.$_SERVER["REQUEST_URI"].$args; function translator(){ global $lang, $site_url, $url, $cache_time, $full_url, $cache_active, $translator, $args; $translator = 'TRANSLATOR_NONE'; $result = acmeCache::fetch($full_url, $cache_time); if(!$result){ //translated page if( $lang == 'id' ) { //Indo $translator = 'TRANSLATOR_KATAKU'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.toggletext.com/kataku_webpage_translate.php?input=http%3A%2F%2F".$site_url."%2F".$url.$args."&langset=en_in"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); if( $tr_post && $tr_post != '' ) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $tr_post); } $page = curl_exec($ch); curl_close($ch); if ((eregi("Fatal Error",$page))) {// if it return an error $translator = 'TRANSLATOR_NONE'; echo '
We are experiencing a temporary problem with the foreign language section. Please try again later. We apologize for the inconvenience.

'.$site_url.'

'; exit(); } //modify all links $page = str_replace('

', '', $page); }else if($lang == "sv" or $lang == "ro" or $lang == "pl" or $lang == "no" or $lang == "hi" or $lang == "fi" or $lang == "da" or $lang == "cs" or $lang == "hr" or $lang == "bg"){ $translator = 'TRANSLATOR_GOOGLE'; $page = curlPage("http://64.233.179.104/translate_c","hl=en&langpair=en%7C".$lang."&u=http://".$site_url."%2F".$url.$args); //$page = "302 Moved"; if ((eregi("302 Moved",$page))) {// if it return an error $translator = 'TRANSLATOR_NONE'; echo '
We are experiencing a temporary problem with the foreign language section. Please try again later. We apologize for the inconvenience.

'.$site_url.'

'; exit(); } }else{ $translator = 'systran'; $page = curlPage("http://www.systranlinks.com/trans", "systran_lp=en_".$lang."&systran_id=http://www.appliedlanguage.com/&systran_url=http://".$site_url."/".$url.$args); if ((eregi("encountered an error",$page))) {// if it return an error $translator = 'TRANSLATOR_NONE'; echo '
We are experiencing a temporary problem with the foreign language section. Please try again later. We apologize for the inconvenience.

'.$site_url.'

'; exit(); } } //modify all links if($translator == 'TRANSLATOR_GOOGLE'){ $page = str_replace('href="http://64.233.179.104/translate_c?hl=en&langpair=en%7C'.$lang.'&u=http://'.$site_url, 'href="http://'.$site_url.'/'.$lang, $page); $page = str_replace('href="http://64.233.179.104/translate_c?hl=en&langpair=en%7C'.$lang.'&u=http://', 'href="http://', $page); $page = str_replace('%3F', '?', $page); $page = str_replace('%3D', '=', $page); $page = str_replace('%26', '&', $page); } else if($translator == 'systran'){ $page = str_replace('href="http://www.systranlinks.com/trans?systran_lp=xx_'.$lang.'&systran_id=http://www.appliedlanguage.com/&systran_url=http%3A%2F%2F'.$site_url, 'href="http://'.$site_url.'/'.$lang, $page); $page = str_replace('href="http://www.systranlinks.com/trans?systran_lp=xx_'.$lang.'&systran_id=http://www.appliedlanguage.com/&systran_url=http%3A', 'href="http:', $page); $page = str_replace('%7C', '&', $page); $page = str_replace('|', '&', $page); $page = str_replace('%3F', '?', $page); $page = str_replace('%2F', '/', $page); $page = str_replace('%3D', '=', $page); } //replace the javascript for the flags code $page = str_replace(' ', flags(), $page); //rewrite the flags link because the translator changes it $flag_subtrings = returnSubstrings($page, '', ''); $flag = $flag_subtrings[0]; $flag_link = flags(); $page = str_replace($flag, $flag_link, $page); $result = $page; // save the result in the cache acmeCache::save($full_url, $result); return $result; } else{ return $result; } } echo translator(); ?>