source: client_files/Generate/create_language_file.php@ 40

Last change on this file since 40 was 40, checked in by george, 16 years ago
  • Upraveno: Změna kódování znaků souborů na UTF-8.
File size: 3.8 KB
Line 
1<?php
2 session_start();
3 include('../../includes/config.php');
4 include('../../includes/databaseconection.php');
5 include('../../includes/global_function.php');
6
7 //připojení do databáze
8 $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password']);
9 $Database->SQLCommand('SET NAMES '.$Config['Database']['Charset']);
10 $Database->SelectDatabase($Config['Database']['Database']);
11
12 if (Licence(2)) { // echo 'Přístup povolen';
13 } else { die('Přístup zamítnut!'); }
14
15 include ('define.php');
16
17 function ReplaceVarInText($string)
18 { // BEGIN function ReplaceVarInText
19 $string = str_replace('$N', '"..strlower(UnitName("player")).."', $string);
20 $string = str_replace('$n', '"..strlower(UnitName("player")).."', $string);
21 $string = str_replace('$c', '"..strlower(UnitClass("player")).."', $string);
22 $string = str_replace('$C', '"..strlower(UnitClass("player")).."', $string);
23 $string = str_replace('$R', '"..strlower(UnitRace("player")).."', $string);
24 $string = str_replace('$r', '"..strlower(UnitRace("player")).."', $string);
25
26 $string = str_replace('$', '', $string);
27 $string = str_replace(chr(13), '', $string);
28 $string = str_replace(chr(10), '', $string);
29 return $string;
30 } // END function ReplaceVarInText
31
32 //funkce na přepsání zlých znaků
33
34 function ReplaceEnText($string)
35 { // BEGIN function ReplaceBadChar
36 // $string = mysql_escape_string($string);
37 $string = strtolower($string);
38 $string = str_replace('$gman:woman;', '"..gsub(gsub(UnitSex("player"), "^2$", "man"), "^3$", "woman").."', $string);
39 $string = str_replace('$g man : woman;', '"..gsub(gsub(UnitSex("player"), "^2$", "man"), "^3$", "woman").."', $string);
40 $string = str_replace('$ghis:her;', '"..gsub(gsub(UnitSex("player"), "^2$", "his"), "^3$", "her").."', $string);
41 $string = str_replace('$g his : her;', '"..gsub(gsub(UnitSex("player"), "^2$", "his"), "^3$", "her").."', $string);
42 $string = str_replace('$glad:lass;', '"..gsub(gsub(UnitSex("lad"), "^2$", "his"), "^3$", "lass").."', $string);
43 $string = str_replace('$g lad : lass;', '"..gsub(gsub(UnitSex("lad"), "^2$", "his"), "^3$", "lass").."', $string);
44
45 $string = str_replace('"', '\"', $string);
46 $string = str_replace('$b$b', ' ', $string);
47 $string = str_replace('$b $b', ' ', $string);
48 $string = str_replace('$b', ' ', $string);
49 $string = str_replace(' ', ' ', $string);
50 $string = ReplaceVarInText($string);
51 return $string;
52 } // END function ReplaceBadChar
53
54 function ReplaceCzText($string)
55 { // BEGIN function ReplaceBadChar
56 $string = mysql_escape_string($string);
57 $string = str_replace('$B', '\r\n', $string);
58 $string = str_replace('$b', '\r\n', $string);
59 $string = ReplaceVarInText($string);
60 return $string;
61 } // END function ReplaceBadChar
62
63 for ($j=0; $j<count($ListFile); ++$j) { //hlavní ciklus souborů
64
65 echo $dir_out.$ListFile[$j]['File'].': ';
66 $i = 0;
67
68 $buffer = $ListFile[$j]['Header']; //hlavička souboru
69
70 $sql = $ListFile[$j]['sql'];
71 $ID = $Database->SQLCommand($sql);
72 while ($Line = mysql_fetch_array($ID)) {
73 $en = ReplaceEnText($Line['en']);
74 $cz = ReplaceCzText($Line['cz']);
75 if ($en <> '' and $cz <> '') {
76 $buffer = $buffer.'
77["'.$en.'"]="'.$cz.'",';
78 $i = $i + 1;
79 }
80 }
81
82 $buffer = $buffer.'
83'.$ListFile[0]['Footer'].'+'.$i.';
84'; //patička souboru
85
86 if ($i > 0) {
87
88 $file_handle = fopen($dir_out.$ListFile[$j]['File'], 'w');
89 $write_result = fwrite($file_handle, $buffer);
90 fclose($file_handle);
91
92 echo '<b>HOTOVO</b><br />';
93 } else {echo '<b>ŽÁDNÝ TEXT</b><br />';}
94 }
95
96?>
Note: See TracBrowser for help on using the repository browser.