CALC: $dir"); $res = array("num"=>0,"size"=>0); if (file_exists($dir) && is_dir($dir) && is_readable($dir)) { $files = glob($dir . '/*'); if (is_array($files)){ foreach($files as $path){ if ($exclusions != "" && strpos($path,$exclusions)!==false) { //gltr_debug("$dir: EXCLUDING====>$item"); continue; } if (is_dir($path)){ //gltr_debug("====>Found dir: $path"); $rres = gltr_files_stats($path, $exclusions); $res["size"] += $rres["size"]; $res["num"] += $rres["num"]; }else if (file_exists($path) && is_file($path)) $res["size"] += filesize($path); $res["num"]++; } } } return $res; } function gltr_init_info(){ global $gltr_stale_size; global $gltr_cache_size; global $gltr_cached_files_num; global $gltr_stale_files_num; global $gltr_cache_dir; global $gltr_stale_dir; //cachedir $res_cache = gltr_files_stats($gltr_cache_dir, "stale"); $gltr_cache_size = $res_cache["size"]; $gltr_cached_files_num = $res_cache["num"]; //staledir $res_cache = gltr_files_stats($gltr_stale_dir); $gltr_stale_size = $res_cache["size"]; $gltr_stale_files_num = $res_cache["num"]; } function gltr_get_last_cached_file_time(){ $res = -1; $last_connection_time = get_option("gltr_last_connection_time"); if ($last_connection_time > 0){ $now = time(); $res = $now - $last_connection_time; } return $res; } load_plugin_textdomain('gltr'); // NLS $location = get_option('siteurl') . '/wp-admin/admin.php?page=global-translator/options-translator.php'; // Form Action URI $diff_time = gltr_get_last_cached_file_time(); /*check form submission and update options*/ if (isset($_POST['stage'])){ //submitting something $gltr_base_lang = $_POST['gltr_base_lang']; $gltr_col_num = $_POST['gltr_col_num']; $gltr_html_bar_tag = $_POST['gltr_html_bar_tag']; $gltr_my_translation_engine = $_POST['gltr_my_translation_engine']; $gltr_conn_interval = $_POST['gltr_conn_interval']; $gltr_cache_expire_time = $_POST['gltr_cache_expire_time']; if (isset($_POST['gltr_preferred_languages'])) $gltr_preferred_languages = $_POST['gltr_preferred_languages']; if(isset($_POST['gltr_enable_debug'])) $gltr_enable_debug = true; else $gltr_enable_debug = false; if(isset($_POST['gltr_ban_prevention'])) $gltr_ban_prevention = true; else $gltr_ban_prevention = false; if(isset($_POST['gltr_sitemap_integration'])) $gltr_sitemap_integration = true; else $gltr_sitemap_integration = false; if(isset($_POST['gltr_compress_cache'])) $gltr_compress_cache = true; else $gltr_compress_cache = false; if ('change' == $_POST['stage']) { //recalculate some things $gltr_my_translation_engine = $_POST['gltr_my_translation_engine']; $gltr_preferred_languages = get_option('gltr_preferred_languages'); } else if ('process' == $_POST['stage']){ if(!empty($_POST["gltr_erase_cache"])) { /* deactivated! //Erase cache button pressed $cachedir = $gltr_cache_dir; if (file_exists($cachedir) && is_dir($cachedir) && is_readable($cachedir)) { $handle = opendir($cachedir); while (FALSE !== ($item = readdir($handle))) { if($item != '.' && $item != '..' && !is_dir($item)) { $path = $cachedir.'/'.$item; if (file_exists($path) && is_file($path)) unlink($path); } } closedir($handle); $message = "Cache dirs successfully erased."; } else { //$message = "Unable to erase cache or cache dir '$cachedir' doesn't exist."; //break; } */ } else { //update options button pressed $iserror = false; if (count ($gltr_preferred_languages) == 0) { $message .= "Error: you must choose almost one of the available translations."; $iserror = true; } if(!$iserror) { if (file_exists($gltr_merged_image) && is_file($gltr_merged_image)) unlink($gltr_merged_image); update_option('gltr_base_lang', $_POST['gltr_base_lang']); update_option('gltr_col_num', $_POST['gltr_col_num']); update_option('gltr_html_bar_tag', $_POST['gltr_html_bar_tag']); update_option('gltr_my_translation_engine', $_POST['gltr_my_translation_engine']); update_option('gltr_preferred_languages', array()); update_option('gltr_preferred_languages', $_POST['gltr_preferred_languages']); update_option("gltr_last_connection_time",time()); update_option("gltr_translation_status","unknown"); $diff_time = -1; $conn_int = $_POST['gltr_conn_interval']; if (!is_numeric($conn_int))$conn_int = 300; update_option('gltr_conn_interval', $conn_int); $gltr_conn_interval = $conn_int; $exp_time = $_POST['gltr_cache_expire_time']; if (!is_numeric($exp_time))$exp_time = 30; update_option('gltr_cache_expire_time', $exp_time); $gltr_cache_expire_time = $exp_time; if(isset($_POST['gltr_ban_prevention'])) update_option('gltr_ban_prevention', true); else update_option('gltr_ban_prevention', false); if(isset($_POST['gltr_sitemap_integration'])) update_option('gltr_sitemap_integration', true); else update_option('gltr_sitemap_integration', false); if(isset($_POST['gltr_compress_cache'])) update_option('gltr_compress_cache', true); else update_option('gltr_compress_cache', false); if(isset($_POST['gltr_enable_debug'])) update_option('gltr_enable_debug', true); else update_option('gltr_enable_debug', false); $wp_rewrite->flush_rules(); $message = "Options saved."; } } } } else { //page loaded by menu: retrieve stored options $gltr_base_lang = get_option('gltr_base_lang'); $gltr_col_num = get_option('gltr_col_num'); $gltr_html_bar_tag = get_option('gltr_html_bar_tag'); $gltr_my_translation_engine = get_option('gltr_my_translation_engine'); $gltr_preferred_languages = get_option('gltr_preferred_languages'); $gltr_ban_prevention = get_option('gltr_ban_prevention'); $gltr_sitemap_integration = get_option('gltr_sitemap_integration'); $gltr_compress_cache = get_option('gltr_compress_cache'); $gltr_enable_debug = get_option('gltr_enable_debug'); $gltr_conn_interval = get_option('gltr_conn_interval'); $gltr_cache_expire_time = get_option('gltr_cache_expire_time'); $gltr_current_engine = $gltr_available_engines[$gltr_my_translation_engine]; $gltr_lang_matrix = $gltr_current_engine->get_languages_matrix(); if (count($gltr_preferred_languages) == 0) { $i = 0; foreach($gltr_lang_matrix[$gltr_base_lang] as $lang_key => $lang_value){ if ($lang_key == $gltr_base_lang) continue; $gltr_preferred_languages[]=$lang_key; $i++; } update_option('gltr_preferred_languages', $gltr_preferred_languages); } $cachedir = $gltr_cache_dir; $message = ""; if (!is_writeable(dirname(__file__))){ $message = "Unable to complete Global Translator initialization. Please make writable and readable the following directory: "; } else if (!is_dir($cachedir) && (!is_readable(WP_CONTENT_DIR) || !is_writable(WP_CONTENT_DIR) )){ $message = "Unable to complete Global Translator initialization. Please make writable and readable the following directory: "; } else { if (!is_dir($cachedir)){ if(!mkdir($cachedir, 0777)){ $message = "Unable to complete Global Translator initialization. Please manually create and make readable and writeable the following directory: "; } } else if (!is_readable($cachedir) || !is_writable($cachedir) ){ $message = "Unable to complete Global Translator initialization. Please make readable and writeable the following directory: "; } if (is_dir($cachedir) && is_readable($cachedir) && is_writable($cachedir)){ $staledir = $gltr_stale_dir; if (!is_dir($staledir)){ if(!mkdir($staledir, 0777)){ $message = "Unable to complete Global Translator initialization. Please manually create and make readable and writeable the following directory: "; } } else if (!is_readable($staledir) || !is_writable($staledir) ){ $message = "Unable to complete Global Translator initialization. Please make readable and writeable the following directory: "; } } //check files /* $datafiles = array(); foreach($datafiles as $datafile){ if(!is_file($datafile)){ if (!gltr_create_file($datafile)){ $message .= "Unable to complete Global Translator initialization. Please create and make readable and writeable the following file:
"; } } else if (!is_readable($datafile) || !is_writeable($datafile)){ $message .= "Unable to complete Global Translator initialization. Please make readable and writeable the following file:
"; } } */ } } //foreach($gltr_preferred_languages as $key => $value){echo "$value
";} /*Get options for form fields*/ $gltr_current_engine = $gltr_available_engines[$gltr_my_translation_engine]; $gltr_lang_matrix = $gltr_current_engine->get_languages_matrix(); function gltr_build_js_function($base_lang, $selected_item) { global $gltr_current_engine; global $gltr_lang_matrix; ?> WARNING! Your blog seems to have been temporarily banned by the '".strtoupper(get_option('gltr_my_translation_engine'))."' translation engine. Try to increase the connection request interval on the \"Translation engine connection\" section."; } */ //Print out the message to the user, if any if($message!="") { ?>

