1 | <?php
|
---|
2 | require_once (dirname(__file__).'/header.php');
|
---|
3 | $gltr_stale_size = 0;
|
---|
4 | $gltr_cache_size = 0;
|
---|
5 | $gltr_cached_files_num = 0;
|
---|
6 | $gltr_stale_files_num = 0;
|
---|
7 | $showstats = false;
|
---|
8 | if (isset($_POST['gltr_stats']) && 'show' == $_POST['gltr_stats']){
|
---|
9 | gltr_init_info();
|
---|
10 | $showstats = true;
|
---|
11 | }
|
---|
12 |
|
---|
13 | function gltr_files_stats($dir,$exclusions=""){
|
---|
14 | //gltr_debug("====>CALC: $dir");
|
---|
15 | $res = array("num"=>0,"size"=>0);
|
---|
16 | if (file_exists($dir) && is_dir($dir) && is_readable($dir)) {
|
---|
17 | $files = glob($dir . '/*');
|
---|
18 | if (is_array($files)){
|
---|
19 | foreach($files as $path){
|
---|
20 | if ($exclusions != "" && strpos($path,$exclusions)!==false) {
|
---|
21 | //gltr_debug("$dir: EXCLUDING====>$item");
|
---|
22 | continue;
|
---|
23 | }
|
---|
24 | if (is_dir($path)){
|
---|
25 | //gltr_debug("====>Found dir: $path");
|
---|
26 | $rres = gltr_files_stats($path, $exclusions);
|
---|
27 | $res["size"] += $rres["size"];
|
---|
28 | $res["num"] += $rres["num"];
|
---|
29 | }else if (file_exists($path) && is_file($path))
|
---|
30 | $res["size"] += filesize($path);
|
---|
31 | $res["num"]++;
|
---|
32 | }
|
---|
33 |
|
---|
34 | }
|
---|
35 | }
|
---|
36 | return $res;
|
---|
37 | }
|
---|
38 |
|
---|
39 | function gltr_init_info(){
|
---|
40 | global $gltr_stale_size;
|
---|
41 | global $gltr_cache_size;
|
---|
42 | global $gltr_cached_files_num;
|
---|
43 | global $gltr_stale_files_num;
|
---|
44 | global $gltr_cache_dir;
|
---|
45 | global $gltr_stale_dir;
|
---|
46 |
|
---|
47 | //cachedir
|
---|
48 | $res_cache = gltr_files_stats($gltr_cache_dir, "stale");
|
---|
49 | $gltr_cache_size = $res_cache["size"];
|
---|
50 | $gltr_cached_files_num = $res_cache["num"];
|
---|
51 | //staledir
|
---|
52 | $res_cache = gltr_files_stats($gltr_stale_dir);
|
---|
53 | $gltr_stale_size = $res_cache["size"];
|
---|
54 | $gltr_stale_files_num = $res_cache["num"];
|
---|
55 |
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 | function gltr_get_last_cached_file_time(){
|
---|
61 | $res = -1;
|
---|
62 | $last_connection_time = get_option("gltr_last_connection_time");
|
---|
63 | if ($last_connection_time > 0){
|
---|
64 | $now = time();
|
---|
65 | $res = $now - $last_connection_time;
|
---|
66 | }
|
---|
67 | return $res;
|
---|
68 | }
|
---|
69 |
|
---|
70 | load_plugin_textdomain('gltr'); // NLS
|
---|
71 |
|
---|
72 | $location = get_option('siteurl') . '/wp-admin/admin.php?page=global-translator/options-translator.php'; // Form Action URI
|
---|
73 |
|
---|
74 | $diff_time = gltr_get_last_cached_file_time();
|
---|
75 |
|
---|
76 | /*check form submission and update options*/
|
---|
77 |
|
---|
78 | if (isset($_POST['stage'])){
|
---|
79 | //submitting something
|
---|
80 | $gltr_base_lang = $_POST['gltr_base_lang'];
|
---|
81 | $gltr_col_num = $_POST['gltr_col_num'];
|
---|
82 | $gltr_html_bar_tag = $_POST['gltr_html_bar_tag'];
|
---|
83 | $gltr_my_translation_engine = $_POST['gltr_my_translation_engine'];
|
---|
84 | $gltr_conn_interval = $_POST['gltr_conn_interval'];
|
---|
85 | $gltr_cache_expire_time = $_POST['gltr_cache_expire_time'];
|
---|
86 |
|
---|
87 | if (isset($_POST['gltr_preferred_languages']))
|
---|
88 | $gltr_preferred_languages = $_POST['gltr_preferred_languages'];
|
---|
89 |
|
---|
90 | if(isset($_POST['gltr_enable_debug']))
|
---|
91 | $gltr_enable_debug = true;
|
---|
92 | else
|
---|
93 | $gltr_enable_debug = false;
|
---|
94 |
|
---|
95 | if(isset($_POST['gltr_ban_prevention']))
|
---|
96 | $gltr_ban_prevention = true;
|
---|
97 | else
|
---|
98 | $gltr_ban_prevention = false;
|
---|
99 |
|
---|
100 | if(isset($_POST['gltr_sitemap_integration']))
|
---|
101 | $gltr_sitemap_integration = true;
|
---|
102 | else
|
---|
103 | $gltr_sitemap_integration = false;
|
---|
104 |
|
---|
105 | if(isset($_POST['gltr_compress_cache']))
|
---|
106 | $gltr_compress_cache = true;
|
---|
107 | else
|
---|
108 | $gltr_compress_cache = false;
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|
112 | if ('change' == $_POST['stage']) {
|
---|
113 | //recalculate some things
|
---|
114 | $gltr_my_translation_engine = $_POST['gltr_my_translation_engine'];
|
---|
115 | $gltr_preferred_languages = get_option('gltr_preferred_languages');
|
---|
116 | } else if ('process' == $_POST['stage']){
|
---|
117 | if(!empty($_POST["gltr_erase_cache"])) {
|
---|
118 | /* deactivated!
|
---|
119 | //Erase cache button pressed
|
---|
120 | $cachedir = $gltr_cache_dir;
|
---|
121 | if (file_exists($cachedir) && is_dir($cachedir) && is_readable($cachedir)) {
|
---|
122 | $handle = opendir($cachedir);
|
---|
123 | while (FALSE !== ($item = readdir($handle))) {
|
---|
124 | if($item != '.' && $item != '..' && !is_dir($item)) {
|
---|
125 | $path = $cachedir.'/'.$item;
|
---|
126 | if (file_exists($path) && is_file($path))
|
---|
127 | unlink($path);
|
---|
128 | }
|
---|
129 | }
|
---|
130 | closedir($handle);
|
---|
131 | $message = "Cache dirs successfully erased.";
|
---|
132 | } else {
|
---|
133 | //$message = "Unable to erase cache or cache dir '$cachedir' doesn't exist.";
|
---|
134 | //break;
|
---|
135 | }
|
---|
136 | */
|
---|
137 | } else {
|
---|
138 | //update options button pressed
|
---|
139 |
|
---|
140 | $iserror = false;
|
---|
141 | if (count ($gltr_preferred_languages) == 0) {
|
---|
142 | $message .= "Error: you must choose almost one of the available translations.";
|
---|
143 | $iserror = true;
|
---|
144 | }
|
---|
145 |
|
---|
146 | if(!$iserror) {
|
---|
147 | if (file_exists($gltr_merged_image) && is_file($gltr_merged_image))
|
---|
148 | unlink($gltr_merged_image);
|
---|
149 | update_option('gltr_base_lang', $_POST['gltr_base_lang']);
|
---|
150 | update_option('gltr_col_num', $_POST['gltr_col_num']);
|
---|
151 | update_option('gltr_html_bar_tag', $_POST['gltr_html_bar_tag']);
|
---|
152 | update_option('gltr_my_translation_engine', $_POST['gltr_my_translation_engine']);
|
---|
153 | update_option('gltr_preferred_languages', array());
|
---|
154 | update_option('gltr_preferred_languages', $_POST['gltr_preferred_languages']);
|
---|
155 | update_option("gltr_last_connection_time",time());
|
---|
156 | update_option("gltr_translation_status","unknown");
|
---|
157 | $diff_time = -1;
|
---|
158 |
|
---|
159 | $conn_int = $_POST['gltr_conn_interval'];
|
---|
160 | if (!is_numeric($conn_int))$conn_int = 300;
|
---|
161 | update_option('gltr_conn_interval', $conn_int);
|
---|
162 | $gltr_conn_interval = $conn_int;
|
---|
163 |
|
---|
164 | $exp_time = $_POST['gltr_cache_expire_time'];
|
---|
165 | if (!is_numeric($exp_time))$exp_time = 30;
|
---|
166 | update_option('gltr_cache_expire_time', $exp_time);
|
---|
167 | $gltr_cache_expire_time = $exp_time;
|
---|
168 |
|
---|
169 |
|
---|
170 | if(isset($_POST['gltr_ban_prevention']))
|
---|
171 | update_option('gltr_ban_prevention', true);
|
---|
172 | else
|
---|
173 | update_option('gltr_ban_prevention', false);
|
---|
174 |
|
---|
175 | if(isset($_POST['gltr_sitemap_integration']))
|
---|
176 | update_option('gltr_sitemap_integration', true);
|
---|
177 | else
|
---|
178 | update_option('gltr_sitemap_integration', false);
|
---|
179 |
|
---|
180 | if(isset($_POST['gltr_compress_cache']))
|
---|
181 | update_option('gltr_compress_cache', true);
|
---|
182 | else
|
---|
183 | update_option('gltr_compress_cache', false);
|
---|
184 |
|
---|
185 |
|
---|
186 | if(isset($_POST['gltr_enable_debug']))
|
---|
187 | update_option('gltr_enable_debug', true);
|
---|
188 | else
|
---|
189 | update_option('gltr_enable_debug', false);
|
---|
190 |
|
---|
191 |
|
---|
192 | $wp_rewrite->flush_rules();
|
---|
193 | $message = "Options saved.";
|
---|
194 | }
|
---|
195 | }
|
---|
196 | }
|
---|
197 | } else {
|
---|
198 | //page loaded by menu: retrieve stored options
|
---|
199 | $gltr_base_lang = get_option('gltr_base_lang');
|
---|
200 | $gltr_col_num = get_option('gltr_col_num');
|
---|
201 | $gltr_html_bar_tag = get_option('gltr_html_bar_tag');
|
---|
202 | $gltr_my_translation_engine = get_option('gltr_my_translation_engine');
|
---|
203 | $gltr_preferred_languages = get_option('gltr_preferred_languages');
|
---|
204 | $gltr_ban_prevention = get_option('gltr_ban_prevention');
|
---|
205 | $gltr_sitemap_integration = get_option('gltr_sitemap_integration');
|
---|
206 | $gltr_compress_cache = get_option('gltr_compress_cache');
|
---|
207 |
|
---|
208 | $gltr_enable_debug = get_option('gltr_enable_debug');
|
---|
209 | $gltr_conn_interval = get_option('gltr_conn_interval');
|
---|
210 | $gltr_cache_expire_time = get_option('gltr_cache_expire_time');
|
---|
211 |
|
---|
212 |
|
---|
213 | $gltr_current_engine = $gltr_available_engines[$gltr_my_translation_engine];
|
---|
214 | $gltr_lang_matrix = $gltr_current_engine->get_languages_matrix();
|
---|
215 | if (count($gltr_preferred_languages) == 0) {
|
---|
216 | $i = 0;
|
---|
217 | foreach($gltr_lang_matrix[$gltr_base_lang] as $lang_key => $lang_value){
|
---|
218 | if ($lang_key == $gltr_base_lang) continue;
|
---|
219 | $gltr_preferred_languages[]=$lang_key;
|
---|
220 | $i++;
|
---|
221 | }
|
---|
222 | update_option('gltr_preferred_languages', $gltr_preferred_languages);
|
---|
223 | }
|
---|
224 |
|
---|
225 | $cachedir = $gltr_cache_dir;
|
---|
226 |
|
---|
227 | $message = "";
|
---|
228 |
|
---|
229 | if (!is_writeable(dirname(__file__))){
|
---|
230 | $message = "Unable to complete Global Translator initialization. Please make writable and readable the following directory:
|
---|
231 | <ul><li>".dirname(__file__)."</li></ul>";
|
---|
232 | } else
|
---|
233 | if (!is_dir($cachedir) && (!is_readable(WP_CONTENT_DIR) || !is_writable(WP_CONTENT_DIR) )){
|
---|
234 | $message = "Unable to complete Global Translator initialization. Please make writable and readable the following directory:
|
---|
235 | <ul><li>".WP_CONTENT_DIR."</li></ul>";
|
---|
236 | } else {
|
---|
237 |
|
---|
238 | if (!is_dir($cachedir)){
|
---|
239 | if(!mkdir($cachedir, 0777)){
|
---|
240 | $message = "Unable to complete Global Translator initialization. Please manually create and make readable and writeable the following directory:
|
---|
241 | <ul><li>".WP_CONTENT_DIR."</li></ul>";
|
---|
242 | }
|
---|
243 | } else if (!is_readable($cachedir) || !is_writable($cachedir) ){
|
---|
244 | $message = "Unable to complete Global Translator initialization. Please make readable and writeable the following directory:
|
---|
245 | <ul><li>".$cachedir."</li></ul>";
|
---|
246 | }
|
---|
247 |
|
---|
248 | if (is_dir($cachedir) && is_readable($cachedir) && is_writable($cachedir)){
|
---|
249 | $staledir = $gltr_stale_dir;
|
---|
250 | if (!is_dir($staledir)){
|
---|
251 | if(!mkdir($staledir, 0777)){
|
---|
252 | $message = "Unable to complete Global Translator initialization. Please manually create and make readable and writeable the following directory:
|
---|
253 | <ul><li>".$cachedir."</li></ul>";
|
---|
254 | }
|
---|
255 | } else if (!is_readable($staledir) || !is_writable($staledir) ){
|
---|
256 | $message = "Unable to complete Global Translator initialization. Please make readable and writeable the following directory:
|
---|
257 | <ul><li>".$staledir."</li></ul>";
|
---|
258 | }
|
---|
259 | }
|
---|
260 |
|
---|
261 | //check files
|
---|
262 | /*
|
---|
263 | $datafiles = array();
|
---|
264 | foreach($datafiles as $datafile){
|
---|
265 | if(!is_file($datafile)){
|
---|
266 | if (!gltr_create_file($datafile)){
|
---|
267 | $message .= "Unable to complete Global Translator initialization. Please create and make readable and writeable the following file:
|
---|
268 | <ul><li>".$datafile."</li></ul><br />";
|
---|
269 | }
|
---|
270 | } else if (!is_readable($datafile) || !is_writeable($datafile)){
|
---|
271 | $message .= "Unable to complete Global Translator initialization. Please make readable and writeable the following file:
|
---|
272 | <ul><li>".$datafile."</li></ul><br />";
|
---|
273 | }
|
---|
274 | }
|
---|
275 | */
|
---|
276 | }
|
---|
277 | }
|
---|
278 |
|
---|
279 | //foreach($gltr_preferred_languages as $key => $value){echo "$value<br>";}
|
---|
280 |
|
---|
281 |
|
---|
282 | /*Get options for form fields*/
|
---|
283 | $gltr_current_engine = $gltr_available_engines[$gltr_my_translation_engine];
|
---|
284 | $gltr_lang_matrix = $gltr_current_engine->get_languages_matrix();
|
---|
285 |
|
---|
286 |
|
---|
287 | function gltr_build_js_function($base_lang, $selected_item) {
|
---|
288 | global $gltr_current_engine;
|
---|
289 | global $gltr_lang_matrix;
|
---|
290 | ?>
|
---|
291 | <script type="text/javascript">
|
---|
292 | calculateOptions('<?php echo $base_lang ?>', <?php echo $selected_item ?>);
|
---|
293 |
|
---|
294 | function languageItem(lang, flags_num){
|
---|
295 | this.lang=lang;
|
---|
296 | this.flags_num=flags_num;
|
---|
297 | }
|
---|
298 |
|
---|
299 | function calculateOptions(lang, selectedItem) {
|
---|
300 | var flags_num = 0;
|
---|
301 | var list = new Array();
|
---|
302 | <?php
|
---|
303 | $j=0;
|
---|
304 | foreach($gltr_lang_matrix as $key => $value){
|
---|
305 | echo " list[$j] = new languageItem('$key', " . count($gltr_lang_matrix[$key]) . ");\n";
|
---|
306 | $j++;
|
---|
307 | }
|
---|
308 | ?>
|
---|
309 | for (z = 0; z < document.forms['form1'].gltr_col_num.options.length; z++) {
|
---|
310 | document.forms['form1'].gltr_col_num.options[z] = null;
|
---|
311 | }
|
---|
312 | document.forms['form1'].gltr_col_num.options.length = 0;
|
---|
313 |
|
---|
314 | for (y = 0; y < list.length; y++) {
|
---|
315 | if (list[y].lang == lang){
|
---|
316 | flags_num = list[y].flags_num;
|
---|
317 | break;
|
---|
318 | }
|
---|
319 | }
|
---|
320 | for (i = 0; i < flags_num; i++) {
|
---|
321 | if (i == 0) {
|
---|
322 | opt_text='all the flags in a single row (default)';
|
---|
323 | } else if (i == 1) {
|
---|
324 | opt_text='1 flag for each row';
|
---|
325 | } else {
|
---|
326 | opt_text= i + ' flags for each row';
|
---|
327 | }
|
---|
328 |
|
---|
329 | if (i == 0)
|
---|
330 | document.forms['form1'].gltr_col_num.options[i]=new Option(opt_text, flags_num);
|
---|
331 | else
|
---|
332 | document.forms['form1'].gltr_col_num.options[i]=new Option(opt_text, i);
|
---|
333 | }
|
---|
334 |
|
---|
335 | //I need to cycle again on the options list in order to correctly choose the selected item
|
---|
336 | for (i = 0; i < flags_num; i++) {
|
---|
337 | document.forms['form1'].gltr_col_num.options[i].selected = (selectedItem == i);
|
---|
338 | }
|
---|
339 | }
|
---|
340 |
|
---|
341 | function calculateAvailableTranslations(lang, selectedItem) {
|
---|
342 | var list = new Array();
|
---|
343 | <?php
|
---|
344 | $j=0;
|
---|
345 | foreach($gltr_lang_matrix as $key => $value){
|
---|
346 | echo " list[$j] = new languageItem('$key', " . count($gltr_lang_matrix[$key]) . ");\n";
|
---|
347 | $j++;
|
---|
348 | }
|
---|
349 | ?>
|
---|
350 | for (z = 0; z < document.forms['form1'].gltr_col_num.options.length; z++) {
|
---|
351 | document.forms['form1'].gltr_col_num.options[z] = null;
|
---|
352 | }
|
---|
353 | document.forms['form1'].gltr_col_num.options.length = 0;
|
---|
354 |
|
---|
355 | for (y = 0; y < list.length; y++) {
|
---|
356 | if (list[y].lang == lang){
|
---|
357 | flags_num = list[y].flags_num;
|
---|
358 | break;
|
---|
359 | }
|
---|
360 | }
|
---|
361 | for (i = 0; i <= flags_num; i++) {
|
---|
362 | if (i == 0) {
|
---|
363 | opt_text='all the flags in a single row (default)';
|
---|
364 | } else if (i == 1) {
|
---|
365 | opt_text='1 flag for each row';
|
---|
366 | } else {
|
---|
367 | opt_text= i + ' flags for each row';
|
---|
368 | }
|
---|
369 | document.forms['form1'].gltr_col_num.options[i]=new Option(opt_text, i);
|
---|
370 | }
|
---|
371 |
|
---|
372 | //I need to cycle again on the options list in order to correctly choose the selected item
|
---|
373 | for (i = 0; i <= flags_num; i++) {
|
---|
374 | document.forms['form1'].gltr_col_num.options[i].selected = (selectedItem == i);
|
---|
375 | }
|
---|
376 | }
|
---|
377 | </script>
|
---|
378 | <?php
|
---|
379 | }
|
---|
380 | /*
|
---|
381 | if (gltr_is_currently_banned()){
|
---|
382 | $message="<font color='red'>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.</font>";
|
---|
383 | }
|
---|
384 | */
|
---|
385 |
|
---|
386 | //Print out the message to the user, if any
|
---|
387 | if($message!="") { ?>
|
---|
388 |
|
---|
389 | <div class="updated"><strong><p>
|
---|
390 | <?php echo $message; ?>
|
---|
391 | </p></strong></div>
|
---|
392 |
|
---|
393 | <?php } else { ?>
|
---|
394 |
|
---|
395 | <?php } ?>
|
---|
396 |
|
---|
397 | <form name="test"></form>
|
---|
398 | <div class="wrap">
|
---|
399 | <h2><?php _e('Global Translator ')?><?php echo($gltr_VERSION);?></h2>
|
---|
400 | <form id="gltr_form" name="form1" method="post" action="<?php echo $location ?>">
|
---|
401 | <input type="hidden" name="stage" value="process" />
|
---|
402 | <input type="hidden" name="gltr_stats" value="<?php echo(($showstats==true)?"show":"hide");?>" />
|
---|
403 | <fieldset class="options">
|
---|
404 | <h3><?php _e('Choose your translation engine') ?></h3>
|
---|
405 | <table width="100%" cellpadding="5" class="editform">
|
---|
406 | <tr><td>
|
---|
407 | <label><input type="radio" onclick="document.forms['form1'].stage.value='change';document.forms['form1'].submit();"
|
---|
408 | <?php if($gltr_my_translation_engine==null || $gltr_my_translation_engine == 'google') {?> checked <?php } ?> name="gltr_my_translation_engine"
|
---|
409 | value="google"> <?php _e('Google Translation Services') ?>
|
---|
410 | </label>
|
---|
411 | </td></tr>
|
---|
412 | <tr><td>
|
---|
413 | <label><input type="radio" onclick="document.forms['form1'].stage.value='change';document.forms['form1'].submit();"
|
---|
414 | <?php if($gltr_my_translation_engine == 'promt') {?> checked <?php } ?> name="gltr_my_translation_engine"
|
---|
415 | value="promt"> <?php _e('Promt Online Translator') ?>
|
---|
416 | </label>
|
---|
417 | </td></tr>
|
---|
418 | <tr><td>
|
---|
419 | <label><input type="radio" onclick="document.forms['form1'].stage.value='change';document.forms['form1'].submit();"
|
---|
420 | <?php if($gltr_my_translation_engine == 'babelfish') {?> checked <?php } ?> name="gltr_my_translation_engine"
|
---|
421 | value="babelfish"> <?php _e('Altavista Babel Fish') ?>
|
---|
422 | </label>
|
---|
423 | </td></tr>
|
---|
424 | <tr><td>
|
---|
425 | <label><input type="radio" onclick="document.forms['form1'].stage.value='change';document.forms['form1'].submit();"
|
---|
426 | <?php if($gltr_my_translation_engine == 'freetransl') {?> checked <?php } ?> name="gltr_my_translation_engine"
|
---|
427 | value="freetransl"> <?php _e('FreeTranslator') ?>
|
---|
428 | </label>
|
---|
429 | </td></tr>
|
---|
430 | </table>
|
---|
431 | </fieldset>
|
---|
432 |
|
---|
433 | <fieldset class="options">
|
---|
434 | <h3><?php _e('Base settings') ?></h3>
|
---|
435 | <table width="100%" cellpadding="5" class="editform"><tr><td>
|
---|
436 | <label><?php _e('My Blog is written in:') ?>
|
---|
437 | <select name="gltr_base_lang" onchange="document.forms['form1'].stage.value='change';document.forms['form1'].submit();">
|
---|
438 | <?php
|
---|
439 | $languages = $gltr_current_engine->get_available_languages();
|
---|
440 | foreach($languages as $key => $value){
|
---|
441 | if ($gltr_base_lang == $key) {
|
---|
442 | ?>
|
---|
443 | <option value="<?php echo $key ?>" selected ><?php echo $value ?></option>
|
---|
444 | <?php
|
---|
445 | } else {
|
---|
446 | ?>
|
---|
447 | <option value="<?php echo $key ?>" ><?php echo $value ?></option>
|
---|
448 | <?php
|
---|
449 | }
|
---|
450 | }
|
---|
451 | ?>
|
---|
452 | </select>
|
---|
453 | </label>
|
---|
454 | </td></tr>
|
---|
455 | <tr><td><label><?php _e('Choose which translations you want to make available for your visitors:') ?><br/>
|
---|
456 | <table border="0">
|
---|
457 | <?php
|
---|
458 | foreach($gltr_lang_matrix as $key => $langs){
|
---|
459 | if ($gltr_base_lang == $key) {
|
---|
460 | $i = 0;
|
---|
461 | foreach($langs as $lang_key => $lang_value){
|
---|
462 | if ($gltr_base_lang == $lang_key) continue;
|
---|
463 | $chk_val = "";
|
---|
464 | if (count ($gltr_preferred_languages) == 0 || in_array($lang_key, $gltr_preferred_languages) )
|
---|
465 | $chk_val = "checked";
|
---|
466 | echo '<tr><td><input type="checkbox" name="gltr_preferred_languages[' . $i . ']" ' . $chk_val . ' value="' . $lang_key . '"></td>
|
---|
467 | <td><img src="' . gltr_get_flag_image($lang_key) . '"/></td><td>' . $lang_value . '</td></tr>';
|
---|
468 | $i++;
|
---|
469 | }
|
---|
470 | }
|
---|
471 | }
|
---|
472 | ?>
|
---|
473 | </table>
|
---|
474 | </td></tr></table>
|
---|
475 | </fieldset>
|
---|
476 |
|
---|
477 | <fieldset class="options">
|
---|
478 | <h3><?php _e('Flags bar layout') ?></h3>
|
---|
479 |
|
---|
480 | <table width="100%" cellpadding="5" class="editform">
|
---|
481 | <tr><td width="350">
|
---|
482 | <label><input type="radio" <?php if($gltr_html_bar_tag == 'TABLE') {?> checked <?php } ?> name="gltr_html_bar_tag" value="TABLE"> <?php _e('Enclose the flags inside a TABLE and show:') ?>
|
---|
483 | </label><br />
|
---|
484 | <label><input type="radio" <?php if($gltr_html_bar_tag == 'MAP') {?> checked <?php } ?> name="gltr_html_bar_tag" value="MAP"> <?php _e('Use a single and optimized image map and show:') ?>
|
---|
485 | </label>
|
---|
486 | </td>
|
---|
487 | <td>
|
---|
488 | <select name="gltr_col_num"/>
|
---|
489 | </td>
|
---|
490 | </tr>
|
---|
491 | <tr><td colspan=2>
|
---|
492 | <label><input type="radio" <?php if($gltr_html_bar_tag == 'DIV') {?> checked <?php } ?> name="gltr_html_bar_tag" value="DIV"> <?php _e('Enclose the flags inside a DIV (for CSS customization)') ?>
|
---|
493 | </label>
|
---|
494 | </td></tr>
|
---|
495 | </table>
|
---|
496 | </fieldset>
|
---|
497 |
|
---|
498 | <fieldset class="options">
|
---|
499 | <h3><?php _e('Cache management') ?></h3>
|
---|
500 | <table width="100%" cellpadding="5" class="editform">
|
---|
501 | <tr><td>
|
---|
502 |
|
---|
503 | 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.
|
---|
504 | 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
|
---|
505 | 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).
|
---|
506 | <br />
|
---|
507 | The cache invalidation will be automatically (and smartly) handled when a post is created, deleted or updated.
|
---|
508 | <br/><br/>
|
---|
509 | <?php if (function_exists('gzcompress')){?>
|
---|
510 | <label><input name="gltr_compress_cache" type="checkbox" id="gltr_compress_cache"
|
---|
511 | <?php if($gltr_compress_cache == TRUE) {?> checked="checked" <?php } ?> /> Enable cache compression (this will strongly decrease the disk space but could give some problems on certain hosts)</label>
|
---|
512 | <?php } else {?>
|
---|
513 | <input name="gltr_compress_cache" disabled="true" type="checkbox" id="gltr_compress_cache"/> Unable to provide cache compression feature: ZLIB not available on you php installation.</label>
|
---|
514 | <?php }?>
|
---|
515 | <br/><br/>
|
---|
516 | Schedule a page for a new translation if it has been cached more than
|
---|
517 | <input size="4" maxlength="5" name="gltr_cache_expire_time" type="text" id="gltr_cache_expire_time" value="<?php echo($gltr_cache_expire_time);?>"/> days ago ("0" means "never").
|
---|
518 | <br/>
|
---|
519 |
|
---|
520 | <h4>Cache statistics</h4>
|
---|
521 | <?php if ($showstats){ ?>
|
---|
522 | <ul>
|
---|
523 | <li>Your cache directory currently contains <strong><?php echo($gltr_cached_files_num)?></strong> successfully translated and cached pages.</li>
|
---|
524 | <li><strong>Cache directory size</strong>: <?php $size=round($gltr_cache_size/1024/1024,1); echo ($size);?> MB</li>
|
---|
525 | <li>Your stale directory currently contains <strong><?php echo($gltr_stale_files_num)?></strong> successfully translated and cached pages waiting for a new translation.</li>
|
---|
526 | <li><strong>Stale directory size</strong>: <?php $size=round($gltr_stale_size/1024/1024,1); echo ($size);?> MB</li>
|
---|
527 | </ul>
|
---|
528 | <input type="button" onclick="
|
---|
529 | document.forms['form1'].stage.value='change';
|
---|
530 | document.forms['form1'].gltr_stats.value='hide';
|
---|
531 | document.forms['form1'].submit();"
|
---|
532 | value="<<Hide" />
|
---|
533 | <?php }else{ ?>
|
---|
534 | <input type="button" onclick="
|
---|
535 | document.forms['form1'].stage.value='change';
|
---|
536 | document.forms['form1'].gltr_stats.value='show';
|
---|
537 | document.forms['form1'].submit();"
|
---|
538 | value="Show >>" />
|
---|
539 | <?php } ?>
|
---|
540 | <br />
|
---|
541 | </td></tr>
|
---|
542 | <tr><td>
|
---|
543 | <label>
|
---|
544 |
|
---|
545 | <!-- <input type="submit" name="gltr_erase_cache" value="<?php _e('Erase cache') ?> »" /> -->
|
---|
546 | </label>
|
---|
547 | </td></tr>
|
---|
548 | </table>
|
---|
549 | </fieldset>
|
---|
550 |
|
---|
551 | <fieldset class="options">
|
---|
552 | <h3><?php _e('Translation engine connection') ?></h3>
|
---|
553 | <table width="100%" cellpadding="5" class="editform">
|
---|
554 | <tr><td>
|
---|
555 | <label><?php _e('Allow only a translation request every ') ?>
|
---|
556 | <input size="4" maxlength="5" name="gltr_conn_interval" type="text" id="gltr_conn_interval" value="<?php echo($gltr_conn_interval);?>"/> seconds.</label><br /><br />
|
---|
557 | This feature represents the solution which can definitively prevent your blog from being banned by the translation engines.<br />
|
---|
558 | 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.<br />
|
---|
559 | 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
|
---|
560 | increase the timeout value and wait for a while (some days could be necessary).<br /><br />
|
---|
561 | <ul>
|
---|
562 | <?php
|
---|
563 | //$diff_time = gltr_get_last_cached_file_time();
|
---|
564 |
|
---|
565 | if ($diff_time > 0){
|
---|
566 | echo ("<li>Latest allowed connection to the translation engine: <strong>");
|
---|
567 | if ($diff_time < 60){
|
---|
568 | echo (round(($diff_time)) . " seconds ago</strong>");
|
---|
569 | }else if ($diff_time > 60*60){
|
---|
570 | echo (round(($diff_time)/3600) . " hours ago</strong>");
|
---|
571 |
|
---|
572 | }else{
|
---|
573 | echo (round(($diff_time)/60) . " minutes ago</strong>");
|
---|
574 | }
|
---|
575 | /*
|
---|
576 | global $gltr_last_cached_url;
|
---|
577 | if (strlen($gltr_last_cached_url)>0){
|
---|
578 | echo (". [<a target='_blank' href='$gltr_last_cached_url'>See latest translated page</a>]");
|
---|
579 | }
|
---|
580 | */
|
---|
581 | } else {
|
---|
582 | echo ("<li>Latest allowed connection to the translation engine: <strong>not available</strong>");
|
---|
583 | }
|
---|
584 | echo ("</li>");
|
---|
585 |
|
---|
586 | echo ("<li><strong>Translations status</strong>:");
|
---|
587 | $ban_status = get_option("gltr_translation_status");
|
---|
588 | if ($ban_status == 'banned'){
|
---|
589 | echo("<strong><font color='red'>Bad or unhandled response from the '".strtoupper(get_option('gltr_my_translation_engine'))."' translation engine.</font></strong> This could mean that:
|
---|
590 | <ul><li>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</li>
|
---|
591 | <li>The translation engine is currently not responding/working: wait for some days or switch to another translation engine</li>
|
---|
592 | <li>The translation engine has changed something (i.e. the translation url): wait for the next release of Global Translator :-)</li>
|
---|
593 | <li>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</li></font>");
|
---|
594 | } else if ($ban_status == 'working'){
|
---|
595 | echo("<strong><font color='green'>Working properly</font></strong>");
|
---|
596 | } else {
|
---|
597 | echo("<strong>not available</strong>");
|
---|
598 | }
|
---|
599 | echo ("</li>");
|
---|
600 | ?>
|
---|
601 | </ul>
|
---|
602 |
|
---|
603 |
|
---|
604 |
|
---|
605 | </td></tr>
|
---|
606 | </table>
|
---|
607 | </fieldset>
|
---|
608 |
|
---|
609 |
|
---|
610 | <fieldset class="options">
|
---|
611 | <h3><?php _e('Bad spiders blocking system') ?></h3>
|
---|
612 | <table width="100%" cellpadding="5" class="editform">
|
---|
613 | <tr><td>
|
---|
614 | <label><?php _e('Block "bad" web spiders and crawlers') ?>
|
---|
615 | <input name="gltr_ban_prevention" type="checkbox" id="gltr_ban_prevention"
|
---|
616 | <?php if($gltr_ban_prevention == TRUE) {?> checked="checked" <?php } ?> /></label>
|
---|
617 | <br /> <br />
|
---|
618 | By enabling this option, Global Translator will block the access to the translated pages to a lot of "bad" web spiders.
|
---|
619 | This function could help the <strong>built-in cache</strong> to prevent "unuseful" translation requests expecially if you have an high-traffic blog.<br />
|
---|
620 | If you have a low traffic blog I suggest you to disable this option.
|
---|
621 |
|
---|
622 | </td></tr>
|
---|
623 | </table>
|
---|
624 | </fieldset>
|
---|
625 |
|
---|
626 | <fieldset class="options">
|
---|
627 | <h3><?php _e('Sitemap integration') ?></h3>
|
---|
628 | <table width="100%" cellpadding="5" class="editform">
|
---|
629 | <tr><td>
|
---|
630 | <?php
|
---|
631 | if (gltr_sitemap_plugin_detected()){?>
|
---|
632 | <label>
|
---|
633 | <?php _e('Enable sitemap integration') ?>
|
---|
634 | <input name="gltr_sitemap_integration" type="checkbox" id="gltr_sitemap_integration"
|
---|
635 | <?php if($gltr_sitemap_integration == TRUE) {?> checked="checked" <?php } ?> /></label>
|
---|
636 | <br /><br />
|
---|
637 | By enabling this option, Global Translator will automatically provide the translated urls to the "<strong>Google XML Sitemaps Generator for WordPress</strong>" plugin.<br />
|
---|
638 | After the next sitemap rebuild, all the translated urls will be added to your sitemap.xml file.<br />
|
---|
639 | 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
|
---|
640 | enable the <strong>"Build the sitemap in a background process"</strong> option from the "<strong>Google XML Sitemaps Generator for WordPress</strong>"
|
---|
641 | admin page, otherwise the post saving/publishing actions could become unresponsive.
|
---|
642 |
|
---|
643 | <?php
|
---|
644 | } else {?>
|
---|
645 | <label>"Google XML Sitemaps Generator for WordPress" not detected.<br />
|
---|
646 | Please download, install and activate the "<a target="_blank" href="http://www.arnebrachhold.de/projects/wordpress-plugins/google-xml-sitemaps-generator/">Google XML Sitemaps Generator for WordPress 3.*</a>" in order to enable this feature.
|
---|
647 | </label>
|
---|
648 | <?php
|
---|
649 | }?>
|
---|
650 | </td></tr>
|
---|
651 | </table>
|
---|
652 | </fieldset>
|
---|
653 |
|
---|
654 | <fieldset class="options">
|
---|
655 | <h3><?php _e('Debug') ?></h3>
|
---|
656 | <table width="100%" cellpadding="5" class="editform">
|
---|
657 | <tr><td>
|
---|
658 | <label><?php _e('Enable debug') ?>
|
---|
659 | <input name="gltr_enable_debug" type="checkbox" id="gltr_enable_debug"
|
---|
660 | <?php if($gltr_enable_debug == TRUE) {?> checked="checked" <?php } ?> /><br /> <br />
|
---|
661 | By enabling this option, Global Translator will trace all its activities on the <strong>"debug.log"</strong> file, which will be saved in the following directory:<br/>
|
---|
662 | <strong><?php echo(dirname(__file__));?></strong>.<br />
|
---|
663 | </label>
|
---|
664 | </td></tr>
|
---|
665 | </table>
|
---|
666 | </fieldset>
|
---|
667 |
|
---|
668 | <p class="submit">
|
---|
669 | <input type="submit" name="gltr_save" value="<?php _e('Update options') ?> »" />
|
---|
670 | </p>
|
---|
671 | <br /><br />
|
---|
672 | <fieldset class="options">
|
---|
673 | <h3><?php _e('Thanks for using this plugin!') ?></h3>
|
---|
674 | <strong><p><?php echo __('If you are satisfied with the results, isn\'t it worth at least one dollar?
|
---|
675 | <a href="http://www.nothing2hide.net/donate_global_translator.php">Donations</a> help me to continue support and development of this <i>free</i> software! '); ?>
|
---|
676 | </p></strong>
|
---|
677 | </fieldset>
|
---|
678 |
|
---|
679 | <fieldset class="options">
|
---|
680 | <h3><?php _e('Advanced functions and support') ?></h3>
|
---|
681 | <p><?php echo str_replace("%s","<a href=\"http://www.nothing2hide.net/global-translator-pro/\">http://www.nothing2hide.net/global-translator-pro/</a>",
|
---|
682 | __("Check %s if you need a supported version with more and advanced functions")); ?></p>
|
---|
683 | </fieldset>
|
---|
684 | </form>
|
---|
685 | </div>
|
---|
686 |
|
---|
687 | <?php
|
---|
688 | if (!is_numeric($gltr_col_num))$gltr_col_num = 0;
|
---|
689 | gltr_build_js_function($gltr_base_lang, $gltr_col_num);
|
---|
690 | ?> |
---|