Changeset 291


Ignore:
Timestamp:
Oct 2, 2010, 4:24:15 PM (14 years ago)
Author:
george
Message:
  • Přidáno: Podpora pro blokování přístupu k internetu. Při blokovaném přístup se přesměrují HTTP požadavky na informační stránku.
Location:
trunk
Files:
1 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/block/index.php

    r163 r291  
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    2 <html><head>
    3   <meta http-equiv="Content-Language" content="cs">
    4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    5   <title>Centrála - Nepovolený přístup</title>
    6 </head><body>
     1<?php
     2include_once('../global.php');
    73
    8 Pokračujte na hlavní stránku serveru Centrála <a href="http://centrala.zdechov.net/">zde</a>
    9 </body></html>
     4class BlockPage extends Page
     5{
     6  var $FullTitle = 'Blokování internetu';
     7  var $ShortTitle = 'Blokování internetu';
     8  var $Reasons = array(
     9    0 => 'Internet máte povolen, avšak došlo k chybě při kontrole přístupů k Internetu.',
     10    1 => 'Váš počítač má blokován přístup k internetu. Pravděpodobně je váš účet v mínusu.',
     11    2 => 'Váš účet je v mínusu. Zaplaťte prosím chybějící peníze.',
     12    3 => 'Přistupovat k internetu můžete pouze pomocí VPN(Virtuální Privátní Sítě). Aktivujte toto připojení.',
     13    4 => 'Váš počítač není registrován. Zaregistrujte jej prosím.'
     14  );
     15
     16  function Show()
     17  {
     18    $Output = '<br/><div style="font-size: 20 pt;">Máte blokován přístup k Internetu.</div>
     19<br/>
     20<strong>Důvod:</strong> ';
     21
     22    $DbResult = $this->Database->query('SELECT * FROM NetworkInterface WHERE LocalIP="'.$_SERVER['REMOTE_ADDR'].'"');
     23    if($DbResult->num_rows > 0)
     24    {
     25      $Interface = $DbResult->fetch_array();
     26      $DbResult = $this->Database->select('NetworkDevice', '*', 'Id='.$Interface['Device']);
     27      $Device = $DbResult->fetch_array();
     28      $DbResult = $this->Database->select('Member', '*', 'Id='.$Device['Member']);
     29      $Member = $DbResult->fetch_array();
     30     
     31      if($Member['Blocked'] == 1)
     32      {
     33        $Output .= $this->Reasons[1];
     34      } else $Output .= $this->Reasons[0];
     35    } else $Output .= $this->Reasons[4];
     36 
     37    $Output .= '<br><br>V případě problémů kontaktujte správce na telefonu 737785792<br/><br/>';
     38    $Output .= 'Pokračujte na portál sítě <a href="http://centrala.zdechov.net/">centrala.zdechov.net</a>
     39</body></html>';
     40    return($Output);
     41  }
     42}
     43
     44$System->AddModule(new BlockPage());
     45$System->Modules['BlockPage']->GetOutput();
     46
     47?>
  • trunk/index.php

    r263 r291  
    4444    $OnlineComputers = $DbRow[0];
    4545
    46     $Output = '<img alt="" src="images/favicons/comp.gif" width="16" height="16" /> '.$OnlineComputers.' / '.$TotalComputers.' &nbsp;  &nbsp; ';
     46    $Output = '<img alt="" src="images/favicons/comp.png" width="16" height="16" /> '.$OnlineComputers.' / '.$TotalComputers.' &nbsp;  &nbsp; ';
    4747
    4848    $DbResult = $this->Database->select('Member', 'COUNT(*)', 'MemberState=0');
     
    5454    $OnlineUser = $DbRow[0];
    5555
    56     $Output .= '<img alt="" src="images/favicons/house.gif" width="16" height="16" /> '.$OnlineUser.' / '.$TotalUser.' &nbsp;  &nbsp; ';
     56    $Output .= '<img alt="" src="images/favicons/house.png" width="16" height="16" /> '.$OnlineUser.' / '.$TotalUser.' &nbsp;  &nbsp; ';
    5757
    5858    $NetworkUsage = 0;
    59     $Output .= '<img alt="" src="images/favicons/usage.gif" width="16" height="16" /> '.$NetworkUsage.' % &nbsp;  &nbsp; ';
     59    $Output .= '<img alt="" src="images/favicons/usage.png" width="16" height="16" /> '.$NetworkUsage.' % &nbsp;  &nbsp; ';
    6060
    6161    //$Output .= 'Server běží: '.$this->GetServerUptime().' &nbsp;  &nbsp; ';
     
    6767      {
    6868        $DbRow = $DbResult->fetch_assoc();
    69         $Output2 .= ' &nbsp;  &nbsp; <img alt="" src="images/favicons/money.gif" width="16" height="16" /> '.$DbRow['Money'].' Kč';
     69        $Output2 .= ' &nbsp;  &nbsp; <img alt="" src="images/favicons/money.png" width="16" height="16" /> '.$DbRow['Money'].' Kč';
    7070      }
    7171    }
  • trunk/system/generators/firewall_nat.php

    r288 r291  
    1313
    1414$InetInterface = $Config['MainRouter']['InetInterface'];
     15$IPCentrala = '10.145.64.8';
    1516
    1617$Items = array();
     18
     19/*
    1720// NTP redirect
    1821$Items[] = array('chain' => 'srcnat', 'src-address' => '10.145.66.1', 'protocol' => 'udp', 'src-port' => 123, 'action' => 'src-nat', 'to-addresses' => '10.145.64.1', 'comment' => 'NTP_redirect_4');
     
    2225$Items[] = array('chain' => 'srcnat', 'src-address' => '10.145.66.250', 'protocol' => 'udp', 'src-port' => 123, 'action' => 'src-nat', 'to-addresses' => '10.145.64.1', 'comment' => 'NTP_redirect_3');
    2326$Items[] = array('chain' => 'srcnat', 'src-address' => '10.145.66.253', 'protocol' => 'udp', 'src-port' => 123, 'action' => 'src-nat', 'to-addresses' => '10.145.64.1', 'comment' => 'NTP_redirect_6');
     27*/
    2428
    2529// Chain for inet interface
     
    4347    $Name = RouterOSIdent($Name);
    4448    echo($Name.'('.$Interface['LocalIP'].'), ');
    45     $Items[] = array('chain' => 'inet-out', 'src-address' => $Interface['LocalIP'], 'action' => 'src-nat',  'to-addresses' => $Interface['ExternalIP'], 'comment' => $Name.'-out');
    46     $Items[] = array('chain' => 'inet-in', 'dst-address' => $Interface['ExternalIP'], 'action' => 'dst-nat', 'to-addresses' => $Interface['LocalIP'], 'comment' => $Name.'-in');
     49    if($Member['Blocked'] == 0)
     50    {
     51      $Items[] = array('chain' => 'inet-out', 'src-address' => $Interface['LocalIP'], 'action' => 'src-nat',  'to-addresses' => $Interface['ExternalIP'], 'comment' => $Name.'-out');
     52      $Items[] = array('chain' => 'inet-in', 'dst-address' => $Interface['ExternalIP'], 'action' => 'dst-nat', 'to-addresses' => $Interface['LocalIP'], 'comment' => $Name.'-in');
     53    } else
     54    {
     55      $Items[] = array('chain' => 'dstnat', 'src-address' => $Interface['LocalIP'], 'dst-port' => 80, 'action' => 'dst-nat',  'to-addresses' => $IPCentrala, 'to-ports' => 81, 'comment' => $Name.'-out');
     56    }
    4757  }
    4858
     
    5363    $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']);
    5464    echo($Subnet['Name'].'('.$Subnet['AddressRange'].'/'.$Subnet['Mask'].'), ');
    55     $NewAddress = new NetworkAddressIPv4();
    56     $NewAddress->AddressFromString($Subnet['ExtAddressRange']);
    57     $NewAddress->Prefix = $Subnet['ExtMask'];
    58     $Range = $NewAddress->GetRange();
    59     if($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
    60       else $Range = $Range['From']->AddressToString();
    61     if($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];
    62       else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask'];
    63     $Items[] = array('chain' => 'inet-out', 'src-address' => $Src, 'action' => 'src-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-out');
     65    if($Member['Blocked'] == 0)
     66    {
     67      $NewAddress = new NetworkAddressIPv4();
     68      $NewAddress->AddressFromString($Subnet['ExtAddressRange']);
     69      $NewAddress->Prefix = $Subnet['ExtMask'];
     70      $Range = $NewAddress->GetRange();
     71      if($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
     72        else $Range = $Range['From']->AddressToString();
     73      if($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];
     74        else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask'];
     75      $Items[] = array('chain' => 'inet-out', 'src-address' => $Src, 'action' => 'src-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-out');
    6476   
    65     $NewAddress = new NetworkAddressIPv4();
    66     $NewAddress->AddressFromString($Subnet['AddressRange']);
    67     $NewAddress->Prefix = $Subnet['Mask'];
    68     $Range = $NewAddress->GetRange();
    69     if($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
    70       else $Range = $Range['From']->AddressToString();
    71     if($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange'];
    72       else $Dest = $Subnet['ExtAddressRange'].'/'.$Subnet['ExtMask'];
    73     $Items[] = array('chain' => 'inet-in', 'dst-address' => $Dest, 'action' => 'dst-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-in');
     77      $NewAddress = new NetworkAddressIPv4();
     78      $NewAddress->AddressFromString($Subnet['AddressRange']);
     79      $NewAddress->Prefix = $Subnet['Mask'];
     80      $Range = $NewAddress->GetRange();
     81      if($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();
     82        else $Range = $Range['From']->AddressToString();
     83      if($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange'];
     84        else $Dest = $Subnet['ExtAddressRange'].'/'.$Subnet['ExtMask'];
     85      $Items[] = array('chain' => 'inet-in', 'dst-address' => $Dest, 'action' => 'dst-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-in');
     86    } else
     87    {
     88      if($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];
     89        else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask'];
     90      $Items[] = array('chain' => 'dstnat', 'src-address' => $Src, 'dst-port' => 80, 'action' => 'dst-nat',  'to-addresses' => $IPCentrala, 'to-ports' => 81, 'comment' => $Subnet['Name'].'-out');
     91    }
    7492  }
    7593  echo("\n");
Note: See TracChangeset for help on using the changeset viewer.