Ejemplo n.º 1
0
 public static function addEntry($blid, $username, $ip = null)
 {
     if (isset($ip)) {
         if (!UserLog::isRemoteVerified($blid, $username, $ip)) {
             return "auth.blockland.us verification failed";
         }
     }
     $db = new DatabaseManager();
     UserLog::verifyTable($db);
     $resource = $db->query("SELECT * FROM `user_log` WHERE `blid`='" . $db->sanitize($blid) . "' AND `username`='" . $db->sanitize($username) . "'");
     if ($resource->num_rows == 0) {
         $db->query("INSERT INTO `user_log` (`blid`, `firstseen`, `lastseen`, `username`) VALUES ('" . $db->sanitize($blid) . "', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '" . $db->sanitize($username) . "');");
     } else {
         $db->query("UPDATE `user_log` SET `lastseen` = CURRENT_TIMESTAMP WHERE `blid`='" . $db->sanitize($blid) . "' AND `username`='" . $db->sanitize($username) . "'");
     }
     //update username
     if ($user = UserManager::getFromBLID($blid)) {
         if ($username != $user->getUsername()) {
             $user->setUsername($username);
         }
     }
 }