>From e05d64a3041dcfdf2dc9e6e599581c60874dfc8c Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Tue, 21 Jul 2009 17:29:52 +0200 Subject: [PATCH] Fix some php warnings while trying to deal with non-existing files --- transl/php/lang.php | 85 ++++++++++++++++++++++++++++----------------------- 1 files changed, 47 insertions(+), 38 deletions(-) diff --git a/transl/php/lang.php b/transl/php/lang.php index 2dfb7c7..1ecb4fa 100644 --- a/transl/php/lang.php +++ b/transl/php/lang.php @@ -4,55 +4,56 @@ include_once("lib.php"); $lang = validate_lang($_REQUEST['lang']); -$file = fopen("$DATAROOT/langs/$lang", "r"); $transl = array(); $notransl = array(); $partial = array(); -$curr_file = ""; -while ($line = fgets($file, 4096)) + +function parse_file($lang) { - if (preg_match("/FILE ([A-Z]+) (.*) ([0-9]+) ([0-9]+) ([0-9]+)/", $line, $m)) + global $transl, $partial, $notransl; + global $DATAROOT; + if (!file_exists("$DATAROOT/langs/$lang")) + return; + + $file = fopen("$DATAROOT/langs/$lang", "r"); + $curr_file = ""; + while ($line = fgets($file, 4096)) { - $curr_file = $m[2]; - if ($m[1] == "NONE") + if (preg_match("/FILE ([A-Z]+) (.*) ([0-9]+) ([0-9]+) ([0-9]+)/", $line, $m)) { - $notransl[$curr_file] = array($m[3], $m[4], $m[5], 0); - continue; - } - - if ($m[4]>0 || $m[5]>0) - { - $partial[$curr_file] = array($m[3], $m[4], $m[5], 0); - continue; + $curr_file = $m[2]; + if ($m[1] == "NONE") + { + $notransl[$curr_file] = array($m[3], $m[4], $m[5], 0); + continue; + } + + if ($m[4]>0 || $m[5]>0) + { + $partial[$curr_file] = array($m[3], $m[4], $m[5], 0); + continue; + } + + $transl[$curr_file] = array($m[3], $m[4], $m[5], 0); } - - $transl[$curr_file] = array($m[3], $m[4], $m[5], 0); - } - if (preg_match(",$curr_file: Warning: ,", $line, $m)) - { - if (array_key_exists($curr_file, $transl)) + if (preg_match(",$curr_file: Warning: ,", $line, $m)) { - $partial[$curr_file] = $transl[$curr_file]; - unset($transl[$curr_file]); - } + if (array_key_exists($curr_file, $transl)) + { + $partial[$curr_file] = $transl[$curr_file]; + unset($transl[$curr_file]); + } - if (array_key_exists($curr_file, $partial)) /* should be true - warning for $notransl shouldn't happen */ - $partial[$curr_file][3]++; + if (array_key_exists($curr_file, $partial)) /* should be true - warning for $notransl shouldn't happen */ + $partial[$curr_file][3]++; + } } + fclose($file); + ksort($transl); + ksort($partial); + ksort($notransl); } -fclose($file); -ksort($transl); -ksort($partial); -ksort($notransl); -?> - - - - - <?php echo get_lang_name($lang) ?> language - Wine translations - -\n"; } - ?> + + + + + + <?php echo get_lang_name($lang) ?> language - Wine translations + +

>