diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:45 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:45 +0200 |
| commit | 5f4e214740242513c837c8a005ca23779bab1d0c (patch) | |
| tree | 3880f745b0d3376030e3342e60679f25b38bdc4c | |
| parent | 23c5e7d57e1e9216f4da3446656df2dc7202975d (diff) | |
tagging ychat-0.8.2ychat-0.8.2
72 files changed, 1986 insertions, 570 deletions
@@ -1,11 +1,176 @@ -Changes from 0.5.2-LEGACYRELEASE to 0.5.3-LEGACYRLEASE -- Code cleanup -- Added ./scripts/* -- Added gmake stats option +-Changes from 0.8.1-RELEASE to 0.8.2-RELEASE +$ Fixed some typos +$ Added the - Versioning - paragraph into the README file +$ Removed the yc_template command module source file +$ scripts/config.pl now also accepts q and quit as a command +$ Minor bugfix in scripts/config.pl +$ Some improvements in src/configure +$ Changed some default values in the src/glob.h -Changes from 0.5.1-RELEASE to 0.5.2-LEGACYRLEASE -- Changed this branch into a LEGACY branch. -- Rewrote the dynamic thread pool (backport from 0.7.8-CURRENT). -- Added scripts/* -- Code now uses ANSI C++ style with 2 space code indenting. +-Changes from 0.8-RELEASE to 0.8.1-RELEASE +$ Fixed a HTML bug in the stream html (h1 should get closed w/ /h1) +$ Fixed some typos in the README +$ Fixed a bug in the /q command +$ Implemented The /gag and /ungag commands +$ Implemented flood protection and added the following ychat.conf options: +$ chat.floodprotection.seconds +$ chat.floodprotection.messages +$ chat.msgs.err.gag +$ chat.msgs.floodgag +$ chat.msgs.gag +$ chat.msgs.ungag +$ chat.msgs.help.gag +$ chat.msgs.help.ungag +$ Added the SHORTDESC file +$ Changed Copyright to "EXA Digital Solutions GbR" +-Changes from 0.7.9.2-RELEASE to 0.8-RELEASE +$ Modified the Makefiles, so that they produce valid output while using +$ the -j flag of gmake. +$ OpenSSL support has been integrated. Thanks to CryptoMail.org for patching! +$ The next release will also have a credits section in the README! +$ The HTTP parsing stuff has been reviewed and improved by CryptoMail as well. +$ Also a mini bug of the configure script has been fixed. + +-Changes from 0.7.9.1-RELEASE to 0.7.9.2-RELEASE - +$ Added monitor/dump, and the dump command to the CLI. +$ Fixed a bug in the session manager. +$ Added gmake dist do the README. +$ Added the charset to the HTTP-header. + +-Changes from 0.7.9-RELEASE to 0.7.9.1-RELEASE - +$ Fixed etc/ychat.conf (Its now valid XML) +$ Fixed some typos. +$ Added the scripts/makedist.sh script, which can be invoked by gmake dist. +$ yhttpd.org has been renamed to yChat.org. The yhttpd.org SLD will be +$ canceled! The yhttpd.org Homepage will remain on yChat.org! + +-Changes from 0.7.8-RELEASE to 0.7.9-RELEASE - +$ In the system messages will be the user printed which has requested the + specified module. +$ Removed the cursor from the ncurses interface. +$ Added wrap::init_wrappers -> The main.cpp is now shorter. +$ Added some Makefile modifications +$ Bugfix: cleanipcache shouldn run every minute but every 10! +$ Bugfix: scripts/stats.pl now counts all text-files properly. + +-Changes from 0.7.7.1-RELEASE to 0.7.8-RELEASE - +$ Updated the yhttpd generation script due new sources in src/memb. +$ Changd some hashmaps back into simple std::map objects, this might +$ has resulted in some bugs due slow hashmap initialization time. +$ Hashmaps now only should being used on permanent objects. +$ Rewrote the dynamic thread pool. +$ makeyhttpd now also removes the yChat specific form etc/yhttpd.conf +$ automatically. +$ Implemnted an IP Cache (makes yChat faster). +$ Implemented signal catcher: +$ SIGUSR1 will clear the html template cache. +$ SIGUSR2 will reload the dynamic modules. +$ SIGSEGV can be catched if defined in src/glob.h. +$ SIGHUP, SIGINT and SIGTERM will shutdown yChat cleanly. +$ Added Allow: GET to the HTTP header. +$ Bugfix: The httpd.logging.accesslines now will be read correctly. +$ Bugfix: JavaScript messages now wont be logged. + +-Changes from 0.7.7-RELEASE to 0.7.7.1-RELEASE - +$ Bugfix in main.cpp which resulted in a core dump on yChat startup. + +-Changes from 0.7.6-RELEASE to 0.7.7-RELEASE - +$ Major code cleanup. +$ Bugfix in /col. +$ Bugfix in gcol #1 (destroy session also if no database is used). +$ Bugfix in gcol #2 (now runs each hour not once a day). +$ Renew the style.css and stream.html. + +-Changes from 0.7.5-RELEASE to 0.7.6-RELEASE - +$ Removed the old hash maps and included the SGI C++ STL extenstion +$ hash_map. + +-Changes from 0.7.4.1-RELEASE to 0.7.5-RELEASE - +$ Garbage collector will now run once a hour rather than each ten minutes. +$ Dynamic thread pool improvements. +$ Removed equiv-http-refresh meta tag from the online list. +$ Minor bugfix in the /topic command. +$ Implemented "User list". + +-Changes from 0.7.4-RELEASE to 0.7.4.1-RELEASE - +$ Dynamic thread pool bugfix (dead lock). + +-Changes from 0.7.3-RELEASE to 0.7.4-RELEASE - +$ Code cleanup. +$ Made the thread pool increasing dynamic. +$ Added some thread pool optimazions. +$ Added some more ${MAKE} vars to the Makefiles. +$ Added Content-length to the HTTPD header. +$ Added the !command to the command line interface. +$ Added Content-type text/plain. +$ Added scrolling checkbox to input.html. +$ Removed modl from yhttpd. Dynamic modules are not needed in yhttpd yet. +$ Improved session engine. +$ Fixed auto logout bug. +$ Fixed newline bug (one \n too much for each html template). +$ Logging can now be completely disabled. + +-Changes from 0.7.2 to 0.7.3-RELEASE - +$ Added FreeBSD 5.3-RELEASE support. +$ Added chat.enableguest option. +$ Added the /all command (Global system message). +$ 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. +$ New commands: /away /room /j /ren. +$ Simple garbage collector for old user and room objects. +$ Use of the database (MySQL). +$ Nick registration and password protection. +$ Status images for Operator, Half-Operator, Voiced user and Guests. +$ New Makefiles. +$ Useful Perl scripts for sourcecode stats generation etc. +$ Added system_log and room logging to access_log logging. +$ Added time-offset option. +$ Added to the admin interface new options. +$ Added Logout button. +$ Added string replacer there certain substr. of postings will be replaced by another string (such as smiley images). +$ Added Superuser levels and the /ko and /set commands. +$ 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 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 do not +$ work). +$ XML based configuration file (ychat.conf). +$ Added default operator option: chat.defaultop. @@ -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.) @@ -1,12 +1,95 @@ -SRCS=base.cpp chat.cpp CHAT.cpp cmnd.cpp conf.cpp CONF.cpp cont.cpp html.cpp HTML.cpp main.cpp mutx.cpp MUTX.cpp name.cpp reqp.cpp room.cpp sock.cpp SOCK.cpp thrd.cpp TOOL.cpp user.cpp -OBJS=$(SRCS:.cpp=.o) -CC=c++ -LDFLAGS=-lstdc++ -LDADD=-pthread -D_THREAD_SAFE -all: ychat -$(SRCS): - $(CC) $(CFLAGS) -c $*.cpp -ychat: $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDADD) -clean: - rm *.o +MAKE=`tail -n 1 make.version` +PREFIX=`grep "define PREFIX" src/glob.h | cut -d'"' -f2` +all: version base modules + @echo "Now edit the ychat.conf and run ychat!" + @echo "The config file is searched in the following order:" + @echo " ./ychat.conf " + @echo " ~/.ychat/ychat.conf " + @echo " ./etc/ychat.conf " + @echo " /etc/ychat.conf " + @echo " $(PREFIX)/etc/ychat.conf " + @echo If you want to help the yChat project please run gmake mail + @echo so that the developers receive an email about the platform + @echo being used. + @echo WARNING! This software is EXPERIMENTAL! +mail: + @echo "VERSION:" > mail.tmp + @${MAKE} 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 +uninstall: deinstall +deinstall: + @echo Install/deinstall is not supported! + @echo Start yChat with ./bin/ychat instead! + @exit 1 +modules: + @if test -d ./src/mods; then ${MAKE} -C ./src/mods; fi +clean_modules: + @if test -d ./src/mods; then ${MAKE} -C ./src/mods clean; fi +base: + @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 + @${MAKE} -C ./src +clean_base: + @${MAKE} -C ./src clean +stats: + @perl scripts/stats.pl +run: + ./bin/ychat +base_start: base + ./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 ${MAKE} with the following parameters:" + @grep "^ ${MAKE} " README + @echo "For more questions read the README file or contact mail@ychat.org!" +setup: + @./configure + @${MAKE} +config: + @sh -c "scripts/config.sh" + @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 -f bin/ychat; then find bin/ -name "*ychat*" | xargs rm -f; fi + @if test -d src/mods; then find src/mods/*/ -name Makefile | xargs rm -f; fi + @find . -name "*.add" | xargs rm -f + @ls | grep core | xargs rm -f +version: + @./scripts/version.sh +debug: + @gdb bin/ychat ychat.core +confdebug: + ./configure -g3 -ggdb +dist: + @./scripts/makedist.sh +ssltest: + openssl genrsa -des3 -out privkey.pem 2048 + openssl req -new -x509 -key privkey.pem -out cert.pem -days 1095 + @mv -f privkey.pem cert.pem etc + + + @@ -1,3 +1,5 @@ +::(21.06.05)::yChat 0.8.1-RELEASE is available. Some changes which were made: The /gag and /ungag commands were added. Flood protection has been implemented. The Copyright has been changed to EXA Digital Solutions (yChat will stay open source as usual, no panic!). Also some minor bugs have been fixed. +::(14.06.05)::The Copyright holder of yChat has been changed from Paul C. Buetow (thats me) into <a href="http://www.exa-ds.com">EXA Digital Solutions</a> webhosting, which a webhosting firm in which I am involved. With EXA DS I could make more yChat publicity. ::(25.05.05)::yChat 0.8-RELEASE is available. This is the first release of the 0.8-CURRENT branch. OpenSSL support has been integrated. Thanks to CryptoMail.org for the patches! Also, the HTTP parsing methods have been reviewed and improved by the CryptoMail crew as well. In addition, several smaller bugs were fixed. ::(08.05.05)::yChat 0.7.9.3-RELEASE is available. This is the first STABLE release of the 0.7 branch. yChat 0.7.9.2 still has been of CURRENT. The new release only includes some bugfixes related to the Makefiles, configure-scripts. Also a security patch for the 0.8-CURRENT branch has been backported into 0.7.9.3. ::(04.05.05)::OpenSSL support has been integrated into yChat 0.8-CURRENT. The 0.8-RELEASE will come soon after some additional documentation stuff related to OpenSSL has been done. Thanks to <a href="http://CryptoMail.org">CryptoMail.org</a> for mailing the OpenSSL patch. @@ -1,4 +1,4 @@ -yhttpd; Homepage: www.yChat.org; Version 0.7.2-RELEASE +yChat; Homepage: www.yChat.org; Version 0.8.2-CURRENT Copyright (C) 2003 Paul C. Buetow, Volker Richter Copyright (C) 2004 Paul C. Buetow @@ -19,39 +19,48 @@ 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: - -0.0 ABOUT DEVELS -1.0 REQUIREMENTS -1.1 TESTED PLATFORMS -1.2 IMPORTANT NOTICES -1.3 HOW TO OBTAIN YHTTPD -1.3 INSTALLATION -1.3 INSTALLATION QUICK-START -1.4 HOW TO USE SCREEN WITH YHTTPD -1.4 HOW TO USE SIGNALS WITH YHTTPD -1.5 CUSTOMIZATION -1.6 FILES -1.7 WRITING BUG REPORTS -1.8 CONTACT -2.0 CREDITS - -0.0 ABOUT DEVELS +YCHAT TABLE OF CONTENTS: + +1.0.0 GENERAL +1.1.0 ABOUT RELEASES +1.2.0 YCHAT FEATURES //<< +2.0.0 INSTALLATION AND SETUP +2.1.0 REQUIREMENTS +2.2.0 TESTED PLATFORMS +2.3.0 HOW TO OBTAIN YCHAT +2.4.0 INSTALLATION QUICK-START +2.4.1 INSTALLATION +2.3.3 HOW TO USE OPENSSL WITH YCHAT +2.3.4 HOW TO USE MYSQL WITH YCHAT //<< +2.3.5 HOW TO USE SCREEN WITH YCHAT +2.3.6 HOW TO USE SIGNALS WITH YCHAT +2.4.0 CONFIGURING YCHAT +2.5.0 YHTTPD CODE BASE GENERATION //<< +3.0.0 EXTENDING YCHAT +3.1.0 SOURCE FILES +4.0.0 DIVERSE +4.1.0 WRITING BUG REPORTS +4.2.0 CONTACT ADDRESSES +4.3.0 CREDITS + +1.0.0 GENERAL + +1.1.0 ABOUT RELEASES There are several projects involved: - The chat - Its a HTTP based chat server written in C++. Clients are normal web browsers -such as MSIE or Gecko based browsers using only CSS, HTML and JavaScript. +such as MSIE or Gecko based browsers using only CSS, HTML and JavaScript. - The httpd - Its a small http server based on the chat's socket and threading engine. yhttpd does not have as much features but is easy to use and faster than apache. yhttpd is a subset of the chat. It can be generated using the -srcipts/yhttpdbase.pl script in the chat's source tree. +srcipts/yhttpdbase.pl script in the chat's source tree. - The ycurses - -ycurses is a easy to use and small C++ wrapper of the C ncurses API. +ycurses is a easy to use and small C++ wrapper around the C ncurses API. There are different branches: @@ -59,14 +68,14 @@ There are different branches: The CURRENT branch is unstable, this is the bleeding developing edge with all the new experimental features. -A DEVEL of CURRENT can be referred as CURRENTDEVEL. +A RELEASE of CURRENT can be referred as CURRENTRELEASE. - STABLE - The STABLE branch is more stable than CURRENT. This branch may get new features as well. But those will be more conservative compared to CURRENT. -A DEVEL of STABLE can be referred as STABLEDEVEL. +A RELEASE of STABLE can be referred as STABLERELEASE. - LEGACY - The LEGACY branch has no real support. This branch may get bugfixes and @@ -80,17 +89,161 @@ can be everything. Commonly DEVEL versions are CURRENT. There are also releases made: -- DEVEL - -There can be DEVELs made out of each branch. While a branch can get -new features, a DEVEL can not. A DEVEL of a branch is just like -a snapshot. DEVELs are complete versions to test and use. But keep -in mind, that a DEVEL of the STABLE branch is recommended over a -DEVEL of a CURRENT or a LEGACY branch in a production environment. -DEVELs of CURRENT are still the bleeding edge and DEVELs of LEGACY +- RELEASE - +There can be RELEASEs made out of each branch. While a branch can get +new features, a RELEASE can not. A RELEASE of a branch is just like +a snapshot. RELEASEs are complete versions to test and use. But keep +in mind, that a RELEASE of the STABLE branch is recommended over a +RELEASE of a CURRENT or a LEGACY branch in a production environment. +RELEASEs of CURRENT are still the bleeding edge and RELEASEs of LEGACY may be out of date. - -1.0 REQUIREMENTS: +- Short names - + +In addition, each description also has short names: (short names are needed +if your text space is limited which happens very fast in IRC channel topics) + +CURRENT aka CUR aka C +RELEASE aka REL aka R +LEGACY aka LEG aka L +STABLE aka SBL aka S +DEVEL aka DEV aka D +PRE aka P + +STABLERELEASE aka STBREL aka SR +PRERELEASE aka PREREL aka PR +PRELEGACYRELEASE aka PRELEGREL aka PLR +etc... + +The short name of the chat is "yC" +The short name of the httpd is "yh" +The short name of ycurses is "yu" + +- Versioning - +In general, versions are made up like X.Y.Z.W. X specifies the major version, +Y specifies the branch of the major version, Z specifies a sub revision +of a specific branch. The optional W can be used to specify a maintenance +revision which only changes small issues. Version numbers can be also normal +alphabetic characters. Example: Version 0.7.A follows 0.7.9. Version 0.T.Y.2 +would be also valid. + +Therefore: The lowest value is 0, the highest possible value is Z. + +//<<* +1.2.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 +featured HTTP web server to the clients (web browsers). + +The yChat code base can be converted to an yhttpd code base automaticaly. yhttpd +is the webserver subset of yChat which runs completely stand alone and provides +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. +Currently, yChat has been measured providing over 1000 hits/requests per second +on a FreeBSD based server box while using less than 2% of CPU usage +on a Athlon XP 1900+. Performance seems to be limited by your bandwith only. +Also, each user gets its own session id (random string) with a standard length +of 50 chars to authenticate each logged in user. The length of the session id +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. +Also, yChat supports secure hypertext transfer protocol (HTTPS) connections +using the OpenSSL library. Then, all chat messages will be encrypted in a +secure manner. HTTPS is optional to HTTP (unsecured connections). + +- 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 through own command and dynamic HTML engine - +All chat commands are realized through dynamic loadable module files which can +be recompiled and reloaded without restarting the whole yChat server. Also +HTML-Sites with certain tasks can be compiled as a module like +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. +//*>> + +2.0.0 INSTALLATION AND SETUP + +2.1.0 REQUIREMENTS: - GNU GCC G++ The GNU C++ compiler version 3.1 or up. @@ -98,7 +251,7 @@ may be out of date. - 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. - SGI STL extension @@ -106,53 +259,55 @@ may be out of date. On *BSD you have to install it first before compiling. On FreeBSD /usr/ports/devel/stlport is your friend. +- OpenSSL + Includes libssl and the ssl header files of the open source SSL library. + OpenSSL is only needed if you chose to compile yChat w/OpenSSL support. + +//<<* +- mysql-client 4.x (3.x may do too but is not supported) + Includes libmysqlclient and the mysql.h header files. mysql-client is only + needed if you chose to compile yChat w/database support. + +//*>> - ncurses 5.x Includes libncurses and the ncurses.h header files. - Screen - Only needed if yhttpd should run in background with + 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. -1.1 TESTED PLATFORMS: +2.1.0 TESTED PLATFORMS: 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-DEVEL (i386) 3.4 3.80 +- FreeBSD 5.4-RELEASE (i386) 3.4.2 3.80 +- FreeBSD 5.3-RELEASE (i386) 3.4.2 3.80 Tested longer time before: -- FreeBSD 5.2-DEVEL (i386) 3.3 3.80 -- FreeBSD 4.10-DEVEL (i386) 3.4 3.80 -- FreeBSD 4.9-DEVEL (i386) 3.3 3.80 -- Gentoo Linux 2004 (i386) 3.3 3.80 -- OpenBSD 3.6 SMP (i386) 3.3 3.80 +- FreeBSD 5.2.1-RELEASE (i386) 3.3.3 3.80 +- FreeBSD 4.10-RELEASE (i386) 3.4.1 3.80 +- FreeBSD 4.9-RELEASE (i386) 3.3.4 3.80 +- Gentoo Linux 2004 (i386) 3.3.2 3.80 +- OpenBSD 3.6 SMP (i386) 3.3.2 3.80 - Red Hat Linux 8.0 SMP (i386) 3.2-7 3.79 -- Slackware Linux 10.0 (i386) 3.4 3.80 -- SUSE Linux 9.0 (i386) 3.3 3.80 -- SUSE Linux 8.1 (i386) 3.2 3.79 +- Slackware Linux 10.0 (i386) 3.4.0 3.80 +- SUSE Linux 9.0 (i386) 3.3.1 3.80 +- SUSE Linux 8.1 (i386) 3.2 3.79.1 Other platforms like Linux based systems, other BSD-Systems or UNICES are very likely to work too. -1.2 IMPORTANT NOTICES: +2.3.0 HOW TO OBTAIN YCHAT: -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.yChat.org. - -1.3 HOW TO OBTAIN YHTTPD: - -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.yChat.org -> Sourcecode -> -Packages or go to http://pub.buetow.org/yhttpd/yhttpd . +Packages or go to http://pub.buetow.org/yChat/yChat . For CVS download type: @@ -169,23 +324,36 @@ Now you may continue with the installation. here are different branches in the CVS: -yhttpd: This is the latest CURRENT branch of yhttpd. -yhttpd-stable: This is the latest STABLE branch of yhttpd. -yhttpd-X.Y: This is the branch with the specified version prefix. +ychat: This is the latest CURRENT branch of yChat. +ychat-stable: This is the latest STABLE branch of yChat. +ychat-X.Y: This is the branch with the specified version prefix. yhttpd: This is the latest CURRENT snapshot of yhttpd. -The CURRENT branch of yhttpd is mostly untested and unstable, so don't +The CURRENT branch of ychat is mostly untested and unstable, so don't cry if you get errors. -1.3 INSTALLATION: +2.4.0 INSTALLATION QUICK START + +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! If you chose OpenSSL support, then +also run gmake ssltest before starting yChat. + +2.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" +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 and runs "gmake mail") @@ -195,88 +363,138 @@ or gmake config): gmake clean_base (only cleans the base obj and rpo files) gmake clean_modules (only cleans the modules .so files) gmake confdebug (runs ./configure with enabling debugging) - gmake config (runs yhttpd configurator) - gmake debug (runs gdb on ./yhttpd.core) + gmake config (runs yChat configurator) + gmake debug (runs gdb on ./ychat.core) gmake dist (creates a .tar.bz2 ball) gmake gpl (shows the GNU General Public License) - gmake help (shows all available yhttpd gmake targets) - gmake mail (sends a mail to the yhttpd developers containing build opts.) + gmake help (shows all available ychat gmake targets) + 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 stats (generates yhttpd statistics) - gmake version (shows the current version of yhttpd) + gmake stats (generates ychat statistics) + gmake ssltest (generates a self signed ssl test certificate) + 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 ! ... have fun :-). -1.3 INSTALLATION QUICK START: +2.3.3 HOW TO USE OPENSSL WITH YCHAT + +If you chose to use OpenSSL support you have to have a valid SSL private and +public key. If you are in hurry, use the gmake ssltest command from the top +source tree directory and follow the instructions. Otherwise type the +following commands manually: + +The private key can be created w/the following command: + + openssl genrsa -des3 -out privkey.pem 2048 + +Afterwards, you can create a self-signed test certificate using the following +command: + + openssl req -new -x509 -key privkey.pem -out cert.pem -days 1095 -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! +Be sure to move the privkey.pem and cert.pem files into the ./etc directory +or edit the path names in the ./etc/ychat.conf file. yChat wont start if there +are no valid files found. +To learn more about SSL certificates, visit http://www.openssl.org/docs/HOWTO/. +Now use https:// and NOT http:// to connect to the yChat server. -1.4 HOW TO USE SCREEN WITH YHTTPD: +//<<* +2.3.4 HOW TO USE MYSQL WITH YCHAT -If you are running yhttpd in ncurses mode you might want to install +If you chose to use MySQL database support you have to create a valid database +to use with yChat. + +Create a new MySQL database called 'ychat' and type the following command into +a MySQL command line client of your choice: + +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. +//*>> + +2.3.5 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. For a closer look read the screen manual page ( man screen ). -1.4 HOW TO USE SIGNALS WITH YHTTPD: +2.3.6 HOW TO USE SIGNALS WITH YCHAT: -You can send UNIX signals to yhttpd. This becomes very interesting if you +You can send UNIX signals to yChat. This becomes very interesting if you don't use the command line interface or the ncurses interface and you don't have access to the options below. Run one of the following commands to send the signal you want: -($PID is here the process id of the current yhttpd process) +($PID is here the process id of the current yChat process) -kill -USR1 $PID # yhttpd clears the HTML template cache -kill -HUP $PID # yhttpd will shutdown savely +kill -USR1 $PID # yChat clears the HTML template cache +kill -USR2 $PID # yChat reloads all dynamic loadable modules //<< +kill -HUP $PID # yChat will shutdown savely -1.5 CUSTOMIZATION: +2.4.0 CONFIGURING YCHAT: -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. @@ -284,56 +502,70 @@ Dynamic loadable modules can be found in the mods/ subdirectory. (chat commands are realized through modules too). Sources of modules can be found in src/mods instead. If you want to create a new module just create a new .cpp file and run in src/mods the ./configure script again. Next time -you run gmake your new module gets compiled. +you run gmake your new module gets compiled. All messages defined in the msgs.h file contain server messages only ( a chat user never wont read them, only the administrator will get to see them ). -1.6 FILES: +Read also section 3.0.0 of this README. + +//<<* +2.5.0 YHTTPD CODE BASE GENERATION -etc/yhttpd.conf - The yhttpd configuration file +See docs/yhttpd.txt +//*>> + +3.0.0 EXTENDING YCHAT + +3.1.0 SOURCE FILES + +This list is not complete. Only the most important files are listed here! + +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 src/msgs.h - Defines some server side messages -1.7 WRITING BUG REPORTS +4.0.0 DIVERSE + +4.1.0 WRITING BUG REPORTS How to submit a good bug report? -Send them to mail at yhttpd dot org. +Send them to Mail at yChat dot 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. @@ -353,23 +585,22 @@ 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 gmake clean confdebug all run -1.8 CONTACT: +4.2.0 CONTACT ADDRESSES You may contact us through the following addresses: - Homepage - The yhttpd homepage is located at http://www.yChat.org + The yChat homepage is located at http://www.yChat.org The EXA Digital Solutions homepage is located at http://www.exa-ds.com - E-Mail - Paul C. Buetow: Buetow at yhttpd point org ( core developer ) - Mail at yhttpd dot org ( reaches everybody of yhttpd ) + Paul C. Buetow: buetow at yChat point org ( core developer ) + Mail at yChat dot org ( reaches everybody of yChat ) - ICQ Paul C. Buetow: 11655527 @@ -382,14 +613,13 @@ You may contact us through the following addresses: D-44866 Bochum Germany +4.2.0 CREDITS -2.0 CREDITS - -Thanks to the following persons. Without them yhttpd would not be like today: +Thanks to the following persons. Without them yChat would not be like today: - Volker Richter <volker at exa-ds dot de> of EXA Digital Solutions GbR - (http://www.exa-ds.com) for adding initial MySQL support and lots of more - code. + for adding initial MySQL support and lots of more code. -- Joshia Teitelbaum <joshuat at cryptomail.org> of CryptpMail.org for adding - lots of security patches in the HTTP header handling. +- Joshua Teitelbaum <joshuat at cryptomail.org> of CryptpMail.org for adding + initial OpenSSL support and lots of security patches in the HTTP header + handling. @@ -2,12 +2,15 @@ Release table Release date Release name and version Release focus +Planing: yChat 0.7.9.4-STABLERELEASE Maintenance Planing: ycurses 0.1-RELEASE________ Initial release Planing: yhttpd 0.8-RELEASE_________ Features -Planing: yChat 0.7.9.4-STABLERELEASE -Planing: yChat 0.8-RELEASE__________ Features +Planing: yChat 0.9.0-RELEASE________ Major rewrite +Planing: yChat 0.8.3-RELEASE________ Not yet defined -May 25th 05: yChat 0.8-RELEASE Major features +Aug 04th 05: yChat 0.8.2-RELEASE Minor enhancements +Jun 21st 05: yChat 0.8.1-RELEASE Major features +May 25th 05: yChat 0.8.0-RELEASE Major features May 08th 05: yChat 0.7.9.3-STABLERELEASE Security bugfixes Apr 11th 05: yChat 0.5.5-STABLERELEASE__ Minor security fixes Apr 10th 05: yChat 0.7.9.2-RELEASE______ Major security fixes @@ -37,4 +40,3 @@ Apr 26th 03 yChat 0.4-RELEASE__________ Mar 30th 03 yChat 0.3-RELEASE__________ Mar 24th 03 yChat 0.2-RELEASE__________ Mar 20th 03 yChat 0.1-RELEASE__________ Initial release - @@ -1,2 +1,2 @@ -The yhttpd 0.7 branch is marked as STABLE and will only get bugfixes and minor -improvements. Most of the new stuff will go into the CURRENT branch instead. +The yChat 0.8 branch is marked as CURRENT. All brand new stuff will go into +this branch. @@ -6,7 +6,6 @@ $ Add thread pool decreasing $ dir : public vector<string> $ Disable /help command for commands wich are not accessible for the $ specific user. -$ Flood protection $ Add /nick, /beam, /su $ Add / to whisper to the last person to whom the user has been whispered the last time. @@ -16,7 +15,9 @@ $ resolved by implementing last modified and current time/date informations $ into the HTTP header. - To do in general for some later RELEASE - -$ Use libevent +$ Use libevent +$ Implement MPI support for some nice load balancing stuff +$ Implement msession support $ Implement a switch so that all dynamic dlopen modules can be compiled within the yChat executable not using dlopen. $ Implement dynamic timer $ Implement ncurse object browser diff --git a/etc/ychat.conf b/etc/ychat.conf index 8f7590e..2a92c9a 100644 --- a/etc/ychat.conf +++ b/etc/ychat.conf @@ -25,6 +25,16 @@ <value>0</value> <descr>The time offset. Negative values are not allowed. If you have an offset of X please enter 24+X+12 here. Example: Offset = -6, 24-6+12 = 30 :)</descr> </option> + <category name="floodprotection"> + <option name="seconds"> + <value>2</value> + <descr>Defines the intervall of seconds yChat is checking for a flood attack.</descr> + </option> + <option name="messages"> + <value>4</value> + <descr>Defines the allowed message posts in chat.floodprotection.seconds seconds.</descr> + </option> + </category> <category name="fields"> <option name="userstrings"> <value>tmpid agnt away col1 col2 email pass</value> @@ -187,6 +197,12 @@ </option> </category> <category name="msgs"> + <option name="gag"> + <value>gags</value> + </option> + <option name="ungag"> + <value>ungags</value> + </option> <option name="userlist"> <value>List of logged in users: </value> </option> @@ -283,6 +299,9 @@ <option name="userkicksout1"> <value> kicks </value> </option> + <option name="floodgag"> + <value> has been gagged (chat flooding).</value> + </option> <option name="userkicksout2"> <value> out of the chat at room </value> </option> @@ -299,6 +318,12 @@ <value>Whispered to </value> </option> <category name="help"> + <option name="gag"> + <value>Gags a specific user. Usage: /gag USER [REASON]</value> + </option> + <option name="ungag"> + <value>Ungags a specific user. Usage: /ungag USER [REASON]</value> + </option> <option name="all"> <value>Writes a global system message into all available rooms. Usage: /all MESSAGE</value> </option> @@ -388,6 +413,12 @@ <option name="alpnum"> <value>The nick you have specifued is not alphanumeric, please change that.<br><br></value> </option> + <option name="flooding"> + <value>You are flooding the chat room!</value> + </option> + <option name="gagged"> + <value>You are currently gagged!</value> + </option> <option name="alreadyinroom"> <value>You are already in the room</value> </option> diff --git a/html/blank.html b/html/blank.html index 4ddd1a7..4ddd1a7 100644..100755 --- a/html/blank.html +++ b/html/blank.html diff --git a/html/favicon.ico b/html/favicon.ico Binary files differindex 4deafd5..4deafd5 100644..100755 --- a/html/favicon.ico +++ b/html/favicon.ico diff --git a/html/frameset.html b/html/frameset.html index fe6b973..672f8fa 100644..100755 --- a/html/frameset.html +++ b/html/frameset.html @@ -1,19 +1,21 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title> - %%PGETITLE%% + %%ychat.version%% </title> </head> - <frameset rows="*,60"> + <frameset boders="0" rows="*,70"> <noframes> Your browser does not support frames, </noframes> <frameset cols="*,150"> - <frame src="stream.html?event=stream&nick=%%nick%%&tmpid=%%tmpid%%" name="stream"> - <frame src="online.html?event=online&nick=%%nick%%&tmpid=%%tmpid%%" name="online"> + <frame src="stream.html?event=stream&tmpid=%%tmpid%%" name="stream"> + <frame src="online.html?event=online&tmpid=%%tmpid%%" name="online"> </frameset> <frameset rows="*,0"> - <frame src="input.html?event=input&nick=%%nick%%&tmpid=%%tmpid%%" name="input"> + <frame src="input.html?event=input&tmpid=%%tmpid%%" name="input"> <frame src="blank.html" name="blank"> </frameset> </frameset> diff --git a/html/index.html b/html/index.html index 140272a..983e7ef 100644..100755 --- a/html/index.html +++ b/html/index.html @@ -1,31 +1,54 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title> - %%PGETITLE%% + %%ychat.version%% </title> +<link rel=stylesheet href="style.css" type=text/css> </head> <body> -Welcome to -<pre> - ___ _ _ - _ _ / __\ |__ __ _| |_ -| | | |/ / | '_ \ / _` | __| -| |_| / /___| | | | (_| | |_ - \__, \____/|_| |_|\__,_|\__| - |___/ -</pre> - -<br> -%%PGETITLE%% -<br> -<br> -%%INFO%% -Enter your nick: -<form action="frameset.html"> +<table align=center width=500> +<tr> +<td> +<center> +%%ychat.version%%<br><br>%%INFO%% +</center> +</td> +</tr> +<tr> +<td colspan=2> </td> +</tr> +<tr> +<td align=center colspan=2> +<form action="frameset.html" method="POST"> <input type="hidden" name="event" value="login"> - <input type="hidden" name="room" value="%%STRDROOM%%"> - <input type="text" name="nick"> - <input type="submit" 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">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 e6fb016..31ed9fe 100644..100755 --- a/html/input.html +++ b/html/input.html @@ -1,32 +1,60 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> - <head> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title> - %%PGETITLE%% + %%HTML_TITLE_TAG_CONTENT%% </title> + <link rel=stylesheet href="style.css" type=text/css> <script language="JavaScript"> <!-- function delout() { - document.input.message.focus(); - document.input.message.select(); + document.input.message.value = document.input.message.value.replace(/&/g, '\\AND'); document.input.submit(); + document.input.message.value = ""; + document.input.message.focus(); return false; } function selectinput() { document.input.message.select(); } + function popup(site,width,height) + { + var left = (screen.availWidth-width)/2; + 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> <body> - <form name="input" action="input.html" target="blank" onsubmit="return delout();"> - <input type="hidden" name="event" value="post"> - <input type="hidden" name="nick" value="%%nick%%"> + <form method="GET" name="input" action="input.html" target="blank" onsubmit="return delout();"> + <div style="position: absolute; top: 5px;"> + <input class="text" type="text" name="message" size="60" maxlength="%%chat.maxlength.message%%"> + <input type="submit" value="Send" accesskey='s'> + <input type="button" value="Select" accesskey='e' onclick="javascript:selectinput();"> + </div> + <div style="position: absolute; top: 29px;"> + <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%%"> - <input type="text" name="message" size="50"> - <input type="submit" value="send"> - <input type="button" value="select" onclick="javascript:selectinput();"> </form> </body> </html> diff --git a/html/notfound.html b/html/notfound.html index 574e341..a14d44b 100644..100755 --- a/html/notfound.html +++ b/html/notfound.html @@ -1,7 +1,9 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title> - %%PGETITLE%% + %%HTML_TITLE_TAG_CONTENT%% </title> </head> <body> diff --git a/html/online.html b/html/online.html index 7f29b0e..3eda553 100644..100755 --- a/html/online.html +++ b/html/online.html @@ -1,6 +1,20 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> - <meta http-equiv="refresh" content="20"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <link rel=stylesheet href="style.css" type=text/css> + </head> <body> - %%MESSAGE%% + <b>%%room%%</b> + <br> + <br> + <table> + <tr> + <td> + %%topic%% + </td> + </tr> + %%userlist%% + </table> </body> </html> diff --git a/html/stream.html b/html/stream.html index 66f8bbd..4814979 100644..100755 --- a/html/stream.html +++ b/html/stream.html @@ -1,29 +1,38 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> - <head> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title> - %%PGETITLE%% + %%HTML_TITLE_TAG_CONTENT%% </title> +<link rel=stylesheet href="style.css" type=text/css> <script language="JavaScript"> - function autoScroll() + var scrolling; + var ison; + function autoscroll() { - window.scroll(1, 50000 ); - timer = setTimeout('autoScroll()',200); + if(!ison){ + scrolling = window.setInterval("window.scroll(1,1606682)",70); + ison = true; + } } - - autoScroll(); - - function stopScroll() + function stopscroll() { - clearTimeout(timer); - } - - function startScroll() - { - timer = setTimeout('autoScroll()', 200); + if(ison) + { + window.clearInterval(scrolling); + ison = false; + } } </script> </head> -<body> - Welcome to yChat %%nick%%! +<body class="stream"> +<h1>Engine: %%ychat.version%%</h1> +<script language="JavaScript"> + autoscroll(); +</script> + + Welcome to the chat, %%nick%%! <br> <br> + diff --git a/log/access_log b/log/access_log new file mode 100644 index 0000000..aa9a3e2 --- /dev/null +++ b/log/access_log @@ -0,0 +1,41 @@ +127.0.0.1 - - [04/Aug/2005:00:50:17 +0000] "GET / HTTP/1.1" 200 0 "index.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:17 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:50:21 +0000] "POST /frameset.html HTTP/1.1" 200 0 "frameset.html" "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.10) Gecko/20050722 Epiphany/1.6.4" +127.0.0.1 - - [04/Aug/2005:00:50:21 +0000] "GET /input.html?event=input&tmpid=0n81ffo3r9a_2.p_f0b81eer8py4idfoxAZ2HCXcvWcjChcXeShR1 HTTP/1.1" 200 0 "input.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:21 +0000] "GET /online.html?event=online&tmpid=0n81ffo3r9a_2.p_f0b81eer8py4idfoxAZ2HCXcvWcjChcXeShR1 HTTP/1.1" 200 0 "online.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:21 +0000] "GET /blank.html HTTP/1.1" 200 0 "blank.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:21 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:50:22 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:50:24 +0000] "GET /input.html?message=sdfsdf&scroll=on&event=input&tmpid=0n81ffo3r9a_2.p_f0b81eer8py4idfoxAZ2HCXcvWcjChcXeShR1 HTTP/1.1" 200 0 "input.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:24 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:50:24 +0000] "GET /input.html?message=fds&scroll=on&event=input&tmpid=0n81ffo3r9a_2.p_f0b81eer8py4idfoxAZ2HCXcvWcjChcXeShR1 HTTP/1.1" 200 0 "input.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:24 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:50:24 +0000] "GET /input.html?message=sdf&scroll=on&event=input&tmpid=0n81ffo3r9a_2.p_f0b81eer8py4idfoxAZ2HCXcvWcjChcXeShR1 HTTP/1.1" 200 0 "input.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:24 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:50:25 +0000] "GET /input.html?message=fsd&scroll=on&event=input&tmpid=0n81ffo3r9a_2.p_f0b81eer8py4idfoxAZ2HCXcvWcjChcXeShR1 HTTP/1.1" 200 0 "input.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:25 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:50:30 +0000] "GET /input.html?event=input&tmpid=0n81ffo3r9a_2.p_f0b81eer8py4idfoxAZ2HCXcvWcjChcXeShR1&message=%2Fq HTTP/1.1" 200 0 "input.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:30 +0000] "GET /stream.html?event=stream&tmpid=0n81ffo3r9a_2.p_f0b81eer8py4idfoxAZ2HCXcvWcjChcXeShR1 HTTP/1.1" 200 0 "stream.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:30 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:50:30 +0000] "GET /index.html HTTP/1.1" 200 0 "index.html" "" +127.0.0.1 - - [04/Aug/2005:00:50:30 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:51:02 +0000] "POST /frameset.html HTTP/1.1" 200 0 "frameset.html" "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.10) Gecko/20050722 Epiphany/1.6.4" +127.0.0.1 - - [04/Aug/2005:00:51:02 +0000] "GET /online.html?event=online&tmpid=wkhkmpvcub33ji_9qz61k8wwho6dtjplrbm4SI.I912ZU/.zHQFd0 HTTP/1.1" 200 0 "online.html" "" +127.0.0.1 - - [04/Aug/2005:00:51:02 +0000] "GET /input.html?event=input&tmpid=wkhkmpvcub33ji_9qz61k8wwho6dtjplrbm4SI.I912ZU/.zHQFd0 HTTP/1.1" 200 0 "input.html" "" +127.0.0.1 - - [04/Aug/2005:00:51:02 +0000] "GET /blank.html HTTP/1.1" 200 0 "blank.html" "" +127.0.0.1 - - [04/Aug/2005:00:51:03 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:51:03 +0000] "GET /online.html?event=online&tmpid=wkhkmpvcub33ji_9qz61k8wwho6dtjplrbm4SI.I912ZU/.zHQFd0 HTTP/1.1" 200 0 "online.html" "" +127.0.0.1 - - [04/Aug/2005:00:51:03 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:51:03 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:51:03 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:51:03 +0000] "GET /images/guest.png HTTP/1.1" 200 0 "images/guest.png" "" +127.0.0.1 - - [04/Aug/2005:00:51:59 +0000] "POST /frameset.html HTTP/1.1" 200 0 "frameset.html" "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.10) Gecko/20050722 Epiphany/1.6.4" +127.0.0.1 - - [04/Aug/2005:00:51:59 +0000] "GET /online.html?event=online&tmpid=zcsiafk16x20ad8_kgk.q2p6qiy0el3723/8msn2stvGQi47h1rW0 HTTP/1.1" 200 0 "online.html" "" +127.0.0.1 - - [04/Aug/2005:00:51:59 +0000] "GET /input.html?event=input&tmpid=zcsiafk16x20ad8_kgk.q2p6qiy0el3723/8msn2stvGQi47h1rW0 HTTP/1.1" 200 0 "input.html" "" +127.0.0.1 - - [04/Aug/2005:00:51:59 +0000] "GET /blank.html HTTP/1.1" 200 0 "blank.html" "" +127.0.0.1 - - [04/Aug/2005:00:51:59 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:52:00 +0000] "GET /online.html?event=online&tmpid=zcsiafk16x20ad8_kgk.q2p6qiy0el3723/8msn2stvGQi47h1rW0 HTTP/1.1" 200 0 "online.html" "" +127.0.0.1 - - [04/Aug/2005:00:52:00 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:52:00 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:52:00 +0000] "GET /style.css HTTP/1.1" 200 0 "style.css" "" +127.0.0.1 - - [04/Aug/2005:00:52:01 +0000] "GET /images/guest.png HTTP/1.1" 200 0 "images/guest.png" "" diff --git a/log/rooms/lounge b/log/rooms/lounge new file mode 100644 index 0000000..201be83 --- /dev/null +++ b/log/rooms/lounge @@ -0,0 +1,8 @@ +[04/Aug/2005:00:50:21 +0000] 02:50:20 sdfsdfs enters the chat. +[04/Aug/2005:00:50:24 +0000] 02:50:23 sdfsdfs: sdfsdf +[04/Aug/2005:00:50:24 +0000] 02:50:24 sdfsdfs: fds +[04/Aug/2005:00:50:24 +0000] 02:50:24 sdfsdfs: sdf +[04/Aug/2005:00:50:25 +0000] 02:50:24 sdfsdfs: fsd +[04/Aug/2005:00:50:30 +0000] 02:50:29 sdfsdfs leaves the chat. +[04/Aug/2005:00:51:02 +0000] 02:51:02 sdfsdf enters the chat. +[04/Aug/2005:00:51:59 +0000] 02:51:58 sdfsdf enters the chat. diff --git a/log/system_log b/log/system_log new file mode 100644 index 0000000..3a9dffc --- /dev/null +++ b/log/system_log @@ -0,0 +1,114 @@ +[04/Aug/2005:00:42:06 +0000] Sock: Created socket on localhost:2000 +[04/Aug/2005:00:42:06 +0000] Pool: Allocating new threads (10,0) +[04/Aug/2005:00:42:06 +0000] Reading standard command exec permissions +[04/Aug/2005:00:42:06 +0000] Chat: Using replacement strings +[04/Aug/2005:00:42:06 +0000] Timer: Initializing +[04/Aug/2005:00:42:06 +0000] Timer: Setting offset to 0 +[04/Aug/2005:00:42:07 +0000] Garbage: Initializing collector +[04/Aug/2005:00:42:07 +0000] Sock: Initializing server socket +[04/Aug/2005:00:42:07 +0000] Sock: Starting unsecure transport [HTTP] +[04/Aug/2005:00:42:07 +0000] Sock: Server socket is ready +[04/Aug/2005:00:42:07 +0000] Timer: Starting timer thread +[04/Aug/2005:00:49:58 +0000] Sock: Bind error +[04/Aug/2005:00:49:58 +0000] Sock: Can't create socket, trying next port 2001 +[04/Aug/2005:00:49:58 +0000] Sock: Created socket on localhost:2001 +[04/Aug/2005:00:49:58 +0000] Pool: Allocating new threads (10,0) +[04/Aug/2005:00:49:58 +0000] Reading standard command exec permissions +[04/Aug/2005:00:49:58 +0000] Chat: Using replacement strings +[04/Aug/2005:00:49:58 +0000] Timer: Initializing +[04/Aug/2005:00:49:58 +0000] Timer: Setting offset to 0 +[04/Aug/2005:00:49:58 +0000] Garbage: Initializing collector +[04/Aug/2005:00:49:58 +0000] Sock: Initializing server socket +[04/Aug/2005:00:49:58 +0000] Sock: Starting unsecure transport [HTTP] +[04/Aug/2005:00:49:58 +0000] Sock: Server socket is ready +[04/Aug/2005:00:49:58 +0000] Timer: Starting timer thread +[04/Aug/2005:00:50:07 +0000] Sock: Bind error +[04/Aug/2005:00:50:07 +0000] Sock: Can't create socket, trying next port 2001 +[04/Aug/2005:00:50:07 +0000] Sock: Created socket on localhost:2001 +[04/Aug/2005:00:50:08 +0000] Pool: Allocating new threads (10,0) +[04/Aug/2005:00:50:08 +0000] Reading standard command exec permissions +[04/Aug/2005:00:50:08 +0000] Chat: Using replacement strings +[04/Aug/2005:00:50:08 +0000] Timer: Initializing +[04/Aug/2005:00:50:08 +0000] Timer: Setting offset to 0 +[04/Aug/2005:00:50:08 +0000] Garbage: Initializing collector +[04/Aug/2005:00:50:08 +0000] Sock: Initializing server socket +[04/Aug/2005:00:50:08 +0000] Sock: Starting unsecure transport [HTTP] +[04/Aug/2005:00:50:08 +0000] Sock: Server socket is ready +[04/Aug/2005:00:50:08 +0000] Timer: Starting timer thread +[04/Aug/2005:00:50:17 +0000] Sock: Caching IP 127.0.0.1 +[04/Aug/2005:00:50:17 +0000] HTML: Caching document html/index.html +[04/Aug/2005:00:50:17 +0000] HTML: Caching document html/style.css +[04/Aug/2005:00:50:21 +0000] New tmpid: 0n81ffo3r9a_2.p_f0b81eer8py4idfoxAZ2HCXcvWcjChcXeShR1 +[04/Aug/2005:00:50:21 +0000] Chat: New room Lounge +[04/Aug/2005:00:50:21 +0000] Chat: New user sdfsdfs +[04/Aug/2005:00:50:21 +0000] HTML: Caching document html/frameset.html +[04/Aug/2005:00:50:21 +0000] HTML: Caching document html/stream.html +[04/Aug/2005:00:50:21 +0000] HTML: Caching document html/input.html +[04/Aug/2005:00:50:21 +0000] HTML: Caching document html/online.html +[04/Aug/2005:00:50:21 +0000] HTML: Caching document html/blank.html +[04/Aug/2005:00:50:30 +0000] Modl: Requesting yc_q.so (sdfsdfs) +[04/Aug/2005:00:50:30 +0000] Garbage: Added room Lounge +[04/Aug/2005:00:50:30 +0000] Garbage: Added user sdfsdfs +[04/Aug/2005:00:50:34 +0000] Garbage collector activated +[04/Aug/2005:00:50:34 +0000] Garbage: Removing room Lounge +[04/Aug/2005:00:50:34 +0000] Garbage: Removing user sdfsdfs +[04/Aug/2005:00:50:59 +0000] Sock: Bind error +[04/Aug/2005:00:50:59 +0000] Sock: Can't create socket, trying next port 2001 +[04/Aug/2005:00:50:59 +0000] Sock: Created socket on localhost:2001 +[04/Aug/2005:00:50:59 +0000] Pool: Allocating new threads (10,0) +[04/Aug/2005:00:50:59 +0000] Reading standard command exec permissions +[04/Aug/2005:00:50:59 +0000] Chat: Using replacement strings +[04/Aug/2005:00:50:59 +0000] Timer: Initializing +[04/Aug/2005:00:50:59 +0000] Timer: Setting offset to 0 +[04/Aug/2005:00:50:59 +0000] Garbage: Initializing collector +[04/Aug/2005:00:50:59 +0000] Sock: Initializing server socket +[04/Aug/2005:00:50:59 +0000] Sock: Starting unsecure transport [HTTP] +[04/Aug/2005:00:50:59 +0000] Sock: Server socket is ready +[04/Aug/2005:00:50:59 +0000] Timer: Starting timer thread +[04/Aug/2005:00:51:02 +0000] Sock: Caching IP 127.0.0.1 +[04/Aug/2005:00:51:02 +0000] New tmpid: wkhkmpvcub33ji_9qz61k8wwho6dtjplrbm4SI.I912ZU/.zHQFd0 +[04/Aug/2005:00:51:02 +0000] Chat: New room Lounge +[04/Aug/2005:00:51:02 +0000] Chat: New user sdfsdf +[04/Aug/2005:00:51:02 +0000] HTML: Caching document html/frameset.html +[04/Aug/2005:00:51:02 +0000] HTML: Caching document html/online.html +[04/Aug/2005:00:51:02 +0000] HTML: Caching document html/stream.html +[04/Aug/2005:00:51:02 +0000] HTML: Caching document html/input.html +[04/Aug/2005:00:51:02 +0000] HTML: Caching document html/blank.html +[04/Aug/2005:00:51:03 +0000] HTML: Caching document html/style.css +[04/Aug/2005:00:51:03 +0000] HTML: Caching document html/images/guest.png +[04/Aug/2005:00:51:53 +0000] Sock: Bind error +[04/Aug/2005:00:51:53 +0000] Sock: Can't create socket, trying next port 2001 +[04/Aug/2005:00:51:53 +0000] Sock: Created socket on localhost:2001 +[04/Aug/2005:00:51:54 +0000] Pool: Allocating new threads (10,0) +[04/Aug/2005:00:51:54 +0000] Reading standard command exec permissions +[04/Aug/2005:00:51:54 +0000] Chat: Using replacement strings +[04/Aug/2005:00:51:54 +0000] Timer: Initializing +[04/Aug/2005:00:51:54 +0000] Timer: Setting offset to 0 +[04/Aug/2005:00:51:54 +0000] Garbage: Initializing collector +[04/Aug/2005:00:51:54 +0000] Sock: Initializing server socket +[04/Aug/2005:00:51:54 +0000] Sock: Starting unsecure transport [HTTP] +[04/Aug/2005:00:51:54 +0000] Sock: Server socket is ready +[04/Aug/2005:00:51:54 +0000] Timer: Starting timer thread +[04/Aug/2005:00:51:59 +0000] Sock: Caching IP 127.0.0.1 +[04/Aug/2005:00:51:59 +0000] Chat: New room Lounge +[04/Aug/2005:00:51:59 +0000] Chat: New user sdfsdf +[04/Aug/2005:00:51:59 +0000] HTML: Caching document html/frameset.html +[04/Aug/2005:00:51:59 +0000] HTML: Caching document html/online.html +[04/Aug/2005:00:51:59 +0000] HTML: Caching document html/stream.html +[04/Aug/2005:00:51:59 +0000] HTML: Caching document html/input.html +[04/Aug/2005:00:51:59 +0000] HTML: Caching document html/blank.html +[04/Aug/2005:00:51:59 +0000] HTML: Caching document html/style.css +[04/Aug/2005:00:52:01 +0000] HTML: Caching document html/images/guest.png +[04/Aug/2005:01:08:20 +0000] Sock: Bind error +[04/Aug/2005:01:08:20 +0000] Sock: Can't create socket, trying next port 2001 +[04/Aug/2005:01:08:20 +0000] Sock: Created socket on localhost:2001 +[04/Aug/2005:01:08:20 +0000] Pool: Allocating new threads (10,0) +[04/Aug/2005:01:08:20 +0000] Reading standard command exec permissions +[04/Aug/2005:01:08:20 +0000] Chat: Using replacement strings +[04/Aug/2005:01:08:20 +0000] Timer: Initializing +[04/Aug/2005:01:08:20 +0000] Timer: Setting offset to 0 +[04/Aug/2005:01:08:20 +0000] Garbage: Initializing collector +[04/Aug/2005:01:08:20 +0000] Sock: Initializing server socket +[04/Aug/2005:01:08:20 +0000] Sock: Starting unsecure transport [HTTP] +[04/Aug/2005:01:08:20 +0000] Sock: Server socket is ready +[04/Aug/2005:01:08:21 +0000] Timer: Starting timer thread 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 8f67195..b9dbc45 100755 --- a/scripts/astyle.sh +++ b/scripts/astyle.sh @@ -1,5 +1,5 @@ #!/bin/sh -# The yhttpd Project (2004) +# The yChat Project (2004) # # This uses "astyle" to format C++ code into a specific code style! diff --git a/scripts/buildnr.pl b/scripts/buildnr.pl index edfffd6..ee3d3e2 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/checkperl.sh b/scripts/checkperl.sh index 642938b..fa5e98f 100755 --- a/scripts/checkperl.sh +++ b/scripts/checkperl.sh @@ -1,5 +1,5 @@ #!/bin/sh -# The yhttpd Project (2005) +# The yChat Project (2005) # # This scripts checks for a perl installation diff --git a/scripts/config.pl b/scripts/config.pl index af58012..73b3ae5 100755 --- a/scripts/config.pl +++ b/scripts/config.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# The yhttpd Project (2004, 2005) +# The yChat Project (2004, 2005) # # This script modifues the src/glob.h file. @@ -8,27 +8,24 @@ use strict; 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; -for (;;) -{ +for (;;) { print "$sep Do you want to use the default before-compile options?\n"; print " (yes/no) [default is NO] "; $stdin = <STDIN>; chomp $stdin; - prove_if_default(\$stdin); print "\n"; - if ( $stdin eq "yes") - { + if ( $stdin eq "yes") { print " You chose to use all the default before-compile options. Exiti-\n"; print " ng the configurator now!\n"; print $sep; @@ -44,46 +41,37 @@ for (;;) my @glob = fopen("src/glob.h.org"); my $flag = 0; -for (@glob) -{ - if ( $flag == 0 && /- CONFIG -/ ) - { +for (@glob) { + if ( $flag == 0 && /- CONFIG -/ ) { print $sep; $flag = 1; next; - } - elsif ( $flag == 1 ) - { - if ( /\*\// ) - { + } elsif ( $flag == 1 ) { + if ( /\*\// ) { $flag = 2; - } - else - { + } else { print; } next; - } - elsif ( $flag == 2 ) - { - if ( /#define (.+) (.+)/ ) - { + } elsif ( $flag == 2 ) { + if ( /#define (.+) (.+)/ ) { my $def = $1; my $val = $2; my $flg = 0; $flg = 1 if $val =~ s/"//g; - print " [Press enter to use default value: $val] "; + print " [Press enter to use default value: $val or q to quit] "; $stdin = <STDIN>; chomp $stdin; - unless ( prove_if_default(\$stdin) ) - { + finish() if $stdin eq "q" or $stdin eq "quit"; + + unless ( parse_input_value(\$stdin,\$val) ) { $stdin = "\"$stdin\"" if $flg == 1; $_ = "#define $def $stdin\n"; } @@ -93,33 +81,28 @@ for (@glob) next; } - elsif ( /#define .+/ ) - { + elsif ( /#define .+/ ) { my $default = "true"; my $stdin; - for (;;) - { + for (;;) { $default = "false" if /\/\/#define/; - print " [Press enter to use default value: $default] "; + print " [Press enter to use default value: $default or q to quit] "; $stdin = <STDIN>; chomp $stdin; + finish() if $stdin eq "q" or $stdin eq "quit"; last if $stdin eq "" || $stdin eq "true" || $stdin eq "false"; print " Wrong input: You need to specify true or false!\n"; } - if ( $default eq "true" ) - { - $_ = "//$_" - unless prove_if_default(\$stdin); + if ( $default eq "true" ) { + $_ = "//$_" unless parse_input_value(\$stdin,\$default); } - else - { - s/^\/\/// - unless prove_if_default(\$stdin); + else { + s/^\/\/// unless parse_input_value(\$stdin,\$default); } print "\n"; @@ -129,16 +112,22 @@ for (@glob) } } // for - fwrite("src/glob.h", @glob); +finish(); + +sub finish() { + fwrite("src/glob.h", @glob); + exit 0; +} -sub prove_if_default -{ +sub parse_input_value { my $val = shift; - if ( $$val eq "" ) - { + my $def = shift; + + if ( $$val eq "" || $$val eq $$def) { print " -> Using default option!\n"; return 1; } + print " -> Using new option $$val!\n"; return 0; } diff --git a/scripts/makedist.sh b/scripts/makedist.sh index 0814611..6c51a07 100755 --- a/scripts/makedist.sh +++ b/scripts/makedist.sh @@ -1,5 +1,5 @@ #!/bin/sh -# The yhttpd Project (2005) +# The yChat Project (2005) # # This script creates a .tar.bz2 ball. 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/version.sh b/scripts/version.sh index 50c189c..46b9fc5 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -1,11 +1,11 @@ #!/bin/sh -# The yhttpd Project (2005) +# The yChat Project (2005) # -# This script shows yhttpd VERSION-BRANCH Build BUILDNUMBER +# This script shows yChat VERSION-BRANCH Build BUILDNUMBER version=`grep VERSION src/msgs.h | head -n 1 | cut -d'"' -f2` branch=`grep BRANCH src/msgs.h | head -n 1 | cut -d'"' -f2` build=`grep BUILD src/msgs.h | tail -n 1 | cut -d' ' -f3` -echo "yhttpd $version-$branch Build $build" +echo "yChat $version-$branch Build $build" 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/chat.cpp b/src/chat/chat.cpp index e405472..ed8f48d 100755 --- a/src/chat/chat.cpp +++ b/src/chat/chat.cpp @@ -170,7 +170,6 @@ chat::login( map<string,string> &map_params ) map_params["tmpid"] = p_sess->get_tmpid(); p_user->set_tmpid( map_params["tmpid"] ); p_user->set_has_sess( true ); - wrap::system_message("New tmpid: " + map_params["tmpid"] ); } } else // if ( p_user == NULL ) // If not in garbage create a new user! @@ -224,7 +223,6 @@ chat::login( map<string,string> &map_params ) sess* p_sess = wrap::SMAN->create_session(); p_sess->set_user(p_user); map_params["tmpid"] = p_sess->get_tmpid(); - wrap::system_message("New tmpid: " + map_params["tmpid"] ); p_user->set_tmpid( map_params["tmpid"] ); p_user->set_col1( map_params["color1"] ); p_user->set_col2( map_params["color2"] ); @@ -328,6 +326,13 @@ chat::post( user* p_user, map<string,string> &map_params ) if ( i_pos == 0 ) return p_user->command( s_msg ); + if (p_user->get_is_gag()) + { + p_user->msg_post(wrap::CONF->colored_error_msg("chat.msgs.err.gagged")); + return; + } + + string_replacer(&s_msg); string s_post; diff --git a/src/chat/user.cpp b/src/chat/user.cpp index 2b76ec8..eb49f8c 100755 --- a/src/chat/user.cpp +++ b/src/chat/user.cpp @@ -25,6 +25,7 @@ user::~user() pthread_mutex_destroy( & mut_b_invisible ); pthread_mutex_destroy( & mut_b_has_sess ); pthread_mutex_destroy( & mut_b_is_reg ); + pthread_mutex_destroy( & mut_b_is_gag ); pthread_mutex_destroy( & mut_s_mess ); pthread_mutex_destroy( & mut_s_pass ); pthread_mutex_destroy( & mut_p_room ); @@ -41,11 +42,14 @@ user::~user() void user::initialize() { + time(&t_flood_time); init_strings(wrap::CONF->get_vector("chat.fields.userstrings")); init_ints(wrap::CONF->get_vector("chat.fields.userints")); init_bools(wrap::CONF->get_vector("chat.fields.userbools")); + this -> p_room = 0; this -> b_is_reg = false; + this -> b_is_gag = false; this -> b_set_changed_data = false; this -> b_away = false; this -> b_fake = false; @@ -60,6 +64,7 @@ user::initialize() 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_b_is_gag , NULL ); pthread_mutex_init( & mut_s_mess , NULL ); pthread_mutex_init( & mut_s_pass , NULL ); pthread_mutex_init( & mut_p_room , NULL ); @@ -72,7 +77,6 @@ user::initialize() pthread_cond_init ( &cond_message, NULL); pthread_mutex_init( &mut_message , NULL); renew_timeout(); - } void @@ -181,6 +185,16 @@ user::get_is_reg( ) return b_ret; } +bool +user::get_is_gag( ) +{ + bool b_ret; + pthread_mutex_lock ( &mut_b_is_gag ); + b_ret = b_is_gag; + pthread_mutex_unlock( &mut_b_is_gag ); + return b_ret; +} + void user::set_is_reg( bool b_is_reg ) { @@ -188,6 +202,14 @@ user::set_is_reg( bool b_is_reg ) } void +user::set_is_gag( bool b_is_gag ) +{ + pthread_mutex_lock ( &mut_b_is_gag ); + this -> b_is_gag = b_is_gag; + pthread_mutex_unlock( &mut_b_is_gag ); +} + +void user::set_online( bool b_online ) { pthread_mutex_lock ( &mut_b_online ); @@ -489,13 +511,52 @@ user::msg_post( string *p_msg ) } void -user::check_timeout( int* i_idle_timeout ) +user::post_action_msg(string s_msgkey) +{ + get_room()->msg_post(wrap::TIMR->get_time()+" "+get_colored_bold_name()+wrap::CONF->get_elem(s_msgkey)+"<br>\n"); +} + +void +user::renew_timeout() { - int i_user_timeout = (int) get_last_activity(); + timo::renew_timeout(); + double d_time_diff = wrap::TIMR->get_time_diff(t_flood_time); - if ( get_away() ? i_idle_timeout[1] <= i_user_timeout : i_idle_timeout[0] <= i_user_timeout ) + if (d_time_diff < static_cast<double>(wrap::CONF->get_int("chat.floodprotection.seconds"))) { - wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")"); + if (++i_flood_messages > static_cast<double>(wrap::CONF->get_int("chat.floodprotection.messages"))) + { + room* p_room = get_room(); + if (p_room == 0) + { + i_flood_messages = 0; + return; + } + + wrap::system_message(CHATFLO+get_name()+","+p_room->get_name()+","+tool::int2string(i_flood_messages)+")"); + msg_post(wrap::CONF->colored_error_msg("chat.msgs.err.flooding")); + if (!get_is_gag()) + { + set_is_gag(true); + post_action_msg("chat.msgs.floodgag"); + } + } + } + + else + { + time(&t_flood_time); + i_flood_messages = 0; + } +} + +void +user::check_timeout( int* i_idle_timeout ) +{ + double d_user_timeout = get_last_activity(); + if ( get_away() ? i_idle_timeout[1] <= d_user_timeout : i_idle_timeout[0] <= d_user_timeout ) + { + wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string((int)d_user_timeout) + ")"); string s_quit = "<script language=JavaScript>top.location.href='/" + wrap::CONF->get_elem("httpd.startsite") + "';</script>"; @@ -504,9 +565,9 @@ user::check_timeout( int* i_idle_timeout ) pthread_cond_signal( &cond_message ); } - else if ( ! get_away() && i_idle_timeout[2] <= i_user_timeout ) + else if ( ! get_away() && i_idle_timeout[2] <= d_user_timeout ) { - wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")"); + wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string((int)d_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"; @@ -599,5 +660,17 @@ user::dumpit() ("TempID: " + get_tmpid()); } +bool +user::same_rooms(user *p_user) +{ + return p_user->get_room()->get_lowercase_name() + .compare(this->get_room()->get_lowercase_name()) == 0; +} + +string +user::make_colors(string s_msg) +{ + return "<font color=\"#" + get_col1() + "\">" + s_msg + "</font>"; +} #endif diff --git a/src/chat/user.h b/src/chat/user.h index 62814b5..06310ca 100755 --- a/src/chat/user.h +++ b/src/chat/user.h @@ -23,16 +23,19 @@ private: // private members: string s_mess; // message string which has to be sent to the user. - 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) - bool b_set_changed_data; // Only set change data if required! - - int i_status; // user's rang ( see enum rang @ globals.h ). - int i_old_status; // user's previous status. + 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_is_gag; // true if user is gagged + 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) + bool b_set_changed_data; // Only set change data if required! + + int i_status; // user's rang ( see enum rang @ globals.h ). + int i_old_status; // user's previous status. + int i_flood_messages; // user's message posts (needed for flood protection, does not need to be syncronized) + time_t t_flood_time; // user's time count (needed for flood protection, does not need to be syncronized) string s_tmpid; string s_agnt; // user's http user agent. @@ -55,6 +58,7 @@ private: pthread_mutex_t mut_b_invisible; pthread_mutex_t mut_b_has_sess; pthread_mutex_t mut_b_is_reg; + pthread_mutex_t mut_b_is_gag; pthread_mutex_t mut_s_pass; pthread_mutex_t mut_p_room; pthread_mutex_t mut_s_col1; @@ -94,15 +98,14 @@ public: bool get_invisible(); bool get_has_sess(); bool get_is_reg(); + bool get_is_gag(); 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; - } + void set_is_gag( bool b_is_gag ); + 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 ); @@ -122,7 +125,9 @@ public: int get_status( ); void set_status( int i_status ); bool new_msgs ( ); + void post_action_msg(string s_msgkey); void check_timeout( int* i_idle_timeout ); + void renew_timeout(); // executes a command. void command( string &s_command ); @@ -142,6 +147,8 @@ public: void get_user_list( string &s_list ); void check_restore_away(); void reconf(); + bool same_rooms(user *p_user); + string make_colors(string s_msg); }; #endif diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 0adddb1..0e7b531 100755 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -31,7 +31,7 @@ cli::parse_input( string s_input ) if ( s_input.compare("help") == 0 || s_input.compare("h") == 0) { cout << CLIPRMO << "COMMAND LINE INTERFACE HELP MENU" << endl - << CLIPRMO << " !command - Uses system to run a command" << endl; + << CLIPRMO << " !command - Uses system to run a command" << endl; #ifdef DEBUG cout << CLIPRMO << " (d)ebug - Starts debug routine (cli.cpp)" << endl; @@ -47,17 +47,22 @@ cli::parse_input( string s_input ) #endif cout << CLIPRMO << " (h)elp - Prints out this help!" << endl; + //<<* + cout << CLIPRMO << " (m)ysql - Runs MySQL client on yChat DB" << endl + << 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 << CLIPRMO << " (t)ime - Prints out time and uptime" << endl; + cout << CLIPRMO << " (unl)oad - Unloads all loaded modules" << endl;//<< cout << CLIPRMO << " (u)nset VAR - Deletes configuration value VAR" << endl << CLIPRMO << " (v)ersion - Prints out version" << endl; cout << CLIPRMI; @@ -110,6 +115,19 @@ cli::parse_input( string s_input ) cout << CLIPRMI; } + //<<* + else if( s_input.compare("mysql") == 0 || s_input.compare("m") == 0 ) + { + cout << CLIPRMO << CLIMSQL << endl; + + system((wrap::CONF->get_elem("chat.system.mysqlclient") + " -p -h " + + wrap::CONF->get_elem("chat.database.serverhost") + " -u " + + wrap::CONF->get_elem("chat.database.user") ).c_str()); + + cout << CLIPRMO << CLIWELC << endl; + cout << CLIPRMI; + } + //*>> #ifdef NCURSES else if( s_input.compare("exit") == 0 || s_input.compare("ex") == 0 ) @@ -118,11 +136,20 @@ cli::parse_input( string s_input ) } #endif + //<<* + else if( s_input.compare("reload") == 0 || s_input.compare("rel") == 0 ) + { + cout << CLIPRMO; + wrap::MODL->reload_modules(); + cout << MODRELO << endl; + cout << CLIPRMI; + } + //*>> #ifdef EXPERIM else if( s_input.compare("reconf") == 0 || s_input.compare("re") == 0 ) { - wrap::HTTPD->reconf(); + wrap::CHAT->reconf(); cout << CLIPRMI; } #endif @@ -183,6 +210,15 @@ cli::parse_input( string s_input ) cout << CLIPRMI; } + //<<* + else if( s_input.compare("unl") == 0 || s_input.compare("unload") == 0 ) + { + cout << CLIPRMO; + wrap::MODL->unload_modules(); + cout << MODUNLO << endl; + cout << CLIPRMI; + } + //*>> else if( s_input.compare("u") == 0 || s_input.compare("unset") == 0 ) { @@ -203,7 +239,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 @@ -259,7 +295,7 @@ cli::print_rusage() } vector<string> -cli::vectorize(string s_param) +cli::vectorize(string s_param) { vector<string> vec_ret; unsigned i_pos; diff --git a/src/cli/cli.h b/src/cli/cli.h index 7d51e3f..8ec75cb 100755 --- a/src/cli/cli.h +++ b/src/cli/cli.h @@ -30,30 +30,30 @@ using namespace std; class cli : public thro { #else -class cli +class cli { #endif private: int parse_input(string s_input); vector<string> vectorize(string s_param); - + public: -cli( ); -~cli( ); + cli( ); + ~cli( ); #ifdef DEBUG -void debug_routine(); + void debug_routine(); #endif -void print_rusage(); + void print_rusage(); #ifndef NCURSES -void start(void* p_void); + void start(void* p_void); #else -void start(); + void start(); #endif }; diff --git a/src/conf/conf.cpp b/src/conf/conf.cpp index 5d5a535..a4a2679 100755 --- a/src/conf/conf.cpp +++ b/src/conf/conf.cpp @@ -6,11 +6,11 @@ using namespace std; -conf::conf( string s_conf, map<string,string>* p_start_params ) : name::name( s_conf ) +conf::conf( string s_conf, map<string,string>* p_main_loop_params ) : name::name( s_conf ) { 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()) }; @@ -54,11 +54,11 @@ conf::conf( string s_conf, map<string,string>* p_start_params ) : name::name( s_ vector<string> vec_string; parse_xml(p_xml, &vec_string); - shashmap<string>::add_elem_insecure(tool::yhttpd_version(), "yhttpd.version"); + shashmap<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++ ) + for ( iter = p_main_loop_params->begin(); iter != p_main_loop_params->end(); iter++ ) { shashmap<string>::del_elem_insecure(iter->first); shashmap<string>::add_elem_insecure(iter->second, iter->first); @@ -161,11 +161,35 @@ conf::exit_if_xml_error() const } } +//<<* +string +conf::colored_error_msg(string s_key) +{ + return "<font color=\"#" + + shashmap<string>::get_elem("chat.html.errorcolor") + + "\">" + shashmap<string>::get_elem(s_key) + "</font><br>\n"; +} +//*>> int conf::get_int(string s_key) { - return tool::string2int(get_elem(s_key)); + return tool::string2int(get_elem(s_key)); } +vector<string> +conf::get_vector(string s_key) +{ + vector<string> vec_ret; + string s_val = get_elem(s_key); + + for (unsigned i_pos = s_val.find(" "); i_pos != string::npos; i_pos = s_val.find(" ")) + { + vec_ret.push_back(s_val.substr(0, i_pos)); + s_val = s_val.substr(i_pos+1); + } + + vec_ret.push_back(s_val); + return vec_ret; +} #endif diff --git a/src/conf/conf.h b/src/conf/conf.h index b385059..7dc779c 100755 --- a/src/conf/conf.h +++ b/src/conf/conf.h @@ -19,10 +19,12 @@ private: void parse_xml( TiXmlNode* p_node, vector<string>* p_vec); public: - conf(string s_conf, map<string,string>* p_start_params); + conf(string s_conf, map<string,string>* p_main_loop_params); ~conf(); - int get_int(string s_key); + string colored_error_msg(string s_key); //<< + int get_int(string s_key); + vector<string> get_vector(string s_key); }; #endif diff --git a/src/configure b/src/configure index 5577c10..43854d8 100755 --- a/src/configure +++ b/src/configure @@ -1,7 +1,7 @@ #!/bin/sh # -# The yhttpd Project (2003 - 2005) +# The yChat Project (2003 - 2005) # if ! ../scripts/checkperl.sh @@ -26,14 +26,19 @@ perl -e ' my @headers = ( "dlfcn.h", "pthread.h", + "mysql/mysql.h", #//<< Not needed for yhttpd "netinet/in.h", "time.h", "ncurses.h", + "openssl/ssl.h", "::test::ext/hash_map" ); my @libs = ( - "libncurses.so" + "libmysqlclient.so", #//<< Not needed for yhttpd + "libncurses.so", + "libssl.so", + "libcrypto.so" ); my @headerpaths = ( @@ -59,36 +64,76 @@ perl -e ' "/opt/local/lib" ); + my %dependfiles = ( + database => ["data"], + ycurses => ["curses", "ycui.cpp", "ycui.h"], + logging => ["logd.cpp", "logd.h"], + cli => ["cli"], + opnssl => ["sock/sslsock.cpp", "sock/sslsock.h"] + ); + open FILE, "glob.h" or die "glob.h: $!\n"; - while(<FILE>) - { - if ( /\/\/#define DATABASE/ ) - { + while(<FILE>) { + if ( /\/\/#define DATABASE/ ) { remove_from_array("mysql/mysql.h",\@headers); remove_from_array("libmysqlclient.so",\@libs); + mkdir "../backuped" unless -d "../backuped"; + `mv $_ ../backuped` for @{$dependfiles{database}}; + } + + elsif ( /^#define DATABASE/ && !-d "data") { + `mv ../backuped/$_ .` for @{$dependfiles{database}}; + } + + if ( /\/\/#define LOGGING/ ) { + mkdir "../backuped" unless -d "../backuped"; + `mv $_ ../backuped` for @{$dependfiles{logging}}; + } + + elsif ( /^#define LOGGING/ && !-f "logd.cpp") { + `mv ../backuped/$_ .` for @{$dependfiles{logging}}; + } + + if ( /\/\/#define CLI/ ) { + mkdir "../backuped" unless -d "../backuped"; + `mv $_ ../backuped` for @{$dependfiles{cli}}; + } + + elsif ( /^#define CLI/ && !-d "cli") { + `mv ../backuped/$_ .` for @{$dependfiles{cli}}; } - if ( /\/\/#define NCURSES/ ) - { - remove_from_array("ncurses.h",\@headers); - remove_from_array("libncurses.so",\@libs); + if ( /\/\/#define YCURSES/ ) { + for ("ncurses", "menu", "panel") { + remove_from_array("$_.h",\@headers); + remove_from_array("lib$_.so",\@libs); + } + + mkdir "../backuped" unless -d "../backuped"; + `mv $_ ../backuped` for @{$dependfiles{ycurses}}; + } + + elsif ( /^#define YCURSES/ && !-d "curses") { + `mv ../backuped/$_ .` for @{$dependfiles{ycurses}}; + } + + if ( /\/\/#define OPENSSL/ ) { + remove_from_array("openssl/ssl.h",\@headers); + remove_from_array("lib$_.so",\@libs) for ("ssl", "crypto"); } } close FILE; - if ( defined $ENV{YHTTPDHEADERPATHS} ) - { - map { print "Adding $_...\n"; - unshift @headerpaths, $_ } split /:/, $ENV{YHTTPDHEADERPATHS}; + if ( defined $ENV{YCHATHEADERPATHS} ) { + map { print "Adding $_...\n"; unshift @headerpaths, $_ } + split /:/, $ENV{YCHATHEADERPATHS}; } - if ( defined $ENV{YHTTPDLIBPATHS} ) - { - map { print "Adding $_...\n"; - unshift @libpaths, $_ } split /:/, $ENV{YHTTPDLIBPATHS}; + if ( defined $ENV{YCHATLIBPATHS} ) { + map { print "Adding $_...\n"; unshift @libpaths, $_ } + split /:/, $ENV{YCHATLIBPATHS}; } - print "Headers:\n"; my $testit = 0; @@ -103,10 +148,7 @@ perl -e ' my $incadd = &make_add("-I", \%incadd); my $libadd = &make_add("-L", \%libadd); - for ( @libs ) - { - $libadd .= "-l$_ " if s/^lib// and s/\.so$//; - } + for ( @libs ) { $libadd .= "-l$_ " if s/^lib// and s/\.so$//; } print "Incadd: $incadd\n"; print "Libadd: $libadd\n"; @@ -133,8 +175,7 @@ perl -e ' chomp $cpp; chomp $version; - while (<Fin>) - { + while (<Fin>) { s/^(CC=).*\n/$1$compiler/; s/^(SRCS=).*/$1$cpp/; s/ -frepo//; # unless $version =~ /3\.4/; @@ -148,8 +189,7 @@ perl -e ' my $args = join(" -",@ARGV); $args = "-".$args unless $args eq ""; - for my $cppfile (split / /, $cpp) - { + for my $cppfile (split / /, $cpp) { my $ofile = $cppfile; $ofile =~ s/\.cpp/\.o/; print Fout "../obj/$ofile: $cppfile\n"; @@ -158,14 +198,12 @@ perl -e ' $class =~ s/\.o//; my $text; - if ( $class =~ /contrib\/.+/ ) - { + if ( $class =~ /contrib\/.+/ ) { my $dirname = `dirname $class`; $text = "\t\@echo -n \"Contributed class $class \"\n"; } - else - { + else { $text = "\t\@echo -n \"Base class $class \"\n"; } @@ -181,16 +219,14 @@ perl -e ' unlink("msgs.h"); open F, ">msgs.h" or die "msgs.h: $!\n"; - for (@msgs) - { + for (@msgs) { s/(UNAME)(.+)$/UNAME "$uname"/; s/(COMPOPT)(.+)$/COMPOPT "$compopt"/; print F; } close F; - if ( -d "mods" ) - { + if ( -d "mods" ) { chdir("mods"); my $cflags = "-fno-inline -fno-default-inline"; @@ -201,15 +237,12 @@ perl -e ' chdir(".."); } - sub remove_from_array - { + sub remove_from_array { my $elem = shift; my $array = shift; - for ( my $i = 0; $i <= $#$array; ++$i ) - { - if ( $$array[$i] eq $elem ) - { + for ( my $i = 0; $i <= $#$array; ++$i ) { + if ( $$array[$i] eq $elem ) { splice(@$array,$i,1); last; } @@ -233,24 +266,18 @@ perl -e ' pop(@_); } - if ($print) - { + if ($print) { print "Checking for $check..."; print "\n" if $testit; } - for (@_) - { - if ( -f "$_/$check" ) - { - if ($testit) - { + for (@_) { + if ( -f "$_/$check" ) { + if ($testit) { return $_ if test_include($_, $check); return ""; - } - else - { + } else { print "OK\n"; return "" if $_ eq "/usr/lib" or $_ eq "/usr/include"; return $_; @@ -258,28 +285,25 @@ perl -e ' } } - for (@_) - { + for (@_) { next unless -d $_; opendir D, $_ or warn "$_: $!\n"; my @dir = readdir(D); closedir D; - for my $dir ( @dir ) - { + for my $dir ( @dir ) { next if $dir =~ /^\.+$/ or !-d "$_/$dir"; my $path = &check($deep-1, $check, "$_/$dir", "subsearch"); return $path if $path ne ""; } } - if ($print) - { + if ($print) { 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"; print "PS: You may use the locate and/or find command to search for files.\n"; exit(1); @@ -301,8 +325,7 @@ perl -e ' return $ret; } - sub test_include - { + sub test_include { my $shift = shift; my $check = shift; my $return = 0; @@ -313,14 +336,11 @@ perl -e ' my $cmd = "`tail -n 1 ../g++.version` -I$shift __test.cpp -o /dev/null 2>/dev/null"; system $cmd; - unless ($?) - { + unless ($?) { print "OK\n"; $return = 1; - } - else - { + } else { print "Not OK\n"; } 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/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 @@ -15,16 +15,49 @@ #define true 1 #define false 0 +//<<* +/* FIRST THE YCHAT ONLY OPTIONS */ /* - CONFIG - - Should yhttpd get compiled with comand line interface support? + Should yChat get compiled with database support? Currently MyS- + QL only is a supported database. +*/ +//#define DATABASE + +#ifdef DATABASE +#define USE_MYSQL +/* - 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 +#endif + +/* - 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 + +/* AFTERWARDS THE YCHAT AND YHTTPD OPTIONS */ +//*>> + +/* - CONFIG - + Should yChat get compiled with OpenSSL support? +*/ +//#define OPENSSL + +/* - CONFIG - + Should yChat get compiled with comand line interface support? */ #define CLI /* - CONFIG - What should be the name of the config file? */ -#define CONFILE "yhttpd.conf" +#define CONFILE "ychat.conf" /* - DISABLED - Enable debugging options. @@ -34,18 +67,18 @@ /* - DISABLED - 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 logging support? + Should yChat get compiled with logging support? */ #define LOGGING /* - 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 +96,7 @@ #define MAXLENGTH 1024 /* - CONFIG - - Should yhttpd get compiled with ncurses support? + Should yChat get compiled with ncurses support? */ #define NCURSES @@ -85,7 +118,7 @@ #define READSOCK 2048 /* - 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" @@ -99,7 +132,7 @@ //#define SERVMSG /* - CONFIG - - Set to true if you want yhttpd to catch the SIGSEGV signal. yhttpd + Set to true if you want yChat to catch the SIGSEGV signal. yChat will print a warning message into the system messages and will not core dump if an error occurs. */ @@ -108,7 +141,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 off if you have heavy server load. @@ -141,8 +174,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 ace041a..3f47867 100755 --- a/src/html.cpp +++ b/src/html.cpp @@ -115,6 +115,22 @@ html::parse( map<string,string> &map_params ) return s_templ; } +//<<* +void +html::online_list( user *p_user, map<string,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["room"] = p_room->get_name(); + map_params["topic"] = p_room->get_topic(); + map_params["userlist"] = s_list; +} +//*>> #ifdef NCURSES void @@ -5,6 +5,7 @@ #define HTML_H #include "maps/shashmap.h" +#include "chat/user.h" #include "name.h" using namespace std; @@ -28,6 +29,7 @@ public: // used for string substituation. string parse( map<string,string> &map_params ); + void online_list( user *p_user, map<string,string> &map_params ); //<< #ifdef NCURSES void print_cached( int i_docs ); diff --git a/src/logd.cpp b/src/logd.cpp index e120fd8..664cd14 100755 --- a/src/logd.cpp +++ b/src/logd.cpp @@ -81,7 +81,7 @@ logd::flush() void logd::log_access( map<string,string> &map_request ) { - //static int i_access_lines = wrap::CONF->get_elem("httpd.logging.accesslines"); + //static int i_access_lines = wrap::CONF->get_elem("httpd.logging.access_lines"); string s_time = get_time_string(); string s_logstr = map_request["REMOTE_ADDR"] + " - - "+s_time+" \"" + map_request["QUERY_STRING"]+"\" 200 0 \""+map_request["request"]+"\" \""+map_request["User-Agent"]+"\"\n"; diff --git a/src/main.cpp b/src/main.cpp index 87f1cab..a9f9170 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ /* - * yhttpd; Contact: www.yChat.org; Mail@yChat.org + * yChat; Contact: www.yChat.org; Mail@yChat.org * Copyright (C) 2003 Paul C. Buetow, Volker Richter * Copyright (C) 2004 Paul C. Buetow * Copyright (C) 2005 EXA Digital Solutions GbR @@ -37,7 +37,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 ... ); + // ( ./ychat -o key1 value1 -o key2 value2 ... ); bool b_conf = 0; // Will store the key of an additional option value (see also b_conf) @@ -58,7 +58,7 @@ 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( YCUSAGE ); @@ -81,7 +81,7 @@ parse_argc( int argc, char* argv[] ) int main(int argc, char* argv[]) { - cout << tool::yhttpd_version() << endl + cout << tool::ychat_version() << endl << DESCRIP << endl << DESCRI2 << endl << CONTACT << endl @@ -89,6 +89,13 @@ main(int argc, char* argv[]) wrap::init_wrapper(parse_argc(argc, argv)); + //<<* + // Initialize database connection queue +#ifdef DATABASE + + wrap::DATA->init_connections(); +#endif + //*>> sign::init_signal_handlers(); diff --git a/src/maps/hashmap.h b/src/maps/hashmap.h index 1bdc515..b3a3212 100644 --- a/src/maps/hashmap.h +++ b/src/maps/hashmap.h @@ -6,13 +6,13 @@ using namespace std; template<class key_type_> -struct compare_allocator +struct compare_allocator { inline bool operator()(key_type_ t_key_1, key_type_ t_key_2) const; }; template<class key_type_> -struct equals_allocator +struct equals_allocator { inline bool operator()(key_type_ t_key_1, key_type_ t_key_2) const; }; @@ -31,10 +31,10 @@ struct self_hash template < - class obj_type, - class key_type_ = string, - class hash_type = size_hash<string>, - class alloc_type = compare_allocator<string> +class obj_type, +class key_type_ = string, +class hash_type = size_hash<string>, +class alloc_type = compare_allocator<string> > struct hashmap : public __gnu_cxx::hash_map<key_type_, obj_type, hash_type, alloc_type> { @@ -42,7 +42,7 @@ struct hashmap : public __gnu_cxx::hash_map<key_type_, obj_type, hash_type, allo virtual inline obj_type get_elem(key_type_ t_key); virtual inline obj_type get_set_elem(obj_type t_obj, key_type_ t_key); virtual inline obj_type get_or_callback_set - (obj_type (*func)(void*), void* p_void, key_type_ t_key); + (obj_type (*func)(void*), void* p_void, key_type_ t_key); virtual inline vector<key_type_>* get_key_vector(); virtual inline bool exists(key_type_ t_key); virtual inline void run_func( void (*func)(obj_type) ); diff --git a/src/maps/nhashmap.h b/src/maps/nhashmap.h index 7f17a55..f440230 100644 --- a/src/maps/nhashmap.h +++ b/src/maps/nhashmap.h @@ -7,10 +7,10 @@ using namespace std; template < - class obj_type, - class key_type_ = string, - class hash_type = size_hash<string>, - class alloc_type = compare_allocator<string> +class obj_type, +class key_type_ = string, +class hash_type = size_hash<string>, +class alloc_type = compare_allocator<string> > struct nhashmap : public shashmap<obj_type, key_type_, hash_type, alloc_type> { diff --git a/src/maps/shashmap.h b/src/maps/shashmap.h index 99dd7c8..f692e32 100644 --- a/src/maps/shashmap.h +++ b/src/maps/shashmap.h @@ -10,13 +10,13 @@ using namespace std; template < - class obj_type, - class key_type_ = string, - class hash_type = size_hash<string>, - class alloc_type = compare_allocator<string> +class obj_type, +class key_type_ = string, +class hash_type = size_hash<string>, +class alloc_type = compare_allocator<string> > class shashmap : protected hashmap<obj_type, key_type_, hash_type, alloc_type>, - public dumpable + public dumpable { private: pthread_mutex_t mut_shashmap; @@ -30,7 +30,7 @@ public: virtual inline void set_elem(obj_type t_obj, key_type_ t_key); virtual inline obj_type get_set_elem(obj_type t_obj, key_type_ t_key); virtual inline obj_type get_or_callback_set - (obj_type (*func)(void*), void* p_void, key_type_ t_key); + (obj_type (*func)(void*), void* p_void, key_type_ t_key); virtual inline void add_elem(obj_type t_obj, key_type_ t_key); virtual inline void add_elem_insecure(obj_type t_obj, key_type_ t_key); virtual inline obj_type get_elem(key_type_ t_key); diff --git a/src/maps/shashmap.tmpl b/src/maps/shashmap.tmpl index c864d28..0bd5796 100644 --- a/src/maps/shashmap.tmpl +++ b/src/maps/shashmap.tmpl @@ -43,7 +43,7 @@ shashmap<obj_type, key_type_, hash_type, alloc_type>::get_or_callback_set { pthread_mutex_lock( &mut_shashmap ); obj_type t_ret = hashmap<obj_type, key_type_, hash_type, alloc_type>::get_or_callback_set - (func, p_void, t_key); + (func, p_void, t_key); pthread_mutex_unlock( &mut_shashmap ); return t_ret; } @@ -144,12 +144,14 @@ template<class obj_type, class key_type_, class hash_type, class alloc_type> void shashmap<obj_type, key_type_, hash_type, alloc_type>::dumpit() { - dumpable::add("[shashmap]"); + dumpable::add + ("[shashmap]"); vector<key_type_>* p_vec = get_key_vector(); typename vector<key_type_>::iterator iter; for (iter = p_vec->begin(); iter != p_vec->end(); ++iter) - dumpable::add(*iter); + dumpable::add + (*iter); delete p_vec; } diff --git a/src/modl.cpp b/src/modl.cpp index dc6770b..32fe33a 100755 --- a/src/modl.cpp +++ b/src/modl.cpp @@ -1,59 +1,85 @@ -// class modl implementation. - -#ifndef MODL_CXX -#define MODL_CXX +#ifndef MODL_CPP +#define MODL_CPP #include <limits.h> #include <stdlib.h> #include <dlfcn.h> #include <stdio.h> -#include "s_mutx.h" #include "modl.h" +#include "tool/dir.h" using namespace std; -modl::modl( ) +modl::modl() { - map_mods = new hmap<dynmod*,string>(80); - pthread_mutex_init( &mut_map_mods, NULL ); +#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") ); + + if ( wrap::CONF->get_elem( "httpd.modules.preloadhtml" ).compare( "true" ) == 0 ) + preload_modules( wrap::CONF->get_elem("httpd.modules.htmldir") ); } modl::~modl() { - pthread_mutex_lock ( &mut_map_mods ); - // dlclose all the_module's first! - map_mods->run_func ( &modl::dlclose_ ); + run_func( &modl::dlclose_ ); // then clean the hash map. - map_mods->make_empty ( ); + unload_modules(); +} - pthread_mutex_unlock ( &mut_map_mods ); - pthread_mutex_destroy( &mut_map_mods ); +void +modl::preload_modules( string s_path ) +{ + dir* p_dir = new dir(); + p_dir->open_dir( s_path ); + + p_dir->read_dir(); + + vector<string> dir_vec = p_dir->get_dir_vec(); + + if ( ! dir_vec.empty() ) + { + vector<string>::iterator iter = dir_vec.begin(); + + do + { + if ( iter->length() >= 3 && iter->compare( iter->length()-3, 3, ".so" ) == 0 ) + cache_module( s_path + *iter, false ); + } + while ( ++iter != dir_vec.end() ); + } + + dir_vec.clear(); + + // This also closes the dir. + delete p_dir; } void modl::dlclose_( dynmod* mod ) { dlclose( mod->the_module ); + free ( 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; - the_module = dlopen( s_name.c_str(), RTLD_NOW ); + the_module = dlopen( s_name.c_str(), RTLD_LAZY ); + //the_module = dlopen( s_name.c_str(), RTLD_NOW ); if ( the_module == NULL ) { - pthread_mutex_lock ( &s_mutx::get - ().mut_stdout ); - cerr << "dlerror: " << dlerror() << endl; - pthread_mutex_unlock( &s_mutx::get - ().mut_stdout ); + wrap::system_message( dlerror() ); return NULL; } @@ -61,44 +87,85 @@ modl::cache_module( string s_name ) if ( the_func == NULL ) { - pthread_mutex_lock ( &s_mutx::get - ().mut_stdout ); - cerr << "dlerror: " << dlerror() << endl; - pthread_mutex_unlock( &s_mutx::get - ().mut_stdout ); + wrap::system_message( dlerror() ); return NULL; } -#ifdef VERBOSE - pthread_mutex_lock ( &s_mutx::get - ().mut_stdout ); - cout << MODULEC << s_name << endl; - pthread_mutex_unlock( &s_mutx::get - ().mut_stdout ); -#endif + 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 mod->the_module = the_module; // the module handler to close if function + // is not needed anymore. - pthread_mutex_lock ( &mut_map_mods ); - map_mods->add_elem ( mod, s_name ); - pthread_mutex_unlock( &mut_map_mods ); + add_elem( mod, s_name ); // DO NOT CLOSE AS LONG THERE EXIST A POINTER TO THE FUNCTION - // dlclose( module ); + // dlclose( module ); will be called in modl::~modl()! + +#ifdef NCURSES + + print_cached( size() ); +#endif return mod; } dynmod* +modl::get_module( string s_name, string s_user ) +{ + wrap::system_message( MODULER + s_name.substr( s_name.find_last_of("/")+1 ) + " (" + s_user + ")"); + dynmod* mod = get_elem( s_name ); + return ! mod ? cache_module( s_name, true ) : mod; +} + +dynmod* modl::get_module( string s_name ) { - pthread_mutex_lock ( &mut_map_mods ); - dynmod* mod = map_mods->get_elem( s_name ); - pthread_mutex_unlock( &mut_map_mods ); + 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, true ) : mod; +} + +void +modl::unload_modules() +{ + wrap::system_message( MODUNLO ); + + // dlclose all the_module's first! + run_func( &modl::dlclose_ ); + + // then clean the hash map. + shashmap<dynmod*>::clear(); + +#ifdef NCURSES + + print_cached( size() ); +#endif - return ! mod ? cache_module( s_name ) : mod; } +void +modl::reload_modules() +{ + unload_modules(); + + wrap::system_message( MODRELO ); + preload_modules( wrap::CONF->get_elem("httpd.modules.commandsdir") ); + preload_modules( wrap::CONF->get_elem("httpd.modules.htmldir") ); +} + +#ifdef NCURSES +void +modl::print_cached( int i_mods ) +{ + if ( !wrap::NCUR->is_ready() ) + return; + + mvprintw( NCUR_CACHED_MODS_X, NCUR_CACHED_MODS_Y, "Mods: %d ", i_mods); + refresh(); +} +#endif + #endif @@ -1,29 +1,39 @@ -// class modl declaration. +#include "incl.h" #ifndef MODL_H #define MODL_H -#include "incl.h" -#include "hmap.h" +#include "maps/shashmap.h" using namespace std; - -class modl +class modl : public shashmap<dynmod*> { private: - hmap<dynmod*,string>* map_mods; - pthread_mutex_t mut_map_mods; - 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 + + void print_cached( int i_mods ); +#endif public: modl(); ~modl(); - dynmod* get_module ( string s_name ); + dynmod* get_module( string s_name ); + dynmod* get_module( string s_name, string s_user ); + + vector<string>* get_mod_vector() + { + vector<string>* p_ret = get_key_vector(); + return p_ret; + } + void unload_modules(); + void reload_modules(); }; #endif diff --git a/src/mods/commands/yc_gag.cpp b/src/mods/commands/yc_gag.cpp index e58a22d..2da03f6 100644..100755 --- a/src/mods/commands/yc_gag.cpp +++ b/src/mods/commands/yc_gag.cpp @@ -1,27 +1,3 @@ -/*:* - *: File: ./src/mods/commands/yc_gag.cpp - *: - *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ - #include "../../chat/user.h" #include "../../chat/room.h" /* diff --git a/src/mods/commands/yc_q.cpp b/src/mods/commands/yc_q.cpp index 1df6156..a250f72 100755 --- a/src/mods/commands/yc_q.cpp +++ b/src/mods/commands/yc_q.cpp @@ -17,7 +17,7 @@ extern "C" conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF; - string s_quit = "<script confuage=JavaScript>top.location.href='/" + string s_quit = "<script language='JavaScript'>top.location.href='/" + p_conf->get_elem("httpd.startsite") + "';</script>"; diff --git a/src/mods/commands/yc_ungag.cpp b/src/mods/commands/yc_ungag.cpp index 6d8c03c..b727be2 100644..100755 --- a/src/mods/commands/yc_ungag.cpp +++ b/src/mods/commands/yc_ungag.cpp @@ -1,27 +1,3 @@ -/*:* - *: File: ./src/mods/commands/yc_ungag.cpp - *: - *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ - #include "../../chat/user.h" #include "../../chat/room.h" /* diff --git a/src/monitor/dump.cpp b/src/monitor/dump.cpp index 6b49bfe..71cc862 100644 --- a/src/monitor/dump.cpp +++ b/src/monitor/dump.cpp @@ -8,13 +8,13 @@ using namespace std; const string dumpable::s_sep = "->"; const int dumpable::i_max_level = 100; -dumpable::dumpable() +dumpable::dumpable() { initialize(0); } void -dumpable::initialize(int i_level) +dumpable::initialize(int i_level) { this->i_level = i_level; this->i_lined = i_level; @@ -24,13 +24,13 @@ dumpable::initialize(int i_level) } string -dumpable::dump() +dumpable::dump() { return dump(0); } string -dumpable::dump(int i_level) +dumpable::dump(int i_level) { initialize(i_level); dumpit(); @@ -38,34 +38,37 @@ dumpable::dump(int i_level) } void -dumpable::add(string s_line) +dumpable::add + (string s_line) { if ( i_lined > i_max_level ) i_lined = i_max_level; - if (!b_lined) + if (!b_lined) s_dump.append(s_sep); - else for ( int i = 0; i < i_lined; ++i ) - s_dump.append(" "); + else + for ( int i = 0; i < i_lined; ++i ) + s_dump.append(" "); s_dump.append(s_line); - if (b_next_no_nl) + if (b_next_no_nl) b_next_no_nl = false; else s_dump.append("\n"); - if (!b_lined) { + if (!b_lined) + { b_lined = true; i_lined = i_level + s_sep.length(); } } int -dumpable::get_level() const -{ +dumpable::get_level() const +{ return i_lined; } @@ -74,6 +77,7 @@ dump::dump(vector<string> vec_params) if (vec_params.empty()) { cout << CLIPRMO << "all conf sock"; + cout << " chat modl sman"; //<< Not for yhttpd cout << endl; return; } @@ -98,6 +102,16 @@ dump::run(vector<string> &vec_params) if (!s_part.compare("sock") || !s_part.compare("all")) s_ret.append(wrap::SOCK->dump()); + //<<* + if (!s_part.compare("modl") || !s_part.compare("all")) + s_ret.append(wrap::MODL->dump()); + + if (!s_part.compare("sman") || !s_part.compare("all")) + s_ret.append(wrap::SMAN->dump()); + + if (!s_part.compare("chat") || !s_part.compare("all")) + s_ret.append(wrap::CHAT->dump()); + //*>> } return s_ret; diff --git a/src/monitor/dump.h b/src/monitor/dump.h index 8e84cb1..ffb3529 100644 --- a/src/monitor/dump.h +++ b/src/monitor/dump.h @@ -15,24 +15,35 @@ private: string s_dump; static const string s_sep; - static const int i_max_level; + static const int i_max_level; virtual void dumpit() = 0; void initialize(int i_level); void reset(); protected: - void add(unsigned i_num) - { add("<unsigned>"); } - - void add(int i_num) - { add("<int>"); } - - void add(string s_line); + void add + (unsigned i_num) + { + add + ("<unsigned>"); + } + + void add + (int i_num) + { + add + ("<int>"); + } + + void add + (string s_line); dumpable(); - void next_no_newline() - { b_next_no_nl = true; } + void next_no_newline() + { + b_next_no_nl = true; + } public: string dump(); diff --git a/src/monitor/stats.cpp b/src/monitor/stats.cpp index e0aa146..5d5cc39 100644 --- a/src/monitor/stats.cpp +++ b/src/monitor/stats.cpp @@ -10,14 +10,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 @@ -98,5 +101,50 @@ 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/monitor/stats.h b/src/monitor/stats.h index 0478258..231d876 100644 --- a/src/monitor/stats.h +++ b/src/monitor/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,20 @@ 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/msgs.h b/src/msgs.h index b317366..031debe 100755..100644 --- a/src/msgs.h +++ b/src/msgs.h @@ -4,8 +4,9 @@ // 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 CHATFLO "Chat: Flooding (" #define CFILEOK "Parsing config file" #define CFILEFA "Failed opening config file!" #define CONTACT "Contact: http://www.yChat.org, Mail@yChat.org, ICQ: 11655527" @@ -93,17 +94,24 @@ #define STATUPR "Stats: Updated rusage history" #define STATRSS "Stats: Max resident set size " #define REUROOM "Garbage: Reusing room object " -#define SOCKER1 "Sock: Can't create socket, aborting" -#define SOCKUNS "Sock: Starting hypertext transport [HTTP]" #define SOCKCLN "Sock: Initializing a client socket at " #define SOCKCON "Sock: Connecting to " #define SOCKCRT "Sock: Created socket on " #define SOCKSRV "Sock: Initializing server socket " #define SOCKERR "Sock: Can't create socket, trying next port " +#define SOCKER1 "Sock: Can't create socket, aborting" #define SOCKER2 "Sock: Unknown hostname " #define SOCKRDY "Sock: Server socket is ready " #define SOCKCAC "Sock: Caching IP " #define SOCKCA2 "Sock: Cleaning IP cache (" +#define SOCKUNS "Sock: Starting unsecure transport [HTTP]" +#ifdef OPENSSL +#define SSLERR1 "SSL: Can't create socket" +#define SSLERR2 "SSL: Private key does not match cert. file" +#define SSLERR3 "SSL: Can't create new SSL context" +#define SSLERR4 "SSL: Can't create new SSL socket via accept" +#define SOCKSEC "SSL: Starting secure transport [HTTPS]" +#endif #define TECACHE "HTML: Caching document " #define THRDSTR "Thread: Running" #define TIMERAT "Timer: User autoaway timeout " @@ -115,16 +123,16 @@ #define XMLREAD "XML: Reading " #define XMLERR "XML Error: " #define XMLER1 "XML Error: Unable to load file " -#define VERSION "0.7.2" +#define VERSION "0.8.2" #define BRANCH "RELEASE" -#define BUILDNR 3807 -#define UNAME "FreeBSD 5.4-DEVEL i386" -#define COMPOPT "Using built-in specs.; Configured with: FreeBSD/i386 system compiler; Thread model: posix; gcc version 3.4 [FreeBSD] 20040728; 3.4; g++" -#define YCUSAGE "Usage: ./yhttpd {h|v}|{o confkey confvalue}\n" +#define BUILDNR 4003 +#define UNAME "FreeBSD 5.4-RELEASE-p3 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++" +#define YCUSAGE "Usage: ./ychat {h|v}|{o confkey confvalue}\n" #define HEADER1 "HTTP/1.1 200 OK\r\n" -#define HEADER2 "Server: yhttpd/" VERSION "-" BRANCH "\r\n" -#define HEADER3 "Cache-control: no-cache\r\n" +#define HEADER2 "Server: yChat/" VERSION "-" BRANCH "\r\n" +#define HEADER3 "Cache-Control: no-cache\r\n" #define HEADER4 "Pragma: no-cache\r\n" #define HEADER5 "Transfer-Encoding: chunked\r\n" #define HEADER6 "Connection: keep-alive\r\n" @@ -132,5 +140,6 @@ #define HEADER8 "Content-Type: "; #define HEADER8b "; charset=ISO-8859-1\r\n"; #define HEADER9 "Allow: GET\r\n"; +//#define MEMBERE "Memb: No such member " #endif diff --git a/src/ncur/ncur.cpp b/src/ncur/ncur.cpp index 3518bbd..3200ee0 100755 --- a/src/ncur/ncur.cpp +++ b/src/ncur/ncur.cpp @@ -38,16 +38,26 @@ ncur::start( void *p_void ) ncur::init_ncurses(); char *choices[] = { - " ", - " ", + "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 + "Close DB connections ", +#else + " ", +#endif + //*>> + //>>" ", "Shut down server" }; @@ -58,18 +68,23 @@ ncur::start( void *p_void ) mvwprintw( p_serveroutput, 2, 2, NCURMSG ); wrefresh ( p_serveroutput ); - print( string("yhttpd ") + VERSION ); + print( string("yChat ") + VERSION ); p_menu = new menu( 1, 1, 30, 19, NCURADM, choices, 11, COLOR_PAIR(1)); mvprintw(NCUR_SERVER_HEADER_X,NCUR_SERVER_HEADER_Y, NCURSE0); mvprintw(NCUR_POOL_HEADER_X,NCUR_POOL_HEADER_Y, NCURSE1); + mvprintw(NCUR_DATA_HEADER_X,NCUR_DATA_HEADER_Y, NCURSE2); //<< + mvprintw(NCUR_CHAT_HEADER_X,NCUR_CHAT_HEADER_Y, NCURSE3); //<< mvprintw(NCUR_CACHED_HEADER_X,NCUR_CACHED_HEADER_Y, NCURSE4); wrap::HTML->print_cached(0); is_ready(true); + wrap::SMAN->print_init_ncurses(); //<< + wrap::STAT->print_num_rooms(); //<< + wrap::SOCK->print_server_port(); p_menu->start( &switch_main_menu_ ); @@ -150,12 +165,29 @@ ncur::switch_main_menu_( int i_choice ) if( i_choice != 0 ) switch ( i_choice ) { + //<<* + case 1: + wrap::MODL->unload_modules(); + mvprintw( 20,2, "Unloaded all modules "); + refresh(); + break; + case 2: + wrap::MODL->reload_modules(); + mvprintw( 20,2, "Reloaded all modules "); + refresh(); + break; + //*>> case 3: wrap::HTML->clear_cache(); mvprintw( 20,2, "Cleared the template cache "); refresh(); break; case 4: + //<<* + if ( ! wrap::GCOL->remove_garbage() ) + wrap::NCUR->print( GAROFFNE ); + mvprintw( 20,2, "Garbage collector activated "); + //*>> refresh(); break; case 5: @@ -197,6 +229,7 @@ ncur::switch_main_menu_( int i_choice ) case 10: #ifdef DATABASE + wrap::DATA->disconnect_all_connections(); //<< #endif break; @@ -222,7 +255,7 @@ ncur::init_ncurses() noecho(); cbreak(); // Line buffering disabled. pass on everything init_pair(1, COLOR_BLACK, COLOR_CYAN); - mvprintw( 0,2, (char*)(tool::yhttpd_version()).c_str()); + mvprintw( 0,2, (char*)(tool::ychat_version()).c_str()); curs_set(0); refresh(); } diff --git a/src/reqp.cpp b/src/reqp.cpp index df9de5d..9b5da0b 100755 --- a/src/reqp.cpp +++ b/src/reqp.cpp @@ -237,6 +237,77 @@ reqp::parse( socketcontainer *p_sock, string s_req, map<string,string> &map_para string s_rep( "" ); + //<<* + // 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 + { + sess *p_sess = wrap::SMAN->get_session( map_params["tmpid"] ); + user *p_user = NULL; + + if( p_sess != NULL ) + { + p_user = p_sess->get_user(); + } + else + { + wrap::system_message(SESSERR); + return s_rep; + } + + if ( ! p_user ) + { + 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_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") ) @@ -269,6 +340,26 @@ reqp::parse( socketcontainer *p_sock, string s_req, map<string,string> &map_para return s_resp; } +//<<* +void +reqp::run_html_mod( string s_event, map<string,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, p_user->get_name() ); + + if ( p_module != NULL ) + ( *( p_module->the_func ) ) ( static_cast<void*>(c) ); + + delete c; +} +//*>> string reqp::remove_dots( string s_ret ) @@ -24,6 +24,7 @@ private: string get_from_header( string s_req, string s_hdr ); int htoi( string *p_str ); + void run_html_mod( string s_event, map<string,string> &map_params, user* p_user ); //<< // Removes double dots ".." string remove_dots( string s_req ); diff --git a/src/sign.cpp b/src/sign.cpp index ad3e02a..584b5f7 100644 --- a/src/sign.cpp +++ b/src/sign.cpp @@ -9,6 +9,13 @@ sign::clean_template_cache(int i_param) wrap::HTML->clear_cache(); } +//<<* +void +sign::reload_dlopen_modules(int i_param) +{ + wrap::MODL->reload_modules(); +} +//*>> #ifdef CTCSEGV void @@ -23,10 +30,19 @@ sign::terminate_received(int i_param) { #ifdef NCURSES + //<<* + if ( ! wrap::GCOL->remove_garbage() ) + wrap::NCUR->print( GAROFFNE ); + //*>> mvprintw( 21,2, "Good bye !"); wrap::NCUR->close_ncurses(); + //<<* +#else + + wrap::GCOL->remove_garbage(); + //*>> #endif exit(0); @@ -40,9 +56,12 @@ sign::init_signal_handlers() signal(SIGPIPE, SIG_IGN); signal(SIGUSR1, clean_template_cache); + signal(SIGUSR2, reload_dlopen_modules); //<< #ifdef CTCSEGV - signal(SIGSEGV, sigsev_received); + + signal(SIGSEGV, sigsev_received); #endif + signal(SIGHUP, terminate_received); signal(SIGINT, terminate_received); signal(SIGTERM, terminate_received); @@ -7,8 +7,10 @@ class sign { private: - static void clean_template_cache(int i_param); + static void clean_template_cache(int i_param); + static void reload_dlopen_modules(int i_param); //<< #ifdef CTCSEGV + static void sigsev_received(int i_param); #endif diff --git a/src/sock/sock.cpp b/src/sock/sock.cpp index b73b78f..9d673ef 100755 --- a/src/sock/sock.cpp +++ b/src/sock/sock.cpp @@ -45,6 +45,64 @@ sock::_close(socketcontainer *p_sock) delete p_sock; } +//<<* +void +sock::chat_stream( socketcontainer *p_sock, user *p_user, map<string,string> &map_params ) +{ + string s_msg( "\n" ); + + for ( int i = 0; i < PUSHSTR; i++ ) + _send(p_sock,s_msg.c_str(), s_msg.size()); + + pthread_mutex_t mutex; + pthread_mutex_init( &mutex, NULL ); + pthread_mutex_lock( &mutex ); + + do + { + s_msg = p_user->get_mess( ); + + if ( 0 > _send( p_sock, s_msg.c_str(), s_msg.size() ) ) + { + p_user->set_online( false ); + break; + } + + 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( p_sock, s_msg.c_str(), s_msg.size()); + + // 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 ) @@ -331,6 +389,15 @@ sock::_main_loop_init() wrap::system_message(SOCKUNS); } +#ifdef OPENSSL +// This method is virtual, and is overloaded by sslsock! +bool +sock::_main_loop_do_ssl_stuff(int &i_new_sock) +{ + return 0; +} +#endif + socketcontainer* sock::_create_container(int &i_sock) { @@ -372,8 +439,6 @@ sock::start() FD_ZERO (&active_fd_set); FD_SET (i_sock, &active_fd_set); - print_server_port(); - while( b_run ) { // block until input arrives on one or more active sockets. @@ -403,6 +468,12 @@ sock::start() size = sizeof(clientname); i_new_sock = accept (i_sock, (struct sockaddr *) &clientname, &size); +#ifdef OPENSSL + + if (_main_loop_do_ssl_stuff(i_new_sock)) + continue; +#endif + #ifdef VERBOSE wrap::system_message(NEWREQU diff --git a/src/sock/sock.h b/src/sock/sock.h index 65fe756..264d9d1 100755 --- a/src/sock/sock.h +++ b/src/sock/sock.h @@ -11,6 +11,7 @@ #include <netdb.h> #include "../reqp.h" +#include "../chat/user.h" #include "../thrd/pool.h" #include "../maps/shashmap.h" @@ -70,11 +71,17 @@ public: void clean_ipcache(); // the chat stream there all the chat messages will sent through. - virtual inline int _send(socketcontainer *p_sock, const char *sz, int len); - virtual inline int _read(socketcontainer *p_sock, char *sz, int len); - virtual inline int _close(socketcontainer *p_sock); + void chat_stream( socketcontainer* p_sock, user* p_user, map<string,string> &map_params ); //<< + virtual int _send(socketcontainer *p_sock, const char *sz, int len); + virtual int _read(socketcontainer *p_sock, char *sz, int len); + virtual int _close(socketcontainer *p_sock); virtual void _main_loop_init(); - virtual inline socketcontainer* _create_container(int& i_sock); +#ifdef OPENSSL + + virtual bool _main_loop_do_ssl_stuff(int& i_new_sock); +#endif + + virtual socketcontainer* _create_container(int& i_sock); virtual int _make_server_socket(int i_port); #ifdef NCURSES diff --git a/src/time/timo.h b/src/time/timo.h index 32268df..ea160c1 100755 --- a/src/time/timo.h +++ b/src/time/timo.h @@ -16,7 +16,7 @@ public: ~timo( ); double get_last_activity(); - void renew_timeout(); + virtual void renew_timeout(); }; #endif diff --git a/src/time/timr.cpp b/src/time/timr.cpp index 6a95984..9e1522f 100755 --- a/src/time/timr.cpp +++ b/src/time/timr.cpp @@ -71,7 +71,7 @@ timr::start( void *v_ptr ) 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 ); @@ -87,14 +87,31 @@ timr::start( void *v_ptr ) #ifdef SERVMSG cout << TIMERUP << get_uptime() << endl; #endif + //<<* + int* p_timeout_settings = new int[3]; + p_timeout_settings[0] = tool::string2int(wrap::CONF->get_elem("chat.idle.timeout")); + p_timeout_settings[1] = tool::string2int(wrap::CONF->get_elem("chat.idle.awaytimeout")); + p_timeout_settings[2] = tool::string2int(wrap::CONF->get_elem("chat.idle.autoawaytimeout")); + wrap::CHAT->check_timeout( p_timeout_settings ); + delete p_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::SOCK->clean_ipcache(); + wrap::SOCK->clean_ipcache(); // Run every hour if ( time_now.tm_min % 60 == 0 ) { + wrap::GCOL->remove_garbage(); //<< // Run every day if (time_now.tm_min == 0 || time_now.tm_min == 60 ) diff --git a/src/tool/tool.cpp b/src/tool/tool.cpp index dbb1f22..3b8e326 100644 --- a/src/tool/tool.cpp +++ b/src/tool/tool.cpp @@ -93,9 +93,9 @@ tool::strip_html( string *p_str) } string -tool::yhttpd_version() +tool::ychat_version() { - return "yhttpd " + string(VERSION) + return "yChat " + string(VERSION) + "-" + string(BRANCH) + " Build " + int2string(BUILDNR); } diff --git a/src/tool/tool.h b/src/tool/tool.h index 7a1958d..e0dea50 100644 --- a/src/tool/tool.h +++ b/src/tool/tool.h @@ -23,7 +23,7 @@ public: static string to_lower( string s_str ); static void strip_html( string *p_str ); static string shell_command( string s_command, method m_method ); - static string yhttpd_version(); + static string ychat_version(); }; #endif diff --git a/src/wrap.cpp b/src/wrap.cpp index e6fb851..e071cc9 100755 --- a/src/wrap.cpp +++ b/src/wrap.cpp @@ -5,6 +5,15 @@ using namespace std; +//<<* +chat* wrap::CHAT = NULL; +#ifdef DATABASE +data* wrap::DATA = NULL; +#endif +gcol* wrap::GCOL = NULL; +sman* wrap::SMAN = NULL; +modl* wrap::MODL = NULL; +//*>> conf* wrap::CONF = NULL; html* wrap::HTML = NULL; @@ -67,10 +76,20 @@ wrap::init_wrapper(map<string,string>* p_main_loop_params) CONF->get_elem("httpd.logging.systemlines") ); #endif + //<<* + // Init the session manager. + WRAP->SMAN = SMAN = new sman; + //*>> // Init the socket manager. int i_port = tool::string2int( wrap::CONF->get_elem( "httpd.serverport" ) ); +#ifndef OPENSSL + WRAP->SOCK = SOCK = new sock; +#else + + WRAP->SOCK = SOCK = new sslsock; +#endif // create the server socket and set it up to accept connections. if(SOCK->_make_server_socket ( i_port ) <= 0) @@ -103,10 +122,27 @@ wrap::init_wrapper(map<string,string>* p_main_loop_params) // Init the thread pool WRAP->POOL = POOL = new pool; + //<<* + // Init the chat manager. + WRAP->CHAT = CHAT = new chat; + //*>> // Init the system timer. WRAP->TIMR = TIMR = new timr; + //<<* + // Init the module-loader manager. + WRAP->MODL = MODL = new modl; + + // Init the garbage collector + WRAP->GCOL = GCOL = new gcol; + + // Init the data manager. +#ifdef DATABASE + + WRAP->DATA = DATA = new data; +#endif + //*>> // Run threads TIMR->run(); @@ -7,15 +7,25 @@ struct socketcontainer { int i_sock; +#ifdef OPENSSL + void *p_ssl_context; +#endif + }; #ifdef DATABASE +#include "data/data.h" #endif +#include "chat/chat.h" #include "conf/conf.h" +#include "chat/gcol.h" #include "html.h" #ifdef LOGGING #include "logd.h" #endif +//<<* +#include "modl.h" +//*>> #ifdef NCURSES #include "ncur/ncur.h" @@ -25,8 +35,14 @@ struct socketcontainer #endif #endif +#include "chat/sman.h" +#ifndef OPENSSL #include "sock/sock.h" +#else +#include "sock/sslsock.h" +#endif + #include "monitor/stats.h" #include "time/timr.h" #include "thrd/pool.h" @@ -38,6 +54,17 @@ using namespace std; class dynamic_wrap { public: + //<<* + chat* CHAT; +#ifdef DATABASE + + data* DATA; +#endif + + gcol* GCOL; + sman* SMAN; + modl* MODL; + //*>> conf* CONF; html* HTML; @@ -73,6 +100,22 @@ public: static void init_wrapper(map<string,string>* p_main_loop_params); + //<<* + static chat* CHAT; +#ifdef DATABASE + + static data* DATA; +#endif + + static gcol* GCOL; + static sman* SMAN; +#ifdef IRCBOT + + static ybot* YBOT; +#endif + + static modl* MODL; + //*>> static conf* CONF; static html* HTML; |
