Changeset 7
- Timestamp:
- Apr 14, 2020, 11:13:32 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Core.php
r3 r7 2 2 3 3 $ConfigFileName = dirname(__FILE__).'/../Config/Config.php'; 4 if (file_exists($ConfigFileName)) include_once($ConfigFileName);4 if (file_exists($ConfigFileName)) include_once($ConfigFileName); 5 5 6 6 include_once(dirname(__FILE__).'/../Packages/Common/Common.php'); … … 31 31 $this->BaseURL = $_SERVER['SCRIPT_NAME']; 32 32 $BaseScriptName = '/index.php'; 33 if (substr($this->BaseURL, -strlen($BaseScriptName), strlen($BaseScriptName)) == $BaseScriptName)33 if (substr($this->BaseURL, -strlen($BaseScriptName), strlen($BaseScriptName)) == $BaseScriptName) 34 34 $this->BaseURL = substr($this->BaseURL, 0, -strlen($BaseScriptName)); 35 35 $this->FormManager = new FormManager($this->Database); … … 48 48 $this->Config = &$Config; 49 49 50 if (isset($this->Config['Database']))50 if (isset($this->Config['Database'])) 51 51 { 52 52 $this->Database->Connect($Config['Database']['Host'], $Config['Database']['User'], … … 59 59 60 60 // SQL injection hack protection 61 foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);62 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);61 foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item); 62 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); 63 63 64 64 $this->RegisterPageBar('Top'); … … 68 68 $this->Setup = new Setup($this); 69 69 $this->Setup->Start(); 70 if ($this->Setup->CheckState())70 if ($this->Setup->CheckState()) 71 71 { 72 72 $this->ModuleManager->Start(); … … 77 77 { 78 78 $this->RunCommon(); 79 if ($this->ShowPage)79 if ($this->ShowPage) 80 80 { 81 81 $this->PathItems = ProcessURL(); … … 90 90 /* @var $Page Page */ 91 91 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 92 if ($ClassName != '')92 if ($ClassName != '') 93 93 { 94 94 $Page = new $ClassName($this); … … 101 101 function RegisterPage($Path, $Handler) 102 102 { 103 if (is_array($Path))103 if (is_array($Path)) 104 104 { 105 105 $Page = &$this->Pages; 106 106 $LastKey = array_pop($Path); 107 foreach ($Path as $PathItem)107 foreach ($Path as $PathItem) 108 108 { 109 109 $Page = &$Page[$PathItem]; 110 110 } 111 if (!is_array($Page)) $Page = array('' => $Page);111 if (!is_array($Page)) $Page = array('' => $Page); 112 112 $Page[$LastKey] = $Handler; 113 113 } else $this->Pages[$Path] = $Handler; … … 136 136 function SearchPage($PathItems, $Pages) 137 137 { 138 if (count($PathItems) > 0) $PathItem = $PathItems[0];138 if (count($PathItems) > 0) $PathItem = $PathItems[0]; 139 139 else $PathItem = ''; 140 if (array_key_exists($PathItem, $Pages))140 if (array_key_exists($PathItem, $Pages)) 141 141 { 142 if (is_array($Pages[$PathItem]))142 if (is_array($Pages[$PathItem])) 143 143 { 144 144 array_shift($PathItems); 145 return ($this->SearchPage($PathItems, $Pages[$PathItem]));146 } else return ($Pages[$PathItem]);147 } else return ('');145 return $this->SearchPage($PathItems, $Pages[$PathItem]); 146 } else return $Pages[$PathItem]; 147 } else return ''; 148 148 } 149 149 150 150 function Link($Target) 151 151 { 152 return ($this->BaseURL.$Target);152 return $this->BaseURL.$Target; 153 153 } 154 154 } … … 166 166 { 167 167 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 168 return ('<h3 align="center">'.T('Required page not found').'</h3>');168 return '<h3 align="center">'.T('Required page not found').'</h3>'; 169 169 } 170 170 } -
trunk/Application/DefaultConfig.php
r1 r7 6 6 { 7 7 $IsDeveloper = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1')); 8 return (array8 return array 9 9 ( 10 10 array('Name' => 'SystemPassword', 'Type' => 'PasswordEncoded', 'Default' => '', 'Title' => 'Systémové heslo'), … … 36 36 array('Name' => 'Web/ShowPHPError', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat PHP chyby'), 37 37 array('Name' => 'Web/ShowRuntimeInfo', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat běhové informace'), 38 ) );38 ); 39 39 } 40 40 } -
trunk/Application/UpdateTrace.php
r1 r7 9 9 function Get() 10 10 { 11 return (array(12 ) );11 return array( 12 ); 13 13 } 14 14 } -
trunk/Application/View.php
r3 r7 5 5 function SystemMessage($Title, $Text) 6 6 { 7 return ('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>');7 return '<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>'; 8 8 } 9 9 … … 37 37 $Output .= '<div class="MenuItem">'; 38 38 $Bar = ''; 39 foreach ($this->System->Bars['TopLeft'] as $BarItem)39 foreach ($this->System->Bars['TopLeft'] as $BarItem) 40 40 $Bar .= call_user_func($BarItem); 41 if (trim($Bar) != '') $Output .= $Bar;41 if (trim($Bar) != '') $Output .= $Bar; 42 42 else $Output .= ' '; 43 43 $Output .= '</div><div class="MenuItem2">'; 44 44 $Bar = ''; 45 foreach ($this->System->Bars['Top'] as $BarItem)45 foreach ($this->System->Bars['Top'] as $BarItem) 46 46 $Bar .= call_user_func($BarItem); 47 if (trim($Bar) != '') $Output .= $Bar;47 if (trim($Bar) != '') $Output .= $Bar; 48 48 else $Output .= ' '; 49 49 $Output .= '</div></div>'; 50 return ($Output);50 return $Output; 51 51 } 52 52 … … 55 55 $Page->OnSystemMessage = array($this->System->BaseView, 'SystemMessage'); 56 56 $Output = $this->ShowPage($Page->Show()); 57 return ($Output);57 return $Output; 58 58 } 59 59 } -
trunk/Global.php
r1 r7 3 3 function HumanDate($Time) 4 4 { 5 return (date('j.n.Y', $Time));5 return date('j.n.Y', $Time); 6 6 } 7 7 … … 9 9 { 10 10 list($Usec, $Sec) = explode(" ", microtime()); 11 return ( (float)$Usec + (float)$Sec);11 return (float)$Usec + (float)$Sec; 12 12 } 13 13 14 14 function MakeLink($Target, $Title) 15 15 { 16 return ('<a href="'.$Target.'">'.$Title.'</a>');16 return '<a href="'.$Target.'">'.$Title.'</a>'; 17 17 } 18 18 … … 21 21 $Result = '<table cellspacing="0" class="BasicTable">'; 22 22 $Result .= '<tr>'; 23 foreach ($Table['Header'] as $Item)23 foreach ($Table['Header'] as $Item) 24 24 $Result .= '<th>'.$Item.'</th>'; 25 25 $Result .= '</tr>'; 26 foreach ($Table['Rows'] as $Row)26 foreach ($Table['Rows'] as $Row) 27 27 { 28 28 $Result .= '<tr>'; 29 foreach ($Row as $Item)29 foreach ($Row as $Item) 30 30 $Result .= '<td>'.$Item.'</td>'; 31 31 $Result .= '</tr>'; 32 32 } 33 33 $Result .= '</table>'; 34 return ($Result);34 return $Result; 35 35 } 36 36 … … 44 44 ); 45 45 46 foreach ($Class as $Index => $Item)46 foreach ($Class as $Index => $Item) 47 47 { 48 if (!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default'];49 switch ($Item['Type'])48 if (!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default']; 49 switch ($Item['Type']) 50 50 { 51 51 case 'Boolean': 52 if ($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"';52 if ($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"'; 53 53 $Edit = '<input type="checkbox" name="'.$Index.'"'.$Checked.'>'; 54 54 break; … … 65 65 } 66 66 $Output = '<h3>Tabulka '.$ClassName.'</h3>'.Table($Table).MakeLink('?Operation=Add2', 'Přidat'); 67 return ($Output);67 return $Output; 68 68 } 69 69 70 70 function ProcessURL() 71 71 { 72 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))72 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) 73 73 $PathString = $_SERVER['REDIRECT_QUERY_STRING']; 74 74 else $PathString = ''; 75 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);75 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1); 76 76 $PathItems = explode('/', $PathString); 77 if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))77 if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false)) 78 78 $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1); 79 79 else $_SERVER['QUERY_STRING'] = ''; 80 80 parse_str($_SERVER['QUERY_STRING'], $_GET); 81 return ($PathItems);81 return $PathItems; 82 82 } 83 83 … … 86 86 $Result = array(); 87 87 $Parts = explode('&', $QueryString); 88 foreach ($Parts as $Part)88 foreach ($Parts as $Part) 89 89 { 90 if ($Part != '')90 if ($Part != '') 91 91 { 92 if (!strpos($Part, '=')) $Part .= '=';92 if (!strpos($Part, '=')) $Part .= '='; 93 93 $Item = explode('=', $Part); 94 94 $Result[$Item[0]] = $Item[1]; 95 95 } 96 96 } 97 return ($Result);97 return $Result; 98 98 } 99 99 … … 101 101 { 102 102 $Parts = array(); 103 foreach ($QueryStringArray as $Index => $Item)103 foreach ($QueryStringArray as $Index => $Item) 104 104 { 105 105 $Parts[] = $Index.'='.$Item; 106 106 } 107 return (implode('&', $Parts));107 return implode('&', $Parts); 108 108 } 109 109 110 110 function GetRemoteAddress() 111 111 { 112 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];112 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR']; 113 113 else $IP = '0.0.0.0'; 114 return ($IP);114 return $IP; 115 115 } -
trunk/Modules/Map/Map.php
r4 r7 53 53 function Geolocate($Text) 54 54 { 55 return (null);56 } 57 58 function Show() 59 { 60 return ('');55 return null; 56 } 57 58 function Show() 59 { 60 return ''; 61 61 } 62 62 … … 66 66 $Result = substr($Text, 0, strpos($Text, $End) - 1); 67 67 $Text = substr($Text, strlen($End)); 68 return ($Result);68 return $Result; 69 69 } 70 70 } … … 107 107 <script>Loader.load()</script>'; 108 108 109 return ($Output);109 return $Output; 110 110 } 111 111 } … … 117 117 $Origins = array(); 118 118 $Destinations = array(); 119 foreach ($this->Path as $Index => $PathItem)119 foreach ($this->Path as $Index => $PathItem) 120 120 if ($Index > 0) 121 121 { … … 134 134 $I++; 135 135 } 136 return ($Points);136 return $Points; 137 137 } 138 138 … … 142 142 array_shift($WayPoints); 143 143 array_pop($WayPoints); 144 if (count($WayPoints) > 0)144 if (count($WayPoints) > 0) 145 145 $WaypointsQuery = '&waypoints='.implode('|', $WayPoints); 146 146 else $WaypointsQuery = ''; … … 151 151 '&destination='.$this->Path[count($this->Path) - 1].''. 152 152 '" style="border: 1px solid black"></iframe>'; 153 return ($Output);153 return $Output; 154 154 } 155 155 } … … 176 176 { 177 177 $this->Points = array(); 178 foreach ($TextPathItems as $TextPathItem)178 foreach ($TextPathItems as $TextPathItem) 179 179 { 180 180 $Result = $this->Geolocate($TextPathItem); … … 184 184 185 185 $WayPoints = array(); 186 foreach ($this->Points as $Point)186 foreach ($this->Points as $Point) 187 187 { 188 188 $WayPoints[] = $Point['Longitude']; … … 208 208 $Points = array(); 209 209 $Separator = '<gml:pos>'; 210 while (strpos($Result, $Separator) !== false)210 while (strpos($Result, $Separator) !== false) 211 211 { 212 212 $Result = substr($Result, strpos($Result, $Separator) + strlen($Separator)); … … 215 215 $Points[] = array('Longitude' => $PosParts[0], 'Latitude' => $PosParts[1]); 216 216 } 217 return (array('TotalDistance' => $TotalDistance, 'TotalTime' => $TotalTime,218 'Points' => $Points) );217 return array('TotalDistance' => $TotalDistance, 'TotalTime' => $TotalTime, 218 'Points' => $Points); 219 219 } 220 220 … … 222 222 { 223 223 $WayPoints = array(); 224 foreach ($this->Points as $Point)224 foreach ($this->Points as $Point) 225 225 { 226 226 $WayPoints[] = $Point['Longitude']; -
trunk/Modules/Ride/Ride.php
r6 r7 140 140 'Vsetín', 'Nový Jičín', 'Prostějov', 'Vyškov', 'Mohelnice', 'Ústí nad Orlicí'); 141 141 142 for ($I = 0; $I < 100; $I++)142 for ($I = 0; $I < 100; $I++) 143 143 { 144 144 $Stops = array_fill(0, random(5), ''); 145 for ($J = 0; $J < count($Stops); $J++)145 for ($J = 0; $J < count($Stops); $J++) 146 146 $Stops[$J] = $Cities[random(count($Cities))]; 147 147 … … 158 158 '<a href="'.$this->System->Link('/jizdy/').'">Hledat jízdu</a> nebo '. 159 159 '<a href="'.$this->System->Link('/nova-jizda/').'">Nabídnout jízdu</a>'; 160 return ($Output);160 return $Output; 161 161 } 162 162 … … 173 173 'LEFT JOIN RideStop AS PassengerRideStopTo ON PassengerRideStopTo.Id=Passenger.RideStopTo '. 174 174 'WHERE Passenger.Ride='.$RideId); 175 while ($DbRow = $DbResult->fetch_assoc())176 { 177 for ($I = $DbRow['SequenceFrom'] + 1; $I <= $DbRow['SequenceTo']; $I++)175 while ($DbRow = $DbResult->fetch_assoc()) 176 { 177 for ($I = $DbRow['SequenceFrom'] + 1; $I <= $DbRow['SequenceTo']; $I++) 178 178 { 179 179 $Stops[$I] = $Stops[$I] + $DbRow['SeatCount']; 180 180 } 181 181 } 182 foreach ($Stops as $Index => $Stop)182 foreach ($Stops as $Index => $Stop) 183 183 { 184 184 $this->System->Database->update('RideStop', 'Ride='.$RideId.' AND Sequence='.$Index, array('PassengerCount' => $Stop)); … … 206 206 $Stops = array(); 207 207 $DbResult2 = $this->Database->query('SELECT * FROM RideStop WHERE Ride='.$DbRow['Id'].' ORDER BY Sequence'); 208 while ($DbRow2 = $DbResult2->fetch_assoc())208 while ($DbRow2 = $DbResult2->fetch_assoc()) 209 209 { 210 210 $Track[] = $DbRow2; … … 239 239 'LEFT JOIN User ON User.Id=Passenger.User '. 240 240 'WHERE Passenger.Ride='.$RideId); 241 while ($Passenger = $DbResult->fetch_assoc())241 while ($Passenger = $DbResult->fetch_assoc()) 242 242 { 243 243 $Passengers[] = $Passenger; … … 245 245 do { 246 246 $Check = true; 247 for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)247 for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++) 248 248 { 249 if ($Table[$I][$Seat] != 0) $Check = false;249 if ($Table[$I][$Seat] != 0) $Check = false; 250 250 } 251 251 if (!$Check) $Seat++; 252 } while (!$Check);253 for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++)252 } while (!$Check); 253 for ($I = $Passenger['SequenceFrom']; $I < $Passenger['SequenceTo']; $I++) 254 254 $Table[$I][$Seat] = count($Passengers) - 1; 255 255 } … … 259 259 $Output .= '<th style="width: 80px">Cestující</th>'; 260 260 $Output .= '</tr>'; 261 foreach ($Track as $Index => $TrackItem)261 foreach ($Track as $Index => $TrackItem) 262 262 { 263 263 $Output .= '<tr><td style="height: 100px">'.$TrackItem['Place'].'<br/>'.$TrackItem['Time'].'</td>'; 264 if ($Index == 0) $Output .= '<td rowspan="'.count($Track).'">Řidič</td>';264 if ($Index == 0) $Output .= '<td rowspan="'.count($Track).'">Řidič</td>'; 265 265 for ($I = 0; $I < $DbRow['SeatCount']; $I++) 266 266 { … … 271 271 } else { 272 272 // Show unused space 273 if (($Index == 0) or ((($Index - 1) >= 0) and (!is_null($Table[$Index - 1][$I]))))273 if (($Index == 0) or ((($Index - 1) >= 0) and (!is_null($Table[$Index - 1][$I])))) 274 274 { 275 275 $J = 1; 276 while ((($Index + $J) < count($Table)) and is_null($Table[$Index + $J][$I])) $J++;276 while ((($Index + $J) < count($Table)) and is_null($Table[$Index + $J][$I])) $J++; 277 277 $Output .= '<td rowspan="'.$J.'"> </td>'; 278 278 } … … 284 284 285 285 286 return ($Output);286 return $Output; 287 287 } 288 288 … … 303 303 } 304 304 } 305 return ($Output);305 return $Output; 306 306 } 307 307 } … … 311 311 function Show() 312 312 { 313 if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];313 if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from']; 314 314 else $PlaceFrom = ''; 315 if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];315 if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to']; 316 316 else $PlaceTo = ''; 317 if (array_key_exists('time', $_GET)) $Time = $_GET['time'];317 if (array_key_exists('time', $_GET)) $Time = $_GET['time']; 318 318 else $Time = ''; 319 319 $Output = '<table style="width: 100%; margin-top: 100px; margin-bottom: 100px;"><tr><td style="text-align: center">'. … … 325 325 '<input type="submit" value="Hledat"/>'. 326 326 '</form></div></td></tr></table>'; 327 return ($Output);327 return $Output; 328 328 } 329 329 } … … 333 333 function Show() 334 334 { 335 if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from'];335 if (array_key_exists('from', $_GET)) $PlaceFrom = $_GET['from']; 336 336 else $PlaceFrom = ''; 337 if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to'];337 if (array_key_exists('to', $_GET)) $PlaceTo = $_GET['to']; 338 338 else $PlaceTo = ''; 339 if (array_key_exists('time', $_GET)) $Time = $_GET['time'];339 if (array_key_exists('time', $_GET)) $Time = $_GET['time']; 340 340 else $Time = ''; 341 341 $Output = '<table style="width: 100%"><tr><td style="text-align: center;">'. … … 349 349 $Output .= $this->ShowRides($_GET['from'], $_GET['to']); 350 350 } else $Output .= $this->ShowRides('', ''); 351 return ($Output);351 return $Output; 352 352 } 353 353 … … 358 358 $Query = 'SELECT Ride.Id, Ride.SeatCount, User.Name AS DriverName, User.BirthDate, '. 359 359 'CONCAT(CarManufacturer.Name, " ", CarModel.Name) AS CarName '; 360 if ((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))360 if ((trim($PlaceFrom) != '') and (trim($PlaceTo != ''))) 361 361 $Query .= ', (SELECT COALESCE(MAX(RideStop.PassengerCount), 0) FROM RideStop '. 362 362 'WHERE (RideStop.Ride=Ride.Id) AND (RideStop.Sequence > RideStopFrom.Sequence) AND '. … … 371 371 'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '. 372 372 'LEFT JOIN User ON User.Id=Ride.Driver '; 373 if ((trim($PlaceFrom) != '') and (trim($PlaceTo != '')))373 if ((trim($PlaceFrom) != '') and (trim($PlaceTo != ''))) 374 374 $Query .= 'JOIN RideStop AS RideStopFrom ON (RideStopFrom.Ride = Ride.Id) AND (RideStopFrom.Place LIKE "%'.$PlaceFrom.'%") '. 375 375 'JOIN RideStop AS RideStopTo ON (RideStopTo.Ride = Ride.Id) AND (RideStopTo.Place LIKE "%'.$PlaceTo.'%") '. … … 377 377 $Query .= 'LIMIT 10'; 378 378 $DbResult = $this->Database->query($Query); 379 while ($DbRow = $DbResult->fetch_assoc())379 while ($DbRow = $DbResult->fetch_assoc()) 380 380 { 381 381 $Stops = array(); 382 382 $Price = 0; 383 383 $DbResult2 = $this->Database->query('SELECT * FROM RideStop WHERE Ride='.$DbRow['Id'].' ORDER BY Sequence'); 384 while ($DbRow2 = $DbResult2->fetch_assoc())384 while ($DbRow2 = $DbResult2->fetch_assoc()) 385 385 { 386 386 $Stops[] = $DbRow2['Place']; … … 400 400 $Output .= '</table>'; 401 401 402 return ($Output);402 return $Output; 403 403 } 404 404 } … … 416 416 417 417 $ret = array(); 418 foreach ($bit as $k => $v)419 if ($v > 0)$ret[] = $v . $k;418 foreach ($bit as $k => $v) 419 if ($v > 0)$ret[] = $v . $k; 420 420 421 421 return join(' ', $ret); … … 483 483 'LEFT JOIN CarManufacturer ON CarManufacturer.Id = CarModel.Manufacturer '. 484 484 'WHERE Car.Owner='.$this->System->User->User['Id']); 485 while ($DbRow = $DbResult->fetch_assoc())485 while ($DbRow = $DbResult->fetch_assoc()) 486 486 { 487 487 $Output .= '<option value="'.$DbRow['Id'].'"/>'.$DbRow['ModelName'].'</option>'; … … 500 500 $PricePerKm = 0.8; 501 501 $Output .= '<table class="WideTable"><tr><th>Úsek</th><th>Odjezd</th><th>Trvání</th><th>Vzdálenost [km]</th><th>Cena [Kč]</th></tr>'; 502 foreach ($Track as $Index => $TrackItem)502 foreach ($Track as $Index => $TrackItem) 503 503 { 504 if ($Index > 0)504 if ($Index > 0) 505 505 { 506 506 $Track[$Index]['Time'] = $TimeFrom + $Track[$Index - 1]['Duration']; … … 542 542 )); 543 543 $RideId = $this->Database->insert_id; 544 foreach ($_SESSION['Track'] as $Index => $TrackItem)544 foreach ($_SESSION['Track'] as $Index => $TrackItem) 545 545 { 546 546 $this->Database->insert('RideStop', array( … … 556 556 } 557 557 } 558 return ($Output);559 } 560 } 561 558 return $Output; 559 } 560 } 561 -
trunk/Modules/User/User.php
r5 r7 121 121 /* 122 122 123 if ($this->InstalledVersion == '1.0') {123 if ($this->InstalledVersion == '1.0') { 124 124 $this->System->Database->Query('SELECT * FROM User WHERE Id=1'); 125 125 $this->InstalledVersion = '1.1'; … … 131 131 { 132 132 $this->System->User = new User($this->System); 133 if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check();133 if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check(); 134 134 $this->System->RegisterPage('userlist', 'PageUserList'); 135 135 $this->System->RegisterPage('user', 'PageUser'); … … 287 287 function TopBarCallback() 288 288 { 289 if ($this->System->User->User['Id'] == null)289 if ($this->System->User->User['Id'] == null) 290 290 { 291 291 $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '. … … 298 298 // <a href="'.$this->System->Link('/?Action=UserOptions').'">Nastavení</a>'; 299 299 } 300 return ($Output);300 return $Output; 301 301 } 302 302 } -
trunk/Modules/User/UserList.php
r1 r7 9 9 function Show() 10 10 { 11 if (!$this->System->User->CheckPermission('User', 'ShowList'))12 return ('Nemáte oprávnění');11 if (!$this->System->User->CheckPermission('User', 'ShowList')) 12 return 'Nemáte oprávnění'; 13 13 14 14 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `User`'); … … 30 30 31 31 $DbResult = $this->Database->query($Query); 32 while ($User = $DbResult->fetch_assoc())32 while ($User = $DbResult->fetch_assoc()) 33 33 { 34 34 $Devices = array(); 35 35 $DbResult2 = $this->Database->query('SELECT `Id` FROM `Member` WHERE `Member`.`ResponsibleUser` = '.$User['Id']); 36 while ($Member = $DbResult2->fetch_assoc())36 while ($Member = $DbResult2->fetch_assoc()) 37 37 { 38 38 $DbResult3 = $this->Database->query('SELECT `Name`, `Id` FROM `NetworkDevice` '. 39 39 'WHERE `Member` = '.$Member['Id'].' AND `Used`=1 ORDER BY `Name`'); 40 while ($Device = $DbResult3->fetch_assoc())40 while ($Device = $DbResult3->fetch_assoc()) 41 41 { 42 42 $Devices[] = $Device['Name']; … … 52 52 $Output .= $PageList['Output']; 53 53 54 return ($Output);54 return $Output; 55 55 } 56 56 } -
trunk/Modules/User/UserModel.php
r6 r7 32 32 function Hash($Password, $Salt) 33 33 { 34 return (sha1(sha1($Password).$Salt));34 return sha1(sha1($Password).$Salt); 35 35 } 36 36 37 37 function Verify($Password, $Salt, $StoredHash) 38 38 { 39 return ($this->Hash($Password, $Salt) == $StoredHash);39 return $this->Hash($Password, $Salt) == $StoredHash; 40 40 } 41 41 … … 73 73 // Lookup user record 74 74 $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"'); 75 if ($Query->num_rows > 0)75 if ($Query->num_rows > 0) 76 76 { 77 77 // Refresh time of last access … … 83 83 84 84 // Logged permanently? 85 if (array_key_exists('LoginHash', $_COOKIE))85 if (array_key_exists('LoginHash', $_COOKIE)) 86 86 { 87 87 $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId']. 88 88 ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"'); 89 if ($DbResult->num_rows > 0)89 if ($DbResult->num_rows > 0) 90 90 { 91 91 $DbRow = $DbResult->fetch_assoc(); 92 if (sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash'])92 if (sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash']) 93 93 { 94 94 $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"'); … … 101 101 $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"'); 102 102 $Row = $Query->fetch_assoc(); 103 if ($Row['User'] != '')103 if ($Row['User'] != '') 104 104 { 105 105 $Query = $this->Database->query('SELECT `User`.* FROM `User` '. … … 116 116 // Remove nonactive users 117 117 $DbResult = $this->Database->select('UserOnline', '`Id`, `User`', '(`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.$this->OnlineStateTimeout.' SECOND)) AND (`StayLogged` = 0)'); 118 while ($DbRow = $DbResult->fetch_array())118 while ($DbRow = $DbResult->fetch_array()) 119 119 { 120 120 $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']); 121 if (($DbRow['User'] != null) and $this->System->ModuleManager->ModulePresent('Log'))121 if (($DbRow['User'] != null) and $this->System->ModuleManager->ModulePresent('Log')) 122 122 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout'); 123 123 } … … 130 130 function Register($Login, $Password, $Password2, $Email, $Name) 131 131 { 132 if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '') || ($Name == '')) $Result = DATA_MISSING;133 else if ($Password != $Password2) $Result = PASSWORDS_UNMATCHED;132 if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '') || ($Name == '')) $Result = DATA_MISSING; 133 else if ($Password != $Password2) $Result = PASSWORDS_UNMATCHED; 134 134 else 135 135 { 136 136 // Is user registred yet? 137 137 $Query = $this->Database->select('User', '*', 'Login = "'.$Login.'"'); 138 if ($Query->num_rows > 0) $Result = LOGIN_USED;138 if ($Query->num_rows > 0) $Result = LOGIN_USED; 139 139 else 140 140 { 141 141 $Query = $this->Database->select('User', '*', 'Name = "'.$Name.'"'); 142 if ($Query->num_rows > 0) $Result = NAME_USED;142 if ($Query->num_rows > 0) $Result = NAME_USED; 143 143 else 144 144 { 145 145 $Query = $this->Database->select('User', '*', 'Email = "'.$Email.'"'); 146 if ($Query->num_rows > 0) $Result = EMAIL_USED;146 if ($Query->num_rows > 0) $Result = EMAIL_USED; 147 147 else 148 148 { … … 175 175 176 176 $Result = USER_REGISTRATED; 177 if ($this->System->ModuleManager->ModulePresent('Log'))177 if ($this->System->ModuleManager->ModulePresent('Log')) 178 178 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'NewRegistration', $Login); 179 179 } … … 181 181 } 182 182 } 183 return ($Result);183 return $Result; 184 184 } 185 185 … … 187 187 { 188 188 $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id); 189 if ($DbResult->num_rows > 0)189 if ($DbResult->num_rows > 0) 190 190 { 191 191 $Row = $DbResult->fetch_array(); 192 192 $NewPassword = substr(sha1(strtoupper($Row['Login'])), 0, 7); 193 if ($Hash == $NewPassword)193 if ($Hash == $NewPassword) 194 194 { 195 195 $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0)); 196 196 $Output = USER_REGISTRATION_CONFIRMED; 197 if ($this->System->ModuleManager->ModulePresent('Log'))197 if ($this->System->ModuleManager->ModulePresent('Log')) 198 198 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'Login='. 199 199 $Row['Login'].', Id='.$Row['Id']); 200 200 } else $Output = PASSWORDS_UNMATCHED; 201 201 } else $Output = USER_NOT_FOUND; 202 return ($Output);202 return $Output; 203 203 } 204 204 205 205 function Login($Login, $Password, $StayLogged = false) 206 206 { 207 if ($StayLogged) $StayLogged = 1; else $StayLogged = 0;207 if ($StayLogged) $StayLogged = 1; else $StayLogged = 0; 208 208 $SID = session_id(); 209 209 $Query = $this->Database->select('User', '*', 'Login="'.$Login.'"'); 210 if ($Query->num_rows > 0)210 if ($Query->num_rows > 0) 211 211 { 212 212 $Row = $Query->fetch_assoc(); 213 213 $PasswordHash = new PasswordHash(); 214 if (!$PasswordHash->Verify($Password, $Row['Salt'], $Row['Password'])) $Result = BAD_PASSWORD;215 else if ($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED;214 if (!$PasswordHash->Verify($Password, $Row['Salt'], $Row['Password'])) $Result = BAD_PASSWORD; 215 else if ($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED; 216 216 else 217 217 { … … 222 222 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array( 223 223 'User' => $Row['Id'], 'StayLogged' => $StayLogged, 'StayLoggedHash' => $StayLoggedSalt)); 224 if ($StayLogged)224 if ($StayLogged) 225 225 { 226 226 setcookie('LoginUserId', $Row['Id'], time()+365*24*60*60, $this->System->Link('/')); … … 233 233 $Result = USER_LOGGED_IN; 234 234 $this->Check(); 235 if (array_key_exists('Log', $this->System->ModuleManager->Modules))235 if (array_key_exists('Log', $this->System->ModuleManager->Modules)) 236 236 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress())); 237 237 } 238 238 } else $Result = USER_NOT_REGISTRED; 239 return ($Result);239 return $Result; 240 240 } 241 241 … … 244 244 $SID = session_id(); 245 245 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => null)); 246 if ($this->System->ModuleManager->ModulePresent('Log'))246 if ($this->System->ModuleManager->ModulePresent('Log')) 247 247 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']); 248 248 $this->Check(); 249 return (USER_LOGGED_OUT);249 return USER_LOGGED_OUT; 250 250 } 251 251 … … 254 254 $this->Roles = array(); 255 255 $DbResult = $this->Database->select('UserRole', '*'); 256 while ($DbRow = $DbResult->fetch_array())256 while ($DbRow = $DbResult->fetch_array()) 257 257 $this->Roles[] = $DbRow; 258 258 } … … 262 262 $this->User['Permission'] = array(); 263 263 $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description` FROM `UserRolePermission` JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` WHERE `UserRolePermission`.`Role` = '.$Role); 264 if ($DbResult->num_rows > 0)265 while ($DbRow = $DbResult->fetch_array())264 if ($DbResult->num_rows > 0) 265 while ($DbRow = $DbResult->fetch_array()) 266 266 $this->User['Permission'][$DbRow['Operation']] = $DbRow; 267 267 } … … 271 271 $Result = array(); 272 272 $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description`, `UserRole`.`Title` FROM `UserRolePermission` LEFT JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` LEFT JOIN `UserRole` ON `UserRole`.`Id` = `UserRolePermission`.`Role`'); 273 while ($DbRow = $DbResult->fetch_array())273 while ($DbRow = $DbResult->fetch_array()) 274 274 { 275 275 $Value = ''; 276 if ($DbRow['Read']) $Value .= 'R';277 if ($DbRow['Write']) $Value .= 'W';276 if ($DbRow['Read']) $Value .= 'R'; 277 if ($DbRow['Write']) $Value .= 'W'; 278 278 $Result[$DbRow['Description']][$DbRow['Title']] = $Value; 279 279 } 280 return ($Result);280 return $Result; 281 281 } 282 282 … … 285 285 $PermissionExists = false; 286 286 // First try to check cache group-group relation 287 if (array_key_exists($GroupId, $this->PermissionGroupCache))287 if (array_key_exists($GroupId, $this->PermissionGroupCache)) 288 288 { 289 289 $PermissionExists = true; … … 294 294 '") AND (`AssignedGroup` IS NOT NULL)'); 295 295 $DbRow = array(); 296 while ($DbRow[] = $DbResult->fetch_array());296 while ($DbRow[] = $DbResult->fetch_array()); 297 297 $this->PermissionGroupCache[$GroupId] = $DbRow; 298 298 $PermissionExists = true; 299 299 } 300 if ($PermissionExists)301 { 302 foreach ($this->PermissionGroupCache[$GroupId] as $DbRow)303 { 304 if ($DbRow['AssignedGroup'] != '')305 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);300 if ($PermissionExists) 301 { 302 foreach ($this->PermissionGroupCache[$GroupId] as $DbRow) 303 { 304 if ($DbRow['AssignedGroup'] != '') 305 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return true; 306 306 } 307 307 } 308 308 309 309 // Check group-operation relation 310 if (array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp))310 if (array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp)) 311 311 { 312 312 $PermissionExists = true; … … 315 315 // If no permission combination exists in cache, do new check of database items 316 316 $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedOperation`="'.$OperationId.'"'); 317 if ($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true;317 if ($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true; 318 318 else $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = false; 319 319 $PermissionExists = true; 320 320 } 321 if ($PermissionExists)322 { 323 return ($this->PermissionGroupCacheOp[$GroupId.','.$OperationId]);324 } 325 return (false);321 if ($PermissionExists) 322 { 323 return $this->PermissionGroupCacheOp[$GroupId.','.$OperationId]; 324 } 325 return false; 326 326 } 327 327 … … 330 330 // Get module id 331 331 $DbResult = $this->Database->select('Module', 'Id', '`Name`="'.$Module.'"'); 332 if ($DbResult->num_rows > 0)332 if ($DbResult->num_rows > 0) 333 333 { 334 334 $DbRow = $DbResult->fetch_assoc(); 335 335 $ModuleId = $DbRow['Id']; 336 } else return (false);336 } else return false; 337 337 338 338 // First try to check cache 339 if (in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache))339 if (in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache)) 340 340 { 341 341 $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemIndex), $this->PermissionCache); … … 346 346 $DbResult = $this->Database->select('PermissionOperation', 'Id', '(`Module`="'.$ModuleId. 347 347 '") AND (`Item`="'.$ItemType.'") AND (`ItemId`='.$ItemIndex.') AND (`Operation`="'.$Operation.'")'); 348 if ($DbResult->num_rows > 0)348 if ($DbResult->num_rows > 0) 349 349 { 350 350 $DbRow = $DbResult->fetch_array(); … … 359 359 } 360 360 361 if ($PermissionExists)362 { 363 if ($this->User['Id'] == null) $UserCondition = '(`User` IS NULL)';361 if ($PermissionExists) 362 { 363 if ($this->User['Id'] == null) $UserCondition = '(`User` IS NULL)'; 364 364 else $UserCondition = '(`User`="'.$this->User['Id'].'")'; 365 365 // Check user-operation relation 366 366 $DbResult = $this->Database->select('PermissionUserAssignment', '*', $UserCondition.' AND (`AssignedOperation`="'.$OperationId.'")'); 367 if ($DbResult->num_rows > 0) return(true);367 if ($DbResult->num_rows > 0) return true; 368 368 369 369 // Check user-group relation 370 370 $DbResult = $this->Database->select('PermissionUserAssignment', 'AssignedGroup', $UserCondition); 371 while ($DbRow = $DbResult->fetch_array())372 { 373 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);374 } 375 return (false);376 } else return (false);371 while ($DbRow = $DbResult->fetch_array()) 372 { 373 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return true; 374 } 375 return false; 376 } else return false; 377 377 } 378 378 … … 380 380 { 381 381 $DbResult = $this->Database->select('User', 'Login, Name, Id, Email, Password', '`Login`="'.$Login.'" AND `Email`="'.$Email.'"'); 382 if ($DbResult->num_rows > 0)382 if ($DbResult->num_rows > 0) 383 383 { 384 384 $Row = $DbResult->fetch_array(); … … 399 399 400 400 $Output = USER_PASSWORD_RECOVERY_SUCCESS; 401 if ($this->System->ModuleManager->ModulePresent('Log'))401 if ($this->System->ModuleManager->ModulePresent('Log')) 402 402 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email); 403 403 } else $Output = USER_PASSWORD_RECOVERY_FAIL; 404 return ($Output);404 return $Output; 405 405 } 406 406 … … 408 408 { 409 409 $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id); 410 if ($DbResult->num_rows > 0)410 if ($DbResult->num_rows > 0) 411 411 { 412 412 $Row = $DbResult->fetch_array(); 413 413 $NewPassword2 = substr(sha1(strtoupper($Row['Login'])), 0, 7); 414 if (($NewPassword == $NewPassword2) and ($Hash == $Row['Password']))414 if (($NewPassword == $NewPassword2) and ($Hash == $Row['Password'])) 415 415 { 416 416 $PasswordHash = new PasswordHash(); … … 418 418 $this->Database->update('User', 'Id='.$Row['Id'], array('Password' => $PasswordHash->Hash($NewPassword, $Salt), 419 419 'Salt' => $Salt, 'Locked' => 0)); 420 if ($this->System->ModuleManager->ModulePresent('Log'))420 if ($this->System->ModuleManager->ModulePresent('Log')) 421 421 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']); 422 422 } else $Output = PASSWORDS_UNMATCHED; 423 423 } else $Output = USER_NOT_FOUND; 424 return ($Output);424 return $Output; 425 425 } 426 426 … … 428 428 { 429 429 $DbResult = $this->Database->select('APIToken', 'User', '`Token`="'.$Token.'"'); 430 if ($DbResult->num_rows > 0)430 if ($DbResult->num_rows > 0) 431 431 { 432 432 $DbRow = $DbResult->fetch_assoc(); 433 433 $User = new User($this->System); 434 434 $User->User = array('Id' => $DbRow['User']); 435 return ($User->CheckPermission($Module, $Operation));436 } else return (false);435 return $User->CheckPermission($Module, $Operation); 436 } else return false; 437 437 } 438 438 } -
trunk/Modules/User/UserPage.php
r1 r7 9 9 function Panel($Title, $Content, $Menu = array()) 10 10 { 11 if (count($Menu) > 0)12 foreach ($Menu as $Item)11 if (count($Menu) > 0) 12 foreach ($Menu as $Item) 13 13 $Title .= '<div class="Action">'.$Item.'</div>'; 14 return ('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');14 return '<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>'; 15 15 } 16 16 … … 39 39 40 40 $DbResult = $this->Database->query($Query); 41 while ($Contact = $DbResult->fetch_assoc())41 while ($Contact = $DbResult->fetch_assoc()) 42 42 { 43 43 $Output .= '<tr>'. … … 50 50 $Output .= $PageList['Output']; 51 51 52 return ($Output);52 return $Output; 53 53 } 54 54 … … 56 56 { 57 57 $Output = ''; 58 if ($this->System->User->User['Id'] != null)58 if ($this->System->User->User['Id'] != null) 59 59 { 60 60 $Actions = ''; 61 foreach ($this->System->ModuleManager->Modules['User']->UserPanel as $Action)62 { 63 if (is_string($Action[0]))61 foreach ($this->System->ModuleManager->Modules['User']->UserPanel as $Action) 62 { 63 if (is_string($Action[0])) 64 64 { 65 65 $Class = new $Action[0]($this->System); … … 71 71 $Output .= $this->Panel('Nabídka uživatele', $Actions); 72 72 $Output .= '</td><td style="vertical-align:top;">'; 73 if ($this->System->User->User['Id'] != null)73 if ($this->System->User->User['Id'] != null) 74 74 { 75 75 $Form = new Form($this->System->FormManager); … … 85 85 $Output .= '</td></tr></table></div>'; 86 86 } else $Output .= $this->SystemMessage('Oprávnění', 'Nejste přihlášen'); 87 return ($Output);87 return $Output; 88 88 } 89 89 … … 91 91 { 92 92 $Output = ''; 93 if (array_key_exists('Action', $_GET))93 if (array_key_exists('Action', $_GET)) 94 94 { 95 95 $Action = $_GET['Action']; 96 if ($Action == 'LoginForm')96 if ($Action == 'LoginForm') 97 97 { 98 98 $Form = new Form($this->System->FormManager); … … 103 103 '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>'; 104 104 } else 105 if ($Action == 'Login')106 { 107 if (array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST))105 if ($Action == 'Login') 106 { 107 if (array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST)) 108 108 { 109 109 $Form = new Form($this->System->FormManager); 110 110 $Form->SetClass('UserLogin'); 111 111 $Form->OnSubmit = '?Action=Login'; 112 if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true;112 if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true; 113 113 else $StayLogged = false; 114 114 $Result = $this->System->User->Login($_POST['Username'], $_POST['Password'], $StayLogged); 115 115 $Output .= $this->SystemMessage('Přihlášení', $Result); 116 if ($Result <> USER_LOGGED_IN)116 if ($Result <> USER_LOGGED_IN) 117 117 { 118 118 $Form->LoadValuesFromForm(); … … 128 128 } else $Output .= $this->SystemMessage('Přihlášení', 'Nezadány přihlašovací údaje'); 129 129 } else 130 if ($Action == 'Logout')131 { 132 if ($this->System->User->User['Id'] != null)130 if ($Action == 'Logout') 131 { 132 if ($this->System->User->User['Id'] != null) 133 133 { 134 134 $Output .= $this->SystemMessage('Odhlášení', $this->System->User->Logout()); 135 135 } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen'); 136 136 } else 137 if ($Action == 'UserOptions')138 { 139 if ($this->System->User->User['Id'] != null)137 if ($Action == 'UserOptions') 138 { 139 if ($this->System->User->User['Id'] != null) 140 140 { 141 141 $Form = new Form($this->System->FormManager); … … 146 146 } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen'); 147 147 } else 148 if ($Action == 'UserOptionsSave')148 if ($Action == 'UserOptionsSave') 149 149 { 150 150 $Form = new Form($this->System->FormManager); … … 158 158 $Output .= $Form->ShowEditForm(); 159 159 } else 160 if ($Action == 'UserRegister')160 if ($Action == 'UserRegister') 161 161 { 162 162 $Form = new Form($this->System->FormManager); … … 166 166 $Output .= $Form->ShowEditForm(); 167 167 } else 168 if ($Action == 'UserRegisterConfirm')168 if ($Action == 'UserRegisterConfirm') 169 169 { 170 170 $Output .= $this->SystemMessage('Potvrzení registrace', 171 171 $this->System->User->RegisterConfirm($_GET['User'], $_GET['H'])); 172 172 } else 173 if ($Action == 'PasswordRecovery')173 if ($Action == 'PasswordRecovery') 174 174 { 175 175 $Form = new Form($this->System->FormManager); … … 178 178 $Output .= $Form->ShowEditForm(); 179 179 } else 180 if ($Action == 'PasswordRecovery2')180 if ($Action == 'PasswordRecovery2') 181 181 { 182 182 $Form = new Form($this->System->FormManager); … … 185 185 $Result = $this->System->User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']); 186 186 $Output .= $this->SystemMessage('Obnova hesla', $Result); 187 if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS)187 if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS) 188 188 { 189 189 $Output .= $Form->ShowEditForm(); 190 190 } 191 191 } else 192 if ($Action == 'PasswordRecoveryConfirm')192 if ($Action == 'PasswordRecoveryConfirm') 193 193 { 194 194 $Output .= $this->SystemMessage('Obnova hesla', $this->System->User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P'])); 195 195 } else 196 if ($Action == 'UserRegisterSave')196 if ($Action == 'UserRegisterSave') 197 197 { 198 198 $Form = new Form($this->System->FormManager); … … 202 202 $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']); 203 203 $Output .= $this->SystemMessage('Registrace nového účtu', $Result); 204 if ($Result <> USER_REGISTRATED)204 if ($Result <> USER_REGISTRATED) 205 205 { 206 206 $Form->OnSubmit = '?Action=UserRegisterSave'; … … 208 208 } 209 209 } else 210 if ($Action == 'UserMenu')210 if ($Action == 'UserMenu') 211 211 { 212 212 $Output = $this->ShowUserPanel(); 213 213 } else $Output = $this->ShowMain(); 214 214 } else $Output = $this->ShowMain(); 215 return ($Output);215 return $Output; 216 216 } 217 217 … … 219 219 { 220 220 $Output = 'Nebyla vybrána akce'; 221 return ($Output);221 return $Output; 222 222 } 223 223 } -
trunk/Packages/Common/AppModule.php
r1 r7 77 77 function Install() 78 78 { 79 if ($this->Installed) return;79 if ($this->Installed) return; 80 80 $List = array(); 81 81 $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotInstalled)); … … 89 89 function Uninstall() 90 90 { 91 if (!$this->Installed) return;91 if (!$this->Installed) return; 92 92 $this->Stop(); 93 93 $this->Installed = false; … … 100 100 function Upgrade() 101 101 { 102 if (!$this->Installed) return;103 if ($this->InstalledVersion == $this->Version) return;102 if (!$this->Installed) return; 103 if ($this->InstalledVersion == $this->Version) return; 104 104 $List = array(); 105 105 $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed)); … … 117 117 function Start() 118 118 { 119 if ($this->Running) return;120 if (!$this->Installed) return;119 if ($this->Running) return; 120 if (!$this->Installed) return; 121 121 $List = array(); 122 122 $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotRunning)); … … 128 128 function Stop() 129 129 { 130 if (!$this->Running) return;130 if (!$this->Running) return; 131 131 $this->Running = false; 132 132 $List = array(); … … 144 144 function Enable() 145 145 { 146 if ($this->Enabled) return;147 if (!$this->Installed) return;146 if ($this->Enabled) return; 147 if (!$this->Installed) return; 148 148 $List = array(); 149 149 $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotEnabled)); … … 154 154 function Disable() 155 155 { 156 if (!$this->Enabled) return;156 if (!$this->Enabled) return; 157 157 $this->Stop(); 158 158 $this->Enabled = false; … … 203 203 function Perform($List, $Actions, $Conditions = array(ModuleCondition::All)) 204 204 { 205 foreach ($List as $Index => $Module)206 { 207 if (in_array(ModuleCondition::All, $Conditions) or205 foreach ($List as $Index => $Module) 206 { 207 if (in_array(ModuleCondition::All, $Conditions) or 208 208 ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or 209 209 (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or … … 213 213 (!$Module->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions))) 214 214 { 215 foreach ($Actions as $Action)215 foreach ($Actions as $Action) 216 216 { 217 if ($Action == ModuleAction::Start) $Module->Start();218 if ($Action == ModuleAction::Stop) $Module->Stop();219 if ($Action == ModuleAction::Install) $Module->Install();220 if ($Action == ModuleAction::Uninstall) $Module->Uninstall();221 if ($Action == ModuleAction::Enable) $Module->Enable();222 if ($Action == ModuleAction::Disable) $Module->Disable();223 if ($Action == ModuleAction::Upgrade) $Module->Upgrade();217 if ($Action == ModuleAction::Start) $Module->Start(); 218 if ($Action == ModuleAction::Stop) $Module->Stop(); 219 if ($Action == ModuleAction::Install) $Module->Install(); 220 if ($Action == ModuleAction::Uninstall) $Module->Uninstall(); 221 if ($Action == ModuleAction::Enable) $Module->Enable(); 222 if ($Action == ModuleAction::Disable) $Module->Disable(); 223 if ($Action == ModuleAction::Upgrade) $Module->Upgrade(); 224 224 } 225 225 } … … 229 229 function EnumDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All)) 230 230 { 231 foreach ($Module->Dependencies as $Dependency)232 { 233 if (!array_key_exists($Dependency, $this->Modules))231 foreach ($Module->Dependencies as $Dependency) 232 { 233 if (!array_key_exists($Dependency, $this->Modules)) 234 234 throw new Exception(sprintf(T('Module "%s" dependency "%s" not found'), $Module->Name, $Dependency)); 235 235 $DepModule = $this->Modules[$Dependency]; 236 if (in_array(ModuleCondition::All, $Conditions) or236 if (in_array(ModuleCondition::All, $Conditions) or 237 237 ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or 238 238 (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or … … 250 250 function EnumSuperiorDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All)) 251 251 { 252 foreach ($this->Modules as $RefModule)253 { 254 if (in_array($Module->Name, $RefModule->Dependencies) and252 foreach ($this->Modules as $RefModule) 253 { 254 if (in_array($Module->Name, $RefModule->Dependencies) and 255 255 (in_array(ModuleCondition::All, $Conditions) or 256 256 ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or … … 270 270 { 271 271 $this->LoadModules(); 272 if (file_exists($this->FileName)) $this->LoadState();272 if (file_exists($this->FileName)) $this->LoadState(); 273 273 $this->StartEnabled(); 274 274 } … … 315 315 function ModulePresent($Name) 316 316 { 317 return (array_key_exists($Name, $this->Modules));317 return array_key_exists($Name, $this->Modules); 318 318 } 319 319 320 320 function ModuleEnabled($Name) 321 321 { 322 return (array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled);322 return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled; 323 323 } 324 324 325 325 function ModuleRunning($Name) 326 326 { 327 return (array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running);327 return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running; 328 328 } 329 329 … … 331 331 function SearchModuleById($Id) 332 332 { 333 foreach ($this->Modules as $Module)333 foreach ($this->Modules as $Module) 334 334 { 335 335 //DebugLog($Module->Name.' '.$Module->Id); 336 if ($Module->Id == $Id) return($Module->Name);337 } 338 return ('');336 if ($Module->Id == $Id) return $Module->Name; 337 } 338 return ''; 339 339 } 340 340 … … 343 343 $ConfigModules = array(); 344 344 include($this->FileName); 345 foreach ($ConfigModules as $Mod)346 { 347 if (array_key_exists($Mod['Name'], $this->Modules))345 foreach ($ConfigModules as $Mod) 346 { 347 if (array_key_exists($Mod['Name'], $this->Modules)) 348 348 { 349 349 $this->Modules[$Mod['Name']] = $this->Modules[$Mod['Name']]; … … 358 358 { 359 359 $Data = array(); 360 foreach ($this->Modules as $Module)360 foreach ($this->Modules as $Module) 361 361 { 362 362 $Data[] = array('Name' => $Module->Name, 'Enabled' => $Module->Enabled, … … 381 381 { 382 382 $List = scandir($Directory); 383 foreach ($List as $Item)384 { 385 if (is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn'))383 foreach ($List as $Item) 384 { 385 if (is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn')) 386 386 { 387 387 include_once($Directory.'/'.$Item.'/'.$Item.'.php'); … … 394 394 function LoadModules() 395 395 { 396 if (method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))396 if (method_exists($this->OnLoadModules[0], $this->OnLoadModules[1])) 397 397 $this->OnLoadModules(); 398 398 else $this->LoadModulesFromDir($this->ModulesDir); -
trunk/Packages/Common/Common.php
r1 r7 60 60 61 61 $Result = ''; 62 if (array_key_exists('all', $QueryItems))62 if (array_key_exists('all', $QueryItems)) 63 63 { 64 64 $PageCount = 1; … … 71 71 } 72 72 73 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;74 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;75 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;76 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;73 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 74 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 75 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 76 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 77 77 $CurrentPage = $_SESSION['Page']; 78 78 … … 80 80 81 81 $Result = ''; 82 if ($PageCount > 1)82 if ($PageCount > 1) 83 83 { 84 if ($CurrentPage > 0)84 if ($CurrentPage > 0) 85 85 { 86 86 $QueryItems['page'] = 0; … … 91 91 $PagesMax = $PageCount - 1; 92 92 $PagesMin = 0; 93 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;94 if ($PagesMin < ($CurrentPage - $Around))93 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 94 if ($PagesMin < ($CurrentPage - $Around)) 95 95 { 96 96 $Result.= ' ... '; 97 97 $PagesMin = $CurrentPage - $Around; 98 98 } 99 for ($i = $PagesMin; $i <= $PagesMax; $i++)99 for ($i = $PagesMin; $i <= $PagesMax; $i++) 100 100 { 101 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';101 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 102 102 else { 103 103 $QueryItems['page'] = $i; … … 105 105 } 106 106 } 107 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';108 if ($CurrentPage < ($PageCount - 1))107 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 108 if ($CurrentPage < ($PageCount - 1)) 109 109 { 110 110 $QueryItems['page'] = ($CurrentPage + 1); … … 115 115 } 116 116 $QueryItems['all'] = '1'; 117 if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';117 if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 118 118 119 119 $Result = '<div style="text-align: center">'.$Result.'</div>'; 120 120 $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage; 121 121 $this->Page = $CurrentPage; 122 return ($Result);122 return $Result; 123 123 } 124 124 } -
trunk/Packages/Common/Config.php
r1 r7 12 12 function ReadValue($Name) 13 13 { 14 if (!is_array($Name)) $Name = explode('/', $Name);14 if (!is_array($Name)) $Name = explode('/', $Name); 15 15 $Last = array_pop($Name); 16 16 $Data = &$this->Data; 17 foreach ($Name as $Item)17 foreach ($Name as $Item) 18 18 { 19 19 $Data = &$Data[$Item]; 20 20 } 21 return ($Data[$Last]);21 return $Data[$Last]; 22 22 } 23 23 24 24 function WriteValue($Name, $Value) 25 25 { 26 if (!is_array($Name)) $Name = explode('/', $Name);26 if (!is_array($Name)) $Name = explode('/', $Name); 27 27 $Last = array_pop($Name); 28 28 $Data = &$this->Data; 29 foreach ($Name as $Item)29 foreach ($Name as $Item) 30 30 { 31 31 $Data = &$Data[$Item]; … … 38 38 $ConfigData = array(); 39 39 include $FileName; 40 foreach ($this->Data as $Index => $Item)40 foreach ($this->Data as $Index => $Item) 41 41 { 42 if (array_key_exits($Index, $ConfigData))42 if (array_key_exits($Index, $ConfigData)) 43 43 $this->Data[$Index] = $ConfigData[$Index]; 44 44 } … … 52 52 function GetAsArray() 53 53 { 54 return ($this->Data);54 return $this->Data; 55 55 } 56 56 } -
trunk/Packages/Common/Database.php
r1 r7 11 11 function fetch_assoc() 12 12 { 13 return ($this->PDOStatement->fetch(PDO::FETCH_ASSOC));13 return $this->PDOStatement->fetch(PDO::FETCH_ASSOC); 14 14 } 15 15 16 16 function fetch_array() 17 17 { 18 return ($this->PDOStatement->fetch(PDO::FETCH_BOTH));18 return $this->PDOStatement->fetch(PDO::FETCH_BOTH); 19 19 } 20 20 21 21 function fetch_row() 22 22 { 23 return ($this->PDOStatement->fetch(PDO::FETCH_NUM));23 return $this->PDOStatement->fetch(PDO::FETCH_NUM); 24 24 } 25 25 } … … 54 54 function Connect($Host, $User, $Password, $Database) 55 55 { 56 if ($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;57 else if ($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host;56 if ($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database; 57 else if ($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host; 58 58 else $ConnectionString = ''; 59 59 try { … … 74 74 function Connected() 75 75 { 76 return (isset($this->PDO));76 return isset($this->PDO); 77 77 } 78 78 … … 84 84 function query($Query) 85 85 { 86 if (!$this->Connected()) throw new Exception(T('Not connected to database'));87 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime();86 if (!$this->Connected()) throw new Exception(T('Not connected to database')); 87 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime(); 88 88 $this->LastQuery = $Query; 89 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))89 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) 90 90 $Duration = ' ; '.round(microtime() - $QueryStartTime, 4). ' s'; 91 if ($this->LogSQLQuery == true)91 if ($this->LogSQLQuery == true) 92 92 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND); 93 if ($this->ShowSQLQuery == true)93 if ($this->ShowSQLQuery == true) 94 94 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '. 95 95 'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n"); 96 96 $Result = new DatabaseResult(); 97 97 $Result->PDOStatement = $this->PDO->query($Query); 98 if ($Result->PDOStatement)98 if ($Result->PDOStatement) 99 99 { 100 100 $Result->num_rows = $Result->PDOStatement->rowCount(); … … 104 104 $this->Error = $this->PDO->errorInfo(); 105 105 $this->Error = $this->Error[2]; 106 if (($this->Error != '') and ($this->ShowSQLError == true))106 if (($this->Error != '') and ($this->ShowSQLError == true)) 107 107 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); 108 108 throw new Exception('SQL Error: '.$this->Error.', Query: '.$Query); 109 109 } 110 return ($Result);110 return $Result; 111 111 } 112 112 113 113 function select($Table, $What = '*', $Condition = 1) 114 114 { 115 return ($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition));115 return $this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 116 116 } 117 117 … … 125 125 $Name = ''; 126 126 $Values = ''; 127 foreach ($Data as $Key => $Value)127 foreach ($Data as $Key => $Value) 128 128 { 129 129 $Name .= ',`'.$Key.'`'; 130 if (!in_array($Value, $this->Functions))130 if (!in_array($Value, $this->Functions)) 131 131 { 132 if (is_null($Value)) $Value = 'NULL';132 if (is_null($Value)) $Value = 'NULL'; 133 133 else $Value = $this->PDO->quote($Value); 134 134 } … … 144 144 { 145 145 $Values = ''; 146 foreach ($Data as $Key => $Value)147 { 148 if (!in_array($Value, $this->Functions))146 foreach ($Data as $Key => $Value) 147 { 148 if (!in_array($Value, $this->Functions)) 149 149 { 150 if (is_null($Value)) $Value = 'NULL';150 if (is_null($Value)) $Value = 'NULL'; 151 151 else $Value = $this->PDO->quote($Value); 152 152 } … … 161 161 $Name = ''; 162 162 $Values = ''; 163 foreach ($Data as $Key => $Value)164 { 165 if (!in_array($Value, $this->Functions))163 foreach ($Data as $Key => $Value) 164 { 165 if (!in_array($Value, $this->Functions)) 166 166 { 167 if (is_null($Value)) $Value = 'NULL';167 if (is_null($Value)) $Value = 'NULL'; 168 168 else $Value = $this->PDO->quote($Value); 169 169 } … … 185 185 function real_escape_string($Text) 186 186 { 187 return (addslashes($Text));187 return addslashes($Text); 188 188 } 189 189 190 190 function quote($Text) 191 191 { 192 return ($this->PDO->quote($Text));192 return $this->PDO->quote($Text); 193 193 } 194 194 … … 205 205 function TimeToMysqlDateTime($Time) 206 206 { 207 if ($Time == NULL) return(NULL);208 else return (date('Y-m-d H:i:s', $Time));207 if ($Time == NULL) return NULL; 208 else return date('Y-m-d H:i:s', $Time); 209 209 } 210 210 211 211 function TimeToMysqlDate($Time) 212 212 { 213 if ($Time == NULL) return(NULL);214 else return (date('Y-m-d', $Time));213 if ($Time == NULL) return NULL; 214 else return date('Y-m-d', $Time); 215 215 } 216 216 217 217 function TimeToMysqlTime($Time) 218 218 { 219 if ($Time == NULL) return(NULL);220 else return (date('H:i:s', $Time));219 if ($Time == NULL) return NULL; 220 else return date('H:i:s', $Time); 221 221 } 222 222 223 223 function MysqlDateTimeToTime($DateTime) 224 224 { 225 if ($DateTime == '') return(NULL);225 if ($DateTime == '') return NULL; 226 226 $Parts = explode(' ', $DateTime); 227 227 $DateParts = explode('-', $Parts[0]); 228 228 $TimeParts = explode(':', $Parts[1]); 229 229 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 230 return ($Result);230 return $Result; 231 231 } 232 232 233 233 function MysqlDateToTime($Date) 234 234 { 235 if ($Date == '') return(NULL);236 return (MysqlDateTimeToTime($Date.' 0:0:0'));235 if ($Date == '') return NULL; 236 return MysqlDateTimeToTime($Date.' 0:0:0'); 237 237 } 238 238 239 239 function MysqlTimeToTime($Time) 240 240 { 241 if ($Time == '') return(NULL);242 return (MysqlDateTimeToTime('0000-00-00 '.$Time));243 } 241 if ($Time == '') return NULL; 242 return MysqlDateTimeToTime('0000-00-00 '.$Time); 243 } -
trunk/Packages/Common/Error.php
r1 r7 45 45 ); 46 46 47 if (($this->UserErrors & $Number))47 if (($this->UserErrors & $Number)) 48 48 { 49 49 // Error was suppressed with the @-operator 50 if (0 === error_reporting())50 if (0 === error_reporting()) 51 51 { 52 52 return false; … … 58 58 $Backtrace[0]['line'] = $LineNumber; 59 59 $this->Report($Backtrace); 60 //if ((E_ERROR | E_PARSE) & $Number)60 //if ((E_ERROR | E_PARSE) & $Number) 61 61 die(); 62 62 } … … 82 82 'An internal error occurred!<br/>'. 83 83 'Administrator will be notified and the problem will be investigated and fixed soon.'.'<br/><br/>'; 84 if ($this->ShowError == true)84 if ($this->ShowError == true) 85 85 $Output .= '<pre>'.$Message.'</pre><br/>'; 86 86 $Output .= '</body></html>'; … … 92 92 $Date = date('Y-m-d H:i:s'); 93 93 $Error = '# '.$Date."\n"; 94 foreach ($Backtrace as $Item)94 foreach ($Backtrace as $Item) 95 95 { 96 if (!array_key_exists('line', $Item)) $Item['line'] = '';97 if (!array_key_exists('file', $Item)) $Item['file'] = '';96 if (!array_key_exists('line', $Item)) $Item['line'] = ''; 97 if (!array_key_exists('file', $Item)) $Item['file'] = ''; 98 98 99 99 $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function']; 100 100 $Arguments = ''; 101 if (array_key_exists('args', $Item) and is_array($Item['args']))102 foreach ($Item['args'] as $Item)101 if (array_key_exists('args', $Item) and is_array($Item['args'])) 102 foreach ($Item['args'] as $Item) 103 103 { 104 if (is_object($Item)) ;105 else if (is_array($Item)) $Arguments .= "'".serialize($Item)."',";104 if (is_object($Item)) ; 105 else if (is_array($Item)) $Arguments .= "'".serialize($Item)."',"; 106 106 else $Arguments .= "'".$Item."',"; 107 107 } 108 if (strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';108 if (strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')'; 109 109 $Error .= "\n"; 110 110 } 111 111 $Error .= "\n"; 112 112 113 foreach ($this->OnError as $OnError)113 foreach ($this->OnError as $OnError) 114 114 call_user_func($OnError, $Error); 115 115 } -
trunk/Packages/Common/Form/Form.php
r1 r7 44 44 { 45 45 $Result = '<table class="BasicTable">'; 46 if (array_key_exists('Header', $Table))46 if (array_key_exists('Header', $Table)) 47 47 { 48 48 $Result .= '<tr>'; 49 foreach ($Table['Header'] as $Item)49 foreach ($Table['Header'] as $Item) 50 50 $Result .= '<th>'.$Item.'</th>'; 51 51 $Result .= '</tr>'; 52 52 } 53 foreach ($Table['Rows'] as $Row)53 foreach ($Table['Rows'] as $Row) 54 54 { 55 55 $Result .= '<tr>'; 56 foreach ($Row as $Index => $Item)57 { 58 if ($Index == 0) $Class = ' class="Header"'; else $Class = '';56 foreach ($Row as $Index => $Item) 57 { 58 if ($Index == 0) $Class = ' class="Header"'; else $Class = ''; 59 59 $Result .= '<td'.$Class.' style="width: '.(floor(100 / count($Row))).'%">'.$Item.'</td>'; 60 60 } … … 62 62 } 63 63 $Result .= '</table>'; 64 return ($Result);64 return $Result; 65 65 } 66 66 67 67 function LoadDefaults() 68 68 { 69 foreach ($this->Definition['Items'] as $Index => $Item)70 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or69 foreach ($this->Definition['Items'] as $Index => $Item) 70 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 71 71 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 72 72 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 73 73 { 74 if (!array_key_exists($Index, $this->Values) and isset($Item['Default']))74 if (!array_key_exists($Index, $this->Values) and isset($Item['Default'])) 75 75 $this->Values[$Index] = $Item['Default']; 76 76 } … … 86 86 { 87 87 $Item = $this->Definition['Items'][$Index]; 88 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))89 { 90 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))88 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 89 { 90 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 91 91 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 92 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')92 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 93 93 $UseType = 'OneToMany'; 94 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')94 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 95 95 $UseType = 'Enumeration'; 96 96 } else $UseType = $Item['Type']; … … 107 107 'Rows' => array(), 108 108 ); 109 foreach ($this->Definition['Items'] as $Index => $Item)110 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))111 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or109 foreach ($this->Definition['Items'] as $Index => $Item) 110 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 111 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 112 112 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 113 113 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 114 114 { 115 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))116 { 117 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))115 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 116 { 117 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 118 118 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 119 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')119 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 120 120 $UseType = 'OneToMany'; 121 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')121 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 122 122 $UseType = 'Enumeration'; 123 123 } else $UseType = $Item['Type']; … … 126 126 'Type' => $Item['Type'], 'Values' => $this->Values, 127 127 'Filter' => $this->ValuesFilter[$Index])); 128 if (array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix'];129 if (!$this->FormManager->Type->IsHidden($UseType))128 if (array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix']; 129 if (!$this->FormManager->Type->IsHidden($UseType)) 130 130 array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); 131 131 } 132 132 $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.$this->Table($Table). 133 133 '</fieldset>'; 134 return ($Output);134 return $Output; 135 135 } 136 136 137 137 function ShowEditForm() 138 138 { 139 if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';139 if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit'; 140 140 $Output = '<form enctype="multipart/form-data" class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock(). 141 141 '<div><input name="submit" type="submit" value="'.$this->Definition['SubmitText'].'" /> '. 142 142 '<input type="button" value="Zrušit" onclick="location.href=\'?\'"/></div></form>'; 143 return ($Output);143 return $Output; 144 144 } 145 145 … … 152 152 'Rows' => array(), 153 153 ); 154 if ($Context != '') $Context = $Context.'-';155 foreach ($this->Definition['Items'] as $Index => $Item)156 { 157 if (!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false;158 if ($Item['ReadOnly'] == false)159 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))160 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or154 if ($Context != '') $Context = $Context.'-'; 155 foreach ($this->Definition['Items'] as $Index => $Item) 156 { 157 if (!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false; 158 if ($Item['ReadOnly'] == false) 159 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 160 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 161 161 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 162 162 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) … … 164 164 $Parameters = array('Value' => $this->Values[$Index], 'Name' => $Index, 165 165 'Type' => $Item['Type'], 'Values' => $this->Values); 166 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];166 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 167 167 else unset($Parameters['Null']); 168 if (array_key_exists('OnPreset', $Item)) $Parameters['OnPreset'] = $Item['OnPreset'];168 if (array_key_exists('OnPreset', $Item)) $Parameters['OnPreset'] = $Item['OnPreset']; 169 169 else unset($Parameters['OnPreset']); 170 170 171 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))172 { 173 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))174 $this->FormManager->Type->RegisterType($Item['Type'], '', 175 $this->FormManager->FormTypes[$Item['Type']]); 176 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')171 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 172 { 173 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 174 $this->FormManager->Type->RegisterType($Item['Type'], '', 175 $this->FormManager->FormTypes[$Item['Type']]); 176 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 177 177 { 178 178 $UseType = 'OneToMany'; 179 } else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')179 } else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 180 180 $UseType = 'Enumeration'; 181 181 } else $UseType = $Item['Type']; 182 182 $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnEdit', $Parameters); 183 if (array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix'];183 if (array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix']; 184 184 185 185 $Caption = $Item['Caption'].':'; 186 if (array_key_exists($Index, $this->ValuesValidate) and186 if (array_key_exists($Index, $this->ValuesValidate) and 187 187 $this->ValuesValidate[$Index]) { 188 188 $Format = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'GetValidationFormat', array()); 189 if ($Format != '') $Caption .= '<br/><small>'.$Format.'</small>';189 if ($Format != '') $Caption .= '<br/><small>'.$Format.'</small>'; 190 190 $Caption = '<span style="color:red;">'.$Caption.'</span>'; 191 191 } 192 if (!$this->FormManager->Type->IsHidden($UseType))192 if (!$this->FormManager->Type->IsHidden($UseType)) 193 193 array_push($Table['Rows'], array($Caption, $Edit)); 194 194 else $Hidden .= $Edit; … … 197 197 $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.$this->Table($Table). 198 198 $Hidden.'</fieldset>'; 199 return ($Output);199 return $Output; 200 200 } 201 201 202 202 function LoadValuesFromDatabase($Id) 203 203 { 204 foreach ($this->Definition['Items'] as $Index => $Item)205 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or204 foreach ($this->Definition['Items'] as $Index => $Item) 205 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 206 206 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 207 207 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 208 208 { 209 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))210 { 211 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))212 $this->FormManager->Type->RegisterType($Item['Type'], '', 213 $this->FormManager->FormTypes[$Item['Type']]); 214 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')215 $UseType = 'OneToMany'; 216 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')217 $UseType = 'Enumeration'; 218 } else $UseType = $Item['Type']; 219 if (!array_key_exists('SQL', $Item)) $Item['SQL'] = '';209 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 210 { 211 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 212 $this->FormManager->Type->RegisterType($Item['Type'], '', 213 $this->FormManager->FormTypes[$Item['Type']]); 214 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 215 $UseType = 'OneToMany'; 216 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 217 $UseType = 'Enumeration'; 218 } else $UseType = $Item['Type']; 219 if (!array_key_exists('SQL', $Item)) $Item['SQL'] = ''; 220 220 else $Item['SQL'] = str_replace('#Id', $Id, $Item['SQL']); 221 221 $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery', … … 223 223 } 224 224 $Columns = implode(',', $Columns); 225 if (array_key_exists('SQL', $this->Definition))225 if (array_key_exists('SQL', $this->Definition)) 226 226 $SourceTable = '('.$this->Definition['SQL'].') AS `TX`'; 227 227 else $SourceTable = '`'.$this->Definition['Table'].'` AS `TX`'; 228 228 $DbResult = $this->Database->query('SELECT '.$Columns.' FROM '.$SourceTable.' WHERE `TX`.`Id`='.$Id); 229 229 $DbRow = $DbResult->fetch_array(); 230 foreach ($this->Definition['Items'] as $Index => $Item)231 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or230 foreach ($this->Definition['Items'] as $Index => $Item) 231 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 232 232 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 233 233 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 234 234 { 235 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))236 { 237 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))238 $this->FormManager->Type->RegisterType($Item['Type'], '', 239 $this->FormManager->FormTypes[$Item['Type']]); 240 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')241 $UseType = 'OneToMany'; 242 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')235 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 236 { 237 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 238 $this->FormManager->Type->RegisterType($Item['Type'], '', 239 $this->FormManager->FormTypes[$Item['Type']]); 240 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 241 $UseType = 'OneToMany'; 242 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 243 243 $UseType = 'Enumeration'; 244 244 } else $UseType = $Item['Type']; … … 253 253 { 254 254 $Values = array(); 255 foreach ($this->Definition['Items'] as $Index => $Item)256 { 257 if (array_key_exists($Index, $this->Values))258 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or255 foreach ($this->Definition['Items'] as $Index => $Item) 256 { 257 if (array_key_exists($Index, $this->Values)) 258 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 259 259 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 260 260 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) … … 263 263 'Type' => $Item['Type'], 'Values' => $this->Values); 264 264 265 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))266 { 267 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))268 $this->FormManager->Type->RegisterType($Item['Type'], '', 269 $this->FormManager->FormTypes[$Item['Type']]); 270 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')265 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 266 { 267 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 268 $this->FormManager->Type->RegisterType($Item['Type'], '', 269 $this->FormManager->FormTypes[$Item['Type']]); 270 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 271 271 { 272 272 $UseType = 'OneToMany'; 273 273 } 274 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')274 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 275 275 $UseType = 'Enumeration'; 276 276 } else $UseType = $Item['Type']; 277 277 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters); 278 if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]);279 } 280 } 281 if ($Id == 0)278 if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]); 279 } 280 } 281 if ($Id == 0) 282 282 { 283 283 $Values['Id'] = $Id; … … 294 294 function LoadValuesFromFormBlock($Context = '') 295 295 { 296 if ($Context != '') $Context = $Context.'-';296 if ($Context != '') $Context = $Context.'-'; 297 297 $Values = array(); 298 foreach ($this->Definition['Items'] as $Index => $Item)299 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))300 { 301 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or298 foreach ($this->Definition['Items'] as $Index => $Item) 299 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 300 { 301 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 302 302 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 303 303 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and … … 306 306 ($Item['ReadOnly'] != true)))) 307 307 { 308 //if (array_key_exists($Context.$Index, $_POST))309 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))310 { 311 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))308 //if (array_key_exists($Context.$Index, $_POST)) 309 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 310 { 311 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 312 312 $this->FormManager->Type->RegisterType($Item['Type'], '', 313 313 $this->FormManager->FormTypes[$Item['Type']]); 314 314 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type']; 315 if ($CustomType == 'Reference')316 $UseType = 'OneToMany'; 317 else if ($CustomType == 'Enumeration')315 if ($CustomType == 'Reference') 316 $UseType = 'OneToMany'; 317 else if ($CustomType == 'Enumeration') 318 318 $UseType = 'Enumeration'; 319 319 } else $UseType = $Item['Type']; 320 320 $Parameters = array('Name' => $Index, 'Type' => $Item['Type'], 'Values' => $this->Values); 321 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];321 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 322 322 else unset($Parameters['Null']); 323 323 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoad', … … 326 326 } else 327 327 { 328 if (isset($Item['Default'])) {329 if (isset($Item['Null']) and ($Item['Null'] == true))328 if (isset($Item['Default'])) { 329 if (isset($Item['Null']) and ($Item['Null'] == true)) 330 330 $Values[$Index] = null; 331 331 else $Values[$Index] = $Item['Default']; 332 332 } 333 333 } 334 return ($Values);334 return $Values; 335 335 } 336 336 … … 338 338 { 339 339 $Valid = true; 340 foreach ($this->Definition['Items'] as $Index => $Item)341 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or340 foreach ($this->Definition['Items'] as $Index => $Item) 341 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 342 342 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 343 343 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and … … 346 346 ($Item['ReadOnly'] != true)))) 347 347 { 348 //if (array_key_exists($Context.$Index, $_POST))349 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))350 { 351 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))348 //if (array_key_exists($Context.$Index, $_POST)) 349 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 350 { 351 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 352 352 $this->FormManager->Type->RegisterType($Item['Type'], '', 353 353 $this->FormManager->FormTypes[$Item['Type']]); 354 354 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type']; 355 if ($CustomType == 'Reference')356 $UseType = 'OneToMany'; 357 else if ($CustomType == 'Enumeration')355 if ($CustomType == 'Reference') 356 $UseType = 'OneToMany'; 357 else if ($CustomType == 'Enumeration') 358 358 $UseType = 'Enumeration'; 359 359 } else $UseType = $Item['Type']; 360 360 361 361 $Parameters = array('Value' => $this->Values[$Index]); 362 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];362 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 363 363 else $Parameters['Null'] = false; 364 if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate',364 if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate', 365 365 $Parameters)) { 366 366 $this->ValuesValidate[$Index] = true; … … 368 368 } 369 369 } 370 if ($Valid == false) throw new Exception('not validated');371 return ($Valid);370 if ($Valid == false) throw new Exception('not validated'); 371 return $Valid; 372 372 } 373 373 } … … 418 418 $this->Database->query('DELETE FROM DataType'); 419 419 420 foreach ($this->Type->TypeDefinitionList as $Name => $Type)420 foreach ($this->Type->TypeDefinitionList as $Name => $Type) 421 421 { 422 422 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Name.'"'); 423 if ($DbResult->num_rows == 0)423 if ($DbResult->num_rows == 0) 424 424 { 425 425 $this->Database->insert('DataType', array('Name' => $Name, … … 433 433 } 434 434 435 foreach ($this->Classes as $Class)436 if (!array_key_exists('SQL', $Class) and ($Class['Table'] != ''))435 foreach ($this->Classes as $Class) 436 if (!array_key_exists('SQL', $Class) and ($Class['Table'] != '')) 437 437 { 438 438 $DbResult = $this->Database->query('SELECT * FROM information_schema.tables WHERE table_schema = "centrala_big" 439 439 AND table_name = "'.$Class['Table'].'" LIMIT 1'); 440 if ($DbResult->num_rows == 0) continue;440 if ($DbResult->num_rows == 0) continue; 441 441 442 442 echo($Class['Table'].'<br>'); 443 443 $Module = 1; 444 444 $DbResult = $this->Database->select('Model', 'Id', 'Name="'.$Class['Table'].'"'); 445 if ($DbResult->num_rows == 0)445 if ($DbResult->num_rows == 0) 446 446 { 447 447 $this->Database->insert('Model', array('Name' => $Class['Table'], 'Title' => $Class['Title'], 'Module' => $Module)); … … 455 455 } 456 456 457 foreach ($Class['Items'] as $Name => $Field)457 foreach ($Class['Items'] as $Name => $Field) 458 458 { 459 459 echo($Name.', '); 460 460 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Field['Type'].'"'); 461 if ($DbResult->num_rows > 0)461 if ($DbResult->num_rows > 0) 462 462 { 463 463 $DbRow = $DbResult->fetch_assoc(); … … 468 468 // Search parent type 469 469 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Type['Type'].'"'); 470 if ($DbResult->num_rows > 0)470 if ($DbResult->num_rows > 0) 471 471 { 472 472 $DbRow = $DbResult->fetch_assoc(); … … 480 480 481 481 $DbResult = $this->Database->select('ModelField', 'Id', '(Name="'.$Name.'") AND (Model='.$Model.')'); 482 if ($DbResult->num_rows == 0)482 if ($DbResult->num_rows == 0) 483 483 { 484 484 $this->Database->insert('ModelField', array('Name' => $Name, -
trunk/Packages/Common/Form/Types/Base.php
r1 r7 17 17 function OnView($Item) 18 18 { 19 return ('');19 return ''; 20 20 } 21 21 22 22 function OnEdit($Item) 23 23 { 24 return ('');24 return ''; 25 25 } 26 26 27 27 function OnLoad($Item) 28 28 { 29 return ('');29 return ''; 30 30 } 31 31 32 32 function OnLoadDb($Item) 33 33 { 34 return ($Item['Value']);34 return $Item['Value']; 35 35 } 36 36 37 37 function OnSaveDb($Item) 38 38 { 39 return ($Item['Value']);39 return $Item['Value']; 40 40 } 41 41 42 42 function DatabaseEscape($Value) 43 43 { 44 return (addslashes($Value));44 return addslashes($Value); 45 45 } 46 46 47 47 function OnFilterName($Item) 48 48 { 49 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))49 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != '')) 50 50 $SQL = '('.$Item['SQL'].') AS '; 51 51 else $SQL = ''; 52 return ($SQL.'`'.$Item['Name'].'`');52 return $SQL.'`'.$Item['Name'].'`'; 53 53 } 54 54 55 55 function OnFilterNameQuery($Item) 56 56 { 57 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))57 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != '')) 58 58 $Output = '('.$Item['SQL'].') AS `'.$Item['Name'].'`, ('.$Item['SQL'].') AS `'.$Item['Name'].'_Filter`'; 59 59 else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`'; 60 return ($Output);60 return $Output; 61 61 } 62 62 63 63 function Validate($Item) 64 64 { 65 return (true);65 return true; 66 66 } 67 67 68 68 function GetValidationFormat() 69 69 { 70 return ('');70 return ''; 71 71 } 72 72 } -
trunk/Packages/Common/Form/Types/Boolean.php
r1 r7 9 9 function OnView($Item) 10 10 { 11 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';12 return ('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>');11 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 12 return '<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>'; 13 13 } 14 14 15 15 function OnEdit($Item) 16 16 { 17 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';18 return ('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>');17 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 18 return '<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>'; 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 if (array_key_exists($Item['Name'], $_POST)) return(1);24 else return (0);23 if (array_key_exists($Item['Name'], $_POST)) return 1; 24 else return 0; 25 25 } 26 26 } -
trunk/Packages/Common/Form/Types/Color.php
r1 r7 10 10 { 11 11 $Output = '<span style="background-color: #'.$Item['Value'].'"> </span>'; 12 return ($Output);12 return $Output; 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return $Output; 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return $_POST[$Item['Name']]; 24 24 } 25 25 } -
trunk/Packages/Common/Form/Types/Date.php
r1 r7 11 11 global $MonthNames; 12 12 13 if ($Item['Value'] == null) return('');14 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();13 if ($Item['Value'] == null) return ''; 14 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 15 15 $Parts = getdate($Item['Value']); 16 16 17 17 $Output = $Parts['mday'].'.'.$Parts['mon'].'.'.$Parts['year']; 18 return ($Output);18 return $Output; 19 19 } 20 20 … … 23 23 global $MonthNames; 24 24 25 if (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time();25 if (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time(); 26 26 $Parts = getdate($Item['Value']); 27 27 28 28 $Output = ''; 29 29 $Style = ''; 30 if (array_key_exists('Null', $Item) and $Item['Null'])30 if (array_key_exists('Null', $Item) and $Item['Null']) 31 31 { 32 if ($Item['Value'] != null)32 if ($Item['Value'] != null) 33 33 { 34 34 $Checked = ' checked="1"'; … … 45 45 // Day 46 46 $Output .= '<select name="'.$Item['Name'].'-day" id="'.$Item['Name'].'-day" '.$Style.'>'; 47 for ($I = 1; $I <= 31; $I++)47 for ($I = 1; $I <= 31; $I++) 48 48 { 49 if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';49 if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 50 50 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 51 51 } … … 53 53 // Month 54 54 $Output .= '<select name="'.$Item['Name'].'-month" id="'.$Item['Name'].'-month" '.$Style.'>'; 55 for ($I = 1; $I <= 12; $I++)55 for ($I = 1; $I <= 12; $I++) 56 56 { 57 if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';57 if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 58 58 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 59 59 } … … 61 61 // Year 62 62 $Output .= '<select name="'.$Item['Name'].'-year" id="'.$Item['Name'].'-year" '.$Style.'>'; 63 for ($I = 1900; $I < 2100; $I++)63 for ($I = 1900; $I < 2100; $I++) 64 64 { 65 if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';65 if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 66 66 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 67 67 } 68 68 $Output .= '</select>'; 69 return ($Output);69 return $Output; 70 70 } 71 71 72 72 function OnLoad($Item) 73 73 { 74 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);75 else return (mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']));74 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null; 75 else return mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']); 76 76 } 77 77 78 78 function OnLoadDb($Item) 79 79 { 80 return (MysqlDateToTime($Item['Value']));80 return MysqlDateToTime($Item['Value']); 81 81 } 82 82 83 83 function OnSaveDb($Item) 84 84 { 85 if ($Item['Value'] == null) return(null);86 else return (date('Y-m-d', $Item['Value']));85 if ($Item['Value'] == null) return null; 86 else return date('Y-m-d', $Item['Value']); 87 87 } 88 88 89 89 function DatabaseEscape($Value) 90 90 { 91 return ('"'.addslashes($Value).'"');91 return '"'.addslashes($Value).'"'; 92 92 } 93 93 } -
trunk/Packages/Common/Form/Types/DateTime.php
r1 r7 11 11 global $MonthNames; 12 12 13 if ($Item['Value'] == 0) return('');14 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();13 if ($Item['Value'] == 0) return ''; 14 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 15 15 $Parts = getdate($Item['Value']); 16 16 $Output = $Parts['mday'].'.'.$Parts['mon'].'.'.$Parts['year'].' '. 17 17 sprintf('%02d', $Parts['hours']).':'.sprintf('%02d', $Parts['minutes']).':'.sprintf('%02d', $Parts['seconds']); 18 return ($Output);18 return $Output; 19 19 } 20 20 … … 23 23 global $MonthNames; 24 24 25 if (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time();25 if (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time(); 26 26 $Parts = getdate($Item['Value']); 27 27 28 28 $Output = ''; 29 29 $Style = ''; 30 if (array_key_exists('Null', $Item) and $Item['Null'])30 if (array_key_exists('Null', $Item) and $Item['Null']) 31 31 { 32 if ($Item['Value'] != null)32 if ($Item['Value'] != null) 33 33 { 34 34 $Checked = ' checked="1"'; … … 46 46 // Hour 47 47 $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>'; 48 for ($I = 1; $I <= 24; $I++)48 for ($I = 1; $I <= 24; $I++) 49 49 { 50 if ($Parts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';50 if ($Parts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 51 51 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 52 52 } … … 54 54 // Minute 55 55 $Output .= '<select name="'.$Item['Name'].'-minute" id="'.$Item['Name'].'-minute" '.$Style.'>'; 56 for ($I = 1; $I <= 60; $I++)56 for ($I = 1; $I <= 60; $I++) 57 57 { 58 if ($Parts['minutes'] == $I) $Selected = ' selected="1"'; else $Selected = '';58 if ($Parts['minutes'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 59 59 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 60 60 } … … 62 62 // Second 63 63 $Output .= '<select name="'.$Item['Name'].'-second" id="'.$Item['Name'].'-second" '.$Style.'>'; 64 for ($I = 1; $I <= 60; $I++)64 for ($I = 1; $I <= 60; $I++) 65 65 { 66 if ($Parts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';66 if ($Parts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 67 67 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 68 68 } … … 70 70 // Day 71 71 $Output .= ' <select name="'.$Item['Name'].'-day" id="'.$Item['Name'].'-day" '.$Style.'>'; 72 for ($I = 1; $I <= 31; $I++)72 for ($I = 1; $I <= 31; $I++) 73 73 { 74 if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';74 if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 75 75 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 76 76 } … … 78 78 // Month 79 79 $Output .= '<select name="'.$Item['Name'].'-month" id="'.$Item['Name'].'-month" '.$Style.'>'; 80 for ($I = 1; $I <= 12; $I++)80 for ($I = 1; $I <= 12; $I++) 81 81 { 82 if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';82 if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 83 83 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 84 84 } … … 86 86 // Year 87 87 $Output .= '<select name="'.$Item['Name'].'-year" id="'.$Item['Name'].'-year" '.$Style.'>'; 88 for ($I = 1900; $I < 2100; $I++)88 for ($I = 1900; $I < 2100; $I++) 89 89 { 90 if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';90 if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 91 91 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 92 92 } 93 93 $Output .= '</select>'; 94 return ($Output);94 return $Output; 95 95 } 96 96 97 97 function OnLoad($Item) 98 98 { 99 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);100 else return (mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'],101 $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']) );99 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null; 100 else return mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'], 101 $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']); 102 102 } 103 103 104 104 function OnLoadDb($Item) 105 105 { 106 return (MysqlDateTimeToTime($Item['Value']));106 return MysqlDateTimeToTime($Item['Value']); 107 107 } 108 108 109 109 function OnSaveDb($Item) 110 110 { 111 if ($Item['Value'] == null) return(null);112 else return (date('Y-m-d H:i:s', $Item['Value']));111 if ($Item['Value'] == null) return null; 112 else return date('Y-m-d H:i:s', $Item['Value']); 113 113 } 114 114 115 115 function DatabaseEscape($Value) 116 116 { 117 return ('"'.addslashes($Value).'"');117 return '"'.addslashes($Value).'"'; 118 118 } 119 119 } -
trunk/Packages/Common/Form/Types/Enumeration.php
r1 r7 8 8 { 9 9 $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']); 10 if (array_key_exists($Item['Value'], $Type['Parameters']['States']))10 if (array_key_exists($Item['Value'], $Type['Parameters']['States'])) 11 11 $Output = $Type['Parameters']['States'][$Item['Value']]; 12 12 else $Output = $Item['Value']; 13 return ($Output);13 return $Output; 14 14 } 15 15 … … 18 18 $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']); 19 19 $Output = '<select name="'.$Item['Name'].'">'; 20 if (array_key_exists('Null', $Item) and $Item['Null'])20 if (array_key_exists('Null', $Item) and $Item['Null']) 21 21 { 22 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';22 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = ''; 23 23 $Output .= '<option value=""'.$Selected.'></option>'; 24 24 } 25 foreach ($Type['Parameters']['States'] as $Index => $StateName)25 foreach ($Type['Parameters']['States'] as $Index => $StateName) 26 26 { 27 if ($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = '';27 if ($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = ''; 28 28 $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$StateName.'</option>'; 29 29 } 30 30 $Output .= '</select>'; 31 return ($Output);31 return $Output; 32 32 } 33 33 34 34 function OnLoad($Item) 35 35 { 36 if ($_POST[$Item['Name']] == '') return(NULL);37 return ($_POST[$Item['Name']]);36 if ($_POST[$Item['Name']] == '') return NULL; 37 return $_POST[$Item['Name']]; 38 38 } 39 39 40 40 function OnLoadDb($Item) 41 41 { 42 if ($Item['Value'] == '') return(NULL);43 else return ($Item['Value']);42 if ($Item['Value'] == '') return NULL; 43 else return $Item['Value']; 44 44 } 45 45 } -
trunk/Packages/Common/Form/Types/File.php
r1 r7 16 16 $Result = $FileInfo->file($this->FileName); 17 17 //$FileInfo->close(); 18 return ($Result);18 return $Result; 19 19 } 20 20 … … 22 22 { 23 23 $FileName = $this->GetFullName($Item); 24 if (file_exists($FileName)) $Result = filesize($FileName);24 if (file_exists($FileName)) $Result = filesize($FileName); 25 25 else $Result = 0; 26 return ($Result);26 return $Result; 27 27 } 28 28 … … 30 30 { 31 31 $ParentId = $this->Directory; 32 while ($ParentId != null)32 while ($ParentId != null) 33 33 { 34 34 $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$ParentId); … … 38 38 } 39 39 $Result = $this->UploadFileFolder.'/'.$Path.$File->Name; 40 return ($Result);40 return $Result; 41 41 } 42 42 43 43 function GetExt() 44 44 { 45 return (substr($this->Name, 0, strpos($this->Name, '.') - 1));45 return substr($this->Name, 0, strpos($this->Name, '.') - 1); 46 46 } 47 47 48 48 function Delete() 49 49 { 50 if (file_exists($this->GetFullName())) unlink($this->GetFullName());50 if (file_exists($this->GetFullName())) unlink($this->GetFullName()); 51 51 } 52 52 53 53 function GetContent() 54 54 { 55 if ($this->TempName != '') $Content = file_get_contents($this->TempName);55 if ($this->TempName != '') $Content = file_get_contents($this->TempName); 56 56 else $Content = file_get_contents($this->GetFullName()); 57 return ($Content);57 return $Content; 58 58 } 59 59 } … … 75 75 { 76 76 $File = &$Item['Value']; 77 return ('<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'.78 $File.'</a> ('.HumanSize($File->Size).')' );77 return '<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'. 78 $File.'</a> ('.HumanSize($File->Size).')'; 79 79 } 80 80 … … 86 86 $File = &$Item['Value']; 87 87 $Output = '<input type="file" name="'.$Item['Name'].'" value="'.$File->Name.'">'; 88 return ($Output);88 return $Output; 89 89 } 90 90 91 91 function OnLoad($Item) 92 92 { 93 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();93 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 94 94 $File = &$Item['Value']; 95 if (array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != ''))95 if (array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != '')) 96 96 { 97 97 $UploadFile = $_FILES[$Item['Name']]; 98 if (file_exists($UploadFile['tmp_name']))98 if (file_exists($UploadFile['tmp_name'])) 99 99 { 100 100 $File->Name = $UploadFile['name']; … … 103 103 } 104 104 } 105 return ($File);105 return $File; 106 106 } 107 107 108 108 function OnLoadDb($Item) 109 109 { 110 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();110 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 111 111 $File = &$Item['Value']; 112 112 $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id); 113 if ($DbResult->num_rows() > 0)113 if ($DbResult->num_rows() > 0) 114 114 { 115 115 $DbRow = $DbResult->fetch_assoc(); … … 118 118 $File->Directory = $DbRow['Directory']; 119 119 } 120 return ($File);120 return $File; 121 121 } 122 122 123 123 function OnSaveDb($Item) 124 124 { 125 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();125 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 126 126 $File = &$Item['Value']; 127 127 $Properties = array('Name' => $File->Name, 128 128 'Size' => $File->GetSize(), 'Directory' => $File->Directory); 129 129 $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id); 130 if ($DbResult->num_rows() > 0)130 if ($DbResult->num_rows() > 0) 131 131 { 132 132 $DbRow = $DbResult->fetch_assoc(); 133 if ($File->TempName != '')133 if ($File->TempName != '') 134 134 { 135 135 $FileName = $File->GetFullName(); … … 142 142 $File->Id = $this->Database->insert_id; 143 143 } 144 if (!move_uploaded_file($File->TempName, $FileName))144 if (!move_uploaded_file($File->TempName, $FileName)) 145 145 SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!'); 146 146 } -
trunk/Packages/Common/Form/Types/Float.php
r1 r7 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return $Output; 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return $Output; 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return $_POST[$Item['Name']]; 24 24 } 25 25 } -
trunk/Packages/Common/Form/Types/GPS.php
r1 r7 10 10 11 11 $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 12 if ($DbResult->num_rows > 0)12 if ($DbResult->num_rows > 0) 13 13 { 14 14 $DbRow = $DbResult->fetch_assoc(); … … 17 17 $Output = '<a href="http://www.mapy.cz/?st=search&fr=loc:'.$DbRow['Latitude'].' '.$DbRow['Longitude'].'">'.$Latitude[0].'°'.$Latitude[1]."'".$Latitude[2].'" '.$Longitude[0].'°'.$Longitude[1]."'".$Longitude[2].'"</a>'; 18 18 } 19 return ($Output);19 return $Output; 20 20 } 21 21 … … 24 24 global $Database; 25 25 26 if ($Item['Value'] != '')26 if ($Item['Value'] != '') 27 27 { 28 28 $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 29 if ($DbResult->num_rows > 0)29 if ($DbResult->num_rows > 0) 30 30 { 31 31 $DbRow = $DbResult->fetch_assoc(); … … 40 40 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'"/>\''; 41 41 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'"/>"'; 42 return ($Output);42 return $Output; 43 43 } 44 44 … … 50 50 $Longitude = $this->Implode($_POST[$Item['Name'].'-lon-deg'], $_POST[$Item['Name'].'-lon-min'], $_POST[$Item['Name'].'-lon-sec']); 51 51 $Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")'); 52 return ($Database->insert_id);52 return $Database->insert_id; 53 53 } 54 54 … … 61 61 $Float = ($Float - intval($Float)) * 60; 62 62 $Seconds = round($Float, 3); 63 return (array($Degrees, $Minutes, $Seconds));63 return array($Degrees, $Minutes, $Seconds); 64 64 } 65 65 66 66 function Implode($Degrees, $Minutes, $Seconds) 67 67 { 68 if ($Degrees < 0) return(-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60));69 else return ($Degrees + ($Minutes + $Seconds / 60) / 60);68 if ($Degrees < 0) return -(abs($Degrees) + ($Minutes + $Seconds / 60) / 60); 69 else return $Degrees + ($Minutes + $Seconds / 60) / 60; 70 70 } 71 71 } -
trunk/Packages/Common/Form/Types/Hidden.php
r1 r7 14 14 { 15 15 $Output = $Item['Value']; 16 return ($Output);16 return $Output; 17 17 } 18 18 … … 20 20 { 21 21 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />'; 22 return ($Output);22 return $Output; 23 23 } 24 24 25 25 function OnLoad($Item) 26 26 { 27 return ($_POST[$Item['Name']]);27 return $_POST[$Item['Name']]; 28 28 } 29 29 } -
trunk/Packages/Common/Form/Types/Hyperlink.php
r1 r7 8 8 { 9 9 $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>'; 10 return ($Output);10 return $Output; 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 return ($Output);16 return $Output; 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return $_POST[$Item['Name']]; 22 22 } 23 23 } -
trunk/Packages/Common/Form/Types/IPv4Address.php
r1 r7 8 8 { 9 9 $Output = $Item['Value']; 10 return ($Output);10 return $Output; 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 return ($Output);16 return $Output; 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return $_POST[$Item['Name']]; 22 22 } 23 23 24 24 function Validate($Item) 25 25 { 26 if ($Item['Null'] and ($Item['Value'] == '')) return(true);27 return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)));26 if ($Item['Null'] and ($Item['Value'] == '')) return true; 27 return filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)); 28 28 } 29 29 30 30 function GetValidationFormat() 31 31 { 32 return ('x.x.x.x kde x je hodnota 0..255');32 return 'x.x.x.x kde x je hodnota 0..255'; 33 33 } 34 34 } -
trunk/Packages/Common/Form/Types/IPv6Address.php
r1 r7 8 8 { 9 9 $Output = $Item['Value']; 10 return ($Output);10 return $Output; 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 return ($Output);16 return $Output; 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return $_POST[$Item['Name']]; 22 22 } 23 23 24 24 function Validate($Item) 25 25 { 26 if ($Item['Null'] and ($Item['Value'] == '')) return(true);27 return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6)));26 if ($Item['Null'] and ($Item['Value'] == '')) return true; 27 return filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6)); 28 28 } 29 29 30 30 function GetValidationFormat() 31 31 { 32 return ('xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f');32 return 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f'; 33 33 } 34 34 } -
trunk/Packages/Common/Form/Types/Image.php
r1 r7 7 7 global $System; 8 8 9 return ('<img src="'.$System->Link('/images/favicons/'.$Item['Value']).'"/> '.$Item['Value']);9 return '<img src="'.$System->Link('/images/favicons/'.$Item['Value']).'"/> '.$Item['Value']; 10 10 } 11 11 } -
trunk/Packages/Common/Form/Types/Integer.php
r1 r7 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return $Output; 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return $Output; 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return $_POST[$Item['Name']]; 24 24 } 25 25 26 26 function Validate($Item) 27 27 { 28 if ($Item['Null'] and ($Item['Value'] == '')) return(true);29 return (preg_match('/^\-*[0-9\.]+$/', $Item['Value']));28 if ($Item['Null'] and ($Item['Value'] == '')) return true; 29 return preg_match('/^\-*[0-9\.]+$/', $Item['Value']); 30 30 } 31 31 32 32 function GetValidationFormat() 33 33 { 34 return ('číselná hodnota');34 return 'číselná hodnota'; 35 35 } 36 36 } -
trunk/Packages/Common/Form/Types/MacAddress.php
r1 r7 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return $Output; 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return $Output; 19 19 } 20 20 … … 22 22 { 23 23 //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>'); 24 return (strtoupper($_POST[$Item['Name']]));24 return strtoupper($_POST[$Item['Name']]); 25 25 } 26 26 27 27 function DatabaseEscape($Value) 28 28 { 29 return ('"'.addslashes($Value).'"');29 return '"'.addslashes($Value).'"'; 30 30 } 31 31 32 32 function Validate($Item) 33 33 { 34 if ($Item['Null'] and ($Item['Value'] == '')) return(true);35 return (preg_match('/^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$/', $Item['Value']));34 if ($Item['Null'] and ($Item['Value'] == '')) return true; 35 return preg_match('/^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$/', $Item['Value']); 36 36 } 37 37 38 38 function GetValidationFormat() 39 39 { 40 return ('XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F');40 return 'XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F'; 41 41 } 42 42 } -
trunk/Packages/Common/Form/Types/OneToMany.php
r1 r7 10 10 { 11 11 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 12 if ($Item['Value'] != '')12 if ($Item['Value'] != '') 13 13 { 14 14 $Output = '<a href="?t='.$Type['Parameters']['Table'].'&a='. 15 15 'view'.'&i='.$Item['Value'].'">'.$Item['Filter'].'</a>'; 16 16 } else $Output = ''; 17 return ($Output);17 return $Output; 18 18 } 19 19 … … 22 22 $Output = '<select name="'.$Item['Name'].'" id="'.$Item['Name'].'">'; 23 23 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 24 if (array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];24 if (array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition']; 25 25 else $Where = ''; 26 if (array_key_exists('Null', $Item) and $Item['Null'])26 if (array_key_exists('Null', $Item) and $Item['Null']) 27 27 { 28 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';28 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = ''; 29 29 $Output .= '<option value=""'.$Selected.'></option>'; 30 30 } 31 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];31 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View']; 32 32 else $Table = $Type['Parameters']['Table']; 33 33 $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS `Name`,'.$Type['Parameters']['Id'].' AS `Id` FROM '.$Table.''.$Where.' ORDER BY `Name`'); 34 while ($DbRow = $DbResult->fetch_assoc())34 while ($DbRow = $DbResult->fetch_assoc()) 35 35 { 36 if ($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';36 if ($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = ''; 37 37 $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Name'].'</option>'; 38 38 } 39 39 $Output .= '</select>'; 40 if ($this->FormManager->ShowRelation)40 if ($this->FormManager->ShowRelation) 41 41 { 42 42 $URL = ''; 43 if (array_key_exists('OnPreset', $Item))43 if (array_key_exists('OnPreset', $Item)) 44 44 { 45 45 $Preset = call_user_func($Item['OnPreset'], $Item['Values']); … … 51 51 'onclick="return popupwindow("'.$this->FormManager->Root.'/is/?a=select&t='.$Table.'&r='.$Item['Name'].'","test");" style="cursor:hand;cursor:pointer"/>'; 52 52 } 53 return ($Output);53 return $Output; 54 54 } 55 55 56 56 function OnLoad($Item) 57 57 { 58 if ($_POST[$Item['Name']] == '') return(NULL);59 else return ($_POST[$Item['Name']]);58 if ($_POST[$Item['Name']] == '') return NULL; 59 else return $_POST[$Item['Name']]; 60 60 } 61 61 62 62 function OnLoadDb($Item) 63 63 { 64 if ($Item['Value'] == '') return(NULL);65 else return ($Item['Value']);64 if ($Item['Value'] == '') return NULL; 65 else return $Item['Value']; 66 66 } 67 67 68 68 function OnFilterName($Item) 69 69 { 70 return ('`'.$Item['Name'].'_Filter`');70 return '`'.$Item['Name'].'_Filter`'; 71 71 } 72 72 … … 74 74 { 75 75 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 76 //if ($Item['Value'] != '')76 //if ($Item['Value'] != '') 77 77 //{ 78 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];78 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View']; 79 79 else $Table = $Type['Parameters']['Table']; 80 80 $Output = '`'.$Item['Name'].'`, (SELECT '.$Type['Parameters']['Name'].''. … … 82 82 $Type['Parameters']['Id'].'`=`TX`.`'.$Item['Name'].'`) AS `'.$Item['Name'].'_Filter`'; 83 83 //} else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`'; 84 return ($Output);84 return $Output; 85 85 } 86 86 } -
trunk/Packages/Common/Form/Types/OneToMany2.php
r1 r7 8 8 { 9 9 $Output = '<a href="?Action=ShowList&TableId='.$Item['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; 10 return ($Output);10 return $Output; 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<a href="?Action=ShowList&TableId='.$Item['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; 16 return ($Output);16 return $Output; 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return $_POST[$Item['Name']]; 22 22 } 23 23 } -
trunk/Packages/Common/Form/Types/Password.php
r1 r7 10 10 { 11 11 $Output = ''; 12 for ($I = 0; $I < 6; $I++)12 for ($I = 0; $I < 6; $I++) 13 13 $Output .= '*'; 14 return ($Output);14 return $Output; 15 15 } 16 16 … … 18 18 { 19 19 $Output = '<input type="password" name="'.$Item['Name'].'" value=""/>'; 20 return ($Output);20 return $Output; 21 21 } 22 22 … … 27 27 $Result = $_POST[$Item['Name']]; 28 28 /* 29 if (!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]);29 if (!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]); 30 30 else 31 31 { 32 32 $DbRestult = $Database->query('SELECT '.$Item['Name'].' FROM '.$Item['SourceTable'].' WHERE Id='.$Item['SourceItemId']); 33 if ($DbResult->num_rows > 0)33 if ($DbResult->num_rows > 0) 34 34 { 35 35 $DbRow = $DbResult->fetch_assoc(); 36 if ($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']];36 if ($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']]; 37 37 else $Result = sha1($_POST[$Item['Name']]); 38 38 } else $Result = sha1($_POST[$Item['Name']]); 39 39 } 40 40 */ 41 return ($Result);41 return $Result; 42 42 } 43 43 44 44 function OnSaveDb($Item) 45 45 { 46 if ($Item['Value'] == '') return('');46 if ($Item['Value'] == '') return ''; 47 47 else { 48 48 $PasswordHash = new PasswordHash(); 49 return ($PasswordHash->Hash($Item['Value'], $Item['Values']['Salt']));49 return $PasswordHash->Hash($Item['Value'], $Item['Values']['Salt']); 50 50 } 51 51 } … … 53 53 function OnLoadDb($Item) 54 54 { 55 return ('');55 return ''; 56 56 } 57 57 } -
trunk/Packages/Common/Form/Types/RandomHash.php
r1 r7 14 14 { 15 15 $Output = $Item['Value']; 16 return ($Output);16 return $Output; 17 17 } 18 18 19 19 function OnEdit($Item) 20 20 { 21 if ($Item['Value'] == '')21 if ($Item['Value'] == '') 22 22 { 23 23 // Create only once … … 26 26 } 27 27 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />'; 28 return ($Output);28 return $Output; 29 29 } 30 30 31 31 function OnLoad($Item) 32 32 { 33 return ($_POST[$Item['Name']]);33 return $_POST[$Item['Name']]; 34 34 } 35 35 } -
trunk/Packages/Common/Form/Types/String.php
r1 r7 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return $Output; 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return $Output; 19 19 } 20 20 … … 22 22 { 23 23 //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>'); 24 return ($_POST[$Item['Name']]);24 return $_POST[$Item['Name']]; 25 25 } 26 26 27 27 function DatabaseEscape($Value) 28 28 { 29 return ('"'.addslashes($Value).'"');29 return '"'.addslashes($Value).'"'; 30 30 } 31 31 } -
trunk/Packages/Common/Form/Types/Text.php
r1 r7 10 10 { 11 11 $Output = str_replace("\n", '<br/>', strip_tags($Item['Value'])); 12 return ($Output);12 return $Output; 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<textarea name="'.$Item['Name'].'">'.$Item['Value'].'</textarea>'; 18 return ($Output);18 return $Output; 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return $_POST[$Item['Name']]; 24 24 } 25 25 26 26 function DatabaseEscape($Value) 27 27 { 28 return ('"'.addslashes($Value).'"');28 return '"'.addslashes($Value).'"'; 29 29 } 30 30 } -
trunk/Packages/Common/Form/Types/Time.php
r1 r7 9 9 function OnView($Item) 10 10 { 11 if ($Item['Value'] == 0) return('');12 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();11 if ($Item['Value'] == 0) return ''; 12 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 13 13 $TimeParts = getdate($Item['Value']); 14 14 15 15 $Output = sprintf('%02d', $TimeParts['hours']).':'.sprintf('%02d', $TimeParts['minutes']).':'.sprintf('%02d', $TimeParts['seconds']); 16 return ($Output);16 return $Output; 17 17 } 18 18 19 19 function OnEdit($Item) 20 20 { 21 if (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time();21 if (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))) $Item['Value'] = time(); 22 22 $TimeParts = getdate($Item['Value']); 23 23 24 24 $Output = ''; 25 25 $Style = ''; 26 if (array_key_exists('Null', $Item) and $Item['Null'])26 if (array_key_exists('Null', $Item) and $Item['Null']) 27 27 { 28 if ($Item['Value'] != null)28 if ($Item['Value'] != null) 29 29 { 30 30 $Checked = ' checked="1"'; … … 41 41 // Hour 42 42 $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>'; 43 for ($I = 1; $I <= 24; $I++)43 for ($I = 1; $I <= 24; $I++) 44 44 { 45 if ($TimeParts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';45 if ($TimeParts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 46 46 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 47 47 } … … 49 49 // Minute 50 50 $Output .= '<select name="'.$Item['Name'].'-minute" id="'.$Item['Name'].'-minute" '.$Style.'>'; 51 for ($I = 1; $I <= 60; $I++)51 for ($I = 1; $I <= 60; $I++) 52 52 { 53 if ($TimeParts['month'] == $I) $Selected = ' selected="1"'; else $Selected = '';53 if ($TimeParts['month'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 54 54 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 55 55 } … … 57 57 // Second 58 58 $Output .= '<select name="'.$Item['Name'].'-second" id="'.$Item['Name'].'-second" '.$Style.'>'; 59 for ($I = 1; $I <= 60; $I++)59 for ($I = 1; $I <= 60; $I++) 60 60 { 61 if ($TimeParts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';61 if ($TimeParts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 62 62 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 63 63 } 64 64 $Output .= '</select>'; 65 return ($Output);65 return $Output; 66 66 } 67 67 68 68 function OnLoad($Item) 69 69 { 70 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);71 return (mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second']));70 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null; 71 return mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second']); 72 72 } 73 73 74 74 function OnLoadDb($Item) 75 75 { 76 return (MysqlTimeToTime($Item['Value']));76 return MysqlTimeToTime($Item['Value']); 77 77 } 78 78 79 79 function OnSaveDb($Item) 80 80 { 81 if ($Item['Value'] == null) return(null);82 else return (date('H:i:s', $Item['Value']));81 if ($Item['Value'] == null) return null; 82 else return date('H:i:s', $Item['Value']); 83 83 } 84 84 85 85 function DatabaseEscape($Value) 86 86 { 87 return ('"'.addslashes($Value).'"');87 return '"'.addslashes($Value).'"'; 88 88 } 89 89 } -
trunk/Packages/Common/Form/Types/TimeDiff.php
r1 r7 7 7 function OnView($Item) 8 8 { 9 if ($Item['Value'] == null) $Output = '';9 if ($Item['Value'] == null) $Output = ''; 10 10 else { 11 11 $Output = sprintf('%02d', floor($Item['Value'] / 3600 % 24)).':'. … … 13 13 sprintf('%02d', floor($Item['Value'] % 60)); 14 14 $Days = floor($Item['Value'] / (60 * 60 * 24)); 15 if ($Days > 0) $Output = $Days.' dnů '.$Output;15 if ($Days > 0) $Output = $Days.' dnů '.$Output; 16 16 } 17 return ($Output);17 return $Output; 18 18 } 19 19 } -
trunk/Packages/Common/Form/Types/Type.php
r1 r7 67 67 function ExecuteTypeEvent($TypeName, $Event, $Parameters = array()) 68 68 { 69 if (array_key_exists($TypeName, $this->TypeDefinitionList))69 if (array_key_exists($TypeName, $this->TypeDefinitionList)) 70 70 { 71 71 $Type = $this->TypeDefinitionList[$TypeName]; 72 72 $TypeClass = 'Type'.$Type['Class']; 73 73 $TypeObject = new $TypeClass($this->FormManager); 74 if (is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters));75 else return ($TypeName.'->'.$Event.'('.serialize($Parameters).')');76 } else return ($TypeName);74 if (is_callable(array($TypeObject, $Event))) return $TypeObject->$Event($Parameters); 75 else return $TypeName.'->'.$Event.'('.serialize($Parameters).')'; 76 } else return $TypeName; 77 77 } 78 78 79 79 function IsHidden($TypeName) 80 80 { 81 if (array_key_exists($TypeName, $this->TypeDefinitionList))81 if (array_key_exists($TypeName, $this->TypeDefinitionList)) 82 82 { 83 83 $Type = $this->TypeDefinitionList[$TypeName]; 84 84 $TypeClass = 'Type'.$Type['Class']; 85 85 $TypeObject = new $TypeClass($this->FormManager); 86 return ($TypeObject->Hidden);87 } else return (false);86 return $TypeObject->Hidden; 87 } else return false; 88 88 } 89 89 90 90 function RegisterType($Name, $ParentType, $Parameters) 91 91 { 92 if ($ParentType != '')92 if ($ParentType != '') 93 93 { 94 94 $Type = $this->TypeDefinitionList[$ParentType]; … … 97 97 $Type['Name'] = $Name; 98 98 $Type['Class'] = $Name; 99 if (array_key_exists('Parameters', $Type))99 if (array_key_exists('Parameters', $Type)) 100 100 $Type['Parameters'] = array_merge($Type['Parameters'], $Parameters); 101 101 else $Type['Parameters'] = $Parameters; … … 111 111 function GetTypeDefinition($TypeName) 112 112 { 113 return ($this->TypeDefinitionList[$TypeName]);113 return $this->TypeDefinitionList[$TypeName]; 114 114 } 115 115 } -
trunk/Packages/Common/Image.php
r1 r7 65 65 function SaveToFile($FileName) 66 66 { 67 if ($this->Type == IMAGETYPE_JPEG)67 if ($this->Type == IMAGETYPE_JPEG) 68 68 { 69 69 imagejpeg($this->Image, $FileName); 70 70 } else 71 if ($this->Type == IMAGETYPE_GIF)71 if ($this->Type == IMAGETYPE_GIF) 72 72 { 73 imagegif ($this->Image, $FileName);73 imagegif ($this->Image, $FileName); 74 74 } else 75 if ($this->Type == IMAGETYPE_PNG)75 if ($this->Type == IMAGETYPE_PNG) 76 76 { 77 77 imagepng($this->Image, $FileName); … … 83 83 $ImageInfo = getimagesize($FileName); 84 84 $this->Type = $ImageInfo[2]; 85 if ($this->Type == IMAGETYPE_JPEG)85 if ($this->Type == IMAGETYPE_JPEG) 86 86 { 87 87 $this->Image = imagecreatefromjpeg($FileName); 88 88 } else 89 if ($this->Type == IMAGETYPE_GIF)89 if ($this->Type == IMAGETYPE_GIF) 90 90 { 91 91 $this->Image = imagecreatefromgif($FileName); 92 92 } else 93 if ( $this->Type == IMAGETYPE_PNG)93 if ( $this->Type == IMAGETYPE_PNG) 94 94 { 95 95 $this->Image = imagecreatefrompng($FileName); … … 112 112 function GetWidth() 113 113 { 114 return (imagesx($this->Image));114 return imagesx($this->Image); 115 115 } 116 116 117 117 function GetHeight() 118 118 { 119 return (imagesy($this->Image));119 return imagesy($this->Image); 120 120 } 121 121 … … 127 127 function ConvertColor($Color) 128 128 { 129 return (imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff));129 return imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff); 130 130 } 131 131 -
trunk/Packages/Common/Locale.php
r1 r7 20 20 function Translate($Text, $Group = '') 21 21 { 22 if (array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != ''))23 return ($this->Data[$Group][$Text]);24 else return ($Text);22 if (array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != '')) 23 return $this->Data[$Group][$Text]; 24 else return $Text; 25 25 } 26 26 … … 28 28 { 29 29 $Key = array_search($Text, $this->Data[$Group]); 30 if (($Key === FALSE) or ($this->Data[$Group][$Key] == '')) return($Text);31 else return ($Key);30 if (($Key === FALSE) or ($this->Data[$Group][$Key] == '')) return $Text; 31 else return $Key; 32 32 } 33 33 } … … 47 47 { 48 48 $FileName = $this->Dir.'/'.$Language.'.php'; 49 if (file_exists($FileName)) {49 if (file_exists($FileName)) { 50 50 include_once($FileName); 51 51 $ClassName = 'LocaleText'.$Language; … … 59 59 // Search for php files 60 60 $FileList = scandir($Path); 61 foreach ($FileList as $FileName)61 foreach ($FileList as $FileName) 62 62 { 63 63 $FullName = $Path.'/'.$FileName; 64 if (($FileName == '.') or ($FileName == '..')) ; // Skip virtual items65 else if (substr($FileName, 0, 1) == '.') ; // Skip Linux hidden files66 else if (is_dir($FullName)) $this->AnalyzeCode($FullName);67 else if (file_exists($FullName))68 { 69 if (substr($FullName, -4) == '.php')64 if (($FileName == '.') or ($FileName == '..')) ; // Skip virtual items 65 else if (substr($FileName, 0, 1) == '.') ; // Skip Linux hidden files 66 else if (is_dir($FullName)) $this->AnalyzeCode($FullName); 67 else if (file_exists($FullName)) 68 { 69 if (substr($FullName, -4) == '.php') 70 70 { 71 71 $Content = file_get_contents($FullName); 72 72 // Search occurence of T() function 73 while (strpos($Content, 'T(') !== false)73 while (strpos($Content, 'T(') !== false) 74 74 { 75 75 $Previous = strtolower(substr($Content, strpos($Content, 'T(') - 1, 1)); … … 77 77 $Ord = ord($Previous); 78 78 //echo($Ord.','); 79 if (!(($Ord >= ord('a')) and ($Ord <= ord('z'))))79 if (!(($Ord >= ord('a')) and ($Ord <= ord('z')))) 80 80 { 81 81 // Do for non-alpha previous character 82 82 $Original = substr($Content, 0, strpos($Content, ')')); 83 83 $Original2 = ''; 84 if ((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'"))84 if ((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'")) 85 85 $Original2 = substr($Original, 1, -1); 86 if ((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"'))86 if ((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"')) 87 87 $Original2 = substr($Original, 1, -1); 88 if ($Original2 != '')88 if ($Original2 != '') 89 89 { 90 if (!array_key_exists($Original2, $this->Texts->Data))90 if (!array_key_exists($Original2, $this->Texts->Data)) 91 91 $this->Texts->Data[$Original2] = ''; 92 92 } … … 109 109 ' $this->Title = \''.$this->Texts->Title.'\';'."\n". 110 110 ' $this->Data = array('."\n"; 111 foreach ($this->Texts->Data as $Index => $Item)111 foreach ($this->Texts->Data as $Index => $Item) 112 112 { 113 113 $Content .= " '".$Index."' => '".$Item."',\n"; … … 122 122 { 123 123 $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode)); 124 if ($DbResult->num_rows > 0)124 if ($DbResult->num_rows > 0) 125 125 { 126 126 $Language = $DbResult->fetch_assoc(); 127 127 $this->Texts->Data = array(); 128 128 $DbResult = $Database->select('Locale', '`Original`, `Translated`', '`Language`='.$Language['Id']); 129 while ($DbRow = $DbResult->fetch_assoc())129 while ($DbRow = $DbResult->fetch_assoc()) 130 130 $this->Texts->Data[$DbRow['Original']] = $DbRow['Translated']; 131 131 } … … 135 135 { 136 136 $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode)); 137 if ($DbResult->num_rows > 0)137 if ($DbResult->num_rows > 0) 138 138 { 139 139 $Language = $DbResult->fetch_assoc(); 140 140 $Database->delete('Locale', '`Language`='.$Language['Id']); 141 foreach ($this->Texts->Data as $Index => $Item)141 foreach ($this->Texts->Data as $Index => $Item) 142 142 $Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '. 143 143 'VALUES('.$Language['Id'].','.$Database->quote($Index).','.$Database->quote($Item).')'); … … 148 148 { 149 149 $DbResult = $Database->select('Language', '*', '`Code`='.$Database->quote($LangCode)); 150 if ($DbResult->num_rows > 0)150 if ($DbResult->num_rows > 0) 151 151 { 152 152 $Language = $DbResult->fetch_assoc(); 153 foreach ($this->Texts->Data as $Index => $Item)153 foreach ($this->Texts->Data as $Index => $Item) 154 154 { 155 155 $DbResult = $Database->select('Locale', '*', '(`Original` ='.$Database->quote($Index). 156 156 ') AND (`Language`='.($Language['Id']).')'); 157 if ($DbResult->num_rows > 0)157 if ($DbResult->num_rows > 0) 158 158 $Database->update('Locale', '(`Language`='.($Language['Id']).') AND '. 159 159 '(`Original` ='.$Database->quote($Index).')', array('Translated' => $Item)); … … 188 188 $this->Available = array(); 189 189 $FileList = scandir($this->Dir); 190 foreach ($FileList as $FileName)191 { 192 if (substr($FileName, -4) == '.php')190 foreach ($FileList as $FileName) 191 { 192 if (substr($FileName, -4) == '.php') 193 193 { 194 194 $Code = substr($FileName, 0, -4); … … 206 206 $Locale->AnalyzeCode($Directory); 207 207 $FileList = scandir($this->Dir); 208 foreach ($FileList as $FileName)209 { 210 if (substr($FileName, -4) == '.php')208 foreach ($FileList as $FileName) 209 { 210 if (substr($FileName, -4) == '.php') 211 211 { 212 212 $FileLocale = new LocaleFile($this->System); … … 215 215 216 216 // Add new 217 foreach ($Locale->Texts->Data as $Index => $Item)218 if (!array_key_exists($Index, $FileLocale->Texts->Data))217 foreach ($Locale->Texts->Data as $Index => $Item) 218 if (!array_key_exists($Index, $FileLocale->Texts->Data)) 219 219 $FileLocale->Texts->Data[$Index] = $Item; 220 220 // Remove old 221 foreach ($FileLocale->Texts->Data as $Index => $Item)222 if (!array_key_exists($Index, $Locale->Texts->Data))221 foreach ($FileLocale->Texts->Data as $Index => $Item) 222 if (!array_key_exists($Index, $Locale->Texts->Data)) 223 223 unset($FileLocale->Texts->Data[$Index]); 224 224 $FileLocale->UpdateToDatabase($this->System->Database, $FileLocale->Texts->Code); … … 232 232 function LoadLocale($Code) 233 233 { 234 if (array_key_exists($Code, $this->Available))234 if (array_key_exists($Code, $this->Available)) 235 235 { 236 236 $this->CurrentLocale->Dir = $this->Dir; … … 245 245 global $GlobalLocaleManager; 246 246 247 if (isset($GlobalLocaleManager)) return($GlobalLocaleManager->CurrentLocale->Texts->Translate($Text, $Group));248 else return ($Text);249 } 247 if (isset($GlobalLocaleManager)) return $GlobalLocaleManager->CurrentLocale->Texts->Translate($Text, $Group); 248 else return $Text; 249 } -
trunk/Packages/Common/Mail.php
r1 r7 69 69 function Organization($org) 70 70 { 71 if (trim($org != '')) $this->xheaders['Organization'] = $org;71 if (trim($org != '')) $this->xheaders['Organization'] = $org; 72 72 } 73 73 74 74 function Priority($Priority) 75 75 { 76 if (!intval($Priority)) return(false);77 78 if (!isset($this->priorities[$Priority - 1])) return(false);76 if (!intval($Priority)) return false; 77 78 if (!isset($this->priorities[$Priority - 1])) return false; 79 79 80 80 $this->xheaders['X-Priority'] = $this->priorities[$Priority - 1]; 81 return (true);81 return true; 82 82 } 83 83 … … 96 96 function Send() 97 97 { 98 if (count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body'));98 if (count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body')); 99 99 100 100 $Body = $this->BuildAttachment($this->BuildBody()); … … 103 103 $this->Headers['CC'] = ''; 104 104 $this->Headers['BCC'] = ''; 105 foreach ($this->Recipients as $Index => $Recipient)106 { 107 if ($Recipient['Type'] == 'SendCombined')108 { 109 if ($Index > 0) $To .= ', ';105 foreach ($this->Recipients as $Index => $Recipient) 106 { 107 if ($Recipient['Type'] == 'SendCombined') 108 { 109 if ($Index > 0) $To .= ', '; 110 110 $To .= $Recipient['Address']; 111 111 } else 112 if ($Recipient['Type'] == 'Send')113 { 114 if ($Index > 0) $To .= ', ';112 if ($Recipient['Type'] == 'Send') 113 { 114 if ($Index > 0) $To .= ', '; 115 115 $To .= $Recipient['Name'].' <'.$Recipient['Address'].'>'; 116 116 } else 117 if ($Recipient['Type'] == 'Copy')118 { 119 if ($Index > 0) $this->Headers['CC'] .= ', ';117 if ($Recipient['Type'] == 'Copy') 118 { 119 if ($Index > 0) $this->Headers['CC'] .= ', '; 120 120 $this->Headers['CC'] .= $Recipient['Name'].' <'.$To['Address'].'>'; 121 121 } else 122 if ($Recipient['Type'] == 'HiddenCopy')123 { 124 if ($Index > 0) $this->Headers['BCC'] .= ', ';122 if ($Recipient['Type'] == 'HiddenCopy') 123 { 124 if ($Index > 0) $this->Headers['BCC'] .= ', '; 125 125 $this->Headers['BCC'] .= $Recipient['Name'].' <'.$To['Address'].'>'; 126 126 } 127 127 } 128 if ($To == '') throw new Exception(T('Mail message need at least one recipient address'));128 if ($To == '') throw new Exception(T('Mail message need at least one recipient address')); 129 129 130 130 $this->Headers['Mime-Version'] = '1.0'; 131 131 132 if ($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent;133 if ($this->ReplyTo != '') $this->Headers['Reply-To'] = $this->ReplyTo;134 if ($this->From != '') $this->Headers['From'] = $this->From;132 if ($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent; 133 if ($this->ReplyTo != '') $this->Headers['Reply-To'] = $this->ReplyTo; 134 if ($this->From != '') $this->Headers['From'] = $this->From; 135 135 136 136 $Headers = ''; 137 foreach ($this->Headers as $Header => $Value)138 { 139 if (($Header != 'Subject') and ($Value != '')) $Headers .= $Header.': '.$Value."\n";137 foreach ($this->Headers as $Header => $Value) 138 { 139 if (($Header != 'Subject') and ($Value != '')) $Headers .= $Header.': '.$Value."\n"; 140 140 } 141 141 142 142 $this->Subject = strtr($this->Subject, "\r\n", ' '); 143 143 144 if ($this->Subject == '') throw new Exception(T('Mail message missing Subject'));144 if ($this->Subject == '') throw new Exception(T('Mail message missing Subject')); 145 145 146 146 147 147 $res = mail($To, $this->Subject, $Body, $Headers); 148 return ($res);148 return $res; 149 149 } 150 150 151 151 function ValidEmail($Address) 152 152 { 153 if (ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1];154 if (ereg("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))155 return (true);156 else return (false);153 if (ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1]; 154 if (ereg("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address)) 155 return true; 156 else return false; 157 157 } 158 158 159 159 function CheckAdresses($Addresses) 160 160 { 161 foreach ($Addresses as $Address)162 { 163 if (!$this->ValidEmail($Address))161 foreach ($Addresses as $Address) 162 { 163 if (!$this->ValidEmail($Address)) 164 164 throw new Exception(sprintf(T('Mail message invalid address %s'), $Address)); 165 165 } … … 168 168 private function ContentEncoding($Charset) 169 169 { 170 if ($Charset != CHARSET_ASCII) return('8bit');171 else return ('7bit');170 if ($Charset != CHARSET_ASCII) return '8bit'; 171 else return '7bit'; 172 172 } 173 173 174 174 private function BuildAttachment($Body) 175 175 { 176 if (count($this->Attachments) > 0)176 if (count($this->Attachments) > 0) 177 177 { 178 178 $this->Headers['Content-Type'] = "multipart/mixed;\n boundary=\"PHP-mixed-".$this->Boundary."\""; … … 181 181 $Result .= $Body; 182 182 183 foreach ($this->Attachments as $Attachment)183 foreach ($this->Attachments as $Attachment) 184 184 { 185 185 $FileName = $Attachment['FileName']; … … 187 187 $ContentType = $Attachment['FileType']; 188 188 $Disposition = $Attachment['Disposition']; 189 if ($Attachment['Type'] == 'File')189 if ($Attachment['Type'] == 'File') 190 190 { 191 if (!file_exists($FileName))191 if (!file_exists($FileName)) 192 192 throw new Exception(sprintf(T('Mail message attached file %s can\'t be found'), $FileName)); 193 193 $Data = file_get_contents($FileName); 194 194 } else 195 if ($Attachment['Type'] == 'Data') $Data = $Attachment['Data'];195 if ($Attachment['Type'] == 'Data') $Data = $Attachment['Data']; 196 196 else $Data = ''; 197 197 … … 203 203 } 204 204 } else $Result = $Body; 205 return ($Result);205 return $Result; 206 206 } 207 207 … … 209 209 { 210 210 $Result = ''; 211 if (count($this->Bodies) > 1)211 if (count($this->Bodies) > 1) 212 212 { 213 213 $this->Headers['Content-Type'] = 'multipart/alternative; boundary="PHP-alt-'.$this->Boundary.'"'; … … 221 221 222 222 223 foreach ($this->Bodies as $Body)224 { 225 if (count($this->Bodies) > 1) $Result .= "\n\n".'--PHP-alt-'.$this->Boundary."\n";223 foreach ($this->Bodies as $Body) 224 { 225 if (count($this->Bodies) > 1) $Result .= "\n\n".'--PHP-alt-'.$this->Boundary."\n"; 226 226 $Result .= 'Content-Type: '.$Body['Type'].'; charset='.$Body['Charset']. 227 227 "\nContent-Transfer-Encoding: ".$this->ContentEncoding($Body['Charset'])."\n\n".$Body['Content']."\n"; 228 228 } 229 return ($Result);229 return $Result; 230 230 } 231 231 } -
trunk/Packages/Common/NetworkAddress.php
r1 r7 14 14 function GetNetMask() 15 15 { 16 return (0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1));16 return 0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1); 17 17 } 18 18 19 19 function AddressToString() 20 20 { 21 return (implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));21 return implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))); 22 22 } 23 23 … … 37 37 $To->Address = $From->Address + $HostMask; 38 38 $To->Prefix = 32; 39 return (array('From' => $From, 'To' => $To));39 return array('From' => $From, 'To' => $To); 40 40 } 41 41 … … 43 43 { 44 44 $this->Prefix = $NewPrefix; 45 if ($this->Prefix > 32) $this->Prefix = 32;46 if ($this->Prefix < 0) $this->Prefix = 0;45 if ($this->Prefix > 32) $this->Prefix = 32; 46 if ($this->Prefix < 0) $this->Prefix = 0; 47 47 $this->Address = $this->Address & $this->GetNetMask(); 48 48 } … … 51 51 { 52 52 $UpperNetmask = $this->GetNetMask(); 53 if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;53 if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true; 54 54 else $Result = false; 55 55 //echo($Address->AddressToString().'/'.$Address->Prefix.' in '.$this->AddressToString().'/'.$this->Prefix.' '.$Result."\n"); 56 return ($Result);56 return $Result; 57 57 } 58 58 } … … 71 71 function AddressToString() 72 72 { 73 return (inet_ntop($this->Address));73 return inet_ntop($this->Address); 74 74 } 75 75 … … 83 83 $Result = array(); 84 84 $Data = array_reverse(unpack('C*', $this->Address)); 85 foreach ($Data as $Item)85 foreach ($Data as $Item) 86 86 { 87 87 … … 89 89 $Result[] = dechex(($Item >> 4) & 15); 90 90 } 91 return ($Result);91 return $Result; 92 92 } 93 93 -
trunk/Packages/Common/Page.php
r1 r7 17 17 function Show() 18 18 { 19 return ('');19 return ''; 20 20 } 21 21 … … 23 23 { 24 24 $Output = $this->Show(); 25 return ($Output);25 return $Output; 26 26 } 27 27 28 28 function SystemMessage($Title, $Text) 29 29 { 30 return (call_user_func_array($this->OnSystemMessage, array($Title, $Text)));30 return call_user_func_array($this->OnSystemMessage, array($Title, $Text)); 31 31 } 32 32 } -
trunk/Packages/Common/PrefixMultiplier.php
r1 r7 74 74 function TruncateDigits($Value, $Digits = 4) 75 75 { 76 for ($II = 2; $II > -6; $II--)76 for ($II = 2; $II > -6; $II--) 77 77 { 78 if ($Value >= pow(10, $II))78 if ($Value >= pow(10, $II)) 79 79 { 80 if ($Digits < ($II + 1)) $RealDigits = $II + 1;80 if ($Digits < ($II + 1)) $RealDigits = $II + 1; 81 81 else $RealDigits = $Digits; 82 82 $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1); … … 84 84 } 85 85 } 86 return ($Value);86 return $Value; 87 87 } 88 88 … … 93 93 $Negative = ($Value < 0); 94 94 $Value = abs($Value); 95 if (($Unit == '') and ($PrefixType != 'Time'))96 return ($this->TruncateDigits($Value, $Digits));95 if (($Unit == '') and ($PrefixType != 'Time')) 96 return $this->TruncateDigits($Value, $Digits); 97 97 98 98 $I = $PrefixMultipliers[$PrefixType]['BaseIndex']; 99 if ($Value == 0) return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);99 if ($Value == 0) return $Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit; 100 100 101 if ($Value > 1)101 if ($Value > 1) 102 102 { 103 while ((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1))103 while ((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1)) 104 104 $I = $I + 1; 105 105 } else 106 if ($Value < 1)106 if ($Value < 1) 107 107 { 108 while ((($I - 1) >= 0) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]) < 1))108 while ((($I - 1) >= 0) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]) < 1)) 109 109 $I = $I - 1; 110 110 } … … 113 113 // Truncate digits count 114 114 $Value = $this->TruncateDigits($Value, $Digits); 115 if ($Negative) $Value = -$Value;116 return ($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);115 if ($Negative) $Value = -$Value; 116 return $Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit; 117 117 } 118 118 } -
trunk/Packages/Common/RSS.php
r1 r7 28 28 " <pubDate>".date('r')."</pubDate>\n". 29 29 " <ttl>20</ttl>\n"; 30 foreach ($this->Items as $Item)30 foreach ($this->Items as $Item) 31 31 { 32 32 $Result .= " <item>\n". … … 39 39 $Result .= " </channel>\n". 40 40 "</rss>"; 41 return ($Result);41 return $Result; 42 42 } 43 43 } -
trunk/Packages/Common/Setup.php
r1 r7 29 29 '<input type="submit" name="login" value="'.T('Login').'"/>'. 30 30 '</form>'; 31 return ($Output);31 return $Output; 32 32 } 33 33 … … 37 37 38 38 $Output .= 'Je připojení k databázi: '.$this->YesNo[$this->UpdateManager->Database->Connected()].'<br/>'; 39 if ($this->UpdateManager->Database->Connected())39 if ($this->UpdateManager->Database->Connected()) 40 40 { 41 41 $Output .= 'Je instalováno: '.$this->YesNo[$this->UpdateManager->IsInstalled()].'<br/>'; 42 if ($this->UpdateManager->IsInstalled())42 if ($this->UpdateManager->IsInstalled()) 43 43 $Output .= 'Je aktuální: '.$this->YesNo[$this->UpdateManager->IsUpToDate()].'<br/>'. 44 44 'Verze databáze: '.$this->UpdateManager->GetDbVersion().'<br/>'; 45 45 $Output .= 'Verze databáze kódu: '.$this->UpdateManager->Revision.'<br/>'; 46 if ($this->UpdateManager->IsInstalled())47 { 48 if (!$this->UpdateManager->IsUpToDate())46 if ($this->UpdateManager->IsInstalled()) 47 { 48 if (!$this->UpdateManager->IsUpToDate()) 49 49 $Output .= '<a href="?action=upgrade">'.T('Upgrade').'</a> '; 50 50 $Output .= '<a href="?action=insert_sample_data">Vložit vzorová data</a> '; … … 59 59 $Output .= '<a href="'.$this->System->Link('/').'">'.T('Go to main page').'</a> '; 60 60 $Output .= ''; 61 return ($Output);61 return $Output; 62 62 } 63 63 … … 73 73 74 74 $Output = ''; 75 if (isset($this->Config))76 { 77 if (!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = '';78 if (array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword'];79 if (sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword'])75 if (isset($this->Config)) 76 { 77 if (!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = ''; 78 if (array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword']; 79 if (sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword']) 80 80 { 81 81 $Output .= $this->LoginPanel(); 82 82 } else 83 83 { 84 if (array_key_exists('action', $_GET)) $Action = $_GET['action'];84 if (array_key_exists('action', $_GET)) $Action = $_GET['action']; 85 85 else $Action = ''; 86 if ($Action == 'logout')86 if ($Action == 'logout') 87 87 { 88 88 $_SESSION['SystemPassword'] = ''; … … 90 90 $Output .= $this->LoginPanel(); 91 91 } else 92 if ($Action == 'models')92 if ($Action == 'models') 93 93 { 94 94 $this->System->FormManager->UpdateSQLMeta(); 95 95 } else 96 if ($Action == 'upgrade')96 if ($Action == 'upgrade') 97 97 { 98 98 $Output .= '<h3>Povýšení</h3>'; … … 105 105 $Output .= $this->ControlPanel(); 106 106 } else 107 if ($Action == 'install')107 if ($Action == 'install') 108 108 { 109 109 $Output .= '<h3>Instalace</h3>'; … … 114 114 $Output .= $this->ControlPanel(); 115 115 } else 116 if ($Action == 'uninstall')116 if ($Action == 'uninstall') 117 117 { 118 118 $Output .= '<h3>Odinstalace</h3>'; … … 120 120 $Output .= $this->ControlPanel(); 121 121 } else 122 if ($Action == 'reload_modules')122 if ($Action == 'reload_modules') 123 123 { 124 124 $Output .= '<h3>Znovunačtení seznamu modulů</h3>'; … … 127 127 $Output .= $this->ControlPanel(); 128 128 } else 129 if ($Action == 'insert_sample_data')129 if ($Action == 'insert_sample_data') 130 130 { 131 131 $Output .= '<h3>Vložení vzorových dat</h3>'; … … 133 133 $Output .= $this->ControlPanel(); 134 134 } else 135 if ($Action == 'modules')135 if ($Action == 'modules') 136 136 { 137 137 $Output .= $this->ShowModules(); 138 138 } else 139 if ($Action == 'configure_save')139 if ($Action == 'configure_save') 140 140 { 141 141 $Output .= $this->ConfigSave($this->Config); 142 142 $Output .= $this->ControlPanel(); 143 143 } else 144 if ($Action == 'configure')144 if ($Action == 'configure') 145 145 { 146 146 $Output .= $this->PrepareConfig($this->Config); … … 152 152 } else 153 153 { 154 if (array_key_exists('configure_save', $_POST))154 if (array_key_exists('configure_save', $_POST)) 155 155 { 156 156 $Output .= $this->ConfigSave(array()); … … 160 160 } 161 161 } 162 return ($Output);162 return $Output; 163 163 } 164 164 … … 166 166 { 167 167 $Output = ''; 168 if (array_key_exists('op', $_GET)) $Operation = $_GET['op'];168 if (array_key_exists('op', $_GET)) $Operation = $_GET['op']; 169 169 else $Operation = ''; 170 if ($Operation == 'install')170 if ($Operation == 'install') 171 171 { 172 172 $this->System->ModuleManager->Modules[$_GET['name']]->Install(); … … 174 174 $Output .= 'Modul '.$_GET['name'].' instalován<br/>'; 175 175 } else 176 if ($Operation == 'uninstall')176 if ($Operation == 'uninstall') 177 177 { 178 178 $this->System->ModuleManager->Modules[$_GET['name']]->Uninstall(); … … 180 180 $Output .= 'Modul '.$_GET['name'].' odinstalován<br/>'; 181 181 } else 182 if ($Operation == 'enable')182 if ($Operation == 'enable') 183 183 { 184 184 $this->System->ModuleManager->Modules[$_GET['name']]->Enable(); … … 186 186 $Output .= 'Modul '.$_GET['name'].' povolen<br/>'; 187 187 } else 188 if ($Operation == 'disable')188 if ($Operation == 'disable') 189 189 { 190 190 $this->System->ModuleManager->Modules[$_GET['name']]->Disable(); … … 192 192 $Output .= 'Modul '.$_GET['name'].' zakázán<br/>'; 193 193 } else 194 if ($Operation == 'upgrade')194 if ($Operation == 'upgrade') 195 195 { 196 196 $this->System->ModuleManager->Modules[$_GET['name']]->Upgrade(); … … 200 200 $Output .= '<h3>Správa modulů</h3>'; 201 201 $Output .= $this->ShowList(); 202 return ($Output);202 return $Output; 203 203 } 204 204 … … 221 221 array('Name' => '', 'Title' => 'Akce'), 222 222 )); 223 foreach ($this->System->ModuleManager->Modules as $Module)224 { 225 if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);223 foreach ($this->System->ModuleManager->Modules as $Module) 224 { 225 if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies); 226 226 else $Dependencies = ' '; 227 227 $Actions = ''; 228 if ($Module->Installed == true)228 if ($Module->Installed == true) 229 229 { 230 230 $Actions .= ' <a href="?action=modules&op=uninstall&name='.$Module->Name.'">Odinstalovat</a>'; 231 if ($Module->Enabled == true) $Actions .= ' <a href="?action=modules&op=disable&name='.$Module->Name.'">Zakázat</a>';231 if ($Module->Enabled == true) $Actions .= ' <a href="?action=modules&op=disable&name='.$Module->Name.'">Zakázat</a>'; 232 232 else $Actions .= ' <a href="?action=modules&op=enable&name='.$Module->Name.'">Povolit</a>'; 233 if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&op=upgrade&name='.$Module->Name.'">Povýšit</a>';233 if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&op=upgrade&name='.$Module->Name.'">Povýšit</a>'; 234 234 } else $Actions .= ' <a href="?action=modules&op=install&name='.$Module->Name.'">Instalovat</a>'; 235 235 … … 244 244 $Output .= $Pageing->Show(); 245 245 //$Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>'; 246 return ($Output);246 return $Output; 247 247 } 248 248 … … 250 250 { 251 251 $Output = ''; 252 if (!file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir))252 if (!file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir)) 253 253 $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože složka "'.$this->ConfigDir.'" není povolená pro zápis!'; 254 if (file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir.'/Config.php'))254 if (file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir.'/Config.php')) 255 255 $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože soubor "'.$this->ConfigDir.'/Config.php" není povolen pro zápis!'; 256 256 $Output .= '<h3>Nastavení systému</h3>'. 257 257 '<form action="?action=configure_save" method="post">'. 258 258 '<table>'; 259 foreach ($this->ConfigDefinition as $Def)259 foreach ($this->ConfigDefinition as $Def) 260 260 { 261 261 $PathParts = explode('/', $Def['Name']); 262 262 $TempConfig = &$Config; 263 foreach ($PathParts as $Part)264 if (array_key_exists($Part, $TempConfig))263 foreach ($PathParts as $Part) 264 if (array_key_exists($Part, $TempConfig)) 265 265 { 266 266 $TempConfig = &$TempConfig[$Part]; 267 267 } 268 if (!is_array($TempConfig)) $Value = $TempConfig;268 if (!is_array($TempConfig)) $Value = $TempConfig; 269 269 else $Value = $Def['Default']; 270 270 $Output .= '<tr><td>'.$Def['Title'].'</td><td>'; 271 if ($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';272 if ($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';273 if ($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';274 if ($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';275 if ($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';276 if ($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';277 if ($Def['Type'] == 'Array') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.implode(',', $Value).'"/>';271 if ($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 272 if ($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>'; 273 if ($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>'; 274 if ($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 275 if ($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 276 if ($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 277 if ($Def['Type'] == 'Array') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.implode(',', $Value).'"/>'; 278 278 } 279 279 $Output .= '</td></tr>'. … … 281 281 '</table>'. 282 282 '</form>'; 283 return ($Output);283 return $Output; 284 284 } 285 285 … … 287 287 { 288 288 $Config = $DefaultConfig; 289 foreach ($this->ConfigDefinition as $Def)289 foreach ($this->ConfigDefinition as $Def) 290 290 { 291 291 $Value = null; 292 if ($Def['Type'] == 'String') if(array_key_exists($Def['Name'], $_POST))292 if ($Def['Type'] == 'String') if (array_key_exists($Def['Name'], $_POST)) 293 293 $Value = $_POST[$Def['Name']]; 294 if ($Def['Type'] == 'Password') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))294 if ($Def['Type'] == 'Password') if (array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != '')) 295 295 $Value = $_POST[$Def['Name']]; 296 if ($Def['Type'] == 'PasswordEncoded') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))296 if ($Def['Type'] == 'PasswordEncoded') if (array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != '')) 297 297 $Value = sha1($_POST[$Def['Name']]); 298 if ($Def['Type'] == 'Integer') if(array_key_exists($Def['Name'], $_POST))298 if ($Def['Type'] == 'Integer') if (array_key_exists($Def['Name'], $_POST)) 299 299 $Value = $_POST[$Def['Name']]; 300 if ($Def['Type'] == 'Float') if(array_key_exists($Def['Name'], $_POST))300 if ($Def['Type'] == 'Float') if (array_key_exists($Def['Name'], $_POST)) 301 301 $Value = $_POST[$Def['Name']]; 302 if ($Def['Type'] == 'Boolean') if(array_key_exists($Def['Name'], $_POST))302 if ($Def['Type'] == 'Boolean') if (array_key_exists($Def['Name'], $_POST)) 303 303 $Value = $_POST[$Def['Name']]; 304 if ($Def['Type'] == 'Array') if(array_key_exists($Def['Name'], $_POST))304 if ($Def['Type'] == 'Array') if (array_key_exists($Def['Name'], $_POST)) 305 305 $Value = explode(',', $_POST[$Def['Name']]); 306 if (!is_null($Value))306 if (!is_null($Value)) 307 307 { 308 308 $PathParts = explode('/', $Def['Name']); 309 309 $TempConfig = &$Config; 310 foreach ($PathParts as $Part)310 foreach ($PathParts as $Part) 311 311 { 312 312 $TempConfig = &$TempConfig[$Part]; 313 313 } 314 if (!is_array($TempConfig)) $TempConfig = $Value;314 if (!is_array($TempConfig)) $TempConfig = $Value; 315 315 else $Value = $Def['Default']; 316 316 } … … 319 319 file_put_contents($this->ConfigDir.'/Config.php', $ConfigText); 320 320 $Output = 'Konfigurace nastavena<br/>'; 321 return ($Output);321 return $Output; 322 322 } 323 323 … … 327 327 "\$IsDeveloper = array_key_exists('REMOTE_ADDR', \$_SERVER) and in_array(\$_SERVER['REMOTE_ADDR'], array('127.0.0.1'));\n\n"; 328 328 329 foreach ($this->ConfigDefinition as $Def)329 foreach ($this->ConfigDefinition as $Def) 330 330 { 331 331 $PathParts = explode('/', $Def['Name']); 332 332 $Output .= "\$Config"; 333 foreach ($PathParts as $Part)333 foreach ($PathParts as $Part) 334 334 $Output .= "['".$Part."']"; 335 335 $TempConfig = &$Config; 336 336 $Output .= ' = '; 337 foreach ($PathParts as $Part)338 if (array_key_exists($Part, $TempConfig))337 foreach ($PathParts as $Part) 338 if (array_key_exists($Part, $TempConfig)) 339 339 { 340 340 $TempConfig = &$TempConfig[$Part]; 341 341 } 342 if (!is_array($TempConfig)) $Value = $TempConfig;342 if (!is_array($TempConfig)) $Value = $TempConfig; 343 343 else $Value = $Def['Default']; 344 if ($Def['Type'] == 'Array')344 if ($Def['Type'] == 'Array') 345 345 { 346 346 $Output .= ' array('; 347 foreach ($Value as $Index => $Item)347 foreach ($Value as $Index => $Item) 348 348 $Output .= '\''.$Item.'\', '; 349 349 $Output .= ')'; … … 353 353 } 354 354 $Output .= "\n\n"; 355 return ($Output);355 return $Output; 356 356 } 357 357 } … … 362 362 { 363 363 $Output = ''; 364 if (!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>';364 if (!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>'; 365 365 else { 366 if (!$this->System->Setup->UpdateManager->IsInstalled())366 if (!$this->System->Setup->UpdateManager->IsInstalled()) 367 367 $Output .= T('System requires database initialization').'<br>'; 368 368 else 369 if (!$this->System->Setup->UpdateManager->IsUpToDate())369 if (!$this->System->Setup->UpdateManager->IsUpToDate()) 370 370 $Output .= T('System requires database upgrade').'<br>'; 371 371 } 372 372 $Output .= sprintf(T('Front page was not configured. Continue to %s'), '<a href="'.$this->System->Link('/setup/').'">'.T('setup').'</a>'); 373 return ($Output);373 return $Output; 374 374 } 375 375 } … … 402 402 function CheckState() 403 403 { 404 return ($this->Database->Connected() and $this->UpdateManager->IsInstalled() and405 $this->UpdateManager->IsUpToDate() );404 return $this->Database->Connected() and $this->UpdateManager->IsInstalled() and 405 $this->UpdateManager->IsUpToDate(); 406 406 } 407 407 … … 435 435 { 436 436 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->UpdateManager->VersionTable.'"'); 437 return ($DbResult->num_rows > 0);437 return $DbResult->num_rows > 0; 438 438 } 439 439 … … 443 443 $this->UpdateManager->Trace = $Updates->Get(); 444 444 $Output = $this->UpdateManager->Upgrade(); 445 return ($Output);445 return $Output; 446 446 } 447 447 } -
trunk/Packages/Common/Table.php
r1 r7 7 7 function Show() 8 8 { 9 return ('');9 return ''; 10 10 } 11 11 } … … 15 15 function GetCell($Y, $X) 16 16 { 17 return ('');17 return ''; 18 18 } 19 19 … … 28 28 function RowsCount() 29 29 { 30 return (0);30 return 0; 31 31 } 32 32 } … … 38 38 function GetCell($Y, $X) 39 39 { 40 return ($this->Cells[$Y][$X]);40 return $this->Cells[$Y][$X]; 41 41 } 42 42 43 43 function RowsCount() 44 44 { 45 return (count($this->Cells));45 return count($this->Cells); 46 46 } 47 47 } … … 55 55 function GetCell($Y, $X) 56 56 { 57 return ($this->Cells[$Y][$X]);57 return $this->Cells[$Y][$X]; 58 58 } 59 59 … … 62 62 $this->Cells = array(); 63 63 $DbResult = $this->Database->query($this->Query); 64 while ($DbRow = $DbResult->fetch_row())64 while ($DbRow = $DbResult->fetch_row()) 65 65 { 66 66 $this->Cells[] = $DbRow; … … 75 75 function RowsCount() 76 76 { 77 return (count($this->Cells));77 return count($this->Cells); 78 78 } 79 79 } … … 112 112 { 113 113 $this->Columns = array(); 114 foreach ($Columns as $Column)114 foreach ($Columns as $Column) 115 115 { 116 116 $NewCol = new TableColumn(); … … 119 119 $this->Columns[] = $NewCol; 120 120 } 121 if (count($this->Columns) > 0)121 if (count($this->Columns) > 0) 122 122 $this->DefaultColumn = $this->Columns[0]->Name; 123 123 else $this->DefaultColumn = ''; … … 129 129 $Output .= $this->GetOrderHeader(); 130 130 $this->Table->BeginRead(); 131 for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++)131 for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++) 132 132 { 133 133 $Output .= '<tr>'; 134 134 135 for ($X = 0; $X < count($this->Columns); $X++)135 for ($X = 0; $X < count($this->Columns); $X++) 136 136 { 137 137 $Cell = $this->Table->GetCell($Y, $X); 138 if ($Cell == '') $Output .= '<td> </td>';138 if ($Cell == '') $Output .= '<td> </td>'; 139 139 else $Output .= '<td>'.$Cell.'</td>'; 140 140 } … … 143 143 $this->Table->EndRead(); 144 144 $Output .= '</table>'; 145 return ($Output);145 return $Output; 146 146 } 147 147 148 148 function GetOrderHeader() 149 149 { 150 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];151 if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];152 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn;153 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder;150 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 151 if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir']; 152 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn; 153 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder; 154 154 155 155 // Check OrderCol 156 156 $Found = false; 157 foreach ($this->Columns as $Column)157 foreach ($this->Columns as $Column) 158 158 { 159 if ($Column->Name == $_SESSION['OrderCol'])159 if ($Column->Name == $_SESSION['OrderCol']) 160 160 { 161 161 $Found = true; … … 163 163 } 164 164 } 165 if ($Found == false)165 if ($Found == false) 166 166 { 167 167 $_SESSION['OrderCol'] = $this->DefaultColumn; … … 169 169 } 170 170 // Check OrderDir 171 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1))171 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) 172 172 $_SESSION['OrderDir'] = 0; 173 173 174 174 $Result = ''; 175 175 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 176 foreach ($this->Columns as $Index => $Column)176 foreach ($this->Columns as $Index => $Column) 177 177 { 178 178 $QueryItems['OrderCol'] = $Column->Name; 179 179 $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir']; 180 if ($Column->Name == $_SESSION['OrderCol'])180 if ($Column->Name == $_SESSION['OrderCol']) 181 181 $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.$this->OrderArrowImage[$_SESSION['OrderDir']].'" alt="order arrow">'; 182 182 else $ArrowImage = ''; 183 if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>';183 if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>'; 184 184 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column->Title.$ArrowImage.'</a></th>'; 185 185 } … … 188 188 $this->OrderDirection = $_SESSION['OrderDir']; 189 189 190 return ('<tr>'.$Result.'</tr>');190 return '<tr>'.$Result.'</tr>'; 191 191 } 192 192 } -
trunk/Packages/Common/UTF8.php
r1 r7 529 529 { 530 530 $Result = ''; 531 for ($I = 0; $I < strlen($String); $I++)531 for ($I = 0; $I < strlen($String); $I++) 532 532 { 533 if (ord($String[$I]) < 128) $Result .= $String[$I];534 else if (ord($String[$I]) > 127)533 if (ord($String[$I]) < 128) $Result .= $String[$I]; 534 else if (ord($String[$I]) > 127) 535 535 { 536 536 $Result .= $this->CharTable[$Charset][ord($String[$I])]; 537 537 } 538 538 } 539 return ($Result);539 return $Result; 540 540 } 541 541 … … 544 544 $Result = ''; 545 545 $UTFPrefix = ''; 546 for ($I = 0; $I < strlen($String); $I++)546 for ($I = 0; $I < strlen($String); $I++) 547 547 { 548 if (ord($String{$I}) & 0x80) // UTF control character548 if (ord($String{$I}) & 0x80) // UTF control character 549 549 { 550 if (ord($String{$I}) & 0x40) // First550 if (ord($String{$I}) & 0x40) // First 551 551 { 552 if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));552 if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset])); 553 553 $UTFPrefix = $String{$I}; 554 554 } … … 556 556 } else 557 557 { 558 if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));558 if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset])); 559 559 $UTFPrefix = ''; 560 560 $Result .= $String{$I}; 561 561 } 562 562 } 563 return ($Result);563 return $Result; 564 564 } 565 565 } -
trunk/Packages/Common/Update.php
r1 r7 23 23 $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1'); 24 24 $Version = $DbResult->fetch_assoc(); 25 return ($Version['Revision']);25 return $Version['Revision']; 26 26 } 27 27 … … 29 29 { 30 30 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"'); 31 return ($DbResult->num_rows > 0);31 return $DbResult->num_rows > 0; 32 32 } 33 33 34 34 function IsUpToDate() 35 35 { 36 return ($this->Revision <= $this->GetDbVersion());36 return $this->Revision <= $this->GetDbVersion(); 37 37 } 38 38 … … 41 41 $DbRevision = $this->GetDbVersion(); 42 42 $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>'; 43 while ($this->Revision > $DbRevision)43 while ($this->Revision > $DbRevision) 44 44 { 45 45 $TraceItem = $this->Trace[$DbRevision]; … … 54 54 $TraceItem['Revision'].' WHERE `Id`=1'); 55 55 } 56 return ($Output);56 return $Output; 57 57 } 58 58 … … 79 79 echo($Query.';<br/>'); 80 80 flush(); 81 return ($this->Database->query($Query));81 return $this->Database->query($Query); 82 82 } 83 83 } -
trunk/Packages/Common/VarDumper.php
r1 r7 49 49 self::$_depth=$depth; 50 50 self::dumpInternal($var,0); 51 if ($highlight)51 if ($highlight) 52 52 { 53 53 $result=highlight_string("<?php\n".self::$_output,true); … … 60 60 private static function dumpInternal($var,$level) 61 61 { 62 switch (gettype($var))62 switch (gettype($var)) 63 63 { 64 64 case 'boolean': … … 84 84 break; 85 85 case 'array': 86 if (self::$_depth<=$level)86 if (self::$_depth<=$level) 87 87 self::$_output.='array(...)'; 88 else if (empty($var))88 else if (empty($var)) 89 89 self::$_output.='array()'; 90 90 else … … 93 93 $spaces=str_repeat(' ',$level*4); 94 94 self::$_output.="array\n".$spaces.'('; 95 foreach ($keys as $key)95 foreach ($keys as $key) 96 96 { 97 97 self::$_output.="\n".$spaces." [$key] => "; … … 102 102 break; 103 103 case 'object': 104 if (($id=array_search($var,self::$_objects,true))!==false)104 if (($id=array_search($var,self::$_objects,true))!==false) 105 105 self::$_output.=get_class($var).'#'.($id+1).'(...)'; 106 else if (self::$_depth<=$level)106 else if (self::$_depth<=$level) 107 107 self::$_output.=get_class($var).'(...)'; 108 108 else … … 114 114 $spaces=str_repeat(' ',$level*4); 115 115 self::$_output.="$className#$id\n".$spaces.'('; 116 foreach ($keys as $key)116 foreach ($keys as $key) 117 117 { 118 118 $keyDisplay=strtr(trim($key),array("\0"=>':'));
Note:
See TracChangeset
for help on using the changeset viewer.