Changeset 69


Ignore:
Timestamp:
Aug 23, 2009, 4:31:12 PM (15 years ago)
Author:
george
Message:
  • Rozpracovaná verze.
  • Přeorganizována struktura souborů projektu.
  • Názvy přepány na stejné s prvním velkým písmenem.
  • Uživatelské podsložky přesunuty do podsložky Application, systémové do podsložky Base.
  • Použití koncepce Model-View-Controller.
Location:
trunk/www
Files:
112 added
7 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/index.php

    r68 r69  
    11<?php
    22
    3 include('include.php');
     3include('Include.php');
    44
    5 class Index extends Page
     5// SQL injection hack protection
     6foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
     7foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
     8
     9if(isset($_SERVER['REMOTE_ADDR'])) session_start();
     10
     11$System = new System();
     12$ScriptTimeStart = $System->GetMicrotime();
     13$System->Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
     14$System->Database->Prefix = $Config['Database']['Prefix'];
     15$System->Database->charset($Config['Database']['Charset']);
     16$System->Config = $Config;
     17$System->AddModule(new Log($System));
     18$System->AddModule(new User($System));
     19if(isset($_SERVER['REMOTE_ADDR'])) $System->Modules['User']->Check();
     20  else $System->Modules['User']->User['Id'] = 0;
     21
     22
     23if(array_key_exists('Module', $_GET)) $Module = $_GET['Module'];
     24  else $Module = 'HomePage';
     25if(array_key_exists('Action', $_GET)) $Action = $_GET['Action'];
     26  else $Action = 'Show';
     27
     28$ControllerName = $Module.'Controller';
     29if(class_exists($ControllerName))
    630{
    7   var $FullTitle = 'Seznam serverů';
    8   var $ShortTitle = 'Seznam serverů'; 
    9    
    10   function Show()
    11   {
    12     global $Config;
    13    
    14     $Output = '';
    15     if(array_key_exists('Action', $_GET))
    16     {
    17       if($_GET['Action'] == 'LoginForm')
    18       {
    19         $UserView = new UserView($this->Database, $this->System);
    20         $Output .= $UserView->LoginForm();
    21       } else
    22       if($_GET['Action'] == 'Login')
    23       {
    24         $UserView = new UserView($this->Database, $this->System);
    25         $Output .= $UserView->LoginResult();
    26       } else
    27       if($_GET['Action'] == 'Logout')
    28       {
    29         $UserView = new UserView($this->Database, $this->System);
    30         $Output .= $UserView->Logout();
    31       } else
    32       if($_GET['Action'] == 'UserOptions')
    33       {
    34         $UserView = new UserView($this->Database, $this->System);
    35         $Output .= $UserView->Options();
    36       } else
    37       if($_GET['Action'] == 'UserOptionsSave')
    38       {
    39         $UserView = new UserView($this->Database, $this->System);
    40         $Output .= $UserView->OptionsSave();
    41       } else
    42       if($_GET['Action'] == 'UserRegister')
    43       {
    44         $UserView = new UserView($this->Database, $this->System);
    45         $Output .= $UserView->Register();
    46       } else
    47       if($_GET['Action'] == 'UserRegisterConfirm')
    48       {
    49         $UserView = new UserView($this->Database, $this->System);
    50         $Output .= $UserView->RegisterConfirm();
    51       } else
    52       if($_GET['Action'] == 'PasswordRecovery')
    53       {
    54         $UserView = new UserView($this->Database, $this->System);
    55         $Output .= $UserView->PasswordRecovery();
    56       } else
    57       if($_GET['Action'] == 'PasswordRecoveryFinish')
    58       {
    59         $UserView = new UserView($this->Database, $this->System);
    60         $Output .= $UserView->PasswordRecoveryFinish();
    61       } else
    62       if($_GET['Action'] == 'PasswordRecoveryConfirm')
    63       {
    64         $UserView = new UserView($this->Database, $this->System);
    65         $Output .= $UserView->PasswordRecoveryConfirm();
    66       } else
    67       if($_GET['Action'] == 'UserRegisterSave')
    68       {
    69         $UserView = new UserView($this->Database, $this->System);
    70         $Output .= $UserView->RegisterSave();
    71       } else
    72       if($_GET['Action'] == 'ServerAdd')
    73       {
    74         $ServerView = new ServerView($this->Database, $this->System);
    75         $Output .= $ServerView->Add();
    76       } else
    77       if($_GET['Action'] == 'ServerCreate')
    78       {
    79         $ServerView = new ServerView($this->Database, $this->System);
    80         $Output .= $ServerView->Create();
    81       } else
    82       if($_GET['Action'] == 'ServerShow')
    83       {
    84         $ServerView = new ServerView($this->Database, $this->System);
    85         $Output .= $ServerView->Item();
    86         //if(array_key_exists('Id', $_GET)) $Output .= $this->ShowServer($_GET['Id']);
    87         //else $this->SystemMessage('Zobrazení serveru', 'Nebylo zadáno Id');
    88       } else
    89       if($_GET['Action'] == 'ServerEdit')
    90       {
    91         $ServerView = new ServerView($this->Database, $this->System);
    92         $Output .= $ServerView->Edit();
    93       } else
    94       if($_GET['Action'] == 'ServerSave')
    95       {
    96         $ServerView = new ServerView($this->Database, $this->System);
    97         $Output .= $ServerView->Save();
    98       } else
    99       if($_GET['Action'] == 'ServerStart')
    100       {
    101         $ServerView = new ServerView($this->Database, $this->System);
    102         $Output .= $ServerView->Start();
    103       } else
    104       if($_GET['Action'] == 'ServerStop')
    105       {
    106         $ServerView = new ServerView($this->Database, $this->System);
    107         $Output .= $ServerView->Stop();
    108       } else
    109       if($_GET['Action'] == 'ServerDatabaseImport')
    110       {
    111         $DatabaseView = new DatabaseView($this->Database, $this->System);
    112         $Output .= $DatabaseView->Import();
    113       } else
    114       if($_GET['Action'] == 'EmulatorShow')
    115       {
    116         $EmulatorView = new EmulatorView($this->Database, $this->System);
    117         $Output .= $EmulatorView->Item();
    118       } else
    119       if($_GET['Action'] == 'EmulatorList')
    120       {
    121         $EmulatorView = new EmulatorView($this->Database, $this->System);
    122         $Output .= $EmulatorView->ItemList();
    123       } else
    124       if($_GET['Action'] == 'EmulatorCompile')
    125       {
    126         $EmulatorView = new EmulatorView($this->Database, $this->System);
    127         $Output .= $EmulatorView->Compile();
    128       } else
    129       if($_GET['Action'] == 'EmulatorDownload')
    130       {
    131         $EmulatorView = new EmulatorView($this->Database, $this->System);
    132         $Output .= $EmulatorView->Download();
    133       } else
    134       if($_GET['Action'] == 'EmulatorAdd')
    135       {
    136         $EmulatorView = new EmulatorView($this->Database, $this->System);
    137         $Output .= $EmulatorView->Add();
    138       } else
    139       if($_GET['Action'] == 'EmulatorAdd2')
    140       {
    141         $EmulatorView = new EmulatorView($this->Database, $this->System);
    142         $Output .= $EmulatorView->AddFinish();
    143       } else     
    144       if($_GET['Action'] == 'ClientList')
    145       {
    146         $ClientView = new ClientView($this->Database, $this->System);
    147         $Output .= $ClientView->ItemList();
    148       } else     
    149       if($_GET['Action'] == 'BackupList')
    150       {
    151         $BackupView = new BackupView($this->Database, $this->System);
    152         $Output .= $BackupView->ItemList();
    153       } else     
    154       if($_GET['Action'] == 'DebugView')
    155       {
    156         $DebugView = new DebugView($this->Database, $this->System);
    157         $Output .= $DebugView->Item();
    158       } else     
    159       if($_GET['Action'] == 'DebugList')
    160       {
    161         $DebugView = new DebugView($this->Database, $this->System);
    162         $Output .= $DebugView->ItemList();
    163       } else     
    164       if($_GET['Action'] == 'UpdateList')
    165       {
    166         $UpdateView = new UpdateView($this->Database, $this->System);
    167         $Output .= $UpdateView->ItemList();
    168       } else     
    169       if($_GET['Action'] == 'GameAccountRegister')
    170       {
    171         $ServerView = new ServerView($this->Database, $this->System);
    172         $Output .= $ServerView->AccountCreate();
    173       } else
    174       if($_GET['Action'] == 'GameAccountRegister2')
    175       {
    176         $ServerView = new ServerView($this->Database, $this->System);
    177         $Output .= $ServerView->AccountCreateFinish();
    178       } else     
    179       if($_GET['Action'] == 'Info')
    180       {
    181         $BaseView = new BaseView($this->Database, $this->System);
    182         $Output .= $BaseView->Info();
    183       } else     
    184       if($_GET['Action'] == 'BackupAdd')
    185       {
    186         $BackupView = new BackupView($this->Database, $this->System);
    187         $Output .= $BackupView->Add();
    188       } else     
    189       if($_GET['Action'] == 'BackupRestore')
    190       {
    191         $BackupView = new BackupView($this->Database, $this->System);
    192         $Output .= $BackupView->Restore();
    193       } else     
    194       if($_GET['Action'] == 'BackupDownload')
    195       {
    196         $BackupView = new BackupView($this->Database, $this->System);
    197         $Output .= $BackupView->Download();
    198       } else     
    199       if($_GET['Action'] == 'TaskList')
    200       {
    201         $TaskView = new TaskView($this->Database, $this->System);
    202         $Output .= $TaskView->ItemList();
    203       } else     
    204       if($_GET['Action'] == 'TaskShowErrorLog')
    205       {
    206         $TaskView = new TaskView($this->Database, $this->System);
    207         $Output .= $TaskView->ErrorLog();
    208       } else     
    209       if($_GET['Action'] == 'TaskShowStandardLog')
    210       {
    211         $TaskView = new TaskView($this->Database, $this->System);
    212         $Output .= $TaskView->StandardLog();
    213       } else     
    214       if($_GET['Action'] == 'Update')
    215       {
    216         $UpdateView = new UpdateView($this->Database, $this->System);
    217         $Output .= $UpdateView->Update();
    218       } else     
    219       if($_GET['Action'] == 'NewsAdd')
    220       {
    221         $NewsView = new NewsView($this->Database, $this->System);
    222         $Output .= $NewsView->Add();
    223       } else     
    224       if($_GET['Action'] == 'NewsAdd2')
    225       {
    226         $NewsView = new NewsView($this->Database, $this->System);
    227         $Output .= $NewsView->AddFinish();
    228       } else     
    229       if($_GET['Action'] == 'EmulatorShow')
    230       {
    231         $EmulatorView = new EmulatorView($this->Database, $this->System);
    232         $Output .= $EmulatorView->Item();
    233       } else
    234       if($_GET['Action'] == 'State')
    235       {
    236         $BaseView = new BaseView($this->Database, $this->System);
    237         $Output .= $BaseView->State();
    238       } else
    239       if($_GET['Action'] == 'ServerList')
    240       {
    241         $ServerView = new ServerView($this->Database, $this->System);
    242         $Output .= $ServerView->ItemList();
    243       } else
    244       if($_GET['Action'] == 'RealmList')
    245       {
    246         $RealmView = new RealmView($this->Database, $this->System);
    247         $Output .= $RealmView->ItemList();
    248       } else
    249       if($_GET['Action'] == 'RealmShow')
    250       {
    251         $RealmView = new RealmView($this->Database, $this->System);
    252         $Output .= $RealmView->Item();
    253       } else
    254       if($_GET['Action'] == 'RealmAdd')
    255       {
    256         $RealmView = new RealmView($this->Database, $this->System);
    257         $Output .= $RealmView->Add();
    258       } else
    259       if($_GET['Action'] == 'RealmCreate')
    260       {
    261         $RealmView = new RealmView($this->Database, $this->System);
    262         $Output .= $RealmView->Create();
    263       } else
    264       if($_GET['Action'] == 'RealmInitDatabase')
    265       {
    266         $RealmView = new RealmView($this->Database, $this->System);
    267         $Output .= $RealmView->InitDatabase();
    268       } else
    269       if($_GET['Action'] == 'RealmEdit')
    270       {
    271         $RealmView = new RealmView($this->Database, $this->System);
    272         $Output .= $RealmView->Edit();
    273       } else
    274       if($_GET['Action'] == 'RealmSave')
    275       {
    276         $RealmView = new RealmView($this->Database, $this->System);
    277         $Output .= $RealmView->Save();
    278       } else
    279       if($_GET['Action'] == 'RealmEditDetailed')
    280       {
    281         $RealmView = new RealmView($this->Database, $this->System);
    282         $Output .= $RealmView->EditDetailed();
    283       } else
    284       if($_GET['Action'] == 'RealmSaveDetailed')
    285       {
    286         $RealmView = new RealmView($this->Database, $this->System);
    287         $Output .= $RealmView->SaveDetailed();
    288       } else
    289       if($_GET['Action'] == 'RealmStart')
    290       {
    291         $RealmView = new RealmView($this->Database, $this->System);
    292         $Output .= $RealmView->Start();
    293       } else
    294       if($_GET['Action'] == 'RealmStop')
    295       {
    296         $RealmView = new RealmView($this->Database, $this->System);
    297         $Output .= $RealmView->Stop();
    298       } else
    299       if($_GET['Action'] == 'UpdateRealmCharacters')
    300       {
    301         $Server = new Server($this->Database, $_GET['Id']);
    302         $Output .= $Server->UpdateRealmlistAccountCount();
    303       } else
    304       if($_GET['Action'] == 'Test')
    305       {
    306         //$Emulator = new Emulator($this->Database, 2);
    307         //  $Emulator->Compile();
    308         //$Server = new Server($this->Database, 1);
    309         //$Output .= $Server->ImportDatabase();
    310         //$Config = new MangosConfigurationFile($this->Database);
    311         //$Config->Load('../emu/mangos/7681/etc/mangosd.conf');
    312         //$Config->Save('../server/1/etc/mangosd.conf');
    313       } else
    314       {
    315         $BaseView = new BaseView($this->Database, $this->System);
    316         $Output .= $BaseView->Welcome();
    317       }
    318     } else
    319     {
    320       $BaseView = new BaseView($this->Database, $this->System);
    321       $Output .= $BaseView->Welcome();
    322     }
    323    
    324     $BaseView = new BaseView($this->Database, $this->System);
    325     $Content = $Output;
    326     $Output = '<table class="BasicTable"><tr>';
    327     if($this->System->Modules['User']->User['Id'] != $this->System->Modules['User']->AnonymousUserId)
    328       $Output .= '<td class="UserMenu">'.$BaseView->UserMenu().'</td>';
    329     $Output .= '<td class="Content">'.$Content.'</td>';
    330     if(!array_key_exists('Action', $_GET))
    331     {
    332       $NewsView = new NewsView($this->Database, $this->System);
    333       $Output .= $NewsView->View();
    334     }
    335     $Output .= '</tr></table>';
    336     return($Output);
    337   }
    338 }
     31  $Controller = new $ControllerName($System);
     32  if(method_exists($Controller, $Action)) $Output = $Controller->$Action();
     33    else $Output = 'Metoda '.$Action.' modulu '.$Module.' neexistuje.';
     34} else $Output = 'Třída '.$ControllerName.' neexistuje.';
    33935
    340 $System->AddModule(new Index($Database, $System));
    341 $System->Modules['Index']->GetOutput();
     36echo($Output);
    34237
    34338?>
Note: See TracChangeset for help on using the changeset viewer.