summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2013-04-06 13:14:43 +0200
committerPaul Buetow <paul@buetow.org>2013-04-06 13:14:43 +0200
commit796609174e5ecb35fab992969e7690186840048a (patch)
tree1e4370d47f2a5c050b768c228e73e028a6611cb8
parent312fe18cb5f97143f3600b207e979bc559256b6f (diff)
tagging ychat-0.7.3ychat-0.7.3
-rw-r--r--CHANGES41
-rwxr-xr-xCOPYING1
-rwxr-xr-xMakefile111
-rw-r--r--NEWS8
-rwxr-xr-xREADME283
-rw-r--r--TODO60
-rwxr-xr-xconfigure27
-rw-r--r--etc/ychat.conf28
-rwxr-xr-xhtml/help.html2
-rwxr-xr-xhtml/index.html37
-rwxr-xr-xhtml/input.html10
-rwxr-xr-xhtml/online.html3
-rwxr-xr-xhtml/stream.html25
-rwxr-xr-xhtml/style.css49
-rw-r--r--scripts/README2
-rwxr-xr-xscripts/astyle.sh2
-rwxr-xr-xscripts/buildnr.pl4
-rwxr-xr-xscripts/config.sh6
-rw-r--r--scripts/makeyhttpd.pl10
-rwxr-xr-xscripts/screen.sh2
-rwxr-xr-xscripts/setglobvals.pl2
-rwxr-xr-xscripts/stats.pl2
-rwxr-xr-xsrc/Makefile.in8
-rwxr-xr-xsrc/chat/base.h154
-rwxr-xr-xsrc/chat/base.tmpl18
-rwxr-xr-xsrc/chat/chat.cpp467
-rwxr-xr-xsrc/chat/chat.h72
-rwxr-xr-xsrc/chat/gcol.cpp159
-rwxr-xr-xsrc/chat/gcol.h31
-rwxr-xr-xsrc/chat/perm.cpp69
-rwxr-xr-xsrc/chat/perm.h45
-rwxr-xr-xsrc/chat/room.cpp96
-rwxr-xr-xsrc/chat/room.h108
-rwxr-xr-xsrc/chat/sess.cpp39
-rwxr-xr-xsrc/chat/sess.h21
-rwxr-xr-xsrc/chat/sman.cpp117
-rwxr-xr-xsrc/chat/sman.h29
-rwxr-xr-xsrc/chat/user.cpp673
-rwxr-xr-xsrc/chat/user.h235
-rwxr-xr-xsrc/cli/cli.cpp16
-rwxr-xr-xsrc/conf/conf.cpp14
-rwxr-xr-xsrc/conf/conf.h3
-rwxr-xr-xsrc/configure25
-rw-r--r--src/contrib/README4
-rw-r--r--src/contrib/crypt/md5.cpp333
-rw-r--r--src/contrib/crypt/md5.h15
-rw-r--r--src/contrib/crypt/md5crypt.cpp233
-rw-r--r--src/contrib/xml/README2
-rwxr-xr-xsrc/data/con.cpp48
-rwxr-xr-xsrc/data/con.h8
-rwxr-xr-xsrc/data/con_base.cpp5
-rwxr-xr-xsrc/data/con_base.h4
-rw-r--r--src/data/data.cpp262
-rw-r--r--src/data/data.h18
-rw-r--r--src/data/data_base.cpp232
-rw-r--r--src/data/data_base.h23
-rwxr-xr-xsrc/glob.h44
-rwxr-xr-xsrc/html.cpp16
-rwxr-xr-xsrc/html.h2
-rwxr-xr-xsrc/logd.cpp4
-rwxr-xr-xsrc/main.cpp33
-rw-r--r--src/maps/hmap.h6
-rw-r--r--src/maps/hmap.tmpl11
-rw-r--r--src/maps/smap.h1
-rw-r--r--src/maps/smap.tmpl8
-rwxr-xr-xsrc/modl.cpp11
-rwxr-xr-xsrc/modl.h2
-rwxr-xr-xsrc/mods/Makefile9
-rw-r--r--src/mods/commands/yc_about.cpp74
-rwxr-xr-xsrc/mods/commands/yc_all.cpp77
-rwxr-xr-xsrc/mods/commands/yc_away.cpp126
-rwxr-xr-xsrc/mods/commands/yc_col.cpp127
-rwxr-xr-xsrc/mods/commands/yc_compopt.cpp21
-rwxr-xr-xsrc/mods/commands/yc_exec.cpp84
-rwxr-xr-xsrc/mods/commands/yc_fake.cpp43
-rwxr-xr-xsrc/mods/commands/yc_getroom.cpp70
-rwxr-xr-xsrc/mods/commands/yc_getrusage.cpp69
-rwxr-xr-xsrc/mods/commands/yc_help.cpp81
-rwxr-xr-xsrc/mods/commands/yc_invisible.cpp45
-rwxr-xr-xsrc/mods/commands/yc_j.cpp183
-rwxr-xr-xsrc/mods/commands/yc_ko.cpp88
-rwxr-xr-xsrc/mods/commands/yc_m.cpp65
-rwxr-xr-xsrc/mods/commands/yc_md5.cpp84
-rwxr-xr-xsrc/mods/commands/yc_me.cpp67
-rwxr-xr-xsrc/mods/commands/yc_morph.cpp77
-rwxr-xr-xsrc/mods/commands/yc_msg.cpp94
-rwxr-xr-xsrc/mods/commands/yc_q.cpp27
-rwxr-xr-xsrc/mods/commands/yc_reload.cpp29
-rwxr-xr-xsrc/mods/commands/yc_ren.cpp108
-rwxr-xr-xsrc/mods/commands/yc_s.cpp81
-rwxr-xr-xsrc/mods/commands/yc_set.cpp175
-rwxr-xr-xsrc/mods/commands/yc_template.cpp25
-rwxr-xr-xsrc/mods/commands/yc_time.cpp27
-rwxr-xr-xsrc/mods/commands/yc_topic.cpp138
-rwxr-xr-xsrc/mods/commands/yc_uptime.cpp27
-rwxr-xr-xsrc/mods/commands/yc_version.cpp21
-rw-r--r--src/mods/html/yc_admin.cpp119
-rwxr-xr-xsrc/mods/html/yc_colors.cpp52
-rwxr-xr-xsrc/mods/html/yc_help.cpp74
-rwxr-xr-xsrc/mods/html/yc_options.cpp81
-rwxr-xr-xsrc/mods/html/yc_register.cpp165
-rw-r--r--src/msgs.h14
-rwxr-xr-xsrc/ncur/ncur.cpp21
-rwxr-xr-xsrc/reqp.cpp107
-rwxr-xr-xsrc/reqp.h1
-rwxr-xr-xsrc/sock/sock.cpp52
-rwxr-xr-xsrc/sock/sock.h2
-rw-r--r--src/stats.cpp46
-rw-r--r--src/stats.h12
-rwxr-xr-xsrc/time/timr.cpp19
-rw-r--r--src/tool/tool.cpp16
-rw-r--r--src/tool/tool.h12
-rwxr-xr-xsrc/wrap.cpp8
-rwxr-xr-xsrc/wrap.h23
114 files changed, 3977 insertions, 3428 deletions
diff --git a/CHANGES b/CHANGES
index 21919f7..c4e2d04 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,39 @@
-Changes from 0.6 to 0.7 RELEASE
+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)
+- Renamed the /getstatus command into /about.
+- Fixed the &-bug (& should be allowed in messages). \AND is now a
+ synonym for & too.
+- 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
+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.
+
+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.
+- Removed some typos from the ychat.conf.
+- Fixed the auto away message. This one will be posted in the room
+ as public rather than only private to the auto-away-user.
+- Fixed some documentation stuff for yhttpd because yhttpd does not
+ need MySQL at all.
+- Added the chat.maxlength.word option.
+
+Changes from 0.6 to 0.7.0 RELEASE
- Better stability
- Better performance (using more hmaps)
- HTML color switcher menu
@@ -18,9 +53,9 @@ Changes from 0.6 to 0.7 RELEASE
- Added admin CLI (Command Line Interface) mode
- Added memory rusage history which tracks memory usage for the last 10 days
- Added HTTP POST request parsing
-- Made yhttpd more modular so yhttpd can be extracted from it (scripts/makeyhttpd.pl)
+- Made yChat more modular so yhttpd can be extracted from it (scripts/makeyhttpd.pl)
- Added CGI support
- Rewrote big parts of the Makefiles and the configure scripts
- Made it compatible to GNU G++ 3.4, 3.3, 3.2 and 3.1 (3.0 and earlier does not work)
-- XML based configuration file (yhttpd.conf)
+- XML based configuration file (ychat.conf)
- Added default operator option: chat.defaultop
diff --git a/COPYING b/COPYING
index 27058a5..a43ea21 100755
--- a/COPYING
+++ b/COPYING
@@ -106,6 +106,7 @@ above, provided that you also meet all of these conditions:
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
diff --git a/Makefile b/Makefile
index ff97421..96266ea 100755
--- a/Makefile
+++ b/Makefile
@@ -1,76 +1,99 @@
+MAKE=`tail -1 make.version`
PREFIX=`grep "define PREFIX" src/glob.h | cut -d'"' -f2`
-all: base modules version
- @echo "Now edit the yhttpd.conf and run yhttpd!"
+all: base modules version mail
+ @echo "Now edit the ychat.conf and run ychat!"
@echo "The config file is searched in the following order:"
- @echo " ./yhttpd.conf "
- @echo " ~/.yhttpd/yhttpd.conf "
- @echo " ./etc/yhttpd.conf "
- @echo " /etc/yhttpd.conf "
- @echo " $(PREFIX)/etc/yhttpd.conf "
+ @echo " ./ychat.conf "
+ @echo " ~/.ychat/ychat.conf "
+ @echo " ./etc/ychat.conf "
+ @echo " /etc/ychat.conf "
+ @echo " $(PREFIX)/etc/ychat.conf "
+mail:
+ @echo "VERSION:" > mail.tmp
+ @gmake version >> mail.tmp
+ @echo >> mail.tmp
+ @echo "UNAME:" >> mail.tmp
+ @uname -a >> mail.tmp
+ @echo >> mail.tmp
+ @echo "DATE:" >> mail.tmp
+ @date >> mail.tmp
+ @echo >> mail.tmp
+ @echo "COMPILER AND MAKE:" >> mail.tmp
+ @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 yhttpd to $(PREFIX)"
- @cp bin/yhttpd $(PREFIX)/bin
- @if ! test -d $(PREFIX)/lib/yhttpd; then mkdir -p $(PREFIX)/lib/yhttpd; fi
- @if ! test -d $(PREFIX)/share/yhttpd/log/rooms; then mkdir -p $(PREFIX)/share/yhttpd/log/rooms; fi
+ @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/yhttpd/mods; fi
- @cp -Rp lang $(PREFIX)/share/yhttpd/lang
- @if test -f $(PREFIX)/etc/yhttpd.conf; then mv $(PREFIX)/etc/yhttpd.conf $(PREFIX)/etc/yhttpd.conf.bak; fi
- @cp etc/yhttpd.conf etc/yhttpd.conf.tmp
- @sed "s#mods/#$(PREFIX)/lib/yhttpd/mods/#" etc/yhttpd.conf.tmp > etc/yhttpd.conf.tmp.2 && mv etc/yhttpd.conf.tmp.2 etc/yhttpd.conf.tmp
- @sed "s#\"log/#\"$(PREFIX)/share/yhttpd/log/#" etc/yhttpd.conf.tmp > etc/yhttpd.conf.tmp.2 && mv etc/yhttpd.conf.tmp.2 etc/yhttpd.conf.tmp
- @sed "s#LANGUAGE_DIR=\"lang/#LANGUAGE_DIR=\"$(PREFIX)/share/yhttpd/lang/#" etc/yhttpd.conf.tmp > etc/yhttpd.conf.tmp.2 && mv etc/yhttpd.conf.tmp.2 etc/yhttpd.conf.tmp
- @mv etc/yhttpd.conf.tmp $(PREFIX)/etc/yhttpd.conf
- @echo "yhttpd configuration file can be found under"
- @echo " $(PREFIX)/etc/yhttpd.conf"
- @echo "Copy it to ~/.yhttpd/yhttpd.conf to use local settings :-)"
- @echo "Be sure that $(PREFIX)/share/yhttpd/logs is writable by your user or modify "
- @echo "logging dirs in the yhttpd.conf to a local directory."
- @echo "The most secure would be an additional user 'yhttpd'!"
+ @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'!"
uninstall: deinstall
deinstall:
- @echo "Deinstalling yhttpd from $(PREFIX)"
- @if test -f $(PREFIX)/bin/yhttpd; then rm -f $(PREFIX)/bin/yhttpd; fi
- @if test -d $(PREFIX)/lib/yhttpd; then rm -Rf $(PREFIX)/lib/yhttpd; fi
- @if test -d $(PREFIX)/share/yhttpd; then rm -Rf $(PREFIX)/share/yhttpd; fi
- @echo "Done. Please remove manually $(PREFIX)/etc/yhttpd.conf to complete"
+ @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"
modules:
- @if test -d ./src/mods; then gmake -C ./src/mods; fi
+ @if test -d ./src/mods; then ${MAKE} -C ./src/mods; fi
clean_modules:
- @if test -d ./src/mods; then gmake -C ./src/mods clean; fi
+ @if test -d ./src/mods; then ${MAKE} -C ./src/mods clean; fi
base:
- @if test -f bin/yhttpd; then echo "Backing up old binary";if test -f bin/yhttpd.old; then rm -f bin/yhttpd.old; fi; mv bin/yhttpd bin/yhttpd.old; fi
+ @if test -f bin/ychat; then echo "Backing up old binary";if test -f bin/ychat.old; then rm -f bin/ychat.old; fi; mv bin/ychat bin/ychat.old; fi
@perl ./scripts/buildnr.pl
@perl ./scripts/setglobvals.pl
- @gmake -C ./src
+ @${MAKE} -C ./src
clean_base:
- @gmake -C ./src clean
+ @${MAKE} -C ./src clean
stats:
@perl scripts/stats.pl
run:
- ./bin/yhttpd
+ ./bin/ychat
base_start: base
- ./bin/yhttpd
+ ./bin/ychat
start: base modules
- ./bin/yhttpd
+ ./bin/ychat
gpl:
@more COPYING
+#//<<*
+yhttpdbase:
+ @perl scripts/makeyhttpd.pl || echo "You need to have perl to do this!"
+ @echo yhttpd code base has been generated in ../yhttpd
+#//*>>
clean: clean_base clean_modules
help:
- @echo "You may run gmake with the following parameters:"
- @grep "^ gmake " README
- @echo "For more questions read the README file or contact mail@yhttpd.org!"
+ @echo "You may run ${MAKE} with the following parameters:"
+ @grep "^ ${MAKE} " README
+ @echo "For more questions read the README file or contact mail@ychat.org!"
setup:
@./configure
- @gmake
+ @${MAKE}
config:
@sh -c "scripts/config.sh"
- @echo If you run gmake config from the command line then you may need
+ @echo If you run ${MAKE} config from the command line then you may need
@echo to rerun ./configure and recompile all now!
mrproper: clean
@if test -f src/glob.h.org; then mv -f src/glob.h.org src/glob.h;fi
@if test -f g++.version; then rm -f g++.version; fi
+ @if test -f make.version; then rm -f make.version; fi
@if test -f src/Makefile; then rm -f src/Makefile; fi
@if test -d src/mods; then find src/mods/*/ -name Makefile | xargs rm -f; fi
@find . -name "*.add" | xargs rm -f
@@ -78,4 +101,4 @@ mrproper: clean
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`"
debug:
- @gdb bin/yhttpd yhttpd.core
+ @gdb bin/ychat ychat.core
diff --git a/NEWS b/NEWS
index f255184..034d63d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,3 @@
-::(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 72410d3..bed3c9d 100755
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-yhttpd; Homepage: www.yhttpd.org; Version 0.7-RELEASE
+yChat; Homepage: www.yChat.org; Version 0.7.3-RELEASE
Copyright (C) 2003 Paul C. Buetow, Volker Richter
Copyright (C) 2004 Paul C. Buetow
@@ -19,20 +19,132 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-----------------------------------------------------------------
-YHTTPD TABLE OF CONTENTS:
+YCHAT TABLE OF CONTENTS:
+0.0.0 YCHAT FEATURES //<<
1.0.0 REQUIREMENTS
1.1.0 TESTED PLATFORMS
1.2.0 IMPORTANT NOTICES
-1.3.0 HOW TO OBTAIN YHTTPD
+1.3.0 HOW TO OBTAIN YCHAT
1.3.1 INSTALLATION
1.3.2 INSTALLATION QUICK-START
-1.4.0 HOW TO USE SCREEN WITH YHTTPD
+1.3.3 MYSQL SETUP //<<
+1.4.0 HOW TO USE SCREEN WITH YCHAT
1.5.0 CUSTOMIZATION
1.6.0 FILES
1.7.0 WRITING BUG REPORTS
1.8.0 CONTACT
-
+1.9.0 YHTTPD CODE BASE GENERATION //<<
+
+//<<*
+0.0.0 YCHAT FEATURES
+
+- Its free & portable -
+yChat is developed under the GNU general public license and is based on GNU
+tools (gcc, gmake), other open source library stuff (such as libncurses etc.)
+and should run on any POSIX capable operating system (such as all Linux based
+systems, FreeBSD, NetBSD, OpenBSD and other BSD-Systems and on UNICES like
+IRIX, HP-UX, Solaris etc.).
+
+- There is no need for special chat clients -
+yChat is web based, that means clients may only connect to the chat server
+with an normal web browser such as Microsoft Internet Explorer or any Gecko-
+Engine powerd browsers like Mozilla, Firefox, Camino etc.
+
+- It has features of a real HTTP webserver -
+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).
+
+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
+normal websites to the net. It also supports Common Gateway Interface (CGI)
+scripting.
+
+- Its fast and secure -
+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
+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
+can be redefined as well. Also, the session id will get md5-hashed optionally
+so thats even harder to reverse engineering the session ids of other users.
+
+- Its HTML template based and easy to customize via XML based configuration -
+All HTML sites are predefined as HTML-Template files and can be easily modified
+to use with an customized web design. Also, a lot of yChat preferences can be
+set in the main configuration file (ychat.conf). ychat.conf is completely written
+in XML 1.0 which makes it easier to use the configuration options in programs of
+3rd persons which may want to write some usefull tools for yChat.
+yChat caches all HTML and web images to improve overall performance. If needed, the
+cache can be cleared to recache new versions of the template files.
+
+- Its language template based -
+The administrator can easily create a new language in which all system messages
+appear to the Chat-User. The predefined languages is english but others can be
+added easily. The language can be edited in the XML based configuration file.
+
+- MySQL based database -
+Registered users are stored in a MySQL database. C++ Programmers may feel free
+to replace the database wrapper class (data.h) with another database routines
+to use other databases such as PostgreSQL, SQLite or a text based database etc.
+If wished, you can disable database support in the pre-compile options.
+
+- It has an administration interface -
+yChat includes an ncurses based administration interface which tracks some
+interesting statistics and system messages and enables you to do certain
+administrative tasks. In addition, you can switch to the CLI (command line
+interface) mode of the administration interface in order to be provided with
+more available functions (like keeping track of the current system usage etc.).
+If you dont like ncurses and/or the CLI you can disable both options in the pre-
+compile options.
+
+- It has logging capabilities -
+The logging manager keeps track to all yChat system messages (such as users
+wich log in and out, modules which are loaded, MySQL queries etc.). Also, an
+Apache-Style combined log file format is created by yChat (you can parse this
+logfile with any Apache logfile parser like awstats etc.). And last but not
+least, all public messages of all available rooms will be logged to disk as
+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 -
+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
+mods/html/yc_register.so, mods/html/yc_options.so and mods/html/yc_colors.so
+etc. so you can also program your dynamic yChat websites in C++.
+
+- Its multi threaded (POSIX threads) -
+There is only one main process which spawns several threads, each for its own
+unique task. For example one thread is used to handle the socket manager which
+waits for incoming TCP/IP requests, another thread schedules the system timer
+which proves if clients are still active or frees not needed memory in certain
+time intervals (see also "Garbage collector"). Also, each Chat-User gets it own
+thread. There is no need of memory wastage by creating for each task a new
+process. All User-Threads are managed by a thread pool to avoid CPU wastage
+creating every time a new thread by reusing thread objects which have done its
+jobs already and have been readded into the queue of the thread pool. The
+standard sizes of the queue and the total pool size can be set in ychat.conf.
+
+- Its using a smart garbage collection engine -
+All users and rooms which dont have to be kept in the main memory (because the
+user has logged out or the room has been destroyed because it was empty) will
+not be deleted immediately but be placed for about 10 minutes in the yChat
+garbage collector. Each time a new room is created the systems checks the
+garbage to reuse an inactive room object. If a certain user wants to log in, the
+system checks if he is already present in the garbage collector. If yes, he will
+be reactivated without wasting expensive database queries to fetch the user's
+options. This improves overall performance on heavily loaded yChat servers if a
+lot of user and room objects are created and destroyed frequently.
+//*>>
1.0.0 REQUIREMENTS:
@@ -42,18 +154,20 @@ YHTTPD TABLE OF CONTENTS:
- GNU make 3.80 (gmake) or higher
If you dont have a gmake executable but make is gnu make then you need
to add a symlink or alias from gmake to make.
- yhttpd Makefiles only have been tested with GNU make and may not work with
+ yChat Makefiles only have been tested with GNU make and may not work with
other make versions.
+//<<*
- mysql-client 4.x (3.x may do too but is not supported)
Includes libmysqlclient and the mysql.h header files.
+//*>>
- ncurses 5.x
Includes libncurses and the ncurses.h header files.
- Screen
- Only needed if yhttpd should run in background with
- ncurses enabled.
+ Only needed if yChat should run in background with
+ ncurses or CLI enabled.
- Perl 5.x
Is needed for some scripts. Is not needed if you use precompiled binaries.
@@ -64,13 +178,14 @@ The following platforms have been tested with success. If you find out that
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.9-RELEASE (i386) 3.3.4 3.80
-- FreeBSD 4.10-RELEASE (i386) 3.4.1 3.80
- Gentoo Linux 2004.2 (i386) 3.3.2 3.80
- OpenBSD 3.6 MP (i386) 3.3.2 3.80
- Slackware Linux 10.0 (i386) 3.4.0 3.80
-- SUSE Linux 8.0, G (i386) 3.3.1 3.80
+- SUSE Linux 8.0 (i386) 3.3.1 3.80
Other platforms like Linux based systems, other BSD-Systems or UNICES
are very likely to work too.
@@ -80,23 +195,23 @@ are very likely to work too.
Before you compile the source you have to be sure to use at least GCC
version 3.1 with pthreads enabled. ( Type gcc -v to check it ).
GCC 2.95 and 3.0 did not work while testing and WON'T BE SUPPORTED!
-If you like to support yhttpd++, please write us an email and tell what
-you can/like/would help ;-]. Please also take a look at the yhttpd++
-homepage which is located at http://www.yhttpd.org.
+If you like to support yChat, please write us an email and tell what
+you can/like/would help ;-]. Please also take a look at the yChat
+homepage which is located at http://www.yChat.org.
-1.3.0 HOW TO OBTAIN YHTTPD++:
+1.3.0 HOW TO OBTAIN YCHAT:
-yhttpd can be downloaded as a source package or through CVS.
+yChat can be downloaded as a source package or through CVS.
-The packages are located at http://www.yhttpd.org -> Sourcecode ->
-Packages or go to http://pub.buetow.org/yhttpd/CPP-yhttpd .
+The packages are located at http://www.yChat.org -> Sourcecode ->
+Packages or go to http://pub.buetow.org/yChat/CPP-yChat .
For CVS download type:
cvs -d:pserver:anonymous@buetow.org:/usr/home/cvs/cvsroot login
( You will be asked for a password. Use "just enter" ).
-vs -z3 -d:pserver:anonymous@buetow.org:/usr/home/cvs/cvsroot co yhttpd
+vs -z3 -d:pserver:anonymous@buetow.org:/usr/home/cvs/cvsroot co ychat
( The sources will be copied into your local folder )
cvs -d:pserver:anonymous@buetow.org:/usr/home/cvs/cvsroot logout
@@ -107,37 +222,47 @@ Now you may continue with the installation.
1.3.1 INSTALLATION:
Invoke "./configure". Afterwards you will get prompted with the before-compile
-options of yhttpd. After choosing those options you are ready to type "gmake"
-afterwards.
+options of yChat. After choosing those options you are ready to type "gmake"
+afterwards. See below what gmake is doing.
+//<<*
+If you have choosen MySQL database support, then take a look at section 1.3.2
+how to setup a valid database table. Be also sure to enter the valid MySQL
+accessing data in the yChat configuration file which is normally located in
+the etc/ychat.conf file if not changed by you with the yChat configurator.
+//*>>
You may also invoke gmake with the following options (the PREFIX can be set
-in the yhttpd configurator which will be launched by the top configure script
+in the yChat configurator which will be launched by the top configure script
or gmake config):
- gmake or gmake all (compiles everything, also modules)
+ gmake or gmake all (compiles everything, also modules and runs "gmake mail")
gmake base (only compiles the base)
gmake base_start (only compiles the base and starts the server)
gmake clean (cleans everything)
gmake clean_base (only cleans the base obj and rpo files)
gmake clean_modules (only cleans the modules .so files)
- gmake config (runs yhttpd configurator)
- gmake deinstall (deinstalls yhttpd from PREFIX)
+ gmake config (runs yChat configurator)
+ gmake deinstall (deinstalls ychat from PREFIX)
gmake gpl (shows the GNU General Public License)
- gmake help (shows all available yhttpd gmake targets)
- gmake install (installs yhttpd to PREFIX)
+ 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 yhttpd statistics)
+ gmake stats (generates ychat statistics)
gmake uninstall (same as deinstall)
- gmake version (shows the current version of yhttpd)
+ gmake version (shows the current version of yChat)
+//<<*
+ gmake yhttpdbase (generates an yhttpd code base)
+//*>> (See section 1.9 to read about this marks)
Example: "gmake all install clean" compiles everything, installs it to PREFIX
and cleans the source directories.
-Now its time to run the server with ./bin/yhttpd.
+Now its time to run the server with ./bin/ychat.
Aferwards point your webbrowser to http://yourip:port !
@@ -145,25 +270,54 @@ Aferwards point your webbrowser to http://yourip:port !
1.3.2 INSTALLATION QUICK START:
-If you in hury, then you may just type gmake setup. In the yhttpd configurator
-you may just choose all the default values. If done, yhttpd will get compiled
-and is ready to run with ./bin/yhttpd!
+If you in hury, then you may just type gmake setup. In the yChat configurator
+you may just choose all the default values. If done, yChat will get compiled
+and is ready to run with ./bin/ychat!
+
+
+//<<*
+1.3.3 MYSQL SETUP
+If you chose to use MySQL database support you have to create a valid database
+to use with yChat.
-1.4.0 HOW TO USE SCREEN WITH YHTTPD:
+Create a new MySQL database called 'ychat' and type the following command into
+a MySQL command line client of your choice:
-If you are running yhttpd in ncurses mode you might want to install
+USE ychat
+CREATE TABLE `user` (
+ `uid` int(10) NOT NULL auto_increment,
+ `nick` varchar(30) NOT NULL default '',
+ `password` varchar(30) NOT NULL default '',
+ `color1` varchar(30),
+ `color2` varchar(30),
+ `email` varchar(50) default '-',
+ `registerdate` varchar(30) default '-',
+ `logincounter` varchar(10) default '0',
+ `status` char(1) default '3',
+ PRIMARY KEY (`uid`),
+ KEY `uid` (`uid`)
+) TYPE=MyISAM;
+GRANT ALL PRIVILEGES ON ychat.* to ychat@localhost IDENTIFIED BY "yctest";
+
+This database uses the default MySQL access informations which are stored in the
+ychat.conf file.
+//*>>
+
+1.4.0 HOW TO USE SCREEN WITH YCHAT:
+
+If you are running yChat in ncurses mode you might want to install
the tool which is called "screen". This will enable you putting the
ncurses interface into the background, closing the terminal session
and reusing the interface later through another terminal.
Just do:
- screen -S yhttpd ./bin/yhttpd ( creates a new session and starts yhttpd in it )
- ctrl+d+a ( will detach the yhttpd session )
+ screen -S ychat ./bin/ychat ( creates a new session and starts yChat in it )
+ ctrl+d+a ( will detach the yChat session )
( closing the terminal )
( opening a new terminal )
- screen -r yhttpd ( will return you to the yhttpd process )
+ screen -r ychat ( will return you to the yChat process )
Screen will terminate automaticaly if all processes in its sessions are
terminated.
@@ -172,25 +326,25 @@ For a closer look read the screen manual page ( man screen ).
1.5.0 CUSTOMIZATION:
-If you like to customize the design/layout/language of yhttpd, you will have
+If you like to customize the design/layout/language of yChat, you will have
to edit src/msgs.h and src/glob.h before you compile the sources. Afterwards
you can change the html-template files which are placed in the html/
subdirectory and the language-templates which are placed in the XML config
-file (etc/yhttpd.conf).
+file (etc/ychat.conf).
Notice, that you dont have to edit the src/glob.h file by hand any more, its
already done by the top ./configure script for you.
-You can edit the etc/yhttpd.conf to fit your needs. If you dont want to change
-the config file, then you also can use yhttpd start parameters.
+You can edit the etc/ychat.conf to fit your needs. If you dont want to change
+the config file, then you also can use ychat start parameters.
-Exmpl: ./bin/yhttpd -o chat.database.password secretpassword
+Exmpl: ./bin/ychat -o chat.database.password secretpassword
You can also use multiple words for a specific option.
-Exmpl: ./bin/yhttpd -o yhttpd.version "word1 word2 word3"
+Exmpl: ./bin/ychat -o ychat.version "word1 word2 word3"
-will overwrite the default database password value of the yhttpd.conf. You can
+will overwrite the default database password value of the ychat.conf. You can
do this with every configuration element by adding several -o option value
arguments to the start command.
@@ -205,16 +359,16 @@ user never wont read them, only the administrator will get to see them ).
1.6.0 FILES:
-etc/yhttpd.conf - The yhttpd configuration file
+etc/ychat.conf - The yChat configuration file
html/* - The html template files
-src/* - The yhttpd base sources
+src/* - The yChat base sources
src/mods/* - The dynamic loadable modules sources
scripts/* - Some nice scripts needed for building & co.
-The following is created by building yhttpd:
-obj/* - The object files of the compiled yhttpd base
+The following is created by building yChat:
+obj/* - The object files of the compiled yChat base
mods/* - The compiled dynamic loadable modules
-bin/yhttpd - The yhttpd binary (linked by the object files)
+bin/ychat - The yChat binary (linked by the object files)
Customizable source files (if changed you need to run gmake clean all)
src/glob.h - Contains some global building options
@@ -225,29 +379,29 @@ src/msgs.h - Defines some server side messages
How to submit a good bug report?
-Send them to Bug@yhttpd.org.
+Send them to Bug@yChat.org.
First you should give the following information:
-- yhttpd version, if CVS (or devel. tarball) then which day?
+- yChat version, if CVS (or devel. tarball) then which day?
- operating system / distribution and it's version
- when did it crash? did you do something? can you reproduce the crash?
-Getting backtrace of the crash also helps a lot, especially if yhttpd crashes
+Getting backtrace of the crash also helps a lot, especially if yChat crashes
randomly. If after crash you see text:
"segmentation fault (core dumped)"
-It writes a file named "core" or "yhttpd.core" depending on your OS to directory
-where you started yhttpd. If it doesn't print the "(core dumped)" or you can't
+It writes a file named "core" or "ychat.core" depending on your OS to directory
+where you started yChat. If it doesn't print the "(core dumped)" or you can't
find the core file, you'll have to raise the limit for max. core file size
-before running yhttpd. To do this, say:
+before running yChat. To do this, say:
ulimit -c unlimited
So, if you have the core file and GNU debugger (gdb), you can get the
backtrace with:
- gdb ./bin/yhttpd yhttpd.core
+ gdb ./bin/ychat ychat.core
bt
Paste all the lines starting from line having #0 at the beginning.
@@ -267,10 +421,10 @@ Here's an example session:
#5 0x281d44ae in _thread_start () from /usr/lib/libc_r.so.5
(gdb)
-If you dont get such a gdb output, you need to recompile the yhttpd using
+If you dont get such a gdb output, you need to recompile the yChat using
debuggig symbols. You can do it this way:
-cd yhttpd
+cd ychat
gmake mrproper
./configure -g3 -ggdb
gmake start
@@ -280,12 +434,12 @@ gmake start
You may contact us through the following addresses:
- Homepage
- The yhttpd homepage is located at http://www.yhttpd.org
+ The yChat homepage is located at http://www.yChat.org
- E-Mail
- Paul C. Buetow: Snooper at yhttpd point org ( core developer )
- Volker Richter: Rover at yhttpd dot org ( core developer )
- Mail at yhttpd dot org ( reaches everybody of yhttpd )
+ Paul C. Buetow: Snooper at yChat point org ( core developer )
+ Volker Richter: Rover at yChat dot org ( core developer )
+ Mail at yChat dot org ( reaches everybody of yChat )
- ICQ
Paul C. Buetow: 11655527
@@ -293,3 +447,8 @@ You may contact us through the following addresses:
- IRC
#Ychat and #Coding at irc.german-elite.net
+//<<*
+1.9 YHTTPD CODE BASE GENERATION
+
+See docs/yhttpd.txt
+//*>>
diff --git a/TODO b/TODO
index e251970..be00c69 100644
--- a/TODO
+++ b/TODO
@@ -1,40 +1,60 @@
-Might do's for next RELEASE:
-- Remove Chat stuff from yhttpd.conf
-- dir : public vector<string>
+Already done for next RELEASE:
+
+Might do's for next feature RELEASE:
- 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.
-- 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
+- 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 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<int>("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 0f9f844..0639500 100755
--- a/configure
+++ b/configure
@@ -9,7 +9,7 @@ fi
perl -e '
use strict;
$|=1;
- sub check {
+ sub check_gcc {
my $f = shift;
my $s = shift;
my $r = 0;
@@ -29,10 +29,32 @@ perl -e '
print "GNU G++ $f.$s found!\n";
return $r;
}
+ sub check_make {
+ print "Checking for GNU make\n";
+ my $err = "No GNU make found.\nPlease install a version of GNU make!\n";
+ my $make;
+ if (`which gmake`) {
+ $make = "gmake";
+ } elsif ( `which make` ) {
+ $make = "make";
+ } else {
+ print $err;
+ exit(1);
+ }
+
+ `sh -c "$make -v > make.version 2>/dev/null"`;
+ if ( `cat make.version` =~ /GNU Make/ ) {
+ `echo $make >> make.version`;
+ } else {
+ print $err;
+ exit(1);
+ }
+ }
+ &check_make;
print "Checking compiler version\n";
my $r = 0;
for (my $i = 4; $i > 0 && $r == 0; --$i ) {
- $r = &check(3,$i);
+ $r = &check_gcc(3,$i);
}
if ($r == 0) {
print "No suitable g++ compiler found!\n";
@@ -49,3 +71,4 @@ perl -e '
' `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!
diff --git a/etc/ychat.conf b/etc/ychat.conf
index 1a48d79..7fc8cc7 100644
--- a/etc/ychat.conf
+++ b/etc/ychat.conf
@@ -1,4 +1,4 @@
-<?xml version="5.0" encoding="ISO-8859-1" standalone="yes" ?>
+<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
<category name="chat">
<option name="defaultop">
<value>Snoop</value>
@@ -49,9 +49,6 @@
<option name="msg">
<value>3</value>
</option>
- <option name="users">
- <value>3</value>
- </option>
<option name="me">
<value>3</value>
</option>
@@ -137,7 +134,7 @@
</category>
<category name="maxlength">
<option name="word">
- <value>50</value>
+ <value>15</value>
<descr>Maximum length of a word inside a chat message. The word will be seperate by a blank if exceeded</descr>
</option>
<option name="message">
@@ -172,9 +169,6 @@
</option>
</category>
<category name="msgs">
- <option name="userlist">
- <value>List of logged in users: </value>
- </option>
<option name="system">
<value>Global system message: </value>
</option>
@@ -359,9 +353,6 @@
<option name="uptime">
<value>Shows the yChat uptime. Usage: /uptime</value>
</option>
- <option name="users">
- <value>Shows currently logged in users. Usage: /users</value>
- </option>
<option name="s">
<value>Screams the TEXT. Usage: /s TEXT</value>
</option>
@@ -592,16 +583,12 @@
</option>
</category>
<category name="thread">
- <option name="initpoolsize">
- <value>20</value>
- <descr>Initial number of threads running at the same time. If all threads are used, the pool will allocate a new thread. Lowest value is 1.</descr>
- </option>
- <option name="maxpoolsize">
- <value>0</value>
- <descr>Maximum amount of parallel running threads. Change this to 0 if you want to use unlimited threads.</descr>
+ <option name="poolsize">
+ <value>50</value>
+ <descr>Number of threads running at the same time</descr>
</option>
<option name="queuesize">
- <value>50</value>
+ <value>10</value>
<descr>Max. number of jobs which can wait for a free thread of the thread pool</descr>
</option>
</category>
@@ -675,9 +662,6 @@
<option name="png">
<value>image/png</value>
</option>
- <option name="txt">
- <value>text/plain</value>
- </option>
<option name="default">
<value>text/html</value>
</option>
diff --git a/html/help.html b/html/help.html
index ad9a25f..57ae511 100755
--- a/html/help.html
+++ b/html/help.html
@@ -11,7 +11,7 @@
<table align=center width=500>
<tr><td>
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). You can also access help for a specific command with the /help command. Example: /help commandname:
+ in memory loaded command modules are listed here which should be the case by yChat default configuration):
</td></tr>
<tr><td>
<br>
diff --git a/html/index.html b/html/index.html
index b1a1793..983e7ef 100755
--- a/html/index.html
+++ b/html/index.html
@@ -3,25 +3,52 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>
- %%yhttpd.version%%
+ %%ychat.version%%
</title>
<link rel=stylesheet href="style.css" type=text/css>
</head>
-<body bgcolor=#000000 text=#ffff00>
+<body>
<table align=center width=500>
<tr>
-<td align=center class=header>%%yhttpd.version%%<br><br>%%INFO%%</td>
+<td>
+<center>
+%%ychat.version%%<br><br>%%INFO%%
+</center>
+</td>
</tr>
<tr>
<td colspan=2>&nbsp;</td>
</tr>
<tr>
<td align=center colspan=2>
-This is the demo website provided by yhttpd :-)
+<form action="frameset.html" method="POST">
+ <input type="hidden" name="event" value="login">
+Enter your nick:<br>
+ <input class="text" type="text" name="nick" value="%%nick%%" maxlength="%%chat.maxlength.username%%" accesskey="n">
+<br>
+<br>
+Enter your password:<br>
+ <input class="text" type="password" name="password" value="%%pass%%" maxlength="%%chat.maxlength.password%%" accesskey="p">
+<br>
+<br>
+Enter your room:<br>
+ <input class="text" type="text" name="room" value="%%chat.defaultroom%%" maxlength="%%chat.maxlength.roomname%%" accesskey="r">
+<br>
+<br>
+ <input type="hidden" name="end" value="end">
+ <input type="submit" value="login" accesskey="s">
+</form>
+<br>
+<a class="fancy" href="register.html">Register</a> a new nick
+<br>
+<br>
+If you don't want to register you may login
+<br>
+without a password using an unregistered nick.
</td>
</tr>
</table>
<br><br>
-<center><span class="signature">yhttpd is OpenSource - get it at <a target="_blank" href="http://www.yhttpd.org">http://www.yhttpd.org</a></span></center>
+<center><span class="signature">yChat is OpenSource - get it at <a class="fancy" target="_blank" href="http://www.yChat.org">http://www.yChat.org</a></span></center>
</body>
</html>
diff --git a/html/input.html b/html/input.html
index 31ed9fe..3a9b564 100755
--- a/html/input.html
+++ b/html/input.html
@@ -26,13 +26,6 @@
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();
- }
//-->
</script>
</head>
@@ -47,11 +40,8 @@
<a href='#' class="fancy" onclick="javascript:popup('colors.html?event=colors&tmpid=%%tmpid%%', 600, 480)">Colors</a>
<a href='#' class="fancy" onclick="javascript:popup('options.html?event=options&tmpid=%%tmpid%%', 600, 480)">Options</a>
<a href='#' class="fancy" onclick="javascript:popup('help.html?event=help&tmpid=%%tmpid%%', 600, 480)">Help</a>
- <a href='#' class="fancy" onclick="javascript:popup('loggedin.html?event=loggedin&tmpid=%%tmpid%%', 600, 480)">Users</a>
<a href='#' class="fancy" onclick="javascript:popup('admin.html?event=admin&tmpid=%%tmpid%%', 600, 480)">Admin</a>
<a href='input.html?event=input&tmpid=%%tmpid%%&message=%2Fq' class="fancy" target='blank'>Logout</a>
- Scrolling:
- <input type="checkbox" name="scroll" checked onClick="chgscroll(this);">
</div>
<input type="hidden" name="event" value="input">
<input type="hidden" name="tmpid" value="%%tmpid%%">
diff --git a/html/online.html b/html/online.html
index 6a10fd9..fc1fd84 100755
--- a/html/online.html
+++ b/html/online.html
@@ -2,6 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="refresh" content="20">
<link rel=stylesheet href="style.css" type=text/css>
<body>
<b>%%ROOMNAME%%</b>
@@ -13,7 +14,7 @@
%%ROOMTOPIC%%
</td>
</tr>
- %%USERLIST%%
+ %%USERLIST%%
</table>
</body>
</html>
diff --git a/html/stream.html b/html/stream.html
index ed08a23..db4c05c 100755
--- a/html/stream.html
+++ b/html/stream.html
@@ -8,31 +8,32 @@
<link rel=stylesheet href="style.css" type=text/css>
<script language="JavaScript">
var scrolling;
- var ison;
- function autoscroll()
+ var isOn;
+ function autoScroll()
{
- if(!ison){
+ if(!isOn)
+ {
scrolling = window.setInterval("window.scroll(1,1606682)",70);
- ison = true;
+ isOn = true;
}
}
- function stopscroll()
+
+ function stopScroll()
{
- if(ison)
+ if(isOn)
{
- window.clearInterval(scrolling);
- ison = false;
+ window.clearInterval(scrolling);
+ isOn=false;
}
}
</script>
</head>
<body class="stream">
-<h1>Engine: %%ychat.version%%</h2>
-<script language="JavaScript">
- autoscroll();
+<script>
+autoScroll();
</script>
- Welcome to the chat, %%nick%%!
+ Welcome to yChat %%nick%%!
<br>
<br>
diff --git a/html/style.css b/html/style.css
index e31bd7e..ade4a1a 100755
--- a/html/style.css
+++ b/html/style.css
@@ -1,11 +1,52 @@
-BODY, TD {
+body, div {
font-family: Verdana, Helvetica, sans-serif;
+ background-color: #000000;
+ color: #FFFFEF;
font-size: 11pt;
}
-A {
- color: #dddddd;
+
+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;
+}
+
+.fancy {
+ font-family: Verdana, Helvetica, sans-serif;
+ text-decoration: none;
+ color: #FFFFEF;
+ background-color: #000000;
+ border: solid #555555 1px;
+ font-size: 9pt;
+ padding: 2px;
+}
+
+a:hover.fancy {
+ text-decoration: none;
+ color: #FFFFEF;
+ background-color: #323232;
+ border: solid #FFFFEF 1px;
+}
+
+b {
+ background-color: #323232;
+ border: solid #555555 1px;
+}
+
+body.stream {
+ background-color: #323232;
}
+
.signature {
- color: #dddddd;
+ color: #AAAAAA;
font-size: 9pt;
}
diff --git a/scripts/README b/scripts/README
index 4a94391..189b169 100644
--- a/scripts/README
+++ b/scripts/README
@@ -1,4 +1,4 @@
-All scripts should be run from the yhttpd main directory, example:
+All scripts should be run from the yChat main directory, example:
./scripts/makeyhttpd.pl
diff --git a/scripts/astyle.sh b/scripts/astyle.sh
index b9dbc45..4376887 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=ansi -s2 $i
+ astyle --style=gnu $i
rm -f $i.orig
done
done
diff --git a/scripts/buildnr.pl b/scripts/buildnr.pl
index 4698f8d..e691a11 100755
--- a/scripts/buildnr.pl
+++ b/scripts/buildnr.pl
@@ -1,8 +1,8 @@
#!/usr/bin/perl
-# The yhttpd Project (2003)
+# The yChat Project (2003)
#
-# This script increases the BUILNR of msgs,h each time the yhttpd
+# This script increases the BUILNR of msgs,h each time the yChat
# gets recompiled!
use strict;
diff --git a/scripts/config.sh b/scripts/config.sh
index f301246..373fad4 100755
--- a/scripts/config.sh
+++ b/scripts/config.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# The yhttpd Project (2004)
+# The yChat Project (2004)
#
# This script modifues the src/glob.h file.
@@ -15,11 +15,11 @@ perl -e '
use scripts::modules::file;
print <<END;
-Welcome to the yhttpd configurator!
+Welcome to the yChat configurator!
You may also edit the src/glob.h file manually instead of using
this configurator option. Please also notice that this are only
before-compile options. All setups which can be made after com-
-iling are placed in the yhttpd configuration file.
+iling are placed in the yChat configuration file.
END
my $sep = "================================================================\n"; my $stdin;
diff --git a/scripts/makeyhttpd.pl b/scripts/makeyhttpd.pl
index 101343a..2805360 100644
--- a/scripts/makeyhttpd.pl
+++ b/scripts/makeyhttpd.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# The yChat & yhttpd Project (2004, 2005)
+# The yChat & yhttpd Project (2004)
#
# This scripts modifies the yChat sources to yhttpd sources.
@@ -17,8 +17,6 @@ my @delete = (
'src/data',
'src/irc',
'src/contrib/crypt',
- 'src/modl.h',
- 'src/modl.cpp',
'src/mods',
'src/mods/commands',
'src/mods/irc',
@@ -77,7 +75,7 @@ foreach (@delete) {
system("rm -Rf $_");
}
-print "\nDeleting CVS directories\n";
+print "Deleting CVS directories\n";
system("find . -name CVS | xargs rm -Rf");
print "Creating new dirs\n->";
@@ -86,14 +84,14 @@ foreach (@createdir) {
system("mkdir $_");
}
-print "\nRenaming config file\n";
+print "Renaming 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/screen.sh b/scripts/screen.sh
index 5c227fc..6d5b7aa 100755
--- a/scripts/screen.sh
+++ b/scripts/screen.sh
@@ -1,3 +1,3 @@
#!/bin/sh
-screen -S yhttpd ./bin/yhttpd
+screen -S ychat ./bin/ychat
diff --git a/scripts/setglobvals.pl b/scripts/setglobvals.pl
index 1ee1de4..13288a5 100755
--- a/scripts/setglobvals.pl
+++ b/scripts/setglobvals.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# The yhttpd Project (2003)
+# The yChat Project (2003)
#
# This script sets up some variables in src/glob.h
diff --git a/scripts/stats.pl b/scripts/stats.pl
index fcbcd33..38cc67c 100755
--- a/scripts/stats.pl
+++ b/scripts/stats.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# The yhttpd Project (2003 - 2004)
+# The yChat Project (2003 - 2004)
#
# This script generates source code and project statistics
diff --git a/src/Makefile.in b/src/Makefile.in
index 262f3a6..0382389 100755
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -6,16 +6,16 @@ LDFLAGS=$(LIBADD) -lstdc++
LDADD=-pthread -D_THREAD_SAFE -export-dynamic -ldl
INCLUDES=`cat includes.add`
CFLAGS=-fno-inline -fno-default-inline -frepo
-all: yhttpd
+all: ychat
$(SRCS):
$(CC) $(INCLUDES) $(CFLAGS) -c $*.cpp
infotext:
@echo Compiling base
-yhttpd: infotext $(OBJS)
+ychat: infotext $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
- @mv yhttpd ../bin
+ @mv ychat ../bin
@echo -n "Size of linked executable: "
- @du -hc ../bin/yhttpd | tail -n 1
+ @du -hc ../bin/ychat | tail -n 1
clean:
@echo Cleaning base obj
@if test -d ../obj; then rm -Rf ../obj; fi
diff --git a/src/chat/base.h b/src/chat/base.h
index 9da4304..ae2e926 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 <map>
-#include "../maps/nhashmap.h"
+#include "../maps/smap.h"
template<class type>
-class base : public nhashmap<type*>
+class base : public smap<type*,string>
{
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 )
- {
- nhashmap<type*>::run_func( &base<type>::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<type*>::run_func( &base<type>::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<type*>::run_func( &base<type>::reconf_ );
- }
-
- static void reconf_ ( type* type_obj )
- {
- type_obj -> reconf ();
- }
-
- void get_data( map<string,string> *p_map_string )
- {
- nhashmap<type*>::run_func( &base<type>::get_data_ , (void*)p_map_string );
- }
-
- static void get_data_( type* type_obj, void* v_arg )
- {
- type_obj -> get_data ( (map<string,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 <font color="usercolor">username</font>seperator
- void get_user_list( string &s_list )
- {
- container c;
- c.elem[0] = (void*) &s_list;
-
- nhashmap<type*>::run_func( &base<type>::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 )
+ {
+ smap<type*,string>::run_func( &base<type>::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<type*,string>::run_func( &base<type>::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<type*,string>::run_func( &base<type>::reconf_ );
+ }
+
+ static void reconf_ ( type* type_obj )
+ {
+ type_obj -> reconf ();
+ }
+
+ void get_data( map_string *p_map_string )
+ {
+ smap<type*,string>::run_func( &base<type>::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 <font color="usercolor">username</font>seperator
+ void get_user_list( string &s_list )
+ {
+ container c;
+ c.elem[0] = (void*) &s_list;
+
+ smap<type*,string>::run_func( &base<type>::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 0be21aa..53b609f 100755
--- a/src/chat/base.tmpl
+++ b/src/chat/base.tmpl
@@ -4,28 +4,30 @@
#include "base.h"
template<class type>
-base<type>::base()
-{}
+base<type>::base() : smap<type*,string>::smap(HMAPOCC)
+{
+}
template<class type>
base<type>::~base( )
-{}
+{
+}
template<class type>
type*
base<type>::get_elem( string s_name, bool &b_found )
{
- s_name = to_lower(s_name);
- type* p_type = nhashmap<type*>::get_elem( s_name );
- b_found = p_type == NULL ? false : true;
- return p_type;
+ s_name = to_lower(s_name);
+ type* p_type = smap<type*,string>::get_elem( s_name );
+ b_found = p_type == NULL ? false : true;
+ return p_type;
}
template<class type>
void
base<type>::add_elem( type* p_type )
{
- nhashmap<type*>::add_elem(p_type, p_type->get_lowercase_name());
+ smap<type*,string>::add_elem(p_type, p_type->get_lowercase_name());
}
#endif
diff --git a/src/chat/chat.cpp b/src/chat/chat.cpp
index 019f939..03cd8c1 100755
--- a/src/chat/chat.cpp
+++ b/src/chat/chat.cpp
@@ -12,193 +12,190 @@ using namespace std;
chat::chat( )
{
- { // Set up replace strings;
- wrap::system_message(CHATREP);
- vector<string>* p_vec_keys = wrap::CONF->get_key_vector();
-
- for (vector<string>::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 )
+ { // Set up replace strings;
+ wrap::system_message(CHATREP);
+ vector<string>* p_vec_keys = wrap::CONF->get_key_vector();
+
+ for (vector<string>::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 )
+ {
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);
- }
- }
+ vec_replace_keys.push_back(s_from);
+ }
+ }
- sort(vec_replace_keys.begin(), vec_replace_keys.end());
- delete p_vec_keys;
- }
+ sort(vec_replace_keys.begin(), vec_replace_keys.end());
+ delete p_vec_keys;
+ }
}
chat::~chat( )
{
- // Delete all room objects!
- run_func( mtools<room*>::delete_obj );
+ // Delete all room objects!
+ run_func( mtools<room*>::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;
- base<room>::run_func( get_user_, (void*)&param );
+ smap<room*,string>::run_func( get_user_, (void*)&param );
- 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( hashmap<string> &map_params )
+chat::login( map_string &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") ) )
- {
- 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"] )
+ 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.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_user(p_user);
- map_params["tmpid"] = p_sess->get_tmpid();
+ p_sess->set_name(s_user);
+ map_params["tmpid"] = p_sess->get_id();
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 );
- // prove if nick is registered, else create a guest chatter.
-#ifdef DATABASE
+ else // if ( p_user == NULL ) // If not in garbage create a new user!
+ {
+ p_user = new user( s_user );
- hashmap<string> map_results = wrap::DATA->select_user_data( tool::to_lower(s_user), "selectlogin");
+ // 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 );
+ 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 );
@@ -209,147 +206,147 @@ chat::login( hashmap<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_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"]));
+ }
+
+ 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);
- }
+ }
- 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_elem( p_room );
+ }
- // add user to the room.
- p_room->add_user( p_user );
+ // add user to the room.
+ p_room->add_user( p_user );
- wrap::system_message( NEWUSER + s_user );
+ wrap::system_message( NEWUSER + s_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" ) + "<br>\n";
+ // 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" ) + "<br>\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 );
+ // 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, hashmap<string> &map_params )
+chat::post( user* p_user, map_string &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 = "<font color=\"" + wrap::CONF->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 = "<font color=\"" + wrap::CONF->get_elem( "chat.html.errorcolor" ) + "\">"
+ wrap::CONF->get_elem( "chat.msgs.err.messagelength" ) + "</font><br>\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<string> list_msg = tool::split_string( s_msg, " ");
- list<string>::iterator iter = list_msg.begin();
+ // Check max word length
+ list<string> list_msg = tool::split_string( s_msg, " ");
+ list<string>::iterator iter = list_msg.begin();
- for ( s_msg = ""; iter != list_msg.end(); ++iter )
- {
- if ( iter->length() > i_max_word_length )
+ for ( s_msg = ""; iter != list_msg.end(); ++iter )
{
+ 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 + " ");
+ }
}
- 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( "<font color=\"#" )
- .append( p_user->get_col1() )
- .append( "\">" )
- .append( p_user->get_name() )
- .append( ":</font> <font color=\"#")
- .append( p_user->get_col2() )
- .append( "\">" )
- .append( s_msg )
- .append( "</font><br>\n" );
-
- p_user->get_room()->msg_post( &s_post );
+
+ 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( "<font color=\"#" )
+ .append( p_user->get_col1() )
+ .append( "\">" )
+ .append( p_user->get_name() )
+ .append( ":</font> <font color=\"#")
+ .append( p_user->get_col2() )
+ .append( "\">" )
+ .append( s_msg )
+ .append( "</font><br>\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<string>::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<string>::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 8508508..2661536 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<room>, public perm
{
private:
- map<string,string> map_replace_strings;
- vector<string> vec_replace_keys;
+ map_string map_replace_strings;
+ vector<string> 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<room*>( 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<string> &map_params );
-
- // will be called if a user posts a message.
- void post ( user* u_user, hashmap<string> &map_params );
-
- void del_elem( string s_name )
- {
- base<room>::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<room*>( 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<room*,string>::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 7df111d..2500b91 100755
--- a/src/chat/gcol.cpp
+++ b/src/chat/gcol.cpp
@@ -7,139 +7,130 @@ using namespace std;
gcol::gcol()
{
- pthread_mutex_init( &mut_vec_rooms , NULL);
+ pthread_mutex_init( &mut_vec_rooms , NULL);
- p_map_users = new shashmap<user*>;
- wrap::system_message( GARBAGE );
+ p_map_users = new smap<user*,string>(HMAPOCC);
+ 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->size() == 0);
- pthread_mutex_unlock( &mut_vec_rooms );
+ pthread_mutex_lock ( &mut_vec_rooms );
+ b_empty = ( vec_rooms.empty() && p_map_users->get_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<room*>::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<room*>::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->clear();
+ p_map_users->run_func( delete_users_ );
+ p_map_users->make_empty();
#ifdef NCURSES
-
- print_garbage();
+ print_garbage();
#endif
-
- return true;
+ return true;
}
room*
gcol::get_room_from_garbage()
{
- pthread_mutex_lock ( &mut_vec_rooms );
+ pthread_mutex_lock ( &mut_vec_rooms );
- if ( vec_rooms.empty() )
- {
- pthread_mutex_unlock( &mut_vec_rooms );
- return NULL;
- }
+ if ( vec_rooms.empty() )
+ {
+ pthread_mutex_unlock( &mut_vec_rooms );
+ return NULL;
+ }
- room* p_room = vec_rooms.back();
- vec_rooms.pop_back();
- pthread_mutex_unlock( &mut_vec_rooms );
+ room* p_room = vec_rooms.back();
+ vec_rooms.pop_back();
+ pthread_mutex_unlock( &mut_vec_rooms );
#ifdef NCURSES
-
- print_garbage();
+ print_garbage();
#endif
- return p_room;
+ return p_room;
}
room*
gcol::get_room_from_garbage_or_new( string s_room )
{
- room* p_room = get_room_from_garbage();
- if ( p_room == NULL )
- return new room( s_room );
- p_room->set_name( s_room );
- return p_room;
+ room* p_room = get_room_from_garbage();
+ if ( p_room == NULL )
+ return new room( s_room );
+ p_room->set_name( s_room );
+ return p_room;
}
user*
gcol::get_user_from_garbage( string s_user )
{
- user* p_user = p_map_users->get_elem( tool::to_lower(s_user) );
- ;
+ user* p_user = p_map_users->get_elem( tool::to_lower(s_user) );;
- if ( p_user != NULL )
+ if ( p_user != NULL )
{
- p_map_users->del_elem( tool::to_lower(s_user) );
- p_user->set_name( s_user );
- p_user->set_online( true );
- p_user->set_invisible( false );
- p_user->renew_timeout();
- wrap::system_message(GARUSE2 + p_user->get_name() );
+ p_map_users->del_elem( tool::to_lower(s_user) );
+ p_user->set_name( s_user );
+ p_user->set_online( true );
+ p_user->set_invisible( false );
+ p_user->renew_timeout();
+ wrap::system_message(GARUSE2 + p_user->get_name() );
#ifdef NCURSES
-
- print_garbage();
+ print_garbage();
#endif
-
}
return p_user;
@@ -148,34 +139,34 @@ gcol::get_user_from_garbage( string s_user )
void
gcol::delete_users_( user *user_obj )
{
- wrap::system_message( REMUSER + user_obj->get_name() );
- user_obj->clean();
- delete user_obj;
+ wrap::system_message( REMUSER + user_obj->get_name() );
+ user_obj->clean();
+ delete user_obj;
}
void
gcol::lock_mutex()
{
- pthread_mutex_lock ( &mut_vec_rooms );
+ pthread_mutex_lock ( &mut_vec_rooms );
}
void
gcol::unlock_mutex()
{
- pthread_mutex_unlock ( &mut_vec_rooms );
+ pthread_mutex_unlock ( &mut_vec_rooms );
}
#ifdef NCURSES
void
gcol::print_garbage( )
{
- if ( wrap::NCUR->is_ready() )
- {
- pthread_mutex_lock ( &mut_vec_rooms );
- mvprintw( NCUR_GARBAGE_X,NCUR_GARBAGE_Y, "Garbage: %d ", p_map_users->size() + vec_rooms.size() );
- pthread_mutex_unlock( &mut_vec_rooms );
- refresh();
- }
+ if ( wrap::NCUR->is_ready() )
+ {
+ pthread_mutex_lock ( &mut_vec_rooms );
+ mvprintw( NCUR_GARBAGE_X,NCUR_GARBAGE_Y, "Garbage: %d ", p_map_users->get_size() + vec_rooms.size() );
+ pthread_mutex_unlock( &mut_vec_rooms );
+ refresh();
+ }
}
#endif
diff --git a/src/chat/gcol.h b/src/chat/gcol.h
index d1fcde3..4936ded 100755
--- a/src/chat/gcol.h
+++ b/src/chat/gcol.h
@@ -1,43 +1,42 @@
-// garbage collector
+// garbage collector
#include "../incl.h"
#ifndef GCOL_H
#define GCOL_H
-#include <vector>
+#include <vector>
#include "room.h"
#include "user.h"
-#include "../maps/shashmap.h"
+#include "../maps/smap.h"
using namespace std;
class gcol
{
-private:
- vector<room*> vec_rooms;
- shashmap<user*>* p_map_users;
+ private:
+ vector<room*> vec_rooms;
+ smap<user*,string>* p_map_users;
pthread_mutex_t mut_vec_rooms;
static void delete_users_( user* user_obj );
#ifdef NCURSES
-
void print_garbage( );
#endif
-public:
+ public:
gcol();
~gcol();
- bool remove_garbage();
- void add_room_to_garbage( room* p_room );
- void add_user_to_garbage( user* p_user );
- virtual room* get_room_from_garbage();
- virtual room* get_room_from_garbage_or_new( string s_room );
- user* get_user_from_garbage( string s_user );
- virtual void lock_mutex();
- virtual void unlock_mutex();
+ bool remove_garbage();
+ void add_room_to_garbage( room* p_room );
+ void add_user_to_garbage( user* p_user );
+ virtual room* get_room_from_garbage();
+ virtual room* get_room_from_garbage_or_new( string s_room );
+ user* get_user_from_garbage( string s_user );
+ virtual void lock_mutex();
+ virtual void unlock_mutex();
};
#endif
diff --git a/src/chat/perm.cpp b/src/chat/perm.cpp
index 2de3031..b862d43 100755
--- a/src/chat/perm.cpp
+++ b/src/chat/perm.cpp
@@ -8,76 +8,73 @@ using namespace std;
perm::perm()
{
- p_command_status = new shashmap< valwrap<int>* >;
- p_command_disabled = new shashmap< valwrap<bool>* >;
+ p_command_status = new smap< valwrap<int>*, string>(HMAPOCC);
+ p_command_disabled = new smap< valwrap<bool>*, string>(HMAPOCC);
- set_standard_command_permissions();
+ set_standard_command_permissions();
}
perm::~perm()
{
- p_command_status->run_func( &mtools< valwrap<int>* >::delete_obj );
- p_command_disabled->run_func( &mtools< valwrap<bool>* >::delete_obj );
+ p_command_status->run_func( &mtools< valwrap<int>* >::delete_obj );
+ p_command_disabled->run_func( &mtools< valwrap<bool>* >::delete_obj );
- delete p_command_status;
- delete p_command_disabled;
+ delete p_command_status;
+ delete p_command_disabled;
}
int
perm::get_command_status( string s_command )
{
- if ( p_command_status->exists( s_command ) )
- return p_command_status->get_elem( s_command )->val;
+ if ( p_command_status->is_avail( s_command ) )
+ return p_command_status->get_elem( s_command )->val;
- return 0;
+ return 0;
}
void
perm::set_command_status( string s_command, int i_int )
{
- valwrap<int>* p_val = p_command_status->get_set_elem( new valwrap<int>(i_int), s_command );
+ valwrap<int>* p_val = p_command_status->set_elem( new valwrap<int>(i_int), s_command );
- if ( p_val )
- delete p_val;
+ if ( p_val )
+ delete p_val;
}
bool
perm::get_command_disabled( string s_command )
{
- if ( p_command_disabled->exists( s_command ) )
- return p_command_disabled->get_elem( s_command )->val;
- return 0;
+ if ( p_command_disabled->is_avail( s_command ) )
+ return p_command_disabled->get_elem( s_command )->val;
+ return 0;
}
void
perm::set_command_disabled( string s_command, bool b_bool )
{
- valwrap<bool>* p_val = p_command_disabled->get_set_elem( new valwrap<bool>(b_bool), s_command );
+ valwrap<bool>* p_val = p_command_disabled->set_elem( new valwrap<bool>(b_bool), s_command );
- if ( p_val )
- delete p_val;
+ if ( p_val )
+ delete p_val;
}
void
perm::set_standard_command_permissions()
{
- wrap::system_message(PERMSTD);
-
- vector<string>* p_vec_keys = wrap::CONF->get_key_vector();
-
- for (vector<string>::iterator iter = p_vec_keys->
- begin();
- iter != p_vec_keys->end();
- iter++ )
- {
- if ( iter->length() > 17 && iter->compare( 0, 16, "chat.permissions" ) == 0 )
- {
- valwrap<int>* p_val = new valwrap<int>( tool::string2int( wrap::CONF->get_elem(*iter) ) );
- p_command_status->add_elem( p_val, iter->substr(17) );
- }
- }
-
- delete p_vec_keys;
+ wrap::system_message(PERMSTD);
+
+ vector<string>* p_vec_keys = wrap::CONF->get_key_vector();
+
+ for (vector<string>::iterator iter = p_vec_keys->begin(); iter != p_vec_keys->end(); iter++ )
+ {
+ if ( iter->length() > 17 && iter->compare( 0, 16, "chat.permissions" ) == 0 )
+ {
+ valwrap<int>* p_val = new valwrap<int>( tool::string2int( wrap::CONF->get_elem(*iter) ) );
+ p_command_status->add_elem( p_val, iter->substr(17) );
+ }
+ }
+
+ delete p_vec_keys;
}
#endif
diff --git a/src/chat/perm.h b/src/chat/perm.h
index fca019f..8e08ba2 100755
--- a/src/chat/perm.h
+++ b/src/chat/perm.h
@@ -1,5 +1,5 @@
#include "../incl.h"
-#include "../maps/shashmap.h"
+#include "../maps/smap.h"
#ifndef PERM_H
#define PERM_H
@@ -7,36 +7,35 @@
using namespace std;
template<class type_>
-struct valwrap
-{
- type_ val;
- valwrap(type_ i)
- {
- val = i;
- }
-
- type_ get_val()
- {
- return val;
- }
+struct valwrap
+{
+ type_ val;
+ valwrap(type_ i)
+ {
+ val = i;
+ }
+ type_ get_val()
+ {
+ return val;
+ }
};
class perm
{
private:
- shashmap< valwrap<int>* >* p_command_status;
- shashmap< valwrap<bool>* >* p_command_disabled;
-
- void set_standard_command_permissions();
+ smap< valwrap<int>*, string>* p_command_status;
+ smap< valwrap<bool>*, string>* p_command_disabled;
+ void set_standard_command_permissions();
+
public:
- perm( );
- ~perm( );
+ perm( );
+ ~perm( );
- virtual int get_command_status( string s_command );
- virtual bool get_command_disabled( string s_command );
- virtual void set_command_status( string s_command, int i_int );
- virtual void set_command_disabled( string s_command, bool b_bool );
+ virtual int get_command_status( string s_command );
+ virtual bool get_command_disabled( string s_command );
+ virtual void set_command_status( string s_command, int i_int );
+ virtual void set_command_disabled( string s_command, bool b_bool );
};
#endif
diff --git a/src/chat/room.cpp b/src/chat/room.cpp
index 00dc463..527e444 100755
--- a/src/chat/room.cpp
+++ b/src/chat/room.cpp
@@ -8,98 +8,86 @@ using namespace std;
room::room( string s_name ) : name( s_name )
{
- pthread_mutex_init( &mut_s_topic, NULL );
-#ifdef LOGGING
-
- p_logd = new logd( wrap::CONF->get_elem("chat.logging.roomlogdir") + get_lowercase_name(),
- wrap::CONF->get_elem("chat.logging.roomloglines") );
-#endif
-
- wrap::STAT->increment_num_rooms();
+ pthread_mutex_init( &mut_s_topic, NULL );
+ p_logd = new logd( wrap::CONF->get_elem("chat.logging.roomlogdir") + get_lowercase_name(),
+ wrap::CONF->get_elem("chat.logging.roomloglines") );
+ wrap::STAT->increment_num_rooms();
}
room::~room()
{
- wrap::STAT->decrement_num_rooms();
+ wrap::STAT->decrement_num_rooms();
- // Delete all user objects
- run_func( mtools<user*>::delete_obj );
+ // Delete all user objects
+ run_func( mtools<user*>::delete_obj );
-#ifdef LOGGING
+ delete p_logd;
- delete p_logd;
-#endif
-
- pthread_mutex_destroy( &mut_s_topic );
- pthread_mutex_destroy( &mut_s_name );
+ pthread_mutex_destroy( &mut_s_topic );
+ pthread_mutex_destroy( &mut_s_name );
}
string
room::get_topic()
{
- string s_ret;
- pthread_mutex_lock ( &mut_s_topic );
- s_ret = s_topic;
- pthread_mutex_unlock( &mut_s_topic );
- return s_ret;
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_topic );
+ s_ret = s_topic;
+ pthread_mutex_unlock( &mut_s_topic );
+ return s_ret;
}
void
room::set_topic( string s_topic )
{
- pthread_mutex_lock ( &mut_s_topic );
- if ( s_topic == "" )
- this->s_topic = "";
- else
- this->s_topic = s_topic + "<br><br>";
- pthread_mutex_unlock( &mut_s_topic );
- reload_onlineframe();
+ pthread_mutex_lock ( &mut_s_topic );
+ if ( s_topic == "" )
+ this->s_topic = "";
+ else
+ this->s_topic = s_topic + "<br><br>";
+ pthread_mutex_unlock( &mut_s_topic );
+ reload_onlineframe();
}
void
room::set_topic( string s_topic, string s_color )
{
- set_topic( "<font color=\"#" + s_color + "\">" + s_topic + "</font>");
+ set_topic( "<font color=\"#" + s_color + "\">" + s_topic + "</font>");
}
void
room::clean_room()
{
- pthread_mutex_lock ( &mut_s_topic );
- this->s_topic = "";
- pthread_mutex_unlock( &mut_s_topic );
- wrap::CHAT->del_elem( get_lowercase_name() );
- wrap::GCOL->add_room_to_garbage( this );
+ pthread_mutex_lock ( &mut_s_topic );
+ this->s_topic = "";
+ pthread_mutex_unlock( &mut_s_topic );
+ wrap::CHAT->del_elem( get_lowercase_name() );
+ wrap::GCOL->add_room_to_garbage( this );
}
void
room::reload_onlineframe()
{
- string s_msg = "<script language=\"JavaScript\"> parent.online.location.reload(); </script>\n";
- msg_post( &s_msg );
+ string s_msg = "<script language=\"JavaScript\"> parent.online.location.reload(); </script>\n";
+ msg_post( &s_msg );
}
-void
+void
room::set_name( string s_name )
{
- if ( tool::to_lower(s_name) == get_lowercase_name() )
- {
- name::set_name( s_name );
- return;
- }
-
-#ifdef LOGGING
- p_logd->flush_logs();
-#endif
+ if ( tool::to_lower(s_name) == get_lowercase_name() )
+ {
+ name::set_name( s_name );
+ return;
+ }
- if ( s_name == "" )
- return;
+ p_logd->flush_logs();
- name::set_name( s_name );
-#ifdef LOGGING
+ if ( s_name == "" )
+ return;
- p_logd->set_logfile( wrap::CONF->get_elem("chat.logging.roomlogdir"), get_lowercase_name() );
-#endif
-}
+ name::set_name( s_name );
+ p_logd->set_logfile( wrap::CONF->get_elem("chat.logging.roomlogdir"), get_lowercase_name() );
+}
#endif
diff --git a/src/chat/room.h b/src/chat/room.h
index 572e68b..9d8dd45 100755
--- a/src/chat/room.h
+++ b/src/chat/room.h
@@ -17,67 +17,59 @@ using namespace std;
class room : public base<user>, public name
{
private:
- string s_topic;
- pthread_mutex_t mut_s_topic;
-#ifdef LOGGING
-
- logd* p_logd;
-#endif
+ string s_topic;
+ pthread_mutex_t mut_s_topic;
+ logd* p_logd;
public:
- room( string s_name );
- ~room();
-
- virtual void reload_onlineframe();
-
- void add_user( user* p_user )
- {
- add_elem( p_user );
- p_user->set_p_room( this );
- reload_onlineframe();
- }
-
- user* get_user( string &s_name, bool &b_found )
- {
- return static_cast<user*>( get_elem( s_name, b_found ) );
- }
-
- void del_elem( string &s_name )
- {
- base<user>::del_elem( s_name );
-
- if ( base<user>::size() == 0 )
+ room( string s_name );
+ ~room();
+
+ virtual void reload_onlineframe();
+
+ void add_user( user* p_user )
+ {
+ add_elem( p_user );
+ p_user->set_p_room( this );
+ reload_onlineframe();
+ }
+
+ user* get_user( string &s_name, bool &b_found )
+ {
+ return static_cast<user*>( get_elem( s_name, b_found ) );
+ }
+
+ void del_elem( string &s_name )
+ {
+ smap<user*,string>::del_elem( s_name );
+ if ( smap<user*,string>::get_size() == 0 )
clean_room();
-
- else
- reload_onlineframe();
- }
-
- void msg_post( string s_msg )
- {
- msg_post( &s_msg );
- }
- void msg_post( string *p_msg )
- {
-#ifdef LOGGING
- p_logd->log_simple_line( logd::remove_html_tags(*p_msg) );
-#endif
-
- base<user>::msg_post( p_msg );
- }
-
- string get_bold_name()
- {
- return "<b>" + get_name() + "</b>";
- }
-
- virtual void set_name( string s_name );
- string get_topic();
- void set_topic( string s_topic );
- void set_topic( string s_topic, string s_color );
- void clean_room();
-
-
+ else
+ reload_onlineframe();
+ }
+
+ void msg_post( string s_msg )
+ {
+ msg_post( &s_msg );
+ }
+ void msg_post( string *p_msg )
+ {
+ p_logd->log_simple_line( logd::remove_html_tags(*p_msg) );
+ base<user>::msg_post( p_msg );
+ }
+
+ string get_bold_name()
+ {
+ return "<b>" + get_name() + "</b>";
+ }
+
+ virtual void set_name( string s_name );
+ string get_topic();
+ void set_topic( string s_topic );
+ void set_topic( string s_topic, string s_color );
+ void clean_room();
+
+
};
diff --git a/src/chat/sess.cpp b/src/chat/sess.cpp
index dc9ba9b..b41c8ce 100755
--- a/src/chat/sess.cpp
+++ b/src/chat/sess.cpp
@@ -3,54 +3,27 @@
#include "sess.h"
-sess::sess( string s_tmpid )
+sess::sess( string s_id )
{
- this->p_user = NULL;
- this->s_tmpid = s_tmpid;
+ this->sess_id=s_id;
}
sess::~sess()
-{}
-
-string
-sess::get_tmpid()
{
- return s_tmpid;
+
}
string
-sess::get_name()
-{
- if ( p_user = NULL )
- return "";
-
- return p_user->get_name();
-}
-
-void
-sess::set_name(string s_name)
-{
- if ( p_user != NULL )
- p_user->set_name(s_name);
-}
-
-user*
-sess::get_user()
-{
- return p_user;
-}
-
-void
-sess::set_user(user* p_user)
+sess::get_id()
{
- this->p_user = p_user;
+ return this->sess_id;
}
void
sess::invalidate()
{
- this->s_tmpid = "0";
+ this->sess_id = "0";
}
#endif
diff --git a/src/chat/sess.h b/src/chat/sess.h
index 17d9cfe..717564a 100755
--- a/src/chat/sess.h
+++ b/src/chat/sess.h
@@ -3,29 +3,24 @@
#ifndef SESS_H
#define SESS_H
+#include <map>
#include <string>
-#include "user.h"
class cont;
using namespace std;
-class sess
+class sess : public name
{
+
private:
- string s_tmpid;
- user *p_user;
+ string sess_id;
public:
- sess(string s_tmpid);
- ~sess();
-
- string get_tmpid();
+ sess(string s_id);
+ ~sess();
- void set_user(user* p_user);
- user* get_user();
- void set_name(string s_name);
- string get_name();
- void invalidate();
+ string get_id();
+ void invalidate();
};
#endif
diff --git a/src/chat/sman.cpp b/src/chat/sman.cpp
index d80d421..464bf24 100755
--- a/src/chat/sman.cpp
+++ b/src/chat/sman.cpp
@@ -6,113 +6,108 @@
#include "../maps/mtools.h"
#include "../contrib/crypt/md5.h"
-sman::sman()
+sman::sman() : smap<sess*,string>::smap(HMAPOCC)
{
- i_session_count = 0;
- pthread_mutex_init( &mut_i_session_count, NULL );
+ i_session_count = 0;
+ pthread_mutex_init( &mut_i_session_count, NULL );
}
sman::~sman()
{
- // Delete each session object of the shashmap!
- shashmap<sess*>::run_func( mtools<sess*>::delete_obj );
- pthread_mutex_destroy( &mut_i_session_count );
+ // Delete each session object of the smap!
+ smap<sess*,string>::run_func( mtools<sess*>::delete_obj );
+ pthread_mutex_destroy( &mut_i_session_count );
}
-string sman::generate_id( int i_len )
+string sman::generate_id( int len )
{
- string valid_chars = wrap::CONF->get_elem("chat.session.validchars");
- string s_ret = "";
-
- srand(time(0)+tool::string2int(wrap::CONF->get_elem("chat.session.kloakkey")));
- int i_char;
-
- for (int i = 0; i < i_len; i++)
- {
- i_char = rand() % 64;
- s_ret += valid_chars[i_char];
- }
-
- if ( wrap::CONF->get_elem("chat.session.md5hash") == "true" )
- {
- string s_salt = wrap::CONF->get_elem("chat.session.md5salt");
- s_ret = string(md5::MD5Crypt(s_ret.c_str(), s_salt.c_str()));
- return s_ret.substr(s_ret.find(s_salt) + s_salt.length() + 3);
- }
-
- return s_ret;
+ string valid_chars = wrap::CONF->get_elem("chat.session.validchars");
+ string s_ret = "";
+
+ srand(time(0)+tool::string2int(wrap::CONF->get_elem("chat.session.kloakkey")));
+ int i_char;
+
+ for (int i = 0; i < len; i++)
+ {
+ i_char = rand() % 64;
+ s_ret += valid_chars[i_char];
+ }
+
+ if ( wrap::CONF->get_elem("chat.session.md5hash") == "true" )
+ {
+ string s_salt = wrap::CONF->get_elem("chat.session.md5salt");
+ s_ret = string(md5::MD5Crypt(s_ret.c_str(), s_salt.c_str()));
+ return s_ret.substr(s_ret.find(s_salt) + s_salt.length() + 3);
+ }
+
+ return s_ret;
}
sess *sman::create_session( )
{
- string s_tmpid = generate_id( tool::string2int( wrap::CONF->get_elem( "chat.session.length" ) ) );
+ string s_id = generate_id( tool::string2int( wrap::CONF->get_elem( "chat.session.length" ) ) );
- sess* p_sess = new sess( s_tmpid );
+ sess* p_sess = new sess( s_id );
- pthread_mutex_lock( &mut_i_session_count );
- i_session_count++;
+ pthread_mutex_lock( &mut_i_session_count );
+ i_session_count++;
#ifdef NCURSES
-
- print_sessions();
+ print_sessions();
#endif
+ pthread_mutex_unlock( &mut_i_session_count );
- pthread_mutex_unlock( &mut_i_session_count );
-
- //????
- add_elem( p_sess, s_tmpid );
+ add_elem( p_sess, s_id );
- return p_sess;
+ return p_sess;
}
sess *sman::get_session( string s_id )
{
- return get_elem( s_id );
+ return get_elem( s_id );
}
void
sman::destroy_session( string s_id )
{
- pthread_mutex_lock( &mut_i_session_count );
- i_session_count--;
+ pthread_mutex_lock( &mut_i_session_count );
+ i_session_count--;
#ifdef NCURSES
-
- print_sessions();
+ print_sessions();
#endif
+ pthread_mutex_unlock( &mut_i_session_count );
- pthread_mutex_unlock( &mut_i_session_count );
-
- sess* p_sess = get_elem( s_id );
- del_elem( s_id );
- delete p_sess;
+ sess* p_sess = get_elem( s_id );
+ del_elem( s_id );
+ delete p_sess;
}
#ifdef NCURSES
void sman::print_sessions()
{
- if ( wrap::NCUR->is_ready() )
- {
- mvprintw( NCUR_SESSION_X,NCUR_SESSION_Y, "Sessions: %d ", i_session_count);
- refresh();
- }
+ if ( wrap::NCUR->is_ready() )
+ {
+ mvprintw( NCUR_SESSION_X,NCUR_SESSION_Y, "Sessions: %d ", i_session_count);
+ refresh();
+ }
}
#ifdef NCURSES
void sman::print_init_ncurses()
{
- pthread_mutex_lock( &mut_i_session_count );
- print_sessions();
- pthread_mutex_unlock( &mut_i_session_count );
+ pthread_mutex_lock( &mut_i_session_count );
+ print_sessions();
+ pthread_mutex_unlock( &mut_i_session_count );
}
#endif
int
sman::get_session_count()
{
- int i_ret;
- pthread_mutex_lock( &mut_i_session_count );
- i_ret = i_session_count;
- pthread_mutex_unlock( &mut_i_session_count );
- return i_ret;
+ int i_ret;
+ pthread_mutex_lock( &mut_i_session_count );
+ i_ret = i_session_count;
+ pthread_mutex_unlock( &mut_i_session_count );
+ return i_ret;
}
#endif
diff --git a/src/chat/sman.h b/src/chat/sman.h
index 992fc64..1843aec 100755
--- a/src/chat/sman.h
+++ b/src/chat/sman.h
@@ -6,34 +6,31 @@
#include <cstdlib>
#include "sess.h"
-#include "../maps/shashmap.h"
+#include "../maps/smap.h"
using namespace std;
-class sman : private shashmap<sess*>
+class sman : private smap<sess*,string>
{
private:
- string generate_id( int i_len );
- int i_session_count;
+ string generate_id( int len );
+ int i_session_count;
- pthread_mutex_t mut_i_session_count;
+ pthread_mutex_t mut_i_session_count;
#ifdef NCURSES
-
- void print_sessions();
+ void print_sessions();
#endif
public:
- sman();
- ~sman();
- sess *get_session( string s_tmpid );
- int get_session_count( );
- sess *create_session( );
- void destroy_session( string s_tmpid );
+ sman();
+ ~sman();
+ sess *get_session( string s_id );
+ int get_session_count( );
+ sess *create_session( );
+ void destroy_session( string s_id );
#ifdef NCURSES
-
- void print_init_ncurses();
+ void print_init_ncurses();
#endif
-
};
diff --git a/src/chat/user.cpp b/src/chat/user.cpp
index c5699e2..40dbee8 100755
--- a/src/chat/user.cpp
+++ b/src/chat/user.cpp
@@ -8,573 +8,572 @@ using namespace std;
user::user() : name( "" )
{
- initialize();
+ initialize();
}
user::user( string s_name ) : name( s_name )
{
- initialize();
+ initialize();
}
user::~user()
{
- // pthread_mutex_destroy( & mut_map_mods );
- pthread_mutex_destroy( & mut_away );
- pthread_mutex_destroy( & mut_b_online );
- pthread_mutex_destroy( & mut_b_fake );
- pthread_mutex_destroy( & mut_b_invisible );
- pthread_mutex_destroy( & mut_b_has_sess );
- pthread_mutex_destroy( & mut_b_is_reg );
- pthread_mutex_destroy( & mut_s_mess );
- pthread_mutex_destroy( & mut_s_pass );
- pthread_mutex_destroy( & mut_p_room );
- pthread_mutex_destroy( & mut_s_col1 );
- pthread_mutex_destroy( & mut_s_col2 );
- pthread_mutex_destroy( & mut_s_email );
- pthread_mutex_destroy( & mut_s_tmpid );
- pthread_mutex_destroy( & mut_i_status );
- pthread_mutex_destroy( & mut_map_changed_data );
- pthread_cond_destroy ( &cond_message );
- pthread_mutex_destroy( &mut_message );
+// pthread_mutex_destroy( & mut_map_mods );
+ pthread_mutex_destroy( & mut_away );
+ pthread_mutex_destroy( & mut_b_online );
+ pthread_mutex_destroy( & mut_b_fake );
+ pthread_mutex_destroy( & mut_b_invisible );
+ pthread_mutex_destroy( & mut_b_has_sess );
+ pthread_mutex_destroy( & mut_b_is_reg );
+ pthread_mutex_destroy( & mut_s_mess );
+ pthread_mutex_destroy( & mut_s_pass );
+ pthread_mutex_destroy( & mut_p_room );
+ pthread_mutex_destroy( & mut_s_col1 );
+ pthread_mutex_destroy( & mut_s_col2 );
+ pthread_mutex_destroy( & mut_s_email );
+ pthread_mutex_destroy( & mut_s_tmpid );
+ pthread_mutex_destroy( & mut_i_status );
+ pthread_mutex_destroy( & mut_map_changed_data );
+ pthread_cond_destroy ( &cond_message );
+ pthread_mutex_destroy( &mut_message );
}
void
user::initialize()
{
- this -> b_is_reg = false;
- this -> b_set_changed_data = false;
- this -> b_away = false;
- this -> b_fake = false;
- this -> b_invisible = false;
- this -> s_col1 = wrap::CONF->get_elem( "chat.html.user.color1" );
- this -> s_col2 = wrap::CONF->get_elem( "chat.html.user.color2" );
-
- // pthread_mutex_init( & mut_map_mods , NULL );
- pthread_mutex_init( & mut_away , NULL );
- pthread_mutex_init( & mut_b_online , NULL );
- pthread_mutex_init( & mut_b_fake , NULL );
- pthread_mutex_init( & mut_b_invisible , NULL );
- pthread_mutex_init( & mut_b_has_sess , NULL );
- pthread_mutex_init( & mut_b_is_reg , NULL );
- pthread_mutex_init( & mut_s_mess , NULL );
- pthread_mutex_init( & mut_s_pass , NULL );
- pthread_mutex_init( & mut_p_room , NULL );
- pthread_mutex_init( & mut_s_col1 , NULL );
- pthread_mutex_init( & mut_s_col2 , NULL );
- pthread_mutex_init( & mut_s_email , NULL );
- pthread_mutex_init( & mut_s_tmpid , NULL );
- pthread_mutex_init( & mut_i_status , NULL );
- pthread_mutex_init( & mut_map_changed_data , NULL );
- pthread_cond_init ( &cond_message, NULL);
- pthread_mutex_init( &mut_message , NULL);
- renew_timeout();
+ this -> b_is_reg = false;
+ this -> b_set_changed_data = false;
+ this -> b_away = false;
+ this -> b_fake = false;
+ this -> b_invisible = false;
+ this -> s_col1 = wrap::CONF->get_elem( "chat.html.user.color1" );
+ this -> s_col2 = wrap::CONF->get_elem( "chat.html.user.color2" );
+ //map_mods = new smap<dynmod*,string>(HMAPOCC);
+
+ // pthread_mutex_init( & mut_map_mods , NULL );
+ pthread_mutex_init( & mut_away , NULL );
+ pthread_mutex_init( & mut_b_online , NULL );
+ pthread_mutex_init( & mut_b_fake , NULL );
+ pthread_mutex_init( & mut_b_invisible , NULL );
+ pthread_mutex_init( & mut_b_has_sess , NULL );
+ pthread_mutex_init( & mut_b_is_reg , NULL );
+ pthread_mutex_init( & mut_s_mess , NULL );
+ pthread_mutex_init( & mut_s_pass , NULL );
+ pthread_mutex_init( & mut_p_room , NULL );
+ pthread_mutex_init( & mut_s_col1 , NULL );
+ pthread_mutex_init( & mut_s_col2 , NULL );
+ pthread_mutex_init( & mut_s_email , NULL );
+ pthread_mutex_init( & mut_s_tmpid , NULL );
+ pthread_mutex_init( & mut_i_status , NULL );
+ pthread_mutex_init( & mut_map_changed_data , NULL );
+ pthread_cond_init ( &cond_message, NULL);
+ pthread_mutex_init( &mut_message , NULL);
+ renew_timeout();
}
void
user::clean()
{
-
- // If this user has a session
- if ( get_has_sess() )
- {
+ // If this user has a session
+ if ( get_has_sess() )
+ {
#ifdef DATABASE
// Store all changed data into the mysql table if this user is registered:
if ( b_is_reg )
- wrap::DATA->update_user_data( get_name(), "savechangednick", map_changed_data );
-#endif
-
+ wrap::DATA->update_user_data( get_name(), "savechangednick", map_changed_data );
wrap::SMAN->destroy_session( get_tmpid() );
- // wrap::system_message( SESSION + tool::int2string( wrap::SMAN->get_session_count() ) );
- }
+#endif
+ // wrap::system_message( SESSION + tool::int2string( wrap::SMAN->get_session_count() ) );
+ }
- set_fake( false );
- set_invisible( false );
- set_away( false, "" );
+ set_fake( false );
+ set_invisible( false );
}
string
user::get_colored_name()
{
- return "<font color=\"#" + get_col1() + "\">" + get_name() + "</font>";
+ return "<font color=\"#" + get_col1() + "\">" + get_name() + "</font>";
}
void
-user::get_data( map<string,string> *p_map_data )
+user::get_data( map_string *p_map_data )
{
- string s_req = (*p_map_data)["!get"];
+ string s_req = (*p_map_data)["!get"];
- // get the nick and the color of the user.
- if ( s_req == "nick" )
- (*p_map_data)[get_name()] = get_col1();
+ // get the nick and the color of the user.
+ if ( s_req == "nick" )
+ (*p_map_data)[get_name()] = get_col1();
}
string
user::get_mess( )
{
- pthread_mutex_lock ( &mut_s_mess );
- string s_ret = s_mess;
- s_mess = "";
- pthread_mutex_unlock( &mut_s_mess );
- return s_ret;
+ pthread_mutex_lock ( &mut_s_mess );
+ string s_ret = s_mess;
+ s_mess = "";
+ pthread_mutex_unlock( &mut_s_mess );
+ return s_ret;
}
bool
user::get_online( )
{
- bool b_ret;
- pthread_mutex_lock ( &mut_b_online );
- b_ret = b_online;
- pthread_mutex_unlock( &mut_b_online );
- return b_ret;
+ bool b_ret;
+ pthread_mutex_lock ( &mut_b_online );
+ b_ret = b_online;
+ pthread_mutex_unlock( &mut_b_online );
+ return b_ret;
}
bool
user::get_fake( )
{
- bool b_ret;
- pthread_mutex_lock ( &mut_b_fake );
- b_ret = b_fake;
- pthread_mutex_unlock( &mut_b_fake );
- return b_ret;
+ bool b_ret;
+ pthread_mutex_lock ( &mut_b_fake );
+ b_ret = b_fake;
+ pthread_mutex_unlock( &mut_b_fake );
+ return b_ret;
}
bool
user::get_invisible( )
{
- bool b_ret;
- pthread_mutex_lock ( &mut_b_invisible );
- b_ret = b_invisible;
- pthread_mutex_unlock( &mut_b_invisible );
- return b_ret;
+ bool b_ret;
+ pthread_mutex_lock ( &mut_b_invisible );
+ b_ret = b_invisible;
+ pthread_mutex_unlock( &mut_b_invisible );
+ return b_ret;
}
bool
user::get_has_sess( )
{
- bool b_ret;
- pthread_mutex_lock ( &mut_b_has_sess );
- b_ret = b_has_sess;
- pthread_mutex_unlock( &mut_b_has_sess );
- return b_ret;
+ bool b_ret;
+ pthread_mutex_lock ( &mut_b_has_sess );
+ b_ret = b_has_sess;
+ pthread_mutex_unlock( &mut_b_has_sess );
+ return b_ret;
}
void
user::set_has_sess( bool b_has_sess )
{
- pthread_mutex_lock ( &mut_b_has_sess );
- this->b_has_sess = b_has_sess;
- pthread_mutex_unlock( &mut_b_has_sess );
+ pthread_mutex_lock ( &mut_b_has_sess );
+ this->b_has_sess = b_has_sess;
+ pthread_mutex_unlock( &mut_b_has_sess );
}
bool
user::get_is_reg( )
{
- bool b_ret;
- b_ret = b_is_reg;
- return b_ret;
+ bool b_ret;
+ b_ret = b_is_reg;
+ return b_ret;
}
void
user::set_is_reg( bool b_is_reg )
{
- this -> b_is_reg = b_is_reg;
+ this -> b_is_reg = b_is_reg;
}
void
user::set_online( bool b_online )
{
- pthread_mutex_lock ( &mut_b_online );
- this -> b_online = b_online;
- pthread_mutex_unlock( &mut_b_online );
+ pthread_mutex_lock ( &mut_b_online );
+ this -> b_online = b_online;
+ pthread_mutex_unlock( &mut_b_online );
}
void
user::set_fake( bool b_fake )
{
- pthread_mutex_lock ( &mut_b_fake );
- this -> b_fake = b_fake;
- pthread_mutex_unlock( &mut_b_fake );
+ pthread_mutex_lock ( &mut_b_fake );
+ this -> b_fake = b_fake;
+ pthread_mutex_unlock( &mut_b_fake );
}
void
user::set_invisible( bool b_invisible )
{
- pthread_mutex_lock ( &mut_b_invisible );
- this -> b_invisible = b_invisible;
- pthread_mutex_unlock( &mut_b_invisible );
+ pthread_mutex_lock ( &mut_b_invisible );
+ this -> b_invisible = b_invisible;
+ pthread_mutex_unlock( &mut_b_invisible );
}
bool
user::get_away()
{
- bool b_ret;
- pthread_mutex_lock ( &mut_away );
- b_ret = b_away;
- pthread_mutex_unlock( &mut_away );
- return b_ret;
+ bool b_ret;
+ pthread_mutex_lock ( &mut_away );
+ b_ret = b_away;
+ pthread_mutex_unlock( &mut_away );
+ return b_ret;
}
string
user::get_away_msg()
{
- string s_ret;
- pthread_mutex_lock ( &mut_away );
- s_ret = s_away;
- pthread_mutex_unlock( &mut_away );
- return s_ret;
+ string s_ret;
+ pthread_mutex_lock ( &mut_away );
+ s_ret = s_away;
+ pthread_mutex_unlock( &mut_away );
+ return s_ret;
}
void
user::set_away( bool b_away, string s_away )
{
- pthread_mutex_lock ( &mut_away );
- this -> b_away = b_away;
- this -> s_away = s_away;
- pthread_mutex_unlock( &mut_away );
+ pthread_mutex_lock ( &mut_away );
+ this -> b_away = b_away;
+ this -> s_away = s_away;
+ pthread_mutex_unlock( &mut_away );
}
void
user::set_away( bool b_away )
{
- pthread_mutex_lock ( &mut_away );
- this -> b_away = b_away;
- pthread_mutex_unlock( &mut_away );
+ pthread_mutex_lock ( &mut_away );
+ this -> b_away = b_away;
+ pthread_mutex_unlock( &mut_away );
}
room*
user::get_room( )
{
- room* p_return;
- pthread_mutex_lock ( &mut_p_room );
- p_return = p_room;
- pthread_mutex_unlock( &mut_p_room );
- return p_return;
+ room* p_return;
+ pthread_mutex_lock ( &mut_p_room );
+ p_return = p_room;
+ pthread_mutex_unlock( &mut_p_room );
+ return p_return;
}
void
user::set_p_room( room* p_room )
{
- pthread_mutex_lock ( &mut_p_room );
- this -> p_room = p_room;
- pthread_mutex_unlock( &mut_p_room );
+ pthread_mutex_lock ( &mut_p_room );
+ this -> p_room = p_room;
+ pthread_mutex_unlock( &mut_p_room );
}
string
user::get_pass()
{
- string s_ret;
- pthread_mutex_lock ( &mut_s_pass );
- s_ret = s_pass;
- pthread_mutex_unlock( &mut_s_pass );
- return s_ret;
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_pass );
+ s_ret = s_pass;
+ pthread_mutex_unlock( &mut_s_pass );
+ return s_ret;
}
string
user::get_col1()
{
- string s_ret;
- pthread_mutex_lock ( &mut_s_col1 );
- s_ret = s_col1;
- pthread_mutex_unlock( &mut_s_col1 );
- return s_ret;
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_col1 );
+ s_ret = s_col1;
+ pthread_mutex_unlock( &mut_s_col1 );
+ return s_ret;
}
string
user::get_col2()
{
- string s_ret;
- pthread_mutex_lock ( &mut_s_col2 );
- s_ret = s_col2;
- pthread_mutex_unlock( &mut_s_col2 );
- return s_ret;
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_col2 );
+ s_ret = s_col2;
+ pthread_mutex_unlock( &mut_s_col2 );
+ return s_ret;
}
string
user::get_email()
{
- string s_ret;
- pthread_mutex_lock ( &mut_s_email );
- s_ret = s_email;
- pthread_mutex_unlock( &mut_s_email );
- return s_ret;
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_email );
+ s_ret = s_email;
+ pthread_mutex_unlock( &mut_s_email );
+ return s_ret;
}
string
user::get_tmpid()
{
- string s_ret;
- pthread_mutex_lock ( &mut_s_tmpid );
- s_ret = s_tmpid;
- pthread_mutex_unlock( &mut_s_tmpid );
- return s_ret;
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_tmpid );
+ s_ret = s_tmpid;
+ pthread_mutex_unlock( &mut_s_tmpid );
+ return s_ret;
}
void
user::set_tmpid ( string s_tmpid )
{
- pthread_mutex_lock ( &mut_s_tmpid );
- this -> s_tmpid = s_tmpid;
- pthread_mutex_unlock( &mut_s_tmpid );
+ pthread_mutex_lock ( &mut_s_tmpid );
+ this -> s_tmpid = s_tmpid;
+ pthread_mutex_unlock( &mut_s_tmpid );
}
void
user::set_pass ( string s_pass )
{
- set_changed_data( "password", s_pass );
- pthread_mutex_lock ( &mut_s_pass );
- this -> s_pass = s_pass;
- pthread_mutex_unlock( &mut_s_pass );
+ set_changed_data( "password", s_pass );
+ pthread_mutex_lock ( &mut_s_pass );
+ this -> s_pass = s_pass;
+ pthread_mutex_unlock( &mut_s_pass );
}
void
user::set_col1 ( string s_col1 )
{
- set_changed_data( "color1", s_col1 );
- pthread_mutex_lock ( &mut_s_col1 );
- this -> s_col1 = s_col1;
- pthread_mutex_unlock( &mut_s_col1 );
+ set_changed_data( "color1", s_col1 );
+ pthread_mutex_lock ( &mut_s_col1 );
+ this -> s_col1 = s_col1;
+ pthread_mutex_unlock( &mut_s_col1 );
}
void
user::set_col2 ( string s_col2 )
{
- set_changed_data( "color2", s_col2 );
- pthread_mutex_lock ( &mut_s_col2 );
- this -> s_col2 = s_col2;
- pthread_mutex_unlock( &mut_s_col2 );
+ set_changed_data( "color2", s_col2 );
+ pthread_mutex_lock ( &mut_s_col2 );
+ this -> s_col2 = s_col2;
+ pthread_mutex_unlock( &mut_s_col2 );
}
void
user::set_email ( string s_email )
{
- set_changed_data( "email", s_email );
- pthread_mutex_lock ( &mut_s_email );
- this -> s_email = s_email;
- pthread_mutex_unlock( &mut_s_email );
+ set_changed_data( "email", s_email );
+ pthread_mutex_lock ( &mut_s_email );
+ this -> s_email = s_email;
+ pthread_mutex_unlock( &mut_s_email );
}
int
user::get_status ( )
{
- int r_ret;
- pthread_mutex_lock ( &mut_i_status );
- r_ret = i_status;
- pthread_mutex_unlock(&mut_i_status );
- return r_ret;
+ int r_ret;
+ pthread_mutex_lock ( &mut_i_status );
+ r_ret = i_status;
+ pthread_mutex_unlock(&mut_i_status );
+ return r_ret;
}
void
user::set_status ( int i_status )
{
- set_changed_data( "status", tool::int2string(i_status));
- pthread_mutex_lock ( &mut_i_status );
- i_old_status = this -> i_status;
- this -> i_status = i_status;
- pthread_mutex_unlock( &mut_i_status );
+ set_changed_data( "status", tool::int2string(i_status));
+ pthread_mutex_lock ( &mut_i_status );
+ i_old_status = this -> i_status;
+ this -> i_status = i_status;
+ pthread_mutex_unlock( &mut_i_status );
}
void
user::set_changed_data( string s_varname, string s_value )
{
- if ( b_set_changed_data )
- {
- pthread_mutex_lock ( &mut_map_changed_data );
- map_changed_data[s_varname] = s_value;
- pthread_mutex_unlock( &mut_map_changed_data );
- }
+ if ( b_set_changed_data )
+ {
+ pthread_mutex_lock ( &mut_map_changed_data );
+ map_changed_data[s_varname] = s_value;
+ pthread_mutex_unlock( &mut_map_changed_data );
+ }
}
bool
user::new_msgs ( )
{
- pthread_mutex_lock ( &mut_s_mess );
- return s_mess.empty();
- pthread_mutex_unlock( &mut_s_mess );
+ pthread_mutex_lock ( &mut_s_mess );
+ return s_mess.empty();
+ pthread_mutex_unlock( &mut_s_mess );
}
void
user::command( string &s_command )
{
- check_restore_away();
-
- unsigned pos = s_command.find( "/" );
- unsigned pos2 = s_command.find( " " );
- if( pos != string::npos )
- {
- s_command.replace( pos, 1, "" );
- }
- else
- return;
-
- if (pos2 == string::npos)
- pos2 = s_command.size() + 1;
-
- string s_mod( wrap::CONF->get_elem("httpd.modules.commandsdir") + "yc_" );
- string s_command2 = s_command.substr(0, pos2-1);
- s_mod.append( s_command2 ).append( ".so" );
-
- dynmod *mod = wrap::MODL->get_module( s_mod );
-
- if ( mod == NULL ||
- wrap::CHAT->get_command_disabled( s_command2 ) ||
- get_status() > wrap::CHAT->get_command_status( s_command2 ) )
- {
- string s_msg = "<font color=\"" + wrap::CONF->get_elem("chat.html.errorcolor") + "\">"
- + wrap::CONF->get_elem( "chat.msgs.err.findingcommand" )
- + "</font>\n";
- msg_post( &s_msg );
- return;
- }
-
- vector<string> params;
-
- // execute the module.
- if (s_command.find(" ") != string::npos)
- {
- s_command = s_command.substr(s_command2.size()+1);
- pos = s_command.find(" ");
- pos2 = 0;
-
- while (pos != string::npos)
+ check_restore_away();
+
+ unsigned pos = s_command.find( "/" );
+ unsigned pos2 = s_command.find( " " );
+ if( pos != string::npos )
{
- string sParam = s_command.substr(pos2, pos - pos2);
- params.push_back(sParam);
- pos2 = pos + 1;
- pos = s_command.find(" ", pos2);
+ s_command.replace( pos, 1, "" );
+ }
+ else
+ return;
+
+ if (pos2 == string::npos)
+ pos2 = s_command.size() + 1;
+
+ string s_mod( wrap::CONF->get_elem("httpd.modules.commandsdir") + "yc_" );
+ string s_command2 = s_command.substr(0, pos2-1);
+ s_mod.append( s_command2 ).append( ".so" );
+
+ dynmod *mod = wrap::MODL->get_module( s_mod );
+
+ if ( mod == NULL ||
+ wrap::CHAT->get_command_disabled( s_command2 ) ||
+ get_status() > wrap::CHAT->get_command_status( s_command2 ) )
+ {
+ string s_msg = "<font color=\"" + wrap::CONF->get_elem("chat.html.errorcolor") + "\">"
+ + wrap::CONF->get_elem( "chat.msgs.err.findingcommand" )
+ + "</font>\n";
+ msg_post( &s_msg );
+ return;
}
- if (pos2 < s_command.size())
+ vector<string> params;
+
+ // execute the module.
+ if (s_command.find(" ") != string::npos)
{
- params.push_back(s_command.substr(pos2, s_command.size()-pos2));
- }
+ s_command = s_command.substr(s_command2.size()+1);
+ pos = s_command.find(" ");
+ pos2 = 0;
+
+ while (pos != string::npos)
+ {
+ string sParam = s_command.substr(pos2, pos - pos2);
+ params.push_back(sParam);
+ pos2 = pos + 1;
+ pos = s_command.find(" ", pos2);
+ }
+
+ if (pos2 < s_command.size())
+ {
+ params.push_back(s_command.substr(pos2, s_command.size()-pos2));
+ }
- }
+ }
- container* c = new container;
- //c->elem[0]=(void*) unreserved
- c->elem[1] = (void*) this;
- c->elem[2] = (void*) &params;
- c->elem[3] = (void*) wrap::WRAP;
+ container* c = new container;
+ //c->elem[0]=(void*) unreserved
+ c->elem[1] = (void*) this;
+ c->elem[2] = (void*) &params;
+ c->elem[3] = (void*) wrap::WRAP;
- ( *(mod->the_func) ) ( (void*) c );
+ ( *(mod->the_func) ) ( (void*) c );
- delete c;
+ delete c;
}
void
user::s_mess_delete( )
{
- pthread_mutex_lock ( &mut_s_mess );
- s_mess = "";
- pthread_mutex_unlock( &mut_s_mess );
+ pthread_mutex_lock ( &mut_s_mess );
+ s_mess = "";
+ pthread_mutex_unlock( &mut_s_mess );
}
void
user::msg_post( string *p_msg )
{
- pthread_mutex_lock ( &mut_s_mess );
- s_mess.append( *p_msg );
- pthread_mutex_unlock( &mut_s_mess );
+ pthread_mutex_lock ( &mut_s_mess );
+ s_mess.append( *p_msg );
+ pthread_mutex_unlock( &mut_s_mess );
- pthread_cond_signal( &cond_message );
+ pthread_cond_signal( &cond_message );
}
void
user::check_timeout( int* i_idle_timeout )
{
- int i_user_timeout = (int) get_last_activity();
-
- if ( get_away() ? i_idle_timeout[1] <= i_user_timeout : i_idle_timeout[0] <= i_user_timeout )
- {
- wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
- string s_quit = "<script language=JavaScript>top.location.href='/"
- + wrap::CONF->get_elem("httpd.startsite")
- + "';</script>";
- msg_post( &s_quit );
- set_online( false );
-
- pthread_cond_signal( &cond_message );
- }
- else if ( ! get_away() && i_idle_timeout[2] <= i_user_timeout )
- {
- wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
- string s_msg = wrap::CONF->get_elem("chat.msgs.userautoawaytimeout");
- set_away( true, s_msg );
- string s_msg2 = wrap::TIMR->get_time() + " <b>" + get_colored_name()+ "</b>" + s_msg + "<br>\n";
- get_room()->msg_post( &s_msg2 );
- get_room()->reload_onlineframe();
- }
+ int i_user_timeout = (int) get_last_activity();
+
+ if ( get_away() ? i_idle_timeout[1] <= i_user_timeout : i_idle_timeout[0] <= i_user_timeout )
+ {
+ wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
+ string s_quit = "<script language=JavaScript>top.location.href='/"
+ + wrap::CONF->get_elem("httpd.startsite")
+ + "';</script>";
+ msg_post( &s_quit );
+ set_online( false );
+ }
+
+ else if ( ! get_away() && i_idle_timeout[2] <= i_user_timeout )
+ {
+ wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
+ string s_msg = wrap::CONF->get_elem("chat.msgs.userautoawaytimeout");
+ set_away( true, s_msg );
+ string s_msg2 = wrap::TIMR->get_time() + " <b>" + get_colored_name()+ "</b>" + s_msg + "<br>\n";
+ get_room()->msg_post( &s_msg2 );
+ get_room()->reload_onlineframe();
+ }
}
void
user::get_user_list( string &s_list )
{
- if ( get_invisible() )
- return;
-
- s_list.append( wrap::CONF->get_elem("chat.html.onlinebefore") );
-
- if ( get_away() )
- {
- s_list.append("<img src=\"" + wrap::CONF->get_elem("chat.html.rangimages.location")+ "away.gif\"" )
- .append( " alt='" )
- .append( get_away_msg() )
- .append( "' title='" )
- .append( get_away_msg() )
- .append( "'" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> " );
- }
- else if ( ! get_is_reg() )
- {
- string s_msgs = wrap::CONF->get_elem("chat.msgs.guest");
- s_list.append("<img src=\"" + wrap::CONF->get_elem("chat.html.rangimages.location")+ "guest.png\"" )
- .append( " alt='" )
- .append( s_msgs )
- .append( "' title='" )
- .append( s_msgs )
- .append( "'" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> " );
- }
- else if ( get_status() != tool::string2int( wrap::CONF->get_elem("chat.defaultrang") ) && ! get_fake() )
- {
- string s_status = "rang" + tool::int2string( get_status() );
- string s_msgs = wrap::CONF->get_elem( "chat.msgs." + s_status );
- s_list.append("<img src=\"" + wrap::CONF->get_elem("chat.html.rangimages.location") + tool::to_lower(s_status) + ".png\"" )
- .append( " alt='" )
- .append( s_msgs )
- .append( "' title='" )
- .append( s_msgs )
- .append( "'" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> " );
- }
- else
- {
- s_list.append("<img src=\"images/blank.gif\"" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> ");
- }
-
- s_list.append( get_colored_name() );
- s_list.append( wrap::CONF->get_elem("chat.html.onlinebehind") );
- s_list.append( "\n" );
+ if ( get_invisible() )
+ return;
+
+ s_list.append( wrap::CONF->get_elem("chat.html.onlinebefore") );
+
+ if ( get_away() )
+ {
+ s_list.append("<img src=\"" + wrap::CONF->get_elem("chat.html.rangimages.location")+ "away.gif\"" )
+ .append( " alt='" )
+ .append( get_away_msg() )
+ .append( "' title='" )
+ .append( get_away_msg() )
+ .append( "'" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> " );
+ }
+ else if ( ! get_is_reg() )
+ {
+ string s_msgs = wrap::CONF->get_elem("chat.msgs.guest");
+ s_list.append("<img src=\"" + wrap::CONF->get_elem("chat.html.rangimages.location")+ "guest.png\"" )
+ .append( " alt='" )
+ .append( s_msgs )
+ .append( "' title='" )
+ .append( s_msgs )
+ .append( "'" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> " );
+ }
+ else if ( get_status() != tool::string2int( wrap::CONF->get_elem("chat.defaultrang") ) && ! get_fake() )
+ {
+ string s_status = "RANG" + tool::int2string( get_status() );
+ string s_msgs = wrap::CONF->get_elem( "chat.msgs." + s_status );
+ s_list.append("<img src=\"" + wrap::CONF->get_elem("chat.html.rangimages.location") + tool::to_lower(s_status) + ".png\"" )
+ .append( " alt='" )
+ .append( s_msgs )
+ .append( "' title='" )
+ .append( s_msgs )
+ .append( "'" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> " );
+ }
+
+ else
+ {
+ s_list.append("<img src=\"images/blank.gif\"" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> ");
+ }
+
+ s_list.append( get_colored_name() );
+ s_list.append( wrap::CONF->get_elem("chat.html.onlinebehind") );
+ s_list.append( "\n" );
}
void
user::check_restore_away()
{
- if ( get_away() )
- {
- get_room()->msg_post(
- new string(
- wrap::TIMR->get_time()
- + " <b>" + get_colored_name()
- + "</b> " + wrap::CONF->get_elem( "chat.msgs.unsetmodeaway" )
- + "( <font color=" + get_col2() + ">"
- + get_away_msg() + "</font>)<br>\n"
- )
- );
- set_away( false );
- get_room()->reload_onlineframe();
- }
+ if ( get_away() )
+ {
+ get_room()->msg_post(
+ new string(
+ wrap::TIMR->get_time()
+ + " <b>" + get_colored_name()
+ + "</b> " + wrap::CONF->get_elem( "chat.msgs.unsetmodeaway" )
+ + "( <font color=" + get_col2() + ">"
+ + get_away_msg() + "</font>)<br>\n"
+ )
+ );
+ set_away( false );
+ get_room()->reload_onlineframe();
+ }
}
void
user::reconf()
-{}
+{
+}
#endif
diff --git a/src/chat/user.h b/src/chat/user.h
index 443eef6..a88aea7 100755
--- a/src/chat/user.h
+++ b/src/chat/user.h
@@ -3,135 +3,132 @@
#ifndef USER_H
#define USER_H
+#include "../maps/smap.h"
#include "../name.h"
#include "../time/timo.h"
-//#include "../memb/memb.h"
class room;
using namespace std;
-class user : public name, public timo//, public memb<string>
+class user : public name, public timo
{
private:
- // private members:
- bool b_online; // true if user is online.
- bool b_has_sess; // true if user already has a session!
- bool b_is_reg; // true if user is registered
- bool b_away; // true if user is away.
- bool b_fake; // true if user hides his status logo (does not work for guest)
- bool b_invisible; // true if user hides his status logo (does not work for guest)
- int i_status; // user's rang ( see enum rang @ globals.h ).
- int i_old_status; // user's previous status.
- string s_tmpid;
- string s_agnt; // user's http user agent.
- string s_away; // user's last away message.
- string s_col1; // user's nick color.
- string s_col2; // user's text color.
- string s_email; // user's email addres
- string s_mess; // message string which has to be sent to the user.
- string s_pass; // password
- room* p_room; // pointer to the user's room.
-
- hashmap<string> map_changed_data; // Needed to tell yChat which data to change after user is removed!
- bool b_set_changed_data; // Only set change data if required!
-
- // Modules which are allowed to be executed by the user.
-
- pthread_mutex_t mut_away;
- pthread_mutex_t mut_b_online;
- pthread_mutex_t mut_b_fake;
- pthread_mutex_t mut_b_invisible;
- pthread_mutex_t mut_b_has_sess;
- pthread_mutex_t mut_b_is_reg;
- pthread_mutex_t mut_s_mess;
- pthread_mutex_t mut_s_pass;
- pthread_mutex_t mut_p_room;
- pthread_mutex_t mut_s_col1;
- pthread_mutex_t mut_s_col2;
- pthread_mutex_t mut_s_email;
- pthread_mutex_t mut_s_tmpid;
- pthread_mutex_t mut_i_status;
- pthread_mutex_t mut_map_changed_data;
-
- void initialize();
- void set_changed_data( string s_varname, string s_value );
-
-public:
- pthread_cond_t cond_message;
- pthread_mutex_t mut_message;
-
- user();
- user(string s_name);
- ~user();
-
- void clean();
-
- // gets specific data of this user und stores it in
- // (*p_map<string,string>)["nick"]. this method will be used
- // every time data has to be got from every user of a room
- // or even of the system.
- void get_data( map<string,string> *p_map_data );
-
- string get_colored_name();
- string get_colored_bold_name()
- {
- return "<b>" + get_colored_name() + "</b>";
- }
- bool get_online();
- bool get_fake();
- bool get_invisible();
- bool get_has_sess();
- bool get_is_reg();
- void set_online( bool b_online );
- void set_fake( bool b_fake );
- void set_invisible( bool b_invisible );
- void set_has_sess( bool b_has_sess );
- void set_is_reg( bool b_is_reg );
- void set_changed_data_on()
- {
- b_set_changed_data = 1;
- }
- bool get_away( );
- string get_away_msg( );
- void set_away( bool b_away, string s_away );
- void set_away( bool b_away );
- room* get_room();
- void set_p_room( room* p_room );
- string get_pass();
- string get_col1();
- string get_col2();
- string get_email();
- string get_tmpid();
- void set_tmpid( string s_tmpid );
- void set_pass( string s_col1 );
- void set_col1( string s_col1 );
- void set_col2( string s_col2 );
- void set_email( string s_email );
- int get_status( );
- void set_status( int i_status );
- bool new_msgs ( );
- void check_timeout( int* i_idle_timeout );
-
- // executes a command.
- void command( string &s_command );
-
- // gets the message and clears s_mess;
- string get_mess();
-
-
- // Here are starting methods which are mainly needed by the data<type> class.
- // appends a string to s_mess including br.
- void msg_post( string s_msg )
- {
- msg_post( &s_msg );
- }
- void msg_post( string *p_msg );
- void s_mess_delete( );
- void get_user_list( string &s_list );
- void check_restore_away();
- void reconf();
+ // private members:
+ bool b_online; // true if user is online.
+ bool b_has_sess; // true if user already has a session!
+ bool b_is_reg; // true if user is registered
+ bool b_away; // true if user is away.
+ bool b_fake; // true if user hides his status logo (does not work for guest)
+ bool b_invisible; // true if user hides his status logo (does not work for guest)
+ int i_status; // user's rang ( see enum rang @ globals.h ).
+ int i_old_status; // user's previous status.
+ string s_tmpid;
+ string s_agnt; // user's http user agent.
+ string s_away; // user's last away message.
+ string s_col1; // user's nick color.
+ string s_col2; // user's text color.
+ string s_email; // user's email addres
+ string s_mess; // message string which has to be sent to the user.
+ string s_pass; // password
+ room* p_room; // pointer to the user's room.
+
+ map_string map_changed_data; // Needed to tell yChat which data to change after user is removed!
+ bool b_set_changed_data; // Only set change data if required!
+
+ // Modules which are allowed to be executed by the user.
+
+ // smap<dynmod*,string>* map_mods;
+
+ // pthread_mutex_t mut_map_mods;
+ pthread_mutex_t mut_away;
+ pthread_mutex_t mut_b_online;
+ pthread_mutex_t mut_b_fake;
+ pthread_mutex_t mut_b_invisible;
+ pthread_mutex_t mut_b_has_sess;
+ pthread_mutex_t mut_b_is_reg;
+ pthread_mutex_t mut_s_mess;
+ pthread_mutex_t mut_s_pass;
+ pthread_mutex_t mut_p_room;
+ pthread_mutex_t mut_s_col1;
+ pthread_mutex_t mut_s_col2;
+ pthread_mutex_t mut_s_email;
+ pthread_mutex_t mut_s_tmpid;
+ pthread_mutex_t mut_i_status;
+ pthread_mutex_t mut_map_changed_data;
+
+ void initialize();
+ void set_changed_data( string s_varname, string s_value );
+
+ public:
+ pthread_cond_t cond_message;
+ pthread_mutex_t mut_message;
+
+ user();
+ user(string s_name);
+ ~user();
+
+ void clean();
+
+ // gets specific data of this user und stores it in
+ // (*p_map_string)["nick"]. this method will be used
+ // every time data has to be got from every user of a room
+ // or even of the system.
+ void get_data( map_string *p_map_data );
+
+ string get_colored_name();
+ string get_colored_bold_name()
+ {
+ return "<b>" + get_colored_name() + "</b>";
+ }
+ bool get_online();
+ bool get_fake();
+ bool get_invisible();
+ bool get_has_sess();
+ bool get_is_reg();
+ void set_online( bool b_online );
+ void set_fake( bool b_fake );
+ void set_invisible( bool b_invisible );
+ void set_has_sess( bool b_has_sess );
+ void set_is_reg( bool b_is_reg );
+ void set_changed_data_on() { b_set_changed_data = 1; }
+ bool get_away( );
+ string get_away_msg( );
+ void set_away( bool b_away, string s_away );
+ void set_away( bool b_away );
+ room* get_room();
+ void set_p_room( room* p_room );
+ string get_pass();
+ string get_col1();
+ string get_col2();
+ string get_email();
+ string get_tmpid();
+ void set_tmpid( string s_tmpid );
+ void set_pass( string s_col1 );
+ void set_col1( string s_col1 );
+ void set_col2( string s_col2 );
+ void set_email( string s_email );
+ int get_status( );
+ void set_status( int i_status );
+ bool new_msgs ( );
+ void check_timeout( int* i_idle_timeout );
+
+ // executes a command.
+ void command( string &s_command );
+
+ // gets the message and clears s_mess;
+ string get_mess();
+
+
+ // Here are starting methods which are mainly needed by the data<type> class.
+ // appends a string to s_mess including br.
+ void msg_post( string s_msg ) { msg_post( &s_msg ); }
+ void msg_post( string *p_msg );
+ void s_mess_delete( );
+ void get_user_list( string &s_list );
+ void check_restore_away();
+ void reconf();
};
#endif
diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp
index f35f77c..2b110db 100755
--- a/src/cli/cli.cpp
+++ b/src/cli/cli.cpp
@@ -33,18 +33,18 @@ cli::parse_input( string s_input )
cout << CLIPRMO << " (d)ebug - Starts debug routine (cli.cpp)" << endl;
#endif
cout << CLIPRMO << " (e)cho VAR - Prints out configuration value of VAR" << endl
- << CLIPRMO << " Wildcards can be used too, example: echo HTML*" << endl
- << CLIPRMO << " (h)elp - Prints out this help!" << endl
- << CLIPRMO << " (m)ysql - Runs MySQL client on yhttpd DB" << endl;
+ << CLIPRMO << " Wildcards can be used too, example: echo http*" << endl;
#ifdef NCURSES
- cout << CLIPRMO << " (q)uit - Quits CLI mode and respawns ncurses mode" << endl;
+ cout << CLIPRMO << " (ex)it - Quits CLI mode and respawns ncurses mode" << endl;
#endif
+ cout << CLIPRMO << " (h)elp - Prints out this help!" << endl
+ << CLIPRMO << " (m)ysql - Runs MySQL client on yChat DB" << endl;
cout << CLIPRMO << " (rel)oad - Reloads all modules" << endl;
#ifdef EXPERIM
cout << CLIPRMO << " (re)conf - Reloads configuration (EXPERIMENTAL)" << endl;
#endif
cout << CLIPRMO << " (r)usage - Shows current resource usage" << endl
- << CLIPRMO << " (ru)sageh - Shows resource usage history (yhttpd needs to run > 1 day)" << endl
+ << CLIPRMO << " (ru)sageh - Shows resource usage history (yChat needs to run > 1 day)" << endl
<< CLIPRMO << " (set) VAR VAL - Sets configuration value VAR to VAL" << endl
<< CLIPRMO << " (sh)ell - Runs a system shell" << endl
<< CLIPRMO << " (s)hutdown - Shuts down the whole server" << endl
@@ -98,7 +98,7 @@ cli::parse_input( string s_input )
cout << CLIPRMI;
}
#ifdef NCURSES
- else if( s_input.compare("quit") == 0 || s_input.compare("q") == 0 )
+ else if( s_input.compare("exit") == 0 || s_input.compare("ex") == 0 )
{
return 0;
}
@@ -112,7 +112,7 @@ cli::parse_input( string s_input )
#ifdef EXPERIM
else if( s_input.compare("reconf") == 0 || s_input.compare("re") == 0 )
{
- wrap::HTTPD->reconf();
+ wrap::CHAT->reconf();
cout << CLIPRMI;
}
#endif
@@ -188,7 +188,7 @@ cli::parse_input( string s_input )
}
else if( s_input.compare("v") == 0 || s_input.compare("version") == 0 )
{
- cout << CLIPRMO << tool::yhttpd_version() << " " << UNAME << endl;
+ cout << CLIPRMO << tool::ychat_version() << " " << UNAME << endl;
cout << CLIPRMI;
}
else
diff --git a/src/conf/conf.cpp b/src/conf/conf.cpp
index 99347e9..67849ef 100755
--- a/src/conf/conf.cpp
+++ b/src/conf/conf.cpp
@@ -12,7 +12,7 @@ conf::conf( string s_conf, map<string,string>* p_start_params ) : nmap<string,st
{
string s_check[] = {
get_name(),
- string(getenv("HOME"))+string("/.yhttpd/") + get_name(),
+ string(getenv("HOME"))+string("/.ychat/") + get_name(),
string("./etc/") + get_name(),
string("/etc/") + get_name(),
string(PREFIX+string("etc/")+get_name()) };
@@ -56,9 +56,9 @@ conf::conf( string s_conf, map<string,string>* p_start_params ) : nmap<string,st
vector<string> vec_string;
parse_xml(p_xml, &vec_string);
- nmap<string,string>::add_elem_insecure(tool::yhttpd_version(), "yhttpd.version");
+ nmap<string,string>::add_elem_insecure(tool::ychat_version(), "ychat.version");
- // Overrides yhttpd.conf values with command line options (yhttpd -o key1 value1 -o key2 value2 ...)
+ // Overrides ychat.conf values with command line options (ychat -o key1 value1 -o key2 value2 ...)
map<string,string>::iterator iter;
for ( iter = p_start_params->begin(); iter != p_start_params->end(); iter++ )
{
@@ -152,4 +152,12 @@ conf::exit_if_xml_error() const
}
}
+//<<*
+string
+conf::colored_error_msg(string s_key)
+{
+ return "<font color=\"#" + nmap<string,string>::get_elem("chat.html.errorcolor") + "\">" + nmap<string,string>::get_elem(s_key) + "</font><br>\n";
+}
+//*>>
+
#endif
diff --git a/src/conf/conf.h b/src/conf/conf.h
index 7508872..7ff69ac 100755
--- a/src/conf/conf.h
+++ b/src/conf/conf.h
@@ -19,9 +19,10 @@ private:
void exit_if_xml_error() const;
void parse_xml( TiXmlNode* p_node, vector<string>* p_vec);
public:
- //conf ( string s_conf );
conf ( string s_conf, map<string,string>* p_start_params );
~conf();
+
+ string colored_error_msg( string s_key ); //<<
};
#endif
diff --git a/src/configure b/src/configure
index c68183c..c53d0de 100755
--- a/src/configure
+++ b/src/configure
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# The yhttpd Project (2003 - 2004)
+# The yChat Project (2003 - 2004)
#
if ! which perl >/dev/null
@@ -26,12 +26,14 @@ perl -e '
my @headers = (
"dlfcn.h",
"pthread.h",
+ "mysql/mysql.h", #//<< Not needed for yhttpd
"netinet/in.h",
"time.h",
"ncurses.h"
);
my @libs = (
+ "libmysqlclient.so", #//<< Not needed for yhttpd
"libncurses.so"
);
@@ -89,14 +91,14 @@ perl -e '
"/opt/local/lib"
);
- if ( defined $ENV{YHTTPDHEADERPATHS} ) {
+ if ( defined $ENV{YCHATHEADERPATHS} ) {
map { print "Adding $_...\n";
- unshift @headerpaths, $_ } split /:/, $ENV{YHTTPDHEADERPATHS};
+ unshift @headerpaths, $_ } split /:/, $ENV{YCHATHEADERPATHS};
}
- if ( defined $ENV{YHTTPDLIBPATHS} ) {
+ if ( defined $ENV{YCHATLIBPATHS} ) {
map { print "Adding $_...\n";
- unshift @libpaths, $_ } split /:/, $ENV{YHTTPDLIBPATHS};
+ unshift @libpaths, $_ } split /:/, $ENV{YCHATLIBPATHS};
}
sub check {
@@ -138,8 +140,8 @@ perl -e '
print "NOT OK\n";
print "Please make sure that you have the needed software installed!\n";
print "If you have a special path for your includes then edit src/configure!\n";
- print "Or set the environment variables YHTTPDHEADERPATHS and YHTTPDLIBPATHS.\n";
- print " Example: setenv YHTTPDHEADERPATHS \"/your/header/includes:/a/includes\"\n";
+ print "Or set the environment variables YCHATHEADERPATHS and YCHATLIBPATHS.\n";
+ print " Example: setenv YCHATHEADERPATHS \"/your/header/includes:/a/includes\"\n";
print "(The environment variables have to be seperated by an :)\n";
exit(1);
}
@@ -188,14 +190,16 @@ perl -e '
my $compiler = `tail -n 1 ../g++.version`;
my $version = `tail -n 2 ../g++.version | head -n 1`;
my $uname = `uname -srm`;
+ my $compopt = join "; ", split /\n/, `cat ../g++.version`;
chomp $uname;
+ chomp $compopt;
print "Configuring for $uname...\n";
chomp $cpp;
chomp $version;
while (<Fin>) {
s/^(CC=).*\n/$1$compiler/;
s/^(SRCS=).*/$1$cpp/;
- s/ -frepo// unless $version =~ /3\.4/;
+ s/ -frepo//; # unless $version =~ /3\.4/;
if ( $uname !~ /Linux/i ) {
print "Disabling -ldl flag...\n" if s/ -ldl//;
}
@@ -230,6 +234,7 @@ perl -e '
open F, ">msgs.h" or die "msgs.h: $!\n";
foreach (@msgs) {
s/(UNAME)(.+)$/UNAME "$uname"/;
+ s/(COMPOPT)(.+)$/COMPOPT "$compopt"/;
print F;
}
close F;
@@ -237,7 +242,9 @@ perl -e '
if ( -d "mods" ) {
chdir("mods");
my $cflags = "-fno-inline -fno-default-inline";
- $cflags .= " -nostdlib" if $uname !~ /Linux/i;
+ $cflags .= " -nostdlib"
+ if $uname =~ /FreeBSD/i
+ && `uname -r` =~ /^4\./;
system("echo $cflags > cflags.add");
system("./configure");
chdir("..");
diff --git a/src/contrib/README b/src/contrib/README
index 105f25d..873f114 100644
--- a/src/contrib/README
+++ b/src/contrib/README
@@ -1,5 +1,5 @@
-This directory includes source code which has been included directly into yhttpd but is not
-programmed by the yhttpd project explicitly which means the source code here is from extern.
+This directory includes source code which has been included directly into yChat but is not
+programmed by the yChat project explicitly which means the source code here is from extern.
Used versions:
tinyxml 2.3.2
diff --git a/src/contrib/crypt/md5.cpp b/src/contrib/crypt/md5.cpp
index 9dd1f08..7023956 100644
--- a/src/contrib/crypt/md5.cpp
+++ b/src/contrib/crypt/md5.cpp
@@ -18,8 +18,7 @@
#include <string.h> /* for memcpy() */
#include "md5.h"
-namespace md5
-{
+namespace md5 {
#ifndef HIGHFIRST
#define byteReverse(buf, len) /* Nothing */
@@ -28,20 +27,18 @@ void byteReverse(unsigned char *buf, unsigned longs);
#ifndef ASM_MD5
/*
-* Note: this code is harmless on little-endian machines.
-*/
+ * Note: this code is harmless on little-endian machines.
+ */
void
byteReverse(unsigned char *buf, unsigned longs)
{
- uint32 t;
- do
- {
- t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
- ((unsigned) buf[1] << 8 | buf[0]);
- *(uint32 *) buf = t;
- buf += 4;
- }
- while (--longs);
+ uint32 t;
+ do {
+ t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+ ((unsigned) buf[1] << 8 | buf[0]);
+ *(uint32 *) buf = t;
+ buf += 4;
+ } while (--longs);
}
#endif
#endif
@@ -53,13 +50,13 @@ byteReverse(unsigned char *buf, unsigned longs)
void
MD5Init(struct MD5Context *ctx)
{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
}
/*
@@ -69,49 +66,46 @@ MD5Init(struct MD5Context *ctx)
void
MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
{
- uint32 t;
+ uint32 t;
- /* Update bitcount */
+ /* Update bitcount */
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
- ctx->bits[1]++; /* Carry from low to high */
- ctx->bits[1] += len >> 29;
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
+ ctx->bits[1]++; /* Carry from low to high */
+ ctx->bits[1] += len >> 29;
- t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
- /* Handle any leading odd-sized chunks */
+ /* Handle any leading odd-sized chunks */
- if (t)
- {
- unsigned char *p = (unsigned char *) ctx->in + t;
+ if (t) {
+ unsigned char *p = (unsigned char *) ctx->in + t;
- t = 64 - t;
- if (len < t)
- {
- memcpy(p, buf, len);
- return;
+ t = 64 - t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+ buf += t;
+ len -= t;
+ }
+ /* Process data in 64-byte chunks */
+
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+ buf += 64;
+ len -= 64;
}
- memcpy(p, buf, t);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *) ctx->in);
- buf += t;
- len -= t;
- }
- /* Process data in 64-byte chunks */
-
- while (len >= 64)
- {
- memcpy(ctx->in, buf, 64);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *) ctx->in);
- buf += 64;
- len -= 64;
- }
- /* Handle any remaining bytes of data. */
+ /* Handle any remaining bytes of data. */
- memcpy(ctx->in, buf, len);
+ memcpy(ctx->in, buf, len);
}
/*
@@ -121,46 +115,43 @@ MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
void
MD5Final(unsigned char digest[16], struct MD5Context *ctx)
{
- unsigned count;
- unsigned char *p;
-
- /* Compute number of bytes mod 64 */
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- /* Set the first char of padding to 0x80. This is safe since there is
- always at least one byte free */
- p = ctx->in + count;
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 64 bytes */
- count = 64 - 1 - count;
-
- /* Pad out to 56 mod 64 */
- if (count < 8)
- {
- /* Two lots of padding: Pad the first block to 64 bytes */
- memset(p, 0, count);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32 *) ctx->in);
+ unsigned count;
+ unsigned char *p;
+
+ /* Compute number of bytes mod 64 */
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ /* Set the first char of padding to 0x80. This is safe since there is
+ always at least one byte free */
+ p = ctx->in + count;
+ *p++ = 0x80;
+
+ /* Bytes of padding needed to make 64 bytes */
+ count = 64 - 1 - count;
+
+ /* Pad out to 56 mod 64 */
+ if (count < 8) {
+ /* Two lots of padding: Pad the first block to 64 bytes */
+ memset(p, 0, count);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+
+ /* Now fill the next block with 56 bytes */
+ memset(ctx->in, 0, 56);
+ } else {
+ /* Pad block to 56 bytes */
+ memset(p, 0, count - 8);
+ }
+ byteReverse(ctx->in, 14);
- /* Now fill the next block with 56 bytes */
- memset(ctx->in, 0, 56);
- }
- else
- {
- /* Pad block to 56 bytes */
- memset(p, 0, count - 8);
- }
- byteReverse(ctx->in, 14);
-
- /* Append length in bits and transform */
- ((uint32 *) ctx->in)[14] = ctx->bits[0];
- ((uint32 *) ctx->in)[15] = ctx->bits[1];
-
- MD5Transform(ctx->buf, (uint32 *) ctx->in);
- byteReverse((unsigned char *) ctx->buf, 4);
- memcpy(digest, ctx->buf, 16);
- memset((char *) ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+ /* Append length in bits and transform */
+ ((uint32 *) ctx->in)[14] = ctx->bits[0];
+ ((uint32 *) ctx->in)[15] = ctx->bits[1];
+
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+ byteReverse((unsigned char *) ctx->buf, 4);
+ memcpy(digest, ctx->buf, 16);
+ memset((char *) ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5
@@ -185,85 +176,85 @@ MD5Final(unsigned char digest[16], struct MD5Context *ctx)
void
MD5Transform(uint32 buf[4], uint32 const in[16])
{
- register uint32 a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
+ register uint32 a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
}
#endif
diff --git a/src/contrib/crypt/md5.h b/src/contrib/crypt/md5.h
index 19c782c..0b9d532 100644
--- a/src/contrib/crypt/md5.h
+++ b/src/contrib/crypt/md5.h
@@ -1,25 +1,22 @@
#ifndef MD5_H
#define MD5_H
-namespace md5
-{
+namespace md5 {
#ifdef __alpha
typedef unsigned int uint32;
#else
-
typedef unsigned long uint32;
#endif
-struct MD5Context
-{
- uint32 buf[4];
- uint32 bits[2];
- unsigned char in[64];
+struct MD5Context {
+ uint32 buf[4];
+ uint32 bits[2];
+ unsigned char in[64];
};
void MD5Init(struct MD5Context *context);
void MD5Update(struct MD5Context *context, unsigned char const *buf,
- unsigned len);
+ unsigned len);
void MD5Final(unsigned char digest[16], struct MD5Context *context);
void MD5Transform(uint32 buf[4], uint32 const in[16]);
diff --git a/src/contrib/crypt/md5crypt.cpp b/src/contrib/crypt/md5crypt.cpp
index 8fb49a7..16b0235 100644
--- a/src/contrib/crypt/md5crypt.cpp
+++ b/src/contrib/crypt/md5crypt.cpp
@@ -16,20 +16,18 @@
#include <string.h>
#include "md5.h"
-namespace md5
-{
+namespace md5 {
static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
- "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static void
to64(char *s, unsigned long v, int n)
{
- while (--n >= 0)
- {
- *s++ = itoa64[v&0x3f];
- v >>= 6;
- }
+ while (--n >= 0) {
+ *s++ = itoa64[v&0x3f];
+ v >>= 6;
+ }
}
/*
@@ -41,122 +39,109 @@ to64(char *s, unsigned long v, int n)
char *
MD5Crypt(const char *pw, const char *salt)
{
- static char *magic = "$1$"; /*
- * This string is magic for
- * this algorithm. Having
- * it this way, we can get
- * get better later on
- */
- static char passwd[120], *p;
- static const char *sp,*ep;
- unsigned char final[16];
- int sl,pl,i,j;
- MD5_CTX ctx,ctx1;
- unsigned long l;
-
- /* Refine the Salt first */
- sp = salt;
-
- /* If it starts with the magic string, then skip that */
- if(!strncmp(sp,magic,strlen(magic)))
- sp += strlen(magic);
-
- /* It stops at the first '$', max 8 chars */
- for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
- continue;
-
- /* get the length of the true salt */
- sl = ep - sp;
-
- MD5Init(&ctx);
-
- /* The password first, since that is what is most unknown */
- MD5Update(&ctx,(const unsigned char*)pw,strlen(pw));
-
- /* Then our magic string */
- MD5Update(&ctx,(const unsigned char*)magic,strlen(magic));
-
- /* Then the raw salt */
- MD5Update(&ctx,(const unsigned char*)sp,sl);
-
- /* Then just as many characters of the MD5(pw,salt,pw) */
- MD5Init(&ctx1);
- MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
- MD5Update(&ctx1,(const unsigned char*)sp,sl);
- MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
- MD5Final(final,&ctx1);
- for(pl = strlen(pw); pl > 0; pl -= 16)
- MD5Update(&ctx,final,pl>16 ? 16 : pl);
-
- /* Don't leave anything around in vm they could use. */
- memset(final,0,sizeof final);
-
- /* Then something really weird... */
- for (j=0,i = strlen(pw); i ; i >>= 1)
- if(i&1)
- MD5Update(&ctx, final+j, 1);
- else
- MD5Update(&ctx, (const unsigned char*)pw+j, 1);
-
- /* Now make the output string */
- strcpy(passwd,magic);
- strncat(passwd,sp,sl);
- strcat(passwd,"$");
-
- MD5Final(final,&ctx);
-
- /*
- * and now, just to make sure things don't run too fast
- * On a 60 Mhz Pentium this takes 34 msec, so you would
- * need 30 seconds to build a 1000 entry dictionary...
- */
- for(i=0;i<1000;i++)
- {
- MD5Init(&ctx1);
- if(i & 1)
- MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
- else
- MD5Update(&ctx1,final,16);
-
- if(i % 3)
- MD5Update(&ctx1,(const unsigned char*)sp,sl);
-
- if(i % 7)
- MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
-
- if(i & 1)
- MD5Update(&ctx1,final,16);
- else
- MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
- MD5Final(final,&ctx1);
- }
-
- p = passwd + strlen(passwd);
-
- l = (final[ 0]<<16) | (final[ 6]<<8) | final[12];
- to64(p,l,4);
- p += 4;
- l = (final[ 1]<<16) | (final[ 7]<<8) | final[13];
- to64(p,l,4);
- p += 4;
- l = (final[ 2]<<16) | (final[ 8]<<8) | final[14];
- to64(p,l,4);
- p += 4;
- l = (final[ 3]<<16) | (final[ 9]<<8) | final[15];
- to64(p,l,4);
- p += 4;
- l = (final[ 4]<<16) | (final[10]<<8) | final[ 5];
- to64(p,l,4);
- p += 4;
- l = final[11] ;
- to64(p,l,2);
- p += 2;
- *p = '\0';
-
- /* Don't leave anything around in vm they could use. */
- memset(final,0,sizeof final);
-
- return passwd;
+ static char *magic = "$1$"; /*
+ * This string is magic for
+ * this algorithm. Having
+ * it this way, we can get
+ * get better later on
+ */
+ static char passwd[120], *p;
+ static const char *sp,*ep;
+ unsigned char final[16];
+ int sl,pl,i,j;
+ MD5_CTX ctx,ctx1;
+ unsigned long l;
+
+ /* Refine the Salt first */
+ sp = salt;
+
+ /* If it starts with the magic string, then skip that */
+ if(!strncmp(sp,magic,strlen(magic)))
+ sp += strlen(magic);
+
+ /* It stops at the first '$', max 8 chars */
+ for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
+ continue;
+
+ /* get the length of the true salt */
+ sl = ep - sp;
+
+ MD5Init(&ctx);
+
+ /* The password first, since that is what is most unknown */
+ MD5Update(&ctx,(const unsigned char*)pw,strlen(pw));
+
+ /* Then our magic string */
+ MD5Update(&ctx,(const unsigned char*)magic,strlen(magic));
+
+ /* Then the raw salt */
+ MD5Update(&ctx,(const unsigned char*)sp,sl);
+
+ /* Then just as many characters of the MD5(pw,salt,pw) */
+ MD5Init(&ctx1);
+ MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
+ MD5Update(&ctx1,(const unsigned char*)sp,sl);
+ MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
+ MD5Final(final,&ctx1);
+ for(pl = strlen(pw); pl > 0; pl -= 16)
+ MD5Update(&ctx,final,pl>16 ? 16 : pl);
+
+ /* Don't leave anything around in vm they could use. */
+ memset(final,0,sizeof final);
+
+ /* Then something really weird... */
+ for (j=0,i = strlen(pw); i ; i >>= 1)
+ if(i&1)
+ MD5Update(&ctx, final+j, 1);
+ else
+ MD5Update(&ctx, (const unsigned char*)pw+j, 1);
+
+ /* Now make the output string */
+ strcpy(passwd,magic);
+ strncat(passwd,sp,sl);
+ strcat(passwd,"$");
+
+ MD5Final(final,&ctx);
+
+ /*
+ * and now, just to make sure things don't run too fast
+ * On a 60 Mhz Pentium this takes 34 msec, so you would
+ * need 30 seconds to build a 1000 entry dictionary...
+ */
+ for(i=0;i<1000;i++) {
+ MD5Init(&ctx1);
+ if(i & 1)
+ MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
+ else
+ MD5Update(&ctx1,final,16);
+
+ if(i % 3)
+ MD5Update(&ctx1,(const unsigned char*)sp,sl);
+
+ if(i % 7)
+ MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
+
+ if(i & 1)
+ MD5Update(&ctx1,final,16);
+ else
+ MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
+ MD5Final(final,&ctx1);
+ }
+
+ p = passwd + strlen(passwd);
+
+ l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; to64(p,l,4); p += 4;
+ l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; to64(p,l,4); p += 4;
+ l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; to64(p,l,4); p += 4;
+ l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; to64(p,l,4); p += 4;
+ l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; to64(p,l,4); p += 4;
+ l = final[11] ; to64(p,l,2); p += 2;
+ *p = '\0';
+
+ /* Don't leave anything around in vm they could use. */
+ memset(final,0,sizeof final);
+
+ return passwd;
}
}
diff --git a/src/contrib/xml/README b/src/contrib/xml/README
index 7da9dfd..c03aaad 100644
--- a/src/contrib/xml/README
+++ b/src/contrib/xml/README
@@ -1,7 +1,7 @@
ATTENTION:
This version of TinyXML has ben very little modified by
-Paul C. Buetow in 2004 to fit the yhttpd project.
+Paul C. Buetow in 2004 to fit the yChat project.
To get the original source go to
http://www.sourceforge.net/projects/tinyxml
diff --git a/src/data/con.cpp b/src/data/con.cpp
index b3aebcc..b381232 100755
--- a/src/data/con.cpp
+++ b/src/data/con.cpp
@@ -8,36 +8,36 @@ using namespace std;
con::con()
{
- p_mysql = mysql_init(NULL);
+ p_mysql = mysql_init(NULL);
- while ( !p_mysql )
- {
- wrap::system_message( MYSQLE1 );
- usleep( 30000000 );
- mysql_init(p_mysql);
- }
+ while ( !p_mysql )
+ {
+ wrap::system_message( MYSQLE1 );
+ usleep( 30000000 );
+ mysql_init(p_mysql);
+ }
- while ( mysql_real_connect(
- p_mysql,
- (const char*)wrap::CONF->get_elem("chat.database.serverhost").c_str(),
- (const char*)wrap::CONF->get_elem("chat.database.user").c_str(),
- (const char*)wrap::CONF->get_elem("chat.database.password").c_str(),
- (const char*)wrap::CONF->get_elem("chat.database.dbname").c_str(),
- tool::string2int(wrap::CONF->get_elem("chat.database.port")),
- NULL, 0 ) == NULL )
- {
- wrap::system_message( MYSQLQU + string( mysql_error(p_mysql) ) );
- usleep( 30000000 );
- }
+ while ( mysql_real_connect(
+ p_mysql,
+ (const char*)wrap::CONF->get_elem("chat.database.serverhost").c_str(),
+ (const char*)wrap::CONF->get_elem("chat.database.user").c_str(),
+ (const char*)wrap::CONF->get_elem("chat.database.password").c_str(),
+ (const char*)wrap::CONF->get_elem("chat.database.dbname").c_str(),
+ tool::string2int(wrap::CONF->get_elem("chat.database.port")),
+ NULL, 0 ) == NULL )
+ {
+ wrap::system_message( MYSQLQU + string( mysql_error(p_mysql) ) );
+ usleep( 30000000 );
+ }
}
con::~con()
{
- if ( p_mysql )
- {
- if (mysql_ping( p_mysql ) != 0)
- mysql_close( p_mysql );
- }
+ if ( p_mysql )
+ {
+ if (mysql_ping( p_mysql ) != 0)
+ mysql_close( p_mysql );
+ }
}
#endif
diff --git a/src/data/con.h b/src/data/con.h
index 9fda07b..bc54341 100755
--- a/src/data/con.h
+++ b/src/data/con.h
@@ -4,7 +4,7 @@
#ifndef CON_H
#define CON_H
-#include <mysql/mysql.h>
+#include <mysql/mysql.h>
#include <iostream>
#include "con_base.h"
@@ -13,9 +13,9 @@ using namespace std;
class con : public con_base
{
public:
- MYSQL* p_mysql;
- con( );
- ~con( );
+ MYSQL* p_mysql;
+ con( );
+ ~con( );
};
#endif
diff --git a/src/data/con_base.cpp b/src/data/con_base.cpp
index 003a376..24bbbc9 100755
--- a/src/data/con_base.cpp
+++ b/src/data/con_base.cpp
@@ -8,11 +8,12 @@ using namespace std;
con_base::con_base()
{
- renew_timeout( );
+ renew_timeout( );
}
con_base::~con_base()
-{}
+{
+}
#endif
diff --git a/src/data/con_base.h b/src/data/con_base.h
index 9ebb89e..60b12c2 100755
--- a/src/data/con_base.h
+++ b/src/data/con_base.h
@@ -11,8 +11,8 @@ using namespace std;
class con_base : public timo
{
public:
- con_base( );
- ~con_base( );
+ con_base( );
+ ~con_base( );
};
#endif
diff --git a/src/data/data.cpp b/src/data/data.cpp
index fe994ea..e8f309c 100644
--- a/src/data/data.cpp
+++ b/src/data/data.cpp
@@ -7,196 +7,194 @@
using namespace std;
data::data()
-{}
+{
+}
data::~data()
-{}
+{
+}
-hashmap<string>
+map_string
data::select_user_data( string s_user, string s_query)
{
- string s_where_rule = " WHERE nick = \"" + s_user + "\"";
- vector<string> vec_elements;
- MYSQL_RES* p_result = select_query( s_query, s_where_rule, vec_elements );
- return parse_result( p_result, vec_elements );
+ string s_where_rule = " WHERE nick = \"" + s_user + "\"";
+ vector<string> vec_elements;
+ MYSQL_RES* p_result = select_query( s_query, s_where_rule, vec_elements );
+ return parse_result( p_result, vec_elements );
}
-MYSQL_RES*
+MYSQL_RES*
data::select_query( string s_query, string s_where_rule, vector<string>& vec_elements )
{
- con* p_con = get_con();
+ con* p_con = get_con();
- vec_elements = map_queries[s_query];
- string s_mysql_query = "SELECT ";
- vector<string>::iterator iter = vec_elements.begin();
+ vec_elements = map_queries[s_query];
+ string s_mysql_query = "SELECT ";
+ vector<string>::iterator iter = vec_elements.begin();
- string s_table = *iter;
- iter++;
+ string s_table = *iter; iter++;
- while ( iter != vec_elements.end() )
- {
- s_mysql_query.append( secure_query(*iter) );
- if ( ++iter != vec_elements.end() )
- s_mysql_query.append( ", " );
- }
+ while ( iter != vec_elements.end() )
+ {
+ s_mysql_query.append( secure_query(*iter) );
+ if ( ++iter != vec_elements.end() )
+ s_mysql_query.append( ", " );
+ }
- s_mysql_query.append(" FROM " + s_table + s_where_rule );
- print_query( MYSQLQU + s_mysql_query );
+ s_mysql_query.append(" FROM " + s_table + s_where_rule );
+ print_query( MYSQLQU + s_mysql_query );
- MYSQL_RES* p_result = NULL;
+ MYSQL_RES* p_result = NULL;
- if ( 0 == mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
- {
- p_result = mysql_store_result( p_con->p_mysql );
- push_con( p_con );
- }
- else
- {
- wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
- if (p_con != NULL)
- delete p_con;
- }
+ if ( 0 == mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
+ {
+ p_result = mysql_store_result( p_con->p_mysql );
+ push_con( p_con );
+ }
+
+ else
+ {
+ wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
+ if (p_con != NULL)
+ delete p_con;
+ }
- return p_result;
+ return p_result;
}
-hashmap<string>
+map_string
data::parse_result( MYSQL_RES* p_result, vector<string>& vec_elements )
{
- hashmap<string> map_ret;
- if ( p_result != NULL )
- {
- MYSQL_ROW row;
- vector<string>::iterator vec_iter = vec_elements.begin();
- vec_iter++;
-
- while( (row = mysql_fetch_row(p_result)) )
- for ( int i=0; i < mysql_num_fields(p_result); i++, vec_iter++ )
- map_ret[*vec_iter] = string(row[i]);
-
- mysql_free_result( p_result );
- }
- return map_ret;
+ map_string map_ret;
+ if ( p_result != NULL )
+ {
+ MYSQL_ROW row;
+ vector<string>::iterator vec_iter = vec_elements.begin(); vec_iter++;
+
+ while( (row = mysql_fetch_row(p_result)) )
+ for ( int i=0; i < mysql_num_fields(p_result); i++, vec_iter++ )
+ map_ret[*vec_iter] = string(row[i]);
+
+ mysql_free_result( p_result );
+ }
+ return map_ret;
}
void
-data::insert_user_data( string s_user, string s_query, hashmap<string> insert_map )
+data::insert_user_data( string s_user, string s_query, map_string insert_map )
{
- insert_query( s_query, insert_map );
+ insert_query( s_query, insert_map );
}
void
-data::insert_query( string s_query, hashmap<string> map_insert )
+data::insert_query( string s_query, map_string map_insert )
{
- vector<string> vec_elements = map_queries[s_query];
- vector<string>::iterator iter = vec_elements.begin();
-
- string s_table = *iter;
- iter++;
- string s_mysql_query = "INSERT INTO " + s_table + " (";
-
- while ( iter != vec_elements.end() )
- {
- s_mysql_query.append( *iter );
-
- if ( ++iter != vec_elements.end() )
- s_mysql_query.append( ", " );
- else
- s_mysql_query.append( ") VALUES(" );
- }
+ vector<string> vec_elements = map_queries[s_query];
+ vector<string>::iterator iter = vec_elements.begin();
+
+ string s_table = *iter; iter++;
+ string s_mysql_query = "INSERT INTO " + s_table + " (";
+
+ while ( iter != vec_elements.end() )
+ {
+ s_mysql_query.append( *iter );
+
+ if ( ++iter != vec_elements.end() )
+ s_mysql_query.append( ", " );
+ else
+ s_mysql_query.append( ") VALUES(" );
+ }
- iter = vec_elements.begin();
- iter++;
+ iter = vec_elements.begin(); iter++;
- while ( iter != vec_elements.end() )
- {
- s_mysql_query.append( "\"" + secure_query(map_insert[*iter]) + "\"" );
- if ( ++iter != vec_elements.end() )
- s_mysql_query.append( ", " );
- else
- s_mysql_query.append( ")" );
- }
+ while ( iter != vec_elements.end() )
+ {
+ s_mysql_query.append( "\"" + secure_query(map_insert[*iter]) + "\"" );
+ if ( ++iter != vec_elements.end() )
+ s_mysql_query.append( ", " );
+ else
+ s_mysql_query.append( ")" );
+ }
- print_query( MYSQLQU + s_mysql_query );
+ print_query( MYSQLQU + s_mysql_query );
- con* p_con = get_con();
+ con* p_con = get_con();
- if ( 0 != mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
- wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
+ if ( 0 != mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
+ wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
- push_con( p_con );
+ push_con( p_con );
- return;
+ return;
}
-void
-data::update_user_data( string s_user, string s_query, hashmap<string> update_map )
+void
+data::update_user_data( string s_user, string s_query, map_string update_map )
{
- vector<string> vec_elements = map_queries[s_query];
+ vector<string> vec_elements = map_queries[s_query];
- if ( vec_elements.size() == 0 )
- return;
+ if ( vec_elements.size() == 0 )
+ return;
- vector<string>::iterator iter = vec_elements.begin();
- vector<string>::iterator iter_second = vec_elements.begin();
- iter_second++;
+ vector<string>::iterator iter = vec_elements.begin();
+ vector<string>::iterator iter_second = vec_elements.begin();
+ iter_second++;
- string s_table = *iter;
- iter++;
- string s_mysql_query = "UPDATE " + s_table + " SET ";
- bool b_flag = 0;
+ string s_table = *iter; iter++;
+ string s_mysql_query = "UPDATE " + s_table + " SET ";
+ bool b_flag = 0;
- while ( iter != vec_elements.end() )
+ while ( iter != vec_elements.end() )
+ {
+ if ( update_map[*iter] == "" ) // Dont update data if it has not been changed / if its empty!
{
- if ( update_map[*iter] == "" ) // Dont update data if it has not been changed / if its empty!
- {
- iter++;
- continue;
- }
+ iter++;
+ continue;
+ }
- if ( iter != iter_second && b_flag )
- s_mysql_query.append( ", " );
+ if ( iter != iter_second && b_flag )
+ s_mysql_query.append( ", " );
- s_mysql_query.append( *iter + "=\"" + secure_query(update_map[*iter]) + "\"" );
- b_flag = 1;
- iter++;
- }
+ s_mysql_query.append( *iter + "=\"" + secure_query(update_map[*iter]) + "\"" );
+ b_flag = 1;
+ iter++;
+ }
- if ( b_flag )
- {
- s_mysql_query.append( " WHERE nick=\"" + tool::to_lower(s_user) + "\"" );
+ if ( b_flag )
+ {
+ s_mysql_query.append( " WHERE nick=\"" + tool::to_lower(s_user) + "\"" );
- con* p_con = get_con();
- print_query( MYSQLQU + s_mysql_query );
+ con* p_con = get_con();
+ print_query( MYSQLQU + s_mysql_query );
- if ( 0 != mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
- wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
+ if ( 0 != mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
+ wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
- push_con( p_con );
- }
+ push_con( p_con );
+ }
}
string
data::secure_query( string s_mysql_query )
{
- // Prevent from MySQL injection attacks (escaping " and \)
- unsigned i_pos = s_mysql_query.find("\\");
+ // Prevent from MySQL injection attacks (escaping " and \)
+ unsigned i_pos = s_mysql_query.find("\\");
- while ( i_pos != string::npos )
- {
- s_mysql_query.replace( i_pos, 1, "/" );
- i_pos = s_mysql_query.find("\\");
- }
+ while ( i_pos != string::npos )
+ {
+ s_mysql_query.replace( i_pos, 1, "/" );
+ i_pos = s_mysql_query.find("\\");
+ }
- i_pos = s_mysql_query.find("\"");
+ i_pos = s_mysql_query.find("\"");
- while ( i_pos != string::npos )
- {
- s_mysql_query.replace( i_pos, 1, "'" );
- i_pos = s_mysql_query.find("\"");
- }
+ while ( i_pos != string::npos )
+ {
+ s_mysql_query.replace( i_pos, 1, "'" );
+ i_pos = s_mysql_query.find("\"");
+ }
- return s_mysql_query;
+ return s_mysql_query;
}
#endif
diff --git a/src/data/data.h b/src/data/data.h
index a9a75f2..fa21763 100644
--- a/src/data/data.h
+++ b/src/data/data.h
@@ -12,17 +12,17 @@ using namespace std;
class data : public data_base // data implementation used in data.h
{
private:
- MYSQL_RES* select_query( string s_query, string s_where_rule, vector<string>& vec_elements );
- hashmap<string> parse_result( MYSQL_RES* p_result, vector<string>& vec_elements );
- void insert_query( string s_query, hashmap<string> map_insert );
- string secure_query( string s_mysql_query );
+ MYSQL_RES* select_query( string s_query, string s_where_rule, vector<string>& vec_elements );
+ map_string parse_result( MYSQL_RES* p_result, vector<string>& vec_elements );
+ void insert_query( string s_query, map_string map_insert );
+ string secure_query( string s_mysql_query );
public:
- data( );
- ~data( );
+ data( );
+ ~data( );
- hashmap<string> select_user_data( string s_user, string s_query );
- void insert_user_data( string s_user, string s_query, hashmap<string> insert_map );
- void update_user_data( string s_user, string s_query, hashmap<string> update_map );
+ map_string select_user_data( string s_user, string s_query );
+ void insert_user_data( string s_user, string s_query, map_string insert_map );
+ void update_user_data( string s_user, string s_query, map_string update_map );
};
#endif
diff --git a/src/data/data_base.cpp b/src/data/data_base.cpp
index 05f4e0a..c8bf033 100644
--- a/src/data/data_base.cpp
+++ b/src/data/data_base.cpp
@@ -8,93 +8,92 @@ using namespace std;
data_base::data_base( )
{
- pthread_mutex_init ( &mut_con, NULL );
+ pthread_mutex_init ( &mut_con, NULL );
- vector<string> vec_keys = *wrap::CONF->get_key_vector();
- vector<string>::iterator iter;
+ vector<string> vec_keys = *wrap::CONF->get_key_vector();
+ vector<string>::iterator iter;
- // Reads all DATA_ elements of conf.txt!
- for ( iter = vec_keys.begin(); iter != vec_keys.end(); iter++ )
+ // Reads all DATA_ elements of conf.txt!
+ for ( iter = vec_keys.begin(); iter != vec_keys.end(); iter++ )
+ {
+ if ( iter->length() > 20
+ && iter->compare(0, 19, "chat.database.mysql") == 0
+ && iter->find(".descr") == string::npos )
{
- if ( iter->length() > 20
- && iter->compare(0, 19, "chat.database.mysql") == 0
- && iter->find(".descr") == string::npos )
+ vector<string> vec_tokens;
+ string s_element = wrap::CONF->get_elem(*iter);
+ unsigned i_pos = 0;
+
+ for ( bool b_find = 1; b_find; )
+ {
+ i_pos = s_element.find_first_of( " ", 0 );
+
+ if ( i_pos != string::npos )
{
- vector<string> vec_tokens;
- string s_element = wrap::CONF->get_elem(*iter);
- unsigned i_pos = 0;
-
- for ( bool b_find = 1; b_find; )
- {
- i_pos = s_element.find_first_of( " ", 0 );
-
- if ( i_pos != string::npos )
- {
- vec_tokens.push_back( s_element.substr(0, i_pos) );
- s_element = s_element.substr( i_pos+1 );
- }
- else
- {
- vec_tokens.push_back( s_element );
- b_find = 0;
- }
- }
-
- string s_mysqlquery = iter->substr(20);
- wrap::system_message(MYSQLQ2 + s_mysqlquery);
- map_queries[s_mysqlquery] = vec_tokens;
+ vec_tokens.push_back( s_element.substr(0, i_pos) );
+ s_element = s_element.substr( i_pos+1 );
}
+
+ else
+ {
+ vec_tokens.push_back( s_element );
+ b_find = 0;
+ }
+ }
+
+ string s_mysqlquery = iter->substr(20);
+ wrap::system_message(MYSQLQ2 + s_mysqlquery);
+ map_queries[s_mysqlquery] = vec_tokens;
}
+ }
}
-void data_base::initialize_connections()
-{
- int i_min_con = tool::string2int( wrap::CONF->get_elem("chat.database.mincon") ),
- i_max_con = tool::string2int( wrap::CONF->get_elem("chat.database.maxcon") );
+void data_base::initialize_connections() {
+ int i_min_con = tool::string2int( wrap::CONF->get_elem("chat.database.mincon") ),
+ i_max_con = tool::string2int( wrap::CONF->get_elem("chat.database.maxcon") );
- wrap::system_message(DATAIN0 + tool::int2string(i_max_con));
- wrap::system_message(DATAIN1 + tool::int2string(i_min_con));
+ wrap::system_message(DATAIN0 + tool::int2string(i_max_con));
+ wrap::system_message(DATAIN1 + tool::int2string(i_min_con));
- for ( int i = 0; i < i_min_con && i < i_max_con; i++ )
- push_back( new con() );
+ for ( int i = 0; i < i_min_con && i < i_max_con; i++ )
+ push_back( new con() );
#ifdef NCURSES
-
- print_queue_size();
+ print_queue_size();
#endif
}
data_base::~data_base()
{
- pthread_mutex_destroy ( &mut_con );
+ pthread_mutex_destroy ( &mut_con );
}
-hashmap<string>
+map_string
data_base::select_user_data( string s_user, string s_query)
{
- print_query( DATAQUE + s_query );
- hashmap<string> map_ret;
- return map_ret;
+ print_query( DATAQUE + s_query );
+ map_string map_ret;
+ return map_ret;
}
void
-data_base::insert_user_data( string s_user, string s_query, hashmap<string> insert_map )
+data_base::insert_user_data( string s_user, string s_query, map_string insert_map )
{
- print_query( DATAQUE + s_query );
+ print_query( DATAQUE + s_query );
}
void
-data_base::update_user_data( string s_user, string s_query, hashmap<string> update_map )
+data_base::update_user_data( string s_user, string s_query, map_string update_map )
{
- print_query( DATAQUE + s_query );
+ print_query( DATAQUE + s_query );
}
void
data_base::print_query( string s_query )
{
#ifdef DATA_PRINT_QUERIES
- print_query_( s_query );
+ print_query_( s_query );
#endif
}
@@ -102,124 +101,119 @@ data_base::print_query( string s_query )
void
data_base::print_query_( string s_query )
{
- wrap::system_message( s_query );
+ wrap::system_message( s_query );
}
#endif
con*
data_base::get_con()
{
- pthread_mutex_lock( &mut_con );
+ pthread_mutex_lock( &mut_con );
- if ( empty() )
- {
- wrap::system_message( DATANEW + string("(") + tool::int2string(size()+1) + ")" );
- pthread_mutex_unlock( &mut_con );
- return new con;
- }
- else if ( size() > i_max_con-1 )
- {
- wrap::system_message( DATAMAX + string("(") + tool::int2string(i_max_con) + ")" );
- usleep( 5000000 );
- pthread_mutex_unlock( &mut_con );
- return get_con();
- }
+ if ( empty() )
+ {
+ wrap::system_message( DATANEW + string("(") + tool::int2string(size()+1) + ")" );
+ pthread_mutex_unlock( &mut_con );
+ return new con;
+ }
+ else if ( size() > i_max_con-1 )
+ {
+ wrap::system_message( DATAMAX + string("(") + tool::int2string(i_max_con) + ")" );
+ usleep( 5000000 );
+ pthread_mutex_unlock( &mut_con );
+ return get_con();
+ }
- con* p_con = *begin();
- pop_front();
-#ifdef NCURSES
+ con* p_con = *begin();
+ pop_front();
- print_queue_size();
+#ifdef NCURSES
+ print_queue_size();
#endif
- pthread_mutex_unlock( &mut_con );
- wrap::system_message( DATAGET );
+ pthread_mutex_unlock( &mut_con );
+ wrap::system_message( DATAGET );
- p_con->renew_timeout();
- return p_con;
+ p_con->renew_timeout();
+ return p_con;
}
void
-data_base::push_con( con* p_con )
+data_base::push_con( con* p_con )
{
- pthread_mutex_lock( &mut_con );
- push_front( p_con );
+ pthread_mutex_lock( &mut_con );
+ push_front( p_con );
#ifdef NCURSES
-
- print_queue_size();
+ print_queue_size();
#endif
-
- pthread_mutex_unlock( &mut_con );
- wrap::system_message( DATAADD );
+ pthread_mutex_unlock( &mut_con );
+ wrap::system_message( DATAADD );
}
#ifdef NCURSES
void
data_base::print_queue_size()
{
- if ( wrap::NCUR->is_ready() )
- {
- mvprintw( NCUR_CON_QUEUE_X,NCUR_CON_QUEUE_Y, "Con. queue: %d ", size());
- refresh();
- }
+ if ( wrap::NCUR->is_ready() )
+ {
+ mvprintw( NCUR_CON_QUEUE_X,NCUR_CON_QUEUE_Y, "Con. queue: %d ", size());
+ refresh();
+ }
}
#endif
void
data_base::disconnect_all_connections()
{
- wrap::system_message( DATADIS );
- pthread_mutex_lock( &mut_con );
+ wrap::system_message( DATADIS );
+ pthread_mutex_lock( &mut_con );
- while ( !empty() )
- {
- con* p_con = *begin();
- pop_front();
- delete p_con;
- }
-
- pthread_mutex_unlock( &mut_con );
+ while ( !empty() )
+ {
+ con* p_con = *begin();
+ pop_front();
+ delete p_con;
+ }
+
+ pthread_mutex_unlock( &mut_con );
#ifdef NCURSES
-
- print_queue_size();
+ print_queue_size();
#endif
}
void
data_base::check_data_con_timeout()
{
- int i_timeout_time = tool::string2int(wrap::CONF->get_elem("chat.database.contimeout"));
- int i_last_activity;
+ int i_timeout_time = tool::string2int(wrap::CONF->get_elem("chat.database.contimeout"));
+ int i_last_activity;
- pthread_mutex_lock( &mut_con );
-
- list< list<con*>::iterator > erase_list;
- for ( list<con*>::iterator iter = begin();
+ pthread_mutex_lock( &mut_con );
+
+ list< list<con*>::iterator > erase_list;
+ for ( list<con*>::iterator iter = begin();
iter != end(); iter++ )
{
- i_last_activity = (int) (*iter)->get_last_activity();
- if ( i_timeout_time <= i_last_activity )
- {
- con* p_con = *iter;
- erase_list.push_back(iter);
- delete p_con;
- wrap::system_message(DATADI2 + tool::int2string(size()-erase_list.size()+1) + ","
- + tool::int2string(i_timeout_time) + ","
- + tool::int2string(i_last_activity) + ")");
- }
+ i_last_activity = (int) (*iter)->get_last_activity();
+ if ( i_timeout_time <= i_last_activity )
+ {
+ con* p_con = *iter;
+ erase_list.push_back(iter);
+ delete p_con;
+ wrap::system_message(DATADI2 + tool::int2string(size()-erase_list.size()+1) + ","
+ + tool::int2string(i_timeout_time) + ","
+ + tool::int2string(i_last_activity) + ")");
+ }
}
for ( list< list<con*>::iterator >::iterator erase_iter = erase_list.begin();
erase_iter != erase_list.end(); erase_iter++ )
- erase( *erase_iter );
+ erase( *erase_iter );
#ifdef NCURSES
-
print_queue_size();
#endif
-
- pthread_mutex_unlock( &mut_con );
+ pthread_mutex_unlock( &mut_con );
}
diff --git a/src/data/data_base.h b/src/data/data_base.h
index 1da5ce7..b38d978 100644
--- a/src/data/data_base.h
+++ b/src/data/data_base.h
@@ -12,36 +12,33 @@ using namespace std;
class data_base : protected list<con*>
{
-private:
+ private:
pthread_mutex_t mut_con;
int i_max_con;
#ifdef NCURSES
-
void print_queue_size();
#endif
-protected:
- hashmap< vector<string> > map_queries;
+ protected:
+ map< string, vector<string> > map_queries;
void print_query( string s_query );
#ifdef DATA_PRINT_QUERIES
-
virtual void print_query_( string s_query );
#endif
-
con* get_con();
void push_con( con* p_con );
-public:
+ public:
data_base();
~data_base();
- void initialize_connections();
- virtual hashmap<string> select_user_data( string s_user, string s_query );
- virtual void insert_user_data( string s_user, string s_query, hashmap<string> insert_map );
- virtual void update_user_data( string s_user, string s_query, hashmap<string> update_map );
- void disconnect_all_connections();
- void check_data_con_timeout();
+ void initialize_connections();
+ virtual map_string select_user_data( string s_user, string s_query );
+ virtual void insert_user_data( string s_user, string s_query, map_string insert_map );
+ virtual void update_user_data( string s_user, string s_query, map_string update_map );
+ void disconnect_all_connections();
+ void check_data_con_timeout();
};
#endif
diff --git a/src/glob.h b/src/glob.h
index c134df5..a426042 100755
--- a/src/glob.h
+++ b/src/glob.h
@@ -19,18 +19,36 @@
/* - CONFIG -
What should be the name of the config file?
*/
-#define CONFILE "yhttpd.conf"
+#define CONFILE "ychat.conf"
/* - CONFIG -
- In which prefix should yhttpd be installed if typing gmake inst-
+ In which prefix should yChat be installed if typing gmake inst-
all?
*/
#define PREFIX "/usr/local"
+//<<*
+/* - CONFIG -
+ Should yChat get compiled with database support? Currently MyS-
+ QL only is a supported database.
+*/
+//#define DATABASE
+
+#ifdef DATABASE
+/* - CONFIG -
+ Should all database queries printed out at the admin interface?
+ (This option wont take action if database support has not been
+ chosen)
+*/
+#define DATA_PRINT_QUERIES
+
+#define USE_MYSQL
+#endif
+//*>>
/* - CONFIG -
Please enter the highest networking port which is allowed to be
- used. If yhttpd is unable to create the server socket on a cert-
+ used. If yChat is unable to create the server socket on a cert-
ain port, it will increment the port number and retries to cre-
ate another socket on the incremented port number. This proced-
ure will continue until MAXPORT has been reached.
@@ -63,7 +81,7 @@
/* - CONFIG -
Please chose if you want to use verbose server outputs or not.
The verbose messages will appear in the ncurses menu if ncurses
- is enabled or in the server-window if yhttpd has been compiled
+ is enabled or in the server-window if yChat has been compiled
without ncurses support. This option shows you all incoming
requests with the client IP and port numbers. You probably want
this to be turned of if you have heavy server load.
@@ -73,17 +91,17 @@
/* - CONFIG -
If you want to enable EXPERIMENTAL features, then set this val-
ue to true. Else use false which is recommended! All experimen-
- al features are marked inside of the running yhttpd!
+ al features are marked inside of the running yChat!
*/
//#define EXPERIM
/* - CONFIG -
- Should yhttpd get compiled with ncurses support?
+ Should yChat get compiled with ncurses support?
*/
#define NCURSES
/* - CONFIG -
- Should yhttpd get compiled with comand line interface support?
+ Should yChat get compiled with comand line interface support?
*/
#define CLI
@@ -99,6 +117,14 @@
// Enables debugging options
//#define DEBUG
+//<<*
+/* - CONFIG -
+ Defines the amount of newlines which have to be sent to the clie-
+ nt's chat stream after the first log-in. It prevents a white scr-
+ een because of browser buffers or proxies.
+*/
+#define PUSHSTR 500
+//*>>
// The following values define the positions of the data stats in the NCURSES interface.
@@ -124,8 +150,8 @@
#define NCUR_CON_QUEUE_X 23
#define NCUR_CON_QUEUE_Y 35
-#define NCUR_HTTPD_HEADER_X 21
-#define NCUR_HTTPD_HEADER_Y 52
+#define NCUR_CHAT_HEADER_X 21
+#define NCUR_CHAT_HEADER_Y 52
#define NCUR_NUM_ROOMS_X 22
#define NCUR_NUM_ROOMS_Y 52
#define NCUR_SESSION_X 23
diff --git a/src/html.cpp b/src/html.cpp
index 7f1440d..1f839bb 100755
--- a/src/html.cpp
+++ b/src/html.cpp
@@ -112,6 +112,22 @@ html::parse( map_string &map_params )
return s_templ;
}
+//<<*
+void
+html::online_list( user *p_user, map_string &map_params )
+{
+ // prepare user_list.
+ string s_list;
+
+ room* p_room = p_user->get_room();
+
+ p_room->get_user_list( s_list );
+
+ map_params["ROOMNAME"] = p_room->get_name();
+ map_params["ROOMTOPIC"] = p_room->get_topic();
+ map_params["USERLIST"] = s_list;
+}
+//*>>
#ifdef NCURSES
void
diff --git a/src/html.h b/src/html.h
index d8d2a16..70d91d3 100755
--- a/src/html.h
+++ b/src/html.h
@@ -5,6 +5,7 @@
#define HTML_H
#include "maps/smap.h"
+#include "chat/user.h"
#include "name.h"
using namespace std;
@@ -31,6 +32,7 @@ public:
// used for string substituation.
string parse( map_string &map_params );
+ void online_list( user *p_user, map_string &map_params ); //<<
#ifdef NCURSES
void print_cached( int i_docs );
#endif
diff --git a/src/logd.cpp b/src/logd.cpp
index 44c42e2..0a6b85d 100755
--- a/src/logd.cpp
+++ b/src/logd.cpp
@@ -88,6 +88,10 @@ logd::log_access( map_string request )
void
logd::log_simple_line( string s_line )
{
+ // Dont log empty lines!
+ if (s_line.empty())
+ return;
+
string s_time = get_time_string();
string s_logstr = s_time + " " + s_line;
diff --git a/src/main.cpp b/src/main.cpp
index 0948e63..c4330d8 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,5 +1,5 @@
/*
- * yhttpd++; Contact: www.yhttpd.org; Mail@yhttpd.org
+ * yChat++; Contact: www.yChat.org; Mail@yChat.org
* Copyright (C) 2003 Paul C. Buetow, Volker Richter
* Copyright (C) 2004 Paul C. Buetow
* -----------------------------------------------------------------
@@ -39,7 +39,7 @@ parse_argc( int argc, char* argv[] )
string s_output = "";
- // Set to 1 if a config option key has to be read ( ./yhttpd -o key1 value1 -o key2 value2 ... );
+ // Set to 1 if a config option key has to be read ( ./ychat -o key1 value1 -o key2 value2 ... );
bool b_conf = 0;
// Will store the key of an additional option value (see also b_conf)
@@ -62,9 +62,9 @@ parse_argc( int argc, char* argv[] )
else
{
if ( string(argv[i]).find("v") != string::npos )
- s_output.append(tool::yhttpd_version()+"\n");
+ s_output.append(tool::ychat_version()+"\n");
if ( string(argv[i]).find("h") != string::npos )
- s_output.append( "Usage: ./yhttpd {h|v}|{o confkey confvalue}\n" );
+ s_output.append( "Usage: ./ychat {h|v}|{o confkey confvalue}\n" );
if ( string(argv[i]).find("o") != string::npos )
b_conf = 1;
}
@@ -85,7 +85,7 @@ main(int argc, char* argv[])
{
map<string,string>* p_start_params = parse_argc( argc, argv );
- cout << tool::yhttpd_version() << endl
+ cout << tool::ychat_version() << endl
<< DESCRIP << endl
<< DESCRI2 << endl
<< CONTACT << endl
@@ -118,6 +118,10 @@ main(int argc, char* argv[])
// init the system message logd
wrap::WRAP->LOGD = wrap::LOGD = new logd( wrap::CONF->get_elem("httpd.logging.systemfile"),
wrap::CONF->get_elem("httpd.logging.systemlines") );
+ //<<*
+ // init the session manager.
+ wrap::WRAP->SMAN = wrap::SMAN = new sman;
+ //*>>
// init the socket manager.
@@ -132,6 +136,10 @@ main(int argc, char* argv[])
usleep(1000);
#endif
+ //<<*
+ // init the chat manager.
+ wrap::WRAP->CHAT = wrap::CHAT = new chat;
+ //*>>
// init the system timer.
wrap::WRAP->TIMR = wrap::TIMR = new timr;
@@ -140,6 +148,15 @@ main(int argc, char* argv[])
// init the module-loader manager.
wrap::WRAP->MODL = wrap::MODL = new modl;
+ //<<*
+ // init the garbage collector
+ wrap::WRAP->GCOL = wrap::GCOL = new gcol;
+
+ // init the data manager.
+#ifdef DATABASE
+ wrap::WRAP->DATA = wrap::DATA = new data;
+#endif
+ //*>>
#ifndef NCURSES
#ifdef CLI
@@ -148,6 +165,12 @@ main(int argc, char* argv[])
#endif
#endif
+ //<<*
+ // Initialize database connection queue
+#ifdef DATABASE
+ wrap::DATA->initialize_connections();
+#endif
+ //*>>
// start the socket manager. this one will listen for incoming http requests and will
// forward them to the specified routines which will generate a http response.
diff --git a/src/maps/hmap.h b/src/maps/hmap.h
index a0824ec..38ea2e4 100644
--- a/src/maps/hmap.h
+++ b/src/maps/hmap.h
@@ -9,11 +9,6 @@
using namespace std;
-// void add_elem( obj_type x, key_type k ) --> Insert x
-// void del_elem( key_type k ) --> Remove x
-// obj_type get_elem( key_type k ) --> Return item that matches x
-// void make_empty( ) --> Remove all items
-
template <class obj_type, class key_type>
class hmap
{
@@ -77,6 +72,7 @@ public:
virtual void make_empty( );
virtual void make_empty( void (*func)(key_type) );
virtual void del_elem ( const key_type &k );
+ virtual void rename_key ( const key_type &k1, const key_type &k2 );
virtual obj_type set_elem ( const obj_type &x, const key_type &k );
virtual void run_func( void (*func)(obj_type) );
diff --git a/src/maps/hmap.tmpl b/src/maps/hmap.tmpl
index 10facac..dcd0426 100644
--- a/src/maps/hmap.tmpl
+++ b/src/maps/hmap.tmpl
@@ -104,6 +104,17 @@ void hmap<obj_type, key_type>::del_elem( const key_type & k )
array[ i_current_pos ].info = DELETED;
}
+// Remove item x from the hash table.
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::rename_key( const key_type & k1, const key_type & k2 )
+{
+ int i_current_pos = find_pos( k1 );
+ if( is_active( i_current_pos ) ) {
+ array[ i_current_pos ].info = DELETED;
+ add_elem( array[ i_current_pos ].element, k2 );
+ }
+}
+
// Finds item x and resets its value.
template <class obj_type, class key_type>
obj_type hmap<obj_type, key_type>::set_elem( const obj_type & x, const key_type & k )
diff --git a/src/maps/smap.h b/src/maps/smap.h
index e056519..2096139 100644
--- a/src/maps/smap.h
+++ b/src/maps/smap.h
@@ -30,6 +30,7 @@ class smap : public hmap<obj_type, key_type>
void add_elem ( const obj_type &x, const key_type &k );
obj_type set_elem ( const obj_type &x, const key_type &k );
void del_elem ( const key_type &k );
+ void rename_key ( const key_type &k1, const key_type &k2 );
bool is_avail ( const key_type &k );
obj_type get_elem ( const key_type &k );
obj_type pop_elem ( const key_type &k );
diff --git a/src/maps/smap.tmpl b/src/maps/smap.tmpl
index 3167504..5ec7d38 100644
--- a/src/maps/smap.tmpl
+++ b/src/maps/smap.tmpl
@@ -77,6 +77,14 @@ smap<obj_type, key_type>::del_elem( const key_type & k )
pthread_mutex_unlock( &mut_smap );
}
+template <class obj_type, class key_type> void
+smap<obj_type, key_type>::rename_key( const key_type & k1, const key_type & k2 )
+{
+ pthread_mutex_lock ( &mut_smap );
+ hmap<obj_type,key_type>::rename_key( k1, k2 );
+ pthread_mutex_unlock( &mut_smap );
+}
+
template <class obj_type, class key_type>
obj_type smap<obj_type, key_type>::get_elem( const key_type &k )
diff --git a/src/modl.cpp b/src/modl.cpp
index ca620ce..f95b90f 100755
--- a/src/modl.cpp
+++ b/src/modl.cpp
@@ -17,7 +17,6 @@ modl::modl( ) : smap<dynmod*,string>(HMAPOCC)
#ifdef NCURSES
print_cached( 0 );
#endif
-
if ( wrap::CONF->get_elem( "httpd.modules.preloadcommands" ).compare( "true" ) == 0 )
preload_modules( wrap::CONF->get_elem("httpd.modules.commandsdir") );
@@ -51,7 +50,7 @@ modl::preload_modules( string s_path )
do
{
if ( iter->length() >= 3 && iter->compare( iter->length()-3, 3, ".so" ) == 0 )
- cache_module( s_path + *iter );
+ cache_module( s_path + *iter, false );
}
while ( ++iter != dir_vec.end() );
}
@@ -70,7 +69,7 @@ modl::dlclose_( dynmod* mod )
}
dynmod*
-modl::cache_module( string s_name )
+modl::cache_module( string s_name, bool b_print_sys_msg )
{
void *the_module = NULL;
function *the_func = NULL;
@@ -92,8 +91,8 @@ modl::cache_module( string s_name )
return NULL;
}
- wrap::system_message( MODULEC + s_name.substr( s_name.find_last_of("/")+1 ) );
-
+ if ( b_print_sys_msg )
+ wrap::system_message( MODULEC + s_name.substr( s_name.find_last_of("/")+1 ) );
dynmod *mod = new dynmod; // encapsulates the function and module handler.
mod->the_func = the_func ; // the function to execute
@@ -117,7 +116,7 @@ modl::get_module( string s_name )
{
wrap::system_message( MODULER + s_name.substr( s_name.find_last_of("/")+1 ) );
dynmod* mod = get_elem( s_name );
- return ! mod ? cache_module( s_name ) : mod;
+ return ! mod ? cache_module( s_name, true ) : mod;
}
void
diff --git a/src/modl.h b/src/modl.h
index 50587cd..a65077d 100755
--- a/src/modl.h
+++ b/src/modl.h
@@ -11,7 +11,7 @@ class modl : private smap<dynmod*,string>
{
private:
static void dlclose_( dynmod* mod );
- dynmod* cache_module ( string s_name );
+ dynmod* cache_module ( string s_name, bool b_print_sys_msg );
void preload_modules( string s_path );
#ifdef NCURSES
diff --git a/src/mods/Makefile b/src/mods/Makefile
index 1b0712b..36ab1f0 100755
--- a/src/mods/Makefile
+++ b/src/mods/Makefile
@@ -1,9 +1,8 @@
-MAKE=`tail -n 1 ../../make.version`
all: mods
mods:
- @${MAKE} -C ./commands #//<<
- @${MAKE} -C ./html
+ gmake -C ./commands #//<<
+ gmake -C ./html
clean:
- @${MAKE} -C ./commands clean #//<<
- @${MAKE} -C ./html clean
+ gmake -C ./commands clean #//<<
+ gmake -C ./html clean
@if test -d ../../mods; then rm -Rf ../../mods; fi
diff --git a/src/mods/commands/yc_about.cpp b/src/mods/commands/yc_about.cpp
index dece71d..086e126 100644
--- a/src/mods/commands/yc_about.cpp
+++ b/src/mods/commands/yc_about.cpp
@@ -6,54 +6,54 @@
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>"
+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>, "
+ + "</b>, "
+ p_conf->get_elem("chat.msgs.userinroom") + "<b>"
- + p_searched_user->get_room()->get_name()
- + "</b><br>\n"
+ + 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=\"#"
+ + "</b><br>\n";
+ p_user->msg_post( &s_msg );
+ }
+
+ else
+ {
+ string s_msg = "<font color=\"#"
+ p_conf->get_elem("chat.html.errorcolor")
- + "\"><b>"
+ + "\"><b>"
+ s_searched_user + "</b> "
+ p_conf->get_elem("chat.msgs.err.notavailable")
+ "</font><br>\n";
- p_user->msg_post( &s_msg );
+ p_user->msg_post( &s_msg );
- }
- }
+ }
+ }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_all.cpp b/src/mods/commands/yc_all.cpp
index 3b5713f..c4c9cdf 100755
--- a/src/mods/commands/yc_all.cpp
+++ b/src/mods/commands/yc_all.cpp
@@ -6,44 +6,43 @@
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;
- }
+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
index 81a2089..af4a4a5 100755
--- a/src/mods/commands/yc_away.cpp
+++ b/src/mods/commands/yc_away.cpp
@@ -4,69 +4,67 @@
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;
- }
+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
index 3e1f591..4449278 100755
--- a/src/mods/commands/yc_col.cpp
+++ b/src/mods/commands/yc_col.cpp
@@ -10,79 +10,76 @@
using namespace std;
-extern "C"
-{
- int valid_color( string );
+extern "C" {
+ int valid_color( string );
+
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
- 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;
- 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;
+ if ( params->empty() )
+ {
+ s_color = p_conf->get_elem( "chat.html.user.color1" );
+ s_color2 = p_conf->get_elem( "chat.html.user.color2" );
+ }
- string s_color;
- string s_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" );
+ }
- 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 );
- 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);
+ }
- 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 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;
- }
+ return 1;
+ }
}
diff --git a/src/mods/commands/yc_compopt.cpp b/src/mods/commands/yc_compopt.cpp
index cd21f6f..ad6ae99 100755
--- a/src/mods/commands/yc_compopt.cpp
+++ b/src/mods/commands/yc_compopt.cpp
@@ -7,17 +7,16 @@
using namespace std;
-extern "C"
-{
- int valid_color( string );
+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");
- 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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_exec.cpp b/src/mods/commands/yc_exec.cpp
index 119942d..f912c20 100755
--- a/src/mods/commands/yc_exec.cpp
+++ b/src/mods/commands/yc_exec.cpp
@@ -9,58 +9,58 @@
using namespace std;
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
+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
- 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;
- 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 );
- vector<string>::iterator iter;
- for ( iter = params->begin(); iter != params->end(); iter++ )
- s_command.append( " " + *iter );
+ s_command.append(" 2>error.log");
- s_command.append(" 2>error.log");
+ s_msg.append( " " + s_command + "<br>\n" );
- s_msg.append( " " + s_command + "<br>\n" );
+ p_user->msg_post( &s_msg );
- p_user->msg_post( &s_msg );
+ FILE *file;
+ char buffer[READBUF];
- 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 );
+ }
- 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;
+ else
+ {
+ s_output.append("<hr>\n");
+ while(true)
+ {
+ if(fgets(buffer, READBUF, file) == NULL)
+ break;
- s_output.append( string(buffer) + "<br>\n" );
- }
+ s_output.append( string(buffer) + "<br>\n" );
+ }
- p_user->msg_post( &s_output );
- pclose(file);
- }
+ p_user->msg_post( &s_output );
+ pclose(file);
+ }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_fake.cpp b/src/mods/commands/yc_fake.cpp
index cfc22c0..c708841 100755
--- a/src/mods/commands/yc_fake.cpp
+++ b/src/mods/commands/yc_fake.cpp
@@ -4,27 +4,26 @@
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;
- }
+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
index e27c468..87e2d25 100755
--- a/src/mods/commands/yc_getroom.cpp
+++ b/src/mods/commands/yc_getroom.cpp
@@ -6,48 +6,48 @@
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>"
+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_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>"
+ + "\"><b>"
+ s_searched_user + "</b> "
+ p_conf->get_elem("chat.msgs.err.notavailable")
+ "</font><br>\n";
- p_user->msg_post( &s_msg );
+ p_user->msg_post( &s_msg );
- }
- }
+ }
+ }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_getrusage.cpp b/src/mods/commands/yc_getrusage.cpp
index 42faa67..83dcbb9 100755
--- a/src/mods/commands/yc_getrusage.cpp
+++ b/src/mods/commands/yc_getrusage.cpp
@@ -18,40 +18,39 @@
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;
- }
+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
index cdeb1be..41899c3 100755
--- a/src/mods/commands/yc_help.cpp
+++ b/src/mods/commands/yc_help.cpp
@@ -7,46 +7,45 @@
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;
- }
+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
index 58a8912..b78d934 100755
--- a/src/mods/commands/yc_invisible.cpp
+++ b/src/mods/commands/yc_invisible.cpp
@@ -4,28 +4,27 @@
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;
- }
+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
index 178a388..903e49b 100755
--- a/src/mods/commands/yc_j.cpp
+++ b/src/mods/commands/yc_j.cpp
@@ -7,98 +7,99 @@
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 )
+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() )
{
- 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;
- }
+ 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
index 36b2fa0..ac32ac7 100755
--- a/src/mods/commands/yc_ko.cpp
+++ b/src/mods/commands/yc_ko.cpp
@@ -6,67 +6,67 @@
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() + " "
+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";
+ + "<br>\n";
- room* p_room1 = p_user->get_room();
- room* p_room2 = p_searched_user->get_room();
+ room* p_room1 = p_user->get_room();
+ room* p_room2 = p_searched_user->get_room();
- p_room1->msg_post( &s_msg );
+ p_room1->msg_post( &s_msg );
- if ( p_room1->get_lowercase_name() !=
- p_room2->get_lowercase_name() )
- p_room2->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='/"
+ 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_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>"
+ + "\"><b>"
+ s_searched_user + "</b> "
+ p_conf->get_elem("chat.msgs.err.notavailable")
+ "</font><br>\n";
- p_user->msg_post( &s_msg );
- }
- }
+ p_user->msg_post( &s_msg );
+ }
+ }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_m.cpp b/src/mods/commands/yc_m.cpp
index 4a57727..a93cc3b 100755
--- a/src/mods/commands/yc_m.cpp
+++ b/src/mods/commands/yc_m.cpp
@@ -7,38 +7,37 @@
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;
- }
+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
index 13bfc3b..d79d952 100755
--- a/src/mods/commands/yc_md5.cpp
+++ b/src/mods/commands/yc_md5.cpp
@@ -8,47 +8,47 @@
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;
- }
+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
index d9de98c..66d54da 100755
--- a/src/mods/commands/yc_me.cpp
+++ b/src/mods/commands/yc_me.cpp
@@ -7,39 +7,38 @@
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;
-
- }
+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
index 1a7db27..cf1f448 100755
--- a/src/mods/commands/yc_morph.cpp
+++ b/src/mods/commands/yc_morph.cpp
@@ -8,44 +8,45 @@
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;
- }
+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
index 8d8f2cf..33beee4 100755
--- a/src/mods/commands/yc_msg.cpp
+++ b/src/mods/commands/yc_msg.cpp
@@ -6,63 +6,63 @@
using namespace std;
-extern "C"
-{
- int valid_color( string );
+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;
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
+ 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() + "\">";
- 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;
+ 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() + "\">";
- 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 );
+ string s_tmp = "";
+ for ( iter++; iter != params->end(); iter++ )
+ s_tmp.append( *iter + " " );
- if ( b_found )
- {
- string s_time = "";
- if ( p_conf->get_elem("chat.printalwaystime") == "true" )
- s_time = p_timr->get_time() + " ";
+ p_chat->string_replacer(&s_tmp);
- 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=\"#"
+ 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>"
+ + "\"><b>"
+ s_whisper_user + "</b> "
+ p_conf->get_elem("chat.msgs.err.notavailable")
+ "</font><br>\n";
- p_user->msg_post( &s_msg );
- }
- }
+ p_user->msg_post( &s_msg );
+ }
+ }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_q.cpp b/src/mods/commands/yc_q.cpp
index 1df6156..4c9584d 100755
--- a/src/mods/commands/yc_q.cpp
+++ b/src/mods/commands/yc_q.cpp
@@ -8,23 +8,22 @@
using namespace std;
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container* c = (container*) v_arg;
- user* p_user = (user*)c->elem[1];
+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;
+ 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>";
+ 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);
+ p_user->msg_post( &s_quit );
+ p_user->set_online(false);
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_reload.cpp b/src/mods/commands/yc_reload.cpp
index 9d613fc..8b9cd0a 100755
--- a/src/mods/commands/yc_reload.cpp
+++ b/src/mods/commands/yc_reload.cpp
@@ -4,22 +4,21 @@
using namespace std;
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
+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";
- user* p_user = (user*) c->elem[1]; // the corresponding user
- conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ p_user->get_room()->reload_onlineframe();
+ p_user->msg_post ( &s_msg );
- 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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_ren.cpp b/src/mods/commands/yc_ren.cpp
index ae6c76a..9735d8e 100755
--- a/src/mods/commands/yc_ren.cpp
+++ b/src/mods/commands/yc_ren.cpp
@@ -7,68 +7,68 @@
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=\"#"
+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_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();
- }
- }
+ 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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_s.cpp b/src/mods/commands/yc_s.cpp
index 011d21e..30a6892 100755
--- a/src/mods/commands/yc_s.cpp
+++ b/src/mods/commands/yc_s.cpp
@@ -3,46 +3,45 @@
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;
-
- }
+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
index 3a1afb0..a18b5e9 100755
--- a/src/mods/commands/yc_set.cpp
+++ b/src/mods/commands/yc_set.cpp
@@ -4,97 +4,98 @@
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";
+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;
- p_user->get_room()->msg_post(&s_msg);
- p_chat->set_command_status( s_command_name, i_newval );
+ 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 if ( s_option == "disable" )
- {
- const char* c_newval = s_newval.c_str();
- if ( isdigit( c_newval[0] ) )
+
+ else
{
- 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 );
+ 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 );
}
- }
- 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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_template.cpp b/src/mods/commands/yc_template.cpp
index 9273fff..e0aa009 100755
--- a/src/mods/commands/yc_template.cpp
+++ b/src/mods/commands/yc_template.cpp
@@ -7,19 +7,18 @@
using namespace std;
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
+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 );
- 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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_time.cpp b/src/mods/commands/yc_time.cpp
index 86a93ec..c22e542 100755
--- a/src/mods/commands/yc_time.cpp
+++ b/src/mods/commands/yc_time.cpp
@@ -2,21 +2,20 @@
using namespace std;
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
+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";
- 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;
+ p_user->msg_post( &s_msg );
- string s_msg = p_conf->get_elem("chat.msgs.servertime") + p_timr->get_time() + "<br>\n";
-
- p_user->msg_post( &s_msg );
-
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_topic.cpp b/src/mods/commands/yc_topic.cpp
index bf650b2..0fd01e9 100755
--- a/src/mods/commands/yc_topic.cpp
+++ b/src/mods/commands/yc_topic.cpp
@@ -5,74 +5,74 @@
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;
- }
+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_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
index 163629b..5fe0929 100755
--- a/src/mods/commands/yc_uptime.cpp
+++ b/src/mods/commands/yc_uptime.cpp
@@ -2,21 +2,20 @@
using namespace std;
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
+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";
- 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;
+ p_user->msg_post( &s_msg );
- string s_msg = p_conf->get_elem("chat.msgs.uptime") + p_timr->get_uptime() + "<br>\n";
-
- p_user->msg_post( &s_msg );
-
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_version.cpp b/src/mods/commands/yc_version.cpp
index cb4831e..d64fabd 100755
--- a/src/mods/commands/yc_version.cpp
+++ b/src/mods/commands/yc_version.cpp
@@ -7,17 +7,16 @@
using namespace std;
-extern "C"
-{
- int valid_color( string );
+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");
- 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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/html/yc_admin.cpp b/src/mods/html/yc_admin.cpp
index f3811f9..d93de4f 100644
--- a/src/mods/html/yc_admin.cpp
+++ b/src/mods/html/yc_admin.cpp
@@ -7,66 +7,63 @@
using namespace std;
-extern "C"
-{
- string replace_chars(string s_string)
- {
- s_string = tool::replace(s_string, "<", "&lt;");
- s_string = tool::replace(s_string, ">", "&gt;");
- 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 = &(*((hashmap<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;
- }
+extern "C" {
+ string replace_chars(string s_string) {
+ s_string = tool::replace(s_string, "<", "&lt;");
+ s_string = tool::replace(s_string, ">", "&gt;");
+ 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*) 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
index 9d9f2ec..4bd20bf 100755
--- a/src/mods/html/yc_colors.cpp
+++ b/src/mods/html/yc_colors.cpp
@@ -6,32 +6,30 @@
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 = &(*((hashmap<string>*) c->elem[1]))["col1"];
- string* p_col2 = &(*((hashmap<string>*) c->elem[1]))["col2"];
- string* p_flag = &(*((hashmap<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 = &(*((hashmap<string>*) c->elem[1])
- )["msgs"];
- p_msgs->append( p_conf->get_elem( "chat.msgs.optionschanged" ) );
- }
-
- return 0;
- }
+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*) c->elem[1]))["col1"];
+ string* p_col2 = &(*((map_string*) c->elem[1]))["col2"];
+ string* p_flag = &(*((map_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*) 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
index ec8e863..5612a50 100755
--- a/src/mods/html/yc_help.cpp
+++ b/src/mods/html/yc_help.cpp
@@ -6,45 +6,43 @@
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 = &(*((hashmap<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" );
+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*) 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++;
}
- }
- p_vec_keys_iter++;
- }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/html/yc_options.cpp b/src/mods/html/yc_options.cpp
index 42c995c..c209b93 100755
--- a/src/mods/html/yc_options.cpp
+++ b/src/mods/html/yc_options.cpp
@@ -6,51 +6,50 @@
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 = &(*((hashmap<string>*) c->elem[1]))["flag"];
- string* p_email = &(*((hashmap<string>*) c->elem[1]))["email"];
- string* p_pass = &(*((hashmap<string>*) c->elem[1]))["pass"];
- string* p_newpass = &(*((hashmap<string>*) c->elem[1]))["newpass"];
- string* p_newpass2 = &(*((hashmap<string>*) c->elem[1]))["newpass2"];
- user* p_user = (user*) c->elem[2];
-
- if ( *p_flag == "submit" )
- {
- string* p_msgs = &(*((hashmap<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 )
+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*) c->elem[1]))["flag"];
+ string* p_email = &(*((map_string*) c->elem[1]))["email"];
+ string* p_pass = &(*((map_string*) c->elem[1]))["pass"];
+ string* p_newpass = &(*((map_string*) c->elem[1]))["newpass"];
+ string* p_newpass2 = &(*((map_string*) c->elem[1]))["newpass2"];
+ user* p_user = (user*) c->elem[2];
+
+ if ( *p_flag == "submit" )
{
- p_msgs->append( p_conf->get_elem( "chat.msgs.err.changepassword" ) );
- return 0;
+ string* p_msgs = &(*((map_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" ) );
}
- if ( *p_newpass != *p_newpass2 )
+ else
{
- p_msgs->append( p_conf->get_elem( "chat.msgs.err.changepassword2" ) );
- return 0;
+ p_email->append( p_user->get_email() );
}
- 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;
- }
+
+ return 0;
+ }
}
diff --git a/src/mods/html/yc_register.cpp b/src/mods/html/yc_register.cpp
index 1acbd73..016c932 100755
--- a/src/mods/html/yc_register.cpp
+++ b/src/mods/html/yc_register.cpp
@@ -6,91 +6,88 @@
using namespace std;
-extern "C"
-{
- int extern_function(void *v_arg)
- {
+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 = &(*((hashmap<string>*) c->elem[1]))["INFO"];
- string* p_nick = &(*((hashmap<string>*) c->elem[1]))["nick"];
- string* p_email = &(*((hashmap<string>*) c->elem[1]))["email"];
- string* p_pass = &(*((hashmap<string>*) c->elem[1]))["pass"];
- string* p_pass2 = &(*((hashmap<string>*) c->elem[1]))["pass2"];
- string* p_request = &(*((hashmap<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") );
-
- hashmap<string> map_insert = *((hashmap<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
+ 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*) c->elem[1]))["INFO"];
+ string* p_nick = &(*((map_string*) c->elem[1]))["nick"];
+ string* p_email = &(*((map_string*) c->elem[1]))["email"];
+ string* p_pass = &(*((map_string*) c->elem[1]))["pass"];
+ string* p_pass2 = &(*((map_string*) c->elem[1]))["pass2"];
+ string* p_request = &(*((map_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
+ {
+ map_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 map_insert = *((map_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
+ }
}
diff --git a/src/msgs.h b/src/msgs.h
index 5937e53..d88467c 100644
--- a/src/msgs.h
+++ b/src/msgs.h
@@ -4,11 +4,11 @@
// alphabetical ordered:
#define ACCPERR "Sock: Accept error "
#define BINDERR "Sock: Bind error "
-#define HTTPDREP "Chat: Using replacement strings"
-#define HTTPDDOP "Chat: Default operator login "
+#define CHATREP "Chat: Using replacement strings"
+#define CHATDOP "Chat: Default operator login "
#define CFILEOK "Parsing config file"
#define CFILEFA "Failed opening config file!"
-#define CONTACT "Contact: http://www.yhttpd.org, Mail@yhttpd.org, ICQ: 11655527"
+#define CONTACT "Contact: http://www.yChat.org, Mail@yChat.org, ICQ: 11655527"
#define CLRHTML "HTML: Cleared the template cache "
#define CLIWELC "Command Line Interface (type help for a list of all commands)"
#define CLIPRMO ">> "
@@ -44,6 +44,7 @@
#define LOGINE1 "Chat: Login failed (alpha nick), nick: "
#define LOGINE2 "Chat: Login failed (nick length), nick: "
#define LOGINE3 "Chat: Login failed (room length), nick/room: "
+#define LOGINE4 "Chat: Login failed (guests disabled), nick: "
#define MODULEC "Modl: Caching "
#define MODULER "Modl: Requesting "
#define MODUNLO "Modl: Unloading all modules "
@@ -93,9 +94,10 @@
#define XMLREAD "XML: Reading "
#define XMLERR "XML Error: "
#define XMLER1 "XML Error: Unable to load file "
-#define VERSION "yhttpd 0.7"
+#define VERSION "yChat 0.7.3"
#define BRANCH "RELEASE"
-#define BUILDNR 2798
-#define UNAME "FreeBSD 5.2.1-RELEASE-p10 i386"
+#define BUILDNR 2958
+#define UNAME "FreeBSD 5.3-RELEASE-p2 i386"
+#define COMPOPT "Using built-in specs.; Configured with: FreeBSD/i386 system compiler; Thread model: posix; gcc version 3.4.2 [FreeBSD] 20040728; 3.4; g++"
#endif
diff --git a/src/ncur/ncur.cpp b/src/ncur/ncur.cpp
index e9e7753..fa91a74 100755
--- a/src/ncur/ncur.cpp
+++ b/src/ncur/ncur.cpp
@@ -38,17 +38,20 @@ ncur::start( void *p_void )
"Unload all modules ",
"Reload all modules ",
"Clear template cache ",
- " ",
+ "Run garbage collector ", //<<
+ //>>" ",
"Show max res. set size ",
"Compile changed sources ",
"Recompile all sources ",
"Show source stats ",
"Command Line Interface ",
#ifdef DATABASE
+ "Disconnect from DB ", //<<
#else
+ " ", //<<
#endif
- " ",
+ //>>" ",
"Shut down server"
};
@@ -67,11 +70,15 @@ ncur::start( void *p_void )
mvprintw( NCUR_SERVER_HEADER_X,NCUR_SERVER_HEADER_Y, "HTTP server:");
mvprintw( NCUR_POOL_HEADER_X,NCUR_POOL_HEADER_Y, "Thread pool:");
#ifdef DATABASE
+ mvprintw( NCUR_DATA_HEADER_X,NCUR_DATA_HEADER_Y, "Data stats:"); //<<
#endif
+ mvprintw( NCUR_CHAT_HEADER_X,NCUR_CHAT_HEADER_Y, "Chat stats:"); //<<
mvprintw( NCUR_CACHED_HEADER_X,NCUR_CACHED_HEADER_Y, "Caching:");
wrap::HTML->print_cached(0);
is_ready( true );
+ wrap::SMAN->print_init_ncurses(); //<<
+ wrap::STAT->print_num_rooms(); //<<
p_menu->start( &switch_main_menu_ );
@@ -166,6 +173,11 @@ ncur::switch_main_menu_( int i_choice )
refresh();
break;
case 4:
+ //<<*
+ if ( ! wrap::GCOL->remove_garbage() )
+ wrap::NCUR->print( GAROFFNE );
+ mvprintw( 20,2, "Garbage collector activated ");
+ //*>>
refresh();
break;
case 5:
@@ -203,10 +215,13 @@ ncur::switch_main_menu_( int i_choice )
break;
case 10:
#ifdef DATABASE
+ wrap::DATA->disconnect_all_connections(); //<<
#endif
break;
case 11: // Shut down server
+ if ( ! wrap::GCOL->remove_garbage() ) //<<
+ wrap::NCUR->print( GAROFFNE ); //<<
mvprintw( 21,2, "Good bye !");
close_ncurses();
exit(0);
@@ -229,7 +244,7 @@ ncur::init_ncurses()
noecho();
cbreak(); // Line buffering disabled. pass on everything
init_pair(1, COLOR_WHITE, COLOR_BLUE);
- mvprintw( 0,2, (char*)(tool::yhttpd_version()).c_str());
+ mvprintw( 0,2, (char*)(tool::ychat_version()).c_str());
refresh();
}
diff --git a/src/reqp.cpp b/src/reqp.cpp
index 630e34c..529f4a4 100755
--- a/src/reqp.cpp
+++ b/src/reqp.cpp
@@ -7,8 +7,8 @@
using namespace std;
string reqp::HTTP_CODEOK = "HTTP/1.1 200 OK\r\n";
-string reqp::HTTP_SERVER = "Server: yhttpd (Unix)\r\n";
-string reqp::HTTP_CONTAC = "Contact: www.yhttpd.org\r\n";
+string reqp::HTTP_SERVER = "Server: yChat (Unix)\r\n";
+string reqp::HTTP_CONTAC = "Contact: www.yChat.org\r\n";
string reqp::HTTP_EXPIRE = "Expires: 0\r\n";
string reqp::HTTP_CACHEC = "Cache-control: no-cache\r\nPragma: no-cache\r\n";
string reqp::HTTP_CONNEC = "Connection: keep-alive\r\n";
@@ -28,8 +28,8 @@ reqp::get_request_parameters( string s_parameters, map_string& map_params )
{
s_tmp = s_parameters.substr(0, i_pos );
- if ( (i_pos2 = s_tmp.find("=")) != string::npos )
- map_params[ s_tmp.substr(0, i_pos2) ] = s_tmp.substr( i_pos2+1 );
+ if ( (i_pos2 = s_tmp.find("=")) != string::npos )
+ map_params[ s_tmp.substr(0, i_pos2) ] = tool::replace( s_tmp.substr( i_pos2+1 ), "\\AND", "&");
s_parameters = s_parameters.substr( i_pos + 1 );
}
@@ -261,6 +261,85 @@ reqp::parse( thrd* p_thrd, string s_req, map_string &map_params )
s_rep.append( get_content_type( map_params["request"] ) );
s_rep.append("\r\n\r\n");
+ //<<*
+ // check the event variable.
+ if ( ! s_event.empty() )
+ {
+ // login procedure.
+ if ( s_event == "login" )
+ {
+ wrap::CHAT->login( map_params );
+ }
+
+ else if ( s_event == "register" )
+ {
+ user* p_user = new user;
+ map_params["INFO"] = "";
+ run_html_mod( s_event, map_params, p_user );
+ wrap::GCOL->add_user_to_garbage( p_user );
+ }
+
+ else
+ {
+ bool b_found;
+
+ // user* p_user = s_chat::get().get_user( map_params["nick"], b_found );
+ sess *sess_temp = wrap::SMAN->get_session( map_params["tmpid"] );
+
+ user *p_user;
+ if( sess_temp != NULL )
+ {
+ string s_nick = sess_temp->get_name();
+ p_user = wrap::CHAT->get_user( s_nick, b_found);
+ }
+
+ else
+ {
+ return s_rep;
+ }
+
+ if ( ! b_found )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.notonline" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ }
+
+ else
+ {
+ map_params["nick"] = p_user->get_name().c_str();
+
+ // if a message input.
+ if ( s_event == "input" )
+ {
+ if ( p_user )
+ {
+ p_user->check_restore_away();
+ wrap::CHAT->post( p_user, map_params );
+ }
+ }
+
+ // if a chat stream
+ else if ( s_event == "stream" )
+ {
+ string s_msg ( wrap::HTML->parse( map_params ) );
+ p_user->msg_post( &s_msg);
+ wrap::SOCK-> chat_stream( p_thrd->get_sock(), p_user, map_params );
+ }
+
+ // if a request for the online list of the active room.
+ else if ( s_event == "online" )
+ {
+ wrap::HTML->online_list( p_user, map_params );
+ }
+
+ else if ( s_event != "input" )
+ {
+ run_html_mod( s_event, map_params, p_user );
+ }
+ }
+ }
+ }
+ //*>>
if ( wrap::CONF->get_elem("httpd.enablecgi").compare("true") == 0 &&
string::npos != map_params["request"].find(".cgi") )
@@ -281,6 +360,26 @@ reqp::parse( thrd* p_thrd, string s_req, map_string &map_params )
return s_rep;
}
+//<<*
+void
+reqp::run_html_mod( string s_event, map_string &map_params, user* p_user )
+{
+ container *c = new container;
+
+ c->elem[0] = (void*) wrap::WRAP;
+ c->elem[1] = (void*) &map_params;
+ c->elem[2] = (void*) p_user;
+
+ string s_mod = wrap::CONF->get_elem("httpd.modules.htmldir") + "yc_" + s_event + ".so";
+
+ dynmod* p_module = wrap::MODL->get_module( s_mod );
+
+ if ( p_module != NULL )
+ ( *( p_module->the_func ) ) ( (void*) c );
+
+ delete c;
+}
+//*>>
string
reqp::remove_dots( string s_ret )
diff --git a/src/reqp.h b/src/reqp.h
index 3a998b9..519100e 100755
--- a/src/reqp.h
+++ b/src/reqp.h
@@ -32,6 +32,7 @@ private:
virtual string get_from_header( string s_req, string s_hdr );
virtual int htoi( string *s );
+ virtual void run_html_mod( string s_event, map_string &map_params, user* p_user ); //<<
// Removes double dots ".."
string remove_dots( string s_req );
diff --git a/src/sock/sock.cpp b/src/sock/sock.cpp
index 7dba4b7..531ccb9 100755
--- a/src/sock/sock.cpp
+++ b/src/sock/sock.cpp
@@ -6,6 +6,8 @@
#include <sys/types.h>
#include <unistd.h>
#include "sock.h"
+#include "../chat/chat.h"
+#include "../chat/user.h"
using namespace std;
@@ -27,6 +29,56 @@ sock::~sock()
pthread_mutex_destroy( &mut_threads );
}
+//<<*
+void
+sock::chat_stream( int i_sock, user* p_user, map_string &map_params )
+{
+ string s_msg( "\n" );
+
+ for ( int i = 0; i < PUSHSTR; i++ )
+ send( i_sock, s_msg.c_str(), s_msg.size(), 0 );
+
+ pthread_mutex_t mutex;
+ pthread_mutex_init( &mutex, NULL );
+ pthread_mutex_lock( &mutex );
+
+ do
+ {
+ s_msg = p_user->get_mess( );
+ if ( 0 > send( i_sock, s_msg.c_str(), s_msg.size(), 0 ) )
+ p_user->set_online( false );
+ pthread_cond_wait( &(p_user->cond_message), &mutex );
+ }
+ while( p_user->get_online() );
+
+ pthread_mutex_destroy( &mutex );
+
+ // if there is still a message to send:
+ s_msg = p_user->get_mess( );
+ if ( ! s_msg.empty() )
+ send( i_sock, s_msg.c_str(), s_msg.size(), 0 );
+
+ // remove the user from its room.
+ string s_user( p_user->get_name() );
+ string s_user_lowercase( p_user->get_lowercase_name() );
+ p_user->get_room()->del_elem( s_user_lowercase );
+
+ // post the room that the user has left the chat.
+ s_msg = wrap::TIMR->get_time() + " "
+ + p_user->get_colored_bold_name()
+ + wrap::CONF->get_elem( "chat.msgs.userleaveschat" )
+ + "<br>\n";
+
+ p_user->get_room()->msg_post( &s_msg );
+ p_user->get_room()->reload_onlineframe();
+
+#ifdef VERBOSE
+ cout << REMUSER << s_user << endl;
+#endif
+
+ wrap::GCOL->add_user_to_garbage( p_user );
+}
+//*>>
int
sock::make_server_socket( int i_port )
diff --git a/src/sock/sock.h b/src/sock/sock.h
index 079dfd8..6f3419e 100755
--- a/src/sock/sock.h
+++ b/src/sock/sock.h
@@ -13,6 +13,7 @@
#include "../thrd/pool.h"
#include "../thrd/thrd.h"
#include "../reqp.h"
+#include "../chat/user.h"
#include "../logd.h"
using namespace std;
@@ -55,6 +56,7 @@ public:
virtual int start();
// the chat stream there all the chat messages will sent through.
+ static void chat_stream( int i_sock, user* p_user, map_string &map_params ); //<<
void increase_num_threads();
void decrease_num_threads();
diff --git a/src/stats.cpp b/src/stats.cpp
index 63757b6..7fba04d 100644
--- a/src/stats.cpp
+++ b/src/stats.cpp
@@ -11,14 +11,17 @@ stats::stats()
i_rusage_vec_size = tool::string2int(
wrap::CONF->get_elem("httpd.stats.rusagehistory"));
+ i_num_rooms = 0; //<<
pthread_mutex_init( &mut_vec_rusage, NULL );
+ pthread_mutex_init( &mut_num_rooms, NULL ); //<<
}
stats::~stats()
{
pthread_mutex_destroy( &mut_vec_rusage );
+ pthread_mutex_destroy( &mut_num_rooms ); //<<
}
void
@@ -99,4 +102,47 @@ stats::get_rusage_history( string s_type, string s_seperator )
return s_ret;
}
+//<<*
+int
+stats::get_num_rooms()
+{
+ pthread_mutex_lock ( &mut_num_rooms );
+ int i_ret = i_num_rooms;
+ pthread_mutex_unlock( &mut_num_rooms );
+ return i_ret;
+}
+
+void
+stats::increment_num_rooms()
+{
+ pthread_mutex_lock ( &mut_num_rooms );
+ ++i_num_rooms;
+ pthread_mutex_unlock( &mut_num_rooms );
+#ifdef NCURSES
+ print_num_rooms();
+#endif
+}
+void
+stats::decrement_num_rooms()
+{
+ pthread_mutex_lock ( &mut_num_rooms );
+ --i_num_rooms;
+ pthread_mutex_unlock( &mut_num_rooms );
+#ifdef NCURSES
+ print_num_rooms();
+#endif
+}
+
+#ifdef NCURSES
+void
+stats::print_num_rooms()
+{
+ if ( !wrap::NCUR->is_ready() )
+ return;
+
+ mvprintw( NCUR_NUM_ROOMS_X, NCUR_NUM_ROOMS_Y, "Rooms: %d", get_num_rooms());
+ refresh();
+}
+#endif
+//*>>
#endif
diff --git a/src/stats.h b/src/stats.h
index 0ef60a2..647f504 100644
--- a/src/stats.h
+++ b/src/stats.h
@@ -21,6 +21,8 @@ private:
vector< map<string,long> > vec_rusage_history;
pthread_mutex_t mut_vec_rusage;
+ int i_num_rooms; //<<
+ pthread_mutex_t mut_num_rooms; //<<
void set_rusage_vec_size( int i_rusage_vec_size );
@@ -28,9 +30,19 @@ public:
stats( );
~stats( );
+ //<<*
+ int get_num_rooms();
+ void increment_num_rooms();
+ void decrement_num_rooms();
+ //*>>
void update_rusage_history();
string get_rusage_history( string s_type, string s_seperator );
long get_ru_maxrss();
+ //<<*
+#ifdef NCURSES
+ void print_num_rooms();
+#endif
+ //*>>
};
#endif
diff --git a/src/time/timr.cpp b/src/time/timr.cpp
index 91dc7f7..fa308d3 100755
--- a/src/time/timr.cpp
+++ b/src/time/timr.cpp
@@ -68,7 +68,7 @@ timr::start( void *v_pointer )
time_now = *localtime( &clock_now );
- // set the current time && the current yhttpd uptime!
+ // set the current time && the current ychat uptime!
set_time( difftime( clock_now, clock_start ),
time_now.tm_sec, time_now.tm_min, time_now.tm_hour );
#ifdef NCURSES
@@ -81,10 +81,27 @@ timr::start( void *v_pointer )
#ifdef SERVMSG
cout << TIMERUP << get_uptime() << endl;
#endif
+ //<<*
+ int* i_timeout_settings = new int[3];
+ i_timeout_settings[0] = tool::string2int(wrap::CONF->get_elem("chat.idle.timeout"));
+ i_timeout_settings[1] = tool::string2int(wrap::CONF->get_elem("chat.idle.awaytimeout"));
+ i_timeout_settings[2] = tool::string2int(wrap::CONF->get_elem("chat.idle.autoawaytimeout"));
+ wrap::CHAT->check_timeout( i_timeout_settings );
+ delete i_timeout_settings;
+
+ string s_ping = "<!-- PING! //-->\n";
+ wrap::CHAT->msg_post( &s_ping );
+
+#ifdef DATABASE
+ // Disconnecting idle database conenction
+ wrap::DATA->check_data_con_timeout();
+#endif
+ //*>>
// run every ten minutes:
if ( time_now.tm_min % 10 == 0 )
{
+ wrap::GCOL->remove_garbage(); //<<
// run every hour
if ( time_now.tm_hour % 60 == 0 )
diff --git a/src/tool/tool.cpp b/src/tool/tool.cpp
index 1da4a12..e2ef9ae 100644
--- a/src/tool/tool.cpp
+++ b/src/tool/tool.cpp
@@ -11,6 +11,22 @@
#include "tool.h"
+list<string>
+tool::split_string(string s_string, string s_split) {
+ list<string> list_ret;
+ unsigned i_pos, i_len = s_split.length();
+
+ while ( (i_pos = s_string.find(s_split)) != string::npos )
+ {
+ list_ret.push_back( s_string.substr(0, i_pos) );
+ s_string = s_string.substr( i_pos + i_len );
+ }
+
+ list_ret.push_back( s_string );
+
+ return list_ret;
+}
+
string
tool::trim( string s_str )
{
diff --git a/src/tool/tool.h b/src/tool/tool.h
index a350c69..7352772 100644
--- a/src/tool/tool.h
+++ b/src/tool/tool.h
@@ -3,16 +3,19 @@
#include "../incl.h"
+#include <list>
+
using namespace std;
class tool
{
public:
+ static list<string> split_string(string s_string, string s_split);
+
static bool is_alpha_numeric( string &s_digit )
{
- auto const char *digit = s_digit.c_str();
- auto int i_len = strlen( digit );
-
+ const char *digit = s_digit.c_str();
+ int i_len = strlen( digit );
for( int i=0; i<i_len; i++ )
{
@@ -27,6 +30,7 @@ public:
static char* clean_char( char* c_str);
static string trim( string s_str );
static string replace( string s_string, string s_search, string s_replace );
+
static string int2string( int i_int )
{
char buffer[64];
@@ -84,7 +88,7 @@ public:
static string shell_command( string s_command, method m_method );
- static string yhttpd_version()
+ static string ychat_version()
{
return string(VERSION) + "-" + string(BRANCH) + " Build " + int2string(BUILDNR);
}
diff --git a/src/wrap.cpp b/src/wrap.cpp
index 81c6679..b6c8358 100755
--- a/src/wrap.cpp
+++ b/src/wrap.cpp
@@ -5,6 +5,14 @@
using namespace std;
+//<<*
+chat* wrap::CHAT;
+#ifdef DATABASE
+data* wrap::DATA;
+#endif
+gcol* wrap::GCOL;
+sman* wrap::SMAN;
+//*>>
conf* wrap::CONF;
html* wrap::HTML;
diff --git a/src/wrap.h b/src/wrap.h
index 1207f03..afc45b1 100755
--- a/src/wrap.h
+++ b/src/wrap.h
@@ -4,14 +4,18 @@
#include "incl.h"
#ifdef DATABASE
+#include "data/data.h"
#endif
+#include "chat/chat.h"
#include "conf/conf.h"
+#include "chat/gcol.h"
#include "html.h"
#include "logd.h"
#include "modl.h"
#ifdef NCURSES
#include "ncur/ncur.h"
#endif
+#include "chat/sman.h"
#include "sock/sock.h"
#include "stats.h"
#include "time/timr.h"
@@ -21,6 +25,14 @@ using namespace std;
class dynamic_wrap
{
public:
+ //<<*
+ chat* CHAT;
+#ifdef DATABASE
+ data* DATA;
+#endif
+ gcol* GCOL;
+ sman* SMAN;
+ //*>>
conf* CONF;
html* HTML;
@@ -49,6 +61,17 @@ public:
static void system_message( string s_message );
+ //<<*
+ static chat* CHAT;
+#ifdef DATABASE
+ static data* DATA;
+#endif
+ static gcol* GCOL;
+ static sman* SMAN;
+#ifdef IRCBOT
+ static ybot* YBOT;
+#endif
+ //*>>
static conf* CONF;
static html* HTML;