예제 #1
0
bool updateFile(char *pFile)
{
	char *ext = strrchr(pFile, '.');
	CString file = pFile;

	if (strcmp(ext, ".graal") == 0 || strcmp(ext, ".nw") == 0 || strcmp(ext, ".zelda") == 0)
		CLevel::updateLevel(file);
	else if (strcmp(pFile, "rchelp.txt") == 0)
		RCHelpMessage.load(pFile);
	else if (strcmp(pFile, "rcmessage.txt") == 0)
		RCMessage.load(pFile);
	else if (strcmp(pFile, "serverflags.txt") == 0)
		serverFlags.load(pFile);
	else if (strcmp(pFile, "servermessage.html") == 0)
		loadServerMessage();
	else if (strcmp(pFile, "rules.txt") == 0)
		WordFilter.load("rules.txt");
	else if ( strcmp(pFile, "foldersconfig.txt") == 0 )
	{
		folderConfig.load( "foldersconfig.txt" );

		// Don't allow .. in the folder path.
		for ( int i = 0; i < folderConfig.count(); ++i )
		{
			if ( ((CBuffer)folderConfig[i]).find( ".." ) != -1 )
			{
				folderConfig.remove(i);
				--i;
			}
		}

		getSubDirs();
	}
	else
		return false;

	return true;
}
예제 #2
0
bool CWordFilter::load(char *pFile)
{
	for (int i = 0; i < WordList.count(); i++)
		delete (WordMatch *)WordList[i];
	WordList.clear();
	CStringList lines;
	lines.load(pFile);
	if(lines.count() < 1)
		return false;

	for (int i = 0; i < lines.count(); i++)
	{
		CStringList words;
		words.load(lines[i].text(), " ");
		if (words.count() <= 0)
			continue;

		if (words[0] == "WARNMESSAGE")
		{
			words.remove(0);
			warnmessage = words.join(" ");
		}
			else if (words[0] == "SHOWWORDSTORC")
		{
			showtorc = CHECK_BOOL(words[1].text());
		}
			else if (words[0] == "RULE")
		{
			WordMatch *word = new WordMatch();
			memset(word->check, false, sizeof(word->check));
			memset(word->action, false, sizeof(word->action));

			for (i++; i < lines.count() && lines[i] != "RULEEND"; i++)
			{
				words.load(lines[i].text(), " ");
				if (words.count() <= 0)
					continue;

				if (words[0] == "ACTION" && words.count() >= 2)
				{
					for (int ii = 1; ii < words.count(); ii++)
					{
						if (words[ii] == "ban") word->action[FILTERA_BAN] = true;
						else if (words[ii] == "jail") word->action[FILTERA_JAIL] = true;
						else if (words[ii] == "log") word->action[FILTERA_LOG] = true;
						else if (words[ii] == "replace") word->action[FILTERA_REPLACE] = true;
						else if (words[ii] == "tellrc") word->action[FILTERA_TELLRC] = true;
						else if (words[ii] == "warn") word->action[FILTERA_WARN] = true;
					}
				}
					else if (words[0] == "CHECK" && words.count() >= 2)
				{
					for (int ii = 1; ii < words.count(); ii++)
					{
						if (words[ii] == "chat") word->check[FILTERC_CHAT] = true;
						else if (words[ii] == "nick") word->check[FILTERC_NICK] = true;
						else if (words[ii] == "pm") word->check[FILTERC_PM] = true;
						else if (words[ii] == "toall") word->check[FILTERC_TOALL] = true;
					}
				}
					else if (words[0] == "MATCH" && words.count() >= 2)
				{
					words.remove(0);
					word->match = words.join(" ");
				}
					else if (words[0] == "PRECISION" && words.count() == 2)
				{
					word->precision = (words[1].find('%') >= 0 ? word->match.length() * atoi(words[1].text()) / 100 : atoi(words[1].text()));
				}
					else if (words[0] == "WORDPOSITION" && words.count() == 2)
				{
					if (words[1] == "full") word->position = FILTERP_FULL;
					else if (words[1] == "part") word->position = FILTERP_PART;
					else if (words[1] == "start") word->position = FILTERP_START;
				}
					else if (words[0] == "WARNMESSAGE" && words.count() >= 2)
				{
					words.remove(0);
					word->warnmessage = words.join(" ");
				}
			}

			if (word->precision <= 0)
				word->precision = word->match.length();

			WordList.add(word);
		}
	}

	return true;
}