Changeset 801 for trunk/Modules/User/Registration.php
- Timestamp:
- Mar 31, 2014, 9:10:41 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/Registration.php
r787 r801 5 5 function ShowForm() 6 6 { 7 global $System;8 9 7 if(array_key_exists('sc', $_POST)) $Human = true; 10 8 else $Human = false; 11 9 if(array_key_exists('user', $_POST)) $UserName = $_POST['user']; 12 10 else $UserName = ''; … … 17 15 if(array_key_exists('Language', $_POST)) $Language = $_POST['Language']; 18 16 else $Language = 1; 19 17 20 18 $Output = '<form action="?" method="post"> 21 19 <fieldset><legend>'.T('New user registration').'</legend> … … 64 62 </tr>'; 65 63 $Output .= '</td></tr>'. 66 '<tr><td>Upřednostněná verze klienta: </td><td>'.ClientVersionSelection('').'</td></tr>'; 67 64 '<tr><td>Upřednostněná verze klienta: </td><td>'.ClientVersionSelection('').'</td></tr>'; 65 68 66 $Output .= '<tr><td>'; 69 67 $Query = 'SELECT * FROM UserTagType'; 70 68 $DbResult = $this->Database->query($Query); 71 69 $Output .= 'Vyberte pravidla, kterými se při překladu chcete řídit:</td><td>'; 72 while ($UserTag = $DbResult->fetch_array()) { 73 $checked = false; 74 75 $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox'); 70 while ($UserTag = $DbResult->fetch_array()) { 71 $checked = false; 72 73 $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox'); 76 74 $Output .= ''.$UserTag['Text'].'<br />'; 77 75 } 78 76 $Output .= '</td></tr>'; 79 77 80 78 $Output .= '<tr> 81 79 <th><input type="submit" value="Registrovat" /></th> … … 84 82 return($Output); 85 83 } 86 84 85 function CheckRegistration() 86 { 87 global $Config; 88 89 $Output = ''; 90 $ShowForm = true; 91 92 if(array_key_exists('user', $_POST)) $UserName = $_POST['user']; 93 else $UserName = ''; 94 if(array_key_exists('pass', $_POST)) $Pass = $_POST['pass']; 95 else $Pass = ''; 96 if(array_key_exists('pass2', $_POST)) $Pass2 = $_POST['pass2']; 97 else $Pass2 = ''; 98 if(array_key_exists('Email', $_POST)) $Email = $_POST['Email']; 99 else $Email = ''; 100 if(array_key_exists('Team', $_POST)) $Team = $_POST['Team'] * 1; 101 else $Team = ''; 102 if(array_key_exists('Language', $_POST)) $Language = $_POST['Language'] * 1; 103 else $Language = ''; 104 if(array_key_exists('ClientVersion', $_POST)) $PreferredVersion = $_POST['ClientVersion'] * 1; 105 else $PreferredVersion = ''; 106 if($PreferredVersion == '') $PreferredVersion = 'NULL'; 107 if(array_key_exists('sc', $_POST)) $SpamCheck = $_POST['sc']; 108 else $SpamCheck = ''; 109 110 if($SpamCheck != '') 111 { 112 if(($UserName != '') and ($Pass != '') and ($Pass2 != '')) 113 { 114 if(!in_array(strtolower($UserName), $Config['ForbiddedUserNames'])) 115 { 116 if($Pass == $Pass2) 117 { 118 $DbResult = $this->Database->query('SELECT * FROM `User` WHERE LOWER(`Name`) = LOWER("'.$UserName.'")'); 119 $Line = $DbResult->fetch_row(); 120 if(!$Line) 121 { 122 if($Team == 0) $Team = 'NULL'; 123 $this->System->User->Register($UserName, $Pass, $Email, $Language, $Team, $PreferredVersion); 124 $Output .= ShowMessage('Registrace proběhla úspěšně.'); 125 $Output .= 'Přečtěte si pozorně <a href="'.$this->System->Link('/info.php').'">pokyny pro překladání</a> a můžete pak hned začít překládat.'; 126 $this->System->User->Login($UserName, $Pass); 127 $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel se zaregistroval: '.$UserName, LOG_TYPE_USER); 128 $ShowForm = false; 129 130 //tag 131 $Query = 'SELECT * FROM UserTagType'; 132 $DbResult = $this->Database->query($Query); 133 while ($UserTag = $DbResult->fetch_array()) { 134 if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) { 135 $Query = 'SELECT * FROM `UserTag` '. 136 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1); 137 $DbResult2 = $this->Database->query($Query); 138 if ($DbResult2->num_rows == 0) { 139 $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '. 140 'VALUES (NULL, '.$UserTag['ID'].' , '.($this->System->User->Id * 1).')'; 141 $DbResult2 = $this->Database->query($Query); 142 } 143 } else { 144 $Query = 'DELETE FROM `UserTag` '. 145 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1); 146 $DbResult2 = $this->Database->query($Query); 147 } 148 } 149 } else $Output = ShowMessage('Uživatel se zadanou přezdívkou již existuje.', MESSAGE_CRITICAL); 150 } else $Output = ShowMessage('Hesla se neshodují.', MESSAGE_CRITICAL); 151 } else $Output = ShowMessage('To jméno uživatele nemůžete použít.', MESSAGE_CRITICAL); 152 } else $Output = ShowMessage('Nelze použít prázdné jméno nebo heslo.', MESSAGE_CRITICAL); 153 } else $Output = ShowMessage('Nejsi člověk. Strojům není dovoleno se registrovat.', MESSAGE_CRITICAL); 154 155 if($ShowForm) $Output .= $this->ShowForm(); 156 return($Output); 157 } 158 87 159 function Show() 88 160 { 89 global $Config;90 91 161 $this->Title = T('User registration'); 92 162 $Output = ''; 93 163 if(array_key_exists('user', $_POST)) 94 164 { 95 $ShowForm = true; 96 97 $UserName = $_POST['user']; 98 $Pass = $_POST['pass']; 99 $Pass2 = $_POST['pass2']; 100 $Email = $_POST['Email']; 101 $Team = $_POST['Team']; 102 $Language = $_POST['Language']; 103 $PreferredVersion = $_POST['ClientVersion']; 104 if($PreferredVersion == '') $PreferredVersion = 'NULL'; 105 if(array_key_exists('sc', $_POST)) $SpamCheck = $_POST['sc']; 106 else $SpamCheck = ''; 107 108 if($SpamCheck != '') 109 { 110 if(($UserName != '') and ($Pass != '') and ($Pass2 != '')) 111 { 112 if(!in_array(strtolower($UserName), $Config['ForbiddedUserNames'])) 113 { 114 if($Pass == $Pass2) 115 { 116 $DbResult = $this->Database->query('SELECT * FROM `User` WHERE LOWER(`Name`) = LOWER("'.$UserName.'")'); 117 $Line = $DbResult->fetch_row(); 118 if(!$Line) 119 { 120 if($Team == 0) $Team = 'NULL'; 121 $this->System->User->Register($UserName, $Pass, $Email, $Language, $Team, $PreferredVersion); 122 $Output .= ShowMessage('Registrace proběhla úspěšně.'); 123 $Output .= 'Přečtěte si pozorně <a href="'.$this->System->Link('/info.php').'">pokyny pro překladání</a> a můžete pak hned začít překládat.'; 124 $this->System->User->Login($UserName, $Pass); 125 $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel se zaregistroval: '.$UserName, LOG_TYPE_USER); 126 $ShowForm = false; 127 128 //tag 129 $Query = 'SELECT * FROM UserTagType'; 130 $DbResult = $this->Database->query($Query); 131 while ($UserTag = $DbResult->fetch_array()) { 132 if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) { 133 $Query = 'SELECT * FROM `UserTag` '. 134 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1); 135 $DbResult2 = $this->Database->query($Query); 136 if ($DbResult2->num_rows == 0) { 137 $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '. 138 'VALUES (NULL, '.$UserTag['ID'].' , '.($this->System->User->Id * 1).')'; 139 $DbResult2 = $this->Database->query($Query); 140 } 141 } else { 142 $Query = 'DELETE FROM `UserTag` '. 143 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1); 144 $DbResult2 = $this->Database->query($Query); 145 } 146 } 147 148 149 150 } else $Output = ShowMessage('Uživatel se zadanou přezdívkou již existuje.', MESSAGE_CRITICAL); 151 } else $Output = ShowMessage('Hesla se neshodují.', MESSAGE_CRITICAL); 152 } else $Output = ShowMessage('To jméno uživatele nemůžete použít.', MESSAGE_CRITICAL); 153 } else $Output = ShowMessage('Nelze použít prázdné jméno nebo heslo.', MESSAGE_CRITICAL); 154 } else $Output = ShowMessage('Nejsi člověk. Strojům není dovoleno se registrovat.', MESSAGE_CRITICAL); 155 156 if($ShowForm) $Output .= $this->ShowForm(); 165 $Output .= $this->CheckRegistration(); 157 166 } else $Output .= $this->ShowForm(); 158 167 return($Output); 159 } 160 } 168 } 169 }
Note:
See TracChangeset
for help on using the changeset viewer.