Changeset 148 for www/global.php


Ignore:
Timestamp:
Feb 15, 2009, 7:59:35 PM (15 years ago)
Author:
george
Message:
  • Upraveno: Přepracován systém generování zobrazení výstupu. Pro nový systím přepsáno mnoho stránek.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • www/global.php

    r145 r148  
    99include('database.php');
    1010//include('error.php');
     11include_once('code.php');
    1112$Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
    1213$Database->Prefix = $Config['Database']['Prefix'];
    1314$Database->charset($Config['Database']['Charset']);
    14 include('module.php');
    15 //include('user.php');
    16 //$User = new User($Database);
    17 //$User->Check();
     15include_once('module.php');
     16include_once('forms.php');
     17include_once('page.php');
     18
     19class System extends Module
     20{
     21  var $Modules = array();
     22
     23  function ModulePresent($Name)
     24  {
     25    return(array_key_exists($Name, $this->Modules));
     26  }
     27
     28  function AddModule($Module)
     29  {
     30    global $Database;
     31
     32    //echo('Přidávám modul '.get_class($Module).'<br>');
     33    $Module->System = &$this;
     34    $Module->Database = &$Database;
     35    $this->Modules[get_class($Module)] = $Module;
     36  }
     37}
     38
     39$System = new System();
     40$System->Config = $Config;
     41/*
     42include_once('log.php');
     43$System->AddModule(new Log());
     44include_once('user.php');
     45$System->AddModule(new User());
     46$System->Modules['User']->Check();
     47include_once('aktuality/news.php');
     48$System->AddModule(new News());
     49include_once('webcam/webcam.php');
     50$System->AddModule(new Webcam());
     51include_once('finance/bills.php');
     52$System->AddModule(new Bill());
     53include_once('finance/finance.php');
     54$System->AddModule(new Finance());
     55*/
    1856
    1957$MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
    2058
    21 $MaxSubnet = 7;
     59$MaxSubnet = $Config['Network']['MaxSubnetCount'];
     60
     61$UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB');
    2262 
     63function HumanSize($Value)
     64{
     65  global $UnitNames;
     66
     67  $UnitIndex = 0;
     68  while($Value > 1024)
     69  {
     70    $Value = round($Value / 1024, 3);
     71    $UnitIndex++;
     72  }
     73  return($Value.' '.$UnitNames[$UnitIndex]);
     74}
     75
    2376function GetMicrotime()
    2477{
     
    120173{
    121174  if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
    122   else $IP = $_SERVER['REMOTE_ADDR'];
    123   //if($IP == '127.0.0.1')
     175  else if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
     176  else $IP = '0.0.0.0';
    124177  return($IP);
    125178}
     
    130183  $RemoteAddr = explode('.', $RemoteAddr);
    131184  return(!(($RemoteAddr[0] == 192) and ($RemoteAddr[1] == 168)));
    132 }
    133 
    134 // Funkce formatovani vystupu
    135 function FormatOutput($s)
    136 {
    137     $out = '';
    138     $nn = 0;
    139     $n = 0;
    140     while($s!='')
    141     {
    142       $start = strpos($s,'<');
    143           $end = strpos($s,'>');
    144         if($start != 0)
    145         {
    146               $end = $start-1;
    147               $start = 0;
    148             }
    149             $line = trim(substr($s,$start,$end+1));
    150             if(strlen($line)>0)
    151             if($line[0] == '<')
    152             {
    153             if($s[$start+1] == '/')
    154               {
    155               $n = $n - 2;
    156                       $nn = $n;
    157               } else
    158               {
    159             if(strpos($line,' ')) $cmd = substr($line,1,strpos($line,' ')-1);
    160                 else $cmd = substr($line,1,strlen($line)-2);
    161           //echo('['.$cmd.']');
    162                       if(strpos($s,'</'.$cmd.'>')) $n = $n + 2;
    163               }   
    164             }// else $line = '['.$line.']';
    165       //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
    166             if($line != '') $out .= (str_repeat(' ',$nn).$line."\n");
    167             $s = substr($s,$end+1,strlen($s));
    168             $nn = $n;
    169     }
    170     return($out);
    171185}
    172186
Note: See TracChangeset for help on using the changeset viewer.