id; } // Clean incomming variables $user_id = Dba::escape($user_id); $timestamp = intval($timestamp); $ip = ip2int($ip); // Log this attempt debug_event('API','Login Attempt, IP:' . int2ip($ip) . ' Time:' . $timestamp . ' User:' . $user_id . ' Auth:' . $passphrase,'1'); // Run the query and return the passphrases as we'll have to mangle them // to figure out if they match what we've got $sql = "SELECT * FROM `access_list` WHERE `type`='rpc' AND `user`='$user_id' AND `start` <= '$ip' AND `end` >= '$ip'"; $db_results = Dba::query($sql); while ($row = Dba::fetch_assoc($db_results)) { // Combine and MD5 this mofo $md5pass = md5($timestamp . $row['key']); if ($md5pass === $passphrase) { // Create the Session, in this class for now needs to be moved $data['username'] = $client->username; $data['type'] = 'api'; $data['value'] = $timestamp; $token = vauth::session_create($data); // Insert the token into the streamer $stream = new Stream(); $stream->user_id = $client->id; $stream->insert_session($token); debug_event('API','Login Success, passphrase matched','1'); return array('auth'=>$token,'api'=>self::$version); } // match } // end while debug_event('API','Login Failed, unable to match passphrase','1'); } // handhsake } // API class ?>