function multiip_check_($search, $string) { // prepare query global $time_intervall, $db_login; $sql = $db_login->prepare("SELECT user \n FROM LoginLog \n WHERE {$string} = :search \n AND stamp > NOW() - INTERVAL :time_intervall HOUR \n AND success = 1 \n GROUP BY user"); $sql->bindValue('search', $search, PDO::PARAM_STR); $sql->bindValue('time_intervall', $time_intervall, PDO::PARAM_INT); // on error if (!$sql->execute()) { multiip_log('Could not check %s from LoginLog', $string); exit(1); } // collect records $users = array(); while ($row = $sql->fetch()) { $users[] = $row['user']; } return $users; }
function multiip_check_($db_login, $search, $string) { // prepare query global $time_intervall; $query = sprintf('SELECT user FROM `LoginLog` WHERE %s = "%s" AND ' . 'stamp > NOW() - INTERVAL %d HOUR AND ' . 'success = 1 GROUP BY user', $string, $search, $time_intervall); // send query $r = $db_login->query($query); // on error if (!$r) { multiip_log('Could not check %s from LoginLog', $string); exit(1); } // collect records $users = array(); while ($row = $r->nextRow()) { $users[] = $row['user']; } return $users; }