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: