[43] | 1 | <?php
|
---|
| 2 |
|
---|
[48] | 3 | define('LICENCE_ANONYMOUS', -1);
|
---|
| 4 | define('LICENCE_USER', 0);
|
---|
| 5 | define('LICENCE_MODERATOR', 1);
|
---|
| 6 | define('LICENCE_ADMIN', 2);
|
---|
[43] | 7 |
|
---|
[61] | 8 | function utf2ascii($text)
|
---|
| 9 | {
|
---|
| 10 | $return = Str_Replace(
|
---|
| 11 | Array("á","č","ď","é","ě","í","ľ","ň","ó","ř","š","ť","ú","ů","ý","ž","Á","Č","Ď","É","Ě","Í","Ľ","Ň","Ó","Ř","Š","Ť","Ú","Ů","Ý","Ž") ,
|
---|
| 12 | Array("a","c","d","e","e","i","l","n","o","r","s","t","u","u","y","z","A","C","D","E","E","I","L","N","O","R","S","T","U","U","Y","Z") ,
|
---|
| 13 | $text);
|
---|
| 14 | //$return = Str_Replace(Array(" ", "_"), "-", $return); //nahradí mezery a podtržítka pomlčkami
|
---|
| 15 | //$return = Str_Replace(Array("(",")",".","!",",","\"","'"), "", $return); //odstraní ().!,"'
|
---|
| 16 | //$return = StrToLower($return); // velká písmena nahradí malými.
|
---|
| 17 | return($return);
|
---|
| 18 | }
|
---|
| 19 |
|
---|
[161] | 20 | function getmonthyears($Days) {
|
---|
| 21 |
|
---|
| 22 | $month = floor($Days/30);
|
---|
| 23 | $year = floor($month/12);
|
---|
[162] | 24 | $Days = floor($Days - $month*30);
|
---|
[163] | 25 | $month = $month - $year*12;
|
---|
[161] | 26 |
|
---|
| 27 | return $year.'r '.$month.'m '.$Days.'d';
|
---|
| 28 | }
|
---|
| 29 |
|
---|
[67] | 30 | function ListPaging($Address, $Table, $Where, $ItemsPerPage, $CurrentPage)
|
---|
| 31 | {
|
---|
| 32 | global $Database;
|
---|
| 33 |
|
---|
| 34 | $Line = mysql_fetch_row($Database->SQLCommand('SELECT count(*) FROM '.$Table.' '.$Where));
|
---|
| 35 | $ItemCount = floor($Line[0] / $ItemsPerPage);
|
---|
| 36 |
|
---|
| 37 | echo('Počet položek: <strong>'.$Line[0].'</strong> Zobrazit stránku: ');
|
---|
| 38 |
|
---|
| 39 | if($CurrentPage > $ItemCount) $CurrentPage = ($ItemCount / $ItemsPerPage) - 1;
|
---|
[113] | 40 | for($Page = 1; $Page <= $ItemCount+1; $Page++)
|
---|
[67] | 41 | {
|
---|
| 42 | if($CurrentPage == $Page) echo('<strong>'.$Page.'</strong> ');
|
---|
| 43 | else echo('<a href="'.$Address.$Page.'">'.$Page.'</a> ');
|
---|
| 44 | }
|
---|
| 45 | echo('<br />');
|
---|
| 46 | }
|
---|
| 47 |
|
---|
[47] | 48 | function FormatOutput($s)
|
---|
| 49 | {
|
---|
| 50 | $out = '';
|
---|
| 51 | $nn = 0;
|
---|
| 52 | $n = 0;
|
---|
| 53 | while($s!='')
|
---|
| 54 | {
|
---|
| 55 | $start = strpos($s,'<');
|
---|
| 56 | $end = strpos($s,'>');
|
---|
| 57 | if($start != 0)
|
---|
| 58 | {
|
---|
| 59 | $end = $start-1;
|
---|
| 60 | $start = 0;
|
---|
| 61 | }
|
---|
| 62 | $line = trim(substr($s,$start,$end+1));
|
---|
| 63 | if(strlen($line)>0)
|
---|
| 64 | if($line[0] == '<')
|
---|
| 65 | {
|
---|
| 66 | if($s[$start+1] == '/')
|
---|
| 67 | {
|
---|
| 68 | $n = $n - 2;
|
---|
| 69 | $nn = $n;
|
---|
| 70 | } else
|
---|
| 71 | {
|
---|
| 72 | if(strpos($line,' ')) $cmd = substr($line,1,strpos($line,' ')-1);
|
---|
| 73 | else $cmd = substr($line,1,strlen($line)-2);
|
---|
| 74 | //echo('['.$cmd.']');
|
---|
| 75 | if(strpos($s,'</'.$cmd.'>')) $n = $n + 2;
|
---|
| 76 | }
|
---|
| 77 | }// else $line = '['.$line.']';
|
---|
| 78 | //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
|
---|
| 79 | if($line != '') $out .= (str_repeat(' ',$nn).$line."\n");
|
---|
| 80 | $s = substr($s,$end+1,strlen($s));
|
---|
| 81 | $nn = $n;
|
---|
| 82 | }
|
---|
| 83 | return($out);
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | function WriteLanguages($Selected)
|
---|
| 87 | {
|
---|
| 88 | echo('<select name="Language">');
|
---|
| 89 | echo('<option value="1"'); if ($Selected == '1') echo(' selected="selected"'); echo('>Českého jazyka</option>');
|
---|
| 90 | echo('<option value="2"'); if ($Selected == '2') echo(' selected="selected"'); echo('>Slovenského jazyka</option>');
|
---|
| 91 | echo('<option value="3"'); if ($Selected == '3') echo(' selected="selected"'); echo('>Jiného jazyka</option>');
|
---|
| 92 | echo('</select>');
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[78] | 95 | function WriteLanguagesWithoutSel($Selected)
|
---|
| 96 | {
|
---|
[158] | 97 | if($Selected == '0') echo('Původní verze jazyka');
|
---|
| 98 | if($Selected == '1') echo('Českého jazyka');
|
---|
| 99 | if($Selected == '2') echo('Slovenského jazyka');
|
---|
| 100 | if($Selected == '3') echo('Jiného jazyka');
|
---|
[78] | 101 | }
|
---|
| 102 |
|
---|
[47] | 103 | function Licence($Licence)
|
---|
| 104 | {
|
---|
| 105 | global $Database;
|
---|
| 106 |
|
---|
| 107 | if($Licence == -1) return(true);
|
---|
| 108 | else
|
---|
[63] | 109 | if(isset($_SESSION['User']) and ($_SESSION['User'] <> '') and ($_SESSION['UserID'] != ''))
|
---|
[47] | 110 | {
|
---|
[43] | 111 | // $User = $_SESSION['User'];
|
---|
[47] | 112 | $Pass = $_SESSION['Pass'];
|
---|
[63] | 113 | $Line = mysql_fetch_array($Database->SQLCommand('SELECT * FROM user WHERE ID = '.$_SESSION['UserID'].'
|
---|
[65] | 114 | AND GM >= '.$Licence.' AND pass = sha1("'.$Pass.'")'));
|
---|
[43] | 115 | // echo "SELECT * FROM user WHERE ID = ".$_SESSION['UserID']." AND GM <= $Licence AND pass = '$Pass'";
|
---|
[47] | 116 | return($Line);
|
---|
| 117 | } else
|
---|
| 118 | {
|
---|
| 119 | return(false);
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
[43] | 122 |
|
---|
[63] | 123 | function MysqlDateTimeToTime($Time)
|
---|
| 124 | {
|
---|
| 125 | $Parts = explode(' ', $Time);
|
---|
| 126 | $DateParts = explode('-', $Parts[0]);
|
---|
| 127 | $TimeParts = explode(':', $Parts[1]);
|
---|
| 128 | $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
|
---|
| 129 | return($Result);
|
---|
| 130 | }
|
---|
| 131 |
|
---|
[47] | 132 | function GetTranslationTree()
|
---|
| 133 | {
|
---|
| 134 | global $Database;
|
---|
| 135 |
|
---|
| 136 | $Result = array();
|
---|
| 137 | $DbResult = $Database->SQLCommand('SELECT * FROM `group`');
|
---|
| 138 | while($DbRow = mysql_fetch_assoc($DbResult))
|
---|
| 139 | {
|
---|
| 140 | $DbRow['Items'] = array();
|
---|
| 141 | $Result[$DbRow['Id']] = $DbRow;
|
---|
| 142 | }
|
---|
| 143 | $DbResult = $Database->SQLCommand('SELECT * FROM `group_item`');
|
---|
| 144 | while($DbRow = mysql_fetch_assoc($DbResult))
|
---|
| 145 | {
|
---|
[49] | 146 | $Result[$DbRow['Group']]['Items'][] = $DbRow;
|
---|
[47] | 147 | }
|
---|
| 148 | return($Result);
|
---|
| 149 | }
|
---|
[43] | 150 |
|
---|
[47] | 151 | $LogTypes = array
|
---|
| 152 | (
|
---|
[43] | 153 | // index, indexname , barva , popis
|
---|
[69] | 154 | array('0', '', 'brown', ''),
|
---|
[67] | 155 | array('1', 'Překlady', 'green', 'Operace s překladdy'),
|
---|
| 156 | array('2', 'Stažení', 'brown', 'Stáhnutí souboru'),
|
---|
[47] | 157 | array('3', 'Uživatelé', 'blue', 'Přihlášení uživatelů, nastavení, registrace'),
|
---|
[136] | 158 | array('4', 'Moderátor', 'orange', 'Operace administrátorů a moderátorů'),
|
---|
| 159 | array('10', 'Chyby', 'red', 'Zachycené chybové hlášení'),
|
---|
[43] | 160 | );
|
---|
| 161 |
|
---|
[57] | 162 | $Moderators = array('Překladatel', 'Moderátor', 'Administrátor');
|
---|
[43] | 163 |
|
---|
[47] | 164 | function WriteLog($Text, $Type)
|
---|
| 165 | {
|
---|
| 166 | global $Database, $Config;
|
---|
| 167 |
|
---|
| 168 | $user = @$_SESSION['UserID'];
|
---|
[59] | 169 | if($user == '') $user = 0;
|
---|
[47] | 170 | $Database->SelectDatabase($Config['Database']['Database']);
|
---|
[49] | 171 | $Query = 'INSERT INTO `log` ( `user` , `type` , `text` , `date` , `IP` )
|
---|
| 172 | VALUES ('.$user.', '.$Type.', "'.addslashes($Text).'", NOW(), "'.addslashes($_SERVER['REMOTE_ADDR']).'")';
|
---|
| 173 | $Database->SQLCommand($Query);
|
---|
[47] | 174 | }
|
---|
[43] | 175 |
|
---|
[47] | 176 | $client_files = array
|
---|
| 177 | (
|
---|
[43] | 178 | '0' => 'LocalizationStrings',
|
---|
| 179 | '1' => 'SpellBufDescription_1',
|
---|
| 180 | '2' => 'SpellDescription_1',
|
---|
| 181 | '3' => 'SpellDescription_2',
|
---|
| 182 | '4' => 'SpellDescription_3',
|
---|
| 183 | '5' => 'SpellDescription_4',
|
---|
| 184 | '6' => 'tallent',
|
---|
| 185 | );
|
---|
[47] | 186 |
|
---|
[57] | 187 | function HumanDate($SQLDateTime)
|
---|
| 188 | {
|
---|
| 189 | $DateTimeParts = explode(' ', $SQLDateTime);
|
---|
| 190 | $DateParts = explode('-', $DateTimeParts[0]);
|
---|
| 191 | return(($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.($DateParts[0] * 1));
|
---|
| 192 | }
|
---|
| 193 |
|
---|
[148] | 194 | function FollowingTran($TextID,$Table,$GroupId, $Prev = false) {
|
---|
| 195 |
|
---|
| 196 | global $Database;
|
---|
| 197 |
|
---|
[158] | 198 | if($Prev)
|
---|
| 199 | {
|
---|
| 200 | $sql = 'SELECT ID FROM '.$Table.' as item WHERE Language = 0 AND NOT EXISTS(SELECT entry FROM '.$Table.' AS sub WHERE sub.Language <> 0 AND sub.entry = item.entry) AND ID < '.$TextID.' ORDER BY ID DESC LIMIT 1';
|
---|
| 201 | } else
|
---|
| 202 | {
|
---|
| 203 | $sql = 'SELECT ID FROM '.$Table.' as item WHERE Language = 0 AND NOT EXISTS(SELECT entry FROM '.$Table.' AS sub WHERE sub.Language <> 0 AND sub.entry = item.entry) AND ID > '.$TextID.' ORDER BY ID LIMIT 1';
|
---|
| 204 | }
|
---|
[148] | 205 |
|
---|
| 206 | $Next = mysql_fetch_array($Database->SQLCommand($sql));
|
---|
[158] | 207 | if(!$Next) {} else
|
---|
| 208 | {
|
---|
| 209 | if($Prev) echo('<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> ');
|
---|
| 210 | else echo('<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Následující '.$Next['ID'].'</a> ');
|
---|
[148] | 211 | }
|
---|
| 212 | }
|
---|
[57] | 213 |
|
---|
[43] | 214 | ?>
|
---|