Example #1
0
void StepManiaLanServer::AnalizeChat(PacketFunctions &Packet, const unsigned int clientNum)
{
	CString message = Packet.ReadNT();
	if (message.at(0) == '/')
	{
		CString command = message.substr(1, message.find(" ")-1);
		if ((command.compare("list") == 0)||(command.compare("have") == 0))
		{
			if (command.compare("list") == 0)
			{
				Reply.ClearPacket();
				Reply.Write1(NSCCM + NSServerOffset);
				Reply.WriteNT(ListPlayers());
				SendNetPacket(clientNum, Reply);
			}
			else
			{
				message = "";
				message += Client[clientNum]->Player[0].name;
				if (Client[clientNum]->twoPlayers)
					message += "&";
				message += Client[clientNum]->Player[1].name;
				message += " forces has song.";
				Client[clientNum]->forceHas = true;
				ServerChat(message);
			}
		}
		else
		{
			if (clientNum == 0)
			{
				if (command.compare("force_start") == 0)
					ForceStart();
				if (command.compare("kick") == 0)
				{
					CString name = message.substr(message.find(" ")+1);
					Kick(name);
				}
				if (command.compare("ban") == 0)
				{
					CString name = message.substr(message.find(" ")+1);
					Ban(name);
				}
			}
			else
			{
				Reply.ClearPacket();
				Reply.Write1(NSCCM + NSServerOffset);
				Reply.WriteNT("You do not have permission to use server commands.");
				SendNetPacket(clientNum, Reply);
			}
		}
	}
	else
		RelayChat(message, clientNum);
}
Example #2
0
CString CHTTPSock::GetParam(const CString& sName,
                            const map<CString, VCString>& msvsParams,
                            const CString& sFilter) {
    CString sRet = GetRawParam(sName, msvsParams);
    sRet.Trim();

    for (size_t i = 0; i < sFilter.length(); i++) {
        sRet.Replace(CString(sFilter.at(i)), "");
    }

    return sRet;
}
Example #3
0
size_t CHTTPSock::GetParamValues(const CString& sName, VCString& vsRet,
                                 const map<CString, VCString>& msvsParams,
                                 const CString& sFilter) {
    vsRet.clear();

    map<CString, VCString>::const_iterator it = msvsParams.find(sName);

    if (it != msvsParams.end()) {
        for (CString sParam : it->second) {
            sParam.Trim();

            for (size_t i = 0; i < sFilter.length(); i++) {
                sParam.Replace(CString(sFilter.at(i)), "");
            }
            vsRet.push_back(sParam);
        }
    }

    return vsRet.size();
}
Example #4
0
bool CIniFile::ReadString(const char* ini_str)
{
  CString   line;
  CString   keyname, valuename, value;
  CString::size_type pLeft, pRight;

  Clear();
  CString _str = ini_str;
  while( getline( _str, line)) {
    // To be compatible with Win32, check for existence of '\r'.
    // Win32 files have the '\r' and Unix files don't at the end of a line.
    // Note that the '\r' will be written to INI files from
    // Unix so that the created INI file can be read under Win32
    // without change.
    //printf("str=%s \n line=%s\n",_str.c_str(),line.c_str());
    if ( line[line.length() - 1] == '\r')
      line = line.substr( 0, line.length() - 1);

    if ( line.length()) {
      // Check that the user hasn't openned a binary file by checking the first
      // character of each line!
      if ( !isprint( line.at(0))) {
//       printf( "Failing on char %d\n", line[0]);
//       f.close();
//        return false;
      };
      if (( pLeft = line.find_first_of(";#[=:")) != CString::npos) {
       switch ( line[pLeft]) {
       case '[':
         if ((pRight = line.find_last_of("]")) != CString::npos &&
              pRight > pLeft) {
           keyname = line.substr( pLeft + 1, pRight - pLeft - 1);
           AddKeyName( keyname);
//           printf("Section: %s\n",keyname.c_str());
         }
       break;

       case '=':
//       case ':':
         valuename = line.substr( 0, pLeft);
         value = line.substr( pLeft + 1);
         AddValue( keyname, valuename, value);
//         printf("%s=%s\n",valuename.c_str(),value.c_str());
       break;

       case ';':
       case '#':
         if ( !names.size())
            HeaderComment( line.substr( pLeft + 1));
          else
            KeyComment( keyname, line.substr( pLeft + 1));
       break;
       };//switch()
      }//if(( pLeft = line.find_first_of(";#[=")) != CString::npos)
    };//if ( line.length())
  };//while( getline( ini_str, line))

  if(minSize <= 0)
    return true;

  if ( names.size())
    return true;

  return false;
};