public function invites() { $f3 = \Base::instance(); $this->_requireLogin(); $this->_requireRank('support'); if ($id = $f3->get('GET.delete_invite')) { \Helpers\Invites::deleteInvite($id); new Notification('Key deleted.', 'success', true); $f3->reroute($f3->get('PATH')); } $f3->set('invites', \Helpers\Invites::getInvites()); // Some side-bar stats $db = $f3->get('db.instance'); $result = $db->exec('SELECT count(*) AS `count` FROM users'); $f3->set('users_count', $result[0]['count']); $result = $db->exec("SELECT count(*) AS `count` FROM support_tickets WHERE status != 'closed'"); $f3->set('tickets_count', $result[0]['count']); $f3->set('target', 'dashboard/admin/invites.html'); $this->_render('base.html'); }
public function claimpost() { $f3 = \Base::instance(); if ($f3->get('user')) { if ($f3->get('user')['rank'] == 1) { new Notification('You cannot claim an invite while logged in.', 'danger', true); $f3->reroute('/dashboard'); return; } } $key = $f3->get('PARAMS.invite'); if (\Helpers\Invites::isValidKey($key)) { if ($f3->get('POST.register-password') != $f3->get('POST.register-password-verify')) { $f3->set('errors', ['Password verify must match the first password.']); } else { $user = User::createUser(array('name' => $f3->get("POST.register-name"), 'username' => $f3->get("POST.register-username"), 'email' => $f3->get("POST.register-email"), 'password' => $f3->get("POST.register-password"))); // Data missing if ($user == false) { $f3->set('errors', ['Some information has not been entered correctly or is not long enough.']); } elseif (is_array($user)) { $f3->set('errors', $user); } else { $f3->set('SESSION.id', $user->id); // Delete the key \Helpers\Invites::deleteInvite($key); // Send a mail $f3->set('tplData', ['name' => $f3->get("POST.register-username")]); SendingAPI::send(['mailTo' => $f3->get("POST.register-email"), 'mailSubject' => 'Thank you for registering on SquareMS !', 'mailContents' => ['html' => \Template::instance()->render('mails/register.html'), 'text' => "Thank you for registering on SquareMS ! \n" . "You can access your account now on https://squarems.net/ ! \n\n" . "Please do not respond to this email, it is sent by an automated system."]]); $f3->reroute("/dashboard"); return; } } $f3->set('css', array('/static/css/auth.css')); $f3->set('target', 'invite.html'); $this->_render('base.html'); } else { $f3->error(404); } }