- Timestamp:
- Mar 24, 2010, 8:43:02 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/img_level.php
r365 r404 6 6 $xp_from_word = 1; 7 7 $index_level = 100; 8 $from_diakrit = 3; // zvýšené xp za slovo s diakritikou8 $from_diakrit = 3; // zvýšené xp za slovo s diakritikou 9 9 $FontFile = 'images/FRIZQT__.ttf'; 10 10 11 function CheckDiakrit($ word)11 function CheckDiakrit($Word) 12 12 { 13 $ result = false;14 $Diakrit = Array("á","č","ď","é","ě","í","ľ","ň","ó","ř","š","ť","ú",13 $Result = false; 14 $Diakrit = array("á","č","ď","é","ě","í","ľ","ň","ó","ř","š","ť","ú", 15 15 "ů","ý","ž","Á","Č","Ď","É","Ě","Í","Ľ","Ň","Ó","Ř","Š","Ť","Ú","Ů","Ý","Ž"); 16 16 for($i = 0; $i < count($Diakrit); $i = $i + 1) 17 17 { 18 if(strpos($word, $Diakrit[$i]) <> false) 19 { 20 $result = true; 21 } 18 if(strpos($Word, $Diakrit[$i]) <> false) 19 $Result = true; 22 20 } 23 return($ result);21 return($Result); 24 22 } 25 23 … … 57 55 } 58 56 59 function GetXPFromTranslation($ user_ID)57 function GetXPFromTranslation($UserId) 60 58 { 61 59 global $Database, $TranslationTree, $xp_from_word, $from_diakrit; 60 62 61 $xp = 0; 63 64 62 foreach($TranslationTree as $Group) 65 { //překladové skupiny63 { 66 64 if($Group['TablePrefix'] != '') 67 65 { 68 $ groupby = 'GROUP BY';66 $GroupBy = 'GROUP BY '; 69 67 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) 70 68 { 71 if($groupby == 'GROUP BY') $groupby .= ' '.$TextItem['Column']; 72 else $groupby .= ', '.$TextItem['Column']; 69 $GroupBy .= '`'.$TextItem['Column'].'`, '; 73 70 } 74 $IDtran = $Database->SQLCommand('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE `User` = '.$user_ID.' AND `Complete` = 1 '.$groupby); 71 $GroupBy = substr($GroupBy, 0, -2); 72 73 $IDtran = $Database->SQLCommand('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE (`User` = '.$UserId.') AND (`Complete` = 1) '.$GroupBy); 75 74 while($Line = mysql_fetch_array($IDtran)) 76 { //jednotlivé překlady 77 $LineComparison = mysql_fetch_assoc($Database->SQLCommand('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE ID = '.$Line['Take'])); 78 $xp_translation = 0; //mazání posledního 75 { 76 $DbResult = $Database->SQLCommand('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE `ID` = '.$Line['Take']); 77 $LineComparison = mysql_fetch_assoc($DbResult); 78 $xp_translation = 0; 79 79 $translated = true; 80 80 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) 81 { //jednotlivé položky překladu81 { 82 82 if(($Line[$TextItem['Column']] <> $LineComparison[$TextItem['Column']]) and (strlen($Line[$TextItem['Column']]) > (strlen($LineComparison[$TextItem['Column']]) * 0.5))) 83 { //zda není stejný, zda je aspoň dlouhý jako polovina84 $TextArr = explode(' ', $Line[$TextItem['Column']]);85 for ($i = 0; $i < count($TextArr); $i = $i + 1)86 { //pro každé slovo87 if(CheckDiakrit($ TextArr[$i])) $indikator = $from_diakrit;83 { 84 $TextArr = explode(' ', $Line[$TextItem['Column']]); 85 foreach($TextArr as $Word) 86 { 87 if(CheckDiakrit($Word)) $indikator = $from_diakrit; 88 88 else $indikator = 1; 89 89 $xp_translation = $xp_translation + ($indikator * $xp_from_word); … … 94 94 } 95 95 } 96 if($translated) $xp = $xp + $xp_translation; // přičítání XP za celý překlad, pokud je celý přeložený96 if($translated) $xp = $xp + $xp_translation; // Přičítání XP za celý překlad, pokud je celý přeložený 97 97 } 98 98 } 99 99 } 100 return $xp;100 return($xp); 101 101 } 102 102
Note:
See TracChangeset
for help on using the changeset viewer.