[php] fge
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- <?
- require_once '../site.php';
- $db->connect();
- $token = STAccounts::createCSRFToken();
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- // Filter username - June 13, 2021
- $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_SPECIAL_CHARS);
- $login = $account->login($username, $_POST['password']);
- // Handle our own exceptions until STAccountsException caught
- if (!$login) {
- $log_attempt = $db->query_params('SELECT user_id, email, login_attempts, avatar_thumb AS avatar FROM users WHERE username = :username LIMIT 1', array(
- 'username' => $username
- ));
- if ($check = $log_attempt->fetch()) {
- // Save login attempt
- if (is_null($check['login_attempts'])) {
- $db->query_params('UPDATE users SET login_attempts = 1 WHERE user_id = :user_id', array(
- 'user_id' => $check['user_id']
- ));
- }
- // dispatch email notice - 3 login failures
- if ($check['login_attempts'] <= 3) {
- $errors[] = 'Password <b>incorrect.</b>';
- $db->query_params('UPDATE users SET login_attempts = login_attempts + 1 WHERE user_id = :user_id', array(
- 'user_id' => $check['user_id']
- ));
- } else if ($check['login_attempts'] >= 3) {
- send_email($check['email'], '3 Failed Login Attempts', '3 Failed Login Attempts', 'Switch-Torrents detected <b>3 failed login attempts</b> to this registered account.', 'Options', 'Reset password', false);
- $db->query_params('UPDATE users SET login_attempts = 0 WHERE user_id = :user_id', array(
- 'user_id' => $check['user_id']
- ));
- $errors[] = 'Please try again.';
- }
- $avatar = '<img src="/' . $check['avatar'] . '" style="width:30px;height:30px;border-radius:100px;vertical-align:middle" />';
- } else {
- $errors[] = 'Username <b>not found.</b>';
- }
- } else {
- header(sprintf('Location: %s/', $CONFIG['base_url']));
- }
- }
- site_header();
- // Collect errors if any
- if (!empty($errors)) {
- foreach ($errors as $error) {
- $message = sprintf('<span class="material-icons" style="color:orange;vertical-align:middle;padding-left:20px">warning</span> %s', $error);
- }
- }
- printf('<h1 itemprop="name"><span class="card-title">Sign In to %s</span></h1>', html_escape($CONFIG['site_title']));
- printf('<article itemprop="itemListElement" itemscope="" itemtype="http://schema.org/Article" class="card" style="height:350px">');
- printf('<div style="float:left"><img src="/images/v2_login_banner.png" style="width:180px;height:350px;overflow:auto"></div>');
- printf('<div style="float:left;padding-left:30px;margin-top:-30px">');
- printf('<form class="cd-form floating-labels" method="POST" action="%s/signin/">', $CONFIG['base_url']);
- printf('<fieldset>
- <div class="icon">
- <label class="cd-label" for="cd-name">Username</label>
- <input class="user" type="text" name="username" id="cd-name" placeholder="Username" value="%s" required>
- </div>
- <div class="icon" style="margin-top:-15px">
- <label class="cd-label" for="cd-company">Password</label>
- <input class="company" type="password" name="password" id="cd-company" required>
- </div>
- <div>
- <button class="btn" onclick="this.form.submit()">%s Sign In</button> <span>%s</span>
- <div style="margin-top:15px">Not registered? Sign up <a href="/signup/">here</a></div>
- </div>
- </fieldset>', $_POST['username'], $avatar, $message);
- printf('<input type="hidden" name="csrf" value="%s">', $token);
- printf('</form>');
- printf('</div>');
- printf('<div style="clear:both"></div>');
- printf('<div class="card-action ng-scope">
- <!-- interactionCount -->
- <span itemprop="interactionCount" class="comments"><a href="/signup/" target="_self" class="ng-binding">Register</a></span>
- <span style="padding-left:10px;padding-right:10px;color:#C0C0C0">-</span>
- <span class="timestamp"><a href="/recover/" target="_self" class="ng-binding">Recover</a></span>
- </div>
- </article>
- </div>');
- site_footer();
Editor
You can edit this paste and save as new: