From d3982ec72b255876db00825605d1d5aae0bc313e Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:43 +0200 Subject: tagging ychat-0.7.7.1 --- CHANGES | 44 +- Makefile | 42 +- NEWS | 8 + README | 33 +- TODO | 60 +- configure | 8 +- etc/ychat.conf | 28 +- html/help.html | 2 +- html/input.html | 10 + html/online.html | 3 +- html/stream.html | 25 +- html/style.css | 22 +- scripts/astyle.sh | 2 +- scripts/buildnr.pl | 2 +- scripts/makeyhttpd.pl | 10 +- scripts/stats.pl | 24 +- src/chat/base.h | 154 +-- src/chat/base.tmpl | 18 +- src/chat/chat.cpp | 467 +++---- src/chat/chat.h | 72 +- src/chat/gcol.cpp | 159 ++- src/chat/gcol.h | 31 +- src/chat/perm.cpp | 69 +- src/chat/perm.h | 45 +- src/chat/room.cpp | 96 +- src/chat/room.h | 108 +- src/chat/sess.cpp | 39 +- src/chat/sess.h | 21 +- src/chat/sman.cpp | 117 +- src/chat/sman.h | 29 +- src/chat/user.cpp | 673 ++++----- src/chat/user.h | 235 ++-- src/cli/cli.cpp | 443 +++--- src/cli/cli.h | 30 +- src/conf/conf.cpp | 192 +-- src/conf/conf.h | 22 +- src/configure | 9 +- src/contrib/crypt/md5.cpp | 333 ++--- src/contrib/crypt/md5.h | 15 +- src/contrib/crypt/md5crypt.cpp | 233 ++-- src/contrib/xml/tinyxml.cpp | 1679 +++++++++++----------- src/contrib/xml/tinyxml.h | 2242 +++++++++++++++++------------- src/contrib/xml/tinyxmlerror.cpp | 44 +- src/contrib/xml/tinyxmlparser.cpp | 2684 ++++++++++++++++++------------------ src/data/con.cpp | 48 +- src/data/con.h | 8 +- src/data/con_base.cpp | 5 +- src/data/con_base.h | 4 +- src/data/data.cpp | 262 ++-- src/data/data.h | 18 +- src/data/data_base.cpp | 232 ++-- src/data/data_base.h | 23 +- src/glob.h | 14 +- src/html.cpp | 163 +-- src/html.h | 45 +- src/incl.h | 6 +- src/logd.cpp | 186 +-- src/logd.h | 41 +- src/main.cpp | 210 +-- src/maps/mtools.h | 6 +- src/maps/mtools.tmpl | 5 +- src/modl.cpp | 155 ++- src/modl.h | 33 +- src/mods/Makefile | 9 +- src/mods/commands/yc_about.cpp | 74 +- src/mods/commands/yc_all.cpp | 77 +- src/mods/commands/yc_away.cpp | 126 +- src/mods/commands/yc_col.cpp | 127 +- src/mods/commands/yc_compopt.cpp | 21 +- src/mods/commands/yc_exec.cpp | 84 +- src/mods/commands/yc_fake.cpp | 43 +- src/mods/commands/yc_getroom.cpp | 70 +- src/mods/commands/yc_getrusage.cpp | 69 +- src/mods/commands/yc_help.cpp | 81 +- src/mods/commands/yc_invisible.cpp | 45 +- src/mods/commands/yc_j.cpp | 183 ++- src/mods/commands/yc_ko.cpp | 88 +- src/mods/commands/yc_m.cpp | 65 +- src/mods/commands/yc_md5.cpp | 84 +- src/mods/commands/yc_me.cpp | 67 +- src/mods/commands/yc_morph.cpp | 77 +- src/mods/commands/yc_msg.cpp | 94 +- src/mods/commands/yc_q.cpp | 27 +- src/mods/commands/yc_reload.cpp | 29 +- src/mods/commands/yc_ren.cpp | 108 +- src/mods/commands/yc_s.cpp | 81 +- src/mods/commands/yc_set.cpp | 175 ++- src/mods/commands/yc_template.cpp | 25 +- src/mods/commands/yc_time.cpp | 27 +- src/mods/commands/yc_topic.cpp | 138 +- src/mods/commands/yc_uptime.cpp | 27 +- src/mods/commands/yc_version.cpp | 21 +- src/mods/html/yc_admin.cpp | 119 +- src/mods/html/yc_colors.cpp | 52 +- src/mods/html/yc_help.cpp | 74 +- src/mods/html/yc_options.cpp | 81 +- src/mods/html/yc_register.cpp | 165 +-- src/msgs.h | 37 +- src/name.cpp | 34 +- src/name.h | 20 +- src/ncur/menu.cpp | 149 +- src/ncur/menu.h | 27 +- src/ncur/ncur.cpp | 374 ++--- src/ncur/ncur.h | 50 +- src/reqp.cpp | 545 ++++---- src/reqp.h | 61 +- src/sock/sock.cpp | 398 +++--- src/sock/sock.h | 80 +- src/stats.cpp | 167 +-- src/stats.h | 23 +- src/thrd/pool.cpp | 315 +++-- src/thrd/pool.h | 108 +- src/thrd/thro.cpp | 23 +- src/thrd/thro.h | 26 +- src/time/timo.cpp | 24 +- src/time/timo.h | 12 +- src/time/timr.cpp | 201 +-- src/time/timr.h | 81 +- src/tool/dir.cpp | 44 +- src/tool/dir.h | 26 +- src/tool/tool.cpp | 255 ++-- src/tool/tool.h | 96 +- src/wrap.cpp | 14 +- src/wrap.h | 106 +- 124 files changed, 9325 insertions(+), 8650 deletions(-) mode change 100644 => 100755 src/msgs.h diff --git a/CHANGES b/CHANGES index c4e2d04..4bf7178 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,40 @@ -Changes from 0.7.2 to 0.7.3 RELEASE +Changes from 0.7.6-RELEASE to 0.7.7-RELEASE +- Major code cleanup +- Bugfix in /col +- Bugfix in gcol #1 (destroy session also if no database is used) +- Bugfix in gcol #2 (now runs each hour not once a day) +- Renew the style.css and stream.html + +Changes from 0.7.5-RELEASE to 0.7.6-RELEASE +- Removed the old hash maps and included the SGI C++ STL extenstion + hash_map. + +Changes from 0.7.4.1-RELEASE to 0.7.5-RELEASE +- Garbage collector will now run once a hour rather than each ten minutes. +- Dynamic thread pool improvements. +- Removed equiv-http-refresh meta tag from the online list. +- Minor bugfix in the /topic command. +- Implemented "User list" + +Changes from 0.7.4-RELEASE to 0.7.4.1-RELEASE: +- Dynamic thread pool bugfix (dead lock) + +Changes from 0.7.3-RELEASE to 0.7.4-RELEASE: +- Code cleanup. +- Made the thread pool increasing dynamic. +- Added some thread pool optimazions. +- Added some more ${MAKE} vars to the Makefiles. +- Added Content-length to the HTTPD header. +- Added the !command to the command line interface. +- Added Content-type text/plain. +- Added scrolling checkbox to input.html +- Removed modl from yhttpd. Dynamic modules are not needed in yhttpd yet. +- Improved session engine. +- Fixed auto logout bug. +- Fixed newline bug (one \n too much for each html template) +- Logging can now be completely disabled. + +Changes from 0.7.2 to 0.7.3-RELEASE: - Added FreeBSD 5.3-RELEASE support. - Added chat.enableguest option. - Added the /all command (Global system message) @@ -8,7 +44,7 @@ Changes from 0.7.2 to 0.7.3 RELEASE - Fixed the /msg bug (In /msg the string replacer should be activated). - Fixed logging bug (do not log any timestamps if there are no messages). -Changes from 0.7.1 to 0.7.2 RELEASE +Changes from 0.7.1 to 0.7.2-RELEASE: New features: - /morph - Added the new standard html template design. @@ -22,7 +58,7 @@ Bugfixes: - /topic now prints the topic in the user's color. - Fixed some typos. -Changes from 0.7.0 to 0.7.1 RELEASE +Changes from 0.7.0 to 0.7.1-RELEASE: - Added ${MAKE} to the config file because some Linux distros dont use the "gmake" command for GNU make but just "make"! Modified the configure script to generate a make.version file. @@ -33,7 +69,7 @@ Changes from 0.7.0 to 0.7.1 RELEASE need MySQL at all. - Added the chat.maxlength.word option. -Changes from 0.6 to 0.7.0 RELEASE +Changes from 0.6 to 0.7.0-RELEASE: - Better stability - Better performance (using more hmaps) - HTML color switcher menu diff --git a/Makefile b/Makefile index 96266ea..e0b6e07 100755 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -MAKE=`tail -1 make.version` +MAKE=`tail -n 1 make.version` PREFIX=`grep "define PREFIX" src/glob.h | cut -d'"' -f2` -all: base modules version mail +all: version base modules version @echo "Now edit the ychat.conf and run ychat!" @echo "The config file is searched in the following order:" @echo " ./ychat.conf " @@ -8,9 +8,12 @@ all: base modules version mail @echo " ./etc/ychat.conf " @echo " /etc/ychat.conf " @echo " $(PREFIX)/etc/ychat.conf " + @echo If you want to help the yChat project please run gmake mail + @echo so that the developers receive an email about the platform + @echo being used. mail: @echo "VERSION:" > mail.tmp - @gmake version >> mail.tmp + @${MAKE} version >> mail.tmp @echo >> mail.tmp @echo "UNAME:" >> mail.tmp @uname -a >> mail.tmp @@ -22,35 +25,12 @@ mail: @cat g++.version make.version >> mail.tmp @cat mail.tmp | mail -s "Successfull build of yChat" successfullbuild@yhttpd.org @rm -f mail.tmp -install: deinstall - @echo "Instaling ychat to $(PREFIX)" - @cp bin/ychat $(PREFIX)/bin - @if ! test -d $(PREFIX)/lib/ychat; then mkdir -p $(PREFIX)/lib/ychat; fi - @if ! test -d $(PREFIX)/share/ychat/log/rooms; then mkdir -p $(PREFIX)/share/ychat/log/rooms; fi - @if ! test -d $(PREFIX)/etc; then mkdir $(PREFIX)/etc; fi - @if test -d mods; then cp -Rp mods $(PREFIX)/lib/ychat/mods; fi - @cp -Rp html $(PREFIX)/share/ychat/html - @cp -Rp lang $(PREFIX)/share/ychat/lang - @if test -f $(PREFIX)/etc/ychat.conf; then mv $(PREFIX)/etc/ychat.conf $(PREFIX)/etc/ychat.conf.bak; fi - @cp etc/ychat.conf etc/ychat.conf.tmp - @sed "s#mods/#$(PREFIX)/lib/ychat/mods/#" etc/ychat.conf.tmp > etc/ychat.conf.tmp.2 && mv etc/ychat.conf.tmp.2 etc/ychat.conf.tmp - @sed "s#\"log/#\"$(PREFIX)/share/ychat/log/#" etc/ychat.conf.tmp > etc/ychat.conf.tmp.2 && mv etc/ychat.conf.tmp.2 etc/ychat.conf.tmp - @sed "s#LANGUAGE_DIR=\"lang/#LANGUAGE_DIR=\"$(PREFIX)/share/ychat/lang/#" etc/ychat.conf.tmp > etc/ychat.conf.tmp.2 && mv etc/ychat.conf.tmp.2 etc/ychat.conf.tmp - @sed "s#HTML_TEMPLATE_DIR=\"html/#HTML_TEMPLATE_DIR=\"$(PREFIX)/share/ychat/html/#" etc/ychat.conf.tmp > etc/ychat.conf.tmp.2 && mv etc/ychat.conf.tmp.2 etc/ychat.conf.tmp - @mv etc/ychat.conf.tmp $(PREFIX)/etc/ychat.conf - @echo "yChat configuration file can be found under" - @echo " $(PREFIX)/etc/ychat.conf" - @echo "Copy it to ~/.ychat/ychat.conf to use local settings :-)" - @echo "Be sure that $(PREFIX)/share/ychat/logs is writable by your user or modify " - @echo "logging dirs in the ychat.conf to a local directory." - @echo "The most secure would be an additional user 'ychat'!" +install: deinstall uninstall: deinstall deinstall: - @echo "Deinstalling ychat from $(PREFIX)" - @if test -f $(PREFIX)/bin/ychat; then rm -f $(PREFIX)/bin/ychat; fi - @if test -d $(PREFIX)/lib/ychat; then rm -Rf $(PREFIX)/lib/ychat; fi - @if test -d $(PREFIX)/share/ychat; then rm -Rf $(PREFIX)/share/ychat; fi - @echo "Done. Please remove manually $(PREFIX)/etc/ychat.conf to complete" + @echo Install/deinstall is not supported! + @echo Start yChat with ./bin/ychat instead! + @exit 1 modules: @if test -d ./src/mods; then ${MAKE} -C ./src/mods; fi clean_modules: @@ -99,6 +79,6 @@ mrproper: clean @find . -name "*.add" | xargs rm -f @ls | grep core | xargs rm -f version: - @echo "`grep VERSION src/msgs.h | cut -d'"' -f2`-`grep BRANCH src/msgs.h| cut -d'"' -f2` Build `grep BUILD src/msgs.h| cut -d' ' -f3`" + @./scripts/version.sh debug: @gdb bin/ychat ychat.core diff --git a/NEWS b/NEWS index 034d63d..f255184 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +::(21.02.05)::Released yChat 0.7.7. A major code cleanup has been made and the ANSI code formating is now being used. Bugfixes in the timer thread have been made and the standard demo HTML style has been renewed. +::(17.02.05)::Released yChat 0.7.6. This release now uses the hash_map class from the SGI STL extension which is more stable then the old Hash Map used by yChat. +::(14.02.05)::Released yChat 0.7.5. The garbage collector will now run once a hour. The dynamic thread pool has been improved. Removed thre equiv-http-refresh meta tag from the online list. Added a minor bugfix in the /topic command. Implemented an HTML based list of all logged in users and the /users command which does the same. +::(13.02.05)::Released yChat 0.7.4.1 This new version includes a major bugfix made in the new dynamic thread pool which has been introdouced in 0.7.4. The bug resulted in a thread pool dead lock.. Tagged yChat 0.7.5-CURRENT into CVS. +::(12.02.05)::Released yChat 0.7.4. This release includes a code cleanup and a dynamic increasing thread pool. Also, some other thread pool and session engine improvements were made. The Makefiles got more organized and the HTTPD header has got a Content-length line. The Content-type text/plain is now also supported. The command line interface has got the ! (bang) operator. So you can run programs of your shell through yChat. The HTML interface has got a scrolling checkbox to de/activate the scrolling of the chat stream. Last but not least some bugfixes were made. +::(09.02.05)::Tagged yChat 0.7.4-PRERELEASE into CVS. The RELEASE will follow this week. +::(08.01.05)::We passed the build number 3000! 3000 times yChat has been compiled during the developing process since there are build numbers! Also the first steps have been made porting yChat/yhttpd to the Windows platform using Cygwin (yChat 0.7.4-CURRENT Build 3040 CYGWIN_NT-5.1 1.5.12 (0.116/4/2) i686). It runs without having installed Cygwin and having an 1MB cygwin1.dll file instead. There are still some issues (like dynamic modules [which means, that there are no chat commands and no color choser etc], command line interface, ncurses interface, database support) which do not yet run on Cygwin. But those issues will be resolved the next weeks. An alpha (experimental) binary yChat/Win32 release might be done also. +::(04.01.05)::First we wish all of you a happy new year. Second we have to announce that yhttpd 0.7-CURRENT now also has tested on an OpenBSD/i386 MP 3.6 box with success. Also yChat 0.7.4-CURRENT is now available from CVS. ::(29.12.04)::Released yChat 0.7.3-RELEASE. New features: Added the /all command (Global system message), added FreeBSD 5.3-RELEASE support, added chat.enableguest option. Renamed the /getstatus command into /about. Fixed some bugs. ::(09.11.04)::Released yChat 0.7.2-RELEASE. New features: /morph. Added the new standard html template design. Bugfixes: /away prints a . instead of a : if no away reason is given. /ko message was wrong. Displayed not room name of the user to be kicked out. /invisible command displayed wrong private messages. /getstatus had no help text. /msg and /s should now print the system time if printalwaystime == true. Added a blank to the /uptime message. /topic now prints the topic in the user's color. - Fixed some typos. diff --git a/README b/README index bed3c9d..cf58741 100755 --- a/README +++ b/README @@ -1,9 +1,7 @@ -yChat; Homepage: www.yChat.org; Version 0.7.3-RELEASE - +yChat; Homepage: www.yChat.org; Version 0.7.7.1-RELEASE Copyright (C) 2003 Paul C. Buetow, Volker Richter -Copyright (C) 2004 Paul C. Buetow +Copyright (C) 2004, 2005 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 @@ -55,7 +53,7 @@ Engine powerd browsers like Mozilla, Firefox, Camino etc. yChat runs completely stand alone and does not need another webserver to build on like Apache and does not need to be run via any kind of CGI. yChat creates its own socket on a customized port (standard port: 2000) and seems to be a full -features HTTP web server to the clients (web browsers). +featured HTTP web server to the clients (web browsers). The yChat code base can be converted to an yhttpd code base automaticaly. yhttpd is the webserver subset of yChat which runs completely stand alone and provides @@ -67,9 +65,8 @@ yChat is written in C++ which is faster than any Java based Chat-Server or any server written in a scripting language like PHP, Python or Perl. As the internal data structures hash maps are used to garuantee searching certain values in O(1) amount of time. If a hash maps gets full, it will be rehashed. -The maximum usage in % can be redefined too (standard is 90%). Currently, yChat -has been measured providing over 5000 hits/requests per second (chat message -postings) on a FreeBSD based server box while using less than 2% of CPU usage +Currently, yChat has been measured providing over 1000 hits/requests per second +on a FreeBSD based server box while using less than 2% of CPU usage on a Athlon XP 1900+. Performance seems to be limited by your bandwith only. Also, each user gets its own session id (random string) with a standard length of 50 chars to authenticate each logged in user. The length of the session id @@ -115,7 +112,7 @@ well . To improve performance, you can define the logging puffer (standardly new logs will be written to disk after each 20 lines). If you want to log everything immediately, you can reset this option to 1 in ychat.conf. -- Its modular - +- Its modular through own command and dynamic HTML engine - All chat commands are realized through dynamic loadable module files which can be recompiled and reloaded without restarting the whole yChat server. Also HTML-Sites with certain tasks can be compiled as a module like @@ -157,6 +154,11 @@ lot of user and room objects are created and destroyed frequently. yChat Makefiles only have been tested with GNU make and may not work with other make versions. +- SGI STL extension + Includes ext/hash_map which may be already default on every Linux distro. + On *BSD you have to install it first before compiling. On FreeBSD + /usr/ports/devel/stlport is your friend. + //<<* - mysql-client 4.x (3.x may do too but is not supported) Includes libmysqlclient and the mysql.h header files. @@ -179,13 +181,15 @@ a listed platform did not work at all please contact me: Operating system (arch) GNU G++ GNU make - FreeBSD 5.3-RELEASE (i386) 3.4.2 3.80 -- FreeBSD 4.10-RELEASE (i386) 3.4.1 3.80 - FreeBSD 5.2.1-RELEASE (i386) 3.3.3 3.80 +- FreeBSD 4.10-RELEASE (i386) 3.4.1 3.80 - FreeBSD 4.9-RELEASE (i386) 3.3.4 3.80 -- Gentoo Linux 2004.2 (i386) 3.3.2 3.80 -- OpenBSD 3.6 MP (i386) 3.3.2 3.80 +- Gentoo Linux 2004 (i386) 3.3.2 3.80 +- OpenBSD 3.6 SMP (i386) 3.3.2 3.80 +- Red Hat Linux 8.0 SMP (i386) 3.2-7 3.79 - Slackware Linux 10.0 (i386) 3.4.0 3.80 -- SUSE Linux 8.0 (i386) 3.3.1 3.80 +- SUSE Linux 9.0 (i386) 3.3.1 3.80 +- SUSE Linux 8.1 (i386) 3.2 3.79.1 Other platforms like Linux based systems, other BSD-Systems or UNICES are very likely to work too. @@ -243,17 +247,14 @@ or gmake config): gmake clean_base (only cleans the base obj and rpo files) gmake clean_modules (only cleans the modules .so files) gmake config (runs yChat configurator) - gmake deinstall (deinstalls ychat from PREFIX) gmake gpl (shows the GNU General Public License) gmake help (shows all available ychat gmake targets) - gmake install (installs ychat to PREFIX) gmake mail (sends a mail to the yChat developers containing build opts.) gmake modules (only compiles modules) gmake mrproper (same as gmake clean plus removing all temp files) gmake setup (runs all configure scripts and afterwards gmake all) gmake start (compiles everything and starts the server) gmake stats (generates ychat statistics) - gmake uninstall (same as deinstall) gmake version (shows the current version of yChat) //<<* gmake yhttpdbase (generates an yhttpd code base) diff --git a/TODO b/TODO index be00c69..e251970 100644 --- a/TODO +++ b/TODO @@ -1,60 +1,40 @@ -Already done for next RELEASE: - -Might do's for next feature RELEASE: +Might do's for next RELEASE: +- Remove Chat stuff from yhttpd.conf +- dir : public vector - Disable /help command for commands wich are not accessible for the specific user. - Flood protection -- Remove sess.cpp, use sman.cpp only. - Add /nick, /beam, /su -- Improve /ko, /msg, so they can used on several users at once with /ko (user1,user2) -- Improve /ko, so that there can be a reason specified as well. - Add / to whisper to the last person to whom the user has been whispered the last time. - Room maxuser limit. -Known Bugs: -- Auto-logout does s.t. not work (ghost chatter) because the socket.h send - function does not always return a false value if the socket is already - closed on the other end. - To do in general for some later RELEASE: +- Not found sites should get a 404 error site! +- Implement dynamic timer +- Implement ncurse object browser +- Implement yXML subproject +- Implement ODBC support - Implement login counter. - Implement msg post counter. - Implement online time counter. - Implement hall of fame rankings of the counters above. Also add a msg/minute hall of fame. -- Make CLI accessible through a chat command /cli -- Disable http-refresh of the online frame. Reload it only if there has been s.t. changed. +- Implement traffic stats +- Implement more chat commands +- Implement new dynamic command permission method +- Implement SSL sockets with OpenSSL +- Implement user profiles +- Implement action form to input.html +- Implement IRC support +- Implement possibility sending Mails through external SMTP server (for password reminder etc) +- Implement chat moderator option +- Implement several HTML styles, each user can use his favourite style +- Implement compatibility to Opera, Links, Konqueror and Safari +- Implement browser side caching for gfx files support - Implement a http:// url detection and make a link out of it! -- Add scroll pause button to input.html - Remove user.cpp member variables as possible and replace them with hash maps for (integer,mutex) and (string,mutex) pairs. Maybe use s.t. like this: p_user->val("name"); to get the users name and p_user->val("name","val"); to reset his name. Maybe use templates to get different types besides strings: p_user->val("hits"); -- Add socket timeouts -- Improve some HTTPD-Stuff -- Add traffic stats - Write changes of the configuration back into XML if wished. -- Add some chat commands -- Make more values of the conf object dynamic (on the fly changable by the CLI) -- Make the thread pool size dynamic -- Remove inline methods -- New dynamic command permission method - The admin should allow/deny commands for each user seperately -- Add PostgreSQL support -- Add SQLite support -- Add SSL sockets with OpenSSL -- Add user profiles -- Add action form to input.html -- FreeBSD ports tree inclusion -- Several HTML styles, each user can use his favourite style -- Chat moderator option -- Possibility sending Mails through external SMTP server - (for password reminder etc) -- Advanced chat statistics -- Add IRC support -- Add ICQ support -- Add MPI support (load balancing) -- Forum -- Compatibility to Opera, Links, Konqueror and Safari -- Add browser side caching for gfx files support diff --git a/configure b/configure index 0639500..20e84d0 100755 --- a/configure +++ b/configure @@ -70,5 +70,9 @@ perl -e ' exit(0); ' `echo "$*" | sed "s/-//g"` -echo You are ready to type gmake now! -echo Please read the README first in order to know what gmake is doing! +if test -f err +then + rm -f err +else + echo You are ready to type gmake now! +fi diff --git a/etc/ychat.conf b/etc/ychat.conf index 7fc8cc7..1a48d79 100644 --- a/etc/ychat.conf +++ b/etc/ychat.conf @@ -1,4 +1,4 @@ - + + @@ -134,7 +137,7 @@ + @@ -353,6 +359,9 @@ + @@ -583,12 +592,16 @@ - + @@ -662,6 +675,9 @@ + diff --git a/html/help.html b/html/help.html index 57ae511..ad9a25f 100755 --- a/html/help.html +++ b/html/help.html @@ -11,7 +11,7 @@ - %%USERLIST%% + %%USERLIST%%
Hello %%nick%%, all chat commands available are summarized below (Please notice that only currently - in memory loaded command modules are listed here which should be the case by yChat default configuration): + in memory loaded command modules are listed here which should be the case by yChat default configuration). You can also access help for a specific command with the /help command. Example: /help commandname:

