Changeset 366 for trunk/import/import_dbc.php
- Timestamp:
- Mar 9, 2010, 1:01:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/import/import_dbc.php
r365 r366 1 1 <?php 2 /*3 DELETE FROM `gametips` WHERE ID > 266;4 DELETE FROM `spell` WHERE ID > 43672;5 UPDATE `gametips` SET VersionStart = 8606,VersionEnd = 8606;6 UPDATE `spell` SET VersionStart = 8606,VersionEnd = 8606;7 DELETE FROM `Log` WHERE Type = 11;8 */9 10 2 11 12 function ImportDBC($import_version,$GroupId) 3 function ImportDBC($import_version, $GroupId) 13 4 { 14 5 global $Database, $TranslationTree, $Config; 6 15 7 $BuildNumber = GetBuildNumber($import_version); 16 8 17 9 echo('Načítání textů z DBC souborů...'); 18 10 $Group = $TranslationTree[$GroupId]; 19 20 21 11 if(($Group['DBCFileName'] != '') and ($Group['TablePrefix'] != '')) 12 { 13 echo('<br />'.$Group['Name'].'<br />'); 22 14 $DBCFile = new DBCFile(); 23 15 $DBCFile->OpenFile('../source/'.$import_version.'/dbc/'.$Group['DBCFileName'].'.dbc', GetDBCColumns($import_version,$Group['DBCFileName'])); … … 26 18 $Count = 0; 27 19 for($i = 0; $i < $ItemCount; $i++) 20 { 21 foreach($Group['Items'] as $GroupItem) 28 22 { 29 foreach($Group['Items'] as $GroupItem) 30 { 31 $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($i, GetDBCColumnIndex($import_version,$Group['DBCFileName'],$GroupItem['Column']))); 32 } 23 $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($i, GetDBCColumnIndex($import_version,$Group['DBCFileName'],$GroupItem['Column']))); 24 } 33 25 34 35 36 37 38 39 26 $Columns = ''; 27 foreach($Group['Items'] as $GroupItem) 28 { 29 $Columns .= ', '.$GroupItem['Column'].' '; 30 } 31 $Columns = substr($Columns, 1); 40 32 41 42 $DbResult2 = $Database->SQLCommand('SELECT VersionEnd, ID, entry, '.$Columns.' FROM '.$Group['TablePrefix'].' WHERE entry='.$ItemId.' AND Language=0 ORDER BY VersionStartDESC LIMIT 1');43 33 $ItemId = $DBCFile->GetUint($i, 0); 34 $DbResult2 = $Database->SQLCommand('SELECT `VersionEnd`, `ID`, `Entry`, '.$Columns.' FROM `'.$Group['TablePrefix'].'` WHERE `Entry`='.$ItemId.' AND `Language`=0 ORDER BY `VersionStart` DESC LIMIT 1'); 35 if(isset($DbResult2) and (mysql_num_rows($DbResult2) > 0)) 44 36 { 45 // Update existed text 46 $DbRow2 = mysql_fetch_assoc($DbResult2); 47 if(HaveSameText($Group, $DbRow2, $Value)) 48 { 49 if ($DbRow2['VersionEnd'] <> $BuildNumber) { 50 $Database->SQLCommand('UPDATE `'.$Group['TablePrefix'].'` SET VersionEnd = "'.$BuildNumber.'" WHERE ID='.$DbRow2['ID']); 51 echo(', '); 52 } else 53 echo('. '); 54 } else 55 { 56 $Columns = 'entry, language, VersionStart, VersionEnd'; 57 $Values = $DbRow2['entry'].', 0, '.$BuildNumber.', '.$BuildNumber; 58 foreach($Group['Items'] as $GroupItem) 59 { 60 $Columns .= ', `'.$GroupItem['Column'].'`'; 61 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 62 } 63 $Database->SQLCommand('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 64 echo('# '); 65 WriteLog('Text <a href="form.php?group='.$Group['Id'].'&ID='.mysql_insert_id().'">'.mysql_insert_id().'</a> ('.$DbRow2['entry'].') ze skupiny '.$Group['Name'].' byl v nové verzi '.$import_version.' změněn.', LOG_TYPE_IMPORT); 66 } 67 37 // Update existed text 38 $DbRow2 = mysql_fetch_assoc($DbResult2); 39 if(HaveSameText($Group, $DbRow2, $Value)) 40 { 41 if ($DbRow2['VersionEnd'] <> $BuildNumber) 42 { 43 $Database->SQLCommand('UPDATE `'.$Group['TablePrefix'].'` SET `VersionEnd` = "'.$BuildNumber.'" WHERE `ID`='.$DbRow2['ID']); 44 echo(', '); 45 } else echo('. '); 46 } else 47 { 48 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; 49 $Values = $DbRow2['entry'].', 0, '.$BuildNumber.', '.$BuildNumber; 50 foreach($Group['Items'] as $GroupItem) 51 { 52 $Columns .= ', `'.$GroupItem['Column'].'`'; 53 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 54 } 55 $Database->SQLCommand('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 56 echo('# '); 57 WriteLog('Text <a href="form.php?group='.$Group['Id'].'&ID='.mysql_insert_id().'">'.mysql_insert_id().'</a> ('.$DbRow2['entry'].') ze skupiny '.$Group['Name'].' byl v nové verzi '.$import_version.' změněn.', LOG_TYPE_IMPORT); 58 } 68 59 } else 69 60 { 70 71 $Columns = 'entry, language, VersionStart, VersionEnd';72 73 74 75 76 77 78 79 80 81 61 // Insert new text 62 $Columns = '`Entry`, `Language`, `VersionStart`, `VersionEnd`'; 63 $Values = $ItemId.', 0, '.$BuildNumber.', '.$BuildNumber; 64 foreach($Group['Items'] as $GroupItem) 65 { 66 $Columns .= ', `'.$GroupItem['Column'].'`'; 67 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 68 } 69 $Database->SQLCommand('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 70 echo('+ '); 71 $NewCount++; 72 WriteLog('Text <a href="form.php?group='.$Group['Id'].'&ID='.mysql_insert_id().'">'.mysql_insert_id().'</a> ('.$ItemId.') ze skupiny '.$Group['Name'].' byl v nové verzi '.$import_version.' přidán.', LOG_TYPE_IMPORT); 82 73 83 74 } 84 85 75 $Count++; 76 } 86 77 echo('<br />Celkem: '.$Count.' Nových: '.$NewCount.'<br />'); 87 $Database->SQLCommand('UPDATE `group` SET LastVersion = "'.$BuildNumber.'", LastImport = NOW() WHERE Id='.$GroupId);78 $Database->SQLCommand('UPDATE `Group` SET `LastVersion` = "'.$BuildNumber.'", `LastImport` = NOW() WHERE `Id`='.$GroupId); 88 79 } 89 80 echo('<strong>Dokončeno.</strong>');
Note:
See TracChangeset
for help on using the changeset viewer.