/**
 *  Blocks user
 *  @param screenName screen name of the user to be blocked
 *  @param includeEntities When set to true, each tweet will include a node called "entities"
 */
void QTweetBlocksCreate::create(const QString& screenName, bool includeEntities)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("https://api.twitter.com/1/blocks/create.json");

    QUrl urlQuery(url);

    urlQuery.addQueryItem("screen_name", screenName);

    if (includeEntities)
        urlQuery.addQueryItem("include_entities", "true");

    QNetworkRequest req(url);

    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);
    req.setRawHeader(AUTH_HEADER, oauthHeader);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);
    postBody.remove(0, 1);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
示例#2
0
void GamesInsert::handleRequest(GlobalContext *pGlobalContext, QSqlDatabase *db, QHttpRequest *req, QJsonObject &response) {
	UserSession *pUserSession = pGlobalContext->userSession(req->url(), db);
	if (pUserSession == NULL) {
		setErrorResponse(response, 1021, "token are not found");
		return;
	} else if (!pUserSession->isAdmin()) {
		setErrorResponse(response, 1022, "this method only for admin");
		return;
	}

	QUrlQuery urlQuery(req->url());
	QString name = urlQuery.queryItemValue("name");

	if (name.isEmpty()) {
		setErrorResponse(response, 1055, "Parameter name are not found or it is empty");
		return;
	}

	QSqlQuery query(*db);
	query.prepare("INSERT INTO backend_games(name) VALUES(:name)");
	query.bindValue(":name", name);
	if (query.exec()) {
		response["result"] = QString("ok");
		response["id"] = query.lastInsertId().toInt();
	} else {
		setErrorResponse(response, 1056, query.lastError().text());
		return;
	}	
};
示例#3
0
/**
 *   Destroys tweet with id
 *   @param id tweet ID
 *   @param trimUser trims users info
 *   @param includeEntities true to include node entities in response
 */
void QTweetStatusDestroy::destroy(qint64 id,
                                  bool trimUser)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("https://api.twitter.com/1.1/statuses/destroy.json");

    QUrl urlQuery(url);

    urlQuery.addQueryItem("id", QString::number(id));

    if (trimUser)
        urlQuery.addQueryItem("trim_user", "true");

    QNetworkRequest req(url);

    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);
    req.setRawHeader(AUTH_HEADER, oauthHeader);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);
    postBody.remove(0, 1);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
/**
 *  Creates place
 *  @param name the name a place is known as
 *  @param containedWithin placeid within which the new place can be found. Be close as possible with
                           contained place
 *  @param token token found in the response from QTweetGeoSimilarPlaces
 *  @param latLong latitude and longitude
 */
void QTweetGeoPlaceCreate::create(const QString &name,
                                  const QString &containedWithin,
                                  const QString &token,
                                  const QTweetGeoCoord &latLong)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("http://api.twitter.com/1/geo/place.json");
    QUrl urlQuery(url);

    urlQuery.addEncodedQueryItem("name", QUrl::toPercentEncoding(name));
    urlQuery.addQueryItem("contained_within", containedWithin);
    urlQuery.addQueryItem("token", token);
    urlQuery.addQueryItem("lat", QString::number(latLong.latitude()));
    urlQuery.addQueryItem("long", QString::number(latLong.longitude()));

    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);

    QNetworkRequest req(url);
    req.setRawHeader(AUTH_HEADER, oauthHeader);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QByteArray statusPost = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);
    statusPost.remove(0, 1);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, statusPost);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
/**
 *   Sends direct message
 *   @param user The ID of the user who should receive the direct message.
 *   @param text The text of direct message
 *   @param includeEntities When set to true each tweet will include a node called "entities,"
 */
void QTweetDirectMessageNew::post(qint64 user,
                                  const QString &text,
                                  bool includeEntities)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("https://api.twitter.com/1/direct_messages/new.json");

    QUrl urlQuery(url);

    urlQuery.addQueryItem("user_id", QString::number(user));
    urlQuery.addEncodedQueryItem("text", QUrl::toPercentEncoding(text));

    if (includeEntities)
        urlQuery.addQueryItem("include_entities", "true");

    QNetworkRequest req(url);

    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);
    req.setRawHeader(AUTH_HEADER, oauthHeader);

    QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);
    postBody.remove(0, 1);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
/** Creates list
 *  @param user user id
 *  @param name the name of the list
 *  @param mode true for public list, false for private list
 *  @param description the description to give the list.
 */
