function __construct() { // Assign their username to a variable if (isset($_SESSION['jigowatt']['username'])) { $this->user = $_SESSION['jigowatt']['username']; } // Are they clicking from an email? if (isset($_GET['key'])) { $this->key = parent::secure($_GET['key']); $this->getKey(); // Do they want the key resent? } else { if (isset($_GET['resend']) && $_GET['resend'] == '1') { $this->resendKey(); // Are they already signed in without a key? } else { if (isset($this->user) && !isset($this->key)) { $this->signedIn(); } else { header('location: home.php'); exit; } } } // Display any errors parent::displayMessage($this->error, false); }
function __construct() { // Only allow guests to view this page parent::guestOnly(); /* Has the admin disabled user registrations? */ $disable = parent::getOption('disable-registrations-enable'); if ($disable) { $this->error = sprintf('<div class="alert alert-block alert-error">%s</div>', _('<h4 class="alert-heading">Registrations disabled.</h4><p>Already have an account? <a href="login.php">Sign in here</a>!</p>')); parent::displayMessage($this->error, true); } $this->use_emails = parent::getOption('email-as-username-enable'); $this->username_type = $this->use_emails ? 'email' : 'username'; // jQuery form validation parent::checkExists(); // Generate a unique token for security purposes parent::generateToken(); // Has the form been submitted? if (!empty($_POST)) { // Sign up form post data foreach ($_POST as $field => $value) { $this->settings[$field] = parent::secure($value); } $this->process(); } if (isset($_GET['new_social'])) { $this->error = sprintf('<div class="alert alert-success">%s</div>', _('We don\'t see you as a registered user. Perhaps you\'d like to sign up :)')); } parent::displayMessage($this->error, false); }
function __construct() { if (isset($_POST['searchUsers'])) { $this->searchUsers(); exit; } // jQuery form validation parent::checkExists(); if (isset($_POST['add_user'])) { $this->name = parent::secure($_POST['name']); $this->username = parent::secure($_POST['username']); $this->email = parent::secure($_POST['email']); $this->password = substr(md5(rand() . rand()), 0, 6); // Confirm all details are correct $this->verify(); // Create the user $this->adduser(); if (!empty($this->error)) { parent::displayMessage($this->error); } else { echo $this->result; } exit; } }
function __construct() { // Begin ! $this->jigowatt_upgrade(); // Message shown to user if (!empty($this->result)) { parent::displayMessage($this->result, false); } }
private function retrieveFields() { $params = array(':user_id' => $this->user_id); $stmt = parent::query("SELECT `user_id`, `username`, `name`, `email` FROM `accounts` WHERE `user_id` = :user_id;", $params); if ($stmt->rowCount() < 1) { $this->error = sprintf('<div class="alert alert-warning">%s</div>', _('Sorry, that user does not exist.')); parent::displayMessage($this->error, true); return false; } foreach ($stmt->fetch(PDO::FETCH_ASSOC) as $field => $value) { $this->settings[$field] = parent::secure($value); } }
function __construct() { // Save level and auth if (!empty($_GET['lid'])) { $this->retrieveInfo(); } if (isset($_POST['do_edit'])) { foreach ($_POST as $key => $value) { $this->options[$key] = parent::secure($value); } $this->options['level_disabled'] = !empty($_POST['disable']) ? 'checked' : ''; $this->options['welcome_email'] = !empty($_POST['welcome_email']) ? 'checked' : ''; // Validate fields $this->validate(); } if (!empty($this->error)) { parent::displayMessage("<div class='alert alert-warning'>{$this->error}</div>", false); } if (!empty($this->result)) { parent::displayMessage("<div class='alert alert-success'>{$this->result}</div>", false); } }
/** * Message shown to users when access is denied. */ private function deny_access() { if (!parent::getOption('block-msg-enable')) { parent::displayMessage(' '); } $error = "<div class='row'>\n\t\t\t\t\t<div class='col-md-12'>\n\t\t\t\t\t\t" . html_entity_decode(parent::getOption('block-msg')) . "\n\t\t\t\t\t</div>\n\t\t\t\t </div>"; parent::displayMessage($error); }
private function process() { if (!empty($this->error)) { return false; } // Ticked the 'delete user' box? if (!empty($this->options['delete'])) { $params = array(':id' => $this->id); $sql = array(); $sql[] = "DELETE FROM login_users WHERE user_id = :id;"; $sql[] = "DELETE FROM login_integration WHERE user_id = :id;"; $sql[] = "DELETE FROM login_profiles WHERE user_id = :id;"; $sql[] = "DELETE FROM login_timestamps WHERE user_id = :id;"; foreach ($sql as $do) { parent::query($do, $params); } $result = sprintf("<div class='alert alert-success'>" . _('User removed from the database:') . " <b>%s</b> (%s).</div>", $this->options['name'], $this->options['username']); parent::displayMessage($result); } if (!empty($this->options['password'])) { $params = array(':restrict' => $this->options['restricted'], ':name' => $this->options['name'], ':email' => $this->options['email'], ':level' => $this->options['user_level'], ':password' => parent::hashPassword($this->options['password']), ':id' => $this->id); $sql = "UPDATE `login_users` SET `restricted` = :restrict, `name` = :name, `email` = :email, `user_level` = :level, `password` = :password WHERE `user_id` = :id;"; parent::query($sql, $params); $result = sprintf("<div class='alert alert-success'>" . _('User information (and password) updated for') . " <b>%s</b> (%s).</div>", $this->options['name'], $this->options['username']); } else { $params = array(':restrict' => $this->options['restricted'], ':name' => $this->options['name'], ':email' => $this->options['email'], ':level' => $this->options['user_level'], ':id' => $this->id); $format = array('%d', '%s', '%s', '%s', '%d'); $sql = "UPDATE `login_users` SET `restricted` = :restrict, `name` = :name, `email` = :email, `user_level` = :level WHERE `user_id` = :id;"; parent::query($sql, $params, $format); $result = sprintf("<div class='alert alert-success'>" . _('User information updated for') . " <b>%s</b> (%s).</div>", $this->options['name'], $this->options['username']); } // Checkbox handling $sql = "SELECT * FROM `login_profile_fields`;"; $stmt = parent::query($sql); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $name = 'p-' . $row['id']; if ($row['type'] == 'checkbox') { $this->options[$name] = !empty($this->options[$name]) ? 1 : 0; } } // Update profile fields foreach ($this->options as $field => $value) { if (strstr($field, 'p-')) { $field = str_replace('p-', '', $field); parent::updateOption($field, $value, true, $this->options['user_id']); } } /* Time to send our welcome email! */ if (!empty($this->sendWelcome)) { $msg = parent::getOption('email-welcome-msg'); $subj = parent::getOption('email-welcome-subj'); $shortcodes = array('site_address' => SITE_PATH, 'full_name' => $this->options['name'], 'username' => $this->options['username'], 'email' => $this->options['email']); if (!parent::sendEmail($shortcodes['email'], $subj, $msg, $shortcodes)) { $this->error = _('ERROR. Mail not sent'); } } return $result; }
/** * * @param unknown $provider * @return unknown */ private function unlink($provider) { if (!in_array($provider, self::$socialLogin)) { return false; } if (empty($this->result[$provider])) { parent::displayMessage(sprintf('<div class="alert alert-warning">' . _('You are not yet linked with %s') . '</div>', ucwords($provider)), false); return false; } $params = array(':user_id' => $_SESSION['jigowatt']['user_id']); $sql = "UPDATE `login_integration` SET {$provider} = null WHERE `user_id` = :user_id;"; parent::query($sql, $params); unset($_SESSION['jigowatt'][$provider]); parent::displayMessage(sprintf('<div class="alert alert-success">' . _('Successfully unlinked from %s') . '</div>', ucwords($provider)), false); }