forked from leftypol/leftypol
hash poster passwords
This commit is contained in:
parent
c7bb61f2ff
commit
8b2f002582
6 changed files with 33 additions and 5 deletions
17
tools/hash-passwords.php
Normal file
17
tools/hash-passwords.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/inc/cli.php';
|
||||
|
||||
$boards = listBoards();
|
||||
foreach ($boards as &$_board) {
|
||||
query(sprintf('ALTER TABLE ``posts_%s`` MODIFY `password` varchar(64) DEFAULT NULL;', $_board['uri'])) or error(db_error());
|
||||
$query = prepare(sprintf("SELECT DISTINCT `password` FROM ``posts_%s``", $_board['uri']));
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
while($entry = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$update_query = prepare(sprintf("UPDATE ``posts_%s`` SET `password` = :password WHERE `password` = :password_org", $_board['uri']));
|
||||
$update_query->bindValue(':password', hashPassword($entry['password']));
|
||||
$update_query->bindValue(':password_org', $entry['password']);
|
||||
$update_query->execute() or error(db_error());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue