예제 #1
0
uint32 GDAFile::identifyType(const Columns &columns, const Row &rows, size_t column) const {
	if (!columns || (column >= columns->size()) || !(*columns)[column])
		return -1;

	if ((*columns)[column]->hasField(kGFF4G2DAColumnType))
		return (uint32) (*columns)[column]->getUint(kGFF4G2DAColumnType, -1);

	if (!rows || rows->empty() || !(*rows)[0])
		return -1;

	GFF4Struct::FieldType fieldType = (*rows)[0]->getFieldType(kGFF4G2DAColumn1 + column);

	switch (fieldType) {
		case GFF4Struct::kFieldTypeString:
			return 0;

		case GFF4Struct::kFieldTypeUint:
		case GFF4Struct::kFieldTypeSint:
			return 1;

		case GFF4Struct::kFieldTypeDouble:
			return 2;

		default:
			break;
	}

	return -1;
}
예제 #2
0
    Value Connection::selectValue(const std::string& query)
    {
      Row t = selectRow(query);
      if (t.empty())
        throw NotFound();

      return t.getValue(0);
    }
예제 #3
0
    Value Connection::selectValue(const std::string& query)
    {
      log_debug("selectValue(\"" << query << "\")");
      Row t = selectRow(query);
      if (t.empty())
        throw NotFound();

      return t.getValue(0);
    }