diff --git a/html/input.html b/html/input.html index 3a9b564..31ed9fe 100755 --- a/html/input.html +++ b/html/input.html @@ -26,6 +26,13 @@ var top = (screen.availHeight-height)/2; var win = window.open(site,"_blank","width="+width+",height="+height+",left="+left+",top="+top+",scrollbars=yes"); } + function chgscroll(f) + { + if(f.checked) + parent.stream.autoscroll(); + else + parent.stream.stopscroll(); + } //--> @@ -40,8 +47,11 @@ Colors Options Help + Users Admin Logout + Scrolling: + diff --git a/html/online.html b/html/online.html index fc1fd84..6a10fd9 100755 --- a/html/online.html +++ b/html/online.html @@ -2,7 +2,6 @@ - %%ROOMNAME%% @@ -14,7 +13,7 @@ %%ROOMTOPIC%%
diff --git a/html/stream.html b/html/stream.html index db4c05c..ed08a23 100755 --- a/html/stream.html +++ b/html/stream.html @@ -8,32 +8,31 @@ - - Welcome to yChat %%nick%%! + Welcome to the chat, %%nick%%!

diff --git a/html/style.css b/html/style.css index ade4a1a..4b6d9ca 100755 --- a/html/style.css +++ b/html/style.css @@ -9,37 +9,33 @@ input { color: #000000; font-family: Verdana, Helvetica, sans-serif; text-decoration: none; - color: #FFFFEF; - background-color: #000000; - border: solid #555555 1px; font-size: 9pt; padding: 2px; } input.text { - background-color: #AA5100; + background-color: #FFFFEF; } .fancy { font-family: Verdana, Helvetica, sans-serif; - text-decoration: none; - color: #FFFFEF; - background-color: #000000; - border: solid #555555 1px; font-size: 9pt; + color: #FFFFEF; padding: 2px; } a:hover.fancy { text-decoration: none; color: #FFFFEF; - background-color: #323232; - border: solid #FFFFEF 1px; + background-color: #000000; } -b { - background-color: #323232; - border: solid #555555 1px; +h1 { + background-color: #ffa500; + border: solid #000000 1px; + font-size: 20pt; + padding: 13px; + font-width: bold; } body.stream { diff --git a/scripts/astyle.sh b/scripts/astyle.sh index 4376887..b9dbc45 100755 --- a/scripts/astyle.sh +++ b/scripts/astyle.sh @@ -8,7 +8,7 @@ do for i in `find . -name "*.$f"` do echo $i - astyle --style=gnu $i + astyle --style=ansi -s2 $i rm -f $i.orig done done diff --git a/scripts/buildnr.pl b/scripts/buildnr.pl index e691a11..ee3d3e2 100755 --- a/scripts/buildnr.pl +++ b/scripts/buildnr.pl @@ -13,7 +13,7 @@ close MSGS; foreach (@msgs) { - if ( /BUILDNR/ ) + if ( /define BUILDNR/ ) { s/(BUILDNR )(.+)$/$1.($2+1)/e; print; diff --git a/scripts/makeyhttpd.pl b/scripts/makeyhttpd.pl index 2805360..101343a 100644 --- a/scripts/makeyhttpd.pl +++ b/scripts/makeyhttpd.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# The yChat & yhttpd Project (2004) +# The yChat & yhttpd Project (2004, 2005) # # This scripts modifies the yChat sources to yhttpd sources. @@ -17,6 +17,8 @@ my @delete = ( 'src/data', 'src/irc', 'src/contrib/crypt', + 'src/modl.h', + 'src/modl.cpp', 'src/mods', 'src/mods/commands', 'src/mods/irc', @@ -75,7 +77,7 @@ foreach (@delete) { system("rm -Rf $_"); } -print "Deleting CVS directories\n"; +print "\nDeleting CVS directories\n"; system("find . -name CVS | xargs rm -Rf"); print "Creating new dirs\n->"; @@ -84,14 +86,14 @@ foreach (@createdir) { system("mkdir $_"); } -print "Renaming config file\n"; +print "\nRenaming config file\n"; system("mv etc/ychat.conf etc/yhttpd.conf"); print "Moving html templates\n"; system("mv demo.html html/index.html"); system("mv test.cgi notfound.html style.css html"); -print "Removing marked lines of code\n ->"; +print "Removing marked lines of code\n->"; &remove_marked_lines('.'); sub remove_marked_lines { diff --git a/scripts/stats.pl b/scripts/stats.pl index 38cc67c..e5cc2b3 100755 --- a/scripts/stats.pl +++ b/scripts/stats.pl @@ -9,6 +9,7 @@ use strict; use scripts::modules::file; my %stats; +my $param = shift; &recursive("."); @@ -17,19 +18,16 @@ $stats{"Lines total"} = $stats{"Lines of source"} + $stats{"Lines of text"} + $stats{"Lines of HTML"}; -my $bool = 0; -foreach ( sort keys %stats ) -{ - if ($bool == 0) - { - print "$_ = " . $stats{$_} . "\n"; - $bool = 1; - } - else - { - print "$_ = " . $stats{$_} . "\n"; - $bool = 0; - } +unless (defined $param) { + + print "$_ = " . $stats{$_} . "\n" + for ( sort keys %stats ); + +} else { + + print $stats{$_} . " " + for sort keys %stats; + } print "\n"; diff --git a/src/chat/base.h b/src/chat/base.h index ae2e926..9da4304 100755 --- a/src/chat/base.h +++ b/src/chat/base.h @@ -1,89 +1,89 @@ -// template class data declaration; #include "../incl.h" #ifndef BASE_H #define BASE_H -#include "../maps/smap.h" +#include +#include "../maps/nhashmap.h" template -class base : public smap +class base : public nhashmap { public: - base(); - ~base(); - - static string to_lower( string s ) - { - string s_tmp(""); - for(int i=0;i < s.size() ;i++) - s_tmp=s_tmp+(char)tolower(s.at(i)); - return s_tmp; - } - - virtual type* get_elem( string s_name, bool &b_found ); // get a element. - virtual void add_elem( type* p_type ); // add a element. - - // chat::msg_post sends to all users of the system a message. - // room::msg_post sends to all users of the room a message. - // user::msg_post sends to the user a message. - virtual void msg_post( string *s_msg ) - { - smap::run_func( &base::msg_post_ , (void*)s_msg ); - } - - static void msg_post_( type* type_obj, void* v_arg ) - { - type_obj -> msg_post( (string*) v_arg ); - } - - virtual void check_timeout( int* i_timeout_settings ) - { - smap::run_func( &base::check_timeout_ , (void*)i_timeout_settings ); - } - - static void check_timeout_( type* type_obj, void* v_arg ) - { - type_obj -> check_timeout( (int*) v_arg ); - } - - virtual void reconf() - { - smap::run_func( &base::reconf_ ); - } - - static void reconf_ ( type* type_obj ) - { - type_obj -> reconf (); - } - - void get_data( map_string *p_map_string ) - { - smap::run_func( &base::get_data_ , (void*)p_map_string ); - } - - static void get_data_( type* type_obj, void* v_arg ) - { - type_obj -> get_data ( (map_string*) v_arg ); - } - - - // chat::get_user_list gets a list of all users of the system. - // room::get_user_list gets a list of all users of the room. - // user::get_user_list gets a "list" of a user usernameseperator - void get_user_list( string &s_list ) - { - container c; - c.elem[0] = (void*) &s_list; - - smap::run_func( &base::get_user_list_, (void*)&c ); - } - - static void get_user_list_( type* type_obj, void* v_arg ) - { - container *c = (container*) v_arg; - type_obj -> get_user_list( *((string*)c->elem[0]) ); - } + base(); + ~base(); + + static string to_lower( string s ) + { + string s_tmp(""); + for(int i=0;i < s.size() ;i++) + s_tmp=s_tmp+(char)tolower(s.at(i)); + return s_tmp; + } + + virtual type* get_elem( string s_name, bool &b_found ); // get a element. + virtual void add_elem( type* p_type ); // add a element. + + // chat::msg_post sends to all users of the system a message. + // room::msg_post sends to all users of the room a message. + // user::msg_post sends to the user a message. + virtual void msg_post( string *s_msg ) + { + nhashmap::run_func( &base::msg_post_ , (void*)s_msg ); + } + + static void msg_post_( type* type_obj, void* v_arg ) + { + type_obj -> msg_post( (string*) v_arg ); + } + + virtual void check_timeout( int* i_timeout_settings ) + { + nhashmap::run_func( &base::check_timeout_ , (void*)i_timeout_settings ); + } + + static void check_timeout_( type* type_obj, void* v_arg ) + { + type_obj -> check_timeout( (int*) v_arg ); + } + + virtual void reconf() + { + nhashmap::run_func( &base::reconf_ ); + } + + static void reconf_ ( type* type_obj ) + { + type_obj -> reconf (); + } + + void get_data( map *p_map_string ) + { + nhashmap::run_func( &base::get_data_ , (void*)p_map_string ); + } + + static void get_data_( type* type_obj, void* v_arg ) + { + type_obj -> get_data ( (map*) v_arg ); + } + + + // chat::get_user_list gets a list of all users of the system. + // room::get_user_list gets a list of all users of the room. + // user::get_user_list gets a "list" of a user usernameseperator + void get_user_list( string &s_list ) + { + container c; + c.elem[0] = (void*) &s_list; + + nhashmap::run_func( &base::get_user_list_, (void*)&c ); + } + + static void get_user_list_( type* type_obj, void* v_arg ) + { + container *c = (container*) v_arg; + type_obj -> get_user_list( *((string*)c->elem[0]) ); + } }; #include "base.tmpl" diff --git a/src/chat/base.tmpl b/src/chat/base.tmpl index 53b609f..0be21aa 100755 --- a/src/chat/base.tmpl +++ b/src/chat/base.tmpl @@ -4,30 +4,28 @@ #include "base.h" template -base::base() : smap::smap(HMAPOCC) -{ -} +base::base() +{} template base::~base( ) -{ -} +{} template type* base::get_elem( string s_name, bool &b_found ) { - s_name = to_lower(s_name); - type* p_type = smap::get_elem( s_name ); - b_found = p_type == NULL ? false : true; - return p_type; + s_name = to_lower(s_name); + type* p_type = nhashmap::get_elem( s_name ); + b_found = p_type == NULL ? false : true; + return p_type; } template void base::add_elem( type* p_type ) { - smap::add_elem(p_type, p_type->get_lowercase_name()); + nhashmap::add_elem(p_type, p_type->get_lowercase_name()); } #endif diff --git a/src/chat/chat.cpp b/src/chat/chat.cpp index 03cd8c1..019f939 100755 --- a/src/chat/chat.cpp +++ b/src/chat/chat.cpp @@ -12,190 +12,193 @@ using namespace std; chat::chat( ) { - { // Set up replace strings; - wrap::system_message(CHATREP); - vector* p_vec_keys = wrap::CONF->get_key_vector(); - - for (vector::iterator iter = p_vec_keys->begin(); - iter != p_vec_keys->end(); iter++ ) + { // Set up replace strings; + wrap::system_message(CHATREP); + vector* p_vec_keys = wrap::CONF->get_key_vector(); + + for (vector::iterator iter = p_vec_keys->begin(); + iter != p_vec_keys->end(); + iter++ ) + { + if ( iter->length() >= 24 && iter->compare( 0, 22, "chat.html.replace.from" ) == 0 ) { - if ( iter->length() >= 24 && iter->compare( 0, 22, "chat.html.replace.from" ) == 0 ) - { string s_from = wrap::CONF->get_elem(*iter); map_replace_strings[s_from] = "chat.html.replace.into." + s_from; - vec_replace_keys.push_back(s_from); - } - } - - sort(vec_replace_keys.begin(), vec_replace_keys.end()); - delete p_vec_keys; + vec_replace_keys.push_back(s_from); + } } + + sort(vec_replace_keys.begin(), vec_replace_keys.end()); + delete p_vec_keys; + } } chat::~chat( ) { - // Delete all room objects! - run_func( mtools::delete_obj ); + // Delete all room objects! + run_func( mtools::delete_obj ); } user* chat::get_user( string &s_user ) { - bool b_flag; - return get_user( s_user, b_flag ); + bool b_flag; + return get_user( s_user, b_flag ); } user* chat::get_user( string &s_user, bool &b_found ) { - container param; + container param; - param.elem[0] = (void*) &s_user ; - param.elem[1] = (void*) &b_found; + param.elem[0] = (void*) &s_user ; + param.elem[1] = (void*) &b_found; - b_found = false; + b_found = false; - smap::run_func( get_user_, (void*)¶m ); + base::run_func( get_user_, (void*)¶m ); - if ( *( (bool*) param.elem[1] ) ) - return (user*) param.elem[2]; + if ( *( (bool*) param.elem[1] ) ) + return (user*) param.elem[2]; } void chat::get_user_( room *room_obj, void *v_arg ) { - container* param = (container*) v_arg; + container* param = (container*) v_arg; - if ( *((bool*)param->elem[1]) ) - return; + if ( *((bool*)param->elem[1]) ) + return; - param->elem[2] = (void*)room_obj->get_elem( *((string*)param->elem[0]), *((bool*)param->elem[1]) ); + param->elem[2] = (void*)room_obj->get_elem( *((string*)param->elem[0]), *((bool*)param->elem[1]) ); } void -chat::login( map_string &map_params ) +chat::login( hashmap &map_params ) { - string s_user = map_params["nick"]; - - // prove if nick is empty: - if ( s_user.empty() ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.nonick" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE0 ); - return; - } - - // prove if the nick is alphanumeric: - else if ( ! tool::is_alpha_numeric( s_user ) ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.alpnum" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE1 + s_user ); - return; - } - - // prove if the nick is too long: - else if ( s_user.length() > tool::string2int( wrap::CONF->get_elem("chat.maxlength.username") ) ) + string s_user = map_params["nick"]; + + // prove if nick is empty: + if ( s_user.empty() ) + { + map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.nonick" ); + map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. + wrap::system_message( LOGINE0 ); + return; + } + + // prove if the nick is alphanumeric: + else if ( ! tool::is_alpha_numeric( s_user ) ) + { + map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.alpnum" ); + map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. + wrap::system_message( LOGINE1 + s_user ); + return; + } + + // prove if the nick is too long: + else if ( s_user.length() > tool::string2int( wrap::CONF->get_elem("chat.maxlength.username") ) ) + { + map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.nicklength" ); + map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. + wrap::system_message( LOGINE2 + s_user ); + return; + } + + // prove if the room name is too long: + else if ( map_params["room"].length() > tool::string2int( wrap::CONF->get_elem("chat.maxlength.roomname") ) ) + { + map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.roomnamelength" ); + map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. + wrap::system_message( LOGINE3 + s_user + " / " + map_params["room"] ); + return; + } + + // prove if the room name is valid + else if ( map_params["room"].length() < 1 ) + { + map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.noroom" ); + map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. + wrap::system_message( LOGINE3 + s_user + " / " + map_params["room"] ); + return; + } + + bool b_flag; + + // prove if nick is already online / logged in. + get_user( s_user, b_flag ); + + if ( b_flag ) + { + map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.online" ); + map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); + + return; + } + + // Prove if user is recycleable from the garbage collector: + user *p_user = wrap::GCOL->get_user_from_garbage( s_user ); + + if ( p_user != NULL ) + { + // 1. possibility to prove the password at login! (using recycled user) + if ( p_user->get_pass() != map_params["password"] ) { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.nicklength" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE2 + s_user ); - return; - } - - // prove if the room name is too long: - else if ( map_params["room"].length() > tool::string2int( wrap::CONF->get_elem("chat.maxlength.roomname") ) ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.roomnamelength" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE3 + s_user + " / " + map_params["room"] ); - return; - } - - // prove if the room name is valid - else if ( map_params["room"].length() < 1 ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.noroom" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE3 + s_user + " / " + map_params["room"] ); - return; - } - - bool b_flag; - - // prove if nick is already online / logged in. - get_user( s_user, b_flag ); - - if ( b_flag ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.online" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); - - return; - } - - // Prove if user is recycleable from the garbage collector: - user *p_user = wrap::GCOL->get_user_from_garbage( s_user ); - - if ( p_user != NULL ) - { - // 1. possibility to prove the password at login! (using recycled user) - if ( p_user->get_pass() != map_params["password"] ) - { map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.wrongpassword" ); map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. wrap::system_message( LOGINER + s_user ); return; - } - if ( p_user->get_has_sess() ) - { + } + if ( p_user->get_has_sess() ) + { map_params["tmpid"] = p_user->get_tmpid(); - } - else - { + } + else + { sess* p_sess = wrap::SMAN->create_session(); //p_sess->set_value( string("nick"), (void *) new string(s_user) ); - p_sess->set_name(s_user); - map_params["tmpid"] = p_sess->get_id(); + p_sess->set_user(p_user); + map_params["tmpid"] = p_sess->get_tmpid(); p_user->set_tmpid( map_params["tmpid"] ); p_user->set_has_sess( true ); - } } + } + else // if ( p_user == NULL ) // If not in garbage create a new user! + { + p_user = new user( s_user ); - else // if ( p_user == NULL ) // If not in garbage create a new user! - { - p_user = new user( s_user ); - - // prove if nick is registered, else create a guest chatter. + // prove if nick is registered, else create a guest chatter. #ifdef DATABASE - map_string map_results = wrap::DATA->select_user_data( tool::to_lower(s_user), "selectlogin"); - if ( map_results["nick"] == tool::to_lower(s_user) ) - { - p_user->set_is_reg( true ); + hashmap map_results = wrap::DATA->select_user_data( tool::to_lower(s_user), "selectlogin"); + + if ( map_results["nick"] == tool::to_lower(s_user) ) + { + p_user->set_is_reg( true ); // User exists in database, prove password: // 2. possibility to prove the password at login! (using new created user from database) if ( map_results["password"] != map_params["password"] ) { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.wrongpassword" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINER + s_user ); - return; + map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.wrongpassword" ); + map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. + wrap::system_message( LOGINER + s_user ); + return; } else { // If registered use saved options - map_params["registered"] = "yes"; - map_params["color1"] = map_results["color1"]; - map_params["color2"] = map_results["color2"]; - map_params["email"] = map_results["email"]; - map_params["status"] = map_results["status"]; + map_params["registered"] = "yes"; + map_params["color1"] = map_results["color1"]; + map_params["color2"] = map_results["color2"]; + map_params["email"] = map_results["email"]; + map_params["status"] = map_results["status"]; } - } - else + } + else #endif - { // If not registered prove if guest chatting is enabled. - if (wrap::CONF->get_elem("chat.enableguest") != "true") { + + { // If not registered prove if guest chatting is enabled. + if (wrap::CONF->get_elem("chat.enableguest") != "true") + { map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.noguest" ); map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. wrap::system_message( LOGINE4 + s_user ); @@ -206,147 +209,147 @@ chat::login( map_string &map_params ) map_params["color1"] = wrap::CONF->get_elem( "chat.html.user.color1" ); map_params["color2"] = wrap::CONF->get_elem( "chat.html.user.color2" ); map_params["status"] = wrap::CONF->get_elem( "chat.defaultrang" ); - } - - sess* p_sess = wrap::SMAN->create_session(); - p_sess->set_name(s_user); - map_params["tmpid"] = p_sess->get_id(); - p_user->set_tmpid( map_params["tmpid"] ); - p_user->set_col1( map_params["color1"] ); - p_user->set_col2( map_params["color2"] ); - p_user->set_status( tool::string2int(map_params["status"])); - // p_user->set_sess( p_sess ); } - // Prove if user is the default operator. - if ( tool::to_lower(wrap::CONF->get_elem("chat.defaultop")) == tool::to_lower(s_user) ) { - wrap::system_message(CHATDOP); - p_user->set_status(0); - } + sess* p_sess = wrap::SMAN->create_session(); + p_sess->set_user(p_user); + map_params["tmpid"] = p_sess->get_tmpid(); + p_user->set_tmpid( map_params["tmpid"] ); + p_user->set_col1( map_params["color1"] ); + p_user->set_col2( map_params["color2"] ); + p_user->set_status( tool::string2int(map_params["status"])); + // p_user->set_sess( p_sess ); + } - string s_room = map_params["room"]; - room* p_room = get_room( s_room , b_flag ); + // Prove if user is the default operator. + if ( tool::to_lower(wrap::CONF->get_elem("chat.defaultop")) == tool::to_lower(s_user) ) + { + wrap::system_message(CHATDOP); + p_user->set_status(0); + } - // if room does not exist add room to list! - if ( ! b_flag ) - { - p_room = wrap::GCOL->get_room_from_garbage(); + string s_room = map_params["room"]; + room* p_room = get_room( s_room , b_flag ); - if ( p_room ) - { + // if room does not exist add room to list! + if ( ! b_flag ) + { + p_room = wrap::GCOL->get_room_from_garbage(); + + if ( p_room ) + { p_room->set_name( s_room ); wrap::system_message( REUROOM + s_room ); - } - - else - { + } + else + { p_room = new room( s_room ); wrap::system_message( NEWROOM + s_room ); - } - - add_elem( p_room ); } - // add user to the room. - p_room->add_user( p_user ); + add_elem( p_room ); + } - wrap::system_message( NEWUSER + s_user ); + // add user to the room. + p_room->add_user( p_user ); - // post "username enters the chat" into the room. - string s_msg = wrap::TIMR->get_time() + " " + p_user->get_colored_bold_name() + wrap::CONF->get_elem( "chat.msgs.userenterschat" ) + "
\n"; + wrap::system_message( NEWUSER + s_user ); - // If created a new user from database while logging on (not a recycled user, they already have this set) - if ( map_params["registered"] == "yes" ) - { - p_user->set_email( map_params["email"] ); - p_user->set_pass( map_params["password"] ); - // Now we will store all wanted user data into MySQL after logging out! (recycled user already have this set) - p_user->set_changed_data_on(); - } - p_room->msg_post( &s_msg ); + // post "username enters the chat" into the room. + string s_msg = wrap::TIMR->get_time() + " " + p_user->get_colored_bold_name() + wrap::CONF->get_elem( "chat.msgs.userenterschat" ) + "
\n"; + + // If created a new user from database while logging on (not a recycled user, they already have this set) + if ( map_params["registered"] == "yes" ) + { + p_user->set_email( map_params["email"] ); + p_user->set_pass( map_params["password"] ); + // Now we will store all wanted user data into MySQL after logging out! (recycled user already have this set) + p_user->set_changed_data_on(); + } + p_room->msg_post( &s_msg ); } void -chat::post( user* p_user, map_string &map_params ) +chat::post( user* p_user, hashmap &map_params ) { - p_user->renew_timeout(); + p_user->renew_timeout(); - string s_msg( map_params["message"] ); + string s_msg( map_params["message"] ); - if ( s_msg.empty() ) - return; + if ( s_msg.empty() ) + return; - int i_max_message_length = tool::string2int(wrap::CONF->get_elem( "chat.maxlength.message" )); - if ( s_msg.length() > i_max_message_length ) - { - s_msg = s_msg.substr( 0, i_max_message_length ); - string s_private = "get_elem( "chat.html.errorcolor" ) + "\">" + int i_max_message_length = tool::string2int(wrap::CONF->get_elem( "chat.maxlength.message" )); + if ( s_msg.length() > i_max_message_length ) + { + s_msg = s_msg.substr( 0, i_max_message_length ); + string s_private = "get_elem( "chat.html.errorcolor" ) + "\">" + wrap::CONF->get_elem( "chat.msgs.err.messagelength" ) + "
\n"; - p_user->msg_post( &s_private ); - } - - int i_max_word_length = tool::string2int(wrap::CONF->get_elem( "chat.maxlength.word" )); + p_user->msg_post( &s_private ); + } + + int i_max_word_length = tool::string2int(wrap::CONF->get_elem( "chat.maxlength.word" )); - // Check max word length - list list_msg = tool::split_string( s_msg, " "); - list::iterator iter = list_msg.begin(); + // Check max word length + list list_msg = tool::split_string( s_msg, " "); + list::iterator iter = list_msg.begin(); - for ( s_msg = ""; iter != list_msg.end(); ++iter ) + for ( s_msg = ""; iter != list_msg.end(); ++iter ) + { + if ( iter->length() > i_max_word_length ) { - if ( iter->length() > i_max_word_length ) - { string s_tmp[] = { iter->substr(0, i_max_word_length ), iter->substr(i_max_word_length) }; - iter = list_msg.erase( iter ); + iter = list_msg.erase( iter ); iter = list_msg.insert( iter, s_tmp[1] ); iter = list_msg.insert( iter, s_tmp[0] ); --iter; - } - else - { - s_msg.append(*iter + " "); - } } - - if ( wrap::CONF->get_elem( "chat.html.tagsallow" ) != "true" ) - tool::strip_html( &s_msg ); - - auto unsigned i_pos = s_msg.find( "/" ); - if ( i_pos == 0 ) - return p_user->command( s_msg ); - - string_replacer(&s_msg); - string s_post; - - if ( wrap::CONF->get_elem( "chat.printalwaystime" ) == "true" ) - s_post.append( wrap::TIMR->get_time() + " " ); - - s_post.append( "get_col1() ) - .append( "\">" ) - .append( p_user->get_name() ) - .append( ": get_col2() ) - .append( "\">" ) - .append( s_msg ) - .append( "
\n" ); - - p_user->get_room()->msg_post( &s_post ); + else + { + s_msg.append(*iter + " "); + } + } + + if ( wrap::CONF->get_elem( "chat.html.tagsallow" ) != "true" ) + tool::strip_html( &s_msg ); + + unsigned i_pos = s_msg.find( "/" ); + if ( i_pos == 0 ) + return p_user->command( s_msg ); + + string_replacer(&s_msg); + string s_post; + + if ( wrap::CONF->get_elem( "chat.printalwaystime" ) == "true" ) + s_post.append( wrap::TIMR->get_time() + " " ); + + s_post.append( "get_col1() ) + .append( "\">" ) + .append( p_user->get_name() ) + .append( ": get_col2() ) + .append( "\">" ) + .append( s_msg ) + .append( "
\n" ); + + p_user->get_room()->msg_post( &s_post ); } void chat::reconf() -{ -} +{} void -chat::string_replacer(string *p_msg) { - if ( wrap::CONF->get_elem( "chat.html.replace.activate" ) == "true" ) - { - for (vector::iterator iter = vec_replace_keys.end()-1; - iter != vec_replace_keys.begin(); - iter-- ) +chat::string_replacer(string *p_msg) +{ + if ( wrap::CONF->get_elem( "chat.html.replace.activate" ) == "true" ) + { + for (vector::iterator iter = vec_replace_keys.end()-1; + iter != vec_replace_keys.begin(); + iter-- ) *p_msg = tool::replace( *p_msg, *iter, wrap::CONF->get_elem(map_replace_strings[*iter]) ); - } + } } #endif diff --git a/src/chat/chat.h b/src/chat/chat.h index 2661536..8508508 100755 --- a/src/chat/chat.h +++ b/src/chat/chat.h @@ -13,50 +13,50 @@ class chat; #include "user.h" #include "sess.h" #include "../tool/tool.h" +#include "../maps/hashmap.h" using namespace std; - #undef chat class chat : public base, public perm { private: - map_string map_replace_strings; - vector vec_replace_keys; + map map_replace_strings; + vector vec_replace_keys; public: - virtual room* get_room( string s_name ) - { - bool b_bool; - return get_room( s_name, b_bool ); - } - - virtual room* get_room( string &s_name, bool &b_found ) - { - return static_cast( get_elem( s_name, b_found ) ); - } - - // public methods: - explicit chat(); // a standard constructor. - ~chat(); // destructor. - - // get the object of a specific user. - user* get_user( string &s_nick ); - user* get_user( string &s_nick, bool &b_found ); - static void get_user_( room* room_obj, void *v_arg ); - - // will be called every time a user tries to login. - void login( map_string &map_params ); - - // will be called if a user posts a message. - void post ( user* u_user, map_string &map_params ); - - void del_elem( string s_name ) - { - smap::del_elem( s_name ); - } - - void reconf(); - void string_replacer(string *p_msg); + virtual room* get_room( string s_name ) + { + bool b_bool; + return get_room( s_name, b_bool ); + } + + virtual room* get_room( string &s_name, bool &b_found ) + { + return static_cast( get_elem( s_name, b_found ) ); + } + + // public methods: + explicit chat(); // a standard constructor. + ~chat(); // destructor. + + // get the object of a specific user. + user* get_user( string &s_nick ); + user* get_user( string &s_nick, bool &b_found ); + static void get_user_( room* room_obj, void *v_arg ); + + // will be called every time a user tries to login. + void login( hashmap &map_params ); + + // will be called if a user posts a message. + void post ( user* u_user, hashmap &map_params ); + + void del_elem( string s_name ) + { + base::del_elem( s_name ); + } + + void reconf(); + void string_replacer(string *p_msg); }; #endif diff --git a/src/chat/gcol.cpp b/src/chat/gcol.cpp index 2500b91..7df111d 100755 --- a/src/chat/gcol.cpp +++ b/src/chat/gcol.cpp @@ -7,130 +7,139 @@ using namespace std; gcol::gcol() { - pthread_mutex_init( &mut_vec_rooms , NULL); + pthread_mutex_init( &mut_vec_rooms , NULL); - p_map_users = new smap(HMAPOCC); - wrap::system_message( GARBAGE ); + p_map_users = new shashmap; + wrap::system_message( GARBAGE ); #ifdef NCURSES - print_garbage(); + + print_garbage(); #endif } gcol::~gcol() { - remove_garbage(); - pthread_mutex_destroy( &mut_vec_rooms ); - delete p_map_users; + remove_garbage(); + pthread_mutex_destroy( &mut_vec_rooms ); + delete p_map_users; } void gcol::add_room_to_garbage( room* p_room ) -{ - pthread_mutex_lock ( &mut_vec_rooms ); - vec_rooms.push_back( p_room ); - pthread_mutex_unlock( &mut_vec_rooms ); - wrap::system_message( GARROOM + p_room->get_name() ); +{ + pthread_mutex_lock ( &mut_vec_rooms ); + vec_rooms.push_back( p_room ); + pthread_mutex_unlock( &mut_vec_rooms ); + wrap::system_message( GARROOM + p_room->get_name() ); #ifdef NCURSES - print_garbage(); + + print_garbage(); #endif } void gcol::add_user_to_garbage( user* p_user ) -{ - p_user->s_mess_delete(); - p_map_users->add_elem( p_user, tool::to_lower(p_user->get_name()) ); - wrap::system_message( GARUSER + p_user->get_name() ); +{ + p_user->s_mess_delete(); + p_map_users->add_elem( p_user, tool::to_lower(p_user->get_name()) ); + wrap::system_message( GARUSER + p_user->get_name() ); #ifdef NCURSES - print_garbage(); + + print_garbage(); #endif } bool gcol::remove_garbage() { - bool b_empty; + bool b_empty; - pthread_mutex_lock ( &mut_vec_rooms ); - b_empty = ( vec_rooms.empty() && p_map_users->get_size() == 0); - pthread_mutex_unlock( &mut_vec_rooms ); + pthread_mutex_lock ( &mut_vec_rooms ); + b_empty = ( vec_rooms.empty() && p_map_users->size() == 0); + pthread_mutex_unlock( &mut_vec_rooms ); - if ( b_empty ) - return false; + if ( b_empty ) + return false; - wrap::system_message( GARBACT ); + wrap::system_message( GARBACT ); - pthread_mutex_lock ( &mut_vec_rooms ); - for ( vector::iterator iter = vec_rooms.begin(); - iter != vec_rooms.end(); iter++ ) - { - wrap::system_message( REMROOM + (*iter)->get_name() ); - delete *iter; - } - vec_rooms.clear(); - pthread_mutex_unlock( &mut_vec_rooms ); + pthread_mutex_lock ( &mut_vec_rooms ); + for ( vector::iterator iter = vec_rooms.begin(); + iter != vec_rooms.end(); iter++ ) + { + wrap::system_message( REMROOM + (*iter)->get_name() ); + delete *iter; + } + vec_rooms.clear(); + pthread_mutex_unlock( &mut_vec_rooms ); - p_map_users->run_func( delete_users_ ); - p_map_users->make_empty(); + p_map_users->run_func( delete_users_ ); + p_map_users->clear(); #ifdef NCURSES - print_garbage(); + + print_garbage(); #endif - return true; + + return true; } room* gcol::get_room_from_garbage() {