Skip to content

Commit

Permalink
* Escape data in sql query
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Assepo committed Nov 27, 2014
1 parent 015e875 commit d00f3e0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions www/class/centreonAuth.class.php
Expand Up @@ -223,10 +223,11 @@ protected function checkPassword($password, $token = "", $autoimport = false) {
* @return void
*/
protected function checkUser($username, $password, $token) {
$usernameForQuery = $this->pearDB->escape($username, true);
if ($this->autologin == 0 || ($this->autologin && $token != "")) {
$DBRESULT = $this->pearDB->query("SELECT * FROM `contact` WHERE `contact_alias` = '" . htmlentities($username, ENT_QUOTES, "UTF-8") . "' AND `contact_activate` = '1' AND `contact_register` = '1' LIMIT 1");
$DBRESULT = $this->pearDB->query("SELECT * FROM `contact` WHERE `contact_alias` = '" . $usernameForQuery . "' AND `contact_activate` = '1' AND `contact_register` = '1' LIMIT 1");
} else {
$DBRESULT = $this->pearDB->query("SELECT * FROM `contact` WHERE MD5(contact_alias) = '" . htmlentities($username, ENT_QUOTES, "UTF-8") . "' AND `contact_activate` = '1' AND `contact_register` = '1' LIMIT 1");
$DBRESULT = $this->pearDB->query("SELECT * FROM `contact` WHERE MD5(contact_alias) = '" . $usernameForQuery . "' AND `contact_activate` = '1' AND `contact_register` = '1' LIMIT 1");
}
if ($DBRESULT->numRows()) {
$this->userInfos = $DBRESULT->fetchRow();
Expand Down Expand Up @@ -264,7 +265,7 @@ protected function checkUser($username, $password, $token) {
/*
* Reset userInfos with imported informations
*/
$DBRESULT = $this->pearDB->query("SELECT * FROM `contact` WHERE `contact_alias` = '" . htmlentities($username, ENT_QUOTES, "UTF-8") . "' AND `contact_activate` = '1' AND `contact_register` = '1' LIMIT 1");
$DBRESULT = $this->pearDB->query("SELECT * FROM `contact` WHERE `contact_alias` = '" . $usernameForQuery . "' AND `contact_activate` = '1' AND `contact_register` = '1' LIMIT 1");
if ($DBRESULT->numRows()) {
$this->userInfos = $DBRESULT->fetchRow();
}
Expand Down

0 comments on commit d00f3e0

Please sign in to comment.