Small code cleanup

This commit is contained in:
Tobias Reich 2014-04-21 14:18:13 +02:00
parent c110f3fb28
commit ed79ddce47
2 changed files with 11 additions and 6 deletions

View File

@ -442,15 +442,19 @@ class Album extends Module {
# Call plugins # Call plugins
$this->plugins(__METHOD__, 0, func_get_args()); $this->plugins(__METHOD__, 0, func_get_args());
if (isset($password)&&strlen($password)>0) { if (strlen($password)>0) {
# get hashed password
# Get hashed password
$password = get_hashed_password($password); $password = get_hashed_password($password);
# set hashed password # Set hashed password
$result = $this->database->query("UPDATE lychee_albums SET password = '$password' WHERE id IN ('$this->albumIDs');"); $result = $this->database->query("UPDATE lychee_albums SET password = '$password' WHERE id IN ('$this->albumIDs');");
} else { } else {
# unset password
# Unset password
$result = $this->database->query("UPDATE lychee_albums SET password = NULL WHERE id IN ('$this->albumIDs');"); $result = $this->database->query("UPDATE lychee_albums SET password = NULL WHERE id IN ('$this->albumIDs');");
} }
# Call plugins # Call plugins

View File

@ -82,9 +82,9 @@ function search($database, $settings, $term) {
function get_hashed_password($password) { function get_hashed_password($password) {
# inspired by -> http://alias.io/2010/01/store-passwords-safely-with-php-and-mysql/ # Inspired by http://alias.io/2010/01/store-passwords-safely-with-php-and-mysql/
# A higher "cost" is more secure but consumes more processing power # A higher $cost is more secure but consumes more processing power
$cost = 10; $cost = 10;
# Create a random salt # Create a random salt
@ -96,6 +96,7 @@ function get_hashed_password($password) {
# Hash the password with the salt # Hash the password with the salt
return crypt($password, $salt); return crypt($password, $salt);
} }
?> ?>