Changeset 42


Ignore:
Timestamp:
Nov 24, 2009, 9:13:38 AM (14 years ago)
Author:
george
Message:
  • Upraveno: Přepracován základový webový systém
Location:
trunk
Files:
20 added
18 deleted
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Model/User.php

    r40 r42  
    77  var $DefaultRole = 2;
    88  var $OnlineStateTimeout = 600; // in seconds
     9  var $AnonymousUserId = 1;
    910
    1011  var $Roles = array('Unknown', 'Anonymous', 'User', 'Administrator');
     
    2425    {
    2526      $this->System->Modules['User']->Data['Id'] = $DbRow['User'];
    26       if($DbRow['User'] != $this->Config['Web']['UserAnonymousId']) $this->System->Modules['Log']->NewRecord('User', 'Logout');
     27      if($DbRow['User'] != $this->AnonymousUserId) $this->System->Modules['Log']->NewRecord('User', 'Logout');
    2728      $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']);
    2829    }
     
    3132    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    3233    if($Query->num_rows == 0)
    33       $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->Config['Web']['UserAnonymousId'], 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress()), 'ScriptName' => $_SERVER['PHP_SELF']));
     34      $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress()), 'ScriptName' => $_SERVER['PHP_SELF']));
    3435    //echo($this->Database->LastQuery);
    3536
     
    3738    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    3839    $Row = $Query->fetch_assoc();
    39     if($Row['User'] != $this->Config['Web']['UserAnonymousId'])
     40    if($Row['User'] != $this->AnonymousUserId)
    4041    {
    4142      $Query = $this->Database->select('User', '*', 'Id='.$Row['User']);
     
    4445    } else
    4546    {
    46       $Query = $this->Database->select('User', '*', 'Id='.$this->Config['Web']['UserAnonymousId']);
     47      $Query = $this->Database->select('User', '*', 'Id='.$this->AnonymousUserId);
    4748      $this->Data = $Query->fetch_assoc();
    4849      $Result = $this->System->Translate('UserNotLogged');
     
    8384           
    8485            $Subject = FromUTF8('Registrace nového účtu', 'iso2');
    85             $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder']."/</a>.<br>\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br><br>\n\nVáš účet je: ".$Login."\n<br>Pro dokončení registrace klikněte na tento odkaz: ".'<a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte.";
    86             $AdditionalHeaders = "To: ".$Name." <".$Email.">\n"."From: ".FromUTF8($Config['Web']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8";
     86            $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/">http://'.$Config['System']['Host'].$Config['System']['RootFolder']."/</a>.<br>\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br><br>\n\nVáš účet je: ".$Login."\n<br>Pro dokončení registrace klikněte na tento odkaz: ".'<a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'">http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte.";
     87            $AdditionalHeaders = "To: ".$Name." <".$Email.">\n"."From: ".FromUTF8($Config['System']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8";
    8788            mail($Email, $Subject, $Message, $AdditionalHeaders);
    8889            $Result = $this->System->Translate('UserRegistrated');
     
    136137  {
    137138    $SID = session_id();
    138     $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $this->Config['Web']['UserAnonymousId']));
     139    $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $this->AnonymousUserId));
    139140    $this->System->Modules['Log']->NewRecord('User', 'Logout', $this->Data['Login']);
    140141    $this->Check();
     
    221222
    222223      $Subject = 'Obnova hesla';
    223       $Message = 'Požádali jste o zaslání nového hesla na serveru <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder']."</a>.<br />\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br /><br />\n\nVaše nové heslo k účtu ".$Row['Login']." je: ".$NewPassword."\n<br>Pro aktivaci tohoto hesla klikněte na ".'<a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=PasswordRecoveryConfirm&User='.$Row['Id'].'&H='.$Row['Password'].'&P='.$NewPassword.'">tento odkaz</a>.'."\n<br /> Po přihlášení si prosím změňte heslo na nové.\n\n<br><br>Na tento email neodpovídejte.";
    224       $AdditionalHeaders = "To: ".$Row['Name']." <".$Row['Email'].">\n"."From: ".FromUTF8($Config['Web']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8";
     224      $Message = 'Požádali jste o zaslání nového hesla na serveru <a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'">http://'.$Config['System']['Host'].$Config['System']['RootFolder']."</a>.<br />\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br /><br />\n\nVaše nové heslo k účtu ".$Row['Login']." je: ".$NewPassword."\n<br>Pro aktivaci tohoto hesla klikněte na ".'<a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/?Action=PasswordRecoveryConfirm&User='.$Row['Id'].'&H='.$Row['Password'].'&P='.$NewPassword.'">tento odkaz</a>.'."\n<br /> Po přihlášení si prosím změňte heslo na nové.\n\n<br><br>Na tento email neodpovídejte.";
     225      $AdditionalHeaders = "To: ".$Row['Name']." <".$Row['Email'].">\n"."From: ".FromUTF8($Config['System']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8";
    225226      mail($Row['Email'], $Subject, $Message, $AdditionalHeaders);
    226227      $Output = $this->System->Translate('UserPasswordRecoverySuccess');
  • trunk/Application/View/User.php

    r40 r42  
    5757    $Output = $Form->ShowEditForm();
    5858    $Output .= '<div class="Centred">';
    59     if($Config['Web']['UserRegistrationEnabled'])
     59    if($Config['System']['UserRegistrationEnabled'])
    6060      $Output .= '<a href="?Module=User&amp;Action=Register">Registrovat se</a> ';
    6161    $Output .= '<a href="?Module=User&amp;Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
     
    8585    global $Config;
    8686   
    87     if($Config['Web']['UserRegistrationEnabled'])
     87    if($Config['System']['UserRegistrationEnabled'])
    8888    {
    8989      $Form = new Form($this->System, $this->RegisterFormClass, array());
     
    166166    global $Config;
    167167   
    168     if($Config['Web']['UserRegistrationEnabled'])
     168    if($Config['System']['UserRegistrationEnabled'])
    169169    {
    170170      $Form = new Form($this->System, $this->RegisterFormClass);
     
    181181    global $Config;
    182182   
    183     if($Config['Web']['UserRegistrationEnabled'])
     183    if($Config['System']['UserRegistrationEnabled'])
    184184    {
    185185      $Page = new PageView($this->System);
  • trunk/Base/Controller.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Module.php');
    24
    35class Controller extends Module
    46{
     7  function OnAccessDenied($Action, $Id)
     8  {
     9    return($this->System->Output->SystemMessage('Nemáte oprávnění provést akci "'.$Action.'" modulu "'.substr(get_class($this), 0, -10).'" na položce "'.$Id.'"'));
     10  }
     11 
     12  function Process()
     13  {
     14    if(array_key_exists('A', $_GET)) $Action = $_GET['A'];
     15      else $Action = 'Show';
     16    if(method_exists($this, $Action))
     17    {
     18      if(array_key_exists('Id', $_GET)) $Id = $_GET['Id'];
     19        else $Id = '';
     20      if($this->System->Modules['Permission']->Check(substr(get_class($this), 0, -10), $Action, $Id))
     21        return($this->$Action());
     22        else return($this->OnAccessDenied($Action, $Id));
     23    } else return($this->System->Output->SystemMessage('Metoda "'.$Action.'" modulu "'.get_class($this).'" nenalezena.'));
     24  }
     25
     26  function RequireParameter($Name)
     27  {
     28    //if(!array_key_exists($Name, $_GET)) return($this->System->SystemMessage('Přístup zamítnut.');
     29  }
    530}
    631
  • trunk/Base/Database.php

    r40 r42  
    44// Date: 2009-02-16
    55
    6 
    76class Database extends mysqli
    87{
    98  var $Prefix = '';
    109  var $Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()');
     10  var $ShowSQLQuery = false;
     11  var $ShowSQLError = false;
    1112 
    1213  function query($Query)
    13   {
    14     global $Config;
    15  
    16     if($Config['Web']['ShowSQLQuery'] == true)
     14  { 
     15    if($this->ShowSQLQuery)
    1716    {
    1817      if(isset($_SERVER['REMOTE_ADDR'])) echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>');
     
    2019    }
    2120    $Result = parent::query($Query);
    22     if(($this->error != '') and ($Config['Web']['ShowSQLError'] == true))
     21    if(($this->error != '') and ($this->ShowSQLError))
    2322    {
    2423      if(isset($_SERVER['REMOTE_ADDR'])) echo('<div><strong>SQL Error: </strong>'.$this->error.'<br />'.$Query.'</div>');
     
    8786    $this->query('SET NAMES "'.$Charset.'"');
    8887  }
    89  
     88
    9089  function TimeToMysqlDateTime($Time)
    9190  {
    92     return(date('Y-m-d H:i:s', $Time)); 
     91    return(date('Y-m-d H:i:s', $Time));
    9392  }
    9493
     
    9695  {
    9796    $Parts = explode(' ', $Time);
    98     $DateParts = explode('-', $Parts[0]); 
     97    $DateParts = explode('-', $Parts[0]);
    9998    $TimeParts = explode(':', $Parts[1]);
    100     $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 
    101     return($Result); 
     99    $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
     100    return($Result);
    102101  }
    103102
    104103  function MysqlDateToTime($Time)
    105104  {
    106     return(MysqlDateTimeToTime($Time.' 0:0:0')); 
    107   } 
     105    return(MysqlDateTimeToTime($Time.' 0:0:0'));
     106  }
    108107}
    109108
  • trunk/Base/Error.php

    r40 r42  
    55  global $Config;
    66 
    7   $Date = date('Y-m-d H:i:s');          // časové razítko položky
     7  $Date = date('Y-m-d H:i:s');    // časové razítko položky
    88  $ErrorType = array
    99  (
     
    5353    //if($Config['Web']['ErrorLogFile'] != '')
    5454      //error_log($Error, 3, $Config['Web']['ErrorLogFile']);
    55           // Pošli mi zprávu (pokud je to kritická chyba)
     55    // Pošli mi zprávu (pokud je to kritická chyba)
    5656      //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error);
    57           // Show error message
    58           if($Config['Web']['ShowPHPError'] == true)
    59           {
    60             echo('<?xml version="1.0" encoding="utf-8"?>'."\n".
     57    // Show error message
     58    if($Config['System']['ShowPHPError'] == true)
     59    {
     60      echo('<?xml version="1.0" encoding="utf-8"?>'."\n".
    6161      '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
    6262      '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'.
     
    6565      '</head><body>'.   
    6666      'Došlo k vnitřní chybě!<br /> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br /><br />');
    67           echo('<pre>'.$Error.'</pre><br />');                  // V případě ladění chybu i zobraz
     67      echo('<pre>'.$Error.'</pre><br />');      // V případě ladění chybu i zobraz
    6868      echo('</body></html>');
    69           }
     69    }
    7070    if((E_ERROR | E_PARSE) & $Number) die();
    7171  }
  • trunk/Base/Model.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Module.php');
    24
    35class Model extends Module
  • trunk/Base/System.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Database.php');
     4include_once(dirname(__FILE__).'/HTML/XHTML.php');
     5include_once(dirname(__FILE__).'/HTML/HTML.php');
     6include_once(dirname(__FILE__).'/HTTP.php');
     7include_once(dirname(__FILE__).'/Types/Type.php');
     8include_once(dirname(__FILE__).'/Output.php');
     9include_once(dirname(__FILE__).'/Permission.php');
     10
     11$MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
    212
    313$PrefixMultipliers = array
     
    7686class System
    7787{
    78   var $Modules = array();
     88  var $Model = array();
     89  var $View = array();
     90  var $Controller = array();
     91  var $Config;
    7992  var $Database;
    80   var $Config;
     93  var $HTTP;
     94  var $HTML;
     95  var $Type;
     96  var $TimeStart;
     97  var $Translation;
     98  var $Output;
     99  var $DefaultModule;
     100  var $Modules = array();
     101
     102  function __construct()
     103  {
     104    global $ShowPHPError;
     105
     106    $TimeStart = $this->GetMicrotime();
     107   
     108    // Change base dir to index. Helpfull if script is executed from command line with related path.
     109    chdir(dirname(__FILE__));
     110
     111    $this->Output = new Output($this);
     112
     113    $FileName = dirname(__FILE__).'/Config/Config.php';
     114    if(file_exists($FileName)) include($FileName);
     115      else {
     116        $this->Output->Show($this->Output->SystemMessage('Configuration file "'.$FileName.'" not found.'));
     117        exit;
     118      }
     119
     120    $FileName = dirname(__FILE__).'/../Application/Config/Config.php';
     121    if(file_exists($FileName)) include($FileName);
     122   
     123    $this->Config = $Config;
     124   
     125    $ShowPHPError = $this->Config['System']['ShowPHPError'];
     126
     127    $FileName = dirname(__FILE__).'/../Application/Locale/'.$this->Config['System']['Locale'].'.php';
     128    if(file_exists($FileName)) include($FileName);
     129      else {
     130        $this->Output->Show($this->Output->SystemMessage('Translation file "'.$FileName.'" not found.'));
     131        exit;
     132      }
     133    $this->Translation = $Translation;
     134
     135    if(isset($_SERVER['REMOTE_ADDR'])) session_start();
     136    $this->Database = new Database($this->Config['Database']['Host'],
     137    $this->Config['Database']['User'], $this->Config['Database']['Password'],
     138    $this->Config['Database']['Database']);
     139    $this->Database->ShowSQLQuery = $this->Config['System']['ShowSQLQuery'];
     140    $this->Database->ShowSQLError = $this->Config['System']['ShowSQLError'];
     141    $this->Database->Prefix = $this->Config['Database']['Prefix'];
     142    $this->Database->charset($this->Config['Database']['Charset']);
     143     
     144    $this->HTTP = new HTTP();
     145    $this->HTML = new HTML($this);
     146    $this->Type = new Type($this);
     147    $this->AddModule('Permission');
     148  }
     149
     150  function Run()
     151  {
     152    $this->TimeStart = $this->GetMicrotime();
     153   
     154    // SQL injection hack protection
     155    foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
     156    foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
     157
     158    if(array_key_exists('M', $_GET)) $Module = $_GET['M'];
     159      else $Module = $this->DefaultModule;
     160
     161    $ControllerName = $Module.'Controller';
     162    $FileName = dirname(__FILE__).'/../Application/Controller/'.$Module.'.php';
     163    if(!file_exists($FileName))
     164    {
     165      $this->Output->Show($this->Output->SystemMessage('Soubor '.$FileName.' nenalezen.'));
     166      exit;
     167    } else include($FileName);
     168    if(class_exists($ControllerName))
     169    {
     170      $Controller = new $ControllerName($this);
     171      $this->Output->Show($Controller->Process());
     172    } else $this->Output->Show($this->Output->SystemMessage('Modul "'.$ControllerName.'" nenalezen.'));
     173  }
    81174
    82175  function ModulePresent($Name)
     
    85178  }
    86179
    87   function AddModule($Module)
    88   {
    89     global $Database;
    90 
    91     //echo('Přidávám modul '.get_class($Module).'<br />');
    92     $this->Modules[get_class($Module)] = $Module;
    93   }
    94  
    95   function AddEmailToQueue($Address, $Subject, $Content, $Headers = '')
    96   {
    97     $this->Database->insert('EmailQueue', array('Address' => $Address, 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 'Headers' => $Headers));
    98   }
    99  
    100   function MailUTF8($To, $Subject = '(No subject)', $Message = '', $Header = '')
    101   {
    102     $Header = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n".$Header;
    103     mail($To, '=?UTF-8?B?'.base64_encode($Subject).'?=', $Message, $Header);
    104     //echo('mail('.$To.', =?UTF-8?B?'.base64_encode($Subject).'?=, '.$Message.', '.$Header.')<br/>');
    105   }
    106 
    107   function ProcessEmailQueue()
    108   {
    109     $Output = '';
    110     $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0');
    111     while($DbRow = $DbResult->fetch_assoc())
    112     {     
    113       $this->MailUTF8($DbRow['Address'], $DbRow['Subject'], $DbRow['Content'], $DbRow['Headers']);
    114       //echo('mail('.$DbRow['Address'].', '.$DbRow['Subject'].', '.$DbRow['Content'].', FromUTF8('.$DbRow['Headers'].', \'iso2\'));');
    115       $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1));
    116       $this->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']);
    117       $Output .= 'To: '.$DbRow['Address'].'  Subject: '.$DbRow['Subject'].'<br />';
    118     }   
    119     return($Output);
     180  function AddModule($Name)
     181  {
     182    $this->Modules[$Name] = new $Name($this);
    120183  }
    121184 
     
    172235  {
    173236    set_error_handler('ErrorHandler');
    174     if($Socket = @fsockopen($Address, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout))
     237    $Socket = @fsockopen($Address, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout);
     238    if($Socket)
    175239    {
    176240      fclose($Socket);
     
    180244    return($Result);
    181245  }
    182  
     246
     247  function Translate($Text)
     248  {
     249    if(array_key_exists($Text, $this->Translation)) return($this->Translation[$Text]);
     250      else return('#'.$Text);
     251  }
     252
     253  function MakeLink($Module, $Action, $Parameters = array())
     254  {
     255    $Parameters = $this->HTTP->SetQueryStringArray($Parameters);
     256    if($Parameters != '') $Parameters = '&amp;'.$Parameters;
     257    return('?M='.$Module.'&amp;A='.$Action.$Parameters);
     258  }
     259
     260  function GetRemoteAddress()
     261  {
     262    if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
     263    else if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
     264    else $IP = '0.0.0.0';
     265    return($IP);
     266  }
     267
    183268  function GetMicrotime()
    184269  {
    185270    list($Usec, $Sec) = explode(' ', microtime());
    186271    return((float)$Usec + (float)$Sec);
    187   } 
    188 
    189   function Translate($Text)
    190   {
    191     global $Translation;
    192 
    193     if(array_key_exists($Text, $Translation)) return($Translation[$Text]);
    194       else return('#'.$Text);
     272  }
     273
     274  function RemoveDiacritic($Text)
     275  {
     276    return(str_replace(
     277      array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'),
     278      array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'),
     279      $Text));
    195280  }
    196281}
  • trunk/Base/Types/Base.php

    r40 r42  
    11<?php
    22
    3 class TypeBase extends Module
     3class TypeBase
    44{
     5  var $System;
    56  var $DatabaseCompareOperators = array();
     7
     8  function __construct($System)
     9  {
     10    $this->System = $System;
     11  }
    612
    713  function OnView($Item)
  • trunk/Base/Types/Boolean.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeBoolean extends TypeBase
     
    810  {
    911    if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
    10     return('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'>');
     12    return('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>');
    1113  }
    1214
     
    1416  {
    1517    if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
    16     return('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'>');
     18    return('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>');
    1719  }
    1820
  • trunk/Base/Types/Date.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeDate extends TypeBase
  • trunk/Base/Types/DateTime.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeDateTime extends TypeBase
  • trunk/Base/Types/Enumeration.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeEnumeration extends TypeBase
     
    57  function OnView($Item)
    68  {
    7     $Type = GetTypeDefinition($Item['Type']);
    8     $Output = $Type['Parameters'][$Item['Value']];
     9    $Type = $this->System->Type->GetTypeDefinition($Item['Type']);
     10    if(array_key_exists($Item['Value'], $Type['Parameters']))
     11      $Output = $Type['Parameters'][$Item['Value']];
     12      else $Output = $Item['Value'];
    913    return($Output);
    1014  }
     
    1216  function OnEdit($Item)
    1317  {
    14     $Type = GetTypeDefinition($Item['Type']);
     18    $Type = $this->System->Type->GetTypeDefinition($Item['Type']);
    1519    $Output = '<select name="'.$Item['Name'].'">';
    1620    foreach($Type['Parameters'] as $Index => $StateName)
  • trunk/Base/Types/Float.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeFloat extends TypeBase
     
    1315  function OnEdit($Item)
    1416  {
    15     $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
     17    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    1618    return($Output);
    1719  }
  • trunk/Base/Types/GPS.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeGPS extends TypeBase
     
    3133    } else $DbRow = array('Longitude' => 0, 'Latitude' => 0);
    3234    $Value = $this->Explode($DbRow['Latitude']);
    33     $Output = '<input type="text" size="3" name="'.$Item['Name'].'-lat-deg" value="'.$Value[0].'">°';
    34     $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-min" value="'.$Value[1].'">\'';
    35     $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-sec" value="'.$Value[2].'">"<br />';
     35    $Output = '<input type="text" size="3" name="'.$Item['Name'].'-lat-deg" value="'.$Value[0].'"/>°';
     36    $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-min" value="'.$Value[1].'"/>\'';
     37    $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-sec" value="'.$Value[2].'"/>"<br />';
    3638    $Value = $this->Explode($DbRow['Longitude']);
    37     $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-deg" value="'.$Value[0].'">°';
    38     $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'">\'';
    39     $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'">"';
     39    $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-deg" value="'.$Value[0].'"/>°';
     40    $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'"/>\'';
     41    $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'"/>"';
    4042    return($Output);
    4143  }
  • trunk/Base/Types/Hidden.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeHidden extends TypeBase
     
    1113  function OnEdit($Item)
    1214  {
    13     $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
     15    $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />';
    1416    return($Output);
    1517  }
  • trunk/Base/Types/Hyperlink.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeHyperlink extends TypeBase
     
    1113  function OnEdit($Item)
    1214  {
    13     $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
     15    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    1416    return($Output);
    1517  }
  • trunk/Base/Types/IPv4Address.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeIPv4Address extends TypeBase
     
    1113  function OnEdit($Item)
    1214  {
    13     $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
     15    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    1416    return($Output);
    1517  }
  • trunk/Base/Types/Integer.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeInteger extends TypeBase
     
    1315  function OnEdit($Item)
    1416  {
    15     $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
     17    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    1618    return($Output);
    1719  }
  • trunk/Base/Types/Password.php

    r40 r42  
    22
    33// SHA1 hash used
     4
     5include_once(dirname(__FILE__).'/Base.php');
    46
    57class TypePassword extends TypeBase
     
    1517  function OnEdit($Item)
    1618  {
    17     $Output = '<input type="password" name="'.$Item['Name'].'" value="">';
     19    $Output = '<input type="password" name="'.$Item['Name'].'" value=""/>';
    1820    return($Output);
    1921  }
  • trunk/Base/Types/PointerOneToMany.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypePointerOneToMany extends TypeBase
  • trunk/Base/Types/PointerOneToOne.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypePointerOneToOne extends TypeBase
     
    57  function OnView($Item)
    68  {
    7     global $TypeDefinitionList;
    8 
    9     $Type = $TypeDefinitionList[$Item['Type']];
    10     $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name FROM `'.$Type['Parameters']['Table'].'` WHERE `'.$Type['Parameters']['Id'].'`='.$Item['Value']);
     9    $Type = $this->System->Type->TypeDefinitionList[$Item['Type']];
     10    $DbResult = $this->System->Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name FROM `'.$Type['Parameters']['Table'].'` WHERE `'.$Type['Parameters']['Id'].'`='.$Item['Value']);
    1111    $DbRow = $DbResult->fetch_assoc();
    12     $Output = $DbRow['Name'];
    13    
    14 /*    $Type = GetTypeDefinition($Item['Type']);
    15     $List = GetListDefinition($Type['Parameters'][0]);
    16     $TargetTable = $Type['Parameters'][0];
    17     $TargetName = $this->GetTablePointerName($Type, $Item);
    18     if($TargetName != '') $Output = '<a href="?Action=ViewItem&amp;Table='.$TargetTable.'&amp;Item='.$TargetName[$List['IdName']].'">'.$TargetName['Name'].'</a>';
    19     else $Output = '';
    20     */
     12    if($this->System->Modules['Permission']->Check('Corporation', 'Show'))
     13      $Output = $this->System->HTML->MakeLink($DbRow['Name'], $this->System->MakeLink($Type['Parameters']['Table'], 'Show', array('Id' => $Item['Value'])));
     14      else $Output = $DbRow['Name'];
    2115    return($Output);
    2216  }
     
    2418  function OnEdit($Item)
    2519  {
    26     global $TypeDefinitionList;
    27 
    2820    $Output = '<select name="'.$Item['Name'].'">';
    29     $Type = $TypeDefinitionList[$Item['Type']];
     21    $Type = $this->System->Type->TypeDefinitionList[$Item['Type']];
    3022    if(array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];
    3123      else $Where = '';
    32     $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name,'.$Type['Parameters']['Id'].' AS Id FROM `'.$Type['Parameters']['Table'].'`'.$Where.' ORDER BY Name DESC');
     24    $DbResult = $this->System->Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name,'.$Type['Parameters']['Id'].' AS Id FROM `'.$Type['Parameters']['Table'].'`'.$Where.' ORDER BY Name DESC');
    3325    while($DbRow = $DbResult->fetch_assoc())
    3426    {
  • trunk/Base/Types/String.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeString extends TypeBase
     
    1315  function OnEdit($Item)
    1416  {
    15     $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'">';
     17    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
    1618    return($Output);
    1719  }
  • trunk/Base/Types/Text.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeText extends TypeBase
  • trunk/Base/Types/Time.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Base.php');
    24
    35class TypeTime extends TypeBase
  • trunk/Base/View.php

    r40 r42  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Module.php');
    24
    35class View extends Module
  • trunk/index.php

    r40 r42  
    11<?php
    22
    3 include('Include.php');
    4 if(array_key_exists('argv', $_SERVER))
    5   $_GET = array_merge($_GET, ParseCommandLineArgs($_SERVER['argv']));
     3// Change current directory to script location
     4$BaseDir = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/'));
     5if($BaseDir != '') chdir($BaseDir);
    66
    7 // SQL injection hack protection
    8 foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
    9 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
     7include_once(dirname(__FILE__).'/Application/Application.php');
    108
    11 if(isset($_SERVER['REMOTE_ADDR'])) session_start();
    12 
    13 $System = new System();
    14 $ScriptTimeStart = $System->GetMicrotime();
    15 $System->Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
    16 $System->Database->Prefix = $Config['Database']['Prefix'];
    17 $System->Database->charset($Config['Database']['Charset']);
    18 $System->Config = $Config;
    19 $System->AddModule(new Log($System));
    20 $System->AddModule(new User($System));
    21 $System->AddModule(new Permission($System));
    22 if(isset($_SERVER['REMOTE_ADDR'])) $System->Modules['User']->Check();
    23   else $System->Modules['User']->Data['Id'] = $Config['Web']['UserConsoleId'];
    24 $System->Modules['Permission']->LoadForUser($System->Modules['User']->Data['Id']);
    25 //print_r($System->Modules['Permission']->Data);
    26 
    27 if(array_key_exists('Module', $_GET)) $Module = $_GET['Module'];
    28   else $Module = 'HomePage';
    29 if(array_key_exists('Action', $_GET)) $Action = $_GET['Action'];
    30   else $Action = 'Show';
    31 
    32 $ControllerName = $Module.'Controller';
    33 if(class_exists($ControllerName))
    34 {
    35   $Controller = new $ControllerName($System);
    36   if(method_exists($Controller, $Action)) $Output = $Controller->$Action();
    37     else $Output = 'Metoda '.$Action.' modulu '.$Module.' neexistuje.';
    38 } else $Output = 'Třída '.$ControllerName.' neexistuje.';
    39 
    40 echo($Output);
     9$Application = new Application();
     10$Application->Run();
    4111
    4212?>
Note: See TracChangeset for help on using the changeset viewer.