diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-15 23:29:40 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-15 23:29:40 +0000 |
| commit | d891a923bc507f28caa69f625079755d1a2083e7 (patch) | |
| tree | 03ae20f0ecd1590629ec1e720026ccf34ddaac3f /src/mods/html | |
moved stuff the trunk
Diffstat (limited to 'src/mods/html')
| -rw-r--r-- | src/mods/html/Makefile | 25 | ||||
| -rw-r--r-- | src/mods/html/yc_admin.cpp | 97 | ||||
| -rw-r--r-- | src/mods/html/yc_colors.cpp | 62 | ||||
| -rw-r--r-- | src/mods/html/yc_help.cpp | 75 | ||||
| -rw-r--r-- | src/mods/html/yc_loggedin.cpp | 54 | ||||
| -rw-r--r-- | src/mods/html/yc_options.cpp | 81 | ||||
| -rw-r--r-- | src/mods/html/yc_register.cpp | 121 |
7 files changed, 515 insertions, 0 deletions
diff --git a/src/mods/html/Makefile b/src/mods/html/Makefile new file mode 100644 index 0000000..c17d7f6 --- /dev/null +++ b/src/mods/html/Makefile @@ -0,0 +1,25 @@ +SRCS=$(shell find ./ -name '*.cpp') +MODS=$(addprefix ../../../mods/html/, $(SRCS:.cpp=.so)) +CXX=g++ +CXXFLAGS=-fno-inline -fno-default-inline -g -O2 ${EFLAGS} +all: mods +${MODS}: + @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi + @${CXX} ${CXXGLAGS} -fPIC -shared -s -o $@ ` \ + echo $(notdir $@) | sed s/.so/.cpp/` + @echo "mods:html:`basename $@ | sed s/\.so// | sed s/yc_//` (` \ + du -hs $@ | awk '{ print $$1 }'`) " +infotext: + @echo "===> Compiling html modules" +mods: infotext ${MODS} + @echo "===> Num of html modules: `ls \ + ../../../mods/html/*.so | wc -l | sed 's/ //g;'`" +clean: + @echo "===> Cleaning html modules" + @if test -d ../../../mods/html; then rm -Rf ../../../mods/html; fi +../../../mods/html/./yc_admin.so: yc_admin.cpp +../../../mods/html/./yc_colors.so: yc_colors.cpp +../../../mods/html/./yc_help.so: yc_help.cpp +../../../mods/html/./yc_loggedin.so: yc_loggedin.cpp +../../../mods/html/./yc_options.so: yc_options.cpp +../../../mods/html/./yc_register.so: yc_register.cpp diff --git a/src/mods/html/yc_admin.cpp b/src/mods/html/yc_admin.cpp new file mode 100644 index 0000000..a3a7f1f --- /dev/null +++ b/src/mods/html/yc_admin.cpp @@ -0,0 +1,97 @@ +/*:* + *: File: ./src/mods/html/yc_admin.cpp + *: + *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: Copyright (C) 2006, 2007 Paul C. Buetow + *: + *: 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..dba0318 --- /dev/null +++ b/src/mods/html/yc_colors.cpp @@ -0,0 +1,62 @@ +/*:* + *: File: ./src/mods/html/yc_colors.cpp + *: + *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: Copyright (C) 2006, 2007 Paul C. Buetow + *: + *: 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..970192e --- /dev/null +++ b/src/mods/html/yc_help.cpp @@ -0,0 +1,75 @@ +/*:* + *: File: ./src/mods/html/yc_help.cpp + *: + *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: Copyright (C) 2006, 2007 Paul C. Buetow + *: + *: 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..a50993f --- /dev/null +++ b/src/mods/html/yc_loggedin.cpp @@ -0,0 +1,54 @@ +/*:* + *: File: ./src/mods/html/yc_loggedin.cpp + *: + *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: Copyright (C) 2006, 2007 Paul C. Buetow + *: + *: 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..ec269c8 --- /dev/null +++ b/src/mods/html/yc_options.cpp @@ -0,0 +1,81 @@ +/*:* + *: File: ./src/mods/html/yc_options.cpp + *: + *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: Copyright (C) 2006, 2007 Paul C. Buetow + *: + *: 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..c37ee02 --- /dev/null +++ b/src/mods/html/yc_register.cpp @@ -0,0 +1,121 @@ +/*:* + *: File: ./src/mods/html/yc_register.cpp + *: + *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT + *: + *: Copyright (C) 2003 Paul C. Buetow, Volker Richter + *: Copyright (C) 2004 Paul C. Buetow + *: Copyright (C) 2005 EXA Digital Solutions GbR + *: Copyright (C) 2006, 2007 Paul C. Buetow + *: + *: 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 + + } +} + |
