summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacques Loubser <jacquesloubser1@gmail.com>2015-09-17 20:12:56 +0200
committerJacques Loubser <jacquesloubser1@gmail.com>2015-09-17 20:12:56 +0200
commitb120ba35a0d929b6a19a10256abff37fbbd76301 (patch)
tree6b9988ce8bbc520d3cbe822a1c5209a7a999f855
parent6517d15976dd378d066ac4b2c27b42d3bbb23f78 (diff)
parent94eff82c1dfe7b8f32df659562399d37047ee0df (diff)
downloadPHPAuth-b120ba35a0d929b6a19a10256abff37fbbd76301.zip
PHPAuth-b120ba35a0d929b6a19a10256abff37fbbd76301.tar.gz
PHPAuth-b120ba35a0d929b6a19a10256abff37fbbd76301.tar.bz2
Merge remote-tracking branch 'PHPAuth/master'
-rw-r--r--.travis.yml5
-rwxr-xr-xauth.class.php44
-rwxr-xr-xconfig.class.php14
-rw-r--r--database.sql5
-rw-r--r--languages/de_DE.php1
-rwxr-xr-xlanguages/en_GB.php1
-rwxr-xr-xlanguages/fr_FR.php1
-rw-r--r--languages/it_IT.php73
-rw-r--r--languages/ru_RU.php1
9 files changed, 124 insertions, 21 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..cf73ec5
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+language: php
+php:
+ - 5.4
+ - 5.5
+ - 5.6
diff --git a/auth.class.php b/auth.class.php
index f9aedd5..c22561a 100755
--- a/auth.class.php
+++ b/auth.class.php
@@ -472,10 +472,10 @@ class Auth
public function isEmailTaken($email)
{
- $query = $this->dbh->prepare("SELECT * FROM {$this->config->table_users} WHERE email = ?");
+ $query = $this->dbh->prepare("SELECT count(*) FROM {$this->config->table_users} WHERE email = ?");
$query->execute(array($email));
- if ($query->rowCount() == 0) {
+ if ($query->fetchColumn() == 0) {
return false;
}
@@ -486,7 +486,7 @@ class Auth
* Adds a new user to database
* @param string $email -- email
* @param string $password -- password
- * @param array $params -- additional params
+ * @param array $params -- additional params
* @return int $uid
*/
@@ -526,7 +526,7 @@ class Auth
$setParams = ', ' . implode(', ', array_map(function ($entry) {
return $entry['value'];
}, $customParamsQueryArray));
- }
+ } else { $setParams = ''; }
$query = $this->dbh->prepare("UPDATE {$this->config->table_users} SET email = ?, password = ? {$setParams} WHERE id = ?");
@@ -717,16 +717,28 @@ class Auth
$mail->addAddress($email);
$mail->isHTML(true);
+ $suppressed = false;
+
if($type == "activation") {
- $mail->Subject = sprintf($this->lang['email_activation_subject'], $this->config->site_name);
- $mail->Body = sprintf($this->lang['email_activation_body'], $this->config->site_url, $this->config->site_activation_page, $key);
- $mail->AltBody = sprintf($this->lang['email_activation_altbody'], $this->config->site_url, $this->config->site_activation_page, $key);
+ if(!$this->config->emailmessage_suppress_activation){
+ $mail->Subject = sprintf($this->lang['email_activation_subject'], $this->config->site_name);
+ $mail->Body = sprintf($this->lang['email_activation_body'], $this->config->site_url, $this->config->site_activation_page, $key);
+ $mail->AltBody = sprintf($this->lang['email_activation_altbody'], $this->config->site_url, $this->config->site_activation_page, $key);
+ } else {
+ $suppressed = true;
+ }
} else {
$mail->Subject = sprintf($this->lang['email_reset_subject'], $this->config->site_name);
$mail->Body = sprintf($this->lang['email_reset_body'], $this->config->site_url, $this->config->site_password_reset_page, $key);
$mail->AltBody = sprintf($this->lang['email_reset_altbody'], $this->config->site_url, $this->config->site_password_reset_page, $key);
}
+ if($suppressed){
+ $this->lang["register_success"] = $this->lang["register_success_emailmessage_suppressed"];
+ $return['error'] = false;
+ return $return;
+ }
+
if(!$mail->send()) {
$this->deleteRequest($request_id);
@@ -1152,12 +1164,12 @@ class Auth
public function isBlocked()
{
- $ip = $this->getIp();
- $this->deleteAttempts($ip, false);
- $query = $this->dbh->prepare("SELECT count, expiredate FROM {$this->config->table_attempts} WHERE ip = ?");
- $query->execute(array($ip));
+ $ip = $this->getIp();
+ $this->deleteAttempts($ip, false);
+ $query = $this->dbh->prepare("SELECT count(*) FROM {$this->config->table_attempts} WHERE ip = ?");
+ $query->execute(array($ip));
- $attempts = $query->rowCount();
+ $attempts = $query->fetchColumn();
if($attempts < intval($this->config->attempts_before_verify))
{
@@ -1200,7 +1212,7 @@ class Auth
/**
* Deletes all attempts for a given IP from database
* @param string $ip
- * @param boolean $all = false
+ * @param boolean $all = false
* @return boolean
*/
@@ -1213,7 +1225,7 @@ class Auth
}
- $query = $this->dbh->prepare("SELECT count, expiredate FROM {$this->config->table_attempts} WHERE ip = ?");
+ $query = $this->dbh->prepare("SELECT id, expiredate FROM {$this->config->table_attempts} WHERE ip = ?");
$query->execute(array($ip));
while ($row = $query->fetch(\PDO::FETCH_ASSOC)) {
@@ -1221,8 +1233,8 @@ class Auth
$currentdate = strtotime(date("Y-m-d H:i:s"));
if($currentdate > $expiredate)
{
- $query = $this->dbh->prepare("DELETE FROM {$this->config->table_attempts} WHERE id = ?");
- $query->execute(array($row['id']));
+ $queryDel = $this->dbh->prepare("DELETE FROM {$this->config->table_attempts} WHERE id = ?");
+ $queryDel->execute(array($row['id']));
}
}
}
diff --git a/config.class.php b/config.class.php
index 20b8641..1d4fadd 100755
--- a/config.class.php
+++ b/config.class.php
@@ -32,7 +32,7 @@ class Config
$this->config[$row['setting']] = $row['value'];
}
- $this->setVerifyDefaults(); // Danger foreseen is half avoided.
+ $this->setForgottenDefaults(); // Danger foreseen is half avoided.
}
/**
@@ -67,11 +67,13 @@ class Config
/**
* Danger foreseen is half avoided.
*
- * Set default verify* values.
+ * Set default values.
* REQUIRED FOR USERS THAT DOES NOT UPDATE THEIR `config` TABLES.
*/
- private function setVerifyDefaults()
+ private function setForgottenDefaults()
{
+ // verify* values.
+
if (! isset($this->config['verify_password_min_length']) )
$this->config['verify_password_min_length'] = 3;
@@ -89,5 +91,11 @@ class Config
if (! isset($this->config['verify_email_use_banlist']) )
$this->config['verify_email_use_banlist'] = 1;
+
+ // emailmessage* values
+
+ if (! isset($this->config['emailmessage_suppress_activation']) )
+ $this->config['emailmessage_suppress_activation'] = 0;
+
}
}
diff --git a/database.sql b/database.sql
index f216cd0..962a9a1 100644
--- a/database.sql
+++ b/database.sql
@@ -11,7 +11,7 @@ CREATE TABLE `config` (
`setting` varchar(100) NOT NULL,
`value` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1;
INSERT INTO `config` (`id`, `setting`, `value`) VALUES
(1, 'site_name', 'PHPAuth'),
@@ -48,7 +48,8 @@ INSERT INTO `config` (`id`, `setting`, `value`) VALUES
(32, 'verify_email_use_banlist', '1'),
(33, 'attack_mitigation_time', '+30 minutes'),
(34, 'attempts_before_verify', '5'),
-(35, 'attempts_before_ban', '30');
+(35, 'attempts_before_ban', '30'),
+(36, 'emailmessage_suppress_activation', '0');
DROP TABLE IF EXISTS `attempts`;
CREATE TABLE `attempts` (
diff --git a/languages/de_DE.php b/languages/de_DE.php
index ebd18b7..0745396 100644
--- a/languages/de_DE.php
+++ b/languages/de_DE.php
@@ -40,6 +40,7 @@ $lang['logged_out'] = "Du bist jetzt abgemeldet.";
$lang['system_error'] = "Ein Systemfehler ist aufgetreten. Bitte versuche es erneut.";
$lang['register_success'] = "Dein Benutzerkonto wurde erstellt. Wir haben dir eine E-Mail mit einem Aktivierungslink geschickt.";
+$lang['register_success_emailmessage_suppressed'] = "Dein Benutzerkonto wurde erstellt.";
$lang['email_taken'] = "Mit dieser E-Mail-Adresse ist bereits ein anderer Benutzer registriert.";
$lang['resetkey_invalid'] = "Sicherheitsschlüssel ist ungültig.";
diff --git a/languages/en_GB.php b/languages/en_GB.php
index 4ffa4e4..c94388f 100755
--- a/languages/en_GB.php
+++ b/languages/en_GB.php
@@ -41,6 +41,7 @@ $lang['logged_out'] = "You are now logged out.";
$lang['system_error'] = "A system error has been encountered. Please try again.";
$lang['register_success'] = "Account created. Activation email sent to email.";
+$lang['register_success_emailmessage_suppressed'] = "Account created.";
$lang['email_taken'] = "The email address is already in use.";
$lang['resetkey_invalid'] = "Reset key is invalid.";
diff --git a/languages/fr_FR.php b/languages/fr_FR.php
index 1f99f3c..493620f 100755
--- a/languages/fr_FR.php
+++ b/languages/fr_FR.php
@@ -40,6 +40,7 @@ $lang['logged_out'] = "Vous avez &eacute;t&eacute; deconnect&eacute;s.";
$lang['system_error'] = "Une erreur syst&egrave;me a &eacute;t&eacute; rencontr&eacute;e. Veuillez r&eacute;essayer.";
$lang['register_success'] = "Le compte a bien &eacute;t&eacute; cr&eacute;e. L'email d'activation vous a &eacute;t&eacute; envoy&eacute;.";
+$lang['register_success_emailmessage_suppressed'] = "Le compte a bien &eacute;t&eacute; cr&eacute;e.";
$lang['email_taken'] = "L'adresse email est d&eacute;j&agrave; utilis&eacute;e.";
$lang['resetkey_invalid'] = "La cl&eacute; de r&eacute;initialisation est invalide.";
diff --git a/languages/it_IT.php b/languages/it_IT.php
new file mode 100644
index 0000000..70bf059
--- /dev/null
+++ b/languages/it_IT.php
@@ -0,0 +1,73 @@
+<?php
+
+$lang = array();
+
+$lang['user_blocked'] = 'Il tuo account &egrave; stato bloccato.';
+$lang['user_verify_failed'] = 'Codice di verifica non valido.';
+
+$lang['email_password_invalid'] = 'Email o password invalidi.';
+$lang['email_password_incorrect'] = 'Email o password non corretti';
+$lang['remember_me_invalid'] = 'Il valore del campo &quot;ricorda&quot; &egrave; invalido';
+
+$lang['password_short'] = 'La password &egrave; troppo corta.';
+$lang['password_long'] = 'La password &egrave; troppo lunga.';
+$lang['password_invalid'] = 'La password deve contenere almeno un carattere maiuscolo, uno minuscolo e una cifra.';
+$lang['password_nomatch'] = 'Le password non coincidono.';
+$lang['password_changed'] = 'Password modificata con successo.';
+$lang['password_incorrect'] = 'La vecchia password non &egrave; corretta.';
+$lang['password_notvalid'] = 'Password non valida.';
+
+$lang['newpassword_short'] = 'La nuova password &egrave; troppo corta.';
+$lang['newpassword_long'] = 'La nuova password &egrave; troppo lunga.';
+$lang['newpassword_invalid'] = 'La nuova password deve contenere almeno un carattere maiuscolo, uno minuscolo e una cifra.';
+$lang['newpassword_nomatch'] = 'Le nuove password non coincidono.';
+$lang['newpassword_match'] = 'La nuova password non pu&ograve; essere uguale a quella vecchia.';
+
+$lang['email_short'] = 'L&quot;indirizzo email &egrave; troppo corto.';
+$lang['email_long'] = 'L&quot;indirizzo email &egrave; troppo lungo.';
+$lang['email_invalid'] = 'L&quot;indirizzo email &egrave; invalido.';
+$lang['email_incorrect'] = 'L&quot;indirizzo email non &egrave; corretto.';
+$lang['email_banned'] = 'Indirizzo email bloccato dall&quot;amministratore.';
+$lang['email_changed'] = 'Email cambiata con successo.';
+
+$lang['newemail_match'] = 'La nuova email coincide con la vecchia email.';
+
+$lang['account_inactive'] = 'L&quot;acccount non &egrave; ancora stato attivato.';
+$lang['account_activated'] = 'Account attivato.';
+
+$lang['logged_in'] = 'Ti sei loggato con successo.';
+$lang['logged_out'] = 'Logout effettuato con successo.';
+
+$lang['system_error'] = 'Si &egrave; verificato un errore tecnico. Per favore riprovate pi&ugrave; tardi.';
+
+$lang['register_success'] = 'Account creato. Codice di attivazione spedito all&quot;indirizzo email.';
+$lang['register_success_emailmessage_suppressed'] = 'Account creato.';
+$lang['email_taken'] = 'L&quot;indirizzo email non &egrave; disponibile.';
+
+$lang['resetkey_invalid'] = 'Il codice per il reset non &egrave; valido.';
+$lang['resetkey_incorrect'] = 'Il codice per il reset non &egrave; corretto.';
+$lang['resetkey_expired'] = 'Il codice per il reset &egrave; scaduto.';
+$lang['password_reset'] = 'Reset della password avvenuto con successo.';
+
+$lang['activationkey_invalid'] = 'Il codice attivazione non &egrave; valido.';
+$lang['activationkey_incorrect'] = 'Il codice attivazione non &egrave; corretto';
+$lang['activationkey_expired'] = 'Il codice attivazione &egrave; scaduto.';
+
+$lang['reset_requested'] = 'Codice per il reset della password spedito all&quot;indirizzo email associato all&quot;account.';
+$lang['reset_exists'] = '&Egrave; gi&agrave; stato richiesto il reset della password.';
+
+$lang['already_activated'] = 'L&quot;account &egrave; gi&agrave; in stato attivo.';
+$lang['activation_sent'] = 'Il codice di attivazione spedito all&quot;indirizzo email associato all&quot;account.';
+$lang['activation_exists'] = 'Il codice di attivazione &agrave; gi&grave; stato spedito.';
+
+$lang['email_activation_subject'] = '%s - Attiva il tuo account';
+$lang['email_activation_body'] = 'Ciao,<br/><br/> per poter accedere al tuo account &grave; necessario attivarlo cliccando su questo link : <strong><a href="%1$s/%2$s">%1$s/%2$s</a></strong><br/><br/> Inserisci poi il seguente codice d&quot;attivazione: <strong>%3$s</strong><br/><br/> Per favore ignora questo messaggio se non ti sei registrato recentemente su %1$s.';
+$lang['email_activation_altbody'] = 'Ciao, ' . "\n\n" . 'per poter accedere al tuo account &grave; necessario attivarlo cliccando su questo link :' . "\n" . '%1$s/%2$s' . "\n\n" . 'Inserisci poi il seguente codice d&quot;attivazione: %3$s' . "\n\n" . 'Per favore ignora questo messaggio se non ti sei registrato recentemente su %1$s.';
+
+$lang['email_reset_subject'] = '%s - Richiesta reset password';
+$lang['email_reset_body'] = 'Ciao,<br/><br/>per eseguire il reset della password clicca su questo link :<br/><br/><strong><a href="%1$s/%2$s">%1$s/%2$s</a></strong><br/><br/>Inserisci poi il seguente codice di reset password: <strong>%3$s</strong><br/><br/>Per favore ignora questo messaggio se non ha richiesto recentemente il reset della password su %1$s';
+$lang['email_reset_altbody'] = 'Ciao, ' . "\n\n" . 'per eseguire il reset della password clicca su questo link :' . "\n" . '%1$s/%2$s' . "\n\n" . 'Inserisci poi il seguente codice di reset password: %3$s' . "\n\n" . 'Per favore ignora questo messaggio se non ha richiesto recentemente il reset della password su %1$s.';
+
+$lang['account_deleted'] = "Account eliminato con successo.";
+
+?>
diff --git a/languages/ru_RU.php b/languages/ru_RU.php
index 95329c3..1082d9e 100644
--- a/languages/ru_RU.php
+++ b/languages/ru_RU.php
@@ -42,6 +42,7 @@ $lang['logged_out'] = "Вы вышли из системы.";
$lang['system_error'] = "Произошла системная ошибка (проблема с печеньками, сессией или базой данных). Попробуйте еще разок.";
$lang['register_success'] = "Учётная запись создана. На вашу почту отправлены инструкции по активации.";
+$lang['register_success_emailmessage_suppressed'] = "Учётная запись создана.";
$lang['resetkey_invalid'] = "Ключ сброса пароля неправильного формата.";
$lang['resetkey_incorrect'] = "Ключ сброса пароля неверный.";