forked from web-cyradm/web-cyradm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrate.php-dist
69 lines (46 loc) · 1.26 KB
/
migrate.php-dist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<h1>Migration from plain to crypt passwords in table accountusers</h1>
<?php
include WC_BASE . "/config/conf.php";
include "DB.php";
include WC_BASE . "/lib/crypto.php";
if ($CRYPT != "crypt"){
die ("Sorry, only crypt is supported, please check config.inc.php");
}
?>
<h2>Please make a backup of your mysql-databases first!!!</h2>
<pre>
/etc/init.d/mysql.server stop
cd /usr/local/mysql
cp -rp var var-backup
/etc/init.d/mysql.server start
</pre>
<?php
if ($confirmed!="yes"){
?>
<h3>Type "yes" to confirm</h3>
<form action="migrate.php">
<input type="text" name="confirmed">
<input type="submit">
</form>
<?php
}
else if ($confirmed=="yes"){
$query="SELECT * FROM adminuser";
$handle=DB::connect ($DB['DSN'],true);
$result=$handle->query($query);
$cnt=$result->numRows($result);
$pwd=new password;
for ($c=0;$c<$cnt;$c++){
$row=$result->fetchRow(DB_FETCHMODE_ASSOC,$c);
$plainpassword=$row['password'];
$username=$row['username'];
$cryptpassword=$pwd->encrypt($plainpassword,$CRYPT);
$query="UPDATE adminuser SET password='$cryptpassword' WHERE username='$username'";
$handle=DB::connect ($DB['DSN'],true);
$result2=$handle->query($query);
if ($result2){
print "User <b>$username</b> successfully migrated<br>";
}
}
}
?>