- Timestamp:
- Oct 13, 2008, 6:52:24 PM (16 years ago)
- Location:
- branches/3
- Files:
-
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3/class/database.php
r25 r27 4 4 // Date: 2007-07-19 5 5 6 class Database extends mysqli6 class database extends mysqli 7 7 { 8 8 var $Prefix = ''; 9 9 var $LastQuery = ''; 10 var $Last_num_rows; 10 11 11 12 function query($Query) … … 18 19 { 19 20 $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); 20 24 return($this->query($this->LastQuery)); 21 25 } -
branches/3/class/user.php
r26 r27 1 1 <?php 2 2 3 class User3 class user 4 4 { // BEGIN class User 5 5 // variables 6 var $ID,$Permission, $ User,$Database;6 var $ID,$Permission, $user,$Database; 7 7 var $AnonymousUserId = 1; 8 var $DefaultRole = 1; 9 var $IPAddress = ' '; 8 10 9 11 // constructor 10 function User($Database)12 function user($Database) 11 13 { // BEGIN constructor 12 14 $this->Database = $Database; … … 18 20 { 19 21 $SID = session_id(); 20 $ IPAddress = gethostbyaddr($_SERVER['REMOTE_ADDR']).' '.$_SERVER['REMOTE_ADDR'];22 $this->IPAddress = gethostbyaddr($_SERVER['REMOTE_ADDR']).' '.$_SERVER['REMOTE_ADDR']; 21 23 // Lookup user record 22 24 $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"'); … … 24 26 { 25 27 // 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)); 27 29 } 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)); 29 31 } 30 32 // Odeber neaktivní uživatele … … 37 39 { 38 40 $Query = $this->Database->select('User', '*', "Id=".$Row['User'].""); 39 $this-> User = $Query->fetch_array();41 $this->user = $Query->fetch_array(); 40 42 $Result = USER_LOGGED; 41 $this->LoadPermission($this-> User['Permission']);43 $this->LoadPermission($this->user['Permission']); 42 44 } else { 43 45 $Query = $this->Database->select('User', '*', "Id=".$this->AnonymousUserId); 44 $this-> User = $Query->fetch_array();46 $this->user = $Query->fetch_array(); 45 47 $Result = USER_NOT_LOGGED; 46 48 } … … 48 50 } 49 51 50 function Register($ Nick, $Password, $Password2, $Email, $FullName)52 function Register($Date) 51 53 { 52 54 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; 55 57 else 56 58 { 57 59 // 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; 60 62 else 61 63 { 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; 63 66 $Result = USER_REGISTRATED; 64 67 } … … 96 99 function LoadPermission($Permission) 97 100 { 98 $this-> User['Permission'] = array();101 $this->user['Permission'] = array(); 99 102 $DbResult = $this->Database->select('Permission','*','ID='.$Permission); 100 103 if($DbResult->num_rows > 0) 101 104 while($DbRow = $DbResult->fetch_array()) 102 $this-> User['Permission'] = $DbRow;105 $this->user['Permission'] = $DbRow; 103 106 } 104 107 105 108 function WriteRegistration() 106 109 { // 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"> 109 112 <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="Pass 2" 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> 113 116 <tr><td>'.REGISTRATION_PAGE_EMAIL.'</td><td><input name="Email" type="text" /></td></tr> 114 117 <tr><td>'.REGISTRATION_PAGE_FULLNAME.'</td><td><input name="FullName" type="text" /></td></tr> … … 124 127 <tr><td></td><td><input value="'.REGISTRATION_PAGE_BUTTON.'" type="submit" /></td></tr> 125 128 </table> 126 </form> </div>';129 </form>'; 127 130 } // END function WriteRegistration 128 131 -
branches/3/events.php
r25 r27 1 1 <?php 2 2 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 = ''; 3 11 4 12 ?> -
branches/3/functions.php
r26 r27 4 4 { // BEGIN function ShowHeader 5 5 global $Config,$menu,$User; 6 echo '<?xml version="1.0" encoding="'.$Config['Charset'].'"? \>6 echo '<?xml version="1.0" encoding="'.$Config['Charset'].'"?> 7 7 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 8 8 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -
branches/3/global.php
r26 r27 11 11 12 12 //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); 17 17 18 18 include('events.php'); -
branches/3/index.php
r26 r27 4 4 ShowHeader(); 5 5 6 if (array_key_exists('user', $_GET)) $User->WriteRegistration(); else 7 echo HOME_PAGE; 6 echo '<div id="content">'; 8 7 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 9 21 ShowFoodter() 10 22 ?> 23 -
branches/3/language_cz.php
r26 r27 20 20 define('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>'); 21 21 define('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>22 define('HOME_PAGE', '<h2>Hlavní stránka</h2> 23 23 <p> 24 24 <b>Nacházíte se na stránce free projektu překládání Questů</b><br /> … … 49 49 50 50 </p> 51 </div>52 51 '); 53 52 … … 66 65 $menu[0] = array('Hlavní strana','Hlavní strana, s pokyny pro překladatele a bannery','index.php'); 67 66 $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'); 69 68 ?> -
branches/3/style.css
r26 r27 144 144 } 145 145 146 t able,td,tr {146 td,tr { 147 147 border-spacing: 0; 148 148 border: thin #c43300 solid; 149 149 } 150 150 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.