Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d801f53154 | |||
| a6b06f82e9 | |||
| b7f3f84080 | |||
| 26715bdd4c | |||
| 083fa7857f | |||
| 9ffda3e070 | |||
| 81160dbbe9 | |||
| 7c266b85e2 | |||
| 48cdca7549 | |||
| 1c401eae3b | |||
| 0e9eb30b5d | |||
| c10c9393c0 | |||
| 8705b3437c | |||
| aed891764a | |||
| 495499d12f | |||
| 8d9a021eab | |||
| be6e09c5af | |||
| 293e426ed4 | |||
| 60f2337b73 | |||
| ce8152de2f | |||
| 496a1979d2 | |||
| fd698ca7b9 | |||
| b4b368d324 | |||
| 825694c880 | |||
| 32750a7d50 | |||
| 0045c6c72c | |||
| 4809016b78 | |||
| 6e2ba65524 | |||
| 8033ac66c4 | |||
| 9ef3736989 | |||
| 099dd55d0c | |||
| 53b4175d00 | |||
| 8aa6f08e08 | |||
| c5024598cb | |||
| dfcf6b29c0 | |||
| 7f48d1eb2e | |||
| eaa97995d2 | |||
| 14f997b844 | |||
| 26e87b20b1 | |||
| 5cdf6eff36 | |||
| 4ed535a3b7 | |||
| da15323c2f | |||
| bd1f717b4c | |||
| 72013046fc | |||
| 14ae19143f |
@@ -1,29 +1,48 @@
|
||||
# Makefile for GNU make
|
||||
|
||||
include Makefile.dep
|
||||
|
||||
ifndef CXX
|
||||
CXX = g++
|
||||
endif
|
||||
|
||||
#ifndef CXX
|
||||
# temporarily workaround: forcing using clang (CXX is defined by the OS and is equal to g++)
|
||||
CXX = clang++
|
||||
#endif
|
||||
|
||||
ifndef CXXFLAGS
|
||||
CXXFLAGS = -fPIC -Wall -O2 -pthread -I/usr/local/include -I/home/tomek/roboczy/winix -I/home/tomek/roboczy/ezc/src -I/home/tomek/roboczy/tito/src -I/home/tomek/roboczy/pikotools -DEZC_USE_WINIX_LOGGER -DEZC_HAS_SPECIAL_STREAM
|
||||
CXXFLAGS = -Wall -O2 -fPIC -pthread -std=c++11 -I/usr/local/include -DEZC_USE_WINIX_LOGGER -DEZC_HAS_SPECIAL_STREAM
|
||||
endif
|
||||
|
||||
|
||||
ifndef CXXWINIXINCLUDEFLAGS
|
||||
# these flags are used for compiling and making dependencies (make depend)
|
||||
# it's better to not using any system directories like -I/usr/local/include here
|
||||
CXXWINIXINCLUDEFLAGS = -I../../winix -I../../../winix -I../../ezc/src -I../../../ezc/src -I../../tito/src -I../../../tito/src -I../../pikotools -I../../../pikotools
|
||||
endif
|
||||
|
||||
ifndef LDFLAGS
|
||||
LDFLAGS = -L/usr/local/lib
|
||||
endif
|
||||
|
||||
# this macro is used in ezc's Makefile
|
||||
EZC_USE_WINIX_LOGGER = yes
|
||||
|
||||
|
||||
# for make install
|
||||
winix_install_dir = /usr/local/winix
|
||||
|
||||
|
||||
export CXX
|
||||
export CXXFLAGS
|
||||
export CXXWINIXINCLUDEFLAGS
|
||||
export LDFLAGS
|
||||
export EZC_USE_WINIX_LOGGER
|
||||
|
||||
|
||||
all: winix.so plugins winix
|
||||
|
||||
|
||||
|
||||
winix.so: FORCE
|
||||
winix.so: $(winix.src.files)
|
||||
@cd core ; $(MAKE) -e
|
||||
@cd db ; $(MAKE) -e
|
||||
@cd functions ; $(MAKE) -e
|
||||
@@ -32,13 +51,12 @@ winix.so: FORCE
|
||||
@cd ../ezc/src ; $(MAKE) -e
|
||||
@cd ../tito/src ; $(MAKE) -e
|
||||
@cd ../pikotools ; $(MAKE) -e
|
||||
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) core/*.o db/*.o functions/*.o templates/*.o notify/*.o ../ezc/src/ezc.a ../tito/src/tito.a ../pikotools/utf8/utf8.a ../pikotools/space/space.a ../pikotools/mainparser/mainparser.a ../pikotools/date/date.a $(LDFLAGS) -lfcgi -lpq -lz -lfetch -lpthread -Wl,-no-whole-archive
|
||||
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) core/*.o db/*.o functions/*.o templates/*.o notify/*.o ../ezc/src/ezc.a ../tito/src/tito.a ../pikotools/utf8/utf8.a ../pikotools/space/space.a ../pikotools/mainparser/mainparser.a ../pikotools/date/date.a $(LDFLAGS) -lfcgi -lpq -lz -lfetch -lpthread -Wl,-no-whole-archive
|
||||
|
||||
|
||||
winix: winix.so FORCE
|
||||
winix: winix.so $(winix.src.files)
|
||||
@cd main ; $(MAKE) -e
|
||||
# use the full path with winix.so
|
||||
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) main/*.o /home/tomek/roboczy/winix/winix.so
|
||||
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) main/*.o winix.so
|
||||
|
||||
|
||||
|
||||
@@ -96,33 +114,42 @@ depend:
|
||||
@cd ../tito/src ; $(MAKE) -e depend
|
||||
@cd ../pikotools ; $(MAKE) -e depend
|
||||
@cd main ; $(MAKE) -e depend
|
||||
echo -n "winix.src.files = " > Makefile.dep
|
||||
find -E . -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
|
||||
find -E ../ezc/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
|
||||
find -E ../tito/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
|
||||
find -E ../pikotools -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
|
||||
|
||||
|
||||
|
||||
install: all
|
||||
# binaries
|
||||
mkdir -p /usr/local/winix/bin
|
||||
cp winix.so /usr/local/winix/bin
|
||||
# use the full path with winix.so (we have to recompile winix with a new path to winix.so)
|
||||
$(CXX) -o /usr/local/winix/bin/winix $(CXXFLAGS) main/*.o /usr/local/winix/bin/winix.so
|
||||
# installing binaries
|
||||
rm -Rf $(winix_install_dir)/bin
|
||||
mkdir -p $(winix_install_dir)/bin
|
||||
cp winix $(winix_install_dir)/bin
|
||||
cp winix.so $(winix_install_dir)/bin
|
||||
# etc configs
|
||||
mkdir -p /usr/local/winix/etc
|
||||
cp -rf etc/ /usr/local/winix/etc/
|
||||
find /usr/local/winix/etc/ -type d -name ".svn" | xargs -I foo rm -fr foo
|
||||
rm -Rf $(winix_install_dir)/etc
|
||||
mkdir -p $(winix_install_dir)/etc
|
||||
cp -rf etc/ $(winix_install_dir)/etc/
|
||||
# html templates
|
||||
mkdir -p /usr/local/winix/html
|
||||
cp -rf html/ /usr/local/winix/html/
|
||||
find /usr/local/winix/html/ -type d -name ".svn" | xargs -I foo rm -fr foo
|
||||
rm -Rf $(winix_install_dir)/html
|
||||
mkdir -p $(winix_install_dir)/html
|
||||
cp -rf html/ $(winix_install_dir)/html/
|
||||
# txt templates
|
||||
mkdir -p /usr/local/winix/txt
|
||||
cp -rf txt/ /usr/local/winix/txt/
|
||||
find /usr/local/winix/txt/ -type d -name ".svn" | xargs -I foo rm -fr foo
|
||||
rm -Rf $(winix_install_dir)/txt
|
||||
mkdir -p $(winix_install_dir)/txt
|
||||
cp -rf txt/ $(winix_install_dir)/txt/
|
||||
# locales
|
||||
mkdir -p /usr/local/winix/locale
|
||||
cp -rf locale/ /usr/local/winix/locale/
|
||||
find /usr/local/winix/locale/ -type d -name ".svn" | xargs -I foo rm -fr foo
|
||||
rm -Rf $(winix_install_dir)/locale
|
||||
mkdir -p $(winix_install_dir)/locale
|
||||
cp -rf locale/ $(winix_install_dir)/locale/
|
||||
# plugins
|
||||
mkdir -p /usr/local/winix/plugins
|
||||
find plugins/ -name "*.so" | xargs -I foo cp foo /usr/local/winix/plugins/
|
||||
# removed provileges for others
|
||||
find /usr/local/winix -exec chmod o-r,o-x,o-w "{}" "+"
|
||||
rm -Rf $(winix_install_dir)/plugins
|
||||
mkdir -p $(winix_install_dir)/plugins
|
||||
find plugins/ -name "*.so" | xargs -I foo cp foo $(winix_install_dir)/plugins/
|
||||
# deleting subversion directories
|
||||
find $(winix_install_dir) -type d -name ".svn" | xargs -I foo rm -fr foo
|
||||
# removing privileges for others
|
||||
find $(winix_install_dir) -exec chmod o-r,o-x,o-w "{}" "+"
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
+2
-2
@@ -5,11 +5,11 @@ all: $(o)
|
||||
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
$(CXX) -c $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $<
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. -I.. -I../../ezc/src -I../../pikotools -I../../tito/src -f- *.cpp > Makefile.dep
|
||||
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
|
||||
|
||||
|
||||
+753
-529
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1 +1 @@
|
||||
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o crypt.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o image.o item.o job.o lastcontainer.o loadavg.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o user.o users.o
|
||||
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o crypt.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o image.o ipbancontainer.o item.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o user.o users.o
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include "acceptbaseparser.h"
|
||||
|
||||
|
||||
|
||||
+96
-76
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <cstdio>
|
||||
#include <fetch.h>
|
||||
#include <signal.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "plugin.h"
|
||||
@@ -55,6 +57,7 @@ App::App()
|
||||
functions.SetSystem(&system);
|
||||
functions.SetTemplates(&templates);
|
||||
functions.SetSynchro(&synchro);
|
||||
functions.SetSessionManager(&session_manager);
|
||||
|
||||
system.SetConfig(&config);
|
||||
system.SetCur(&cur);
|
||||
@@ -149,6 +152,7 @@ bool App::Init()
|
||||
|
||||
// init notify after templates (it uses locales from templates)
|
||||
system.notify.ReadTemplates();
|
||||
session_manager.InitBanList();
|
||||
session_manager.InitTmpSession();
|
||||
session_manager.LoadSessions();
|
||||
|
||||
@@ -220,76 +224,39 @@ return true;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if this method returns true then we make a redirect
|
||||
*/
|
||||
bool App::ShouldNotUseSSL()
|
||||
|
||||
void App::CheckIfNeedSSLredirect()
|
||||
{
|
||||
if( cur.request->method == Request::post )
|
||||
return false;
|
||||
|
||||
if( !config.use_ssl )
|
||||
return true;
|
||||
|
||||
// !! IMPROVE ME add a flag to functions to indicate if the function need SSL
|
||||
if( cur.request->function == &functions.fun_login ||
|
||||
cur.request->function == &functions.fun_adduser )
|
||||
return false;
|
||||
|
||||
if( config.use_ssl_only_for_logged_users && !cur.session->puser )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
{
|
||||
// something comes via POST, don't do the redirect because you lose the date
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if this method returns true then we make a redirect
|
||||
*/
|
||||
bool App::ShouldUseSSL()
|
||||
if( config.use_ssl )
|
||||
{
|
||||
if( cur.request->method == Request::post )
|
||||
return false;
|
||||
|
||||
if( !config.use_ssl )
|
||||
return false;
|
||||
|
||||
// !! IMPROVE ME add a flag to functions to indicate if the function need SSL
|
||||
if( cur.request->function == &functions.fun_login ||
|
||||
cur.request->function == &functions.fun_adduser )
|
||||
return true;
|
||||
|
||||
if( config.use_ssl_only_for_logged_users && !cur.session->puser )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool App::CheckSSLcorrectness()
|
||||
if( !cur.request->using_ssl )
|
||||
{
|
||||
bool status = true;
|
||||
|
||||
if( cur.request->using_ssl )
|
||||
{
|
||||
if( ShouldNotUseSSL() )
|
||||
if( !config.use_ssl_only_for_logged_users ||
|
||||
cur.session->puser ||
|
||||
(cur.request->function && cur.request->function->need_ssl) )
|
||||
{
|
||||
log << log3 << "App: this operation should be used through SSL" << logend;
|
||||
BaseUrlRedirect(config.use_ssl_redirect_code, true);
|
||||
log << log3 << "App: this operation should NOT be used in SSL connection" << logend;
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if( ShouldUseSSL() )
|
||||
{
|
||||
if( cur.request->using_ssl )
|
||||
{
|
||||
log << log3 << "App: this operation should NOT be used through SSL" << logend;
|
||||
BaseUrlRedirect(config.use_ssl_redirect_code, true);
|
||||
log << log3 << "App: this operation should be used in SSL connection" << logend;
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::SetLocale()
|
||||
@@ -312,6 +279,23 @@ size_t locale_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool App::CheckAccessFromPlugins()
|
||||
{
|
||||
PluginRes res = plugin.Call(WINIX_CHECK_PLUGIN_ACCESS);
|
||||
|
||||
if( res.res_false > 0 )
|
||||
{
|
||||
cur.request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
log << log2 << "App: access prevented by a plugin" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::ProcessRequestThrow()
|
||||
{
|
||||
ReadRequest();
|
||||
@@ -333,16 +317,11 @@ void App::ProcessRequestThrow()
|
||||
|
||||
plugin.Call(WINIX_SESSION_CHANGED);
|
||||
functions.Parse(); // parsing directories,files,functions and parameters
|
||||
|
||||
|
||||
if( CheckSSLcorrectness() )
|
||||
{
|
||||
cur.mount = system.mounts.CalcCurMount();
|
||||
|
||||
if( system.mounts.pmount->type != system.mounts.MountTypeStatic() )
|
||||
if( cur.mount->type != system.mounts.MountTypeStatic() )
|
||||
Make();
|
||||
}
|
||||
}
|
||||
|
||||
SendAnswer();
|
||||
}
|
||||
@@ -387,6 +366,7 @@ void App::ProcessRequest()
|
||||
// simple operations which should not throw an exception
|
||||
templates.RequestEnd();
|
||||
cur.request->Clear();
|
||||
cur.session->ClearOnEndRequest();
|
||||
cur.session = session_manager.GetTmpSession();
|
||||
log << logendrequest;
|
||||
}
|
||||
@@ -458,6 +438,7 @@ bool sent = false;
|
||||
|
||||
if( cur.request->ajax_serializer )
|
||||
{
|
||||
log << log3 << "App: sending JSON" << logend;
|
||||
std::wstring & ajax_content = cur.request->ajax.Add(L"content", L"");
|
||||
ajax_content = cur.request->page.Str();
|
||||
cur.request->ajax_serializer->Serialize(cur.request->ajax, cur.request->ajaxpage, true);
|
||||
@@ -486,6 +467,7 @@ void App::CheckPostRedirect()
|
||||
|
||||
// zmienic nazwe np na ProcessRequest
|
||||
// !! ta nazwa chyba juz zajeta...
|
||||
// !! IMPROVE ME need some refactoring
|
||||
void App::Make()
|
||||
{
|
||||
if( cur.request->dir_tab.empty() )
|
||||
@@ -494,6 +476,16 @@ void App::Make()
|
||||
return;
|
||||
}
|
||||
|
||||
if( cur.session->ip_ban && cur.session->ip_ban->IsIPBanned() )
|
||||
{
|
||||
PT::Date date(cur.session->ip_ban->expires);
|
||||
|
||||
log << log2 << "App: this IP address is banned until to: " << date << " UTC" << logend;
|
||||
slog << logerror << T("this_ip_is_banned_until") << ' ' << date << " UTC" << logend;
|
||||
|
||||
cur.request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
// cur.request->status can be changed by function_parser
|
||||
if( cur.request->status == WINIX_ERR_OK )
|
||||
plugin.Call(WINIX_PREPARE_REQUEST);
|
||||
@@ -501,6 +493,15 @@ void App::Make()
|
||||
if( cur.request->status == WINIX_ERR_OK )
|
||||
functions.CheckFunctionAndSymlink();
|
||||
|
||||
CheckAccessFromPlugins();
|
||||
|
||||
// !! CHECK ME CheckFunctionAndSymlink can set redirect_to
|
||||
// may it should be tested before calling CheckIfNeedSSLredirect?
|
||||
CheckIfNeedSSLredirect();
|
||||
|
||||
if( !cur.request->redirect_to.empty() )
|
||||
return;
|
||||
|
||||
if( cur.request->status == WINIX_ERR_OK )
|
||||
functions.MakeFunction();
|
||||
|
||||
@@ -524,6 +525,13 @@ void App::Make()
|
||||
return;
|
||||
}
|
||||
|
||||
if( !cur.request->ajax_serializer && cur.request->ParamValue(L"reqtype") == L"json")
|
||||
{
|
||||
log << log3 << "App: using generic JSON serializer" << logend;
|
||||
ajax_generic_serializer.Clear();
|
||||
cur.request->ajax_serializer = &ajax_generic_serializer;
|
||||
}
|
||||
|
||||
plugin.Call(WINIX_CONTENT_MAKE);
|
||||
MakePage();
|
||||
|
||||
@@ -569,7 +577,7 @@ void App::ReadRequest()
|
||||
CheckKonqueror();
|
||||
|
||||
if( cur.request->using_ssl )
|
||||
log << log3 << "App: SSL enabled" << logend;
|
||||
log << log3 << "App: connection secure through SSL" << logend;
|
||||
|
||||
if( cur.request->role == Request::authorizer )
|
||||
log << log3 << "App: fast cgi role: authorizer" << logend;
|
||||
@@ -604,6 +612,8 @@ void App::ReadEnvVariables()
|
||||
SetEnv(cur.request->env_content_type, "CONTENT_TYPE");
|
||||
SetEnv(cur.request->env_http_accept_encoding, "HTTP_ACCEPT_ENCODING");
|
||||
SetEnv(cur.request->env_https, "HTTPS");
|
||||
|
||||
cur.request->ip = (int)inet_addr(cur.request->env_remote_addr);
|
||||
}
|
||||
|
||||
|
||||
@@ -799,7 +809,14 @@ void App::SendHeadersStatic()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::SendHeaderContentType()
|
||||
{
|
||||
if( cur.request->ajax_serializer )
|
||||
{
|
||||
FCGX_PutS("Content-Type: application/json", fcgi_request.out);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( config.content_type_header )
|
||||
{
|
||||
@@ -815,6 +832,7 @@ void App::SendHeaderContentType()
|
||||
default:
|
||||
FCGX_PutS("Content-Type: text/html", fcgi_request.out);
|
||||
}
|
||||
}
|
||||
|
||||
if( config.utf8 )
|
||||
FCGX_PutS("; charset=UTF-8", fcgi_request.out);
|
||||
@@ -828,7 +846,6 @@ void App::SendHeadersForbidden()
|
||||
{
|
||||
FCGX_PutS("Status: 403 Forbidden\r\n", fcgi_request.out);
|
||||
SendHeaderContentType();
|
||||
log << log2 << "App: response: 403 Forbidden" << logend;
|
||||
}
|
||||
|
||||
|
||||
@@ -891,7 +908,6 @@ void App::SendHeadersNormal(Header header)
|
||||
case h_404:
|
||||
FCGX_PutS("Status: 404 Not Found\r\n", fcgi_request.out);
|
||||
SendHeaderContentType();
|
||||
log << log2 << "App: response: 404 Not Found" << logend;
|
||||
break;
|
||||
|
||||
case h_403:
|
||||
@@ -969,6 +985,9 @@ void App::FilterCompressSend(bool compressing, int compress_encoding, const std:
|
||||
else
|
||||
AssignString(*source, source_a);
|
||||
|
||||
if( config.log_server_answer )
|
||||
log << log1 << "App: the server's answer is:\n" << source_a << "\nApp: end of the server's answer" << logend;
|
||||
|
||||
if( compressing )
|
||||
compress.CompressAndPut(source_a.c_str(), source_a.length(), fcgi_request.out, compress_encoding);
|
||||
else
|
||||
@@ -1087,10 +1106,22 @@ int compress_encoding;
|
||||
SelectCompression(source->length(), compressing, compress_encoding);
|
||||
|
||||
if( status == WINIX_ERR_NO_ITEM || status == WINIX_ERR_NO_FUNCTION || status == WINIX_ERR_UNKNOWN_PARAM )
|
||||
{
|
||||
header = h_404;
|
||||
log << log2 << "App: http response: 404 Not Found" << logend;
|
||||
}
|
||||
|
||||
if( status == WINIX_ERR_PERMISSION_DENIED || status == WINIX_ERR_CANT_CHANGE_USER || status == WINIX_ERR_CANT_CHANGE_GROUP )
|
||||
{
|
||||
header = h_403;
|
||||
log << log2 << "App: http response: 403 Forbidden" << logend;
|
||||
}
|
||||
|
||||
if( cur.request->use_200_status_for_not_found_and_permission_denied && (header == h_404 || header == h_403) )
|
||||
{
|
||||
log << log3 << "App: changing the http response to: 200 OK" << logend;
|
||||
header = h_200;
|
||||
}
|
||||
|
||||
SendHeaders(compressing, compress_encoding, header);
|
||||
|
||||
@@ -1112,24 +1143,13 @@ void App::SendData(const BinaryPage & page, FCGX_Stream * out)
|
||||
BinaryPage::const_iterator i = page.begin();
|
||||
BinaryPage::const_iterator end = page.end();
|
||||
|
||||
// log << log1 << "size: " << page.size() << logend;
|
||||
|
||||
// for(size_t x=0 ; x<page.size() ; ++x)
|
||||
// log << int((unsigned char)page[x]) << ' ';
|
||||
|
||||
// log << logend;
|
||||
|
||||
while( i != end )
|
||||
{
|
||||
size_t s = 0;
|
||||
|
||||
for( ; i != end && s < buf_size ; ++i, ++s)
|
||||
{
|
||||
send_data_buf[s] = *i;
|
||||
|
||||
// log << "swinka: " << int((unsigned char)*i) << logend;
|
||||
}
|
||||
|
||||
if( s > 0 )
|
||||
FCGX_PutStr(send_data_buf.c_str(), s, fcgi_request.out);
|
||||
}
|
||||
|
||||
+4
-4
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -122,14 +122,14 @@ private:
|
||||
std::string sendh_t, sendh_t2, sendh_t3;
|
||||
std::string sendfilea, sendfile2a;
|
||||
std::string send_data_buf;
|
||||
PT::SpaceToJSON ajax_generic_serializer;
|
||||
|
||||
bool CheckAccessFromPlugins();
|
||||
void ProcessRequestThrow();
|
||||
void ProcessRequest();
|
||||
void BaseUrlRedirect(int code, bool add_subdomain);
|
||||
bool BaseUrlRedirect();
|
||||
bool ShouldUseSSL();
|
||||
bool ShouldNotUseSSL();
|
||||
bool CheckSSLcorrectness();
|
||||
void CheckIfNeedSSLredirect();
|
||||
void SetLocale();
|
||||
void CheckPostRedirect();
|
||||
void MakePage();
|
||||
|
||||
+36
-1
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -113,6 +113,7 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
log_request = Int(L"log_request", 1);
|
||||
log_save_each_line = Bool(L"log_save_each_line", false);
|
||||
log_time_zone_id = Size(L"log_time_zone_id", 34);
|
||||
log_server_answer = Bool(L"log_server_answer", false);
|
||||
log_stdout = Bool(L"log_stdout", false);
|
||||
log_db_query = Bool(L"log_db_query", false);
|
||||
log_plugin_call = Bool(L"log_plugin_call", false);
|
||||
@@ -246,6 +247,18 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
etc_dir = Text(L"etc_dir", L"");
|
||||
time_zones_file = Text(L"time_zones_file", L"time_zones.conf");
|
||||
|
||||
use_ban_list = Bool(L"use_ban_list", true);
|
||||
ban_list_soft_max_size = Size(L"ban_list_soft_max_size", 50000);
|
||||
ban_list_max_size = Size(L"ban_list_max_size", 51000);
|
||||
ban_level_1_delay = Size(L"ban_level_1_delay", 1800);
|
||||
ban_level_2_delay = Size(L"ban_level_2_delay", 86400);
|
||||
ban_level_3_delay = Size(L"ban_level_3_delay", 604800);
|
||||
|
||||
incorrect_login_min_time_between_get_post = Size(L"incorrect_login_min_time_between_get_post", 2);
|
||||
incorrect_login_captcha_treshold = Size(L"incorrect_login_captcha_treshold", 3);
|
||||
incorrect_login_cannot_login_mode = Int(L"incorrect_login_cannot_login_mode", 0);
|
||||
incorrect_login_cannot_login_treshold = Size(L"incorrect_login_cannot_login_treshold", 20);
|
||||
incorrect_login_cannot_login_delay = Size(L"incorrect_login_cannot_login_delay", 1800);
|
||||
}
|
||||
|
||||
|
||||
@@ -421,6 +434,28 @@ bool Config::ListText(const std::wstring & name, std::vector<std::wstring> & lis
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Config::HasValue(const wchar_t * name, const wchar_t * value)
|
||||
{
|
||||
return space.HasValue(name, value);
|
||||
}
|
||||
|
||||
bool Config::HasValue(const wchar_t * name, const std::wstring & value)
|
||||
{
|
||||
return space.HasValue(name, value);
|
||||
}
|
||||
|
||||
bool Config::HasValue(const std::wstring & name, const wchar_t * value)
|
||||
{
|
||||
return space.HasValue(name, value);
|
||||
}
|
||||
|
||||
bool Config::HasValue(const std::wstring & name, const std::wstring & value)
|
||||
{
|
||||
return space.HasValue(name, value);
|
||||
}
|
||||
|
||||
|
||||
void Config::Print(std::wostream & out)
|
||||
{
|
||||
space.Serialize(out);
|
||||
|
||||
+78
-9
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -71,6 +71,10 @@ public:
|
||||
// default: 34 (Coordinated Universal Time UTC+00:00)
|
||||
size_t log_time_zone_id;
|
||||
|
||||
// put to log what server is sending back to the client (html/json etc)
|
||||
// default: false
|
||||
bool log_server_answer;
|
||||
|
||||
// logging db queries
|
||||
// default: false
|
||||
bool log_db_query;
|
||||
@@ -523,6 +527,68 @@ public:
|
||||
// each time zone is in a seperate space
|
||||
std::wstring time_zones_file;
|
||||
|
||||
// turn on the IP ban mechanizm
|
||||
// we have got three levels of bans (level 1, level 2, and the highest level 3)
|
||||
// default: true
|
||||
bool use_ban_list;
|
||||
|
||||
// the so called 'soft' max size
|
||||
// read below description for explanation
|
||||
// this is introduced to avoid deleting only one record from the ban list
|
||||
// default: 50000
|
||||
size_t ban_list_soft_max_size;
|
||||
|
||||
// this is the 'hard' max size of an IP's ban list
|
||||
// if there are more records than this value
|
||||
// then some of them will be removed (until the size will be ban_list_soft_max_size equal)
|
||||
// this value should be a little larger from ban_list_soft_max_size
|
||||
// default: 51000
|
||||
size_t ban_list_max_size;
|
||||
|
||||
// delay in seconds of the first level ban
|
||||
// default: 1800 (30 minutes)
|
||||
// it means withing the next 30 minutes you see only 'you are banned...' message on your webbrowser
|
||||
size_t ban_level_1_delay;
|
||||
|
||||
// delay in seconds of the second level ban
|
||||
// default: 86400 (24 hours)
|
||||
size_t ban_level_2_delay;
|
||||
|
||||
// delay in seconds of the third level ban
|
||||
// default: 604800 (7 days)
|
||||
size_t ban_level_3_delay;
|
||||
|
||||
// the minimum time in seconds which has to pass between the first GET request
|
||||
// (showing your the login form) and the second POST request (which sends the
|
||||
// login and password to the server)
|
||||
// if the time is shorter then the login attempt is treated as incorrect
|
||||
// (the same as if you provide incorrect user/password)
|
||||
// default: 2
|
||||
size_t incorrect_login_min_time_between_get_post;
|
||||
|
||||
// how many incorrect logins there must have been passed to display a captcha
|
||||
// next to the login form
|
||||
// default: 3
|
||||
size_t incorrect_login_captcha_treshold;
|
||||
|
||||
// the way how we prevent to login if there are too many incorrect login attempts
|
||||
// 0 - 'block logging' - do not show the login form in 'login' winix function
|
||||
// (instead a warning message will be printed)
|
||||
// 1 - add to ban list (warning: people from this IP will not be able to see your site and do anything)
|
||||
// default: 0
|
||||
int incorrect_login_cannot_login_mode;
|
||||
|
||||
// after how many incorrect login attempts we do the incorrect_login_cannot_login_mode action
|
||||
// default: 20
|
||||
size_t incorrect_login_cannot_login_treshold;
|
||||
|
||||
// used when incorrect_login_cannot_login_mode is zero
|
||||
// it is the time which should be passed to allow logging
|
||||
// default: 1800 (30 minutes)
|
||||
// if incorrect_login_cannot_login_mode is one then ban_level_X_delay times
|
||||
// will be taken accordingly
|
||||
size_t incorrect_login_cannot_login_delay;
|
||||
|
||||
|
||||
|
||||
Config();
|
||||
@@ -550,26 +616,29 @@ public:
|
||||
bool ListText(const wchar_t * name, std::vector<std::wstring> & list);
|
||||
bool ListText(const std::wstring & name, std::vector<std::wstring> & list);
|
||||
|
||||
bool HasValue(const wchar_t * name, const wchar_t * value);
|
||||
bool HasValue(const wchar_t * name, const std::wstring & value);
|
||||
bool HasValue(const std::wstring & name, const wchar_t * value);
|
||||
bool HasValue(const std::wstring & name, const std::wstring & value);
|
||||
|
||||
// for debug
|
||||
void Print(std::wostream & out);
|
||||
|
||||
// raw access to the config
|
||||
PT::Space space;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
PT::SpaceParser parser;
|
||||
std::string default_str;
|
||||
bool errors_to_stdout;
|
||||
|
||||
void ShowError();
|
||||
void AssignValues(bool stdout_is_closed);
|
||||
void SetAdditionalVariables();
|
||||
void CheckPasswd();
|
||||
|
||||
PT::SpaceParser parser;
|
||||
|
||||
std::string default_str;
|
||||
int default_int;
|
||||
bool default_bool;
|
||||
|
||||
bool errors_to_stdout;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
+73
-32
@@ -10,7 +10,6 @@
|
||||
#include <cstring>
|
||||
#include "crypt.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "misc.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
@@ -21,22 +20,19 @@ void Crypt::SetConfig(Config * pconfig)
|
||||
}
|
||||
|
||||
|
||||
void Crypt::TrimLastWhite(std::string & str)
|
||||
|
||||
char Crypt::ConvertToHexForm(int val)
|
||||
{
|
||||
if( str.empty() )
|
||||
return;
|
||||
if( val < 10 )
|
||||
return val + '0';
|
||||
|
||||
size_t i = str.size();
|
||||
|
||||
while( i > 0 && (IsWhite(str[i-1]) || str[i-1]==10) )
|
||||
i -= 1;
|
||||
|
||||
if( i < str.size() )
|
||||
str.erase(i);
|
||||
return val - 10 + 'a';
|
||||
}
|
||||
|
||||
|
||||
bool Crypt::Hash(int hash, const char * in, size_t inlen, std::string & out)
|
||||
|
||||
|
||||
bool Crypt::HashBin(int hash, const char * in, size_t inlen, std::string & out)
|
||||
{
|
||||
out.clear();
|
||||
|
||||
@@ -47,6 +43,7 @@ bool Crypt::Hash(int hash, const char * in, size_t inlen, std::string & out)
|
||||
PT::WideToUTF8(config->opensll_path, command);
|
||||
run.Cmd(command);
|
||||
run.Par("dgst");
|
||||
run.Par("-binary");
|
||||
|
||||
switch(hash)
|
||||
{
|
||||
@@ -62,52 +59,96 @@ bool Crypt::Hash(int hash, const char * in, size_t inlen, std::string & out)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = run.Go(in, inlen, out) == 0;
|
||||
TrimLastWhite(out);
|
||||
|
||||
return result;
|
||||
return run.Go(in, inlen, out) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::Hash(int hash, const char * in, std::string & out)
|
||||
bool Crypt::HashBin(int hash, const char * in, std::string & out)
|
||||
{
|
||||
size_t len = strlen(in);
|
||||
return Hash(hash, in, len, out);
|
||||
return HashBin(hash, in, len, out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::Hash(int hash, const std::string & in, std::string & out)
|
||||
bool Crypt::HashBin(int hash, const std::string & in, std::string & out)
|
||||
{
|
||||
return Hash(hash, in.c_str(), in.size(), out);
|
||||
return HashBin(hash, in.c_str(), in.size(), out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::Hash(int hash, const wchar_t * in, size_t inlen, std::wstring & out)
|
||||
bool Crypt::HashBin(int hash, const wchar_t * in, size_t inlen, std::string & out)
|
||||
{
|
||||
PT::WideToUTF8(in, inlen, bufina);
|
||||
int res = Hash(hash, bufina.c_str(), bufina.size(), bufouta);
|
||||
|
||||
// the output hash is not a UTF8 string
|
||||
// it consists only from ascii letters
|
||||
AssignString(bufouta, out);
|
||||
int res = HashBin(hash, bufina.c_str(), bufina.size(), out);
|
||||
bufina.clear();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool Crypt::Hash(int hash, const wchar_t * in, std::wstring & out)
|
||||
bool Crypt::HashBin(int hash, const wchar_t * in, std::string & out)
|
||||
{
|
||||
size_t len = wcslen(in);
|
||||
return Hash(hash, in, len, out);
|
||||
|
||||
return HashBin(hash, in, len, out);
|
||||
}
|
||||
|
||||
bool Crypt::Hash(int hash, const std::wstring & in, std::wstring & out)
|
||||
|
||||
bool Crypt::HashBin(int hash, const std::wstring & in, std::string & out)
|
||||
{
|
||||
return Hash(hash, in.c_str(), in.size(), out);
|
||||
return HashBin(hash, in.c_str(), in.size(), out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::HashHex(int hash, const char * in, size_t inlen, std::string & out)
|
||||
{
|
||||
int res = HashBin(hash, in, inlen, out_temp);
|
||||
|
||||
ConvertToHexForm(out_temp, out);
|
||||
out_temp.clear();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool Crypt::HashHex(int hash, const char * in, std::string & out)
|
||||
{
|
||||
size_t len = strlen(in);
|
||||
return HashHex(hash, in, len, out);
|
||||
}
|
||||
|
||||
|
||||
bool Crypt::HashHex(int hash, const std::string & in, std::string & out)
|
||||
{
|
||||
return HashHex(hash, in.c_str(), in.size(), out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::HashHex(int hash, const wchar_t * in, size_t inlen, std::wstring & out)
|
||||
{
|
||||
int res = HashBin(hash, in, inlen, out_temp);
|
||||
|
||||
ConvertToHexForm(out_temp, out);
|
||||
out_temp.clear();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool Crypt::HashHex(int hash, const wchar_t * in, std::wstring & out)
|
||||
{
|
||||
size_t len = wcslen(in);
|
||||
return HashHex(hash, in, len, out);
|
||||
}
|
||||
|
||||
|
||||
bool Crypt::HashHex(int hash, const std::wstring & in, std::wstring & out)
|
||||
{
|
||||
return HashHex(hash, in.c_str(), in.size(), out);
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +240,7 @@ bool Crypt::PassHash(const std::wstring & salt, UserPass & up)
|
||||
pass_salted = up.pass;
|
||||
pass_salted += salt;
|
||||
|
||||
if( Hash(up.pass_type, pass_salted, up.pass) )
|
||||
if( HashHex(up.pass_type, pass_salted, up.pass) )
|
||||
{
|
||||
if( !salt.empty() )
|
||||
up.pass_hash_salted = true;
|
||||
|
||||
+68
-15
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -50,11 +50,11 @@ public:
|
||||
in - input buffer
|
||||
inlen - the length of the buffer
|
||||
output:
|
||||
out - the hash
|
||||
out - the hash in binary form
|
||||
*/
|
||||
bool Hash(int hash, const char * in, size_t inlen, std::string & out);
|
||||
bool Hash(int hash, const char * in, std::string & out);
|
||||
bool Hash(int hash, const std::string & in, std::string & out);
|
||||
bool HashBin(int hash, const char * in, size_t inlen, std::string & out);
|
||||
bool HashBin(int hash, const char * in, std::string & out);
|
||||
bool HashBin(int hash, const std::string & in, std::string & out);
|
||||
|
||||
|
||||
/*
|
||||
@@ -66,11 +66,43 @@ public:
|
||||
in - input buffer
|
||||
inlen - the length of the buffer
|
||||
output:
|
||||
out - the hash
|
||||
out - the hash in binary form
|
||||
*/
|
||||
bool Hash(int hash, const wchar_t * in, size_t inlen, std::wstring & out);
|
||||
bool Hash(int hash, const wchar_t * in, std::wstring & out);
|
||||
bool Hash(int hash, const std::wstring & in, std::wstring & out);
|
||||
bool HashBin(int hash, const wchar_t * in, size_t inlen, std::string & out);
|
||||
bool HashBin(int hash, const wchar_t * in, std::string & out);
|
||||
bool HashBin(int hash, const std::wstring & in, std::string & out);
|
||||
|
||||
|
||||
/*
|
||||
calculating a hash from a given input
|
||||
|
||||
input:
|
||||
hash - the kind of the hash - WINIX_CRYPT_HASH_*
|
||||
in - input buffer
|
||||
inlen - the length of the buffer
|
||||
output:
|
||||
out - the hash in the hex form (one byte is saved as two hex digits)
|
||||
*/
|
||||
bool HashHex(int hash, const char * in, size_t inlen, std::string & out);
|
||||
bool HashHex(int hash, const char * in, std::string & out);
|
||||
bool HashHex(int hash, const std::string & in, std::string & out);
|
||||
|
||||
|
||||
/*
|
||||
calculating a hash from a given input
|
||||
the input string is first changed to UTF8 and then hash is calculated
|
||||
|
||||
input:
|
||||
hash - the kind of the hash - WINIX_CRYPT_HASH_*
|
||||
in - input buffer
|
||||
inlen - the length of the buffer
|
||||
output:
|
||||
out - the hash in the hex form (one byte is saved as two hex digits)
|
||||
the 'out' here is std::wstring (not std::string like beforehand)
|
||||
*/
|
||||
bool HashHex(int hash, const wchar_t * in, size_t inlen, std::wstring & out);
|
||||
bool HashHex(int hash, const wchar_t * in, std::wstring & out);
|
||||
bool HashHex(int hash, const std::wstring & in, std::wstring & out);
|
||||
|
||||
|
||||
/*
|
||||
@@ -83,7 +115,7 @@ public:
|
||||
inlen - the size of the buffer
|
||||
|
||||
output:
|
||||
out - encrypted or decrypted buffer
|
||||
out - encrypted or decrypted buffer (always binary)
|
||||
*/
|
||||
bool RSA(bool encrypt, const char * keypath, const char * in, size_t inlen, std::string & out);
|
||||
bool RSA(bool encrypt, const char * keypath, const std::string & in, std::string & out);
|
||||
@@ -179,22 +211,27 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void TrimLastWhite(std::string & str);
|
||||
|
||||
Config * config;
|
||||
Run run;
|
||||
std::string command, bufina, bufouta, keypatha;
|
||||
std::string command, bufina, keypatha;
|
||||
//std::wstring pass_salted;//, pass_hashed;
|
||||
//std::string pass_hasheda, pass_encrypteda;
|
||||
|
||||
std::wstring pass_salted, pass_org;
|
||||
std::string passa;
|
||||
std::string passa, out_temp;
|
||||
std::wstring empty;
|
||||
|
||||
|
||||
template<typename StringType>
|
||||
void ConvertToHexForm(const std::string & in, StringType & out);
|
||||
|
||||
char ConvertToHexForm(int val);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
template<typename StringType>
|
||||
void Crypt::ClearString(StringType & str)
|
||||
{
|
||||
for(size_t i=0 ; i<str.size() ; ++i)
|
||||
@@ -204,6 +241,22 @@ void Crypt::ClearString(StringType & str)
|
||||
}
|
||||
|
||||
|
||||
template<typename StringType>
|
||||
void Crypt::ConvertToHexForm(const std::string & in, StringType & out)
|
||||
{
|
||||
out.clear();
|
||||
|
||||
if( in.size() * 2 > out.capacity() )
|
||||
out.reserve(in.size() * 2);
|
||||
|
||||
for(size_t i=0 ; i<in.size() ; ++i)
|
||||
{
|
||||
out += ConvertToHexForm(((unsigned char)in[i]) >> 4);
|
||||
out += ConvertToHexForm(((unsigned char)in[i]) & 0x0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+18
-5
@@ -351,7 +351,7 @@ return &(*etc);
|
||||
}
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::wstring & name, long parent)
|
||||
Item * Dirs::GetDir(const wchar_t * name, long parent)
|
||||
{
|
||||
DirContainer::ParentIterator i = dir_tab.FindFirstChild(parent);
|
||||
|
||||
@@ -363,10 +363,16 @@ return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::wstring & path)
|
||||
Item * Dirs::GetDir(const std::wstring & name, long parent)
|
||||
{
|
||||
if( path.empty() )
|
||||
return GetDir(name.c_str(), parent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const wchar_t * path)
|
||||
{
|
||||
if( *path == 0 )
|
||||
return 0;
|
||||
|
||||
DirContainer::Iterator root = dir_tab.GetRoot();
|
||||
@@ -376,7 +382,7 @@ Item * Dirs::GetDir(const std::wstring & path)
|
||||
return 0;
|
||||
|
||||
Item * pitem = &(*root);
|
||||
const wchar_t * s = path.c_str();
|
||||
const wchar_t * s = path;
|
||||
|
||||
while( ExtractName(s, get_dir_temp) )
|
||||
{
|
||||
@@ -390,6 +396,13 @@ return pitem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::wstring & path)
|
||||
{
|
||||
return GetDir(path.c_str());
|
||||
}
|
||||
|
||||
|
||||
Item * Dirs::GetDir(long id)
|
||||
{
|
||||
DirContainer::Iterator i = dir_tab.FindId(id);
|
||||
|
||||
@@ -67,7 +67,10 @@ public:
|
||||
Item * GetRootDir();
|
||||
Item * GetEtcDir();
|
||||
Item * GetVarDir();
|
||||
|
||||
Item * GetDir(const wchar_t * name, long parent);
|
||||
Item * GetDir(const std::wstring & name, long parent);
|
||||
Item * GetDir(const wchar_t * path);
|
||||
Item * GetDir(const std::wstring & path);
|
||||
Item * GetDir(long id);
|
||||
Item * AddDir(const Item & item);
|
||||
|
||||
+265
-86
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "log.h"
|
||||
#include "system.h"
|
||||
#include "plugin.h"
|
||||
#include "lock.h"
|
||||
|
||||
|
||||
|
||||
@@ -35,11 +36,87 @@ void Image::SetSystem(System * psystem)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void Image::Resize(const Item & item, size_t cx, size_t cy, int aspect_mode, int quality)
|
||||
Image::Scale Image::GetImageScale(long dir_id)
|
||||
{
|
||||
Scale scale;
|
||||
|
||||
Mount * m = system->mounts.CalcMount(dir_id);
|
||||
scale.cx = config->image_cx;
|
||||
scale.cy = config->image_cy;
|
||||
scale.aspect_mode = config->image_mode;
|
||||
scale.quality = config->image_quality;
|
||||
|
||||
// reading width and height from the mount point (if exists)
|
||||
int index = system->mounts.MountParImageSize();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 2 )
|
||||
{
|
||||
scale.cx = Tol(m->param[index].arg[0]);
|
||||
scale.cy = Tol(m->param[index].arg[1]);
|
||||
}
|
||||
|
||||
// reading image mode from the mount point (if exists)
|
||||
index = system->mounts.MountParImageMode();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||
scale.aspect_mode = Toi(m->param[index].arg[0]);
|
||||
|
||||
// reading image quality from the mount point (if exists)
|
||||
index = system->mounts.MountParImageQuality();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||
scale.quality = Toi(m->param[index].arg[0]);
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
Image::Scale Image::GetThumbScale(long dir_id)
|
||||
{
|
||||
Scale scale;
|
||||
|
||||
Mount * m = system->mounts.CalcMount(dir_id);
|
||||
scale.cx = config->thumb_cx;
|
||||
scale.cy = config->thumb_cy;
|
||||
scale.aspect_mode = config->thumb_mode;
|
||||
scale.quality = config->thumb_quality;
|
||||
|
||||
// reading width and height from the mount point (if exists)
|
||||
int index = system->mounts.MountParThumbSize();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 2 )
|
||||
{
|
||||
scale.cx = Tol(m->param[index].arg[0]);
|
||||
scale.cy = Tol(m->param[index].arg[1]);
|
||||
}
|
||||
|
||||
// reading thumb mode from the mount point (if exists)
|
||||
index = system->mounts.MountParThumbMode();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||
scale.aspect_mode = Toi(m->param[index].arg[0]);
|
||||
|
||||
// reading image quality from the mount point (if exists)
|
||||
index = system->mounts.MountParThumbQuality();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||
scale.quality = Toi(m->param[index].arg[0]);
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void Image::Resize(long file_id, size_t cx, size_t cy, int aspect_mode, int quality)
|
||||
{
|
||||
item_temp.type = WINIX_IMAGE_TYPE_RESIZE;
|
||||
item_temp.file = item;
|
||||
item_temp.file_id = file_id;
|
||||
item_temp.cx = cx;
|
||||
item_temp.cy = cy;
|
||||
item_temp.aspect_mode = aspect_mode;
|
||||
@@ -51,13 +128,14 @@ void Image::Resize(const Item & item, size_t cx, size_t cy, int aspect_mode, int
|
||||
}
|
||||
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void Image::CreateThumb(const Item & item, size_t cx, size_t cy, int aspect_mode, int quality)
|
||||
void Image::CreateThumb(long file_id, size_t thumb_cx, size_t thumb_cy, int aspect_mode, int quality)
|
||||
{
|
||||
item_temp.type = WINIX_IMAGE_TYPE_CREATE_THUMB;
|
||||
item_temp.file = item;
|
||||
item_temp.cx = cx;
|
||||
item_temp.cy = cy;
|
||||
item_temp.file_id = file_id;
|
||||
item_temp.thumb_cx = thumb_cx;
|
||||
item_temp.thumb_cy = thumb_cy;
|
||||
item_temp.aspect_mode = aspect_mode;
|
||||
item_temp.quality = quality;
|
||||
|
||||
@@ -68,31 +146,75 @@ void Image::CreateThumb(const Item & item, size_t cx, size_t cy, int aspect_mode
|
||||
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void Image::Crop(long file_id, size_t xoffset, size_t yoffset, size_t cx, size_t cy, int quality)
|
||||
{
|
||||
item_temp.type = WINIX_IMAGE_TYPE_CROP;
|
||||
item_temp.file_id = file_id;
|
||||
item_temp.xoffset = xoffset;
|
||||
item_temp.yoffset = yoffset;
|
||||
item_temp.cx = cx;
|
||||
item_temp.cy = cy;
|
||||
item_temp.quality = quality;
|
||||
|
||||
CheckParam(item_temp);
|
||||
image_tab.insert(image_tab.end(), item_temp);
|
||||
WakeUpThread();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void Image::CropThumb(long file_id, size_t xoffset, size_t yoffset, size_t cx, size_t cy, int quality)
|
||||
{
|
||||
item_temp.type = WINIX_IMAGE_TYPE_CROP_THUMB;
|
||||
item_temp.file_id = file_id;
|
||||
item_temp.xoffset = xoffset;
|
||||
item_temp.yoffset = yoffset;
|
||||
item_temp.cx = cx;
|
||||
item_temp.cy = cy;
|
||||
item_temp.quality = quality;
|
||||
|
||||
CheckParam(item_temp);
|
||||
image_tab.insert(image_tab.end(), item_temp);
|
||||
WakeUpThread();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void Image::CropNewThumb(long file_id, size_t xoffset, size_t yoffset, size_t cx, size_t cy,
|
||||
size_t thumb_cx, size_t thumb_cy, int aspect_mode, int quality)
|
||||
{
|
||||
item_temp.type = WINIX_IMAGE_TYPE_CREATE_CROP_NEW_THUMB;
|
||||
item_temp.file_id = file_id;
|
||||
item_temp.xoffset = xoffset;
|
||||
item_temp.yoffset = yoffset;
|
||||
item_temp.cx = cx;
|
||||
item_temp.cy = cy;
|
||||
item_temp.thumb_cx = thumb_cx;
|
||||
item_temp.thumb_cy = thumb_cy;
|
||||
item_temp.aspect_mode = aspect_mode;
|
||||
item_temp.quality = quality;
|
||||
|
||||
CheckParam(item_temp);
|
||||
image_tab.insert(image_tab.end(), item_temp);
|
||||
WakeUpThread();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Image::CheckParam(ImageItem & item)
|
||||
{
|
||||
if( item.aspect_mode < 1 )
|
||||
item.aspect_mode = 1;
|
||||
|
||||
if( item.aspect_mode > 7 )
|
||||
item.aspect_mode = 7;
|
||||
|
||||
if( item.quality < 0 )
|
||||
item.quality = 0;
|
||||
|
||||
if( item.quality > 100 )
|
||||
item.quality = 100;
|
||||
|
||||
if( item_temp.cx < 5 )
|
||||
item_temp.cx = 5;
|
||||
|
||||
if( item_temp.cy < 5 )
|
||||
item_temp.cy = 5;
|
||||
|
||||
if( item_temp.cx > 10000 )
|
||||
item_temp.cx = 10000;
|
||||
|
||||
if( item_temp.cy > 10000 )
|
||||
item_temp.cy = 10000;
|
||||
SetMinMax(item.aspect_mode, 1, 7);
|
||||
SetMinMax(item.quality, 0, 100);
|
||||
SetMinMax(item.cx, 1, 30000);
|
||||
SetMinMax(item.cy, 1, 30000);
|
||||
SetMinMax(item.thumb_cx, 1, 30000);
|
||||
SetMinMax(item.thumb_cy, 1, 30000);
|
||||
SetMinMax(item.xoffset, 0, 30000);
|
||||
SetMinMax(item.yoffset, 0, 30000);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +239,7 @@ bool end;
|
||||
|
||||
do
|
||||
{
|
||||
Lock();
|
||||
class Lock lock_object(synchro);
|
||||
|
||||
if( i != image_tab.end() )
|
||||
{
|
||||
@@ -130,7 +252,7 @@ bool end;
|
||||
end = true;
|
||||
}
|
||||
|
||||
Unlock();
|
||||
lock_object.Unlock();
|
||||
|
||||
if( !end )
|
||||
CreateImage();
|
||||
@@ -163,6 +285,7 @@ void Image::EscapePath(const std::string & path, TextStream<std::string> & out,
|
||||
if( path[i] == '"' )
|
||||
out << '\\';
|
||||
|
||||
if( path[i] != 0 )
|
||||
out << path[i];
|
||||
}
|
||||
|
||||
@@ -184,37 +307,37 @@ widthxheight! Width and height emphatically given, original aspect ratio ignor
|
||||
widthxheight> Change as per widthxheight but only if an image dimension exceeds a specified dimension.
|
||||
widthxheight< Change dimensions only if both image dimensions exceed specified dimensions.
|
||||
*/
|
||||
void Image::SelectAspect()
|
||||
void Image::SelectAspect(size_t cx, size_t cy)
|
||||
{
|
||||
switch( item_work.aspect_mode )
|
||||
{
|
||||
case WINIX_IMAGE_MODE_1:
|
||||
command << item_work.cx;
|
||||
command << cx;
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_3:
|
||||
command << item_work.cx << "x" << item_work.cy;
|
||||
command << cx << "x" << cy;
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_4:
|
||||
command << '"' << item_work.cx << "x" << item_work.cy << "^\"";
|
||||
command << '"' << cx << "x" << cy << "^\"";
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_5:
|
||||
command << '"' << item_work.cx << "x" << item_work.cy << "!\"";
|
||||
command << '"' << cx << "x" << cy << "!\"";
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_6:
|
||||
command << '"' << item_work.cx << "x" << item_work.cy << ">\"";
|
||||
command << '"' << cx << "x" << cy << ">\"";
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_7:
|
||||
command << '"' << item_work.cx << "x" << item_work.cy << "<\"";
|
||||
command << '"' << cx << "x" << cy << "<\"";
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_2:
|
||||
default:
|
||||
command << "x" << item_work.cy;
|
||||
command << "x" << cy;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -224,7 +347,17 @@ void Image::SelectAspect()
|
||||
// second thread (objects locked)
|
||||
bool Image::CreateInputFileName()
|
||||
{
|
||||
if( system->MakeFilePath(item_work.file, src_path) )
|
||||
bool thumb = (item_work.type == WINIX_IMAGE_TYPE_CROP_THUMB);
|
||||
|
||||
if( thumb && !file_work.has_thumb )
|
||||
{
|
||||
log << log1 << "Image: file id: " << file_work.id << ", url: " << file_work.url
|
||||
<< " doesn't have a thumbnail yet (skipping)" << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( system->MakeFilePath(file_work, src_path, thumb) )
|
||||
{
|
||||
PT::WideToUTF8(src_path, input_file_name);
|
||||
return true;
|
||||
@@ -237,6 +370,7 @@ bool Image::CreateInputFileName()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread (objects locked)
|
||||
void Image::CreateTmpFileName()
|
||||
{
|
||||
@@ -250,26 +384,17 @@ void Image::CreateTmpFileName()
|
||||
// second thread (objects are not locked)
|
||||
bool Image::CreateCommand()
|
||||
{
|
||||
Lock();
|
||||
class Lock lock_object(synchro);
|
||||
|
||||
iq.SetAll(true, false);
|
||||
iq.WhereId(item_work.file.id);
|
||||
|
||||
// !! skoro teraz i tak wczytujemy caly obiekt
|
||||
// to teraz w kolejce wystarczy zapamietywac tylko samo item.id (a nie caly obiekt item)
|
||||
iq.WhereId(item_work.file_id);
|
||||
|
||||
// the file could have been changed especially when there is a long queue of files
|
||||
if( db->GetItem(item_work.file, iq) != WINIX_ERR_OK )
|
||||
{
|
||||
Unlock();
|
||||
if( db->GetItem(file_work, iq) != WINIX_ERR_OK )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !CreateInputFileName() )
|
||||
{
|
||||
Unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
command.Clear();
|
||||
Add(config->convert_cmd, command);
|
||||
@@ -279,11 +404,38 @@ bool Image::CreateCommand()
|
||||
command << " -quiet -quality " << item_work.quality;
|
||||
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_RESIZE )
|
||||
{
|
||||
command << " -resize ";
|
||||
SelectAspect(item_work.cx, item_work.cy);
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CREATE_THUMB )
|
||||
{
|
||||
command << " -strip -thumbnail ";
|
||||
SelectAspect(item_work.thumb_cx, item_work.thumb_cy);
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CROP )
|
||||
{
|
||||
command << " -crop " << item_work.cx << "x" << item_work.cy
|
||||
<< "+" << item_work.xoffset << "+" << item_work.yoffset << " +repage ";
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CROP_THUMB )
|
||||
{
|
||||
command << " -strip -crop " << item_work.cx << "x" << item_work.cy
|
||||
<< "+" << item_work.xoffset << "+" << item_work.yoffset
|
||||
<< " +repage ";
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CREATE_CROP_NEW_THUMB )
|
||||
{
|
||||
command << " -strip -crop " << item_work.cx << "x" << item_work.cy
|
||||
<< "+" << item_work.xoffset << "+" << item_work.yoffset
|
||||
<< " +repage -thumbnail ";
|
||||
SelectAspect(item_work.thumb_cx, item_work.thumb_cy);
|
||||
}
|
||||
|
||||
SelectAspect();
|
||||
CreateTmpFileName();
|
||||
|
||||
command << " ";
|
||||
@@ -291,7 +443,6 @@ bool Image::CreateCommand()
|
||||
|
||||
log << log4 << "Image: running: " << command.Str() << logend;
|
||||
|
||||
Unlock();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -299,43 +450,77 @@ return true;
|
||||
|
||||
|
||||
|
||||
// second thread (objects are locked)
|
||||
void Image::ImageSavedCorrectly()
|
||||
{
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CREATE_THUMB )
|
||||
{
|
||||
if( !file_work.has_thumb )
|
||||
{
|
||||
file_work.has_thumb = true;
|
||||
db->EditHasThumbById(true, file_work.id);
|
||||
}
|
||||
|
||||
log << log3 << "Image: generated a thumbnail: " << dst_path << logend;
|
||||
plugin.Call((Session*)0, WINIX_CREATED_THUMB, &file_work);
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_RESIZE )
|
||||
{
|
||||
log << log3 << "Image: image resized: " << dst_path << logend;
|
||||
plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CROP )
|
||||
{
|
||||
log << log3 << "Image: image cropped: " << dst_path << logend;
|
||||
// !! IMPROVE ME add a correct message
|
||||
//plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CROP_THUMB )
|
||||
{
|
||||
log << log3 << "Image: image thumbnail cropped: " << dst_path << logend;
|
||||
// !! IMPROVE ME add a correct message
|
||||
//plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
}
|
||||
else
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_CREATE_CROP_NEW_THUMB )
|
||||
{
|
||||
log << log3 << "Image: a new thumbnail from an original image was cropped: " << dst_path << logend;
|
||||
// !! IMPROVE ME add a correct message
|
||||
//plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &file_work);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// second thread (objects are not locked)
|
||||
void Image::SaveImage()
|
||||
{
|
||||
bool moved = false;
|
||||
|
||||
Lock();
|
||||
class Lock lock_object(synchro);
|
||||
|
||||
// the file could have been changed especially when creating the image lasted too long
|
||||
iq.SetAll(true, false);
|
||||
iq.WhereId(item_work.file.id);
|
||||
iq.WhereId(item_work.file_id);
|
||||
|
||||
if( db->GetItem(item_work.file, iq) == WINIX_ERR_OK )
|
||||
if( db->GetItem(file_work, iq) == WINIX_ERR_OK )
|
||||
{
|
||||
bool thumb = (item_work.type == WINIX_IMAGE_TYPE_CREATE_THUMB);
|
||||
bool thumb = (item_work.type == WINIX_IMAGE_TYPE_CREATE_THUMB ||
|
||||
item_work.type == WINIX_IMAGE_TYPE_CROP_THUMB ||
|
||||
item_work.type == WINIX_IMAGE_TYPE_CREATE_CROP_NEW_THUMB );
|
||||
|
||||
if( system->MakeFilePath(item_work.file, dst_path, thumb, true, config->upload_dirs_chmod) )
|
||||
if( system->MakeFilePath(file_work, dst_path, thumb, true, config->upload_dirs_chmod) )
|
||||
{
|
||||
if( RenameFile(stream_tmp_path.Str(), dst_path) )
|
||||
{
|
||||
if( thumb )
|
||||
{
|
||||
item_work.file.has_thumb = true;
|
||||
db->EditHasThumbById(true, item_work.file.id);
|
||||
log << log3 << "Image: generated a thumbnail: " << dst_path << logend;
|
||||
plugin.Call((Session*)0, WINIX_CREATED_THUMB, &item_work.file);
|
||||
ImageSavedCorrectly();
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log3 << "Image: image resized: " << dst_path << logend;
|
||||
plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &item_work.file);
|
||||
}
|
||||
log << log1 << "Image: cannot move a temporary file: " << stream_tmp_path.Str()
|
||||
<< ", to: " << dst_path << logend;
|
||||
|
||||
moved = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Image: cannot move a temporary file: " << stream_tmp_path.Str() << ", to: " << dst_path << logend;
|
||||
::RemoveFile(stream_tmp_path.Str());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -343,11 +528,6 @@ bool moved = false;
|
||||
log << log1 << "Image: cannot create a destination path" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
if( !moved )
|
||||
::RemoveFile(stream_tmp_path.Str());
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -355,9 +535,8 @@ bool moved = false;
|
||||
// second thread (objects are not locked)
|
||||
void Image::CreateImage()
|
||||
{
|
||||
if( !CreateCommand() )
|
||||
return;
|
||||
|
||||
if( CreateCommand() )
|
||||
{
|
||||
int res = std::system(command.CStr());
|
||||
|
||||
if( res == 0 )
|
||||
@@ -366,10 +545,10 @@ void Image::CreateImage()
|
||||
}
|
||||
else
|
||||
{
|
||||
Lock();
|
||||
class Lock lock_object(synchro);
|
||||
log << log3 << "Image: some problems with creating an image"
|
||||
<< ", 'convert' process returned: " << res << logend;
|
||||
Unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+74
-6
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -22,7 +22,7 @@
|
||||
class System;
|
||||
|
||||
|
||||
|
||||
// aspect modes:
|
||||
// Width given, height automagically selected to preserve aspect ratio.
|
||||
#define WINIX_IMAGE_MODE_1 1
|
||||
|
||||
@@ -45,25 +45,74 @@ class System;
|
||||
#define WINIX_IMAGE_MODE_7 7
|
||||
|
||||
|
||||
|
||||
|
||||
// resizing
|
||||
#define WINIX_IMAGE_TYPE_RESIZE 1
|
||||
|
||||
// generating a thumbnail
|
||||
#define WINIX_IMAGE_TYPE_CREATE_THUMB 2
|
||||
|
||||
// cropping an image
|
||||
#define WINIX_IMAGE_TYPE_CROP 3
|
||||
|
||||
// cropping an thumbnail
|
||||
#define WINIX_IMAGE_TYPE_CROP_THUMB 4
|
||||
|
||||
// creating by cropping a new thumbnail (from an original image)
|
||||
#define WINIX_IMAGE_TYPE_CREATE_CROP_NEW_THUMB 5
|
||||
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
class Image : public BaseThread
|
||||
{
|
||||
public:
|
||||
|
||||
struct Scale
|
||||
{
|
||||
size_t cx;
|
||||
size_t cy;
|
||||
int aspect_mode;
|
||||
int quality;
|
||||
|
||||
Scale()
|
||||
{
|
||||
cx = cy = 1;
|
||||
aspect_mode = 2;
|
||||
quality = 100;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
void SetDb(Db * pdb);
|
||||
void SetConfig(Config * pconfig);
|
||||
void SetSystem(System * psystem);
|
||||
|
||||
void Resize(const Item & item, size_t cx, size_t cy, int aspect_mode, int quality);
|
||||
void CreateThumb(const Item & item, size_t cx, size_t cy, int aspect_mode, int quality);
|
||||
|
||||
// returning scale info for a directory
|
||||
Scale GetImageScale(long dir_id);
|
||||
|
||||
// returning scale info (for thumbnails) for a directory
|
||||
Scale GetThumbScale(long dir_id);
|
||||
|
||||
|
||||
|
||||
void Resize(long file_id, size_t cx, size_t cy, int aspect_mode, int quality);
|
||||
|
||||
// creating a new thumbnail from an original image
|
||||
void CreateThumb(long file_id, size_t thumb_cx, size_t thumb_cy, int aspect_mode, int quality);
|
||||
|
||||
// cropping an image (the thumbnail is not changed)
|
||||
void Crop(long file_id, size_t xoffset, size_t yoffset, size_t cx, size_t cy, int quality);
|
||||
|
||||
// cropping an existing thumbnail
|
||||
void CropThumb(long file_id, size_t xoffset, size_t yoffset, size_t cx, size_t cy, int quality);
|
||||
|
||||
// creating and cropping a new thumbnail (from an original image)
|
||||
void CropNewThumb(long file_id, size_t xoffset, size_t yoffset, size_t cx, size_t cy,
|
||||
size_t thumb_cx, size_t thumb_cy, int aspect_mode, int quality);
|
||||
|
||||
|
||||
private:
|
||||
@@ -75,13 +124,29 @@ private:
|
||||
struct ImageItem
|
||||
{
|
||||
int type; // WINIX_IMAGE_TYPE_*
|
||||
Item file;
|
||||
long file_id;
|
||||
size_t cx;
|
||||
size_t cy;
|
||||
size_t xoffset; // xoffset and yoffset are used when cropping
|
||||
size_t yoffset;
|
||||
size_t thumb_cx;
|
||||
size_t thumb_cy;
|
||||
int aspect_mode;
|
||||
int quality;
|
||||
};
|
||||
|
||||
|
||||
template<typename int_type>
|
||||
void SetMinMax(int_type & var, int var_min, int var_max)
|
||||
{
|
||||
if( static_cast<int>(var) < var_min )
|
||||
var = var_min;
|
||||
|
||||
if( static_cast<int>(var) > var_max )
|
||||
var = var_max;
|
||||
}
|
||||
|
||||
|
||||
// queue of thumbnails to create
|
||||
typedef std::list<ImageItem> ImageTab;
|
||||
ImageTab image_tab;
|
||||
@@ -96,6 +161,7 @@ private:
|
||||
std::string add_tempa;
|
||||
std::string input_file_name;
|
||||
std::string tmp_file_name;
|
||||
Item file_work;
|
||||
|
||||
virtual bool SignalReceived();
|
||||
virtual void Do();
|
||||
@@ -104,10 +170,12 @@ private:
|
||||
void CreateTmpFileName();
|
||||
void SaveImage();
|
||||
void CreateImage();
|
||||
void SelectAspect();
|
||||
void SelectAspect(size_t cx, size_t cy);
|
||||
void EscapePath(const std::string & path, TextStream<std::string> & out, bool clear_stream = true);
|
||||
void CheckParam(ImageItem & item);
|
||||
void Add(const std::wstring & in, TextStream<std::string> & out);
|
||||
void ImageSavedCorrectly();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_ipban
|
||||
#define headerfile_winix_core_ipban
|
||||
|
||||
#include <ctime>
|
||||
|
||||
|
||||
// telling if the IPBan record is active
|
||||
// we have two records: active and non active
|
||||
// non active records is something like a history
|
||||
// it is used to remember the last ban level
|
||||
// so based on this in the future a next greater ban can be calculated
|
||||
#define WINIX_IPBAN_FLAG_ACTIVE 1
|
||||
|
||||
// current ban level
|
||||
// (if one of these flag is set and the record is active then it means the IP is banned at the moment)
|
||||
// level 1: banned for short time
|
||||
// level 2: can be set after level 1 has expired and the attacker still have not given up
|
||||
// banned for some longer time in level 1
|
||||
// level 3: can be set after level 2
|
||||
// banned for much more time
|
||||
#define WINIX_IPBAN_FLAG_BAN_LEVEL1 2
|
||||
#define WINIX_IPBAN_FLAG_BAN_LEVEL2 4
|
||||
#define WINIX_IPBAN_FLAG_BAN_LEVEL3 8
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
struct defining some restrictions to an IP address
|
||||
*/
|
||||
struct IPBan
|
||||
{
|
||||
// at the moment only IPv4 are supported
|
||||
int ip;
|
||||
|
||||
// one or more flags from WINIX_IPBAN_FLAG_*
|
||||
int flags;
|
||||
|
||||
// when this record was last used
|
||||
time_t last_used;
|
||||
|
||||
// when the restrictions (ban) should be removed
|
||||
// valid only if some of WINIX_IPBAN_FLAG_BAN_LEVELX flags are set
|
||||
// actually we do not remove the record but unsets WINIX_IPBAN_FLAG_ACTIVE flag
|
||||
// so in the future we can check whether we need to change
|
||||
// the ban level to a greater value
|
||||
time_t expires;
|
||||
|
||||
// how many incorrect login attempts there are
|
||||
unsigned int incorrect_login_events;
|
||||
|
||||
// in the future there can be more *_events fields
|
||||
|
||||
|
||||
|
||||
bool HasFlag(int flag) const
|
||||
{
|
||||
return (flags & flag) != 0;
|
||||
}
|
||||
|
||||
|
||||
void SetFlag(int flag)
|
||||
{
|
||||
flags = flags | flag;
|
||||
}
|
||||
|
||||
|
||||
void ClearFlag(int flag)
|
||||
{
|
||||
flags = flags & (~flag);
|
||||
}
|
||||
|
||||
|
||||
bool IsIPBanned() const
|
||||
{
|
||||
if( !HasFlag(WINIX_IPBAN_FLAG_ACTIVE) )
|
||||
return false;
|
||||
|
||||
return HasFlag(WINIX_IPBAN_FLAG_BAN_LEVEL1) ||
|
||||
HasFlag(WINIX_IPBAN_FLAG_BAN_LEVEL2) ||
|
||||
HasFlag(WINIX_IPBAN_FLAG_BAN_LEVEL3);
|
||||
}
|
||||
|
||||
|
||||
void AddNextBanLevel(time_t level1_expires, time_t level2_expires, time_t level3_expires)
|
||||
{
|
||||
if( HasFlag(WINIX_IPBAN_FLAG_BAN_LEVEL3) )
|
||||
{
|
||||
expires = level3_expires;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( HasFlag(WINIX_IPBAN_FLAG_BAN_LEVEL2) )
|
||||
{
|
||||
SetFlag(WINIX_IPBAN_FLAG_BAN_LEVEL3);
|
||||
expires = level3_expires;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( HasFlag(WINIX_IPBAN_FLAG_BAN_LEVEL1) )
|
||||
{
|
||||
SetFlag(WINIX_IPBAN_FLAG_BAN_LEVEL2);
|
||||
expires = level2_expires;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFlag(WINIX_IPBAN_FLAG_BAN_LEVEL1);
|
||||
expires = level1_expires;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IPBan()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void Clear()
|
||||
{
|
||||
ip = 0;
|
||||
flags = 0;
|
||||
last_used = 0;
|
||||
expires = 0;
|
||||
incorrect_login_events = 0;
|
||||
}
|
||||
|
||||
|
||||
void ClearAfterRemovingBan()
|
||||
{
|
||||
ClearFlag(WINIX_IPBAN_FLAG_ACTIVE);
|
||||
incorrect_login_events = 0;
|
||||
expires = 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "ipbancontainer.h"
|
||||
#include "log.h"
|
||||
#include "date/date.h"
|
||||
|
||||
|
||||
|
||||
IPBanContainer::IPBanContainer()
|
||||
{
|
||||
is_ipban_tab_sorted = true; // an empty list is sorted
|
||||
soft_max_size = 100;
|
||||
max_size = 110;
|
||||
}
|
||||
|
||||
|
||||
void IPBanContainer::SetMaxSize(size_t soft_size, size_t size)
|
||||
{
|
||||
soft_max_size = soft_size;
|
||||
max_size = size;
|
||||
|
||||
if( max_size < soft_max_size )
|
||||
max_size = soft_max_size + 1;
|
||||
|
||||
ipban_tab.reserve(max_size);
|
||||
sort_helper_tab.reserve(max_size);
|
||||
}
|
||||
|
||||
|
||||
// returning a reference to the added (or existed) record
|
||||
IPBan & IPBanContainer::AddIP(int ip)
|
||||
{
|
||||
IPBan * old_ip_ban = FindIP(ip);
|
||||
|
||||
if( !old_ip_ban )
|
||||
{
|
||||
IPBan ip_ban;
|
||||
ip_ban.ip = ip;
|
||||
|
||||
if( ipban_tab.size() >= max_size )
|
||||
RemoveOldRecords();
|
||||
|
||||
ipban_tab.push_back(ip_ban);
|
||||
is_ipban_tab_sorted = false;
|
||||
return ipban_tab.back();
|
||||
}
|
||||
else
|
||||
{
|
||||
return *old_ip_ban;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IPBanContainer::RemoveIP(int ip)
|
||||
{
|
||||
IPBan * ipban = FindIP(ip);
|
||||
|
||||
if( ipban )
|
||||
{
|
||||
size_t index = ipban - &ipban_tab[0];
|
||||
ipban_tab.erase(ipban_tab.begin() + index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool IPBanContainer::IsSorted()
|
||||
{
|
||||
return is_ipban_tab_sorted;
|
||||
}
|
||||
|
||||
|
||||
void IPBanContainer::Clear()
|
||||
{
|
||||
ipban_tab.clear();
|
||||
is_ipban_tab_sorted = true;
|
||||
}
|
||||
|
||||
|
||||
// we need to remove some old records for the size of the container
|
||||
// to be less or equal to soft_max_size
|
||||
void IPBanContainer::RemoveOldRecords()
|
||||
{
|
||||
size_t to_remove = 0;
|
||||
|
||||
if( ipban_tab.size() >= soft_max_size )
|
||||
to_remove = ipban_tab.size() - soft_max_size;
|
||||
|
||||
if( to_remove > 0 )
|
||||
{
|
||||
sort_helper_tab.resize(ipban_tab.size());
|
||||
|
||||
for(size_t i=0 ; i<ipban_tab.size() ; ++i)
|
||||
sort_helper_tab[i] = i;
|
||||
|
||||
std::sort(sort_helper_tab.begin(), sort_helper_tab.end(), SortByLastUsedHelper(this));
|
||||
sort_helper_tab.resize(to_remove);
|
||||
std::sort(sort_helper_tab.begin(), sort_helper_tab.end());
|
||||
|
||||
while( to_remove-- > 0 )
|
||||
ipban_tab.erase(ipban_tab.begin() + sort_helper_tab[to_remove]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// for debug purposes
|
||||
void IPBanContainer::PrintTab()
|
||||
{
|
||||
log << log4 << "ipban_tab (size: " << ipban_tab.size() << ")" << logend;
|
||||
|
||||
for(size_t i=0 ; i<ipban_tab.size() ; ++i)
|
||||
{
|
||||
log << log4 << i << ": ip: " << ipban_tab[i].ip << ", flags: " << ipban_tab[i].flags << ", last_used: ";
|
||||
|
||||
PT::Date date(ipban_tab[i].last_used);
|
||||
log << date << ", expires: ";
|
||||
|
||||
date = ipban_tab[i].expires;
|
||||
log << date << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// for debug purposes
|
||||
void IPBanContainer::PrintTab2()
|
||||
{
|
||||
log << log4 << "sort_helper_tab (size: " << sort_helper_tab.size() << ")" << logend;
|
||||
|
||||
for(size_t i=0 ; i<sort_helper_tab.size() ; ++i)
|
||||
{
|
||||
IPBan & ipban = ipban_tab[sort_helper_tab[i]];
|
||||
|
||||
log << log4 << i << ": ip: " << ipban.ip << ", flags: " << ipban.flags << ", last_used: ";
|
||||
|
||||
PT::Date date(ipban.last_used);
|
||||
log << date << ", expires: ";
|
||||
|
||||
date = ipban.expires;
|
||||
log << date << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool IPBanContainer::SortByLastUsedHelper::operator()(size_t index1, size_t index2)
|
||||
{
|
||||
if( index1 < container->ipban_tab.size() &&
|
||||
index2 < container->ipban_tab.size() )
|
||||
{
|
||||
IPBan & ip1 = container->ipban_tab[index1];
|
||||
IPBan & ip2 = container->ipban_tab[index2];
|
||||
|
||||
// prefer to select records which do not have WINIX_IPBAN_FLAG_ACTIVE
|
||||
if( ip1.HasFlag(WINIX_IPBAN_FLAG_ACTIVE) !=
|
||||
ip2.HasFlag(WINIX_IPBAN_FLAG_ACTIVE) )
|
||||
{
|
||||
return ip2.HasFlag(WINIX_IPBAN_FLAG_ACTIVE);
|
||||
}
|
||||
|
||||
return ip1.last_used < ip2.last_used;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
IPBan * IPBanContainer::FindIP(int ip)
|
||||
{
|
||||
// !! IMPROVE ME add binary search if is_ipban_tab_sorted is true
|
||||
|
||||
for(size_t i=0 ; i<ipban_tab.size() ; ++i)
|
||||
{
|
||||
if( ipban_tab[i].ip == ip )
|
||||
{
|
||||
return &ipban_tab[i];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
IPBan & IPBanContainer::GetIPBan(size_t index)
|
||||
{
|
||||
return ipban_tab[index];
|
||||
}
|
||||
|
||||
|
||||
void IPBanContainer::Sort()
|
||||
{
|
||||
std::sort(ipban_tab.begin(), ipban_tab.end(), SortIPBansFunction);
|
||||
is_ipban_tab_sorted = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t IPBanContainer::Size()
|
||||
{
|
||||
return ipban_tab.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool IPBanContainer::SortIPBansFunction(const IPBan & ip1, const IPBan & ip2)
|
||||
{
|
||||
return ip1.ip < ip2.ip;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_ipbancontainer
|
||||
#define headerfile_winix_core_ipbancontainer
|
||||
|
||||
#include <vector>
|
||||
#include "ipban.h"
|
||||
|
||||
|
||||
|
||||
class IPBanContainer
|
||||
{
|
||||
public:
|
||||
|
||||
IPBanContainer();
|
||||
|
||||
IPBan & AddIP(int ip);
|
||||
IPBan * FindIP(int ip);
|
||||
void Sort();
|
||||
size_t Size();
|
||||
IPBan & GetIPBan(size_t index);
|
||||
void SetMaxSize(size_t soft_size, size_t size);
|
||||
void RemoveIP(int ip);
|
||||
void Clear();
|
||||
bool IsSorted();
|
||||
|
||||
private:
|
||||
|
||||
std::vector<IPBan> ipban_tab;
|
||||
bool is_ipban_tab_sorted;
|
||||
size_t soft_max_size, max_size;
|
||||
std::vector<size_t> sort_helper_tab;
|
||||
|
||||
static bool SortIPBansFunction(const IPBan & ip1, const IPBan & ip2);
|
||||
void RemoveOldRecords();
|
||||
void PrintTab();
|
||||
void PrintTab2();
|
||||
|
||||
struct SortByLastUsedHelper
|
||||
{
|
||||
IPBanContainer * container;
|
||||
|
||||
SortByLastUsedHelper(IPBanContainer * c) : container(c) {}
|
||||
bool operator()(size_t index1, size_t index2);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -74,6 +74,7 @@ void Item::Clear()
|
||||
html_template.clear();
|
||||
sort_index = 0;
|
||||
meta.Clear();
|
||||
ameta.Clear();
|
||||
|
||||
SetDateToNow();
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ struct Item
|
||||
|
||||
// meta information
|
||||
PT::Space meta;
|
||||
PT::Space ameta;
|
||||
|
||||
|
||||
// methods
|
||||
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lock.h"
|
||||
|
||||
|
||||
|
||||
Lock::Lock()
|
||||
{
|
||||
synchro = 0;
|
||||
}
|
||||
|
||||
|
||||
Lock::Lock(Synchro * synchro_)
|
||||
{
|
||||
synchro = synchro_;
|
||||
synchro->Lock();
|
||||
}
|
||||
|
||||
|
||||
Lock::Lock(Synchro & synchro_)
|
||||
{
|
||||
synchro = &synchro_;
|
||||
synchro->Lock();
|
||||
}
|
||||
|
||||
|
||||
Lock::~Lock()
|
||||
{
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
void Lock::Unlock()
|
||||
{
|
||||
if( synchro )
|
||||
{
|
||||
synchro->Unlock();
|
||||
synchro = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_lock
|
||||
#define headerfile_winix_core_lock
|
||||
|
||||
#include "synchro.h"
|
||||
|
||||
|
||||
class Lock
|
||||
{
|
||||
public:
|
||||
|
||||
Lock(Synchro * synchro_);
|
||||
Lock(Synchro & synchro_);
|
||||
|
||||
~Lock();
|
||||
|
||||
void Unlock();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Synchro * synchro;
|
||||
|
||||
Lock();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
+2
-10
@@ -142,16 +142,8 @@ size_t min_size = value.size() < max_size ? value.size() : max_size;
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
Log & Log::operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
|
||||
typename PT::TextStreamBase<char_type, stack_size, heap_block_size>::const_iterator i = buf.begin();
|
||||
|
||||
// in the future we change buffer to PT::TextStreamBuffer
|
||||
// so then there'll be << operator
|
||||
|
||||
for( ; i != buf.end() ; ++i)
|
||||
buffer << *i;
|
||||
if( current_level <= log_level )
|
||||
buffer << buf;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
+87
-1
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include "misc.h"
|
||||
#include "log.h"
|
||||
#include "templates/templates.h"
|
||||
@@ -77,6 +78,34 @@ long Tol(const wchar_t * str, int base)
|
||||
|
||||
|
||||
|
||||
double Tod(const std::string & str)
|
||||
{
|
||||
return strtod(str.c_str(), 0);
|
||||
}
|
||||
|
||||
|
||||
double Tod(const std::wstring & str)
|
||||
{
|
||||
return wcstold(str.c_str(), 0);
|
||||
}
|
||||
|
||||
|
||||
double Tod(const char * str)
|
||||
{
|
||||
return strtod(str, 0);
|
||||
}
|
||||
|
||||
|
||||
double Tod(const wchar_t * str)
|
||||
{
|
||||
return wcstold(str, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const wchar_t * Toa(unsigned int value, int base)
|
||||
{
|
||||
@@ -526,6 +555,29 @@ return buffer;
|
||||
|
||||
|
||||
|
||||
PT::WTextStream IPToStr(unsigned int ip)
|
||||
{
|
||||
PT::WTextStream buf;
|
||||
|
||||
for(int i=0 ; i<4 ; ++i, ip >>= 8)
|
||||
{
|
||||
buf << (ip & 0xff);
|
||||
|
||||
if( i<3 )
|
||||
buf << '.';
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
PT::WTextStream IPToStr(int ip)
|
||||
{
|
||||
return IPToStr(static_cast<unsigned int>(ip));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
we do not treat a new line character (10) as a white character
|
||||
*/
|
||||
@@ -561,6 +613,40 @@ return false;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
return true if the whole string has only white characters
|
||||
an empty string is treated as white
|
||||
*/
|
||||
bool IsWhite(const wchar_t * str, bool treat_new_line_as_white)
|
||||
{
|
||||
for( ; *str != 0 ; ++str )
|
||||
{
|
||||
if( *str == '\n' )
|
||||
{
|
||||
if( !treat_new_line_as_white )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if( !IsWhite(*str) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
return true if the whole string has only white characters
|
||||
*/
|
||||
bool IsWhite(const std::wstring & str, bool treat_new_line_as_white)
|
||||
{
|
||||
return IsWhite(str.c_str(), treat_new_line_as_white);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool IsLastSlash(const std::wstring & path)
|
||||
{
|
||||
|
||||
+63
-9
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -38,6 +38,11 @@ long Tol(const std::wstring & str, int base = 10);
|
||||
long Tol(const char * str, int base = 10);
|
||||
long Tol(const wchar_t * str, int base = 10);
|
||||
|
||||
double Tod(const std::string & str);
|
||||
double Tod(const std::wstring & str);
|
||||
double Tod(const char * str);
|
||||
double Tod(const wchar_t * str);
|
||||
|
||||
|
||||
// if the buffer is too small it will be terminated at the beginning (empty string)
|
||||
// and the function returns false
|
||||
@@ -224,9 +229,20 @@ const char * DateToStrCookie(int year, int month, int day, int hour, int min, in
|
||||
const char * DateToStrCookie(const PT::Date & d);
|
||||
const char * DateToStrCookie(time_t t);
|
||||
|
||||
// depracated
|
||||
// not thread safe
|
||||
const wchar_t * IpToStr(unsigned int ip_);
|
||||
|
||||
// in a new code we can use WTextStream in such a way
|
||||
// DateToStr() etc can use it too
|
||||
PT::WTextStream IPToStr(unsigned int ip);
|
||||
PT::WTextStream IPToStr(int ip);
|
||||
|
||||
|
||||
|
||||
bool IsWhite(wchar_t s);
|
||||
bool IsWhite(const wchar_t * str, bool treat_new_line_as_white = false);
|
||||
bool IsWhite(const std::wstring & str, bool treat_new_line_as_white = false);
|
||||
bool IsLastSlash(const std::wstring & path);
|
||||
|
||||
template<class StringType>
|
||||
@@ -261,7 +277,24 @@ typename StringType::size_type i;
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void Trim(StringType & s, wchar_t c)
|
||||
void TrimFirst(StringType & s, wchar_t c)
|
||||
{
|
||||
typename StringType::size_type i;
|
||||
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
// looking for the 'c' characters at the beginning
|
||||
for(i=0 ; i<s.size() && s[i]==c ; ++i);
|
||||
|
||||
// deleting the 'c' characters at the beginning
|
||||
if( i != 0 )
|
||||
s.erase(0, i);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TrimLast(StringType & s, wchar_t c)
|
||||
{
|
||||
typename StringType::size_type i;
|
||||
|
||||
@@ -281,16 +314,23 @@ typename StringType::size_type i;
|
||||
// deleting 'c' characters at the end
|
||||
if( i != s.size() - 1 )
|
||||
s.erase(i+1, StringType::npos);
|
||||
|
||||
// looking for the 'c' characters at the beginning
|
||||
for(i=0 ; i<s.size() && s[i]==c ; ++i);
|
||||
|
||||
// deleting the 'c' characters at the beginning
|
||||
if( i != 0 )
|
||||
s.erase(0, i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void Trim(StringType & s, wchar_t c)
|
||||
{
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
TrimLast(s, c);
|
||||
TrimFirst(s, c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void MaxSize(StringType & str, size_t max_size)
|
||||
{
|
||||
@@ -960,4 +1000,18 @@ size_t i1, i2;
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename IntType>
|
||||
void SetMinMax(IntType & val, IntType min_val, IntType max_val)
|
||||
{
|
||||
if( val < min_val )
|
||||
val = min_val;
|
||||
|
||||
if( val > max_val )
|
||||
val = max_val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+6
-1
@@ -246,11 +246,16 @@
|
||||
//
|
||||
#define WINIX_POST_PARAMS 31040
|
||||
|
||||
|
||||
// this is the raw string sent in POST method
|
||||
// in p1 there is a pointer to std::string object
|
||||
#define WINIX_RAW_POST_STRING 31050
|
||||
|
||||
// this message is sent before calling MakePost() or MakeGet()
|
||||
// if you return false (which is default) you can prevent the access
|
||||
// to the resource
|
||||
#define WINIX_CHECK_PLUGIN_ACCESS 31060
|
||||
|
||||
|
||||
|
||||
/*
|
||||
messages sent from other threads
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "postmultiparser.h"
|
||||
#include "log.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
+3
-1
@@ -149,7 +149,9 @@ bool Rebus::CheckRebus()
|
||||
if( IsAnswerOk(cur->session->rebus_item, cur->request->PostVar(L"rebus")) )
|
||||
return true;
|
||||
|
||||
log << log1 << "Rebus: rebus has an incorrect answer" << logend;
|
||||
log << log1 << "Rebus: rebus has an incorrect answer, expected: "
|
||||
<< cur->session->rebus_item->answer << logend;
|
||||
|
||||
// don't add cur->session->spam_score when the rebus has incorrect answer
|
||||
// a user could have made a mistake
|
||||
|
||||
|
||||
+4
-1
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -127,6 +127,9 @@ void Request::Clear()
|
||||
gen_trim_white = false;
|
||||
gen_skip_new_line = false;
|
||||
gen_use_special_chars = false;
|
||||
|
||||
ip = 0;
|
||||
use_200_status_for_not_found_and_permission_denied = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+11
-2
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -89,6 +89,10 @@ struct Request
|
||||
const char * env_content_type;
|
||||
const char * env_https;
|
||||
|
||||
// current IP address of the remote host (read from REMOTE_ADDR environment variable)
|
||||
// (at the moment only IPv4 are supported)
|
||||
int ip;
|
||||
|
||||
// true if the browser is Microsoft Internet Explorer
|
||||
bool browser_msie;
|
||||
|
||||
@@ -156,12 +160,17 @@ struct Request
|
||||
// used as a JSON output (when ajax_serializer is defined)
|
||||
// it will be serialized and have at least:
|
||||
// 'content' string - the whole html content
|
||||
// 'http_status' integer - http status code (e.g. 200)
|
||||
// 'http_status' integer - http status code (e.g. 200) !! FIXME this is not added at the moment
|
||||
PT::Space ajax;
|
||||
|
||||
// if not null then the request will have a JSON as an output
|
||||
PT::SpaceToJSON * ajax_serializer;
|
||||
|
||||
// if this variable is true then winix always return 200 OK header
|
||||
// when the status would be 404 (not found) or 403 (permission denied)
|
||||
// default: false
|
||||
bool use_200_status_for_not_found_and_permission_denied;
|
||||
|
||||
// options used by ezc generators
|
||||
bool gen_trim_white;
|
||||
bool gen_skip_new_line;
|
||||
|
||||
+2
-1
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* Copyright (c) 2011-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -78,9 +78,17 @@ void Session::Clear(bool clear_plugin_data)
|
||||
|
||||
log_buffer.Clear();
|
||||
last_css.clear();
|
||||
ip_ban = 0;
|
||||
|
||||
if( clear_plugin_data )
|
||||
plugin_data.Resize(0);
|
||||
}
|
||||
|
||||
|
||||
// clearing some variables when a request is ended (just for safety)
|
||||
void Session::ClearOnEndRequest()
|
||||
{
|
||||
// ip_ban list can be sorted by SessionManager (in the special thread)
|
||||
ip_ban = 0;
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -20,6 +20,7 @@
|
||||
#include "rebus.h"
|
||||
#include "textstream.h"
|
||||
#include "date/date.h"
|
||||
#include "ipban.h"
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +32,7 @@ struct Session
|
||||
|
||||
void SetTimesTo(time_t time);
|
||||
void Clear(bool clear_plugin_data = true);
|
||||
void ClearOnEndRequest();
|
||||
|
||||
|
||||
// 0 - means that there is a temporary session
|
||||
@@ -50,7 +52,7 @@ struct Session
|
||||
PT::Date last_date;
|
||||
|
||||
// when there was a last get request
|
||||
// (used to calculate spam)
|
||||
// (used to calculate spam or invalid login attempts etc.)
|
||||
time_t last_time_get;
|
||||
|
||||
|
||||
@@ -78,10 +80,17 @@ struct Session
|
||||
// buffer for the session log
|
||||
TextStream<std::wstring> log_buffer;
|
||||
|
||||
// !! IMPROVE ME it is still needed?
|
||||
// css cannot be taken directly from the mountpoint?
|
||||
// table with css files
|
||||
// used by some javascript wysiwyg editors (ckeditor, tinymce)
|
||||
std::vector<std::wstring> last_css;
|
||||
|
||||
// pointer to IPBan struct if exists for this IP
|
||||
// many sessions can pointer to the same IPBan struct
|
||||
// (it can be null)
|
||||
IPBan * ip_ban;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
+76
-5
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -57,6 +57,11 @@ void SessionManager::SetLastContainer(LastContainer * plast_container)
|
||||
}
|
||||
|
||||
|
||||
void SessionManager::InitBanList()
|
||||
{
|
||||
ban_tab.SetMaxSize(config->ban_list_soft_max_size, config->ban_list_max_size);
|
||||
}
|
||||
|
||||
|
||||
size_t SessionManager::Size()
|
||||
{
|
||||
@@ -84,7 +89,7 @@ long id;
|
||||
{
|
||||
if( sizeof(long) == 8 )
|
||||
{
|
||||
id = ((unsigned long)std::rand()) << 32 + std::rand();
|
||||
id = (((unsigned long)std::rand()) << 32) + std::rand();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -136,14 +141,19 @@ SessionContainer::Iterator i = session_tab.End();
|
||||
{
|
||||
// there is a problem with generating a new session id
|
||||
// we do not set a session cookie
|
||||
log << log1 << "SM: cannot create a session id (temporary used: with id 0)" << logend;
|
||||
SetTemporarySession();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SessionManager::SetTemporarySession()
|
||||
{
|
||||
session = &temporary_session;
|
||||
session->Clear(false);
|
||||
session->SetTimesTo(cur->request->start_time);
|
||||
session->new_session = false; // temporary session was initialized at the beginning
|
||||
log << log1 << "SM: cannot create a session id (temporary used: with id 0)" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -178,6 +188,24 @@ return true;
|
||||
|
||||
void SessionManager::SetSession()
|
||||
{
|
||||
current_ip_ban = ban_tab.FindIP(cur->request->ip);
|
||||
|
||||
if( current_ip_ban && current_ip_ban->IsIPBanned() )
|
||||
{
|
||||
if( current_ip_ban->expires != 0 && cur->request->start_time >= current_ip_ban->expires )
|
||||
{
|
||||
log << log2 << "SM: removing a ban from this IP and resetting events counter" << logend;
|
||||
current_ip_ban->ClearAfterRemovingBan();
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "SM: this ip is bannned, using a temporary session" << logend;
|
||||
SetTemporarySession();
|
||||
session->ip_ban = current_ip_ban;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CookieTab::iterator i = cur->request->cookie_tab.find(config->http_session_id_name);
|
||||
|
||||
if( i == cur->request->cookie_tab.end() )
|
||||
@@ -196,9 +224,12 @@ void SessionManager::SetSession()
|
||||
CreateSession();
|
||||
}
|
||||
}
|
||||
|
||||
session->ip_ban = current_ip_ban;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Session * SessionManager::FindSession(long id)
|
||||
{
|
||||
SessionContainer::Iterator i = session_tab.FindById(id);
|
||||
@@ -411,6 +442,34 @@ return how_many;
|
||||
}
|
||||
|
||||
|
||||
IPBan & SessionManager::AddIPToBanList(int ip)
|
||||
{
|
||||
return ban_tab.AddIP(ip);
|
||||
}
|
||||
|
||||
|
||||
size_t SessionManager::BanListSize()
|
||||
{
|
||||
return ban_tab.Size();
|
||||
}
|
||||
|
||||
|
||||
IPBan & SessionManager::GetIPBan(size_t index)
|
||||
{
|
||||
return ban_tab.GetIPBan(index);
|
||||
}
|
||||
|
||||
|
||||
void SessionManager::RemoveIPBan(int ip)
|
||||
{
|
||||
ban_tab.RemoveIP(ip);
|
||||
}
|
||||
|
||||
|
||||
void SessionManager::ClearIPBanList()
|
||||
{
|
||||
ban_tab.Clear();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -437,6 +496,7 @@ SessionContainer::Iterator i;
|
||||
{
|
||||
Lock();
|
||||
|
||||
CheckWheterIPListIsSorted();
|
||||
CheckSession(i);
|
||||
exit = synchro->was_stop_signal;
|
||||
|
||||
@@ -445,6 +505,17 @@ SessionContainer::Iterator i;
|
||||
}
|
||||
|
||||
|
||||
// objects locked
|
||||
void SessionManager::CheckWheterIPListIsSorted()
|
||||
{
|
||||
if( !ban_tab.IsSorted() )
|
||||
{
|
||||
log << log4 << "SM: sorting the ban list" << logend;
|
||||
ban_tab.Sort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// it's called from the other thread (with Lock and Unlock)
|
||||
void SessionManager::CheckSession(SessionContainer::Iterator & i)
|
||||
{
|
||||
|
||||
+14
-1
@@ -14,6 +14,7 @@
|
||||
#include <ctime>
|
||||
|
||||
#include "sessioncontainer.h"
|
||||
#include "ipbancontainer.h"
|
||||
#include "config.h"
|
||||
#include "request.h"
|
||||
#include "lastcontainer.h"
|
||||
@@ -34,6 +35,7 @@ public:
|
||||
void SetSystem(System * psystem);
|
||||
void SetLastContainer(LastContainer * plast_container);
|
||||
|
||||
|
||||
// can return a null pointer
|
||||
Session * FindSession(long id);
|
||||
|
||||
@@ -41,6 +43,7 @@ public:
|
||||
void DeleteSessions(); // deleting all sessions
|
||||
bool ChangeSessionId(long old_id);
|
||||
|
||||
void InitBanList();
|
||||
void InitTmpSession();
|
||||
void UninitTmpSession();
|
||||
|
||||
@@ -56,6 +59,12 @@ public:
|
||||
size_t Size();
|
||||
size_t MarkAllSessionsToRemove(long user_id);
|
||||
|
||||
IPBan & AddIPToBanList(int ip);
|
||||
size_t BanListSize();
|
||||
IPBan & GetIPBan(size_t index);
|
||||
void RemoveIPBan(int ip);
|
||||
void ClearIPBanList();
|
||||
|
||||
private:
|
||||
|
||||
Config * config;
|
||||
@@ -68,6 +77,9 @@ private:
|
||||
Session * session;
|
||||
|
||||
SessionContainer session_tab;
|
||||
IPBanContainer ban_tab;
|
||||
|
||||
IPBan * current_ip_ban;
|
||||
|
||||
// session with id 0
|
||||
Session temporary_session;
|
||||
@@ -77,7 +89,7 @@ private:
|
||||
long CreateSessionId();
|
||||
void CreateSession();
|
||||
bool SetSessionFromCookie(const std::string & cookie);
|
||||
|
||||
void SetTemporarySession();
|
||||
|
||||
// second thread
|
||||
int deleted;
|
||||
@@ -85,6 +97,7 @@ private:
|
||||
void CheckSession(SessionContainer::Iterator & i);
|
||||
bool IsSessionOutdated(const Session & s) const;
|
||||
void DeleteSession(Session * del_session);
|
||||
void CheckWheterIPListIsSorted();
|
||||
|
||||
};
|
||||
|
||||
|
||||
+8
-1
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -114,6 +114,13 @@ SLog & SLog::operator<<(double s)
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const PT::Date & date)
|
||||
{
|
||||
return PutLog(date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SLog & SLog::operator<<(LogManipulators m)
|
||||
{
|
||||
if( cur && cur->session )
|
||||
|
||||
+16
-3
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "cur.h"
|
||||
#include "logmanipulators.h"
|
||||
#include "templates/locale.h"
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
#define WINIX_SLOG_MAX_LOG_SIZE 10240
|
||||
@@ -68,6 +69,11 @@ public:
|
||||
SLog & operator<<(size_t s);
|
||||
SLog & operator<<(double s);
|
||||
SLog & operator<<(LogManipulators m);
|
||||
SLog & operator<<(const PT::Date & date);
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
SLog & operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf);
|
||||
|
||||
|
||||
SLog & TranslateText(const char * str);
|
||||
SLog & TranslateText(const wchar_t * str);
|
||||
@@ -95,7 +101,7 @@ public:
|
||||
private:
|
||||
|
||||
template<class LogParam>
|
||||
SLog & PutLog(LogParam par);
|
||||
SLog & PutLog(const LogParam & par);
|
||||
|
||||
Cur * cur;
|
||||
Locale * locale;
|
||||
@@ -111,8 +117,15 @@ SLog::TranslateTextHelper<RawType> T(const RawType & par)
|
||||
}
|
||||
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
SLog & SLog::operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf)
|
||||
{
|
||||
return PutLog(buf);
|
||||
}
|
||||
|
||||
|
||||
template<class LogParam>
|
||||
SLog & SLog::PutLog(LogParam par)
|
||||
SLog & SLog::PutLog(const LogParam & par)
|
||||
{
|
||||
if( cur && cur->session )
|
||||
cur->session->log_buffer << par;
|
||||
|
||||
+62
-11
@@ -132,8 +132,7 @@ bool ssl = false;
|
||||
{
|
||||
if( !config->use_ssl_only_for_logged_users ||
|
||||
cur->session->puser ||
|
||||
cur->request->function == &functions->fun_login ||
|
||||
cur->request->function == &functions->fun_adduser)
|
||||
(cur->request->function && cur->request->function->need_ssl) )
|
||||
{
|
||||
str += config->url_ssl_proto;
|
||||
ssl = true;
|
||||
@@ -151,7 +150,7 @@ bool ssl = false;
|
||||
/*
|
||||
postfix will not be UrlEncoded
|
||||
*/
|
||||
void System::RedirectTo(const Item & item, const wchar_t * postfix)
|
||||
void System::RedirectTo(const Item & item, const wchar_t * postfix, bool use_reqtype)
|
||||
{
|
||||
PutUrlProto(config->use_ssl, cur->request->redirect_to);
|
||||
|
||||
@@ -177,6 +176,12 @@ void System::RedirectTo(const Item & item, const wchar_t * postfix)
|
||||
|
||||
if( postfix )
|
||||
cur->request->redirect_to += postfix;
|
||||
|
||||
if( use_reqtype && cur->request->IsParam(L"reqtype") )
|
||||
{
|
||||
cur->request->redirect_to += L"/-/reqtype:";
|
||||
cur->request->redirect_to += cur->request->ParamValue(L"reqtype");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +189,7 @@ void System::RedirectTo(const Item & item, const wchar_t * postfix)
|
||||
/*
|
||||
postfix will not be UrlEncoded
|
||||
*/
|
||||
void System::RedirectTo(long item_id, const wchar_t * postfix)
|
||||
void System::RedirectTo(long item_id, const wchar_t * postfix, bool use_reqtype)
|
||||
{
|
||||
PutUrlProto(config->use_ssl, cur->request->redirect_to);
|
||||
|
||||
@@ -225,6 +230,12 @@ void System::RedirectTo(long item_id, const wchar_t * postfix)
|
||||
|
||||
if( postfix )
|
||||
cur->request->redirect_to += postfix;
|
||||
|
||||
if( use_reqtype && cur->request->IsParam(L"reqtype") )
|
||||
{
|
||||
cur->request->redirect_to += L"/-/reqtype:";
|
||||
cur->request->redirect_to += cur->request->ParamValue(L"reqtype");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +243,7 @@ void System::RedirectTo(long item_id, const wchar_t * postfix)
|
||||
/*
|
||||
url will not be UrlEncoded
|
||||
*/
|
||||
void System::RedirectTo(const wchar_t * url)
|
||||
void System::RedirectTo(const wchar_t * url, bool use_reqtype)
|
||||
{
|
||||
PutUrlProto(config->use_ssl, cur->request->redirect_to);
|
||||
|
||||
@@ -263,15 +274,21 @@ void System::RedirectTo(const wchar_t * url)
|
||||
cur->request->redirect_to += url;
|
||||
}
|
||||
}
|
||||
|
||||
if( use_reqtype && cur->request->IsParam(L"reqtype") )
|
||||
{
|
||||
cur->request->redirect_to += L"/-/reqtype:";
|
||||
cur->request->redirect_to += cur->request->ParamValue(L"reqtype");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
url will not be UrlEncoded
|
||||
*/
|
||||
void System::RedirectTo(const std::wstring & url)
|
||||
void System::RedirectTo(const std::wstring & url, bool use_reqtype)
|
||||
{
|
||||
RedirectTo(url.c_str());
|
||||
RedirectTo(url.c_str(), use_reqtype);
|
||||
}
|
||||
|
||||
|
||||
@@ -325,20 +342,54 @@ void System::RedirectWithFunctionAndParamsTo(const std::wstring & url)
|
||||
}
|
||||
|
||||
|
||||
void System::RedirectToLastDir()
|
||||
void System::RedirectToLastDir(const wchar_t * postfix, bool use_reqtype)
|
||||
{
|
||||
if( !cur->request->dir_tab.empty() )
|
||||
RedirectTo( *cur->request->dir_tab.back() );
|
||||
RedirectTo( *cur->request->dir_tab.back(), postfix, use_reqtype);
|
||||
}
|
||||
|
||||
|
||||
void System::RedirectToLastItem()
|
||||
void System::RedirectToLastItem(const wchar_t * postfix, bool use_reqtype)
|
||||
{
|
||||
if( cur->request->last_item )
|
||||
RedirectTo( *cur->request->last_item );
|
||||
RedirectTo( *cur->request->last_item, postfix, use_reqtype );
|
||||
}
|
||||
|
||||
|
||||
void System::RedirectToLastFunction(const wchar_t * postfix, bool use_reqtype)
|
||||
{
|
||||
RedirectToLastDir(0, false);
|
||||
TrimLast(cur->request->redirect_to, '/');
|
||||
|
||||
if( cur->request->is_item )
|
||||
{
|
||||
cur->request->redirect_to += '/';
|
||||
cur->request->redirect_to += cur->request->item.url;
|
||||
}
|
||||
|
||||
if( cur->request->function )
|
||||
{
|
||||
cur->request->redirect_to += '/';
|
||||
cur->request->redirect_to += cur->request->function->fun.url;
|
||||
}
|
||||
|
||||
if( postfix )
|
||||
{
|
||||
cur->request->redirect_to += '/';
|
||||
cur->request->redirect_to += postfix;
|
||||
}
|
||||
|
||||
if( use_reqtype && cur->request->IsParam(L"reqtype") )
|
||||
{
|
||||
if( !cur->request->function && !postfix )
|
||||
cur->request->redirect_to += L"/-";
|
||||
|
||||
cur->request->redirect_to += L"/reqtype:";
|
||||
cur->request->redirect_to += cur->request->ParamValue(L"reqtype");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool System::CanChangeUser(const Item & item, long new_user_id)
|
||||
{
|
||||
|
||||
+8
-6
@@ -90,14 +90,16 @@ public:
|
||||
void AddParams(const ParamTab & param_tab, std::wstring & str, bool clear_str = true);
|
||||
|
||||
void PutUrlProto(bool can_use_ssl, std::wstring & str, bool clear_str = true);
|
||||
void RedirectTo(const Item & item, const wchar_t * postfix = 0);
|
||||
void RedirectTo(long item_id, const wchar_t * postfix = 0);
|
||||
void RedirectTo(const wchar_t * url);
|
||||
void RedirectTo(const std::wstring & url);
|
||||
void RedirectTo(const Item & item, const wchar_t * postfix = 0, bool use_reqtype = true);
|
||||
void RedirectTo(long item_id, const wchar_t * postfix = 0, bool use_reqtype = true);
|
||||
void RedirectTo(const wchar_t * url, bool use_reqtype = true);
|
||||
void RedirectTo(const std::wstring & url, bool use_reqtype = true);
|
||||
void RedirectWithFunctionAndParamsTo(const wchar_t * url);
|
||||
void RedirectWithFunctionAndParamsTo(const std::wstring & url);
|
||||
void RedirectToLastDir();
|
||||
void RedirectToLastItem(); // redirect to an item if exists or to the last directory
|
||||
void RedirectToLastDir(const wchar_t * postfix = 0, bool use_reqtype = true);
|
||||
void RedirectToLastItem(const wchar_t * postfix = 0, bool use_reqtype = true); // redirect to an item if exists or to the last directory
|
||||
void RedirectToLastFunction(const wchar_t * postfix = 0, bool use_reqtype = true);
|
||||
|
||||
|
||||
bool CanChangeUser(const Item & item, long new_user_id);
|
||||
bool CanChangeGroup(const Item & item, long new_group_id);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "misc.h"
|
||||
#include "space/space.h"
|
||||
#include "date/date.h"
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
|
||||
@@ -62,6 +63,9 @@ public:
|
||||
TextStream & operator<<(const PT::Space & space);
|
||||
TextStream & operator<<(const PT::Date & date);
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
TextStream & operator<<(const PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & arg);
|
||||
|
||||
TextStream & Write(const char * buf, size_t len);
|
||||
TextStream & Write(const wchar_t * buf, size_t len);
|
||||
TextStream & write(const char * buf, size_t len); // for compatibility with standard library (Ezc uses it)
|
||||
@@ -327,6 +331,19 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(
|
||||
const PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & arg)
|
||||
{
|
||||
typename PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size>::const_iterator i;
|
||||
|
||||
for(i=arg.begin() ; i != arg.end() ; ++i)
|
||||
buffer += static_cast<char_type>(*i);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#define WINIX_VER_MAJOR 0
|
||||
#define WINIX_VER_MINOR 5
|
||||
#define WINIX_VER_REVISION 0
|
||||
#define WINIX_VER_REVISION 5
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@ all: $(o)
|
||||
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
$(CXX) -c $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $<
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. -I.. -I../../ezc/src -I../../pikotools -I../../tito/src -f- *.cpp > Makefile.dep
|
||||
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
|
||||
|
||||
|
||||
+45
-34
@@ -1,58 +1,69 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
db.o: db.h dbbase.h dbconn.h dbtextstream.h ../core/textstream.h
|
||||
db.o: ../core/misc.h ../core/item.h ../../pikotools/space/space.h
|
||||
db.o: ../../pikotools/textstream/types.h ../../pikotools/date/date.h
|
||||
db.o: ../core/requesttypes.h ../../pikotools/textstream/textstream.h
|
||||
db.o: db.h dbbase.h dbconn.h dbtextstream.h ../../winix/core/textstream.h
|
||||
db.o: ../../winix/core/misc.h ../../winix/core/item.h
|
||||
db.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
db.o: ../../pikotools/date/date.h ../../winix/core/requesttypes.h
|
||||
db.o: ../../pikotools/textstream/textstream.h
|
||||
db.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
db.o: ../../pikotools/membuffer/membuffer.h
|
||||
db.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
db.o: ../core/error.h ../../pikotools/space/spaceparser.h
|
||||
db.o: ../../pikotools/space/space.h dbitemquery.h ../core/item.h
|
||||
db.o: dbitemcolumns.h ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
db.o: ../core/ugcontainer.h ../core/log.h ../core/textstream.h
|
||||
db.o: ../core/logmanipulators.h ../core/slog.h ../core/cur.h
|
||||
db.o: ../core/request.h ../core/error.h ../core/config.h ../core/htmlfilter.h
|
||||
db.o: ../templates/htmltextstream.h ../../pikotools/space/spacetojson.h
|
||||
db.o: ../core/session.h ../core/user.h ../core/plugindata.h ../core/rebus.h
|
||||
db.o: ../core/mount.h ../templates/locale.h ../core/log.h ../core/misc.h
|
||||
dbbase.o: dbbase.h dbconn.h dbtextstream.h ../core/textstream.h
|
||||
dbbase.o: ../core/misc.h ../core/item.h ../../pikotools/space/space.h
|
||||
dbbase.o: ../../pikotools/textstream/types.h ../../pikotools/date/date.h
|
||||
dbbase.o: ../core/requesttypes.h ../../pikotools/textstream/textstream.h
|
||||
db.o: ../../winix/core/error.h ../../pikotools/space/spaceparser.h
|
||||
db.o: ../../pikotools/space/space.h dbitemquery.h ../../winix/core/item.h
|
||||
db.o: dbitemcolumns.h ../../winix/core/user.h ../../winix/core/group.h
|
||||
db.o: ../../winix/core/dircontainer.h ../../winix/core/ugcontainer.h
|
||||
db.o: ../../winix/core/log.h ../../winix/core/textstream.h
|
||||
db.o: ../../winix/core/logmanipulators.h ../../winix/core/slog.h
|
||||
db.o: ../../winix/core/cur.h ../../winix/core/request.h
|
||||
db.o: ../../winix/core/error.h ../../winix/core/config.h
|
||||
db.o: ../../winix/core/htmlfilter.h ../../winix/templates/htmltextstream.h
|
||||
db.o: ../../pikotools/space/spacetojson.h ../../winix/core/session.h
|
||||
db.o: ../../winix/core/user.h ../../winix/core/plugindata.h
|
||||
db.o: ../../winix/core/rebus.h ../../winix/core/ipban.h
|
||||
db.o: ../../winix/core/mount.h ../../winix/templates/locale.h
|
||||
db.o: ../../winix/core/log.h ../../winix/core/misc.h
|
||||
dbbase.o: dbbase.h dbconn.h dbtextstream.h ../../winix/core/textstream.h
|
||||
dbbase.o: ../../winix/core/misc.h ../../winix/core/item.h
|
||||
dbbase.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
dbbase.o: ../../pikotools/date/date.h ../../winix/core/requesttypes.h
|
||||
dbbase.o: ../../pikotools/textstream/textstream.h
|
||||
dbbase.o: ../../pikotools/convert/convert.h
|
||||
dbbase.o: ../../pikotools/convert/inttostr.h
|
||||
dbbase.o: ../../pikotools/membuffer/membuffer.h
|
||||
dbbase.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
dbbase.o: ../core/error.h ../../pikotools/space/spaceparser.h
|
||||
dbbase.o: ../../pikotools/space/space.h ../core/log.h ../core/misc.h
|
||||
dbconn.o: dbconn.h dbtextstream.h ../core/textstream.h ../core/misc.h
|
||||
dbconn.o: ../core/item.h ../../pikotools/space/space.h
|
||||
dbconn.o: ../../pikotools/textstream/types.h ../../pikotools/date/date.h
|
||||
dbconn.o: ../core/requesttypes.h ../../pikotools/textstream/textstream.h
|
||||
dbbase.o: ../../winix/core/error.h ../../pikotools/space/spaceparser.h
|
||||
dbbase.o: ../../pikotools/space/space.h ../../winix/core/log.h
|
||||
dbbase.o: ../../winix/core/misc.h
|
||||
dbconn.o: dbconn.h dbtextstream.h ../../winix/core/textstream.h
|
||||
dbconn.o: ../../winix/core/misc.h ../../winix/core/item.h
|
||||
dbconn.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
dbconn.o: ../../pikotools/date/date.h ../../winix/core/requesttypes.h
|
||||
dbconn.o: ../../pikotools/textstream/textstream.h
|
||||
dbconn.o: ../../pikotools/convert/convert.h
|
||||
dbconn.o: ../../pikotools/convert/inttostr.h
|
||||
dbconn.o: ../../pikotools/membuffer/membuffer.h
|
||||
dbconn.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
dbconn.o: ../core/log.h ../core/error.h
|
||||
dbitemcolumns.o: dbitemcolumns.h ../core/item.h dbbase.h dbconn.h
|
||||
dbitemcolumns.o: dbtextstream.h ../core/textstream.h ../core/misc.h
|
||||
dbitemcolumns.o: ../core/item.h ../../pikotools/space/space.h
|
||||
dbconn.o: ../../winix/core/log.h ../../winix/core/error.h
|
||||
dbitemcolumns.o: dbitemcolumns.h ../../winix/core/item.h dbbase.h dbconn.h
|
||||
dbitemcolumns.o: dbtextstream.h ../../winix/core/textstream.h
|
||||
dbitemcolumns.o: ../../winix/core/misc.h ../../winix/core/item.h
|
||||
dbitemcolumns.o: ../../pikotools/space/space.h
|
||||
dbitemcolumns.o: ../../pikotools/textstream/types.h
|
||||
dbitemcolumns.o: ../../pikotools/date/date.h ../core/requesttypes.h
|
||||
dbitemcolumns.o: ../../pikotools/date/date.h ../../winix/core/requesttypes.h
|
||||
dbitemcolumns.o: ../../pikotools/textstream/textstream.h
|
||||
dbitemcolumns.o: ../../pikotools/convert/convert.h
|
||||
dbitemcolumns.o: ../../pikotools/convert/inttostr.h
|
||||
dbitemcolumns.o: ../../pikotools/membuffer/membuffer.h
|
||||
dbitemcolumns.o: ../../pikotools/textstream/types.h
|
||||
dbitemcolumns.o: ../../pikotools/utf8/utf8.h ../core/error.h
|
||||
dbitemcolumns.o: ../../pikotools/utf8/utf8.h ../../winix/core/error.h
|
||||
dbitemcolumns.o: ../../pikotools/space/spaceparser.h
|
||||
dbitemcolumns.o: ../../pikotools/space/space.h ../core/log.h
|
||||
dbitemquery.o: dbitemquery.h ../core/item.h
|
||||
dbtextstream.o: dbtextstream.h ../core/textstream.h ../core/misc.h
|
||||
dbtextstream.o: ../core/item.h ../../pikotools/space/space.h
|
||||
dbitemcolumns.o: ../../pikotools/space/space.h ../../winix/core/log.h
|
||||
dbitemquery.o: dbitemquery.h ../../winix/core/item.h
|
||||
dbtextstream.o: dbtextstream.h ../../winix/core/textstream.h
|
||||
dbtextstream.o: ../../winix/core/misc.h ../../winix/core/item.h
|
||||
dbtextstream.o: ../../pikotools/space/space.h
|
||||
dbtextstream.o: ../../pikotools/textstream/types.h
|
||||
dbtextstream.o: ../../pikotools/date/date.h ../core/requesttypes.h
|
||||
dbtextstream.o: ../../pikotools/date/date.h ../../winix/core/requesttypes.h
|
||||
dbtextstream.o: ../../pikotools/textstream/textstream.h
|
||||
dbtextstream.o: ../../pikotools/convert/convert.h
|
||||
dbtextstream.o: ../../pikotools/convert/inttostr.h
|
||||
|
||||
@@ -311,7 +311,7 @@ Error Db::AddItemIntoItem(Item & item)
|
||||
query.Clear();
|
||||
query << R("insert into core.item (user_id, modification_user_id, group_id, privileges, "
|
||||
"date_creation, date_modification, type, parent_id, content_id, "
|
||||
"link_to, link_redirect, subject, guest_name, template, sort_index, meta, url) values (")
|
||||
"link_to, link_redirect, subject, guest_name, template, sort_index, meta, ameta, url) values (")
|
||||
<< item.user_id
|
||||
<< item.modification_user_id
|
||||
<< item.group_id
|
||||
@@ -327,7 +327,8 @@ Error Db::AddItemIntoItem(Item & item)
|
||||
<< item.guest_name
|
||||
<< item.html_template
|
||||
<< item.sort_index
|
||||
<< item.meta;
|
||||
<< item.meta
|
||||
<< item.ameta;
|
||||
|
||||
url_without_id = AddItemCreateUrlSubject(item);
|
||||
|
||||
@@ -469,7 +470,7 @@ Error Db::EditItemInItem(Item & item, bool with_url)
|
||||
query.Clear();
|
||||
query << R("update core.item set (user_id, modification_user_id, group_id, privileges, "
|
||||
"date_creation, date_modification, type, link_to, link_redirect, parent_id, subject, "
|
||||
"guest_name, template, sort_index, meta");
|
||||
"guest_name, template, sort_index, meta, ameta");
|
||||
|
||||
if( with_url )
|
||||
query << R(", url");
|
||||
@@ -489,7 +490,8 @@ Error Db::EditItemInItem(Item & item, bool with_url)
|
||||
<< item.guest_name
|
||||
<< item.html_template
|
||||
<< item.sort_index
|
||||
<< item.meta;
|
||||
<< item.meta
|
||||
<< item.ameta;
|
||||
|
||||
if( with_url )
|
||||
{
|
||||
@@ -771,7 +773,7 @@ void Db::GetItemsQuerySelect(const DbItemQuery & iq, DbTextStream & query, bool
|
||||
if( iq.sel_file ) query << R(", file_path, file_fs, file_type, has_thumb, hash, hash_type, file_size");
|
||||
if( iq.sel_html_template ) query << R(", template");
|
||||
if( iq.sel_sort_index ) query << R(", sort_index");
|
||||
if( iq.sel_meta ) query << R(", meta");
|
||||
if( iq.sel_meta ) query << R(", meta, ameta");
|
||||
}
|
||||
|
||||
query << R(" from core.item");
|
||||
@@ -1343,6 +1345,19 @@ return DoCommand(query);
|
||||
}
|
||||
|
||||
|
||||
Error Db::EditAdminMetaById(const PT::Space & ameta, long id)
|
||||
{
|
||||
query.Clear();
|
||||
query << R("update core.item set (ameta) = (")
|
||||
<< ameta
|
||||
<< R(") where id=")
|
||||
<< id
|
||||
<< R(";");
|
||||
|
||||
return DoCommand(query);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Error Db::EditSubjectById(Item & item, long id)
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
Error EditFileById(const Item & item, long id); // file_path, file_fs, file_type
|
||||
Error EditHasThumbById(bool has_thumb, long id);
|
||||
Error EditMetaById(const PT::Space & meta, long id);
|
||||
Error EditAdminMetaById(const PT::Space & meta, long id);
|
||||
|
||||
Error DelDirById(long id);
|
||||
Error DelFileById(long file_id);
|
||||
|
||||
+3
-2
@@ -2,11 +2,12 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "dbconn.h"
|
||||
#include "core/log.h"
|
||||
#include "core/error.h"
|
||||
@@ -76,7 +77,7 @@ void DbConn::WaitForConnection()
|
||||
{
|
||||
if( !pg_conn || PQstatus(pg_conn) != CONNECTION_OK )
|
||||
{
|
||||
log << log3 << "Db: waiting for the db to be ready...." << logend;
|
||||
log << log3 << "Db: waiting for the db to be ready...." << logend << logsave;
|
||||
|
||||
while( !AssertConnection(false, false) )
|
||||
sleep(5);
|
||||
|
||||
@@ -46,6 +46,7 @@ void DbItemColumns::SetColumns(PGresult * r)
|
||||
modify_index = PQfnumber(r, "modify_index");
|
||||
sort_index = PQfnumber(r, "sort_index");
|
||||
meta = PQfnumber(r, "meta");
|
||||
ameta = PQfnumber(r, "ameta");
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +84,7 @@ void DbItemColumns::SetItem(PGresult * r, long row, Item & item)
|
||||
if( sort_index != -1 ) item.sort_index = DbBase::AssertValueInt(r, row, sort_index);
|
||||
|
||||
if( meta != -1 ) db_base.AssertValueSpace(r, row, meta, item.meta);
|
||||
if( ameta != -1 ) db_base.AssertValueSpace(r, row, ameta, item.ameta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ struct DbItemColumns
|
||||
int modify_index;
|
||||
int sort_index;
|
||||
int meta;
|
||||
int ameta;
|
||||
|
||||
DbItemColumns(DbBase & db_base_) : db_base(db_base_)
|
||||
{
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ struct DbItemQuery
|
||||
bool sel_file; // file_path, file_fs, file_type, has_thumb, hash, hash_type, file_size
|
||||
bool sel_html_template; // template
|
||||
bool sel_sort_index; // sort_index
|
||||
bool sel_meta; // meta PT::Space
|
||||
bool sel_meta; // meta and ameta (PT::Space)
|
||||
|
||||
bool where_id; //
|
||||
bool where_parent_id; //
|
||||
|
||||
+38
-1
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <ctime>
|
||||
#include "core/textstream.h"
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
|
||||
@@ -115,6 +116,8 @@ public:
|
||||
DbTextStream & operator<<(RawText<void*> raw);
|
||||
DbTextStream & operator<<(RawText<PT::Date> date);
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
DbTextStream & operator<<(RawText<PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> > raw);
|
||||
|
||||
/*
|
||||
with escaping
|
||||
@@ -154,6 +157,8 @@ public:
|
||||
DbTextStream & operator<<(const PT::Space & space);
|
||||
DbTextStream & operator<<(const PT::Date & date);
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
DbTextStream & operator<<(const PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & arg);
|
||||
|
||||
private:
|
||||
|
||||
@@ -167,6 +172,38 @@ private:
|
||||
|
||||
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
DbTextStream & DbTextStream::operator<<(RawText<PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> > raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
DbTextStream & DbTextStream::operator<<(const PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & arg)
|
||||
{
|
||||
typename PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size>::const_iterator i;
|
||||
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += '\'';
|
||||
|
||||
for(i=arg.begin() ; i != arg.end() ; ++i)
|
||||
ETextPutChar(*i);
|
||||
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@ all: $(o)
|
||||
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
$(CXX) -c $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $<
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. -I.. -I../../ezc/src -I../../pikotools -I../../tito/src -f- *.cpp > Makefile.dep
|
||||
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
|
||||
|
||||
|
||||
+2286
-1504
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
||||
o = adduser.o cat.o chmod.o chown.o ckeditor.o cp.o default.o download.o emacs.o env.o functionbase.o functionparser.o functions.o last.o ln.o locale.o login.o logout.o ls.o man.o meta.o mkdir.o mount.o mv.o nicedit.o node.o passwd.o priv.o privchanger.o pw.o reload.o rm.o rmuser.o run.o sort.o specialdefault.o stat.o subject.o template.o timezone.o tinymce.o uname.o upload.o uptime.o vim.o who.o
|
||||
o = account.o adduser.o cat.o chmod.o chown.o ckeditor.o cp.o default.o download.o emacs.o env.o functionbase.o functionparser.o functions.o imgcrop.o ipban.o last.o ln.o locale.o login.o logout.o ls.o man.o meta.o mkdir.o mount.o mv.o nicedit.o node.o passwd.o priv.o privchanger.o pw.o reload.o rm.o rmuser.o run.o sort.o specialdefault.o stat.o subject.o template.o timezone.o tinymce.o uname.o upload.o uptime.o vim.o who.o
|
||||
|
||||
Executable
+134
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "account.h"
|
||||
#include "core/log.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
Account::Account()
|
||||
{
|
||||
fun.url = L"account";
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Account::ActivateAccount(User * puser, long code, bool use_ses_log)
|
||||
{
|
||||
std::wstring * user_code_str = puser->aenv.GetValue(L"activation_code");
|
||||
|
||||
if( user_code_str )
|
||||
{
|
||||
if( Tol(*user_code_str) == code )
|
||||
{
|
||||
if( db->ChangeUserStatus(puser->id, WINIX_ACCOUNT_READY) == WINIX_ERR_OK )
|
||||
{
|
||||
puser->aenv.Remove(L"activation_code");
|
||||
db->ChangeUserAdminEnv(puser->id, puser->aenv);
|
||||
puser->status = WINIX_ACCOUNT_READY;
|
||||
|
||||
log << log2 << "Account: account: " << puser->name << " activated" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"account_activated") << logend;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Account: account not activated -- database error" << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// !! IMPROVE ME if too many errors from the same IP address
|
||||
// add this ip to the banip list
|
||||
|
||||
log << log2 << "Account: incorrect activation code" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"incorrect_activation_code") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Account: there is no activation_code value in an admin environment" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"account_cannot_be_activated") << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Account::ActivateAccount(const std::wstring & login, long code, bool use_ses_log)
|
||||
{
|
||||
bool result = false;
|
||||
User * puser = system->users.GetUser(login);
|
||||
|
||||
if( puser )
|
||||
{
|
||||
if( puser->status == WINIX_ACCOUNT_NOT_ACTIVATED )
|
||||
{
|
||||
result = ActivateAccount(puser, code, use_ses_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Account: this account is already activated" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"account_already_activated") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Account: there is no a user: " << login << logend;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Account::ActivateAccount()
|
||||
{
|
||||
const std::wstring & login = cur->request->ParamValue(L"login");
|
||||
long code = Tol(cur->request->ParamValue(L"code"));
|
||||
|
||||
if( !login.empty() )
|
||||
{
|
||||
ActivateAccount(login, code, true);
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Account::MakePost()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Account::MakeGet()
|
||||
{
|
||||
if( cur->request->IsParam(L"activate") )
|
||||
ActivateAccount();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_functions_account
|
||||
#define headerfile_winix_functions_account
|
||||
|
||||
#include "functionbase.h"
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
|
||||
class Account : public FunctionBase
|
||||
{
|
||||
public:
|
||||
|
||||
Account();
|
||||
|
||||
void MakeGet();
|
||||
void MakePost();
|
||||
|
||||
bool ActivateAccount(const std::wstring & login, long code, bool use_ses_log = false);
|
||||
|
||||
private:
|
||||
|
||||
bool ActivateAccount(User * puser, long code, bool use_ses_log);
|
||||
void ActivateAccount();
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
@@ -22,6 +22,7 @@ namespace Fun
|
||||
AddUser::AddUser()
|
||||
{
|
||||
fun.url = L"adduser";
|
||||
need_ssl = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+13
-8
@@ -54,7 +54,7 @@ return (conf_parser.ParseString(env_str) == PT::SpaceParser::ok);
|
||||
}
|
||||
|
||||
|
||||
bool Env::EditAdminEnv(long user_id, const std::wstring & env_str)
|
||||
bool Env::EditAdminEnv(long user_id, const std::wstring & env_str, bool use_ses_log)
|
||||
{
|
||||
if( Parse(env_str) )
|
||||
{
|
||||
@@ -69,21 +69,23 @@ bool Env::EditAdminEnv(long user_id, const std::wstring & env_str)
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Evn: a problem with changing environment variables for user: "
|
||||
log << log1 << "Evn: a database problem with changing environment variables for user: "
|
||||
<< cur->session->puser->name << ", id: " << cur->session->puser->id << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Env: Syntax error in line: " << conf_parser.line << logend;
|
||||
slog << logerror << "Syntax error in line: " << conf_parser.line << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Env::EditEnv(long user_id, const std::wstring & env_str)
|
||||
bool Env::EditEnv(long user_id, const std::wstring & env_str, bool use_ses_log)
|
||||
{
|
||||
if( Parse(env_str) )
|
||||
{
|
||||
@@ -98,20 +100,23 @@ bool Env::EditEnv(long user_id, const std::wstring & env_str)
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Evn: a problem with changing admin environment variables for user: "
|
||||
log << log1 << "Evn: a database problem with changing admin environment variables for user: "
|
||||
<< cur->session->puser->name << ", id: " << cur->session->puser->id << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Env: Syntax error in line: " << conf_parser.line << logend;
|
||||
slog << logerror << "Syntax error in line: " << conf_parser.line << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Env::SaveEnv()
|
||||
{
|
||||
if( GetUser() )
|
||||
@@ -123,11 +128,11 @@ void Env::SaveEnv()
|
||||
if( cur->request->IsParam(L"a") )
|
||||
{
|
||||
if( cur->session->puser->super_user )
|
||||
status = EditAdminEnv(user_id, env_str);
|
||||
status = EditAdminEnv(user_id, env_str, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = EditEnv(user_id, env_str);
|
||||
status = EditEnv(user_id, env_str, true);
|
||||
}
|
||||
|
||||
if( status )
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ public:
|
||||
|
||||
Env();
|
||||
|
||||
bool EditAdminEnv(long user_id, const std::wstring & env_str);
|
||||
bool EditEnv(long user_id, const std::wstring & env_str);
|
||||
bool EditAdminEnv(long user_id, const std::wstring & env_str, bool use_ses_log = false);
|
||||
bool EditEnv(long user_id, const std::wstring & env_str, bool use_ses_log = false);
|
||||
|
||||
bool HasAccess();
|
||||
void MakePost();
|
||||
|
||||
@@ -16,6 +16,7 @@ FunctionBase::FunctionBase()
|
||||
{
|
||||
follow_symlinks = true;
|
||||
template_index = size_t(-1);
|
||||
need_ssl = false;
|
||||
|
||||
fun.user_id = -1;
|
||||
fun.group_id = -1;
|
||||
@@ -70,6 +71,12 @@ void FunctionBase::SetSynchro(Synchro * psynchro)
|
||||
}
|
||||
|
||||
|
||||
void FunctionBase::SetSessionManager(SessionManager * pmanager)
|
||||
{
|
||||
session_manager = pmanager;
|
||||
}
|
||||
|
||||
|
||||
void FunctionBase::Init()
|
||||
{
|
||||
// this method is called only once at the beginning
|
||||
|
||||
@@ -43,6 +43,14 @@ public:
|
||||
// html template index (for using with 'patterns' object)
|
||||
size_t template_index;
|
||||
|
||||
// try to use SSL
|
||||
// if in the config 'use_ssl' is true and 'use_ssl_only_for_logged_users' is true
|
||||
// then ssl is used only for logged users but sometimes there is a need to use
|
||||
// SSL even if noone is logged (for example for such functions like 'login' or 'adduser')
|
||||
// default: false
|
||||
// (this option is ignored if 'use_ssl' in the config is false)
|
||||
bool need_ssl;
|
||||
|
||||
virtual void Init();
|
||||
virtual bool HasAccess();
|
||||
virtual void MakePost();
|
||||
@@ -55,6 +63,7 @@ public:
|
||||
void SetFunctions(Functions * pfunctions);
|
||||
void SetTemplates(Templates * ptemplates);
|
||||
void SetSynchro(Synchro * psynchro);
|
||||
void SetSessionManager(SessionManager * pmanager);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -65,7 +74,7 @@ protected:
|
||||
Functions * functions;
|
||||
Templates * templates;
|
||||
Synchro * synchro;
|
||||
|
||||
SessionManager * session_manager;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+10
-1
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -52,6 +52,11 @@ void Functions::SetSynchro(Synchro * psynchro)
|
||||
}
|
||||
|
||||
|
||||
void Functions::SetSessionManager(SessionManager * pmanager)
|
||||
{
|
||||
session_manager = pmanager;
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t Functions::FunctionsSize()
|
||||
@@ -143,6 +148,7 @@ void Functions::SetObjects(FunctionBase * fun)
|
||||
fun->SetFunctions(this);
|
||||
fun->SetTemplates(templates);
|
||||
fun->SetSynchro(synchro);
|
||||
fun->SetSessionManager(session_manager);
|
||||
}
|
||||
|
||||
|
||||
@@ -176,6 +182,7 @@ void Functions::Add(FunctionBase & fun)
|
||||
|
||||
void Functions::CreateFunctions()
|
||||
{
|
||||
Add(fun_account);
|
||||
Add(fun_adduser);
|
||||
Add(fun_cat);
|
||||
Add(fun_chmod);
|
||||
@@ -186,12 +193,14 @@ void Functions::CreateFunctions()
|
||||
Add(fun_download);
|
||||
Add(fun_emacs);
|
||||
Add(fun_env);
|
||||
Add(fun_imgcrop);
|
||||
Add(fun_last);
|
||||
Add(fun_locale);
|
||||
Add(fun_login);
|
||||
Add(fun_logout);
|
||||
Add(fun_ln);
|
||||
Add(fun_ls);
|
||||
Add(fun_ipban);
|
||||
Add(fun_man);
|
||||
Add(fun_meta);
|
||||
Add(fun_mkdir);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <string>
|
||||
#include "functionbase.h"
|
||||
#include "functionparser.h"
|
||||
#include "account.h"
|
||||
#include "adduser.h"
|
||||
#include "cat.h"
|
||||
#include "chmod.h"
|
||||
@@ -23,12 +24,14 @@
|
||||
#include "download.h"
|
||||
#include "emacs.h"
|
||||
#include "env.h"
|
||||
#include "imgcrop.h"
|
||||
#include "last.h"
|
||||
#include "locale.h"
|
||||
#include "login.h"
|
||||
#include "logout.h"
|
||||
#include "ln.h"
|
||||
#include "ls.h"
|
||||
#include "ipban.h"
|
||||
#include "man.h"
|
||||
#include "meta.h"
|
||||
#include "mkdir.h"
|
||||
@@ -66,6 +69,7 @@ class Functions
|
||||
{
|
||||
public:
|
||||
|
||||
Fun::Account fun_account;
|
||||
Fun::AddUser fun_adduser;
|
||||
Fun::Cat fun_cat;
|
||||
Fun::Chmod fun_chmod;
|
||||
@@ -76,12 +80,14 @@ public:
|
||||
Fun::Download fun_download;
|
||||
Fun::Emacs fun_emacs;
|
||||
Fun::Env fun_env;
|
||||
Fun::ImgCrop fun_imgcrop;
|
||||
Fun::Last fun_last;
|
||||
Fun::Locale fun_locale;
|
||||
Fun::Login fun_login;
|
||||
Fun::Logout fun_logout;
|
||||
Fun::Ln fun_ln;
|
||||
Fun::Ls fun_ls;
|
||||
Fun::IPBanFun fun_ipban;
|
||||
Fun::Man fun_man;
|
||||
Fun::Meta fun_meta;
|
||||
Fun::Mkdir fun_mkdir;
|
||||
@@ -129,6 +135,7 @@ public:
|
||||
void SetSystem(System * psystem);
|
||||
void SetTemplates(Templates * ptemplates);
|
||||
void SetSynchro(Synchro * psynchro);
|
||||
void SetSessionManager(SessionManager * pmanager);
|
||||
|
||||
FunctionBase * Find(const std::wstring & function_name);
|
||||
Error CheckSpecialFile(const Item & item);
|
||||
@@ -163,6 +170,7 @@ private:
|
||||
System * system;
|
||||
Synchro * synchro;
|
||||
Templates * templates;
|
||||
SessionManager * session_manager;
|
||||
|
||||
std::wstring temp;
|
||||
HTMLFilter html_filter;
|
||||
|
||||
Executable
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "imgcrop.h"
|
||||
#include "functions.h"
|
||||
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
ImgCrop::ImgCrop()
|
||||
{
|
||||
fun.url = L"imgcrop";
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ImgCrop::HasAccess()
|
||||
{
|
||||
if( cur->request->is_item )
|
||||
return system->HasWriteAccess(cur->request->item);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ImgCrop::GetDirContent()
|
||||
{
|
||||
iq.sel_type = Item::file;
|
||||
iq.sel_content = false;
|
||||
|
||||
iq.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
|
||||
|
||||
db->GetItems(cur->request->item_tab, iq);
|
||||
system->CheckWriteAccessToItems(cur->request->item_tab);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ImgCrop::MakePost()
|
||||
{
|
||||
int xoffset = int(Tod(cur->request->PostVar(L"cropxtop")) + 0.5);
|
||||
int yoffset = int(Tod(cur->request->PostVar(L"cropytop")) + 0.5);
|
||||
int width = int(Tod(cur->request->PostVar(L"cropwidth")) + 0.5);
|
||||
int height = int(Tod(cur->request->PostVar(L"cropheight")) + 0.5);
|
||||
|
||||
SetMinMax(xoffset, 0, 30000);
|
||||
SetMinMax(yoffset, 0, 30000);
|
||||
SetMinMax(width, 1, 30000);
|
||||
SetMinMax(height, 1, 30000);
|
||||
|
||||
Item & item = cur->request->item;
|
||||
|
||||
if( cur->request->is_item && item.type == Item::file && item.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
{
|
||||
if( system->HasWriteAccess(item) )
|
||||
{
|
||||
// !! IMPROVE ME add info about modification (Item::modify_time)
|
||||
if( cur->request->IsParam(L"thumb") )
|
||||
{
|
||||
Image::Scale scale = system->image.GetThumbScale(item.parent_id);
|
||||
system->image.CropThumb(item.id, xoffset, yoffset, width, height, scale.quality);
|
||||
}
|
||||
else
|
||||
if( cur->request->IsParam(L"newthumb") )
|
||||
{
|
||||
Image::Scale scale = system->image.GetThumbScale(item.parent_id);
|
||||
system->image.CropNewThumb(item.id, xoffset, yoffset, width, height, scale.cx, scale.cy,
|
||||
scale.aspect_mode, scale.quality);
|
||||
}
|
||||
else
|
||||
{
|
||||
Image::Scale scale = system->image.GetImageScale(item.parent_id);
|
||||
system->image.Crop(item.id, xoffset, yoffset, width, height, scale.quality);
|
||||
}
|
||||
|
||||
// !! IMPROVE ME redirect me somewhere else
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ImgCrop::MakeGet()
|
||||
{
|
||||
if( !cur->request->is_item )
|
||||
GetDirContent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_functions_imgcrop
|
||||
#define headerfile_winix_functions_imgcrop
|
||||
|
||||
#include "functionbase.h"
|
||||
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
|
||||
class ImgCrop : public FunctionBase
|
||||
{
|
||||
public:
|
||||
|
||||
ImgCrop();
|
||||
|
||||
bool HasAccess();
|
||||
void MakeGet();
|
||||
void MakePost();
|
||||
|
||||
private:
|
||||
|
||||
DbItemQuery iq;
|
||||
|
||||
void GetDirContent();
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "ipban.h"
|
||||
#include "functions.h"
|
||||
#include "core/sessionmanager.h"
|
||||
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
IPBanFun::IPBanFun()
|
||||
{
|
||||
fun.url = L"ipban";
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool IPBanFun::HasAccess()
|
||||
{
|
||||
return cur->session->puser && cur->session->puser->super_user;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void IPBanFun::MakePost()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void IPBanFun::MakeGet()
|
||||
{
|
||||
if( cur->request->IsParam(L"removeip") )
|
||||
{
|
||||
if( cur->request->ParamValue(L"removeip") == L"all" )
|
||||
{
|
||||
session_manager->ClearIPBanList();
|
||||
cur->session->ip_ban = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int cur_ip = 0;
|
||||
|
||||
if( cur->session->ip_ban )
|
||||
cur_ip = cur->session->ip_ban->ip;
|
||||
|
||||
AssignString(cur->request->ParamValue(L"removeip"), tmp_ip_str);
|
||||
int ip = (int)inet_addr(tmp_ip_str.c_str());
|
||||
session_manager->RemoveIPBan(ip);
|
||||
|
||||
if( cur->session->ip_ban && cur_ip == ip )
|
||||
cur->session->ip_ban = 0;
|
||||
}
|
||||
|
||||
system->RedirectToLastFunction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_functions_ipban
|
||||
#define headerfile_winix_functions_ipban
|
||||
|
||||
#include "functionbase.h"
|
||||
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
// IPBanFun in order to not confused with IPBan from core winix
|
||||
class IPBanFun : public FunctionBase
|
||||
{
|
||||
public:
|
||||
|
||||
IPBanFun();
|
||||
|
||||
bool HasAccess();
|
||||
void MakePost();
|
||||
void MakeGet();
|
||||
|
||||
private:
|
||||
|
||||
std::string tmp_ip_str;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
+152
-6
@@ -7,6 +7,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/sessionmanager.h"
|
||||
#include "login.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
@@ -18,6 +19,7 @@ namespace Fun
|
||||
Login::Login()
|
||||
{
|
||||
fun.url = L"login";
|
||||
need_ssl = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +65,12 @@ bool Login::CheckPasswords(const std::wstring & password)
|
||||
return false;
|
||||
}
|
||||
|
||||
return up.pass == up2.pass;
|
||||
bool result = (up.pass == up2.pass);
|
||||
|
||||
if( !result )
|
||||
log << log2 << "Login: incorrect login/password" << logend;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +91,7 @@ bool result;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Login: there is no a user: " << login << " in the database (or an error)" << logend;
|
||||
log << log2 << "Login: there is no a user name: " << login << logend;
|
||||
result = false;
|
||||
}
|
||||
|
||||
@@ -94,24 +101,160 @@ return result;
|
||||
}
|
||||
|
||||
|
||||
bool Login::LoginUser(const std::wstring & login, const std::wstring & password, bool remember_me, bool use_ses_log)
|
||||
|
||||
void Login::AddBanInfo()
|
||||
{
|
||||
IPBan * ip_ban = cur->session->ip_ban;
|
||||
|
||||
if( !ip_ban )
|
||||
ip_ban = &session_manager->AddIPToBanList(cur->request->ip);
|
||||
|
||||
ip_ban->last_used = cur->request->start_time;
|
||||
|
||||
if( ip_ban->expires != 0 && cur->request->start_time >= ip_ban->expires )
|
||||
{
|
||||
// the 'ip block' has expired
|
||||
ip_ban->ClearAfterRemovingBan();
|
||||
log << log3 << "Login: removing the IP block for logging" << logend;
|
||||
}
|
||||
|
||||
if( ip_ban->incorrect_login_events < config->incorrect_login_cannot_login_treshold )
|
||||
ip_ban->incorrect_login_events += 1;
|
||||
|
||||
if( ip_ban->incorrect_login_events >= config->incorrect_login_cannot_login_treshold )
|
||||
{
|
||||
log << log2 << "Login: too many incorrect login attempts from this IP" << logend;
|
||||
|
||||
if( config->incorrect_login_cannot_login_mode == 0 )
|
||||
{
|
||||
// don't set WINIX_IPBAN_FLAG_ACTIVE here for IPBan::IsIPBanned() to return false (in CannotLoginFrom)
|
||||
ip_ban->expires = cur->request->start_time + (time_t)config->incorrect_login_cannot_login_delay;
|
||||
PT::Date date(ip_ban->expires);
|
||||
log << log2 << "Login: logging from this IP address has been blocked until to: " << date << " UTC" << logend;
|
||||
}
|
||||
else
|
||||
if( config->incorrect_login_cannot_login_mode == 1 )
|
||||
{
|
||||
ip_ban->SetFlag(WINIX_IPBAN_FLAG_ACTIVE);
|
||||
ip_ban->AddNextBanLevel(cur->request->start_time + (time_t)config->ban_level_1_delay,
|
||||
cur->request->start_time + (time_t)config->ban_level_2_delay,
|
||||
cur->request->start_time + (time_t)config->ban_level_3_delay);
|
||||
PT::Date date(ip_ban->expires);
|
||||
log << log2 << "Login: this IP address has been banned until to: " << date << " UTC" << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Login::ShouldUseCaptchaForCurrentIP()
|
||||
{
|
||||
if( cur->session->ip_ban )
|
||||
return ShouldUseCaptchaFor(*cur->session->ip_ban);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Login::ShouldUseCaptchaFor(const IPBan & ipban)
|
||||
{
|
||||
if( ipban.expires != 0 && cur->request->start_time >= ipban.expires )
|
||||
return false; // the 'ip block' has expired (but incorrect_login_events has the old value)
|
||||
|
||||
return ipban.incorrect_login_events >= config->incorrect_login_captcha_treshold;
|
||||
}
|
||||
|
||||
|
||||
bool Login::CannotLoginFromCurrentIP()
|
||||
{
|
||||
if( cur->session->ip_ban )
|
||||
return CannotLoginFrom(*cur->session->ip_ban);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Login::CannotLoginFrom(const IPBan & ipban)
|
||||
{
|
||||
if( ipban.IsIPBanned() )
|
||||
return true;
|
||||
|
||||
if( ipban.expires != 0 &&
|
||||
cur->request->start_time < ipban.expires &&
|
||||
ipban.incorrect_login_events >= config->incorrect_login_cannot_login_treshold )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Login::CheckAbuse()
|
||||
{
|
||||
time_t diff = (time_t)config->incorrect_login_min_time_between_get_post;
|
||||
|
||||
if( cur->session->last_time_get + diff > cur->request->start_time )
|
||||
{
|
||||
log << log2 << "Login: the minimum time between GET and POST have not passed" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ShouldUseCaptchaForCurrentIP() )
|
||||
{
|
||||
if( !system->rebus.CheckRebus() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// if you are logging not from a webbrowser but from an application
|
||||
// then probably you need check_abuse to be false
|
||||
bool Login::LoginUser(const std::wstring & login, const std::wstring & password, bool remember_me,
|
||||
bool use_ses_log, bool check_abuse)
|
||||
{
|
||||
long user_id;
|
||||
|
||||
if( cur->session->id == 0 )
|
||||
{
|
||||
log << log1 << "Login: can't login in a temporary session (skipped)" << logend;
|
||||
log << log2 << "Login: can't login in a temporary session (skipped)" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( CannotLoginFromCurrentIP() )
|
||||
{
|
||||
log << log2 << "Login: you cannot login from this IP address" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( login.empty() )
|
||||
{
|
||||
log << log3 << "Login: login is empty (skipping)" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( check_abuse && !CheckAbuse() )
|
||||
{
|
||||
AddBanInfo();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( CheckUserPass(login, password, user_id) )
|
||||
{
|
||||
if( system->users.LoginUser(user_id, remember_me, use_ses_log) )
|
||||
{
|
||||
if( cur->session->ip_ban )
|
||||
cur->session->ip_ban->incorrect_login_events = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Login: incorrect login/password" << logend;
|
||||
AddBanInfo();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -124,11 +267,14 @@ void Login::MakePost()
|
||||
const std::wstring & pass = cur->request->PostVar(L"password");
|
||||
const std::wstring & remem = cur->request->PostVar(L"rememberme");
|
||||
|
||||
if( LoginUser(login, pass, !remem.empty(), true) )
|
||||
if( LoginUser(login, pass, !remem.empty(), true, true) )
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
|
||||
|
||||
void Login::MakeGet()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
+16
-2
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -24,19 +24,33 @@ class Login : public FunctionBase
|
||||
public:
|
||||
|
||||
Login();
|
||||
|
||||
void MakePost();
|
||||
void MakeGet();
|
||||
|
||||
bool ShouldUseCaptchaForCurrentIP();
|
||||
bool ShouldUseCaptchaFor(const IPBan & ipban);
|
||||
|
||||
bool CannotLoginFromCurrentIP();
|
||||
bool CannotLoginFrom(const IPBan & ipban);
|
||||
|
||||
bool CheckUserPass(const std::wstring & login, const std::wstring & password, long & user_id);
|
||||
bool LoginUser(const std::wstring & login, const std::wstring & password, bool remember_me, bool use_ses_log = false);
|
||||
bool LoginUser(const std::wstring & login, const std::wstring & password, bool remember_me,
|
||||
bool use_ses_log = false, bool check_abuse = false);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void ClearTmpStruct();
|
||||
bool CheckPasswords(const std::wstring & password);
|
||||
void AddBanInfo();
|
||||
bool CheckAbuse();
|
||||
|
||||
UserPass up, up2;
|
||||
std::string pass_decrypted;
|
||||
std::wstring pass_hashed;
|
||||
std::wstring salt;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
+78
-12
@@ -17,30 +17,53 @@ namespace Fun
|
||||
Meta::Meta()
|
||||
{
|
||||
fun.url = L"meta";
|
||||
// !! CHECKME what about follow symlinks?
|
||||
}
|
||||
|
||||
|
||||
bool Meta::HasAccess()
|
||||
{
|
||||
return system->HasReadAccess(*cur->request->last_item);
|
||||
if( cur->request->IsParam(L"a") )
|
||||
return cur->session->puser && cur->session->puser->super_user;
|
||||
else
|
||||
return system->HasWriteAccess(*cur->request->last_item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Meta::AddMetaInfo(Item & item, const std::wstring & meta_str)
|
||||
bool Meta::Parse(const std::wstring & meta_str)
|
||||
{
|
||||
space.Clear();
|
||||
conf_parser.SetSpace(space);
|
||||
conf_parser.UTF8(config->utf8);
|
||||
conf_parser.SplitSingle(true);
|
||||
|
||||
if( conf_parser.ParseString(meta_str) == PT::SpaceParser::ok )
|
||||
return (conf_parser.ParseString(meta_str) == PT::SpaceParser::ok);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Meta::EditAdminMeta(long item_id, const std::wstring & meta_str, bool use_ses_log)
|
||||
{
|
||||
if( db->EditMetaById(space, item.id) == WINIX_ERR_OK )
|
||||
if( Parse(meta_str) )
|
||||
{
|
||||
if( db->EditAdminMetaById(space, item_id) == WINIX_ERR_OK )
|
||||
{
|
||||
item.meta = space;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Meta: a database problem with changing admin meta information for item id: "
|
||||
<< item_id << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Meta: Syntax error in line: " << conf_parser.line << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -48,21 +71,64 @@ return false;
|
||||
|
||||
|
||||
|
||||
void Meta::MakePost()
|
||||
bool Meta::EditMeta(long item_id, const std::wstring & meta_str, bool use_ses_log)
|
||||
{
|
||||
if( Parse(meta_str) )
|
||||
{
|
||||
if( db->EditMetaById(space, item_id) == WINIX_ERR_OK )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Meta: a database problem with changing meta information for item id: "
|
||||
<< item_id << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Meta: Syntax error in line: " << conf_parser.line << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Meta::ChangeAdminMeta()
|
||||
{
|
||||
if( cur->session->puser && cur->session->puser->super_user )
|
||||
{
|
||||
const std::wstring & meta_str = cur->request->PostVar(L"itemmeta");
|
||||
|
||||
if( EditAdminMeta(cur->request->last_item->id, meta_str, true) )
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Meta::ChangeMeta()
|
||||
{
|
||||
if( system->HasWriteAccess(*cur->request->last_item) )
|
||||
{
|
||||
const std::wstring & meta_str = cur->request->PostVar(L"itemmeta");
|
||||
|
||||
if( AddMetaInfo(*cur->request->last_item, meta_str) )
|
||||
if( EditMeta(cur->request->last_item->id, meta_str, true) )
|
||||
system->RedirectToLastItem();
|
||||
else
|
||||
slog << logerror << "Syntax error in line: " << conf_parser.line << logend;
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Meta::MakePost()
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
if( cur->request->IsParam(L"a") )
|
||||
ChangeAdminMeta();
|
||||
else
|
||||
ChangeMeta();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+8
-1
@@ -26,12 +26,19 @@ public:
|
||||
|
||||
bool HasAccess();
|
||||
void MakePost();
|
||||
bool AddMetaInfo(Item & item, const std::wstring & meta_str);
|
||||
|
||||
bool EditAdminMeta(long item_id, const std::wstring & meta_str, bool use_ses_log = false);
|
||||
bool EditMeta(long item_id, const std::wstring & meta_str, bool use_ses_log = false);
|
||||
|
||||
private:
|
||||
|
||||
PT::SpaceParser conf_parser;
|
||||
PT::Space space;
|
||||
|
||||
bool Parse(const std::wstring & meta_str);
|
||||
void ChangeAdminMeta();
|
||||
void ChangeMeta();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
+140
-2
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* Copyright (c) 2011-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -25,7 +25,8 @@ Passwd::Passwd()
|
||||
|
||||
bool Passwd::HasAccess()
|
||||
{
|
||||
return cur->session->puser != 0;
|
||||
// a not logged user can use this function to reset his password
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +125,127 @@ long user_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Passwd::SetNewPassword(User * puser, bool use_ses_log)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
const std::wstring & pass = cur->request->PostVar(L"passwordnew");
|
||||
const std::wstring & pass_conf = cur->request->PostVar(L"passwordconfirm");
|
||||
|
||||
if( IsPasswordCorrect(pass, pass_conf, use_ses_log) )
|
||||
{
|
||||
if( ChangePassword(puser->id, pass) )
|
||||
{
|
||||
result = true;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T("pw_password_changed") << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("service_unavailable") << logend;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Passwd::ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access)
|
||||
{
|
||||
std::wstring * user_code_str = puser->aenv.GetValue(L"password_change_code");
|
||||
|
||||
if( user_code_str )
|
||||
{
|
||||
if( Tol(*user_code_str) == code )
|
||||
{
|
||||
if( only_check_access )
|
||||
return true;
|
||||
else
|
||||
return SetNewPassword(puser, use_ses_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Passwd: incorrect change password code" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"incorrect_change_password_code") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Passwd: there is no change password code in admin environment" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"password_cannot_be_changed") << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Passwd::ResetPassword(const std::wstring & login, long code, bool use_ses_log, bool only_check_access)
|
||||
{
|
||||
bool result = false;
|
||||
User * puser = system->users.GetUser(login);
|
||||
|
||||
if( puser )
|
||||
{
|
||||
long t = static_cast<long>(cur->request->start_time);
|
||||
|
||||
if( puser->aenv.Long(L"password_change_time") + config->reset_password_code_expiration_time > t )
|
||||
{
|
||||
result = ResetPassword(puser, code, use_ses_log, only_check_access);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Passwd: the code has expired" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"code_expired") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Passwd: there is no a user: " << login << logend;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void Passwd::ResetPassword()
|
||||
{
|
||||
const std::wstring & login = cur->request->PostVar(L"login");
|
||||
long code = Tol(cur->request->PostVar(L"code"));
|
||||
|
||||
if( ResetPassword(login, code, true, false) )
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
|
||||
|
||||
void Passwd::ShowResetPasswordForm()
|
||||
{
|
||||
const std::wstring & login = cur->request->ParamValue(L"login");
|
||||
long code = Tol(cur->request->ParamValue(L"code"));
|
||||
|
||||
if( !login.empty() )
|
||||
{
|
||||
if( !ResetPassword(login, code, true, true) )
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if you are a root (super_user) you can change a password for everyone
|
||||
(the html form has a select option)
|
||||
@@ -149,8 +271,24 @@ const std::wstring * plogin;
|
||||
else
|
||||
log << log1 << "Passwd: there is no such a user: " << *plogin << logend;
|
||||
}
|
||||
else
|
||||
if( cur->request->IsParam(L"resetpassword") )
|
||||
{
|
||||
ResetPassword();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Passwd::MakeGet()
|
||||
{
|
||||
if( cur->request->IsParam(L"resetpassword") )
|
||||
ShowResetPasswordForm();
|
||||
else
|
||||
if( !cur->session->puser )
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
+9
-1
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* Copyright (c) 2011-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -24,10 +24,12 @@ public:
|
||||
|
||||
Passwd();
|
||||
bool HasAccess();
|
||||
void MakeGet();
|
||||
void MakePost();
|
||||
|
||||
bool IsPasswordCorrect(const std::wstring & pass, const std::wstring & conf_pass, bool use_ses_log = false);
|
||||
bool ChangePassword(long user_id, const std::wstring & new_password);
|
||||
bool ResetPassword(const std::wstring & login, long code, bool use_ses_log = false, bool only_check_access = false);
|
||||
|
||||
private:
|
||||
|
||||
@@ -35,6 +37,12 @@ private:
|
||||
|
||||
void ChangePassword(User * puser);
|
||||
|
||||
bool ResetPassword(User * puser, long code, bool use_ses_log);
|
||||
bool SetNewPassword(User * puser, bool use_ses_log);
|
||||
bool ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access);
|
||||
void ResetPassword();
|
||||
void ShowResetPasswordForm();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
+4
-211
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "pw.h"
|
||||
#include "core/log.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
|
||||
namespace Fun
|
||||
@@ -19,6 +19,7 @@ namespace Fun
|
||||
Pw::Pw()
|
||||
{
|
||||
fun.url = L"pw";
|
||||
fun.privileges = 07000;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,224 +30,16 @@ bool Pw::HasAccess()
|
||||
|
||||
|
||||
|
||||
bool Pw::ActivateAccount(User * puser, long code, bool use_ses_log)
|
||||
{
|
||||
std::wstring * user_code_str = puser->aenv.GetValue(L"activation_code");
|
||||
|
||||
if( user_code_str )
|
||||
{
|
||||
if( Tol(*user_code_str) == code )
|
||||
{
|
||||
if( db->ChangeUserStatus(puser->id, WINIX_ACCOUNT_READY) == WINIX_ERR_OK )
|
||||
{
|
||||
puser->aenv.Remove(L"activation_code");
|
||||
db->ChangeUserAdminEnv(puser->id, puser->aenv);
|
||||
puser->status = WINIX_ACCOUNT_READY;
|
||||
|
||||
log << log2 << "Pw: account: " << puser->name << " activated" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"account_activated") << logend;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Pw: account not activated -- database error" << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Pw: incorrect activation code" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"incorrect_activation_code") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Pw: there is no activation_code value in admin environment" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"account_cannot_be_activated") << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Pw::ActivateAccount(const std::wstring & login, long code, bool use_ses_log)
|
||||
{
|
||||
bool result = false;
|
||||
User * puser = system->users.GetUser(login);
|
||||
|
||||
if( puser )
|
||||
{
|
||||
if( puser->status == WINIX_ACCOUNT_NOT_ACTIVATED )
|
||||
{
|
||||
result = ActivateAccount(puser, code, use_ses_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Pw: this account is already activated" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"account_already_activated") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Pw: there is no a user: " << login << logend;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Pw::ActivateAccount()
|
||||
{
|
||||
const std::wstring & login = cur->request->ParamValue(L"login");
|
||||
long code = Tol(cur->request->ParamValue(L"code"));
|
||||
|
||||
ActivateAccount(login, code, true);
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Pw::SetNewPassword(User * puser, bool use_ses_log)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
const std::wstring & pass = cur->request->PostVar(L"passwordnew");
|
||||
const std::wstring & pass_conf = cur->request->PostVar(L"passwordconfirm");
|
||||
|
||||
if( functions->fun_passwd.IsPasswordCorrect(pass, pass_conf, use_ses_log) )
|
||||
{
|
||||
if( functions->fun_passwd.ChangePassword(puser->id, pass) )
|
||||
{
|
||||
result = true;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T("pw_password_changed") << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("service_unavailable") << logend;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Pw::ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access)
|
||||
{
|
||||
std::wstring * user_code_str = puser->aenv.GetValue(L"password_change_code");
|
||||
|
||||
if( user_code_str )
|
||||
{
|
||||
if( Tol(*user_code_str) == code )
|
||||
{
|
||||
if( only_check_access )
|
||||
return true;
|
||||
else
|
||||
return SetNewPassword(puser, use_ses_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Pw: incorrect change password code" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"incorrect_change_password_code") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Pw: there is no change password code in admin environment" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << loginfo << T(L"password_cannot_be_changed") << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Pw::ResetPassword(const std::wstring & login, long code, bool use_ses_log, bool only_check_access)
|
||||
{
|
||||
bool result = false;
|
||||
User * puser = system->users.GetUser(login);
|
||||
|
||||
if( puser )
|
||||
{
|
||||
long t = static_cast<long>(cur->request->start_time);
|
||||
|
||||
if( puser->aenv.Long(L"password_change_time") + config->reset_password_code_expiration_time > t )
|
||||
{
|
||||
result = ResetPassword(puser, code, use_ses_log, only_check_access);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Pw: the code has expired" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"code_expired") << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Pw: there is no a user: " << login << logend;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void Pw::ResetPassword()
|
||||
{
|
||||
const std::wstring & login = cur->request->PostVar(L"login");
|
||||
long code = Tol(cur->request->PostVar(L"code"));
|
||||
|
||||
ResetPassword(login, code, true, false);
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
|
||||
|
||||
void Pw::ShowResetPasswordForm()
|
||||
{
|
||||
const std::wstring & login = cur->request->ParamValue(L"login");
|
||||
long code = Tol(cur->request->ParamValue(L"code"));
|
||||
|
||||
if( !login.empty() )
|
||||
{
|
||||
if( !ResetPassword(login, code, true, true) )
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
}
|
||||
|
||||
/* this function will be used for: adding a new user, adding a new group, deleting an existing user etc. */
|
||||
|
||||
void Pw::MakePost()
|
||||
{
|
||||
if( cur->request->IsParam(L"resetpassword") )
|
||||
ResetPassword();
|
||||
}
|
||||
|
||||
|
||||
void Pw::MakeGet()
|
||||
{
|
||||
if( cur->request->IsParam(L"activate") )
|
||||
ActivateAccount();
|
||||
else
|
||||
if( cur->request->IsParam(L"resetpassword") )
|
||||
ShowResetPasswordForm();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-10
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -27,18 +27,9 @@ public:
|
||||
void MakePost();
|
||||
void MakeGet();
|
||||
|
||||
bool ActivateAccount(const std::wstring & login, long code, bool use_ses_log = false);
|
||||
bool ResetPassword(const std::wstring & login, long code, bool use_ses_log = false, bool only_check_access = false);
|
||||
|
||||
private:
|
||||
|
||||
bool ActivateAccount(User * puser, long code, bool use_ses_log);
|
||||
bool ResetPassword(User * puser, long code, bool use_ses_log);
|
||||
void ActivateAccount();
|
||||
bool SetNewPassword(User * puser, bool use_ses_log);
|
||||
bool ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access);
|
||||
void ResetPassword();
|
||||
void ShowResetPasswordForm();
|
||||
|
||||
};
|
||||
|
||||
|
||||
+33
-1
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -214,6 +214,38 @@ return RemoveFile(item);
|
||||
}
|
||||
|
||||
|
||||
bool Rm::RemoveFileOrSymlink(long item_id, bool check_access)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
// selecting files, symlinks and directories
|
||||
rm_by_id_iq.SetAll(false, false);
|
||||
rm_by_id_iq.sel_parent_id = true;
|
||||
rm_by_id_iq.sel_type = true;
|
||||
rm_by_id_iq.sel_url = true;
|
||||
rm_by_id_iq.sel_file = true;
|
||||
rm_by_id_iq.sel_user_id = true;
|
||||
rm_by_id_iq.sel_group_id = true;
|
||||
rm_by_id_iq.sel_privileges = true;
|
||||
rm_by_id_iq.sel_meta = true;
|
||||
rm_by_id_iq.WhereId(item_id);
|
||||
|
||||
if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
||||
{
|
||||
if( rm_by_id_item.type == Item::file || rm_by_id_item.type == Item::symlink )
|
||||
{
|
||||
result = RemoveFileOrSymlink(rm_by_id_item, check_access);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Rm: I cannot remove file or symlink, item_id: " << item_id
|
||||
<< " is a directory" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// for other uses (plugins etc)
|
||||
bool Rm::RemoveItemById(long item_id, bool check_access)
|
||||
|
||||
+2
-1
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* Copyright (c) 2010-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
void RemoveDirTree(Item & dir, bool remove_this_dir, bool check_access = true);
|
||||
|
||||
// removing either a file or a symlink
|
||||
bool RemoveFileOrSymlink(long item_id, bool check_access = true);
|
||||
bool RemoveFileOrSymlink(Item & item, bool check_access = true);
|
||||
|
||||
// removing either a directory or a symlink or a file
|
||||
|
||||
+5
-57
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* Copyright (c) 2008-2013, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -89,68 +89,16 @@ bool Upload::UploadSaveStaticFile(const Item & item, const std::wstring & tmp_fi
|
||||
|
||||
void Upload::ResizeImage(Item & item)
|
||||
{
|
||||
::Mount * m = system->mounts.CalcMount(item.parent_id);
|
||||
size_t cx = config->image_cx;
|
||||
size_t cy = config->image_cy;
|
||||
int mode = config->image_mode;
|
||||
int quality = config->image_quality;
|
||||
|
||||
// reading width and height from the mount point (if exists)
|
||||
int index = system->mounts.MountParImageSize();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 2 )
|
||||
{
|
||||
cx = Tol(m->param[index].arg[0]);
|
||||
cy = Tol(m->param[index].arg[1]);
|
||||
}
|
||||
|
||||
// reading image mode from the mount point (if exists)
|
||||
index = system->mounts.MountParImageMode();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||
mode = Toi(m->param[index].arg[0]);
|
||||
|
||||
// reading image quality from the mount point (if exists)
|
||||
index = system->mounts.MountParImageQuality();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||
quality = Toi(m->param[index].arg[0]);
|
||||
|
||||
system->image.Resize(item, cx, cy, mode, quality);
|
||||
Image::Scale scale = system->image.GetImageScale(item.parent_id);
|
||||
system->image.Resize(item.id, scale.cx, scale.cy, scale.aspect_mode, scale.quality);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Upload::CreateThumb(Item & item)
|
||||
{
|
||||
::Mount * m = system->mounts.CalcMount(item.parent_id);
|
||||
size_t cx = config->thumb_cx;
|
||||
size_t cy = config->thumb_cy;
|
||||
int mode = config->thumb_mode;
|
||||
int quality = config->thumb_quality;
|
||||
|
||||
// reading width and height from the mount point (if exists)
|
||||
int index = system->mounts.MountParThumbSize();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 2 )
|
||||
{
|
||||
cx = Tol(m->param[index].arg[0]);
|
||||
cy = Tol(m->param[index].arg[1]);
|
||||
}
|
||||
|
||||
// reading thumb mode from the mount point (if exists)
|
||||
index = system->mounts.MountParThumbMode();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||
mode = Toi(m->param[index].arg[0]);
|
||||
|
||||
// reading image quality from the mount point (if exists)
|
||||
index = system->mounts.MountParThumbQuality();
|
||||
|
||||
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||
quality = Toi(m->param[index].arg[0]);
|
||||
|
||||
system->image.CreateThumb(item, cx, cy, mode, quality);
|
||||
Image::Scale scale = system->image.GetThumbScale(item.parent_id);
|
||||
system->image.CreateThumb(item.id, scale.cx, scale.cy, scale.aspect_mode, scale.quality);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p class="iteminfo">
|
||||
<p class="winix_iteminfo">
|
||||
{added_by}: [dir_last_user], [dir_last_date_creation_nice]
|
||||
|
||||
[if-no dir_last_dates_equal]
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{error_404}</h1>
|
||||
|
||||
<p>{error_404_msg}</p>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{access_denied}</h1>
|
||||
|
||||
<p>{access_denied_msg}</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
[if-no winix_err_is "0"]
|
||||
<p class="error">
|
||||
[if-one winix_is_err_in_locales]
|
||||
[winix_err_msg_from_locales]
|
||||
[else]
|
||||
{winix_err_default} [winix_err_code]
|
||||
[end]
|
||||
</p>
|
||||
[end]
|
||||
@@ -0,0 +1,20 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>Account</h1>
|
||||
|
||||
[if user_logged]
|
||||
<p>You are logged as: [user_name]<br>
|
||||
[if user_super_user]
|
||||
You are the root
|
||||
[end]
|
||||
[# !! IMPROVE ME add info about groups, may other parameters like time zone, language?]
|
||||
</p>
|
||||
[else]
|
||||
<p>You are not logged in.</p>
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,3 +1,5 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>[if-one user_logged]{adduser_header_add}[else]{adduser_header_register}[end]</h1>
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir]adduser">
|
||||
@@ -35,4 +37,5 @@
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
+35
-23
@@ -1,33 +1,42 @@
|
||||
<div class="winix">
|
||||
|
||||
[if item_is]<h1>{edit}</h1>[else]<h1>{add}</h1>[end]
|
||||
|
||||
[include "error.html"]
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]ckeditor">
|
||||
<fieldset>
|
||||
<legend>{form_emacs_legend}</legend>
|
||||
|
||||
[if mount_type_is "cms"]
|
||||
<p class="withnext" style="text-indent: 0;">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_title_id">{title}:</label>
|
||||
<input id="winix_title_id" type="text" name="subject" value="[item_subject]">
|
||||
</div>
|
||||
|
||||
<p class="withnext" style="text-indent: 0;">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_url_id">{suggested_url}:</label>
|
||||
<input id="winix_url_id" type="text" name="url" value="[item_url]">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
[if-any mount_type_is "thread" mount_thread_arg_is "subject"]
|
||||
<p class="withnext" style="text-indent: 0;">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
[if-any mount_type_is "thread" thread_mount_arg_is "subject"]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_title_id">{title}:</label>
|
||||
<input id="winix_title_id" type="text" name="subject" value="[item_subject]">
|
||||
</div>
|
||||
|
||||
<p class="withnext" style="text-indent: 0;">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_url_id">{suggested_url}:</label>
|
||||
<input id="winix_url_id" type="text" name="url" value="[item_url]">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
[if mount_type_is "cms"]<p class="withnext">{form_emacs_content_cms}</p>[end]
|
||||
[if mount_type_is "thread"]<p class="withnext">{form_emacs_content_thread}</p>[end]
|
||||
[if mount_type_is "ticket"]<p class="withnext">{form_emacs_content_ticket}</p>[end]
|
||||
<div class="winix_input_a">
|
||||
[if mount_type_is "cms"]<label for="winix_content_id">{form_emacs_content_cms}</label>[end]
|
||||
[if mount_type_is "thread"]<label for="winix_content_id">{form_emacs_content_thread}</label>[end]
|
||||
[if mount_type_is "ticket"]<label for="winix_content_id">{form_emacs_content_ticket}</label>[end]
|
||||
|
||||
[# template fun_ls.html uses the name: itemcontent to refer to this textarea item]
|
||||
<textarea class="multitext" rows="[if mount_type_is "cms"]30[else]10[end]" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
<textarea id="winix_content_id" rows="[if mount_type_is "cms"]30[else]10[end]" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="contenttype" value="2">
|
||||
|
||||
@@ -39,21 +48,24 @@
|
||||
[end]
|
||||
|
||||
[if-no user_logged]
|
||||
<p class="withnext" style="text-indent: 0;">{nick}:</p>
|
||||
<input class="edit" type="text" name="guestname" value="[item_guest_name]">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_nick_id">{nick}:</label>
|
||||
<input id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
|
||||
</div>
|
||||
|
||||
<p class="withnext" style="text-indent: 0;">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input class="edit" type="text" name="rebus">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_rebus_id">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input id="winix_rebus_id" type="text" name="rebus">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="[if item_is]{change}[else]{add}[end]">
|
||||
<input type="submit" value="[if item_is]{change}[else]{add}[end]">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{cp_header}</h1>
|
||||
|
||||
[include "error.html"]
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if-one item_is][item_url]/[end]cp[if-no item_is]/r[end]">
|
||||
<fieldset>
|
||||
@@ -35,3 +36,4 @@
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{create_thread_header}</h1>
|
||||
|
||||
[include "error.html"]
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir]createthread">
|
||||
@@ -10,7 +11,7 @@
|
||||
<p class="withnext">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
|
||||
[if mount_thread_arg_is "subject"]
|
||||
[if thread_mount_arg_is "subject"]
|
||||
<p class="withnext">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
[end]
|
||||
@@ -33,3 +34,4 @@
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
+44
-31
@@ -1,32 +1,29 @@
|
||||
<div class="winix">
|
||||
|
||||
[# this template is used in fun_editticket.html as well]
|
||||
|
||||
[if item_is]<h1>{edit_ticket_header}</h1>[else]<h1>{create_ticket_header}</h1>[end]
|
||||
|
||||
[include "error.html"]
|
||||
|
||||
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/editticket[else]createticket[end]" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
<form method="post" action="[doc_base_url][dir][if item_is][item_url]/editticket[else]createticket[end]" enctype="multipart/form-data">
|
||||
|
||||
[if item_is]
|
||||
<legend>{form_edit_ticket_legend}</legend>
|
||||
[else]
|
||||
<legend>{form_create_ticket_legend}</legend>
|
||||
[end]
|
||||
|
||||
<p class="withnext">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_title_id">{title}:</label>
|
||||
<input id="winix_title_id" type="text" name="subject" value="[item_subject]">
|
||||
</div>
|
||||
|
||||
|
||||
[if ticket_tab]
|
||||
<table class="ticket">
|
||||
<table class="winix_create_ticket">
|
||||
|
||||
[for ticket_tab]
|
||||
|
||||
<tr>
|
||||
<th>[ticket_tab_param_name]:</th>
|
||||
<th>[filter fil_firstup][ticket_tab_param_name]:[end]</th>
|
||||
|
||||
<td>
|
||||
|
||||
@@ -51,11 +48,14 @@
|
||||
|
||||
[if ticket_tab_type_is "images"]
|
||||
[for ticket_tab_file_tab]
|
||||
<div class="winix_create_ticket_file_row">
|
||||
<img src="[doc_base_url][ticket_tab_file_tab_path]/-/thumb" alt="[ticket_tab_file_tab_path]" height="150">
|
||||
<input type="submit" name="ticketdeletefile_[ticket_tab_file_tab_itemid]" value="{ticket_delete_file}">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
<input size="30" class="edit" type="file" name="ticketparam[ticket_tab_param_id]" multiple>
|
||||
<input class="filesubmit" type="submit" name="fileuploadsubmit" value="{add}">
|
||||
<input size="30" type="file" name="ticketparam[ticket_tab_param_id]" multiple>
|
||||
<input type="submit" name="fileuploadsubmit" value="{add}">
|
||||
[end]
|
||||
|
||||
|
||||
@@ -63,13 +63,17 @@
|
||||
[if ticket_tab_file_tab]
|
||||
<ul>
|
||||
[for ticket_tab_file_tab]
|
||||
<li><a href="[doc_base_url][ticket_tab_file_tab_path]/download">[ticket_tab_file_tab_path]</a></li>
|
||||
<li>
|
||||
<a href="[doc_base_url][ticket_tab_file_tab_path]/download">[ticket_tab_file_tab_path]</a>
|
||||
[# !! CHECK ME how this look like -- css was not set]
|
||||
<input type="submit" name="ticketdeletefile_[ticket_tab_file_tab_itemid]" value="{ticket_delete_file}">
|
||||
</li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
|
||||
<input size="30" class="edit" type="file" name="ticketparam[ticket_tab_param_id]" multiple>
|
||||
<input class="filesubmit" type="submit" name="fileuploadsubmit" value="{add}">
|
||||
<input size="30" type="file" name="ticketparam[ticket_tab_param_id]" multiple>
|
||||
<input type="submit" name="fileuploadsubmit" value="{add}">
|
||||
[end]
|
||||
|
||||
[if-any-no ticket_tab_type_is "images" ticket_tab_type_is "files" ticket_is_creating_new ticket_tab_has_value]
|
||||
@@ -85,31 +89,36 @@
|
||||
[end]
|
||||
|
||||
|
||||
[# !! change names form_emacs_content_thread and form_emacs_content_ticket]
|
||||
|
||||
<p class="withnext">{form_emacs_content_ticket}</p>
|
||||
<textarea class="multitext" rows="10" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
[# FIXME !! change names form_emacs_content_thread and form_emacs_content_ticket]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_content_id">{form_emacs_content_ticket}</label>
|
||||
<textarea id="winix_content_id" rows="10" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="withnext">{form_emacs_content_type}</p>
|
||||
|
||||
<select name="contenttype" class="contenttype">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_content_type_id">{form_emacs_content_type}</label>
|
||||
<select id="winix_content_type_id" name="contenttype">
|
||||
<option[if item_content_type_is "text"] selected[end] value="0">{form_emacs_content_type_text}</option>
|
||||
<option[if item_content_type_is "formatted text"] selected[end] value="1">{form_emacs_content_type_formatted_text}</option>
|
||||
[if-one user_can_use_html]<option[if item_content_type_is "html"] selected[end] value="2">{form_emacs_content_type_html}</option>[end]
|
||||
[if-one user_can_use_bbcode]<option[if item_content_type_is "bbcode"] selected[end] value="3">{form_emacs_content_type_bbcode}</option>[end]
|
||||
[if-one user_can_use_raw]<option[if item_content_type_is "raw"] selected[end] value="4">{form_emacs_content_type_raw}</option>[end]
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
[if-no user_logged]
|
||||
<p class="withnext">{nick}:</p>
|
||||
<input class="edit" type="text" name="guestname" value="[item_guest_name]">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_nick_id">{nick}:</label>
|
||||
<input id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
|
||||
</div>
|
||||
|
||||
<p class="withnext">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input class="edit" type="text" name="rebus">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_rebus_id">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input id="winix_rebus_id" type="text" name="rebus">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
|
||||
@@ -118,6 +127,10 @@
|
||||
[end]
|
||||
|
||||
|
||||
<input class="submit" type="submit" value="[if item_is]{form_ticket_edit_submit}[else]{form_ticket_create_submit}[end]">
|
||||
</fieldset>
|
||||
<input type="submit" value="[if item_is]{form_ticket_edit_submit}[else]{form_ticket_create_submit}[end]">
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{default_header}</h1>
|
||||
|
||||
[include "error.html"]
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir]default">
|
||||
<fieldset>
|
||||
@@ -21,4 +22,5 @@
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
+22
-14
@@ -1,34 +1,42 @@
|
||||
<div class="winix">
|
||||
|
||||
[if item_is]<h1>{edit}</h1>[else]<h1>{add}</h1>[end]
|
||||
|
||||
[include "error.html"]
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]emacs">
|
||||
<fieldset>
|
||||
<legend>{form_emacs_legend}</legend>
|
||||
<form method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]emacs">
|
||||
|
||||
<p class="withnext">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_title_id">{title}:</label>
|
||||
<input id="winix_title_id" type="text" name="subject" value="[item_subject]">
|
||||
</div>
|
||||
|
||||
<p class="withnext">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_url_id">{suggested_url}:</label>
|
||||
<input id="winix_url_id" type="text" name="url" value="[item_url]">
|
||||
</div>
|
||||
|
||||
[include "fun_emacs_post.html"]
|
||||
|
||||
[if-no user_logged]
|
||||
<p class="withnext">{nick}:</p>
|
||||
<input class="edit" type="text" name="guestname" value="[item_guest_name]">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_nick_id">{nick}:</label>
|
||||
<input id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
|
||||
</div>
|
||||
|
||||
<p class="withnext">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input class="edit" type="text" name="rebus">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_rebus_id">{rebus_how_is_it} [rebus_question]?</label>
|
||||
<input id="winix_rebus_id" type="text" name="rebus">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="[if item_is]{change}[else]{add}[end]">
|
||||
</fieldset>
|
||||
<input type="submit" value="[if item_is]{change}[else]{add}[end]">
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
|
||||
<div class="winix_input_a">
|
||||
|
||||
[if winix_function_is "upload"]
|
||||
<p class="withnext">{upload_content}</p>
|
||||
<label for="winix_content_id">{upload_content}</label>
|
||||
[else]
|
||||
[if mount_type_is "cms"]<p class="withnext">{form_emacs_content_cms}</p>[end]
|
||||
[if mount_type_is "thread"]<p class="withnext">{form_emacs_content_thread}</p>[end]
|
||||
[if mount_type_is "ticket"]<p class="withnext">{form_emacs_content_ticket}</p>[end]
|
||||
[if mount_type_is "cms"]<label for="winix_content_id">{form_emacs_content_cms}</label>[end]
|
||||
[if mount_type_is "thread"]<label for="winix_content_id">{form_emacs_content_thread}</label>[end]
|
||||
[if mount_type_is "ticket"]<label for="winix_content_id">{form_emacs_content_ticket}</label>[end]
|
||||
[end]
|
||||
|
||||
<textarea class="multitext" rows="[if winix_function_is "upload"]7[else][if mount_type_is "cms"]30[else]10[end][end]" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
<textarea id="winix_content_id" rows="[if winix_function_is "upload"]7[else][if mount_type_is "cms"]30[else]10[end][end]" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="withnext">{form_emacs_content_type}</p>
|
||||
|
||||
<select name="contenttype" class="contenttype">
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_contenttype_id">{form_emacs_content_type}</label>
|
||||
<select name="contenttype" id="winix_contenttype_id">
|
||||
<option[if item_content_type_is "text"] selected[end] value="0">{form_emacs_content_type_text}</option>
|
||||
<option[if item_content_type_is "formatted text"] selected[end] value="1">{form_emacs_content_type_formatted_text}</option>
|
||||
[if user_can_use_html]<option[if item_content_type_is "html"] selected[end] value="2">{form_emacs_content_type_html}</option>[end]
|
||||
[if user_can_use_bbcode]<option[if item_content_type_is "bbcode"] selected[end] value="3">{form_emacs_content_type_bbcode}</option>[end]
|
||||
[if user_can_use_raw]<option[if item_content_type_is "raw"] selected[end] value="4">{form_emacs_content_type_raw}</option>[end]
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{env_header}</h1>
|
||||
|
||||
|
||||
@@ -50,3 +52,5 @@
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
+11
-15
@@ -1,14 +1,19 @@
|
||||
<h1>Export</h1>
|
||||
<div class="winix">
|
||||
|
||||
<h1>{export_header}</h1>
|
||||
|
||||
|
||||
<p>Press Export to transfer the [if item_is]file[else]directory[end] to an external ftp server</p>
|
||||
[if item_is]
|
||||
<p>{export_transer_file_info}</p>
|
||||
[else]
|
||||
<p>{export_transer_dir_info}</p>
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
<form action="[doc_base_url][dir][if item_is][item_url]/[end]export" method="post">
|
||||
<fieldset>
|
||||
|
||||
|
||||
<input type="checkbox" name="onlynonstatic" id="nonstaticfiles"><label for="nonstaticfiles">Export only non static files</label>
|
||||
<input type="checkbox" name="staticfilestoo" id="nonstaticfiles"><label for="nonstaticfiles">{export_checkbox_static_file_too}</label>
|
||||
|
||||
<br><br>
|
||||
<input type="submit" value="Export">
|
||||
@@ -17,16 +22,7 @@
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
+88
-1
@@ -1,3 +1,5 @@
|
||||
<div class="winix">
|
||||
|
||||
[if mount_page_arg_is "subject"][if mount_page_arg_is "info"]<h1 class="withinfo">[else]<h1>[end][dir_last_subject]</h1>[end]
|
||||
[if mount_page_arg_is "info"][include "dir_last_info.html"][end]
|
||||
|
||||
@@ -37,13 +39,58 @@
|
||||
[if-no winix_function_param_is "image"]
|
||||
<script type="text/javascript">$('.galleryimages').galleria();</script>
|
||||
[else]
|
||||
<script type="text/javascript">$('.galleryimages').galleria(\{show: [winix_function_param_value "image"]\});</script>
|
||||
[# !! IMPROVE ME add this javascript code to the rest of galleria types]
|
||||
<script type="text/javascript">var url = window.document.URL.toString(); var num = 0; var re = /\/image:(\d+)/; var numarr = re.exec(url); if( numarr && numarr.length == 2 ) \{var num = numarr\[1\];\}; $('.galleryimages').galleria(\{show: num\});</script>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
[if gallery_mount_type_arg_is "galleria1.2.9"]
|
||||
|
||||
[if gallery_tab]
|
||||
|
||||
<ul class="galleryimages" style="width: [gallery_width]; height: [gallery_height];">
|
||||
[for gallery_tab]
|
||||
<li><a href="[gallery_tab_link]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
|
||||
|
||||
[if gallery_mount_theme_arg_is "transparent"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/galleria/themes/transparent/galleria.transparent.js');</script>
|
||||
|
||||
[if-no winix_function_param_is "image"]
|
||||
<script type="text/javascript">Galleria.configure(\{showInfo:false\}); Galleria.run('.galleryimages');</script>
|
||||
[else]
|
||||
<script type="text/javascript">Galleria.configure(\{showInfo:false, show: [winix_function_param_value "image"]\}); Galleria.run('.galleryimages');</script>
|
||||
[end]
|
||||
|
||||
[else]
|
||||
[if gallery_mount_theme_arg_is "transparentinfo"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/galleria/themes/transparentinfo/galleria.transparent.js');</script>
|
||||
|
||||
[if-no winix_function_param_is "image"]
|
||||
<script type="text/javascript">Galleria.configure(\{\}); Galleria.run('.galleryimages');</script>
|
||||
[else]
|
||||
<script type="text/javascript">Galleria.configure(\{show: [winix_function_param_value "image"]\}); Galleria.run('.galleryimages');</script>
|
||||
[end]
|
||||
[else]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/galleria/themes/classic/galleria.classic.js');</script>
|
||||
|
||||
[if-no winix_function_param_is "image"]
|
||||
<script type="text/javascript">Galleria.configure(\{\}); Galleria.run('.galleryimages');</script>
|
||||
[else]
|
||||
<script type="text/javascript">Galleria.configure(\{show: [winix_function_param_value "image"]\}); Galleria.run('.galleryimages');</script>
|
||||
[end]
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
[if gallery_mount_type_arg_is "galleriathumb"]
|
||||
|
||||
@@ -77,3 +124,43 @@
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
[if gallery_mount_type_arg_is "galleriathumb1.2.9"]
|
||||
|
||||
|
||||
[if-no winix_function_param_is "image"]
|
||||
[if gallery_tab]
|
||||
<ul class="galleryimages">
|
||||
[for gallery_tab]
|
||||
<li><a href="[doc_base_url][dir]-/image:[gallery_tab_index]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
[else]
|
||||
|
||||
[if gallery_tab]
|
||||
|
||||
<ul class="galleryimages" style="width: [gallery_width]; height: [gallery_height];">
|
||||
[for gallery_tab]
|
||||
<li><a href="[gallery_tab_link]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
|
||||
[if gallery_mount_theme_arg_is "transparent"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/galleria/themes/transparent/galleria.transparent.js');</script>
|
||||
<script type="text/javascript">Galleria.configure(\{showInfo:false, show: [winix_function_param_value "image"]\}); Galleria.run('.galleryimages');</script>
|
||||
[else]
|
||||
[if gallery_mount_theme_arg_is "transparentinfo"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/galleria/themes/transparentinfo/galleria.transparent.js');</script>
|
||||
<script type="text/javascript">Galleria.configure(\{show: [winix_function_param_value "image"]\}); Galleria.run('.galleryimages');</script>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<div class="winix">
|
||||
|
||||
|
||||
<h1>Kadrowanie obrazów</h1>
|
||||
|
||||
[if item_is]
|
||||
|
||||
[if winix_function_param_is "thumb"]
|
||||
<p>Kadruj miniaturę zdjęcia, obraz oryginalny (duży) nie zostanie zmodyfikowany.</p>.
|
||||
[else]
|
||||
[if winix_function_param_is "newthumb"]
|
||||
<p>Zaznacz myszką kadr na zdjęciu, z tej części zostanie stworzona nowa miniatura, obraz oryginalny (duży) nie zostanie zmodyfikowany.</p>.
|
||||
[else]
|
||||
<p>Kadruj oryginalny obraz (miniatura nie zostanie zmodyfikowana).</p>.
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[if-any item_is item_filetype_is_image]
|
||||
|
||||
<script type="text/javascript">
|
||||
var winix_jcrop;
|
||||
</script>
|
||||
|
||||
<img src="[item_link][if winix_function_param_is "thumb"]/-/thumb[end]" alt="" id="winix_imgcropper">
|
||||
|
||||
<form id="winix_cropform" action="[item_link]/imgcrop[if winix_function_param_is "thumb"]/thumb[end][if winix_function_param_is "newthumb"]/newthumb[end]" method="post">
|
||||
<input type="hidden" name="cropxtop" value="" id="winix_idcropxtop">
|
||||
<input type="hidden" name="cropytop" value="" id="winix_idcropytop">
|
||||
<input type="hidden" name="cropwidth" value="" id="winix_idcropwidth">
|
||||
<input type="hidden" name="cropheight" value="" id="winix_idcropheight">
|
||||
|
||||
[if-any-no winix_function_param_is "thumb" winix_function_param_is "newthumb"]
|
||||
|
||||
[if false]
|
||||
<div class="winix_input_b">
|
||||
<input type="checkbox" name="createthumbtoo" id="winix_createthumbtooid">
|
||||
<label for="winix_createthumbtooid">Stwórz także nową miniaturę</label>
|
||||
</div>
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input type="submit" value="Kadruj">
|
||||
</form>
|
||||
|
||||
|
||||
[else]
|
||||
<p>To nie jest obrazek.</p>
|
||||
[end]
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#winix_imgcropper').Jcrop(\{boxWidth: 700, boxHeight: 450\}, function()\{winix_jcrop = this;\});
|
||||
|
||||
$('form#winix_cropform').submit(function()\{
|
||||
var c = winix_jcrop.tellSelect();
|
||||
$('form#winix_cropform input#winix_idcropxtop').val(c.x);
|
||||
$('form#winix_cropform input#winix_idcropytop').val(c.y);
|
||||
$('form#winix_cropform input#winix_idcropwidth').val(c.w);
|
||||
$('form#winix_cropform input#winix_idcropheight').val(c.h);
|
||||
|
||||
return c.w != 0 && c.h != 0;
|
||||
\});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
[else]
|
||||
|
||||
[if item_tab]
|
||||
<ul class="winix_imgcrop_list">
|
||||
[for item_tab]
|
||||
|
||||
<li>
|
||||
|
||||
<div class="winix_imgcrop_list_image">
|
||||
<img src="[item_tab_link][if item_tab_has_thumb]/-/thumb[end]" alt="[item_tab_subject]">
|
||||
</div>
|
||||
|
||||
<div class="winix_imgcrop_list_imageurl">
|
||||
[item_tab_url]
|
||||
</div>
|
||||
|
||||
<div class="winix_imgcrop_list_options">
|
||||
|
||||
<ul>
|
||||
<li><a href="[item_tab_link]/imgcrop/postredirect:[filter fil_urlencode][doc_base_url][dir]imgcrop[end]">Kadruj zdjęcie</a></li>
|
||||
<li><a href="[item_tab_link]/imgcrop/thumb/postredirect:[filter fil_urlencode][doc_base_url][dir]imgcrop[end]">Kadruj miniature</a></li>
|
||||
<li><a href="[item_tab_link]/imgcrop/newthumb/postredirect:[filter fil_urlencode][doc_base_url][dir]imgcrop[end]">Kadruj i stwórz nową miniature</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{ipban_header}</h1>
|
||||
|
||||
[if ipban_tab]
|
||||
|
||||
<table>
|
||||
|
||||
<tr>
|
||||
<th>{ipban_col_id}</th>
|
||||
<th>{ipban_col_ip_address}</th>
|
||||
<th>{ipban_col_login_failures}</th>
|
||||
<th>{ipban_col_login_allowed}</th>
|
||||
<th>{ipban_col_ban_level}</th>
|
||||
<th>{ipban_col_active_flag}</th>
|
||||
<th>{ipban_col_last_used}</th>
|
||||
<th>{ipban_col_expires}</th>
|
||||
<th>{ipban_col_remove}</th>
|
||||
</tr>
|
||||
|
||||
[for ipban_tab]
|
||||
|
||||
<tr>
|
||||
<td>[ipban_tab_id]</td>
|
||||
<td>[ipban_tab_ip]</td>
|
||||
<td>[ipban_tab_incorrect_login]</td>
|
||||
<td>[if ipban_tab_is_logging_allowed]{ipban_loggin_allowed}[else]{ipban_loggin_not_allowed}[end]</td>
|
||||
<td>[ipban_tab_ban_level]</td>
|
||||
<td>[if ipban_tab_has_active_flag]{ipban_has_active_flag}[end]</td>
|
||||
<td>[ipban_tab_last_used]</td>
|
||||
<td>[ipban_tab_expires]</td>
|
||||
<td><a href="[doc_base_url][dir][if item_is][item_url]/[end]ipban/removeip:[ipban_tab_ip]">{ipban_remove_ip}</a></td>
|
||||
</tr>
|
||||
|
||||
[end]
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<a href="[doc_base_url][dir][if item_is][item_url]/[end]ipban/removeip:all">{ipban_remove_all_ip}</a>
|
||||
</p>
|
||||
|
||||
[else]
|
||||
<p>{ipban_ban_list_empty}</p>
|
||||
[end]
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1 class="simple">{last_header}</h1>
|
||||
|
||||
[if-one last_tab]
|
||||
@@ -12,3 +14,4 @@
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{ln_header}</h1>
|
||||
|
||||
[include "error.html"]
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir]ln">
|
||||
<fieldset>
|
||||
@@ -33,4 +34,5 @@
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{locale_header}</h1>
|
||||
|
||||
[if user_has_correct_locale]
|
||||
@@ -31,3 +33,4 @@
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
+36
-8
@@ -1,23 +1,51 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{login_header}</h1>
|
||||
|
||||
[if-one user_logged]
|
||||
<p>{logged_as_long}: [user_name]<br>
|
||||
<a href="[doc_base_url][if-one dir_can_read_exec][dir][if-any item_is item_can_read][item_url]/[end][else]/[end]logout">{logout}</a></p>
|
||||
[else]
|
||||
<form id="additem" method="post" action="[login_path]login">
|
||||
<fieldset>
|
||||
<legend>{form_login_legend}:</legend>
|
||||
<input class="editshort" type="text" name="login">
|
||||
<input class="editshort" type="password" name="password">
|
||||
<label><input class="remember" type="checkbox" name="rememberme">{remember_me}</label>
|
||||
<input class="submit" type="submit" value="{button_login}">
|
||||
|
||||
[if login_cannot_login]
|
||||
<p>{login_cannot_login_from_this_ip}<br>
|
||||
{login_cannot_login_available} [login_when_available_login]</p>
|
||||
[else]
|
||||
|
||||
<form method="post" action="[login_path]login">
|
||||
|
||||
<div class="winix_input_b">
|
||||
<input type="text" name="login">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_b">
|
||||
<input type="password" name="password">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_b">
|
||||
<input id="winix_login_rememberme_id" type="checkbox" name="rememberme">
|
||||
<label for="winix_login_rememberme_id">{remember_me}</label>
|
||||
</div>
|
||||
|
||||
[if login_should_use_captcha]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_rebus_id">{rebus_how_is_it} [rebus_question]?</label>
|
||||
<input id="winix_rebus_id" type="text" name="rebus">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
<input type="submit" value="{button_login}">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user