Changeset 880 for trunk/includes
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- Location:
- trunk/includes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/FileStream.php
r815 r880 15 15 function __destruct() 16 16 { 17 if ($this->Handle)17 if ($this->Handle) 18 18 fclose($this->Handle); 19 19 } … … 24 24 $this->CloseFile(); 25 25 $this->Handle = fopen($FileName, 'rb'); 26 if (!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND));26 if (!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND)); 27 27 } 28 28 … … 32 32 $this->CloseFile(); 33 33 $this->Handle = fopen($FileName, 'wb+'); 34 if (!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND));34 if (!$this->Handle) die(str_replace('%s', $FileName, FILE_NOT_FOUND)); 35 35 } 36 36 37 37 public function CloseFile() 38 38 { 39 if ($this->Handle)39 if ($this->Handle) 40 40 fclose($this->Handle); 41 41 } … … 43 43 public function ReadBlock($Count) 44 44 { 45 return (fread($this->Handle, $Count));45 return fread($this->Handle, $Count); 46 46 } 47 47 48 48 public function ReadByte() 49 49 { 50 return (fread($this->Handle, 1));50 return fread($this->Handle, 1); 51 51 } 52 52 … … 54 54 { 55 55 $val = unpack('V*', fread($this->Handle, 4)); 56 return ($val[1]);56 return $val[1]; 57 57 } 58 58 … … 60 60 { 61 61 $val = unpack('I*', fread($this->Handle, 4)); 62 return ($val[1]);62 return $val[1]; 63 63 } 64 64 … … 66 66 { 67 67 $val = unpack('f*', fread($this->Handle, 4)); 68 return ($val[1]);68 return $val[1]; 69 69 } 70 70 71 71 public function ReadChar() 72 72 { 73 return (fread($this->Handle, 1));73 return fread($this->Handle, 1); 74 74 } 75 75 76 76 public function ReadLine() 77 77 { 78 return (fgets($this->Handle));78 return fgets($this->Handle); 79 79 } 80 80 81 81 public function ReadTextLine() 82 82 { 83 return (fgets($this->Handle));83 return fgets($this->Handle); 84 84 } 85 85 … … 131 131 public function GetPosition() 132 132 { 133 return (ftell($this->Handle));133 return ftell($this->Handle); 134 134 } 135 135 136 136 public function GetSize() 137 137 { 138 return (filesize($this->FileName));138 return filesize($this->FileName); 139 139 } 140 140 141 141 public function SetSize($Size) 142 142 { 143 return (ftruncate($this->Handle, $Size));143 return ftruncate($this->Handle, $Size); 144 144 } 145 145 146 146 public function EOF() 147 147 { 148 return (feof($this->Handle));148 return feof($this->Handle); 149 149 } 150 150 } -
trunk/includes/Global.php
r879 r880 2 2 3 3 include_once(dirname(__FILE__).'/../Packages/Common/Common.php'); 4 if (file_exists(dirname(__FILE__).'/../Config/Config.php'))4 if (file_exists(dirname(__FILE__).'/../Config/Config.php')) 5 5 include_once(dirname(__FILE__).'/../Config/Config.php'); 6 6 include_once(dirname(__FILE__).'/../Application/Core.php'); … … 13 13 14 14 // Back compatibility, will be removed 15 if (isset($InitSystem) and $InitSystem)15 if (isset($InitSystem) and $InitSystem) 16 16 { 17 17 $System = new Core(); … … 25 25 { 26 26 global $TempPageContent; 27 return ($TempPageContent);27 return $TempPageContent; 28 28 } 29 29 } … … 54 54 { 55 55 list($Usec, $Sec) = explode(' ', microtime()); 56 return ( (float)$Usec + (float)$Sec);56 return (float)$Usec + (float)$Sec; 57 57 } 58 58 … … 64 64 65 65 $UnitIndex = 0; 66 while ($Value > 1024)66 while ($Value > 1024) 67 67 { 68 68 $Value = round($Value / 1024, 3); 69 69 $UnitIndex++; 70 70 } 71 return ($Value.' '.$UnitNames[$UnitIndex]);71 return $Value.' '.$UnitNames[$UnitIndex]; 72 72 } 73 73 … … 76 76 $Result = array(); 77 77 $Parts = explode('&', $QueryString); 78 foreach ($Parts as $Part)79 { 80 if ($Part != '')81 { 82 if (!strpos($Part, '=')) $Part .= '=';78 foreach ($Parts as $Part) 79 { 80 if ($Part != '') 81 { 82 if (!strpos($Part, '=')) $Part .= '='; 83 83 $Item = explode('=', $Part); 84 84 $Result[$Item[0]] = $Item[1]; 85 85 } 86 86 } 87 return ($Result);87 return $Result; 88 88 } 89 89 … … 91 91 { 92 92 $Parts = array(); 93 foreach ($QueryStringArray as $Index => $Item)93 foreach ($QueryStringArray as $Index => $Item) 94 94 { 95 95 $Parts[] = $Index.'='.$Item; 96 96 } 97 return (implode('&', $Parts));97 return implode('&', $Parts); 98 98 } 99 99 … … 107 107 //$return = Str_Replace(Array("(",")",".","!",",","\"","'"), "", $return); //odstraní ().!,"' 108 108 //$return = StrToLower($return); // velká písmena nahradí malými. 109 return ($return);109 return $return; 110 110 } 111 111 … … 116 116 $Days = floor($Days - $month * 30); 117 117 $month = $month - $year * 12; 118 return ($year.'r '.$month.'m '.$Days.'d');118 return $year.'r '.$month.'m '.$Days.'d'; 119 119 } 120 120 … … 137 137 138 138 error_reporting(E_ALL ^ E_WARNING); 139 if (($handle = @fopen($url, "r")) === FALSE) return (false);139 if (($handle = @fopen($url, "r")) === FALSE) return false; 140 140 141 141 $data = stream_get_contents($handle); … … 164 164 $data = strip_tags($data); 165 165 166 return ($data);166 return $data; 167 167 } 168 168 … … 178 178 $PageCount = floor($TotalCount / $ItemPerPage) + 1; 179 179 180 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;181 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;182 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;183 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;180 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 181 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 182 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 183 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 184 184 $CurrentPage = $_SESSION['Page']; 185 185 … … 188 188 189 189 $Result = ''; 190 if ($PageCount > 1)191 { 192 if ($CurrentPage > 0)190 if ($PageCount > 1) 191 { 192 if ($CurrentPage > 0) 193 193 { 194 194 $QueryItems['page'] = 0; … … 199 199 $PagesMax = $PageCount - 1; 200 200 $PagesMin = 0; 201 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;202 if ($PagesMin < ($CurrentPage - $Around))201 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 202 if ($PagesMin < ($CurrentPage - $Around)) 203 203 { 204 204 $Result.= ' ... '; 205 205 $PagesMin = $CurrentPage - $Around; 206 206 } 207 for ($i = $PagesMin; $i <= $PagesMax; $i++)208 { 209 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';207 for ($i = $PagesMin; $i <= $PagesMax; $i++) 208 { 209 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 210 210 else { 211 211 $QueryItems['page'] = $i; … … 213 213 } 214 214 } 215 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';216 if ($CurrentPage < ($PageCount - 1))215 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 216 if ($CurrentPage < ($PageCount - 1)) 217 217 { 218 218 $QueryItems['page'] = ($CurrentPage + 1); … … 223 223 } 224 224 $Result = '<div style="text-align: center">'.$Result.'</div>'; 225 return (array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,225 return array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 226 226 'Page' => $CurrentPage, 227 227 'Output' => $Result, 228 ) );228 ); 229 229 } 230 230 … … 236 236 global $OrderDirSQL, $OrderArrowImage, $Config, $System; 237 237 238 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];239 if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage)))238 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 239 if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage))) 240 240 $_SESSION['OrderDir'] = $_GET['OrderDir']; 241 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;242 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;241 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn; 242 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder; 243 243 244 244 // Check OrderCol 245 245 $Found = false; 246 foreach ($Columns as $Column)247 { 248 if ($Column['Name'] == $_SESSION['OrderCol'])246 foreach ($Columns as $Column) 247 { 248 if ($Column['Name'] == $_SESSION['OrderCol']) 249 249 { 250 250 $Found = true; … … 252 252 } 253 253 } 254 if ($Found == false)254 if ($Found == false) 255 255 { 256 256 $_SESSION['OrderCol'] = $DefaultColumn; … … 258 258 } 259 259 // Check OrderDir 260 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;260 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0; 261 261 262 262 $Result = ''; 263 263 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 264 foreach ($Columns as $Index => $Column)264 foreach ($Columns as $Index => $Column) 265 265 { 266 266 $QueryItems['OrderCol'] = $Column['Name']; 267 267 $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir']; 268 if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.268 if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'. 269 269 $System->Link('/images/'.$OrderArrowImage[$_SESSION['OrderDir']]).'" alt="order arrow"/>'; 270 270 else $ArrowImage = ''; 271 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';271 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>'; 272 272 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>'; 273 273 } 274 return (array(274 return array( 275 275 'SQL' => ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$OrderDirSQL[$_SESSION['OrderDir']], 276 276 'Output' => '<tr>'.$Result.'</tr>', 277 277 'Column' => $_SESSION['OrderCol'], 278 278 'Direction' => $_SESSION['OrderDir'], 279 ) );279 ); 280 280 } 281 281 … … 287 287 $DbResult = $System->Database->select('ClientVersion', '`Id`, `Version`', '`Imported` = 1'); 288 288 $Output .= '<option value=""'; 289 if ($Selected == '')289 if ($Selected == '') 290 290 $Output .= ' selected="selected"'; 291 291 $Output .= '>'.T('None').'</option>'; 292 while ($ClientVersion = $DbResult->fetch_assoc())292 while ($ClientVersion = $DbResult->fetch_assoc()) 293 293 { 294 294 $Output .= '<option value="'.$ClientVersion['Id'].'"'; 295 if ($Selected == $ClientVersion['Id'])295 if ($Selected == $ClientVersion['Id']) 296 296 $Output .= ' selected="selected"'; 297 297 $Output .= '>'.$ClientVersion['Version'].'</option>'; 298 298 } 299 299 $Output .= '</select>'; 300 return ($Output);300 return $Output; 301 301 } 302 302 … … 307 307 $Result = array(); 308 308 $DbResult = $System->Database->query('SELECT * FROM `Language` WHERE `Enabled` = 1'); 309 while ($DbRow = $DbResult->fetch_assoc())309 while ($DbRow = $DbResult->fetch_assoc()) 310 310 $Result[$DbRow['Id']] = $DbRow; 311 return ($Result);311 return $Result; 312 312 } 313 313 … … 316 316 function HumanDate($SQLDateTime) 317 317 { 318 if ($SQLDateTime == '') return(' ');318 if ($SQLDateTime == '') return ' '; 319 319 $DateTimeParts = explode(' ', $SQLDateTime); 320 if ($DateTimeParts[0] != '0000-00-00')320 if ($DateTimeParts[0] != '0000-00-00') 321 321 { 322 322 $DateParts = explode('-', $DateTimeParts[0]); 323 return (($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.($DateParts[0] * 1));324 } else return (' ');323 return ($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.($DateParts[0] * 1); 324 } else return ' '; 325 325 } 326 326 327 327 function HumanDateTime($SQLDateTime) 328 328 { 329 if ($SQLDateTime == '') return(' ');329 if ($SQLDateTime == '') return ' '; 330 330 $DateTimeParts = explode(' ', $SQLDateTime); 331 if ($DateTimeParts[0] != '0000-00-00' and $SQLDateTime <> '')331 if ($DateTimeParts[0] != '0000-00-00' and $SQLDateTime <> '') 332 332 { 333 333 $DateParts = explode('-', $DateTimeParts[0]); 334 334 $Output = ($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.($DateParts[0] * 1); 335 335 } else $Output = ' '; 336 if (count($DateTimeParts) > 1)337 if ($DateTimeParts[1] != '00:00:00')336 if (count($DateTimeParts) > 1) 337 if ($DateTimeParts[1] != '00:00:00') 338 338 { 339 339 $TimeParts = explode(':', $DateTimeParts[1]); 340 340 $Output .= ' '.($TimeParts[0] * 1).':'.($TimeParts[1] * 1).':'.($TimeParts[2] * 1); 341 341 }; 342 return ($Output);342 return $Output; 343 343 } 344 344 … … 347 347 global $System, $Config; 348 348 349 if ($Prev)349 if ($Prev) 350 350 $sql = 'SELECT `ID` FROM `'.$Table.'` AS `item` WHERE '. 351 351 '(`Language` = '.$Config['OriginalLanguage'].') AND NOT EXISTS(SELECT `entry` '. … … 359 359 $DbResult = $System->Database->query($sql); 360 360 $Next = $DbResult->fetch_assoc(); 361 if ($Next)362 { 363 if ($Prev) $Output = '<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> ';361 if ($Next) 362 { 363 if ($Prev) $Output = '<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> '; 364 364 else $Output = '<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Následující '.$Next['ID'].'</a> '; 365 return ('form.php?group='.$GroupId.'&ID='.$Next['ID']);365 return 'form.php?group='.$GroupId.'&ID='.$Next['ID']; 366 366 } 367 367 } … … 371 371 global $System, $BuildNumbers; 372 372 373 if (isset($BuildNumbers[$Version]) == false)373 if (isset($BuildNumbers[$Version]) == false) 374 374 { 375 375 $sql = 'SELECT `BuildNumber` FROM `ClientVersion` WHERE `Version` = "'.$Version.'"'; … … 378 378 $BuildNumbers[$Version] = $DbRow['BuildNumber']; 379 379 } 380 return ($BuildNumbers[$Version]);380 return $BuildNumbers[$Version]; 381 381 } 382 382 … … 386 386 global $System, $VersionsWOW; 387 387 388 if (isset($VersionsWOW[$BuildNumber]) == false)388 if (isset($VersionsWOW[$BuildNumber]) == false) 389 389 { 390 390 $sql = 'SELECT `Version` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"'; … … 393 393 $VersionsWOW[$BuildNumber] = $Version['Version']; 394 394 } 395 return ($VersionsWOW[$BuildNumber]);395 return $VersionsWOW[$BuildNumber]; 396 396 } 397 397 … … 401 401 global $System, $VersionsWOWId; 402 402 403 if (isset($VersionsWOWId[$BuildNumber]) == false)403 if (isset($VersionsWOWId[$BuildNumber]) == false) 404 404 { 405 405 $sql = 'SELECT `Id` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"'; … … 408 408 $VersionsWOWId[$BuildNumber] = $Version['Id']; 409 409 } 410 return ($VersionsWOWId[$BuildNumber]);410 return $VersionsWOWId[$BuildNumber]; 411 411 } 412 412 … … 416 416 $TranslationTree = $System->ModuleManager->Modules['Translation']->GetTranslationTree(); 417 417 418 if (array_key_exists('group', $_GET)) $GroupId = $_GET['group'] * 1;418 if (array_key_exists('group', $_GET)) $GroupId = $_GET['group'] * 1; 419 419 else $GroupId = 1; 420 420 421 if (isset($TranslationTree[$GroupId]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.');422 return ($GroupId);421 if (isset($TranslationTree[$GroupId]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 422 return $GroupId; 423 423 } 424 424 425 425 function LoadCommandLineParameters() 426 426 { 427 if (!array_key_exists('REMOTE_ADDR', $_SERVER))428 { 429 foreach ($_SERVER['argv'] as $Parameter)430 { 431 if (strpos($Parameter, '=') !== false)427 if (!array_key_exists('REMOTE_ADDR', $_SERVER)) 428 { 429 foreach ($_SERVER['argv'] as $Parameter) 430 { 431 if (strpos($Parameter, '=') !== false) 432 432 { 433 433 $Index = substr($Parameter, 0, strpos($Parameter, '=')); … … 444 444 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 445 445 446 if (array_key_exists('Tab', $_GET)) $_SESSION['Tab'] = $_GET['Tab'];447 if (!array_key_exists('Tab', $_SESSION)) $_SESSION['Tab'] = 0;448 if (($_SESSION['Tab'] < 0) or ($_SESSION['Tab'] > (count($Tabs) - 1))) $_SESSION['Tab'] = 0;446 if (array_key_exists('Tab', $_GET)) $_SESSION['Tab'] = $_GET['Tab']; 447 if (!array_key_exists('Tab', $_SESSION)) $_SESSION['Tab'] = 0; 448 if (($_SESSION['Tab'] < 0) or ($_SESSION['Tab'] > (count($Tabs) - 1))) $_SESSION['Tab'] = 0; 449 449 $Output = '<div id="header">'. 450 450 '<ul>'; 451 foreach ($Tabs as $Index => $Tab)451 foreach ($Tabs as $Index => $Tab) 452 452 { 453 453 $QueryItems['Tab'] = $Index; 454 if ($Index == $_SESSION['Tab']) $Selected = ' id="selected"';454 if ($Index == $_SESSION['Tab']) $Selected = ' id="selected"'; 455 455 else $Selected = ''; 456 456 $Output .= '<li'.$Selected.'><a href="?'.SetQueryStringArray($QueryItems).'">'.$Tab.'</a></li>'; 457 457 } 458 458 $Output .= '</ul></div>'; 459 return ($Output);459 return $Output; 460 460 } 461 461 462 462 function CheckBox($Name, $Checked = false, $Id = '', $Class = '', $Disabled = false) 463 463 { 464 if ($Id) $Id = ' id="'.$Id.'"'; else $Id = '';465 if ($Class) $Class = ' class="'.$Class.'"'; else $Class = '';466 if ($Checked) $Checked = ' checked="checked"'; else $Checked = '';467 if ($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = '';468 return ('<input type="checkbox" value="checked" name="'.$Name.'"'.$Checked.$Disabled.$Id.$Class.' />');464 if ($Id) $Id = ' id="'.$Id.'"'; else $Id = ''; 465 if ($Class) $Class = ' class="'.$Class.'"'; else $Class = ''; 466 if ($Checked) $Checked = ' checked="checked"'; else $Checked = ''; 467 if ($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = ''; 468 return '<input type="checkbox" value="checked" name="'.$Name.'"'.$Checked.$Disabled.$Id.$Class.' />'; 469 469 } 470 470 471 471 function RadioButton($Name, $Value, $Checked = false, $OnClick = '', $Disabled = false) 472 472 { 473 if ($Checked) $Checked = ' checked="checked"'; else $Checked = '';474 if ($OnClick != '') $OnClick = ' onclick="'.$OnClick.'"'; else $OnClick = '';475 if ($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = '';476 return ('<input type="radio" name="'.$Name.'" value="'.$Value.'"'.$Checked.$Disabled.$OnClick.'/>');473 if ($Checked) $Checked = ' checked="checked"'; else $Checked = ''; 474 if ($OnClick != '') $OnClick = ' onclick="'.$OnClick.'"'; else $OnClick = ''; 475 if ($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = ''; 476 return '<input type="radio" name="'.$Name.'" value="'.$Value.'"'.$Checked.$Disabled.$OnClick.'/>'; 477 477 } 478 478 479 479 function SelectOption($Name, $Text, $Selected = false) 480 480 { 481 if ($Selected) $Selected = ' selected="selected"'; else $Selected = '';482 return ('<option value="'.$Name.'"'.$Selected.'>'.$Text.'</option>');481 if ($Selected) $Selected = ' selected="selected"'; else $Selected = ''; 482 return '<option value="'.$Name.'"'.$Selected.'>'.$Text.'</option>'; 483 483 } 484 484 485 485 function DeleteDirectory($dirname) 486 486 { 487 if (is_dir($dirname))487 if (is_dir($dirname)) 488 488 { 489 489 $dir_handle = opendir($dirname); 490 if (!$dir_handle) return(false);491 while ($file = readdir($dir_handle))492 { 493 if (($file != '.') and ($file != '..'))490 if (!$dir_handle) return false; 491 while ($file = readdir($dir_handle)) 492 { 493 if (($file != '.') and ($file != '..')) 494 494 { 495 if (!is_dir($dirname.'/'.$file)) unlink($dirname.'/'.$file);495 if (!is_dir($dirname.'/'.$file)) unlink($dirname.'/'.$file); 496 496 else DeleteDirectory($dirname.'/'.$file); 497 497 } … … 500 500 rmdir($dirname); 501 501 } 502 return (true);502 return true; 503 503 } 504 504 … … 515 515 $TranslationTree = $System->ModuleManager->Modules['Translation']->GetTranslationTree(); 516 516 517 foreach ($TranslationTree as $TableID => $Value)518 { 519 if ($Value['TablePrefix'] == $Table) return $TableID;517 foreach ($TranslationTree as $TableID => $Value) 518 { 519 if ($Value['TablePrefix'] == $Table) return $TableID; 520 520 } 521 521 } … … 540 540 'Dictionary' => 'Text', 541 541 ); 542 return ($TablesColumn);542 return $TablesColumn; 543 543 } 544 544 … … 578 578 $sqlall = ''; 579 579 580 foreach ($TablesColumn as $Table => $Column)580 foreach ($TablesColumn as $Table => $Column) 581 581 { 582 582 $orderinby = ' ORDER BY ID DESC '; … … 588 588 589 589 $where = '(`Language` = '.$Config['OriginalLanguage'].') '; 590 if ($mode == 1) 590 if ($mode == 1) 591 591 { 592 592 $where .= ' AND EXISTS(SELECT 1 FROM `'.$Table. … … 594 594 ') AND (`Sub`.`Entry` = `O`.`Entry`))'; 595 595 } 596 if ($mode == 2) 596 if ($mode == 2) 597 597 { 598 598 $where .= ' AND NOT EXISTS(SELECT 1 FROM `'.$Table. … … 601 601 } 602 602 $where .= ' AND ('; 603 if (array_search('the', $ArrStr)) 603 if (array_search('the', $ArrStr)) 604 604 { 605 605 $where .= '(`O`.`'.$Column.'` LIKE "The %") OR '; … … 607 607 608 608 $SqlOK = false; 609 if (count($ArrStr) > 0) 609 if (count($ArrStr) > 0) 610 610 { 611 611 for ($i = 0; $i < count($ArrStr); $i++) … … 614 614 if ((strlen($ArrStr[$i]) > 3) or ( ((count($ArrStr) < 6) or ($i == 0)) and (strlen($ArrStr[$i]) > 0) ) ) //length 615 615 if ((!$FirstBig) or (ctype_upper(substr($ArrStr[$i], 0, 1))) or (count($ArrStr) < 6) ) //first big 616 if (array_search($ArrStr[$i], $ArrStr) == $i) 616 if (array_search($ArrStr[$i], $ArrStr) == $i) 617 617 { // first in array 618 618 $where .= '(`O`.`'.$Column.'` LIKE "'.addslashes($ArrStr[$i]).'%") OR '; … … 623 623 $where .= ')'; 624 624 } 625 if ($SqlOK) 625 if ($SqlOK) 626 626 { 627 627 //$sql.$where.$groupby.$orderby 628 628 // $buff[] = array($Line['ID'], GetIDbyName($Table), $Line['Orig'], $Line['Tran']); 629 if ($sqlall <> '') 630 { 631 $sqlall .= ' UNION ALL ( '.$sql.$where.$groupby.' )'; 629 if ($sqlall <> '') 630 { 631 $sqlall .= ' UNION ALL ( '.$sql.$where.$groupby.' )'; 632 632 } else { 633 $sqlall .= ' ( '.$sql.$where.$groupby.' )'; 633 $sqlall .= ' ( '.$sql.$where.$groupby.' )'; 634 634 } 635 635 } 636 636 } 637 if ($SqlOK) 637 if ($SqlOK) 638 638 { 639 639 $orderby = ' ORDER BY LENGTH(Orig) DESC '; … … 641 641 $DbResult = $System->Database->query($sqlall.$orderby); 642 642 // echo ($sql.'|'.$where.'|'.$groupby); 643 while ($Line = $DbResult->fetch_assoc())643 while ($Line = $DbResult->fetch_assoc()) 644 644 { 645 645 $buff[] = array($Line['ID'], $Line['GroupId'], $Line['Orig'], $Line['Tran']); … … 652 652 { 653 653 $Pixels = $Width * ($Percent / 100); 654 if ($Pixels > $Width) $Pixels = $Width;655 if ($Text == '') $Text = $Percent;656 657 return ('<div class="progressbar" style="width: '.$Width.'px">'.654 if ($Pixels > $Width) $Pixels = $Width; 655 if ($Text == '') $Text = $Percent; 656 657 return '<div class="progressbar" style="width: '.$Width.'px">'. 658 658 '<div class="bar" style="width: '.$Pixels.'px;"></div>'. 659 659 '<div class="text" style="width: '.$Width.'px">'.$Text.'</div>'. 660 '</div>' );660 '</div>'; 661 661 } 662 662 … … 665 665 $IndexLevel = 100; 666 666 667 if ($XP > 0) $Level = floor(sqrt($XP / $IndexLevel));667 if ($XP > 0) $Level = floor(sqrt($XP / $IndexLevel)); 668 668 else $Level = 0; 669 669 $MinXP = $Level * $Level * $IndexLevel; … … 671 671 $MaxXP = $MaxXP - $MinXP; 672 672 $XP = $XP - $MinXP; 673 return (array('Level' => $Level, 'XP' => $XP, 'MaxXP' => $MaxXP));673 return array('Level' => $Level, 'XP' => $XP, 'MaxXP' => $MaxXP); 674 674 } 675 675 … … 677 677 { 678 678 $Result = $Default; 679 if (array_key_exists($Name, $_GET)) $Result = $_GET[$Name];680 else if (array_key_exists($Name, $_POST)) $Result = $_POST[$Name];681 else if ($Session and array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name];682 if ($Numeric and !is_numeric($Result)) $Result = $Default;683 if ($Session) $_SESSION[$Name] = $Result;684 return ($Result);679 if (array_key_exists($Name, $_GET)) $Result = $_GET[$Name]; 680 else if (array_key_exists($Name, $_POST)) $Result = $_POST[$Name]; 681 else if ($Session and array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name]; 682 if ($Numeric and !is_numeric($Result)) $Result = $Default; 683 if ($Session) $_SESSION[$Name] = $Result; 684 return $Result; 685 685 } 686 686 … … 693 693 $Result = ''; 694 694 $I = 0; 695 while ((strpos($Content, 'http://') !== false) or (strpos($Content, 'https://') !== false))696 { 697 if (strpos($Content, 'http://') !== false) $I = strpos($Content, 'http://');698 if (strpos($Content, 'https://') !== false) $I = strpos($Content, 'https://');695 while ((strpos($Content, 'http://') !== false) or (strpos($Content, 'https://') !== false)) 696 { 697 if (strpos($Content, 'http://') !== false) $I = strpos($Content, 'http://'); 698 if (strpos($Content, 'https://') !== false) $I = strpos($Content, 'https://'); 699 699 $Result .= substr($Content, 0, $I); 700 700 $Content = substr($Content, $I); 701 701 $SpacePos = strpos($Content, ' '); 702 if ($SpacePos !== false) $URL = substr($Content, 0, strpos($Content, ' '));702 if ($SpacePos !== false) $URL = substr($Content, 0, strpos($Content, ' ')); 703 703 else $URL = substr($Content, 0); 704 704 … … 707 707 } 708 708 $Result .= $Content; 709 return ($Result);709 return $Result; 710 710 } 711 711 … … 729 729 ); 730 730 731 return ('<div class="message" style="background-color: '.$BackgroundColor[$Type].731 return '<div class="message" style="background-color: '.$BackgroundColor[$Type]. 732 732 ';"><table><tr><td class="icon"><img src="'. 733 733 $System->Link('/images/message/'.$IconName[$Type].'.png').'" alt="'. 734 $IconName[$Type].'"><td>'.$Text.'</td></tr></table></div>' );734 $IconName[$Type].'"><td>'.$Text.'</td></tr></table></div>'; 735 735 } 736 736 737 737 function ProcessURL() 738 738 { 739 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))739 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) 740 740 $PathString = $_SERVER['REDIRECT_QUERY_STRING']; 741 741 else $PathString = ''; 742 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);742 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1); 743 743 $PathItems = explode('/', $PathString); 744 if (strpos(GetRequestURI(), '?') !== false)744 if (strpos(GetRequestURI(), '?') !== false) 745 745 $_SERVER['QUERY_STRING'] = substr(GetRequestURI(), strpos(GetRequestURI(), '?') + 1); 746 746 else $_SERVER['QUERY_STRING'] = ''; 747 747 parse_str($_SERVER['QUERY_STRING'], $_GET); 748 748 // SQL injection hack protection 749 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]);750 return ($PathItems);749 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]); 750 return $PathItems; 751 751 } 752 752 … … 757 757 $Output = '<select name="Language">'; 758 758 $DbResult = $System->Database->select('Language', '`Id`, `Name`', '`Enabled` = 1'); 759 while ($Language = $DbResult->fetch_assoc())759 while ($Language = $DbResult->fetch_assoc()) 760 760 { 761 761 $Output .= '<option value="'.$Language['Id'].'"'; 762 if ($Selected == $Language['Id'])762 if ($Selected == $Language['Id']) 763 763 $Output .= ' selected="selected"'; 764 764 $Output .= '>'.T($Language['Name']).'</option>'; 765 765 } 766 766 $Output .= '</select>'; 767 return ($Output);767 return $Output; 768 768 } 769 769 770 770 function GetClientProxyAddresses() 771 771 { 772 if (array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'];772 if (array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR']; 773 773 else $IP = array(); 774 774 } … … 776 776 function GetRemoteAddress() 777 777 { 778 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];778 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR']; 779 779 else $IP = ''; 780 return ($IP);780 return $IP; 781 781 } 782 782 783 783 function GetRequestURI() 784 784 { 785 if (array_key_exists('REQUEST_URI', $_SERVER)) return($_SERVER['REQUEST_URI']);786 else return ($_SERVER['PHP_SELF']);787 } 785 if (array_key_exists('REQUEST_URI', $_SERVER)) return $_SERVER['REQUEST_URI']; 786 else return $_SERVER['PHP_SELF']; 787 } -
trunk/includes/MemoryStream.php
r815 r880 20 20 $Result = substr($this->Data, $this->Position, $Count); 21 21 $this->Position = $this->Position + $Count; 22 return ($Result);22 return $Result; 23 23 } 24 24 … … 27 27 $Result = $this->Data[$this->Position]; 28 28 $this->Position = $this->Position + 1; 29 return ($Result);29 return $Result; 30 30 } 31 31 … … 34 34 $val = unpack('V*', substr($this->Data, $this->Position, 4)); 35 35 $this->Position = $this->Position + 4; 36 return ($val[1]);36 return $val[1]; 37 37 } 38 38 … … 41 41 $val = unpack('I*', substr($this->Data, $this->Position, 4)); 42 42 $this->Position = $this->Position + 4; 43 return ($val[1]);43 return $val[1]; 44 44 } 45 45 … … 48 48 $val = unpack('f*', substr($this->Data, $this->Position, 4)); 49 49 $this->Position = $this->Position + 4; 50 return ($val[1]);50 return $val[1]; 51 51 } 52 52 … … 55 55 $Result = $this->Data[$this->Position]; 56 56 $this->Position = $this->Position + 1; 57 return ($Result);57 return $Result; 58 58 } 59 59 … … 62 62 $Length = 0; 63 63 $StartPosition = $this->Position; 64 while (!$this->EOF())64 while (!$this->EOF()) 65 65 { 66 66 $Char = $this->ReadChar(); 67 if ($Char == $EndSymbol) break;67 if ($Char == $EndSymbol) break; 68 68 } 69 69 $Result = substr($this->Data, $StartPosition, $this->Position - $StartPosition); 70 return ($Result);70 return $Result; 71 71 } 72 72 … … 116 116 public function GetPosition() 117 117 { 118 return ($this->Position);118 return $this->Position; 119 119 } 120 120 121 121 public function GetSize() 122 122 { 123 return (strlen($this->Data));123 return strlen($this->Data); 124 124 } 125 125 126 126 public function SetSize($Size) 127 127 { 128 return ($this->Data = substr($this->Data, 0, $Size));128 return $this->Data = substr($this->Data, 0, $Size); 129 129 } 130 130 131 131 public function EOF() 132 132 { 133 return ($this->Position >= strlen($this->Data));133 return $this->Position >= strlen($this->Data); 134 134 } 135 135 } -
trunk/includes/PageEdit.php
r838 r880 16 16 ); 17 17 $this->AllowEdit = false; 18 if ($this->AllowEdit) $this->ItemActions[] = array('Name' => T('Delete'), 'URL' => '?action=remove&id=#Id');18 if ($this->AllowEdit) $this->ItemActions[] = array('Name' => T('Delete'), 'URL' => '?action=remove&id=#Id'); 19 19 } 20 20 … … 22 22 { 23 23 $Output = ''; 24 if (array_key_exists('action', $_GET))24 if (array_key_exists('action', $_GET)) 25 25 { 26 if ($_GET['action'] == 'add') $Output .= $this->AddItem();27 else if ($_GET['action'] == 'view') $Output .= $this->ViewItem();28 else if ($_GET['action'] == 'edit') $Output .= $this->ModifyItem();29 else if ($_GET['action'] == 'remove') $Output .= $this->RemoveItem();30 else if ($_GET['action'] == 'delete') $Output .= $this->DeleteItem();26 if ($_GET['action'] == 'add') $Output .= $this->AddItem(); 27 else if ($_GET['action'] == 'view') $Output .= $this->ViewItem(); 28 else if ($_GET['action'] == 'edit') $Output .= $this->ModifyItem(); 29 else if ($_GET['action'] == 'remove') $Output .= $this->RemoveItem(); 30 else if ($_GET['action'] == 'delete') $Output .= $this->DeleteItem(); 31 31 else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL); 32 32 } else $Output .= $this->ViewList(); 33 return ($Output);33 return $Output; 34 34 } 35 35 … … 37 37 { 38 38 $DbResult = $this->Database->query('SELECT * FROM ('.$this->TableSQL.') AS `T` WHERE `Id`='.$_GET['id']); 39 if ($DbResult->num_rows > 0)39 if ($DbResult->num_rows > 0) 40 40 { 41 41 $DbRow = $DbResult->fetch_assoc(); … … 43 43 $Output = T('Item'). 44 44 '<table>'; 45 foreach ($this->Definition as $DefIndex => $Def)45 foreach ($this->Definition as $DefIndex => $Def) 46 46 { 47 47 $Output .= '<tr><td>'.$Def['Title'].':</td><td>'.$this->ViewControl($Def['Type'], $DefIndex, $DbRow[$DefIndex]).'</tr>'; … … 50 50 '</table>'; 51 51 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 52 if ($this->AllowEdit)52 if ($this->AllowEdit) 53 53 { 54 54 $Output .= '<a href="?action=add">'.T('Add').'</a> '; … … 57 57 } 58 58 $Output .= '<a href="?">'.T('List').'</a><br/>'; 59 return ($Output);59 return $Output; 60 60 } 61 61 … … 69 69 $Output .= '<table class="BaseTable">'; 70 70 $TableColumns = array(); 71 foreach ($this->Definition as $Index => $Def)72 if ($Def['InList'])71 foreach ($this->Definition as $Index => $Def) 72 if ($Def['InList']) 73 73 $TableColumns[] = array('Name' => $Index, 'Title' => $Def['Title']); 74 if (count($this->ItemActions) > 0)74 if (count($this->ItemActions) > 0) 75 75 $TableColumns[] = array('Name' => '', 'Title' => 'Akce'); 76 76 … … 79 79 80 80 $DbResult = $this->Database->query('SELECT * FROM ('.$this->Table.') '.$Order['SQL'].$PageList['SQLLimit']); 81 while ($Item = $DbResult->fetch_assoc())81 while ($Item = $DbResult->fetch_assoc()) 82 82 { 83 83 $Output .= '<tr>'; 84 foreach ($this->Definition as $Index => $Def)85 if ($Def['InList'])84 foreach ($this->Definition as $Index => $Def) 85 if ($Def['InList']) 86 86 { 87 if ($Def['Type'] == 'URL') $Output .= '<td><a href="'.$Item[$Index].'">'.$Item[$Index].'</a></td>';87 if ($Def['Type'] == 'URL') $Output .= '<td><a href="'.$Item[$Index].'">'.$Item[$Index].'</a></td>'; 88 88 else $Output .= '<td>'.$Item[$Index].'</td>'; 89 89 } 90 if (count($this->ItemActions) > 0)90 if (count($this->ItemActions) > 0) 91 91 { 92 92 $Output .= '<td>'; 93 foreach ($this->ItemActions as $Index => $Action)93 foreach ($this->ItemActions as $Index => $Action) 94 94 { 95 95 $URL = $Action['URL']; 96 if (strpos($URL, '#Id')) $URL = str_replace('#Id', $Item['Id'], $URL);96 if (strpos($URL, '#Id')) $URL = str_replace('#Id', $Item['Id'], $URL); 97 97 $Output .= '<a href="'.$URL.'">'.$Action['Name'].'</a> '; 98 98 } … … 102 102 } 103 103 $Output .= '</table>'; 104 if ($this->AllowEdit) $Output .= '<a href="?action=add">'.T('Add').'</a><br/>';105 return ($Output);104 if ($this->AllowEdit) $Output .= '<a href="?action=add">'.T('Add').'</a><br/>'; 105 return $Output; 106 106 } 107 107 … … 109 109 { 110 110 $Output = ''; 111 if ($this->System->User->Licence(LICENCE_USER))111 if ($this->System->User->Licence(LICENCE_USER)) 112 112 { 113 if (array_key_exists('finish', $_GET))113 if (array_key_exists('finish', $_GET)) 114 114 { 115 115 $Items = array(); 116 foreach ($this->Definition as $Index => $Def)116 foreach ($this->Definition as $Index => $Def) 117 117 { 118 118 $Items[$Index] = $_POST[$Index]; … … 125 125 '<fieldset><legend>'.T('New item').'</legend>'. 126 126 '<table>'; 127 foreach ($this->Definition as $DefIndex => $Def)127 foreach ($this->Definition as $DefIndex => $Def) 128 128 { 129 129 $Output .= '<tr><td>'.$Def['Title'].':</td><td>'.$this->GetControl($Def['Type'], $DefIndex, '').'</tr>'; … … 135 135 } 136 136 } else $Output .= ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 137 return ($Output);137 return $Output; 138 138 } 139 139 140 140 function DeleteItem() 141 141 { 142 if ($this->System->User->Licence(LICENCE_USER))142 if ($this->System->User->Licence(LICENCE_USER)) 143 143 { 144 144 $this->Database->query('DELETE FROM `'.$this->Table.'` WHERE (`User`='.$this->System->User->Id.') AND (`Id`='.($_GET['id'] * 1).')'); 145 145 $Output = ShowMessage(T('Record removed')); 146 146 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 147 return ($Output);147 return $Output; 148 148 } 149 149 150 150 function GetControl($Type, $Name, $Value) 151 151 { 152 if ($Type == 'Text') $Output = '<input type="text" name="'.$Name.'" value="'.$Value.'"/>';153 else if ($Type == 'Boolean') $Output = '<input type="checkbox" name="'.$Name.'"/>';152 if ($Type == 'Text') $Output = '<input type="text" name="'.$Name.'" value="'.$Value.'"/>'; 153 else if ($Type == 'Boolean') $Output = '<input type="checkbox" name="'.$Name.'"/>'; 154 154 else $Output = '<input type="text" name="'.$Name.'" value="'.$Value.'"/>'; 155 return ($Output);155 return $Output; 156 156 } 157 157 158 158 function ViewControl($Type, $Name, $Value) 159 159 { 160 if ($Type == 'Text') $Output = $Value;161 else if ($Type == 'URL') $Output = '<a href="'.$Value.'">'.$Value.'</a>';162 else if ($Type == 'Boolean') $Output = $Value;160 if ($Type == 'Text') $Output = $Value; 161 else if ($Type == 'URL') $Output = '<a href="'.$Value.'">'.$Value.'</a>'; 162 else if ($Type == 'Boolean') $Output = $Value; 163 163 else $Output = $Value; 164 return ($Output);164 return $Output; 165 165 } 166 166 } -
trunk/includes/dbc.php
r815 r880 35 35 36 36 $this->ColumnFormat = $ColumnFormat; 37 if ($this->ReadUint() != DBC_SIGNATURE) die(NOT_DBC_FILE);37 if ($this->ReadUint() != DBC_SIGNATURE) die(NOT_DBC_FILE); 38 38 39 39 $this->RecordCount = $this->ReadUint(); … … 43 43 44 44 $this->GenerateOffsetTable(); 45 if ($this->EndOffset != $this->RecordSize)45 if ($this->EndOffset != $this->RecordSize) 46 46 die(RECORD_SIZE_NOT_MATCH.$this->EndOffset.' <> '.$this->RecordSize); 47 47 } … … 71 71 { 72 72 // Preallocate array 73 if ($this->FieldCount > 0) $this->Offsets = array_fill(0, $this->FieldCount, 0);73 if ($this->FieldCount > 0) $this->Offsets = array_fill(0, $this->FieldCount, 0); 74 74 else $this->Offsets = array(); 75 75 76 76 $Offset = 0; 77 77 $I = 0; 78 while ($I < $this->FieldCount)78 while ($I < $this->FieldCount) 79 79 { 80 80 $this->Offsets[$I] = $Offset; 81 if (array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I];81 if (array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I]; 82 82 else $Format = FORMAT_UINT32; 83 switch ($Format)83 switch ($Format) 84 84 { 85 85 case FORMAT_BYTE: … … 100 100 private function CellPos($Row, $Column) 101 101 { 102 return ($this->HeaderSize + $Row * $this->RecordSize + $this->Offsets[$Column]);102 return $this->HeaderSize + $Row * $this->RecordSize + $this->Offsets[$Column]; 103 103 } 104 104 … … 106 106 { 107 107 $this->SetPosition($this->CellPos($Row, $Column)); 108 return ($this->ReadByte());108 return $this->ReadByte(); 109 109 } 110 110 … … 112 112 { 113 113 $this->SetPosition($this->CellPos($Row, $Column)); 114 return ($this->ReadUint());114 return $this->ReadUint(); 115 115 } 116 116 … … 118 118 { 119 119 $this->SetPosition($this->CellPos($Row, $Column)); 120 return ($this->ReadInt());120 return $this->ReadInt(); 121 121 } 122 122 … … 124 124 { 125 125 $this->SetPosition($this->CellPos($Row, $Column)); 126 return ($this->ReadFloat());126 return $this->ReadFloat(); 127 127 } 128 128 … … 156 156 157 157 $Position = $this->HeaderSize + $this->RecordCount * $this->RecordSize + $Offset; 158 if ($Position >= $this->GetSize()) return('');158 if ($Position >= $this->GetSize()) return ''; 159 159 $this->SetPosition($Position); 160 160 161 161 $String = ''; 162 while (($Char = $this->ReadChar()) != "\0")162 while (($Char = $this->ReadChar()) != "\0") 163 163 { 164 164 $String .= $Char; 165 165 } 166 return ($String);166 return $String; 167 167 } 168 168 169 169 public function SetString($Row, $Column, $Value) 170 170 { 171 if (in_array($Value, $this->StringList))171 if (in_array($Value, $this->StringList)) 172 172 { 173 173 $this->SetUint($Row, $Column, $this->StringListOffset[array_search($Value, $this->StringList)]); … … 192 192 $this->SetPosition($this->HeaderSize + $this->RecordCount * $this->RecordSize); 193 193 $this->WriteByte(0); 194 foreach ($this->StringList as $Index => $Item)194 foreach ($this->StringList as $Index => $Item) 195 195 { 196 196 $this->WriteString($Item."\0"); … … 206 206 207 207 // Preallocate array 208 if ($this->FieldCount > 0) $Line = array_fill(0, $this->FieldCount, 0);208 if ($this->FieldCount > 0) $Line = array_fill(0, $this->FieldCount, 0); 209 209 else $Line = array(); 210 for ($I = 0; $I < $this->FieldCount; $I++)211 { 212 if (array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I];210 for ($I = 0; $I < $this->FieldCount; $I++) 211 { 212 if (array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I]; 213 213 else $Format = FORMAT_UINT32; 214 214 $Record->SetPosition($this->Offsets[$I]); 215 switch ($Format)215 switch ($Format) 216 216 { 217 217 case FORMAT_BYTE: … … 231 231 232 232 $Position = $this->HeaderSize + $this->RecordCount * $this->RecordSize + $Offset; 233 if ($Position >= $this->GetSize()) $String = '';233 if ($Position >= $this->GetSize()) $String = ''; 234 234 else 235 235 { 236 236 $this->SetPosition($Position); 237 237 $String = ''; 238 while (($Char = $this->ReadChar()) != "\0")238 while (($Char = $this->ReadChar()) != "\0") 239 239 $String .= $Char; 240 240 } … … 245 245 } 246 246 } 247 return ($Line);247 return $Line; 248 248 } 249 249 … … 253 253 $Record = new MemoryStream(); 254 254 255 for ($I = 0; $I < $this->FieldCount; $I++)256 { 257 if (array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I];255 for ($I = 0; $I < $this->FieldCount; $I++) 256 { 257 if (array_key_exists($I, $this->ColumnFormat)) $Format = $this->ColumnFormat[$I]; 258 258 else $Format = FORMAT_UINT32; 259 259 $Record->SetPosition($this->Offsets[$I]); 260 switch ($Format)260 switch ($Format) 261 261 { 262 262 case FORMAT_BYTE: … … 273 273 break; 274 274 case FORMAT_STRING: 275 if (in_array($Line[$I], $this->StringList))275 if (in_array($Line[$I], $this->StringList)) 276 276 { 277 277 $Record->WriteUint($this->StringListOffset[array_search($Line[$I], $this->StringList)]); … … 291 291 $this->SetPosition($this->CellPos($Row, 0)); 292 292 $this->WriteBlock($Record->Data, $this->RecordSize); 293 return ($Line);293 return $Line; 294 294 } 295 295 296 296 public function GetRecordCount() 297 297 { 298 return ($this->RecordCount);298 return $this->RecordCount; 299 299 } 300 300 … … 306 306 public function GetFieldCount() 307 307 { 308 return ($this->FieldCount);308 return $this->FieldCount; 309 309 } 310 310
Note:
See TracChangeset
for help on using the changeset viewer.