Example #1
0
void cServerDC::AfterUserLogin(cConnDC *conn)
{
	ostringstream os;
	if(conn->Log(3))
		conn->LogStream() << "Entered the hub." << endl;
	mCo->mTriggers->TriggerAll(eTF_MOTD, conn);

	// The user has to change password
	if(conn->mRegInfo && conn->mRegInfo->mPwdChange) {

		os << _("You must set your password now using +passwd command.");
		DCPrivateHS(os.str(), conn);
		DCPublicHS(os.str(), conn);
		conn->SetTimeOut(eTO_SETPASS, mC.timeout_length[eTO_SETPASS], this->mTime);
		os.str("");
	}

	// send the hub topic
	if (!mC.hub_topic.empty()) {
		string topic("$HubTopic ");
		topic += mC.hub_topic + "|";
		conn->Send(topic, false);
	}

	if (mC.send_user_info) {
		os << _("Your information") << ":\r\n";
		conn->mpUser->DisplayInfo(os, eUC_OPERATOR);
		DCPublicHS(os.str(), conn);
	}

	if(mUserList.Size() > mUsersPeak)
		mUsersPeak = mUserList.Size();
	#ifndef WITHOUT_PLUGINS
	if (!mCallBacks.mOnUserLogin.CallAll(conn->mpUser)) {
		conn->CloseNow();
		return;
	}
	#endif

	if ((conn->mpUser->mClass >= eUC_NORMUSER) && (conn->mpUser->mClass <= eUC_MASTER)) {
		if (mC.msg_welcome[conn->mpUser->mClass].size()) {
			string ToSend;
			ReplaceVarInString(mC.msg_welcome[conn->mpUser->mClass], "nick", ToSend, conn->mpUser->mNick);
			ReplaceVarInString(ToSend, "CC", ToSend, conn->mCC);
			DCPublicHSToAll(ToSend);
		}
	}
}
Example #2
0
bool cTriggerConsole::CheckData(cfBase *cmd, cTrigger &data)
{
	if(data.mDefinition.empty()) {
		*cmd->mOS << _("The definition is empty or not specified. Please define it with -d option.");
		return false;
	}
	size_t pos = data.mDefinition.rfind("dbconfig");
	if(pos != string::npos) {
		*cmd->mOS << _("It's not allowed to define dbconfig file as trigger.") << "\n";
		cConnDC *conn = (cConnDC *) cmd->mConn;
		ostringstream message;
		message << autosprintf(_("User '%s' tried to define dbconfig as trigger"), conn->mpUser->mNick.c_str());
		mOwner->mServer->ReportUserToOpchat(conn, message.str());
		return false;
	}
	FilterPath(data.mDefinition);
	string vPath(mOwner->mServer->mConfigBaseDir), triggerPath, triggerName;
	ExpandPath(vPath);
	GetPath(data.mDefinition, triggerPath, triggerName);
	ReplaceVarInString(triggerPath, "CFG", triggerPath, vPath);
	ExpandPath(triggerPath);

	if ((triggerPath.substr(0, vPath.length()) != vPath)) {
		(*cmd->mOS) << autosprintf(_("The file %s for the trigger %s must be located in %s configuration folder, use %%[CFG] variable, for example: %%[CFG]/%s"), data.mDefinition.c_str(), data.mCommand.c_str(), HUB_VERSION_NAME, triggerName.c_str());
		return false;
	}

	return true;
}
Example #3
0
int cServerDC::SaveFile(const string &file, const string &text)
{
	string filename;
	ReplaceVarInString(file, "CFG", filename, mConfigBaseDir);
	ofstream os(file.c_str());
	if(!os.is_open())
		return 0;
	os << text << endl;
	os.close();
	return 1;
}
Example #4
0
/*!
    \fn ReplaceVarInString(const string&,const string &varname,string &dest, __int64 by)
 */
void ReplaceVarInString(const string &src,const string &varname,string &dest, __int64 by)
{
	ReplaceVarInString(src, varname, dest, StringFrom(by));
}
Example #5
0
/*!
    \fn ReplaceVarInString(const string&,const string &varname,string &dest, long by)
 */
void ReplaceVarInString(const string &src,const string &varname,string &dest, long by)
{
	ostringstream os;
	os << by;
	ReplaceVarInString(src, varname, dest, os.str());
}