Changeset 309 for trunk/save.php
- Timestamp:
- Jan 31, 2010, 10:13:41 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/save.php
r286 r309 12 12 if(array_key_exists('entry', $_POST) and Licence(LICENCE_USER)) 13 13 { 14 $entry = $_POST['entry'] ;14 $entry = $_POST['entry'] * 1; // Make numeric 15 15 $UserID = $_SESSION['UserID']; 16 $TextID = $_POST['ID'] ;17 $Language = $_POST['Language'] ;16 $TextID = $_POST['ID'] * 1; 17 $Language = $_POST['Language'] * 1; 18 18 if(array_key_exists('End', $_POST)) $complete = 1; 19 19 else $complete = 0; 20 20 21 $LineAJ = mysql_fetch_array($Database->SQLCommand('SELECT * FROM '.$Table.' WHERE Language = 0 AND entry = '.$entry)); 21 $DbResult = $Database->SQLCommand('SELECT * FROM '.$Table.' WHERE Language = 0 AND entry = '.$entry); 22 if(mysql_num_rows($DbResult) == 0) ErrorMessage('Neznámé Id položky'); 23 $LineAJ = mysql_fetch_array($DbResult); 22 24 $LineTake = mysql_fetch_array($Database->SQLCommand('SELECT VersionEnd,VersionStart FROM '.$Table.' WHERE ID = '.$TextID)); 23 $Line = mysql_fetch_array($Database->SQLCommand('SELECT * FROM '.$Table.' WHERE user='.$UserID.' AND entry = '.$entry.' 24 AND VersionStart = '.$LineTake['VersionStart'].' AND VersionEnd = '.$LineTake['VersionEnd'])); 25 if(mysql_num_rows($DbResult) == 0) ErrorMessage('Neznámé Id položky'); 26 $DbResult = $Database->SQLCommand('SELECT * FROM '.$Table.' WHERE user='.$UserID.' AND entry = '.$entry.' AND VersionStart = '.$LineTake['VersionStart'].' AND VersionEnd = '.$LineTake['VersionEnd']); 27 $Line = mysql_fetch_array($DbResult); 25 28 if(!$Line) 26 29 { 27 $Columns = '`Language` , `User` , `Complete` , `Take` , `VersionStart` , `VersionEnd`';28 $Values = $Language.','.$UserID.','.$complete.','.$TextID.','.$LineTake['VersionStart'].','.$LineTake['VersionEnd'];29 foreach($TranslationTree[$GroupId]['Items'] as $GroupItem)30 {30 $Columns = '`Language` , `User` , `Complete` , `Take` , `VersionStart` , `VersionEnd`'; 31 $Values = $Language.','.$UserID.','.$complete.','.$TextID.','.$LineTake['VersionStart'].','.$LineTake['VersionEnd']; 32 foreach($TranslationTree[$GroupId]['Items'] as $GroupItem) 33 { 31 34 if(array_key_exists($GroupItem['Column'], $_POST)) 35 { 36 if (($GroupItem['Column'] <> 'ShortCut') and ($GroupItem['Column'] <> 'Rank')) 37 { 38 $Columns .= ', `'.$GroupItem['Column'].'`'; 39 $Values .= ', "'.@$_POST[$GroupItem['Column']].'"'; 40 } 41 } 42 } 43 //echo('INSERT INTO `'.$Table.'` ('.$Columns.') VALUES ('.$Values.')'); 44 // $Database->SQLCommand('INSERT INTO `'.$Table.'` (`entry`, '.$Columns.') VALUES ('.$entry.','.$Values.')'); 45 // $LastID = mysql_insert_id(); 46 47 // Kontrolování stejných textů 48 $Where = 'Language = 0'; 49 foreach($TranslationTree[$GroupId]['Items'] as $GroupItem) 32 50 { 33 if (($GroupItem['Column'] <> 'ShortCut') and ($GroupItem['Column'] <> 'Rank')) { 34 $Columns .= ', `'.$GroupItem['Column'].'`'; 35 $Values .= ', "'.@$_POST[$GroupItem['Column']].'"'; 36 } 51 if(($GroupItem['Column'] <> 'ShortCut') and ($GroupItem['Column'] <> 'Rank')) 52 { 53 if(array_key_exists($GroupItem['Column'], $_POST)) 54 $Where .= ' AND `'.$GroupItem['Column'].'` = "'.addslashes($LineAJ[$GroupItem['Column']]).'"'; 55 else $Where .= ' AND `'.$GroupItem['Column'].'` = ""'; 56 } 57 if($GroupItem['Column'] == 'Rank') 58 { 59 if(array_key_exists('Rank', $_POST)) 60 { 61 $Rank = substr($_POST['Rank'],0 ,strpos($_POST['Rank'],' ')); 62 if(strlen($Rank) <= 2) 63 $Rank = substr($_POST['Rank'], strpos($_POST['Rank'],' ') + 1); 64 } else $Rank = 'Úroveň'; 65 } 37 66 } 38 } 39 //echo('INSERT INTO `'.$Table.'` ('.$Columns.') VALUES ('.$Values.')'); 40 // $Database->SQLCommand('INSERT INTO `'.$Table.'` (`entry`, '.$Columns.') VALUES ('.$entry.','.$Values.')'); 41 // $LastID = mysql_insert_id(); 42 43 //kontrolování stejných textů 67 68 $SameTranID = $Database->SQLCommand('SELECT * FROM '.$Table.' WHERE '.$Where); 69 while($SameTranLine = mysql_fetch_assoc($SameTranID)) 70 { 71 $Line = mysql_fetch_array($Database->SQLCommand('SELECT * FROM '.$Table.' WHERE user='.$UserID.' AND entry = '.$SameTranLine['entry'].' AND VersionStart = '.$LineTake['VersionStart'].' AND VersionEnd = '.$LineTake['VersionEnd'])); 72 if(!$Line) 73 { 74 if($GroupItem['Column'] <> 'ShortCut') 75 { 76 if(isset($Rank)) 77 { 78 $Rank_number = substr($SameTranLine['Rank'], strpos($SameTranLine['Rank'],' ') + 1); 79 if($Rank_number <> '') $Rank_cur = $Rank.' '.$Rank_number; 80 else $Rank_cur = $SameTranLine['Rank']; 81 $Database->SQLCommand('INSERT INTO `'.$Table.'` (`entry`, '.$Columns.', `Rank`) VALUES ('.$SameTranLine['entry'].','.$Values.',"'.$Rank_cur.'")'); 82 } else 83 { 84 $Database->SQLCommand('INSERT INTO `'.$Table.'` (`entry`, '.$Columns.') VALUES ('.$SameTranLine['entry'].','.$Values.')'); 85 } 86 } else 87 { 88 $Database->SQLCommand('INSERT INTO `'.$Table.'` (`entry`, '.$Columns.', `ShortCut`) VALUES ('.$SameTranLine['entry'].','.$Values.',"'.$SameTranLine['ShortCut'].'")'); 89 } 90 $LastIDs[] = mysql_insert_id(); 91 } 92 } 44 93 45 46 $Where = 'Language = 0'; 47 foreach($TranslationTree[$GroupId]['Items'] as $GroupItem) 48 { 49 if (($GroupItem['Column'] <> 'ShortCut') and ($GroupItem['Column'] <> 'Rank')) 50 if(array_key_exists($GroupItem['Column'], $_POST)) { 51 $Where .= ' AND `'.$GroupItem['Column'].'` = "'.addslashes($LineAJ[$GroupItem['Column']]).'"'; 52 } else { 53 $Where .= ' AND `'.$GroupItem['Column'].'` = ""'; 54 } 55 if ($GroupItem['Column'] == 'Rank') { 56 if (array_key_exists('Rank',$_POST)) { 57 $Rank = substr($_POST['Rank'], 0 ,strpos($_POST['Rank'],' ')); 58 if (strlen($Rank)<= 2) 59 $Rank = substr($_POST['Rank'], strpos($_POST['Rank'],' ')+1); 60 } else { 61 $Rank = 'Úroveň'; 62 } 63 } 64 } 65 66 $SameTranID = $Database->SQLCommand('SELECT * FROM '.$Table.' WHERE '.$Where); 67 while($SameTranLine = mysql_fetch_assoc($SameTranID)) 68 { 69 $Line = mysql_fetch_array($Database->SQLCommand('SELECT * FROM '.$Table.' WHERE user='.$UserID.' AND entry = '.$SameTranLine['entry'].' 70 AND VersionStart = '.$LineTake['VersionStart'].' AND VersionEnd = '.$LineTake['VersionEnd'])); 71 if(!$Line) { 72 if ($GroupItem['Column'] <> 'ShortCut') { 73 if (isset($Rank)) { 74 $Rank_number = substr($SameTranLine['Rank'], strpos($SameTranLine['Rank'],' ')+1); 75 if ($Rank_number <> '') { 76 $Rank_cur = $Rank.' '.$Rank_number; 77 } else { 78 $Rank_cur = $SameTranLine['Rank']; 79 } 80 $Database->SQLCommand('INSERT INTO `'.$Table.'` (`entry`, '.$Columns.', `Rank`) VALUES ('.$SameTranLine['entry'].','.$Values.',"'.$Rank_cur.'")'); 81 } else { 82 $Database->SQLCommand('INSERT INTO `'.$Table.'` (`entry`, '.$Columns.') VALUES ('.$SameTranLine['entry'].','.$Values.')'); 83 } 84 } else { 85 $Database->SQLCommand('INSERT INTO `'.$Table.'` (`entry`, '.$Columns.', `ShortCut`) VALUES ('.$SameTranLine['entry'].','.$Values.',"'.$SameTranLine['ShortCut'].'")'); 86 } 87 $LastIDs[] = mysql_insert_id(); 88 } 89 } 90 91 //konec kontrolování stejných textů 94 // Konec kontrolování stejných textů 92 95 93 96 echo('Překlad <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a> ('.$entry.') uložen!<br />'); 94 foreach($LastIDs as $LastID)95 {96 if (count($LastIDs) > 1) echo 'Nalezen stejný překlad, systémově přeložen: <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> Převzat z: <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a><br />';97 foreach($LastIDs as $LastID) 98 { 99 if(count($LastIDs) > 1) echo('Nalezen stejný překlad, systémově přeložen: <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> Převzat z: <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a><br />'); 97 100 WriteLog('Text <a href="form.php?group='.$GroupId.'&ID='.$LastID.'">'.$LastID.'</a> ze skupiny <a href="?group='.$GroupId.'&action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen! Převzat z <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a>.', 1); 98 }101 } 99 102 } else 100 103 { … … 110 113 WriteLog('Změny v překladu <a href="form.php?group='.$GroupId.'&ID='.$TextID.'">'.$TextID.'</a> ('.$entry.') uloženy!', 1); 111 114 } 112 //addres and redirecting113 115 // Address and redirecting 116 echo('<br />Překládat: <a href="TranslationList.php?group='.$GroupId.'&action=notran">Nepřeložené</a> '); 114 117 115 116 117 118 $prev = FollowingTran($TextID,$Table,$GroupId, True); 119 $next = FollowingTran($TextID,$Table,$GroupId); 120 echo('<br /><br />'); 118 121 $redirecting = mysql_fetch_assoc($Database->SQLCommand('SELECT redirecting FROM user WHERE ID='.$UserID)); 119 122 120 switch ($redirecting['redirecting']) { 121 case 1: 122 echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'. 123 'setTimeout("parent.location.href=\''.htmlspecialchars_decode('TranslationList.php?group='.$GroupId.'&action=notran').'\'", 1500)'. 124 '</script>'); 125 break; 126 case 2: 127 if ($next <> '') 128 echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'. 123 switch($redirecting['redirecting']) 124 { 125 case 1: 126 echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'. 127 'setTimeout("parent.location.href=\''.htmlspecialchars_decode('TranslationList.php?group='.$GroupId.'&action=notran').'\'", 1500)'. 128 '</script>'); 129 break; 130 case 2: 131 if($next <> '') 132 echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'. 129 133 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($next).'\'", 1500)'. 130 134 '</script>'); 131 132 133 if($prev <> '')134 135 break; 136 case 3: 137 if($prev <> '') 138 echo('<script type="text/javascript" language="JavaScript" charset="utf-8">'. 135 139 'setTimeout("parent.location.href=\''.htmlspecialchars_decode($prev).'\'", 1500)'. 136 140 '</script>'); 137 141 break; 138 142 } 139 143 140 144 echo ('Z této stránky můžete být automaticky přesměrování. Nastavit kam chcete být přesměrování si můžete v <a href="'.$Config['Web']['BaseURL'].'Options.php" Title = "Nastavení uživatele">Nastavení</a>'); 141 145 142 $Database->SQLCommand('UPDATE `user` SET `NeedUpdate` = 1 WHERE ID = '.$UserID); //informace o nutnosti načíst XP 146 // Aktualizace informace o nutnosti načíst XP 147 $Database->SQLCommand('UPDATE `user` SET `NeedUpdate` = 1 WHERE ID = '.$UserID); 143 148 } else 144 149 { … … 170 175 171 176 ShowFooter(); 177 172 178 ?>
Note:
See TracChangeset
for help on using the changeset viewer.