'.T('New user registration').' '; if ($Human) $Checked = ' checked="checked"'; else $Checked = ''; $Output .= ''; if ($Team == '') $Selected = ' selected="selected"'; else $Selected = ''; $Output .= ''. ''; $Query = 'SELECT * FROM UserTagType'; $DbResult = $this->Database->query($Query); $Output .= ''; $Output .= '
'.sprintf(T('Please read carefully %s and follow them. Translate with diacritics!'), ''.T('translation guidelines').''). '

'.T('Are you human?').'
'.T('Name').':
'.T('Password').':
'.T('Password confirmation').':
'.T('E-mail').':
'.T('I will translate normally to').': '.WriteLanguages($Language).'
'.T('I belong to team').':'; $Output .= '
'.T('Preferred client version').':'.ClientVersionSelection('').'
'. T('Select rules which you will apply during translation').':'; while ($UserTag = $DbResult->fetch_array()) { $checked = false; $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox'); $Output .= ''.$UserTag['Text'].'
'; } $Output .= '
'; return $Output; } function CheckRegistration() { $Output = ''; $User = ModuleUser::Cast($this->System->GetModule('User'))->User; $ShowForm = true; if (array_key_exists('user', $_POST)) $UserName = $_POST['user']; else $UserName = ''; if (array_key_exists('pass', $_POST)) $Pass = $_POST['pass']; else $Pass = ''; if (array_key_exists('pass2', $_POST)) $Pass2 = $_POST['pass2']; else $Pass2 = ''; if (array_key_exists('Email', $_POST)) $Email = $_POST['Email']; else $Email = ''; if (array_key_exists('Team', $_POST)) $Team = $_POST['Team'] * 1; else $Team = ''; if (array_key_exists('Language', $_POST)) $Language = $_POST['Language'] * 1; else $Language = ''; if (array_key_exists('ClientVersion', $_POST) and is_numeric($_POST['ClientVersion'])) $PreferredVersion = $_POST['ClientVersion'] * 1; else $PreferredVersion = ''; if ($PreferredVersion == '') $PreferredVersion = 'NULL'; if (array_key_exists('sc', $_POST)) $SpamCheck = $_POST['sc']; else $SpamCheck = ''; if ($SpamCheck != '') { if (($UserName != '') and ($Pass != '') and ($Pass2 != '')) { if (!in_array(strtolower($UserName), Core::Cast($this->System)->Config['ForbiddedUserNames'])) { if ($Pass == $Pass2) { $DbResult = $this->Database->query('SELECT * FROM `User` WHERE LOWER(`Name`) = LOWER("'.$UserName.'")'); $Line = $DbResult->fetch_row(); if (!$Line) { if ($Team == 0) $Team = 'NULL'; $User->Register($UserName, $Pass, $Email, $Language, $Team, $PreferredVersion); $Output .= ShowMessage(T('Registration was successful')); $Output .= 'Přečtěte si pozorně pokyny pro překladání a můžete pak hned začít překládat.'; $User->Login($UserName, $Pass); $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel se zaregistroval: '.$UserName, LOG_TYPE_USER); $ShowForm = false; // User tags $Query = 'SELECT * FROM `UserTagType`'; $DbResult = $this->Database->query($Query); while ($UserTag = $DbResult->fetch_array()) { if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) { $Query = 'SELECT * FROM `UserTag` '. 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1); $DbResult2 = $this->Database->query($Query); if ($DbResult2->num_rows == 0) { $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '. 'VALUES (NULL, '.$UserTag['ID'].' , '.($User->Id * 1).')'; $DbResult2 = $this->Database->query($Query); } } else { $Query = 'DELETE FROM `UserTag` '. 'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1); $DbResult2 = $this->Database->query($Query); } } } else $Output = ShowMessage('Uživatel se zadanou přezdívkou již existuje.', MESSAGE_CRITICAL); } else $Output = ShowMessage('Hesla se neshodují.', MESSAGE_CRITICAL); } else $Output = ShowMessage('To jméno uživatele nemůžete použít.', MESSAGE_CRITICAL); } else $Output = ShowMessage('Nelze použít prázdné jméno nebo heslo.', MESSAGE_CRITICAL); } else $Output = ShowMessage('Nejsi člověk. Strojům není dovoleno se registrovat.', MESSAGE_CRITICAL); if ($ShowForm) $Output .= $this->ShowForm(); return $Output; } function Show(): string { $this->Title = T('User registration'); $Output = ''; if (array_key_exists('user', $_POST)) { $Output .= $this->CheckRegistration(); } else $Output .= $this->ShowForm(); return $Output; } }