void QTweetListCreate::create(qint64 user,
                              const QString &name,
                              bool mode,
                              const QString &description)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url(QString("http://api.twitter.com/1/%1/lists.json").arg(user));

    QUrl urlQuery(url);

    urlQuery.addEncodedQueryItem("name", QUrl::toPercentEncoding(name));

    if (!mode)
        urlQuery.addQueryItem("mode", "private");

    if (!description.isEmpty())
        urlQuery.addEncodedQueryItem("description", QUrl::toPercentEncoding(description));

    QNetworkRequest req(url);

    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);
    req.setRawHeader(AUTH_HEADER, oauthHeader);

    QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);
    postBody.remove(0, 1);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
void XMLHttpRequestClass::open(const QString& method, const QString& url, bool async, const QString& username,
                               const QString& password) {
    if (_readyState == UNSENT) {
        _method = method;
        _url.setUrl(url);
        _async = async;

        if (url.toLower().left(METAVERSE_API_URL.length()) == METAVERSE_API_URL) {
            auto accountManager = DependencyManager::get<AccountManager>();
                
            if (accountManager->hasValidAccessToken()) {
                QUrlQuery urlQuery(_url.query());
                urlQuery.addQueryItem("access_token", accountManager->getAccountInfo().getAccessToken().token);
                _url.setQuery(urlQuery);
            }
                
        }
        if (!username.isEmpty()) {
            _url.setUserName(username);
        }
        if (!password.isEmpty()) {
            _url.setPassword(password);
        }
        _request.setUrl(_url);
        setReadyState(OPENED);
    }
}
/**
 *   save a search query
 */
void QTweetSaveSearchQuery::save(const QString& query)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("https://api.twitter.com/1.1/saved_searches/create.json");

    QUrl urlQuery(url);

    urlQuery.addQueryItem("query", query);


    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);
    req.setRawHeader(AUTH_HEADER, oauthHeader);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);
    postBody.remove(0, 1);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
示例#9
0
/**
 *   Parses oauth_token and oauth_token_secret from response of the service provider
 *   and sets m_oauthToken and m_oauthTokenSecret accordingly
 *   @param response response from service provider
 */
void OAuth::parseTokens(const QByteArray& response)
{
    //OAuth spec 5.3, 6.1.2, 6.3.2
    QUrlQuery urlQuery(response);

    m_oauthToken = urlQuery.queryItemValue("oauth_token").toLatin1();
    m_oauthTokenSecret = urlQuery.queryItemValue("oauth_token_secret").toLatin1();
}
示例#10
0
/* ---------------------------------------------------------------------------*/
void UTIL::urlAddQueryItem( QUrl& url, const QString& key, const QString& value )
{
  #if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
      QUrlQuery urlQuery( url );
      urlQuery.addQueryItem( key, value );
      url.setQuery( urlQuery );
  #else
      url.addQueryItem( key, value );
  #endif
}
void
GTransport::setMaxResults (unsigned int limit)
{
    FUNCTION_CALL_TRACE;

    QUrlQuery urlQuery(iUrl);
    if (!urlQuery.hasQueryItem (MAX_RESULTS_TAG)) {
        urlQuery.addQueryItem (MAX_RESULTS_TAG, QString::number (limit));
        iUrl.setQuery(urlQuery);
    }
}
void
GTransport::setShowDeleted ()
{
    FUNCTION_CALL_TRACE;

    QUrlQuery urlQuery(iUrl);
    if (!urlQuery.hasQueryItem (SHOW_DELETED_TAG)) {
        urlQuery.addQueryItem (SHOW_DELETED_TAG, "true");
        iUrl.setQuery(urlQuery);
    }
}
void
GTransport::setStartIndex (const int index)
{
    FUNCTION_CALL_TRACE;

    QUrlQuery urlQuery(iUrl);
    if (urlQuery.hasQueryItem ("start-index"))
        urlQuery.removeQueryItem ("start-index");

    urlQuery.addQueryItem ("start-index", QString::number (index));
    iUrl.setQuery(urlQuery);
}
示例#14
0
/**
 *   Posts a tweet
 *   @param status text of the status update
 *   @param inReplyToStatus ID of a existing tweet is in reply to
 *   @param latLong latitude and longitude
 *   @param placeid a place in the world (use reverse geocoding)
 *   @param displayCoordinates whether or not to put a exact coordinates a tweet has been sent from
 */