예제 #4
0
파일: IRCBot.cpp 프로젝트: segrax/KiLLARMY
size_t IRCBot::readMemberID( string memberName) {
	size_t memberID = 0;
	
	Row Smoking = _db->memberRead(memberName);
	if(Smoking.empty())
		return 0;

	memberID = ((size_t) Smoking["memberID"]);

	return memberID;
}
예제 #5
0
파일: IRCBot.cpp 프로젝트: segrax/KiLLARMY
size_t IRCBot::readServerName(string serverName) {
	size_t serverID = 0;
	
	if(! _db->ready() )
		return 0;

	Row Smoking = _db->serverRead(serverName);
	if(Smoking.empty())
		return 0;

	serverID = ((size_t) Smoking["serverID"]);

	return serverID;
}
예제 #6
0
QueryData genBiosInfo(QueryContext& context) {
  QueryData results;
  std::string manufacturer;

  WmiRequest wmiComputerSystemReq(
      "select Manufacturer from Win32_ComputerSystem");
  std::vector<WmiResultItem>& wmiComputerSystemResults =
      wmiComputerSystemReq.results();

  if (!wmiComputerSystemResults.empty()) {
    wmiComputerSystemResults[0].GetString("Manufacturer", manufacturer);
    manufacturer = getManufacturer(manufacturer);
  } else {
    return results;
  }

  if (kQueryMap.find(manufacturer) != kQueryMap.end()) {
    WmiRequest wmiBiosReq(std::get<0>(kQueryMap.at(manufacturer)),
                          (std::get<1>(kQueryMap.at(manufacturer))));
    std::vector<WmiResultItem>& wmiResults = wmiBiosReq.results();

    for (unsigned int i = 0; i < wmiResults.size(); ++i) {
      Row r;

      if (manufacturer == "hp") {
        r = getHPBiosInfo(wmiResults[i]);

      } else if (manufacturer == "lenovo") {
        r = getLenovoBiosInfo(wmiResults[i]);

      } else if (manufacturer == "dell") {
        r = getDellBiosInfo(wmiResults[i]);
      }
      if (!r.empty()) {
        results.push_back(r);
      }
    }
  } else {
    LOG(INFO) << "Vendor \"" << manufacturer << "\" is currently not supported";
  }
  return results;
}
예제 #7
0
// Attempt to login to server
void moduleAuth::a_Login( void *buffer, size_t bufferSize ) {
	const byte *bytePtr		= (const byte*) buffer;
	size_t		dataSize	= *((size_t*) bytePtr);
	
	string		username, password;
	Row			memberRow;
    
	// Decrease the buffer, increase the byte ptr
	bufferSize  -= sizeof(size_t);
	bytePtr		+= sizeof(size_t);

	// Test data size against the buffersize
	if( ( dataSize - bufferSize ) )
		return;

	// Grab the username, (grabs until byte 0x00)
	username.append( (const char*) bytePtr);
	
	// Increase the pointer, decrease remaining size
	bufferSize -= username.size() + 1;
	bytePtr += username.size() + 1;

	// Grab the password, (grabs until byte 0x00)
	password.append( (const char *) bytePtr );

	// Read the user row from the member table
	memberRow = _client->databaseGet()->memberRead( username );

	// Check No Result, or member name/password doesn't match entered ones (enforce case)
	if( memberRow.empty() || username.compare( memberRow["nameUser"] ) != 0 || password.compare( memberRow["password"] ) != 0 ) {
        stringstream ircMessage;
		ircMessage << "Login Attempt Failed. v" << _version << " " << username << " from ";
		ircMessage << _client->remoteIPGet() << " (" << _client->ipResolve( _client->remoteIPGet() ) << ")";

		_client->smokingmanGet()->thebotGet()->speak("Auth", ircMessage, channelADMIN);

		_loginAttempts++;
		packetSend( (byte) modAUTH_LoginFailed );
		
        if( _loginAttempts > 2 ) {
            packetSend( (byte) modAUTH_Disconnecting );
            _client->shutdown();
        }

		return;
	}
    
	// Is this member active?
	if( (bool) memberRow["active"] == false) {
		stringstream ircMessage;
		ircMessage << "Inactive member login attempt. v" << _version << " " << username << " from ";
		ircMessage << _client->remoteIPGet() << " (" << _client->ipResolve( _client->remoteIPGet() ) << ")";
		_client->smokingmanGet()->thebotGet()->speak("Auth", ircMessage, channelADMIN);

		string reason = (string) memberRow["reason"];

		packetSend( (byte) modAUTH_MemberInactive, reason );
        packetSend( (byte) modAUTH_Disconnecting );
        _client->shutdown();
		return;
	}

    // 
	_userRow		= memberRow;

    // Check IP
    //
    if( ipValidate(_client->databaseGet(), _client->remoteIPGet(), memberIDGet() ) == false ) {
		stringstream ircMessage;
		ircMessage << "IP has no match. v" << _version << " " << username << " from ";
		ircMessage << _client->remoteIPGet() << " (" << _client->ipResolve( _client->remoteIPGet() ) << ")";
		_client->smokingmanGet()->thebotGet()->speak("Auth", ircMessage, channelADMIN);

		packetSend( (byte) modAUTH_IPInvalid );

        _client->shutdown();
        return;
    }

    if( memberLevel() == levelSPIDZ ) {
        stringstream ircMessage;
        ircMessage << "connected. v" << _version;
        _client->smokingmanGet()->thebotGet()->speak("spidz", ircMessage);

        _client->smokingmanGet()->spidzSet( _client );
    }

	if(!_versionOk) {
		stringstream ircMessage;
		ircMessage << "[" << OSNameGet( _OS ) << "] " << memberUserNameGet() << " Old Client v" << _version << " from ";
		ircMessage << _client->remoteIPGet() << " (" << _client->ipResolve( _client->remoteIPGet() ) << ")";

		_client->smokingmanGet()->thebotGet()->speak("Auth", ircMessage, channelADMIN);
	}

	// Set our last online time
	_client->databaseGet()->memberLastOnlineSet( memberRow["memberID"] );

	// Success!
	_authenticated	= true;

	// Inform the client connection is established
	packetSend( (byte) modAUTH_LoginSuccess );

    // Join the pipe network
	_client->thepipeGet()->userLogin( memberRow, _client );

	// Check members servers
	if(_client->moduleGet<moduleKillarmy>(modKILLARMY))
		_client->moduleGet<moduleKillarmy>(modKILLARMY)->serverCheck();
    
	return;
}
예제 #8
0
파일: xorbasis.cpp 프로젝트: ExpHP/defect
bool is_zero(const Row & row) { return row.empty(); }