File: //usr/local/share/hostingplatform/api_authentication.inc.php
<?php
class HostingPlatformAuthentication {
public static function checkLogin($username, $password) {
$htpasswd = @file_get_contents(
"/etc/apache2-hostingplatform-api/htpasswd");
$lines = explode("\n", $htpasswd);
foreach($lines as $line) {
$parts = explode(":", $line);
if($parts[0] == $username) {
if(password_verify($password, $parts[1])) {
return true;
}
else {
break;
}
}
}
// Sleep to annoy brute forcers...
sleep(3);
return false;
}
}
?>