diff options
Diffstat (limited to 'src/mods')
39 files changed, 2745 insertions, 0 deletions
diff --git a/src/mods/Makefile b/src/mods/Makefile new file mode 100644 index 0000000..1b0712b --- /dev/null +++ b/src/mods/Makefile @@ -0,0 +1,9 @@ +MAKE=`tail -n 1 ../../make.version` +all: mods +mods: + @${MAKE} -C ./commands #//<< + @${MAKE} -C ./html +clean: + @${MAKE} -C ./commands clean #//<< + @${MAKE} -C ./html clean + @if test -d ../../mods; then rm -Rf ../../mods; fi diff --git a/src/mods/commands/Makefile.in b/src/mods/commands/Makefile.in new file mode 100644 index 0000000..42884b6 --- /dev/null +++ b/src/mods/commands/Makefile.in @@ -0,0 +1,18 @@ +MODS=$(addprefix ../../../mods/commands/, $(SRCS:.cpp=.so)) +CC=COMPILER +INCLUDES=`cat ../../includes.add` +CFLAGS=`cat ../cflags.add` +all: mods +$(MODS): + @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi + @$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/` + @echo -n "Command module `basename $@ | sed s/\.so// | sed s/yc_//` " + @du -hc $@ | tail -n 1 | sed s/total// | sed "s/ //g" +infotext: + @echo Compiling command modules +mods: infotext $(MODS) + @echo "Num of command modules: " + @ls ../../../mods/commands/*.so | wc -l +clean: + @echo Cleaning command modules + @if test -d ../../../mods/commands; then rm -Rf ../../../mods/commands; fi diff --git a/src/mods/commands/yc_about.cpp b/src/mods/commands/yc_about.cpp new file mode 100644 index 0000000..b4449a1 --- /dev/null +++ b/src/mods/commands/yc_about.cpp @@ -0,0 +1,83 @@ +/*:* + *: File: ./src/mods/commands/yc_about.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params = (vector<string>*) c->elem[2]; // param array + chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + + if ( ! params->empty() ) + { + vector<string>::iterator iter = params->begin(); + string s_searched_user( *iter ); + bool b_found; + user* p_searched_user = p_chat->get_user( s_searched_user, b_found ); + + if ( b_found ) + { + string s_msg = "<b>" + p_searched_user->get_colored_name() + "</b>" + + p_conf->get_elem("chat.msgs.userhasstatus") + "<b>" + + tool::int2string(p_searched_user->get_status()) + + "</b>, " + + p_conf->get_elem("chat.msgs.userinroom") + "<b>" + + p_searched_user->get_room()->get_name() + + "</b><br>\n" + + p_conf->get_elem("chat.msgs.lastactivity") + "<b>" + + tool::int2string((int)( p_searched_user->get_last_activity())) + + "</b><br>\n"; + p_user->msg_post( &s_msg ); + } + else + { + string s_msg = "<font color=\"#" + + p_conf->get_elem("chat.html.errorcolor") + + "\"><b>" + + s_searched_user + "</b> " + + p_conf->get_elem("chat.msgs.err.notavailable") + + "</font><br>\n"; + p_user->msg_post( &s_msg ); + + } + } + + return 0; + } + +} + diff --git a/src/mods/commands/yc_all.cpp b/src/mods/commands/yc_all.cpp new file mode 100644 index 0000000..24edb56 --- /dev/null +++ b/src/mods/commands/yc_all.cpp @@ -0,0 +1,73 @@ +/*:* + *: File: ./src/mods/commands/yc_all.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include <iostream> +#include "../../chat/chat.h" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int valid_color( string ); + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params= (vector<string>*) c->elem[2]; // param array + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT; + + string s_tmp = ""; + string s_msg = ""; + + + if ( ! params->empty() ) + { + vector<string>::iterator iter = params->begin(); + for ( iter = params->begin(); iter != params->end(); iter++ ) + s_tmp.append( *iter + " " ); + + s_msg = p_timr->get_time() + " <b><font color=\"#" + + p_conf->get_elem("chat.html.sysmsgcolor") + + "\"> " + + p_conf->get_elem("chat.msgs.system"); + + p_chat->string_replacer(&s_tmp); + s_msg.append( s_tmp + "</font></b><br>\n" ); + p_chat->msg_post( &s_msg ); + return 0; + } + + s_msg = p_conf->colored_error_msg("chat.msgs.err.wrongcommandusage"); + p_user->msg_post(s_msg); + return 0; + } +} + diff --git a/src/mods/commands/yc_away.cpp b/src/mods/commands/yc_away.cpp new file mode 100644 index 0000000..0e879fc --- /dev/null +++ b/src/mods/commands/yc_away.cpp @@ -0,0 +1,96 @@ +/*:* + *: File: ./src/mods/commands/yc_away.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" +#include "../../chat/room.h" +#include "../../chat/user.h" + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user* p_user = (user*) c->elem[1]; // the corresponding user + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + vector<string> *params = (vector<string>*) c->elem[2]; // param array + + string s_msg; + string s_away; + string s_col; + + vector<string>::iterator iter; + + string s_time = p_timr->get_time(); + + s_away.append( s_time ).append( " " ); + + s_msg = s_time + + " " + + p_user->get_colored_bold_name() + + " " + + p_conf->get_elem("chat.msgs.setmodeaway") + + "<font color=" + p_user->get_col2() + ">"; + + if ( params->size() > 0 ) + { + s_msg.append(": "); + for ( iter = params->begin(); iter != params->end(); iter++ ) + { + s_msg.append( " " + *iter ); + s_away.append( *iter + " " ); + } + } + else + { + s_msg.append("."); + } + + s_msg.append( "</font><br>\n" ); + + room* p_room = p_user->get_room(); + + // Remove ' from away message: + auto unsigned int pos; + + do + { + pos = s_away.find_first_of( "'" ); + if ( pos == string::npos ) + break; + s_away.replace( pos, 1, "\"" ); + } + while (true); + + p_user->set_away( true, s_away ); + p_room->reload_onlineframe(); + p_room->msg_post ( &s_msg ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_col.cpp b/src/mods/commands/yc_col.cpp new file mode 100644 index 0000000..dca1bde --- /dev/null +++ b/src/mods/commands/yc_col.cpp @@ -0,0 +1,112 @@ +/*:* + *: File: ./src/mods/commands/yc_col.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include <iostream> +#include "../../wrap.h" +#include "../../chat/room.h" +#include "../../chat/user.h" +#include "../../tool/tool.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int valid_color( string ); + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + + user *p_user = (user*)c->elem[1]; // the corresponding user + vector<string> *params= (vector<string>*) c->elem[2]; // param array + + string s_color; + string s_color2; + + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + if ( params->empty() ) + { + s_color = p_conf->get_elem( "chat.html.user.color1" ); + s_color2 = p_conf->get_elem( "chat.html.user.color2" ); + } + else + { + s_color = (string) params->front(); + params->erase( params->begin() ); + if ( ! params->empty() ) + s_color2 = (string) params->front(); + else + s_color2 = p_conf->get_elem( "chat.html.user.color1" ); + } + + s_color = tool::to_lower( s_color ); + s_color2 = tool::to_lower( s_color2 ); + + if( valid_color(s_color) != 1 ) + { + string *answerstring=new string(s_color + " is not a valid color.<br>\n"); + p_user->msg_post( answerstring ); + } + else if( valid_color(s_color2) != 1 ) + { + string *answerstring=new string( s_color2 + " is not a valid color.<br>\n"); + p_user->msg_post( answerstring ); + } + else + { + string *answerstring=new string(p_timr->get_time() + " " + p_user->get_colored_bold_name()+ " changes color to <font color=\"#" + + s_color + "\">" + s_color + "</font> <font color=\"#" + + s_color2 + "\">" + s_color2 + "</font><br>\n"); + p_user->get_room()->msg_post( answerstring ); + p_user->set_col1(s_color); + p_user->set_col2(s_color2); + p_user->get_room()->reload_onlineframe(); + } + + return 0; + } + int valid_color( string s_color ) + { + + if(s_color.size()!=6) + return 0; + string valid="abcdef0123456789"; + for(int i=0;i<s_color.size();i++) + { + string s_char=s_color.substr(i,1); + if(valid.find(s_char)==string::npos) + return 0; + } + + return 1; + } + +} + diff --git a/src/mods/commands/yc_compopt.cpp b/src/mods/commands/yc_compopt.cpp new file mode 100644 index 0000000..43e5e1b --- /dev/null +++ b/src/mods/commands/yc_compopt.cpp @@ -0,0 +1,47 @@ +/*:* + *: File: ./src/mods/commands/yc_compopt.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include <iostream> +#include "../../msgs.h" +#include "../../chat/user.h" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int valid_color( string ); + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + user *p_user = (user*)c->elem[1]; // the corresponding user + p_user->msg_post( tool::ychat_version() + " " + UNAME + "<br>\n" + COMPOPT + "<br>\n"); + + return 0; + } +} + diff --git a/src/mods/commands/yc_exec.cpp b/src/mods/commands/yc_exec.cpp new file mode 100644 index 0000000..6f2d533 --- /dev/null +++ b/src/mods/commands/yc_exec.cpp @@ -0,0 +1,90 @@ +/*:* + *: File: ./src/mods/commands/yc_exec.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" +#include "../../chat/room.h" +#include "../../chat/user.h" +#include <unistd.h> +#include <sys/wait.h> +#include <stdio.h> +#include <sys/types.h> +#include <fcntl.h> + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user* p_user = (user*) c->elem[1]; // the corresponding user + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + vector<string> *params = (vector<string>*) c->elem[2]; // param array + + string s_command; + string s_msg = p_timr->get_time(); + string s_output; + + vector<string>::iterator iter; + for ( iter = params->begin(); iter != params->end(); iter++ ) + s_command.append( " " + *iter ); + + s_command.append(" 2>error.log"); + + s_msg.append( " " + s_command + "<br>\n" ); + + p_user->msg_post( &s_msg ); + + FILE *file; + char buffer[READBUF]; + + if( (file=popen(s_command.c_str(), "r")) == NULL ) + { + s_output = "<font color=\"#" + + p_conf->get_elem("chat.html.errorcolor") + + p_conf->get_elem("chat.msgs.err.execcommand") + + "</font><br>\n"; + p_user->msg_post( &s_output ); + } + else + { + s_output.append("<hr>\n"); + while(true) + { + if(fgets(buffer, READBUF, file) == NULL) + break; + + s_output.append( string(buffer) + "<br>\n" ); + } + + p_user->msg_post( &s_output ); + pclose(file); + } + + return 0; + } +} + diff --git a/src/mods/commands/yc_fake.cpp b/src/mods/commands/yc_fake.cpp new file mode 100644 index 0000000..3eb1442 --- /dev/null +++ b/src/mods/commands/yc_fake.cpp @@ -0,0 +1,54 @@ +/*:* + *: File: ./src/mods/commands/yc_fake.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" +#include "../../chat/room.h" +#include "../../chat/user.h" + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user* p_user = (user*) c->elem[1]; // the corresponding user + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + + bool b_fake = p_user->get_fake(); + + string s_msg = (b_fake == 1 + ? p_conf->get_elem("chat.msgs.unsetmodefake") + "<br>\n" + : p_conf->get_elem("chat.msgs.setmodefake") + "<br>\n"); + + + p_user->set_fake( !b_fake ); + p_user->get_room()->reload_onlineframe(); + p_user->msg_post ( &s_msg ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_getroom.cpp b/src/mods/commands/yc_getroom.cpp new file mode 100644 index 0000000..4b22d81 --- /dev/null +++ b/src/mods/commands/yc_getroom.cpp @@ -0,0 +1,77 @@ +/*:* + *: File: ./src/mods/commands/yc_getroom.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params = (vector<string>*) c->elem[2]; // param array + chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + + if ( ! params->empty() ) + { + vector<string>::iterator iter = params->begin(); + string s_searched_user( *iter ); + bool b_found; + user* p_searched_user = p_chat->get_user( s_searched_user, b_found ); + + if ( b_found ) + { + string s_msg = "<b>" + p_searched_user->get_colored_name() + "</b>" + + p_conf->get_elem("chat.msgs.userinroom") + "<b>" + + p_searched_user->get_room()->get_name() + + "</b><br>\n"; + p_user->msg_post( &s_msg ); + } + else + { + string s_msg = "<font color=\"#" + + p_conf->get_elem("chat.html.errorcolor") + + "\"><b>" + + s_searched_user + "</b> " + + p_conf->get_elem("chat.msgs.err.notavailable") + + "</font><br>\n"; + p_user->msg_post( &s_msg ); + + } + } + + return 0; + } + +} + diff --git a/src/mods/commands/yc_getrusage.cpp b/src/mods/commands/yc_getrusage.cpp new file mode 100644 index 0000000..56a7fbb --- /dev/null +++ b/src/mods/commands/yc_getrusage.cpp @@ -0,0 +1,81 @@ +/*:* + *: File: ./src/mods/commands/yc_getrusage.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include <stdio.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <iostream> +#include "../../chat/user.h" + +#ifndef RUSAGE_SELF +#define RUSAGE_SELF 0 +#endif +#ifndef RUSAGE_CHILDREN +#define RUSAGE_CHILDREN -1 +#endif + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int valid_color( string ); + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + rusage* p_rusage = new rusage; + getrusage( RUSAGE_SELF, p_rusage ); + char c_msg[1024]; + + /* see man getrusage */ + + sprintf(c_msg, "getrusage:<br>\nmaxrss: %D (max resident set size)<br>\nixrss: %D (integral shared text memory size)<br>\nidrss: %D (integral unshared data size)<br>\nisrss %D (integral unshared stack size)<br>\nminflt: %D (page reclaims)<br>\nmajflt: %D (page faults)<br>\nnswap: %D (swaps)<br>\ninblock: %D (block input operations)<br>\noublock: %D (block output operations)<br>\nmsgsnd: %D (messages sent)<br>\nmsgrcv: %D (messages received)<br>\nnsignals: %D (signals received)<br>\nnvcsw: %D (voluntary context switches)<br>\nnivcsw: %D (involuntary context switches)<br>\n", + p_rusage->ru_maxrss, + p_rusage->ru_ixrss, + p_rusage->ru_idrss, + p_rusage->ru_isrss, + p_rusage->ru_minflt, + p_rusage->ru_majflt, + p_rusage->ru_nswap, + p_rusage->ru_inblock, + p_rusage->ru_oublock, + p_rusage->ru_msgsnd, + p_rusage->ru_msgrcv, + p_rusage->ru_nsignals, + p_rusage->ru_nvcsw, + p_rusage->ru_nivcsw + ); + + p_user->msg_post( new string( c_msg ) ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_help.cpp b/src/mods/commands/yc_help.cpp new file mode 100644 index 0000000..33faf60 --- /dev/null +++ b/src/mods/commands/yc_help.cpp @@ -0,0 +1,76 @@ +/*:* + *: File: ./src/mods/commands/yc_help.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" +#include "../../chat/user.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params = (vector<string>*) c->elem[2]; // param array + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + string s_msg = ""; + + if (params->size() >= 1) + { + vector<string>::iterator iter = params->begin(); + + string s_help = p_conf->get_elem("chat.msgs.help." + *iter); + + if ( s_help != "" ) + { + s_msg.append("<b>" + *iter + ":</b> " + s_help + "<br>\n"); + p_user->msg_post( &s_msg ); + return 0; + } + + s_msg.append(*iter + " " + p_conf->get_elem("chat.msgs.err.notavailable")); + } + else + { + s_msg.append(p_conf->get_elem("chat.msgs.err.wrongcommandusage")); + } + + s_msg = "<font color=\"#" + + p_conf->get_elem("chat.html.errorcolor") + + "\"> " + + s_msg + + "</font><br>\n"; + + p_user->msg_post( &s_msg ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_invisible.cpp b/src/mods/commands/yc_invisible.cpp new file mode 100644 index 0000000..5eea510 --- /dev/null +++ b/src/mods/commands/yc_invisible.cpp @@ -0,0 +1,55 @@ +/*:* + *: File: ./src/mods/commands/yc_invisible.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" +#include "../../chat/room.h" +#include "../../chat/user.h" + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user* p_user = (user*) c->elem[1]; // the corresponding user + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + + bool b_invisible = p_user->get_invisible(); + + string s_msg = b_invisible + ? p_conf->get_elem("chat.msgs.setmodeinvisible") + + "<br>\n" + : p_conf->get_elem("chat.msgs.unsetmodeinvisible") + + "<br>\n"; + + p_user->set_invisible( !b_invisible ); + p_user->get_room()->reload_onlineframe(); + p_user->msg_post ( &s_msg ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_j.cpp b/src/mods/commands/yc_j.cpp new file mode 100644 index 0000000..15e97cc --- /dev/null +++ b/src/mods/commands/yc_j.cpp @@ -0,0 +1,128 @@ +/*:* + *: File: ./src/mods/commands/yc_j.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../chat/user.h" +#include "../../chat/room.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params = (vector<string> *) c->elem[2]; // param array + chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + gcol* p_gcol = (gcol*) ((dynamic_wrap*)c->elem[3])->GCOL; + + if ( ! params->empty() ) + { + vector<string> ::iterator iter; + + string s_room; + + for ( iter = params->begin(); iter != params->end(); iter++ ) + { + s_room.append( *iter ); + if ( iter+1 != params->end() ) + s_room.append(" "); + } + + int i_max_room_len = tool::string2int( p_conf->get_elem("chat.maxlength.roomname") ); + if ( i_max_room_len < s_room.length() ) + s_room = s_room.substr(0, i_max_room_len ); + + if ( tool::to_lower(s_room) == p_user->get_room()->get_lowercase_name() ) + { + string s_msg = "<font color=\"" + p_conf->get_elem("chat.html.errorcolor") + "\">" + + p_conf->get_elem("chat.msgs.err.alreadyinroom") + "<b>" + + p_user->get_room()->get_name() + "</b></font><br>\n"; + p_user->msg_post( &s_msg ); + } + else + { + string s_user = p_timr->get_time() + " " + p_user->get_colored_bold_name(); + string s_msg = s_user + p_conf->get_elem( "chat.msgs.userleavesroom" ) + "<b>"; + string s_msg2 = s_user + p_conf->get_elem( "chat.msgs.userentersroom" ) + "<b>"; + + bool b_flag; + room* p_room = p_chat->get_room( s_room , b_flag ); + + // if room does not exist add room to list! + if ( p_room == NULL ) + { + p_room = p_gcol->get_room_from_garbage_or_new( s_room ); + + s_msg.append( s_room + "</b><br>\n" ); + s_msg2.append( s_room + "</b><br>\n" ); + + room* p_room_old = p_user->get_room(); + + string s_name_lowercase = p_user->get_lowercase_name(); + p_user->get_room()->del_elem( s_name_lowercase ); + + p_gcol->lock_mutex(); + if ( p_room_old != NULL ) + p_room_old->msg_post( &s_msg ); + p_gcol->unlock_mutex(); + + p_room->add_user( p_user ); + p_chat->add_elem( p_room ); + p_room->msg_post( &s_msg2 ); + } + else // p_room != NULL + { + s_msg.append( p_room->get_name() + "</b><br>\n" ); + s_msg2.append( p_room->get_name() + "</b><br>\n" ); + + room* p_room_old = p_user->get_room(); + + string s_name_lowercase = p_user->get_lowercase_name(); + p_user->get_room()->del_elem( s_name_lowercase ); + + p_gcol->lock_mutex(); + if ( p_room_old != NULL ) + p_room_old->msg_post( &s_msg ); + p_gcol->unlock_mutex(); + + p_room->add_user( p_user ); + p_room->msg_post( &s_msg2 ); + } + } + } + + return 0; + } + +} + diff --git a/src/mods/commands/yc_ko.cpp b/src/mods/commands/yc_ko.cpp new file mode 100644 index 0000000..40592eb --- /dev/null +++ b/src/mods/commands/yc_ko.cpp @@ -0,0 +1,96 @@ +/*:* + *: File: ./src/mods/commands/yc_ko.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params = (vector<string>*) c->elem[2]; // param array + chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + + if ( ! params->empty() ) + { + vector<string>::iterator iter = params->begin(); + string s_searched_user( *iter ); + bool b_found; + user* p_searched_user = p_chat->get_user( s_searched_user, b_found ); + + if ( b_found ) + { + + string s_msg = p_timr->get_time() + " " + + p_user->get_colored_bold_name() + + p_conf->get_elem( "chat.msgs.userkicksout1" ) + + p_searched_user->get_colored_bold_name() + + p_conf->get_elem( "chat.msgs.userkicksout2" ) + + p_searched_user->get_room()->get_bold_name() + + "<br>\n"; + + room* p_room1 = p_user->get_room(); + room* p_room2 = p_searched_user->get_room(); + + p_room1->msg_post( &s_msg ); + + if ( p_room1->get_lowercase_name() != + p_room2->get_lowercase_name() ) + p_room2->msg_post( &s_msg ); + + string s_kick = "<script confuage=JavaScript>top.location.href='/" + + p_conf->get_elem("httpd.startsite") + + "';</script>"; + + p_searched_user->msg_post( &s_kick ); + p_searched_user->set_online(false); + } + else + { + string s_msg = "<font color=\"#" + + p_conf->get_elem("chat.html.errorcolor") + + "\"><b>" + + s_searched_user + "</b> " + + p_conf->get_elem("chat.msgs.err.notavailable") + + "</font><br>\n"; + p_user->msg_post( &s_msg ); + } + } + + return 0; + } + +} + diff --git a/src/mods/commands/yc_m.cpp b/src/mods/commands/yc_m.cpp new file mode 100644 index 0000000..fa63719 --- /dev/null +++ b/src/mods/commands/yc_m.cpp @@ -0,0 +1,68 @@ +/*:* + *: File: ./src/mods/commands/yc_m.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include <iostream> +#include "../../chat/user.h" +#include "../../chat/room.h" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int valid_color( string ); + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params= (vector<string>*) c->elem[2]; // param array + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + + string s_msg = ""; + + if ( p_conf->get_elem("chat.printalwaystime") == "true" ) + s_msg = p_timr->get_time() + " "; + + s_msg.append( "<i>" + p_user->get_colored_name() + + " <font color=\"#" + p_user->get_col2() + + "\">" ); + if ( ! params->empty() ) + { + vector<string>::iterator iter = params->begin(); + for ( iter = params->begin(); iter != params->end(); iter++ ) + s_msg.append( *iter + " " ); + } + + s_msg.append( "</font></i><br>\n" ); + p_user->get_room()->msg_post( &s_msg ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_md5.cpp b/src/mods/commands/yc_md5.cpp new file mode 100644 index 0000000..4e81ede --- /dev/null +++ b/src/mods/commands/yc_md5.cpp @@ -0,0 +1,78 @@ +/*:* + *: File: ./src/mods/commands/yc_md5.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" +#include "../../chat/user.h" +#include "../../contrib/crypt/md5.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params = (vector<string>*) c->elem[2]; // param array + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + + if (params->size() >= 2) + { + vector<string>::iterator iter; + string s_string = ""; + string s_salt = ""; + + for (iter = params->begin(); iter+1 != params->end(); ++iter) + { + s_string.append(*iter); + } + + s_salt = *iter; + + string s_msg = "Crypt: <b>" + s_string + "</b>, Salt: <b>" + + s_salt + "</b> = <b>" + + + md5::MD5Crypt(s_string.c_str(), s_salt.c_str()) + + "</b><br>\n"; + p_user->msg_post( &s_msg ); + } + else + { + string s_msg = "<font color=\"#" + + p_conf->get_elem("chat.html.errorcolor") + + "\"> " + + p_conf->get_elem("ERR_WRONG_COMMAND_USAGE") + + "</font><br>\n"; + p_user->msg_post( &s_msg ); + + } + + return 0; + } +} + diff --git a/src/mods/commands/yc_me.cpp b/src/mods/commands/yc_me.cpp new file mode 100644 index 0000000..d105723 --- /dev/null +++ b/src/mods/commands/yc_me.cpp @@ -0,0 +1,69 @@ +/*:* + *: File: ./src/mods/commands/yc_me.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include <iostream> +#include "../../chat/user.h" +#include "../../chat/room.h" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int valid_color( string ); + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params= (vector<string>*) c->elem[2]; // param array + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + + string s_msg = ""; + + if ( p_conf->get_elem("chat.printalwaystime") == "true" ) + s_msg = p_timr->get_time() + " "; + + s_msg.append( "<i><font color=\"#" +p_user->get_col1() + "\">" + + p_user->get_name() + " "); + + if ( ! params->empty() ) + { + vector<string>::iterator iter = params->begin(); + for ( iter = params->begin(); iter != params->end(); iter++ ) + s_msg.append( *iter + " " ); + } + + s_msg.append( "</font></i><br>\n" ); + p_user->get_room()->msg_post( &s_msg ); + + return 0; + + } +} + diff --git a/src/mods/commands/yc_morph.cpp b/src/mods/commands/yc_morph.cpp new file mode 100644 index 0000000..22a8174 --- /dev/null +++ b/src/mods/commands/yc_morph.cpp @@ -0,0 +1,76 @@ +/*:* + *: File: ./src/mods/commands/yc_morph.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../chat/user.h" +#include "../../chat/room.h" +#include "../../tool/tool.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c = (container*) v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *p_params = (vector<string>*) c->elem[2]; // param array + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + + if ( p_params->empty() ) + { + string s_msg = p_conf->colored_error_msg("chat.msgs.err.wrongcommandusage"); + p_user->msg_post(s_msg); + } + else + { + string s_morphed_name = p_params->at(0); + + if ( tool::to_lower(s_morphed_name) != p_user->get_lowercase_name() ) + { + string s_msg = p_conf->colored_error_msg("chat.msgs.err.morphnick"); + p_user->msg_post(s_msg); + } + else + { + string s_msg = p_timr->get_time() + " " + p_user->get_colored_bold_name() + p_conf->get_elem( "chat.msgs.usermorphs" ) + "<font color=\"#" + p_user->get_col1() + "\"><b>" + s_morphed_name + "</b></font><br>\n"; + + room* p_room = p_user->get_room(); + p_room->msg_post( &s_msg ); + p_user->set_name( s_morphed_name ); + p_room->reload_onlineframe(); + } + } + + return 0; + } + +} + + diff --git a/src/mods/commands/yc_msg.cpp b/src/mods/commands/yc_msg.cpp new file mode 100644 index 0000000..8889e9f --- /dev/null +++ b/src/mods/commands/yc_msg.cpp @@ -0,0 +1,92 @@ +/*:* + *: File: ./src/mods/commands/yc_msg.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../chat/user.h" +#include "../../chat/room.h" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int valid_color( string ); + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params = (vector<string>*) c->elem[2]; // param array + chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + + if ( ! params->empty() ) + { + vector<string>::iterator iter = params->begin(); + string s_whisper_user( *iter ); + bool b_found; + user* p_whisper_user = p_chat->get_user( s_whisper_user, b_found ); + + if ( b_found ) + { + string s_time = ""; + if ( p_conf->get_elem("chat.printalwaystime") == "true" ) + s_time = p_timr->get_time() + " "; + + string s_msg = s_time + "<i> " + p_conf->get_elem("chat.msgs.whisperto") + " " + p_whisper_user->get_colored_name() + ": <font color=\"#" + p_user->get_col2() + "\">"; + + string s_whisper_msg = s_time + "<i>" + p_user->get_colored_name() + " " + p_conf->get_elem("chat.msgs.whisper") + ": <font color=\"#" + p_user->get_col2() + "\">"; + + string s_tmp = ""; + for ( iter++; iter != params->end(); iter++ ) + s_tmp.append( *iter + " " ); + + p_chat->string_replacer(&s_tmp); + + s_msg .append( s_tmp + "</font></i><br>\n" ); + s_whisper_msg.append( s_tmp + "</font></i><br>\n" ); + + p_user ->msg_post( &s_msg ); + p_whisper_user->msg_post( &s_whisper_msg ); + } + else + { + string s_msg = "<font color=\"#" + + p_conf->get_elem("chat.html.errorcolor") + + "\"><b>" + + s_whisper_user + "</b> " + + p_conf->get_elem("chat.msgs.err.notavailable") + + "</font><br>\n"; + + p_user->msg_post( &s_msg ); + } + } + + return 0; + } +} + diff --git a/src/mods/commands/yc_q.cpp b/src/mods/commands/yc_q.cpp new file mode 100644 index 0000000..37f472c --- /dev/null +++ b/src/mods/commands/yc_q.cpp @@ -0,0 +1,54 @@ +/*:* + *: File: ./src/mods/commands/yc_q.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include <iostream> +#include "../../chat/user.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + + +extern "C" +{ + int extern_function(void *v_arg) + { + container* c = (container*) v_arg; + user* p_user = (user*)c->elem[1]; + + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + + string s_quit = "<script confuage=JavaScript>top.location.href='/" + + p_conf->get_elem("httpd.startsite") + + "';</script>"; + + p_user->msg_post( &s_quit ); + p_user->set_online(false); + + return 0; + } +} + diff --git a/src/mods/commands/yc_reload.cpp b/src/mods/commands/yc_reload.cpp new file mode 100644 index 0000000..2fe7522 --- /dev/null +++ b/src/mods/commands/yc_reload.cpp @@ -0,0 +1,49 @@ +/*:* + *: File: ./src/mods/commands/yc_reload.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" +#include "../../chat/room.h" +#include "../../chat/user.h" + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user* p_user = (user*) c->elem[1]; // the corresponding user + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + + string s_msg = p_conf->get_elem("chat.msgs.reloadonlineframe") + + "<br>\n"; + + p_user->get_room()->reload_onlineframe(); + p_user->msg_post ( &s_msg ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_ren.cpp b/src/mods/commands/yc_ren.cpp new file mode 100644 index 0000000..90de221 --- /dev/null +++ b/src/mods/commands/yc_ren.cpp @@ -0,0 +1,98 @@ +/*:* + *: File: ./src/mods/commands/yc_ren.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../chat/user.h" +#include "../../chat/room.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c = (container*) v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params = (vector<string>*) c->elem[2]; // param array + + chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + + if ( ! params->empty() ) + { + vector<string>::iterator iter; + + string s_room; + + for ( iter = params->begin(); iter != params->end(); iter++ ) + { + s_room.append( *iter ); + if ( iter+1 != params->end() ) + s_room.append(" "); + } + + int i_max_room_len = tool::string2int( p_conf->get_elem("chat.maxlength.roomname") ); + if ( i_max_room_len < s_room.length() ) + s_room = s_room.substr(0, i_max_room_len ); + + bool b_found; + string s_room_lower = tool::to_lower(s_room); + room* p_room = p_user->get_room(); + + if ( s_room_lower != p_room->get_lowercase_name() && + NULL != p_chat->get_room( s_room_lower , b_found ) ) + { + string s_msg = "<font color=\"#" + + p_conf->get_elem("chat.html.errorcolor") + + "\">" + + p_conf->get_elem("chat.msgs.err.roomexists") + + "</font><br>\n"; + + p_user->msg_post( &s_msg ); + } + else + { + string s_msg = p_timr->get_time() + " " + + p_user->get_colored_bold_name() + + p_conf->get_elem( "chat.msgs.userrenamesroom" ) + + "<b>" + s_room + "</b><br>\n"; + + p_chat->del_elem( p_room->get_lowercase_name() ); + p_room->set_name( s_room ); + p_chat->add_elem( p_room ); + p_room->msg_post( &s_msg ); + p_room->reload_onlineframe(); + } + } + + return 0; + } + +} + diff --git a/src/mods/commands/yc_s.cpp b/src/mods/commands/yc_s.cpp new file mode 100644 index 0000000..42213ac --- /dev/null +++ b/src/mods/commands/yc_s.cpp @@ -0,0 +1,72 @@ +/*:* + *: File: ./src/mods/commands/yc_s.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../chat/user.h" +#include "../../chat/room.h" + +using namespace std; + +extern "C" +{ + string to_upper( string &s_msg ) + { + char* c_msg = (char*) s_msg.c_str(); + + for ( int i = 0; i < strlen( c_msg ); i++ ) + c_msg[i] = toupper( c_msg[i] ); + + return string( c_msg ); + }; + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + vector<string> *params= (vector<string>*) c->elem[2]; // param array + + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + + string s_time = ""; + if ( p_conf->get_elem("chat.printalwaystime") == "true" ) + s_time = p_timr->get_time() + " "; + + string s_msg = s_time + "<i>" + p_user->get_colored_name() + " " + p_conf->get_elem("chat.msgs.scream") + " <font color=\"#" + p_user->get_col2() + "\"><b>"; + + if ( ! params->empty() ) + { + vector<string>::iterator iter = params->begin(); + for ( iter = params->begin(); iter != params->end(); iter++ ) + s_msg.append( to_upper(*iter) + " " ); + } + + s_msg.append( "</b></font></i><br>\n" ); + p_user->get_room()->msg_post( &s_msg ); + + return 0; + + } +} + diff --git a/src/mods/commands/yc_set.cpp b/src/mods/commands/yc_set.cpp new file mode 100644 index 0000000..8d59908 --- /dev/null +++ b/src/mods/commands/yc_set.cpp @@ -0,0 +1,124 @@ +/*:* + *: File: ./src/mods/commands/yc_set.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" +#include "../../chat/room.h" +#include "../../chat/user.h" + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user* p_user = (user*) c->elem[1]; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT; + + vector<string> *params = (vector<string>*) c->elem[2]; // param array + + bool b_invalid_syntax = 0; + + if ( params->size() >= 3 ) + { + string s_msg; + string s_command_name = params->at(0); + string s_option = params->at(1); + string s_newval = params->at(2); + + if ( s_option == "status" ) + { + const char* c_newval = s_newval.c_str(); + if ( isdigit( c_newval[0] ) ) + { + int i_newval = c_newval[0] - '0'; + + s_msg = p_timr->get_time() + + " " + + p_user->get_colored_bold_name() + + " " + + p_conf->get_elem("chat.msgs.setcommandstatus") + + " (" + + s_command_name + "," + s_newval + "," + + tool::int2string( p_chat->get_command_disabled(s_command_name)) + + ")<br>\n"; + + p_user->get_room()->msg_post(&s_msg); + p_chat->set_command_status( s_command_name, i_newval ); + } + } + else if ( s_option == "disable" ) + { + const char* c_newval = s_newval.c_str(); + if ( isdigit( c_newval[0] ) ) + { + int i_newval = c_newval[0] - '0'; + + if ( i_newval != 0 ) + i_newval = 1; + + s_newval = tool::int2string(i_newval); + + s_msg = p_timr->get_time() + + " " + + p_user->get_colored_bold_name() + + " " + + p_conf->get_elem("chat.msgs.setcommandstatus") + + " (" + + s_command_name + "," + + tool::int2string( p_chat->get_command_status(s_command_name)) + + "," + s_newval + ")<br>\n"; + + p_user->get_room()->msg_post(&s_msg); + p_chat->set_command_disabled( s_command_name, (bool)i_newval ); + } + } + else + { + b_invalid_syntax = 1; + } + + } + else + { + b_invalid_syntax = 1; + } + + if ( b_invalid_syntax ) + { + string s_msg = "<font color=\"#" + + p_conf->get_elem("chat.html.errorcolor") + + "\">" + + p_conf->get_elem("chat.msgs.err.wrongcommandusage") + + "</font><br>\n"; + p_user->msg_post( &s_msg ); + } + + return 0; + } +} + diff --git a/src/mods/commands/yc_template.cpp b/src/mods/commands/yc_template.cpp new file mode 100644 index 0000000..a49bb69 --- /dev/null +++ b/src/mods/commands/yc_template.cpp @@ -0,0 +1,49 @@ +/*:* + *: File: ./src/mods/commands/yc_template.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include <iostream> +#include "../../chat/user.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*)c->elem[1]; // the corresponding user + vector<string> *params=(vector<string>*)c->elem[2]; // param array + + string *quitstring=new string("Text to send<br>"); + p_user->msg_post( quitstring ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_time.cpp b/src/mods/commands/yc_time.cpp new file mode 100644 index 0000000..31198a1 --- /dev/null +++ b/src/mods/commands/yc_time.cpp @@ -0,0 +1,46 @@ +/*:* + *: File: ./src/mods/commands/yc_time.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + + string s_msg = p_conf->get_elem("chat.msgs.servertime") + p_timr->get_time() + "<br>\n"; + + p_user->msg_post( &s_msg ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_topic.cpp b/src/mods/commands/yc_topic.cpp new file mode 100644 index 0000000..b2dfed5 --- /dev/null +++ b/src/mods/commands/yc_topic.cpp @@ -0,0 +1,102 @@ +/*:* + *: File: ./src/mods/commands/yc_topic.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../tool/tool.h" +#include "../../incl.h" +#include "../../chat/room.h" +#include "../../chat/user.h" + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user* p_user = (user*) c->elem[1]; // the corresponding user + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + vector<string> *params = (vector<string>*) c->elem[2]; // param array + + string s_msg; + string s_topic; + string s_col; + + room* p_room = p_user->get_room(); + + if ( ! params->empty() ) + { + vector<string>::iterator iter; + + s_col = "<font color=\"" + p_user->get_col1() + "\">"; + + s_msg = p_timr->get_time() + + " " + + p_user->get_colored_bold_name() + + " " + + p_conf->get_elem("chat.msgs.topic") + + s_col; + + for ( iter = params->begin(); iter != params->end(); iter++ ) + { + s_msg.append( " " + *iter ); + s_topic.append( *iter + " " ); + } + s_msg.append( "</font>" ); + + int i_topic_length = tool::string2int(p_conf->get_elem("chat.maxlength.topic")); + if ( s_topic.length() > i_topic_length ) + { + s_topic = s_topic.substr(0, i_topic_length ); + s_topic.append(" ... "); + + string s_private_msg = "<font color=#" + p_conf->get_elem("chat.html.errorcolor") + + ">" + p_conf->get_elem( "chat.msgs.topiccut" ) + "</font><br>"; + + p_user->msg_post ( &s_private_msg ); + } + + s_topic = "( " + s_topic + ")"; + p_room->set_topic( s_topic, p_user->get_col1() ); + } + else + { + s_msg = p_timr->get_time() + + " " + + p_user->get_colored_bold_name() + + " " + + p_conf->get_elem("chat.msgs.topicdelete"); + + p_room->set_topic( "" ); + } + + s_msg.append( "<script confuage='JavaScript'>parent.online.location.reload();</script><br>\n" ); + + p_room->msg_post ( &s_msg ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_uptime.cpp b/src/mods/commands/yc_uptime.cpp new file mode 100644 index 0000000..c86f440 --- /dev/null +++ b/src/mods/commands/yc_uptime.cpp @@ -0,0 +1,46 @@ +/*:* + *: File: ./src/mods/commands/yc_uptime.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + user *p_user = (user*) c->elem[1]; // the corresponding user + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR; + + string s_msg = p_conf->get_elem("chat.msgs.uptime") + p_timr->get_uptime() + "<br>\n"; + + p_user->msg_post( &s_msg ); + + return 0; + } +} + diff --git a/src/mods/commands/yc_users.cpp b/src/mods/commands/yc_users.cpp new file mode 100644 index 0000000..f5cf3fc --- /dev/null +++ b/src/mods/commands/yc_users.cpp @@ -0,0 +1,52 @@ +/*:* + *: File: ./src/mods/commands/yc_users.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../chat/chat.h" +#include "../../chat/user.h" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int valid_color( string ); + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT; + conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; + user *p_user = (user*)c->elem[1]; + + string s_list; + p_chat->get_user_list(s_list); + p_user->msg_post( p_conf->get_elem("chat.msgs.userlist") + + "<br><table>" + s_list + "</table>\n"); + + return 0; + } +} + diff --git a/src/mods/commands/yc_version.cpp b/src/mods/commands/yc_version.cpp new file mode 100644 index 0000000..797b6c7 --- /dev/null +++ b/src/mods/commands/yc_version.cpp @@ -0,0 +1,47 @@ +/*:* + *: File: ./src/mods/commands/yc_version.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include <iostream> +#include "../../msgs.h" +#include "../../chat/user.h" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int valid_color( string ); + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + user *p_user = (user*)c->elem[1]; // the corresponding user + p_user->msg_post( tool::ychat_version() + "<br>\n"); + + return 0; + } +} + diff --git a/src/mods/configure b/src/mods/configure new file mode 100755 index 0000000..839380b --- /dev/null +++ b/src/mods/configure @@ -0,0 +1,26 @@ +#! /bin/sh + +if ! test -f ../../g++.version +then + echo You need to run ./configure of the top level source dir first + exit 1 +fi + +echo Creating module Makefiles... +for dir in commands html +do + if test -d $dir + then + cd $dir && + srcs="SRCS=`ls *.cpp`" && + echo $srcs > Makefile + compiler=`tail -n 1 ../../../g++.version` + sed s/COMPILER/$compiler/ Makefile.in >> Makefile && + for i in *.cpp + do + echo "../../../mods/$dir/`echo $i | sed s/.cpp/.so/`: $i" >> Makefile + done + cd .. + fi +done + diff --git a/src/mods/html/Makefile.in b/src/mods/html/Makefile.in new file mode 100644 index 0000000..4b7c728 --- /dev/null +++ b/src/mods/html/Makefile.in @@ -0,0 +1,18 @@ +MODS=$(addprefix ../../../mods/html/, $(SRCS:.cpp=.so)) +CC=COMPILER +INCLUDES=`cat ../../includes.add` +CFLAGS=`cat ../cflags.add` +all: mods +$(MODS): + @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi + @$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/` + @echo -n "HTML module `basename $@ | sed s/\.so// | sed s/yc_//` " + @du -hc $@ | tail -n 1 | sed s/total// | sed "s/ //g" +infotext: + @echo Compiling HTML modules +mods: infotext $(MODS) + @echo "Num of html modules: " + @ls ../../../mods/html/*.so | wc -l +clean: + @echo Cleaning html modules + @if test -d ../../../mods/html; then rm -Rf ../../../mods/html; fi diff --git a/src/mods/html/yc_admin.cpp b/src/mods/html/yc_admin.cpp new file mode 100644 index 0000000..9201021 --- /dev/null +++ b/src/mods/html/yc_admin.cpp @@ -0,0 +1,96 @@ +/*:* + *: File: ./src/mods/html/yc_admin.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" +#include "../../tool/tool.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + string replace_chars(string s_string) + { + s_string = tool::replace(s_string, "<", "<"); + s_string = tool::replace(s_string, ">", ">"); + s_string = tool::replace(s_string, "\n", "<br>"); + return s_string; + } + + int extern_function(void *v_arg) + { + container* c = (container*) v_arg; + dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0]; + user* p_user = (user*) c->elem[2]; + conf* p_conf = (conf*) p_wrap->CONF; + string* p_content = &(*((map<string,string>*) c->elem[1]))["content"]; + + vector<string>* p_vec_keys = p_conf->get_key_vector(); + sort(p_vec_keys->begin(), p_vec_keys->end()); + vector<string>::iterator p_vec_keys_iter = p_vec_keys->begin(); + + p_content->append( "Currently are " + tool::int2string(p_vec_keys->size()) + " options available!<br><br>\n"); + p_content->append( "<table bordercolor=\"1\">\n" ); + + for( ;p_vec_keys_iter != p_vec_keys->end(); ++p_vec_keys_iter ) + { + + if ( p_vec_keys_iter->find(".descr") != string::npos ) + continue; + + p_content->append( "<tr><td>\n<font color=\"#FFFFFF\"><b>" + *p_vec_keys_iter + "\n</b></font></td></tr>\n" ); + + string s_descr = p_conf->get_elem(*p_vec_keys_iter + ".descr"); + if ( s_descr.length() + > 0 ) + { + p_content->append( "<tr><td><font color=\"#CCCCCC\">\n" ); + p_content->append( replace_chars(p_conf->get_elem(*p_vec_keys_iter + ".descr")) ); + p_content->append( "\n</font></td></tr>\n" ); + } + + p_content->append( "<tr><td>\n" ); + + // Hide some fields! + if ( p_vec_keys_iter->find(".password") + != string::npos + || p_vec_keys_iter->find("base.user") != string::npos + || p_vec_keys_iter->find(".dbname") != string::npos ) + p_content->append( "X X X X X X X X X X" ); + + else + p_content->append( replace_chars(p_conf->get_elem(*p_vec_keys_iter)) ); + + p_content->append( "<br><br></td></tr>\n" ); + } // while + + p_content->append( "</table>\n<br>\n" ); + + return 0; + } +} + diff --git a/src/mods/html/yc_colors.cpp b/src/mods/html/yc_colors.cpp new file mode 100644 index 0000000..4f717ad --- /dev/null +++ b/src/mods/html/yc_colors.cpp @@ -0,0 +1,61 @@ +/*:* + *: File: ./src/mods/html/yc_colors.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container* c = (container*) v_arg; + dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0]; + conf* p_conf = (conf*) p_wrap->CONF; + string* p_col1 = &(*((map<string,string>*) c->elem[1]))["col1"]; + string* p_col2 = &(*((map<string,string>*) c->elem[1]))["col2"]; + string* p_flag = &(*((map<string,string>*) c->elem[1]))["flag"]; + user* p_user = (user*) c->elem[2]; + + p_col1->erase(0); + p_col2->erase(0); + + p_col1->append( p_user->get_col1() ); + p_col2->append( p_user->get_col2() ); + + if ( *p_flag == "submit" ) + { + string* p_msgs = &(*((map<string,string>*) c->elem[1]) + )["msgs"]; + p_msgs->append( p_conf->get_elem( "chat.msgs.optionschanged" ) ); + } + + return 0; + } +} + diff --git a/src/mods/html/yc_help.cpp b/src/mods/html/yc_help.cpp new file mode 100644 index 0000000..b7a0237 --- /dev/null +++ b/src/mods/html/yc_help.cpp @@ -0,0 +1,74 @@ +/*:* + *: File: ./src/mods/html/yc_help.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container* c = (container*) v_arg; + dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0]; + user* p_user = (user*) c->elem[2]; + + modl* p_modl = (modl*) p_wrap->MODL; + conf* p_conf = (conf*) p_wrap->CONF; + chat* p_chat = (chat*) p_wrap->CHAT; + string* s_content = &(*((map<string,string>*) c->elem[1]))["content"]; + + vector<string>* p_vec_keys = p_modl->get_mod_vector(); + + sort(p_vec_keys->begin(), p_vec_keys->end()); + vector<string>::iterator p_vec_keys_iter = p_vec_keys->begin(); + + while( p_vec_keys_iter != p_vec_keys->end() ) + { + + if ( p_vec_keys_iter->find( "mods/commands/", 0 ) != string::npos ) + { + + string s_command_name = p_vec_keys_iter->substr(17); + s_command_name.erase( s_command_name.find( ".so" ) ); + + if ( !p_chat->get_command_disabled( s_command_name ) && + p_chat->get_command_status( s_command_name ) >= p_user->get_status()) + { + s_content->append( "<table bordercolor=\"1\">\n" ); + s_content->append( "<tr><td><font color=\"#FFFFFF\"><b>/" + s_command_name + "</b></font></td></tr>\n" ); + s_content->append( "<tr><td>" + p_conf->get_elem("chat.msgs.help." + s_command_name) + "</td></tr>\n" ); + s_content->append( "</table>\n<br>\n" ); + } + } + p_vec_keys_iter++; + } + return 0; + } +} + diff --git a/src/mods/html/yc_loggedin.cpp b/src/mods/html/yc_loggedin.cpp new file mode 100644 index 0000000..6f7d020 --- /dev/null +++ b/src/mods/html/yc_loggedin.cpp @@ -0,0 +1,53 @@ +/*:* + *: File: ./src/mods/html/yc_loggedin.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../chat/chat.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container* c = (container*) v_arg; + dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0]; + chat* p_chat = (chat*) p_wrap->CHAT; + map<string,string>* p_map = (map<string,string>*) c->elem[1]; + + /* + string s_list; + p_chat->get_user_list(s_list); + (*p_map)["USERLIST"] = s_list; + */ + + p_chat->get_user_list((*p_map)["USERLIST"]); + + return 0; + } +} + diff --git a/src/mods/html/yc_options.cpp b/src/mods/html/yc_options.cpp new file mode 100644 index 0000000..71d5eef --- /dev/null +++ b/src/mods/html/yc_options.cpp @@ -0,0 +1,80 @@ +/*:* + *: File: ./src/mods/html/yc_options.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { + container* c = (container*) v_arg; + dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0]; + conf* p_conf = (conf*) p_wrap->CONF; + string* p_flag = &(*((map<string,string>*) c->elem[1]))["flag"]; + string* p_email = &(*((map<string,string>*) c->elem[1]))["email"]; + string* p_pass = &(*((map<string,string>*) c->elem[1]))["pass"]; + string* p_newpass = &(*((map<string,string>*) c->elem[1]))["newpass"]; + string* p_newpass2 = &(*((map<string,string>*) c->elem[1]))["newpass2"]; + user* p_user = (user*) c->elem[2]; + + if ( *p_flag == "submit" ) + { + string* p_msgs = &(*((map<string,string>*) c->elem[1]) + )["msgs"]; + + // If the password has to be changed: + if ( *p_pass != "" || *p_newpass != "" || *p_newpass2 != "" ) + { + if ( p_user->get_pass() != *p_pass ) + { + p_msgs->append( p_conf->get_elem( "chat.msgs.err.changepassword" ) ); + return 0; + } + + if ( *p_newpass != *p_newpass2 ) + { + p_msgs->append( p_conf->get_elem( "chat.msgs.err.changepassword2" ) ); + return 0; + } + p_user->set_pass( *p_newpass ); + } + + p_user->set_email( *p_email ); + p_msgs->append( p_conf->get_elem( "chat.msgs.optionschanged" ) ); + } + else + { + p_email->append( p_user->get_email() ); + } + + return 0; + } +} + diff --git a/src/mods/html/yc_register.cpp b/src/mods/html/yc_register.cpp new file mode 100644 index 0000000..e39deaf --- /dev/null +++ b/src/mods/html/yc_register.cpp @@ -0,0 +1,120 @@ +/*:* + *: File: ./src/mods/html/yc_register.cpp + *: + *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: + *: This program is free software; you can redistribute it and/or + *: modify it under the terms of the GNU General Public License + *: as published by the Free Software Foundation; either version 2 + *: of the License, or (at your option) any later version. + *: + *: This program is distributed in the hope that it will be useful, + *: but WITHOUT ANY WARRANTY; without even the implied warranty of + *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *: GNU General Public License for more details. + *: + *: You should have received a copy of the GNU General Public License + *: along with this program; if not, write to the Free Software + *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *:*/ + +#include "../../incl.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" +{ + int extern_function(void *v_arg) + { +#ifdef DATABASE + container* c = (container*) v_arg; + dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0]; + conf* p_conf = (conf*) p_wrap->CONF; + data* p_data = (data*) p_wrap->DATA; + string* p_msgs = &(*((map<string,string>*) c->elem[1]))["INFO"]; + string* p_nick = &(*((map<string,string>*) c->elem[1]))["nick"]; + string* p_email = &(*((map<string,string>*) c->elem[1]))["email"]; + string* p_pass = &(*((map<string,string>*) c->elem[1]))["pass"]; + string* p_pass2 = &(*((map<string,string>*) c->elem[1]))["pass2"]; + string* p_request = &(*((map<string,string>*) c->elem[1]))["request"]; + user* p_user = (user*) c->elem[2]; + string s_nick = *p_nick; + + + p_user->set_name( "!" + s_nick ); + p_user->set_has_sess( false ); + *p_nick = tool::to_lower(*p_nick); + + if ( *p_pass != *p_pass2 ) + { + p_msgs->append( p_conf->get_elem( "chat.msgs.err.registerpassword" ) ) + ; + } + + // prove if the nick is alphanumeric: + else if ( ! tool::is_alpha_numeric( *p_nick ) ) + { + p_msgs->append( p_conf->get_elem( "chat.msgs.err.alpnum" ) ) + ; + } + + // prove if the nick is too long: + else if ( p_nick->length() > tool::string2int( p_conf->get_elem("chat.maxlength.username") + ) ) + { + p_msgs->append( p_conf->get_elem( "chat.msgs.err.nicklength" ) ); + } + else if ( p_pass->length() > tool::string2int( p_conf->get_elem("chat.maxlength.password") + ) ) + { + p_msgs->append( p_conf->get_elem( "chat.msgs.err.passlength" ) ); + } + else if ( p_email->length() > tool::string2int( p_conf->get_elem("chat.maxlength.emailaddress") + ) ) + { + p_msgs->append( p_conf->get_elem( "chat.msgs.err.emaillength" ) ); + } + else + { + hashmap<string> result_map = p_data->select_user_data( *p_nick, "selectnick" ); + if (result_map["nick"] == *p_nick) + { + p_msgs->append( p_conf->get_elem( "chat.msgs.err.registerexists" ) ); + } + else + { + p_user->set_name( s_nick ); + p_msgs->append( p_conf->get_elem( "chat.msgs.registernick" ) ); + p_request->replace( 0, p_request->length(), p_conf->get_elem("httpd.startsite") ); + + map<string,string> map_insert = *((map<string,string>*) c->elem[1]); + map_insert["password"] = *p_pass; + map_insert["color1"] = p_conf->get_elem("chat.html.user.color1"); + map_insert["color2"] = p_conf->get_elem("chat.html.user.color2"); + map_insert["registerdate"] = tool::int2string((int)tool::unixtime()); + + p_user->set_pass( map_insert["password"] ); + p_user->set_email( map_insert["email"] ); + p_user->set_col1( map_insert["color1"] ); + p_user->set_col2( map_insert["color2"] ); + p_user->set_is_reg( 1 ); + p_user->set_status( tool::string2int(p_conf->get_elem("chat.defaultrang") ) ); + + p_data->insert_user_data( *p_nick, "registernick", map_insert ); + } + } + + return 0; +#endif + + } +} + |
