Changeset 30
- Timestamp:
- Dec 16, 2008, 8:15:34 AM (16 years ago)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
base.php
r29 r30 1 1 <?php 2 3 function GetListTableName($List) 4 { 5 if($List['Database'] != '') return('`'.$List['Database'].'`.`'.$List['TableName'].'`'); 6 else return('`'.$List['TableName'].'`'); 7 } 2 8 3 9 function ShowList($List, $Column = '', $ColumnValue = 0, $Title = '', $Filter = '') … … 54 60 //$Where .= ' AND (ValidFromTime <= NOW()) AND ((ValidToTime >= NOW()) OR (ValidToTime IS NULL))'; 55 61 $Where .= ' '.$Order; 56 $DbResult = $Database->query('SELECT COUNT(*) AS Count FROM `'.$List['TableName'].'`WHERE '.$Where);62 $DbResult = $Database->query('SELECT COUNT(*) AS Count FROM '.GetListTableName($List).' WHERE '.$Where); 57 63 $DbRow = $DbResult->fetch_row(); 58 64 $TotalItemCount = $DbRow[0]; 59 65 60 $DbResult = $Database->query('SELECT * FROM `'.$List['TableName'].'`WHERE '.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']);66 $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$Where.' LIMIT '.($Page * $Config['Web']['ItemsPerPage']).', '.$Config['Web']['ItemsPerPage']); 61 67 //echo($Database->LastQuery); 62 68 while($DbRow = $DbResult->fetch_assoc()) … … 67 73 if($Item['VisibleInList'] == 1) 68 74 { 69 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[ 'Id'], 'Type' => $Item['Type']);75 $ItemDefinition = array('Name' => $Index, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']); 70 76 $Output .= '<td>'.ExecuteTypeEvent($Item['Type'], 'OnView', $ItemDefinition).'</td>'; 71 77 } 72 78 } 73 79 $Output .= '<td>'; 74 if(CheckPermission('Read', $List['Id'])) $Output .= '<a href="?Action=ViewItem&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a>';75 if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=EditItem&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'"><img border="0" src="images/edit.png" alt="Editovat" title="Editovat"></a>';76 if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=DeleteItem&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'"><img border="0" src="images/delete.png" alt="Smazat" title="Smazat" onclick="return confirmAction(\'Opravdu smazat položku?\');"></a>';80 if(CheckPermission('Read', $List['Id'])) $Output .= '<a href="?Action=ViewItem&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'"><img border="0" src="images/view.png" alt="Zobrazit" title="Zobrazit"></a>'; 81 if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=EditItem&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'"><img border="0" src="images/edit.png" alt="Editovat" title="Editovat"></a>'; 82 if(CheckPermission('Write', $List['Id'])) $Output .= ' <a href="?Action=DeleteItem&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'"><img border="0" src="images/delete.png" alt="Smazat" title="Smazat" onclick="return confirmAction(\'Opravdu smazat položku?\');"></a>'; 77 83 $Output .= '</td></tr>'; 78 84 } … … 158 164 159 165 if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 160 $DbResult = $Database-> select($List['TableName'], '*', 'Id='.$Id);166 $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id); 161 167 while($DbRow = $DbResult->fetch_assoc()) 162 168 { … … 169 175 if($Item['Editable'] == 1) 170 176 { 171 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[ 'Id'], 'Type' => $Item['Type']);177 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']); 172 178 } else $DefinitionItems[] = array('Name' => $Index, 'Type' => TypeHiddenId, 'Caption' => '', 'Value' => $DbRow[$Index]); 173 179 } … … 198 204 199 205 if(!CheckPermission('Write', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 200 $DbResult = $Database-> select($List['TableName'], '*', 'Id='.$Id);206 $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id); 201 207 while($DbRow = $DbResult->fetch_assoc()) 202 208 { … … 207 213 if($Type['BaseType'] != 'PointerOneToMany') 208 214 { 209 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[ 'Id'], 'Type' => $Item['Type']);215 $DefinitionItems[] = array('Name' => $Index, 'Caption' => $Item['TextBefore'].$Required, 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => $DbRow[$List['IdName']], 'Type' => $Item['Type']); 210 216 } 211 217 } … … 227 233 $Form->Values['Id'] = $Id; 228 234 $Form->Values['ListTableName'] = $List['TableName']; 235 $Form->Values['ListDatabaseName'] = $List['Database']; 229 236 ExecuteListEvent($List['Id'], 'OnEdit', $Form->Values); 230 237 return($Output); … … 320 327 if(!CheckPermission('Read', $List['Id'])) return(SystemMessage('Řízení přístupu', 'Nemáte dostatečná oprávnění')); 321 328 $Output = ''; 322 $DbResult = $Database-> select($List['TableName'], '*', 'Id='.$Id);329 $DbResult = $Database->query('SELECT * FROM '.GetListTableName($List).' WHERE '.$List['IdName'].'='.$Id); 323 330 while($DbRow = $DbResult->fetch_assoc()) 324 331 { … … 340 347 ); 341 348 $Output .= $Form->ShowReadOnlyForm(); 342 if(CheckPermission('Write', $List['Id'])) $Output .= '<a href="?Action=EditItem&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'">Editovat</a> ';349 if(CheckPermission('Write', $List['Id'])) $Output .= '<a href="?Action=EditItem&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'">Editovat</a> '; 343 350 344 351 if(($Column != '') and ($ColumnValue != 0)) … … 349 356 $Output .= '<a href="?Action=ShowList&Table='.$List['Id'].'">Celkový seznam</a>'; 350 357 } 351 $Output .= ' <a href="?Action=ShowHistory&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'">Historie</a>';352 $Output .= ' <a href="?Action=DeleteItem&Table='.$List['Id'].'&Item='.$DbRow[ 'Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>';358 $Output .= ' <a href="?Action=ShowHistory&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'">Historie</a>'; 359 $Output .= ' <a href="?Action=DeleteItem&Table='.$List['Id'].'&Item='.$DbRow[$List['IdName']].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>'; 353 360 $Output .= '<div class="line"></div>'; 354 361 foreach($List['Items'] as $Index => $Item) … … 358 365 { 359 366 $SubList = GetListDefinition($Type['Parameters'][0]); 360 $Output .= ShowList($SubList, $Type['Parameters'][1], $DbRow[ 'Id'], $Item['TextBefore']).'<br /><br />';367 $Output .= ShowList($SubList, $Type['Parameters'][1], $DbRow[$List['IdName']], $Item['TextBefore']).'<br /><br />'; 361 368 } 362 369 } … … 472 479 while($DbRow2 = $DbResult2->fetch_assoc()) 473 480 { 474 if(CheckPermission('Read', $DbRow2[ 'Id']))481 if(CheckPermission('Read', $DbRow2[$List['IdName']])) 475 482 $Group .= '<a href="?Action=ShowList&Table='.$DbRow2['Id'].'">'.$DbRow2['Title'].'</a><br />'; 476 483 } … … 485 492 function Output() 486 493 { 494 //print_r($_SESSION); 487 495 $PermanentVar = array('Table', 'Item', 'Column', 'ColumnValue', 'Action'); 488 496 if($_GET['Table'] != $_SESSION['Table']) … … 496 504 } 497 505 $Output = ''; 498 if(array_key_exists('Table', $_SESSION) )506 if(array_key_exists('Table', $_SESSION) and ($_SESSION['Table'] != '')) 499 507 { 500 508 $List = GetListDefinition($_SESSION['Table']); … … 561 569 'Id' => $DbRow['Id'], 562 570 'TableName' => $DbRow['TableName'], 571 'Database' => $DbRow['Database'], 563 572 'Title' => $DbRow['Title'], 573 'IdName' => $DbRow['IdName'], 564 574 'Items' => $Items, 565 575 ); … … 643 653 global $Database; 644 654 645 $DbResult = $Database->select( 'SystemList', '*');655 $DbResult = $Database->select(array('Table' => 'SystemList')); 646 656 while($DbRow = $DbResult->fetch_assoc()) 647 657 { -
database.php
r24 r30 2 2 3 3 // Extended database class 4 // Date: 2008-1 0-134 // Date: 2008-12-15 5 5 6 6 class Database extends mysqli … … 16 16 if(($this->ShowError == TRUE) and ($this->error != '')) 17 17 { 18 echo('<strong>Database error:</strong> '.$this->error.'<br /><strong>Query:</strong> '.$Query.'<br />'); 18 echo('<strong>Database error:</strong> '.$this->error.'<br />'); 19 echo('<strong>Query:</strong> '.$Query.'<br />'); 19 20 echo('<pre style="font-size: 9px">'); print_r(debug_backtrace()); echo('</pre>'); 20 21 } … … 22 23 } 23 24 24 function select($ Table, $What = '*', $Condition = 1)25 function select($Parameters) // Database, Table, Columns, Condition, Order 25 26 { 26 return($this->query("SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition)); 27 $Query = 'SELECT '; 28 if(array_key_exists('Columns', $Parameters)) $Query .= $Parameters['Columns']; else $Query .= '*'; 29 $Query .= ' FROM '; 30 if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.'; 31 $Query .= '`'.$this->Prefix.$Parameters['Table'].'`'; 32 if(array_key_exists('Condition', $Parameters)) $Query .= ' WHERE '.$Parameters['Condition']; 33 return($this->query($Query)); 27 34 } 28 35 29 function delete($ Table, $Condition)36 function delete($Parameters) 30 37 { 31 $this->query("DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition); 38 $Query = 'DELETE FROM '; 39 if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.'; 40 $Query .= '`'.$this->Prefix.$Parameters['Table'].'`'; 41 if(array_key_exists('Condition', $Parameters)) $Query .= ' WHERE '.$Parameters['Condition']; 42 $this->query($Query); 32 43 } 33 44 34 function insert($ Table, $Data)45 function insert($Parameters, $Data) 35 46 { 36 47 $Name = ''; … … 45 56 $Name = substr($Name, 1); 46 57 $Values = substr($Values, 1); 47 $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 58 $Query = 'INSERT INTO '; 59 if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.'; 60 $Query .= '`'.$this->Prefix.$Parameters['Table'].'`'; 61 $Query .= ' ('.$Name.') VALUES ('.$Values.')'; 62 $this->query($Query); 48 63 } 49 64 50 function update($ Table, $Condition, $Data)65 function update($Parameters, $Data) 51 66 { 52 67 $Values = ''; … … 58 73 } 59 74 $Values = substr($Values, 2); 60 $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'); 75 $Query = 'UPDATE '; 76 if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.'; 77 $Query .= '`'.$this->Prefix.$Parameters['Table'].'`'; 78 $Query .= ' SET '.$Values; 79 if(array_key_exists('Condition', $Parameters)) $Query .= ' WHERE '.$Parameters['Condition']; 80 $this->query($Query); 61 81 } 62 82 63 function replace($ Table, $Data)83 function replace($Parameters, $Data) 64 84 { 65 85 $Name = ''; … … 75 95 $Values = substr($Values, 1); 76 96 //echo('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES ('.$Values.')<br>'); 77 $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 97 $Query = 'REPLACE INTO '; 98 if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.'; 99 $Query .= '`'.$this->Prefix.$Parameters['Table'].'`'; 100 $Query .= ' ('.$Name.') VALUES ('.$Values.')'; 101 $this->query($Query); 78 102 } 79 103 -
database_list.php
r28 r30 7 7 function AddItem($TableId, $Values) 8 8 { 9 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId);9 $DbResult = $this->Database->query('SELECT `TableName`, `Database` FROM `SystemList` WHERE `Id`='.$TableId); 10 10 $DbRow = $DbResult->fetch_assoc(); 11 11 $TableName = $DbRow['TableName']; 12 12 13 $this->Database->insert( $TableName, $Values);13 $this->Database->insert(array('Table' => $TableName), $Values); 14 14 return($this->Database->insert_id); 15 15 } … … 17 17 function DeleteItem($TableId, $ItemId) 18 18 { 19 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId);19 $DbResult = $this->Database->query('SELECT `TableName`, `Database` FROM `SystemList` WHERE `Id`='.$TableId); 20 20 $DbRow = $DbResult->fetch_assoc(); 21 21 $TableName = $DbRow['TableName']; 22 $this->Database->delete( $TableName, 'Id='.$ItemId, array('DeletionTime' => 'NOW()'));22 $this->Database->delete(array('Table' => $TableName, 'Condition' => 'Id='.$ItemId), array('DeletionTime' => 'NOW()')); 23 23 } 24 24 25 25 function EditItem($TableId, $Values, $ItemId) 26 26 { 27 $DbResult = $this->Database->query('SELECT TableName FROM SystemList WHERE Id='.$TableId);27 $DbResult = $this->Database->query('SELECT `TableName`, `Database` FROM `SystemList` WHERE `Id`='.$TableId); 28 28 $DbRow = $DbResult->fetch_assoc(); 29 29 $TableName = $DbRow['TableName']; 30 30 $this->DeleteItem($TableId, $ItemId); 31 31 $Values['Id'] = $ItemId; 32 $this->Database->replace( $TableName, $Values);32 $this->Database->replace(array('Table' => $TableName), $Values); 33 33 } 34 34 } -
install/system_init.php
r29 r30 1 1 <?php 2 2 3 $SytemList = array(); 3 function TableStructure() 4 { 5 global $Database; 6 7 $Database->query('CREATE TABLE IF NOT EXISTS `SystemType` ( 8 `Id` int(11) NOT NULL auto_increment, 9 `Name` varchar(255) collate utf8_czech_ci NOT NULL, 10 `Description` varchar(255) collate utf8_czech_ci NOT NULL, 11 `ParentType` int(255) NOT NULL, 12 `Parameters` varchar(255) collate utf8_czech_ci NOT NULL, 13 `System` tinyint(1) NOT NULL default '0', 14 `DbDataType` varchar(255) collate utf8_czech_ci NOT NULL, 15 `ParameterList` int(11) NOT NULL, 16 PRIMARY KEY (`Id`) 17 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 18 $Database->query("INSERT INTO `SystemType` (`Id`, `Name`, `Description`, `ParentType`, `Parameters`, `System`, `DbDataType`, `ParameterList`) VALUES 19 (1, 'Integer', 'Číslo', 0, '', 1, 'INT', 0), 20 (2, 'Date', 'Datum', 0, '', 1, 'DATE', 0), 21 (3, 'String', 'Řetězec', 0, '', 1, 'VARCHAR(255)', 0), 22 (4, 'Boolean', 'Logická hodnota', 0, '', 1, 'BOOL', 0), 23 (5, 'Float', 'Desetinné číslo', 0, '', 1, 'FLOAT', 0), 24 (6, 'Enumeration', 'Výčet', 0, '', 0, 'INT', 0), 25 (7, 'PointerOneToOne', 'Ukazatel na jednu položku', 0, '', 1, 'INT', 0), 26 (8, 'PointerOneToMany', 'Ukazatel na více položek', 0, '', 1, 'INT', 0), 27 (9, 'Password', 'Heslo', 0, '', 1, 'INT', 0), 28 (10, 'Hyperlink', 'Internetový odkaz', 0, '', 0, 'VARCHAR(255)', 0), 29 (11, 'IPv4Address', 'IP adresa v4', 0, '', 0, 'VARCHAR(16)', 0), 30 (12, 'Hidden', 'Skrytá položka formuláře', 0, '', 1, 'VARCHAR(255)', 0), 31 (13, 'DateTime', 'Datum a čas', 0, '', 1, 'DATETIME', 0), 32 (14, 'File', 'Soubor', 0, '', 1, 'INT', 0), 33 (15, 'GPS', 'Zemská souřadnice', 0, '', 1, 'INT', 0), 34 (16, 'MySQLDataTypes', 'Databázový datový typ ', 14, 'INT|VARCHAR(255)|TEXT|FLOAT|DOUBLE|TIME|DATE|DATETIME|', 1, 'INT', 0), 4 35 36 (17, 'Sex', 'Pohlaví', 14, 'Muž|Žena', 0, 'INT', 0), 37 (18, 'PointerToSystemListItemList', '', 13, 'SystemListItem|List', 0, 'INT', 0), 38 (19, 'PointerToSystemList', '', 12, 'SystemList', 0, 'INT', 0), 39 (20, 'PointerToSystemType', '', 12, 'SystemType', 0, 'INT', 0), 40 (21, 'PointerToMenu', 'Ukazatel na menu', 12, 'SystemMenu', 0, 'INT', 0), 41 (22, 'PointerToSystemListMenu', 'Položky menu', 13, 'SystemList|Menu', 0, 'INT', 0), 42 (23, 'PointerToSystemTypeParameter', 'Ukazatel na seznam paramtrů', 13, 'SystemTypeParameter|ParentType', 0, 'INT', 0), 43 (24, 'PointerToSystemEnumerationState', 'Seznam stavů výčtu', 13, 'SystemEnumerationState|ParentType', 0, 'INT', 0);"); 44 45 $Database->query('CREATE TABLE IF NOT EXISTS `SystemEnumerationState` ( 46 `Id` int(11) NOT NULL auto_increment, 47 `Name` varchar(255) collate utf8_czech_ci NOT NULL, 48 `ParentParameter` int(11) NOT NULL, 49 PRIMARY KEY (`Id`) 50 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 51 $Database->query('CREATE TABLE IF NOT EXISTS `SystemFile` ( 52 `Id` int(11) NOT NULL auto_increment, 53 `Name` varchar(255) collate utf8_czech_ci NOT NULL, 54 `Size` int(11) NOT NULL, 55 PRIMARY KEY (`Id`) 56 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 57 $Database->query('CREATE TABLE IF NOT EXISTS `SystemGPS` ( 58 `Id` int(11) NOT NULL auto_increment, 59 `Longitude` double NOT NULL, 60 `Latitude` double NOT NULL, 61 PRIMARY KEY (`Id`) 62 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 63 $Database->query('CREATE TABLE IF NOT EXISTS `SystemList` ( 64 `Id` int(11) NOT NULL auto_increment, 65 `TableName` varchar(255) collate utf8_czech_ci NOT NULL, 66 `Title` varchar(255) collate utf8_czech_ci NOT NULL, 67 `Items` varchar(255) collate utf8_czech_ci NOT NULL, 68 `Menu` int(11) NOT NULL, 69 `Sequence` int(11) NOT NULL, 70 PRIMARY KEY (`Id`) 71 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 72 $Database->query('CREATE TABLE IF NOT EXISTS `SystemListItem` ( 73 `Id` int(11) NOT NULL auto_increment, 74 `Name` varchar(255) collate utf8_czech_ci NOT NULL, 75 `TextBefore` varchar(255) collate utf8_czech_ci NOT NULL, 76 `TextAfter` varchar(255) collate utf8_czech_ci NOT NULL, 77 `Type` varchar(255) collate utf8_czech_ci NOT NULL, 78 `Help` varchar(255) collate utf8_czech_ci NOT NULL, 79 `Default` varchar(255) collate utf8_czech_ci NOT NULL, 80 `Required` tinyint(1) NOT NULL default '1', 81 `Editable` tinyint(1) NOT NULL default '1', 82 `VisibleInList` tinyint(1) NOT NULL default '0', 83 `VisibleInPointer` tinyint(1) NOT NULL default '0', 84 `List` int(11) NOT NULL, 85 `Sequence` int(11) NOT NULL, 86 PRIMARY KEY (`Id`) 87 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 88 $Database->query('CREATE TABLE IF NOT EXISTS `SystemLog` ( 89 `Id` int(11) NOT NULL auto_increment, 90 `User` int(11) NOT NULL, 91 `List` int(11) NOT NULL, 92 `Item` int(11) NOT NULL, 93 `Action` int(11) NOT NULL, 94 PRIMARY KEY (`Id`) 95 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 96 $Database->query('CREATE TABLE IF NOT EXISTS `SystemMenu` ( 97 `Id` int(11) NOT NULL auto_increment, 98 `Name` varchar(255) collate utf8_czech_ci NOT NULL, 99 `SystemListItems` int(11) NOT NULL, 100 `Sequence` int(11) NOT NULL, 101 PRIMARY KEY (`Id`) 102 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 103 $Database->query('CREATE TABLE IF NOT EXISTS `SystemType` ( 104 `Id` int(11) NOT NULL auto_increment, 105 `Name` varchar(255) collate utf8_czech_ci NOT NULL, 106 `Description` varchar(255) collate utf8_czech_ci NOT NULL, 107 `ParentType` int(255) NOT NULL, 108 `Parameters` varchar(255) collate utf8_czech_ci NOT NULL, 109 `System` tinyint(1) NOT NULL default '0', 110 `DbDataType` varchar(255) collate utf8_czech_ci NOT NULL, 111 `ParameterList` int(11) NOT NULL, 112 PRIMARY KEY (`Id`) 113 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 114 $Database->query('CREATE TABLE IF NOT EXISTS `SystemTypeParameter` ( 115 `Id` int(11) NOT NULL auto_increment, 116 `Name` varchar(255) collate utf8_czech_ci NOT NULL, 117 `Type` int(11) NOT NULL, 118 `ParentType` int(11) NOT NULL, 119 `Description` varchar(255) collate utf8_czech_ci NOT NULL, 120 PRIMARY KEY (`Id`) 121 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci'); 122 $Database->query('CREATE TABLE IF NOT EXISTS `SystemTypeParameterValue` ( 123 `Id` int(11) NOT NULL auto_increment, 124 PRIMARY KEY (`Id`) 125 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 126 $Database->query('CREATE TABLE IF NOT EXISTS `User` ( 127 `Id` int(11) NOT NULL auto_increment, 128 `UserName` varchar(255) collate utf8_czech_ci NOT NULL, 129 `Password` varchar(255) collate utf8_czech_ci NOT NULL, 130 `FirstName` varchar(255) character set ucs2 collate ucs2_czech_ci NOT NULL, 131 `SecondName` varchar(255) character set ucs2 collate ucs2_czech_ci NOT NULL, 132 `Email` varchar(255) character set ucs2 collate ucs2_czech_ci NOT NULL, 133 `ICQ` int(11) NOT NULL, 134 `Sex` int(11) NOT NULL default '0', 135 `BirthDay` date NOT NULL, 136 `Phone` varchar(255) collate utf8_czech_ci NOT NULL, 137 `Member` int(11) NOT NULL, 138 `RegistrationTime` datetime NOT NULL, 139 `LastLoginTime` datetime NOT NULL, 140 `Locked` tinyint(1) NOT NULL, 141 `LastIpAddress` varchar(255) collate utf8_czech_ci NOT NULL, 142 `PermissionGroup` int(11) NOT NULL, 143 PRIMARY KEY (`Id`) 144 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci'); 145 $Database->query('CREATE TABLE IF NOT EXISTS `UserOnline` ( 146 `User` int(11) NOT NULL, 147 `LoginTime` datetime NOT NULL, 148 `ActivityTime` datetime NOT NULL, 149 `SessionId` varchar(255) collate utf8_czech_ci NOT NULL, 150 `IpAddress` varchar(16) collate utf8_czech_ci NOT NULL, 151 `HostName` varchar(255) collate utf8_czech_ci NOT NULL, 152 `Id` int(11) NOT NULL auto_increment, 153 PRIMARY KEY (`Id`), 154 KEY `User` (`User`) 155 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci'); 156 157 } 158 159 function LoadInitData() 160 { 161 162 } 5 163 6 164 ?> -
types/PointerOneToOne.php
r29 r30 23 23 { 24 24 //print_r($Type); 25 $DbResult = $Database->select( $List['TableName'], '*', 'Id='.$Item['Value']);25 $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $List['TableName'], 'Condition' => 'Id='.$Item['Value'])); 26 26 $DbRow = $DbResult->fetch_assoc(); 27 27 $DefinitionItem = array('Name' => $Index, 'Type' => $Item['Type'], 'Caption' => $Item['TextBefore'], 'Value' => $DbRow[$Index], 'SourceTable' => $List['Id'], 'SourceItemId' => 0); … … 34 34 if($Columns == '') $Columns = 'Id AS Name, Id'; 35 35 else $Columns = 'CONCAT('.$Columns.') AS Name, Id'; 36 $DbResult = $Database->select( $TargetTable, $Columns, 'Id='.$Item['Value']);36 $DbResult = $Database->select(array('Database' => $List['Database'], 'Table' => $TargetTable, 'Columns' => $Columns, 'Condition' => 'Id='.$Item['Value'])); 37 37 //echo($Database->LastQuery); 38 38 if($DbResult->num_rows > 0) -
user.php
r28 r30 41 41 $SID = session_id(); 42 42 // Lookup user record 43 $Query = $this->Database->select( $this->TableUserOnline, '*', '`SessionId`="'.$SID.'"');43 $Query = $this->Database->select(array('Table' => $this->TableUserOnline, 'Condition' => '`SessionId`="'.$SID.'"')); 44 44 if($Query->num_rows > 0) 45 45 { 46 46 // Refresh time of last access 47 $this->Database->update( $this->TableUserOnline, '`SessionId`="'.$SID.'"', array('ActivityTime' => 'NOW()'));48 } else $this->Database->insert( $this->TableUserOnline, array('SessionId' => $SID, 'User' => 0, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress())));47 $this->Database->update(array('Table' => $this->TableUserOnline, 'Condition' => '`SessionId`="'.$SID.'"'), array('ActivityTime' => 'NOW()')); 48 } else $this->Database->insert(array('Table' => $this->TableUserOnline), array('SessionId' => $SID, 'User' => 0, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress()))); 49 49 //echo($this->Database->LastQuery); 50 50 51 51 // Zkontroluj přihlášení 52 $Query = $this->Database->select( $this->TableUserOnline, '*', 'SessionId="'.$SID.'"');52 $Query = $this->Database->select(array('Table' => $this->TableUserOnline, 'Condition' => 'SessionId="'.$SID.'"')); 53 53 $Row = $Query->fetch_assoc(); 54 54 if($Row['User'] != 0) … … 60 60 } else 61 61 { 62 $Query = $this->Database->select( $this->TableUser, '*', "`Id`=0");62 $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => "`Id`=0")); 63 63 $this->User = $Query->fetch_assoc(); 64 64 $Result = USER_NOT_LOGGED; … … 66 66 67 67 // Odeber neaktivní uživatele 68 $DbResult = $this->Database->select( $this->TableUserOnline, 'User', '`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.USER_TIMEOUT.' SECOND)');68 $DbResult = $this->Database->select(array('Table' => $this->TableUserOnline, 'Columns' => 'User', 'Condition' => '`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.USER_TIMEOUT.' SECOND)')); 69 69 while($DbRow = $DbResult->fetch_assoc()) 70 70 { 71 $this->Database->delete( $this->TableUserOnline, '`User`='.$DbRow['User']);71 $this->Database->delete(array('Table' => $this->TableUserOnline, 'Condition' => '`User`='.$DbRow['User'])); 72 72 //$this->System->Modules['Log']->Add('User', 'Logout'); 73 73 } … … 87 87 { 88 88 // Je uživatel registrován? 89 $Query = $this->Database->select( $this->TableUser, '*', 'Name = "'.$Nick.'"');89 $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => 'Name = "'.$Nick.'"')); 90 90 if($Query->num_rows > 0) $Result = NICK_USED; 91 91 else 92 92 { 93 $Query = $this->Database->select( $this->TableUser, '*', 'Email = "'.$Email.'"');93 $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => 'Email = "'.$Email.'"')); 94 94 if($Query->num_rows > 0) $Result = EMAIL_USED; 95 95 else 96 96 { 97 $this->Database->insert( $this->TableUser, array('Name' => $Nick, 'FirstName' => $FirstName, 'SecondName' => $SecondName, 'Password' => $Password, 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1));97 $this->Database->insert(array('Table' => $this->TableUser), array('Name' => $Nick, 'FirstName' => $FirstName, 'SecondName' => $SecondName, 'Password' => $Password, 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1)); 98 98 $UserId = $this->Database->insert_id; 99 99 … … 112 112 function RegisterConfirm($Id, $Hash) 113 113 { 114 $DbResult = $this->Database->select( $this->TableUser, 'Id, Name, Password', 'Id = '.$Id);114 $DbResult = $this->Database->select(array('Table' => $this->TableUser, 'Columns' => 'Id, Name, Password', 'Condition' => 'Id = '.$Id)); 115 115 if($DbResult->num_rows > 0) 116 116 { … … 118 118 if($Hash == $Row['Password']) 119 119 { 120 $this->Database->update( $this->TableUser, 'Id='.$Row['Id'], array('Locked' => 0));120 $this->Database->update(array('Table' => $this->TableUser, 'Condition' => 'Id='.$Row['Id']), array('Locked' => 0)); 121 121 $Output = USER_REGISTRATION_CONFIRMED; 122 122 //$this->System->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'UserName='.$Row['Name']); … … 130 130 $SID = session_id(); 131 131 // Je uživatel registrován? 132 $Query = $this->Database->select( $this->TableUser, '*', 'UserName="'.$Nick.'"');132 $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => 'UserName="'.$Nick.'"')); 133 133 if($Query->num_rows > 0) 134 134 { … … 138 138 else 139 139 { 140 $this->Database->update( $this->TableUser, 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()'));141 $this->Database->update( $this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => $Row['Id'], 'Id' => $Row['mId']));140 $this->Database->update(array('Table' => $this->TableUser, 'Condition' => 'Id='.$Row['Id']), array('LastLoginTime' => 'NOW()')); 141 $this->Database->update(array('Table' => $this->TableUserOnline, 'Condition' => 'SessionId="'.$SID.'"'), array('User' => $Row['Id'], 'Id' => $Row['mId'])); 142 142 // načtení stavu stromu 143 143 $Result = USER_LOGGED_IN; … … 154 154 155 155 $SID = session_id(); 156 $this->Database->update( $this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => 0));156 $this->Database->update(array('Table' => $this->TableUserOnline, 'Condition' => 'SessionId="'.$SID.'"'), array('User' => 0)); 157 157 //$this->System->Modules['Log']->NewRecord('User', 'Logout', $this->User['Name']); 158 158 $this->Check(); … … 164 164 global $Config; 165 165 166 $DbResult = $this->Database->select( $this->TableUser, 'Name, Id, Email, Password', '`Name`="'.$Name.'" AND `Email`="'.$Email.'"');166 $DbResult = $this->Database->select(array('Table' => $this->TableUser, 'Columns' => 'Name, Id, Email, Password', 'Condition' => '`Name`="'.$Name.'" AND `Email`="'.$Email.'"')); 167 167 if($DbResult->num_rows > 0) 168 168 { … … 182 182 function PasswordRecoveryConfirm($Id, $Hash, $NewPassword) 183 183 { 184 $DbResult = $this->Database->select( $this->TableUser, 'Id, Name, Password', 'Id = '.$Id);184 $DbResult = $this->Database->select(array('Table' => $this->TableUser, 'Columns' => 'Id, Name, Password', 'Condition' => 'Id = '.$Id)); 185 185 if($DbResult->num_rows > 0) 186 186 { … … 189 189 if(($NewPassword == $NewPassword2) and ($Hash == $Row['Password'])) 190 190 { 191 $this->Database->update( $this->TableUser, 'Id='.$Row['Id'], array('Password' => $NewPassword, 'Locked' => 0));191 $this->Database->update(array('Table' => $this->TableUser, 'Condition' => 'Id='.$Row['Id']), array('Password' => $NewPassword, 'Locked' => 0)); 192 192 $Output = USER_PASSWORD_RECOVERY_CONFIRMED; 193 193 //$this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'UserName='.$Row['Name']);
Note:
See TracChangeset
for help on using the changeset viewer.