void QTweetStatusUpdate::post(const QString &status,
                              qint64 inReplyToStatus,
                              const QTweetGeoCoord& latLong,
                              const QString &placeid,
                              bool displayCoordinates,
                              bool trimUser,
                              bool includeEntities)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("http://api.twitter.com/1/statuses/update.json");

    QUrl urlQuery("http://api.twitter.com/1/statuses/update.json");

    urlQuery.addEncodedQueryItem("status", QUrl::toPercentEncoding(status));

    if (inReplyToStatus != 0)
        urlQuery.addQueryItem("in_reply_to_status_id", QString::number(inReplyToStatus));

    if (latLong.isValid()) {
        urlQuery.addQueryItem("lat", QString::number(latLong.latitude()));
        urlQuery.addQueryItem("long", QString::number(latLong.longitude()));
    }

    if (!placeid.isEmpty())
        urlQuery.addQueryItem("place_id", placeid);

    if (displayCoordinates)
        urlQuery.addQueryItem("display_coordinates", "true");

    if (trimUser)
        urlQuery.addQueryItem("trim_user", "true");

    if (includeEntities)
        urlQuery.addQueryItem("include_entities", "true");

    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);
    QNetworkRequest req(url);
    req.setRawHeader(AUTH_HEADER, oauthHeader);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    //build status post array
    QByteArray statusPost = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);

    //remove '?'
    statusPost.remove(0, 1);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, statusPost);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
void
GTransport::setUpdatedMin (const QDateTime datetime)
{
    FUNCTION_CALL_TRACE;

    mUpdatedMin = datetime;
    QUrlQuery urlQuery(iUrl);

    if (!urlQuery.hasQueryItem (UPDATED_MIN_TAG)) {
        urlQuery.addQueryItem (UPDATED_MIN_TAG,
                           mUpdatedMin.toString (Qt::ISODate));
        iUrl.setQuery(urlQuery);
    }
}
void
GTransport::construct (const QUrl& url)
{
    FUNCTION_CALL_TRACE;

    iUrl = url;
    QUrlQuery urlQuery(iUrl);

    QList<QPair<QString, QString> > queryList = urlQuery.queryItems();
    for (int i=0; i < queryList.size(); i++)
    {
        QPair<QString, QString> pair = queryList.at(i);
        QByteArray leftEncode = QUrl::toPercentEncoding(pair.first);
        QByteArray rightEncode = QUrl::toPercentEncoding(pair.second);
        urlQuery.removeQueryItem(pair.first);
        urlQuery.addQueryItem(leftEncode, rightEncode);
    }
    iUrl.setQuery(urlQuery);
}
void trackerinterface::random(int count)
{
    int randIndex;

    randIndex = rand() % count;

    QSparqlQuery urlQuery(QString("SELECT ?url " \
                                    "WHERE { ?song a nmm:MusicPiece . "  \
                                    "?song nie:url ?url . " \
                                  "?song nie:mimeType ?mime " \
                                  "FILTER ( ?mime != 'audio/x-mpegurl') " \
                                    "} " \
                          "OFFSET %1" \
                                  " LIMIT 1").arg(randIndex) );

    randomResult = conn->exec(urlQuery);

    QObject::connect(randomResult, &QSparqlResult::finished, this, &trackerinterface::randomItemCallback);

}
示例#18
0
QUrl DNSUpdater::getUpdateUrl() const
{
  QUrl url;
#ifdef QT_NO_OPENSSL
  url.setScheme("http");
#else
  url.setScheme("https");
#endif
  url.setUserName(m_username);
  url.setPassword(m_password);

  Q_ASSERT(!m_lastIP.isNull());
  // Service specific
  switch(m_service) {
  case DNS::DYNDNS:
    url.setHost("members.dyndns.org");
    break;
  case DNS::NOIP:
    url.setHost("dynupdate.no-ip.com");
    break;
  default:
    qWarning() << "Unrecognized Dynamic DNS service!";
    Q_ASSERT(0);
  }
  url.setPath("/nic/update");

#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
  url.addQueryItem("hostname", m_domain);
  url.addQueryItem("myip", m_lastIP.toString());
#else
  QUrlQuery urlQuery(url);
  urlQuery.addQueryItem("hostname", m_domain);
  urlQuery.addQueryItem("myip", m_lastIP.toString());
  url.setQuery(urlQuery);
#endif
  Q_ASSERT(url.isValid());

  qDebug() << Q_FUNC_INFO << url.toString();
  return url;
}
示例#19
0
void GamesDelete::handleRequest(GlobalContext *pGlobalContext, QSqlDatabase *db, QHttpRequest *req, QJsonObject &response) {
	UserSession *pUserSession = pGlobalContext->userSession(req->url(), db);
	if (pUserSession == NULL) {
		setErrorResponse(response, 1025, "token are not found");
		return;
	} else if (!pUserSession->isAdmin()) {
		setErrorResponse(response, 1026, "this method only for admin");
		return;
	}
	
	QUrlQuery urlQuery(req->url());
	QString sId = urlQuery.queryItemValue("id");

	if (sId.isEmpty()) {
		setErrorResponse(response, 1057, "Parameter id are not found or it is empty");
		return;
	}
	
	bool bConvert;
	int nId = sId.toInt(&bConvert, 10);
	if (!bConvert) {
		setErrorResponse(response, 1058, "Parameter id must be integer");
		return;
	}
	
	// TODO check exists game

	QSqlQuery query(*db);
	query.prepare("DELETE FROM backend_games WHERE id = :id");
	query.bindValue(":id", nId);
	if (query.exec()) {
		response["result"] = QString("ok");
	} else {
		setErrorResponse(response, 1059, query.lastError().text());
		return;
	}
};
示例#20
0
/**
 *   Generates OAuth signature base
 *   @param url Url with encoded parameters
 *   @param method Http method
 *   @param timestamp timestamp
 *   @param nonce random string
 *   @return signature base
 */
