nodeType == XML_TEXT_NODE ) { if ( substr( $strNode->nodeValue, 0, 1 ) == " " ) { $strLS = " "; } else { $strLS = ""; } if ( substr( $strNode->nodeValue, strlen( $strNode->nodeValue ) - 1, 1 ) == " " ) { $strTS = " "; } else { $strTS = ""; } $strJSON = json_decode( curlgetcontents( "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode( $strNode->nodeValue )."&langpair=".$strBase."%7C".$strLang ) ); $strNode->nodeValue = $strLS.$strJSON->responseData->translatedText.$strTS; } $strChild = $strNode->childNodes; if ( 0 < count( $strChild ) ) { ++$intLevel; foreach ( $strChild as $cNode ) { parsedom( $cNode, $intLevel ); $intLevel -= 1; } } } function ShowMySQLError( $strErrorCode ) { global $strTemplate; global $strSupport; switch ( $strErrorCode ) { case "1" : $strError = "The Incansoft Translator was not able to Connect to the MySQL Database. This may occur if the MySQL Database has not yet been created or the Login Credentials were not entered correctly in the Configuration file."; break; case "2" : $strError = "The Incansoft Translator was not able to Select the MySQL Database. This may occur if the MySQL Database has not yet been created or the Login Credentials were not entered correctly in the Configuration file."; break; case "3" : $strError = "The Incansoft Translator was not able to Create the required Tables in the MySQL Database. This may occur if the MySQL Database has not yet been created or the Login Credentials were not entered correctly in the Configuration file."; break; case "4" : $strError = "The Incansoft Translator was not able to Insert a New Record in the MySQL Database. This may occur if the MySQL Database has not yet been created or the Login Credentials were not entered correctly in the Configuration file."; } echo str_replace( "[MESSAGE]", $strError.$strSupport, $strTemplate ); exit( ); } error_reporting( 0 ); include( "TransCfg.php" ); $strTemplate = "
Incansoft
Solutions Evolved
Translator Error

[MESSAGE]
© 2000 - ".date( "Y" ).", Incansoft.com
"; $strRegKeyNo = "It would appear that the Registration Key for this copy of the Incansoft Translator is not valid. This may be due to a typo when entering it in the Configuration file, or your Hosting Service not supporting all of the required Modules."; $strSupport = "

If you believe this message was received in error, please contact Incansoft Support for assistance. Be certain to provide all of the relevant details we need to assist you in resolving the issue.
"; checklicense( $regKeys ); if ( !( $datLink = @mysql_connect( $datHost, $datUser, $datPass ) ) ) { exit( showmysqlerror( "1" ) ); } if ( !@mysql_select_db( $datName ) ) { exit( showmysqlerror( "2" ) ); } if ( !mysql_query( "CREATE TABLE IF NOT EXISTS Translate (ID INT NULL AUTO_INCREMENT , PageURL MEDIUMTEXT NULL , PageLang VARCHAR(8) NULL , PageContent LONGTEXT NULL , TransDate VARCHAR(10) NULL , PRIMARY KEY (`ID`))" ) ) { exit( showmysqlerror( "3" ) ); } if ( isset( $_GET['Lang'], $_GET['Page'] ) ) { header( "location: ".$_SERVER['HTTP_REFERER'] ); exit( ); } $strLang = strtoupper( $_GET['Lang'] ); $strPage = $_GET['Page']; if ( !isset( $_GET['NOCACHE'] ) ) { $strCached = mysql_fetch_array( mysql_query( "SELECT * FROM Translate WHERE PageURL = '".$strPage."' AND PageLang = '".$strLang."' LIMIT 1" ) ); if ( $strCached['PageContent'] != "" ) { if ( strtotime( date( "Y-m-d" ) ) - strtotime( $strCached['TransDate'] ) <= $strCache * 86400 ) { echo html_entity_decode( stripslashes( $strCached['PageContent'] ) ); exit( ); } mysql_query( "DELETE FROM Translate WHERE PageURL = '".$strPage."' AND PageLang = '".$strLang."' LIMIT 1" ); } } ( "1.0", "UTF-8" ); $objDocs = new DOMDocument( ); $strDocs = curlgetcontents( $strPage ); $objDocs->loadHTML( $strDocs ); parsedom( $objDocs ); $strData = $objDocs->saveHTML( ).""; $strMeta = get_meta_tags( $strPage ); $strDesc = json_decode( curlgetcontents( "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode( $strMeta['description'] )."&langpair=".$strBase."%7C".$strLang ) ); $strKeyw = json_decode( curlgetcontents( "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode( $strMeta['keywords'] )."&langpair=".$strBase."%7C".$strLang ) ); $strData = str_replace( $strMeta['description'], $strDesc->responseData->translatedText, str_replace( $strMeta['keywords'], $strKeyw->responseData->translatedText, $strData ) ); mysql_query( "INSERT INTO Translate (PageURL, PageLang, PageContent, TransDate) VALUES('".$strPage."', '".$strLang."', '".addslashes( $strData )."', '".date( "Y-m-d" )."')" ); mysql_query( "DELETE FROM Translate WHERE PageURL = ''" ); echo html_entity_decode( $strData ); ?>