Index: trunk/Packages/Common/Common.php
===================================================================
--- trunk/Packages/Common/Common.php	(revision 61)
+++ trunk/Packages/Common/Common.php	(revision 61)
@@ -0,0 +1,29 @@
+<?php
+
+include_once(dirname(__FILE__).'/Database.php');
+include_once(dirname(__FILE__).'/Image.php');
+include_once(dirname(__FILE__).'/Mail.php');
+include_once(dirname(__FILE__).'/NetworkAddress.php');
+include_once(dirname(__FILE__).'/PrefixMultiplier.php');
+include_once(dirname(__FILE__).'/RSS.php');
+include_once(dirname(__FILE__).'/UTF8.php');
+include_once(dirname(__FILE__).'/VarDumper.php');
+include_once(dirname(__FILE__).'/Error.php');
+
+class PackageCommon
+{
+  var $Name;
+  var $Version;
+  var $License;
+  var $Creator;
+  var $Homepage;
+
+  function __construct()
+  {
+    $this->Name = 'Common';
+    $this->Version = '1.1';
+    $this->Creator = 'Chronos';
+    $this->License = 'GNU/GPL';
+    $this->Homepage = 'http://svn.zdechov.net/svn/PHPlib/Common/';
+  }
+}
Index: trunk/Packages/Common/Error.php
===================================================================
--- trunk/Packages/Common/Error.php	(revision 61)
+++ trunk/Packages/Common/Error.php	(revision 61)
@@ -0,0 +1,116 @@
+<?php
+
+class ErrorHandler
+{
+  var $Encoding;
+  var $ShowError;
+  var $UserErrors;
+  var $OnError;
+
+  function __construct()
+  {
+    $this->Encoding = 'utf-8';
+    $this->ShowError = false;
+    $this->UserErrors = E_ALL;  //E_ERROR | E_WARNING | E_PARSE;
+    $this->OnError = array(array($this, 'ShowDefaultError'));
+  }
+
+  function Start()
+  {
+    set_error_handler(array($this, 'ErrorHandler'));
+    set_exception_handler(array($this, 'ExceptionHandler'));
+  }
+
+  function Stop()
+  {
+    restore_error_handler();
+    restore_exception_handler();
+  }
+
+  function ErrorHandler($Number, $Message, $FileName, $LineNumber, $Variables)
+  {
+    $ErrorType = array
+    (
+      1 => 'Error',
+      2 => 'Warning',
+      4 => 'Parsing Error',
+      8 => 'Notice',
+      16 => 'Core Error',
+      32 => 'Core Warning',
+      64 => 'Compile Error',
+      128 => 'Compile Warning',
+      256 => 'User Error',
+      512 => 'User Warning',
+      1024 => 'User Notice'
+    );
+
+    if(($this->UserErrors & $Number))
+    {
+      // Error was suppressed with the @-operator
+      if(0 === error_reporting())
+      {
+        return false;
+      }
+      $Backtrace = debug_backtrace();
+      $Backtrace[0]['function'] = $Message;
+      $Backtrace[0]['args'] = '';
+      $Backtrace[0]['file'] = $FileName;
+      $Backtrace[0]['line'] = $LineNumber;
+      $this->Report($Backtrace);
+      //if((E_ERROR | E_PARSE) & $Number)
+      die();
+    }
+  }
+
+  function ExceptionHandler(Exception $Exception)
+  {
+    $Backtrace = $Exception->getTrace();
+    array_unshift($Backtrace, array(
+      'function' => $Exception->getMessage(),
+      'file' => $Exception->getFile(),
+      'line' => $Exception->getLine(),
+    ));
+    $this->Report($Backtrace);
+    die();
+  }
+  
+  function ShowDefaultError($Message)
+  {
+    $Output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".
+      '<meta http-equiv="Content-Language" content="en">'."\n".
+      '<meta http-equiv="Content-Type" content="text/html; charset='.$this->Encoding.'"></head><body>'."\n".
+      'An internal error occurred!<br/>'.
+      'Administrator will be notified and the problem will be investigated and fixed soon.'.'<br/><br/>';
+    if($this->ShowError == true)
+      $Output .= '<pre>'.$Message.'</pre><br/>';
+    $Output .= '</body></html>';
+    echo($Output);
+  }
+
+  function Report($Backtrace)
+  {
+    $Date = date('Y-m-d H:i:s');
+    $Error = '# '.$Date."\n";
+    foreach($Backtrace as $Item)
+    {
+      if(!array_key_exists('line', $Item)) $Item['line'] = '';
+      if(!array_key_exists('file', $Item)) $Item['file'] = '';
+
+      $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
+      $Arguments = '';
+      if(array_key_exists('args', $Item) and is_array($Item['args']))
+        foreach($Item['args'] as $Item)
+        {
+          if(is_object($Item)) ;
+          else if(is_array($Item)) $Arguments .= "'".serialize($Item)."',";
+          else $Arguments .= "'".$Item."',";
+        }
+        if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';
+        $Error .= "\n";
+    }
+    $Error .= "\n";
+
+    foreach($this->OnError as $OnError)
+      $OnError[0]->$OnError[1]($Error);
+  }
+}
Index: trunk/Packages/Common/Package.php
===================================================================
--- trunk/Packages/Common/Package.php	(revision 60)
+++ 	(revision )
@@ -1,15 +1,0 @@
-<?php
-
-$Package = array(
-  'Name' => 'Common',
-  'Version' => 1,
-);
-
-include_once(dirname(__FILE__).'/PrefixMultiplier.php');
-include_once(dirname(__FILE__).'/Database.php');
-include_once(dirname(__FILE__).'/Image.php');
-include_once(dirname(__FILE__).'/Mail.php');
-include_once(dirname(__FILE__).'/UTF8.php');
-include_once(dirname(__FILE__).'/NetworkAddress.php');
-include_once(dirname(__FILE__).'/VarDumper.php');
-include_once(dirname(__FILE__).'/RSS.php');
Index: trunk/Packages/Common/RSS.php
===================================================================
--- trunk/Packages/Common/RSS.php	(revision 60)
+++ trunk/Packages/Common/RSS.php	(revision 61)
@@ -1,5 +1,5 @@
 <?php
 
