Skip to content

Commit

Permalink
Fix Sqli
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 15, 2018
1 parent c3b9c91 commit f0f6f71
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions htdocs/accountancy/class/bookkeeping.class.php
Expand Up @@ -1101,7 +1101,7 @@ public function updateByMvt($piece_num='', $field='', $value='', $mode='')
$this->db->begin();

$sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab";
$sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$value."'");
$sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$this->db->escape($value)."'");
$sql .= ' WHERE ab.piece_num=' . $piece_num ;
$resql = $this->db->query($sql);

Expand Down Expand Up @@ -1184,7 +1184,7 @@ function deleteByImportkey($importkey) {
// first check if line not yet in bookkeeping
$sql = "DELETE";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE import_key = '" . $importkey . "'";
$sql .= " WHERE import_key = '" . $this->db->escape($importkey) . "'";

$resql = $this->db->query($sql);

Expand Down Expand Up @@ -1222,7 +1222,7 @@ function deleteByYearAndJournal($delyear='', $journal='', $mode='') {
$sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql.= " WHERE 1 = 1";
if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between
if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'";
if (! empty($journal)) $sql.= " AND code_journal = '".$this->db->escape($journal)."'";
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
$resql = $this->db->query($sql);

Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/class/html.formcompany.class.php
Expand Up @@ -222,8 +222,8 @@ function select_state($selected='',$country_codeid=0, $htmlname='state_id')
$sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c";
$sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
$sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1";
if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$country_codeid."'";
if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$country_codeid."'";
if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'";
if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'";
$sql .= " ORDER BY c.code, d.code_departement";

dol_syslog(get_class($this)."::select_departement", LOG_DEBUG);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/class/translate.class.php
Expand Up @@ -895,7 +895,7 @@ function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel,$keyforselect

$sql = "SELECT ".$fieldlabel." as label";
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
$sql.= " WHERE ".$fieldkey." = '".($keyforselect?$keyforselect:$key)."'";
$sql.= " WHERE ".$fieldkey." = '".$this->db->escape($keyforselect?$keyforselect:$key)."'";
if ($filteronentity) $sql.= " AND entity IN (" . getEntity($tablename). ')';
dol_syslog(get_class($this).'::getLabelFromKey', LOG_DEBUG);
$resql = $db->query($sql);
Expand Down Expand Up @@ -977,7 +977,7 @@ public function loadCacheCurrencies($currency_code)
$sql = "SELECT code_iso, label, unicode";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE active = 1";
if (! empty($currency_code)) $sql.=" AND code_iso = '".$currency_code."'";
if (! empty($currency_code)) $sql.=" AND code_iso = '".$this->db->escape($currency_code)."'";
//$sql.= " ORDER BY code_iso ASC"; // Not required, a sort is done later

dol_syslog(get_class($this).'::loadCacheCurrencies', LOG_DEBUG);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/societe/class/societe.class.php
Expand Up @@ -1002,7 +1002,7 @@ function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmod
$sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id:"null");
$sql .= ", fk_multicurrency = ".(int) $this->fk_multicurrency;
$sql .= ", multicurrency_code = '".$this->db->escape($this->multicurrency_code)."'";
$sql .= " WHERE rowid = '" . $id ."'";
$sql .= " WHERE rowid = " . (int) $id;

$resql=$this->db->query($sql);
if ($resql)
Expand Down

0 comments on commit f0f6f71

Please sign in to comment.