QByteArray OAuth::generateSignatureBase(const QUrl& url, HttpMethod method, const QByteArray& timestamp, const QByteArray& nonce)
{
    // ### TODO: Return parameter should be QSTring

    //OAuth spec. 9.1 http://oauth.net/core/1.0/#anchor14

    //OAuth spec. 9.1.1
    QUrlQuery urlQuery(url);

    QList<QPair<QString, QString> > urlParameters = urlQuery.queryItems();
    QList<QString> normParameters;

    QListIterator<QPair<QString, QString> > i(urlParameters);
    while(i.hasNext()){
            QPair<QString, QString> queryItem = i.next();
            QString normItem = queryItem.first + '=' + queryItem.second;
            normParameters.append(normItem);
    }

    //consumer key
    normParameters.append("oauth_consumer_key=" + m_oauthConsumerKey);

    //token
    if(!m_oauthToken.isEmpty()){
            normParameters.append("oauth_token=" + m_oauthToken);
    }

    //signature method, only HMAC_SHA1
    normParameters.append("oauth_signature_method=HMAC-SHA1");
    //time stamp
    normParameters.append("oauth_timestamp=" + timestamp);
    //nonce
    normParameters.append("oauth_nonce=" + nonce);
    //version
    normParameters.append("oauth_version=1.0");

    //OAuth spec. 9.1.1.1
    qSort(normParameters);

    //OAuth spec. 9.1.1.2
    //QByteArray normString;
    //QListIterator<QByteArray> j(normParameters);
    //while(j.hasNext()){
    //	normString += j.next();
    //	normString += '&';
    //}
    //normString.chop(1);

    QString normString;
    QListIterator<QString> j(normParameters);
    while (j.hasNext()) {
        normString += j.next().toLatin1().toPercentEncoding();
        normString += "%26";
    }
    normString.chop(3);

    //OAuth spec. 9.1.2
    QString urlScheme = url.scheme();
    QString urlPath = url.path();
    QString urlHost = url.host();
    QString normUrl = urlScheme.toUtf8() + "://" + urlHost.toUtf8() + urlPath.toUtf8();

    QString httpm;

    switch (method)
    {
        case OAuth::GET:
                httpm = "GET";
                break;
        case OAuth::POST:
                httpm = "POST";
                break;
        case OAuth::DELETE:
                httpm = "DELETE";
                break;
        case OAuth::PUT:
                httpm = "PUT";
                break;
    }

    //OAuth spec. 9.1.3
    return httpm.toLatin1() + '&' + normUrl.toLatin1().toPercentEncoding() + '&' + normString.toLatin1();
}
示例#21
0
void Scoreboard::handleRequest(GlobalContext *pGlobalContext, QSqlDatabase *db, QHttpRequest *req, QJsonObject &response) {
	int gameid = 0;

	QUrlQuery urlQuery(req->url());
	if (urlQuery.hasQueryItem("gameid")) {
		QString sGameid = urlQuery.queryItemValue("gameid");
		gameid = sGameid.toInt();
	} else {
		gameid = pGlobalContext->getGameID();
	}

	if (gameid == 0) {
		setErrorResponse(response, 1002, "Game not found.");
		return;
	}

	response["gameid"] = gameid;
	response["result"] = QString("ok");

	QMap<QString, ctfight_team> teams;
	
	// TODO select from games_teams
	{
		QSqlQuery query(*db);
		query.prepare(
			" SELECT "
			" games_teams.gameid, "
			" games_teams.teamid, "
			" games_teams.offence, "
			" games_teams.forfeit, "
			" teams.name as teamname "
			" FROM games_teams "
			" INNER JOIN teams ON teams.id = games_teams.teamid "
			" WHERE games_teams.gameid = :gameid"
		);
		query.bindValue(":gameid", gameid);
		bool bResult = query.exec();
		if (!bResult) {
			std::cerr << "[ERROR] " << query.lastError().text().toStdString() << "\n";
		}

		QSqlRecord rec = query.record();
		while (query.next()) {
			QString teamname = query.value(rec.indexOf("teamname")).toString();
			if (!teams.contains(teamname)) {
				teams[teamname] = ctfight_team();
				teams[teamname].name = teamname;
				teams[teamname].id = query.value(rec.indexOf("teamid")).toInt();
			}

			teams[teamname].offence = query.value(rec.indexOf("offence")).toInt();
			teams[teamname].forfeit = query.value(rec.indexOf("forfeit")).toInt();
		}
	}
		
	{
		QSqlQuery query(*db);
		query.prepare(
			" SELECT "
			" services.name as servicename, "
			" services.teamid, "
			" teams.name as teamname, "
			" services.ip, "
			" services.flags, "
			" services.defence, "
			" services.lost, "
			" services.advisers, "
			" services.tries "
			" FROM services "
			" INNER JOIN teams ON teams.id = services.teamid "
			" WHERE gameid = :gameid"
		);
		query.bindValue(":gameid", gameid);
		bool bResult = query.exec();
		if (!bResult) {
			std::cerr << "[ERROR] " << query.lastError().text().toStdString() << "\n";
		}
			
		QSqlRecord rec = query.record();
		int i = 0;
		
		while (query.next()) {
			i++;
			QString teamname = query.value(rec.indexOf("teamname")).toString();
			if (!teams.contains(teamname)) {
				setErrorResponse(response, 1002, "Team did not found in this game.");
				std::cerr << "[ERROR] database incorrect, team did not found in this game.\n";
				return;
			}

			QString servicename = query.value(rec.indexOf("servicename")).toString();
			if (!teams[teamname].services.contains(servicename)) {
				teams[teamname].services[servicename] = ctfight_service();
			}
			
			int flags = query.value(rec.indexOf("flags")).toInt();
			int defence = query.value(rec.indexOf("defence")).toInt();
			int lost = query.value(rec.indexOf("lost")).toInt();
			int advisers = query.value(rec.indexOf("advisers")).toInt();
			int tries = query.value(rec.indexOf("tries")).toInt();
			
			QString serviceip = query.value(rec.indexOf("ip")).toString();
			teams[teamname].services[servicename].name = servicename;
			teams[teamname].services[servicename].ip = serviceip;
			
			teams[teamname].services[servicename].flags = flags;
			teams[teamname].services[servicename].defence = defence;
			teams[teamname].services[servicename].lost = lost;
			teams[teamname].services[servicename].advisers = advisers;
			teams[teamname].services[servicename].tries = tries;
		
			teams[teamname].flags += flags;
			teams[teamname].defence += defence;
			teams[teamname].lost += lost;
			teams[teamname].advisers += advisers;
			teams[teamname].tries += tries;

			// calculate score for team
			teams[teamname].score = 
				teams[teamname].offence
				+ teams[teamname].defence
				+ teams[teamname].advisers
				- teams[teamname].forfeit;
		}

		// check
		if (i == 0) {
			setErrorResponse(response, 1002, "Game with this id did not found.");
			return;
		}

		// calculate places
		QVector<int> places;
		foreach (ctfight_team teamval, teams) {
			if (!places.contains(teamval.score))
				places.push_back(teamval.score);
		}
		qSort(places);

		foreach (ctfight_team teamval, teams) {
			teams[teamval.name].place = places.size() - places.lastIndexOf(teamval.score);
		}

		// serialize to json
		QJsonObject scoreboard;
		foreach (ctfight_team teamval, teams) {
			scoreboard[teamval.name] = teamval.toJsonObject();
		}
		response["scoreboard"] = scoreboard;
	}