UPDATE
- Register hinzugefügt
- Client hinzugefügt
Ein weiteres Update. Der Register ist nun auch fertig, nur mir persönlich gefällt das design nicht so gut. Darum würde ich euch bitte mir Vorschläge zu geben, oder soll ich es so lassen? Zudem wurde auch der Client hinzugefügt. Ist aber alles noch auf Englisch, ich werden es dann übersetzen und einen anderen Katalog einfügen.
Snippets:
Spoiler anzeigen
Register Einstellungen
Code
'register' => [
'credits' => 25000, // Taler
'duckets' => 3000, // Duckets
'diamonds' => 150, // Diamanten
'loyalty' => 50, // Loyalty Punkte
'rank' => 1, // Standart Rank
'motto' => 'Willkommen im Hotel!', // Standart Motto
'vip' => true, // Ist er VIP?
'vip_points' => 50 // VIP Punkte
],
PHP
<?php
class Register
{
public $err = '';
private $user;
private $config;
private $connection;
public function __construct($config, $connection)
{
$this->config = $config;
$this->connection = $connection;
$this->user = new User($this->config, $this->connection);
}
public function ValidateStep1($username, $password, $repeat, $mail)
{
if(empty($username) || empty($password) || empty($repeat) || empty($mail)) {
$this->err = 'Füll bitte alle Felder aus.';
} elseif(strlen($username) < 3) {
$this->err = 'Der Username muss mindestens 3 Zeichen lang sein.';
} elseif(strlen($username) > 12) {
$this->err = 'Der Username darf maximal 12 Zeichen lang sein.';
} elseif(!preg_match('/^[A-Za-z0-9@:.]+$/', $username)) {
$this->err = 'Ungültiger Username.';
} elseif(strpos(strtolower($username), 'mod-')) {
$this->err = 'Ungültiger Username.';
} else {
$query = $this->connection->prepare('SELECT username FROM users WHERE LOWER(username) = :username LIMIT 1');
$query->execute([':username' => strtolower($username)]);
if($query->rowCount()) {
$this->err = 'Dieser Username ist leider schon vergeben.';
} elseif(!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
$this->err = 'Gib bitte eine gültige E-Mail Adresse ein.';
} elseif(strlen($password) < 8) {
$this->err = 'Das Passwort muss mindestens 8 Zeichen lang sein.';
} elseif(strlen($password) > 32) {
$this->err = 'Das Passwort darf maximal 32 Zeichen lang sein.';
} elseif(!preg_match('/^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])[A-Za-z0-9]+$/', $password)) {
$this->err = 'Das Passwort muss Buchstaben und Zahlen entahlten.';
} elseif($repeat !== $password) {
$this->err = 'Die Passwörter stimmen nicht überein.';
} else {
$_SESSION['SYNC-REGISTER-USERNAME'] = $username;
$_SESSION['SYNC-REGISTER-PASSWORD'] = password_hash($password, PASSWORD_DEFAULT);
$_SESSION['SYNC-REGISTER-MAIL'] = strtolower($mail);
header('Location: ' . $this->config['website']['url'] . '/register/step2');
}
}
}
public function ValidateStep2($day, $month, $year, $gender) {
if(empty($day) || empty($month) || empty($year) || empty($gender)) {
$this->err = 'Füll bitte alle Felder aus.';
} elseif(!is_numeric($day) || !is_numeric($month) || !is_numeric($year)) {
$this->err = 'Ungültiges Geburtsdatum.';
} else {
if($this->config['register']['vip'] == true) {
$vip = 1;
$expire = time() + (86400 * 50);
$votes = 5;
$respect = 5;
$pet_respect = 5;
} else {
$vip = 0;
$expire = time() - 3600;
$votes = 3;
$respect = 3;
$pet_respect = 3;
}
if($gender == 'm') {
$look = 'ch-215-66.lg-270-79.hr-100-0.sh-305-62.ha-1002-70.hd-180-7.wa-2007-0';
} else {
$look = 'ch-635-70.hd-600-1.lg-716-66-62.hr-515-33.sh-735-68';
}
$query = $this->connection->prepare('INSERT INTO users (username, real_name, password, auth_ticket, rank, vip_points, credits, activity_points, seasonal_currency, loyalty_points, look, gender, motto, mail, account_created, ip_last, ip_reg, vip, vip_expire, birth) VALUES (:username, :real_name, :password, :auth_ticket, :rank, :vip_points, :credits, :activity_points, :seasonal_currency, :loyalty_points, :look, :gender, :motto, :mail, :account_created, :ip_last, :ip_reg, :vip, :vip_expire, :birth)');
$query->execute([
'username' => $_SESSION['SYNC-REGISTER-USERNAME'],
'real_name' => $this->config['website']['name'] . ' Hotel',
'password' => $_SESSION['SYNC-REGISTER-PASSWORD'],
'auth_ticket' => $this->GenerateTicket(),
'rank' => $this->config['register']['rank'],
'vip_points' => $this->config['register']['vip_points'],
'credits' => $this->config['register']['credits'],
'activity_points' => $this->config['register']['duckets'],
'seasonal_currency' => $this->config['register']['diamonds'],
'loyalty_points' => $this->config['register']['loyalty'],
'look' => $look,
'gender' => strtoupper($gender),
'motto' => $this->config['register']['motto'],
'mail' => $_SESSION['SYNC-REGISTER-MAIL'],
'account_created' => time(),
'ip_last' => $this->user->getUserIp(),
'ip_reg' => $this->user->getUserIp(),
'vip' => $vip,
'vip_expire' => $expire,
'birth' => $day . '.' . $month . '.' . $year
]);
$query = $this->connection->prepare('SELECT id FROM users WHERE username = :username LIMIT 1');
$query->execute([':username' => $_SESSION['SYNC-REGISTER-USERNAME']]);
if($query->rowCount()) {
$r = $query->fetchObject();
}
$query = $this->connection->prepare('INSERT INTO users_stats (id, online_seconds, daily_respect_points, daily_pet_respect_points, daily_competition_votes) VALUES (:id, :online_seconds, :daily_respect_points, :daily_pet_respect_points, :daily_competition_votes)');
$query->execute([
':id' => $r->id,
':online_seconds' => 0,
':daily_respect_points' => $respect,
':daily_pet_respect_points' => $pet_respect,
':daily_competition_votes' => $votes
]);
if($vip == 1) {
$query = $this->connection->prepare('INSERT INTO users_badges (user_id, badge_id) VALUES (:user_id, :badge_id)');
$query->execute([
':user_id' => $r->id,
':badge_id' => 'VIP'
]);
}
$_SESSION['SYNC-LOGIN'] = $_SESSION['SYNC-REGISTER-USERNAME'];
$_SESSION['SYNC-REGISTER-USERNAME'] = null;
$_SESSION['SYNC-REGISTER-PASSWORD'] = null;
$_SESSION['SYNC-REGISTER-MAIL'] = null;
unset($_SESSION['SYNC-REGISTER-USERNAME']);
unset($_SESSION['SYNC-REGISTER-PASSWORD']);
unset($_SESSION['SYNC-REGISTER-MAIL']);
header('Location: ' . $this->config['website']['url'] . '/home');
}
}
public function GenerateTicket()
{
return 'SYNC-AUTH-' . rand(000, 999) . '-' . rand(00000, 99999) . '-' . rand(000, 999) . '-' . $this->config['app']['version'];
}
public function GenerateDays()
{
for($i = 1; $i <= 31; $i++) {
echo '<option value="' . $i . '">' . $i . '</option>';
}
}
public function GenerateMonths()
{
$months = [
'1' => 'Januar',
'2' => 'Februar',
'3' => 'März',
'4' => 'April',
'5' => 'Mai',
'6' => 'Juni',
'7' => 'Juli',
'8' => 'August',
'9' => 'September',
'10' => 'Oktober',
'11' => 'November',
'12' => 'Dezember'
];
foreach($months as $key => $value) {
echo '<option value="' . $key . '">' . $value . '</option>';
}
}
public function GenerateYears()
{
for($i = 2015; $i >= 1900; $i--) {
echo '<option value="' . $i . '">' . $i . '</option>';
}
}
public function __destruct()
{
$this->err = null;
$this->user = null;
$this->config = null;
$this->connection = null;
}
}
?>
Alles anzeigen
Screens:
Freundliche Grüsse,
Synergy