Skip to content

Commit 97f1326

Browse files
author
shino
committed
* Change password hashing to sha1
* Fix big typo in some classes (forgot 'new' before Exception !) * No utf8_bin in mysql schemas git-svn-id: http://svn.gna.org/svn/nevertable/trunk@113 8c9cce2d-531c-0410-91e8-f72d6ccfd7b9
1 parent 3de7ba4 commit 97f1326

13 files changed

+26
-22
lines changed

classes/class.auth.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ function SessionBegin()
4343
{
4444
$cookiedata = unserialize(stripslashes($_COOKIE[$config["cookie_name"]]));
4545
if ($cookiedata["auto"] && !isset($_SESSION['user_logged']))
46-
$this->Perform($cookiedata["user"], $cookiedata["md5"], true, false);
46+
$this->Perform($cookiedata["user"], $cookiedata["sha1"], true, false);
4747
}
4848
}
4949

50-
function Perform($login, $passwd, $md5_passwd=false, $cookie=false)
50+
function Perform($login, $passwd, $sha1_passwd=false, $cookie=false)
5151
{
5252
global $config;
5353

@@ -67,8 +67,8 @@ function Perform($login, $passwd, $md5_passwd=false, $cookie=false)
6767
}
6868
$val = $this->db->FetchArray($res);
6969

70-
if (!$md5_passwd)
71-
$passwd = md5($passwd);
70+
if (!$sha1_passwd)
71+
$passwd = Auth::Hash($passwd);
7272

7373
if($passwd == $val['passwd'])
7474
{
@@ -84,7 +84,7 @@ function Perform($login, $passwd, $md5_passwd=false, $cookie=false)
8484
/* create cookie */
8585
$cookiedata["auto"] = true;
8686
$cookiedata["user"] = $_SESSION['user_pseudo'];
87-
$cookiedata["md5"] = $val['passwd'];
87+
$cookiedata["sha1"] = $val['passwd'];
8888
setcookie($config["cookie_name"], serialize($cookiedata), time()+$config["cookie_expire"], $config["cookie_path"], $config["cookie_domain"], false);
8989
}
9090
return true;
@@ -111,6 +111,10 @@ function CloseSession()
111111
setcookie($config["cookie_name"], serialize($cookiedata), time()+$config["cookie_expire"], $config["cookie_path"], $config["cookie_domain"], false);
112112
}
113113

114+
static function Hash($v)
115+
{
116+
return sha1($v);
117+
}
114118
static function Check($level)
115119
{
116120
return (isset($level) && isset($_SESSION['user_logged']) && $_SESSION['user_logged']

classes/class.comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function GetFields()
178178
function SetError($error)
179179
{
180180
$this->error = $error;
181-
throw Exception($this->error);
181+
throw new Exception($this->error);
182182
}
183183

184184
function GetError()

classes/class.map.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function SetFields($fields)
146146
function SetError($error)
147147
{
148148
$this->error = $error;
149-
throw Exception($this->error);
149+
throw new Exception($this->error);
150150
}
151151

152152
function GetError()

classes/class.record.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ function _UpdateUserStats()
348348
function SetError($error)
349349
{
350350
$this->error = $error;
351-
throw Exception($this->error);
351+
throw new Exception($this->error);
352352
}
353353

354354
function GetError()

classes/class.replay.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function IsGoalReached()
195195
function SetError($error)
196196
{
197197
$this->error = $error;
198-
throw Exception($this->error);
198+
throw new Exception($this->error);
199199
}
200200

201201
function GetError()

classes/class.set.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function SetFields($fields)
204204
function SetError($error)
205205
{
206206
$this->error = $error;
207-
throw Exception($this->error);
207+
throw new Exception($this->error);
208208
}
209209

210210
function GetError()

classes/class.smilies.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function IsLoad()
9696
function SetError($error)
9797
{
9898
$this->error = $error;
99-
// throw Exception($this->error);
99+
// throw new Exception($this->error);
100100
}
101101

102102
function GetError()

classes/class.tag.tagboard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function Purge($id)
167167
function SetError($error)
168168
{
169169
$this->error = $error;
170-
throw Exception($this->error);
170+
throw new Exception($this->error);
171171
}
172172

173173
function GetError()

classes/class.user.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ function _CleanFields()
445445
function SetError($error)
446446
{
447447
$this->error = $error;
448-
throw Exception($this->error);
448+
throw new Exception($this->error);
449449
}
450450

451451
function GetError()

forgot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
if (!isset($val['id']))
5858
exit;
5959
$table->db->NewQuery("UPDATE", "users");
60-
$table->db->UpdateSet(array("passwd" => md5($newpass)));
60+
$table->db->UpdateSet(array("passwd" => Auth::Hash($newpass)));
6161
$table->db->Where("id", $val['id']);
6262
$table->db->Limit(1);
6363
$table->db->Query();

0 commit comments

Comments
 (0)