Changeset 300 for trunk/action.php
- Timestamp:
- Dec 28, 2009, 7:43:42 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/action.php
r296 r300 5 5 function Search() 6 6 { 7 global $Database ;7 global $Database, $TranslationTree; 8 8 9 9 if(array_key_exists('search', $_GET)) $Search = $_GET['search']; … … 11 11 12 12 echo('<table class="BaseTable"><tr><th>Skupina</th><th>Výsledků</th></tr>'); 13 foreach($TranslationTree as $Group) { 13 foreach($TranslationTree as $Group) 14 { 14 15 $Table = $Group['TablePrefix']; 15 16 … … 18 19 OR `User` LIKE "%'.$Search.'%" 19 20 OR `Complete` LIKE "%'.$Search.'%"'; 20 foreach($Group['Items'] as $Item) { 21 if($Item['Column'] != '') $sql .= ' OR `'.$Item['Column'].'` LIKE "%'.$Search.'%"'; 21 foreach($Group['Items'] as $Item) 22 { 23 if($Item['Column'] != '') $sql .= ' OR `'.$Item['Column'].'` LIKE "%'.$Search.'%"'; 22 24 } 23 25 $Line = mysql_fetch_row($Database->SQLCommand($sql)); 24 echo('<tr><td><a href="TranslationList.php?group='.$Group['Id'].'&action=search&search='.$Search.'">'.$Group['Name'].'</a></td><td>'.$Line[0].'</td></tr>');26 echo('<tr><td><a href="TranslationList.php?group='.$Group['Id'].'&action=search&search='.$Search.'">'.$Group['Name'].'</a></td><td>'.$Line[0].'</td></tr>'); 25 27 } 26 28 … … 41 43 function DatabaseKit() 42 44 { 43 global $Database ;45 global $Database, $TranslationTree; 44 46 45 47 if(Licence(LICENCE_ADMIN)) 46 48 { 47 echo('<form action="?action=dbkit" method="post">');48 echo('Najít: <input type="text" name="find" /><br />');49 echo('Nahradit: <input type="text" name="replace" /><br />');50 echo('<input type="submit" value="Najít/nahradit" /><br />');49 echo('<form action="?action=dbkit" method="post">'); 50 echo('Najít: <input type="text" name="find" /><br />'); 51 echo('Nahradit: <input type="text" name="replace" /><br />'); 52 echo('<input type="submit" value="Najít/nahradit" /><br />'); 51 53 echo('</form><br />'); 52 echo('<a href="?action=dbkit&Take">Opravit data v sloupci Take</a><br />');53 echo('<a href="?action=dbkit&ShortCut">Opravit data v sloupci ShortCut</a><br />');54 55 echo('<br /><form action="?action=dbkit" method="post">');56 echo('Vymazat log typ : <input type="text" name="Type" /> ');57 echo('<input type="submit" value="Vymazat" /><br />');54 echo('<a href="?action=dbkit&Take">Opravit data v sloupci Take</a><br />'); 55 echo('<a href="?action=dbkit&ShortCut">Opravit data v sloupci ShortCut</a><br />'); 56 57 echo('<br /><form action="?action=dbkit" method="post">'); 58 echo('Vymazat log typ : <input type="text" name="Type" /> '); 59 echo('<input type="submit" value="Vymazat" /><br />'); 58 60 echo('</form><br />'); 59 61 60 if (array_key_exists('Type',$_POST)) { 61 $sql = 'DELETE FROM log WHERE Type = '.$_POST['Type']; 62 $Database->SQLCommand($sql); 62 if(array_key_exists('Type',$_POST)) 63 { 64 $sql = 'DELETE FROM log WHERE Type = '.$_POST['Type']; 65 $Database->SQLCommand($sql); 63 66 WriteLog('Vymazán log '.$_POST['Type'], 4); 64 67 echo (' Vymazán log '.$_POST['Type']); 65 68 } 66 69 67 if (array_key_exists('find',$_POST)) { 68 echo ('Začínám nahrazovat: <br />'); 70 if(array_key_exists('find',$_POST)) 71 { 72 echo('Začínám nahrazovat: <br />'); 69 73 $find = $_POST['find']; 70 74 $replace = $_POST['replace']; 71 75 72 foreach($TranslationTree as $Group) { 73 $Table = $Group['TablePrefix']; 74 echo ($Table.' '); 75 76 $sql = 'SELECT * FROM '.$Table.' WHERE (Language <> 0) AND ('; 77 foreach($Group['Items'] as $Item) { 78 if($Item['Column'] != '') $sql .= '`'.$Item['Column'].'` LIKE "%'.$find.'%" OR '; 76 foreach($TranslationTree as $Group) 77 { 78 $Table = $Group['TablePrefix']; 79 echo($Table.' '); 80 81 $sql = 'SELECT * FROM '.$Table.' WHERE (Language <> 0) AND ('; 82 foreach($Group['Items'] as $Item) 83 { 84 if($Item['Column'] != '') $sql .= '`'.$Item['Column'].'` LIKE "%'.$find.'%" OR '; 85 } 86 $sql = substr($sql,0,strlen($sql)-4); 87 $sql .= ')'; 88 89 $ID = $Database->SQLCommand($sql); 90 while ($Line = mysql_fetch_assoc($ID)) 91 { 92 $sql = 'UPDATE '.$Table.' SET '; 93 foreach($Group['Items'] as $Item) 94 { 95 $Column_text = addslashes(str_replace($find, $replace, $Line[$Item['Column']])); 96 $sql .= ' '.$Item['Column'].' = "'.$Column_text.'",'; 97 } 98 $sql = substr($sql,0,strlen($sql)-1); 99 $sql .= ' WHERE ID = '.$Line['ID']; 100 $Database->SQLCommand($sql); 101 echo ('.'); 102 } 103 104 echo(' <strong>Hotovo</strong> <br />'); 105 if(mysql_num_rows($ID) > 0) 106 { 107 WriteLog('Použita oprava DB ovlivněno '.mysql_num_rows($ID).' řádků z tabulky '.$Table.', "'.$find.'" nahrazeno za "'.$replace.'"', 4); 108 echo (' Použita oprava DB ovlivněno '.mysql_num_rows($ID).' řádků z tabulky '.$Table.', "'.$find.'" nahrazeno za "'.$replace.'"<br />'); 109 } 79 110 } 80 $sql = substr($sql,0,strlen($sql)-4);81 $sql .= ')';82 83 $ID = $Database->SQLCommand($sql);84 while ($Line = mysql_fetch_assoc($ID)) {85 $sql = 'UPDATE '.$Table.' SET ';86 foreach($Group['Items'] as $Item) {87 $Column_text = addslashes(str_replace($find,$replace,$Line[$Item['Column']]));88 $sql .= ' '.$Item['Column'].' = "'.$Column_text.'",';89 }90 $sql = substr($sql,0,strlen($sql)-1);91 $sql .= ' WHERE ID = '.$Line['ID'];92 $Database->SQLCommand($sql);93 echo ('.');94 }95 96 echo (' <strong>Hotovo</strong> <br />');97 if (mysql_num_rows($ID) > 0) {98 WriteLog('Použita oprava DB ovlivněno '.mysql_num_rows($ID).' řádků z tabulky '.$Table.', "'.$find.'" nahrazeno za "'.$replace.'"', 4);99 echo (' Použita oprava DB ovlivněno '.mysql_num_rows($ID).' řádků z tabulky '.$Table.', "'.$find.'" nahrazeno za "'.$replace.'"<br />');100 111 } 101 } 102 } 103 104 //oprava dat v sloupci Take 105 if (array_key_exists('Take',$_GET)) { 112 113 // Oprava dat v sloupci Take 114 if(array_key_exists('Take',$_GET)) 115 { 106 116 echo ('Začínám opravovat Take: <br />'); 107 117 108 foreach($TranslationTree as $Group) { 109 $Table = $Group['TablePrefix']; 110 echo ($Table.' '); 111 112 $sql = 'SELECT ID,entry as entry_tran, Take, 118 foreach($TranslationTree as $Group) 119 { 120 $Table = $Group['TablePrefix']; 121 echo($Table.' '); 122 123 $sql = 'SELECT ID,entry as entry_tran, Take, 113 124 (SELECT ID FROM '.$Table.' WHERE Language = 0 AND entry = entry_tran LIMIT 1) as ID_orig 114 125 FROM '.$Table.' as tran WHERE (Language <> 0) AND ((Take = 0) OR (ID = Take) OR NOT EXISTS(SELECT 1 FROM '.$Table.' WHERE ID = tran.Take))'; 115 126 116 $ID = $Database->SQLCommand($sql); 117 while ($Line = mysql_fetch_assoc($ID)) { 118 $sql = 'UPDATE '.$Table.' SET Take = '.$Line['ID_orig'].' WHERE ID = '.$Line['ID']; 119 $Database->SQLCommand($sql); 120 echo ('.'); 127 $ID = $Database->SQLCommand($sql); 128 while($Line = mysql_fetch_assoc($ID)) 129 { 130 $sql = 'UPDATE '.$Table.' SET Take = '.$Line['ID_orig'].' WHERE ID = '.$Line['ID']; 131 $Database->SQLCommand($sql); 132 echo('.'); 133 } 134 135 echo(' <strong>Hotovo</strong> <br />'); 136 if(mysql_num_rows($ID) > 0) 137 { 138 WriteLog('Použita oprava DB na sloupec Take '.mysql_num_rows($ID).' řádků z tabulky '.$Table, 4); 139 echo (' Použita oprava DB na sloupec Take '.mysql_num_rows($ID).' řádků z tabulky '.$Table.'<br />'); 140 } 121 141 } 122 123 echo (' <strong>Hotovo</strong> <br />'); 124 if (mysql_num_rows($ID) > 0) { 125 WriteLog('Použita oprava DB na sloupec Take '.mysql_num_rows($ID).' řádků z tabulky '.$Table, 4); 126 echo (' Použita oprava DB na sloupec Take '.mysql_num_rows($ID).' řádků z tabulky '.$Table.'<br />'); 127 } 142 } 143 // Oprava dat ShortCut 144 if(array_key_exists('ShortCut', $_GET)) 145 { 146 echo ('Začínám opravovat Take: <br />'); 147 148 $Tables = array ('global_strings', 'glue_strings'); 149 150 foreach($Tables as $Table) 151 { 152 echo ($Table.' '); 153 $sql = 'SELECT gs_orig.ID, gs_tran.entry, gs_tran.ShortCut as ShortCut_tran, gs_orig.ShortCut as ShortCut_orig FROM '.$Table.' as gs_tran JOIN '.$Table.' as gs_orig ON gs_orig.entry = gs_tran.entry WHERE gs_tran.Language <> 0 AND gs_tran.ShortCut <> gs_orig.ShortCut'; 154 $ID = $Database->SQLCommand($sql); 155 while ($Line = mysql_fetch_assoc($ID)) 156 { 157 $sql = 'UPDATE '.$Table.' SET ShortCut = '.$Line['ShortCut_orig'].' WHERE ID = '.$Line['ID']; 158 $Database->SQLCommand($sql); 159 echo ('.'); 160 } 161 162 echo (' <strong>Hotovo</strong> <br />'); 163 if(mysql_num_rows($ID) > 0) 164 { 165 WriteLog('Použita oprava DB na sloupec ShortCut '.mysql_num_rows($ID).' řádků z tabulky '.$Table, 4); 166 echo (' Použita oprava DB na sloupec ShortCut '.mysql_num_rows($ID).' řádků z tabulky '.$Table.'<br />'); 167 } 128 168 } 129 } 130 //oprava dat ShortCut 131 if (array_key_exists('ShortCut',$_GET)) { 132 echo ('Začínám opravovat Take: <br />'); 133 134 135 $Tables = array ('global_strings','glue_strings'); 136 137 foreach($Tables as $Table) { 138 echo ($Table.' '); 139 $sql = 'SELECT gs_orig.ID, gs_tran.entry, gs_tran.ShortCut as ShortCut_tran, gs_orig.ShortCut as ShortCut_orig FROM '.$Table.' as gs_tran JOIN '.$Table.' as gs_orig ON gs_orig.entry = gs_tran.entry WHERE gs_tran.Language <> 0 AND gs_tran.ShortCut <> gs_orig.ShortCut'; 140 $ID = $Database->SQLCommand($sql); 141 while ($Line = mysql_fetch_assoc($ID)) { 142 $sql = 'UPDATE '.$Table.' SET ShortCut = '.$Line['ShortCut_orig'].' WHERE ID = '.$Line['ID']; 143 $Database->SQLCommand($sql); 144 echo ('.'); 145 } 146 147 echo (' <strong>Hotovo</strong> <br />'); 148 if (mysql_num_rows($ID) > 0) { 149 WriteLog('Použita oprava DB na sloupec ShortCut '.mysql_num_rows($ID).' řádků z tabulky '.$Table, 4); 150 echo (' Použita oprava DB na sloupec ShortCut '.mysql_num_rows($ID).' řádků z tabulky '.$Table.'<br />'); 151 } 152 } 153 } 154 } 155 } 156 169 } 170 } 171 } 157 172 158 173 function Delete()
Note:
See TracChangeset
for help on using the changeset viewer.