Changeset 27


Ignore:
Timestamp:
Oct 13, 2008, 6:52:24 PM (16 years ago)
Author:
maron
Message:

Registrace

Location:
branches/3
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • branches/3/class/database.php

    r25 r27  
    44// Date: 2007-07-19
    55
    6 class Database extends mysqli
     6class database extends mysqli
    77{
    88  var $Prefix = '';
    99  var $LastQuery = '';
     10  var $Last_num_rows;
    1011 
    1112  function query($Query)
     
    1819  {
    1920    $this->LastQuery = "SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition;
     21    $count = $this->query($this->LastQuery);
     22    $count = $count->fetch_array();
     23    $this->Last_num_rows = count($count);
    2024    return($this->query($this->LastQuery)); 
    2125  }
  • branches/3/class/user.php

    r26 r27  
    11<?php
    22
    3   class User
     3  class user
    44  { // BEGIN class User
    55        // variables
    6         var $ID,$Permission, $User,$Database;
     6        var $ID,$Permission, $user,$Database;
    77          var $AnonymousUserId = 1;
     8        var $DefaultRole = 1;
     9        var $IPAddress = ' ';
    810 
    911        // constructor
    10         function User($Database)
     12        function user($Database)
    1113        { // BEGIN constructor
    1214                $this->Database = $Database;
     
    1820  {
    1921    $SID = session_id();
    20     $IPAddress = gethostbyaddr($_SERVER['REMOTE_ADDR']).' '.$_SERVER['REMOTE_ADDR'];
     22    $this->IPAddress = gethostbyaddr($_SERVER['REMOTE_ADDR']).' '.$_SERVER['REMOTE_ADDR'];
    2123    // Lookup user record
    2224    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
     
    2426    {
    2527      // Refresh time of last access
    26       $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('Time' => 'NOW()','IpAddress' => $IPAddress));
     28      $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('Time' => 'NOW()','IpAddress' => $this->IPAddress));
    2729    } else {
    28      $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'Time' => 'NOW()', 'IpAddress' => $IPAddress)); 
     30     $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'Time' => 'NOW()', 'IpAddress' => $this->IPAddress)); 
    2931    }
    3032    // Odeber neaktivní uživatele
     
    3739    {
    3840      $Query = $this->Database->select('User', '*', "Id=".$Row['User']."");
    39       $this->User = $Query->fetch_array();
     41      $this->user = $Query->fetch_array();
    4042      $Result = USER_LOGGED;
    41       $this->LoadPermission($this->User['Permission']);
     43      $this->LoadPermission($this->user['Permission']);
    4244    } else {
    4345      $Query = $this->Database->select('User', '*', "Id=".$this->AnonymousUserId);
    44       $this->User = $Query->fetch_array();
     46      $this->user = $Query->fetch_array();
    4547      $Result = USER_NOT_LOGGED;
    4648    }   
     
    4850  }
    4951
    50   function Register($Nick, $Password, $Password2, $Email, $FullName)
     52  function Register($Date)
    5153  {
    5254    global $Options;
    53     if(($Email == '') || ($Nick == '') || ($Password == '') || ($Password2 == '')) $Result = DATA_MISSING;
    54     else if($Password != $Password2) $Result = PASSWORDS_UNMATCHED;
     55    if(($Date['Email'] == '') || ($Date['Nick'] == '') || ($Date['Password'] == '') || ($Date['Password2'] == '')) $Result = DATA_MISSING;
     56    else if($Date['Password'] != $Date['Password2']) $Result = PASSWORDS_UNMATCHED;
    5557    else
    5658    {
    5759      // Je uživatel registrován?
    58       $Query = $this->Database->select('User', '*', 'Name = "'.$Nick.'"');
    59       if($Query->num_rows() > 0) $Result = NICK_USED;
     60      $Query = $this->Database->select('User', '*', 'Name = "'.$Date['Nick'].'"');
     61      if($this->Database->Last_num_rows > 0) $Result = NICK_USED;
    6062      else
    6163      {
    62         $this->Database->insert('User', array('Name' => addslashes($Nick), 'FullName' => addslashes($FullName), 'Password' => addslashes($Password), 'Email' => htmlspecialchars($Email), 'Role' => $this->DefaultRole));
     64        $this->Database->insert('User', array('Name' => addslashes($Date['Nick']), 'FullName' => addslashes($Date['FullName']), 'Password' => addslashes($Date['Password']), 'Email' => htmlspecialchars($Date['Email']), 'Permission' => $this->DefaultRole, 'TranslationLanguage' => $Date['Language'], 'LastIpAddress' => $this->IPAddress, 'LastLoginTime' => 'NOW()'));
     65      //echo $this->Database->LastQuery;
    6366        $Result = USER_REGISTRATED;
    6467      }
     
    9699  function LoadPermission($Permission)
    97100  {
    98     $this->User['Permission'] = array();
     101    $this->user['Permission'] = array();
    99102    $DbResult = $this->Database->select('Permission','*','ID='.$Permission);
    100103    if($DbResult->num_rows > 0)
    101104    while($DbRow = $DbResult->fetch_array())
    102       $this->User['Permission'] = $DbRow;
     105      $this->user['Permission'] = $DbRow;
    103106  }
    104107 
    105108  function WriteRegistration()
    106109  { // BEGIN function WriteRegistration
    107         echo '<div id="content"><h2>'.REGISTRATION_PAGE_TITLE.'</h2>
    108     <form action="?reg" method="post">
     110        echo '<h2>'.REGISTRATION_PAGE_TITLE.'</h2>
     111    <form action="" method="post">
    109112    <table>
    110     <tr><td>'.REGISTRATION_PAGE_NAME.'</td><td><input name="User" type="text" /></td></tr>
    111     <tr><td>'.REGISTRATION_PAGE_PASS.'</td><td><input name="Pass" type="password" /></td></tr>
    112     <tr><td>'.REGISTRATION_PAGE_PASS2.'</td><td><input name="Pass2" type="password" /></td></tr>
     113    <tr><td>'.REGISTRATION_PAGE_NAME.'</td><td><input name="Nick" type="text" /></td></tr>
     114    <tr><td>'.REGISTRATION_PAGE_PASS.'</td><td><input name="Password" type="password" /></td></tr>
     115    <tr><td>'.REGISTRATION_PAGE_PASS2.'</td><td><input name="Password2" type="password" /></td></tr>
    113116    <tr><td>'.REGISTRATION_PAGE_EMAIL.'</td><td><input name="Email" type="text" /></td></tr>
    114117    <tr><td>'.REGISTRATION_PAGE_FULLNAME.'</td><td><input name="FullName" type="text" /></td></tr>
     
    124127    <tr><td></td><td><input value="'.REGISTRATION_PAGE_BUTTON.'" type="submit" /></td></tr>
    125128     </table>
    126     </form></div>';
     129    </form>';
    127130  } // END function WriteRegistration
    128131 
  • branches/3/events.php

    r25 r27  
    11<?php
    22
     3  if (array_key_exists('Email', $_POST)) {
     4    $Result = $user->Register($_POST);
     5
     6  }
     7
     8  if (array_key_exists('Action', $_GET)) {
     9    $Action = $_GET['Action'];
     10  } else $Action = '';
    311
    412?>
  • branches/3/functions.php

    r26 r27  
    44  { // BEGIN function ShowHeader
    55    global $Config,$menu,$User;
    6         echo '<?xml version="1.0" encoding="'.$Config['Charset'].'"?\>
     6        echo '<?xml version="1.0" encoding="'.$Config['Charset'].'"?>
    77    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    88    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  • branches/3/global.php

    r26 r27  
    1111
    1212//include('error.php');
    13 $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
    14 $Database->Prefix = $Config['Database']['Prefix'];
    15 $Database->charset($Config['Database']['Charset']);
    16 $User = new User($Database);
     13$database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
     14$database->Prefix = $Config['Database']['Prefix'];
     15$database->charset($Config['Database']['Charset']);
     16$user = new user($database);
    1717
    1818  include('events.php');
  • branches/3/index.php

    r26 r27  
    44  ShowHeader();
    55 
    6   if (array_key_exists('user', $_GET)) $User->WriteRegistration(); else
    7     echo HOME_PAGE;
     6  echo '<div id="content">';
    87 
     8  if (isset($Result) == false) {
     9    switch ($Action) {
     10      default: echo HOME_PAGE;
     11      break;
     12        case 'Register':
     13        $user->WriteRegistration();
     14        break;
     15       
     16    }
     17  } else echo '<p><h2>'.$Result.'</h2></p>';
     18 
     19  echo '</div>';
     20
    921  ShowFoodter()
    1022?>
     23
  • branches/3/language_cz.php

    r26 r27  
    2020define('BANNER_BIG', '<a href="'.$Config['BaseURL'].'"><img src="'.$Config['BaseURL'].'banners/baner_468_60.jpg" alt="baner_'.$Config['BaseURL'].'" title="Free projekt překládání celé hry World of Warcraft" border="0" height="60" width="468"/></a>');
    2121define('BANNER_SMALL', '<a href="'.$Config['BaseURL'].'"><img src="'.$Config['BaseURL'].'banners/baner_88_31.jpg" alt="baner_'.$Config['BaseURL'].'" title="Free projekt překládání celé hry World of Warcraft" border="0" height="31" width="88"/></a>');
    22 define('HOME_PAGE', '<div id="content"><h2>Hlavní stránka</h2>
     22define('HOME_PAGE', '<h2>Hlavní stránka</h2>
    2323  <p>
    2424  <b>Nacházíte se na stránce free projektu překládání Questů</b><br />
     
    4949 
    5050  </p>
    51   </div>
    5251');
    5352
     
    6665$menu[0] = array('Hlavní strana','Hlavní strana, s pokyny pro překladatele a bannery','index.php');
    6766$menu[1] = array('Forum projektu','Diskuze okolo překladu WoW','http://wow.zdechov.net/forum/viewforum.php?f=22');
    68 $menu[2] = array('Registrace','Zde si můžete vytvořit nový účet','?user=new');
     67$menu[2] = array('Registrace','Zde si můžete vytvořit nový účet','?Action=Register');
    6968?>
  • branches/3/style.css

    r26 r27  
    144144 }
    145145 
    146  table,td,tr {
     146 td,tr {
    147147   border-spacing: 0;
    148148   border: thin #c43300 solid;
    149149 }
    150150 
     151 table {
     152   margin: 10px;
     153   border-spacing: 0;
     154   border: thin #c43300 solid;
     155 }
Note: See TracChangeset for help on using the changeset viewer.