-class RSS
+class RSS 
 {
   var $Charset;
@@ -9,5 +9,5 @@
   var $WebmasterEmail;
   var $Items;
-
+  
   function __construct()
   {
Index: trunk/code.php
===================================================================
--- trunk/code.php	(revision 60)
+++ 	(revision )
@@ -1,560 +1,0 @@
-<?php
-/*
-  ISO8859-2 <-> UTF-8 conversion functions designed for use in PHP-GTK apps
-  Adam Rambousek - rambousek@volny.cz
-
-  version history:
-  1.03 --- 12/02/2002
-   * added Win1257 support
-  1.02 --- 30/11/2001
-   * added ISO8859-1 support
-  1.01
-   * added Win1250 support
-  1.00
-
-  string to_utf8(string string [, string charset])
-  string from_utf8(string string [, string charset])
-
-  supported charsets: name of charset you must use in script
-  ISO8859-2: iso2   (this is the default charset, you don't have to specify it)
-  Windows1250: win1250
-  ISO8859-1: iso1
-  Windows1257: win1257
-  
-  example:  $new_string=to_utf8($some_string,"win1250");
-*/
-
-
-/*
-  translation table - actually, it's array where key is hexadecimal number of
-  character in ISO8859-2/Windows1250 and value is its two byte representation in UTF-8 
-*/
-
-$iso2_utf8 = array(
-	0x80=>"\xc2\x80",
-	0x81=>"\xc2\x81",
-	0x82=>"\xc2\x82",
-	0x83=>"\xc2\x83",
-	0x84=>"\xc2\x84",
-	0x85=>"\xc2\x85",
-	0x86=>"\xc2\x86",
-	0x87=>"\xc2\x87",
-	0x88=>"\xc2\x88",
-	0x89=>"\xc2\x89",
-	0x8A=>"\xc2\x8a",
-	0x8B=>"\xc2\x8b",
-	0x8C=>"\xc2\x8c",
-	0x8D=>"\xc2\x8d",
-	0x8E=>"\xc2\x8e",
-	0x8F=>"\xc2\x8f",
-	0x90=>"\xc2\x90",
-	0x91=>"\xc2\x91",
-	0x92=>"\xc2\x92",
-	0x93=>"\xc2\x93",
-	0x94=>"\xc2\x94",
-	0x95=>"\xc2\x95",
-	0x96=>"\xc2\x96",
-	0x97=>"\xc2\x97",
-	0x98=>"\xc2\x98",
-	0x99=>"\xc2\x99",
-	0x9A=>"\xc2\x9a",
-	0x9B=>"\xc2\x9b",
-	0x9C=>"\xc2\x9c",
-	0x9D=>"\xc2\x9d",
-	0x9E=>"\xc2\x9e",
-	0x9F=>"\xc2\x9f",
-	0xA0=>"\xc2\xa0",
-	0xA1=>"\xc4\x84",
-	0xA2=>"\xcb\x98",
-	0xA3=>"\xc5\x81",
-	0xA4=>"\xc2\xa4",
-	0xA5=>"\xc4\xbd",
-	0xA6=>"\xc5\x9a",
-	0xA7=>"\xc2\xa7",
-	0xA8=>"\xc2\xa8",
-	0xA9=>"\xc5\xa0",
-	0xAA=>"\xc5\x9e",
-	0xAB=>"\xc5\xa4",
-	0xAC=>"\xc5\xb9",
-	0xAD=>"\xc2\xad",
-	0xAE=>"\xc5\xbd",
-	0xAF=>"\xc5\xbb",
-	0xB0=>"\xc2\xb0",
-	0xB1=>"\xc4\x85",
-	0xB2=>"\xcb\x9b",
-	0xB3=>"\xc5\x82",
-	0x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\xc3\xab",
-	0xEC=>"\xc4\x9b",
-	0xED=>"\xc3\xad",
-	0xEE=>"\xc3\xae",
-	0xEF=>"\xc4\x8f",
-	0xF0=>"\xc4\x91",
-	0xF1=>"\xc5\x84",
-	0xF2=>"\xc5\x88",
-	0xF3=>"\xc3\xb3",
-	0xF4=>"\xc3\xb4",
-	0xF5=>"\xc5\x91",
-	0xF6=>"\xc3\xb6",
-	0xF7=>"\xc3\xb7",
-	0xF8=>"\xc5\x99",
-	0xF9=>"\xc5\xaf",
-	0xFA=>"\xc3\xba",
-	0xFB=>"\xc5\xb1",
-	0xFC=>"\xc3\xbc",
-	0xFD=>"\xc3\xbd",
-	0xFE=>"\xc5\xa3",
-	0xFF=>"\xcb\x99"
-);
-
-$win1250_utf8 = array(
-	0x80=>"\xc2\x80",
-	0x81=>"\xc2\x81",
-	0x82=>"\x140\x9a",
-	0x83=>"\xc2\x83",
-	0x84=>"\x140\x9e",
-	0x85=>"\x140\xa6",
-	0x86=>"\x140\xa0",
-	0x87=>"\x140\xa1",
-	0x88=>"\xc2\x88",
-	0x89=>"\x140\xb0",
-	0x8a=>"\xc5\xa0",
-	0x8b=>"\x140\xb9",
-	0x8c=>"\xc5\x9a",
-	0x8d=>"\xc5\xa4",
-	0x8e=>"\xc5\xbd",
-	0x8f=>"\xc5\xb9",
-	0x90=>"\xc2\x90",
-	0x91=>"\x140\x98",
-	0x92=>"\x140\x99",
-	0x93=>"\x140\x9c",
-	0x94=>"\x140\x9d",
-	0x95=>"\x140\xa2",
-	0x96=>"\x140\x93",
-	0x97=>"\x140\x94",
-	0x98=>"\xc2\x98",
-	0x99=>"\x144\xa2",
-	0x9a=>"\xc5\xa1",
-	0x9b=>"\x140\xba",
-	0x9c=>"\xc5\x9b",
-	0x9d=>"\xc5\xa5",
-	0x9e=>"\xc5\xbe",
-	0x9f=>"\xc5\xba",
-	0xa0=>"\xc2\xa0",
-	0xa1=>"\xcb\x87",
-	0xa2=>"\xcb\x98",
-	0xa3=>"\x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c3\xa8",
-	0xE9=>"\xc3\xa9",
-	0xEA=>"\xc3\xaa",
-	0xEB=>"\xc3\xab",
-	0xEC=>"\xc3\xac",
-	0xED=>"\xc3\xad",
-	0xEE=>"\xc3\xae",
-	0xEF=>"\xc3\xaf",
-	0xF0=>"\xc3\xb0",
-	0xF1=>"\xc3\xb1",
-	0xF2=>"\xc3\xb2",
-	0xF3=>"\xc3\xb3",
-	0xF4=>"\xc3\xb4",
-	0xF5=>"\xc3\xb5",
-	0xF6=>"\xc3\xb6",
-	0xF7=>"\xc3\xb7",
-	0xF8=>"\xc3\xb8",
-	0xF9=>"\xc3\xb9",
-	0xFA=>"\xc3\xba",
-	0xFB=>"\xc3\xbb",
-	0xFC=>"\xc3\xbc",
-	0xFD=>"\xc3\xbd",
-	0xFE=>"\xc3\xbe"
-);
-
-$win1257_utf8 = array(
-	0x80=>"\x142\xac",
-	0x81=>"\xc0\x4",
-	0x82=>"\x140\x9a",
-	0x83=>"\xc0\x4",
-	0x84=>"\x140\x9e",
-	0x85=>"\x140\xa6",
-	0x86=>"\x140\xa0",
-	0x87=>"\x140\xa1",
-	0x88=>"\xc0\x4",
-	0x89=>"\x140\xb0",
-	0x8A=>"\xc0\x4",
-	0x8B=>"\x140\xb9",
-	0x8C=>"\xc0\x4",
-	0x8D=>"\xc2\xa8",
-	0x8E=>"\xcb\x87",
-	0x8F=>"\xc2\xb8",
-	0x90=>"\xc0\x4",
-	0x91=>"\x140\x98",
-	0x92=>"\x140\x99",
-	0x93=>"\x140\x9c",
-	0x94=>"\x140\x9d",
-	0x95=>"\x140\xa2",
-	0x96=>"\x140\x93",
-	0x97=>"\x140\x94",
-	0x98=>"\xc0\x4",
-	0x99=>"\x144\xa2",
-	0x9A=>"\xc0\x4",
-	0x9B=>"\x140\xba",
-	0x9C=>"\xc0\x4",
-	0x9D=>"\xc2\xaf",
-	0x9E=>"\xcb\x9b",
-	0x9F=>"\xc0\x4",
-	0xA0=>"\xc2\xa0",
-	0xA1=>"\xc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",
-	0xD9=>"\xc5\x81",
-	0xDA=>"\xc5\x9a",
-	0xDB=>"\xc5\xaa",
-	0xDC=>"\xc3\x9c",
-	0xDD=>"\xc5\xbb",
-	0xDE=>"\xc5\xbd",
-	0xDF=>"\xc3\x9f",
-	0xE0=>"\xc4\x85",
-	0xE1=>"\xc4\xaf",
-	0xE2=>"\xc4\x81",
-	0xE3=>"\xc4\x87",
-	0xE4=>"\xc3\xa4",
-	0xE5=>"\xc3\xa5",
-	0xE6=>"\xc4\x99",
-	0xE7=>"\xc4\x93",
-	0xE8=>"\xc4\x8d",
-	0xE9=>"\xc3\xa9",
-	0xEA=>"\xc5\xba",
-	0xEB=>"\xc4\x97",
-	0xEC=>"\xc4\xa3",
-	0xED=>"\xc4\xb7",
-	0xEE=>"\xc4\xab",
-	0xEF=>"\xc4\xbc",
-	0xF0=>"\xc5\xa1",
-	0xF1=>"\xc5\x84",
-	0xF2=>"\xc5\x86",
-	0xF3=>"\xc3\xb3",
-	0xF4=>"\xc5\x8d",
-	0xF5=>"\xc3\xb5",
-	0xF6=>"\xc3\xb6",
-	0xF7=>"\xc3\xb7",
-	0xF8=>"\xc5\xb3",
-	0xF9=>"\xc5\x82",
-	0xFA=>"\xc5\x9b",
-	0xFB=>"\xc5\xab",
-	0xFC=>"\xc3\xbc",
-	0xFD=>"\xc5\xbc",
-	0xFE=>"\xc5\xbe",
-	0xFF=>"\xcb\x99"
-);
-
-/*
-  function to convert to UTF-8
-  because characters numbered 0-127 are standard ASCII characters and are same in Unicode,
-  we have to recode only higher characters
-  function pass through the string and when it finds such character, it is replaced with
-  UTF-8 two byte representation
-*/
-function to_utf8($string,$charset="iso2") {
-    eval("global \$".$charset."_utf8;");
-    eval("\$coding=\$".$charset."_utf8;");
-
-    for ($i=0;$i<strlen($string);$i++) {
-        if (ord($string[$i])>127) {
-            $string=substr($string,0,$i).$coding[ord($string[$i])].substr($string,++$i);
-        }
-    }
-    return $string;   
-}
-
-/*
-  reverse function to convert from UTF-8
-  and again it pass through the string and when the two following bytes correspond to
-  two byte combination given in translation array, these two characters are replaced with
-  one character from given coding
-    it takes the key returned by array_search() and since the key is the number of specific
-    character, we can use chr()
-*/
-function from_utf8($string,$charset="iso2") {
-    eval("global \$".$charset."_utf8;");
-    eval("\$coding=\$".$charset."_utf8;");
-
-    for ($i=0;$i<strlen($string)-1;$i++) {
-        if ($code=array_search($string[$i].$string[($i+1)],$coding))
-            $string=substr($string,0,$i).chr($code).substr($string,$i+2);
-    }
-    return $string;
-}
Index: trunk/create_groups.php
===================================================================
--- trunk/create_groups.php	(revision 60)
+++ trunk/create_groups.php	(revision 61)
@@ -1,5 +1,4 @@
 <?php
 
-include('error.php');
 include('stat_functions.php');
 include('db.php');
Index: trunk/database.php
===================================================================
--- trunk/database.php	(revision 60)
+++ 	(revision )
@@ -1,77 +1,0 @@
-<?php
-
-// Extended database class
-// Date: 2007-07-19
-
-class Database extends mysqli
-{
-  var $Prefix = '';
-
-  function query($Query)
-  {
-    //echo($Query."<br/>\n");
-    return(parent::query($Query));
-  }
-
-  function select($Table, $What = '*', $Condition = 1)
-  {
-    $Query = "SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition;
-    return($this->query($Query));  
-  }
-
-  function delete($Table, $Condition)
-  {
-    $this->query("DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition);  
-  }
-
-  function insert($Table, $Data)
-  {
-    $Name = '';
-    $Values = '';
-    foreach($Data as $Key => $Value)
-    {
-      $Value = strtr($Value, '"', '\"');
-      $Name .= ','.$Key;
-      if($Value == 'NOW()') $Values .= ",".$Value;
-        else $Values .= ",'".$Value."'";
-    }
-    $Name = substr($Name, 1);
-    $Values = substr($Values, 1);
-    $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');  
-    //echo('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
-  }
-
-  function update($Table, $Condition, $Data)
-  {
-    $Values = '';
-    foreach($Data as $Key => $Value)
-    {
-      $Value = strtr($Value, '"', '\"');
-      if($Value != 'NOW()') $Value = "'".$Value."'";
-      $Values .= ", ".$Key."=".$Value;
-    }
-    $Values = substr($Values, 2);  
-    $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
-  }
-
-  function replace($Table, $Data)
-  {
-    $Name = '';
-    $Values = '';
-    foreach($Data as $Key => $Value)
-    {
-      $Value = strtr($Value, '"', '\"');
-      $Name .= ",".$Key;
-      if($Value == 'NOW()') $Values .= ",".$Value;
-        else $Values .= ',"'.$Value.'"';
-    }
-    $Name = substr($Name, 1);
-    $Values = substr($Values, 1);
-    $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` (`'.$Name.'`) VALUES('.$values.')');
-  }
-
-  function charset($Charset)
-  {
-    $this->query('SET CHARACTER SET '.$Charset);
-  }
-}
Index: trunk/error.php
===================================================================
--- trunk/error.php	(revision 60)
+++ 	(revision )
@@ -1,65 +1,0 @@
-<?php
-
-// Obsluha chyb v1.1.1 //
-include_once('config.php');
-
-//error_reporting(0);					// Vypni interní obsluhu chyb
-
-function obsluha_chyb($errno, $errmsg, $filename, $linenum, $vars)
-{
-  global $Config;
-  
-  $dt = date("Y-m-d H:i:s");		// časové razítko položky
-  $errortype = array(
-    1 => "Error",
-    2 => "Warning",
-    4 => "Parsing Error",
-    8 => "Notice",
-    16 => "Core Error",
-    32 => "Core Warning",
-    64 => "Compile Error",
-    128 => "Compile Warning",
-    256 => "User Error",
-    512 => "User Warning",
-    1024 => "User Notice"
-  );
-  $user_errors = E_ALL;  //E_ERROR | E_WARNING | E_PARSE;
-  
-  if(($user_errors & $errno))
-  {
-    $err = '# '.$dt.' : '.$errmsg." on line ".$linenum."\n";
-    $Backtrace = debug_backtrace();
-    array_shift($Backtrace);
-    //array_shift($Backtrace);
-    //print_r($Backtrace);
-    foreach($Backtrace as $Item)
-    {
-      $err .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function'];
-      $arguments = '';
-      if(array_key_exists('args',$Item))
-      if(is_array($Item['args']))
-      foreach($Item['args'] as $Arg)
-      {
-        if(is_array($Arg)) $arguments .= "'".serialize($Arg)."',";
-        else $arguments .= "'".$Arg."',";
-      }
-      if(strlen($arguments) > 0) $err .= '('.substr($arguments,0,-1).")";
-      $err .= "\n";
-     
-    }
-    $err .= "\n";
-    //echo('Uvnitř'.$errno);
-    error_log($err, 3, $Config['Web']['ErrorLogFile']);				// Ulož do chybového protokolu
-	  //$err = "Datum: ".$dt."\nHlášení: ".$errmsg."\nSkript: ".$filename."\nŘádek: ".$linenum;
-    // mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $err);		// Pošli mi zprávu (pokud je to kritická chyba)
-	  echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".
-    '<meta http-equiv="Content-Language" content="cs">'."\n".
-    '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"></head><body>'."\n".
-    'Došlo k vnitřní chybě!<br> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br><br>');
-  	if($Config['Web']['ShowError'] == 1) echo('<pre>'.$err.'</pre><br>');			// V případě ladění chybu i zobraz
-    echo('</body></html>');
-    if((E_ERROR | E_PARSE) & $errno) die(); 
-  }// else echo($errmsg.'<br>');
-}
-
-set_error_handler('obsluha_chyb');				// Aktivuj novou obsluhu chyb
Index: trunk/global.php
===================================================================
--- trunk/global.php	(revision 60)
+++ trunk/global.php	(revision 61)
@@ -3,14 +3,16 @@
 session_start();
 $FileName = dirname(__FILE__).'/config.php';
-if(file_exists($FileName)) include($FileName);
+if(file_exists($FileName)) include_once($FileName);
 else {
   die('Configuration file "'.$FileName.'" not found.');
 }
-include_once('config.php');
 include_once('Version.php');
 include_once('types.php');
 include_once('classes.php');
-include_once('Packages/Common/Package.php');
+include_once('Packages/Common/Common.php');
 $PrefixMultiplier = new PrefixMultiplier();
+$ErrorHandler = new ErrorHandler();
+$ErrorHandler->Start();
+$ErrorHandler->ShowError = $Config['Web']['ShowError'];
 include_once('stat_functions.php');
 $Database = new Database();
@@ -55,5 +57,5 @@
 function MakeLink($Target, $Title)
 {
-  return('<a href="'.$Target.'">'.$Title.'</a>'); 
+  return('<a href="'.$Target.'">'.$Title.'</a>');
 }
 
@@ -87,5 +89,5 @@
   foreach($Class as $Index => $Item)
   {
-    if(!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default']; 
+    if(!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default'];
     switch($Item['Type'])
     {
Index: trunk/graph.php
===================================================================
--- trunk/graph.php	(revision 60)
+++ trunk/graph.php	(revision 61)
@@ -3,5 +3,5 @@
 include('global.php');
 
-if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug']; 
+if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];
   else $Debug = 0;
 
@@ -14,5 +14,5 @@
 if(!array_key_exists('Measure',$_GET)) die('Musíte zadat měřenou veličinu');
 $MeasureId = addslashes($_GET['Measure']);
-if(!array_key_exists('Width', $_GET)) $Width = $DefaultWidth; 
+if(!array_key_exists('Width', $_GET)) $Width = $DefaultWidth;
 else $Width = addslashes($_GET['Width']);
 if(!array_key_exists('Height', $_GET)) $Height = $DefaultHeight;
@@ -32,6 +32,6 @@
 $Points = GetValues($Measure, $StartTime, $EndTime, $Level);
 
-if($Debug) echo('Points count: '.count($Points).'<br>'); 
-//if($Debug) foreach($Points as $Index => $Item) 
+if($Debug) echo('Points count: '.count($Points).'<br>');
+//if($Debug) foreach($Points as $Index => $Item)
 //  echo($Index.': '.$Item['min'].'<br>');
 
@@ -55,5 +55,5 @@
 $AvgValue = $AvgValue / count($Points); //round(* $Measure['Divider']) / $Measure['Divider'];
 
-// Generate polygon and recalculate y values to fit graph height 
+// Generate polygon and recalculate y values to fit graph height
 $PointsMin = array(0, $Height-1);
 $PointsAvg = array(0, $Height-1);
@@ -97,5 +97,5 @@
 {
   Header("Content-type: image/png");
-  Header("Cache-Control: no-cache");	// Dynamic graph - no cache 
+  Header("Cache-Control: no-cache");	// Dynamic graph - no cache
   $Image = @imagecreate($Width, $Height);
   $BackgroundColor = imagecolorallocate($Image, 255, 255, 255);
@@ -122,7 +122,7 @@
   if($TimeMarksIndex < 2) $TimeMarksIndex = 2;
   $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1];
-  $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2];  
+  $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2];
 
-  $TimeShift = AlignTime($StartTime, $MajorTimeMarks) - $StartTime; 
+  $TimeShift = AlignTime($StartTime, $MajorTimeMarks) - $StartTime;
   //imagestring($Image, 10, 40, 50, $TimeShift, $Black);
 
@@ -134,7 +134,7 @@
     for($X=1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
     //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
-  } 
+  }
 
-  $TimeShift = AlignTime($StartTime, $MinorTimeMarks) - $StartTime; 
+  $TimeShift = AlignTime($StartTime, $MinorTimeMarks) - $StartTime;
 
   // Zobraz měřítko X
@@ -142,5 +142,5 @@
   for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
   {
-    $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 
+    $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width;
     //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
     if(($MajorTimeMarks > 60*60*24)) $Text = date('j.n.Y', $Time + $TimeShift);
