Changeset 3


Ignore:
Timestamp:
Jun 7, 2009, 9:41:18 AM (15 years ago)
Author:
george
Message:
  • Přidáno: Pracovní vývojová verze webových stránek.
  • Přidáno: Rozvržení pracovních složek.
Location:
trunk
Files:
19 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/www

    • Property svn:ignore set to
      config.php
  • trunk/www/index.php

    r1 r3  
    11<?php
    22
    3 Vítejte
     3include('global.php');
     4
     5class Index extends Page
     6{
     7  var $FullTitle = 'Seznam serverů';
     8  var $ShortTitle = 'Seznam serverů';
     9 
     10  function ShowServerList()
     11  {
     12    $Output = '<h4>Seznam serverů</h4>';
     13    $Output .= '<table class="WideTable"><tr><th>Název</th><th>Uživatel</th><th>Realmd</th><th>Verze hry</th></tr>';
     14    $DbResult = $this->Database->query('SELECT `ClientVersion`.`Version`, `Server`.`Name`, `Server`.`NetworkPortRealmd`, `User`.`Name` AS `UserName` FROM `Server` JOIN `User` ON `User`.`Id` = `Server`.`User` JOIN `Database` ON `Database`.`Id` = `Server`.`Database` JOIN `Emulator` ON `Emulator`.`Id` = `Database`.`Emulator` JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Emulator`.`ClientVersion`');
     15    while($Server = $DbResult->fetch_assoc())
     16    {
     17      $Output .= '<tr><td>'.$Server['Name'].'</td><td>'.$Server['UserName'].'</td><td>'.$this->System->Config['Web']['Host'].':'.$Server['NetworkPortRealmd'].'</td><td>'.$Server['Version'].'</td></tr>';
     18    }
     19    $Output .= '</table>';
     20    return($Output);
     21  }
     22 
     23  function ShowServer($Id)
     24  {
     25    $DbResult = $this->Database->query('SELECT * FROM Server WHERE Id='.$Id);
     26    $Server = $DbResult->fetch_assoc();
     27    $Output = '<h4>Podrobnosti serveru</h4>';
     28    $Output .= '<table class="WideTable"><tr><th>Položka</th><th>Hodnota</th></tr>';
     29    $Output .= '<tr><td>Jméno</td><td>'.$Server['Name'].'</td></tr>'.
     30      '<tr><td>Síťový port realmd</td><td>'.$Server['NetworkPortRealmd'].'</td></tr>'.
     31      '<tr><td>Síťový port mangosd</td><td>'.$Server['NetworkPortMangosd'].'</td></tr>'.
     32      '<tr><td>Emulátor</td><td>'.$Server['NetworkPortMangosd'].'</td></tr>'.
     33      '<tr><td>Databáze</td><td>'.$this->System->Config['Web']['Host'].':'.$Server['NetworkPortRealmd'].'</td></tr>';
     34    $Output .= '</table>';
     35    $Output .= '<br /><a hreg="'.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a><br />';
     36    return($Output);
     37  }
     38 
     39  function Show()
     40  {
     41    $Output = '';
     42    if(array_key_exists('Action', $_GET))
     43    {
     44      if($_GET['Action'] == 'LoginForm')
     45      {
     46        $Form = new Form('UserLogin');
     47        $Form->OnSubmit = '?Action=Login';
     48        $Output .= $Form->ShowEditForm();
     49        $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '.
     50                    '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
     51      } else
     52      if($_GET['Action'] == 'Login')
     53      {
     54        $Form = new Form('UserLogin');
     55        $Form->OnSubmit = '?Action=Login';
     56        $Result = $this->System->Modules['User']->Login($_POST['Username'], $_POST['Password']);
     57        $Output .= $this->SystemMessage('Přihlášení', $Result);
     58        if($Result <> USER_LOGGED_IN)
     59        {
     60          $Form->LoadValuesFromForm();
     61          $Form->Values['Password'] = '';
     62          $Output .= $Form->ShowEditForm();
     63          $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '.
     64                    '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
     65        }
     66      } else
     67      if($_GET['Action'] == 'Logout')
     68      {
     69        $Output .= $this->SystemMessage('Odhlášení', $this->System->Modules['User']->Logout());
     70      } else
     71      if($_GET['Action'] == 'UserOptions')
     72      {
     73        $UserOptions = new Form('UserOptions');
     74        $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
     75        $UserOptions->OnSubmit = '?Action=UserOptionsSave';
     76        $Output .= $UserOptions->ShowEditForm();
     77      } else
     78      if($_GET['Action'] == 'UserOptionsSave')
     79      {
     80        $UserOptions = new Form('UserOptions', array());
     81        $UserOptions->LoadValuesFromForm();
     82        $UserOptions->SaveValuesToDatabase($this->System->Modules['User']->User['Id']);
     83        $Output .= $this->SystemMessage('Nastavení', 'Nastavení uloženo.');
     84        $this->System->Modules['Log']->NewRecord('User', 'Nastavení uživatele změněno', $UserOptions->Values['Name']);
     85        $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
     86        $UserOptions->OnSubmit = '?Action=UserOptionsSave';
     87        $Output .= $UserOptions->ShowEditForm();
     88      } else
     89      if($_GET['Action'] == 'UserRegister')
     90      {
     91        $Form = new Form('UserRegister');
     92        $Form->LoadValuesFromForm();
     93        $Form->OnSubmit = '?Action=UserRegisterSave';
     94        $Output .= $Form->ShowEditForm();
     95      } else
     96      if($_GET['Action'] == 'UserRegisterConfirm')
     97      {
     98        $Output .= $this->SystemMessage('Potvrzení registrace', $this->System->Modules['User']->RegisterConfirm($_GET['User'], $_GET['H']));
     99      } else
     100      if($_GET['Action'] == 'PasswordRecovery')
     101      {
     102        $Form = new Form('PasswordRecovery');
     103        $Form->OnSubmit = '?Action=PasswordRecovery2';
     104        $Output .= $Form->ShowEditForm();
     105      } else
     106      if($_GET['Action'] == 'PasswordRecovery2')
     107      {
     108        $Form = new Form('PasswordRecovery');
     109        $Form->LoadValuesFromForm();
     110        $Result = $this->System->Modules['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
     111        $Output .= $this->SystemMessage('Obnova hesla', $Result);
     112        if($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
     113        {
     114          $Output .= $Form->ShowEditForm();
     115        }       
     116      } else
     117      if($_GET['Action'] == 'PasswordRecoveryConfirm')
     118      {
     119        $Output .= $this->SystemMessage('Obnova hesla', $this->System->Modules['User']->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));
     120      } else
     121      if($_GET['Action'] == 'UserRegisterSave')
     122      {
     123        $Form = new Form('UserRegister', array());
     124        $Form->LoadValuesFromForm();
     125        $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name'], $Form->Values['PhoneNumber'], $Form->Values['ICQ']);
     126        $Output .= $this->SystemMessage('Registrace nového účtu', $Result);
     127        if($Result <> USER_REGISTRATED)
     128        {
     129          $Form->OnSubmit = '?Action=UserRegisterSave';
     130          $Output .= $Form->ShowEditForm();
     131        }
     132      } else
     133      if($_GET['Action'] == 'MemberOptions')
     134      {
     135        $UserOptions = new Form('MemberOptions');
     136        $DbResult = $this->Database->query('SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Modules['User']->User['Member']);
     137        $DbRow = $DbResult->fetch_array();
     138        foreach($UserOptions->Definition['Items'] as $Index => $Item)
     139        {
     140          $UserOptions->Values[$Index] = $DbRow[$Index];
     141        }
     142        $UserOptions->OnSubmit = '?Action=MemberOptionsSave';
     143        $Output .= $UserOptions->ShowEditForm();
     144      } else
     145      if($_GET['Action'] == 'MemberOptionsSave')
     146      {
     147        $UserOptions = new Form('MemberOptions');
     148        $UserOptions->LoadValuesFromForm();
     149        if($UserOptions->Values['FamilyMemberCount'] < 0)
     150          $UserOptions->Values['FamilyMemberCount'] = 0;
     151        if($UserOptions->Values['BillingPeriodNext'] < 2)
     152          $UserOptions->Values['BillingPeriodNext'] = 2;
     153         
     154        $DbResult = $this->Database->update('Member', 'Id='.$this->System->Modules['User']->User['Member'], array('InternetTariffNextMonth' => $UserOptions->Values['InternetTariffNextMonth'], 'FamilyMemberCount' => $UserOptions->Values['FamilyMemberCount'], 'BillingPeriodNext' => $UserOptions->Values['BillingPeriodNext']));
     155        $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$this->System->Modules['User']->User['Member']);
     156        $Member = $DbResult->fetch_assoc();
     157        $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'], array('Name' => $UserOptions->Values['Name'], 'AddressStreet' => $UserOptions->Values['AddressStreet'], 'AddressTown' => $UserOptions->Values['AddressTown'], 'AddressPSC' => $UserOptions->Values['AddressPSC'], 'IC' => $UserOptions->Values['IC'], 'DIC' => $UserOptions->Values['DIC']));
     158        $Output .= $this->SystemMessage('Nastavení', 'Nastavení domácnosti uloženo.');
     159        $this->System->Modules['Log']->NewRecord('Member+Subject', 'Nastavení člena/subjektu změněno', $UserOptions->Values['Name']);
     160        $DbResult = $this->Database->query('SELECT Member.Id, Member.InternetTariffNextMonth, Member.FamilyMemberCount, Member.BillingPeriodNext, Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, Subject.IC, Subject.DIC FROM Member JOIN Subject ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->Modules['User']->User['Member']);
     161        $DbRow = $DbResult->fetch_array();
     162        foreach($UserOptions->Definition['Items'] as $Index => $Item)
     163        {
     164          $UserOptions->Values[$Index] = $DbRow[$Index];
     165        }
     166        $UserOptions->OnSubmit = '?Action=MemberOptionsSave';
     167        $Output .= $UserOptions->ShowEditForm();
     168      } else
     169      if($_GET['Action'] == 'NewServer')
     170      {
     171        $Form = new Form('Server');
     172        $Form->LoadValuesFromForm();
     173        $Form->OnSubmit = '?Action=ServerSave';
     174        $Output .= $Form->ShowEditForm();
     175      } else
     176      if($_GET['Action'] == 'NewServerSave')
     177      {
     178        $UserOptions = new Form('Server', array());
     179        $UserOptions->LoadValuesFromForm();
     180        $Output .= $this->SystemMessage('Nový server', 'Server vytvořen.');
     181        $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
     182        $UserOptions->OnSubmit = '?Action=ServerSave';
     183        $Output .= $UserOptions->ShowEditForm();
     184      } else
     185      if($_GET['Action'] == 'Test')
     186      {
     187        //$Server = new Server($this->Database, 1);
     188        //$Output .= $Server->ImportDatabase();
     189        $Config = new MangosConfigurationFile($this->Database);
     190        $Config->Load('../emu/mangos/7681/etc/mangosd.conf');
     191        $Config->Save('../server/1/etc/mangosd.conf');
     192      } else
     193      {
     194        $Output = $this->ShowServerList();
     195        $Output .= '<br /><a href="?Action=NewServer">Nový server</a>';     
     196      }
     197    } else
     198    {
     199      $Output = $this->ShowServerList();
     200      $Output .= '<br /><a href="?Action=NewServer">Nový server</a>';     
     201    }
     202    return($Output);
     203  }
     204}
     205
     206$System->AddModule(new Index());
     207$System->Modules['Index']->GetOutput();
    4208
    5209?>
Note: See TracChangeset for help on using the changeset viewer.