Changeset 873 for trunk/Modules
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- Location:
- trunk/Modules
- Files:
-
- 105 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/API/API.php
r804 r873 47 47 { 48 48 // p - token 49 if (array_key_exists('p', $_GET)) {49 if (array_key_exists('p', $_GET)) { 50 50 $Token = $_GET['p']; 51 51 $DbResult = $this->Database->query('SELECT `User` FROM `APIToken` WHERE `Token`="'.$Token.'"'); 52 if ($DbResult->num_rows > 0)52 if ($DbResult->num_rows > 0) 53 53 { 54 54 $DbRow = $DbResult->fetch_assoc(); … … 57 57 } else die('Missing access token'); 58 58 // f - data format 59 if (array_key_exists('f', $_GET)) $this->DataFormat = $_GET['f'];59 if (array_key_exists('f', $_GET)) $this->DataFormat = $_GET['f']; 60 60 else $this->DataFormat = 'php'; 61 61 // a - action 62 if (array_key_exists('a', $_GET)) $Action = $_GET['a'];62 if (array_key_exists('a', $_GET)) $Action = $_GET['a']; 63 63 else $Action = ''; 64 64 // t - table 65 if (array_key_exists('t', $_GET)) $Table = $_GET['t'];65 if (array_key_exists('t', $_GET)) $Table = $_GET['t']; 66 66 else $Table = ''; 67 67 // i - index of item 68 if (array_key_exists('i', $_GET)) $ItemId = $_GET['i'];68 if (array_key_exists('i', $_GET)) $ItemId = $_GET['i']; 69 69 else $ItemId = 0; 70 70 71 if ($Action == 'list') $Output = $this->ShowList($Table, $ItemId);71 if ($Action == 'list') $Output = $this->ShowList($Table, $ItemId); 72 72 else $Output = 'Unsupported action'; 73 73 74 return ($Output);74 return ($Output); 75 75 } 76 76 77 77 function ShowList($Table, $ItemId) 78 78 { 79 if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))79 if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes))) 80 80 $FormClass = $this->System->FormManager->Classes[$Table]; 81 else return ('Table not found');81 else return ('Table not found'); 82 82 83 if (array_key_exists('SQL', $FormClass))83 if (array_key_exists('SQL', $FormClass)) 84 84 $SourceTable = '('.$FormClass['SQL'].') AS `TX`'; 85 85 else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`'; 86 86 87 87 $Filter = ''; 88 if ($ItemId != 0)88 if ($ItemId != 0) 89 89 { 90 90 $Filter .= '`Id`='.$ItemId; 91 91 } 92 if ($Filter != '') $Filter = ' WHERE '.$Filter;92 if ($Filter != '') $Filter = ' WHERE '.$Filter; 93 93 94 94 $Result = array(); 95 95 $DbResult = $this->Database->query('SELECT * FROM '.$SourceTable.$Filter); 96 while ($DbRow = $DbResult->fetch_assoc())96 while ($DbRow = $DbResult->fetch_assoc()) 97 97 { 98 98 $Result[] = $DbRow; 99 99 } 100 if ($this->DataFormat == 'php') $Output = serialize($Result);101 else if ($this->DataFormat == 'xml') $Output = $this->array2xml($Result);102 else if ($this->DataFormat == 'json') $Output = json_encode($Result);100 if ($this->DataFormat == 'php') $Output = serialize($Result); 101 else if ($this->DataFormat == 'xml') $Output = $this->array2xml($Result); 102 else if ($this->DataFormat == 'json') $Output = json_encode($Result); 103 103 else die('Unknown data format '.$this->DataFormat); 104 return ($Output);104 return ($Output); 105 105 } 106 106 … … 114 114 $array2xml = function ($node, $array) use ($dom, &$array2xml) 115 115 { 116 foreach ($array as $key => $value)116 foreach ($array as $key => $value) 117 117 { 118 118 if ( is_array($value) ) 119 119 { 120 if (is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric');120 if (is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric'); 121 121 $n = $dom->createElement($key); 122 122 $node->appendChild($n); 123 123 $array2xml($n, $value); 124 124 } else { 125 if (is_numeric($key)) $key = 'N'.$key; //die('XML attribute name "'.$key.'" can\'t be numeric');125 if (is_numeric($key)) $key = 'N'.$key; //die('XML attribute name "'.$key.'" can\'t be numeric'); 126 126 $attr = $dom->createAttribute($key); 127 127 $attr->value = $value; -
trunk/Modules/Chat/Chat.php
r790 r873 14 14 { 15 15 $Num = dechex($Num); 16 return (substr($Num, 4, 2).substr($Num, 2, 2).substr($Num, 0, 2));16 return (substr($Num, 4, 2).substr($Num, 2, 2).substr($Num, 0, 2)); 17 17 } 18 18 … … 21 21 global $MonthNames; 22 22 23 if (!$this->System->User->CheckPermission('Chat', 'Display')) return('Nemáte oprávnění');23 if (!$this->System->User->CheckPermission('Chat', 'Display')) return ('Nemáte oprávnění'); 24 24 25 if (array_key_exists('date', $_GET)) $Date = $_GET['date'];25 if (array_key_exists('date', $_GET)) $Date = $_GET['date']; 26 26 else $Date = date('Y-m-d'); 27 27 $DateParts = explode('-', $Date); … … 35 35 $EndDateParts = explode('-', $EndDateTimeParts[0]); 36 36 37 if (!array_key_exists('year', $_SESSION)) $_SESSION['year'] = date('Y', time());38 if (array_key_exists('year', $_GET)) $_SESSION['year'] = addslashes($_GET['year']);37 if (!array_key_exists('year', $_SESSION)) $_SESSION['year'] = date('Y', time()); 38 if (array_key_exists('year', $_GET)) $_SESSION['year'] = addslashes($_GET['year']); 39 39 40 if (!array_key_exists('month', $_SESSION)) $_SESSION['month'] = date('n', time());41 if (array_key_exists('month', $_GET)) $_SESSION['month'] = addslashes($_GET['month']);40 if (!array_key_exists('month', $_SESSION)) $_SESSION['month'] = date('n', time()); 41 if (array_key_exists('month', $_GET)) $_SESSION['month'] = addslashes($_GET['month']); 42 42 43 43 $Output = '<div class="ChatHistory">'; 44 for ($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--)44 for ($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--) 45 45 { 46 if ($_SESSION['year'] == $Year)46 if ($_SESSION['year'] == $Year) 47 47 { 48 48 $Output .= '<div class="Year">'.$Year.'<div class="YearContent">'; 49 if ($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1] + 0); else $StartMonth = 1;50 if ($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1] + 0); else $EndMonth = 12;51 for ($Month = $EndMonth; $Month >= $StartMonth; $Month--)49 if ($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1] + 0); else $StartMonth = 1; 50 if ($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1] + 0); else $EndMonth = 12; 51 for ($Month = $EndMonth; $Month >= $StartMonth; $Month--) 52 52 { 53 if ($_SESSION['month'] == $Month)53 if ($_SESSION['month'] == $Month) 54 54 { 55 55 $Output .= '<div class="Months">'.$MonthNames[$Month].'<span>'; 56 if (($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1;57 if (($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year));58 for ($Day = $StartDay; $Day <= $EndDay; $Day++)56 if (($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1; 57 if (($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year)); 58 for ($Day = $StartDay; $Day <= $EndDay; $Day++) 59 59 { 60 60 $Text = '<a href="?date='.$Year.'-'.$Month.'-'.$Day.'">'.$Day.'</a> '; 61 if (($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong>'.$Text.'</strong>';61 if (($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong>'.$Text.'</strong>'; 62 62 $Output .= $Text; 63 63 } … … 72 72 $DbResult = $this->Database->select('ChatHistory', 'Nick, Color, Text, UNIX_TIMESTAMP(Time)', "RoomType = 0 AND Time > '".$Date." 00:00:00' AND Time < '".$Date." 23:59:59' ORDER BY Time DESC"); 73 73 $Output .= '<div class="ChatHistoryText">'; 74 if ($DbResult->num_rows > 0)75 while ($Row = $DbResult->fetch_array())74 if ($DbResult->num_rows > 0) 75 while ($Row = $DbResult->fetch_array()) 76 76 { 77 77 $Text = $Row['Text'];; … … 81 81 else $Output .= 'V daném dni nebyly zaznamenány žádné zprávy.'; 82 82 $Output .= '</div>'; 83 return ($Output);83 return ($Output); 84 84 } 85 85 } -
trunk/Modules/Chat/irc_bot.php
r738 r873 30 30 function Say($Message, $Recipient = '') 31 31 { 32 if ($Recipient == '') $Recipient = $this->Channel;32 if ($Recipient == '') $Recipient = $this->Channel; 33 33 $this->Command(': PRIVMSG '.$Recipient.' :'.$Message); 34 34 } … … 43 43 global $Database; 44 44 45 while (!fwrite($this->File, ''))45 while (!fwrite($this->File, '')) 46 46 { 47 47 $this->Command('JOIN '.$this->Channel); … … 51 51 52 52 $LineParts = explode(' ', $Line); 53 if (count($LineParts) > 0)53 if (count($LineParts) > 0) 54 54 { 55 if ($LineParts[0] == 'PING')55 if ($LineParts[0] == 'PING') 56 56 { 57 57 $this->Command('PONG '.trim($LineParts[1])."\n"); … … 59 59 } 60 60 61 if (count($LineParts) > 1)62 { 63 if ((trim($LineParts[1]) == 'INVITE') && (substr(trim($LineParts[3]), 0, 2) == ':#'))61 if (count($LineParts) > 1) 62 { 63 if ((trim($LineParts[1]) == 'INVITE') && (substr(trim($LineParts[3]), 0, 2) == ':#')) 64 64 { 65 65 $CurrentChannel = substr(trim($LineParts[3]), 1); … … 78 78 79 79 // Log messages to database 80 if (strpos($Line, 'PRIVMSG') !== false)80 if (strpos($Line, 'PRIVMSG') !== false) 81 81 { 82 82 $Text = addslashes($Commands[2]); … … 91 91 92 92 explode(':', $Line); 93 foreach ($Commands as $Index => $Item)93 foreach ($Commands as $Index => $Item) 94 94 $Commands[$Index] = trim($Item); 95 95 96 if (count($Commands) >= 2)96 if (count($Commands) >= 2) 97 97 { 98 98 $Command = $Commands[2]; 99 99 100 100 // Jméno - Pošle vizitku 101 if ($Command == $this->Nick)101 if ($Command == $this->Nick) 102 102 { 103 103 $this->Say('Ahoj lidi, ja jsem '.$this->OwnerName.' bot. Random#: '.rand(0, 10)); … … 106 106 107 107 // hhelp - vypise tuto napovedu 108 if ($Command == 'hhelp')108 if ($Command == 'hhelp') 109 109 { 110 110 $this->Say('Ja jsem Harvester.'); … … 124 124 125 125 // hsay:Message - Posle zpravu 126 if ($Command == 'hsay')126 if ($Command == 'hsay') 127 127 { 128 128 $this->Say($Commands[3]); … … 131 131 132 132 // hpsay:to:Message - Posle soukromou zpravu kanalu nebo osobe 133 if ($Command == 'hpsay')133 if ($Command == 'hpsay') 134 134 { 135 135 $this->Say($Commands[4], $Commands[3]); … … 138 138 139 139 // hcol:to:Message - Posle kolizni zpravu kanalu nebo osobe 140 if ($Command == 'hcol')140 if ($Command == 'hcol') 141 141 { 142 142 $this->Say($Commands[4], $Commands[3]); … … 145 145 146 146 // hdo:Command - Posle serveru prikaz 147 if ($Command == 'hdo')147 if ($Command == 'hdo') 148 148 { 149 149 $hdo = explode('hdo:', $Line); … … 153 153 154 154 // hpart:Channel - Odpoji se z kanalu 155 if ($Command == 'hpart')155 if ($Command == 'hpart') 156 156 { 157 157 $hdo = explode('hpart:', $Line); 158 if (trim($hdo[1]) != trim($this->Channel))158 if (trim($hdo[1]) != trim($this->Channel)) 159 159 { 160 160 $this->Command('PART :'.trim($hdo[1])."\n"); … … 164 164 165 165 // hmove:Channel - Zmeni aktivni kanal 166 if ($Command == 'hmove')166 if ($Command == 'hmove') 167 167 { 168 168 $hdo = explode("hmove:", $Line); 169 if (trim($hdo[1]) != trim($$this->Cannel))169 if (trim($hdo[1]) != trim($$this->Cannel)) 170 170 { 171 171 $this->Channel = trim($hdo[1]); … … 177 177 178 178 // htime - udaje o casu 179 if ($Command == 'htime')179 if ($Command == 'htime') 180 180 { 181 181 $Date = implode("-", getdate(time())); … … 185 185 186 186 // hjoke - Posle nahodny vtip 187 if ($Command == 'hjoke')187 if ($Command == 'hjoke') 188 188 { 189 189 $Joke = ($this->Jokes[rand(0, (sizeof($this->Jokes) - 1))]); -
trunk/Modules/Customer/Customer.php
r871 r873 201 201 $Output .= ' platících:'.$DbRow['0'].'<br/>'; 202 202 203 return ($Output);203 return ($Output); 204 204 } 205 205 -
trunk/Modules/EmailQueue/EmailQueue.php
r738 r873 11 11 $Output = $this->System->ModuleManager->Modules['EmailQueue']->Process(); 12 12 $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány').$Output; 13 return ($Output);13 return ($Output); 14 14 } 15 15 } … … 79 79 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 80 80 'From' => $From); 81 if ($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId;81 if ($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId; 82 82 $this->Database->insert('EmailQueue', $Values); 83 83 } … … 87 87 $Output = ''; 88 88 $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0'); 89 while ($DbRow = $DbResult->fetch_assoc())89 while ($DbRow = $DbResult->fetch_assoc()) 90 90 { 91 91 $Mail = new Mail(); … … 95 95 $Mail->AddBody(strip_tags($DbRow['Content']), 'text/plain'); 96 96 $Mail->AddBody($DbRow['Content'], 'text/html'); 97 if ($DbRow['AttachmentFile'] != '')97 if ($DbRow['AttachmentFile'] != '') 98 98 { 99 99 $DbResult2 = $this->Database->select('File', '*', 'Id='.$DbRow['AttachmentFile']); 100 while ($File = $DbResult2->fetch_assoc())100 while ($File = $DbResult2->fetch_assoc()) 101 101 $Mail->AttachFile($this->Config['Web']['FileRootFolder'].$File['DrivePath'], $File['MimeType']); 102 102 } … … 106 106 $Output .= 'To: '.$DbRow['To'].' Subject: '.$DbRow['Subject'].'<br />'; 107 107 } 108 return ($Output);108 return ($Output); 109 109 } 110 110 } -
trunk/Modules/Error/Error.php
r784 r873 45 45 $this->System->ModuleManager->Modules['Log']->NewRecord('Error', 'Log', $Error); 46 46 47 //if ($Config['Web']['ErrorLogFile'] != '')47 //if ($Config['Web']['ErrorLogFile'] != '') 48 48 // error_log($Error, 3, $Config['Web']['ErrorLogFile']); 49 49 // Pošli mi zprávu (pokud je to kritická chyba) 50 50 //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error); 51 51 // Show error message 52 if ($this->ErrorHandler->ShowError == true)52 if ($this->ErrorHandler->ShowError == true) 53 53 { 54 if (array_key_exists('REMOTE_ADDR', $_SERVER))54 if (array_key_exists('REMOTE_ADDR', $_SERVER)) 55 55 { 56 56 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n". -
trunk/Modules/File/File.php
r738 r873 16 16 { 17 17 $DbResult = $this->Database->select('File', 'Name', 'Id='.$Id); 18 if ($DbResult->num_rows > 0)18 if ($DbResult->num_rows > 0) 19 19 { 20 20 $DbRow = $DbResult->fetch_assoc(); … … 28 28 // Submited form with file input have to be enctype="multipart/form-data" 29 29 $Result = 0; 30 if (array_key_exists($Name, $_FILES) and ($_FILES[$Name]['name'] != ''))30 if (array_key_exists($Name, $_FILES) and ($_FILES[$Name]['name'] != '')) 31 31 { 32 if (file_exists($_FILES[$Name]['tmp_name']))32 if (file_exists($_FILES[$Name]['tmp_name'])) 33 33 { 34 34 $FileName = substr($_FILES[$Name]['name'], strrpos($_FILES[$Name]['name'], '/')); 35 35 $this->Database->query('INSERT INTO File (`Name`, `Size`) VALUES ("'.$FileName.'", '.filesize($_FILES[$Name]['tmp_name']).')'); 36 36 $InsertId = $this->Database->insert_id; 37 if (move_uploaded_file($_FILES[$Name]['tmp_name'], $this->FilesDir.'/'.$InsertId.'_'.$FileName)) $Result = $InsertId;37 if (move_uploaded_file($_FILES[$Name]['tmp_name'], $this->FilesDir.'/'.$InsertId.'_'.$FileName)) $Result = $InsertId; 38 38 } 39 39 } 40 return ($Result);40 return ($Result); 41 41 } 42 42 … … 46 46 47 47 $Result = $MimeTypes[pathinfo($FileName, PATHINFO_EXTENSION)][0]; 48 return ($Result);48 return ($Result); 49 49 } 50 50 … … 52 52 { 53 53 $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id)); 54 if ($DbResult->num_rows > 0)54 if ($DbResult->num_rows > 0) 55 55 { 56 56 $DbRow = $DbResult->fetch_assoc(); 57 if ($DbRow['Directory'] != '') $FileName = $this->GetDir($DbRow['Directory']);57 if ($DbRow['Directory'] != '') $FileName = $this->GetDir($DbRow['Directory']); 58 58 else $FileName = $this->FilesDir; 59 59 $FileName .= $DbRow['Name']; 60 if (file_exists($FileName))60 if (file_exists($FileName)) 61 61 { 62 62 Header('Content-Type: '.$this->DetectMimeType($FileName)); … … 71 71 $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$Id); 72 72 $DbRow = $DbResult->fetch_assoc(); 73 if ($DbRow['Parent'] != '') $Result = $this->GetDir($DbRow['Parent']);73 if ($DbRow['Parent'] != '') $Result = $this->GetDir($DbRow['Parent']); 74 74 else $Result = $this->FilesDir; 75 75 $Result .= $DbRow['Name'].'/'; 76 return ($Result);76 return ($Result); 77 77 } 78 78 } … … 83 83 function Show() 84 84 { 85 if (array_key_exists('id', $_GET)) $Id = $_GET['id'];86 else if (array_key_exists('i', $_GET)) $Id = $_GET['i'];87 else return ($this->SystemMessage('Chyba', 'Nezadáno id souboru'));85 if (array_key_exists('id', $_GET)) $Id = $_GET['id']; 86 else if (array_key_exists('i', $_GET)) $Id = $_GET['i']; 87 else return ($this->SystemMessage('Chyba', 'Nezadáno id souboru')); 88 88 $this->ClearPage = true; 89 89 $Output = $this->System->Modules['File']->Download($Id); 90 return ($Output);90 return ($Output); 91 91 } 92 92 } -
trunk/Modules/Finance/Bill.php
r748 r873 8 8 function GenerateHTML() 9 9 { 10 return ('');10 return (''); 11 11 } 12 12 … … 22 22 { 23 23 $Encoding = new Encoding(); 24 if ($this->Checked == false) {25 if (CommandExist('htmldoc')) {24 if ($this->Checked == false) { 25 if (CommandExist('htmldoc')) { 26 26 $this->Checked = true; 27 27 } else throw new Exception('htmldoc is not installed.'); … … 29 29 $Output = shell_exec('echo "'.addslashes($Encoding->FromUTF8($HtmlCode)). 30 30 '"|htmldoc --no-numbered --webpage --no-embedfonts --charset 8859-2 -t pdf -'); 31 return ($Output);31 return ($Output); 32 32 } 33 33 } … … 43 43 $Subject['AddressStreet'].'<br>'. 44 44 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; 45 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';46 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';47 if ($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>';48 if ($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>';49 return ($Output);45 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>'; 46 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>'; 47 if ($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>'; 48 if ($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>'; 49 return ($Output); 50 50 } 51 51 … … 78 78 $InvoiceItems = array(); 79 79 $DbResult = $this->Database->select('FinanceInvoiceItem', '*, ROUND(`Price` * `Quantity`, '.$Finance->Rounding.') AS `Total`', '`FinanceInvoice`='.$this->InvoiceId); 80 while ($Item = $DbResult->fetch_assoc())80 while ($Item = $DbResult->fetch_assoc()) 81 81 { 82 82 $InvoiceItems[$Item['Id']] = $Item; … … 84 84 85 85 // If direction is in => switch sides 86 if ($Invoice['Direction'] == FINANCE_DIRECTION_OUT)87 { 88 } 89 else if ($Invoice['Direction'] == FINANCE_DIRECTION_IN)86 if ($Invoice['Direction'] == FINANCE_DIRECTION_OUT) 87 { 88 } 89 else if ($Invoice['Direction'] == FINANCE_DIRECTION_IN) 90 90 { 91 91 $Subject = $SubjectTo; … … 121 121 'Datum zdanitel. plnění: '.HumanDate($Invoice['Time']).'<br>'. 122 122 'Datum splatnosti: '.HumanDate($Invoice['TimeDue']).'<br>'; 123 if (($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != ''))123 if (($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != '')) 124 124 $Output .= 'Fakturované období: '.HumanDate($Invoice['PeriodFrom']).' - '. 125 125 HumanDate($Invoice['PeriodTo']).'<br>'; … … 133 133 134 134 $Total = 0; 135 foreach ($InvoiceItems as $Item)135 foreach ($InvoiceItems as $Item) 136 136 { 137 137 $Output .= '<tr><td>'.$Item['Description'].'</td><td align="right">'. … … 146 146 '</table>'; 147 147 148 return ($Output);148 return ($Output); 149 149 } 150 150 } … … 174 174 175 175 $BooleanText = array('Ne', 'Ano'); 176 if ($Operation['Direction'] == FINANCE_DIRECTION_OUT)176 if ($Operation['Direction'] == FINANCE_DIRECTION_OUT) 177 177 $Desc = array( 178 178 'Type' => 'VÝDAJOVÝ', … … 180 180 'Target' => 'Vydáno komu', 181 181 ); 182 else if ($Operation['Direction'] == FINANCE_DIRECTION_IN)182 else if ($Operation['Direction'] == FINANCE_DIRECTION_IN) 183 183 $Desc = array( 184 184 'Type' => 'PŘÍJMOVÝ', … … 206 206 $Subject['AddressStreet'].'<br>'. 207 207 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; 208 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';209 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';208 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>'; 209 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>'; 210 210 $Description = $Operation['Text']; 211 211 $Output .= '</td></tr>'. … … 215 215 '<tr><td> </td><td><br><br>'.$Desc['Signature'].':</td></tr>'; 216 216 $Output .= '</table>'; 217 return ($Output);217 return ($Output); 218 218 } 219 219 } -
trunk/Modules/Finance/Finance.php
r866 r873 44 44 { 45 45 $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`'); 46 while ($BillingPeriod = $DbResult->fetch_assoc())46 while ($BillingPeriod = $DbResult->fetch_assoc()) 47 47 $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod; 48 48 … … 80 80 function W2Kc($Spotreba) 81 81 { 82 return (round($Spotreba * 0.72 * $this->kWh));82 return (round($Spotreba * 0.72 * $this->kWh)); 83 83 } 84 84 … … 93 93 // Create DocumentLineSequence from previous 94 94 $DbResult = $this->Database->select('DocumentLine', 'Id', '`Yearly` = 1'); 95 while ($DbRow = $DbResult->fetch_assoc())95 while ($DbRow = $DbResult->fetch_assoc()) 96 96 { 97 97 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId, … … 102 102 function GetFinanceYear($Year) 103 103 { 104 if ($Year == 0)104 if ($Year == 0) 105 105 { 106 106 // Get latest year 107 107 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1'); 108 108 } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 109 if ($DbResult->num_rows == 0) {110 if ($Year == date('Y'))109 if ($DbResult->num_rows == 0) { 110 if ($Year == date('Y')) 111 111 { 112 112 $this->CreateFinanceYear($Year); … … 115 115 } 116 116 $FinanceYear = $DbResult->fetch_assoc(); 117 if ($FinanceYear['Closed'] == 1)117 if ($FinanceYear['Closed'] == 1) 118 118 throw new Exception('Rok '.$FinanceYear['Year'].' je již uzavřen. Nelze do něj přidávat položky.'); 119 119 return $FinanceYear; … … 131 131 $Sequence = $DbResult->fetch_assoc(); 132 132 133 if ($Sequence['YearPrefix'] == 1)133 if ($Sequence['YearPrefix'] == 1) 134 134 { 135 135 $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year']; … … 138 138 $this->Database->query('UPDATE `DocumentLineSequence` SET `NextNumber` = `NextNumber` + 1 '. 139 139 'WHERE (`DocumentLine`='.$Id.') AND (`FinanceYear`='.$FinanceYear['Id'].')'); 140 return ($Result);140 return ($Result); 141 141 } 142 142 … … 151 151 { 152 152 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id); 153 if ($DbResult->num_rows == 1) {153 if ($DbResult->num_rows == 1) { 154 154 $Group = $DbResult->fetch_assoc(); 155 return ($Group);155 return ($Group); 156 156 } else die('Finance group id '.$Id.' not found in table '.$Table); 157 157 } … … 162 162 $this->Database->query('TRUNCATE TABLE `MemberPayment`'); 163 163 $DbResult = $this->Database->query('SELECT * FROM `Member`'); 164 while ($Member = $DbResult->fetch_assoc())164 while ($Member = $DbResult->fetch_assoc()) 165 165 { 166 166 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(`Value`), 0) FROM `FinanceOperation` '. … … 182 182 $DbRow = $DbResult2->fetch_assoc(); 183 183 $Monthly = 0; 184 if ($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price'];184 if ($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price']; 185 185 else $MonthlyInet = 0; 186 186 … … 189 189 $Monthly = round($Monthly); 190 190 191 if ($Member['BillingPeriod'] == 1)191 if ($Member['BillingPeriod'] == 1) 192 192 { 193 193 // Inactive payer … … 204 204 } 205 205 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment'); 206 return ($Output);206 return ($Output); 207 207 } 208 208 … … 214 214 TimeToMysqlDate($Time).'") OR (ValidTo IS NULL)) LIMIT 1'); 215 215 $Row = $DbResult->fetch_array(); 216 return ($Row[0]);216 return ($Row[0]); 217 217 } 218 218 } … … 665 665 function BeforeInsertFinanceOperation($Form) 666 666 { 667 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);667 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 668 668 else $Year = date("Y", $Form->Values['ValidFrom']); 669 669 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 670 670 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 671 return ($Form->Values);671 return ($Form->Values); 672 672 } 673 673 … … 677 677 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 678 678 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 679 return ($Form->Values);679 return ($Form->Values); 680 680 } 681 681 … … 685 685 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 686 686 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 687 return ($Form->Values);687 return ($Form->Values); 688 688 } 689 689 … … 691 691 { 692 692 // Get new DocumentLineCode by selected invoice Group 693 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);693 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 694 694 else $Year = date("Y", $Form->Values['ValidFrom']); 695 695 $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 696 696 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 697 return ($Form->Values);697 return ($Form->Values); 698 698 } 699 699 … … 707 707 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 708 708 ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 709 return ($Form->Values);709 return ($Form->Values); 710 710 } 711 711 … … 718 718 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 719 719 ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 720 return ($Form->Values);720 return ($Form->Values); 721 721 } 722 722 … … 727 727 $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']); 728 728 $this->AfterInsertFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']); 729 return ($Form->Values);729 return ($Form->Values); 730 730 } 731 731 … … 736 736 $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']); 737 737 $this->BeforeModifyFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']); 738 return ($Form->Values);738 return ($Form->Values); 739 739 } 740 740 741 741 function BeforeInsertContract($Form) 742 742 { 743 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);743 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 744 744 else $Year = date("Y", $Form->Values['ValidFrom']); 745 745 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year); 746 return ($Form->Values);746 return ($Form->Values); 747 747 } 748 748 } -
trunk/Modules/Finance/Import.php
r812 r873 9 9 function Show() 10 10 { 11 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');12 if (array_key_exists('Operation', $_GET))11 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return ('Nemáte oprávnění'); 12 if (array_key_exists('Operation', $_GET)) 13 13 { 14 if ($_GET['Operation'] == 'prepare') return($this->Prepare());15 else if ($_GET['Operation'] == 'insert') return($this->Insert());14 if ($_GET['Operation'] == 'prepare') return ($this->Prepare()); 15 else if ($_GET['Operation'] == 'insert') return ($this->Insert()); 16 16 else echo('Neplatná akce'); 17 17 } else … … 22 22 $Output .= '<input type="submit" value="Analyzovat"/>'; 23 23 $Output .= '</form>'; 24 return ($Output);24 return ($Output); 25 25 } 26 26 } … … 31 31 $Finance->LoadMonthParameters(0); 32 32 $Data = explode("\n", $_POST['Source']); 33 foreach ($Data as $Key => $Value)33 foreach ($Data as $Key => $Value) 34 34 { 35 35 $Value = str_replace('\"', '"', $Value); 36 36 $Data[$Key] = str_getcsv($Value, ',', '"', "\\"); 37 37 //print_r($Data[$Key]); 38 foreach ($Data[$Key] as $Key2 => $Value2)38 foreach ($Data[$Key] as $Key2 => $Value2) 39 39 { 40 if (substr($Data[$Key][$Key2], 0, 2) == '\"')40 if (substr($Data[$Key][$Key2], 0, 2) == '\"') 41 41 $Data[$Key][$Key2] = substr($Data[$Key][$Key2], 2, -2); 42 42 } … … 61 61 //print_r($Data); 62 62 63 if ($Header != $Data[0]) {63 if ($Header != $Data[0]) { 64 64 $Output = 'Nekompatibilní struktura CSV'; 65 65 print_r($Header); … … 73 73 $Output = '<form action="?Operation=insert" method="post">'; 74 74 $I = 0; 75 foreach ($Data as $Key => $Value)75 foreach ($Data as $Key => $Value) 76 76 { 77 if (count($Value) <= 1) continue;78 if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna77 if (count($Value) <= 1) continue; 78 if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna 79 79 $Time = explode('.', $Value[0]); 80 80 $Time = $Time[2].'-'.$Time[1].'-'.$Time[0]; 81 81 $Money = $Value[1]; 82 if (is_numeric($Value[5]))82 if (is_numeric($Value[5])) 83 83 { 84 84 $Subject = $Value[5] * 1; 85 85 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id='.$this->Database->real_escape_string($Subject)); 86 if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';86 if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')'; 87 87 } else 88 88 { 89 89 $Subject = '? ('.$Value[5].')'; 90 90 } 91 if (!is_numeric($Subject))91 if (!is_numeric($Subject)) 92 92 { 93 93 $Mode = 'Ručně'; … … 99 99 } 100 100 101 if ($Money < 0) $Text = 'Platba převodem';101 if ($Money < 0) $Text = 'Platba převodem'; 102 102 else $Text = 'Přijatá platba'; 103 103 $Automatic .= '<tr>'. … … 121 121 $Output .= '<input type="submit" value="Zpracovat"/></form>'; 122 122 } 123 return ($Output);123 return ($Output); 124 124 } 125 125 … … 142 142 $Output = ''; 143 143 144 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)144 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 145 145 { 146 if ($_POST['Money'.$I] < 0) {146 if ($_POST['Money'.$I] < 0) { 147 147 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 148 148 } else { … … 156 156 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted'); 157 157 } 158 return ($Output);158 return ($Output); 159 159 } 160 160 } -
trunk/Modules/Finance/Manage.php
r866 r873 10 10 { 11 11 $Output = ''; 12 if (!$this->System->User->CheckPermission('Finance', 'Manage'))13 return ('Nemáte oprávnění');14 15 if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation'];12 if (!$this->System->User->CheckPermission('Finance', 'Manage')) 13 return ('Nemáte oprávnění'); 14 15 if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; 16 16 else $Operation = ''; 17 switch ($Operation)17 switch ($Operation) 18 18 { 19 19 case 'Recalculate': … … 42 42 $Output .= '<a href="'.$this->System->Link('/finance/import/').'">Import plateb</a><br />'; 43 43 } 44 return ($Output);44 return ($Output); 45 45 } 46 46 … … 52 52 53 53 $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount']; 54 if ($MonthCount <= 0) return(array('From' => NULL, 'To' => NULL, 'MonthCount' => 0));54 if ($MonthCount <= 0) return (array('From' => NULL, 'To' => NULL, 'MonthCount' => 0)); 55 55 $MonthCurrent = date('n', $Time); 56 56 … … 67 67 $PeriodTo = mktime(0, 0, 0, $MonthTo, date('t', mktime(0, 0, 0, $MonthTo, 1, $Year)), $Year); 68 68 69 return (array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount));69 return (array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount)); 70 70 } 71 71 72 72 function ShowMonthlyPayment() 73 73 { 74 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');74 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění'); 75 75 $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '. 76 76 '`MemberPayment`.`Cash` AS `Cash`, '. … … 106 106 107 107 $DbResult = $this->Database->query($Query); 108 while ($Row = $DbResult->fetch_assoc())108 while ($Row = $DbResult->fetch_assoc()) 109 109 { 110 110 $Output .= '<tr>'. … … 120 120 $Output .= $PageList['Output']; 121 121 $Output .= '<a href="?Operation=ProcessMonthlyPayment">Generovat faktury</a>'; 122 return ($Output);122 return ($Output); 123 123 } 124 124 … … 131 131 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 132 132 $SumValue = 0; 133 foreach ($Items as $Item) {133 foreach ($Items as $Item) { 134 134 $SumValue = $SumValue + $Item['Price'] * $Item['Quantity']; 135 135 } … … 143 143 'Generate' => 1, 'Group' => $Group['Id'])); 144 144 $InvoiceId = $this->Database->insert_id; 145 foreach ($Items as $Item)145 foreach ($Items as $Item) 146 146 $this->Database->insert('FinanceInvoiceItem', array('FinanceInvoice' => $InvoiceId, 147 147 'Description' => $Item['Description'], 'Price' => $Item['Price'], … … 149 149 //$LastInsertTime = $Time; 150 150 //$this->CheckAdvancesAndLiabilities($Subject); 151 return ($InvoiceId);151 return ($InvoiceId); 152 152 } 153 153 … … 162 162 'FROM `MemberPayment` JOIN `Member` ON `Member`.`Id`=`MemberPayment`.`Member` '. 163 163 'JOIN `Subject` ON `Subject`.`Id`=`Member`.`Subject`'); 164 while ($Member = $DbResult->fetch_assoc())164 while ($Member = $DbResult->fetch_assoc()) 165 165 { 166 166 $Output .= $Member['SubjectName'].': '; … … 168 168 169 169 /* Check if need to produce new invoice for customer */ 170 if (($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and170 if (($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and 171 171 ($Period['From'] > $Member['BillingPeriodLastUnixTime'])) 172 172 { … … 178 178 'WHERE (`ServiceCustomerRel`.`Customer`='. 179 179 $Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '); 180 while ($Service = $DbResult2->fetch_assoc())180 while ($Service = $DbResult2->fetch_assoc()) 181 181 { 182 182 $InvoiceItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'], … … 188 188 // TODO: In case of negative invoice it is not sufficient to reverse invoicing direction 189 189 // Other subject should invoice only positive items. Negative items should be somehow removed. 190 if ($MonthlyTotal >= 0)190 if ($MonthlyTotal >= 0) 191 191 { 192 192 $InvoiceGroupId = INVOICE_GROUP_OUT; … … 197 197 // Load invoice group 198 198 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup'); 199 foreach ($InvoiceItems as $Index => $Item)199 foreach ($InvoiceItems as $Index => $Item) 200 200 { 201 201 $InvoiceItems[$Index]['Price'] = $Item['Price'] * $FinanceGroup['ValueSign']; 202 202 } 203 203 204 if ($PayPerPeriod != 0)204 if ($PayPerPeriod != 0) 205 205 { 206 206 $TimePeriodText = date('j.n.Y', $Period['From']).' - '.date('j.n.Y', $Period['To']); … … 217 217 $Output .= "\n"; 218 218 } 219 return ($Output);219 return ($Output); 220 220 } 221 221 … … 225 225 $DbResult = $this->Database->select($Table, '*', '(`ChangeAction` IS NOT NULL) AND '. 226 226 '(`ChangeTime` <= "'.TimeToMysqlDateTime($Time).'") ORDER BY `ChangeTime` ASC'); 227 while ($Service = $DbResult->fetch_assoc())228 { 229 if ($Service['ChangeAction'] == 'add')227 while ($Service = $DbResult->fetch_assoc()) 228 { 229 if ($Service['ChangeAction'] == 'add') 230 230 { 231 231 unset($Service['Id']); … … 235 235 $this->Database->insert($Table, $Service); 236 236 } else 237 if ($Service['ChangeAction'] == 'modify')237 if ($Service['ChangeAction'] == 'modify') 238 238 { 239 239 unset($Service['Id']); … … 244 244 $this->Database->update($Table, '`Id`='.$ReplaceId, $Service); 245 245 } else 246 if ($Service['ChangeAction'] == 'delete')246 if ($Service['ChangeAction'] == 'delete') 247 247 { 248 248 $this->Database->delete($Table, '`Id`='.$Service['ReplaceId']); … … 270 270 $this->TableUpdateChanges('ServiceCustomerRel'); 271 271 272 return ($Output);272 return ($Output); 273 273 } 274 274 275 275 function ProcessMonthlyPayment() 276 276 { 277 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');277 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění'); 278 278 $Output = ''; 279 279 … … 311 311 // Zkontrolovat odečtení měsíčního poplatku 312 312 $Output .= 'Kontrola odečtení poplatků: Poslední měsíc-'.$MonthLast.' Aktuální měsíc-'.$MonthCurrent."\n"; 313 if ($MonthCurrent != $MonthLast)313 if ($MonthCurrent != $MonthLast) 314 314 { 315 315 $Output .= 'Odečítám pravidelný poplatek...'."\n"; … … 335 335 } 336 336 $Output = str_replace("\n", '<br/>', $Output); 337 return ($Output);337 return ($Output); 338 338 } 339 339 … … 366 366 $MainSubjectAccount = $DbResult->fetch_assoc(); 367 367 368 if ($User['Email'] != '')368 if ($User['Email'] != '') 369 369 { 370 370 $Title = 'Pravidelné vyúčtování služeb'; … … 392 392 '`Time`, -`Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='. 393 393 $Member['Subject'].')) ORDER BY `Time` DESC) AS `T1` WHERE (`T1`.`Time` > "'.$Member['BillingPeriodLastDate'].'")'); 394 while ($DbRow = $DbResult->fetch_assoc())394 while ($DbRow = $DbResult->fetch_assoc()) 395 395 { 396 396 $Text = $DbRow['Text']; … … 417 417 $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '. 418 418 'AND (`Value` != 0) AND (`Generate` = 1)'.$Where); 419 while ($Row = $DbResult->fetch_assoc())419 while ($Row = $DbResult->fetch_assoc()) 420 420 { 421 421 if ($Row['File'] == null) … … 447 447 $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '. 448 448 'AND (`Value` != 0) AND (`Generate` = 1)'.$Where); 449 while ($Row = $DbResult->fetch_assoc())449 while ($Row = $DbResult->fetch_assoc()) 450 450 { 451 451 if ($Row['File'] == null) … … 462 462 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName; 463 463 $Bill->SaveToFile($FullFileName); 464 if (file_exists($FullFileName))464 if (file_exists($FullFileName)) 465 465 { 466 466 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName))); … … 478 478 $Output .= $this->GenerateInvoice(' AND (`File` IS NULL)'); 479 479 $Output .= $this->GenerateOperation(' AND (`File` IS NULL)'); 480 return ($Output);480 return ($Output); 481 481 } 482 482 } -
trunk/Modules/Finance/Trade.php
r847 r873 65 65 $Row = $DbResult->fetch_array(); 66 66 $Balance['SmallAssets']['End'] = $Row[0] + 0; 67 return ($Balance);67 return ($Balance); 68 68 } 69 69 … … 77 77 $StartYear = date('Y', $this->StartEvidence); 78 78 $EndYear = date('Y', time()); 79 for ($Year = $StartYear; $Year <= $EndYear; $Year++)79 for ($Year = $StartYear; $Year <= $EndYear; $Year++) 80 80 { 81 81 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 82 82 //$Year = date('Y', $EndTime); 83 83 $StartTime = mktime(0, 0, 0, 1, 1, $Year); 84 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;84 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; 85 85 86 86 $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); … … 113 113 $StartYear = date('Y', $this->StartEvidence); 114 114 $EndYear = date('Y', time()); 115 for ($Year = $StartYear; $Year <= $EndYear; $Year++)116 { 117 for ($Month = 1; $Month <= 12; $Month++)115 for ($Year = $StartYear; $Year <= $EndYear; $Year++) 116 { 117 for ($Month = 1; $Month <= 12; $Month++) 118 118 { 119 119 $EndTime = mktime(0, 0, 0, $Month, 31, $Year); 120 120 //$Year = date('Y', $EndTime); 121 121 $StartTime = mktime(0, 0, 0, $Month, 1, $Year); 122 if (($StartTime < time()) and ($EndTime > $this->StartEvidence))122 if (($StartTime < time()) and ($EndTime > $this->StartEvidence)) 123 123 { 124 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;124 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; 125 125 126 126 $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); … … 164 164 'WHERE (`ValueSign` = 1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 165 165 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 166 while ($Row = $DbResult->fetch_array())166 while ($Row = $DbResult->fetch_array()) 167 167 { 168 168 $Row['Time'] = explode(' ', $Row['Time']); … … 204 204 'WHERE (`FinanceOperationGroup`.`ValueSign` = -1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 205 205 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 206 while ($Row = $DbResult->fetch_array())206 while ($Row = $DbResult->fetch_array()) 207 207 { 208 208 $Row['Time'] = explode(' ', $Row['Time']); … … 245 245 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 246 246 '") AND (`FinanceInvoice`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 247 while ($Row = $DbResult->fetch_array())248 { 249 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' ';247 while ($Row = $DbResult->fetch_array()) 248 { 249 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 250 250 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 251 251 '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>'; … … 276 276 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 277 277 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 278 while ($Row = $DbResult->fetch_array())279 { 280 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' ';278 while ($Row = $DbResult->fetch_array()) 279 { 280 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 281 281 $Row['Value'] = $Row['Value'] * $Row['ValueSign']; 282 282 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. … … 314 314 'WHERE (T6.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = -1)) AS `Spends` '. 315 315 'FROM Subject ORDER BY Name'); 316 while ($Row = $DbResult->fetch_assoc())316 while ($Row = $DbResult->fetch_assoc()) 317 317 { 318 318 $Output .= '<tr><td style="text-align: left;"><a href="?table=SubjectAccount&Id='.$Row['Id'].'">'.$Row['Name'].'</a></td><td>'.$Row['Liabilities'].' / '.$Row['OpenedLiabilities'].'</td><td>'.$Row['Claims'].' / '.$Row['OpenedClaims'].'</td><td>'.$Row['Gains'].'</td><td>'.$Row['Spends'].'</td><td>'.($Row['Gains'] - $Row['Spends'] - $Row['Claims'] + $Row['Liabilities']).'</td><td>'.$Row['Cash'].'</td></tr>'; … … 330 330 'FROM StockSerialNumber JOIN Product ON Product.Id = StockSerialNumber.Product '. 331 331 'WHERE (TimeElimination IS NOT NULL)'); 332 while ($Row = $DbResult->fetch_array())332 while ($Row = $DbResult->fetch_array()) 333 333 { 334 334 $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Price'].'</td><td>'.$Row['TimeEnlistment'].'</td><td>'.$Row['TimeElimination'].'</td></tr>'; … … 349 349 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 350 350 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 351 while ($Row = $DbResult->fetch_array())351 while ($Row = $DbResult->fetch_array()) 352 352 { 353 353 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text']. … … 364 364 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 365 365 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 366 while ($Row = $DbResult->fetch_array())366 while ($Row = $DbResult->fetch_array()) 367 367 { 368 368 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']). … … 375 375 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>'; 376 376 $DbResult = $this->Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']); 377 while ($Row = $DbResult->fetch_array())377 while ($Row = $DbResult->fetch_array()) 378 378 { 379 379 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['ValueSign'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>'; … … 411 411 $Output .= '<strong>Roční přehledy</strong><br/>'; 412 412 $Output .= $this->ShowFinanceYears(); 413 if (array_key_exists('year', $_GET))413 if (array_key_exists('year', $_GET)) 414 414 { 415 415 $Year = $_GET['year'] * 1; … … 426 426 function Show() 427 427 { 428 if (!$this->System->User->CheckPermission('Finance', 'TradingStatus'))429 return ('Nemáte oprávnění');428 if (!$this->System->User->CheckPermission('Finance', 'TradingStatus')) 429 return ('Nemáte oprávnění'); 430 430 431 431 $Finance = &$this->System->Modules['Finance']; 432 432 433 433 $Output = ''; 434 if (!array_key_exists('table', $_GET)) $_GET['table'] = '';435 switch ($_GET['table'])434 if (!array_key_exists('table', $_GET)) $_GET['table'] = ''; 435 switch ($_GET['table']) 436 436 { 437 437 case 'AnnualBalance': … … 478 478 $Output = $this->ShowDefault(); 479 479 } 480 return ($Output);480 return ($Output); 481 481 } 482 482 … … 485 485 $Output = 'Roky: '; 486 486 $DbRows = $this->Database->select('FinanceYear', '*'); 487 while ($DbRow = $DbRows->fetch_assoc())487 while ($DbRow = $DbRows->fetch_assoc()) 488 488 $Output .= '<a href="?year='.$DbRow['Id'].'">'.$DbRow['Year'].'</a> '; 489 489 $Output .= '<br/>'; 490 return ($Output);490 return ($Output); 491 491 } 492 492 -
trunk/Modules/Finance/UserState.php
r825 r873 44 44 $DbResult = $this->Database->query($Query); 45 45 $SumValue = 0; 46 while ($Row = $DbResult->fetch_assoc())46 while ($Row = $DbResult->fetch_assoc()) 47 47 { 48 48 $Row['State'] = round($Row['State'], 2); 49 if ($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>';50 if ($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>';51 if ($Row['Value'] == -0) $Row['Value'] = 0;52 if ($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];53 if ($Row['BillName'] == '') $Row['BillName'] = 'PDF';54 if ($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>';49 if ($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>'; 50 if ($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>'; 51 if ($Row['Value'] == -0) $Row['Value'] = 0; 52 if ($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; 53 if ($Row['BillName'] == '') $Row['BillName'] = 'PDF'; 54 if ($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>'; 55 55 else $Invoice = NotBlank($Row['BillName']); 56 if ($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']);56 if ($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']); 57 57 else $Period = ' '; 58 58 $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td>'. … … 66 66 $Output .= '</table>'; 67 67 $Output .= $PageList['Output']; 68 return ($Output);68 return ($Output); 69 69 } 70 70 … … 75 75 76 76 // Determine which customer should be displayed 77 if (array_key_exists('i', $_GET))77 if (array_key_exists('i', $_GET)) 78 78 { 79 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');79 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění'); 80 80 $CustomerId = $_GET['i']; 81 81 } else 82 82 { 83 if (!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');83 if (!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return ('Nemáte oprávnění'); 84 84 $UserId = $this->System->User->User['Id']; 85 85 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1'); 86 if ($DbResult->num_rows > 0)86 if ($DbResult->num_rows > 0) 87 87 { 88 88 $CustomerUserRel = $DbResult->fetch_assoc(); 89 89 $CustomerId = $CustomerUserRel['Customer']; 90 } else return ($this->SystemMessage('Chyba', 'Nejste zákazníkem'));90 } else return ($this->SystemMessage('Chyba', 'Nejste zákazníkem')); 91 91 } 92 92 93 93 // Load customer info 94 94 $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId); 95 if ($DbResult->num_rows == 1)95 if ($DbResult->num_rows == 1) 96 96 { 97 97 $Customer = $DbResult->fetch_assoc(); 98 } else return ($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen'));98 } else return ($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen')); 99 99 100 100 101 101 // Load subject info 102 102 $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']); 103 if ($DbResult->num_rows == 1)103 if ($DbResult->num_rows == 1) 104 104 { 105 105 $Subject = $DbResult->fetch_assoc(); 106 } else return ($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen'));106 } else return ($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen')); 107 107 108 108 … … 141 141 'LEFT JOIN `Service` ON `Service`.`Id`=`ServiceCustomerRel`.`Service` '. 142 142 'WHERE (`ServiceCustomerRel`.`Customer`='.$Customer['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL)'); 143 while ($DbRow = $DbResult->fetch_assoc())143 while ($DbRow = $DbResult->fetch_assoc()) 144 144 { 145 145 $Output .= '<tr><td>'.$DbRow['Name'].'</td><td>'.$DbRow['Price'].'</td></tr>'; … … 152 152 153 153 $Output .= '</td></tr></table>'; 154 return ($Output);154 return ($Output); 155 155 } 156 156 } -
trunk/Modules/FinanceBankAPI/FileImport.php
r765 r873 26 26 { 27 27 $DbResult = $this->Database->select('FinanceBankImport', '*', 'FinanceOperation IS NULL'); 28 while ($DbRow = $DbResult->fetch_assoc())28 while ($DbRow = $DbResult->fetch_assoc()) 29 29 { 30 if (is_numeric($DbRow['VariableSymbol']))30 if (is_numeric($DbRow['VariableSymbol'])) 31 31 { 32 32 $DbResult2 = $this->Database->select('Subject', 'Id', 'Id='.$DbRow['VariableSymbol']); 33 if ($DbResult2->num_rows == 1)33 if ($DbResult2->num_rows == 1) 34 34 { 35 35 $DbRow2 = $DbResult2->fetch_assoc(); 36 if ($DbRow['Value'] >= 0) {36 if ($DbRow['Value'] >= 0) { 37 37 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 38 38 } else { … … 51 51 $Form->SetClass('FinanceOperation'); 52 52 $Form->LoadValuesFromDatabase($Id); 53 if (array_key_exists('AfterInsert', $Form->Definition))53 if (array_key_exists('AfterInsert', $Form->Definition)) 54 54 { 55 55 $Class = $Form->Definition['AfterInsert'][0]; … … 80 80 $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'."\n"; 81 81 82 if ($Bank['Code'] == '2010') $Import = new ImportFio($this->System);83 else if ($Bank['Code'] == '0300') $Import = new ImportPS($this->System);82 if ($Bank['Code'] == '2010') $Import = new ImportFio($this->System); 83 else if ($Bank['Code'] == '0300') $Import = new ImportPS($this->System); 84 84 else $Output = $this->SystemMessage('Nepodporované API', 'Pro zvolenou banku není import podporován'); 85 if (isset($Import))85 if (isset($Import)) 86 86 { 87 87 $Import->BankAccount = $BankAccount; … … 89 89 $Import->PairOperations(); 90 90 } 91 return ($Output);91 return ($Output); 92 92 } 93 93 94 94 function Show() 95 95 { 96 if (!$this->System->User->CheckPermission('Finance', 'SubjectList'))97 return ('Nemáte oprávnění');96 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) 97 return ('Nemáte oprávnění'); 98 98 99 99 $Output = $this->Import($_GET['i']); 100 return ($Output);100 return ($Output); 101 101 } 102 102 } … … 111 111 { 112 112 $Output = ''; 113 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');114 if (array_key_exists('Operation', $_GET))113 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return ('Nemáte oprávnění'); 114 if (array_key_exists('Operation', $_GET)) 115 115 { 116 if ($_GET['Operation'] == 'prepare') $Output .= $this->Prepare();117 else if ($_GET['Operation'] == 'insert') $Output .= $this->Insert();116 if ($_GET['Operation'] == 'prepare') $Output .= $this->Prepare(); 117 else if ($_GET['Operation'] == 'insert') $Output .= $this->Insert(); 118 118 else $Output .= 'Neplatná akce'; 119 119 } else $Output .= $this->ShowForm(); 120 return ($Output);120 return ($Output); 121 121 } 122 122 … … 128 128 $Form->Values['BankAccount'] = $_GET['id']; 129 129 $Output = $Form->ShowEditForm(); 130 return ($Output);130 return ($Output); 131 131 } 132 132 … … 147 147 $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'; 148 148 149 if ($Bank['Code'] == '2010') $Import = new ImportFio($this->System);150 else if ($Bank['Code'] == '0300') $Import = new ImportPS($this->System);149 if ($Bank['Code'] == '2010') $Import = new ImportFio($this->System); 150 else if ($Bank['Code'] == '0300') $Import = new ImportPS($this->System); 151 151 else $Output = $this->SystemMessage('Nepodporované API', 'Pro zvolenou banku není import podporován'); 152 152 $Import->BankAccount = $BankAccount; 153 153 $Output .= $Import->ImportFile($File->GetContent(), $File->GetExt()); 154 154 155 return ($Output);155 return ($Output); 156 156 } 157 157 … … 171 171 $Output = ''; 172 172 173 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)173 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 174 174 { 175 if ($_POST['Money'.$I] >= 0) {175 if ($_POST['Money'.$I] >= 0) { 176 176 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 177 177 'FinanceOperationGroup'); … … 187 187 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted'); 188 188 } 189 return ($Output);189 return ($Output); 190 190 } 191 191 } -
trunk/Modules/FinanceBankAPI/FinanceBankAPI.php
r799 r873 76 76 $DbRow = $DbResult->fetch_row(); 77 77 $Output = 'Nezpárovaných plateb: '.$DbRow['0'].'<br/>'; 78 return ($Output);78 return ($Output); 79 79 } 80 80 … … 82 82 { 83 83 $Preset = array(); 84 if ($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT;84 if ($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT; 85 85 else $OperationGroupId = OPERATION_GROUP_ACCOUNT_IN; 86 86 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup'); … … 94 94 'presetBankAccount' => $Item['BankAccount'], 95 95 'presetGroup' => $FinanceGroup['Id']); 96 return ($Preset);96 return ($Preset); 97 97 } 98 98 } … … 106 106 '(`AutoImport`=1) AND (`TimeCreate` < NOW()) AND '. 107 107 '((`TimeEnd` IS NULL) OR (`TimeEnd` > NOW()))'); 108 while ($DbRow = $DbResult->fetch_assoc())108 while ($DbRow = $DbResult->fetch_assoc()) 109 109 { 110 110 echo($DbRow['Comment']."\n"); … … 112 112 $Output .= $Page->Import($DbRow['Id']); 113 113 } 114 return ($Output);114 return ($Output); 115 115 } 116 116 } -
trunk/Modules/FinanceBankAPI/Fio.php
r738 r873 11 11 function Import($TimeFrom, $TimeTo) 12 12 { 13 if ($this->UserName == '') throw new Exception('Missing value for UserName property.');14 if ($this->Password == '') throw new Exception('Missing value for Password property.');15 if (!is_numeric($this->Account)) throw new Exception('Missing or not numeric value for Account property.');13 if ($this->UserName == '') throw new Exception('Missing value for UserName property.'); 14 if ($this->Password == '') throw new Exception('Missing value for Password property.'); 15 if (!is_numeric($this->Account)) throw new Exception('Missing or not numeric value for Account property.'); 16 16 17 17 $fp = fsockopen('ssl://www.fio.cz', 443, $errno, $errstr, 30); 18 if (!$fp)18 if (!$fp) 19 19 { 20 20 throw new Exception('Connection error: '.$errstr); … … 35 35 // Read response 36 36 $Response = array(); 37 while (!feof($fp))37 while (!feof($fp)) 38 38 { 39 39 $Response[] = trim(fgets($fp, 1024)); … … 42 42 43 43 // Strip HTTP header 44 while ($Response[0] != '') array_shift($Response);44 while ($Response[0] != '') array_shift($Response); 45 45 array_shift($Response); // Remove empty line 46 46 //echo(implode("\n", $Response)); … … 49 49 $GPC = new GPC(); 50 50 $Result = array(); 51 foreach ($Response as $Index => $Line)51 foreach ($Response as $Index => $Line) 52 52 { 53 if (($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response);53 if (($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response); 54 54 $GPCLine = $GPC->ParseLine($Line); 55 if ($GPCLine != NULL) $Result[] = $GPCLine;55 if ($GPCLine != NULL) $Result[] = $GPCLine; 56 56 } 57 return ($Result);57 return ($Result); 58 58 } 59 59 } … … 65 65 $Response = implode('', $Response); 66 66 $ErrorMessageStart = '<div id="oldform_warning">'; 67 if (strpos($Response, $ErrorMessageStart) !== false)67 if (strpos($Response, $ErrorMessageStart) !== false) 68 68 { 69 69 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart)); -
trunk/Modules/FinanceBankAPI/FioAPI.php
r836 r873 7 7 function RemoveComma($Text) 8 8 { 9 if ((mb_strlen($Text) >= 2) and ($Text[0] == '"') and (mb_substr($Text, -1, 1) == '"')) return(mb_substr($Text, 1, -1));10 else return ($Text);9 if ((mb_strlen($Text) >= 2) and ($Text[0] == '"') and (mb_substr($Text, -1, 1) == '"')) return (mb_substr($Text, 1, -1)); 10 else return ($Text); 11 11 } 12 12 … … 25 25 function Import($TimeFrom, $TimeTo) 26 26 { 27 if ($this->Token == '') throw new Exception('Missing value for Token property.');27 if ($this->Token == '') throw new Exception('Missing value for Token property.'); 28 28 29 29 // URL format: https://www.fio.cz/ib_api/rest/periods/{token}/{datum od}/{datum do}/transactions.{format} … … 33 33 $Response = ''; 34 34 $Response = @file_get_contents('https://www.fio.cz'.$RequestURL); 35 if ($Response == FALSE)35 if ($Response == FALSE) 36 36 { 37 37 throw new Exception('Connection error'); 38 38 } else 39 39 { 40 if ($this->Format == 'gpc') $Response = iconv('windows-1250', $this->Encoding, $Response);40 if ($this->Format == 'gpc') $Response = iconv('windows-1250', $this->Encoding, $Response); 41 41 $Response = explode("\n", $Response); 42 42 43 if ($this->Format == 'gpc')43 if ($this->Format == 'gpc') 44 44 { 45 45 // Parse all GPC lines 46 46 $GPC = new GPC(); 47 47 $Result = array(); 48 foreach ($Response as $Index => $Line)48 foreach ($Response as $Index => $Line) 49 49 { 50 if (($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response);50 if (($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response); 51 51 $GPCLine = $GPC->ParseLine($Line); 52 if ($GPCLine != NULL) $Result[] = $GPCLine;52 if ($GPCLine != NULL) $Result[] = $GPCLine; 53 53 } 54 54 } else 55 if ($this->Format == 'csv')55 if ($this->Format == 'csv') 56 56 { 57 57 $Result = array( … … 60 60 61 61 // CVS header 62 while ((count($Response) > 0) and ($Response[0] != ''))62 while ((count($Response) > 0) and ($Response[0] != '')) 63 63 { 64 64 $Line = explode(';', $Response[0]); 65 if ($Line[0] == 'accountId') $Result['AccountNumber'] = $Line[0];66 else if ($Line[0] == 'bankId') $Result['BankId'] = $Line[0];67 else if ($Line[0] == 'currency') $Result['Currency'] = $Line[0];68 else if ($Line[0] == 'iban') $Result['IBAN'] = $Line[0];69 else if ($Line[0] == 'bic') $Result['BIC'] = $Line[0];70 else if ($Line[0] == 'openingBalance') $Result['OpeningBalance'] = $Line[0];71 else if ($Line[0] == 'closingBalance') $Result['ClosingBalance'] = $Line[0];72 else if ($Line[0] == 'dateStart') $Result['DateStart'] = $Line[0];73 else if ($Line[0] == 'dateEnd') $Result['DateEnd'] = $Line[0];74 else if ($Line[0] == 'idFrom') $Result['IdFrom'] = $Line[0];75 else if ($Line[0] == 'idTo') $Result['IdTo'] = $Line[0];65 if ($Line[0] == 'accountId') $Result['AccountNumber'] = $Line[0]; 66 else if ($Line[0] == 'bankId') $Result['BankId'] = $Line[0]; 67 else if ($Line[0] == 'currency') $Result['Currency'] = $Line[0]; 68 else if ($Line[0] == 'iban') $Result['IBAN'] = $Line[0]; 69 else if ($Line[0] == 'bic') $Result['BIC'] = $Line[0]; 70 else if ($Line[0] == 'openingBalance') $Result['OpeningBalance'] = $Line[0]; 71 else if ($Line[0] == 'closingBalance') $Result['ClosingBalance'] = $Line[0]; 72 else if ($Line[0] == 'dateStart') $Result['DateStart'] = $Line[0]; 73 else if ($Line[0] == 'dateEnd') $Result['DateEnd'] = $Line[0]; 74 else if ($Line[0] == 'idFrom') $Result['IdFrom'] = $Line[0]; 75 else if ($Line[0] == 'idTo') $Result['IdTo'] = $Line[0]; 76 76 array_shift($Response); 77 77 } 78 78 array_shift($Response); // Remove empty line 79 79 80 if ((count($Response) == 0) or80 if ((count($Response) == 0) or 81 81 ($Response[0] != 'ID pohybu;Datum;Objem;Měna;Protiúčet;Název protiúčtu;Kód banky;Název banky;KS;VS;SS;Uživatelská identifikace;Zpráva pro příjemce;Typ;Provedl;Upřesnění;Komentář;BIC;ID pokynu') 82 82 ) throw new Exception('Unsupported CSV header'); 83 83 array_shift($Response); 84 84 array_pop($Response); 85 foreach ($Response as $Index => $Line)85 foreach ($Response as $Index => $Line) 86 86 { 87 87 $Line = explode(';', $Line); … … 97 97 } 98 98 } 99 return ($Result);99 return ($Result); 100 100 } 101 101 } … … 107 107 $Response = implode('', $Response); 108 108 $ErrorMessageStart = '<div id="oldform_warning">'; 109 if (strpos($Response, $ErrorMessageStart) !== false)109 if (strpos($Response, $ErrorMessageStart) !== false) 110 110 { 111 111 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart)); -
trunk/Modules/FinanceBankAPI/FioDemo.php
r738 r873 11 11 echo('<html><head><meta charset="utf-8"></head><body>'); 12 12 echo('<table border="1">'); 13 foreach ($Records as $Record)13 foreach ($Records as $Record) 14 14 { 15 15 echo('<tr>'); 16 if ($Record['Type'] == GPC_TYPE_REPORT)16 if ($Record['Type'] == GPC_TYPE_REPORT) 17 17 { 18 18 echo('<td>Jméno účtu: '.$Record['AccountName'].'</td>'); … … 35 35 echo('<th>Uživatelská identifikace</th>'); 36 36 } else 37 if ($Record['Type'] == GPC_TYPE_ITEM)37 if ($Record['Type'] == GPC_TYPE_ITEM) 38 38 { 39 39 echo('<td>'.date('j.n.Y', $Record['DueDate']).'</td>'); -
trunk/Modules/FinanceBankAPI/GPC.php
r738 r873 11 11 $Type = mb_substr($Line, 1, 3); 12 12 13 if ($Type == GPC_TYPE_REPORT)13 if ($Type == GPC_TYPE_REPORT) 14 14 { 15 15 $GPCLine = array … … 29 29 ); 30 30 } else 31 if ($Type == GPC_TYPE_ITEM)31 if ($Type == GPC_TYPE_ITEM) 32 32 { 33 33 $GPCLine = array … … 53 53 $GPCLine = NULL; 54 54 55 return ($GPCLine);55 return ($GPCLine); 56 56 } 57 57 } -
trunk/Modules/FinanceBankAPI/ImportFio.php
r765 r873 9 9 $Fio = new FioAPI(); 10 10 $Fio->Token = $this->BankAccount['LoginName']; 11 if ($this->BankAccount['LastImportDate'] == '') $PeriodStart = time();11 if ($this->BankAccount['LastImportDate'] == '') $PeriodStart = time(); 12 12 else $PeriodStart = MysqlDateToTime($this->BankAccount['LastImportDate']); 13 13 $PeriodEnd = time(); … … 22 22 //$Output .= '<td>Suma výdajů: '.$Records['DebitValue'].' Kč</td>'; 23 23 //$Output .= '</tr>'; 24 foreach ($Records['Items'] as $Record)24 foreach ($Records['Items'] as $Record) 25 25 { 26 26 $DbResult = $this->Database->select('FinanceBankImport', 'ID', 'Identification='.$Record['ID']); 27 if ($DbResult->num_rows == 0)27 if ($DbResult->num_rows == 0) 28 28 { 29 29 $Output .= '<tr>'; … … 44 44 $this->Database->update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'], 45 45 array('LastImportDate' => TimeToMysqlDate($PeriodEnd))); 46 return ($Output);46 return ($Output); 47 47 } 48 48 } -
trunk/Modules/FinanceBankAPI/ImportPS.php
r738 r873 5 5 function ImportFile($Content, $Ext) 6 6 { 7 if ($Ext == 'txt') $this->ImportTxt($Content);8 else if ($Ext == 'cvs') $this->ImportCVS($Content);7 if ($Ext == 'txt') $this->ImportTxt($Content); 8 else if ($Ext == 'cvs') $this->ImportCVS($Content); 9 9 } 10 10 … … 20 20 21 21 $Data = explode("\n", $Content); 22 foreach ($Data as $Key => $Value)22 foreach ($Data as $Key => $Value) 23 23 { 24 24 $Value = str_replace('\"', '"', $Value); 25 25 $Data[$Key] = str_getcsv($Value, ',', '"', "\\"); 26 26 //print_r($Data[$Key]); 27 foreach ($Data[$Key] as $Key2 => $Value2)27 foreach ($Data[$Key] as $Key2 => $Value2) 28 28 { 29 if (substr($Data[$Key][$Key2], 0, 2) == '\"')29 if (substr($Data[$Key][$Key2], 0, 2) == '\"') 30 30 $Data[$Key][$Key2] = substr($Data[$Key][$Key2], 2, -2); 31 31 } … … 46 46 ); 47 47 48 if ($Header != $Data[0]) $Output = 'Nekompatibilní struktura CSV';48 if ($Header != $Data[0]) $Output = 'Nekompatibilní struktura CSV'; 49 49 else 50 50 { … … 54 54 $Output = '<form action="?Operation=insert" method="post">'; 55 55 $I = 0; 56 foreach ($Data as $Key => $Value)56 foreach ($Data as $Key => $Value) 57 57 { 58 if (count($Value) <= 1) continue;59 if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna58 if (count($Value) <= 1) continue; 59 if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna 60 60 $Time = explode('.', $Value[0]); 61 61 $Time = $Time[2].'-'.$Time[1].'-'.$Time[0]; 62 62 $Money = $Value[1]; 63 if (is_numeric($Value[5]))63 if (is_numeric($Value[5])) 64 64 { 65 65 $Subject = $Value[5] * 1; 66 66 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id='.$this->Database->real_escape_string($Subject)); 67 if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';67 if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')'; 68 68 } else 69 69 { 70 70 $Subject = '? ('.$Value[5].')'; 71 71 } 72 if (!is_numeric($Subject))72 if (!is_numeric($Subject)) 73 73 { 74 74 $Mode = 'Ručně'; … … 80 80 } 81 81 82 if ($Money < 0) $Text = 'Platba převodem';82 if ($Money < 0) $Text = 'Platba převodem'; 83 83 else $Text = 'Přijatá platba'; 84 84 $Automatic .= '<tr>'. -
trunk/Modules/IS/IS.php
r871 r873 309 309 $DbRow = $DbResult->fetch_assoc(); 310 310 $Actions[] = '<a href="javascript:window.close();" onclick="add_select_item('.$Id.',"'.$DbRow['Name'].'","'. 311 $_GET['r'].'"); set_return ('.$Id.',"'.311 $_GET['r'].'"); set_return ('.$Id.',"'. 312 312 $_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'. 313 313 $this->System->Link('/images/select.png').'"/> Vybrat</a>'; … … 679 679 $this->BasicHTML = true; 680 680 $this->HideMenu = true; 681 $RowActions = '<a href="javascript:window.close();" onclick="set_return (#RowId,"'.681 $RowActions = '<a href="javascript:window.close();" onclick="set_return (#RowId,"'. 682 682 $_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'. 683 683 $this->System->Link('/images/select.png').'"/></a>'; … … 706 706 if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read')) 707 707 return 'Nemáte oprávnění'; 708 if (!array_key_exists($Table, $this->System->FormManager->Classes))708 if (!array_key_exists($Table, $this->System->FormManager->Classes)) 709 709 return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'); 710 710 $FormClass = $this->System->FormManager->Classes[$Table]; -
trunk/Modules/Log/Log.php
r681 r873 49 49 function NewRecord($Module, $Operation, $Value = '') 50 50 { 51 if (array_key_exists('User', $this->System->ModuleManager->Modules) and51 if (array_key_exists('User', $this->System->ModuleManager->Modules) and 52 52 array_key_exists('Id', $this->System->User->User)) 53 53 $UserId = $this->System->User->User['Id']; 54 54 else $UserId = NULL; 55 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR'];55 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR']; 56 56 else $IPAddress = ''; 57 57 $this->Database->insert('Log', array('Time' => 'NOW()', … … 69 69 $Output = ''; 70 70 $Items = array(); 71 if (array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"';71 if (array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"'; 72 72 else $Where = ''; 73 73 $sql = 'SELECT *, UNIX_TIMESTAMP(`Time`) AS `TimeCreate`, (SELECT `User`.`Name` FROM `User` WHERE `User`.`Id` = `Log`.`User`) AS `UserName`, `Time` FROM `Log`'. 74 74 $Where.' ORDER BY `Time` DESC LIMIT '.$Count; 75 75 $DbResult = $this->System->Database->query($sql); 76 while ($Line = $DbResult->fetch_assoc())76 while ($Line = $DbResult->fetch_assoc()) 77 77 { 78 78 $Line['Value'] = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $Line['Value']); … … 96 96 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 97 97 $RSS->Items = $Items; 98 return ($RSS->Generate());98 return ($RSS->Generate()); 99 99 } 100 100 } -
trunk/Modules/Map/Map.php
r865 r873 13 13 function Show() 14 14 { 15 if (!$this->System->User->CheckPermission('Map', 'Show'))16 return ('Nemáte oprávnění');17 18 if (count($this->System->PathItems) > 1)19 { 20 if ($this->System->PathItems[1] == 'show-position') return($this->ShowPosition());21 else return (PAGE_NOT_FOUND);22 } else return ($this->ShowMain());15 if (!$this->System->User->CheckPermission('Map', 'Show')) 16 return ('Nemáte oprávnění'); 17 18 if (count($this->System->PathItems) > 1) 19 { 20 if ($this->System->PathItems[1] == 'show-position') return ($this->ShowPosition()); 21 else return (PAGE_NOT_FOUND); 22 } else return ($this->ShowMain()); 23 23 } 24 24 … … 26 26 { 27 27 $DbResult = $this->Database->select('MapPosition', '*', '`Id`='.$_GET['i']); 28 if ($DbResult->num_rows > 0)28 if ($DbResult->num_rows > 0) 29 29 { 30 30 $DbRow = $DbResult->fetch_assoc(); … … 40 40 $MapApi->Markers[] = $Marker; 41 41 $Output = $MapApi->ShowPage($this); 42 return ($Output);43 } else return ('Položka nenalezena');42 return ($Output); 43 } else return ('Položka nenalezena'); 44 44 } 45 45 … … 59 59 'WHERE (`NetworkDevice`.`Used`=1) AND (`NetworkDevice`.`MapPosition` IS NOT NULL) '. 60 60 'GROUP BY `NetworkDevice`.`MapPosition`'); 61 while ($Device = $DbResult->fetch_assoc())61 while ($Device = $DbResult->fetch_assoc()) 62 62 { 63 63 $Pos = explode(';', $Device['Pos']); … … 69 69 70 70 $DbResult = $this->Database->query('SELECT * FROM `NetworkLink` WHERE (`Interface1` <> 0) AND (`Interface2` <> 0)'); 71 while ($Link = $DbResult->fetch_assoc())71 while ($Link = $DbResult->fetch_assoc()) 72 72 { 73 73 $DbResult2 = $this->Database->query('SELECT `NetworkDevice`.`Used`, `MapPosition`.`Pos` FROM `NetworkDevice` '. … … 77 77 'JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '. 78 78 'WHERE `NetworkDevice`.`Id` = (SELECT `NetworkInterface`.`Device` FROM `NetworkInterface` WHERE `NetworkInterface`.`Id` = '.$Link['Interface2'].')'); 79 if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))79 if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0)) 80 80 { 81 81 $Device1 = $DbResult2->fetch_assoc(); … … 83 83 $Device2 = $DbResult3->fetch_assoc(); 84 84 $Pos2 = explode(';', $Device2['Pos']); 85 if (($Device1['Used'] == 1) and ($Device2['Used'] == 1))85 if (($Device1['Used'] == 1) and ($Device2['Used'] == 1)) 86 86 { 87 87 $PolyLine = new MapPolyLine(); … … 146 146 NetworkLinks = ['; 147 147 $DbResult = $this->Database->query('SELECT * FROM `NetworkLink` WHERE (`Interface1` <> 0) AND (`Interface2` <> 0)'); 148 while ($Link = $DbResult->fetch_assoc())148 while ($Link = $DbResult->fetch_assoc()) 149 149 { 150 150 $DbResult2 = $this->Database->query('SELECT `NetworkDevice`.`Used`, `MapPosition`.`Pos` FROM `NetworkDevice` '. … … 154 154 'JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '. 155 155 'WHERE `NetworkDevice`.`Id` = (SELECT `NetworkInterface`.`Device` FROM `NetworkInterface` WHERE `NetworkInterface`.`Id` = '.$Link['Interface2'].')'); 156 if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))156 if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0)) 157 157 { 158 158 $Device1 = $DbResult2->fetch_assoc(); … … 160 160 $Device2 = $DbResult3->fetch_assoc(); 161 161 $Pos2 = explode(';', $Device2['Pos']); 162 if (($Device1['Used'] == 1) and ($Device2['Used'] == 1))162 if (($Device1['Used'] == 1) and ($Device2['Used'] == 1)) 163 163 $Output .= 'new google.maps.Polyline([new google.maps.LatLng('.$Pos1[0].', '. 164 164 $Pos1[1].'),new google.maps.LatLng('.$Pos2[0].', '.$Pos2[1].')], "#4F4FBF", 3, 0.8), '; … … 198 198 'WHERE (`NetworkDevice`.`Used`=1) AND (`NetworkDevice`.`MapPosition` IS NOT NULL) '. 199 199 'GROUP BY `NetworkDevice`.`MapPosition`'); 200 while ($Device = $DbResult->fetch_assoc())200 while ($Device = $DbResult->fetch_assoc()) 201 201 { 202 202 $Pos = explode(';', $Device['Pos']); … … 236 236 </table>'; 237 237 */ 238 return ($Output);238 return ($Output); 239 239 } 240 240 } … … 245 245 { 246 246 $Output = parent::OnEdit($Item); 247 if ($this->FormManager->ShowRelation)247 if ($this->FormManager->ShowRelation) 248 248 $Output .= '<img src="'.$this->FormManager->Root.'/images/select.png" alf="Vybrat" language="javascript" '. 249 249 'onclick="return popupwindow("'.$this->FormManager->Root.'/is/?a=mapselect&r='. 250 250 $Item['Name'].'","test");" style="cursor:hand;cursor:pointer"/>'; 251 return ($Output);251 return ($Output); 252 252 } 253 253 } -
trunk/Modules/Map/MapAPI.php
r864 r873 37 37 function Show() 38 38 { 39 return ('');39 return (''); 40 40 } 41 41 } … … 78 78 if (point) 79 79 { 80 set_return (point.lat() + ";" + point.lng(),"'.$this->OnClickObject.'");80 set_return (point.lat() + ";" + point.lng(),"'.$this->OnClickObject.'"); 81 81 window.close(); 82 82 } … … 102 102 </script>'; 103 103 $Output .= '<div id="map_canvas" style="width: 100%; height: 98%;"></div>'; 104 return ($Output);104 return ($Output); 105 105 } 106 106 } … … 162 162 if (e) 163 163 { 164 set_return (e.latlng.lat + ";" + e.latlng.lng,"'.$this->OnClickObject.'");164 set_return (e.latlng.lat + ";" + e.latlng.lng,"'.$this->OnClickObject.'"); 165 165 window.close(); 166 166 } -
trunk/Modules/Meals/Meals.php
r790 r873 13 13 function Show() 14 14 { 15 if (count($this->System->PathItems) > 1)16 { 17 if ($this->System->PathItems[1] == 'tisk') return($this->ShowPrint());18 else if ($this->System->PathItems[1] == 'menuedit.php') return($this->ShowEdit());19 else return (PAGE_NOT_FOUND);20 } else return ($this->ShowMenu());15 if (count($this->System->PathItems) > 1) 16 { 17 if ($this->System->PathItems[1] == 'tisk') return ($this->ShowPrint()); 18 else if ($this->System->PathItems[1] == 'menuedit.php') return ($this->ShowEdit()); 19 else return (PAGE_NOT_FOUND); 20 } else return ($this->ShowMenu()); 21 21 } 22 22 … … 26 26 $Output = '<table align="center" class="WideTable"><tr><th>Den</th><th>Datum</th><th>Polévka</th><th>Hlavní jídlo</th></tr>'; 27 27 $DbResult = $this->Database->select('Meals', '*, UNIX_TIMESTAMP(Date)','Date >= NOW() ORDER BY Date'); 28 while ($Row = $DbResult->fetch_array())29 { 30 if ($Row['Status'] == 1) $Output .= '<tr><td>'.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].'</td><td align="right">'.HumanDate($Row['Date']).'</td><td>'.$Row['Soup'].'</td><td>'.$Row['Meal'].'</td></tr>';31 else if (($Row['Status' ] == 2) or ($Row['Status'] == 3))28 while ($Row = $DbResult->fetch_array()) 29 { 30 if ($Row['Status'] == 1) $Output .= '<tr><td>'.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].'</td><td align="right">'.HumanDate($Row['Date']).'</td><td>'.$Row['Soup'].'</td><td>'.$Row['Meal'].'</td></tr>'; 31 else if (($Row['Status' ] == 2) or ($Row['Status'] == 3)) 32 32 { 33 33 $Output .= '<tr><td>'.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].'</td><td align="right">'.HumanDate($Row['Date']).'</td><td colspan="2" align="center">'.$this->Status[$Row['Status']].'</td></tr>'; … … 40 40 $Output .= 'Cena jednoho menu: '.$Row['Price'].' Kč<br />'; 41 41 $Output .= $Row['Info']; 42 return ($Output);42 return ($Output); 43 43 } 44 44 … … 66 66 $Date = explode('-', $_GET['date']); 67 67 $Time2 = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]); 68 for ($I = 0; $I < 5; $I++)68 for ($I = 0; $I < 5; $I++) 69 69 { 70 70 $Time = $Time2 + $I * 86400; … … 74 74 $Row = $DbResult->fetch_array(); 75 75 $Output .= '<tr><td style="border-style: solid; border-color: black; border-width: 2; font-size: xx-large;" width="10%">'.$this->DayNamesShort[$DayOfWeek].'</td><td style="font-size: x-large; border-style: solid; border-color: black; border-width: 2;" width="90%">'; 76 if ($Row['Status'] == 0) $Output .= ' <br><br> ';77 if ($Row['Status'] == 1) $Output .= 'Polévka: '.$Row['Soup'].'<br><br>'.$Row['Meal'];78 else if (($Row['Status'] == 2) or ($Row['Status'] == 3))76 if ($Row['Status'] == 0) $Output .= ' <br><br> '; 77 if ($Row['Status'] == 1) $Output .= 'Polévka: '.$Row['Soup'].'<br><br>'.$Row['Meal']; 78 else if (($Row['Status'] == 2) or ($Row['Status'] == 3)) 79 79 { 80 80 $Output .= '<br>'.$this->Status[$Row['Status']].'<br> '; … … 91 91 92 92 $Output .= '</body></html>'; 93 return ($Output);93 return ($Output); 94 94 } 95 95 … … 103 103 $Week = date('w', mktime(0, 0, 0, $Date[1], $Date[2], $Date[0])); 104 104 $WeekOfYear = date('W', mktime(0, 0, 0, $Date[1], $Date[2], $Date[0])); 105 if ($WeekOfYear != $LastWeekOfYear)105 if ($WeekOfYear != $LastWeekOfYear) 106 106 $WeekRowSpan = '<td align="center" rowspan="'.(7 - (($Week + 7 - 1) % 7)).'">'. 107 107 $WeekOfYear.'<br /><a href="tisk/?date='. … … 109 109 '">Tisk</a></td>'; 110 110 else $WeekRowSpan = ''; 111 if ($Week == 0) $Color = ' style="color: #ff0000;" '; else $Color = '';111 if ($Week == 0) $Color = ' style="color: #ff0000;" '; else $Color = ''; 112 112 $Output = '<tr><td'.$Color.'>'.$this->DayNames[$Week].'</td><td>'.HumanDate($Row['Date']).'</td>'.$WeekRowSpan.' 113 113 <td><input name="soup_'.$Row['Date'].'" size="30" value="'.$Row['Soup'].'"></td> 114 114 <td><input name="meal_'.$Row['Date'].'" size="30" value="'.$Row['Meal'].'"></td> 115 115 <td><select name="status_'.$Row['Date'].'">'; 116 for ($I = 0; $I < 4; $I++) $Output .= ' <option '.$Selected[$I].'value="'.$I.'">'.$this->Status[$I].'</option>';116 for ($I = 0; $I < 4; $I++) $Output .= ' <option '.$Selected[$I].'value="'.$I.'">'.$this->Status[$I].'</option>'; 117 117 $Output .= '</select></td></tr>'; 118 118 $LastWeekOfYear = $WeekOfYear; 119 return ($Output);119 return ($Output); 120 120 } 121 121 … … 125 125 126 126 $Output = ''; 127 if (array_key_exists('action', $_GET))128 { 129 if ($_GET['action'] == 'savemenu')130 { 131 for ($I = 0; $I < $this->DayCount; $I++)127 if (array_key_exists('action', $_GET)) 128 { 129 if ($_GET['action'] == 'savemenu') 130 { 131 for ($I = 0; $I < $this->DayCount; $I++) 132 132 { 133 133 $Time = time() + $I * 86400; … … 138 138 $this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'MenuSave'); 139 139 } 140 if ($_GET['action'] == 'saveinfo')140 if ($_GET['action'] == 'saveinfo') 141 141 { 142 142 $this->Database->delete('MealsInfo', '1'); … … 149 149 <fieldset><legend>Jídlo pro jednotlivé dny</legend> 150 150 <table align="center" class="WideTable"><tr><th>Den</th><th>Datum</th><th>Týden</th><th>Polévka</th><th>Hlavní jídlo</th><th>Stav</th></tr>'; 151 for ($I = 0; $I < $this->DayCount; $I++)151 for ($I = 0; $I < $this->DayCount; $I++) 152 152 { 153 153 $Time = time() + $I * 86400; 154 154 $DbResult = $this->Database->select('Meals', '*', 'Date = "'.date('Y-m-d', $Time).'"'); 155 if ($Row = $DbResult->fetch_array())155 if ($Row = $DbResult->fetch_array()) 156 156 $Output .= $this->PrintTableRow($Row); 157 157 else … … 173 173 '<div align="center"><input type="submit" value="Uložit údaje"></div> 174 174 </fieldset></form>'; 175 return ($Output);175 return ($Output); 176 176 } 177 177 } -
trunk/Modules/Meteostation/Download.php
r548 r873 4 4 5 5 $MeteoStation = new MeteoStation($System->Database, $System); 6 while (true)6 while (true) 7 7 { 8 8 $MeteoStation->DownloadAll(); -
trunk/Modules/Meteostation/Meteostation.php
r747 r873 11 11 $Output = 'Stav meteostanice:<br/>'; 12 12 $Output .= '<img src="'.$this->System->Link('/Modules/Meteostation/cache/1.png').'" alt="stav meteostanice"/>'; 13 return ($Output);13 return ($Output); 14 14 } 15 15 } … … 91 91 { 92 92 $DbResult = $this->Database->select('MeteoStation', '*'); 93 while ($DbRow = $DbResult->fetch_assoc())93 while ($DbRow = $DbResult->fetch_assoc()) 94 94 { 95 95 $MeteoStation = new MeteoStation(); -
trunk/Modules/Network/HostList.php
r833 r873 11 11 function Show() 12 12 { 13 if (!$this->System->User->CheckPermission('Network', 'ShowHostList'))14 return ('Nemáte oprávnění');13 if (!$this->System->User->CheckPermission('Network', 'ShowHostList')) 14 return ('Nemáte oprávnění'); 15 15 16 if (array_key_exists('admin', $_GET)) $Where = 'AND NetworkDevice.Type IN (1,4,5) ';16 if (array_key_exists('admin', $_GET)) $Where = 'AND NetworkDevice.Type IN (1,4,5) '; 17 17 else $Where = ''; 18 18 $Output = '<div align="center" style="font-size: small;"><table class="WideTable">'; … … 22 22 'LEFT JOIN User ON Member.ResponsibleUser = User.Id '. 23 23 'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 '.$Where.'ORDER BY NetworkDevice.Name'); 24 while ($Device = $DbResult->fetch_assoc())24 while ($Device = $DbResult->fetch_assoc()) 25 25 { 26 if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';26 if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = ''; 27 27 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE Device = '.$Device['Id']); 28 28 $DbRow = $DbResult2->fetch_row(); 29 if ($DbRow[0] == 1)29 if ($DbRow[0] == 1) 30 30 { 31 31 $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']); 32 32 $Interface = $DbResult2->fetch_assoc(); 33 if ($Interface['ExternalIP'] == '') $Interface['ExternalIP'] = ' ';34 if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = ' ';35 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';33 if ($Interface['ExternalIP'] == '') $Interface['ExternalIP'] = ' '; 34 if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = ' '; 35 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = ''; 36 36 $InterfaceName = $Device['Name']; 37 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];37 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name']; 38 38 $Output .= '<tr><td style="text-align: left; '.$Style.'">'.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td>'.$Interface['ExternalIP'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>'; 39 39 } else … … 41 41 $Output .= '<tr><td colspan="3" style="text-align: left; font-weight: bold; '.$Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>'; 42 42 $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']); 43 while ($Interface = $DbResult2->fetch_assoc())43 while ($Interface = $DbResult2->fetch_assoc()) 44 44 { 45 if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = ' ';46 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';45 if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = ' '; 46 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = ''; 47 47 $InterfaceName = $Device['Name']; 48 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];48 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name']; 49 49 $Output .= '<tr><td style="text-align: left; '.$Style.'"> '.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td> </td><td> </td><td> </td><td> </td></tr>'; 50 50 } … … 52 52 } 53 53 $Output .= '</table></div>'; 54 return ($Output);54 return ($Output); 55 55 } 56 56 } -
trunk/Modules/Network/Hosting.php
r790 r873 11 11 $Output = '<br /><table class="WideTable"><tr><th>Název projektu</th><th>Založeno</th><th>Umístění na serveru</th><th>Zodpovědná osoba</th></tr>'; 12 12 $DbResult = $this->Database->query('SELECT NetworkDevice.Name as ServerName, HostedProject.Name, HostedProject.Homepage, HostedProject.TimeCreate, User.Name AS UserName FROM HostedProject JOIN User ON User.Id = HostedProject.User JOIN NetworkDevice ON NetworkDevice.Id = HostedProject.Server ORDER BY HostedProject.Name'); 13 while ($DbRow = $DbResult->fetch_assoc())13 while ($DbRow = $DbResult->fetch_assoc()) 14 14 { 15 15 $Output .= '<tr><td><a href="'.$DbRow['Homepage'].'">'.$DbRow['Name'].'</a></td><td>'.HumanDate($DbRow['TimeCreate']).'</td><td>'.$DbRow['ServerName'].'</td><td>'.$DbRow['UserName'].'</td></tr>'; 16 16 } 17 17 $Output .= '</table>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 } -
trunk/Modules/Network/Network.php
r871 r873 25 25 '<tr><th/><br/>SSID<br/><br/></th>'; 26 26 $ChannelList = array(); 27 if (!array_key_exists('range', $_GET)) $_GET['range'] = 'a';28 if ($_GET['range'] == 'a')27 if (!array_key_exists('range', $_GET)) $_GET['range'] = 'a'; 28 if ($_GET['range'] == 'a') 29 29 { 30 30 $Where = '(Frequency < 5000)'; 31 for ($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq;31 for ($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq; 32 32 } 33 if ($_GET['range'] == 'bc')33 if ($_GET['range'] == 'bc') 34 34 { 35 35 $Where = '(Frequency >= 5000) AND (Frequency <= 5350)'; 36 for ($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq;36 for ($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq; 37 37 } 38 if ($_GET['range'] == 'd')38 if ($_GET['range'] == 'd') 39 39 { 40 40 $Where = '(Frequency >= 5470)'; 41 for ($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq;41 for ($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq; 42 42 } 43 43 44 foreach ($ChannelList as $Frequency)44 foreach ($ChannelList as $Frequency) 45 45 { 46 46 $Output .= '<th><div class="RotatedHeader">'.$Frequency.'<div></th>'; … … 48 48 $Output .= '</tr>'; 49 49 $DbResult = $this->Database->query('SELECT `Frequency` FROM `NetworkInterfaceWireless` WHERE '.$Where.' AND (`Mode`=0) GROUP BY `Frequency`'); 50 while ($DbRow = $DbResult->fetch_assoc())50 while ($DbRow = $DbResult->fetch_assoc()) 51 51 { 52 52 $DbResult2 = $this->Database->query('SELECT * FROM `NetworkInterfaceWireless` WHERE (`Frequency`='.$DbRow['Frequency'].') AND '.$Where); 53 while ($DbRow2 = $DbResult2->fetch_assoc())53 while ($DbRow2 = $DbResult2->fetch_assoc()) 54 54 { 55 55 $LowFrequency = $DbRow['Frequency'] - $DbRow2['ChannelWidth'] / 2 - $DbRow2['ChannelWidthLower']; 56 56 $HighFrequency = $DbRow['Frequency'] + $DbRow2['ChannelWidth'] / 2 + $DbRow2['ChannelWidthUpper']; 57 57 $Output .= '<tr><td>'.$DbRow2['SSID'].'</td>'; 58 foreach ($ChannelList as $Frequency)58 foreach ($ChannelList as $Frequency) 59 59 { 60 if (($DbRow2['Frequency'] == $Frequency)) $Color = '#000000';61 else if (($LowFrequency <= ($Frequency - 2.5)) and ($HighFrequency >= ($Frequency + 2.5))) $Color = '#808080';62 else if (($LowFrequency == $Frequency) or ($HighFrequency == $Frequency)) $Color = '#c0c0c0';60 if (($DbRow2['Frequency'] == $Frequency)) $Color = '#000000'; 61 else if (($LowFrequency <= ($Frequency - 2.5)) and ($HighFrequency >= ($Frequency + 2.5))) $Color = '#808080'; 62 else if (($LowFrequency == $Frequency) or ($HighFrequency == $Frequency)) $Color = '#c0c0c0'; 63 63 else $Color = '#ffffff'; 64 64 $Output .= '<td style="background-color: '.$Color.';"> </td>'; … … 69 69 } 70 70 $Output .= '</table>'; 71 return ($Output);71 return ($Output); 72 72 } 73 73 } … … 81 81 function Show() 82 82 { 83 if (count($this->System->PathItems) > 1)83 if (count($this->System->PathItems) > 1) 84 84 { 85 85 $Output = $this->PageNotFound(); 86 86 } else $Output = $this->ShowInformation(); 87 return ($Output);87 return ($Output); 88 88 } 89 89 90 90 function ShowInformation() 91 91 { 92 if (!$this->System->User->CheckPermission('Network', 'ShowInfo'))93 return ('Nemáte oprávnění');92 if (!$this->System->User->CheckPermission('Network', 'ShowInfo')) 93 return ('Nemáte oprávnění'); 94 94 95 95 $Output = '<a href="'.$this->System->Link('/network/frequency-plan/').'">Frekvenční plán</a><br />'; 96 96 $Output .= '<a href="'.$this->System->Link('/network/subnet/').'">Výpis registrovaných podsítí</a><br />'; 97 97 $Output .= '<a href="'.$this->System->Link('/network/hosts/').'">Registrované zařízení</a><br />'; 98 return ($Output);98 return ($Output); 99 99 } 100 100 } … … 862 862 '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkInterface`.`Enabled`=1)'. 863 863 'ORDER BY `Name` ASC'); 864 if ($DbResult3->num_rows > 0)864 if ($DbResult3->num_rows > 0) 865 865 { 866 866 $Output .= $Title.'<br/>'; 867 867 $Output .= '<table>'. 868 868 '<tr><th align="center">Jméno</th><th align="center">Stav</th><th align="center">Čas</th><th align="center">Trvání</th></tr>'."\n"; 869 while ($Item = $DbResult3->fetch_assoc())869 while ($Item = $DbResult3->fetch_assoc()) 870 870 { 871 871 $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']); … … 874 874 sprintf('%02d', floor($Duration % 60)); 875 875 $Days = floor($Duration / (60 * 60 * 24)); 876 if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText;876 if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText; 877 877 878 878 $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']]. … … 895 895 $Output .= $StillOffline['Report']; 896 896 $Offline = $this->OnlineList('Offline', 0, -1, 0); 897 return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva'));897 return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva')); 898 898 } 899 899 … … 918 918 $Output .= '<table>'. 919 919 '<tr><th align="center">Jméno</th><th align="center">Stav</th><th align="center">Čas</th><th align="center">Trvání</th></tr>'."\n"; 920 while ($Item = $DbResult3->fetch_assoc())920 while ($Item = $DbResult3->fetch_assoc()) 921 921 { 922 922 $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']); … … 925 925 sprintf('%02d', floor($Duration % 60)); 926 926 $Days = floor($Duration / (60 * 60 * 24)); 927 if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText;927 if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText; 928 928 929 929 $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']]. … … 947 947 $Output .= $StillOffline['Report']; 948 948 $Offline = $this->PortCheckList('Offline', 0, -1, 0); 949 return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port'));949 return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port')); 950 950 } 951 951 } -
trunk/Modules/Network/Subnet.php
r825 r873 36 36 37 37 $DbResult = $this->Database->query($Query); 38 while ($Subnet = $DbResult->fetch_assoc())38 while ($Subnet = $DbResult->fetch_assoc()) 39 39 { 40 40 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE CompareNetworkPrefix(INET_ATON("'.$Subnet['AddressRange'].'"), INET_ATON(LocalIP), '.$Subnet['Mask'].')'); … … 54 54 $Output .= '</table>'; 55 55 $Output .= $PageList['Output']; 56 return ($Output);56 return ($Output); 57 57 } 58 58 } -
trunk/Modules/Network/UserHosts.php
r738 r873 15 15 global $Config; 16 16 17 if ($this->System->User->User['Id'] == '') return($this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci'));17 if ($this->System->User->User['Id'] == '') return ($this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci')); 18 18 $Output = '<div align="center" style="font-size: small;"><table class="WideTable">'; 19 19 $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>'; … … 21 21 'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '. 22 22 'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->User->User['Id'].') ORDER BY NetworkDevice.Name'); 23 while ($Device = $DbResult->fetch_assoc())23 while ($Device = $DbResult->fetch_assoc()) 24 24 { 25 if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';25 if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = ''; 26 26 $Output .= '<tr><td colspan="4" style="text-align: left; font-weight: bold; '. 27 27 $Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td></tr>'; 28 28 $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']); 29 while ($Interface = $DbResult2->fetch_assoc())29 while ($Interface = $DbResult2->fetch_assoc()) 30 30 { 31 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';31 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = ''; 32 32 $InterfaceName = $Device['Name']; 33 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];33 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name']; 34 34 $Output .= '<tr><td style="text-align: left; '.$Style.'"> '. 35 35 $InterfaceName.'</td><td>'.NotBlank($Interface['LocalIP']).'</td><td>'. … … 39 39 } 40 40 $Output .= '</table></div>'; 41 return ($Output);41 return ($Output); 42 42 } 43 43 } -
trunk/Modules/NetworkConfig/Generate.php
r848 r873 1 1 <?php 2 2 3 if (isset($_SERVER['REMOTE_ADDR'])) die();3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 include_once(dirname(__FILE__).'/../../Application/System.php'); 5 5 $System = new Core(); … … 9 9 $Now = time(); 10 10 $DbResult = $System->Database->select('NetworkConfiguration', '*, UNIX_TIMESTAMP(`LastTime`)', '(`Changed` = 1) AND (`Enabled` = 1)'); 11 while ($Service = $DbResult->fetch_assoc())11 while ($Service = $DbResult->fetch_assoc()) 12 12 { 13 if ($Service['UNIX_TIMESTAMP(LastTime)'] < (time() - $Service['Period']))13 if ($Service['UNIX_TIMESTAMP(LastTime)'] < (time() - $Service['Period'])) 14 14 { 15 15 $System->Database->update('NetworkConfiguration', '`Id`='.$Service['Id'], array('Changed' => 2)); … … 19 19 $ExecuteParts = explode('|', $Service['Execute']); 20 20 $Output = array(); 21 foreach ($ExecuteParts as $Command)22 if ($Command != '')21 foreach ($ExecuteParts as $Command) 22 if ($Command != '') 23 23 { 24 24 exec($Command, $Output); -
trunk/Modules/NetworkConfig/NetworkConfig.php
r820 r873 80 80 { 81 81 $Output = ''; 82 if ($Parameters >= 3)82 if ($Parameters >= 3) 83 83 { 84 84 $ConfigItemName = $Parameters[2]; 85 if (array_key_exists($ConfigItemName, $this->ConfigItems))85 if (array_key_exists($ConfigItemName, $this->ConfigItems)) 86 86 { 87 87 $ClassName = $this->ConfigItems[$ConfigItemName]; … … 90 90 } else $Output = 'Config item '.$ConfigItemName.' not found'; 91 91 } else $Output = 'Not enough parameters'; 92 return ($Output);92 return ($Output); 93 93 } 94 94 } -
trunk/Modules/NetworkConfigAirOS/Generators/SSHClient.php
r856 r873 25 25 { 26 26 $Commands = trim($Commands); 27 if ($Commands != '')27 if ($Commands != '') 28 28 { 29 29 $Commands = addslashes($Commands); … … 34 34 $Command = $this->SSHPath.' -oBatchMode=yes -o ConnectTimeout='.$this->Timeout.' -l '. 35 35 $this->UserName.$PrivKey.' '.$this->HostName.' "'.$Commands.'"'; 36 if ($this->Debug) echo($Command);36 if ($this->Debug) echo($Command); 37 37 $Output = array(); 38 38 exec($Command, $Output); 39 39 } else $Output = ''; 40 if ($this->Debug) print_r($Output);41 return ($Output);40 if ($this->Debug) print_r($Output); 41 return ($Output); 42 42 } 43 43 } -
trunk/Modules/NetworkConfigAirOS/Generators/Signal.php
r856 r873 13 13 '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '. 14 14 'FROM `NetworkDevice` WHERE (`API` = 2) AND (`Used` = 1)'); 15 while ($Device = $DbResult3->fetch_assoc())15 while ($Device = $DbResult3->fetch_assoc()) 16 16 { 17 17 echo($Device['LocalIP'].""); … … 25 25 //print_r($Array); 26 26 echo('-'); 27 foreach ($Array as $Properties)27 foreach ($Array as $Properties) 28 28 { 29 29 $DbResult = $this->Database->select('NetworkInterface', 'Id', '`MAC`="'.$Properties['mac'].'"'); 30 if ($DbResult->num_rows > 0)30 if ($DbResult->num_rows > 0) 31 31 { 32 32 $DbRow = $DbResult->fetch_assoc(); -
trunk/Modules/NetworkConfigLinux/Generators/CheckPorts.php
r819 r873 7 7 $Timeout = 1; 8 8 $State = 0; 9 if ($Protocol == 'tcp') $Prefix = '';10 else if ($Protocol == 'udp') $Prefix = 'udp://';9 if ($Protocol == 'tcp') $Prefix = ''; 10 else if ($Protocol == 'udp') $Prefix = 'udp://'; 11 11 else throw new Exception('Unsupported protocol "'.$Protocol.'"'); 12 if ($Socket = @fsockopen($Prefix.$IP, $Port, $ErrorNumber, $ErrorString, $Timeout))12 if ($Socket = @fsockopen($Prefix.$IP, $Port, $ErrorNumber, $ErrorString, $Timeout)) 13 13 { 14 14 fclose($Socket); 15 15 $State = 1; 16 16 } 17 return ($State);17 return ($State); 18 18 } 19 19 … … 29 29 'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id`=`NetworkPort`.`Interface` '. 30 30 'WHERE (`NetworkPort`.`Enabled`=1) AND (`NetworkInterface`.`LocalIP` !="")'); 31 while ($DbRow = $DbResult->fetch_assoc())31 while ($DbRow = $DbResult->fetch_assoc()) 32 32 $Ports[$DbRow['Id']] = $DbRow; 33 33 34 foreach ($Ports as $Index => $Port)34 foreach ($Ports as $Index => $Port) 35 35 { 36 if ($Port['Protocol'] == 0) $Port['Protocol'] = 'tcp';37 if ($Port['Protocol'] == 1) $Port['Protocol'] = 'udp';36 if ($Port['Protocol'] == 0) $Port['Protocol'] = 'tcp'; 37 if ($Port['Protocol'] == 1) $Port['Protocol'] = 'udp'; 38 38 $Port['NewOnline'] = $this->CheckPortStatus($Port['LocalIP'], $Port['Number'], $Port['Protocol']); 39 39 40 40 // Update last online time if still online 41 if ($Port['NewOnline'])41 if ($Port['NewOnline']) 42 42 { 43 43 $DbResult = $this->Database->update('NetworkPort', '`Id` = "'.$Port['Id'].'"', … … 46 46 47 47 // Update UpDown table 48 if ($Port['Online'] != $Port['NewOnline'])48 if ($Port['Online'] != $Port['NewOnline']) 49 49 { 50 50 // Online state changed … … 65 65 $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 1) AND '. 66 66 '(`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'")'); 67 while ($DbRow = $DbResult->fetch_assoc())67 while ($DbRow = $DbResult->fetch_assoc()) 68 68 { 69 69 echo('Port '.$DbRow['Number'].' online but time not updated.'."\n"); … … 71 71 $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 0) AND '. 72 72 '(`LastOnline` >= "'.TimeToMysqlDateTime($StartTime).'")'); 73 while ($DbRow = $DbResult->fetch_assoc())73 while ($DbRow = $DbResult->fetch_assoc()) 74 74 { 75 75 echo('Port '.$DbRow['Number'].' not online but time updated.'."\n"); -
trunk/Modules/NetworkConfigLinux/Generators/DHCP.php
r790 r873 1 1 <?php 2 2 3 if (isset($_SERVER['REMOTE_ADDR'])) die();3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 /* 5 5 include_once('../../global.php'); … … 23 23 'option netbios-scope "";'."\n". 24 24 "server-identifier 192.168.0.1;\n\n"); 25 for ($i = 0; $i <= $MaxSubnet; $i++)25 for ($i = 0; $i <= $MaxSubnet; $i++) 26 26 { 27 27 fputs($File, "subnet 192.168.".$i.".0 netmask 255.255.255.0 {\n". … … 30 30 " option routers 192.168.".$i.".1;\n"); 31 31 $DbResult = $Database->select('hosts', '*', "IP LIKE '192.168.".$i."%' ORDER BY IP"); 32 while ($Row = $DbResult->fetch_array())32 while ($Row = $DbResult->fetch_array()) 33 33 { 34 34 $Data = $Row['name']; 35 if (strlen($Data) < 9) $Data .= "\t";35 if (strlen($Data) < 9) $Data .= "\t"; 36 36 fputs($File, " host ".$Data."\t{ fixed-address ".$Row['IP'].";\thardware ethernet ".$Row['MAC']."; }\n"); 37 37 } -
trunk/Modules/NetworkConfigLinux/Generators/DNS.php
r854 r873 18 18 "\t\t\t".$DNS['Minimum']."\t; minimum\n". 19 19 "\t\t\t)\n"; 20 foreach ($DNS['NameServer'] as $NameServer)20 foreach ($DNS['NameServer'] as $NameServer) 21 21 { 22 22 $Output .= "\t\tIN\tNS\t".strtolower($NameServer).".\n"; … … 26 26 // Mail server records 27 27 $Priority = 10; 28 foreach ($DNS['MailServer'] as $MailServer)28 foreach ($DNS['MailServer'] as $MailServer) 29 29 { 30 30 $Output .="\t\t\tMX\t".$Priority." ".strtolower($MailServer).".\n"; … … 34 34 $DNS['Domain'].".\tIN\tTXT\t\"v=spf1 mx -all\"\n". 35 35 $DNS['Domain'].".\tIN\tSPF\t\"v=spf1 mx -all\"\n"; 36 foreach ($DNS['MailServer'] as $MailServer)36 foreach ($DNS['MailServer'] as $MailServer) 37 37 { 38 38 $Output .= $MailServer.".\tIN\tTXT\t\"v=spf1 a -all\"\n". … … 45 45 46 46 // IPv4 host list 47 foreach ($DNS['Host'] as $Host)48 { 49 if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t";47 foreach ($DNS['Host'] as $Host) 48 { 49 if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t"; 50 50 $Output .= strtolower($Host['Name'])."\tIN\tA\t".$Host['Address']."\n"; 51 51 } 52 52 53 53 // IPv6 host list 54 foreach ($DNS['Host'] as $Host)55 { 56 if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t";57 if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))54 foreach ($DNS['Host'] as $Host) 55 { 56 if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t"; 57 if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != '')) 58 58 $Output .= strtolower($Host['Name'])."\tIN\tAAAA\t".$Host['IPv6']."\n"; 59 59 } 60 60 61 61 // Alias list 62 foreach ($DNS['Alias'] as $Alias)63 { 64 if (strlen($Alias['Name']) < 8) $Alias['Name'] .= "\t";62 foreach ($DNS['Alias'] as $Alias) 63 { 64 if (strlen($Alias['Name']) < 8) $Alias['Name'] .= "\t"; 65 65 $Output .= strtolower($Alias['Name'])."\tIN\tCNAME\t".strtolower($Alias['Target'])."\n"; 66 66 } … … 71 71 72 72 // Generate reverse DNS records 73 foreach ($DNS['Network'] as $Network)73 foreach ($DNS['Network'] as $Network) 74 74 { 75 75 $Parts = explode('.', $Network); … … 83 83 "\t\t\t\t".$DNS['Minimum']."\t; minimum\n". 84 84 "\t\t\t\t)\n"; 85 foreach ($DNS['ReverseNameServer'] as $NameServer)85 foreach ($DNS['ReverseNameServer'] as $NameServer) 86 86 { 87 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])87 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain']) 88 88 $Output .= "@\tIN\tNS\t".$NameServer.".\n"; 89 89 else $Output .= "\tIN\tNS\t".$NameServer.".\n"; 90 90 } 91 foreach ($DNS['Host'] as $Host)92 if (substr($Host['Address'], 0, strlen($Network)) == $Network)91 foreach ($DNS['Host'] as $Host) 92 if (substr($Host['Address'], 0, strlen($Network)) == $Network) 93 93 { 94 94 $AddressParts = explode('.', $Host['Address']); … … 103 103 104 104 // Generate reverse DNS IPv6 records 105 foreach ($DNS['IPv6Network'] as $Network)105 foreach ($DNS['IPv6Network'] as $Network) 106 106 { 107 107 $Parts = explode('/', $Network); … … 117 117 "\t\t\t\t".$DNS['Minimum']."\t; minimum\n". 118 118 "\t\t\t\t)\n"; 119 foreach ($DNS['ReverseNameServer'] as $NameServer)119 foreach ($DNS['ReverseNameServer'] as $NameServer) 120 120 { 121 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])121 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain']) 122 122 $Output .= "@\tIN\tNS\t".$NameServer.".\n"; 123 123 else $Output .= "\tIN\tNS\t".$NameServer.".\n"; 124 124 } 125 foreach ($DNS['Host'] as $Host)126 if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))125 foreach ($DNS['Host'] as $Host) 126 if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != '')) 127 127 { 128 128 $Addr = new NetworkAddressIPv6(); … … 161 161 $BaseDir = '/var/cache/bind'; 162 162 //$BaseDir = '/home/chronos/Projekty/centrala/trunk/var/named'; 163 if (!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.');163 if (!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.'); 164 164 $MailServer = 'centrala'; 165 165 … … 193 193 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '. 194 194 'WHERE (`NetworkInterface`.`LocalIP` <> "") AND (`NetworkDevice`.`Used` = 1)'); 195 while ($Interface = $DbResult->fetch_assoc())196 { 197 $Name = $Interface['DeviceName']; 198 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];195 while ($Interface = $DbResult->fetch_assoc()) 196 { 197 $Name = $Interface['DeviceName']; 198 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 199 199 $LocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP'], 200 200 'IPv6' => $Interface['IPv6']); … … 205 205 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '. 206 206 'WHERE (`NetworkInterface`.`ExternalIP` <> "") AND (`NetworkDevice`.`Used` = 1)'); 207 while ($Interface = $DbResult->fetch_assoc())208 { 209 $Name = $Interface['DeviceName']; 210 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];207 while ($Interface = $DbResult->fetch_assoc()) 208 { 209 $Name = $Interface['DeviceName']; 210 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 211 211 $LocalDNS['Host'][] = array('Name' => $Name.'-ext', 'Address' => $Interface['ExternalIP']); 212 212 } … … 216 216 $DbResult = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface '. 217 217 'JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.CZFreeIP <> ""'); 218 while ($Interface = $DbResult->fetch_assoc())218 while ($Interface = $DbResult->fetch_assoc()) 219 219 { 220 220 $Name = $Interface['DeviceName']; 221 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];221 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 222 222 $LocalDNS['Host'][] = array('Name' => $Name.'-czfree', 'Address' => $Interface['CZFreeIP']); 223 223 } … … 226 226 // Domain aliases 227 227 $DbResult = $this->Database->select('NetworkDomainAlias', '*'); 228 while ($Alias = $DbResult->fetch_assoc())228 while ($Alias = $DbResult->fetch_assoc()) 229 229 { 230 230 $LocalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); … … 257 257 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE '. 258 258 '(`NetworkInterface`.`ExternalIP` != "") AND (`NetworkDevice`.`Used` = 1)'); 259 while ($Interface = $DbResult->fetch_assoc())260 { 261 $Name = $Interface['DeviceName']; 262 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];259 while ($Interface = $DbResult->fetch_assoc()) 260 { 261 $Name = $Interface['DeviceName']; 262 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 263 263 $ExternalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['ExternalIP'], 264 264 'IPv6' => $Interface['IPv6']); … … 268 268 $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`'); 269 269 // JOIN `NetworkDevice` ON NetworkDomainAlias.Target LIKE NetworkDevice.Name AND NetworkInterface.ExternalIP != ""'); 270 while ($Alias = $DbResult->fetch_assoc())270 while ($Alias = $DbResult->fetch_assoc()) 271 271 { 272 272 $ExternalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); … … 302 302 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '. 303 303 'WHERE (`NetworkInterface`.`LocalIP` != "") AND (`NetworkDevice`.`Used` = 1)'); 304 while ($Interface = $DbResult->fetch_assoc())305 { 306 $Name = $Interface['DeviceName']; 307 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];304 while ($Interface = $DbResult->fetch_assoc()) 305 { 306 $Name = $Interface['DeviceName']; 307 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 308 308 $CZFreeDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']); 309 309 } … … 312 312 $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`'); 313 313 // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""'); 314 while ($Alias = $DbResult->fetch_assoc())314 while ($Alias = $DbResult->fetch_assoc()) 315 315 { 316 316 $CZFreeDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); … … 344 344 $DbResult = $this->Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface` '. 345 345 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE `NetworkInterface`.`LocalIP` != ""'); 346 while ($Interface = $DbResult->fetch_assoc())347 { 348 $Name = $Interface['DeviceName']; 349 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];346 while ($Interface = $DbResult->fetch_assoc()) 347 { 348 $Name = $Interface['DeviceName']; 349 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 350 350 // $CZFreeLocalDNS['Host'][] = array('Name' => $Name.'-czfree', 'Address' => $Interface['LocalIP']); 351 351 $CZFreeLocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']); … … 355 355 $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`'); 356 356 // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""'); 357 while ($Alias = $DbResult->fetch_assoc())357 while ($Alias = $DbResult->fetch_assoc()) 358 358 { 359 359 $CZFreeLocalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); -
trunk/Modules/NetworkConfigLinux/Generators/IPTables.php
r790 r873 1 1 <?php 2 if (isset($_SERVER['REMOTE_ADDR'])) die();2 if (isset($_SERVER['REMOTE_ADDR'])) die(); 3 3 include_once('../../../Common/Global.php'); 4 4 … … 14 14 // Blocking according IP address 15 15 $DbResult = $Database->select('users', '*', 'inet = 0'); 16 while ($User = $DbResult->fetch_array())16 while ($User = $DbResult->fetch_array()) 17 17 { 18 18 $DbResult2 = $Database->select('hosts', '*', "block<2 AND MAC!='' AND user=".$User['id']); 19 while ($Row = $DbResult2->fetch_array())19 while ($Row = $DbResult2->fetch_array()) 20 20 { 21 21 exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local'); … … 23 23 } 24 24 $DbResult = $Database->select('users', '*', 'inet = 1'); 25 while ($User = $DbResult->fetch_array())25 while ($User = $DbResult->fetch_array()) 26 26 { 27 27 $DbResult2 = $Database->select('hosts','*',"block<2 AND MAC!='' AND vpn=1 AND user=".$User['id']); 28 while ($Row = $DbResult2->fetch_array())28 while ($Row = $DbResult2->fetch_array()) 29 29 { 30 30 exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local'); … … 36 36 // Blocking according MAC address 37 37 $DbResult = $Database->select('users', '*'); 38 while ($User = $DbResult->fetch_array())38 while ($User = $DbResult->fetch_array()) 39 39 { 40 40 //echo($User['fullname']."\n"); 41 41 $DbResult2 = $Database->select('hosts', '*', '(block < 2) AND (MAC != "") AND (user='.$User['id'].') AND (IP != external_ip) ORDER BY id DESC'); 42 while ($Row = $DbResult2->fetch_array())42 while ($Row = $DbResult2->fetch_array()) 43 43 { 44 44 //echo(' '.$Row['name']." ".$Row['MAC']." "); 45 if ($User['inet'] == 0)45 if ($User['inet'] == 0) 46 46 { 47 //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");47 //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 48 48 // else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 49 49 } else { 50 if ($Row['vpn'] == 0)50 if ($Row['vpn'] == 0) 51 51 { 52 52 $CZFreeLocalIP = $Row['IP']; 53 53 //echo($Row['external_ip']."\n"); 54 //if ($Row['name'] == 'TBC')54 //if ($Row['name'] == 'TBC') 55 55 //{ 56 56 // exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725'); 57 57 // exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o '.$InetInterface.' -j SNAT --to-source '.$Row['external_ip'].':3724'); 58 58 //} 59 if (strtolower($Row['name']) != 'gate')59 if (strtolower($Row['name']) != 'gate') 60 60 { 61 if ($Row['external_ip'] != '')61 if ($Row['external_ip'] != '') 62 62 { 63 63 echo($Row['name'].'='.$Row['external_ip']."\n"); … … 75 75 //echo('vpn'); 76 76 //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP'); 77 if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');77 if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT'); 78 78 exec('/sbin/iptables -t nat -A Block -s '.ToVpnIp($Row)." -j Proxy"); 79 79 80 //if ($Row['vpn'] == 1)80 //if ($Row['vpn'] == 1) 81 81 //{ 82 82 //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 83 //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");83 //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 84 84 } 85 if ($Row['czfree_ip'] != '')85 if ($Row['czfree_ip'] != '') 86 86 { 87 87 // CZFree -
trunk/Modules/NetworkConfigLinux/Generators/Latency.php
r852 r873 14 14 'FROM `NetworkInterface` '. 15 15 'WHERE (`NetworkInterface`.`Enabled`=1) AND (`NetworkInterface`.`LocalIP` !="")'); 16 while ($DbRow = $DbResult->fetch_assoc())16 while ($DbRow = $DbResult->fetch_assoc()) 17 17 { 18 18 $Hosts[] = $DbRow['LocalIP']; … … 23 23 24 24 $Queries = array(); 25 foreach ($Output as $Index => $Line)25 foreach ($Output as $Index => $Line) 26 26 { 27 27 $IP = substr($Line, 0, strPos($Line, ' ')); -
trunk/Modules/NetworkConfigLinux/Generators/NAT.php
r790 r873 1 1 <?php 2 if (isset($_SERVER['REMOTE_ADDR'])) die();2 if (isset($_SERVER['REMOTE_ADDR'])) die(); 3 3 include_once('../../../Common/Global.php'); 4 4 … … 14 14 // Blocking according IP address 15 15 $DbResult = $Database->select('users', '*', 'inet = 0'); 16 while ($User = $DbResult->fetch_array())16 while ($User = $DbResult->fetch_array()) 17 17 { 18 18 $DbResult2 = $Database->select('hosts', '*', "block<2 AND MAC!='' AND user=".$User['id']); 19 while ($Row = $DbResult2->fetch_array())19 while ($Row = $DbResult2->fetch_array()) 20 20 { 21 21 exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local'); … … 23 23 } 24 24 $DbResult = $Database->select('users', '*', 'inet = 1'); 25 while ($User = $DbResult->fetch_array())25 while ($User = $DbResult->fetch_array()) 26 26 { 27 27 $DbResult2 = $Database->select('hosts','*',"block<2 AND MAC!='' AND vpn=1 AND user=".$User['id']); 28 while ($Row = $DbResult2->fetch_array())28 while ($Row = $DbResult2->fetch_array()) 29 29 { 30 30 exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local'); … … 36 36 // Blocking according MAC address 37 37 $DbResult = $Database->select('users', '*'); 38 while ($User = $DbResult->fetch_array())38 while ($User = $DbResult->fetch_array()) 39 39 { 40 40 //echo($User['fullname']."\n"); 41 41 $DbResult2 = $Database->select('hosts','*','block<2 AND MAC!="" AND user='.$User['id'].' ORDER BY id DESC'); 42 while ($Row = $DbResult2->fetch_array())42 while ($Row = $DbResult2->fetch_array()) 43 43 { 44 44 //echo(' '.$Row['name']." ".$Row['MAC']." "); 45 if ($User['inet'] == 0)45 if ($User['inet'] == 0) 46 46 { 47 //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");47 //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 48 48 // else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 49 49 } else { 50 if ($Row['vpn'] == 0)50 if ($Row['vpn'] == 0) 51 51 { 52 52 $CZFreeLocalIP = $Row['IP']; 53 53 //echo($Row['external_ip']."\n"); 54 //if ($Row['name'] == 'TBC')54 //if ($Row['name'] == 'TBC') 55 55 //{ 56 56 // exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725'); 57 57 // exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o eth1 -j SNAT --to-source '.$Row['external_ip'].':3724'); 58 58 //} 59 if (strtolower($Row['name']) != 'centrala')59 if (strtolower($Row['name']) != 'centrala') 60 60 { 61 if ($Row['external_ip'] != '')61 if ($Row['external_ip'] != '') 62 62 { 63 63 echo($Row['name'].'='.$Row['external_ip']."\n"); … … 75 75 //echo('vpn'); 76 76 //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP'); 77 if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');77 if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT'); 78 78 exec('/sbin/iptables -t nat -A Block -s '.ToVpnIp($Row)." -j Proxy"); 79 79 80 //if ($Row['vpn'] == 1)80 //if ($Row['vpn'] == 1) 81 81 //{ 82 82 //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 83 //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");83 //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 84 84 } 85 if ($Row['czfree_ip'] != '')85 if ($Row['czfree_ip'] != '') 86 86 { 87 87 // CZFree -
trunk/Modules/NetworkConfigLinux/Generators/TrafficShaping.php
r790 r873 1 1 <?php 2 2 3 if (isset($_SERVER['REMOTE_ADDR'])) die();3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 5 5 $Enabled = 1; … … 37 37 exec('/sbin/iptables -t mangle -F PREROUTING'); 38 38 exec('/sbin/iptables -t mangle -F POSTROUTING'); 39 if ($Enabled)39 if ($Enabled) 40 40 { 41 41 //exec('/sbin/iptables -t mangle -A FORWARD -j MARK --set-mark 0'); … … 48 48 // In going traffic 49 49 fputs($File, "/sbin/tc qdisc del dev ".$InInterface." root\n"); 50 if ($Enabled)50 if ($Enabled) 51 51 { 52 52 fputs($File, "/sbin/tc qdisc add dev ".$InInterface." root handle 1:0 htb default 2\n"); … … 59 59 // Out going traffic 60 60 fputs($File, "/sbin/tc qdisc del dev ".$OutInterface." root\n"); 61 if ($Enabled)61 if ($Enabled) 62 62 { 63 63 fputs($File, "/sbin/tc qdisc add dev ".$OutInterface." root handle 1:0 htb default 2\n"); … … 69 69 } 70 70 71 if (!$Enabled) die("Traffic shaping disabled\n");72 73 if ($ClassesEnabled)71 if (!$Enabled) die("Traffic shaping disabled\n"); 72 73 if ($ClassesEnabled) 74 74 { 75 75 $ClassId = 3; … … 124 124 125 125 $DbResult = $Database->select('users', '*, CONCAT(second_name, " ", first_name) as fullname', '(inet=1)'); 126 while ($User = $DbResult->fetch_array())126 while ($User = $DbResult->fetch_array()) 127 127 { 128 128 $UserClassId = $ClassId; … … 152 152 153 153 $DbResult2 = $Database->select('hosts','*',"block=0 AND MAC!='' AND user=".$User['id']); 154 while ($Host = $DbResult2->fetch_array())155 //if ($Row['name'] != 'WOW')154 while ($Host = $DbResult2->fetch_array()) 155 //if ($Row['name'] != 'WOW') 156 156 { 157 157 $HostClassId = $ClassId; … … 160 160 fputs($FileClassInfo, '1:'.$HostClassId.' '.$Host['name']."\n"); 161 161 //echo(' Host class id: '.$HostClassId."\n"); 162 //if ($User['inet'] == 1)162 //if ($User['inet'] == 1) 163 163 { 164 164 $Prio = 1; 165 if ($Host['vpn'] == 1)165 if ($Host['vpn'] == 1) 166 166 { 167 if ($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip'];167 if ($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip']; 168 168 else $Host['IP'] = ToVpnIp($Host); 169 169 } 170 170 171 //if ($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5;171 //if ($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5; 172 172 //else 173 173 $SpeedDivider = 1; 174 174 175 if ($Host['name'] == 'centrala')175 if ($Host['name'] == 'centrala') 176 176 { 177 177 $Host['IP'] = $Host['external_ip']; … … 183 183 $TableIn = 'FORWARD'; 184 184 } 185 //if ($Row['name'] == 'TERMINAL2') $Prio = 0;186 // if ($Row['name'] = 'TERMINAL2') $Prio = 0;187 if ($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp';185 //if ($Row['name'] == 'TERMINAL2') $Prio = 0; 186 // if ($Row['name'] = 'TERMINAL2') $Prio = 0; 187 if ($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp'; 188 188 else $Protocol = ''; 189 // if ($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000;189 // if ($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000; 190 190 /* 191 if ($Host['name'] == 'GAME')191 if ($Host['name'] == 'GAME') 192 192 { 193 193 exec('/sbin/iptables -t mangle -F game-server'); … … 195 195 $TableIn = 'game-server'; 196 196 }*/ 197 //if ($Host['name'] == 'TBC') continue;197 //if ($Host['name'] == 'TBC') continue; 198 198 199 199 // In going traffic … … 213 213 } 214 214 // Free inet 215 if ($Tarify[$User['inet_tarif_now']]['group_id'] == 3)215 if ($Tarify[$User['inet_tarif_now']]['group_id'] == 3) 216 216 { 217 217 //exec('/sbin/iptables -t mangle -A '.$TableIn.' -i eth1 -d '.$Host['IP'].$Protocol." -j MARK --set-mark ".$FreeInetClass); … … 220 220 // VoIP devices 221 221 /* 222 if (($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP'))222 if (($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP')) 223 223 { 224 224 exec('/sbin/iptables -t mangle -A '.$TableIn." -i eth1 -d ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId); 225 225 exec('/sbin/iptables -t mangle -A '.$TableOut." -o eth1 -s ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId); 226 226 } else 227 if ($Host['name'] == 'GAME')227 if ($Host['name'] == 'GAME') 228 228 { 229 229 exec('/sbin/iptables -t mangle -A FORWARD -o eth1 -s '.$Host['IP']." -j game-server"); -
trunk/Modules/NetworkConfigRouterOS/Generators/AddressPortability.php
r738 r873 1 1 <?php 2 2 3 if (isset($_SERVER['REMOTE_ADDR'])) die();3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 5 include_once(dirname(__FILE__).'/../Routerboard.php'); … … 11 11 { 12 12 $TimeParts = explode(':', $Time); 13 return ($TimeParts[0] * 3600 + $TimeParts[1] * 60 + $TimeParts[2]);13 return ($TimeParts[0] * 3600 + $TimeParts[1] * 60 + $TimeParts[2]); 14 14 } 15 15 … … 19 19 20 20 $DbResult3 = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0 GROUP BY `DHCP`'); 21 while ($Subnet = $DbResult3->fetch_assoc())21 while ($Subnet = $DbResult3->fetch_assoc()) 22 22 { 23 23 echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n"); 24 24 $Routerboard->HostName = $Subnet['DHCP']; 25 25 $List = $Routerboard->ListGet($Path, array('address', 'active-mac-address', 'active-address', 'expires-after', 'server', 'dynamic')); 26 foreach ($List as $Properties)26 foreach ($List as $Properties) 27 27 { 28 if ($Properties['dynamic'] == 'true')28 if ($Properties['dynamic'] == 'true') 29 29 //and ($Properties['address'] != $Properties['active-address'])) 30 30 { … … 32 32 echo('MAC: '.$Properties['active-mac-address']."\n"); 33 33 $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterface` WHERE `MAC`="'.$Properties['active-mac-address'].'"'); 34 if ($DbRows2->num_rows > 0)34 if ($DbRows2->num_rows > 0) 35 35 { 36 36 $Interface = $DbRows2->fetch_assoc(); 37 37 $InterfaceId = $Interface['Id']; 38 38 $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterfacePortable` WHERE `NetworkInterface`='.$InterfaceId); 39 if ($DbRows2->num_rows > 0)39 if ($DbRows2->num_rows > 0) 40 40 { 41 41 $System->Database->update('NetworkInterfacePortable', '`Time` < "'.TimeToMysqlDateTime($Properties['expires-after']).'" AND `NetworkInterface`='.$InterfaceId, array('DynamicIP' => $Properties['active-address'], 'Update' => 1)); … … 53 53 $NATRule = array(); 54 54 $DbRows = $System->Database->query('SELECT NetworkDevice.Name AS DeviceName, NetworkInterface.Name AS InterfaceName, DynamicIP FROM `NetworkInterfacePortable` JOIN NetworkInterface ON NetworkInterface.Id=NetworkInterfacePortable.NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE `Update`=1'); 55 while ($Portable = $DbRows->fetch_assoc())55 while ($Portable = $DbRows->fetch_assoc()) 56 56 { 57 57 $Name = $Portable['DeviceName']; 58 if ($Portable['InterfaceName'] != '') $Name .= '-'.$Portable['InterfaceName'];58 if ($Portable['InterfaceName'] != '') $Name .= '-'.$Portable['InterfaceName']; 59 59 array_push($NATRule, implode(' ', $PathNAT).' set [find comment="'.$Name.'-in"] to-addresses='.$Portable['DynamicIP']); 60 60 array_push($NATRule, implode(' ', $PathNAT).' set [find comment="'.$Name.'-out"] src-address='.$Portable['DynamicIP']); -
trunk/Modules/NetworkConfigRouterOS/Generators/Common.php
r870 r873 6 6 7 7 $DbResult = $Database->query('SELECT `Id` FROM `NetworkMark` WHERE `Comment`="'.$Comment.'"'); 8 if ($DbResult->num_rows > 0)8 if ($DbResult->num_rows > 0) 9 9 { 10 10 $DbRow = $DbResult->fetch_assoc(); 11 return ($DbRow['Id']);11 return ($DbRow['Id']); 12 12 } else 13 13 { 14 14 $DbResult = $Database->query('INSERT INTO `NetworkMark` (`Comment`) VALUES ("'.$Comment.'")'); 15 return ($Database->insert_id);15 return ($Database->insert_id); 16 16 } 17 17 } … … 22 22 23 23 $DbResult = $Database->query('SELECT `Id` FROM `NetworkMangleSubgroup` WHERE `AddressRange`="'.$AddressRange.'"'); 24 if ($DbResult->num_rows > 0)24 if ($DbResult->num_rows > 0) 25 25 { 26 26 $DbRow = $DbResult->fetch_assoc(); 27 return ($DbRow['Id']);27 return ($DbRow['Id']); 28 28 } else 29 29 { 30 30 $DbResult = $Database->query('INSERT INTO `NetworkMangleSubgroup` (`AddressRange`) VALUES ("'.$AddressRange.'")'); 31 return ($Database->insert_id);31 return ($Database->insert_id); 32 32 } 33 33 } … … 38 38 39 39 $Found = false; 40 foreach ($Tree['Items'] as $Index => $Node)40 foreach ($Tree['Items'] as $Index => $Node) 41 41 { 42 if ($Node['Address']->Contain($Address))42 if ($Node['Address']->Contain($Address)) 43 43 { 44 44 InsertToAddressTreeIPv4($Tree['Items'][$Index], $Address, $Name, true); … … 46 46 } 47 47 } 48 if ($Found == false)48 if ($Found == false) 49 49 { 50 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and50 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and 51 51 ($Address->Prefix > ($Tree['Address']->Prefix + 1))) 52 52 { … … 62 62 // Should be existed items placed under new node? 63 63 $Found = false; 64 foreach ($Tree['Items'] as $Index => $Node)64 foreach ($Tree['Items'] as $Index => $Node) 65 65 { 66 if (($Node['Address']->Address == $NewNode['Address']->Address) and66 if (($Node['Address']->Address == $NewNode['Address']->Address) and 67 67 ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true; 68 68 69 if ($Address->Contain($Node['Address']))69 if ($Address->Contain($Node['Address'])) 70 70 { 71 71 $NewNode['Items'][] = $Node; … … 73 73 } 74 74 } 75 if ($Found == false) $Tree['Items'][] = $NewNode;75 if ($Found == false) $Tree['Items'][] = $NewNode; 76 76 } 77 77 } … … 83 83 84 84 $Found = false; 85 foreach ($Tree['Items'] as $Index => $Node)85 foreach ($Tree['Items'] as $Index => $Node) 86 86 { 87 if ($Node['Address']->Contain($Address))87 if ($Node['Address']->Contain($Address)) 88 88 { 89 89 InsertToAddressTreeIPv6($Tree['Items'][$Index], $Address, $Name, true); … … 91 91 } 92 92 } 93 if ($Found == false)93 if ($Found == false) 94 94 { 95 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and95 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and 96 96 ($Address->Prefix > ($Tree['Address']->Prefix + 1))) 97 97 { … … 107 107 // Should be existed items placed under new node? 108 108 $Found = false; 109 foreach ($Tree['Items'] as $Index => $Node)109 foreach ($Tree['Items'] as $Index => $Node) 110 110 { 111 if (($Node['Address']->Address == $NewNode['Address']->Address) and111 if (($Node['Address']->Address == $NewNode['Address']->Address) and 112 112 ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true; 113 113 114 if ($Address->Contain($Node['Address']))114 if ($Address->Contain($Node['Address'])) 115 115 { 116 116 $NewNode['Items'][] = $Node; … … 118 118 } 119 119 } 120 if ($Found == false) $Tree['Items'][] = $NewNode;120 if ($Found == false) $Tree['Items'][] = $NewNode; 121 121 } 122 122 } … … 126 126 { 127 127 echo(str_repeat(' ', $Indent).$Node['Address']->AddressToString().'/'.$Node['Address']->Prefix.' '.$Node['Name']."\n"); 128 foreach ($Node['Items'] as $Index => $Item)128 foreach ($Node['Items'] as $Index => $Item) 129 129 { 130 130 ShowSubnetNode($Item, $Indent + 1); -
trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php
r861 r873 14 14 15 15 $DbResult = $this->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Configure`=1'); 16 while ($Subnet = $DbResult->fetch_assoc())16 while ($Subnet = $DbResult->fetch_assoc()) 17 17 { 18 18 echo($Subnet['DHCP']); … … 24 24 'WHERE CompareNetworkPrefix(INET_ATON(`LocalIP`), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].') '. 25 25 'AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`'); 26 while ($Interface = $DbResult2->fetch_assoc())26 while ($Interface = $DbResult2->fetch_assoc()) 27 27 { 28 28 $Name = $Interface['DeviceName']; 29 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];29 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 30 30 $Items[] = array('mac-address' => $Interface['MAC'], 'address' => $Interface['LocalIP'], 'server' => $Server, 'comment' => $Name, 'lease-time' => '1d'); 31 31 } -
trunk/Modules/NetworkConfigRouterOS/Generators/DNS.php
r781 r873 13 13 14 14 $DbResult = $this->Database->query('SELECT * FROM `NetworkDomain`'); 15 while ($Domain = $DbResult->fetch_assoc())15 while ($Domain = $DbResult->fetch_assoc()) 16 16 { 17 17 $DomainName = $Domain['Name']; … … 19 19 // Get full domain name from parent items 20 20 $CurrentDomain = $Domain; 21 while ($CurrentDomain['Parent'] > 0)21 while ($CurrentDomain['Parent'] > 0) 22 22 { 23 23 $DbResult2 = $this->Database->query('SELECT * FROM `NetworkDomain` WHERE `Id`='.$CurrentDomain['Parent']); … … 32 32 'JOIN `NetworkDevice` ON `NetworkInterface`.`Device`=`NetworkDevice`.`Id` '. 33 33 'WHERE (`NetworkDevice`.`Used`=1)'); 34 while ($Interface = $DbResult2->fetch_assoc())34 while ($Interface = $DbResult2->fetch_assoc()) 35 35 { 36 36 $Name = $Interface['DeviceName']; 37 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];37 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 38 38 $NameFull = $Name.'.'.$DomainName; 39 39 $NameExtFull = $Name.'-ext.'.$DomainName; 40 if ($Interface['LocalIP'] != '')40 if ($Interface['LocalIP'] != '') 41 41 $Items[] = array('name' => $NameFull, 'address' => $Interface['LocalIP']); 42 if ($Interface['IPv6'] != '')42 if ($Interface['IPv6'] != '') 43 43 $Items[] = array('name' => $NameFull, 'address' => $Interface['IPv6']); 44 if ($Interface['ExternalIP'] != '')44 if ($Interface['ExternalIP'] != '') 45 45 $Items[] = array('name' => $NameExtFull, 'address' => $Interface['ExternalIP']); 46 46 } … … 53 53 'WHERE (`NetworkDevice`.`Used`=1) AND '. 54 54 '(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")) = `NetworkDomainAlias`.`Target`)'); 55 while ($Alias = $DbResult2->fetch_assoc())55 while ($Alias = $DbResult2->fetch_assoc()) 56 56 { 57 57 $Name = $Alias['Name']; 58 58 $NameFull = $Name.'.'.$DomainName; 59 59 $NameExtFull = $Name.'-ext.'.$DomainName; 60 if ($Alias['LocalIP'] != '')60 if ($Alias['LocalIP'] != '') 61 61 $Items[] = array('name' => $NameFull, 'address' => $Alias['LocalIP']); 62 if ($Alias['IPv6'] != '')62 if ($Alias['IPv6'] != '') 63 63 $Items[] = array('name' => $NameFull, 'address' => $Alias['IPv6']); 64 if ($Alias['ExternalIP'] != '')64 if ($Alias['ExternalIP'] != '') 65 65 $Items[] = array('name' => $NameExtFull, 'address' => $Alias['ExternalIP']); 66 66 } 67 67 68 68 $DbResult2 = $this->Database->query('SELECT * FROM `NetworkDomainServer` WHERE `Domain`='.$Domain['Id']); 69 while ($Server = $DbResult2->fetch_assoc())69 while ($Server = $DbResult2->fetch_assoc()) 70 70 { 71 71 $Routerboard->HostName = $Server['Address']; -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallFilter.php
r831 r873 42 42 // Insert blocked addresses 43 43 $DbResult = $this->Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id WHERE Member.Blocked=1'); 44 while ($Member = $DbResult->fetch_assoc())44 while ($Member = $DbResult->fetch_assoc()) 45 45 { 46 46 echo($Member['Name'].': '); 47 47 // Hosts 48 48 $DbResult2 = $this->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.ExternalIP <> "") AND (NetworkDevice.Member = '.$Member['Id'].') AND (NetworkInterface.LocalIP != NetworkInterface.ExternalIP) ORDER BY id DESC'); 49 while ($Interface = $DbResult2->fetch_assoc())49 while ($Interface = $DbResult2->fetch_assoc()) 50 50 { 51 51 $Name = $Interface['DeviceName']; 52 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];52 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 53 53 $Name = RouterOSIdent($Name); 54 54 echo($Name.'('.$Interface['LocalIP'].'), '); … … 59 59 // Subnets 60 60 $DbResult2 = $this->Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']); 61 while ($Subnet = $DbResult2->fetch_assoc())61 while ($Subnet = $DbResult2->fetch_assoc()) 62 62 { 63 63 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); … … 67 67 $NewAddress->Prefix = $Subnet['ExtMask']; 68 68 $Range = $NewAddress->GetRange(); 69 if ($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();69 if ($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString(); 70 70 else $Range = $Range['From']->AddressToString(); 71 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];71 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange']; 72 72 else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask']; 73 73 $Items[] = array('chain' => 'forward', 'out-interface' => $InetInterface, 'src-address' => $Src, 'action' => 'drop','comment' => $Subnet['Name'].'-out-drop'); … … 77 77 $NewAddress->Prefix = $Subnet['Mask']; 78 78 $Range = $NewAddress->GetRange(); 79 if ($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();79 if ($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString(); 80 80 else $Range = $Range['From']->AddressToString(); 81 if ($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange'];81 if ($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange']; 82 82 else $Dest = $Subnet['ExtAddressRange'].'/'.$Subnet['ExtMask']; 83 83 $Items[] = array('chain' => 'forward', 'in-interface' => $InetInterface, 'dst-address' => $Dest, 'action' => 'drop', 'comment' => $Subnet['Name'].'-in-drop'); -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php
r870 r873 7 7 global $InetInterface, $ItemsFirewall; 8 8 9 foreach ($Node['Items'] as $Index => $Item)10 { 11 if (count($Item['Items']) == 0)9 foreach ($Node['Items'] as $Index => $Item) 10 { 11 if (count($Item['Items']) == 0) 12 12 { 13 13 // Hosts 14 14 $ParentSubnetId = GetSubgroupByRange($Node['Address']->AddressToString().'/'.$Node['Address']->Prefix); 15 15 $Address = $Item['Address']->AddressToString(); 16 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;16 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix; 17 17 18 18 $PacketMark = GetMarkByComment($Item['Name'].'-out'); … … 28 28 29 29 $Address = $Item['Address']->AddressToString(); 30 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;30 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix; 31 31 32 32 $ItemsFirewall[] = array('chain' => 'inet-'.$ParentSubnetId.'-out', 'src-address' => $Address, 'out-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-'.$SubnetId.'-out', 'comment' => $Item['Name'].'-out'); … … 36 36 } 37 37 } 38 if ($Node['ForceMark'] == true)38 if ($Node['ForceMark'] == true) 39 39 { 40 40 // Mark member subnets … … 72 72 // Divide rules by subnet number 73 73 $DbResult = $this->System->Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet` WHERE `Member` IS NULL'); 74 while ($Subnet = $DbResult->fetch_assoc())74 while ($Subnet = $DbResult->fetch_assoc()) 75 75 { 76 76 $NewAddress = new NetworkAddressIPv4(); … … 84 84 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 85 85 'WHERE `Member`.`Blocked` = 0'); 86 while ($Member = $DbResult->fetch_assoc())86 while ($Member = $DbResult->fetch_assoc()) 87 87 { 88 88 $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] ); … … 90 90 91 91 $DbResult2 = $this->System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']); 92 while ($Device = $DbResult2->fetch_assoc())92 while ($Device = $DbResult2->fetch_assoc()) 93 93 { 94 94 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""'); 95 while ($Interface = $DbResult3->fetch_assoc())95 while ($Interface = $DbResult3->fetch_assoc()) 96 96 { 97 97 $Name = $Device['Name']; 98 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];98 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 99 99 $Name = RouterOSIdent($Name); 100 100 echo($Name.', '); … … 107 107 108 108 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '(`Member`='.$Member['Id'].') AND (AddressRange != "")'); 109 while ($Subnet = $DbResult2->fetch_assoc())109 while ($Subnet = $DbResult2->fetch_assoc()) 110 110 { 111 111 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); … … 114 114 $NewAddress->AddressFromString($Subnet['AddressRange']); 115 115 $NewAddress->Prefix = $Subnet['Mask']; 116 if ($Subnet['Member'] != 0) $ForceMark = true;116 if ($Subnet['Member'] != 0) $ForceMark = true; 117 117 else $ForceMark = false; 118 118 echo($ForceMark.', '); … … 169 169 $DbResult = $this->System->Database->query('SELECT `Id`, `Name`, `AddressRangeIPv6`, `MaskIPv6` FROM `NetworkSubnet` '. 170 170 'WHERE (`Member` IS NULL) AND (`AddressRangeIPv6` != "")'); 171 while ($Subnet = $DbResult->fetch_assoc())171 while ($Subnet = $DbResult->fetch_assoc()) 172 172 { 173 173 $NewAddress = new NetworkAddressIPv6(); … … 181 181 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 182 182 'WHERE `Member`.`Blocked` = 0'); 183 while ($Member = $DbResult->fetch_assoc())183 while ($Member = $DbResult->fetch_assoc()) 184 184 { 185 185 $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] ); … … 187 187 188 188 $DbResult2 = $this->System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']); 189 while ($Device = $DbResult2->fetch_assoc())189 while ($Device = $DbResult2->fetch_assoc()) 190 190 { 191 191 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `IPv6` != ""'); 192 while ($Interface = $DbResult3->fetch_assoc())192 while ($Interface = $DbResult3->fetch_assoc()) 193 193 { 194 194 $Name = $Device['Name']; 195 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];195 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 196 196 $Name = RouterOSIdent($Name); 197 197 echo($Name.', '); … … 204 204 205 205 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '(`Member`='.$Member['Id'].') AND (AddressRangeIPv6 != "")'); 206 while ($Subnet = $DbResult2->fetch_assoc())206 while ($Subnet = $DbResult2->fetch_assoc()) 207 207 { 208 208 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); … … 211 211 $NewAddress->AddressFromString($Subnet['AddressRangeIPv6']); 212 212 $NewAddress->Prefix = $Subnet['MaskIPv6']; 213 if ($Subnet['Member'] != 0) $ForceMark = true;213 if ($Subnet['Member'] != 0) $ForceMark = true; 214 214 else $ForceMark = false; 215 215 echo($ForceMark.', '); -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallNAT.php
r860 r873 39 39 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 40 40 'WHERE `Member`.`Blocked` = 0'); 41 while ($Member = $DbResult->fetch_assoc())41 while ($Member = $DbResult->fetch_assoc()) 42 42 { 43 43 echo($Member['Name'].': '); … … 47 47 ' AND (`NetworkInterface`.`LocalIP` <> "")'. 48 48 ' AND (`NetworkDevice`.`Member` = '.$Member['Id'].') AND (`NetworkInterface`.`LocalIP` != `NetworkInterface`.`ExternalIP`) ORDER BY `id` DESC'); 49 while ($Interface = $DbResult2->fetch_assoc())49 while ($Interface = $DbResult2->fetch_assoc()) 50 50 { 51 51 $Name = $Interface['DeviceName']; 52 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];52 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 53 53 $Name = RouterOSIdent($Name); 54 54 echo($Name.'('.$Interface['LocalIP'].'), '); 55 if ($Member['Blocked'] == 0)55 if ($Member['Blocked'] == 0) 56 56 { 57 57 $Items[] = array('chain' => 'inet-out', 'src-address' => $Interface['LocalIP'], 'action' => 'src-nat', 'to-addresses' => $Interface['ExternalIP'], 'comment' => $Name.'-out'); 58 if ($Interface['InboundNATPriority'] > 0)58 if ($Interface['InboundNATPriority'] > 0) 59 59 $Items[] = array('chain' => 'inet-in', 'dst-address' => $Interface['ExternalIP'], 'action' => 'dst-nat', 'to-addresses' => $Interface['LocalIP'], 'comment' => $Name.'-in'); 60 60 } else … … 66 66 // Subnets 67 67 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']); 68 while ($Subnet = $DbResult2->fetch_assoc())68 while ($Subnet = $DbResult2->fetch_assoc()) 69 69 { 70 70 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); 71 71 echo($Subnet['Name'].'('.$Subnet['AddressRange'].'/'.$Subnet['Mask'].'), '); 72 if ($Member['Blocked'] == 0)72 if ($Member['Blocked'] == 0) 73 73 { 74 74 $NewAddress = new NetworkAddressIPv4(); … … 76 76 $NewAddress->Prefix = $Subnet['ExtMask']; 77 77 $Range = $NewAddress->GetRange(); 78 if ($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();78 if ($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString(); 79 79 else $Range = $Range['From']->AddressToString(); 80 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];80 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange']; 81 81 else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask']; 82 82 $Items[] = array('chain' => 'inet-out', 'src-address' => $Src, 'action' => 'src-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-out'); … … 86 86 $NewAddress->Prefix = $Subnet['Mask']; 87 87 $Range = $NewAddress->GetRange(); 88 if ($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();88 if ($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString(); 89 89 else $Range = $Range['From']->AddressToString(); 90 if ($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange'];90 if ($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange']; 91 91 else $Dest = $Subnet['ExtAddressRange'].'/'.$Subnet['ExtMask']; 92 92 $Items[] = array('chain' => 'inet-in', 'dst-address' => $Dest, 'action' => 'dst-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-in'); 93 93 } else 94 94 { 95 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];95 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange']; 96 96 else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask']; 97 97 $Items[] = array('chain' => 'dstnat', 'src-address' => $Src, 'protocol' => 'tcp', 'dst-port' => 80, 'action' => 'dst-nat', 'to-addresses' => $IPCentrala, 'to-ports' => 81, 'comment' => $Subnet['Name'].'-out'); … … 124 124 // Route public addresses localy 125 125 $DbResult = $this->Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id'); 126 while ($Member = $DbResult->fetch_assoc())126 while ($Member = $DbResult->fetch_assoc()) 127 127 { 128 128 echo($Member['Name'].': '); 129 129 // Hosts 130 130 $DbResult2 = $this->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.ExternalIP <> "") AND (NetworkDevice.Member = '.$Member['Id'].') AND (NetworkInterface.LocalIP != NetworkInterface.ExternalIP) ORDER BY id DESC'); 131 while ($Interface = $DbResult2->fetch_assoc())131 while ($Interface = $DbResult2->fetch_assoc()) 132 132 { 133 133 $Name = $Interface['DeviceName']; 134 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];134 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 135 135 $Name = RouterOSIdent($Name); 136 136 echo($Name.'('.$Interface['LocalIP'].'), '); -
trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php
r835 r873 13 13 14 14 $DbResult3 = $this->Database->query('SELECT DISTINCT (`DHCP`) FROM `NetworkSubnet` WHERE `Configure` = 1'); // WHERE `Member` = 0'); 15 while ($Router = $DbResult3->fetch_assoc())15 while ($Router = $DbResult3->fetch_assoc()) 16 16 { 17 17 echo($Router['DHCP']."\n"); … … 19 19 $Items = array(); 20 20 $DbResult = $this->Database->query('SELECT * FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`DHCP`="'.$Router['DHCP'].'")'); 21 while ($Subnet = $DbResult->fetch_assoc())21 while ($Subnet = $DbResult->fetch_assoc()) 22 22 { 23 23 $I = explode('.', $Subnet['AddressRange']); … … 26 26 ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE CompareNetworkPrefix(INET_ATON(`LocalIP`), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].')'. 27 27 ' AND (`NetworkDevice`.`Used` = 1) ORDER BY `NetworkInterface`.`LocalIP`'); 28 while ($Interface = $DbResult2->fetch_assoc())28 while ($Interface = $DbResult2->fetch_assoc()) 29 29 { 30 30 $Name = $Interface['DeviceName']; 31 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];31 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 32 32 echo($Name.', '); 33 33 $Items[] = array('host' => $Interface['LocalIP'], 'interval' => '00:00:10', 'comment' => $Name); -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r863 r873 10 10 $Interfaces = array(); 11 11 $DbResult = $this->Database->select('NetworkInterface', '`Id`, `LocalIP` AS `IP`, `Online`, 0 AS `NewOnline`'); 12 while ($DbRow = $DbResult->fetch_assoc())12 while ($DbRow = $DbResult->fetch_assoc()) 13 13 $Interfaces[$DbRow['IP']] = $DbRow; 14 14 … … 16 16 $DbResult3 = $this->Database->query('SELECT `DHCP` FROM `NetworkSubnet` '. 17 17 'WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY `DHCP`'); 18 while ($Subnet = $DbResult3->fetch_assoc())18 while ($Subnet = $DbResult3->fetch_assoc()) 19 19 { 20 20 echo('router '.$Subnet['DHCP']."\n"); … … 22 22 $Routerboard->Connect($Subnet['DHCP'], $this->System->Config['API']['UserName'], 23 23 $this->System->Config['API']['Password']); 24 if (!$Routerboard->Connected) continue;24 if (!$Routerboard->Connected) continue; 25 25 $Routerboard->Write('/tool/netwatch/getall', false); 26 26 $Routerboard->Write('=.proplist=host,status'); 27 27 $Read = $Routerboard->Read(false); 28 28 $List = $Routerboard->ParseResponse($Read); 29 foreach ($List as $Properties)29 foreach ($List as $Properties) 30 30 { 31 31 $IP = $Properties['host']; 32 if ($Properties['status'] == 'up') $Online = 1;32 if ($Properties['status'] == 'up') $Online = 1; 33 33 else $Online = 0; 34 34 35 if ($Online)35 if ($Online) 36 36 { 37 if (array_key_exists($IP, $Interfaces))37 if (array_key_exists($IP, $Interfaces)) 38 38 $Interfaces[$IP]['NewOnline'] = 1; 39 39 else echo('IP '.$IP.' not found.'."\n"); … … 44 44 $Queries = array(); 45 45 $QueriesInsert = array(); 46 foreach ($Interfaces as $Index => $Interface)46 foreach ($Interfaces as $Index => $Interface) 47 47 { 48 48 // Update last online time if still online 49 if ($Interface['NewOnline'])49 if ($Interface['NewOnline']) 50 50 $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = '.$Interface['Id'], 51 51 array('LastOnline' => TimeToMysqlDateTime($StartTime))); 52 52 53 if ($Interface['Online'] != $Interface['NewOnline'])53 if ($Interface['Online'] != $Interface['NewOnline']) 54 54 { 55 55 // Online state changed … … 78 78 $DbResult = $this->Database->select('NetworkInterface', '*', '(`Online` = 1) AND '. 79 79 '(`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'")'); 80 while ($DbRow = $DbResult->fetch_assoc())80 while ($DbRow = $DbResult->fetch_assoc()) 81 81 { 82 82 echo('IP '.$DbRow['LocalIP'].' online but time not updated.'."\n"); … … 84 84 $DbResult = $this->Database->select('NetworkInterface', '*', '(`Online` = 0) AND '. 85 85 '(`LastOnline` >= "'.TimeToMysqlDateTime($StartTime).'")'); 86 while ($DbRow = $DbResult->fetch_assoc())86 while ($DbRow = $DbResult->fetch_assoc()) 87 87 { 88 88 echo('IP '.$DbRow['LocalIP'].' not online but time updated.'."\n"); … … 92 92 // Update device online state 93 93 $DbResult = $this->Database->select('NetworkInterface', '`Device`, SUM(`Online`) AS `SumOnline`', '`Online` = 1 GROUP BY `Device`'); 94 while ($Device = $DbResult->fetch_assoc())94 while ($Device = $DbResult->fetch_assoc()) 95 95 { 96 if ($Device['SumOnline'] > 0)96 if ($Device['SumOnline'] > 0) 97 97 $Queries[] = $this->Database->GetUpdate('NetworkDevice', 'Id='.$Device['Device'], array('LastOnline' => TimeToMysqlDateTime($StartTime), 'Online' => 1)); 98 98 } -
trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php
r869 r873 48 48 function CheckName($Name, &$UsedNames) 49 49 { 50 if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name);50 if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name); 51 51 else $UsedNames[] = $Name; 52 52 } … … 189 189 $DbResult = $this->Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '. 190 190 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` WHERE `Member`.`Blocked`=0'); 191 while ($Member = $DbResult->fetch_assoc())191 while ($Member = $DbResult->fetch_assoc()) 192 192 { 193 193 $ServiceIndex = 1; … … 198 198 'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '. 199 199 'AND (`Service`.`InternetSpeedMax` > 0) AND (`Service`.`InternetSpeedMin` > 0)'); 200 while ($Service = $DbResult4->fetch_assoc())200 while ($Service = $DbResult4->fetch_assoc()) 201 201 { 202 202 echo('Služba '.$Service['Name'].': '); … … 231 231 $Row = $DbResult2->fetch_row(); 232 232 $HostCount = $Row[0]; 233 if ($HostCount > 0)233 if ($HostCount > 0) 234 234 { 235 235 $HostSpeedIn = round($SpeedIn / $HostCount); … … 242 242 243 243 $DbResult2 = $this->Database->select('NetworkDevice', '*', $Filter); 244 while ($Device = $DbResult2->fetch_assoc())244 while ($Device = $DbResult2->fetch_assoc()) 245 245 { 246 246 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""'); 247 while ($Interface = $DbResult3->fetch_assoc())247 while ($Interface = $DbResult3->fetch_assoc()) 248 248 { 249 249 $DeviceName = $Device['Name']; 250 if ($Interface['Name'] != '') $DeviceName .= '-'.$Interface['Name'];250 if ($Interface['Name'] != '') $DeviceName .= '-'.$Interface['Name']; 251 251 $DeviceName = RouterOSIdent($DeviceName); 252 252 echo($DeviceName.', '); … … 258 258 259 259 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']); 260 while ($Subnet = $DbResult2->fetch_assoc())260 while ($Subnet = $DbResult2->fetch_assoc()) 261 261 { 262 262 $SubnetName = RouterOSIdent('subnet-'.$Subnet['Name']); … … 329 329 { 330 330 $MinSpeed = 0; 331 foreach ($this->Devices[$DeviceId]['Childs'] as $DeviceChild)331 foreach ($this->Devices[$DeviceId]['Childs'] as $DeviceChild) 332 332 { 333 333 $this->UpdateMinSpeed($DeviceChild); … … 335 335 } 336 336 $this->Devices[$DeviceId]['MinSpeed'] = $MinSpeed; 337 if ($this->Devices[$DeviceId]['DeviceCount'] > 0)337 if ($this->Devices[$DeviceId]['DeviceCount'] > 0) 338 338 $this->Devices[$DeviceId]['MinSpeed'] += round($this->Devices[$DeviceId]['InternetSpeedMin'] / $this->Devices[$DeviceId]['DeviceCount']); 339 339 } … … 349 349 'LEFT JOIN `ServiceCustomerRel` ON `ServiceCustomerRel`.`Id`=`NetworkDevice`.`Service` '. 350 350 'LEFT JOIN `Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service`'); 351 while ($Device = $DbResult->fetch_assoc())351 while ($Device = $DbResult->fetch_assoc()) 352 352 { 353 353 $Device['Interfaces'] = array(); … … 364 364 $Interfaces = array(); 365 365 $DbResult = $this->Database->query('SELECT `Device`,`Name`,`Id` FROM `NetworkInterface`'); 366 while ($Interface = $DbResult->fetch_assoc())366 while ($Interface = $DbResult->fetch_assoc()) 367 367 { 368 368 $Interface['Links'] = array(); … … 376 376 '`NetworkLink`.`Interface2`,`NetworkLinkType`.`MaxRealSpeed` FROM `NetworkLink` '. 377 377 'LEFT JOIN `NetworkLinkType` ON `NetworkLinkType`.`Id`=`NetworkLink`.`Type`'); 378 while ($Link = $DbResult->fetch_assoc())378 while ($Link = $DbResult->fetch_assoc()) 379 379 { 380 380 $Links[$Link['Id']] = $Link; … … 388 388 $this->Devices[$RootDeviceId]['Calculated'] = true; 389 389 390 while (count($DevicesToCheck) > 0)390 while (count($DevicesToCheck) > 0) 391 391 { 392 392 //echo('Pass'."\n"); 393 393 $NewDevicesToCheck = array(); 394 foreach ($DevicesToCheck as $DeviceId)394 foreach ($DevicesToCheck as $DeviceId) 395 395 { 396 396 //echo($this->Devices[$DeviceId]['Name'].': '); 397 foreach ($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId)397 foreach ($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId) 398 398 { 399 foreach ($Interfaces[$InterfaceId]['Links'] as $LinkId)399 foreach ($Interfaces[$InterfaceId]['Links'] as $LinkId) 400 400 { 401 401 $Link = $Links[$LinkId]; 402 402 $Interface2Id = $Link['Interface1']; 403 if ($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2'];403 if ($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2']; 404 404 405 405 $Device2Id = $Interfaces[$Interface2Id]['Device']; 406 if ($this->Devices[$Device2Id]['Calculated'] == false)406 if ($this->Devices[$Device2Id]['Calculated'] == false) 407 407 { 408 408 $this->Devices[$Device2Id]['Calculated'] = true; 409 409 $NewMaxSpeed = $this->Devices[$DeviceId]['MaxSpeed']; 410 if ($NewMaxSpeed > $Link['MaxRealSpeed'])410 if ($NewMaxSpeed > $Link['MaxRealSpeed']) 411 411 $NewMaxSpeed = $Link['MaxRealSpeed']; 412 412 //echo($this->Devices[$Device2Id]['Name'].' '.$Device2Id.', '); … … 431 431 432 432 echo('Not linked network devices: '); 433 foreach ($this->Devices as $Device)434 { 435 if ($Device['MaxSpeed'] == 0) echo($Device['Name'].', ');433 foreach ($this->Devices as $Device) 434 { 435 if ($Device['MaxSpeed'] == 0) echo($Device['Name'].', '); 436 436 } 437 437 echo("\n"); … … 455 455 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$DeviceId.' AND `LocalIP` != ""'); 456 456 $IntCount = $DbResult3->num_rows; 457 while ($Interface = $DbResult3->fetch_assoc())457 while ($Interface = $DbResult3->fetch_assoc()) 458 458 { 459 459 $InterfaceName = $Device['Name']; 460 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];460 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name']; 461 461 else $InterfaceName .= '-'; 462 462 $InterfaceName = RouterOSIdent($InterfaceName); … … 469 469 470 470 // Process childs 471 foreach ($Device['Childs'] as $DeviceChild)471 foreach ($Device['Childs'] as $DeviceChild) 472 472 { 473 473 $this->BuildQueueItems($DeviceChild, $LimitDevice); … … 505 505 506 506 $DbResult = $this->Database->select('Service', '*', '(`ChangeAction` IS NULL) AND (`Id`='.TARIFF_FREE.')'); 507 if ($DbResult->num_rows == 1)507 if ($DbResult->num_rows == 1) 508 508 { 509 509 $Service = $DbResult->fetch_array(); -
trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php
r851 r873 12 12 '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '. 13 13 'FROM `NetworkDevice` WHERE (`API` = 1) AND (`Used` = 1)'); 14 while ($Device = $DbResult3->fetch_assoc())14 while ($Device = $DbResult3->fetch_assoc()) 15 15 { 16 16 echo($Device['LocalIP']."\n"); … … 19 19 //$Routerboard->Port = 8729; 20 20 $Routerboard->Connect($Device['LocalIP'], $this->System->Config['API']['UserName'], $this->System->Config['API']['Password']); 21 if (!$Routerboard->Connected) continue;21 if (!$Routerboard->Connected) continue; 22 22 $Routerboard->Write('/interface/wireless/registration-table/getall', false); 23 23 $Routerboard->Write('=.proplist=signal-strength,mac-address,rx-rate,tx-rate', false); … … 25 25 $Read = $Routerboard->Read(false); 26 26 $Array = $Routerboard->ParseResponse($Read); 27 foreach ($Array as $Properties)27 foreach ($Array as $Properties) 28 28 { 29 29 $DbResult = $this->Database->select('NetworkInterface', 'Id', 'MAC="'.$Properties['mac-address'].'"'); 30 if ($DbResult->num_rows > 0)30 if ($DbResult->num_rows > 0) 31 31 { 32 32 $DbRow = $DbResult->fetch_assoc(); … … 34 34 } else $Interface = 'NULL'; 35 35 36 if (strpos($Properties['signal-strength'], '@') === false)36 if (strpos($Properties['signal-strength'], '@') === false) 37 37 { 38 38 $Strength = $Properties['signal-strength']; 39 39 } else { 40 40 $Parts = explode('@', $Properties['signal-strength']); 41 if (substr($Parts[0], -3) == 'dBm')41 if (substr($Parts[0], -3) == 'dBm') 42 42 $Strength = substr($Parts[0], 0, -3); // without dBm 43 43 else $Strength = $Parts[0]; … … 50 50 /* 51 51 $DbResult = $this->Database->select('Measure', 'Id', '`Name` = "'.$Properties['mac-address'].'"'); 52 if ($DbResult->num_rows > 0)52 if ($DbResult->num_rows > 0) 53 53 { 54 54 $this->Database->insert('Measure', array('Name' => $Properties['mac-address'])); … … 74 74 if (substr($Value, -3, 3) == "Mbp") $Value = substr($Value, 0, -3); // without Mbp unit 75 75 if (substr($Value, -1, 1) == "M") $Value = substr($Value, 0, -1); // without M unit 76 return ($Value);76 return ($Value); 77 77 } 78 78 -
trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php
r860 r873 70 70 $IPAddress = GetRemoteAddress(); 71 71 $Output = 'Vaše IP adresa je: '.$IPAddress.'<br/>'; 72 if (IsInternetAddr($IPAddress)) {72 if (IsInternetAddr($IPAddress)) { 73 73 $Output .= '<p>Internet zdarma je dostupný pouze z vnitřní sítě.</p>'; 74 return ($Output);74 return ($Output); 75 75 } 76 76 $Time = time(); … … 78 78 $DbResult = $this->Database->select('NetworkFreeAccess', '*', '(IPAddress="'.$IPAddress. 79 79 '") ORDER BY Time DESC LIMIT 1'); 80 if ($DbResult->num_rows > 0)80 if ($DbResult->num_rows > 0) 81 81 { 82 82 $DbRow = $DbResult->fetch_assoc(); 83 83 $ActivationTime = MysqlDateTimeToTime($DbRow['Time']); 84 if (($ActivationTime + $this->Timeout) < $Time)84 if (($ActivationTime + $this->Timeout) < $Time) 85 85 { 86 86 $Activated = false; … … 88 88 } else $Activated = false; 89 89 90 if (array_key_exists('a', $_GET))90 if (array_key_exists('a', $_GET)) 91 91 { 92 if ($_GET['a'] == 'activate')92 if ($_GET['a'] == 'activate') 93 93 { 94 if ($Activated == false)94 if ($Activated == false) 95 95 { 96 96 $DbResult = $this->Database->insert('NetworkFreeAccess', … … 108 108 109 109 $PrefixMultiplier = new PrefixMultiplier(); 110 if ($Activated) $Output .= 'Aktivováno. Vyprší za '.$PrefixMultiplier->Add($ActivationTime + $this->Timeout - $Time, '', 4, 'Time');110 if ($Activated) $Output .= 'Aktivováno. Vyprší za '.$PrefixMultiplier->Add($ActivationTime + $this->Timeout - $Time, '', 4, 'Time'); 111 111 else $Output .= '<a href="?a=activate">Aktivovat</a>'; 112 112 113 return ($Output);113 return ($Output); 114 114 } 115 115 } … … 122 122 $Commands = array(); 123 123 $DbResult = $this->Database->select('NetworkFreeAccess', '`Id`, `IPAddress`', '(`Configured`=0)'); 124 while ($DbRow = $DbResult->fetch_assoc())124 while ($DbRow = $DbResult->fetch_assoc()) 125 125 { 126 126 $Commands[] = '/ip firewall address-list add address='.$DbRow['IPAddress']. … … 135 135 $Routerboard->ExecuteBatch(implode(';', $Commands)); 136 136 137 return ($Output);137 return ($Output); 138 138 } 139 139 } -
trunk/Modules/NetworkConfigRouterOS/Routerboard.php
r860 r873 22 22 { 23 23 $Output = array(); 24 if (is_array($Commands))24 if (is_array($Commands)) 25 25 { 26 26 $I = 0; 27 27 $Batch = array(); 28 while ($I < count($Commands))29 { 30 if (($I % $this->MaxBurstLineCount) == 0)31 { 32 if (count($Batch) > 0)28 while ($I < count($Commands)) 29 { 30 if (($I % $this->MaxBurstLineCount) == 0) 31 { 32 if (count($Batch) > 0) 33 33 $Output = array_merge($Output, $this->ExecuteBatch(implode(';', $Batch))); 34 34 $Batch = array(); … … 37 37 $I++; 38 38 } 39 if (count($Batch) > 0)39 if (count($Batch) > 0) 40 40 $Output = array_merge($Output, $this->ExecuteBatch(implode(';', $Batch))); 41 41 } else 42 42 $Output = array_merge($Output, $this->ExecuteBatch($Commands)); 43 return ($Output);43 return ($Output); 44 44 } 45 45 … … 47 47 { 48 48 $Commands = trim($Commands); 49 if ($Commands != '')49 if ($Commands != '') 50 50 { 51 51 $Commands = addslashes($Commands); … … 57 57 $Command = $this->SSHPath.' -oBatchMode=no -o ConnectTimeout='.$this->Timeout.' -l '.$this->UserName. 58 58 $PrivKey.' '.$this->HostName.' "'.$Commands.'"'; 59 if ($this->Debug) echo($Command);59 if ($this->Debug) echo($Command); 60 60 $Output = array(); 61 61 exec($Command, $Output); 62 62 } else $Output = ''; 63 if ($this->Debug) print_r($Output);64 return ($Output);63 if ($this->Debug) print_r($Output); 64 return ($Output); 65 65 } 66 66 … … 70 70 array_pop($Result); 71 71 $List = array(); 72 foreach ($Result as $ResultLine)72 foreach ($Result as $ResultLine) 73 73 { 74 74 $ResultLineParts = explode(' ', trim($ResultLine)); 75 if (count($ResultLineParts) > 1)76 { 77 if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes75 if (count($ResultLineParts) > 1) 76 { 77 if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes 78 78 $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1]; 79 79 } else $List[substr($ResultLineParts[0], 0, -1)] = ''; 80 80 } 81 return ($List);81 return ($List); 82 82 } 83 83 … … 85 85 { 86 86 $PropertyList = '"'; 87 foreach ($Properties as $Index => $Property)87 foreach ($Properties as $Index => $Property) 88 88 { 89 89 $PropertyList .= $Index.'=".[get $i '.$Property.']." '; … … 92 92 93 93 $ConditionList = ''; 94 foreach ($Conditions as $Index => $Item)95 { 96 if ($Item == 'no') $ConditionList .= $Index.'='.$Item.' ';94 foreach ($Conditions as $Index => $Item) 95 { 96 if ($Item == 'no') $ConditionList .= $Index.'='.$Item.' '; 97 97 else $ConditionList .= $Index.'="'.$Item.'" '; 98 98 } … … 101 101 $Result = $this->Execute(implode(' ', $Path).' {:foreach i in=[find '.$ConditionList.'] do={:put ('.$PropertyList.')}}'); 102 102 $List = array(); 103 foreach ($Result as $ResultLine)103 foreach ($Result as $ResultLine) 104 104 { 105 105 $ResultLineParts = explode(' ', $ResultLine); 106 106 $ListItem = array(); 107 foreach ($ResultLineParts as $ResultLinePart)107 foreach ($ResultLineParts as $ResultLinePart) 108 108 { 109 109 $Value = explode('=', $ResultLinePart); 110 if (count($Value) > 1) $ListItem[$Properties[$Value[0]]] = $Value[1];110 if (count($Value) > 1) $ListItem[$Properties[$Value[0]]] = $Value[1]; 111 111 else $ListItem[$Properties[$Value[0]]] = ''; 112 112 } 113 113 $List[] = $ListItem; 114 114 } 115 return ($List);115 return ($List); 116 116 } 117 117 … … 119 119 { 120 120 $ConditionList = ''; 121 foreach ($Conditions as $Index => $Item)121 foreach ($Conditions as $Index => $Item) 122 122 { 123 123 $ConditionList .= $Index.'="'.$Item.'" '; 124 124 } 125 125 $ConditionList = substr($ConditionList, 0, -1); 126 if (trim($ConditionList) != '')126 if (trim($ConditionList) != '') 127 127 $ConditionList = ' where '.$ConditionList; 128 128 129 129 $Result = $this->Execute(implode(' ', $Path).' print terse'.$ConditionList); 130 130 $List = array(); 131 foreach ($Result as $ResultLine)131 foreach ($Result as $ResultLine) 132 132 { 133 133 $ResultLineParts = explode(' ', $ResultLine); 134 134 $ListItem = array(); 135 foreach ($ResultLineParts as $ResultLinePart)135 foreach ($ResultLineParts as $ResultLinePart) 136 136 { 137 137 $Value = explode('=', $ResultLinePart); 138 if (in_array($Value[0], $Properties))139 { 140 if (count($Value) > 1)138 if (in_array($Value[0], $Properties)) 139 { 140 if (count($Value) > 1) 141 141 { 142 if ($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1);143 //if (strlen($Value[1]) > 0)142 if ($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1); 143 //if (strlen($Value[1]) > 0) 144 144 $ListItem[$Value[0]] = $Value[1]; 145 145 } else $ListItem[$Value[0]] = ''; 146 146 } 147 147 } 148 if (count($ListItem) > 0) $List[] = $ListItem;149 } 150 return ($List);148 if (count($ListItem) > 0) $List[] = $ListItem; 149 } 150 return ($List); 151 151 } 152 152 … … 159 159 { 160 160 // Get current list from routerboard 161 if ($UsePrint == 0)161 if ($UsePrint == 0) 162 162 { 163 163 $List = $this->ListGet($Path, $Properties, $Condition); 164 164 // Change boolean values yes/no to true/false 165 foreach ($List as $Index => $ListItem)166 { 167 foreach ($ListItem as $Index2 => $Item2)168 { 169 if ($Item2 == 'true') $List[$Index][$Index2] = 'yes';170 if ($Item2 == 'false') $List[$Index][$Index2] = 'no';165 foreach ($List as $Index => $ListItem) 166 { 167 foreach ($ListItem as $Index2 => $Item2) 168 { 169 if ($Item2 == 'true') $List[$Index][$Index2] = 'yes'; 170 if ($Item2 == 'false') $List[$Index][$Index2] = 'no'; 171 171 } 172 172 } … … 178 178 179 179 // Add empty properties to values 180 foreach ($Values as $Index => $Item)181 { 182 foreach ($Properties as $Property)183 { 184 if (!array_key_exists($Property, $Item))180 foreach ($Values as $Index => $Item) 181 { 182 foreach ($Properties as $Property) 183 { 184 if (!array_key_exists($Property, $Item)) 185 185 $Item[$Property] = ''; 186 186 } 187 187 $Values[$Index] = $Item; 188 188 } 189 foreach ($List as $Index => $Item)190 { 191 foreach ($Properties as $Property)192 { 193 if (!array_key_exists($Property, $Item))189 foreach ($List as $Index => $Item) 190 { 191 foreach ($Properties as $Property) 192 { 193 if (!array_key_exists($Property, $Item)) 194 194 $Item[$Property] = ''; 195 195 } … … 198 198 199 199 // Sort properties 200 foreach ($Values as $Index => $Item)200 foreach ($Values as $Index => $Item) 201 201 { 202 202 ksort($Values[$Index]); 203 203 } 204 foreach ($List as $Index => $Item)204 foreach ($List as $Index => $Item) 205 205 { 206 206 ksort($List[$Index]); 207 207 } 208 if ($this->Debug) print_r($List);209 if ($this->Debug) print_r($Values);208 if ($this->Debug) print_r($List); 209 if ($this->Debug) print_r($Values); 210 210 211 211 // Erase all items not existed in $Values 212 foreach ($List as $Index => $ListItem)213 { 214 if (!in_array($ListItem, $Values))212 foreach ($List as $Index => $ListItem) 213 { 214 if (!in_array($ListItem, $Values)) 215 215 { 216 216 $Prop = ''; 217 foreach ($ListItem as $Index => $Property)218 { 219 if ($Property != '')217 foreach ($ListItem as $Index => $Property) 218 { 219 if ($Property != '') 220 220 { 221 if (($Property == 'yes') or ($Property == 'no')) $Prop .= $Index.'='.$Property.' ';221 if (($Property == 'yes') or ($Property == 'no')) $Prop .= $Index.'='.$Property.' '; 222 222 else $Prop .= $Index.'="'.$Property.'" '; 223 223 } 224 224 } 225 225 $Prop = substr($Prop, 0, -1); 226 if (trim($Prop) != '')226 if (trim($Prop) != '') 227 227 $Commands[] = implode(' ', $Path).' remove [find '.$Prop.']'; 228 228 } … … 230 230 231 231 // Add new items 232 foreach ($Values as $ListItem)233 { 234 if (!in_array($ListItem, $List))232 foreach ($Values as $ListItem) 233 { 234 if (!in_array($ListItem, $List)) 235 235 { 236 236 $Prop = ''; 237 foreach ($ListItem as $Index => $Property)238 { 239 if ($Property != '') $Prop .= $Index.'="'.$Property.'" ';237 foreach ($ListItem as $Index => $Property) 238 { 239 if ($Property != '') $Prop .= $Index.'="'.$Property.'" '; 240 240 } 241 241 $Prop = substr($Prop, 0, -1); … … 243 243 } 244 244 } 245 if ($this->Debug) print_r($Commands);246 return ($this->Execute($Commands));245 if ($this->Debug) print_r($Commands); 246 return ($this->Execute($Commands)); 247 247 } 248 248 } -
trunk/Modules/NetworkConfigRouterOS/Routerboard2.php
r738 r873 13 13 function Execute($Commands) 14 14 { 15 if (is_array($Commands)) $Commands = implode(';', $Commands);16 return (parent::Execute($Commands));15 if (is_array($Commands)) $Commands = implode(';', $Commands); 16 return (parent::Execute($Commands)); 17 17 } 18 18 … … 22 22 array_pop($Result); 23 23 $List = array(); 24 foreach ($Result as $ResultLine)24 foreach ($Result as $ResultLine) 25 25 { 26 26 $ResultLineParts = explode(' ', trim($ResultLine)); 27 if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes27 if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes 28 28 $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1]; 29 29 } 30 return ($List);30 return ($List); 31 31 } 32 32 … … 34 34 { 35 35 $PropertyList = '"'; 36 foreach ($Properties as $Property)36 foreach ($Properties as $Property) 37 37 { 38 38 $PropertyList .= $Property.'=".[get $i '.$Property.']." '; … … 41 41 $Result = $this->Execute($Command.' {:foreach i in=[find] do={:put ('.$PropertyList.')}}'); 42 42 $List = array(); 43 foreach ($Result as $ResultLine)43 foreach ($Result as $ResultLine) 44 44 { 45 45 $ResultLineParts = explode(' ', $ResultLine); 46 46 $ListItem = array(); 47 foreach ($ResultLineParts as $ResultLinePart)47 foreach ($ResultLineParts as $ResultLinePart) 48 48 { 49 49 $Value = explode('=', $ResultLinePart); … … 52 52 $List[] = $ListItem; 53 53 } 54 return ($List);54 return ($List); 55 55 } 56 56 57 57 function GetSystemResource() 58 58 { 59 return ($this->GetItem('/system resource print'));59 return ($this->GetItem('/system resource print')); 60 60 } 61 61 62 62 function GetFirewallFilterList() 63 63 { 64 return ($this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes')));64 return ($this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes'))); 65 65 } 66 66 67 67 function GetDHCPServerLeasesList() 68 68 { 69 return ($this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name')));69 return ($this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name'))); 70 70 } 71 71 } -
trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
r861 r873 40 40 } else if ($Length >= 0x10000000) 41 41 $Length = chr(0xF0).chr(($Length >> 24) & 0xFF).chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF); 42 return ($Length);42 return ($Length); 43 43 } 44 44 45 45 function ConnectOnce($IP, $Login, $Password) 46 46 { 47 if ($this->Connected) $this->Disconnect();48 if ($this->SSL)47 if ($this->Connected) $this->Disconnect(); 48 if ($this->SSL) 49 49 { 50 50 $IP = 'ssl://'.$IP; 51 51 } 52 52 $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout); 53 if ($this->Socket)53 if ($this->Socket) 54 54 { 55 55 socket_set_timeout($this->Socket, $this->Timeout); … … 58 58 $this->Write('=password='.$Password); 59 59 $Response = $this->Read(false); 60 if ((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true;61 if (!$this->Connected) fclose($this->Socket);60 if ((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true; 61 if (!$this->Connected) fclose($this->Socket); 62 62 } 63 63 } … … 65 65 function Connect($IP, $Login, $Password) 66 66 { 67 for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++)67 for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++) 68 68 { 69 69 $this->ConnectOnce($IP, $Login, $Password); 70 if ($this->Connected) break;70 if ($this->Connected) break; 71 71 sleep($this->Delay); 72 72 } 73 return ($this->Connected);73 return ($this->Connected); 74 74 } 75 75 76 76 function Disconnect() 77 77 { 78 if ($this->Connected)78 if ($this->Connected) 79 79 { 80 80 fclose($this->Socket); … … 183 183 $Response[] = $Line; 184 184 } 185 if ($this->Debug) echo($Line);185 if ($this->Debug) echo($Line); 186 186 // If we get a !done, make a note of it. 187 187 if ($Line == "!done") $ReceivedDone = true; … … 192 192 break; 193 193 } 194 if ($Parse) $Response = $this->ParseResponse($Response);194 if ($Parse) $Response = $this->ParseResponse($Response); 195 195 return $Response; 196 196 } … … 198 198 function Write($Command, $Param2 = true) 199 199 { 200 if ($Command)200 if ($Command) 201 201 { 202 202 $Data = explode("\n", $Command); … … 234 234 $this->Write($el, $Last); 235 235 } 236 return ($this->Read());236 return ($this->Read()); 237 237 } 238 238 } -
trunk/Modules/NetworkConfigRouterOS/SSH.php
r738 r873 18 18 { 19 19 echo($Commands); 20 if (!function_exists("ssh2_connect")) die("Function ssh2_connect doesn't exist");21 if (!($this->Session = ssh2_connect($this->HostName, 22, $this->Methods))) echo("Fail: Unable to establish connection to host\n");20 if (!function_exists("ssh2_connect")) die("Function ssh2_connect doesn't exist"); 21 if (!($this->Session = ssh2_connect($this->HostName, 22, $this->Methods))) echo("Fail: Unable to establish connection to host\n"); 22 22 else 23 23 { 24 if (!ssh2_auth_password($this->Session, $this->UserName, $this->Password)) echo("Fail: unable to authenticate\n");24 if (!ssh2_auth_password($this->Session, $this->UserName, $this->Password)) echo("Fail: unable to authenticate\n"); 25 25 else 26 26 { 27 //if (!($Stream = ssh2_shell($this->Session, 'xterm', null, 80, 40, SSH2_TERM_UNIT_CHARS))) echo("Fail: unable to execute command\n");28 if (!($Stream = ssh2_exec($this->Session, $Commands))) echo("Fail: unable to execute command\n");27 //if (!($Stream = ssh2_shell($this->Session, 'xterm', null, 80, 40, SSH2_TERM_UNIT_CHARS))) echo("Fail: unable to execute command\n"); 28 if (!($Stream = ssh2_exec($this->Session, $Commands))) echo("Fail: unable to execute command\n"); 29 29 else 30 30 { 31 31 $Response = ''; 32 32 stream_set_blocking($Stream, true); 33 while ($Buffer = fread($Stream, 4000))33 while ($Buffer = fread($Stream, 4000)) 34 34 { 35 35 $Response .= $Buffer; … … 37 37 /* 38 38 //echo(') '.strlen($Buffer).' '.ord($Buffer{0}).'('); 39 for ($I = 0; $I < strlen($Buffer); $I++)39 for ($I = 0; $I < strlen($Buffer); $I++) 40 40 { 41 if (((ord($Buffer{$I}) >= 32) and (ord($Buffer{$I}) <= 128)) or ($Buffer{$I} = "\n") or ($Buffer{$I} = "\r")) echo($Buffer{$I});42 if ($Buffer{$I} == '>')41 if (((ord($Buffer{$I}) >= 32) and (ord($Buffer{$I}) <= 128)) or ($Buffer{$I} = "\n") or ($Buffer{$I} = "\r")) echo($Buffer{$I}); 42 if ($Buffer{$I} == '>') 43 43 { 44 44 fwrite($Stream, $Commands."\n\r"); … … 54 54 } 55 55 echo($Response); 56 return (explode("\n", substr($Response, 0, -1)));56 return (explode("\n", substr($Response, 0, -1))); 57 57 } 58 58 } -
trunk/Modules/NetworkShare/SharePage.php
r790 r873 22 22 function ShowTime() 23 23 { 24 return (date("H:i:s")."<br />\n");24 return (date("H:i:s")."<br />\n"); 25 25 } 26 26 … … 41 41 $Cesta = ''; //$Row['name']; 42 42 $i = 0; 43 while (($Otec > 1) && ($i < $this->MaxNesting))43 while (($Otec > 1) && ($i < $this->MaxNesting)) 44 44 { 45 45 $DbResult = $this->Database->query('SELECT Id,Name,Parent FROM NetworkShareItem WHERE Id='.$Otec); … … 50 50 $i++; 51 51 } 52 if ($i >= $this->MaxNesting) $Cesta = '?'.'\\'.$Cesta;53 return ('\\\\'.$Cesta);52 if ($i >= $this->MaxNesting) $Cesta = '?'.'\\'.$Cesta; 53 return ('\\\\'.$Cesta); 54 54 } 55 55 … … 58 58 { 59 59 $Jednotky = array('B','kB','MB','GB','TB','PB','EB'); 60 while ($Velikost >= 1024)60 while ($Velikost >= 1024) 61 61 { 62 62 $Velikost = round($Velikost / 1024 * 10) / 10; 63 63 array_shift($Jednotky); 64 64 } 65 return ($Velikost.' '.$Jednotky[0]);65 return ($Velikost.' '.$Jednotky[0]); 66 66 } 67 67 68 68 function Show() 69 69 { 70 if (!$this->System->User->CheckPermission('NetworkShare', 'Display')) return('Nemáte oprávnění');70 if (!$this->System->User->CheckPermission('NetworkShare', 'Display')) return ('Nemáte oprávnění'); 71 71 72 72 // If not only online checkbox checked 73 if (array_key_exists('view', $_POST) and !array_key_exists('online', $_POST)) $_POST['online'] = 'off';73 if (array_key_exists('view', $_POST) and !array_key_exists('online', $_POST)) $_POST['online'] = 'off'; 74 74 75 75 // Default host list view 76 if ((count($_POST) == 0) and (count($_GET) == 0))76 if ((count($_POST) == 0) and (count($_GET) == 0)) 77 77 { 78 78 $_POST['view'] = 1; … … 81 81 82 82 // Toggle order direction 83 if (array_key_exists('order', $_GET) and ($_SESSION['order'] == $_GET['order'])) $_GET['order'] .= ' DESC';83 if (array_key_exists('order', $_GET) and ($_SESSION['order'] == $_GET['order'])) $_GET['order'] .= ' DESC'; 84 84 85 85 //print_r($_POST); 86 foreach ($this->Promene as $Index => $Prvek)87 { 88 if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $this->Promene[$Index];89 if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];90 if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];91 if (($Index == 'keyword') and (array_key_exists('view', $_GET))) $_SESSION[$Index] = $this->Promene[$Index];92 if (($Index == 'view') and ((array_key_exists('keyword', $_POST)) or (array_key_exists('keyword', $_GET)))) $_SESSION[$Index] = '';86 foreach ($this->Promene as $Index => $Prvek) 87 { 88 if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $this->Promene[$Index]; 89 if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index]; 90 if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index]; 91 if (($Index == 'keyword') and (array_key_exists('view', $_GET))) $_SESSION[$Index] = $this->Promene[$Index]; 92 if (($Index == 'view') and ((array_key_exists('keyword', $_POST)) or (array_key_exists('keyword', $_GET)))) $_SESSION[$Index] = ''; 93 93 $$Index = $_SESSION[$Index]; 94 94 //echo('$'.$Index.' = '.$_SESSION[$Index].'<br>'); 95 95 } 96 96 //echo($keyword); 97 //if ($keyword)98 //if ($keyword != '') $view = '';97 //if ($keyword) 98 //if ($keyword != '') $view = ''; 99 99 100 100 //$this->Database->select_db('share'); 101 101 102 102 // Log search 103 if (array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET))103 if (array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET)) 104 104 $this->System->ModuleManager->Modules['Log']->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']); 105 105 … … 139 139 </select> '; 140 140 141 if ($online == 'on') $Selected = 'checked '; else $Selected = '';141 if ($online == 'on') $Selected = 'checked '; else $Selected = ''; 142 142 $Output .= '<input type="checkbox" '.$Selected.'name="online">Pouze aktivní uživatele<br> 143 143 </form>'; 144 144 145 145 //$Output .= $view; 146 if ($view != '')146 if ($view != '') 147 147 { 148 148 // Zobrazení obsahu vybrané složky … … 170 170 "(ext LIKE 'iso') OR (ext LIKE 'nrg') OR (ext LIKE 'ccd') OR (ext LIKE 'bin') OR (ext LIKE 'mds')", 171 171 ); 172 if ($file_type > 0) $Podminka .= ' AND ('.$Pripony[$file_type].')';172 if ($file_type > 0) $Podminka .= ' AND ('.$Pripony[$file_type].')'; 173 173 174 174 //Hledání podle velikosti 175 175 $Jednotky = array(1, 1024, 1048576, 1073741824); 176 if (is_numeric($size))176 if (is_numeric($size)) 177 177 { 178 178 $Metoda = array('=', '>', '<'); … … 184 184 // Omezení na online/offline uživatele 185 185 //$this->Database->select_db('is'); 186 if ($online == 'on') $DbResult = $this->Database->query('SELECT Id FROM NetworkDevice WHERE Online=1 AND Member IS NOT NULL');186 if ($online == 'on') $DbResult = $this->Database->query('SELECT Id FROM NetworkDevice WHERE Online=1 AND Member IS NOT NULL'); 187 187 else $DbResult = $this->Database->query('SELECT Id FROM NetworkDevice'); 188 188 $Vyber = ''; 189 while ($Row = $DbResult->fetch_array()) $Vyber .= $Row['Id'].',';189 while ($Row = $DbResult->fetch_array()) $Vyber .= $Row['Id'].','; 190 190 $Podminka .= ' AND (Host IN ('.substr($Vyber, 0, -1).'))'; 191 191 //echo($Podminka.'<br>'); … … 200 200 201 201 // Zobrazení [..] 202 if (($view != '') && ($page == 0) && ($Nahoru > 0))202 if (($view != '') && ($page == 0) && ($Nahoru > 0)) 203 203 { 204 204 $DbResult = $this->Database->query('SELECT * FROM NetworkShareItem WHERE Id='.$view); … … 212 212 $PerPage = 30; 213 213 $Dotaz = "SELECT COUNT(*) FROM NetworkShareItem WHERE (".$Podminka.")"; 214 if ($order != '') $Dotaz .= ' ORDER BY '.$order;214 if ($order != '') $Dotaz .= ' ORDER BY '.$order; 215 215 $Dotaz .= " LIMIT ".($page * $PerPage).",".$PerPage; 216 216 $DbResult = $this->Database->query($Dotaz); … … 218 218 $Pocet = $Row[0]; 219 219 220 if ($Pocet > 0)220 if ($Pocet > 0) 221 221 { 222 222 $Output .= 'Nalezeno celkem: '.$Pocet.' položek<br />'; 223 223 } else 224 224 $Output .= 'Podle zadaných podmínek nic nenalezeno'; 225 if (($Pocet > 0) || ($upstr))225 if (($Pocet > 0) || ($upstr)) 226 226 { 227 227 $Output .= '<table width="100%" style="font-size: 8pt;" border="0" cellpadding="2" cellspacing="2"> 228 228 <tr><th bgcolor="#E0E0FF"><a href="index.php?order=name">Soubor</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=ext">Přípona</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=size">Velikost</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=date">Datum</a></th><th bgcolor="#E0E0FF">Umístění</th></tr>'; 229 229 $Output .= $upstr; 230 if ($Pocet > 0)230 if ($Pocet > 0) 231 231 { 232 232 // Zobrazení tabulky s výsledky … … 235 235 236 236 // Zobrazení poloľek 237 while ($Row = $DbResult->fetch_array())237 while ($Row = $DbResult->fetch_array()) 238 238 { 239 239 // Loguj('Radek '.$Row['name']); … … 244 244 // Zobrazení řádku 245 245 $Cesta2 = strtr($Cesta.$Radek['Name'], '\\', '/'); 246 if ($Radek['Ext'] != '') $Cesta2 .= '.'.$Radek['Ext'];247 if ($Radek['Type'] != 0) $Adresa = 'index.php?view='.$Radek['Id'].'">['.$Radek['Name'].']';246 if ($Radek['Ext'] != '') $Cesta2 .= '.'.$Radek['Ext']; 247 if ($Radek['Type'] != 0) $Adresa = 'index.php?view='.$Radek['Id'].'">['.$Radek['Name'].']'; 248 248 else 249 249 { 250 if (strstr($_SERVER['HTTP_USER_AGENT'], 'Linux')) $Adresa = 'smb:'.$Cesta2.'">'.$Radek['Name'];250 if (strstr($_SERVER['HTTP_USER_AGENT'], 'Linux')) $Adresa = 'smb:'.$Cesta2.'">'.$Radek['Name']; 251 251 else $Adresa = 'file:///'.$Cesta2.'">'.$Radek['Name']; 252 252 } … … 260 260 } 261 261 } 262 if ($Pocet > 0)262 if ($Pocet > 0) 263 263 { 264 264 // Celkový přehled 265 if ($view == 1)265 if ($view == 1) 266 266 { 267 267 $DbResult = $this->Database->query('SELECT SUM(Size) FROM NetworkShareItem WHERE (Parent=1) AND (Host IN ('.substr($Vyber,0,-1).'))'); … … 285 285 $Host = strtoupper(substr($Host, 0, strpos($Host, '.'))); 286 286 $DbResult = $this->Database->select('NetworkShareError', '*', 'Host="'.$Host.'"'); 287 if ($DbResult->num_rows > 0) $Output .= '<strong>Výpis chybových hlášení pro počítač '.$Host.':</strong><br />';287 if ($DbResult->num_rows > 0) $Output .= '<strong>Výpis chybových hlášení pro počítač '.$Host.':</strong><br />'; 288 288 //echo('host="'.$Host.'"'); 289 while ($Row = $DbResult->fetch_array())289 while ($Row = $DbResult->fetch_array()) 290 290 { 291 291 $Row['Message'] = str_replace('/', '\\', $Row['Message']); … … 295 295 296 296 // Zobrazení seznamu stránek 297 if ($Pages > 1)297 if ($Pages > 1) 298 298 { 299 if ($page > 0) $Output .= '<a href="index.php?page=0"><<</a> ';300 if ($page > 0) $Output .= '<a href="index.php?page='.($page-1).'"><</a> ';299 if ($page > 0) $Output .= '<a href="index.php?page=0"><<</a> '; 300 if ($page > 0) $Output .= '<a href="index.php?page='.($page-1).'"><</a> '; 301 301 $PagesMax = $Pages; 302 302 $PagesMin = 0; 303 if ($PagesMax > ($page + 10)) $PagesMax = $page + 10;304 if ($PagesMin < ($page - 10))303 if ($PagesMax > ($page + 10)) $PagesMax = $page + 10; 304 if ($PagesMin < ($page - 10)) 305 305 { 306 306 $Output .= ' .. '; 307 307 $PagesMin = $page - 10; 308 308 } 309 for ($i = $PagesMin; $i <= $PagesMax; $i++)309 for ($i = $PagesMin; $i <= $PagesMax; $i++) 310 310 { 311 if ($i == $page) $Output .= '<strong>';311 if ($i == $page) $Output .= '<strong>'; 312 312 $Output .= '<a href="index.php?page='.$i.'">'.($i + 1).'</a> '; 313 if ($i == $page) $Output .= '</strong>';313 if ($i == $page) $Output .= '</strong>'; 314 314 } 315 if ($PagesMax < $Pages) $Output .= ' .. ';316 if ($page < $Pages) $Output .= '<a href="index.php?page='.($page + 1).'">></a> ';317 if ($page < $Pages) $Output .= '<a href="index.php?page='.$Pages.'">>></a>';315 if ($PagesMax < $Pages) $Output .= ' .. '; 316 if ($page < $Pages) $Output .= '<a href="index.php?page='.($page + 1).'">></a> '; 317 if ($page < $Pages) $Output .= '<a href="index.php?page='.$Pages.'">>></a>'; 318 318 } 319 319 } 320 return ($Output);320 return ($Output); 321 321 } 322 322 } -
trunk/Modules/NetworkShare/browse.php
r790 r873 9 9 $MountDir = '/tmp/browse/host'; // Složka, kde se dočasně připojují síťové disky 10 10 $TempDir = '/tmp/browse/'; // Složka, kde se dočasně připojují síťové disky 11 if (!is_dir($TempDir)) mkdir($TempDir, 0777);12 if (!is_dir($MountDir)) mkdir($MountDir, 0777);11 if (!is_dir($TempDir)) mkdir($TempDir, 0777); 12 if (!is_dir($MountDir)) mkdir($MountDir, 0777); 13 13 14 14 // Nacteni seznamu sdileni 15 15 $Host = strtoupper(getenv('browse_host')); 16 if ($Host=='') die("Musite nastavit browse_host!\n");16 if ($Host=='') die("Musite nastavit browse_host!\n"); 17 17 $HostID = getenv('browse_id'); 18 if ($HostID=='') die("Musite nastavit browse_id!\n");18 if ($HostID=='') die("Musite nastavit browse_id!\n"); 19 19 //echo("\n================== Prochazec sdileni =================\n\n"); 20 20 echo("Nacitam seznam sdileni pro ".$Host.'('.$HostID.')...'); … … 23 23 echo("OK\n"); 24 24 //print_r($Output); 25 if ($Output[0]=='Connection to '.$Host.' failed') die('Pocitac '.$Host." nenalezen!\n");25 if ($Output[0]=='Connection to '.$Host.' failed') die('Pocitac '.$Host." nenalezen!\n"); 26 26 $Output = array_slice($Output,3); 27 27 $Shares = array(); 28 foreach ($Output as $Radek)29 { 30 if ($Radek=='') break;28 foreach ($Output as $Radek) 29 { 30 if ($Radek=='') break; 31 31 //$Radek = iconv('UTF-8','ISO-8859-2',$Radek); 32 32 $Title = trim(substr($Radek,1,16)); … … 34 34 $Desc = trim(substr($Radek,26)); 35 35 //echo($Title.','.$Type.','.$Desc."\n"); 36 if (($Type=='Disk') && (substr($Title,-1,1)!='$')) array_push($Shares,$Title);36 if (($Type=='Disk') && (substr($Title,-1,1)!='$')) array_push($Shares,$Title); 37 37 //ShowArray($Radek); 38 38 } … … 61 61 //echo(strlen($Nazev).","); 62 62 array_push($Files,$Nazev); 63 } while (($Nazev != "\n") && (!feof($Soubor)));63 } while (($Nazev != "\n") && (!feof($Soubor))); 64 64 array_pop($Files); 65 //if (($Pocet-floor($Pocet/10)*10)==9)65 //if (($Pocet-floor($Pocet/10)*10)==9) 66 66 $Hotovo = floor(ftell($Soubor) / $FileSize * $MaxProgress); 67 if ($Hotovo >= $Pocet)67 if ($Hotovo >= $Pocet) 68 68 { 69 69 echo(str_repeat('#', $Hotovo-$Pocet)); … … 71 71 } 72 72 //echo('['.memory_get_usage().'] '.$Cesta."\n"); 73 foreach ($Files as $Radek)73 foreach ($Files as $Radek) 74 74 { 75 75 //echo($Radek.""); 76 76 $Radek = substr($Radek,0,-1); 77 77 //echo($Radek.",\n"); 78 if ($Radek[0] == 'd') $Type = 2; else $Type = 0;78 if ($Radek[0] == 'd') $Type = 2; else $Type = 0; 79 79 $Prava = substr($Radek,0,strpos($Radek,' ')); 80 80 $Radek = ltrim(substr($Radek,strlen($Prava)+1)); … … 94 94 //echo($Date.','.$Time.','.$Radek.' '); 95 95 96 if ((strpos($Nazev,'.') > 0) && ($Type != 2))96 if ((strpos($Nazev,'.') > 0) && ($Type != 2)) 97 97 { 98 98 $Ext = substr($Nazev,strrpos($Nazev,'.')+1); … … 114 114 $Citac = $Citac + 1; 115 115 // Pokud jde o sloľku, tak projdi jeji obsah a aktualizuj velikost 116 if ($Type == 2)116 if ($Type == 2) 117 117 { 118 118 //echo($Vlozit); 119 // if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky119 // if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky 120 120 // $Vlozit = ''; 121 121 $VelikostSlozky += Vetev($Cesta.$Nazev.'/',$Zanoreni+1); … … 123 123 } 124 124 //echo($Vlozit); 125 //if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky125 //if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky 126 126 127 127 // Aktualizuj velikost … … 130 130 $Database->update('NetworkShareItem', 'id='.$Parent, array('size' => $VelikostSlozky)); 131 131 //closedir($Dir); 132 return ($VelikostSlozky);132 return ($VelikostSlozky); 133 133 } 134 134 … … 152 152 $Parent = $Row[0]; 153 153 154 foreach ($Shares as $Share)154 foreach ($Shares as $Share) 155 155 { 156 156 $Pocet = 0; … … 163 163 // echo($SambaSbinDir."mount.cifs '".$ShareFull."' ".$MountDir.' -o guest,codepage=cp852,iocharset=iso8859-2'); 164 164 passthru('ls -A -R -X -l --time-style=+"%Y-%m-%d %I:%M:%S" '.$MountDir.'>'.$TempDir.$Host.'.list 2>'.$TempDir.'errors/'.$Host.'_'.$Share.'.err',$Result); 165 //if ($Result==0)165 //if ($Result==0) 166 166 //{ 167 167 echo("OK\n"); 168 168 169 if (file_exists($TempDir.$Host.'.list'))169 if (file_exists($TempDir.$Host.'.list')) 170 170 { 171 171 // Přidej poloľku sdílení do datanáze … … 215 215 $DbResult = $Database->query('SELECT id FROM hosts'); 216 216 $Vyber = ''; 217 while ($Row = $DbResult->fetch_array())217 while ($Row = $DbResult->fetch_array()) 218 218 $Vyber .= $Row['id'].','; 219 219 … … 226 226 echo("Chyby sdílení...\n"); 227 227 $Database->delete('NetworkShareError', 'host="'.$Host.'"'); 228 if (is_dir($TempDir.'errors'))228 if (is_dir($TempDir.'errors')) 229 229 { 230 230 $Dir = scandir($TempDir.'errors'); 231 foreach ($Dir as $File)231 foreach ($Dir as $File) 232 232 { 233 if (substr($File, 0, strpos($File, '_')) == $Host)233 if (substr($File, 0, strpos($File, '_')) == $Host) 234 234 { 235 235 $Share = substr($File, strpos($File, '_')+1, -4); 236 236 $ShareFull = '//'.$Host.'/'.$Share; 237 if (filesize($TempDir.'errors/'.$File) > 0)237 if (filesize($TempDir.'errors/'.$File) > 0) 238 238 { 239 239 $ErrorFile = fopen($TempDir.'errors/'.$File, 'r+'); 240 while (!feof($ErrorFile))240 while (!feof($ErrorFile)) 241 241 { 242 242 $Row = fgets($ErrorFile); 243 if ($Row != '')243 if ($Row != '') 244 244 { 245 245 $Row = substr($ShareFull.'/'.substr($Row, 39), 0, -1); -
trunk/Modules/NetworkShare/firefox.php
r790 r873 10 10 var msg="Přidání vyhledávacího modulu selhalo - "; 11 11 12 if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")){13 if (engineURL == null || engineURL == ""){12 if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")){ 13 if (engineURL == null || engineURL == ""){ 14 14 alert(msg + "nebyla zadána jeho URL."); 15 15 return false; 16 16 } 17 if (iconURL == null || iconURL == ""){17 if (iconURL == null || iconURL == ""){ 18 18 alert(msg + "nebyla zadána URL ikony."); 19 19 return false; 20 20 } 21 if (engineURL.search(/^http:\/\//i) == -1 || engineURL.search(/\.src$/i) == -1){21 if (engineURL.search(/^http:\/\//i) == -1 || engineURL.search(/\.src$/i) == -1){ 22 22 alert(msg + "nebyla zadána platná URL."); 23 23 return false; 24 24 } 25 if (iconURL.search(/^http:\/\//i) == -1 || iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1){25 if (iconURL.search(/^http:\/\//i) == -1 || iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1){ 26 26 alert(msg + " nebyla platná URL ikony."); 27 27 return false; 28 28 } 29 if (suggestedTitle == null) suggestedTitle = "";30 if (suggestedCategory == null) suggestedCategory = "";29 if (suggestedTitle == null) suggestedTitle = ""; 30 if (suggestedCategory == null) suggestedCategory = ""; 31 31 window.sidebar.addSearchEngine(engineURL, iconURL, suggestedTitle, suggestedCategory); 32 32 }else{ -
trunk/Modules/NetworkShare/online.php
r790 r873 3 3 //$Database->select_db('share'); 4 4 echo("\n====================== Kontrola online pocitacu ============================\n\n"); 5 //while (true)5 //while (true) 6 6 { 7 7 echo('Nacitam strom sdileni...'); … … 13 13 array_shift($Output); 14 14 $Online = array(); // Seznam online pocitacu 15 foreach ($Output as $Radek)15 foreach ($Output as $Radek) 16 16 { 17 if (ord($Radek[0])!=9) continue;17 if (ord($Radek[0])!=9) continue; 18 18 $Host = explode(' ',substr($Radek,3)); 19 19 $Host = $Host[0]; … … 21 21 $Section = 0; 22 22 // Zjisti IP a MAC adresu 23 if ($Host=='CENTRALA')23 if ($Host=='CENTRALA') 24 24 { 25 25 $MAC = '00:E0:4C:20:64:22'; … … 27 27 $Section = 0; 28 28 } else 29 if ($Host=='CENTRALA2')29 if ($Host=='CENTRALA2') 30 30 { 31 31 $MAC = '00:E0:4C:20:64:22'; … … 38 38 //echo('arping -c 1 '.$Host); 39 39 exec('arping -c 1 '.$Host,$Output); 40 if (count($Output)!=4)40 if (count($Output)!=4) 41 41 { 42 42 $Output = array(); 43 43 exec('arping -I wlan0 -c 1 '.$Host,$Output); 44 if (count($Output)!=4)44 if (count($Output)!=4) 45 45 { 46 46 $Output = array(); 47 47 exec('arping -I wlan1 -c 1 '.$Host,$Output); 48 if (count($Output)!=4)48 if (count($Output)!=4) 49 49 { 50 50 $Output = array(); 51 51 exec('arping -I wlan2 -c 1 '.$Host,$Output); 52 if (count($Output)!=4)52 if (count($Output)!=4) 53 53 { 54 54 $Output = array(); 55 55 exec('arping -I eth2 -c 1 '.$Host,$Output); 56 if (count($Output)!=4) continue;56 if (count($Output)!=4) continue; 57 57 else $Section = 4; 58 58 } else $Section = 3; … … 74 74 //print_r($Online); 75 75 // Aktivuj online pocitace 76 foreach ($Online as $Item)76 foreach ($Online as $Item) 77 77 { 78 78 $DbResult = $Database->query("SELECT * FROM hosts WHERE name='".$Item['host']."'"); 79 if ($DbResult->num_rows > 0)79 if ($DbResult->num_rows > 0) 80 80 { 81 81 $Database->update('hosts',"name='".$Item['host']."'",array( 'IP' => $Item['IP'], 'MAC' => $Item['MAC'], 'online' => 1, 'lastdate' => 'NOW()', 'section' => $Section)); … … 85 85 echo("\nSeznam offline pocitacu:\n"); 86 86 $DbResult = $Database->query("SELECT * FROM hosts WHERE online=0"); 87 while ($Row = $DbResult->fetch_array())87 while ($Row = $DbResult->fetch_array()) 88 88 { 89 89 echo($Row['name'].", "); -
trunk/Modules/NetworkShare/playlist.php
r790 r873 6 6 $Vyber = ''; 7 7 $Podminka = ''; 8 while ($Row = $DbResult->fetch_array())8 while ($Row = $DbResult->fetch_array()) 9 9 $Vyber .= $Row['id'].','; 10 10 $Podminka .= ' AND (host IN ('.substr($Vyber,0,-1).'))'; … … 25 25 $Cesta = ''; //$Row['name']; 26 26 $i = 0; 27 while (($Otec>1)&&($i<$MaxNesting))27 while (($Otec>1)&&($i<$MaxNesting)) 28 28 { 29 29 $DbResult = $Database->query("SELECT id,name,parent FROM items WHERE id=$Otec"); … … 33 33 $i++; 34 34 } 35 if ($i >= $MaxNesting) $Cesta = '?'.'\\'.$Cesta;36 return ('\\\\'.$Cesta);35 if ($i >= $MaxNesting) $Cesta = '?'.'\\'.$Cesta; 36 return ('\\\\'.$Cesta); 37 37 } 38 38 … … 40 40 { 41 41 //$FileInfo = new finfo(FILEINFO_MIME); 42 //return ($FileInfo->file($FileName));43 return ('');42 //return ($FileInfo->file($FileName)); 43 return (''); 44 44 } 45 45 … … 51 51 $Dir = ''; 52 52 $DbResult = $Database->select('items', '*', 'ext="mp3"'.$Podminka); //.' LIMIT 0,1000'); 53 while ($Row = $DbResult->fetch_array())53 while ($Row = $DbResult->fetch_array()) 54 54 { 55 if ($Parent != $Row['parent']) $Dir = PlnaCesta($Row); //echo('d'.PlnaCesta($Row)."\n");55 if ($Parent != $Row['parent']) $Dir = PlnaCesta($Row); //echo('d'.PlnaCesta($Row)."\n"); 56 56 $Parent = $Row['parent']; 57 57 echo($Dir.$Row['name'].'.'.$Row['ext']."\n"); -
trunk/Modules/NetworkShare/update.php
r790 r873 4 4 5 5 $Dnes = date('Y-m-d'); 6 //while (1)6 //while (1) 7 7 //{ 8 8 $Hosts = array(); 9 9 $StartTime = GetMicrotime(); 10 10 $DbResult = $Database->query("SELECT * FROM NetworkDevice WHERE Online=1 AND (Block=0 OR Name='centrala') AND (Name!='GATE') AND User>0"); 11 while ($Row = $DbResult->fetch_array())11 while ($Row = $DbResult->fetch_array()) 12 12 { 13 13 //echo('Host: '.$Host."...\n"); … … 16 16 $HostID = 100; 17 17 $StartTime2 = GetMicrotime(); 18 if ($Dnes != $Row['last_share_check'])18 if ($Dnes != $Row['last_share_check']) 19 19 { 20 20 echo("Kontroluji ".$Row['Name']."...\n"); -
trunk/Modules/NetworkTopology/NetworkTopology.php
r738 r873 10 10 function Show() 11 11 { 12 if (count($this->System->PathItems) > 1)12 if (count($this->System->PathItems) > 1) 13 13 { 14 if ($this->System->PathItems[1] == 'topologie.png') return($this->ShowImage());15 else return (PAGE_NOT_FOUND);14 if ($this->System->PathItems[1] == 'topologie.png') return ($this->ShowImage()); 15 else return (PAGE_NOT_FOUND); 16 16 17 } else return ($this->ShowOverview());17 } else return ($this->ShowOverview()); 18 18 } 19 19 … … 23 23 $this->FormatHTML = false; 24 24 25 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];25 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug']; 26 26 else $debug = 0; 27 27 … … 54 54 'FROM NetworkTopology LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkTopology.Host '. 55 55 'LEFT JOIN NetworkDeviceType ON NetworkDevice.Type = NetworkDeviceType.Id'); 56 while ($item = $DbResult->fetch_array())56 while ($item = $DbResult->fetch_array()) 57 57 { 58 58 $id = $item['Id']; … … 62 62 $vlast = $item['Last']; 63 63 $xpos = $vleft * $spacex; 64 if (($vtop > 0) or ($item['Name'] == $this->TopHostName))64 if (($vtop > 0) or ($item['Name'] == $this->TopHostName)) 65 65 { 66 if ($vtop > 0) imageline($im, $xpos + $halfx, $vtop * $spacey, $xpos + $halfx, $vtop * $spacey + 8, $black);67 if ($vfirst >= 0)66 if ($vtop > 0) imageline($im, $xpos + $halfx, $vtop * $spacey, $xpos + $halfx, $vtop * $spacey + 8, $black); 67 if ($vfirst >= 0) 68 68 { 69 69 imageline($im, $vfirst*$spacex + $halfx, $vtop * $spacey + $spacey, $vlast*$spacex + $halfx, $vtop * $spacey + $spacey, $black); … … 71 71 } 72 72 // $ip = explode('.',$item['IP']); 73 // if (!array_key_exists(3, $ip)) $ip[3] = '';74 if ($item['IconName'] == 'comp')73 // if (!array_key_exists(3, $ip)) $ip[3] = ''; 74 if ($item['IconName'] == 'comp') 75 75 { 76 if ($item['Online'] == 1) $color = $green;76 if ($item['Online'] == 1) $color = $green; 77 77 else $color = $black; 78 78 $image = $im_comp; 79 79 } else $image = $im_dev; 80 if ($item['IconName'] == 'device')80 if ($item['IconName'] == 'device') 81 81 { 82 if ($item['Online'] == 1) $color = $green;82 if ($item['Online'] == 1) $color = $green; 83 83 else $color = $red; 84 84 $image = $im_dev; 85 85 } 86 if ($item['ShowOnline'] == 0)86 if ($item['ShowOnline'] == 0) 87 87 { 88 88 $color = $gray; … … 100 100 101 101 // === Sestavení výsledného souboru ============================================ 102 if ($debug == 0)102 if ($debug == 0) 103 103 { 104 104 Header("Content-type: image/png"); … … 109 109 imagedestroy($im_dev); 110 110 } 111 return ('');111 return (''); 112 112 } 113 113 … … 126 126 zařízení, které jsou přes něj připojeny. U zařízení, kde není stav možné 127 127 zjišťovat je použita <span style="color:gray">šedá barvou</span>.</p>'; 128 return ($Output);128 return ($Output); 129 129 } 130 130 } -
trunk/Modules/NetworkTopology/topologie-gen.php
r548 r873 6 6 global $Database, $debug; 7 7 8 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];8 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug']; 9 9 else $debug = 0; 10 10 //$debug = 0; … … 110 110 $markskip = 0; 111 111 } 112 } while ($level >= 1);112 } while ($level >= 1); 113 113 } 114 114 … … 128 128 $Database->query("INSERT INTO NetworkTopology (Host, Depth, Pos, First, Last) '. 129 129 'VALUES (".$node->index.','.$node->level.','.$this->calc_pos($node).','.$first.','.$last.");"); 130 foreach ($node->children as $key => $value) {130 foreach ($node->children as $key => $value) { 131 131 $this->store_node($value); 132 132 } … … 149 149 $this->setborder($node->level, $this->border[$node->level+1]+1); 150 150 } 151 foreach ($node->children as $key => $value) {151 foreach ($node->children as $key => $value) { 152 152 if ($key == count($node->children)-1) { 153 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);153 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 154 154 } 155 155 $this->left_align($value); 156 156 if ($key == 0) { 157 if ($this->border[$node->level] <= $this->border[$node->level+1]) {157 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 158 158 $node->pos = $this->border[$node->level+1]-1; 159 159 $this->setborder($node->level, $this->border[$node->level+1]); … … 174 174 $this->setborder($node->level, $this->border[$node->level+1]+1); 175 175 } 176 for ($key=count($node->children)-1;$key>=0;$key--) {176 for ($key=count($node->children)-1;$key>=0;$key--) { 177 177 $value = $node->children[$key]; 178 178 if ((count($value->children)>0) && count($node->order)>0) { … … 180 180 } 181 181 if ($key == 0) { 182 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);182 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 183 183 } 184 184 $this->right_align($value); 185 185 if ($key == count($node->children)-1) { 186 if ($this->border[$node->level] <= $this->border[$node->level+1]) {186 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 187 187 $node->rpos = $this->border[$node->level+1]-1; 188 188 $this->setborder($node->level, $this->border[$node->level+1]); … … 196 196 /** Reset construction border **/ 197 197 function reset_border() { 198 foreach ($this->border as $key => $value) $this->border[$key] = 0;198 foreach ($this->border as $key => $value) $this->border[$key] = 0; 199 199 $this->maxborder = 0; 200 200 } … … 214 214 $target = 0; // Index cílového uzlu 215 215 $lastindex = 0; // Index poslední vydličky 216 foreach ($node->children as $key => $value) {216 foreach ($node->children as $key => $value) { 217 217 if (count($value->children)>0) { 218 218 array_push($forkmap,$value); … … 221 221 } 222 222 } 223 for ($i=0;$i<$node->forkcnt-1;$i++) {224 for ($j=0;$j<count($forkmap);$j++) {223 for ($i=0;$i<$node->forkcnt-1;$i++) { 224 for ($j=0;$j<count($forkmap);$j++) { 225 225 $this->border = $preborder; 226 226 $this->maxborder = $premax; 227 227 $k = 0; // index zpracovávané vydličky 228 foreach ($node->children as $key => $value) {228 foreach ($node->children as $key => $value) { 229 229 if (count($value->children)>0) { 230 230 if ($order[$value->index]) { … … 241 241 } 242 242 if ($key == count($node->children)-1) { 243 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);243 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 244 244 } 245 245 $this->left_align($value); 246 246 if ($key == 0) { 247 if ($this->border[$node->level] <= $this->border[$node->level+1]) {247 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 248 248 $node->pos = $this->border[$node->level+1]-1; 249 249 $this->setborder($node->level, $this->border[$node->level+1]); … … 272 272 $this->setborder($node->level, $this->border[$node->level+1]+1); 273 273 } 274 foreach ($node->children as $key => $value) {274 foreach ($node->children as $key => $value) { 275 275 if ((count($value->children)>0) && count($order)>0) { 276 276 $value = $order[$value->index]; 277 277 } 278 278 if ($key == count($node->children)-1) { 279 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);279 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 280 280 } 281 281 $this->reorder($value); 282 282 if ($key == 0) { 283 if ($this->border[$node->level] <= $this->border[$node->level+1]) {283 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 284 284 $node->pos = $this->border[$node->level+1]-1; 285 285 $this->setborder($node->level, $this->border[$node->level+1]); … … 301 301 } 302 302 $forkcnt = 0; // Fork counter 303 foreach ($node->children as $key => $value) {303 foreach ($node->children as $key => $value) { 304 304 if ($forkcnt == count($node->children)-1) { 305 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);305 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 306 306 } 307 307 if (count($value->children)>0) { 308 308 $this->left_stub($value); 309 309 if ($forkcnt == 0) { 310 if ($this->border[$node->level] <= $this->border[$node->level+1]) {310 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 311 311 $node->pos = $this->border[$node->level+1]-1; 312 312 $this->setborder($node->level, $this->border[$node->level+1]); … … 335 335 $lastindex = 0; // Index poslední vydličky 336 336 $fact = 1; // Faktoriál kombinací vydliček 337 foreach ($node->children as $key => $value) {337 foreach ($node->children as $key => $value) { 338 338 if (count($value->children)>0) { 339 339 if ($key>0) $fact = $fact * ($key+1); … … 343 343 } 344 344 } 345 for ($i=0;$i<$node->forkcnt-1;$i++) {346 for ($j=0;$j<count($forkmap);$j++) {345 for ($i=0;$i<$node->forkcnt-1;$i++) { 346 for ($j=0;$j<count($forkmap);$j++) { 347 347 $this->border = $preborder; 348 348 $this->maxborder = $premax; 349 349 $k = 0; // index zpracovávané vydličky 350 foreach ($node->children as $key => $value) {350 foreach ($node->children as $key => $value) { 351 351 if (count($value->children)>0) { 352 352 if ($order[$value->index]) { … … 363 363 } 364 364 if ($key == count($node->children)-1) { 365 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);365 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 366 366 } 367 367 $this->left_align($value); 368 368 if ($key == 0) { 369 if ($this->border[$node->level] <= $this->border[$node->level+1]) {369 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 370 370 $node->pos = $this->border[$node->level+1]-1; 371 371 $this->setborder($node->level, $this->border[$node->level+1]); … … 395 395 $this->setborder($node->level, $this->border[$node->level+1]+1); 396 396 } 397 foreach ($node->children as $key => $value) {397 foreach ($node->children as $key => $value) { 398 398 if ((count($value->children)>0) && count($order)>0) { 399 399 $value = $order[$value->index]; 400 400 } 401 401 if ($key == count($node->children)-1) { 402 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);402 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 403 403 } 404 404 $this->reorder($value); 405 405 if ($key == 0) { 406 if ($this->border[$node->level] <= $this->border[$node->level+1]) {406 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 407 407 $node->pos = $this->border[$node->level+1]-1; 408 408 $this->setborder($node->level, $this->border[$node->level+1]); -
trunk/Modules/NetworkTopology/topologie-img.php
r738 r873 3 3 include('../global.php'); 4 4 5 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];5 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug']; 6 6 else $debug = 0; 7 7 $TopHostName = 'nix-router'; … … 13 13 global $debug, $bbound; 14 14 15 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0;16 if ($i = $vfirst[$id])15 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0; 16 if ($i = $vfirst[$id]) 17 17 { 18 18 //if ($debug==2) echo $id.':'.@$i.','.@$vpred[$i].'-'.@$vleft[@$vpred[$i]]."\n"; … … 37 37 $vleft[$i]+=$diff; 38 38 $limit = balance($i,$level+1, $vlast,$vleft,$vpred, $vfirst,$vnext,$tbound, $width, $limit) + 2; 39 if (!array_key_exists($i, $vnext)) $vnext[$i] = 0;39 if (!array_key_exists($i, $vnext)) $vnext[$i] = 0; 40 40 $i = $vnext[$i]; 41 41 } … … 91 91 $item = $DbResult->fetch_array(); 92 92 //print_r($item); 93 if ($item)93 if ($item) 94 94 { 95 95 // --- Zpracování položky z DB ----------------------------------------------- 96 if ($position[$level] > 0)96 if ($position[$level] > 0) 97 97 { 98 98 $vnext[$curr] = $item['id']; // Neprvní položka, nastav předchozí … … 103 103 $vlast[$parent[$level]] = $curr; 104 104 $vtop[$curr] = $level; 105 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0;105 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0; 106 106 $vleft[$curr] = $tbound[$level]; 107 if (!array_key_exists($level, $tranger)) $tranger[$level] = 0;107 if (!array_key_exists($level, $tranger)) $tranger[$level] = 0; 108 108 $vpred[$curr] = $tranger[$level]; 109 109 $tranger[$level] = $curr; … … 117 117 { 118 118 // Uzelový vrchol 119 if (array_key_exists($level + 1, $tbound))120 if ($tbound[$level + 1] > $vleft[$curr]) $vleft[$curr] = $tbound[$level + 1];119 if (array_key_exists($level + 1, $tbound)) 120 if ($tbound[$level + 1] > $vleft[$curr]) $vleft[$curr] = $tbound[$level + 1]; 121 121 } 122 122 $tbound[$level] = $vleft[$curr] + 2; … … 133 133 { 134 134 // --- Zarovnávání prvků kvůli vzhledu 135 if (!array_key_exists($vfirst[$parent[$level]], $vleft)) $vleft[$vfirst[$parent[$level]]] = 0;136 if (!array_key_exists($parent[$level], $vleft)) $vleft[$parent[$level]] = 0;135 if (!array_key_exists($vfirst[$parent[$level]], $vleft)) $vleft[$vfirst[$parent[$level]]] = 0; 136 if (!array_key_exists($parent[$level], $vleft)) $vleft[$parent[$level]] = 0; 137 137 if ($vleft[$vfirst[$parent[$level]]] > $vleft[$parent[$level]]) 138 138 { … … 146 146 } 147 147 $level--; 148 if (!array_key_exists($level, $parent)) $parent[$level] = 0;149 if (!array_key_exists($parent[$level], $vlast)) $vlast[$parent[$level]] = 0;148 if (!array_key_exists($level, $parent)) $parent[$level] = 0; 149 if (!array_key_exists($parent[$level], $vlast)) $vlast[$parent[$level]] = 0; 150 150 $curr = $vlast[$parent[$level]]; 151 151 152 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0;153 if (!array_key_exists($level + 1, $tbound)) $tbound[$level + 1] = 0;154 if ($tbound[$level] > $tbound[$level + 1]) $tbound[$level + 1] = $tbound[$level];155 } 156 } while ($level >= 0);152 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0; 153 if (!array_key_exists($level + 1, $tbound)) $tbound[$level + 1] = 0; 154 if ($tbound[$level] > $tbound[$level + 1]) $tbound[$level + 1] = $tbound[$level]; 155 } 156 } while ($level >= 0); 157 157 $data = compact('tbound', 'count', 'tbound', 'vfirst', 'vlast', 'vtop', 'vleft', 'height', 'width', 'index', 'maxindex'); 158 return ($data);158 return ($data); 159 159 }; 160 160 … … 164 164 $data = gentree(1); 165 165 $datawidth = $data['width']; 166 for ($i = 0; $i <= $maxindex; $i++)167 { 168 if (!array_key_exists($i, $vleft)) $vleft[$i] = 0;169 if (!array_key_exists($i, $data['vleft'])) $data['vleft'][$i] = 0;166 for ($i = 0; $i <= $maxindex; $i++) 167 { 168 if (!array_key_exists($i, $vleft)) $vleft[$i] = 0; 169 if (!array_key_exists($i, $data['vleft'])) $data['vleft'][$i] = 0; 170 170 $vleft[$i] = .2 + ($vleft[$i] + ($datawidth - $data['vleft'][$i])) / 2; 171 171 } … … 179 179 $IconList = array(); 180 180 $DbResult = $Database->query('SELECT * FROM HostType'); 181 while ($HostType = $DbResult->fetch_assoc())181 while ($HostType = $DbResult->fetch_assoc()) 182 182 $IconList[$HostType['Id']] = imagecreatefrompng('images/'.$HostType['IconName'].'.png'); 183 183 … … 194 194 { 195 195 global $vleft, $spacex; 196 return ($vleft[$id] * $spacex);196 return ($vleft[$id] * $spacex); 197 197 } 198 198 199 199 $DbResult = $Database->query('SELECT * FROM hosts JOIN HostType ON HostType.Id = hosts.type WHERE hosts.used=1'); 200 while ($item = $DbResult->fetch_array())200 while ($item = $DbResult->fetch_array()) 201 201 { 202 202 $id = $item['id']; 203 if (!array_key_exists($id, $vtop)) $vtop[$id] = 0;204 if (($vtop[$id] > 0) || ($item['name'] == $TopHostName))203 if (!array_key_exists($id, $vtop)) $vtop[$id] = 0; 204 if (($vtop[$id] > 0) || ($item['name'] == $TopHostName)) 205 205 { 206 if ($vtop[$id] > 0) imageline($im, xpos($id) + $halfx, $vtop[$id] * $spacey, xpos($id) + $halfx, $vtop[$id] * $spacey + 8, $black);207 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0;208 if ($vfirst[$id] > 0)206 if ($vtop[$id] > 0) imageline($im, xpos($id) + $halfx, $vtop[$id] * $spacey, xpos($id) + $halfx, $vtop[$id] * $spacey + 8, $black); 207 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0; 208 if ($vfirst[$id] > 0) 209 209 { 210 210 imageline($im, xpos($vfirst[$id]) + $halfx, $vtop[$id] * $spacey + $spacey, xpos($vlast[$id]) + $halfx, $vtop[$id] * $spacey + $spacey, $black); … … 213 213 214 214 $image = $IconList[$item['type']]; 215 if ($item['IP'] == '')215 if ($item['IP'] == '') 216 216 { 217 217 $color = $gray; 218 218 } else 219 if ($item['ShowOnline'] == 1)220 { 221 if ($item['online'] == 1) $color = $green; else $color = $black;222 } else 223 { 224 if ($item['online'] == 1) $color = $green; else $color = $red;219 if ($item['ShowOnline'] == 1) 220 { 221 if ($item['online'] == 1) $color = $green; else $color = $black; 222 } else 223 { 224 if ($item['online'] == 1) $color = $green; else $color = $red; 225 225 } 226 226 // $text='IP: '.$ip[0]; … … 228 228 imagecopy($im, $image, xpos($id) + $halfx - 15, $vtop[$id] * $spacey + 12, 0, 0, 30, 30); 229 229 // imagerectangle($im,xpos($id)+$halfx-6,$vtop[$id]*$spacey+16,xpos($id)+$halfx+6,$vtop[$id]*$spacey+28,$color); 230 if ($debug)230 if ($debug) 231 231 { 232 232 imagestring($im, 2, xpos($id) + ($spacex - strlen($item['id']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), $item['id'], $color); … … 237 237 238 238 // === Sestavení výsledného souboru ============================================ 239 if (!($debug > 1))239 if (!($debug > 1)) 240 240 { 241 241 header('Content-type: image/png'); -
trunk/Modules/NetworkTopology/topologie2.php
r858 r873 29 29 $Hosts = array(); 30 30 $DbResult = $Database->select('hosts', 'id, name, ip, parent, online', 'used=1'); 31 while ($DbRow = $DbResult->fetch_array())31 while ($DbRow = $DbResult->fetch_array()) 32 32 { 33 if (!array_key_exists($DbRow['id'], $Hosts)) $Hosts[$DbRow['id']] = array('subitems' => array());33 if (!array_key_exists($DbRow['id'], $Hosts)) $Hosts[$DbRow['id']] = array('subitems' => array()); 34 34 $Hosts[$DbRow['id']] = array('id' => $DbRow['id'], 'name' => $DbRow['name'], 'parent' => $DbRow['parent'], 'online' => $DbRow['online'], 'subitems' => $Hosts[$DbRow['id']]['subitems']); 35 if (!array_key_exists($DbRow['parent'], $Hosts)) $Hosts[$DbRow['parent']] = array('subitems' => array());35 if (!array_key_exists($DbRow['parent'], $Hosts)) $Hosts[$DbRow['parent']] = array('subitems' => array()); 36 36 $Hosts[$DbRow['parent']]['subitems'][] = &$Hosts[$DbRow['id']]; 37 37 $Hosts[$DbRow['id']]['parent_node'] = &$Hosts[$DbRow['parent']]; … … 44 44 { 45 45 $Result = array('min' => $Host['displacement'], 'max' => $Host['displacement']); 46 foreach ($Host['subitems'] as $Index => $SubHost)46 foreach ($Host['subitems'] as $Index => $SubHost) 47 47 { 48 48 $SubitemResult = $this->CalculateDimension($Host['subitems'][$Index]); … … 50 50 $Result['max'] = max($SubitemResult['max'], $Result['max']); 51 51 } 52 return ($Result);52 return ($Result); 53 53 } 54 54 55 55 function CalculateDisplacement(&$Host, $Level = 0) 56 56 { 57 if (!array_key_exists('displacement', $Host)) $Host['displacement'] = 0;57 if (!array_key_exists('displacement', $Host)) $Host['displacement'] = 0; 58 58 $Host['level'] = $Level; 59 foreach ($Host['subitems'] as $Index => $SubHost)59 foreach ($Host['subitems'] as $Index => $SubHost) 60 60 { 61 61 $Host['subitems'][$Index]['rel_displacement'] = (-(count($Host['subitems']) - 1) * 0.5 + $Index) * $this->HostWidth; … … 68 68 { 69 69 $Host['displacement'] = $Host['displacement'] + $Displacement; 70 foreach ($Host['subitems'] as $Index => $SubHost)70 foreach ($Host['subitems'] as $Index => $SubHost) 71 71 { 72 72 $this->MoveNode($Host['subitems'][$Index], $Displacement); … … 76 76 function CheckColision() 77 77 { 78 foreach ($this->Levels as $Index => $Level)78 foreach ($this->Levels as $Index => $Level) 79 79 { 80 for ($I = 0; $I < count($Level) - 1; $I++)81 if ($Level[$I]['displacement'] >= $Level[$I + 1]['displacement'])80 for ($I = 0; $I < count($Level) - 1; $I++) 81 if ($Level[$I]['displacement'] >= $Level[$I + 1]['displacement']) 82 82 { 83 83 // Search for common parent 84 84 $LeftHost = $Level[$I]; 85 85 $RightHost = $Level[$I + 1]; 86 while (($LeftHost['level'] > 0) and ($LeftHost['parent'] != $RightHost['parent']))86 while (($LeftHost['level'] > 0) and ($LeftHost['parent'] != $RightHost['parent'])) 87 87 { 88 88 $LeftHost = $LeftHost['parent_node']; … … 91 91 $Host = $RightHost['parent_node']['subitems'][0]; 92 92 $II = 0; 93 while ($RightHost['parent_node']['subitems'][$II]['id'] != $RightHost['id']) $II++;94 while ($II < count($RightHost['parent_node']['subitems']))93 while ($RightHost['parent_node']['subitems'][$II]['id'] != $RightHost['id']) $II++; 94 while ($II < count($RightHost['parent_node']['subitems'])) 95 95 { 96 96 $this->MoveNode($RightHost['parent_node']['subitems'][$II], $Level[$I]['displacement'] - $Level[$I + 1]['displacement']); … … 104 104 { 105 105 $this->Levels[$Host['level']][] = &$Host; 106 foreach ($Host['subitems'] as $Index => $SubHost)106 foreach ($Host['subitems'] as $Index => $SubHost) 107 107 { 108 108 $this->BuildLevels($Host['subitems'][$Index]); … … 113 113 { 114 114 $ParentHostPos = array('x' => -$this->RelPos['min'] + $Host['displacement'], 'y' => $Host['level'] * $this->HostHeight); 115 foreach ($Host['subitems'] as $Index => $SubHost)115 foreach ($Host['subitems'] as $Index => $SubHost) 116 116 { 117 117 $HostPos = array('x' => -$this->RelPos['min'] + $SubHost['displacement'], 'y' => $SubHost['level'] * $this->HostHeight); -
trunk/Modules/News/ImportKinoVatra.php
r790 r873 16 16 $doc = new DOMDocument(); 17 17 $doc->load($SourceURL); 18 foreach ($doc->getElementsByTagName('item') as $node)18 foreach ($doc->getElementsByTagName('item') as $node) 19 19 { 20 20 $Title = $node->getElementsByTagName('title')->item(0)->nodeValue; … … 26 26 $Description = str_replace("\r", '', $Description); 27 27 $Description = str_replace("\n", '<br>', $Description); 28 //if (($CommaPos = strpos($Date, ',')) !== FALSE)28 //if (($CommaPos = strpos($Date, ',')) !== FALSE) 29 29 // $Date = substr($Date, $CommaPos + 1); 30 30 $Date = TimeToMysqlDateTime(strtotime($Date)); … … 32 32 $Query = 'SELECT Id FROM News WHERE (`Title`="'.$System->Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$System->Database->real_escape_string($Description).'") AND (`Link` = "'.$System->Database->real_escape_string($Link).'")'; 33 33 $DbResult = $System->Database->query($Query); 34 if ($DbResult->num_rows == 0)34 if ($DbResult->num_rows == 0) 35 35 { 36 36 $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); -
trunk/Modules/News/ImportObecHovezi.php
r827 r873 16 16 $doc = new DOMDocument(); 17 17 @$doc->load($SourceURL); 18 foreach ($doc->getElementsByTagName('item') as $node)18 foreach ($doc->getElementsByTagName('item') as $node) 19 19 { 20 20 $Title = $node->getElementsByTagName('title')->item(0)->nodeValue; … … 26 26 $Description = str_replace("\r", '', $Description); 27 27 $Description = str_replace("\n", '<br>', $Description); 28 //if (($CommaPos = strpos($Date, ',')) !== FALSE)28 //if (($CommaPos = strpos($Date, ',')) !== FALSE) 29 29 // $Date = substr($Date, $CommaPos + 1); 30 30 $Date = TimeToMysqlDateTime(strtotime($Date)); … … 33 33 $DbResult = $System->Database->select('News', 'Id', '(`Title`="'.$System->Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$System->Database->real_escape_string($Description).'") AND (`Link` = "'.$System->Database->real_escape_string($Link).'")'); 34 34 //echo($System->Database->LastQuery); 35 if ($DbResult->num_rows == 0)35 if ($DbResult->num_rows == 0) 36 36 { 37 37 $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); … … 44 44 //$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250')); 45 45 $Content = file_get_contents($SourceURL); 46 while (strpos($Content, $StartText) !== false)46 while (strpos($Content, $StartText) !== false) 47 47 { 48 48 $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText)); … … 74 74 $DbResult = $System->Database->select('News', 'Id', '(`Title`="'.$Title.'") AND (`Category`='.$Category.') AND (`Content` = "'.$Description.'") AND (`Link` = "'.$Link.'")'); 75 75 //echo($System->Database->LastQuery); 76 if ($DbResult->num_rows == 0)76 if ($DbResult->num_rows == 0) 77 77 { 78 78 $System->Database->insert('News', array('Title' => $Title, 'Date' => 'NOW()', 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); -
trunk/Modules/News/ImportTvBeskyd.php
r827 r873 17 17 //$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250')); 18 18 $Content = @file_get_contents($SourceURL); 19 while (strpos($Content, $StartText) !== false)19 while (strpos($Content, $StartText) !== false) 20 20 { 21 21 $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText)); … … 37 37 $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Category`='.$Category); 38 38 //echo($System->Database->LastQuery); 39 if ($DbResult->num_rows == 0)39 if ($DbResult->num_rows == 0) 40 40 { 41 41 $System->Database->insert('News', array('Title' => $Title, 'Date' => 'NOW()', 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); -
trunk/Modules/News/ImportZdechovCzNews.php
r827 r873 16 16 $Author = 'Automat'; 17 17 $Content = @file_get_contents($SourceURL); 18 while (strpos($Content, $StartText) !== false)18 while (strpos($Content, $StartText) !== false) 19 19 { 20 20 $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText)); … … 25 25 $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink)); 26 26 $Link = substr($Content, 0, strpos($Content, '"')); 27 if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;27 if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link; 28 28 $Content = substr($Content, strpos($Content, $StartTitle) + strlen($StartTitle)); 29 29 $Title = substr($Content, 0, strpos($Content, '<')); … … 40 40 $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category); 41 41 //echo($System->Database->LastQuery); 42 if ($DbResult->num_rows == 0)42 if ($DbResult->num_rows == 0) 43 43 { 44 44 $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); -
trunk/Modules/News/ImportZdechovCzRecords.php
r827 r873 16 16 $Author = 'Automat'; 17 17 $Content = @file_get_contents($SourceURL); 18 while (strpos($Content, $StartText) !== false)18 while (strpos($Content, $StartText) !== false) 19 19 { 20 20 $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText)); … … 22 22 $Date = substr($Content, 0, strpos($Content, '<')); 23 23 $DateParts = explode('.', $Date); 24 if (count($DateParts) >= 3)24 if (count($DateParts) >= 3) 25 25 $Date = $DateParts[2].'-'.$DateParts[1].'-'.$DateParts[0]; 26 26 else break; 27 27 $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink)); 28 28 $Link = substr($Content, 0, strpos($Content, '"')); 29 if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;29 if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link; 30 30 $Content = substr($Content, strpos($Content, $StartTitle) + strlen($StartTitle)); 31 31 $Title = substr($Content, 0, strpos($Content, '<')); … … 42 42 $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category); 43 43 //echo($System->Database->LastQuery); 44 if ($DbResult->num_rows == 0)44 if ($DbResult->num_rows == 0) 45 45 { 46 46 $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); -
trunk/Modules/News/News.php
r790 r873 5 5 function CategoryItemCompare($Item1, $Item2) 6 6 { 7 if ($Item1['Index'] == $Item2['Index']) return (0);7 if ($Item1['Index'] == $Item2['Index']) return (0); 8 8 return ($Item1['Index'] > $Item2['Index']) ? -1 : 1; 9 9 } … … 81 81 )); 82 82 83 if ($this->System->ModuleManager->ModulePresent('Search'))83 if ($this->System->ModuleManager->ModulePresent('Search')) 84 84 { 85 85 $this->System->ModuleManager->Modules['Search']->RegisterSearch('Novinky', 'News', array('Title', 'Content')); … … 95 95 $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption']; 96 96 $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>'; 97 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))97 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category)) 98 98 $Output .= ' <a href="aktuality/?action=add&category='.$Category.'">Přidat</a>'; 99 99 $Output .= '</div></div><div class="Content">'; … … 102 102 $Index = 0; 103 103 $FontSize = 12; 104 if ($DbResult->num_rows > 0)104 if ($DbResult->num_rows > 0) 105 105 { 106 106 $Output .= '<table class="NewsTable">'; 107 while ($Row = $DbResult->fetch_array())108 { 109 if ($Row['Name'] == '') $Author = $Row['Author'];107 while ($Row = $DbResult->fetch_array()) 108 { 109 if ($Row['Name'] == '') $Author = $Row['Author']; 110 110 else $Author = $Row['Name']; 111 111 $Output .= '<tr><td onclick="window.location=\'aktuality/?action=view&id='.$Row['Id']. … … 114 114 '<td align="right" style="font-size: '.$FontSize.'pt">'.$Author.' ('.HumanDate($Row['Date']).')</td></tr></table>'; 115 115 $Output .= '<div id="new'.$Category.$Index.'" class="NewsTableItem">'.$this->ModifyContent($Row['Content']); 116 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';117 118 if ($Row['Enclosure'] != '')116 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 117 118 if ($Row['Enclosure'] != '') 119 119 { 120 120 $Output .= '<br />Přílohy: '; 121 121 $Enclosures = explode(';', $Row['Enclosure']); 122 foreach ($Enclosures as $Enclosure)122 foreach ($Enclosures as $Enclosure) 123 123 { 124 if (file_exists($this->UploadedFilesFolder.$Enclosure))124 if (file_exists($this->UploadedFilesFolder.$Enclosure)) 125 125 $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>'; 126 126 } … … 133 133 } 134 134 $Output .= '</div></div>'; 135 return ($Output);135 return ($Output); 136 136 } 137 137 … … 142 142 $I = 1; 143 143 $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY Sequence'); 144 while ($NewsCategory = $DbResult->fetch_array())144 while ($NewsCategory = $DbResult->fetch_array()) 145 145 { 146 146 $this->NewsSetting[] = array('CategoryId' => $NewsCategory['Id'], 'Index' => $I, 'Enabled' => 1, … … 149 149 } 150 150 // Merge defaults with user setting 151 if (array_key_exists('NewsSetting', $_COOKIE))151 if (array_key_exists('NewsSetting', $_COOKIE)) 152 152 { 153 153 $NewsSettingCookie = unserialize($_COOKIE['NewsSetting']); 154 foreach ($this->NewsSetting as $Index => $this->NewSetting)155 { 156 if (array_key_exists($Index, $NewsSettingCookie))154 foreach ($this->NewsSetting as $Index => $this->NewSetting) 155 { 156 if (array_key_exists($Index, $NewsSettingCookie)) 157 157 $this->NewsSetting[$Index] = array_merge($this->NewSetting, $NewsSettingCookie[$Index]); 158 158 } … … 166 166 $this->LoadSettingsFromCookies(); 167 167 168 if (array_key_exists('Action', $_GET))168 if (array_key_exists('Action', $_GET)) 169 169 { 170 170 // Show news customize menu 171 if ($_GET['Action'] == 'CustomizeNews')171 if ($_GET['Action'] == 'CustomizeNews') 172 172 { 173 173 $Output .= $this->ShowCustomizeMenu(); … … 179 179 $ColumnCount = 2; 180 180 $Output .= '<table style="width: 100%"><tr>'; 181 for ($Column = 1; $Column <= $ColumnCount; $Column++)181 for ($Column = 1; $Column <= $ColumnCount; $Column++) 182 182 { 183 183 $Output .= '<td style="vertical-align: top; width: '.round(100 / $ColumnCount).'%;">'; 184 foreach ($this->NewsSetting as $SettingItem)185 if (($SettingItem['Enabled'] == 1) and ($SettingItem['Group'] == $Column))184 foreach ($this->NewsSetting as $SettingItem) 185 if (($SettingItem['Enabled'] == 1) and ($SettingItem['Group'] == $Column)) 186 186 $Output .= $this->ShowNews($SettingItem['CategoryId'], $SettingItem['ItemCount'], $SettingItem['DaysAgo']); 187 187 $Output .= '</td>'; … … 191 191 $Output .= '<a href="aktuality/subscription"><img class="RSSIcon" src="images/rss20.png" alt="Aktuality přes RSS" /></a> <a href="aktuality/subscription">Automatické sledování novinek</a>'; 192 192 $Output .= '</div>'; 193 return ($Output);193 return ($Output); 194 194 } 195 195 … … 200 200 $Output .= '<tr><th>Kategorie</th><th>Pozice</th><th>Zobrazit</th><th>Max. počet</th><th>Posledních dnů</th><th>Sloupec</th></tr>'; 201 201 $I = 0; 202 foreach ($this->NewsSetting as $SettingItem)202 foreach ($this->NewsSetting as $SettingItem) 203 203 { 204 204 $DbResult = $this->Database->select('NewsCategory', '*', 'Id='.$SettingItem['CategoryId']); 205 205 $NewsCategory = $DbResult->fetch_array(); 206 206 $Output .= '<tr><td>'.$NewsCategory['Caption'].'</td><td align="center"><input type="text" size="2" name="NewsCategoryIndex'.$I.'" value="'.$SettingItem['Index'].'" /></td><td align="center"><input type="checkbox" name="NewsCategoryEnabled'.$I.'"'; 207 if ($SettingItem['Enabled'] == 1) $Output .= ' checked="checked"';207 if ($SettingItem['Enabled'] == 1) $Output .= ' checked="checked"'; 208 208 $Output .= ' /></td>'. 209 209 '<td align="center"><input type="text" size="2" name="NewsCategoryCount'.$I.'" value="'.$SettingItem['ItemCount'].'" />'. … … 214 214 } 215 215 $Output .= '</table><input type="hidden" name="NewsCategoryCount" value="'.count($this->NewsSetting).'" /><input type="submit" value="Uložit" /></form></td></tr></table><br>'; 216 return ($Output);216 return ($Output); 217 217 } 218 218 … … 221 221 $Checkbox = array('' => 0, 'on' => 1); 222 222 $Setting = array(); 223 for ($I = 0; $I < $_POST['NewsCategoryCount']; $I++)224 { 225 if (($_POST['NewsCategoryDaysAgo'.$I] * 1) < 0) $_POST['NewsCategoryIndex'.$I] = 0;226 if (($_POST['NewsCategoryCount'.$I] * 1) < 0) $_POST['NewsCategoryCount'.$I] = 0;227 if (($_POST['NewsColumn'.$I] * 1) < 1) $_POST['NewsColumn'.$I] = 1;228 if (!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = '';223 for ($I = 0; $I < $_POST['NewsCategoryCount']; $I++) 224 { 225 if (($_POST['NewsCategoryDaysAgo'.$I] * 1) < 0) $_POST['NewsCategoryIndex'.$I] = 0; 226 if (($_POST['NewsCategoryCount'.$I] * 1) < 0) $_POST['NewsCategoryCount'.$I] = 0; 227 if (($_POST['NewsColumn'.$I] * 1) < 1) $_POST['NewsColumn'.$I] = 1; 228 if (!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = ''; 229 229 $Setting[] = array('CategoryId' => $_POST['NewsCategoryId'.$I], 'Enabled' => $Checkbox[$_POST['NewsCategoryEnabled'.$I]], 'ItemCount' => ($_POST['NewsCategoryCount'.$I]*1), 'DaysAgo' => ($_POST['NewsCategoryDaysAgo'.$I]*1), 'Index' => ($_POST['NewsCategoryIndex'.$I]*1), 230 230 'Group' => $_POST['NewsColumn'.$I]); … … 234 234 $Setting = array_reverse($Setting); 235 235 // Normalize indexes 236 foreach ($Setting as $Index => $Item)236 foreach ($Setting as $Index => $Item) 237 237 $Setting[$Index]['Index'] = $Index + 1; 238 238 … … 248 248 // Make HTML link from URL 249 249 $I = 0; 250 while (strpos($Content, 'http://') !== false)250 while (strpos($Content, 'http://') !== false) 251 251 { 252 252 $I = strpos($Content, 'http://'); 253 if (($I > 0) and ($Content{$I - 1} != '"'))253 if (($I > 0) and ($Content{$I - 1} != '"')) 254 254 { 255 255 $Result .= substr($Content, 0, $I); 256 256 $Content = substr($Content, $I); 257 if (strpos($Content, ' ') !== false)257 if (strpos($Content, ' ') !== false) 258 258 $URL = substr($Content, 0, strpos($Content, ' ')); 259 259 else $URL = substr($Content, 0); … … 267 267 } 268 268 $Result .= $Content; 269 return ($Result);269 return ($Result); 270 270 } 271 271 } -
trunk/Modules/News/NewsPage.php
r839 r873 11 11 { 12 12 $this->UploadedFilesFolder = $this->System->ModuleManager->Modules['News']->UploadedFilesFolder; 13 if (count($this->System->PathItems) > 1)14 { 15 if ($this->System->PathItems[1] == 'subscription') return($this->ShowSubscription());16 else if ($this->System->PathItems[1] == 'rss') return($this->ShowRSS());17 else return (PAGE_NOT_FOUND);18 } else return ($this->ShowMain());13 if (count($this->System->PathItems) > 1) 14 { 15 if ($this->System->PathItems[1] == 'subscription') return ($this->ShowSubscription()); 16 else if ($this->System->PathItems[1] == 'rss') return ($this->ShowRSS()); 17 else return (PAGE_NOT_FOUND); 18 } else return ($this->ShowMain()); 19 19 } 20 20 … … 22 22 { 23 23 $Output = ''; 24 if (!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';24 if (!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění'; 25 25 else 26 26 { 27 27 $Category = $this->GetCategory(); 28 if (array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1;28 if (array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1; 29 29 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '. 30 30 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id); 31 if ($DbResult->num_rows > 0)31 if ($DbResult->num_rows > 0) 32 32 { 33 33 $Row = $DbResult->fetch_array(); 34 if ($Row['Name'] == '') $Author = $Row['Author'];34 if ($Row['Name'] == '') $Author = $Row['Author']; 35 35 else $Author = $Row['Name']; 36 36 $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')'; 37 if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))37 if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 38 38 { 39 39 $Output .= '<div class="Action">'; … … 43 43 } 44 44 $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />'; 45 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';46 if ($Row['Enclosure'] != '')45 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 46 if ($Row['Enclosure'] != '') 47 47 { 48 48 $Output .= '<br />Přílohy: '; 49 49 $Enclosures = explode(';', $Row['Enclosure']); 50 foreach ($Enclosures as $Enclosure)50 foreach ($Enclosures as $Enclosure) 51 51 { 52 if (file_exists($this->UploadedFilesFolder.$Enclosure))52 if (file_exists($this->UploadedFilesFolder.$Enclosure)) 53 53 $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 54 54 } … … 57 57 } else $Output .= 'Položka nenalezena.'; 58 58 } 59 return ($Output);59 return ($Output); 60 60 } 61 61 … … 64 64 $Output = ''; 65 65 $Category = $this->GetCategory(); 66 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))66 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 67 67 { 68 68 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); 69 69 $Output = '<strong>Vložení nové aktuality:</strong><br />'; 70 70 // TODO: Static reference to dynamic category item 71 if ($Category['Id'] == 2) $Output .= 'U inzerátů uvádějte co nejvíce informací ať případný zájemce ví co kupuje. Uvádějte kontaktní údaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát již není platný, připište do něj např. "Prodáno" pomocí editace.';71 if ($Category['Id'] == 2) $Output .= 'U inzerátů uvádějte co nejvíce informací ať případný zájemce ví co kupuje. Uvádějte kontaktní údaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát již není platný, připište do něj např. "Prodáno" pomocí editace.'; 72 72 $Output .= '<form enctype="multipart/form-data" action="?action=add2" method="post">'. 73 73 'Kategorie: <select name="category">'; 74 74 $DbResult = $this->Database->select('NewsCategory', '*'); 75 while ($DbRow = $DbResult->fetch_array())76 { 77 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))78 { 79 if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"';75 while ($DbRow = $DbResult->fetch_array()) 76 { 77 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id'])) 78 { 79 if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"'; 80 80 else $Selected = ''; 81 81 $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>'; … … 93 93 '</form>'; 94 94 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 95 return ($Output);95 return ($Output); 96 96 } 97 97 … … 101 101 $RemoteAddr = GetRemoteAddress(); 102 102 $Category = $this->GetCategory(); 103 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))103 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 104 104 { 105 105 // Process uploaded file … … 107 107 $EnclosureFileNames = array('enclosure1', 'enclosure2', 'enclosure3'); 108 108 $Enclosures = ''; 109 foreach ($EnclosureFileNames as $EnclosureName)110 if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != ''))109 foreach ($EnclosureFileNames as $EnclosureName) 110 if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != '')) 111 111 { 112 112 $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']); 113 if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))113 if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath)) 114 114 { 115 115 $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' byl uložen na serveru.<br />'; … … 130 130 $this->System->ModuleManager->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id); 131 131 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 132 return ($Output);132 return ($Output); 133 133 } 134 134 135 135 function GetPageHeader() 136 136 { 137 return ('<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'.137 return ('<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'. 138 138 "<script>tinymce.init({ 139 139 selector: 'textarea', … … 156 156 $Output = ''; 157 157 $Category = $this->GetCategory(); 158 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))158 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 159 159 { 160 160 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']); 161 161 $Row = $DbResult->fetch_array(); 162 if (($this->System->User->User['Id'] == $Row['User']))162 if (($this->System->User->User['Id'] == $Row['User'])) 163 163 { 164 164 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); … … 174 174 } else $Output .= 'Nepovolená operace!'; 175 175 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 176 return ($Output);176 return ($Output); 177 177 } 178 178 … … 182 182 $RemoteAddr = GetRemoteAddress(); 183 183 $Category = $this->GetCategory(); 184 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))184 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 185 185 { 186 186 $_POST['id'] = $_POST['id'] * 1; 187 187 $DbResult = $this->Database->select('News', '*', '`Id`='.$_POST['id']); 188 if ($DbResult->num_rows > 0)188 if ($DbResult->num_rows > 0) 189 189 { 190 190 $Row = $DbResult->fetch_array(); 191 if ($this->System->User->User['Id'] == $Row['User'])191 if ($this->System->User->User['Id'] == $Row['User']) 192 192 { 193 193 $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], … … 198 198 } else $Output .= 'ID nenalezeno!'; 199 199 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 200 return ($Output);200 return ($Output); 201 201 } 202 202 … … 205 205 $Output = ''; 206 206 $Category = $this->GetCategory(); 207 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))207 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 208 208 { 209 209 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']); 210 210 $Row = $DbResult->fetch_array(); 211 if ($this->System->User->User['Id'] == $Row['User'])211 if ($this->System->User->User['Id'] == $Row['User']) 212 212 { 213 213 // TODO: Make upload using general File class 214 if ($Row['Enclosure'] != '')214 if ($Row['Enclosure'] != '') 215 215 { 216 216 $Output .= '<br />Přílohy: '; 217 217 $Enclosures = explode(';', $Row['Enclosure']); 218 foreach ($Enclosures as $Enclosure)218 foreach ($Enclosures as $Enclosure) 219 219 { 220 if (file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);220 if (file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure); 221 221 } 222 222 } … … 225 225 } else $Output .= 'Nemáte oprávnění.'; 226 226 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 227 return ($Output);227 return ($Output); 228 228 } 229 229 … … 232 232 $Output = ''; 233 233 $Category = $this->GetCategory(); 234 if ($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id']))234 if ($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id'])) 235 235 { 236 236 $PerPage = 20; … … 238 238 $RowTotal = $DbResult->fetch_array(); 239 239 $PageMax = $RowTotal[0]; 240 if (array_key_exists('page', $_GET)) $Page = $_GET['page'];240 if (array_key_exists('page', $_GET)) $Page = $_GET['page']; 241 241 else $Page = 0; //round($PageMax/$PerPage); 242 242 $Output .= '<strong>Seznam aktualit kategorie '.$Category['Caption'].':</strong><div style="font-size: small;">'; … … 245 245 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '. 246 246 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category['Id'].' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage); 247 while ($Row = $DbResult->fetch_array())248 { 249 if ($Row['Name'] == '') $Author = $Row['Author'];247 while ($Row = $DbResult->fetch_array()) 248 { 249 if ($Row['Name'] == '') $Author = $Row['Author']; 250 250 else $Author = $Row['Name']; 251 251 $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')'; 252 if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))252 if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 253 253 { 254 254 $Output .= '<div class="Action">'; … … 258 258 } 259 259 $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />'; 260 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';261 if ($Row['Enclosure'] != '')260 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 261 if ($Row['Enclosure'] != '') 262 262 { 263 263 $Output .= '<br />Přílohy: '; 264 264 $Enclosures = explode(';', $Row['Enclosure']); 265 foreach ($Enclosures as $Enclosure)265 foreach ($Enclosures as $Enclosure) 266 266 { 267 if (file_exists($this->UploadedFilesFolder.$Enclosure))267 if (file_exists($this->UploadedFilesFolder.$Enclosure)) 268 268 $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 269 269 } … … 274 274 $Output .= '</div>'; 275 275 } else $Output .= 'Nemáte oprávnění.'; 276 return ($Output);276 return ($Output); 277 277 } 278 278 … … 280 280 { 281 281 $Category = array('Id' => 1); // Default category 282 if (array_key_exists('category', $_GET)) $Category['Id'] = $_GET['category'] * 1;283 if (array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1;284 //if (is_null($Category)) throw new Exception('Kategorie neurčena');282 if (array_key_exists('category', $_GET)) $Category['Id'] = $_GET['category'] * 1; 283 if (array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1; 284 //if (is_null($Category)) throw new Exception('Kategorie neurčena'); 285 285 else 286 286 { 287 287 $DbResult = $this->Database->select('NewsCategory', '*', '`Id`='.$Category['Id'].' ORDER BY `Sequence`'); 288 if ($DbResult->num_rows > 0) $Category = $DbResult->fetch_array();288 if ($DbResult->num_rows > 0) $Category = $DbResult->fetch_array(); 289 289 else $Category = array('Id' => 0); //throw new Exception('Kategorie nenalezena'); 290 290 } 291 return ($Category);291 return ($Category); 292 292 } 293 293 … … 295 295 { 296 296 $Output = ''; 297 if (array_key_exists('action',$_GET)) $Action = $_GET['action'];297 if (array_key_exists('action',$_GET)) $Action = $_GET['action']; 298 298 else $Action = ''; 299 if ($Action == 'view') $Output .= $this->ShowView();300 else if ($Action == 'add') $Output .= $this->ShowAdd();301 else if ($Action == 'add2') $Output .= $this->ShowAdd2();302 else if ($Action == 'edit') $Output .= $this->ShowEdit();303 else if ($Action == 'update') $Output .= $this->ShowUpdate();304 else if ($Action == 'del') $Output .= $this->ShowDelete();299 if ($Action == 'view') $Output .= $this->ShowView(); 300 else if ($Action == 'add') $Output .= $this->ShowAdd(); 301 else if ($Action == 'add2') $Output .= $this->ShowAdd2(); 302 else if ($Action == 'edit') $Output .= $this->ShowEdit(); 303 else if ($Action == 'update') $Output .= $this->ShowUpdate(); 304 else if ($Action == 'del') $Output .= $this->ShowDelete(); 305 305 else $Output .= $this->ShowList(); 306 return ($Output);306 return ($Output); 307 307 } 308 308 309 309 function ShowSubscription() 310 310 { 311 if (array_key_exists('build', $_GET))311 if (array_key_exists('build', $_GET)) 312 312 { 313 313 $Select = ''; 314 foreach ($_POST as $Index => $Item)315 { 316 if (substr($Index, 0, 8) == 'category') $Select .= '-'.substr($Index, 8);314 foreach ($_POST as $Index => $Item) 315 { 316 if (substr($Index, 0, 8) == 'category') $Select .= '-'.substr($Index, 8); 317 317 } 318 318 $Select = $this->System->Config['Web']['RootFolder'].'/aktuality/rss/?select='.substr($Select, 1); … … 324 324 $Output .= '<form action="?build=1" method="post">'; 325 325 $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY `Caption`'); 326 while ($Category = $DbResult->fetch_array())326 while ($Category = $DbResult->fetch_array()) 327 327 { 328 328 $Output .= '<input type="checkbox" name="category'.$Category['Id'].'" />'.$Category['Caption'].'<br />'; … … 331 331 '</form>'; 332 332 } 333 return ($Output);333 return ($Output); 334 334 } 335 335 … … 349 349 350 350 // Prepare WHERE condition 351 if (array_key_exists('select', $_GET))351 if (array_key_exists('select', $_GET)) 352 352 { 353 353 $Where = ''; 354 354 $Parts = explode('-', $_GET['select']); 355 foreach ($Parts as $Part)355 foreach ($Parts as $Part) 356 356 { 357 357 $Where .= 'OR (`Category`='.($Part * 1).')'; … … 363 363 $Categories = array(); 364 364 $DbResult = $this->Database->select('NewsCategory', '*'); 365 while ($Category = $DbResult->fetch_array())365 while ($Category = $DbResult->fetch_array()) 366 366 { 367 367 $Categories[$Category['Id']] = $Category['Caption']; … … 375 375 $Index = 0; 376 376 //echo(DB_NumRows().','); 377 while ($Row = $DbResult->fetch_array())377 while ($Row = $DbResult->fetch_array()) 378 378 { 379 379 $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); … … 390 390 //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"'); 391 391 $DbResult2 = $Database->select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"'); 392 if ($DbResult2->num_rows == 0) //echo('.'); else echo('x');392 if ($DbResult2->num_rows == 0) //echo('.'); else echo('x'); 393 393 $Database->insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date)); 394 394 //echo($Date); … … 400 400 // Get news from database by selected categories 401 401 $DbResult = $this->Database->query('SELECT *, UNIX_TIMESTAMP(`Date`) AS `UnixTime` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE '.$Where.' ORDER BY News.Date DESC LIMIT 0,'.$NewsCount); 402 while ($Row = $DbResult->fetch_assoc())402 while ($Row = $DbResult->fetch_assoc()) 403 403 { 404 404 $EnclosuresText = ''; 405 if ($Row['Enclosure'] != '')405 if ($Row['Enclosure'] != '') 406 406 { 407 407 $EnclosuresText .= '<br />Přílohy: '; 408 408 $Enclosures = explode(';', $Row['Enclosure']); 409 foreach ($Enclosures as $Enclosure)410 { 411 if (file_exists($this->UploadedFilesFolder.$Enclosure))409 foreach ($Enclosures as $Enclosure) 410 { 411 if (file_exists($this->UploadedFilesFolder.$Enclosure)) 412 412 $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 413 413 } 414 414 } 415 if ($Row['Name'] == '') $Author = $Row['Author'];415 if ($Row['Name'] == '') $Author = $Row['Author']; 416 416 else $Author = $Row['Name']; 417 417 $Items[] = array( … … 429 429 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 430 430 $RSS->Items = $Items; 431 return ($RSS->Generate());431 return ($RSS->Generate()); 432 432 } 433 433 } -
trunk/Modules/Notify/Notify.php
r868 r873 46 46 function RegisterCheck($Name, $Callback) 47 47 { 48 if (array_key_exists($Name, $this->Checks))48 if (array_key_exists($Name, $this->Checks)) 49 49 throw new Exception('Check function "'.$Name.'" already registered.'); 50 50 $this->Checks[$Name] = array('Callback' => $Callback); … … 53 53 function UnregisterCheck($Name) 54 54 { 55 if (!array_key_exists($Name, $this->Checks))55 if (!array_key_exists($Name, $this->Checks)) 56 56 throw new Exception('Check function "'.$Name.'" not registered.'); 57 57 unset($this->Checks[$Name]); … … 88 88 'LEFT JOIN `User` ON `User`.`Id` = `NotifyUser`.`User` '. 89 89 'LEFT JOIN `Contact` ON `Contact`.`Id` = `NotifyUser`.`Contact`'); 90 while ($User = $DbResult->fetch_assoc())90 while ($User = $DbResult->fetch_assoc()) 91 91 { 92 92 $Output .= 'User '.$User['Name'].'<br/>'; … … 94 94 $this->Database->update('NotifyUser', '`Id`='.$User['Id'], array('LastTime' => TimeToMysqlDateTime($Time))); 95 95 96 if (($User['Category'] == CONTACT_CATEGORY_EMAIL) and ($Content != ''))96 if (($User['Category'] == CONTACT_CATEGORY_EMAIL) and ($Content != '')) 97 97 { 98 98 $Mail = new Mail(); … … 120 120 } 121 121 122 return ($Output);122 return ($Output); 123 123 } 124 124 … … 178 178 ' ORDER BY `Time` DESC LIMIT '.$Count; 179 179 $DbResult = $this->System->Database->query($sql); 180 while ($Line = $DbResult->fetch_assoc())180 while ($Line = $DbResult->fetch_assoc()) 181 181 { 182 182 $Items[] = array … … 195 195 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 196 196 $RSS->Items = $Items; 197 return ($RSS->Generate());197 return ($RSS->Generate()); 198 198 } 199 199 } -
trunk/Modules/OpeningHours/OpeningHours.php
r738 r873 15 15 $Hours = floor($Time / 60); 16 16 $Minutes = $Time - $Hours * 60; 17 if ($Minutes < 10) $Minutes = '0'.$Minutes;17 if ($Minutes < 10) $Minutes = '0'.$Minutes; 18 18 $Hours = $Hours % 24; 19 return ($Hours.':'.$Minutes);19 return ($Hours.':'.$Minutes); 20 20 } 21 21 … … 28 28 $Minutes = $Time; 29 29 $Output = ''; 30 if ($Days > 0) $Output .= $Days.' dnů, ';31 if ($Hours > 0) $Output .= $Hours.' hodin, ';32 if ($Minutes > 0) $Output .= $Minutes.' minut';33 return ($Output);30 if ($Days > 0) $Output .= $Days.' dnů, '; 31 if ($Hours > 0) $Output .= $Hours.' hodin, '; 32 if ($Minutes > 0) $Output .= $Minutes.' minut'; 33 return ($Output); 34 34 } 35 35 36 36 function EditSubject($Id) 37 37 { 38 if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))38 if ($this->System->User->CheckPermission('OpeningHours', 'Edit')) 39 39 { 40 40 $Output = '<div class="Centred">'; … … 46 46 $Day = array(); 47 47 $DbResult = $this->Database->query('SELECT * FROM SubjectOpenTimeDay WHERE Subject = '.$Id); 48 while ($DbRow = $DbResult->fetch_assoc())48 while ($DbRow = $DbResult->fetch_assoc()) 49 49 $Day[$DbRow['Day']] = $DbRow; 50 foreach ($this->DaysOfWeek as $Index => $Name)51 { 52 if (!array_key_exists($Index, $Day)) $Day[$Index] = array('Open1' => 0, 'Close1' => 0, 'Open2' => 0, 'Close2' => 0);50 foreach ($this->DaysOfWeek as $Index => $Name) 51 { 52 if (!array_key_exists($Index, $Day)) $Day[$Index] = array('Open1' => 0, 'Close1' => 0, 'Open2' => 0, 'Close2' => 0); 53 53 $Output .= '<tr><td>'.$Name.'</td>'. 54 54 '<td><input type="text" name="day'.$Index.'_open1_h" value="'.floor($Day[$Index]['Open1'] / 60).'" size="2" />'. … … 70 70 '</form></div>'; 71 71 } else $Output = 'Nemáte oprávnění'; 72 return ($Output);72 return ($Output); 73 73 } 74 74 … … 78 78 79 79 $Output = ''; 80 if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))80 if ($this->System->User->CheckPermission('OpeningHours', 'Edit')) 81 81 { 82 82 $this->Database->delete('SubjectOpenTimeDay', 'Subject='.$Id); 83 foreach ($this->DaysOfWeek as $Index => $Name)84 { 85 if ($_POST['day'.$Index.'_open1_h'] > 24) $_POST['day'.$Index.'_open1_h'] = 24;86 if ($_POST['day'.$Index.'_close1_h'] > 24) $_POST['day'.$Index.'_close1_h'] = 24;87 if ($_POST['day'.$Index.'_open2_h'] > 24) $_POST['day'.$Index.'_open2_h'] = 24;88 if ($_POST['day'.$Index.'_close2_h'] > 24) $_POST['day'.$Index.'_close2_h'] = 24;89 if ($_POST['day'.$Index.'_open1_m'] > 59) $_POST['day'.$Index.'_open1_m'] = 59;90 if ($_POST['day'.$Index.'_close1_m'] > 59) $_POST['day'.$Index.'_close1_m'] = 59;91 if ($_POST['day'.$Index.'_open2_m'] > 59) $_POST['day'.$Index.'_open2_m'] = 59;92 if ($_POST['day'.$Index.'_close2_m'] > 59) $_POST['day'.$Index.'_close2_m'] = 59;83 foreach ($this->DaysOfWeek as $Index => $Name) 84 { 85 if ($_POST['day'.$Index.'_open1_h'] > 24) $_POST['day'.$Index.'_open1_h'] = 24; 86 if ($_POST['day'.$Index.'_close1_h'] > 24) $_POST['day'.$Index.'_close1_h'] = 24; 87 if ($_POST['day'.$Index.'_open2_h'] > 24) $_POST['day'.$Index.'_open2_h'] = 24; 88 if ($_POST['day'.$Index.'_close2_h'] > 24) $_POST['day'.$Index.'_close2_h'] = 24; 89 if ($_POST['day'.$Index.'_open1_m'] > 59) $_POST['day'.$Index.'_open1_m'] = 59; 90 if ($_POST['day'.$Index.'_close1_m'] > 59) $_POST['day'.$Index.'_close1_m'] = 59; 91 if ($_POST['day'.$Index.'_open2_m'] > 59) $_POST['day'.$Index.'_open2_m'] = 59; 92 if ($_POST['day'.$Index.'_close2_m'] > 59) $_POST['day'.$Index.'_close2_m'] = 59; 93 93 $Day = array('Subject' => $Id, 'Day' => $Index); 94 94 $Day['Open1'] = $_POST['day'.$Index.'_open1_m'] + $_POST['day'.$Index.'_open1_h'] * 60; … … 111 111 $this->Database->update('SubjectOpenTime', 'Subject='.$Id, array('UpdateTime' => 'NOW()', 'Notice' => $_POST['notice'], 'Photo' => $FileId)); 112 112 } else $Output = 'Nemáte oprávnění'; 113 return ($Output);113 return ($Output); 114 114 } 115 115 … … 118 118 $Output = '<div class="Centred">'; 119 119 $DbResult = $this->Database->query('SELECT SubjectOpenTime.*, DATE_FORMAT(SubjectOpenTime.UpdateTime, "%e.%c.%Y") as UpdateTime, Subject.Id, Subject.Name as Name FROM SubjectOpenTime JOIN Subject ON Subject.Id = SubjectOpenTime.Subject ORDER BY Name'); 120 while ($Subject = $DbResult->fetch_assoc())120 while ($Subject = $DbResult->fetch_assoc()) 121 121 { 122 122 $Output .= '<strong>'.$Subject['Name'].':</strong><br />'; … … 125 125 $Events = array(); 126 126 $DbResult2 = $this->Database->query('SELECT * FROM `SubjectOpenTimeDay` WHERE Subject='.$Subject['Subject'].' ORDER BY Day ASC'); 127 while ($DbRow = $DbResult2->fetch_assoc())128 { 129 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1']))127 while ($DbRow = $DbResult2->fetch_assoc()) 128 { 129 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1'])) 130 130 { 131 131 $Events[] = array('Time' => $DbRow['Open1'] + $DbRow['Day'] * 24 * 60, 'Type' => 1); 132 132 $Events[] = array('Time' => $DbRow['Close1'] + $DbRow['Day'] * 24 * 60, 'Type' => 2); 133 133 } 134 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2']))134 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2'])) 135 135 { 136 136 $Events[] = array('Time' => $DbRow['Open2'] + $DbRow['Day'] * 24 * 60, 'Type' => 1); … … 141 141 142 142 // Calculate time to next event 143 if (count($Events) > 0)143 if (count($Events) > 0) 144 144 { 145 145 $CurrentTime = ((date('w') + 6) % 7) * 24 * 60 + date('G') * 60 + date('i'); 146 146 147 147 $I = 0; 148 while (($I < count($Events)) and ($Events[$I]['Time'] < $CurrentTime))148 while (($I < count($Events)) and ($Events[$I]['Time'] < $CurrentTime)) 149 149 $I++; 150 if ($I < count($Events))150 if ($I < count($Events)) 151 151 { 152 152 $NextTime = $Events[$I]['Time']; … … 160 160 $TimeDelta = $NextTime - $CurrentTime; 161 161 //$Output .= $CurrentTime.' '.$NextTime; 162 if ($NextEventType == 2) $Output .= 'Zavírá za '.$this->ToHumanTime2($TimeDelta);162 if ($NextEventType == 2) $Output .= 'Zavírá za '.$this->ToHumanTime2($TimeDelta); 163 163 else $Output .= 'Otevírá za '.$this->ToHumanTime2($TimeDelta); 164 164 } … … 166 166 // Show time inteval table 167 167 $Output .= '<table class="WideTable"><tr><th>Den</th><th>Čas</th></tr>'; 168 foreach ($this->DaysOfWeek as $DayIndex => $DayOfWeek)168 foreach ($this->DaysOfWeek as $DayIndex => $DayOfWeek) 169 169 { 170 170 $DbResult2 = $this->Database->query('SELECT * FROM SubjectOpenTimeDay WHERE Subject = '.$Subject['Subject'].' AND Day='.$DayIndex); 171 171 $Output .= '<tr><td>'.$DayOfWeek.'</td><td align="center">'; 172 if ($DbResult2->num_rows)172 if ($DbResult2->num_rows) 173 173 { 174 174 $DbRow = $DbResult2->fetch_assoc(); 175 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1']))175 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1'])) 176 176 { 177 177 $Output .= $this->ToHumanTime($DbRow['Open1']).' - '.$this->ToHumanTime($DbRow['Close1']).' '; 178 178 } 179 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2']))179 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2'])) 180 180 { 181 181 $Output .= $this->ToHumanTime($DbRow['Open2']).' - '.$this->ToHumanTime($DbRow['Close2']).''; … … 186 186 } 187 187 $Output .= '</table>Aktualizováno: '.$Subject['UpdateTime'].'<br />'; 188 if ($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />';189 190 if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> ';191 192 if ($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))188 if ($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />'; 189 190 if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> '; 191 192 if ($this->System->User->CheckPermission('SubjectOpenTime', 'Edit')) 193 193 $Output .= '<a href="edit?Subject='.$Subject['Id'].'">Editovat</a><br />'; 194 194 $Output .= '<br />'; 195 195 } 196 196 $Output .= '</div>'; 197 return ($Output);197 return ($Output); 198 198 } 199 199 200 200 function Show() 201 201 { 202 if (count($this->System->PathItems) > 1)203 { 204 if ($this->System->PathItems[1] == 'edit') $Output = $this->EditSubject($_GET['Subject']);205 else if ($this->System->PathItems[1] == 'save')202 if (count($this->System->PathItems) > 1) 203 { 204 if ($this->System->PathItems[1] == 'edit') $Output = $this->EditSubject($_GET['Subject']); 205 else if ($this->System->PathItems[1] == 'save') 206 206 { 207 207 $Output = $this->SaveSubject($_GET['Subject']); … … 209 209 } else $Output = PAGE_NOT_FOUND; 210 210 } else $Output = $this->ShowAll(); 211 return ($Output);211 return ($Output); 212 212 } 213 213 } -
trunk/Modules/Portal/Portal.php
r860 r873 60 60 $DbResult = $this->Database->query('SELECT `Id` FROM `Action` '. 61 61 'WHERE (`Action`.`Group`='.$ActionGroup['Id'].') AND (`Action`.`Enable` = 1)'); 62 while ($Action = $DbResult->fetch_assoc())62 while ($Action = $DbResult->fetch_assoc()) 63 63 { 64 64 $Output .= $this->System->ShowAction($Action['Id']).'<br/>'; 65 65 } 66 return ($this->Panel($ActionGroup['Name'], $Output));66 return ($this->Panel($ActionGroup['Name'], $Output)); 67 67 } 68 68 … … 98 98 //$Output .= 'Server běží: '.$this->GetServerUptime().' '; 99 99 100 if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))100 if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) 101 101 { 102 102 $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='.$this->System->User->User['Id'].')'); 103 if ($DbResult->num_rows > 0)103 if ($DbResult->num_rows > 0) 104 104 { 105 105 $DbRow = $DbResult->fetch_assoc(); … … 109 109 110 110 $Output = '<div class="Navigation"><span class="MenuItem">'.$Output.'</span><div class="MenuItem2"> '.$Output2.'</div></div>'; 111 return ($Output);111 return ($Output); 112 112 } 113 113 … … 115 115 { 116 116 $Output = '<a href="'.$this->System->Link('/user/?Action=UserOptions').'">Profil</a><br />'; 117 if ($this->System->User->CheckPermission('Finance', 'MemberOptions'))117 if ($this->System->User->CheckPermission('Finance', 'MemberOptions')) 118 118 $Output .= '<a href="'.$this->System->Link('/?Action=MemberOptions').'">Fakturační adresa</a><br />'; 119 if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))119 if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) 120 120 $Output .= '<a href="'.$this->System->Link('/finance/platby/').'">Finance</a><br />'; 121 if ($this->System->User->CheckPermission('Network', 'RegistredHostList'))121 if ($this->System->User->CheckPermission('Network', 'RegistredHostList')) 122 122 $Output .= '<a href="'.$this->System->Link('/network/user-hosts/').'">Počítače</a><br />'; 123 if ($this->System->User->CheckPermission('News', 'Insert'))123 if ($this->System->User->CheckPermission('News', 'Insert')) 124 124 $Output .= '<a href="'.$this->System->Link('/aktuality/?action=add').'">Vložení aktuality</a><br />'; 125 if ($this->System->User->CheckPermission('EatingPlace', 'Edit'))125 if ($this->System->User->CheckPermission('EatingPlace', 'Edit')) 126 126 $Output .= '<a href="'.$this->System->Link('/jidelna/menuedit.php').'">Úprava jídelníčků</a><br />'; 127 if ($this->System->User->CheckPermission('Finance', 'Manage'))127 if ($this->System->User->CheckPermission('Finance', 'Manage')) 128 128 $Output .= '<a href="'.$this->System->Link('/finance/sprava/').'">Správa financí</a><br />'; 129 if ($this->System->User->CheckPermission('IS', 'Manage'))129 if ($this->System->User->CheckPermission('IS', 'Manage')) 130 130 $Output .= '<a href="'.$this->System->Link('/is/').'">Správa dat</a><br />'; 131 return ($Output);131 return ($Output); 132 132 } 133 133 … … 135 135 { 136 136 $Output = $this->System->ModuleManager->Modules['WebCam']->ShowImage(); 137 return ($Output);137 return ($Output); 138 138 } 139 139 … … 141 141 { 142 142 $Output = '<a href="https://stat.zdechov.net/meteo/?Measure=28" title="Klikněte pro detailní informace a předpověď"><img src="https://www.zdechov.net/meteo/koliba.png" border="0" alt="Počasí - Meteostanice Zděchov" width="150" height="150" /></a>'; 143 return ($Output);143 return ($Output); 144 144 } 145 145 … … 150 150 'LEFT JOIN `NetworkDeviceType` ON `NetworkDeviceType`.`Id` = `NetworkDevice`.`Type` '. 151 151 'WHERE (`NetworkDeviceType`.`ShowOnline` = 1) AND (`NetworkDevice`.`Online` = 1) ORDER BY `NetworkDevice`.`Name`'); 152 while ($Device = $DbResult->fetch_array())152 while ($Device = $DbResult->fetch_array()) 153 153 { 154 154 $Output .= $Device['Name'].'<br />'; 155 155 } 156 156 $Output .= '</span>'; 157 return ($Output);157 return ($Output); 158 158 } 159 159 … … 162 162 $Output .= '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">'; 163 163 $DbResult = $Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money'); 164 while ($Row = $DbResult->fetch_array())164 while ($Row = $DbResult->fetch_array()) 165 165 { 166 166 $Output .= $Row['Name'].'<br />'; 167 167 } 168 168 $Output .= '</span>'; 169 return ($Output);169 return ($Output); 170 170 } 171 171 172 172 function Panel($Title, $Content, $Menu = array()) 173 173 { 174 if (count($Menu) > 0)175 foreach ($Menu as $Item)174 if (count($Menu) > 0) 175 foreach ($Menu as $Item) 176 176 $Title .= '<div class="Action">'.$Item.'</div>'; 177 return ('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');177 return ('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>'); 178 178 } 179 179 … … 181 181 { 182 182 $Output = ''; 183 if (array_key_exists('Action', $_GET))183 if (array_key_exists('Action', $_GET)) 184 184 { 185 185 $Action = $_GET['Action']; 186 if ($Action == 'CustomizeNewsSave')186 if ($Action == 'CustomizeNewsSave') 187 187 { 188 188 $Output .= $this->System->ModuleManager->Modules['News']->CustomizeSave(); 189 189 } else 190 if ($Action == 'MemberOptions')190 if ($Action == 'MemberOptions') 191 191 { 192 192 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` '. 193 193 'WHERE `User`='.$this->System->User->User['Id']); 194 while ($CustomerUserRel = $DbResult->fetch_assoc())194 while ($CustomerUserRel = $DbResult->fetch_assoc()) 195 195 { 196 196 $DbResult2 = $this->Database->query('SELECT `Member`.`Id`, '. … … 202 202 $Form->SetClass('MemberOptions'); 203 203 $DbRow = $DbResult2->fetch_array(); 204 foreach ($Form->Definition['Items'] as $Index => $Item)204 foreach ($Form->Definition['Items'] as $Index => $Item) 205 205 { 206 206 $Form->Values[$Index] = $DbRow[$Index]; … … 210 210 } 211 211 } else 212 if ($Action == 'MemberOptionsSave')212 if ($Action == 'MemberOptionsSave') 213 213 { 214 214 $Form = new Form($this->System->FormManager); 215 215 $Form->SetClass('MemberOptions'); 216 216 $Form->LoadValuesFromForm(); 217 if ($Form->Values['FamilyMemberCount'] < 0)217 if ($Form->Values['FamilyMemberCount'] < 0) 218 218 $Form->Values['FamilyMemberCount'] = 0; 219 219 … … 235 235 'ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->User->User['Member']); 236 236 $DbRow = $DbResult->fetch_array(); 237 foreach ($Form->Definition['Items'] as $Index => $Item)237 foreach ($Form->Definition['Items'] as $Index => $Item) 238 238 { 239 239 $Form->Values[$Index] = $DbRow[$Index]; … … 243 243 } 244 244 } else $Output = $this->ShowMain(); 245 return ($Output);245 return ($Output); 246 246 } 247 247 … … 250 250 $Output = ''; 251 251 $DbResult = $this->Database->query('SELECT * FROM `ActionGroup`'); 252 while ($DbRow = $DbResult->fetch_assoc())252 while ($DbRow = $DbResult->fetch_assoc()) 253 253 $ActionGroups[$DbRow['Id']] = $DbRow; 254 254 255 255 // Show pannels 256 //if (IsInternetAddr()) echo('Internet'); else echo('LAN');256 //if (IsInternetAddr()) echo('Internet'); else echo('LAN'); 257 257 //$Output .= $this->InfoBar(); 258 258 $Output .= '<table id="MainTable"><tr>'; 259 259 $DbResult = $this->Database->select('PanelColumn', '*'); 260 while ($PanelColumn = $DbResult->fetch_assoc())261 { 262 if ($PanelColumn != '') $Width = ' width="'.$PanelColumn['Width'].'"';260 while ($PanelColumn = $DbResult->fetch_assoc()) 261 { 262 if ($PanelColumn != '') $Width = ' width="'.$PanelColumn['Width'].'"'; 263 263 else $Width = ''; 264 264 $Output .= '<td valign="top"'.$Width.'>'; 265 265 $DbResult2 = $this->Database->query('SELECT * FROM `Panel` WHERE `PanelColumn`='.$PanelColumn['Id'].' ORDER BY `Order`'); 266 while ($Panel = $DbResult2->fetch_assoc())267 { 268 if ($Panel['Module'] == 'ActionGroup') $Output .= $this->ShowActions($ActionGroups[$Panel['Parameters']]);269 else if ($Panel['Module'] == 'OnlineHostList') $Output .= $this->Panel('Online počítače', $this->OnlineHostList());270 else if ($Panel['Module'] == 'UserOptions')266 while ($Panel = $DbResult2->fetch_assoc()) 267 { 268 if ($Panel['Module'] == 'ActionGroup') $Output .= $this->ShowActions($ActionGroups[$Panel['Parameters']]); 269 else if ($Panel['Module'] == 'OnlineHostList') $Output .= $this->Panel('Online počítače', $this->OnlineHostList()); 270 else if ($Panel['Module'] == 'UserOptions') 271 271 { 272 //if ($this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());272 //if ($this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel()); 273 273 } else 274 if ($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel());275 if ($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel());276 else if ($Panel['Module'] == 'NewsGroupList')274 if ($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel()); 275 if ($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel()); 276 else if ($Panel['Module'] == 'NewsGroupList') 277 277 $Output .= $this->Panel('Aktuality', $this->System->ModuleManager->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>')); 278 278 } … … 280 280 } 281 281 $Output .= '</tr></table>'; 282 return ($Output);282 return ($Output); 283 283 } 284 284 } -
trunk/Modules/RSS/RSS.php
r840 r873 27 27 $this->RSSChannels[$Channel['Channel']] = $Channel; 28 28 29 if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel'];29 if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel']; 30 30 else { 31 31 array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']); … … 42 42 { 43 43 $Output = ''; 44 foreach ($this->RSSChannels as $Channel)44 foreach ($this->RSSChannels as $Channel) 45 45 { 46 //if ($this->System->User->Licence($Channel['Permission']))46 //if ($this->System->User->Licence($Channel['Permission'])) 47 47 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 48 48 $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; 49 49 } 50 return ($Output);50 return ($Output); 51 51 } 52 52 } … … 58 58 $this->ClearPage = true; 59 59 60 if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel'];60 if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel']; 61 61 else $ChannelName = ''; 62 if (array_key_exists('token', $_GET)) $Token = $_GET['token'];62 if (array_key_exists('token', $_GET)) $Token = $_GET['token']; 63 63 else $Token = ''; 64 if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels))64 if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels)) 65 65 { 66 66 $Channel = $this->System->ModuleManager->Modules['RSS']->RSSChannels[$ChannelName]; 67 if ($this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or67 if ($this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or 68 68 $this->System->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token)) 69 69 { 70 if (is_string($Channel['Callback'][0]))70 if (is_string($Channel['Callback'][0])) 71 71 { 72 72 $Class = new $Channel['Callback'][0]($this->System); … … 76 76 } else $Output = 'Nemáte oprávnění'; 77 77 } else $Output = 'Kanál nenalezen'; 78 return ($Output);78 return ($Output); 79 79 } 80 80 } -
trunk/Modules/Scheduler/Scheduler.php
r830 r873 61 61 function Run($Parameters) 62 62 { 63 while (true)63 while (true) 64 64 { 65 65 $DbResult = $this->Database->query('SELECT `Scheduler`.*, `SchedulerAction`.`Class` AS `Class` FROM `Scheduler` '. … … 68 68 '(`Scheduler`.`ScheduledTime` < "'.TimeToMysqlDateTime(time()).'") OR '. 69 69 '(`Scheduler`.`ScheduledTime` IS NULL))'); 70 while ($DbRow = $DbResult->fetch_assoc())70 while ($DbRow = $DbResult->fetch_assoc()) 71 71 { 72 72 echo('Executing '.$DbRow['Name']."\n"); 73 73 $Output = ''; 74 74 $StartTime = time(); 75 if (class_exists($DbRow['Class']))75 if (class_exists($DbRow['Class'])) 76 76 { 77 77 $Class = new $DbRow['Class']($this->System); … … 88 88 array('Log' => $Output, 'LastExecutedTime' => TimeToMysqlDateTime($StartTime), 89 89 'Duration' => $Duration)); 90 if ($DbRow['Period'] != '') {91 if ($DbRow['ScheduledTime'] == '') $NewScheduledTime = $StartTime + $DbRow['Period'];90 if ($DbRow['Period'] != '') { 91 if ($DbRow['ScheduledTime'] == '') $NewScheduledTime = $StartTime + $DbRow['Period']; 92 92 else $NewScheduledTime = MysqlDateTimeToTime($DbRow['ScheduledTime']) + $DbRow['Period']; 93 if ($NewScheduledTime < $StopTime) $NewScheduledTime = $StopTime + $DbRow['Period'];93 if ($NewScheduledTime < $StopTime) $NewScheduledTime = $StopTime + $DbRow['Period']; 94 94 $this->Database->update('Scheduler', 'Id='.$DbRow['Id'], 95 95 array('ScheduledTime' => TimeToMysqlDateTime($NewScheduledTime))); … … 115 115 { 116 116 $Output = '#'; 117 return ($Output);117 return ($Output); 118 118 } 119 119 } -
trunk/Modules/Search/Search.php
r738 r873 14 14 { 15 15 $Output = ''; 16 if (array_key_exists('t', $_GET)) $Text = $_GET['t'];16 if (array_key_exists('t', $_GET)) $Text = $_GET['t']; 17 17 else $Text = ''; 18 18 $Output .= '<form action="?" method="get">'. … … 20 20 '<input type="submit" value="Hledat"/>'. 21 21 '</form>'; 22 if ($Text != '')23 foreach ($this->System->ModuleManager->Modules['Search']->Items as $Item)22 if ($Text != '') 23 foreach ($this->System->ModuleManager->Modules['Search']->Items as $Item) 24 24 { 25 25 $Columns = ''; 26 26 $Condition = ''; 27 foreach ($Item['Columns'] as $Column)27 foreach ($Item['Columns'] as $Column) 28 28 { 29 29 $Columns .= ', `'.$Column.'`'; … … 34 34 $DbResult = $this->Database->Select($Item['Table'], $Columns, $Condition.' LIMIT '. 35 35 $this->System->ModuleManager->Modules['Search']->MaxItemCount); 36 if ($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>';37 while ($Row = $DbResult->fetch_assoc())36 if ($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>'; 37 while ($Row = $DbResult->fetch_assoc()) 38 38 { 39 39 $Output .= '<p>'; 40 foreach ($Item['Columns'] as $Column)40 foreach ($Item['Columns'] as $Column) 41 41 $Output .= $Row[$Column].'<br/>'; 42 42 $Output .= '</p>'; 43 43 } 44 44 } 45 return ($Output);45 return ($Output); 46 46 } 47 47 } -
trunk/Modules/SpeedTest/SpeedTest.php
r738 r873 39 39 function Show() 40 40 { 41 if (count($this->System->PathItems) > 1)41 if (count($this->System->PathItems) > 1) 42 42 { 43 if ($this->System->PathItems[1] == 'download.php') return($this->ShowDownload());44 //else if ($this->System->PathItems[1] == 'rss') return($this->ShowRSS());45 else return (PAGE_NOT_FOUND);46 } else return ($this->ShowMain());43 if ($this->System->PathItems[1] == 'download.php') return ($this->ShowDownload()); 44 //else if ($this->System->PathItems[1] == 'rss') return ($this->ShowRSS()); 45 else return (PAGE_NOT_FOUND); 46 } else return ($this->ShowMain()); 47 47 } 48 48 … … 62 62 63 63 ## Redirect immediately to download.php if auto_start = 1 64 if ($config->{'general'}->{'auto_start'}) {64 if ($config->{'general'}->{'auto_start'}) { 65 65 Header("Location: ".$config['general']['base_url']."/download.php"); 66 66 exit; … … 77 77 <body>'; 78 78 79 if (file_exists("header.html")) {79 if (file_exists("header.html")) { 80 80 ## Include "header.html" for a custom header, if the file exists 81 81 include("header.html"); … … 86 86 $Output .= '<div id="speedtest_content">'; 87 87 88 if (file_exists("welcome.html")) {88 if (file_exists("welcome.html")) { 89 89 ## Include "welcome.html" for a custom welcome page, if the file exists 90 90 include("welcome.html"); … … 107 107 </div>'; 108 108 109 if (file_exists("footer.html")) {109 if (file_exists("footer.html")) { 110 110 ## Include "footer.html" for a custom footer, if the file exists 111 111 include("footer.html"); … … 114 114 print "</center>\n"; 115 115 } 116 return ($Output);116 return ($Output); 117 117 } 118 118 } -
trunk/Modules/SpeedTest/common.php
r560 r873 18 18 foreach ($lines as $line_num => $line) { 19 19 $line = rtrim(preg_replace("/#.*/","",$line)); 20 if (preg_match("/\[.*\]/", $line, $parts)) {20 if (preg_match("/\[.*\]/", $line, $parts)) { 21 21 $section = $parts[0]; 22 22 $section = preg_replace("/[\[\]]/","",$section); … … 34 34 function Debug($message) { 35 35 global $config; 36 if ($config->{'general'}->{'debug'}) {36 if ($config->{'general'}->{'debug'}) { 37 37 BCLog($message); 38 38 } … … 43 43 global $config; 44 44 $logfile = $config->{'general'}->{'logfile'}; 45 if (! $logfile) {45 if (! $logfile) { 46 46 return; 47 47 } -
trunk/Modules/SpeedTest/download.php
r738 r873 19 19 $disallow = $config->{'general'}->{'disallow'}; 20 20 $allow = $config->{'general'}->{'allow'}; 21 if ( $allow && (! preg_match("/$allow/",$remote_addr)) ) {21 if ( $allow && (! preg_match("/$allow/",$remote_addr)) ) { 22 22 include("unallowed.html"); 23 23 exit; 24 } elseif ( $disallow && preg_match("/$disallow/", $remote_addr) ) {24 } elseif ( $disallow && preg_match("/$disallow/", $remote_addr) ) { 25 25 include("unallowed.html"); 26 26 exit; … … 33 33 ## on initial results 34 34 $config_auto_size = $config->{'general'}->{'auto_size'}; 35 if ($config_auto_size) {35 if ($config_auto_size) { 36 36 ## We're using the auto_size functionality 37 if ( isset($_GET['auto_size']) && $_GET['auto_size']) {37 if ( isset($_GET['auto_size']) && $_GET['auto_size']) { 38 38 ## Intial test is done. Set down/upload sizes to the same as 39 39 ## our initial measured speeds. That way the test should take … … 55 55 56 56 ## Make sure sizes are below our configured limits 57 if ($down_kbytes > $config->{'download'}->{'max_kbytes'}) {57 if ($down_kbytes > $config->{'download'}->{'max_kbytes'}) { 58 58 $down_kbytes = $config->{'download'}->{'max_kbytes'}; 59 59 } 60 if ($up_kbytes > $config->{'upload'}->{'max_kbytes'}) {60 if ($up_kbytes > $config->{'upload'}->{'max_kbytes'}) { 61 61 $up_kbytes = $config->{'upload'}->{'max_kbytes'}; 62 62 } 63 63 64 if ($config->{'upload'}->{'skip_upload'}) {64 if ($config->{'upload'}->{'skip_upload'}) { 65 65 $up_kbytes = 0; 66 66 } … … 92 92 93 93 <?php 94 if (file_exists("header.html")) {94 if (file_exists("header.html")) { 95 95 ## Include "header.html" for a custom header, if the file exists 96 96 include("header.html"); … … 103 103 104 104 <?php 105 if ( ($config_auto_size) && (! isset($_GET['auto_size'])) ) {105 if ( ($config_auto_size) && (! isset($_GET['auto_size'])) ) { 106 106 ## auto_size is performing the initial, small test 107 107 print "<div>Calculating appropriate file sizes for testing</div>\n"; … … 137 137 </div> 138 138 139 <?php if (file_exists("footer.html")) { include("footer.html"); } ?>139 <?php if (file_exists("footer.html")) { include("footer.html"); } ?> 140 140 141 141 <?php /* Begin JavaScript functions that we'll need */ ?> … … 144 144 function StartUpload() { 145 145 uploadDiv = document.getElementById('upload_message'); 146 if (uploadDiv) {146 if (uploadDiv) { 147 147 uploadDiv.style.visibility='visible'; 148 148 uploadDiv.style.display='block'; 149 <?php if ($pretty_version) { ?>149 <?php if ($pretty_version) { ?> 150 150 setInterval("IncrementUploadBar()",200); 151 151 <?php } ?> … … 158 158 function IncrementDownloadBar() { 159 159 download_barElement = document.getElementById('download_bar'); 160 if (download_barElement) {160 if (download_barElement) { 161 161 download_bar_current_width += <?php echo $download_progress_bar_increment; ?>; 162 if (download_bar_current_width <= <?php echo $progress_bar_width; ?>) {162 if (download_bar_current_width <= <?php echo $progress_bar_width; ?>) { 163 163 download_barElement.style.width = download_bar_current_width +"px"; 164 164 } … … 176 176 function IncrementUploadBar() { 177 177 upload_barElement = document.getElementById('upload_bar'); 178 if (upload_barElement) {178 if (upload_barElement) { 179 179 upload_bar_current_width += <?php echo $upload_progress_bar_increment; ?>; 180 if (upload_bar_current_width < <?php echo $progress_bar_width; ?>) {180 if (upload_bar_current_width < <?php echo $progress_bar_width; ?>) { 181 181 upload_barElement.style.width = upload_bar_current_width +"px"; 182 182 } … … 186 186 function CompleteDownloadBar() { 187 187 download_barElement = document.getElementById('download_bar'); 188 if (download_barElement) {188 if (download_barElement) { 189 189 download_barElement.style.width = "100%"; 190 190 } … … 209 209 <?php 210 210 211 if ($pretty_version) {211 if ($pretty_version) { 212 212 print " 213 213 //--> … … 225 225 $extra_down_kbytes = $down_kbytes - $up_kbytes; 226 226 $total_kbytes = 0; 227 while ($total_kbytes <= $extra_down_kbytes) {228 if ($pretty_version) {227 while ($total_kbytes <= $extra_down_kbytes) { 228 if ($pretty_version) { 229 229 print " 230 230 <script language=\"javascript\"> … … 240 240 $total_kbytes += $each_chunk; 241 241 } 242 if (!$pretty_version) {242 if (!$pretty_version) { 243 243 print "dataElement.value=\"$data\";"; 244 244 print "CompleteDownloadBar();\n"; … … 254 254 ## Now, download the remaining bytes ($up_kbytes) and save it into a 255 255 ## form variable that we will post back to test the upload speed 256 while ($total_kbytes <= $down_kbytes) {257 if ($pretty_version) {256 while ($total_kbytes <= $down_kbytes) { 257 if ($pretty_version) { 258 258 print " 259 259 <script language=\"javascript\"> … … 270 270 } 271 271 272 if (!$pretty_version) {272 if (!$pretty_version) { 273 273 #print "\";"; 274 274 } else { … … 288 288 downloadtime = (endtime - starttime)/1000; 289 289 } 290 <?php if (! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?>290 <?php if (! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?> 291 291 292 292 down_size = <?php echo $total_kbytes; ?>; … … 297 297 298 298 <?php 299 if ($config_auto_size && (! isset($_GET['auto_size'])) ) {299 if ($config_auto_size && (! isset($_GET['auto_size'])) ) { 300 300 $params_auto_size = "&auto_size=1"; 301 301 } else { 302 302 $params_auto_size = ""; 303 303 } 304 if ($config->{'upload'}->{'skip_upload'} && (! $params_auto_size)) {304 if ($config->{'upload'}->{'skip_upload'} && (! $params_auto_size)) { 305 305 $next_url = $config->{'general'}->{'base_url'}."results.php"; 306 306 } else { -
trunk/Modules/SpeedTest/results.php
r786 r873 16 16 17 17 ## Save the results of this speedtest to the database, if enabled 18 if ($config->{'database'}->{'enable'}) {18 if ($config->{'database'}->{'enable'}) { 19 19 $ip_matches = $config->{'database'}->{'ip_matches'}; 20 if ( (! $ip_matches) || ($ip_matches && preg_match("/$ip_matches/",$_SERVER['REMOTE_ADDR'])) ) {20 if ( (! $ip_matches) || ($ip_matches && preg_match("/$ip_matches/",$_SERVER['REMOTE_ADDR'])) ) { 21 21 Debug("Saving to database"); 22 22 $dbh = mysql_connect( … … 57 57 58 58 <?php 59 if (file_exists("header.html")) {59 if (file_exists("header.html")) { 60 60 ## Include "header.html" for a custom header, if the file exists 61 61 include("header.html"); … … 75 75 print "<h2>Download Speed: $clean_down</h2>\n"; 76 76 ## Find the biggest value 77 foreach ($config->{'comparisons-download'} as $key=>$value) {78 if ($value > $download_biggest) {77 foreach ($config->{'comparisons-download'} as $key=>$value) { 78 if ($value > $download_biggest) { 79 79 $download_biggest = $value; 80 80 } … … 82 82 ## Print a pretty table with a graph of the results 83 83 print "<center><table>\n"; 84 foreach ($config->{'comparisons-download'} as $key=>$value) {84 foreach ($config->{'comparisons-download'} as $key=>$value) { 85 85 $this_bar_width = $bar_width / $download_biggest * $value; 86 86 print "<tr><td>$key</td><td>".CleanSpeed($value)."</td><td width=\"400\">\n"; … … 97 97 98 98 ## Don't display the upload stuff if we didn't get a speed to compare with 99 if (isset($_GET['upspeed'])) {99 if (isset($_GET['upspeed'])) { 100 100 $clean_up = CleanSpeed($_GET['upspeed']); 101 101 $upload_biggest = $_GET['upspeed']; 102 102 print "<h2>Upload Speed: $clean_up</h2>\n"; 103 foreach ($config->{'comparisons-upload'} as $key=>$value) {104 if ($value > $upload_biggest) {103 foreach ($config->{'comparisons-upload'} as $key=>$value) { 104 if ($value > $upload_biggest) { 105 105 $upload_biggest = $value; 106 106 } 107 107 } 108 108 print "<table>\n"; 109 foreach ($config->{'comparisons-upload'} as $key=>$value) {109 foreach ($config->{'comparisons-upload'} as $key=>$value) { 110 110 $this_bar_width = $bar_width / $upload_biggest * $value; 111 111 print "<tr><td>$key</td><td>".CleanSpeed($value)."</td>\n"; … … 128 128 </div> 129 129 130 <?php if (file_exists("footer.html")) { include("footer.html"); } ?>130 <?php if (file_exists("footer.html")) { include("footer.html"); } ?> 131 131 132 132 </body> … … 136 136 ## Convert the raw speed value to a nicer value 137 137 function CleanSpeed($kbps) { 138 if ($kbps > 1024) {138 if ($kbps > 1024) { 139 139 $cleanspeed = round($kbps / 1024,2) . " Mbps"; 140 140 } else { -
trunk/Modules/Stock/Stock.php
r807 r873 248 248 function BeforeInsertStockMove($Form) 249 249 { 250 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);250 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 251 251 else $Year = date("Y", $Form->Values['ValidFrom']); 252 252 $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup'); 253 253 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 254 return ($Form->Values);254 return ($Form->Values); 255 255 } 256 256 } -
trunk/Modules/Subject/Subject.php
r761 r873 184 184 $DbRow = $DbResult->fetch_row(); 185 185 $Output = 'Subjektů: '.$DbRow['0'].'<br/>'; 186 return ($Output);186 return ($Output); 187 187 } 188 188 } -
trunk/Modules/System/System.php
r825 r873 39 39 40 40 $DbResult = $this->Database->query($Query); 41 while ($Module = $DbResult->fetch_assoc())42 { 43 if ($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies'];41 while ($Module = $DbResult->fetch_assoc()) 42 { 43 if ($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies']; 44 44 else $Dependencies = ' '; 45 if ($Module['Installed'] == 1) $Installed = 'Ano';45 if ($Module['Installed'] == 1) $Installed = 'Ano'; 46 46 else $Installed = 'Ne'; 47 if ($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&Id='.$Module['Id'].'">Odinstalovat</a>';47 if ($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&Id='.$Module['Id'].'">Odinstalovat</a>'; 48 48 else $Actions = '<a href="?A=Install&Id='.$Module['Id'].'">Instalovat</a>'; 49 49 $Output .= '<tr><td>'.$Module['Name'].'</td>'. … … 59 59 $Output .= $PageList['Output']; 60 60 $Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>'; 61 return ($Output);61 return ($Output); 62 62 } 63 63 … … 65 65 { 66 66 $Output = ''; 67 if (array_key_exists('A', $_GET))68 { 69 if ($_GET['A'] == 'SaveToDb')67 if (array_key_exists('A', $_GET)) 68 { 69 if ($_GET['A'] == 'SaveToDb') 70 70 { 71 71 $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase(); 72 72 $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován'); 73 73 } else 74 if ($_GET['A'] == 'Install')74 if ($_GET['A'] == 'Install') 75 75 { 76 76 $this->System->ModuleManager->LoadModules(false); 77 77 $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']); 78 if ($ModuleName != '')78 if ($ModuleName != '') 79 79 { 80 80 $this->System->Modules[$ModuleName]->Install(); … … 83 83 84 84 } else 85 if ($_GET['A'] == 'Uninstall')85 if ($_GET['A'] == 'Uninstall') 86 86 { 87 87 $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']); 88 if ($ModuleName != '')88 if ($ModuleName != '') 89 89 { 90 90 $this->System->ModuleManager->Modules[$ModuleName]->UnInstall(); … … 94 94 } 95 95 $Output .= $this->ShowList(); 96 return ($Output);96 return ($Output); 97 97 } 98 98 } … … 408 408 function IsInstalled() 409 409 { 410 if ($this->InstalledChecked == false)410 if ($this->InstalledChecked == false) 411 411 { 412 412 $DbResult = $this->Database->query('SELECT table_name FROM information_schema.tables 413 413 WHERE table_schema = "'.$this->Database->Database.'" AND table_name = "SystemVersion";'); 414 if ($DbResult->num_rows > 0) $this->Installed = true;414 if ($DbResult->num_rows > 0) $this->Installed = true; 415 415 else $this->Installed = false; 416 416 $this->InstalledChecked = true; 417 417 } 418 return ($this->Installed);418 return ($this->Installed); 419 419 } 420 420 421 421 function ModuleChange($Module) 422 422 { 423 //if ($this->IsInstalled())424 { 425 426 if ($Module->IsInstalled()) $Installed = 1;423 //if ($this->IsInstalled()) 424 { 425 426 if ($Module->IsInstalled()) $Installed = 1; 427 427 else $Installed = 0; 428 428 $this->Database->query('UPDATE `Module` SET `Installed`=1 WHERE `Name`="'.$Module->Name.'"'); … … 436 436 $Query = 'SELECT `Id`, `Name`,`Installed` FROM `Module`'; 437 437 $DbResult = $this->Database->query($Query); 438 while ($Module = $DbResult->fetch_array())438 while ($Module = $DbResult->fetch_array()) 439 439 { 440 440 //echo($Module['Name'].','); … … 453 453 $Modules = array(); 454 454 $DbResult = $this->Database->query('SELECT * FROM `Module`'); 455 while ($DbRow = $DbResult->fetch_assoc())455 while ($DbRow = $DbResult->fetch_assoc()) 456 456 { 457 457 $Modules[$DbRow['Name']] = $DbRow; 458 if ($this->System->ModuleManager->ModulePresent($DbRow['Name']))458 if ($this->System->ModuleManager->ModulePresent($DbRow['Name'])) 459 459 $this->System->ModuleManager->Modules[$DbRow['Name']]->Id = $DbRow['Id']; 460 460 } 461 461 462 462 // Add missing 463 foreach ($this->System->ModuleManager->Modules as $Module)464 { 465 if (!array_key_exists($Module->Name, $Modules))463 foreach ($this->System->ModuleManager->Modules as $Module) 464 { 465 if (!array_key_exists($Module->Name, $Modules)) 466 466 { 467 467 $this->Database->insert('Module', array('Name' => $Module->Name, … … 480 480 481 481 // Remove exceeding 482 foreach ($Modules as $Module)483 if (!$this->System->ModuleManager->ModulePresent($Module['Name']))482 foreach ($Modules as $Module) 483 if (!$this->System->ModuleManager->ModulePresent($Module['Name'])) 484 484 { 485 485 $Output .= 'Removing module '.$Module['Name'].' from list</br/>'; … … 487 487 $this->Database->query('DELETE FROM `ModuleLink` WHERE `LinkedModule` = '.$Module['Id']); 488 488 $DbResult = $this->Database->query('SELECT Id FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']); 489 while ($DbRow = $DbResult->fetch_assoc())489 while ($DbRow = $DbResult->fetch_assoc()) 490 490 { 491 491 $this->Database->query('DELETE FROM `PermissionGroupAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']); … … 495 495 $this->Database->query('DELETE FROM `Model` WHERE `Module` = '.$Module['Id']); 496 496 $DbResult = $this->Database->query('SELECT Id FROM `Model` WHERE `Module` = '.$Module['Id']); 497 while ($DbRow = $DbResult->fetch_assoc())497 while ($DbRow = $DbResult->fetch_assoc()) 498 498 $this->Database->query('DELETE FROM `ModelField` WHERE `Model` = '.$DbRow['Id']); 499 499 $this->Database->query('DELETE FROM `Module` WHERE `Id` = '.$Module['Id']); … … 503 503 $DbDependency = array(); 504 504 $DbResult = $this->Database->query('SELECT * FROM `ModuleLink`'); 505 while ($DbRow = $DbResult->fetch_assoc())505 while ($DbRow = $DbResult->fetch_assoc()) 506 506 $DbDependency[$DbRow['Module']][] = $DbRow['LinkedModule']; 507 507 508 foreach ($this->System->ModuleManager->Modules as $Module)508 foreach ($this->System->ModuleManager->Modules as $Module) 509 509 { 510 510 // Add missing 511 foreach ($Module->Dependencies as $Dependency)512 { 513 if (!array_key_exists($Module->Id, $DbDependency) or511 foreach ($Module->Dependencies as $Dependency) 512 { 513 if (!array_key_exists($Module->Id, $DbDependency) or 514 514 !in_array($this->System->ModuleManager->Modules[$Dependency]->Id, $DbDependency[$Module->Id])) 515 515 { 516 if (array_key_exists($Dependency, $this->System->ModuleManager->Modules))516 if (array_key_exists($Dependency, $this->System->ModuleManager->Modules)) 517 517 $DependencyId = $this->System->ModuleManager->Modules[$Dependency]->Id; 518 518 else throw new Exception('Dependent module '.$Dependency.' not found'); … … 523 523 524 524 // Remove exceeding 525 if (array_key_exists($Module->Id, $DbDependency))526 foreach ($DbDependency[$Module->Id] as $Dep)525 if (array_key_exists($Module->Id, $DbDependency)) 526 foreach ($DbDependency[$Module->Id] as $Dep) 527 527 { 528 528 $DepModName = $this->System->ModuleManager->SearchModuleById($Dep); 529 if (!in_array($DepModName, $Module->Dependencies))529 if (!in_array($DepModName, $Module->Dependencies)) 530 530 $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '. 531 531 $Module->Id.' AND LinkedModule='.$Dep); 532 532 } 533 533 } 534 return ($Output);534 return ($Output); 535 535 } 536 536 } -
trunk/Modules/TV/TV.php
r825 r873 11 11 function Show() 12 12 { 13 if (count($this->System->PathItems) > 1)13 if (count($this->System->PathItems) > 1) 14 14 { 15 if ($this->System->PathItems[1] == 'playlist.m3u') return($this->ShowPlayList());16 else return (PAGE_NOT_FOUND);17 } else return ($this->ShowChannelList());15 if ($this->System->PathItems[1] == 'playlist.m3u') return ($this->ShowPlayList()); 16 else return (PAGE_NOT_FOUND); 17 } else return ($this->ShowChannelList()); 18 18 } 19 19 … … 51 51 52 52 $DbResult = $this->Database->query($Query); 53 while ($Line = $DbResult->fetch_assoc())53 while ($Line = $DbResult->fetch_assoc()) 54 54 { 55 if ($Line['Stream'] <> '') $Line['Show'] = '<a href="playlist.m3u?id='.$Line['ShortName'].'">Naladit</a>';55 if ($Line['Stream'] <> '') $Line['Show'] = '<a href="playlist.m3u?id='.$Line['ShortName'].'">Naladit</a>'; 56 56 else 57 if ($Line['StreamWeb'] <> '') $Line['Show'] = '<a href="'.$Line['StreamWeb'].'">Naladit</a>';57 if ($Line['StreamWeb'] <> '') $Line['Show'] = '<a href="'.$Line['StreamWeb'].'">Naladit</a>'; 58 58 else $Line['Show'] = ' '; 59 59 … … 72 72 $Output .= 'Další online TV na webu: <a href="http://www.tvinfo.cz/live/televize/evropa/cz">TV info</a><br/>'; 73 73 74 return ($Output);74 return ($Output); 75 75 } 76 76 … … 83 83 84 84 echo('#EXTM3U'."\n"); 85 if (array_key_exists('id', $_GET))85 if (array_key_exists('id', $_GET)) 86 86 { 87 87 $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") AND (`ShortName`="'.addslashes($_GET['id']).'") '); 88 if ($DbResult->num_rows > 0)88 if ($DbResult->num_rows > 0) 89 89 { 90 90 $Channel = $DbResult->fetch_array(); … … 95 95 { 96 96 $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") ORDER BY `Name` '); 97 while ($Channel = $DbResult->fetch_array())97 while ($Channel = $DbResult->fetch_array()) 98 98 { 99 99 echo('#EXTINF:0,'.$Channel['Name']."\n"); -
trunk/Modules/TV/tkr.php
r738 r873 12 12 '<tr><th>Číslo</th<th>Jméno stanice</th><th>Frekvence [MHz]</th><th>Jazyk</th></tr>'; 13 13 $DbResult = $this->Database->select('TV', '*', ' 1 ORDER BY Id'); 14 while ($Row = $DbResult->fetch_array())14 while ($Row = $DbResult->fetch_array()) 15 15 { 16 16 $Output .= '<tr><td>'.$Row['Id'].'</td><td><a href="'.$Row['Homepage'].'">'.$Row['Name'].'</a></td><td align="right">'.($Row['Frequency'] / 1000).'</td><td>'.$Row['Language'].'</td></tr>'; 17 17 } 18 18 $Output .= '</table>Aktualizováno dne 17.12.2007<br></div>'; 19 return ($Output);19 return ($Output); 20 20 } 21 21 } -
trunk/Modules/TimeMeasure/Graph.php
r738 r873 20 20 { 21 21 $this->ClearPage = true; 22 return ($this->Render());22 return ($this->Render()); 23 23 } 24 24 … … 27 27 $PrefixMultiplier = new PrefixMultiplier(); 28 28 29 if (array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];29 if (array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug']; 30 30 else $Debug = 0; 31 31 32 if (!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku');32 if (!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku'); 33 33 $StartTime = addslashes($_GET['From']); 34 if (!array_key_exists('To', $_GET)) die('Musíte zadat čas konce');34 if (!array_key_exists('To', $_GET)) die('Musíte zadat čas konce'); 35 35 $EndTime = addslashes($_GET['To']); 36 if ($EndTime < $StartTime) $EndTime = $StartTime + 60;36 if ($EndTime < $StartTime) $EndTime = $StartTime + 60; 37 37 $TimeDifference = $EndTime - $StartTime; 38 if (!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');38 if (!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu'); 39 39 $MeasureId = addslashes($_GET['Measure']); 40 if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;40 if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth; 41 41 else $Width = addslashes($_GET['Width']); 42 if (!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;42 if (!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight; 43 43 else $Height = addslashes($_GET['Height']); 44 if (!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential'];44 if (!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential']; 45 45 else $Differential = addslashes($_GET['Differential']); 46 46 $VerticalLinesCount = round($Height / ($this->FontSize + 4)); … … 63 63 64 64 $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1; 65 if ($Level < 0) $Level = 0;66 if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;65 if ($Level < 0) $Level = 0; 66 if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel; 67 67 //$Level = 0; 68 68 69 69 $Points = $Measure->GetValues($StartTime, $EndTime, $Level); 70 70 71 if ($Debug) echo('Points count: '.count($Points).'<br/>');72 //if ($Debug) foreach($Points as $Index => $Item)71 if ($Debug) echo('Points count: '.count($Points).'<br/>'); 72 //if ($Debug) foreach ($Points as $Index => $Item) 73 73 // echo($Index.': '.$Item['min'].'<br>'); 74 74 … … 77 77 $AvgValue = 0; 78 78 $MinValue = 1000000000000000000; 79 foreach ($Points as $Index => $Item)79 foreach ($Points as $Index => $Item) 80 80 { 81 81 //$Points[$Index]['min'] = $Points[$Index]['min'] / $Measure['Divider']; 82 82 //$Points[$Index]['avg'] = $Points[$Index]['avg'] / $Measure['Divider']; 83 83 //$Points[$Index]['max'] = $Points[$Index]['max'] / $Measure['Divider']; 84 if ($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg'];85 if ($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg'];86 if ($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max'];87 if ($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min'];84 if ($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg']; 85 if ($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg']; 86 if ($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max']; 87 if ($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min']; 88 88 $AvgValue = $AvgValue + $Points[$Index]['Avg']; 89 89 } … … 96 96 $PointsAvg = array(0, $Height - 1); 97 97 $PointsMax = array(0, $Height - 1); 98 if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;98 if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1; 99 99 { 100 foreach ($Points as $Index => $Item)100 foreach ($Points as $Index => $Item) 101 101 { 102 102 $PointsMin[] = $Index * $Width / $Measure->DivisionCount; … … 128 128 129 129 // Generate image 130 if (!$Debug)130 if (!$Debug) 131 131 { 132 132 Header('Content-type: image/png'); … … 153 153 $TimeRange = $EndTime - $StartTime; 154 154 $TimeMarksIndex = 0; 155 while (($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) $TimeMarksIndex += 1;156 if ($TimeMarksIndex < 2) $TimeMarksIndex = 2;155 while (($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) $TimeMarksIndex += 1; 156 if ($TimeMarksIndex < 2) $TimeMarksIndex = 2; 157 157 $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1]; 158 158 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; … … 163 163 // Zobraz měřítko Y 164 164 $VerticalLinesDistance = $Height / $VerticalLinesCount; 165 for ($I = 1; $I <= $VerticalLinesCount; $I++)165 for ($I = 1; $I <= $VerticalLinesCount; $I++) 166 166 { 167 167 $Y = $Height - 1 - ($VerticalLinesDistance * $I); 168 for ($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);168 for ($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray); 169 169 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 170 170 } … … 174 174 // Zobraz měřítko X 175 175 $LastTextEnd = 0; 176 for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)176 for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks) 177 177 { 178 178 $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 179 179 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 180 if (($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift);180 if (($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift); 181 181 else $Text = date('j.n.Y G:i', $Time + $TimeShift); 182 182 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 183 if ($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))183 if ($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2)) 184 184 { 185 for ($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);185 for ($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray); 186 186 imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2, $Height - 2, $Black, $FontFile, $Text); 187 187 $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2; 188 188 } 189 else for ($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);189 else for ($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray); 190 190 } 191 191 192 192 // Popisky osy Y 193 for ($I = 1; $I <= $VerticalLinesCount; $I++)193 for ($I = 1; $I <= $VerticalLinesCount; $I++) 194 194 { 195 195 $Y = $Height - 1 - ($VerticalLinesDistance * $I); … … 199 199 $this->ValueToImageHeigthCoefficient * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3); 200 200 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 201 if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)201 if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) 202 202 imagettftext($Image, $FontSize, 0, 2, $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text); 203 203 } -
trunk/Modules/TimeMeasure/Main.php
r825 r873 62 62 // Day selection 63 63 $Output .= '<select name="Day">'; 64 for ($I = 1; $I < 32; $I++)65 { 66 if ($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';64 for ($I = 1; $I < 32; $I++) 65 { 66 if ($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = ''; 67 67 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 68 68 } … … 71 71 // Month selection 72 72 $Output .= '<select name="Month">'; 73 foreach ($MonthNames as $Index => $Month)74 { 75 if ($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';76 if ($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';73 foreach ($MonthNames as $Index => $Month) 74 { 75 if ($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = ''; 76 if ($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>'; 77 77 } 78 78 $Output .= '</select>. '; … … 80 80 // Day selection 81 81 $Output .= '<select name="Year">'; 82 for ($I = 2000; $I < 2010; $I++)83 { 84 if ($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';82 for ($I = 2000; $I < 2010; $I++) 83 { 84 if ($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = ''; 85 85 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 86 86 } … … 89 89 // Hour selection 90 90 $Output .= '<select name="Hour">'; 91 for ($I = 0; $I < 24; $I++)92 { 93 if ($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';91 for ($I = 0; $I < 24; $I++) 92 { 93 if ($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = ''; 94 94 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 95 95 } … … 98 98 // Minute selection 99 99 $Output .= '<select name="Minute">'; 100 for ($I = 0; $I < 60; $I++)101 { 102 if ($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';100 for ($I = 0; $I < 60; $I++) 101 { 102 if ($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = ''; 103 103 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 104 104 } … … 111 111 $Output .= '</form>'; 112 112 113 return ($Output);113 return ($Output); 114 114 } 115 115 … … 118 118 $Debug = 0; 119 119 120 foreach ($this->DefaultVariables as $Index => $Variable)121 { 122 if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;123 if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];124 if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];120 foreach ($this->DefaultVariables as $Index => $Variable) 121 { 122 if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable; 123 if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index]; 124 if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index]; 125 125 //$$Index = $_SESSION[$Index]; 126 126 } 127 127 128 if ($_SESSION['TimeSpecify'] == 0)128 if ($_SESSION['TimeSpecify'] == 0) 129 129 { 130 130 $_SESSION['TimeEnd'] = time() - 60; … … 134 134 $Output = '<div style="text-align: center;">'; 135 135 136 if (!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';137 switch ($_GET['Operation'])136 if (!array_key_exists('Operation', $_GET)) $_GET['Operation'] = ''; 137 switch ($_GET['Operation']) 138 138 { 139 139 case 'SetTime': 140 if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and140 if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and 141 141 array_key_exists('Year', $_POST) and array_key_exists('Hour', $_POST) and array_key_exists('Minute', $_POST)) 142 142 { 143 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))143 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) 144 144 { 145 145 $_SESSION[$_GET['Time']] = mktime($_POST['Hour'], $_POST['Minute'], 0, $_POST['Month'], … … 150 150 break; 151 151 case 'SetTimeNow': 152 if (array_key_exists('Time', $_GET))152 if (array_key_exists('Time', $_GET)) 153 153 { 154 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))154 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) 155 155 { 156 156 $_SESSION[$_GET['Time']] = time(); … … 162 162 $Output .= '<strong>Časový úsek:</strong><br>'; 163 163 // Show graf time range menu 164 if ($_SESSION['TimeSpecify'] == 0)164 if ($_SESSION['TimeSpecify'] == 0) 165 165 { 166 166 $Output .= 'Délka úseku: '; 167 foreach ($this->GraphTimeRanges as $Index => $Item)167 foreach ($this->GraphTimeRanges as $Index => $Item) 168 168 $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a> '; 169 169 $Output .= '<br/>'; … … 179 179 180 180 $Output .= '<br/>'.$this->MeasureTable(); 181 return ($Output);181 return ($Output); 182 182 } 183 183 … … 191 191 $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&TimeStart='. 192 192 $_SESSION['TimeStart'].'&TimeEnd='.$_SESSION['TimeEnd'].'&TimeSpecify=1&Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>'; 193 return ($Output);193 return ($Output); 194 194 } 195 195 … … 212 212 array('Name' => 'Description', 'Title' => 'Popis'), 213 213 ); 214 if (array_key_exists('Debug', $_GET))214 if (array_key_exists('Debug', $_GET)) 215 215 { 216 216 $TableColumns[] = array('Name' => 'ItemCount', 'Title' => 'Počet položek'); … … 221 221 222 222 $Result = $this->Database->select('Measure', '*', '`Enabled`=1 '.$Order['SQL'].$PageList['SQLLimit']); 223 while ($Measure = $Result->fetch_array())223 while ($Measure = $Result->fetch_array()) 224 224 { 225 225 $DbResult2 = $this->Database->select('MeasureMethod', '*', '`Id`='.$Measure['Method']); 226 226 $MeasureMethod = $DbResult2->fetch_assoc(); 227 227 $StopWatchStart = GetMicrotime(); 228 if (array_key_exists('Debug', $_GET))228 if (array_key_exists('Debug', $_GET)) 229 229 { 230 230 $DbResult = $this->Database->select($Measure['DataTable'], 'COUNT(*)', 'Measure='.$Measure['Id']); … … 233 233 } 234 234 $Result2 = $this->Database->select($Measure['DataTable'], 'Time, Avg', 'Measure='.$Measure['Id'].' AND Level=0 ORDER BY Time DESC LIMIT 1'); 235 if ($Result2->num_rows > 0)235 if ($Result2->num_rows > 0) 236 236 { 237 237 $Row = $Result2->fetch_array(); … … 243 243 $LastMeasureValue = ' '; 244 244 } 245 if ($Measure['Continuity'] == 1) $Interpolate = 'Ano';245 if ($Measure['Continuity'] == 1) $Interpolate = 'Ano'; 246 246 else $Interpolate = 'Ne'; 247 //if ($Measure['Description'] == '') $Measure['Description'] = ' ';247 //if ($Measure['Description'] == '') $Measure['Description'] = ' '; 248 248 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 249 249 $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'&Differential=0">'.$Measure['Name'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Description'].'</td>'; 250 if (array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';250 if (array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>'; 251 251 $Output .= '</tr>'; 252 252 } … … 260 260 //echo($PrefixMultiplier->Add('-0.000000071112345', 'B')); 261 261 $Output .= '</div>'; 262 return ($Output);262 return ($Output); 263 263 } 264 264 } … … 271 271 272 272 $Output = ''; 273 if (!array_key_exists('MeasureId', $_GET)) return('Nebylo zadáno Id měření.');274 if (!array_key_exists('Value', $_GET)) return('Nebyla zadána hodnota.');273 if (!array_key_exists('MeasureId', $_GET)) return ('Nebylo zadáno Id měření.'); 274 if (!array_key_exists('Value', $_GET)) return ('Nebyla zadána hodnota.'); 275 275 $Measure = new Measure($this->System); 276 276 $Measure->Load($_GET['MeasureId']); 277 if (!isset($Measure->Data['Id'])) return('Měření s Id '.$_GET['MeasureId'].' nenalezeno.');277 if (!isset($Measure->Data['Id'])) return ('Měření s Id '.$_GET['MeasureId'].' nenalezeno.'); 278 278 $Measure->AddValue(array('Min' => $_GET['Value'], 'Avg' => $_GET['Value'], 'Max' => $_GET['Value'])); 279 return ($Output);279 return ($Output); 280 280 } 281 281 } -
trunk/Modules/TimeMeasure/Measure.php
r790 r873 15 15 { 16 16 $Result = $this->Database->select('Measure', '*', 'Id='.$Id); 17 if ($Result->num_rows > 0)17 if ($Result->num_rows > 0) 18 18 { 19 19 $this->Data = $Result->fetch_assoc(); 20 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous20 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous 21 21 else $this->Data['ContinuityEnabled'] = 2; // continuous graph 22 22 } else throw new Exception('Measure not found'); … … 25 25 function TimeSegment($Base, $Level) 26 26 { 27 return (pow($this->LevelReducing, $Level) * $Base);27 return (pow($this->LevelReducing, $Level) * $Base); 28 28 } 29 29 30 30 function StatTableName($Level) 31 31 { 32 if ($Level == 0) return('Data');33 else return ('DataCache');32 if ($Level == 0) return ('Data'); 33 else return ('DataCache'); 34 34 } 35 35 36 36 function AlignTime($Time, $TimeSegment) 37 37 { 38 return (round(($Time - $this->ReferenceTime) / $TimeSegment) * $TimeSegment + $this->ReferenceTime);38 return (round(($Time - $this->ReferenceTime) / $TimeSegment) * $TimeSegment + $this->ReferenceTime); 39 39 } 40 40 41 41 function AddValue($Value = array('Min' => 0, 'Avg' => 0, 'Max' => 0), $Level = 0, $Time = 0) 42 42 { 43 if ($Time == 0) $Time = time();43 if ($Time == 0) $Time = time(); 44 44 45 45 $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='. 46 46 $this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2'); 47 if ($Result->num_rows == 0)47 if ($Result->num_rows == 0) 48 48 { 49 49 $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 50 50 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 51 51 'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time), 'Continuity' => 0)); 52 } else if ($Result->num_rows == 1)52 } else if ($Result->num_rows == 1) 53 53 { 54 54 $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], … … 59 59 $LastValue = $Result->fetch_assoc(); 60 60 $NextToLastValue = $Result->fetch_assoc(); 61 if ((($Time - MysqlDateTimeToTime($LastValue['Time'])) < 0.75 * $this->Data['Period']) and ($Level == 0))61 if ((($Time - MysqlDateTimeToTime($LastValue['Time'])) < 0.75 * $this->Data['Period']) and ($Level == 0)) 62 62 { 63 63 echo('Too short period. Minimal period is '.(0.75 * $this->Data['Period'])." seconds\n"); 64 64 } else 65 65 { 66 if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1;66 if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1; 67 67 else $Continuity = 0; 68 if (($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] ==68 if (($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == 69 69 $Value['Min']) and ($LastValue['Avg'] == $NextToLastValue['Avg']) and 70 70 ($LastValue['Avg'] == $Value['Avg']) and ($LastValue['Max'] == $NextToLastValue['Max']) … … 82 82 83 83 // Update next level 84 if ($Level < $this->MaxLevel)84 if ($Level < $this->MaxLevel) 85 85 { 86 86 $Level = $Level + 1; 87 87 $TimeSegment = $this->TimeSegment($this->Data['Period'], 1); 88 88 $EndTime = $this->AlignTime($Time, $TimeSegment); 89 //if ($EndTime < $Time) $EndTime = $EndTime + $TimeSegment;89 //if ($EndTime < $Time) $EndTime = $EndTime + $TimeSegment; 90 90 $StartTime = $EndTime - $TimeSegment; 91 91 … … 96 96 TimeToMysqlDateTime($StartTime).'") AND (Time < "'.TimeToMysqlDateTime($EndTime). 97 97 '") AND (Measure='.$this->Data['Id'].') AND (Level='.($Level - 1).') ORDER BY Time'); 98 while ($Row = $Result->fetch_assoc())98 while ($Row = $Result->fetch_assoc()) 99 99 { 100 100 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 101 101 $Values[] = $Row; 102 102 } 103 //if (count($Values) > 2)103 //if (count($Values) > 2) 104 104 { 105 105 //array_pop($Values); … … 124 124 { 125 125 $Y = ($Y2 - $Y1) / ($X2 - $X1) * ($X - $X1) + $Y1; 126 return ($Y);126 return ($Y); 127 127 } 128 128 … … 132 132 133 133 // Trim outside parts 134 foreach ($this->ValueTypes as $ValueType)134 foreach ($this->ValueTypes as $ValueType) 135 135 { 136 136 $Values[0][$ValueType] = $this->Interpolation($Values[0]['Time'], $Values[0][$ValueType], $Values[1]['Time'], $Values[1][$ValueType], $LeftTime); 137 137 } 138 138 $Values[0]['Time'] = $LeftTime; 139 foreach ($this->ValueTypes as $ValueType)139 foreach ($this->ValueTypes as $ValueType) 140 140 { 141 141 $Values[count($Values) - 1][$ValueType] = $this->Interpolation($Values[count($Values) - 2]['Time'], $Values[count($Values) - 2][$ValueType], … … 145 145 146 146 // Perform computation 147 foreach ($this->ValueTypes as $ValueType)147 foreach ($this->ValueTypes as $ValueType) 148 148 { 149 149 // Compute new value 150 for ($I = 0; $I < (count($Values) - 1); $I++)151 { 152 if ($ValueType == 'Avg')153 { 154 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']);155 else if ($this->Differential == 0)150 for ($I = 0; $I < (count($Values) - 1); $I++) 151 { 152 if ($ValueType == 'Avg') 153 { 154 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']); 155 else if ($this->Differential == 0) 156 156 { 157 157 $NewValue[$ValueType] = $NewValue[$ValueType] + ($Values[$I + 1]['Time'] - $Values[$I]['Time']) * … … 163 163 } 164 164 } 165 else if ($ValueType == 'Max')166 { 167 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])168 { 169 if (0 > $NewValue[$ValueType]) $NewValue[$ValueType] = 0;165 else if ($ValueType == 'Max') 166 { 167 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']) 168 { 169 if (0 > $NewValue[$ValueType]) $NewValue[$ValueType] = 0; 170 170 } else 171 171 { 172 if ($this->Differential == 0)172 if ($this->Differential == 0) 173 173 { 174 if ($Values[$I + 1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];174 if ($Values[$I + 1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType]; 175 175 } else { 176 176 $Difference = $Values[$I + 1][$ValueType] - $Values[$I][$ValueType]; 177 if ($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;177 if ($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference; 178 178 } 179 179 } 180 180 } 181 else if ($ValueType == 'Min')182 { 183 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])184 { 185 if (0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0;181 else if ($ValueType == 'Min') 182 { 183 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']) 184 { 185 if (0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0; 186 186 } else 187 187 { 188 if ($this->Differential == 0)188 if ($this->Differential == 0) 189 189 { 190 if ($Values[$I + 1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];190 if ($Values[$I + 1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType]; 191 191 } else { 192 192 $Difference = $Values[$I + 1][$ValueType] - $Values[$I][$ValueType]; 193 if ($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;193 if ($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference; 194 194 } 195 195 } … … 198 198 $NewValue[$ValueType] = $NewValue[$ValueType]; 199 199 } 200 //if (($RightTime - $LeftTime) > 0)201 if ($this->Data['Cumulative'] == 0)200 //if (($RightTime - $LeftTime) > 0) 201 if ($this->Data['Cumulative'] == 0) 202 202 { 203 203 $NewValue['Avg'] = $NewValue['Avg'] / ($RightTime - $LeftTime); 204 204 } 205 return ($NewValue);205 return ($NewValue); 206 206 } 207 207 … … 210 210 // Get first and last time 211 211 $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time LIMIT 1'); 212 if ($Result->num_rows > 0)212 if ($Result->num_rows > 0) 213 213 { 214 214 $Row = $Result->fetch_assoc(); … … 217 217 218 218 $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1'); 219 if ($Result->num_rows > 0)219 if ($Result->num_rows > 0) 220 220 { 221 221 $Row = $Result->fetch_assoc(); … … 223 223 } else $AbsoluteRightTime = 0; 224 224 225 if ($this->Debug)225 if ($this->Debug) 226 226 { 227 227 echo('AbsoluteLeftTime: '.$AbsoluteLeftTime.'('.TimeToMysqlDateTime($AbsoluteLeftTime).')<br>'); 228 228 echo('AbsoluteRightTime: '.$AbsoluteRightTime.'('.TimeToMysqlDateTime($AbsoluteRightTime).')<br>'); 229 229 } 230 return (array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime));230 return (array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime)); 231 231 } 232 232 … … 235 235 $Result = array(); 236 236 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1'); 237 if ($DbResult->num_rows > 0)237 if ($DbResult->num_rows > 0) 238 238 { 239 239 $Row = $DbResult->fetch_assoc(); 240 240 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 241 return (array($Row));241 return (array($Row)); 242 242 } else 243 243 { … … 247 247 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time < "'. 248 248 TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1'); 249 if ($DbResult->num_rows > 0)249 if ($DbResult->num_rows > 0) 250 250 { 251 251 $Row = $DbResult->fetch_assoc(); 252 252 array_unshift($Result, array('Time' => (MysqlDateTimeToTime($Row['Time']) + 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 253 253 } 254 // if ($Debug) print_r($Result);255 return ($Result);254 // if ($Debug) print_r($Result); 255 return ($Result); 256 256 } 257 257 } … … 262 262 $DbResult = $this->Database->select($this->Data['DataTable'], '*', '(Time < "'. 263 263 TimeToMysqlDateTime($Time).'") AND (Measure='.$this->Data['Id'].') AND (Level='.$Level.') ORDER BY Time DESC LIMIT 1'); 264 if ($DbResult->num_rows > 0)264 if ($DbResult->num_rows > 0) 265 265 { 266 266 $Row = $DbResult->fetch_assoc(); 267 267 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 268 return (array($Row));268 return (array($Row)); 269 269 } else 270 270 { 271 271 //$Time = $Values[0]['Time'] - 60; 272 272 //array_unshift($Values, array('Time' => $Time, 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 273 if ($this->Debug) echo($this->TimeSegment($this->Data['Period'], $Level));273 if ($this->Debug) echo($this->TimeSegment($this->Data['Period'], $Level)); 274 274 $Result[] = array('Time' => ($Time - $this->TimeSegment($this->Data['Period'], $Level)), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0); 275 275 276 276 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1'); 277 if ($DbResult->num_rows > 0)277 if ($DbResult->num_rows > 0) 278 278 { 279 279 $Row = $DbResult->fetch_assoc(); 280 280 array_push($Result, array('Time' => (MysqlDateTimeToTime($Row['Time']) - 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 281 281 } 282 return ($Result);282 return ($Result); 283 283 } 284 284 } … … 286 286 function GetValues($TimeFrom, $TimeTo, $Level) 287 287 { 288 if ($this->Debug) echo('TimeFrom: '.$TimeFrom.'('.TimeToMysqlDateTime($TimeFrom).')<br>');289 if ($this->Debug) echo('TimeTo: '.$TimeTo.'('.TimeToMysqlDateTime($TimeTo).')<br>');288 if ($this->Debug) echo('TimeFrom: '.$TimeFrom.'('.TimeToMysqlDateTime($TimeFrom).')<br>'); 289 if ($this->Debug) echo('TimeTo: '.$TimeTo.'('.TimeToMysqlDateTime($TimeTo).')<br>'); 290 290 291 291 //$AbsoluteTime = GetTimeRange($MeasureId); 292 292 293 // if (($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and293 // if (($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and 294 294 // ($TimeTo > $AbsoluteLeftTime) and ($TimeTo < $AbsoluteRightTime)) 295 295 // { … … 304 304 // echo(DB_NumRows()); 305 305 // $III = 0; 306 while ($Row = $Result->fetch_assoc())306 while ($Row = $Result->fetch_assoc()) 307 307 { 308 308 // echo($III.' '.$Row['Time'].' '.memory_get_usage().','); … … 314 314 // echo('abc'); 315 315 // die(); 316 if ($this->Debug) echo('Item count: '.count($Values));316 if ($this->Debug) echo('Item count: '.count($Values)); 317 317 318 318 $Points = array(); 319 if (count($Values) > 0)319 if (count($Values) > 0) 320 320 { 321 321 $Values = array_merge($this->LoadLeftSideValue($Level, $TimeFrom), $Values, $this->LoadRightSideValue($Level, $TimeTo)); 322 322 $StartIndex = 0; 323 323 $Points = array(); 324 if ($this->Debug) print_r($Values);325 for ($I = 0; $I < $this->DivisionCount; $I++)324 if ($this->Debug) print_r($Values); 325 for ($I = 0; $I < $this->DivisionCount; $I++) 326 326 { 327 327 $TimeStart = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * $I; 328 328 $TimeEnd = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * ($I + 1); 329 if ($this->Debug) echo('TimeEnd '.$I.': '.$TimeEnd.'('.TimeToMysqlDateTime($TimeEnd).')<br>');329 if ($this->Debug) echo('TimeEnd '.$I.': '.$TimeEnd.'('.TimeToMysqlDateTime($TimeEnd).')<br>'); 330 330 331 331 $EndIndex = $StartIndex; 332 while (($Values[$EndIndex]['Time'] < $TimeEnd) and ($EndIndex < count($Values))) $EndIndex = $EndIndex + 1;333 //while (($Values[$EndIndex]['Time'] < $TimeEnd)) $EndIndex = $EndIndex + 1;332 while (($Values[$EndIndex]['Time'] < $TimeEnd) and ($EndIndex < count($Values))) $EndIndex = $EndIndex + 1; 333 //while (($Values[$EndIndex]['Time'] < $TimeEnd)) $EndIndex = $EndIndex + 1; 334 334 $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1); 335 335 $Points[] = $this->ComputeOneValue($TimeStart, $TimeEnd, $SubValues, $Level); 336 336 $StartIndex = $EndIndex - 1; 337 337 } 338 if ($this->Debug) print_r($Points);338 if ($this->Debug) print_r($Points); 339 339 } else $Points[] = array('Min' => 0, 'Avg' => 0, 'Max' => 0); 340 return ($Points);340 return ($Points); 341 341 } 342 342 … … 344 344 { 345 345 echo('Veličina '.$this->Data['Name']."<br>\n"); 346 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous346 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous 347 347 else $this->Data['ContinuityEnabled'] = 2; // continuous graph 348 348 … … 354 354 echo("<br>\n"); 355 355 356 for ($Level = 1; $Level <= $this->MaxLevel; $Level++)356 for ($Level = 1; $Level <= $this->MaxLevel; $Level++) 357 357 { 358 358 echo('Uroven '.$Level."<br>\n"); … … 363 363 $BurstCount = 500; 364 364 echo('For 0 to '.round(($EndTime - $StartTime) / $TimeSegment / $BurstCount)."<br>\n"); 365 for ($I = 0; $I <= round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); $I++)365 for ($I = 0; $I <= round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); $I++) 366 366 { 367 367 echo($I.' '); … … 371 371 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'. 372 372 TimeToMysqlDateTime($StartTime2).'" AND Time < "'.TimeToMysqlDateTime($EndTime2).'" AND Measure='.$this->Data['Id'].' AND Level='.($Level - 1).' ORDER BY Time'); 373 while ($Row = $DbResult->fetch_assoc())373 while ($Row = $DbResult->fetch_assoc()) 374 374 { 375 375 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); … … 377 377 } 378 378 379 if (count($Values) > 0)379 if (count($Values) > 0) 380 380 { 381 381 $Values = array_merge($this->LoadLeftSideValue($Level - 1, $StartTime2), … … 383 383 384 384 $StartIndex = 0; 385 for ($B = 0; $B < $BurstCount; $B++)385 for ($B = 0; $B < $BurstCount; $B++) 386 386 { 387 387 echo('.'); … … 390 390 391 391 $EndIndex = $StartIndex; 392 while ($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1;392 while ($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1; 393 393 $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1); 394 if (count($SubValues) > 2)394 if (count($SubValues) > 2) 395 395 { 396 396 $Point = $this->ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Level); … … 420 420 $Measures = array(); 421 421 $Result = $Database->select('Measure', '*'); 422 while ($Row = $Result->fetch_assoc())422 while ($Row = $Result->fetch_assoc()) 423 423 { 424 424 $Measures = new Measure(); … … 426 426 } 427 427 428 foreach ($Measures as $Measure)428 foreach ($Measures as $Measure) 429 429 { 430 430 $Measure->RebuildMeasureCache(); -
trunk/Modules/TimeMeasure/Measurement/MeasureClient.php
r738 r873 8 8 { 9 9 $DbResult = $this->Database->select('MeasureClient', '*'); 10 while ($MeasureClient = $DbResult->fetch_assoc())10 while ($MeasureClient = $DbResult->fetch_assoc()) 11 11 { 12 12 $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$MeasureClient['Method']); … … 15 15 include_once(dirname(__FILE__).'/'.$MeasureMethod['MeasureClass'].'.php'); 16 16 $MeasureMethod['MeasureClass'] .= 'Measurement'; 17 if (class_exists($MeasureMethod['MeasureClass']))17 if (class_exists($MeasureMethod['MeasureClass'])) 18 18 { 19 19 $MeasureClass = new $MeasureMethod['MeasureClass']($this->System); 20 if (method_exists($MeasureClass, $MeasureMethod['Method']))20 if (method_exists($MeasureClass, $MeasureMethod['Method'])) 21 21 { 22 if ($MeasureClient['Parameter'] != '') $Value = $Measure->$MeasureMethod['Method']($MeasureClient['Parameter']);22 if ($MeasureClient['Parameter'] != '') $Value = $Measure->$MeasureMethod['Method']($MeasureClient['Parameter']); 23 23 else $Value = $MeasureClass->$MeasureMethod['Method'](); 24 24 echo(file_get_contents('http://'.$MeasureClient['Host'].$MeasureClient['Path'].'/?M=Add&MeasureId='.$MeasureClient['MeasureId'].'&Value='.addslashes($Value))); -
trunk/Modules/TimeMeasure/Measurement/System.php
r660 r873 11 11 set_error_handler('ErrorHandler'); 12 12 //error_reporting(0); 13 if ($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout))13 if ($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout)) 14 14 { 15 15 fclose($Fp1); 16 return (TRUE);16 return (TRUE); 17 17 } else 18 18 { 19 19 //echo($ERROR_NO.','.$ERROR_STR); 20 return (FALSE);20 return (FALSE); 21 21 } 22 22 restore_error_handler(); … … 30 30 // c - ping count 31 31 $Parts = explode(' ', $Row[0]); 32 if (count($Parts) > 6)32 if (count($Parts) > 6) 33 33 { 34 34 $Time = $Parts[7]; 35 35 $TimeParts = explode('=', $Time); 36 return ($TimeParts[1]);37 } else return (0);36 return ($TimeParts[1]); 37 } else return (0); 38 38 } 39 39 … … 43 43 exec('free -b', $Output); 44 44 $Row = $Output[2]; 45 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row);45 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); 46 46 $RowParts = explode(' ', $Row); 47 47 $Row = $Output[3]; 48 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row);48 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); 49 49 $RowParts2 = explode(' ', $Row); 50 return ($RowParts[2] + $RowParts2[2]);50 return ($RowParts[2] + $RowParts2[2]); 51 51 } 52 52 … … 81 81 } 82 82 file_put_contents($CpuStateFileName, serialize($CpuUsage)); 83 return (100 - round($CpuUsagePercent['Idle'], 2));83 return (100 - round($CpuUsagePercent['Idle'], 2)); 84 84 } 85 85 … … 93 93 array_shift($Output); // Skip header 94 94 array_shift($Output); // Skip header 95 foreach ($Output as $Item)95 foreach ($Output as $Item) 96 96 { 97 while (strpos($Item, ' ') !== false) $Item = str_replace(' ', ' ', $Item); // Rrmove multiple spaces97 while (strpos($Item, ' ') !== false) $Item = str_replace(' ', ' ', $Item); // Rrmove multiple spaces 98 98 $Item = explode(':', $Item); 99 99 $Interface = trim($Item[0]); 100 100 $Item = explode(' ', trim($Item[1])); 101 101 $NetworkState[$Interface] = array('Down' => $Item[0], 'Up' => $Item[8]); 102 if (array_key_exists($Interface, $LastNetworkState))102 if (array_key_exists($Interface, $LastNetworkState)) 103 103 { 104 104 $Period = time() - $LastNetworkState['Time']; … … 110 110 $NetworkState[$Interface]['UpAverage'] = 0; 111 111 } 112 if ($NetworkState[$Interface]['DownAverage'] < 0) $NetworkState[$Interface]['DownAverage'] = 0;113 if ($NetworkState[$Interface]['UpAverage'] < 0) $NetworkState[$Interface]['UpAverage'] = 0;112 if ($NetworkState[$Interface]['DownAverage'] < 0) $NetworkState[$Interface]['DownAverage'] = 0; 113 if ($NetworkState[$Interface]['UpAverage'] < 0) $NetworkState[$Interface]['UpAverage'] = 0; 114 114 } 115 115 file_put_contents($NetworkStateFile, serialize($NetworkState)); 116 return ($NetworkState);116 return ($NetworkState); 117 117 } 118 118 … … 120 120 { 121 121 $NetworkState = $this->GetNetworkState(); 122 return ($NetworkState['Interface']['DownAverage']);122 return ($NetworkState['Interface']['DownAverage']); 123 123 } 124 124 … … 126 126 { 127 127 $NetworkState = $this->GetNetworkState(); 128 return ($NetworkState['Interface']['UpAverage']);128 return ($NetworkState['Interface']['UpAverage']); 129 129 } 130 130 … … 134 134 $Output = array(); 135 135 exec('cat /proc/net/nf_conntrack|grep "dst='.$HostIP.' "|grep "dport='.$Port.' "|grep "ASSURED"', $Output); 136 return (count($Output));136 return (count($Output)); 137 137 } 138 138 … … 142 142 exec('iostat -d '.$Device.' -x -m 2 2', $Output); // 2 second measure delay 143 143 $Row = $Output[6]; 144 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row);144 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); 145 145 $Parts = explode(' ', $Row); 146 146 $Value = str_replace(',', '.', $Parts[11]); 147 return ($Value);147 return ($Value); 148 148 } 149 149 150 150 function DiskFree($Path) 151 151 { 152 return (disk_free_space($Path));152 return (disk_free_space($Path)); 153 153 } 154 154 … … 157 157 $Output = array(); 158 158 exec('/usr/bin/sensors', $Output); 159 foreach ($Output as $Line)159 foreach ($Output as $Line) 160 160 { 161 if (substr($Line, 0, strlen($Sensor)) == $Sensor)161 if (substr($Line, 0, strlen($Sensor)) == $Sensor) 162 162 { 163 163 $Line = substr($Line, strpos($Line, '+') + 1); 164 164 $Line = substr($Line, 0, strpos($Line, '°')); 165 return ($Line);165 return ($Line); 166 166 } 167 167 } 168 return (0);168 return (0); 169 169 } 170 170 … … 175 175 fclose($File); 176 176 $UptimeParts = explode(' ', $Uptime); 177 return ($UptimeParts[0]);177 return ($UptimeParts[0]); 178 178 } 179 179 } -
trunk/Modules/TimeMeasure/Measurement/WoW.php
r738 r873 12 12 $DbResult = $Database->query('SELECT COUNT(*) FROM account WHERE online=1'); 13 13 $Row = $DbResult->fetch_array(); 14 return ($Row[0]);14 return ($Row[0]); 15 15 } 16 16 … … 20 20 $DbResult = $Database->query('SELECT COUNT(*) FROM account WHERE online=1 AND gmlevel > 0'); 21 21 $Row = $DbResult->fetch_array(); 22 return ($Row[0]);22 return ($Row[0]); 23 23 } 24 24 … … 28 28 $DbResult = $Database->query('SELECT COUNT(*) FROM account'); 29 29 $Row = $DbResult->fetch_array(); 30 return ($Row[0]);30 return ($Row[0]); 31 31 } 32 32 … … 36 36 $DbResult = $Database->query('SELECT COUNT(*) FROM guild'); 37 37 $Row = $DbResult->fetch_array(); 38 return ($Row[0]);38 return ($Row[0]); 39 39 } 40 40 … … 44 44 $DbResult = $Database->query('SELECT COUNT(*) FROM `characters`'); 45 45 $Row = $DbResult->fetch_array(); 46 return ($Row[0]);46 return ($Row[0]); 47 47 } 48 48 … … 52 52 $DbResult = $Database->query('SELECT COUNT(*) FROM uptime'); 53 53 $Row = $DbResult->fetch_array(); 54 return ($Row[0]);54 return ($Row[0]); 55 55 } 56 56 57 57 function WoWEmulatorAvailability() 58 58 { 59 if (CheckPortStatus('localhost', 8085)) return(100); else return(0);59 if (CheckPortStatus('localhost', 8085)) return (100); else return (0); 60 60 } 61 61 … … 69 69 $Row = $DbResult->fetch_array(); 70 70 $Value = $Row[0]; 71 return ($Value);71 return ($Value); 72 72 } 73 73 } -
trunk/Modules/User/User.php
r858 r873 122 122 /* 123 123 124 if ($this->InstalledVersion == '1.0') {124 if ($this->InstalledVersion == '1.0') { 125 125 $this->System->Database->Query('SELECT * FROM User WHERE Id=1'); 126 126 $this->InstalledVersion = '1.1'; … … 132 132 { 133 133 $this->System->User = new User($this->System); 134 if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check();134 if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check(); 135 135 $this->System->RegisterPage('userlist', 'PageUserList'); 136 136 $this->System->RegisterPage('user', 'PageUser'); … … 290 290 function TopBarCallback() 291 291 { 292 if ($this->System->User->User['Id'] == null)292 if ($this->System->User->User['Id'] == null) 293 293 { 294 294 $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '. … … 301 301 // <a href="'.$this->System->Link('/?Action=UserOptions').'">Nastavení</a>'; 302 302 } 303 return ($Output);303 return ($Output); 304 304 } 305 305 } -
trunk/Modules/User/UserList.php
r833 r873 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
r828 r873 30 30 function Hash($Password, $Salt) 31 31 { 32 return (sha1(sha1($Password).$Salt));32 return (sha1(sha1($Password).$Salt)); 33 33 } 34 34 35 35 function Verify($Password, $Salt, $StoredHash) 36 36 { 37 return ($this->Hash($Password, $Salt) == $StoredHash);37 return ($this->Hash($Password, $Salt) == $StoredHash); 38 38 } 39 39 … … 71 71 // Lookup user record 72 72 $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"'); 73 if ($Query->num_rows > 0)73 if ($Query->num_rows > 0) 74 74 { 75 75 // Refresh time of last access … … 81 81 82 82 // Logged permanently? 83 if (array_key_exists('LoginHash', $_COOKIE))83 if (array_key_exists('LoginHash', $_COOKIE)) 84 84 { 85 85 $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId']. 86 86 ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"'); 87 if ($DbResult->num_rows > 0)87 if ($DbResult->num_rows > 0) 88 88 { 89 89 $DbRow = $DbResult->fetch_assoc(); 90 if (sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash'])90 if (sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash']) 91 91 { 92 92 $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"'); … … 99 99 $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"'); 100 100 $Row = $Query->fetch_assoc(); 101 if ($Row['User'] != '')101 if ($Row['User'] != '') 102 102 { 103 103 $Query = $this->Database->query('SELECT `User`.*, `UserCustomerRel`.`Customer` AS `Member` FROM `User` '. … … 114 114 // Remove nonactive users 115 115 $DbResult = $this->Database->select('UserOnline', '`Id`, `User`', '(`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.$this->OnlineStateTimeout.' SECOND)) AND (`StayLogged` = 0)'); 116 while ($DbRow = $DbResult->fetch_array())116 while ($DbRow = $DbResult->fetch_array()) 117 117 { 118 118 $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']); 119 if ($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');119 if ($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout'); 120 120 } 121 121 //$this->LoadPermission($this->User['Role']); … … 127 127 function Register($Login, $Password, $Password2, $Email, $Name) 128 128 { 129 if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '') || ($Name == '')) $Result = DATA_MISSING;130 else if ($Password != $Password2) $Result = PASSWORDS_UNMATCHED;129 if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '') || ($Name == '')) $Result = DATA_MISSING; 130 else if ($Password != $Password2) $Result = PASSWORDS_UNMATCHED; 131 131 else 132 132 { 133 133 // Is user registred yet? 134 134 $Query = $this->Database->select('User', '*', 'Login = "'.$Login.'"'); 135 if ($Query->num_rows > 0) $Result = LOGIN_USED;135 if ($Query->num_rows > 0) $Result = LOGIN_USED; 136 136 else 137 137 { 138 138 $Query = $this->Database->select('User', '*', 'Name = "'.$Name.'"'); 139 if ($Query->num_rows > 0) $Result = NAME_USED;139 if ($Query->num_rows > 0) $Result = NAME_USED; 140 140 else 141 141 { 142 142 $Query = $this->Database->select('User', '*', 'Email = "'.$Email.'"'); 143 if ($Query->num_rows > 0) $Result = EMAIL_USED;143 if ($Query->num_rows > 0) $Result = EMAIL_USED; 144 144 else 145 145 { … … 177 177 } 178 178 } 179 return ($Result);179 return ($Result); 180 180 } 181 181 … … 183 183 { 184 184 $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id); 185 if ($DbResult->num_rows > 0)185 if ($DbResult->num_rows > 0) 186 186 { 187 187 $Row = $DbResult->fetch_array(); 188 188 $NewPassword = substr(sha1(strtoupper($Row['Login'])), 0, 7); 189 if ($Hash == $NewPassword)189 if ($Hash == $NewPassword) 190 190 { 191 191 $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0)); … … 195 195 } else $Output = PASSWORDS_UNMATCHED; 196 196 } else $Output = USER_NOT_FOUND; 197 return ($Output);197 return ($Output); 198 198 } 199 199 200 200 function Login($Login, $Password, $StayLogged = false) 201 201 { 202 if ($StayLogged) $StayLogged = 1; else $StayLogged = 0;202 if ($StayLogged) $StayLogged = 1; else $StayLogged = 0; 203 203 $SID = session_id(); 204 204 $Query = $this->Database->select('User', '*', 'Login="'.$Login.'"'); 205 if ($Query->num_rows > 0)205 if ($Query->num_rows > 0) 206 206 { 207 207 $Row = $Query->fetch_assoc(); 208 208 $PasswordHash = new PasswordHash(); 209 if (!$PasswordHash->Verify($Password, $Row['Salt'], $Row['Password'])) $Result = BAD_PASSWORD;210 else if ($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED;209 if (!$PasswordHash->Verify($Password, $Row['Salt'], $Row['Password'])) $Result = BAD_PASSWORD; 210 else if ($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED; 211 211 else 212 212 { … … 217 217 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array( 218 218 'User' => $Row['Id'], 'StayLogged' => $StayLogged, 'StayLoggedHash' => $StayLoggedSalt)); 219 if ($StayLogged)219 if ($StayLogged) 220 220 { 221 221 setcookie('LoginUserId', $Row['Id'], time()+365*24*60*60, $this->System->Link('/')); … … 231 231 } 232 232 } else $Result = USER_NOT_REGISTRED; 233 return ($Result);233 return ($Result); 234 234 } 235 235 … … 240 240 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']); 241 241 $this->Check(); 242 return (USER_LOGGED_OUT);242 return (USER_LOGGED_OUT); 243 243 } 244 244 … … 247 247 $this->Roles = array(); 248 248 $DbResult = $this->Database->select('UserRole', '*'); 249 while ($DbRow = $DbResult->fetch_array())249 while ($DbRow = $DbResult->fetch_array()) 250 250 $this->Roles[] = $DbRow; 251 251 } … … 255 255 $this->User['Permission'] = array(); 256 256 $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description` FROM `UserRolePermission` JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` WHERE `UserRolePermission`.`Role` = '.$Role); 257 if ($DbResult->num_rows > 0)258 while ($DbRow = $DbResult->fetch_array())257 if ($DbResult->num_rows > 0) 258 while ($DbRow = $DbResult->fetch_array()) 259 259 $this->User['Permission'][$DbRow['Operation']] = $DbRow; 260 260 } … … 264 264 $Result = array(); 265 265 $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`'); 266 while ($DbRow = $DbResult->fetch_array())266 while ($DbRow = $DbResult->fetch_array()) 267 267 { 268 268 $Value = ''; 269 if ($DbRow['Read']) $Value .= 'R';270 if ($DbRow['Write']) $Value .= 'W';269 if ($DbRow['Read']) $Value .= 'R'; 270 if ($DbRow['Write']) $Value .= 'W'; 271 271 $Result[$DbRow['Description']][$DbRow['Title']] = $Value; 272 272 } 273 return ($Result);273 return ($Result); 274 274 } 275 275 … … 278 278 $PermissionExists = false; 279 279 // First try to check cache group-group relation 280 if (array_key_exists($GroupId, $this->PermissionGroupCache))280 if (array_key_exists($GroupId, $this->PermissionGroupCache)) 281 281 { 282 282 $PermissionExists = true; … … 287 287 '") AND (`AssignedGroup` IS NOT NULL)'); 288 288 $DbRow = array(); 289 while ($DbRow[] = $DbResult->fetch_array());289 while ($DbRow[] = $DbResult->fetch_array()); 290 290 $this->PermissionGroupCache[$GroupId] = $DbRow; 291 291 $PermissionExists = true; 292 292 } 293 if ($PermissionExists)294 { 295 foreach ($this->PermissionGroupCache[$GroupId] as $DbRow)296 { 297 if ($DbRow['AssignedGroup'] != '')298 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);293 if ($PermissionExists) 294 { 295 foreach ($this->PermissionGroupCache[$GroupId] as $DbRow) 296 { 297 if ($DbRow['AssignedGroup'] != '') 298 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return (true); 299 299 } 300 300 } 301 301 302 302 // Check group-operation relation 303 if (array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp))303 if (array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp)) 304 304 { 305 305 $PermissionExists = true; … … 308 308 // If no permission combination exists in cache, do new check of database items 309 309 $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedOperation`="'.$OperationId.'"'); 310 if ($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true;310 if ($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true; 311 311 else $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = false; 312 312 $PermissionExists = true; 313 313 } 314 if ($PermissionExists)315 { 316 return ($this->PermissionGroupCacheOp[$GroupId.','.$OperationId]);317 } 318 return (false);314 if ($PermissionExists) 315 { 316 return ($this->PermissionGroupCacheOp[$GroupId.','.$OperationId]); 317 } 318 return (false); 319 319 } 320 320 … … 323 323 // Get module id 324 324 $DbResult = $this->Database->select('Module', 'Id', '`Name`="'.$Module.'"'); 325 if ($DbResult->num_rows > 0)325 if ($DbResult->num_rows > 0) 326 326 { 327 327 $DbRow = $DbResult->fetch_assoc(); 328 328 $ModuleId = $DbRow['Id']; 329 } else return (false);329 } else return (false); 330 330 331 331 // First try to check cache 332 if (in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache))332 if (in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache)) 333 333 { 334 334 $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemIndex), $this->PermissionCache); … … 339 339 $DbResult = $this->Database->select('PermissionOperation', 'Id', '(`Module`="'.$ModuleId. 340 340 '") AND (`Item`="'.$ItemType.'") AND (`ItemId`='.$ItemIndex.') AND (`Operation`="'.$Operation.'")'); 341 if ($DbResult->num_rows > 0)341 if ($DbResult->num_rows > 0) 342 342 { 343 343 $DbRow = $DbResult->fetch_array(); … … 352 352 } 353 353 354 if ($PermissionExists)355 { 356 if ($this->User['Id'] == null) $UserCondition = '(`User` IS NULL)';354 if ($PermissionExists) 355 { 356 if ($this->User['Id'] == null) $UserCondition = '(`User` IS NULL)'; 357 357 else $UserCondition = '(`User`="'.$this->User['Id'].'")'; 358 358 // Check user-operation relation 359 359 $DbResult = $this->Database->select('PermissionUserAssignment', '*', $UserCondition.' AND (`AssignedOperation`="'.$OperationId.'")'); 360 if ($DbResult->num_rows > 0) return(true);360 if ($DbResult->num_rows > 0) return (true); 361 361 362 362 // Check user-group relation 363 363 $DbResult = $this->Database->select('PermissionUserAssignment', 'AssignedGroup', $UserCondition); 364 while ($DbRow = $DbResult->fetch_array())365 { 366 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);367 } 368 return (false);369 } else return (false);364 while ($DbRow = $DbResult->fetch_array()) 365 { 366 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return (true); 367 } 368 return (false); 369 } else return (false); 370 370 } 371 371 … … 373 373 { 374 374 $DbResult = $this->Database->select('User', 'Login, Name, Id, Email, Password', '`Login`="'.$Login.'" AND `Email`="'.$Email.'"'); 375 if ($DbResult->num_rows > 0)375 if ($DbResult->num_rows > 0) 376 376 { 377 377 $Row = $DbResult->fetch_array(); … … 394 394 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email); 395 395 } else $Output = USER_PASSWORD_RECOVERY_FAIL; 396 return ($Output);396 return ($Output); 397 397 } 398 398 … … 400 400 { 401 401 $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id); 402 if ($DbResult->num_rows > 0)402 if ($DbResult->num_rows > 0) 403 403 { 404 404 $Row = $DbResult->fetch_array(); 405 405 $NewPassword2 = substr(sha1(strtoupper($Row['Login'])), 0, 7); 406 if (($NewPassword == $NewPassword2) and ($Hash == $Row['Password']))406 if (($NewPassword == $NewPassword2) and ($Hash == $Row['Password'])) 407 407 { 408 408 $PasswordHash = new PasswordHash(); … … 414 414 } else $Output = PASSWORDS_UNMATCHED; 415 415 } else $Output = USER_NOT_FOUND; 416 return ($Output);416 return ($Output); 417 417 } 418 418 … … 420 420 { 421 421 $DbResult = $this->Database->select('APIToken', 'User', '`Token`="'.$Token.'"'); 422 if ($DbResult->num_rows > 0)422 if ($DbResult->num_rows > 0) 423 423 { 424 424 $DbRow = $DbResult->fetch_assoc(); 425 425 $User = new User($this->System); 426 426 $User->User = array('Id' => $DbRow['User']); 427 return ($User->CheckPermission($Module, $Operation));428 } else return (false);427 return ($User->CheckPermission($Module, $Operation)); 428 } else return (false); 429 429 } 430 430 } -
trunk/Modules/User/UserPage.php
r828 r873 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/Modules/WebCam/WebCam.php
r860 r873 9 9 function Show() 10 10 { 11 if (file_exists($this->System->ModuleManager->Modules['WebCam']->ImageFileName))11 if (file_exists($this->System->ModuleManager->Modules['WebCam']->ImageFileName)) 12 12 { 13 13 $Output = '<script language="JavaScript"> … … 38 38 '<a href="http://www.mestovsetin.cz/vismo/dokumenty2.asp?id_org=18676&id=480245">Webové kamery ve Vsetíně</a><br />'; 39 39 40 return ($Output);40 return ($Output); 41 41 } 42 42 } … … 72 72 $Output .= '<a href="//www.zdechov.net/kamery/?Id=3"><img alt="Skiareál, motokrosová grapa" width="140" height="79" src="//www.zdechov.net/images/webcam/webcam3.jpg" /></a>'; 73 73 $Output .= '<a href="//www.zdechov.net/kamery/?Id=4"><img alt="Fotbalové hřiště" width="140" height="79" src="//www.zdechov.net/images/webcam/webcam4.jpg" /></a>'; 74 return ($Output);74 return ($Output); 75 75 } 76 76 } -
trunk/Modules/WebCam/webcam_refresh.php
r738 r873 3 3 4 4 $Config['Web']['ShowPHPError'] = true; 5 while (1)5 while (1) 6 6 { 7 7 $ModifyTime = filemtime('webcam.jpg'); 8 if ((time() - $Config['Web']['WebcamRefresh']) >= $ModifyTime)8 if ((time() - $Config['Web']['WebcamRefresh']) >= $ModifyTime) 9 9 { 10 10 // $Output = shell_exec('wget "http://kamera-stred/Webcam.jpg?MobilePass='.$Config['Web']['WebcamPassword'].'&V=2&Q=2&B=2&U=0" -O webcam_cache.jpg -T '.($Config['Web']['WebcamRefresh']).' --limit-rate=200k'); 11 11 $Output = shell_exec('wget "http://kamera-knihovna/cgi-bin/viewer/video.jpg" -O webcam_cache.jpg -T '.($Config['Web']['WebcamRefresh']).' --limit-rate=200k'); 12 12 13 if ((strpos($Output, 'failed') === false) and (strpos($Output, 'error') === false))13 if ((strpos($Output, 'failed') === false) and (strpos($Output, 'error') === false)) 14 14 shell_exec('mv -f webcam_cache.jpg webcam.jpg'); 15 15 } -
trunk/Modules/Wiki/Wiki.php
r825 r873 60 60 { 61 61 $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1'); 62 while ($DbRow = $DbResult->fetch_assoc())62 while ($DbRow = $DbResult->fetch_assoc()) 63 63 { 64 64 $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki'); … … 82 82 function Show() 83 83 { 84 if (array_key_exists('Action', $_GET))85 { 86 if ($_GET['Action'] == 'Edit') $Output = $this->EditContent();87 else if ($_GET['Action'] == 'EditSave') $Output = $this->SaveContent();88 else if ($_GET['Action'] == 'History') $Output = $this->ShowHistory();84 if (array_key_exists('Action', $_GET)) 85 { 86 if ($_GET['Action'] == 'Edit') $Output = $this->EditContent(); 87 else if ($_GET['Action'] == 'EditSave') $Output = $this->SaveContent(); 88 else if ($_GET['Action'] == 'History') $Output = $this->ShowHistory(); 89 89 else $Output = $this->ShowContent(); 90 90 } else $Output = $this->ShowContent(); 91 return ($Output);91 return ($Output); 92 92 } 93 93 … … 96 96 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 97 97 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 98 if ($DbResult->num_rows > 0)98 if ($DbResult->num_rows > 0) 99 99 { 100 100 $DbRow = $DbResult->fetch_assoc(); 101 if (array_key_exists('ver', $_GET))101 if (array_key_exists('ver', $_GET)) 102 102 { 103 103 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' AND Id='.$_GET['ver']*1); 104 if ($DbResult2->num_rows > 0)104 if ($DbResult2->num_rows > 0) 105 105 { 106 106 $DbRow2 = $DbResult2->fetch_assoc(); 107 107 $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>'; 108 108 $Output .= $DbRow2['Content']; 109 if ($this->System->User->Licence(LICENCE_MODERATOR))109 if ($this->System->User->Licence(LICENCE_MODERATOR)) 110 110 $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>'; 111 111 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); … … 113 113 { 114 114 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 115 if ($DbResult2->num_rows > 0)115 if ($DbResult2->num_rows > 0) 116 116 { 117 117 $DbRow2 = $DbResult2->fetch_assoc(); 118 118 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 119 119 $Output .= $DbRow2['Content']; 120 if ($this->System->User->Licence(LICENCE_MODERATOR))120 if ($this->System->User->Licence(LICENCE_MODERATOR)) 121 121 $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>'; 122 122 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 123 123 } 124 124 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 125 return ($Output);125 return ($Output); 126 126 } 127 127 128 128 function EditContent() 129 129 { 130 if ($this->System->User->Licence(LICENCE_MODERATOR))130 if ($this->System->User->Licence(LICENCE_MODERATOR)) 131 131 { 132 132 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 133 133 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 134 if ($DbResult->num_rows > 0)134 if ($DbResult->num_rows > 0) 135 135 { 136 136 $DbRow = $DbResult->fetch_assoc(); 137 137 $Output = '<h3>Úprava '.$DbRow['Name'].'</h3>'; 138 138 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 139 if ($DbResult2->num_rows > 0)139 if ($DbResult2->num_rows > 0) 140 140 { 141 141 $DbRow2 = $DbResult2->fetch_assoc(); … … 148 148 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 149 149 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 150 return ($Output);150 return ($Output); 151 151 } 152 152 153 153 function SaveContent() 154 154 { 155 if ($this->System->User->Licence(LICENCE_MODERATOR))155 if ($this->System->User->Licence(LICENCE_MODERATOR)) 156 156 { 157 157 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 158 158 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 159 if ($DbResult->num_rows > 0)159 if ($DbResult->num_rows > 0) 160 160 { 161 161 $DbRow = $DbResult->fetch_assoc(); 162 if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST))162 if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST)) 163 163 { 164 164 $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']), … … 169 169 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 170 170 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 171 return ($Output);171 return ($Output); 172 172 } 173 173 174 174 function ShowHistory() 175 175 { 176 if ($this->System->User->Licence(LICENCE_MODERATOR))176 if ($this->System->User->Licence(LICENCE_MODERATOR)) 177 177 { 178 178 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 179 179 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 180 if ($DbResult->num_rows > 0)180 if ($DbResult->num_rows > 0) 181 181 { 182 182 $DbRow = $DbResult->fetch_assoc(); … … 202 202 ' FROM `WikiPageContent` WHERE Page='. 203 203 $DbRow['Id'].' '.$Order['SQL'].$PageList['SQLLimit']); 204 while ($PageContent = $DbResult2->fetch_assoc())204 while ($PageContent = $DbResult2->fetch_assoc()) 205 205 { 206 206 $Output .= '<tr>'. … … 215 215 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 216 216 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 217 return ($Output);217 return ($Output); 218 218 } 219 219 … … 242 242 $text = str_replace("\r\n", '<br/>', $text); 243 243 $text = '<p>'.$text.'</p>'; 244 return ($text);244 return ($text); 245 245 } 246 246 }
Note:
See TracChangeset
for help on using the changeset viewer.