moved winix directories to winixdsubdirectory
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1028 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
28
winixd/plugins/stats/Makefile
Normal file
28
winixd/plugins/stats/Makefile
Normal file
@@ -0,0 +1,28 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
name = stats.so
|
||||
|
||||
|
||||
all: $(name)
|
||||
|
||||
$(name): $(o)
|
||||
$(CXX) -shared -Wl,-soname,$(name) -o $(name) $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $(LDFLAGS) *.o
|
||||
|
||||
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. $(CXXWINIXINCLUDEFLAGS) -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f *.so
|
||||
rm -f $(name)
|
||||
|
||||
include Makefile.dep
|
||||
217
winixd/plugins/stats/Makefile.dep
Normal file
217
winixd/plugins/stats/Makefile.dep
Normal file
@@ -0,0 +1,217 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
bot.o: bot.h
|
||||
init.o: ../../../winix/core/log.h ../../../winix/core/textstream.h
|
||||
init.o: ../../../winix/core/misc.h ../../../winix/core/item.h
|
||||
init.o: ../../../pikotools/space/space.h
|
||||
init.o: ../../../pikotools/textstream/types.h ../../../pikotools/date/date.h
|
||||
init.o: ../../../winix/core/requesttypes.h
|
||||
init.o: ../../../pikotools/textstream/textstream.h
|
||||
init.o: ../../../pikotools/convert/convert.h
|
||||
init.o: ../../../pikotools/convert/inttostr.h
|
||||
init.o: ../../../pikotools/membuffer/membuffer.h
|
||||
init.o: ../../../pikotools/textstream/types.h ../../../pikotools/utf8/utf8.h
|
||||
init.o: ../../../winix/core/winix_const.h
|
||||
init.o: ../../../winix/core/logmanipulators.h ../../../winix/core/slog.h
|
||||
init.o: ../../../winix/core/cur.h ../../../winix/core/request.h
|
||||
init.o: ../../../winix/core/error.h ../../../winix/core/config.h
|
||||
init.o: ../../../pikotools/space/spaceparser.h
|
||||
init.o: ../../../pikotools/space/space.h ../../../winix/core/htmlfilter.h
|
||||
init.o: ../../../winix/templates/htmltextstream.h
|
||||
init.o: ../../../winix/core/textstream.h
|
||||
init.o: ../../../pikotools/space/spacetojson.h ../../../ezc/src/outstreams.h
|
||||
init.o: ../../../winix/core/session.h ../../../winix/core/user.h
|
||||
init.o: ../../../winix/core/plugindata.h ../../../winix/core/rebus.h
|
||||
init.o: ../../../winix/core/ipban.h ../../../winix/core/mount.h
|
||||
init.o: ../../../winix/templates/locale.h ../../../winix/core/request.h
|
||||
init.o: ../../../winix/core/config.h ../../../winix/db/db.h
|
||||
init.o: ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
|
||||
init.o: ../../../winix/db/dbtextstream.h ../../../winix/core/error.h
|
||||
init.o: ../../../winix/db/dbitemquery.h ../../../winix/core/item.h
|
||||
init.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
|
||||
init.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
|
||||
init.o: ../../../winix/core/ugcontainer.h ../../../winix/core/log.h bot.h
|
||||
init.o: stats.h templates.h ../../../winix/core/plugin.h
|
||||
init.o: ../../../winix/core/pluginmsg.h ../../../winix/core/system.h
|
||||
init.o: ../../../winix/core/job.h ../../../winix/core/basethread.h
|
||||
init.o: ../../../winix/core/synchro.h ../../../winix/core/dirs.h
|
||||
init.o: ../../../winix/core/dircontainer.h ../../../winix/notify/notify.h
|
||||
init.o: ../../../winix/notify/notifypool.h
|
||||
init.o: ../../../winix/templates/patterns.h ../../../winix/templates/locale.h
|
||||
init.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
init.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
|
||||
init.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
|
||||
init.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
|
||||
init.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
|
||||
init.o: ../../../winix/notify/notifythread.h ../../../winix/core/basethread.h
|
||||
init.o: ../../../winix/notify/templatesnotify.h ../../../winix/core/users.h
|
||||
init.o: ../../../winix/core/ugcontainer.h ../../../winix/core/lastcontainer.h
|
||||
init.o: ../../../winix/core/mounts.h ../../../winix/core/mountparser.h
|
||||
init.o: ../../../winix/core/crypt.h ../../../winix/core/run.h
|
||||
init.o: ../../../winix/core/users.h ../../../winix/core/groups.h
|
||||
init.o: ../../../winix/core/group.h ../../../winix/core/loadavg.h
|
||||
init.o: ../../../winix/core/image.h ../../../winix/core/threadmanager.h
|
||||
init.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
|
||||
init.o: ../../../winix/core/sessionmanager.h
|
||||
init.o: ../../../winix/core/sessioncontainer.h
|
||||
init.o: ../../../winix/core/ipbancontainer.h
|
||||
init.o: ../../../winix/core/sessionidmanager.h ../../../tito/src/base64.h
|
||||
init.o: ../../../tito/src/aes.h ../../../winix/functions/functions.h
|
||||
init.o: ../../../winix/functions/functionbase.h ../../../winix/core/system.h
|
||||
init.o: ../../../winix/core/synchro.h
|
||||
init.o: ../../../winix/functions/functionparser.h ../../../winix/core/cur.h
|
||||
init.o: ../../../winix/functions/account.h ../../../winix/functions/adduser.h
|
||||
init.o: ../../../winix/functions/cat.h ../../../winix/functions/chmod.h
|
||||
init.o: ../../../winix/functions/privchanger.h
|
||||
init.o: ../../../winix/functions/chown.h ../../../winix/functions/ckeditor.h
|
||||
init.o: ../../../winix/functions/cp.h ../../../winix/functions/default.h
|
||||
init.o: ../../../winix/functions/download.h ../../../winix/functions/emacs.h
|
||||
init.o: ../../../winix/functions/env.h ../../../winix/functions/imgcrop.h
|
||||
init.o: ../../../winix/functions/last.h ../../../winix/functions/login.h
|
||||
init.o: ../../../winix/functions/logout.h ../../../winix/functions/ln.h
|
||||
init.o: ../../../winix/functions/ls.h ../../../winix/functions/man.h
|
||||
init.o: ../../../winix/functions/meta.h ../../../winix/functions/mkdir.h
|
||||
init.o: ../../../winix/functions/mv.h ../../../winix/functions/nicedit.h
|
||||
init.o: ../../../winix/functions/node.h ../../../winix/functions/passwd.h
|
||||
init.o: ../../../winix/functions/priv.h ../../../winix/functions/pw.h
|
||||
init.o: ../../../winix/functions/reload.h ../../../winix/functions/rm.h
|
||||
init.o: ../../../winix/functions/rmuser.h ../../../winix/functions/sort.h
|
||||
init.o: ../../../winix/functions/specialdefault.h
|
||||
init.o: ../../../winix/functions/stat.h ../../../winix/functions/subject.h
|
||||
init.o: ../../../winix/functions/template.h
|
||||
init.o: ../../../winix/functions/tinymce.h ../../../winix/functions/uname.h
|
||||
init.o: ../../../winix/functions/upload.h ../../../winix/functions/uptime.h
|
||||
init.o: ../../../winix/functions/who.h ../../../winix/functions/vim.h
|
||||
init.o: ../../../winix/core/htmlfilter.h ../../../winix/templates/templates.h
|
||||
init.o: ../../../winix/templates/patterncacher.h
|
||||
init.o: ../../../winix/templates/indexpatterns.h
|
||||
init.o: ../../../winix/templates/patterns.h
|
||||
init.o: ../../../winix/templates/changepatterns.h
|
||||
init.o: ../../../winix/templates/htmltextstream.h
|
||||
init.o: ../../../winix/core/sessionmanager.h statssession.h
|
||||
init.o: ../../../winix/core/plugindata.h
|
||||
stats.o: stats.h ../../../winix/core/config.h ../../../winix/core/log.h
|
||||
stats.o: ../../../winix/core/textstream.h ../../../winix/core/misc.h
|
||||
stats.o: ../../../winix/core/item.h ../../../pikotools/space/space.h
|
||||
stats.o: ../../../pikotools/textstream/types.h ../../../pikotools/date/date.h
|
||||
stats.o: ../../../winix/core/requesttypes.h
|
||||
stats.o: ../../../pikotools/textstream/textstream.h
|
||||
stats.o: ../../../pikotools/convert/convert.h
|
||||
stats.o: ../../../pikotools/convert/inttostr.h
|
||||
stats.o: ../../../pikotools/membuffer/membuffer.h
|
||||
stats.o: ../../../pikotools/textstream/types.h ../../../pikotools/utf8/utf8.h
|
||||
stats.o: ../../../winix/core/winix_const.h
|
||||
stats.o: ../../../winix/core/logmanipulators.h ../../../winix/core/slog.h
|
||||
stats.o: ../../../winix/core/cur.h ../../../winix/core/request.h
|
||||
stats.o: ../../../winix/core/error.h ../../../winix/core/config.h
|
||||
stats.o: ../../../pikotools/space/spaceparser.h
|
||||
stats.o: ../../../pikotools/space/space.h ../../../winix/core/htmlfilter.h
|
||||
stats.o: ../../../winix/templates/htmltextstream.h
|
||||
stats.o: ../../../winix/core/textstream.h
|
||||
stats.o: ../../../pikotools/space/spacetojson.h ../../../ezc/src/outstreams.h
|
||||
stats.o: ../../../winix/core/session.h ../../../winix/core/user.h
|
||||
stats.o: ../../../winix/core/plugindata.h ../../../winix/core/rebus.h
|
||||
stats.o: ../../../winix/core/ipban.h ../../../winix/core/mount.h
|
||||
stats.o: ../../../winix/templates/locale.h
|
||||
templates.o: templates.h ../../../winix/core/plugin.h
|
||||
templates.o: ../../../winix/core/pluginmsg.h ../../../winix/core/log.h
|
||||
templates.o: ../../../winix/core/plugindata.h ../../../winix/core/config.h
|
||||
templates.o: ../../../pikotools/space/spaceparser.h
|
||||
templates.o: ../../../pikotools/space/space.h
|
||||
templates.o: ../../../winix/core/htmlfilter.h ../../../winix/core/request.h
|
||||
templates.o: ../../../winix/core/requesttypes.h
|
||||
templates.o: ../../../pikotools/textstream/textstream.h
|
||||
templates.o: ../../../pikotools/space/space.h
|
||||
templates.o: ../../../pikotools/textstream/types.h
|
||||
templates.o: ../../../pikotools/date/date.h
|
||||
templates.o: ../../../pikotools/convert/convert.h
|
||||
templates.o: ../../../pikotools/convert/inttostr.h
|
||||
templates.o: ../../../pikotools/membuffer/membuffer.h
|
||||
templates.o: ../../../pikotools/textstream/types.h ../../../winix/core/item.h
|
||||
templates.o: ../../../winix/core/error.h ../../../winix/core/textstream.h
|
||||
templates.o: ../../../winix/core/misc.h ../../../pikotools/utf8/utf8.h
|
||||
templates.o: ../../../winix/core/winix_const.h
|
||||
templates.o: ../../../winix/templates/htmltextstream.h
|
||||
templates.o: ../../../winix/core/textstream.h
|
||||
templates.o: ../../../pikotools/space/spacetojson.h
|
||||
templates.o: ../../../ezc/src/outstreams.h ../../../winix/core/system.h
|
||||
templates.o: ../../../winix/core/job.h ../../../winix/core/basethread.h
|
||||
templates.o: ../../../winix/core/synchro.h ../../../winix/core/dirs.h
|
||||
templates.o: ../../../winix/core/dircontainer.h ../../../winix/db/db.h
|
||||
templates.o: ../../../winix/db/dbbase.h ../../../winix/db/dbconn.h
|
||||
templates.o: ../../../winix/db/dbtextstream.h ../../../winix/core/error.h
|
||||
templates.o: ../../../winix/db/dbitemquery.h ../../../winix/core/item.h
|
||||
templates.o: ../../../winix/db/dbitemcolumns.h ../../../winix/core/user.h
|
||||
templates.o: ../../../winix/core/group.h ../../../winix/core/dircontainer.h
|
||||
templates.o: ../../../winix/core/ugcontainer.h ../../../winix/notify/notify.h
|
||||
templates.o: ../../../winix/notify/notifypool.h
|
||||
templates.o: ../../../winix/templates/locale.h
|
||||
templates.o: ../../../winix/templates/patterns.h
|
||||
templates.o: ../../../winix/templates/locale.h
|
||||
templates.o: ../../../winix/templates/localefilter.h ../../../ezc/src/ezc.h
|
||||
templates.o: ../../../ezc/src/generator.h ../../../ezc/src/blocks.h
|
||||
templates.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
|
||||
templates.o: ../../../ezc/src/funinfo.h ../../../ezc/src/objects.h
|
||||
templates.o: ../../../ezc/src/pattern.h ../../../ezc/src/patternparser.h
|
||||
templates.o: ../../../winix/notify/notifythread.h
|
||||
templates.o: ../../../winix/core/basethread.h
|
||||
templates.o: ../../../winix/notify/templatesnotify.h
|
||||
templates.o: ../../../winix/core/config.h ../../../winix/core/users.h
|
||||
templates.o: ../../../winix/core/user.h ../../../winix/core/ugcontainer.h
|
||||
templates.o: ../../../winix/core/lastcontainer.h ../../../winix/core/cur.h
|
||||
templates.o: ../../../winix/core/session.h ../../../winix/core/rebus.h
|
||||
templates.o: ../../../winix/core/ipban.h ../../../winix/core/mount.h
|
||||
templates.o: ../../../winix/core/mounts.h ../../../winix/core/mountparser.h
|
||||
templates.o: ../../../winix/core/crypt.h ../../../winix/core/run.h
|
||||
templates.o: ../../../winix/core/users.h ../../../winix/core/groups.h
|
||||
templates.o: ../../../winix/core/group.h ../../../winix/core/loadavg.h
|
||||
templates.o: ../../../winix/core/image.h ../../../winix/core/threadmanager.h
|
||||
templates.o: ../../../winix/core/timezones.h ../../../winix/core/timezone.h
|
||||
templates.o: ../../../winix/core/sessionmanager.h
|
||||
templates.o: ../../../winix/core/sessioncontainer.h
|
||||
templates.o: ../../../winix/core/ipbancontainer.h
|
||||
templates.o: ../../../winix/core/sessionidmanager.h
|
||||
templates.o: ../../../tito/src/base64.h ../../../tito/src/aes.h
|
||||
templates.o: ../../../winix/functions/functions.h
|
||||
templates.o: ../../../winix/functions/functionbase.h
|
||||
templates.o: ../../../winix/core/request.h ../../../winix/core/system.h
|
||||
templates.o: ../../../winix/core/synchro.h
|
||||
templates.o: ../../../winix/functions/functionparser.h
|
||||
templates.o: ../../../winix/core/cur.h ../../../winix/functions/account.h
|
||||
templates.o: ../../../winix/functions/adduser.h
|
||||
templates.o: ../../../winix/functions/cat.h ../../../winix/functions/chmod.h
|
||||
templates.o: ../../../winix/functions/privchanger.h
|
||||
templates.o: ../../../winix/functions/chown.h
|
||||
templates.o: ../../../winix/functions/ckeditor.h
|
||||
templates.o: ../../../winix/functions/cp.h ../../../winix/functions/default.h
|
||||
templates.o: ../../../winix/functions/download.h
|
||||
templates.o: ../../../winix/functions/emacs.h ../../../winix/functions/env.h
|
||||
templates.o: ../../../winix/functions/imgcrop.h
|
||||
templates.o: ../../../winix/functions/last.h ../../../winix/functions/login.h
|
||||
templates.o: ../../../winix/functions/logout.h ../../../winix/functions/ln.h
|
||||
templates.o: ../../../winix/functions/ls.h ../../../winix/functions/man.h
|
||||
templates.o: ../../../winix/functions/meta.h ../../../winix/functions/mkdir.h
|
||||
templates.o: ../../../winix/functions/mv.h ../../../winix/functions/nicedit.h
|
||||
templates.o: ../../../winix/functions/node.h
|
||||
templates.o: ../../../winix/functions/passwd.h
|
||||
templates.o: ../../../winix/functions/priv.h ../../../winix/functions/pw.h
|
||||
templates.o: ../../../winix/functions/reload.h ../../../winix/functions/rm.h
|
||||
templates.o: ../../../winix/functions/rmuser.h
|
||||
templates.o: ../../../winix/functions/sort.h
|
||||
templates.o: ../../../winix/functions/specialdefault.h
|
||||
templates.o: ../../../winix/functions/stat.h
|
||||
templates.o: ../../../winix/functions/subject.h
|
||||
templates.o: ../../../winix/functions/template.h
|
||||
templates.o: ../../../winix/functions/tinymce.h
|
||||
templates.o: ../../../winix/functions/uname.h
|
||||
templates.o: ../../../winix/functions/upload.h
|
||||
templates.o: ../../../winix/functions/uptime.h ../../../winix/functions/who.h
|
||||
templates.o: ../../../winix/functions/vim.h ../../../winix/core/htmlfilter.h
|
||||
templates.o: ../../../winix/templates/templates.h
|
||||
templates.o: ../../../winix/templates/patterncacher.h
|
||||
templates.o: ../../../winix/templates/indexpatterns.h
|
||||
templates.o: ../../../winix/templates/patterns.h
|
||||
templates.o: ../../../winix/templates/changepatterns.h
|
||||
templates.o: ../../../winix/templates/htmltextstream.h
|
||||
templates.o: ../../../winix/core/sessionmanager.h ../../../winix/core/misc.h
|
||||
templates.o: stats.h ../../../winix/templates/misc.h
|
||||
1
winixd/plugins/stats/Makefile.o.dep
Normal file
1
winixd/plugins/stats/Makefile.o.dep
Normal file
@@ -0,0 +1 @@
|
||||
o = bot.o init.o stats.o templates.o
|
||||
85
winixd/plugins/stats/bot.cpp
Normal file
85
winixd/plugins/stats/bot.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "bot.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
namespace Stats
|
||||
{
|
||||
|
||||
|
||||
|
||||
void Bot::SetBrowserName(const std::wstring & name)
|
||||
{
|
||||
browser_name = &name;
|
||||
}
|
||||
|
||||
|
||||
bool Bot::BrowserNameHas(const wchar_t * name)
|
||||
{
|
||||
return (browser_name->find(name) != std::wstring::npos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Bot::IsGoogle()
|
||||
{
|
||||
return BrowserNameHas(L"Googlebot") && BrowserNameHas(L"+http://www.google.com/bot.html");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Bot::IsYahoo()
|
||||
{
|
||||
return BrowserNameHas(L"Yahoo!") && BrowserNameHas(L"yahoo.com");
|
||||
}
|
||||
|
||||
|
||||
bool Bot::IsBing()
|
||||
{
|
||||
if( BrowserNameHas(L"msnbot") && BrowserNameHas(L"+http://search.msn.com/msnbot.htm") )
|
||||
return true;
|
||||
|
||||
return BrowserNameHas(L"bingbot") && BrowserNameHas(L"+http://www.bing.com/bingbot.htm");
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
73
winixd/plugins/stats/bot.h
Normal file
73
winixd/plugins/stats/bot.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_stats_bot
|
||||
#define headerfile_winix_plugins_stats_bot
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
namespace Stats
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct Bot
|
||||
{
|
||||
void SetBrowserName(const std::wstring & name);
|
||||
|
||||
bool IsGoogle();
|
||||
bool IsYahoo();
|
||||
bool IsBing();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
const std::wstring * browser_name;
|
||||
|
||||
bool BrowserNameHas(const wchar_t * name);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
||||
245
winixd/plugins/stats/init.cpp
Normal file
245
winixd/plugins/stats/init.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/log.h"
|
||||
#include "core/request.h"
|
||||
#include "core/config.h"
|
||||
#include "db/db.h"
|
||||
|
||||
#include "bot.h"
|
||||
#include "stats.h"
|
||||
#include "templates.h"
|
||||
#include "statssession.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
extern "C" void Init(PluginInfo &);
|
||||
static const wchar_t plugin_name[] = L"stats";
|
||||
|
||||
// if there is a winix function parameter nostat_param used
|
||||
// such as: http://mysite.com/uptime/nostat
|
||||
// then the statistics will not be calculated
|
||||
// and winix will not log about creating and destroying plugins date
|
||||
// (useful when making performance tests so it not change the real statistics)
|
||||
static const wchar_t nostat_param[] = L"nostat";
|
||||
|
||||
|
||||
|
||||
namespace Stats
|
||||
{
|
||||
|
||||
Stats stats;
|
||||
Bot bot;
|
||||
long current_item_id;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void CalcItemId(Cur * cur)
|
||||
{
|
||||
if( cur->request->is_item )
|
||||
current_item_id = cur->request->item.id;
|
||||
else
|
||||
if( !cur->request->dir_tab.empty() )
|
||||
current_item_id = cur->request->dir_tab.back()->id;
|
||||
else
|
||||
current_item_id = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void UpdateStats(PluginInfo & info, Stats::ItemStats & item_stats)
|
||||
{
|
||||
bot.SetBrowserName(info.cur->request->env_http_user_agent);
|
||||
|
||||
stats.global_all += 1;
|
||||
item_stats.all += 1;
|
||||
|
||||
if( bot.IsGoogle() )
|
||||
{
|
||||
stats.global_google += 1;
|
||||
item_stats.google += 1;
|
||||
}
|
||||
|
||||
if( bot.IsYahoo() )
|
||||
{
|
||||
stats.global_yahoo += 1;
|
||||
item_stats.yahoo += 1;
|
||||
}
|
||||
|
||||
if( bot.IsBing() )
|
||||
{
|
||||
stats.global_bing += 1;
|
||||
item_stats.bing += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ContentMake(PluginInfo & info)
|
||||
{
|
||||
StatsSession * stats_session = 0;
|
||||
|
||||
CalcItemId(info.cur);
|
||||
|
||||
if( current_item_id == - 1 || !info.plugin_data_base )
|
||||
return;
|
||||
|
||||
stats_session = reinterpret_cast<StatsSession*>(info.plugin_data_base);
|
||||
stats_session->nostat = info.cur->request->IsParam(nostat_param);
|
||||
|
||||
if( stats_session->nostat )
|
||||
return;
|
||||
|
||||
// this simply prevents F5 (refresh) from a webbrowser
|
||||
if( stats_session->last_visited != -1 &&
|
||||
stats_session->last_visited == current_item_id )
|
||||
return;
|
||||
|
||||
stats_session->last_visited = current_item_id;
|
||||
|
||||
UpdateStats(info, stats.stats_tab[current_item_id]);
|
||||
|
||||
if( !stats_session->calculated )
|
||||
{
|
||||
stats.global_unique += 1;
|
||||
stats_session->calculated = true;
|
||||
}
|
||||
|
||||
stats.PeriodicSave();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionCreated(PluginInfo & info)
|
||||
{
|
||||
StatsSession * d = new StatsSession();
|
||||
info.session->plugin_data.Assign(d);
|
||||
|
||||
if( !info.cur->request->IsParam(nostat_param) )
|
||||
{
|
||||
log << log4 << "Stats: created stats plugin data"
|
||||
<< ", plugin id: " << info.plugin_id
|
||||
<< ", pointer: " << d << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RemoveSession(PluginInfo & info)
|
||||
{
|
||||
if( !info.plugin_data_base )
|
||||
{
|
||||
// temporarily for debug
|
||||
// sometimes the pointer is null here
|
||||
log << log1 << "Stats: why the info.plugin_data_base is zero? !!!!, ses_id: " << info.session->id << logend;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
StatsSession * d = reinterpret_cast<StatsSession*>(info.plugin_data_base);
|
||||
|
||||
if( !d->nostat )
|
||||
{
|
||||
log << log4 << "Stats: deleting stats plugin data"
|
||||
<< ", plugin id: " << info.plugin_id
|
||||
<< ", pointer: " << info.plugin_data_base << logend;
|
||||
}
|
||||
|
||||
delete info.plugin_data_base;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Close(PluginInfo & info)
|
||||
{
|
||||
stats.SaveStats();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void RemoveFile(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
stats.RemoveItem(item->id);
|
||||
}
|
||||
|
||||
|
||||
void RemoveDir(PluginInfo & info)
|
||||
{
|
||||
const Item * item = reinterpret_cast<Item*>(info.p1);
|
||||
|
||||
if( item )
|
||||
stats.RemoveItem(item->id);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
|
||||
void Init(PluginInfo & info)
|
||||
{
|
||||
using namespace Stats;
|
||||
|
||||
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, CreateFunctions);
|
||||
plugin.Assign(WINIX_CONTENT_MAKE, ContentMake);
|
||||
plugin.Assign(WINIX_SESSION_CREATED, SessionCreated);
|
||||
plugin.Assign(WINIX_PLUGIN_SESSION_DATA_REMOVE, RemoveSession);
|
||||
plugin.Assign(WINIX_CLOSE, Close);
|
||||
plugin.Assign(WINIX_FILE_REMOVED, RemoveFile);
|
||||
plugin.Assign(WINIX_DIR_PREPARE_TO_REMOVE, RemoveDir);
|
||||
|
||||
stats.ReadConfig(info.config);
|
||||
stats.ReadStats();
|
||||
|
||||
info.p1 = (void*)plugin_name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
213
winixd/plugins/stats/stats.cpp
Normal file
213
winixd/plugins/stats/stats.cpp
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctime>
|
||||
#include "stats.h"
|
||||
#include "core/log.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
namespace Stats
|
||||
{
|
||||
|
||||
|
||||
|
||||
Stats::Stats()
|
||||
{
|
||||
global_all = 0;
|
||||
global_unique = 0;
|
||||
global_google = 0;
|
||||
global_yahoo = 0;
|
||||
|
||||
req_save_freq = 1000;
|
||||
req_current = 0;
|
||||
|
||||
stats_start = time(0);
|
||||
}
|
||||
|
||||
|
||||
void Stats::ReadStats(std::ifstream & file)
|
||||
{
|
||||
file >> stats_start;
|
||||
file >> global_all;
|
||||
file >> global_unique;
|
||||
file >> global_google;
|
||||
file >> global_yahoo;
|
||||
file >> global_bing;
|
||||
|
||||
size_t len;
|
||||
file >> len;
|
||||
|
||||
ItemStats s;
|
||||
long item_id;
|
||||
|
||||
for(size_t i = 0 ; i<len && !file.eof() ; ++i)
|
||||
{
|
||||
file >> item_id;
|
||||
file >> s.all;
|
||||
file >> s.google;
|
||||
file >> s.yahoo;
|
||||
file >> s.bing;
|
||||
|
||||
stats_tab.insert( std::make_pair(item_id, s) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Stats::ReadStats()
|
||||
{
|
||||
if( stats_file.empty() )
|
||||
return;
|
||||
|
||||
PT::WideToUTF8(stats_file, astats_file);
|
||||
std::ifstream file(astats_file.c_str());
|
||||
|
||||
if( !file )
|
||||
{
|
||||
log << log1 << "Stats: I cannot open a file: " << astats_file << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
ReadStats(file);
|
||||
file.close();
|
||||
|
||||
log << log3 << "Stats: statistics loaded from: " << astats_file
|
||||
<< " (" << stats_tab.size() << " items)" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Stats::SaveStats(std::ofstream & file)
|
||||
{
|
||||
file << stats_start << std::endl;
|
||||
|
||||
file << global_all << ' ';
|
||||
file << global_unique << ' ';
|
||||
file << global_google << ' ';
|
||||
file << global_yahoo << ' ';
|
||||
file << global_bing << ' ';
|
||||
file << std::endl;
|
||||
|
||||
file << stats_tab.size() << std::endl;
|
||||
|
||||
StatsTab::iterator i = stats_tab.begin();
|
||||
|
||||
for( ; i != stats_tab.end() ; ++i)
|
||||
{
|
||||
file << i->first << ' ';
|
||||
file << i->second.all << ' ';
|
||||
file << i->second.google << ' ';
|
||||
file << i->second.yahoo << ' ';
|
||||
file << i->second.bing << ' ';
|
||||
file << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Stats::SaveStats()
|
||||
{
|
||||
if( stats_file.empty() )
|
||||
return;
|
||||
|
||||
PT::WideToUTF8(stats_file, astats_file);
|
||||
std::ofstream file(astats_file.c_str());
|
||||
|
||||
if( !file )
|
||||
{
|
||||
log << log1 << "Stats: I cannot open a file: " << astats_file << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
SaveStats(file);
|
||||
file.close();
|
||||
|
||||
log << log3 << "Stats: statistics saved to: " << astats_file << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Stats::PeriodicSave()
|
||||
{
|
||||
req_current += 1;
|
||||
|
||||
if( req_save_freq != 0 && req_current >= req_save_freq )
|
||||
{
|
||||
SaveStats();
|
||||
req_current = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Stats::ReadConfig(Config * config)
|
||||
{
|
||||
stats_file = config->Text(L"stats_file");
|
||||
req_save_freq = config->Int(L"stats_req_save_freq", req_save_freq);
|
||||
|
||||
if( stats_file.empty() )
|
||||
{
|
||||
log << log1 << "you should set stats_file in your config to keep statistics between restarting winix" << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Stats: stats_file: " << stats_file << logend;
|
||||
log << log2 << "Stats: statistics will be saved after each " << req_save_freq << " requests" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Stats::RemoveItem(long id)
|
||||
{
|
||||
StatsTab::iterator i = stats_tab.find(id);
|
||||
|
||||
if( i == stats_tab.end() )
|
||||
return;
|
||||
|
||||
stats_tab.erase(i);
|
||||
log << log3 << "Stats: statistics erased for item: " << id << logend;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
121
winixd/plugins/stats/stats.h
Normal file
121
winixd/plugins/stats/stats.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_stats_stats
|
||||
#define headerfile_winix_plugins_stats_stats
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include "core/config.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
namespace Stats
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct Stats
|
||||
{
|
||||
Stats();
|
||||
|
||||
void ReadStats();
|
||||
void SaveStats();
|
||||
void PeriodicSave();
|
||||
void ReadConfig(Config * config);
|
||||
void RemoveItem(long id);
|
||||
|
||||
// file name for reading/saving statistics
|
||||
std::wstring stats_file;
|
||||
std::string astats_file;
|
||||
|
||||
// when the statistics start
|
||||
time_t stats_start;
|
||||
|
||||
int global_all;
|
||||
int global_unique;
|
||||
|
||||
int global_google;
|
||||
int global_yahoo;
|
||||
int global_bing;
|
||||
|
||||
|
||||
// statistics for files/dirs
|
||||
struct ItemStats
|
||||
{
|
||||
int all;
|
||||
int google;
|
||||
int yahoo;
|
||||
int bing;
|
||||
|
||||
ItemStats()
|
||||
{
|
||||
all = 0;
|
||||
google = 0;
|
||||
yahoo = 0;
|
||||
bing = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// <item_id, Item_stats>
|
||||
typedef std::map<long, ItemStats> StatsTab;
|
||||
StatsTab stats_tab;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// when to save the config (how many requests should have gone)
|
||||
// (for safety: power failure etc)
|
||||
// default: 1000
|
||||
// you can set: stats_req_save_freq in the config file to overwrite it
|
||||
// 0 - turn it off
|
||||
int req_save_freq;
|
||||
int req_current; // helper
|
||||
|
||||
|
||||
void ReadStats(std::ifstream & file);
|
||||
void SaveStats(std::ofstream & file);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
||||
68
winixd/plugins/stats/statssession.h
Normal file
68
winixd/plugins/stats/statssession.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_stats_statssession
|
||||
#define headerfile_winix_plugins_stats_statssession
|
||||
|
||||
#include "core/plugindata.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
namespace Stats
|
||||
{
|
||||
|
||||
|
||||
// session data for the plugin
|
||||
struct StatsSession : public PluginDataBase
|
||||
{
|
||||
// whether this session has been calculated
|
||||
bool calculated;
|
||||
long last_visited;
|
||||
bool nostat; // is nostat parameter
|
||||
|
||||
StatsSession()
|
||||
{
|
||||
calculated = false;
|
||||
last_visited = -1;
|
||||
nostat = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
||||
139
winixd/plugins/stats/templates.cpp
Normal file
139
winixd/plugins/stats/templates.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
#include "ezc.h"
|
||||
#include "core/misc.h"
|
||||
#include "stats.h"
|
||||
#include "templates/misc.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
namespace Stats
|
||||
{
|
||||
using TemplatesFunctions::Info;
|
||||
|
||||
extern long current_item_id;
|
||||
extern Stats stats;
|
||||
|
||||
|
||||
void stats_from(Info & i)
|
||||
{
|
||||
i.out << DateToStrWithoutHours(stats.stats_start);
|
||||
|
||||
}
|
||||
|
||||
void stats_all(Info & i)
|
||||
{
|
||||
i.out << stats.global_all;
|
||||
}
|
||||
|
||||
|
||||
void stats_unique(Info & i)
|
||||
{
|
||||
i.out << stats.global_unique;
|
||||
}
|
||||
|
||||
|
||||
void stats_google(Info & i)
|
||||
{
|
||||
i.out << stats.global_google;
|
||||
}
|
||||
|
||||
|
||||
void stats_yahoo(Info & i)
|
||||
{
|
||||
i.out << stats.global_yahoo;
|
||||
}
|
||||
|
||||
|
||||
void stats_bing(Info & i)
|
||||
{
|
||||
i.out << stats.global_bing;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void stats_item_all(Info & i)
|
||||
{
|
||||
i.out << stats.stats_tab[current_item_id].all;
|
||||
}
|
||||
|
||||
|
||||
void stats_item_google(Info & i)
|
||||
{
|
||||
i.out << stats.stats_tab[current_item_id].google;
|
||||
}
|
||||
|
||||
void stats_item_yahoo(Info & i)
|
||||
{
|
||||
i.out << stats.stats_tab[current_item_id].yahoo;
|
||||
}
|
||||
|
||||
void stats_item_bing(Info & i)
|
||||
{
|
||||
i.out << stats.stats_tab[current_item_id].bing;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CreateFunctions(PluginInfo & info)
|
||||
{
|
||||
using TemplatesFunctions::EzcFun;
|
||||
EzcFun * fun = reinterpret_cast<EzcFun*>(info.p1);
|
||||
|
||||
fun->Insert("stats_from", stats_from);
|
||||
|
||||
fun->Insert("stats_all", stats_all);
|
||||
fun->Insert("stats_unique", stats_unique);
|
||||
fun->Insert("stats_google", stats_google);
|
||||
fun->Insert("stats_yahoo", stats_yahoo);
|
||||
fun->Insert("stats_bing", stats_bing);
|
||||
|
||||
fun->Insert("stats_item_all", stats_item_all);
|
||||
fun->Insert("stats_item_google", stats_item_google);
|
||||
fun->Insert("stats_item_yahoo", stats_item_yahoo);
|
||||
fun->Insert("stats_item_bing", stats_item_bing);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
56
winixd/plugins/stats/templates.h
Normal file
56
winixd/plugins/stats/templates.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_plugins_stats_templates
|
||||
#define headerfile_winix_plugins_stats_templates
|
||||
|
||||
#include "core/plugin.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
namespace Stats
|
||||
{
|
||||
|
||||
|
||||
void CreateFunctions(PluginInfo & info);
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user