本文整理匯總了PHP中newznab\db\Settings::Prepare方法的典型用法代碼示例。如果您正苦於以下問題:PHP Settings::Prepare方法的具體用法?PHP Settings::Prepare怎麽用?PHP Settings::Prepare使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類newznab\db\Settings
的用法示例。
在下文中一共展示了Settings::Prepare方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: needUpdate
It is intended for use ONLY if you have a *lot* of users, as this is not
secure (a user's email addresses may be known to other users). If you only have
a few users then run setUsersPasswordHash.php for each of them instead.
WARNING;
$usage = "\nUsage: php {$argv[0]} <IUnderStandTheRisks>";
echo $colorCLI->warning($warning);
if ($argc != 2) {
exit($colorCLI->error("\nWrong number of parameters{$usage}"));
} else {
if ($argv[1] !== 1 && $argv[1] != '<IUnderStandTheRisks>' && $argv[1] != 'IUnderStandTheRisks' && $argv[1] != 'true') {
exit($colorCLI->error("\nInvalid parameter(s){$usage}"));
}
}
$pdo = new Settings();
$users = $pdo->query("SELECT id, username, email, password FROM users");
$update = $pdo->Prepare('UPDATE users SET password = :password WHERE id = :id');
$Users = new Users(['Settings' => $pdo]);
foreach ($users as $user) {
if (needUpdate($user)) {
$hash = $Users->hashPassword($user['email']);
if ($hash !== false) {
$update->execute([':password' => $hash, ':id' => $user['id']]);
echo $colorCLI->primary('Updating hash for user:') . $user['username'];
} else {
echo $colorCLI->error('Error updating hash for user:') . $user['username'];
}
}
}
function needUpdate($user)
{
global $colorCLI;