Changeset 214 for trunk/import/index.php
- Timestamp:
- Jun 22, 2009, 9:22:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/import/index.php
r195 r214 3 3 include('../includes/global.php'); 4 4 include('../includes/dbc.php'); 5 6 function ImportSQLMangos() 7 { 8 global $Database, $TranslationTree, $Config; 9 10 echo('Načítání textů z databáze MaNGOSu...'); 11 foreach($TranslationTree as $Group) 12 { 13 if(($Group['MangosTable'] != '') and ($Group['TablePrefix'] != '')) 14 { 15 echo('<br />'.$Group['Name'].'<br />'); 16 $DbName = $Config['Database']['MangosPrefix'].$Group['MangosDatabase']; 17 $Columns = '`'.$DbName.'`.`'.$Group['MangosTable'].'`.`'.$Group['MangosTableIndex'].'`'; 18 $Where = ''; 19 foreach($Group['Items'] as $GroupItem) 20 { 21 $Columns .= ', `'.$DbName.'`.`'.$Group['MangosTable'].'`.`'.$GroupItem['MangosColumn'].'` AS `'.$GroupItem['Column'].'`'; 22 $Where .= ' OR `'.$DbName.'`.`'.$Group['MangosTable'].'`.`'.$GroupItem['MangosColumn'].'` != "" '; 23 } 24 $Where = substr($Where, 4); 25 $Query = 'SELECT '.$Columns.' FROM `'.$DbName.'`.`'.$Group['MangosTable'].'` WHERE '.$Where; 26 //echo($Query.'<br />'); 27 $Count = 0; 28 $NewCount = 0; 29 $DbResult = $Database->SQLCommand($Query); 30 while($DbRow = mysql_fetch_assoc($DbResult)) 31 { 32 //echo('SELECT ID FROM '.$Group['TablePrefix'].' WHERE entry='.$DbRow[$Group['MangosTableIndex']].' AND Language=0'."<br>"); 33 $DbResult2 = $Database->SQLCommand('SELECT ID FROM '.$Group['TablePrefix'].' WHERE entry='.$DbRow[$Group['MangosTableIndex']].' AND Language=0'); 34 if(isset($DbResult2) and (mysql_num_rows($DbResult2) > 0)) 35 { 36 $DbRow2 = mysql_fetch_assoc($DbResult2); 37 //echo($DbRow2['ID']); 38 $ColumnsValues = ''; 39 foreach($Group['Items'] as $GroupItem) 40 { 41 $ColumnsValues .= ', `'.$GroupItem['Column'].'`="'.addslashes($DbRow[$GroupItem['Column']]).'"'; 42 } 43 $ColumnsValues = substr($ColumnsValues, 2); 44 echo('. '); //'UPDATE `'.$Group['TablePrefix'].'` SET '.$ColumnsValues.' WHERE ID='.$DbRow2['ID']."<br>"); 45 //print_r($DbRow2); 46 $Database->SQLCommand('UPDATE `'.$Group['TablePrefix'].'` SET '.$ColumnsValues.' WHERE ID='.$DbRow2['ID']); 47 } else 48 { 49 $Columns = 'entry, language'; 50 $Values = $DbRow[$Group['MangosTableIndex']].', 0'; 51 foreach($Group['Items'] as $GroupItem) 52 { 53 $Columns .= ', `'.$GroupItem['Column'].'`'; 54 $Values .= ', "'.addslashes($DbRow[$GroupItem['Column']]).'"'; 55 } 56 //$Columns = substr($Columns, 2); 57 //$Values = substr($Values, 2); 58 $Database->SQLCommand('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 59 echo('# '); 60 //echo('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'."<br>"); 61 $NewCount++; 62 } 63 $Count++; 64 } 65 echo('<br />Celkem: '.$Count.' Nových: '.$NewCount.'<br />'); 66 } 67 } 68 echo('Dokončeno.</div>'); 69 } 70 71 function ImportDBC() 72 { 73 global $Database, $TranslationTree, $Config; 74 75 echo('Načítání textů z DBC souborů...'); 76 foreach($TranslationTree as $Group) 77 { 78 if(($Group['DBCFileName'] != '') and ($Group['TablePrefix'] != '')) 79 { 80 echo('<br />'.$Group['Name'].'<br />'); 81 $DBCFile = new DBCFile(); 82 $DBCFile->OpenFile('../source/'.$Config['Web']['GameVersion'].'/dbc/'.$Group['DBCFileName'].'.dbc', $Group['DBCColumns']); 83 $ItemCount = $DBCFile->GetRecordCount(); 84 $NewCount = 0; 85 $Count = 0; 86 for($i = 0; $i < $ItemCount; $i++) 87 { 88 $ItemId = $DBCFile->GetUint($i, 0); 89 $DbResult2 = $Database->SQLCommand('SELECT ID FROM '.$Group['TablePrefix'].' WHERE entry='.$ItemId.' AND Language=0'); 90 if(isset($DbResult2) and (mysql_num_rows($DbResult2) > 0)) 91 { 92 $DbRow2 = mysql_fetch_assoc($DbResult2); 93 //echo($DbRow2['ID']); 94 $ColumnsValues = ''; 95 foreach($Group['Items'] as $GroupItem) 96 { 97 $ColumnsValues .= ', `'.$GroupItem['Column'].'`="'.addslashes($DBCFile->GetString($i, $GroupItem['DBCColumnIndex'])).'"'; 98 } 99 $ColumnsValues = substr($ColumnsValues, 2); 100 echo('. '); //'UPDATE `'.$Group['TablePrefix'].'` SET '.$ColumnsValues.' WHERE ID='.$DbRow2['ID']."<br>"); 101 //print_r($DbRow2); 102 $Database->SQLCommand('UPDATE `'.$Group['TablePrefix'].'` SET '.$ColumnsValues.' WHERE ID='.$DbRow2['ID']); 103 } else 104 { 105 $Columns = 'entry, language'; 106 $Values = $ItemId.', 0'; 107 foreach($Group['Items'] as $GroupItem) 108 { 109 $Columns .= ', `'.$GroupItem['Column'].'`'; 110 $Values .= ', "'.addslashes($DBCFile->GetString($i, $GroupItem['DBCColumnIndex'])).'"'; 111 } 112 //$Columns = substr($Columns, 2); 113 //$Values = substr($Values, 2); 114 $Database->SQLCommand('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 115 echo('# '); 116 //echo('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'."<br>"); 117 $NewCount++; 118 } 119 $Count++; 120 } 121 echo('<br />Celkem: '.$Count.' Nových: '.$NewCount.'<br />'); 122 } 123 } 124 echo('Dokončeno.</div>'); 125 } 126 127 function ImportLUA() 128 { 129 global $Database, $TranslationTree, $PatchVersion, $Config; 130 131 echo('Načítání textů z LUA souborů...'); 132 foreach($TranslationTree as $Group) 133 { 134 if(($Group['LuaFileName'] != '') and ($Group['TablePrefix'] != '')) 135 { 136 echo('<br />'.$Group['Name'].'<br />'); 137 $File = new FileStream(); 138 $File->OpenFile('../source/'.$Config['Web']['GameVersion'].'/lua/'.$Group['LuaFileName'].'.lua'); 139 $NewCount = 0; 140 $Count = 0; 141 while(!$File->EOF()) 142 { 143 $Line = $File->ReadLine(); 144 if(strpos($Line, '=') !== false) 145 { 146 $LineParts = explode(';', $Line); 147 $LineParts2 = explode('=', $LineParts[0]); 148 $Value['ShortCut'] = trim($LineParts2[0]); 149 $Value['Text'] = substr(trim($LineParts2[1]), 1, -1); 150 $Value['Comment'] = addslashes(substr(trim($LineParts[1]), 3)); 151 152 $DbResult2 = $Database->SQLCommand('SELECT ID FROM '.$Group['TablePrefix'].' WHERE ShortCut="'.$Value['ShortCut'].'" AND (Language=0)'); 153 if(isset($DbResult2) and (mysql_num_rows($DbResult2) > 0)) 154 { 155 $ColumnsValues = ''; 156 foreach($Group['Items'] as $GroupItem) 157 { 158 $ColumnsValues .= ', `'.$GroupItem['Column'].'`="'.$Value[$GroupItem['Column']].'"'; 159 } 160 $ColumnsValues = substr($ColumnsValues, 2); 161 162 $DbRow2 = mysql_fetch_assoc($DbResult2); 163 echo('. '); //'UPDATE `'.$Group['TablePrefix'].'` SET '.$ColumnsValues.' WHERE ID='.$DbRow2['ID']."<br>"); 164 $Database->SQLCommand('UPDATE `'.$Group['TablePrefix'].'` SET '.$ColumnsValues.' WHERE ID='.$DbRow2['ID']); 165 } else 166 { 167 $Entry = 1; 168 $DbResult = $Database->SQLCommand('SELECT MAX(`entry`) FROM `'.$Group['TablePrefix'].'`'); 169 if(mysql_num_rows($DbResult) > 0) 170 { 171 $DbRow = mysql_fetch_row($DbResult); 172 $Entry += $DbRow[0]; 173 } 174 175 $Columns = 'entry, language, ShortCut'; 176 $Values = $Entry.', 0, "'.$Value['ShortCut'].'"'; 177 foreach($Group['Items'] as $GroupItem) 178 { 179 $Columns .= ', `'.$GroupItem['Column'].'`'; 180 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 181 } 182 $Database->SQLCommand('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 183 echo('# '); 184 $NewCount++; 185 } 186 }; 187 $Count++; 188 } 189 echo('<br />Celkem: '.$Count.' Nových: '.$NewCount.'<br />'); 190 } 191 } 192 echo('Dokončeno.</div>'); 193 } 5 include('import_lua.php'); 6 include('import_sql_mangos.php'); 7 include('import_dbc.php'); 8 include('update_version.php'); 194 9 195 10 ShowPage(); … … 220 35 break; 221 36 case 'lua': 222 ImportLUA(); 37 ImportLUA($Config['Web']['GameVersion']); //$Config['Web']['GameVersion'] 38 UpdateVersion(); 223 39 break; 224 40 case 'xml': … … 229 45 } 230 46 WriteLog('Plnění databáze', 4); 47 echo('</div>'); 48 231 49 } 232 50
Note:
See TracChangeset
for help on using the changeset viewer.