Changeset 120 for trunk/export/export.php
- Timestamp:
- Feb 21, 2009, 7:38:18 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/export/export.php
r117 r120 167 167 global $Database, $Config, $TranslationTree; 168 168 169 $TempDir = 'tmp/'.$_SESSION['User'].'/dbc/';169 $TempDir = $Config['Web']['TempFolder'].$_SESSION['User'].'/dbc/'; 170 170 if(!file_exists($TempDir)) mkdir($TempDir, 0777, true); 171 171 … … 205 205 echo($Group['Name'].'... '); 206 206 $DBCFile = new DBCFile(); 207 $DBCFile->OpenFile(' dbc/'.$Group['DBCFileName'].'.dbc', $Group['DBCColumns']);207 $DBCFile->OpenFile('../source/'.$Config['Web']['GameVersion'].'/dbc/'.$Group['DBCFileName'].'.dbc', $Group['DBCColumns']); 208 208 $DBCFile2 = new DBCFile(); 209 209 $DBCFile2->CreateFile($TempDir.$Group['DBCFileName'].'.dbc', $Group['DBCColumns']); … … 235 235 } 236 236 237 function ExportToLua($Setting) 238 { 239 global $Database, $Config, $TranslationTree; 240 241 $TempDir = $Config['Web']['TempFolder'].$_SESSION['User'].'/lua/'; 242 if(!file_exists($TempDir)) mkdir($TempDir, 0777, true); 243 244 if($_SESSION['UserID'] != '') 245 { 246 $DbResult = $Database->SQLCommand('SELECT user FROM `user` WHERE ID='.$_SESSION['UserID']); 247 $User = mysql_fetch_assoc($DbResult); 248 } else $User = array('user' => 'Neznámý'); 249 250 $WhereLang = ''; 251 if($Setting['language-cz']) $WhereLang .= " OR (Language = 1)"; 252 if($Setting['language-sk']) $WhereLang .= " OR (Language = 2)"; 253 if($Setting['language-other']) $WhereLang .= " OR (Language = 3)"; 254 if($WhereLang == '') $WhereLang = 1; 255 else $WhereLang = '('.substr($WhereLang, 4).')'; 256 257 $SelectedUsers = ''; 258 foreach($Setting['users-selection'] as $Item) 259 $SelectedUsers .= ','.$Item; 260 $SelectedUsers = substr($SelectedUsers, 1); 261 262 if($SelectedUsers == '') $Where = 0; 263 else $Where = 'ID IN ('.$SelectedUsers.')'; 264 265 $UserNames = ''; 266 $DbResult = $Database->SQLCommand('SELECT user FROM `user` WHERE '.$Where); 267 while($DbRow = mysql_fetch_assoc($DbResult)) 268 $UserNames .= ','.$DbRow['user']; 269 $UserNames = substr($UserNames, 1); 270 271 if($SelectedUsers == '') $WhereUsers = 1; 272 else $WhereUsers = '(User IN ('.$SelectedUsers.'))'; 273 274 foreach($TranslationTree as $Group) 275 if(in_array($Group['Id'], $Setting['groups']) and ($Group['LuaFileName'] != '')) 276 { 277 echo($Group['Name'].'... '); 278 $File = new FileStream(); 279 $File->OpenFile('../source/'.$Config['Web']['GameVersion'].'/lua/'.$Group['LuaFileName'].'.lua'); 280 $File2 = new FileStream(); 281 $File2->CreateFile($TempDir.$Group['LuaFileName'].'.lua'); 282 283 while(!$File->EOF()) 284 { 285 $Line = $File->ReadLine(); 286 if(strpos($Line, '=') !== false) 287 { 288 $LineParts = explode(';', $Line); 289 $LineParts2 = explode('=', $LineParts[0]); 290 $Value['ShortCut'] = addslashes(trim($LineParts2[0])); 291 $Value['Text'] = addslashes(substr(trim($LineParts2[1]), 1, -1)); 292 $Value['Comment'] = addslashes(substr(trim($LineParts[1]), 3)); 293 294 $Query = 'SELECT * FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND '.$WhereLang.' AND '.$WhereUsers.' AND (ShortCut="'.$Value['ShortCut'].'") ORDER BY FIELD(User, '.$SelectedUsers.')) AS T GROUP BY T.entry'; 295 //echo($Query); 296 $DbResult = $Database->SQLCommand($Query); 297 if(mysql_num_rows($DbResult) > 0) 298 { 299 $DbRow = mysql_fetch_assoc($DbResult); 300 $Value['Text'] = $DbRow['Text']; 301 $Value['Comment'] = $DbRow['Comment']; 302 //echo('.'); 303 } 304 $File2->WriteLine($Value['ShortCut'].' = "'.$Value['Text'].'"; -- '.$Value['Comment']."\n"); 305 } else $File2->WriteLine($Line."\n"); 306 } 307 echo('Hotovo <br />'); 308 } 309 } 310 237 311 ?>
Note:
See TracChangeset
for help on using the changeset viewer.