" />


Global Translator uses a fast, smart, optimized, self-cleaning and built-in caching system in order to drastically reduce the connections to the translation engines. This feature cannot be optional and is needed in order to prevent from banning by the translation services. For the same reason the translation process will not be immediate and the full translation of the blog could take a while: this is because by default only a translation request every 5 minutes will be allowed (see next section).
The cache invalidation will be automatically (and smartly) handled when a post is created, deleted or updated.

Unable to provide cache compression feature: ZLIB not available on you php installation.

Schedule a page for a new translation if it has been cached more than days ago ("0" means "never").

Cache statistics

  • Your cache directory currently contains successfully translated and cached pages.
  • Cache directory size: MB
  • Your stale directory currently contains successfully translated and cached pages waiting for a new translation.
  • Stale directory size: MB



This feature represents the solution which can definitively prevent your blog from being banned by the translation engines.
For this reason we strongly discourage you to insert an interval value lower than "300" (5 minutes), which should represent an optimal value expecially for high-traffic blogs.
If your blog is sharing its IP address with other blogs using this plugin, the risk of being banned could come back again: in this case I suggest you to increase the timeout value and wait for a while (some days could be necessary).

    0){ echo ("
  • Latest allowed connection to the translation engine: "); if ($diff_time < 60){ echo (round(($diff_time)) . " seconds ago"); }else if ($diff_time > 60*60){ echo (round(($diff_time)/3600) . " hours ago"); }else{ echo (round(($diff_time)/60) . " minutes ago"); } /* global $gltr_last_cached_url; if (strlen($gltr_last_cached_url)>0){ echo (". [See latest translated page]"); } */ } else { echo ("
  • Latest allowed connection to the translation engine: not available"); } echo ("
  • "); echo ("
  • Translations status:"); $ban_status = get_option("gltr_translation_status"); if ($ban_status == 'banned'){ echo("Bad or unhandled response from the '".strtoupper(get_option('gltr_my_translation_engine'))."' translation engine. This could mean that:
    • Your blog has been temporarily banned: increase the time interval between the translation requests and wait for some days or switch to another translation engine
    • The translation engine is currently not responding/working: wait for some days or switch to another translation engine
    • The translation engine has changed something (i.e. the translation url): wait for the next release of Global Translator :-)
    • You haven't added the flags widget on your pages: adding the flags bar is mandatory in order to make Global Translator able to work correctly
    • "); } else if ($ban_status == 'working'){ echo("Working properly"); } else { echo("not available"); } echo (""); ?>



By enabling this option, Global Translator will block the access to the translated pages to a lot of "bad" web spiders. This function could help the built-in cache to prevent "unuseful" translation requests expecially if you have an high-traffic blog.
If you have a low traffic blog I suggest you to disable this option.



By enabling this option, Global Translator will automatically provide the translated urls to the "Google XML Sitemaps Generator for WordPress" plugin.
After the next sitemap rebuild, all the translated urls will be added to your sitemap.xml file.
This feature could make the sitemap generation process very slow and could require a lot of system resources (a lot of urls could be added): I strongly suggest you to enable the "Build the sitemap in a background process" option from the "Google XML Sitemaps Generator for WordPress" admin page, otherwise the post saving/publishing actions could become unresponsive.



Donations help me to continue support and development of this free software! '); ?>

http://www.nothing2hide.net/global-translator-pro/", __("Check %s if you need a supported version with more and advanced functions")); ?>