Exemplo n.º 1
0
void CWebSock::GetAvailSkins(VCString& vRet) const {
	vRet.clear();

	CString sRoot(GetSkinPath("_default_"));

	sRoot.TrimRight("/");
	sRoot.TrimRight("_default_");
	sRoot.TrimRight("/");

	if (!sRoot.empty()) {
		sRoot += "/";
	}

	if (!sRoot.empty() && CFile::IsDir(sRoot)) {
		CDir Dir(sRoot);

		for (unsigned int d = 0; d < Dir.size(); d++) {
			const CFile& SubDir = *Dir[d];

			if (SubDir.IsDir() && SubDir.GetShortName() == "_default_") {
				vRet.push_back(SubDir.GetShortName());
				break;
			}
		}

		for (unsigned int e = 0; e < Dir.size(); e++) {
			const CFile& SubDir = *Dir[e];

			if (SubDir.IsDir() && SubDir.GetShortName() != "_default_" && SubDir.GetShortName() != ".svn") {
				vRet.push_back(SubDir.GetShortName());
			}
		}
	}
}
Exemplo n.º 2
0
void CWebSock::GetAvailSkins(VCString& vRet) const {
	vRet.clear();

	CString sRoot(GetSkinPath("_default_"));

	sRoot.TrimRight("/");
	sRoot.TrimRight("_default_");
	sRoot.TrimRight("/");

	if (!sRoot.empty()) {
		sRoot += "/";
	}

	if (!sRoot.empty() && CFile::IsDir(sRoot)) {
		CDir Dir(sRoot);

		for (const CFile* pSubDir : Dir) {
			if (pSubDir->IsDir() && pSubDir->GetShortName() == "_default_") {
				vRet.push_back(pSubDir->GetShortName());
				break;
			}
		}

		for (const CFile* pSubDir : Dir) {
			if (pSubDir->IsDir() && pSubDir->GetShortName() != "_default_" && pSubDir->GetShortName() != ".svn") {
				vRet.push_back(pSubDir->GetShortName());
			}
		}
	}
}
Exemplo n.º 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();
}
Exemplo n.º 4
0
void CUrlBufferModule::OnModCommand(const CString& sCommand) 
{
	CString command = sCommand.Token(0).AsLower().Trim_n();
	
	if (command == "help") 
	{
		CTable CmdTable;

		CmdTable.AddColumn("Command");
		CmdTable.AddColumn("Description");

		CmdTable.AddRow();
		CmdTable.SetCell("Command", "ENABLE");
		CmdTable.SetCell("Description", "Activates link buffering.");

		CmdTable.AddRow();
		CmdTable.SetCell("Command", "DISABLE");
		CmdTable.SetCell("Description", "Deactivates link buffering.");

		CmdTable.AddRow();
		CmdTable.SetCell("Command", "ENABLELOCAL");
		CmdTable.SetCell("Description", "Enables downloading of each link to local directory.");

		CmdTable.AddRow();
		CmdTable.SetCell("Command", "DISABLELOCAL");
		CmdTable.SetCell("Description", "Disables downloading of each link to local directory.");

		CmdTable.AddRow();
		CmdTable.SetCell("Command","ENABLEPUBLIC");
		CmdTable.SetCell("Description", "Enables the usage of !showlinks publicly, by other users.");

		CmdTable.AddRow();
        CmdTable.SetCell("Command","DISABLEPUBLIC");
        CmdTable.SetCell("Description", "Disables the usage of !showlinks publicly, by other users.");

		CmdTable.AddRow();
		CmdTable.SetCell("Command", "DIRECTORY <#directory>");
		CmdTable.SetCell("Description", "Sets the local directory where the links will be saved.");
		
		CmdTable.AddRow();
		CmdTable.SetCell("Command", "CLEARBUFFER");
		CmdTable.SetCell("Description", "Empties the link buffer.");
		
		CmdTable.AddRow();
		CmdTable.SetCell("Command", "BUFFERSIZE <#size>");
		CmdTable.SetCell("Description", "Sets the size of the link buffer. Only integers >=0.");
		
		CmdTable.AddRow();
		CmdTable.SetCell("Command", "SHOWSETTINGS");
		CmdTable.SetCell("Description", "Prints all the settings.");

		CmdTable.AddRow();
        CmdTable.SetCell("Command", "BUFFERALLLINKS");
        CmdTable.SetCell("Description", "Toggles the buffering of all links or only image links.");

        CmdTable.AddRow();
        CmdTable.SetCell("Command", "REUPLOAD");
        CmdTable.SetCell("Description", "Toggles the reuploading of image links to imgur.");

		CmdTable.AddRow();
		CmdTable.SetCell("Command", "SHOWLINKS <#number>");
		CmdTable.SetCell("Description", "Prints <#number> or <#buffersize> number of cached links.");

		CmdTable.AddRow();
		CmdTable.SetCell("Command", "HELP");
		CmdTable.SetCell("Description", "This help.");

		PutModule(CmdTable);
		return;
	} else if (command == "enable") 
	{
		SetNV("enable","true",true);
		PutModule("Enabled buffering");
	} else if (command == "disable") 
	{
		SetNV("enable","false",true);
		PutModule("Disabled buffering");
	} else if (command == "enablelocal")
	{
		if(GetNV("directory") == "")
		{
			PutModule("Directory is not set. First set a directory and then enable local caching");
			return;
		}
		SetNV("enablelocal","true",true);
		PutModule("Enabled local caching");
	} else if (command == "disablelocal")
	{
		SetNV("enablelocal", "false", true);
		PutModule("Disabled local caching");
	} else if (command == "enablepublic")
	{
		SetNV("enablepublic", "true", true);
		PutModule("Enabled public usage of showlinks.");
	} else if (command == "disablepublic")
        {
                SetNV("enablepublic", "false", true);
                PutModule("Disabled public usage of showlinks.");
        } else if (command == "directory") 
	{
		CString dir=sCommand.Token(1).Replace_n("//", "/").TrimRight_n("/") + "/";
		if (!isValidDir(dir))
		{
			PutModule("Error in directory name. Avoid using: | ; ! @ # ( ) < > \" ' ` ~ = & ^ <space> <tab>");
			return;
		}
		// Check if file exists and is directory
		if (dir.empty() || !CFile::Exists(dir) || !CFile::IsDir(dir, false))
		{
			PutModule("Invalid path or no write access to ["+ sCommand.Token(1) +"].");
			return;
		} 
		SetNV("directory", dir, true);
		PutModule("Directory for local caching set to " + GetNV("directory"));
	} else if (command == "clearbuffer")
	{
		lastUrls.clear();
		nicks.clear();
	} else if (command == "buffersize")
	{
		unsigned int bufSize = sCommand.Token(1).ToUInt();
		if(bufSize==0 || bufSize==UINT_MAX)
		{
			PutModule("Error in buffer size. Use only integers >= 0.");
			return;
		}
		SetNV("buffersize", CString(bufSize), true);
		PutModule("Buffer size set to " + GetNV("buffersize")); 
	} else if (command == "showsettings")
	{
		for(MCString::iterator it = BeginNV(); it != EndNV(); it++)
		{
			PutModule(it->first.AsUpper() + " : " + it->second);
		}
	} else if(command == "bufferalllinks"){
		SetNV("bufferalllinks", CString(!GetNV("bufferalllinks").ToBool()), true); 
		PutModule( CString(GetNV("bufferalllinks").ToBool()?"Enabled":"Disabled") + " buffering of all links.");
	} else if(command == "reupload"){
                SetNV("reupload", CString(!GetNV("reupload").ToBool()), true);
                PutModule( CString(GetNV("reupload").ToBool()?"Enabled":"Disabled") + " reuploading of images.");
    } else if (command == "showlinks")
	{
		 if(lastUrls.empty())
                        PutModule("No links were found...");
                 else
                 {
                        unsigned int maxLinks = GetNV("buffersize").ToUInt();
                        unsigned int size = sCommand.Token(1).ToUInt();
                        if(size!=0 && size<UINT_MAX) //if it was a valid number
                              maxLinks = size;
			unsigned int maxSize = lastUrls.size()-1;
			for(unsigned int i=0; i<=maxSize && i< maxLinks; i++)
		    {
                		PutModule(nicks[maxSize-i] + ": " + lastUrls[maxSize-i]);
            }
  		 }
	} else
	{
		PutModule("Unknown command! Try HELP.");
	}
}