Compare commits
304 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0045c6c72c | |||
| 4809016b78 | |||
| 6e2ba65524 | |||
| 8033ac66c4 | |||
| 9ef3736989 | |||
| 099dd55d0c | |||
| 53b4175d00 | |||
| 8aa6f08e08 | |||
| c5024598cb | |||
| dfcf6b29c0 | |||
| 7f48d1eb2e | |||
| eaa97995d2 | |||
| 14f997b844 | |||
| 26e87b20b1 | |||
| 5cdf6eff36 | |||
| 4ed535a3b7 | |||
| da15323c2f | |||
| bd1f717b4c | |||
| 72013046fc | |||
| 14ae19143f | |||
| d8260d8383 | |||
| 9174555ff8 | |||
| 0c6ddc2218 | |||
| 43b4075b16 | |||
| 8f8e44fee5 | |||
| 260c12894d | |||
| adf273479a | |||
| 54480da405 | |||
| 90261b2005 | |||
| cc71c225a3 | |||
| e739f30088 | |||
| 51d95b49a0 | |||
| b5c155b927 | |||
| 5a5fe1b0cc | |||
| 1c4e010fc1 | |||
| d8d523d983 | |||
| 1c2589a2f2 | |||
| 1ec61ffa11 | |||
| ca0a5c9cbe | |||
| 8dd31e737f | |||
| e98cca7fbc | |||
| 9830b0a50f | |||
| f76a0ca3e9 | |||
| 5a6d1991ac | |||
| 329e2d8001 | |||
| 403cca5aad | |||
| b8ff5d4cfc | |||
| 54e6c07efc | |||
| d11cda3577 | |||
| abafb80caf | |||
| e0dd85ca99 | |||
| 2c38fe180e | |||
| 0d0f12b394 | |||
| 86d6c96aeb | |||
| b605fb0a77 | |||
| ec773e5f29 | |||
| 9d5d088b4a | |||
| 1b858f5782 | |||
| 5b845f1d03 | |||
| db9d381a43 | |||
| 0df088e1e2 | |||
| 67099d5d06 | |||
| 07e8e0c63c | |||
| ecc89d8596 | |||
| c94b0311b6 | |||
| fc33b4f882 | |||
| 1da1eef768 | |||
| baf10a9ba9 | |||
| bcea4f9464 | |||
| 920290e9dc | |||
| 1d83cf42a1 | |||
| 09bfdf9e77 | |||
| e83fd91423 | |||
| 70421b7bd1 | |||
| 71ae70f670 | |||
| b1b3cea64e | |||
| 2712c57f15 | |||
| 0b528c7225 | |||
| b7007da5a9 | |||
| 489310ba1c | |||
| 6c2c12fe5e | |||
| e61f0db57e | |||
| 3e3546a2fd | |||
| d2fa3b7171 | |||
| 0e9f587591 | |||
| 9208b15167 | |||
| a45fb30e0a | |||
| 97c7edafd6 | |||
| 1a51b1adc7 | |||
| 9d2be5c50d | |||
| f381f24402 | |||
| f6db85fcdb | |||
| 9687d5cd66 | |||
| 6e2d00bc5b | |||
| 5aaab89cd8 | |||
| 7407d24586 | |||
| c9931da5ba | |||
| 4311f06ade | |||
| 8b64b5d372 | |||
| 631ca4f8a3 | |||
| 424618de38 | |||
| b2d3ca9543 | |||
| cb33f20a24 | |||
| 973d804db2 | |||
| 84eaa6b7b6 | |||
| f967a428ce | |||
| 543d464cbc | |||
| 43470b2a41 | |||
| fa05e25a9d | |||
| fe2f1605f1 | |||
| 48b5c167bf | |||
| 08a0a36dfd | |||
| d135c31ca0 | |||
| dce68221ad | |||
| 93273bd470 | |||
| 92f7c11999 | |||
| 024ce8e73c | |||
| 7902389ef1 | |||
| 1e9ab2f805 | |||
| 0550212b64 | |||
| c7b6ca67a2 | |||
| 9dae2de2fa | |||
| 968593106e | |||
| 302cb0130d | |||
| 89efaa790f | |||
| 60f0e62c23 | |||
| f113e2ef31 | |||
| 39923d6617 | |||
| 72be443414 | |||
| 392e8060ba | |||
| 8c01b0f6c0 | |||
| b984475e49 | |||
| 4f114ea33c | |||
| 5b8a9c0108 | |||
| ee6500ac65 | |||
| 3b2a1c3f25 | |||
| 4d87359aca | |||
| c37c1ff812 | |||
| 1812a2e9ad | |||
| ccc02f41bf | |||
| eaf10c70b7 | |||
| 06f42dd9cb | |||
| 1d6ff73aad | |||
| 700a6fe643 | |||
| 0a7432b059 | |||
| b369fda1d9 | |||
| c49c35cfbd | |||
| fb4742e165 | |||
| fce45b93a2 | |||
| 18ecd46a01 | |||
| af8fbdae72 | |||
| c84997be30 | |||
| 06551d6084 | |||
| 84145d7cc8 | |||
| 426beae796 | |||
| aadf12c7b3 | |||
| 1b60935d08 | |||
| d68731fd55 | |||
| ba63c8c661 | |||
| 15487b347f | |||
| e7e90c6527 | |||
| ca5421347a | |||
| c8a57f2046 | |||
| 583df13139 | |||
| 5049961e17 | |||
| 18492e5d61 | |||
| d4d9f89d1d | |||
| ecf19034ae | |||
| 00521c490e | |||
| 3071df227a | |||
| 915cabdf97 | |||
| 61ac29b2de | |||
| ab84a5169e | |||
| 3fad25b8c8 | |||
| 8154c403d8 | |||
| bb83aed20d | |||
| 600c9fc907 | |||
| 5d09eb149c | |||
| e854fe3681 | |||
| 36c8822e6c | |||
| 9b29cce1a4 | |||
| 508f06339e | |||
| 0a9cdd2f15 | |||
| 7f77b6e3ec | |||
| 9507b0b1ba | |||
| ad9d6f4301 | |||
| b721fb6860 | |||
| 5f46cd2ea5 | |||
| 35efed9fef | |||
| 08e53919e2 | |||
| 933c8841ff | |||
| 518281e101 | |||
| 515d4bab0d | |||
| 8e72a820dd | |||
| f1f0fa34cb | |||
| 5010ef93e8 | |||
| e6679a3192 | |||
| 7cf8d5d2d3 | |||
| 14198eca41 | |||
| c6473f20dc | |||
| 9c34cb5862 | |||
| 149fd1629f | |||
| c48241f78a | |||
| a1bee81a5b | |||
| 1b053c03ba | |||
| 33057acd62 | |||
| 07511a2eb0 | |||
| 69c634d53f | |||
| 7bc17a9202 | |||
| d94a08b991 | |||
| a8b8c1feec | |||
| a589e5a090 | |||
| 8b1db3304f | |||
| 23aedd68b0 | |||
| f48f08a98b | |||
| 81dd88d25a | |||
| c92081d6e1 | |||
| d6e80f5a23 | |||
| 37cf71234c | |||
| 3b655f39e1 | |||
| eec0ddf466 | |||
| ca4e53bb0f | |||
| d9f2e91806 | |||
| 7bfed62526 | |||
| b63ac98f40 | |||
| 1e7d297c0e | |||
| f3cd3b88b9 | |||
| 9a199cd834 | |||
| c3fac2e83f | |||
| c7f6d2727c | |||
| 9901c63ede | |||
| 76897b8a83 | |||
| 217cf1420b | |||
| 6897192364 | |||
| 031ace3fe5 | |||
| e4683b9a05 | |||
| 93da32cfb3 | |||
| 62a0e52092 | |||
| 262ba10443 | |||
| 50cb88c5ed | |||
| 76e32703ac | |||
| d9f5fbaf04 | |||
| 16bb238518 | |||
| 759135fd7d | |||
| 56075857f2 | |||
| 8d3c7500d8 | |||
| 1e3f5e8695 | |||
| 08f5865c72 | |||
| ff3c141138 | |||
| fe31e0e849 | |||
| 2a26968c6c | |||
| fe8774953a | |||
| 4a7f036561 | |||
| 612f260938 | |||
| 2ad666d221 | |||
| aff4cc516e | |||
| 6fbcffe63b | |||
| ebd868fa33 | |||
| 71a63cc70e | |||
| 3702efc5be | |||
| 16e51cd4e5 | |||
| 87747fab06 | |||
| 4fe3d4339f | |||
| a276fb6b79 | |||
| fa8d8f9ea0 | |||
| c58031cbf4 | |||
| 4aae12fc63 | |||
| 256a8fb5c5 | |||
| 3c5a7cd664 | |||
| 796985472a | |||
| 7e0014865e | |||
| cd74d1887a | |||
| adf36e71ce | |||
| fc3c303d30 | |||
| 0e50977779 | |||
| ed9feaf542 | |||
| 09d427b4ba | |||
| 5dac8af300 | |||
| 1493a6180a | |||
| 848ddcebd7 | |||
| 71763d340e | |||
| 89daf6489d | |||
| 356e93914b | |||
| 5523d0c27a | |||
| 590a94523e | |||
| 3c95b84633 | |||
| 59943c87cd | |||
| 3f9a46b1f7 | |||
| 81faca041a | |||
| 60fccea703 | |||
| 118bf1fc65 | |||
| ce7ae3edd4 | |||
| 717eb526fb | |||
| 9241fddb1e | |||
| 2dff0bed72 | |||
| 4827c116f0 | |||
| 848afac803 | |||
| 13b0204427 | |||
| dc5f002de3 | |||
| 2ca44ec361 | |||
| c62d48160a | |||
| 9129f1b82a | |||
| 378cfc0c3d | |||
| 7db71d43e0 |
134
Makefile
134
Makefile
@@ -1,42 +1,128 @@
|
||||
# Makefile for GNU make
|
||||
|
||||
|
||||
ifndef CXX
|
||||
CXX = g++
|
||||
export CXX
|
||||
endif
|
||||
|
||||
ifndef CXXFLAGS
|
||||
CXXFLAGS = -Wall -pedantic -g -I/usr/local/include -L/usr/local/lib
|
||||
export 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
|
||||
endif
|
||||
|
||||
ifndef LDFLAGS
|
||||
LDFLAGS = -L/usr/local/lib
|
||||
endif
|
||||
|
||||
|
||||
all: cmslu.a
|
||||
|
||||
cmslu.a: FORCE
|
||||
@cd core ; $(MAKE) -e
|
||||
@cd content ; $(MAKE) -e
|
||||
@cd confparser ; $(MAKE) -e
|
||||
@cd templates ; $(MAKE) -e
|
||||
@cd templatesnotify ; $(MAKE) -e
|
||||
ar rcs cmslu.a core/*.o content/*.o templates/*.o templatesnotify/*.o confparser/*.o
|
||||
export CXX
|
||||
export CXXFLAGS
|
||||
export LDFLAGS
|
||||
|
||||
|
||||
clean:
|
||||
@cd core ; $(MAKE) -e clean
|
||||
@cd content ; $(MAKE) -e clean
|
||||
@cd confparser ; $(MAKE) -e clean
|
||||
@cd templates ; $(MAKE) -e clean
|
||||
@cd templatesnotify ; $(MAKE) -e clean
|
||||
rm -f cmslu.a
|
||||
all: winix.so plugins winix
|
||||
|
||||
|
||||
|
||||
winix.so: FORCE
|
||||
@cd core ; $(MAKE) -e
|
||||
@cd db ; $(MAKE) -e
|
||||
@cd functions ; $(MAKE) -e
|
||||
@cd notify ; $(MAKE) -e
|
||||
@cd templates ; $(MAKE) -e
|
||||
@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
|
||||
|
||||
|
||||
winix: winix.so FORCE
|
||||
@cd main ; $(MAKE) -e
|
||||
# use the full path with winix.so
|
||||
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) main/*.o /home/tomek/roboczy/winix/winix.so
|
||||
|
||||
|
||||
|
||||
plugins: FORCE
|
||||
@cd plugins/stats ; $(MAKE) -e
|
||||
@cd plugins/thread ; $(MAKE) -e
|
||||
@cd plugins/ticket ; $(MAKE) -e
|
||||
@cd plugins/gallery ; $(MAKE) -e
|
||||
@cd plugins/group ; $(MAKE) -e
|
||||
@cd plugins/menu ; $(MAKE) -e
|
||||
@cd plugins/export ; $(MAKE) -e
|
||||
|
||||
|
||||
FORCE:
|
||||
|
||||
|
||||
clean:
|
||||
@cd core ; $(MAKE) -e clean
|
||||
@cd db ; $(MAKE) -e clean
|
||||
@cd functions ; $(MAKE) -e clean
|
||||
@cd templates ; $(MAKE) -e clean
|
||||
@cd notify ; $(MAKE) -e clean
|
||||
@cd plugins/stats ; $(MAKE) -e clean
|
||||
@cd plugins/thread ; $(MAKE) -e clean
|
||||
@cd plugins/ticket ; $(MAKE) -e clean
|
||||
@cd plugins/gallery ; $(MAKE) -e clean
|
||||
@cd plugins/group ; $(MAKE) -e clean
|
||||
@cd plugins/menu ; $(MAKE) -e clean
|
||||
@cd plugins/export ; $(MAKE) -e clean
|
||||
@cd ../ezc/src ; $(MAKE) -e clean
|
||||
@cd ../tito/src ; $(MAKE) -e clean
|
||||
@cd ../pikotools ; $(MAKE) -e clean
|
||||
@cd main ; $(MAKE) -e clean
|
||||
rm -f winix.so
|
||||
rm -f winix
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
@cd core ; $(MAKE) -e depend
|
||||
@cd content ; $(MAKE) -e depend
|
||||
@cd confparser ; $(MAKE) -e depend
|
||||
@cd templates ; $(MAKE) -e depend
|
||||
@cd templatesnotify ; $(MAKE) -e depend
|
||||
@cd core ; $(MAKE) -e depend
|
||||
@cd db ; $(MAKE) -e depend
|
||||
@cd functions ; $(MAKE) -e depend
|
||||
@cd templates ; $(MAKE) -e depend
|
||||
@cd notify ; $(MAKE) -e depend
|
||||
@cd plugins/stats ; $(MAKE) -e depend
|
||||
@cd plugins/thread ; $(MAKE) -e depend
|
||||
@cd plugins/ticket ; $(MAKE) -e depend
|
||||
@cd plugins/gallery ; $(MAKE) -e depend
|
||||
@cd plugins/group ; $(MAKE) -e depend
|
||||
@cd plugins/menu ; $(MAKE) -e depend
|
||||
@cd plugins/export ; $(MAKE) -e depend
|
||||
@cd ../ezc/src ; $(MAKE) -e depend
|
||||
@cd ../tito/src ; $(MAKE) -e depend
|
||||
@cd ../pikotools ; $(MAKE) -e depend
|
||||
@cd main ; $(MAKE) -e depend
|
||||
|
||||
|
||||
|
||||
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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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 "{}" "+"
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfileappcontent
|
||||
#define headerfileappcontent
|
||||
|
||||
|
||||
|
||||
namespace AppContent
|
||||
{
|
||||
|
||||
|
||||
#ifdef APPPREPARE
|
||||
|
||||
void PrepareApp();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfileapptemplates
|
||||
#define headerfileapptemplates
|
||||
|
||||
|
||||
#include "../../ezc/src/ezc.h"
|
||||
|
||||
|
||||
namespace AppTemplateFunctions
|
||||
{
|
||||
|
||||
|
||||
//void CreateAppFunctions(Ezc::Functions & functions);
|
||||
|
||||
void ReadAppPatterns();
|
||||
|
||||
void CreateAppFunctions(Ezc::Functions & functions);
|
||||
Ezc::Pattern * GetAppPattern();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,3 +0,0 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
confparser.o: confparser.h
|
||||
@@ -1 +0,0 @@
|
||||
o = confparser.o
|
||||
@@ -1,208 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "confparser.h"
|
||||
|
||||
|
||||
ConfParser::ConfParser()
|
||||
{
|
||||
separator = '=';
|
||||
commentary = '#';
|
||||
}
|
||||
|
||||
|
||||
ConfParser::Status ConfParser::Parse(const char * file_name)
|
||||
{
|
||||
file.open( file_name );
|
||||
|
||||
if( !file )
|
||||
return cant_open_file;
|
||||
|
||||
line = 1;
|
||||
table.clear();
|
||||
ReadChar();
|
||||
status = ParseFile();
|
||||
|
||||
file.close();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ConfParser::Status ConfParser::ParseFile()
|
||||
{
|
||||
while( lastc != -1 )
|
||||
{
|
||||
if( ReadVariable() )
|
||||
{
|
||||
if( lastc != separator )
|
||||
return syntax_error;
|
||||
|
||||
ReadChar(); // skipping separator
|
||||
|
||||
if( !ReadValue() )
|
||||
return syntax_error;
|
||||
|
||||
table.insert( std::make_pair(variable, value) );
|
||||
}
|
||||
|
||||
if( lastc == commentary )
|
||||
SkipLine();
|
||||
|
||||
if( lastc != -1 && lastc != '\n' )
|
||||
return syntax_error;
|
||||
|
||||
ReadChar(); // skipping '\n' if was
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool ConfParser::IsVariableChar(int c)
|
||||
{
|
||||
if( (c>='a' && c<='z') ||
|
||||
(c>='A' && c<='Z') ||
|
||||
(c>='0' && c<='9') ||
|
||||
c=='.' || c==',' || c=='_' )
|
||||
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool ConfParser::IsValueSimpleChar(int c)
|
||||
{
|
||||
if( c==-1 || c=='\n' || IsWhite(c) || c==commentary )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ConfParser::ReadVariable()
|
||||
{
|
||||
variable.clear();
|
||||
|
||||
SkipWhite();
|
||||
|
||||
while( IsVariableChar(lastc) )
|
||||
{
|
||||
variable += lastc;
|
||||
ReadChar();
|
||||
}
|
||||
|
||||
SkipWhite();
|
||||
|
||||
return !variable.empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ConfParser::ReadValue()
|
||||
{
|
||||
value.clear();
|
||||
|
||||
SkipWhite();
|
||||
|
||||
|
||||
if( lastc == '"' )
|
||||
// quoted value
|
||||
return ReadValueQuoted();
|
||||
else
|
||||
return ReadValueSimple();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool ConfParser::ReadValueQuoted()
|
||||
{
|
||||
ReadChar(); // skipping the first quote
|
||||
|
||||
while( lastc != '\n' && lastc != '"' && lastc != -1 )
|
||||
{
|
||||
if( lastc == '\\' )
|
||||
ReadChar();
|
||||
|
||||
value += lastc;
|
||||
ReadChar();
|
||||
}
|
||||
|
||||
if( lastc != '"' )
|
||||
return false;
|
||||
|
||||
ReadChar(); // skipping the last quote
|
||||
|
||||
SkipWhite();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool ConfParser::ReadValueSimple()
|
||||
{
|
||||
while( IsValueSimpleChar(lastc) )
|
||||
{
|
||||
value += lastc;
|
||||
ReadChar();
|
||||
}
|
||||
|
||||
SkipWhite();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int ConfParser::ReadChar()
|
||||
{
|
||||
lastc = file.get();
|
||||
|
||||
if( lastc == '\n' )
|
||||
++line;
|
||||
|
||||
return lastc;
|
||||
}
|
||||
|
||||
|
||||
bool ConfParser::IsWhite(int c)
|
||||
{
|
||||
if( c==' ' || c=='\t' || c==13 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ConfParser::SkipWhite()
|
||||
{
|
||||
while( IsWhite(lastc) )
|
||||
ReadChar();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ConfParser::SkipLine()
|
||||
{
|
||||
while( lastc != -1 && lastc != '\n' )
|
||||
ReadChar();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfileconfparser
|
||||
#define headerfileconfparser
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
|
||||
class ConfParser
|
||||
{
|
||||
public:
|
||||
|
||||
enum Status { ok, cant_open_file, syntax_error };
|
||||
|
||||
ConfParser();
|
||||
Status Parse(const char * file_name);
|
||||
|
||||
|
||||
// last status
|
||||
Status status;
|
||||
|
||||
// line in which there is a syntax_error
|
||||
int line;
|
||||
|
||||
typedef std::map<std::string, std::string> Table;
|
||||
Table table;
|
||||
|
||||
private:
|
||||
|
||||
// last read variable, value
|
||||
std::string variable, value;
|
||||
|
||||
// separator between a variable and a value, usually '='
|
||||
int separator;
|
||||
|
||||
// commentary char
|
||||
int commentary;
|
||||
|
||||
// last read char
|
||||
int lastc;
|
||||
|
||||
// current file
|
||||
std::ifstream file;
|
||||
|
||||
|
||||
Status ParseFile();
|
||||
|
||||
bool IsVariableChar(int c);
|
||||
bool IsValueSimpleChar(int c);
|
||||
|
||||
bool ReadVariable();
|
||||
bool ReadValue();
|
||||
bool ReadValueQuoted();
|
||||
bool ReadValueSimple();
|
||||
|
||||
int ReadChar();
|
||||
bool IsWhite(int c);
|
||||
void SkipWhite();
|
||||
void SkipLine();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,131 +0,0 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
cat.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
cat.o: ../templates/patterncacher.h ../app/templates.h ../core/thread.h
|
||||
cat.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
cat.o: ../core/done.h ../core/item.h ../core/error.h ../core/log.h
|
||||
cat.o: ../core/user.h ../core/function.h ../core/thread.h ../core/compress.h
|
||||
cat.o: ../core/error.h
|
||||
content.o: content.h ../core/item.h ../templates/templates.h
|
||||
content.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
||||
content.o: ../app/templates.h ../core/thread.h ../core/request.h
|
||||
content.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
content.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h
|
||||
content.o: ../core/function.h ../core/thread.h ../core/compress.h
|
||||
content.o: ../core/error.h ../core/db.h ../core/group.h
|
||||
content.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/data.h
|
||||
content.o: ../core/dirs.h ../core/users.h ../core/groups.h
|
||||
content.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
|
||||
content.o: ../core/mount.h ../app/content.h ../core/misc.h
|
||||
createthread.o: content.h ../core/item.h ../templates/templates.h
|
||||
createthread.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
||||
createthread.o: ../app/templates.h ../core/thread.h ../core/request.h
|
||||
createthread.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
createthread.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h
|
||||
createthread.o: ../core/function.h ../core/thread.h ../core/compress.h
|
||||
createthread.o: ../core/error.h ../core/db.h ../core/group.h
|
||||
createthread.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/mount.h
|
||||
createthread.o: ../core/data.h ../core/dirs.h ../core/users.h
|
||||
createthread.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
|
||||
createthread.o: ../core/mounts.h ../core/mount.h
|
||||
default.o: content.h ../core/item.h ../templates/templates.h
|
||||
default.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
||||
default.o: ../app/templates.h ../core/thread.h ../core/request.h
|
||||
default.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
default.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h
|
||||
default.o: ../core/function.h ../core/thread.h ../core/compress.h
|
||||
default.o: ../core/error.h ../core/db.h ../core/group.h
|
||||
default.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/data.h
|
||||
default.o: ../core/dirs.h ../core/users.h ../core/groups.h
|
||||
default.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
|
||||
default.o: ../core/mount.h
|
||||
emacs.o: content.h ../core/item.h ../templates/templates.h
|
||||
emacs.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../app/templates.h
|
||||
emacs.o: ../core/thread.h ../core/request.h ../core/requesttypes.h
|
||||
emacs.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
|
||||
emacs.o: ../core/log.h ../core/user.h ../core/function.h ../core/thread.h
|
||||
emacs.o: ../core/compress.h ../core/error.h ../core/db.h ../core/group.h
|
||||
emacs.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/data.h
|
||||
emacs.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h
|
||||
emacs.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
emacs.o: ../core/notify.h ../templatesnotify/templatesnotify.h
|
||||
emacs.o: ../core/mount.h
|
||||
last.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
last.o: ../templates/patterncacher.h ../app/templates.h ../core/thread.h
|
||||
login.o: content.h ../core/item.h ../templates/templates.h
|
||||
login.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../app/templates.h
|
||||
login.o: ../core/thread.h ../core/request.h ../core/requesttypes.h
|
||||
login.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
|
||||
login.o: ../core/log.h ../core/user.h ../core/function.h ../core/thread.h
|
||||
login.o: ../core/compress.h ../core/error.h ../core/db.h ../core/group.h
|
||||
login.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/data.h
|
||||
login.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h
|
||||
login.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
logout.o: content.h ../core/item.h ../templates/templates.h
|
||||
logout.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../app/templates.h
|
||||
logout.o: ../core/thread.h ../core/request.h ../core/requesttypes.h
|
||||
logout.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
|
||||
logout.o: ../core/log.h ../core/user.h ../core/function.h ../core/thread.h
|
||||
logout.o: ../core/compress.h ../core/data.h ../core/dirs.h
|
||||
logout.o: ../core/dircontainer.h ../core/users.h ../core/ugcontainer.h
|
||||
logout.o: ../core/groups.h ../core/group.h ../core/functions.h
|
||||
logout.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
ls.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
ls.o: ../templates/patterncacher.h ../app/templates.h ../core/thread.h
|
||||
ls.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
ls.o: ../core/done.h ../core/item.h ../core/error.h ../core/log.h
|
||||
ls.o: ../core/user.h ../core/function.h ../core/thread.h ../core/compress.h
|
||||
ls.o: ../core/db.h ../core/group.h ../core/dircontainer.h
|
||||
ls.o: ../core/ugcontainer.h
|
||||
mkdir.o: content.h ../core/item.h ../templates/templates.h
|
||||
mkdir.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../app/templates.h
|
||||
mkdir.o: ../core/thread.h ../core/request.h ../core/requesttypes.h
|
||||
mkdir.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
|
||||
mkdir.o: ../core/log.h ../core/user.h ../core/function.h ../core/thread.h
|
||||
mkdir.o: ../core/compress.h ../core/error.h ../core/db.h ../core/group.h
|
||||
mkdir.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/data.h
|
||||
mkdir.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h
|
||||
mkdir.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
mkdir.o: ../core/notify.h ../templatesnotify/templatesnotify.h
|
||||
mkdir.o: ../core/mount.h
|
||||
node.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
node.o: ../templates/patterncacher.h ../app/templates.h ../core/thread.h
|
||||
node.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
node.o: ../core/done.h ../core/item.h ../core/error.h ../core/log.h
|
||||
node.o: ../core/user.h ../core/function.h ../core/thread.h ../core/compress.h
|
||||
priv.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
priv.o: ../templates/patterncacher.h ../app/templates.h ../core/thread.h
|
||||
priv.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
priv.o: ../core/done.h ../core/item.h ../core/error.h ../core/log.h
|
||||
priv.o: ../core/user.h ../core/function.h ../core/thread.h ../core/compress.h
|
||||
priv.o: ../core/error.h ../core/db.h ../core/group.h ../core/dircontainer.h
|
||||
priv.o: ../core/ugcontainer.h ../core/data.h ../core/dirs.h ../core/users.h
|
||||
priv.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
|
||||
priv.o: ../core/mounts.h ../core/mount.h
|
||||
rm.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
rm.o: ../templates/patterncacher.h ../app/templates.h ../core/thread.h
|
||||
rm.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
rm.o: ../core/done.h ../core/item.h ../core/error.h ../core/log.h
|
||||
rm.o: ../core/user.h ../core/function.h ../core/thread.h ../core/compress.h
|
||||
rm.o: ../core/error.h ../core/db.h ../core/group.h ../core/dircontainer.h
|
||||
rm.o: ../core/ugcontainer.h ../core/data.h ../core/dirs.h ../core/users.h
|
||||
rm.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
|
||||
rm.o: ../core/mounts.h ../core/mount.h
|
||||
run.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
run.o: ../templates/patterncacher.h ../app/templates.h ../core/thread.h
|
||||
run.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
run.o: ../core/done.h ../core/item.h ../core/error.h ../core/log.h
|
||||
run.o: ../core/user.h ../core/function.h ../core/thread.h ../core/compress.h
|
||||
run.o: ../core/error.h
|
||||
thread.o: content.h ../core/item.h ../templates/templates.h
|
||||
thread.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../app/templates.h
|
||||
thread.o: ../core/thread.h ../core/request.h ../core/requesttypes.h
|
||||
thread.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
|
||||
thread.o: ../core/log.h ../core/user.h ../core/function.h ../core/thread.h
|
||||
thread.o: ../core/compress.h ../core/db.h ../core/group.h
|
||||
thread.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/data.h
|
||||
thread.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h
|
||||
thread.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
thread.o: ../core/mount.h
|
||||
who.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
||||
who.o: ../templates/patterncacher.h ../app/templates.h ../core/thread.h
|
||||
@@ -1 +0,0 @@
|
||||
o = cat.o content.o createthread.o default.o emacs.o last.o login.o logout.o ls.o mkdir.o node.o priv.o rm.o run.o thread.o who.o
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/error.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunCat()
|
||||
{
|
||||
if( !request.is_item )
|
||||
{
|
||||
log << log1 << "Content: Cat function requires an item" << logend;
|
||||
request.status = Error::item_required;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( !request.HasReadAccess(request.item) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,373 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/error.h"
|
||||
#include "../core/db.h"
|
||||
#include "../core/data.h"
|
||||
#include "../app/content.h"
|
||||
#include "../core/misc.h"
|
||||
|
||||
|
||||
bool Content::Init()
|
||||
{
|
||||
templates.Read();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool Content::DirsHaveReadExecPerm()
|
||||
{
|
||||
std::vector<Item*>::iterator i;
|
||||
|
||||
for(i = request.dir_table.begin() ; i!=request.dir_table.end() ; ++i)
|
||||
{
|
||||
if( !request.HasReadExecAccess(**i) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Content::SetDefaultFunctionForFile()
|
||||
{
|
||||
if( request.HasReadExecAccess(request.item) )
|
||||
request.pfunction = data.functions.GetFunction(FUN_RUN);
|
||||
else
|
||||
request.pfunction = data.functions.GetFunction(FUN_CAT);
|
||||
|
||||
if( request.pfunction )
|
||||
log << log3 << "Content: default function: " << request.pfunction->item.url << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::SetDefaultFunctionForDir()
|
||||
{
|
||||
long default_item = request.dir_table.back()->default_item;
|
||||
|
||||
if( default_item != -1 )
|
||||
{
|
||||
request.session->IncrementTimersIfExist();
|
||||
|
||||
log << log3 << "Content: Default item: id: " << default_item << logend;
|
||||
RedirectTo(default_item);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( data.mounts.CurrentMountType() == Mount::thread )
|
||||
{
|
||||
request.pfunction = data.functions.GetFunction(FUN_THREAD);
|
||||
|
||||
if( request.pfunction )
|
||||
log << log3 << "Content: default function: " << request.pfunction->item.url << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
// cms
|
||||
request.pfunction = data.functions.GetFunction(FUN_LS);
|
||||
|
||||
if( request.pfunction )
|
||||
log << log3 << "Content: default function: " << request.pfunction->item.url << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Content::SetDefaultFunction()
|
||||
{
|
||||
if( request.is_item )
|
||||
{
|
||||
SetDefaultFunctionForFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDefaultFunctionForDir();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::MakeStandardFunction()
|
||||
{
|
||||
if( !request.pfunction )
|
||||
SetDefaultFunction();
|
||||
|
||||
if( request.result == Request::redirect )
|
||||
return;
|
||||
|
||||
|
||||
if( !request.pfunction )
|
||||
{
|
||||
log << log1 << "Content: no function (neither cat nor ls)" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( request.pfunction->code == FUN_LOGOUT )
|
||||
FunLogout();
|
||||
else
|
||||
if( request.pfunction->code == FUN_CAT )
|
||||
FunCat();
|
||||
else
|
||||
if( request.pfunction->code == FUN_LS )
|
||||
FunLs();
|
||||
else
|
||||
if( request.pfunction->code == FUN_EMACS )
|
||||
FunEmacs();
|
||||
else
|
||||
if( request.pfunction->code == FUN_MKDIR )
|
||||
FunMkdir();
|
||||
else
|
||||
if( request.pfunction->code == FUN_DEFAULT )
|
||||
FunDefault();
|
||||
else
|
||||
if( request.pfunction->code == FUN_PRIV )
|
||||
FunPriv();
|
||||
else
|
||||
if( request.pfunction->code == FUN_RM )
|
||||
FunRm();
|
||||
else
|
||||
if( request.pfunction->code == FUN_RUN )
|
||||
FunRun();
|
||||
else
|
||||
if( request.pfunction->code == FUN_NODE )
|
||||
FunNode();
|
||||
else
|
||||
if( request.pfunction->code == FUN_WHO )
|
||||
FunWho();
|
||||
else
|
||||
if( request.pfunction->code == FUN_LAST )
|
||||
FunLast();
|
||||
else
|
||||
if( request.pfunction->code == FUN_THREAD )
|
||||
FunThread();
|
||||
else
|
||||
if( request.pfunction->code == FUN_CREATETHREAD )
|
||||
FunCreateThread();
|
||||
else
|
||||
request.status = Error::permision_denied;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::MakePost()
|
||||
{
|
||||
if( !request.pfunction )
|
||||
SetDefaultFunction();
|
||||
|
||||
if( !request.pfunction )
|
||||
{
|
||||
log << log1 << "Content: MakePost: no function" << logend;
|
||||
request.status = Error::no_function;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch( request.pfunction->code )
|
||||
{
|
||||
case FUN_EMACS:
|
||||
PostFunEmacs();
|
||||
break;
|
||||
|
||||
case FUN_MKDIR:
|
||||
PostFunMkdir();
|
||||
break;
|
||||
|
||||
case FUN_DEFAULT:
|
||||
PostFunDefault();
|
||||
break;
|
||||
|
||||
case FUN_PRIV:
|
||||
PostFunPriv();
|
||||
break;
|
||||
|
||||
case FUN_LOGIN:
|
||||
PostFunLogin();
|
||||
break;
|
||||
|
||||
case FUN_CREATETHREAD:
|
||||
PostFunCreateThread();
|
||||
break;
|
||||
|
||||
default:
|
||||
log << log1 << "Content: unknown post function" << logend;
|
||||
// !! moze daj tutaj tez access denied?
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Content::Make()
|
||||
{
|
||||
if( request.dir_table.empty() )
|
||||
{
|
||||
log << log1 << "Content: there is no a root dir (dir_table is empty)" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
// request.status can be changed by function_parser
|
||||
if( request.status == Error::ok )
|
||||
{
|
||||
if( DirsHaveReadExecPerm() )
|
||||
{
|
||||
#ifdef APPPREPARE
|
||||
AppContent::PrepareApp();
|
||||
#endif
|
||||
|
||||
if( request.method == Request::post )
|
||||
MakePost();
|
||||
|
||||
if( request.result == Request::redirect )
|
||||
return;
|
||||
|
||||
if( request.status == Error::ok )
|
||||
MakeStandardFunction();
|
||||
}
|
||||
else
|
||||
request.status = Error::permision_denied;
|
||||
}
|
||||
|
||||
if( request.result == Request::redirect )
|
||||
return;
|
||||
|
||||
|
||||
if( request.dir_table.empty() )
|
||||
{
|
||||
log << log1 << "Content: there is no a root dir (dir_table is empty -- after calling some standard functions)" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
templates.Generate();
|
||||
|
||||
|
||||
//request.PrintGetTable();
|
||||
//request.PrintEnv();
|
||||
//request.PrintIn();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// !! mozna zrobic jakas obsluge kiedy nie mozemy sie redirectnac, np gdy wystapil blad
|
||||
// !! moze zwracac jakas wartosc?
|
||||
void Content::RedirectTo(const Item & item)
|
||||
{
|
||||
std::string path;
|
||||
|
||||
request.result = Request::redirect;
|
||||
request.str = data.base_url;
|
||||
|
||||
|
||||
if( item.type == Item::dir )
|
||||
{
|
||||
// item_id is pointing to a directory
|
||||
data.dirs.MakePath(item.id, path);
|
||||
request.str += path;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !data.dirs.MakePath(item.parent_id, path) )
|
||||
log << log1 << "Content: Can't redirect: no dirs for item id: " << item.id << logend;
|
||||
|
||||
request.str += path;
|
||||
request.str += item.url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Content::RedirectTo(long item_id)
|
||||
{
|
||||
std::string path;
|
||||
Item * pdir;
|
||||
|
||||
request.result = Request::redirect;
|
||||
request.str = data.base_url;
|
||||
pdir = data.dirs.GetDir(item_id);
|
||||
|
||||
|
||||
if( pdir )
|
||||
{
|
||||
// item_id is pointing to a directory
|
||||
data.dirs.MakePath(pdir->id, path);
|
||||
request.str += path;
|
||||
}
|
||||
else
|
||||
{
|
||||
// !! zrobic nowy interfejs
|
||||
// !! GetItem pozamieniac na GetFile
|
||||
db.GetItem(request.item_table, item_id);
|
||||
|
||||
if( !request.item_table.empty() )
|
||||
{
|
||||
if( !data.dirs.MakePath(request.item_table[0].parent_id, path) )
|
||||
log << log1 << "Content: Can't redirect: no dirs for item id: " << request.item_table[0].id << ", requested directory id: " << request.item_table[0].parent_id << logend;
|
||||
|
||||
request.str += path + request.item_table[0].url;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: Can't redirect: no such item: id: " << item_id << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Content::ReadAdditionalInfo()
|
||||
{
|
||||
if( request.dir_table.empty() )
|
||||
return;
|
||||
|
||||
if( data.mounts.CurrentMountType() == Mount::thread )
|
||||
{
|
||||
if( db.GetThreadByDirId(request.dir_table.back()->id, request.thread) == Error::ok )
|
||||
request.is_thread = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Content::PrepareUrl(Item & item)
|
||||
{
|
||||
TrimWhite(item.url);
|
||||
|
||||
if( item.url.empty() )
|
||||
item.url = item.subject; // if the subject is empty then the url will be corrected by CorrectUrl()
|
||||
|
||||
CorrectUrl(item);
|
||||
|
||||
if( data.functions.GetFunction(item.url) )
|
||||
{
|
||||
// the name provided by an user is the same as a name of a function
|
||||
// we add one underscore character at the beginning
|
||||
|
||||
// names of functions should not begin with an underscore '_'
|
||||
// and we can simply add one '_' at the beginning
|
||||
// and the name will be unique
|
||||
item.url.insert(item.url.begin(), '_');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucontentcontent
|
||||
#define headerfilecmslucontentcontent
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fcgiapp.h>
|
||||
#include <ctime>
|
||||
|
||||
#include "../core/item.h"
|
||||
#include "../templates/templates.h"
|
||||
#include "../core/thread.h"
|
||||
|
||||
|
||||
|
||||
class Content
|
||||
{
|
||||
Templates templates;
|
||||
|
||||
|
||||
|
||||
void PrepareUrl(Item & item);
|
||||
|
||||
|
||||
void SetDefaultFunctionForFile();
|
||||
void SetDefaultFunctionForDir();
|
||||
void SetDefaultFunction();
|
||||
bool DirsHaveReadExecPerm();
|
||||
|
||||
void MakeStandardFunction();
|
||||
|
||||
|
||||
|
||||
void MakePost();
|
||||
|
||||
void FunCat();
|
||||
void FunLogout();
|
||||
void FunLs();
|
||||
void FunEmacs();
|
||||
void FunPriv();
|
||||
|
||||
void FunRmDirRecursive();
|
||||
void FunRmDir();
|
||||
void FunRm();
|
||||
|
||||
void FunNode();
|
||||
void FunMkdir();
|
||||
void FunDefault();
|
||||
void FunRun();
|
||||
void FunWho();
|
||||
void FunLast();
|
||||
|
||||
static bool FunThreadSort(const Thread & t1, const Thread & t2);
|
||||
void FunThread();
|
||||
void FunCreateThread();
|
||||
|
||||
void PostFunLogin();
|
||||
void PostFunEmacsAdd();
|
||||
void PostFunEmacsEdit(bool with_url);
|
||||
void PostFunEmacs();
|
||||
void PostFunMkdir(bool add_to_dir_table = false, int mask = 0755 );
|
||||
long PostFunDefaultParsePath();
|
||||
void PostFunDefault();
|
||||
void PostFunPriv();
|
||||
void PostFunPriv(Item & item);
|
||||
|
||||
bool FunCreateThreadCheckAccess();
|
||||
void PostFunCreateThread();
|
||||
|
||||
void RedirectTo(const Item & item);
|
||||
void RedirectTo(long item_id);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
bool Init();
|
||||
|
||||
void ReadAdditionalInfo();
|
||||
void Make();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/error.h"
|
||||
#include "../core/db.h"
|
||||
#include "../core/mount.h"
|
||||
#include "../core/data.h"
|
||||
|
||||
|
||||
bool Content::FunCreateThreadCheckAccess()
|
||||
{
|
||||
if( !request.CanCreateThread() )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Content::PostFunCreateThread()
|
||||
{
|
||||
if( !FunCreateThreadCheckAccess() )
|
||||
return;
|
||||
|
||||
request.post_table.insert( std::make_pair(std::string("url"), std::string()) ); // !! tymczasowo, zrobic aby mkdir i emacs nie rzucaly wyjatkiem gdy nie ma url zdefiniowanego
|
||||
|
||||
request.thread.parent_id = request.dir_table.back()->id;
|
||||
PostFunMkdir(true, 0777); // !! tymczasowo 777 aby wszyscy mogli wysylac posty
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
{
|
||||
PostFunEmacs();
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
{
|
||||
request.thread.dir_id = request.dir_table.back()->id;
|
||||
request.thread.closed = false;
|
||||
request.thread.items = 1;
|
||||
request.thread.last_item = request.item; // set by PostFunEmacs()
|
||||
|
||||
request.session->done_status = db.AddThread(request.thread);
|
||||
}
|
||||
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
{
|
||||
request.session->done = Done::added_thread;
|
||||
RedirectTo(*request.dir_table.back());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunCreateThread()
|
||||
{
|
||||
FunCreateThreadCheckAccess();
|
||||
|
||||
TemplatesFunctions::thread_show_edit_subject_var = true; // !! tymczasowe rozwiazanie
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/error.h"
|
||||
#include "../core/db.h"
|
||||
#include "../core/data.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
long Content::PostFunDefaultParsePath()
|
||||
{
|
||||
Item * pdir, * pdir2;
|
||||
long defaultid = -1;
|
||||
|
||||
std::string & path = request.PostVar("defaultitem");
|
||||
|
||||
|
||||
if( !path.empty() )
|
||||
{
|
||||
std::string dir, file;
|
||||
Dirs::SplitPath(path, dir, file);
|
||||
|
||||
pdir = data.dirs.GetDir(dir);
|
||||
|
||||
if( !pdir )
|
||||
throw Error(Error::incorrect_dir);
|
||||
|
||||
if( file.empty() )
|
||||
{
|
||||
defaultid = pdir->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// checking whether the file is a directory too (the method SplitPath does not check it)
|
||||
pdir2 = data.dirs.GetDir(file, pdir->id);
|
||||
|
||||
if( !pdir2 )
|
||||
{
|
||||
defaultid = db.GetFileId(pdir->id, file);
|
||||
|
||||
if( defaultid == -1 )
|
||||
throw Error(Error::db_no_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
// file is a directory
|
||||
defaultid = pdir2->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return defaultid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::PostFunDefault()
|
||||
{
|
||||
request.session->done = Done::defaulted_dir;
|
||||
|
||||
|
||||
if( !request.HasWriteAccess(*request.dir_table.back()) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
long defaultid = PostFunDefaultParsePath();
|
||||
request.session->done_status = db.EditDefaultItem(request.dir_table.back()->id, defaultid);
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
request.dir_table.back()->default_item = defaultid;
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
request.session->done_status = e;
|
||||
}
|
||||
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
RedirectTo(*request.dir_table.back());
|
||||
else
|
||||
log << log1 << "Content: PostFunDefaultItem: Error: " << request.session->done_status << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunDefault()
|
||||
{
|
||||
if( !request.HasWriteAccess(*request.dir_table.back()) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/error.h"
|
||||
#include "../core/db.h"
|
||||
#include "../core/data.h"
|
||||
#include "../core/notify.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::PostFunEmacsAdd()
|
||||
{
|
||||
request.session->done = Done::added_item;
|
||||
|
||||
request.is_item = true;
|
||||
|
||||
if( request.session->puser )
|
||||
{
|
||||
request.item.user_id = request.session->puser->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
request.item.user_id = -1;
|
||||
request.item.guest_name = request.PostVar("guestname");
|
||||
}
|
||||
|
||||
request.item.group_id = -1;
|
||||
request.item.privileges = 0644; // !! tymczasowo, bedzie uzyte umask
|
||||
request.item.parent_id = request.dir_table.back()->id;
|
||||
request.item.type = Item::file;
|
||||
request.item.content_type = 1;// !! tymczasowo formatted text
|
||||
|
||||
// dates (creation and modification) is set by request.item.Clear() at the beginning
|
||||
|
||||
if( !request.CanUseEmacs(*request.dir_table.back() ) )
|
||||
throw Error(Error::permision_denied);
|
||||
|
||||
request.session->done_status = db.AddItem(request.item);
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
{
|
||||
request.notify_code |= CMSLU_NOTIFY_ITEM_ADD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Content::PostFunEmacsEdit(bool with_url)
|
||||
{
|
||||
request.session->done = Done::edited_item;
|
||||
|
||||
if( !request.CanUseEmacs(request.item) )
|
||||
throw Error(Error::permision_denied);
|
||||
|
||||
time_t t = std::time(0);
|
||||
request.item.date_modification = *std::localtime( &t );
|
||||
|
||||
request.session->done_status = db.EditItemById(request.item, with_url);
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
{
|
||||
TemplatesFunctions::pattern_cacher.UpdatePattern(request.item);
|
||||
|
||||
request.notify_code |= CMSLU_NOTIFY_ITEM_EDIT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Content::PostFunEmacs()
|
||||
{
|
||||
bool adding = true;
|
||||
|
||||
if( request.is_item )
|
||||
adding = false;
|
||||
|
||||
try
|
||||
{
|
||||
// these old values are ignored (if exists)
|
||||
|
||||
//!! tymczasowo, zabezpieczenie przed pustym url-em
|
||||
try {
|
||||
request.item.url = request.PostVar("url");
|
||||
request.item.subject = request.PostVar("subject");
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
|
||||
if( request.item.subject.empty() )
|
||||
request.item.subject = request.dir_table.back()->subject;
|
||||
// !! dodac skladanie tytuly z ostatniego katalogu i liczby okreslajacej ile jest elementow w srodku
|
||||
// !! nie bedzie obciazany modul wyszukujacy bardzo
|
||||
////////
|
||||
|
||||
request.item.content = request.PostVar("content");
|
||||
|
||||
bool with_url = false;
|
||||
|
||||
if( !request.is_item || request.PostVar("old_url") != request.item.url )
|
||||
with_url = true;
|
||||
|
||||
PrepareUrl(request.item);
|
||||
|
||||
if( adding )
|
||||
PostFunEmacsAdd();
|
||||
else
|
||||
PostFunEmacsEdit(with_url);
|
||||
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
request.session->done_status = e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
{
|
||||
request.session->item = request.item;
|
||||
|
||||
if( data.mounts.CurrentMountType() == Mount::thread )
|
||||
{
|
||||
if( adding )
|
||||
db.EditThreadAddItem(request.dir_table.back()->id, request.item.id);
|
||||
|
||||
|
||||
// request.session->item = request.item;
|
||||
// request.session->done_timer = 2;
|
||||
RedirectTo(*request.dir_table.back());
|
||||
}
|
||||
else
|
||||
{
|
||||
request.session->item = request.item;
|
||||
request.session->done_timer = 2;
|
||||
RedirectTo(request.item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: PostFunEmacs: Error: " << request.session->done_status << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunEmacs()
|
||||
{
|
||||
if( !request.is_item )
|
||||
{
|
||||
// adding a new item
|
||||
if( !request.CanUseEmacs(*request.dir_table.back()) )
|
||||
request.status = Error::permision_denied;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// editing an existing item
|
||||
if( !request.CanUseEmacs(request.item) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunLast()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/error.h"
|
||||
#include "../core/db.h"
|
||||
#include "../core/data.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void Content::PostFunLoginAddLast()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void Content::PostFunLogin()
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string & login = request.PostVar("login");
|
||||
std::string & pass = request.PostVar("password");
|
||||
long user_id;
|
||||
|
||||
if( db.CheckUser(login, pass, user_id) )
|
||||
{
|
||||
request.session->puser = data.users.GetUser(user_id);
|
||||
|
||||
if( !request.session->puser )
|
||||
{
|
||||
log << log1 << "Content: user: " << login << " is in the database but is not in data.users" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
data.last.UserLogin(user_id, login, inet_addr(request.env_remote_addr), request.session->id);
|
||||
|
||||
log << log2 << "User " << login << " (id: " << user_id << ") logged" << logend;
|
||||
}
|
||||
|
||||
// !! zglosic komunikat o nie poprawnym logowaniu
|
||||
}
|
||||
catch(const Error &)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
if( request.is_item )
|
||||
RedirectTo(request.item);
|
||||
else
|
||||
RedirectTo(*request.dir_table.back());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/data.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunLogout()
|
||||
{
|
||||
if( request.session->puser )
|
||||
{
|
||||
log << log2 << "User: " << request.session->puser->name << ", id: " << request.session->puser->id << " logged out" << logend;
|
||||
|
||||
data.last.UserLogout(request.session->puser->id, request.session->id);
|
||||
|
||||
request.session->puser = 0;
|
||||
}
|
||||
|
||||
request.result = Request::redirect;
|
||||
std::string path;
|
||||
|
||||
data.dirs.MakePath(request.dir_table.back()->id, path);
|
||||
|
||||
request.str = data.base_url + path;
|
||||
|
||||
if( request.is_item )
|
||||
request.str += request.item.url;
|
||||
|
||||
request.session->done = Done::loggedout;
|
||||
request.session->done_timer = 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/db.h"
|
||||
|
||||
|
||||
|
||||
void Content::FunLs()
|
||||
{
|
||||
if( request.is_item )
|
||||
{
|
||||
// we're showing only the item
|
||||
request.item_table.push_back( request.item );
|
||||
return;
|
||||
}
|
||||
|
||||
// we're reading only files here
|
||||
db.GetItems(request.item_table, request.dir_table.back()->id, Item::file, false, false, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/error.h"
|
||||
#include "../core/db.h"
|
||||
#include "../core/data.h"
|
||||
#include "../core/notify.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::PostFunMkdir(bool add_to_dir_table, int mask)
|
||||
{
|
||||
if( !request.CanUseMkdir(*request.dir_table.back()) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
|
||||
Item item;
|
||||
request.session->done = Done::added_dir;
|
||||
|
||||
try
|
||||
{
|
||||
item.type = Item::dir;
|
||||
item.subject = request.PostVar("subject");
|
||||
item.url = request.PostVar("url");
|
||||
item.parent_id = request.dir_table.back()->id;
|
||||
|
||||
if( request.session->puser )
|
||||
{
|
||||
item.user_id = request.session->puser->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.user_id = -1;
|
||||
item.guest_name = request.PostVar("guestname");
|
||||
}
|
||||
|
||||
item.group_id = -1;
|
||||
item.privileges = mask;
|
||||
item.default_item = -1;
|
||||
|
||||
// dates (creation and modification) is set by the Item() constructor
|
||||
|
||||
PrepareUrl(item);
|
||||
|
||||
request.session->done_status = db.AddItem(item);
|
||||
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
request.session->done_status = e;
|
||||
}
|
||||
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
{
|
||||
Item * pdir = data.dirs.AddDir(item);
|
||||
|
||||
if( add_to_dir_table )
|
||||
request.dir_table.push_back(pdir);
|
||||
|
||||
request.session->item = item;
|
||||
request.session->done_timer = 2;
|
||||
request.notify_code |= CMSLU_NOTIFY_DIR_ADD;
|
||||
|
||||
RedirectTo(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: PostFunMkdir: Error: " << request.session->done_status << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunMkdir()
|
||||
{
|
||||
if( !request.CanUseMkdir(*request.dir_table.back()) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunNode()
|
||||
{
|
||||
if( request.param_table.empty() )
|
||||
{
|
||||
//request.status = Error
|
||||
//!!zglosic 404
|
||||
return;
|
||||
}
|
||||
|
||||
long id = atol( request.param_table[0]->c_str() );
|
||||
|
||||
RedirectTo(id);
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/error.h"
|
||||
#include "../core/db.h"
|
||||
#include "../core/data.h"
|
||||
|
||||
|
||||
void Content::PostFunPriv(Item & item)
|
||||
{
|
||||
try
|
||||
{
|
||||
long user_id = data.users.GetUserId( request.PostVar("user") );
|
||||
long group_id = data.groups.GetGroupId( request.PostVar("group") );
|
||||
int privileges = strtol( request.PostVar("privileges").c_str() , 0, 8);
|
||||
|
||||
if( user_id==item.user_id && group_id==item.group_id && privileges==item.privileges )
|
||||
{
|
||||
log << log3 << "Content: PostFunPriv: nothing to change" << logend;
|
||||
throw Error(Error::ok);
|
||||
}
|
||||
|
||||
if( !request.CanChangeUser(item, user_id) )
|
||||
throw Error(Error::cant_change_user);
|
||||
|
||||
if( !request.CanChangeGroup(item, group_id) )
|
||||
throw Error(Error::cant_change_group);
|
||||
|
||||
if( !request.CanChangePrivileges(item, privileges) )
|
||||
throw Error(Error::cant_change_privileges);
|
||||
|
||||
item.user_id = user_id;
|
||||
item.group_id = group_id;
|
||||
item.privileges = privileges;
|
||||
|
||||
request.session->done = Done::privileged_item;
|
||||
request.session->done_status = db.EditPrivById(item, item.id);
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
request.session->done_status = e;
|
||||
}
|
||||
|
||||
if( request.session->done_status == Error::ok )
|
||||
{
|
||||
request.session->item = item;
|
||||
request.session->done_timer = 2;
|
||||
RedirectTo(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: PostFunPriv: Error: " << static_cast<int>(request.session->done_status) << logend;
|
||||
}
|
||||
|
||||
request.status = request.session->done_status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::PostFunPriv()
|
||||
{
|
||||
if( request.is_item )
|
||||
PostFunPriv( request.item );
|
||||
else
|
||||
PostFunPriv( *request.dir_table.back() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Content::FunPriv()
|
||||
{
|
||||
// we do not check permissions here
|
||||
// permissions depends on the user, group, and privileges
|
||||
}
|
||||
124
content/rm.cpp
124
content/rm.cpp
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/error.h"
|
||||
#include "../core/db.h"
|
||||
#include "../core/data.h"
|
||||
|
||||
|
||||
|
||||
void Content::FunRmDirRecursive()
|
||||
{
|
||||
data.dirs.MakePath(request.dir_table.back()->id, request.session->dir_old);
|
||||
|
||||
// this method deletes recursively all directories
|
||||
data.dirs.DeleteDir(request.dir_table.back()->id);
|
||||
|
||||
request.dir_table.erase(--request.dir_table.end());
|
||||
|
||||
if( request.dir_table.empty() )
|
||||
{
|
||||
// we have deleted the root directory
|
||||
|
||||
data.dirs.CheckRootDir();
|
||||
|
||||
Item * proot = data.dirs.GetRootDir();
|
||||
|
||||
if( proot )
|
||||
request.dir_table.push_back(proot);
|
||||
else
|
||||
// there is no a root dir
|
||||
// CheckRootDir() didn't add the root dir (probably problem with the database)
|
||||
// make sure that Content::Make() will check that the dir_table is empty and returns
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
request.session->done = Done::deleted_dir;
|
||||
request.session->done_status = Error::ok;
|
||||
request.session->done_timer = 2;
|
||||
|
||||
// redirect to the last valid directory
|
||||
RedirectTo(**(--request.dir_table.end()));
|
||||
}
|
||||
|
||||
|
||||
void Content::FunRmDir()
|
||||
{
|
||||
if( !request.CanRemove(*request.dir_table.back()) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
|
||||
if( request.param_table.empty() )
|
||||
request.status = Error::permision_denied;
|
||||
else
|
||||
if( request.IsParam("confirm") )
|
||||
return;
|
||||
else
|
||||
if( request.IsParam("r") )
|
||||
FunRmDirRecursive();
|
||||
else
|
||||
request.status = Error::unknown_param;
|
||||
}
|
||||
|
||||
|
||||
void Content::FunRm()
|
||||
{
|
||||
if( !request.is_item )
|
||||
{
|
||||
FunRmDir();
|
||||
return;
|
||||
}
|
||||
|
||||
if( !request.CanRemove(request.item) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( request.param_table.empty() )
|
||||
{
|
||||
// we'll put some information about the deleted item (on the next page)
|
||||
request.session->item = request.item;
|
||||
|
||||
// !! zmienic interfejs dla db.DelItem
|
||||
if( db.DelItem( request.item ) )
|
||||
{
|
||||
request.session->done_status = Error::ok;
|
||||
log << log2 << "Content: deleted item: subject: " << request.item.subject << ", id: " << request.item.id << logend;
|
||||
TemplatesFunctions::pattern_cacher.DeletePattern(request.item);
|
||||
|
||||
if( data.mounts.CurrentMountType() == Mount::thread )
|
||||
db.EditThreadRemoveItem(request.item.parent_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
request.session->done_status = Error::db_no_item;
|
||||
}
|
||||
|
||||
request.session->done = Done::deleted_item;
|
||||
|
||||
RedirectTo(*request.dir_table.back());
|
||||
request.session->done_timer = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !request.IsParam("confirm") )
|
||||
//request.result = Request::err404;
|
||||
request.status = Error::unknown_param;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/error.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunRun()
|
||||
{
|
||||
if( !request.is_item )
|
||||
{
|
||||
log << log1 << "Content: Run function requires an item" << logend;
|
||||
request.status = Error::item_required;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !request.HasReadExecAccess(request.item) )
|
||||
{
|
||||
request.status = Error::permision_denied;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/db.h"
|
||||
#include "../core/data.h"
|
||||
#include "../core/mount.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
bool Content::FunThreadSort(const Thread & t1, const Thread & t2)
|
||||
{
|
||||
Item * pdir1 = data.dirs.GetDir(t1.dir_id);
|
||||
Item * pdir2 = data.dirs.GetDir(t2.dir_id);
|
||||
|
||||
if( !pdir1 || !pdir2 )
|
||||
return false;
|
||||
|
||||
time_t time1 = mktime(&pdir1->date_creation);
|
||||
time_t time2 = mktime(&pdir2->date_creation);
|
||||
|
||||
return time1 > time2;
|
||||
}
|
||||
|
||||
|
||||
void Content::FunThread()
|
||||
{
|
||||
bool asc = true;
|
||||
|
||||
if( data.mounts.CurrentMountIsParam(Mount::desc) )
|
||||
asc = false;
|
||||
|
||||
db.GetItems(request.item_table, request.dir_table.back()->id, Item::file, true, true, asc);
|
||||
db.GetThreads(request.dir_table.back()->id, request.thread_tab);
|
||||
|
||||
std::sort(request.thread_tab.begin(), request.thread_tab.end(), FunThreadSort);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "content.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Content::FunWho()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,15 +4,12 @@ include Makefile.o.dep
|
||||
all: $(o)
|
||||
|
||||
|
||||
.SUFFIXES: .cpp .o
|
||||
|
||||
.cpp.o:
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend $(DEPMACROS) -Y. -f- *.cpp > Makefile.dep
|
||||
makedepend -Y. -I.. -I../../ezc/src -I../../pikotools -I../../tito/src -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
|
||||
|
||||
|
||||
@@ -1,83 +1,883 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
compress.o: compress.h log.h
|
||||
config.o: config.h ../confparser/confparser.h log.h data.h dirs.h item.h
|
||||
config.o: dircontainer.h users.h user.h ugcontainer.h groups.h group.h
|
||||
config.o: functions.h function.h lastcontainer.h mounts.h mount.h
|
||||
data.o: data.h dirs.h item.h dircontainer.h users.h user.h ugcontainer.h
|
||||
data.o: log.h groups.h group.h functions.h function.h lastcontainer.h
|
||||
data.o: mounts.h mount.h
|
||||
db.o: db.h item.h user.h group.h thread.h error.h log.h dircontainer.h
|
||||
db.o: ugcontainer.h misc.h
|
||||
db_itemcolumns.o: db.h item.h user.h group.h thread.h error.h log.h
|
||||
db_itemcolumns.o: dircontainer.h ugcontainer.h
|
||||
dircontainer.o: dircontainer.h item.h log.h
|
||||
dirs.o: dirs.h item.h dircontainer.h error.h log.h db.h user.h group.h
|
||||
dirs.o: thread.h ugcontainer.h data.h users.h groups.h functions.h function.h
|
||||
dirs.o: lastcontainer.h mounts.h mount.h
|
||||
done.o: done.h
|
||||
error.o: error.h log.h
|
||||
function.o: function.h item.h
|
||||
functioncodeparser.o: functioncodeparser.h item.h function.h log.h
|
||||
functionparser.o: functionparser.h requesttypes.h ../app/content.h log.h
|
||||
functionparser.o: item.h error.h data.h dirs.h dircontainer.h users.h user.h
|
||||
functionparser.o: ugcontainer.h groups.h group.h functions.h function.h
|
||||
functionparser.o: lastcontainer.h mounts.h mount.h db.h thread.h request.h
|
||||
functionparser.o: session.h done.h compress.h
|
||||
functions.o: functions.h function.h item.h
|
||||
groups.o: groups.h group.h ugcontainer.h log.h db.h item.h user.h thread.h
|
||||
groups.o: error.h dircontainer.h
|
||||
acceptbaseparser.o: acceptbaseparser.h
|
||||
app.o: app.h config.h ../../pikotools/space/spaceparser.h
|
||||
app.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
app.o: htmlfilter.h system.h job.h basethread.h synchro.h
|
||||
app.o: ../../pikotools/space/space.h dirs.h item.h
|
||||
app.o: ../../pikotools/date/date.h dircontainer.h ../db/db.h ../db/dbbase.h
|
||||
app.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h misc.h
|
||||
app.o: requesttypes.h ../../pikotools/textstream/textstream.h
|
||||
app.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
app.o: ../../pikotools/membuffer/membuffer.h
|
||||
app.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
app.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
|
||||
app.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
app.o: ../core/dircontainer.h ../core/ugcontainer.h log.h textstream.h
|
||||
app.o: logmanipulators.h slog.h cur.h request.h error.h
|
||||
app.o: ../templates/htmltextstream.h ../../pikotools/space/spacetojson.h
|
||||
app.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
app.o: ../templates/locale.h ../notify/notify.h ../notify/notifypool.h
|
||||
app.o: ../templates/patterns.h ../templates/locale.h
|
||||
app.o: ../templates/localefilter.h ../../ezc/src/ezc.h
|
||||
app.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
app.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
app.o: ../../ezc/src/stringconv.h ../notify/notifythread.h
|
||||
app.o: ../core/basethread.h ../notify/templatesnotify.h ../core/config.h
|
||||
app.o: ../core/users.h ugcontainer.h lastcontainer.h mounts.h mountparser.h
|
||||
app.o: crypt.h run.h users.h groups.h group.h loadavg.h image.h
|
||||
app.o: threadmanager.h timezones.h timezone.h sessionmanager.h
|
||||
app.o: sessioncontainer.h ipbancontainer.h ../functions/functions.h
|
||||
app.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
app.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
app.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
app.o: ../functions/privchanger.h ../functions/chown.h
|
||||
app.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
|
||||
app.o: ../functions/download.h ../functions/emacs.h ../functions/env.h
|
||||
app.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
app.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
app.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
app.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
app.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
app.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
app.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
app.o: ../functions/subject.h ../functions/template.h ../functions/tinymce.h
|
||||
app.o: ../functions/uname.h ../functions/upload.h ../functions/uptime.h
|
||||
app.o: ../functions/who.h ../functions/vim.h ../core/htmlfilter.h
|
||||
app.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
app.o: ../templates/indexpatterns.h ../templates/patterns.h
|
||||
app.o: ../templates/changepatterns.h ../templates/htmltextstream.h
|
||||
app.o: ../core/sessionmanager.h compress.h postparser.h httpsimpleparser.h
|
||||
app.o: plugin.h pluginmsg.h cookieparser.h postmultiparser.h
|
||||
app.o: acceptencodingparser.h acceptbaseparser.h
|
||||
basethread.o: basethread.h synchro.h
|
||||
bbcodeparser.o: bbcodeparser.h htmlfilter.h
|
||||
compress.o: compress.h requesttypes.h ../../pikotools/textstream/textstream.h
|
||||
compress.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
compress.o: ../../pikotools/convert/convert.h
|
||||
compress.o: ../../pikotools/convert/inttostr.h
|
||||
compress.o: ../../pikotools/membuffer/membuffer.h
|
||||
compress.o: ../../pikotools/textstream/types.h log.h textstream.h
|
||||
compress.o: logmanipulators.h slog.h cur.h request.h item.h error.h config.h
|
||||
compress.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
compress.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
compress.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
compress.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
compress.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
compress.o: ../templates/locale.h
|
||||
config.o: config.h ../../pikotools/space/spaceparser.h
|
||||
config.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
config.o: htmlfilter.h log.h textstream.h logmanipulators.h
|
||||
config.o: ../../pikotools/textstream/textstream.h
|
||||
config.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
config.o: ../../pikotools/convert/convert.h
|
||||
config.o: ../../pikotools/convert/inttostr.h
|
||||
config.o: ../../pikotools/membuffer/membuffer.h
|
||||
config.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
config.o: requesttypes.h item.h error.h ../templates/htmltextstream.h
|
||||
config.o: ../core/textstream.h misc.h ../../pikotools/utf8/utf8.h
|
||||
config.o: ../../pikotools/space/spacetojson.h session.h user.h plugindata.h
|
||||
config.o: rebus.h ipban.h mount.h ../templates/locale.h plugin.h pluginmsg.h
|
||||
config.o: system.h job.h basethread.h synchro.h dirs.h dircontainer.h
|
||||
config.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
config.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
|
||||
config.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
config.o: ../core/dircontainer.h ../core/ugcontainer.h ../notify/notify.h
|
||||
config.o: ../notify/notifypool.h ../templates/patterns.h
|
||||
config.o: ../templates/locale.h ../templates/localefilter.h
|
||||
config.o: ../../ezc/src/ezc.h ../../ezc/src/generator.h
|
||||
config.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
|
||||
config.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
|
||||
config.o: ../notify/notifythread.h ../core/basethread.h
|
||||
config.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
config.o: ugcontainer.h lastcontainer.h mounts.h mountparser.h crypt.h run.h
|
||||
config.o: users.h groups.h group.h loadavg.h image.h threadmanager.h
|
||||
config.o: timezones.h timezone.h sessionmanager.h sessioncontainer.h
|
||||
config.o: ipbancontainer.h ../functions/functions.h
|
||||
config.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
config.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
config.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
config.o: ../functions/privchanger.h ../functions/chown.h
|
||||
config.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
|
||||
config.o: ../functions/download.h ../functions/emacs.h ../functions/env.h
|
||||
config.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
config.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
config.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
config.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
config.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
config.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
config.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
config.o: ../functions/subject.h ../functions/template.h
|
||||
config.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
config.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
config.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
config.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
config.o: ../templates/patterns.h ../templates/changepatterns.h
|
||||
config.o: ../templates/htmltextstream.h ../core/sessionmanager.h
|
||||
crypt.o: crypt.h run.h config.h ../../pikotools/space/spaceparser.h
|
||||
crypt.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
crypt.o: htmlfilter.h user.h ../../pikotools/utf8/utf8.h log.h textstream.h
|
||||
crypt.o: logmanipulators.h ../../pikotools/textstream/textstream.h
|
||||
crypt.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
crypt.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
crypt.o: ../../pikotools/membuffer/membuffer.h
|
||||
crypt.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
crypt.o: requesttypes.h item.h error.h ../templates/htmltextstream.h
|
||||
crypt.o: ../core/textstream.h misc.h ../../pikotools/space/spacetojson.h
|
||||
crypt.o: session.h plugindata.h rebus.h ipban.h mount.h ../templates/locale.h
|
||||
dircontainer.o: dircontainer.h item.h ../../pikotools/space/space.h
|
||||
dircontainer.o: ../../pikotools/date/date.h log.h textstream.h
|
||||
dircontainer.o: logmanipulators.h ../../pikotools/textstream/textstream.h
|
||||
dircontainer.o: ../../pikotools/convert/convert.h
|
||||
dircontainer.o: ../../pikotools/convert/inttostr.h
|
||||
dircontainer.o: ../../pikotools/membuffer/membuffer.h
|
||||
dircontainer.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
dircontainer.o: requesttypes.h error.h config.h
|
||||
dircontainer.o: ../../pikotools/space/spaceparser.h
|
||||
dircontainer.o: ../../pikotools/space/space.h
|
||||
dircontainer.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
dircontainer.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
dircontainer.o: ../../pikotools/utf8/utf8.h
|
||||
dircontainer.o: ../../pikotools/space/spacetojson.h session.h user.h
|
||||
dircontainer.o: plugindata.h rebus.h ipban.h mount.h ../templates/locale.h
|
||||
dirs.o: dirs.h item.h ../../pikotools/space/space.h
|
||||
dirs.o: ../../pikotools/date/date.h dircontainer.h ../db/db.h ../db/dbbase.h
|
||||
dirs.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h misc.h
|
||||
dirs.o: requesttypes.h ../../pikotools/textstream/textstream.h
|
||||
dirs.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
dirs.o: ../../pikotools/membuffer/membuffer.h
|
||||
dirs.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
dirs.o: ../core/error.h ../../pikotools/space/spaceparser.h
|
||||
dirs.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
dirs.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
dirs.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
dirs.o: ../core/ugcontainer.h log.h textstream.h logmanipulators.h slog.h
|
||||
dirs.o: cur.h request.h error.h config.h htmlfilter.h
|
||||
dirs.o: ../templates/htmltextstream.h ../../pikotools/space/spacetojson.h
|
||||
dirs.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
dirs.o: ../templates/locale.h ../notify/notify.h ../notify/notifypool.h
|
||||
dirs.o: ../templates/patterns.h ../templates/locale.h
|
||||
dirs.o: ../templates/localefilter.h ../../ezc/src/ezc.h
|
||||
dirs.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
dirs.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
dirs.o: ../../ezc/src/stringconv.h ../notify/notifythread.h
|
||||
dirs.o: ../core/basethread.h ../notify/templatesnotify.h ../core/config.h
|
||||
dirs.o: ../core/users.h ugcontainer.h lastcontainer.h
|
||||
groups.o: groups.h group.h ugcontainer.h ../db/db.h ../db/dbbase.h
|
||||
groups.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h misc.h
|
||||
groups.o: item.h ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
groups.o: requesttypes.h ../../pikotools/textstream/textstream.h
|
||||
groups.o: ../../pikotools/convert/convert.h
|
||||
groups.o: ../../pikotools/convert/inttostr.h
|
||||
groups.o: ../../pikotools/membuffer/membuffer.h
|
||||
groups.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
groups.o: ../core/error.h ../../pikotools/space/spaceparser.h
|
||||
groups.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
groups.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
groups.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
groups.o: ../core/ugcontainer.h log.h textstream.h logmanipulators.h slog.h
|
||||
groups.o: cur.h request.h error.h config.h htmlfilter.h
|
||||
groups.o: ../templates/htmltextstream.h ../../pikotools/space/spacetojson.h
|
||||
groups.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
groups.o: ../templates/locale.h
|
||||
htmlfilter.o: htmlfilter.h
|
||||
httpsimpleparser.o: httpsimpleparser.h
|
||||
lastcontainer.o: lastcontainer.h log.h
|
||||
log.o: log.h
|
||||
main.o: requestcontroller.h ../content/content.h ../core/item.h
|
||||
main.o: ../templates/templates.h ../../ezc/src/ezc.h
|
||||
main.o: ../templates/patterncacher.h ../app/templates.h ../core/thread.h
|
||||
main.o: sessionmanager.h sessioncontainer.h session.h done.h item.h error.h
|
||||
main.o: log.h user.h functionparser.h requesttypes.h ../app/content.h data.h
|
||||
main.o: dirs.h dircontainer.h users.h ugcontainer.h groups.h group.h
|
||||
main.o: functions.h function.h lastcontainer.h mounts.h mount.h request.h
|
||||
main.o: thread.h compress.h db.h config.h ../confparser/confparser.h notify.h
|
||||
main.o: ../templatesnotify/templatesnotify.h ../core/mount.h
|
||||
misc.o: misc.h item.h log.h
|
||||
mount.o: mount.h
|
||||
mountparser.o: mountparser.h mount.h item.h error.h log.h data.h dirs.h
|
||||
mountparser.o: dircontainer.h users.h user.h ugcontainer.h groups.h group.h
|
||||
mountparser.o: functions.h function.h lastcontainer.h mounts.h
|
||||
mounts.o: mounts.h mount.h data.h dirs.h item.h dircontainer.h users.h user.h
|
||||
mounts.o: ugcontainer.h log.h groups.h group.h functions.h function.h
|
||||
mounts.o: lastcontainer.h request.h requesttypes.h session.h done.h error.h
|
||||
mounts.o: thread.h compress.h mountparser.h
|
||||
notify.o: log.h notify.h ../templatesnotify/templatesnotify.h ../core/mount.h
|
||||
notify.o: ../../ezc/src/ezc.h data.h dirs.h item.h dircontainer.h users.h
|
||||
notify.o: user.h ugcontainer.h groups.h group.h functions.h function.h
|
||||
notify.o: lastcontainer.h mounts.h mount.h misc.h request.h requesttypes.h
|
||||
notify.o: session.h done.h error.h thread.h compress.h
|
||||
request.o: request.h requesttypes.h session.h done.h item.h error.h log.h
|
||||
request.o: user.h function.h thread.h compress.h getparser.h
|
||||
request.o: httpsimpleparser.h postparser.h cookieparser.h data.h dirs.h
|
||||
request.o: dircontainer.h users.h ugcontainer.h groups.h group.h functions.h
|
||||
request.o: lastcontainer.h mounts.h mount.h
|
||||
requestcontroller.o: requestcontroller.h ../content/content.h ../core/item.h
|
||||
requestcontroller.o: ../templates/templates.h ../../ezc/src/ezc.h
|
||||
requestcontroller.o: ../templates/patterncacher.h ../app/templates.h
|
||||
requestcontroller.o: ../core/thread.h sessionmanager.h sessioncontainer.h
|
||||
requestcontroller.o: session.h done.h item.h error.h log.h user.h
|
||||
requestcontroller.o: functionparser.h requesttypes.h ../app/content.h data.h
|
||||
requestcontroller.o: dirs.h dircontainer.h users.h ugcontainer.h groups.h
|
||||
requestcontroller.o: group.h functions.h function.h lastcontainer.h mounts.h
|
||||
requestcontroller.o: mount.h request.h thread.h compress.h postparser.h
|
||||
requestcontroller.o: httpsimpleparser.h cookieparser.h notify.h
|
||||
requestcontroller.o: ../templatesnotify/templatesnotify.h ../core/mount.h
|
||||
session.o: session.h done.h item.h error.h log.h user.h
|
||||
sessioncontainer.o: sessioncontainer.h session.h done.h item.h error.h log.h
|
||||
sessioncontainer.o: user.h data.h dirs.h dircontainer.h users.h ugcontainer.h
|
||||
sessioncontainer.o: groups.h group.h functions.h function.h lastcontainer.h
|
||||
sessioncontainer.o: mounts.h mount.h
|
||||
sessionmanager.o: sessionmanager.h sessioncontainer.h session.h done.h item.h
|
||||
sessionmanager.o: error.h log.h user.h request.h requesttypes.h function.h
|
||||
sessionmanager.o: thread.h compress.h data.h dirs.h dircontainer.h users.h
|
||||
sessionmanager.o: ugcontainer.h groups.h group.h functions.h lastcontainer.h
|
||||
sessionmanager.o: mounts.h mount.h
|
||||
users.o: users.h user.h ugcontainer.h log.h db.h item.h group.h thread.h
|
||||
users.o: error.h dircontainer.h
|
||||
image.o: image.h basethread.h synchro.h textstream.h ../db/db.h
|
||||
image.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
image.o: ../core/textstream.h misc.h item.h ../../pikotools/space/space.h
|
||||
image.o: ../../pikotools/date/date.h requesttypes.h
|
||||
image.o: ../../pikotools/textstream/textstream.h
|
||||
image.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
image.o: ../../pikotools/membuffer/membuffer.h
|
||||
image.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
image.o: ../core/error.h ../../pikotools/space/spaceparser.h
|
||||
image.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
image.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
image.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
image.o: ../core/ugcontainer.h log.h logmanipulators.h slog.h cur.h request.h
|
||||
image.o: error.h config.h htmlfilter.h ../templates/htmltextstream.h
|
||||
image.o: ../../pikotools/space/spacetojson.h session.h user.h plugindata.h
|
||||
image.o: rebus.h ipban.h mount.h ../templates/locale.h ../core/config.h
|
||||
image.o: system.h job.h dirs.h dircontainer.h ../notify/notify.h
|
||||
image.o: ../notify/notifypool.h ../templates/patterns.h ../templates/locale.h
|
||||
image.o: ../templates/localefilter.h ../../ezc/src/ezc.h
|
||||
image.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
image.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
image.o: ../../ezc/src/stringconv.h ../notify/notifythread.h
|
||||
image.o: ../core/basethread.h ../notify/templatesnotify.h ../core/users.h
|
||||
image.o: ugcontainer.h lastcontainer.h mounts.h mountparser.h crypt.h run.h
|
||||
image.o: users.h groups.h group.h loadavg.h threadmanager.h timezones.h
|
||||
image.o: timezone.h plugin.h pluginmsg.h sessionmanager.h sessioncontainer.h
|
||||
image.o: ipbancontainer.h ../functions/functions.h
|
||||
image.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
image.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
image.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
image.o: ../functions/privchanger.h ../functions/chown.h
|
||||
image.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
|
||||
image.o: ../functions/download.h ../functions/emacs.h ../functions/env.h
|
||||
image.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
image.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
image.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
image.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
image.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
image.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
image.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
image.o: ../functions/subject.h ../functions/template.h
|
||||
image.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
image.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
image.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
image.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
image.o: ../templates/patterns.h ../templates/changepatterns.h
|
||||
image.o: ../templates/htmltextstream.h ../core/sessionmanager.h
|
||||
ipbancontainer.o: ipbancontainer.h ipban.h log.h textstream.h
|
||||
ipbancontainer.o: logmanipulators.h ../../pikotools/textstream/textstream.h
|
||||
ipbancontainer.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
ipbancontainer.o: ../../pikotools/convert/convert.h
|
||||
ipbancontainer.o: ../../pikotools/convert/inttostr.h
|
||||
ipbancontainer.o: ../../pikotools/membuffer/membuffer.h
|
||||
ipbancontainer.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
ipbancontainer.o: requesttypes.h item.h error.h config.h
|
||||
ipbancontainer.o: ../../pikotools/space/spaceparser.h
|
||||
ipbancontainer.o: ../../pikotools/space/space.h
|
||||
ipbancontainer.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
ipbancontainer.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
ipbancontainer.o: ../../pikotools/utf8/utf8.h
|
||||
ipbancontainer.o: ../../pikotools/space/spacetojson.h session.h user.h
|
||||
ipbancontainer.o: plugindata.h rebus.h mount.h ../templates/locale.h
|
||||
item.o: item.h ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
item.o: misc.h requesttypes.h ../../pikotools/textstream/textstream.h
|
||||
item.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
item.o: ../../pikotools/membuffer/membuffer.h
|
||||
item.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
item.o: crypt.h run.h config.h ../../pikotools/space/spaceparser.h
|
||||
item.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
item.o: htmlfilter.h user.h
|
||||
job.o: job.h basethread.h synchro.h ../../pikotools/space/space.h plugin.h
|
||||
job.o: pluginmsg.h log.h textstream.h logmanipulators.h
|
||||
job.o: ../../pikotools/textstream/textstream.h ../../pikotools/date/date.h
|
||||
job.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
job.o: ../../pikotools/membuffer/membuffer.h
|
||||
job.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
job.o: requesttypes.h item.h error.h config.h
|
||||
job.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
job.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
job.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
job.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
job.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
job.o: ../templates/locale.h system.h dirs.h dircontainer.h ../db/db.h
|
||||
job.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
|
||||
job.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
job.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
job.o: ../core/ugcontainer.h ../notify/notify.h ../notify/notifypool.h
|
||||
job.o: ../templates/patterns.h ../templates/locale.h
|
||||
job.o: ../templates/localefilter.h ../../ezc/src/ezc.h
|
||||
job.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
job.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
job.o: ../../ezc/src/stringconv.h ../notify/notifythread.h
|
||||
job.o: ../core/basethread.h ../notify/templatesnotify.h ../core/config.h
|
||||
job.o: ../core/users.h ugcontainer.h lastcontainer.h mounts.h mountparser.h
|
||||
job.o: crypt.h run.h users.h groups.h group.h loadavg.h image.h
|
||||
job.o: threadmanager.h timezones.h timezone.h sessionmanager.h
|
||||
job.o: sessioncontainer.h ipbancontainer.h ../functions/functions.h
|
||||
job.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
job.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
job.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
job.o: ../functions/privchanger.h ../functions/chown.h
|
||||
job.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
|
||||
job.o: ../functions/download.h ../functions/emacs.h ../functions/env.h
|
||||
job.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
job.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
job.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
job.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
job.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
job.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
job.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
job.o: ../functions/subject.h ../functions/template.h ../functions/tinymce.h
|
||||
job.o: ../functions/uname.h ../functions/upload.h ../functions/uptime.h
|
||||
job.o: ../functions/who.h ../functions/vim.h ../core/htmlfilter.h
|
||||
job.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
job.o: ../templates/indexpatterns.h ../templates/patterns.h
|
||||
job.o: ../templates/changepatterns.h ../templates/htmltextstream.h
|
||||
job.o: ../core/sessionmanager.h
|
||||
lastcontainer.o: lastcontainer.h ../../pikotools/date/date.h log.h
|
||||
lastcontainer.o: textstream.h logmanipulators.h
|
||||
lastcontainer.o: ../../pikotools/textstream/textstream.h
|
||||
lastcontainer.o: ../../pikotools/space/space.h
|
||||
lastcontainer.o: ../../pikotools/convert/convert.h
|
||||
lastcontainer.o: ../../pikotools/convert/inttostr.h
|
||||
lastcontainer.o: ../../pikotools/membuffer/membuffer.h
|
||||
lastcontainer.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
lastcontainer.o: requesttypes.h item.h error.h config.h
|
||||
lastcontainer.o: ../../pikotools/space/spaceparser.h
|
||||
lastcontainer.o: ../../pikotools/space/space.h
|
||||
lastcontainer.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
lastcontainer.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
lastcontainer.o: ../../pikotools/utf8/utf8.h
|
||||
lastcontainer.o: ../../pikotools/space/spacetojson.h session.h user.h
|
||||
lastcontainer.o: plugindata.h rebus.h ipban.h mount.h ../templates/locale.h
|
||||
loadavg.o: loadavg.h log.h textstream.h logmanipulators.h
|
||||
loadavg.o: ../../pikotools/textstream/textstream.h
|
||||
loadavg.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
loadavg.o: ../../pikotools/convert/convert.h
|
||||
loadavg.o: ../../pikotools/convert/inttostr.h
|
||||
loadavg.o: ../../pikotools/membuffer/membuffer.h
|
||||
loadavg.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
loadavg.o: requesttypes.h item.h error.h config.h
|
||||
loadavg.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
loadavg.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
loadavg.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
loadavg.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
loadavg.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
loadavg.o: ../templates/locale.h
|
||||
lock.o: lock.h synchro.h
|
||||
log.o: log.h textstream.h logmanipulators.h
|
||||
log.o: ../../pikotools/textstream/textstream.h ../../pikotools/space/space.h
|
||||
log.o: ../../pikotools/date/date.h ../../pikotools/convert/convert.h
|
||||
log.o: ../../pikotools/convert/inttostr.h
|
||||
log.o: ../../pikotools/membuffer/membuffer.h
|
||||
log.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
log.o: requesttypes.h item.h error.h config.h
|
||||
log.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
log.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
log.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
log.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
log.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
log.o: ../templates/locale.h timezones.h timezone.h
|
||||
misc.o: misc.h item.h ../../pikotools/space/space.h
|
||||
misc.o: ../../pikotools/date/date.h requesttypes.h
|
||||
misc.o: ../../pikotools/textstream/textstream.h
|
||||
misc.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
misc.o: ../../pikotools/membuffer/membuffer.h
|
||||
misc.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h log.h
|
||||
misc.o: textstream.h logmanipulators.h slog.h cur.h request.h error.h
|
||||
misc.o: config.h ../../pikotools/space/spaceparser.h
|
||||
misc.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
misc.o: htmlfilter.h ../templates/htmltextstream.h ../core/textstream.h
|
||||
misc.o: ../../pikotools/space/spacetojson.h session.h user.h plugindata.h
|
||||
misc.o: rebus.h ipban.h mount.h ../templates/locale.h
|
||||
misc.o: ../templates/templates.h ../../ezc/src/ezc.h
|
||||
misc.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
misc.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
misc.o: ../../ezc/src/stringconv.h ../templates/patterncacher.h
|
||||
misc.o: ../core/item.h ../templates/indexpatterns.h ../templates/patterns.h
|
||||
misc.o: ../templates/locale.h ../templates/changepatterns.h
|
||||
misc.o: ../templates/htmltextstream.h ../templates/localefilter.h
|
||||
misc.o: ../core/config.h ../core/cur.h ../core/system.h
|
||||
misc.o: ../core/sessionmanager.h ../core/htmlfilter.h ../db/db.h
|
||||
misc.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
|
||||
misc.o: ../db/dbitemquery.h ../db/dbitemcolumns.h ../core/user.h
|
||||
misc.o: ../core/group.h ../core/dircontainer.h ../core/ugcontainer.h
|
||||
mount.o: mount.h misc.h item.h ../../pikotools/space/space.h
|
||||
mount.o: ../../pikotools/date/date.h requesttypes.h
|
||||
mount.o: ../../pikotools/textstream/textstream.h
|
||||
mount.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
mount.o: ../../pikotools/membuffer/membuffer.h
|
||||
mount.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
mountparser.o: mountparser.h mount.h item.h ../../pikotools/space/space.h
|
||||
mountparser.o: ../../pikotools/date/date.h dirs.h dircontainer.h ../db/db.h
|
||||
mountparser.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
mountparser.o: ../core/textstream.h misc.h requesttypes.h
|
||||
mountparser.o: ../../pikotools/textstream/textstream.h
|
||||
mountparser.o: ../../pikotools/convert/convert.h
|
||||
mountparser.o: ../../pikotools/convert/inttostr.h
|
||||
mountparser.o: ../../pikotools/membuffer/membuffer.h
|
||||
mountparser.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
mountparser.o: ../core/error.h ../../pikotools/space/spaceparser.h
|
||||
mountparser.o: ../../pikotools/space/space.h
|
||||
mountparser.o: ../../pikotools/textstream/types.h ../db/dbitemquery.h
|
||||
mountparser.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h
|
||||
mountparser.o: ../core/group.h ../core/dircontainer.h ../core/ugcontainer.h
|
||||
mountparser.o: log.h textstream.h logmanipulators.h slog.h cur.h request.h
|
||||
mountparser.o: error.h config.h htmlfilter.h ../templates/htmltextstream.h
|
||||
mountparser.o: ../../pikotools/space/spacetojson.h session.h user.h
|
||||
mountparser.o: plugindata.h rebus.h ipban.h ../templates/locale.h
|
||||
mountparser.o: ../notify/notify.h ../notify/notifypool.h
|
||||
mountparser.o: ../templates/patterns.h ../templates/locale.h
|
||||
mountparser.o: ../templates/localefilter.h ../../ezc/src/ezc.h
|
||||
mountparser.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
mountparser.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
mountparser.o: ../../ezc/src/stringconv.h ../notify/notifythread.h
|
||||
mountparser.o: ../core/basethread.h ../notify/templatesnotify.h
|
||||
mountparser.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
|
||||
mounts.o: mounts.h mount.h error.h dirs.h item.h
|
||||
mounts.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
mounts.o: dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
|
||||
mounts.o: ../db/dbtextstream.h ../core/textstream.h misc.h requesttypes.h
|
||||
mounts.o: ../../pikotools/textstream/textstream.h
|
||||
mounts.o: ../../pikotools/convert/convert.h
|
||||
mounts.o: ../../pikotools/convert/inttostr.h
|
||||
mounts.o: ../../pikotools/membuffer/membuffer.h
|
||||
mounts.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
mounts.o: ../core/error.h ../../pikotools/space/spaceparser.h
|
||||
mounts.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
mounts.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
mounts.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
mounts.o: ../core/ugcontainer.h log.h textstream.h logmanipulators.h slog.h
|
||||
mounts.o: cur.h request.h config.h htmlfilter.h ../templates/htmltextstream.h
|
||||
mounts.o: ../../pikotools/space/spacetojson.h session.h user.h plugindata.h
|
||||
mounts.o: rebus.h ipban.h ../templates/locale.h ../notify/notify.h
|
||||
mounts.o: ../notify/notifypool.h ../templates/patterns.h
|
||||
mounts.o: ../templates/locale.h ../templates/localefilter.h
|
||||
mounts.o: ../../ezc/src/ezc.h ../../ezc/src/generator.h
|
||||
mounts.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
|
||||
mounts.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
|
||||
mounts.o: ../notify/notifythread.h ../core/basethread.h
|
||||
mounts.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
mounts.o: ugcontainer.h lastcontainer.h mountparser.h plugin.h pluginmsg.h
|
||||
mounts.o: system.h job.h basethread.h synchro.h crypt.h run.h users.h
|
||||
mounts.o: groups.h group.h loadavg.h image.h threadmanager.h timezones.h
|
||||
mounts.o: timezone.h sessionmanager.h sessioncontainer.h ipbancontainer.h
|
||||
mounts.o: ../functions/functions.h ../functions/functionbase.h
|
||||
mounts.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
mounts.o: ../functions/functionparser.h ../core/cur.h ../functions/adduser.h
|
||||
mounts.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
mounts.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
mounts.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
|
||||
mounts.o: ../functions/env.h ../functions/last.h ../functions/login.h
|
||||
mounts.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
|
||||
mounts.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
mounts.o: ../functions/mv.h ../functions/nicedit.h ../functions/node.h
|
||||
mounts.o: ../functions/passwd.h ../functions/priv.h ../functions/pw.h
|
||||
mounts.o: ../functions/reload.h ../functions/rm.h ../functions/rmuser.h
|
||||
mounts.o: ../functions/sort.h ../functions/specialdefault.h
|
||||
mounts.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
mounts.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
mounts.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
mounts.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
mounts.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
mounts.o: ../templates/patterns.h ../templates/changepatterns.h
|
||||
mounts.o: ../templates/htmltextstream.h ../core/sessionmanager.h
|
||||
plugin.o: plugin.h pluginmsg.h log.h textstream.h logmanipulators.h
|
||||
plugin.o: ../../pikotools/textstream/textstream.h
|
||||
plugin.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
plugin.o: ../../pikotools/convert/convert.h
|
||||
plugin.o: ../../pikotools/convert/inttostr.h
|
||||
plugin.o: ../../pikotools/membuffer/membuffer.h
|
||||
plugin.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
plugin.o: requesttypes.h item.h error.h config.h
|
||||
plugin.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
plugin.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
plugin.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
plugin.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
plugin.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
plugin.o: ../templates/locale.h system.h job.h basethread.h synchro.h dirs.h
|
||||
plugin.o: dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
|
||||
plugin.o: ../db/dbtextstream.h ../core/error.h ../db/dbitemquery.h
|
||||
plugin.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
plugin.o: ../core/dircontainer.h ../core/ugcontainer.h ../notify/notify.h
|
||||
plugin.o: ../notify/notifypool.h ../templates/patterns.h
|
||||
plugin.o: ../templates/locale.h ../templates/localefilter.h
|
||||
plugin.o: ../../ezc/src/ezc.h ../../ezc/src/generator.h
|
||||
plugin.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
|
||||
plugin.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
|
||||
plugin.o: ../notify/notifythread.h ../core/basethread.h
|
||||
plugin.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
plugin.o: ugcontainer.h lastcontainer.h mounts.h mountparser.h crypt.h run.h
|
||||
plugin.o: users.h groups.h group.h loadavg.h image.h threadmanager.h
|
||||
plugin.o: timezones.h timezone.h sessionmanager.h sessioncontainer.h
|
||||
plugin.o: ipbancontainer.h ../functions/functions.h
|
||||
plugin.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
plugin.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
plugin.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
plugin.o: ../functions/privchanger.h ../functions/chown.h
|
||||
plugin.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
|
||||
plugin.o: ../functions/download.h ../functions/emacs.h ../functions/env.h
|
||||
plugin.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
plugin.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
plugin.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
plugin.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
plugin.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
plugin.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
plugin.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
plugin.o: ../functions/subject.h ../functions/template.h
|
||||
plugin.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
plugin.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
plugin.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
plugin.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
plugin.o: ../templates/patterns.h ../templates/changepatterns.h
|
||||
plugin.o: ../templates/htmltextstream.h ../core/sessionmanager.h
|
||||
plugindata.o: plugindata.h plugin.h pluginmsg.h log.h textstream.h
|
||||
plugindata.o: logmanipulators.h ../../pikotools/textstream/textstream.h
|
||||
plugindata.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
plugindata.o: ../../pikotools/convert/convert.h
|
||||
plugindata.o: ../../pikotools/convert/inttostr.h
|
||||
plugindata.o: ../../pikotools/membuffer/membuffer.h
|
||||
plugindata.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
plugindata.o: requesttypes.h item.h error.h config.h
|
||||
plugindata.o: ../../pikotools/space/spaceparser.h
|
||||
plugindata.o: ../../pikotools/space/space.h
|
||||
plugindata.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
plugindata.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
plugindata.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
plugindata.o: session.h user.h rebus.h ipban.h mount.h ../templates/locale.h
|
||||
plugindata.o: system.h job.h basethread.h synchro.h dirs.h dircontainer.h
|
||||
plugindata.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
plugindata.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
|
||||
plugindata.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
plugindata.o: ../core/dircontainer.h ../core/ugcontainer.h ../notify/notify.h
|
||||
plugindata.o: ../notify/notifypool.h ../templates/patterns.h
|
||||
plugindata.o: ../templates/locale.h ../templates/localefilter.h
|
||||
plugindata.o: ../../ezc/src/ezc.h ../../ezc/src/generator.h
|
||||
plugindata.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
|
||||
plugindata.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
|
||||
plugindata.o: ../notify/notifythread.h ../core/basethread.h
|
||||
plugindata.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
plugindata.o: ugcontainer.h lastcontainer.h mounts.h mountparser.h crypt.h
|
||||
plugindata.o: run.h users.h groups.h group.h loadavg.h image.h
|
||||
plugindata.o: threadmanager.h timezones.h timezone.h sessionmanager.h
|
||||
plugindata.o: sessioncontainer.h ipbancontainer.h ../functions/functions.h
|
||||
plugindata.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
plugindata.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
plugindata.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
plugindata.o: ../functions/privchanger.h ../functions/chown.h
|
||||
plugindata.o: ../functions/ckeditor.h ../functions/cp.h
|
||||
plugindata.o: ../functions/default.h ../functions/download.h
|
||||
plugindata.o: ../functions/emacs.h ../functions/env.h ../functions/last.h
|
||||
plugindata.o: ../functions/login.h ../functions/logout.h ../functions/ln.h
|
||||
plugindata.o: ../functions/ls.h ../functions/man.h ../functions/meta.h
|
||||
plugindata.o: ../functions/mkdir.h ../functions/mv.h ../functions/nicedit.h
|
||||
plugindata.o: ../functions/node.h ../functions/passwd.h ../functions/priv.h
|
||||
plugindata.o: ../functions/pw.h ../functions/reload.h ../functions/rm.h
|
||||
plugindata.o: ../functions/rmuser.h ../functions/sort.h
|
||||
plugindata.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
plugindata.o: ../functions/subject.h ../functions/template.h
|
||||
plugindata.o: ../functions/tinymce.h ../functions/uname.h
|
||||
plugindata.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h
|
||||
plugindata.o: ../functions/vim.h ../core/htmlfilter.h
|
||||
plugindata.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
plugindata.o: ../templates/indexpatterns.h ../templates/patterns.h
|
||||
plugindata.o: ../templates/changepatterns.h ../templates/htmltextstream.h
|
||||
plugindata.o: ../core/sessionmanager.h
|
||||
postmultiparser.o: postmultiparser.h error.h requesttypes.h
|
||||
postmultiparser.o: ../../pikotools/textstream/textstream.h
|
||||
postmultiparser.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
postmultiparser.o: ../../pikotools/convert/convert.h
|
||||
postmultiparser.o: ../../pikotools/convert/inttostr.h
|
||||
postmultiparser.o: ../../pikotools/membuffer/membuffer.h
|
||||
postmultiparser.o: ../../pikotools/textstream/types.h config.h
|
||||
postmultiparser.o: ../../pikotools/space/spaceparser.h
|
||||
postmultiparser.o: ../../pikotools/space/space.h
|
||||
postmultiparser.o: ../../pikotools/textstream/types.h htmlfilter.h misc.h
|
||||
postmultiparser.o: item.h ../../pikotools/utf8/utf8.h log.h textstream.h
|
||||
postmultiparser.o: logmanipulators.h slog.h cur.h request.h
|
||||
postmultiparser.o: ../templates/htmltextstream.h ../core/textstream.h
|
||||
postmultiparser.o: ../../pikotools/space/spacetojson.h session.h user.h
|
||||
postmultiparser.o: plugindata.h rebus.h ipban.h mount.h ../templates/locale.h
|
||||
rebus.o: log.h textstream.h logmanipulators.h
|
||||
rebus.o: ../../pikotools/textstream/textstream.h
|
||||
rebus.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
rebus.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
rebus.o: ../../pikotools/membuffer/membuffer.h
|
||||
rebus.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
rebus.o: requesttypes.h item.h error.h config.h
|
||||
rebus.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
rebus.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
rebus.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
rebus.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
rebus.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
rebus.o: ../templates/locale.h
|
||||
request.o: request.h requesttypes.h ../../pikotools/textstream/textstream.h
|
||||
request.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
request.o: ../../pikotools/convert/convert.h
|
||||
request.o: ../../pikotools/convert/inttostr.h
|
||||
request.o: ../../pikotools/membuffer/membuffer.h
|
||||
request.o: ../../pikotools/textstream/types.h item.h error.h config.h
|
||||
request.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
request.o: ../../pikotools/textstream/types.h htmlfilter.h textstream.h
|
||||
request.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
request.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
request.o: log.h logmanipulators.h slog.h cur.h session.h user.h plugindata.h
|
||||
request.o: rebus.h ipban.h mount.h ../templates/locale.h plugin.h pluginmsg.h
|
||||
request.o: system.h job.h basethread.h synchro.h dirs.h dircontainer.h
|
||||
request.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
request.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
|
||||
request.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
request.o: ../core/dircontainer.h ../core/ugcontainer.h ../notify/notify.h
|
||||
request.o: ../notify/notifypool.h ../templates/patterns.h
|
||||
request.o: ../templates/locale.h ../templates/localefilter.h
|
||||
request.o: ../../ezc/src/ezc.h ../../ezc/src/generator.h
|
||||
request.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
|
||||
request.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
|
||||
request.o: ../notify/notifythread.h ../core/basethread.h
|
||||
request.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
request.o: ugcontainer.h lastcontainer.h mounts.h mountparser.h crypt.h run.h
|
||||
request.o: users.h groups.h group.h loadavg.h image.h threadmanager.h
|
||||
request.o: timezones.h timezone.h sessionmanager.h sessioncontainer.h
|
||||
request.o: ipbancontainer.h ../functions/functions.h
|
||||
request.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
request.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
request.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
request.o: ../functions/privchanger.h ../functions/chown.h
|
||||
request.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
|
||||
request.o: ../functions/download.h ../functions/emacs.h ../functions/env.h
|
||||
request.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
request.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
request.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
request.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
request.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
request.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
request.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
request.o: ../functions/subject.h ../functions/template.h
|
||||
request.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
request.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
request.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
request.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
request.o: ../templates/patterns.h ../templates/changepatterns.h
|
||||
request.o: ../templates/htmltextstream.h ../core/sessionmanager.h
|
||||
run.o: run.h log.h textstream.h logmanipulators.h
|
||||
run.o: ../../pikotools/textstream/textstream.h ../../pikotools/space/space.h
|
||||
run.o: ../../pikotools/date/date.h ../../pikotools/convert/convert.h
|
||||
run.o: ../../pikotools/convert/inttostr.h
|
||||
run.o: ../../pikotools/membuffer/membuffer.h
|
||||
run.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
run.o: requesttypes.h item.h error.h config.h
|
||||
run.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
run.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
run.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
run.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
run.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
run.o: ../templates/locale.h
|
||||
session.o: session.h item.h ../../pikotools/space/space.h
|
||||
session.o: ../../pikotools/date/date.h error.h user.h plugindata.h rebus.h
|
||||
session.o: textstream.h ipban.h misc.h requesttypes.h
|
||||
session.o: ../../pikotools/textstream/textstream.h
|
||||
session.o: ../../pikotools/convert/convert.h
|
||||
session.o: ../../pikotools/convert/inttostr.h
|
||||
session.o: ../../pikotools/membuffer/membuffer.h
|
||||
session.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
sessioncontainer.o: sessioncontainer.h session.h item.h
|
||||
sessioncontainer.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
sessioncontainer.o: error.h user.h plugindata.h rebus.h textstream.h ipban.h
|
||||
sessioncontainer.o: cur.h request.h requesttypes.h
|
||||
sessioncontainer.o: ../../pikotools/textstream/textstream.h
|
||||
sessioncontainer.o: ../../pikotools/convert/convert.h
|
||||
sessioncontainer.o: ../../pikotools/convert/inttostr.h
|
||||
sessioncontainer.o: ../../pikotools/membuffer/membuffer.h
|
||||
sessioncontainer.o: ../../pikotools/textstream/types.h config.h
|
||||
sessioncontainer.o: ../../pikotools/space/spaceparser.h
|
||||
sessioncontainer.o: ../../pikotools/space/space.h
|
||||
sessioncontainer.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
sessioncontainer.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
sessioncontainer.o: ../../pikotools/utf8/utf8.h
|
||||
sessioncontainer.o: ../../pikotools/space/spacetojson.h mount.h log.h
|
||||
sessioncontainer.o: logmanipulators.h slog.h ../templates/locale.h
|
||||
sessionmanager.o: sessionmanager.h sessioncontainer.h session.h item.h
|
||||
sessionmanager.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
sessionmanager.o: error.h user.h plugindata.h rebus.h textstream.h ipban.h
|
||||
sessionmanager.o: cur.h request.h requesttypes.h
|
||||
sessionmanager.o: ../../pikotools/textstream/textstream.h
|
||||
sessionmanager.o: ../../pikotools/convert/convert.h
|
||||
sessionmanager.o: ../../pikotools/convert/inttostr.h
|
||||
sessionmanager.o: ../../pikotools/membuffer/membuffer.h
|
||||
sessionmanager.o: ../../pikotools/textstream/types.h config.h
|
||||
sessionmanager.o: ../../pikotools/space/spaceparser.h
|
||||
sessionmanager.o: ../../pikotools/space/space.h
|
||||
sessionmanager.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
sessionmanager.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
sessionmanager.o: ../../pikotools/utf8/utf8.h
|
||||
sessionmanager.o: ../../pikotools/space/spacetojson.h mount.h
|
||||
sessionmanager.o: ipbancontainer.h lastcontainer.h system.h job.h
|
||||
sessionmanager.o: basethread.h synchro.h dirs.h dircontainer.h ../db/db.h
|
||||
sessionmanager.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
sessionmanager.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
|
||||
sessionmanager.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
|
||||
sessionmanager.o: ../core/dircontainer.h ../core/ugcontainer.h log.h
|
||||
sessionmanager.o: logmanipulators.h slog.h ../templates/locale.h
|
||||
sessionmanager.o: ../notify/notify.h ../notify/notifypool.h
|
||||
sessionmanager.o: ../templates/patterns.h ../templates/locale.h
|
||||
sessionmanager.o: ../templates/localefilter.h ../../ezc/src/ezc.h
|
||||
sessionmanager.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
sessionmanager.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
sessionmanager.o: ../../ezc/src/stringconv.h ../notify/notifythread.h
|
||||
sessionmanager.o: ../core/basethread.h ../notify/templatesnotify.h
|
||||
sessionmanager.o: ../core/config.h ../core/users.h ugcontainer.h mounts.h
|
||||
sessionmanager.o: mountparser.h crypt.h run.h users.h groups.h group.h
|
||||
sessionmanager.o: loadavg.h image.h threadmanager.h timezones.h timezone.h
|
||||
sessionmanager.o: sessionparser.h plugin.h pluginmsg.h
|
||||
sessionmanager.o: ../functions/functions.h ../functions/functionbase.h
|
||||
sessionmanager.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
sessionmanager.o: ../functions/functionparser.h ../core/cur.h
|
||||
sessionmanager.o: ../functions/adduser.h ../functions/cat.h
|
||||
sessionmanager.o: ../functions/chmod.h ../functions/privchanger.h
|
||||
sessionmanager.o: ../functions/chown.h ../functions/ckeditor.h
|
||||
sessionmanager.o: ../functions/cp.h ../functions/default.h
|
||||
sessionmanager.o: ../functions/download.h ../functions/emacs.h
|
||||
sessionmanager.o: ../functions/env.h ../functions/last.h ../functions/login.h
|
||||
sessionmanager.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
|
||||
sessionmanager.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
sessionmanager.o: ../functions/mv.h ../functions/nicedit.h
|
||||
sessionmanager.o: ../functions/node.h ../functions/passwd.h
|
||||
sessionmanager.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
sessionmanager.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
sessionmanager.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
sessionmanager.o: ../functions/subject.h ../functions/template.h
|
||||
sessionmanager.o: ../functions/tinymce.h ../functions/uname.h
|
||||
sessionmanager.o: ../functions/upload.h ../functions/uptime.h
|
||||
sessionmanager.o: ../functions/who.h ../functions/vim.h ../core/htmlfilter.h
|
||||
sessionmanager.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
sessionmanager.o: ../templates/indexpatterns.h ../templates/patterns.h
|
||||
sessionmanager.o: ../templates/changepatterns.h ../templates/htmltextstream.h
|
||||
sessionmanager.o: ../core/sessionmanager.h
|
||||
sessionparser.o: sessionparser.h session.h item.h
|
||||
sessionparser.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
sessionparser.o: error.h user.h plugindata.h rebus.h textstream.h ipban.h
|
||||
sessionparser.o: sessioncontainer.h cur.h request.h requesttypes.h
|
||||
sessionparser.o: ../../pikotools/textstream/textstream.h
|
||||
sessionparser.o: ../../pikotools/convert/convert.h
|
||||
sessionparser.o: ../../pikotools/convert/inttostr.h
|
||||
sessionparser.o: ../../pikotools/membuffer/membuffer.h
|
||||
sessionparser.o: ../../pikotools/textstream/types.h config.h
|
||||
sessionparser.o: ../../pikotools/space/spaceparser.h
|
||||
sessionparser.o: ../../pikotools/space/space.h
|
||||
sessionparser.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
sessionparser.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
sessionparser.o: ../../pikotools/utf8/utf8.h
|
||||
sessionparser.o: ../../pikotools/space/spacetojson.h mount.h users.h log.h
|
||||
sessionparser.o: logmanipulators.h slog.h ../templates/locale.h
|
||||
slog.o: slog.h cur.h request.h requesttypes.h
|
||||
slog.o: ../../pikotools/textstream/textstream.h ../../pikotools/space/space.h
|
||||
slog.o: ../../pikotools/date/date.h ../../pikotools/convert/convert.h
|
||||
slog.o: ../../pikotools/convert/inttostr.h
|
||||
slog.o: ../../pikotools/membuffer/membuffer.h
|
||||
slog.o: ../../pikotools/textstream/types.h item.h error.h config.h
|
||||
slog.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
slog.o: ../../pikotools/textstream/types.h htmlfilter.h textstream.h
|
||||
slog.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
slog.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
slog.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
slog.o: logmanipulators.h ../templates/locale.h
|
||||
synchro.o: synchro.h
|
||||
system.o: system.h job.h basethread.h synchro.h ../../pikotools/space/space.h
|
||||
system.o: dirs.h item.h ../../pikotools/date/date.h dircontainer.h ../db/db.h
|
||||
system.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
system.o: ../core/textstream.h misc.h requesttypes.h
|
||||
system.o: ../../pikotools/textstream/textstream.h
|
||||
system.o: ../../pikotools/convert/convert.h
|
||||
system.o: ../../pikotools/convert/inttostr.h
|
||||
system.o: ../../pikotools/membuffer/membuffer.h
|
||||
system.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
system.o: ../core/error.h ../../pikotools/space/spaceparser.h
|
||||
system.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
system.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
system.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
system.o: ../core/ugcontainer.h log.h textstream.h logmanipulators.h slog.h
|
||||
system.o: cur.h request.h error.h config.h htmlfilter.h
|
||||
system.o: ../templates/htmltextstream.h ../../pikotools/space/spacetojson.h
|
||||
system.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
system.o: ../templates/locale.h ../notify/notify.h ../notify/notifypool.h
|
||||
system.o: ../templates/patterns.h ../templates/locale.h
|
||||
system.o: ../templates/localefilter.h ../../ezc/src/ezc.h
|
||||
system.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
system.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
system.o: ../../ezc/src/stringconv.h ../notify/notifythread.h
|
||||
system.o: ../core/basethread.h ../notify/templatesnotify.h ../core/config.h
|
||||
system.o: ../core/users.h ugcontainer.h lastcontainer.h mounts.h
|
||||
system.o: mountparser.h crypt.h run.h users.h groups.h group.h loadavg.h
|
||||
system.o: image.h threadmanager.h timezones.h timezone.h
|
||||
system.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
system.o: ../templates/indexpatterns.h ../templates/patterns.h
|
||||
system.o: ../templates/changepatterns.h ../templates/htmltextstream.h
|
||||
system.o: ../core/cur.h ../core/system.h ../core/sessionmanager.h
|
||||
system.o: ../core/htmlfilter.h ../functions/functions.h
|
||||
system.o: ../functions/functionbase.h ../core/request.h ../core/synchro.h
|
||||
system.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
system.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
system.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
system.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
|
||||
system.o: ../functions/env.h ../functions/last.h ../functions/login.h
|
||||
system.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
|
||||
system.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
system.o: ../functions/mv.h ../functions/nicedit.h ../functions/node.h
|
||||
system.o: ../functions/passwd.h ../functions/priv.h ../functions/pw.h
|
||||
system.o: ../functions/reload.h ../functions/rm.h ../functions/rmuser.h
|
||||
system.o: ../functions/sort.h ../functions/specialdefault.h
|
||||
system.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
system.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
system.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
system.o: plugin.h pluginmsg.h sessionmanager.h sessioncontainer.h
|
||||
system.o: ipbancontainer.h
|
||||
threadmanager.o: threadmanager.h basethread.h synchro.h log.h textstream.h
|
||||
threadmanager.o: logmanipulators.h ../../pikotools/textstream/textstream.h
|
||||
threadmanager.o: ../../pikotools/space/space.h ../../pikotools/date/date.h
|
||||
threadmanager.o: ../../pikotools/convert/convert.h
|
||||
threadmanager.o: ../../pikotools/convert/inttostr.h
|
||||
threadmanager.o: ../../pikotools/membuffer/membuffer.h
|
||||
threadmanager.o: ../../pikotools/textstream/types.h slog.h cur.h request.h
|
||||
threadmanager.o: requesttypes.h item.h error.h config.h
|
||||
threadmanager.o: ../../pikotools/space/spaceparser.h
|
||||
threadmanager.o: ../../pikotools/space/space.h
|
||||
threadmanager.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
threadmanager.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
threadmanager.o: ../../pikotools/utf8/utf8.h
|
||||
threadmanager.o: ../../pikotools/space/spacetojson.h session.h user.h
|
||||
threadmanager.o: plugindata.h rebus.h ipban.h mount.h ../templates/locale.h
|
||||
timezone.o: timezone.h ../../pikotools/date/date.h
|
||||
timezone.o: ../../pikotools/space/space.h misc.h item.h requesttypes.h
|
||||
timezone.o: ../../pikotools/textstream/textstream.h
|
||||
timezone.o: ../../pikotools/convert/convert.h
|
||||
timezone.o: ../../pikotools/convert/inttostr.h
|
||||
timezone.o: ../../pikotools/membuffer/membuffer.h
|
||||
timezone.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
timezones.o: timezones.h timezone.h ../../pikotools/date/date.h
|
||||
timezones.o: ../../pikotools/space/space.h
|
||||
timezones.o: ../../pikotools/space/spaceparser.h
|
||||
timezones.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
timezones.o: misc.h item.h requesttypes.h
|
||||
timezones.o: ../../pikotools/textstream/textstream.h
|
||||
timezones.o: ../../pikotools/convert/convert.h
|
||||
timezones.o: ../../pikotools/convert/inttostr.h
|
||||
timezones.o: ../../pikotools/membuffer/membuffer.h
|
||||
timezones.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
timezones.o: log.h textstream.h logmanipulators.h slog.h cur.h request.h
|
||||
timezones.o: error.h config.h htmlfilter.h ../templates/htmltextstream.h
|
||||
timezones.o: ../core/textstream.h ../../pikotools/space/spacetojson.h
|
||||
timezones.o: session.h user.h plugindata.h rebus.h ipban.h mount.h
|
||||
timezones.o: ../templates/locale.h
|
||||
user.o: user.h
|
||||
users.o: users.h sessionmanager.h sessioncontainer.h session.h item.h
|
||||
users.o: ../../pikotools/space/space.h ../../pikotools/date/date.h error.h
|
||||
users.o: user.h plugindata.h rebus.h textstream.h ipban.h cur.h request.h
|
||||
users.o: requesttypes.h ../../pikotools/textstream/textstream.h
|
||||
users.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
users.o: ../../pikotools/membuffer/membuffer.h
|
||||
users.o: ../../pikotools/textstream/types.h config.h
|
||||
users.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
users.o: ../../pikotools/textstream/types.h htmlfilter.h
|
||||
users.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
users.o: ../../pikotools/utf8/utf8.h ../../pikotools/space/spacetojson.h
|
||||
users.o: mount.h ipbancontainer.h lastcontainer.h system.h job.h basethread.h
|
||||
users.o: synchro.h dirs.h dircontainer.h ../db/db.h ../db/dbbase.h
|
||||
users.o: ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
|
||||
users.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
users.o: ../core/user.h ../core/group.h ../core/dircontainer.h
|
||||
users.o: ../core/ugcontainer.h log.h logmanipulators.h slog.h
|
||||
users.o: ../templates/locale.h ../notify/notify.h ../notify/notifypool.h
|
||||
users.o: ../templates/patterns.h ../templates/locale.h
|
||||
users.o: ../templates/localefilter.h ../../ezc/src/ezc.h
|
||||
users.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
|
||||
users.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
users.o: ../../ezc/src/stringconv.h ../notify/notifythread.h
|
||||
users.o: ../core/basethread.h ../notify/templatesnotify.h ../core/config.h
|
||||
users.o: ../core/users.h ugcontainer.h mounts.h mountparser.h crypt.h run.h
|
||||
users.o: groups.h group.h loadavg.h image.h threadmanager.h timezones.h
|
||||
users.o: timezone.h plugin.h pluginmsg.h ../functions/functions.h
|
||||
users.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
users.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
users.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
users.o: ../functions/privchanger.h ../functions/chown.h
|
||||
users.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
|
||||
users.o: ../functions/download.h ../functions/emacs.h ../functions/env.h
|
||||
users.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
users.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
users.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
users.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
users.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
users.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
users.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
users.o: ../functions/subject.h ../functions/template.h
|
||||
users.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
users.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
users.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
users.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
users.o: ../templates/patterns.h ../templates/changepatterns.h
|
||||
users.o: ../templates/htmltextstream.h ../core/sessionmanager.h
|
||||
|
||||
@@ -1 +1 @@
|
||||
o = compress.o config.o data.o db.o db_itemcolumns.o dircontainer.o dirs.o done.o error.o function.o functioncodeparser.o functionparser.o functions.o groups.o httpsimpleparser.o lastcontainer.o log.o main.o misc.o mount.o mountparser.o mounts.o notify.o request.o requestcontroller.o session.o sessioncontainer.o sessionmanager.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
|
||||
|
||||
113
core/acceptbaseparser.cpp
Executable file
113
core/acceptbaseparser.cpp
Executable file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "acceptbaseparser.h"
|
||||
|
||||
|
||||
|
||||
bool AcceptBaseParser::IsWhite(int c)
|
||||
{
|
||||
if( c==' ' || c=='\t' )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void AcceptBaseParser::SkipWhite()
|
||||
{
|
||||
while( IsWhite(*text) )
|
||||
++text;
|
||||
}
|
||||
|
||||
|
||||
void AcceptBaseParser::RemoveWhiteFromEnd(std::string & str)
|
||||
{
|
||||
if( str.empty() )
|
||||
return;
|
||||
|
||||
size_t i = str.size() - 1;
|
||||
|
||||
for( ; i!=0 && IsWhite(str[i]) ; --i);
|
||||
|
||||
if( !IsWhite(str[i]) )
|
||||
++i;
|
||||
|
||||
if( i < str.size() )
|
||||
str.erase(i); // erasing until the end of the string
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AcceptBaseParser::ReadParameter()
|
||||
{
|
||||
param.clear();
|
||||
|
||||
SkipWhite();
|
||||
|
||||
while( *text!=0 && *text!=',' && *text!=';' )
|
||||
{
|
||||
param += *text;
|
||||
++text;
|
||||
}
|
||||
|
||||
RemoveWhiteFromEnd(param);
|
||||
}
|
||||
|
||||
|
||||
void AcceptBaseParser::ReadQ()
|
||||
{
|
||||
q = 1.0;
|
||||
|
||||
SkipWhite();
|
||||
|
||||
if( *text != ';' )
|
||||
return;
|
||||
|
||||
++text; // skipping a semicolon
|
||||
|
||||
while( *text!=0 && *text!=',' && *text!='=' )
|
||||
// skipping until ',' or '='
|
||||
++text;
|
||||
|
||||
if( *text==0 || *text==',' )
|
||||
return;
|
||||
|
||||
++text; // skipping '='
|
||||
|
||||
SkipWhite();
|
||||
q = strtod(text, (char**)&text);
|
||||
}
|
||||
|
||||
|
||||
void AcceptBaseParser::SkipParam()
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
if( *text == ',' )
|
||||
++text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AcceptBaseParser::Parse(const char * str)
|
||||
{
|
||||
text = str;
|
||||
Init();
|
||||
|
||||
while( *text != 0 )
|
||||
{
|
||||
ReadParameter();
|
||||
ReadQ();
|
||||
SkipParam();
|
||||
Param(param, q);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
47
core/acceptbaseparser.h
Executable file
47
core/acceptbaseparser.h
Executable file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_acceptbaseparser
|
||||
#define headerfile_winix_core_acceptbaseparser
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
// sample (you must create your own class derived from this one):
|
||||
// object.Parse(" text/html ; , ; q = 45, application / xhtml+xml ; q = 0.4 , application/xml ; q = 0.9 , */* ; q = 0.8 ");
|
||||
class AcceptBaseParser
|
||||
{
|
||||
public:
|
||||
|
||||
void Parse(const char * str);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
virtual void Init() {} ;
|
||||
virtual void Param(const std::string & param, double q) = 0;
|
||||
|
||||
bool IsWhite(int c);
|
||||
void SkipWhite();
|
||||
void RemoveWhiteFromEnd(std::string & str);
|
||||
void ReadParameter();
|
||||
void ReadQ();
|
||||
void SkipParam();
|
||||
|
||||
|
||||
const char * text;
|
||||
std::string param;
|
||||
double q;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
85
core/acceptencodingparser.h
Executable file
85
core/acceptencodingparser.h
Executable file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_acceptencodingparser
|
||||
#define headerfile_winix_core_acceptencodingparser
|
||||
|
||||
#include "acceptbaseparser.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
class AcceptEncodingParser : public AcceptBaseParser
|
||||
{
|
||||
public:
|
||||
|
||||
bool AcceptDeflate()
|
||||
{
|
||||
return accept_deflate;
|
||||
}
|
||||
|
||||
|
||||
bool AcceptGzip()
|
||||
{
|
||||
return accept_gzip;
|
||||
}
|
||||
|
||||
|
||||
void ParseAndLog(const char * str)
|
||||
{
|
||||
Parse(str);
|
||||
|
||||
if( accept_deflate || accept_gzip )
|
||||
{
|
||||
log << log3 << "AEP: ";
|
||||
|
||||
if( accept_deflate )
|
||||
{
|
||||
log << "accept deflate";
|
||||
|
||||
if( accept_gzip )
|
||||
log << ", ";
|
||||
}
|
||||
|
||||
if( accept_gzip )
|
||||
log << "accept gzip";
|
||||
|
||||
log << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void Init()
|
||||
{
|
||||
accept_deflate = false;
|
||||
accept_gzip = false;
|
||||
}
|
||||
|
||||
|
||||
void Param(const std::string & param, double q)
|
||||
{
|
||||
if( param=="deflate" && q!=0.0 )
|
||||
{
|
||||
accept_deflate = true;
|
||||
}
|
||||
|
||||
if( param=="gzip" && q!=0.0 )
|
||||
{
|
||||
accept_gzip = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool accept_deflate;
|
||||
bool accept_gzip;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
1535
core/app.cpp
Executable file
1535
core/app.cpp
Executable file
File diff suppressed because it is too large
Load Diff
192
core/app.h
Executable file
192
core/app.h
Executable file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_app
|
||||
#define headerfile_winix_core_app
|
||||
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <errno.h>
|
||||
#include <fcgiapp.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "mounts.h"
|
||||
#include "request.h"
|
||||
#include "synchro.h"
|
||||
#include "sessionmanager.h"
|
||||
#include "db/db.h"
|
||||
#include "functions/functions.h"
|
||||
#include "templates/templates.h"
|
||||
#include "compress.h"
|
||||
#include "postparser.h"
|
||||
#include "cookieparser.h"
|
||||
#include "postmultiparser.h"
|
||||
#include "acceptencodingparser.h"
|
||||
|
||||
|
||||
|
||||
class App
|
||||
{
|
||||
public:
|
||||
|
||||
App();
|
||||
|
||||
bool InitFCGI();
|
||||
bool DropPrivileges();
|
||||
bool Init();
|
||||
void Start();
|
||||
void Close();
|
||||
void LogUserGroups();
|
||||
bool Demonize();
|
||||
void SetStopSignal();
|
||||
bool WasStopSignal();
|
||||
bool Lock();
|
||||
void Unlock();
|
||||
void StartThreads();
|
||||
void WaitForThreads();
|
||||
|
||||
// configuration read from a config file
|
||||
Config config;
|
||||
|
||||
// pointers to the current request and a session
|
||||
Cur cur;
|
||||
|
||||
// temporary one request object
|
||||
// current request
|
||||
Request req;
|
||||
|
||||
// users sessions
|
||||
SessionManager session_manager;
|
||||
|
||||
// database
|
||||
Db db;
|
||||
DbConn db_conn;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
model
|
||||
*/
|
||||
|
||||
// ...
|
||||
System system;
|
||||
|
||||
// functions (ls, cat, emacs, ...)
|
||||
Functions functions;
|
||||
|
||||
// false at the beginning
|
||||
// !! moze to do loggera dac?
|
||||
bool stdout_is_closed;
|
||||
|
||||
|
||||
/*
|
||||
view
|
||||
*/
|
||||
|
||||
Templates templates;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
enum Header
|
||||
{
|
||||
h_200,
|
||||
h_404,
|
||||
h_403
|
||||
};
|
||||
|
||||
PostParser post_parser;
|
||||
PostMultiParser post_multi_parser;
|
||||
CookieParser cookie_parser;
|
||||
AcceptEncodingParser accept_encoding_parser;
|
||||
Compress compress;
|
||||
std::wstring clean_html, html_with_debug;
|
||||
FCGX_Request fcgi_request;
|
||||
int fcgi_socket;
|
||||
Synchro synchro;
|
||||
pthread_t signal_thread;
|
||||
std::string url_to_fetch_on_exit;
|
||||
std::string source_a;
|
||||
std::string sendh_t, sendh_t2, sendh_t3;
|
||||
std::string sendfilea, sendfile2a;
|
||||
std::string send_data_buf;
|
||||
|
||||
bool CheckAccessFromPlugins();
|
||||
void ProcessRequestThrow();
|
||||
void ProcessRequest();
|
||||
void BaseUrlRedirect(int code, bool add_subdomain);
|
||||
bool BaseUrlRedirect();
|
||||
void CheckIfNeedSSLredirect();
|
||||
void SetLocale();
|
||||
void CheckPostRedirect();
|
||||
void MakePage();
|
||||
void Make();
|
||||
void SaveSessionsIfNeeded(); // !! wywalic do menagera sesji??
|
||||
void LogAccess();
|
||||
void SendData(const BinaryPage & page, FCGX_Stream * out);
|
||||
|
||||
void ReadRequest();
|
||||
void SendTextAnswer();
|
||||
void SendBinaryAnswer();
|
||||
void SendAnswer();
|
||||
|
||||
void PrintEnv();
|
||||
|
||||
void SetEnv(const char * & env, const char * name);
|
||||
void ReadEnvVariables();
|
||||
void ReadGetPostVars();
|
||||
|
||||
void CheckIE();
|
||||
void CheckKonqueror();
|
||||
void CheckRequestMethod();
|
||||
void CheckFCGIRole();
|
||||
void CheckSSL();
|
||||
void SetSubdomain();
|
||||
|
||||
void PrepareSessionCookie();
|
||||
void AddDebugInfo(std::wstring & out);
|
||||
void FilterCompressSend(bool compressing, int compress_encoding, const std::wstring & source_ref);
|
||||
bool SendHeadersStaticCreateResource();
|
||||
void SendHeadersStatic();
|
||||
void SendHeaderContentType();
|
||||
void SendHeadersForbidden();
|
||||
void SendHeadersRedirect();
|
||||
void SendHeadersSendFile();
|
||||
void SendHeadersCompression(int compress_encoding);
|
||||
void SendHeadersNormal(Header header);
|
||||
void SendHeaders(bool compressing, int compress_encoding, Header header);
|
||||
int SelectDeflateVersion();
|
||||
void SelectCompression(size_t source_len, bool & compression_allowed, int & compression_encoding);
|
||||
bool CanSendContent(Header header);
|
||||
|
||||
void LogUser(const char * msg, uid_t id);
|
||||
void LogGroup(const char * msg, gid_t id, bool put_logend = true);
|
||||
void LogUsers();
|
||||
void LogEffectiveGroups(std::vector<gid_t> & tab);
|
||||
void LogGroups();
|
||||
bool DropPrivileges(const std::string & user, uid_t uid, gid_t gid, bool additional_groups);
|
||||
|
||||
static void * SpecialThreadForSignals(void*);
|
||||
void FetchPageOnExit();
|
||||
|
||||
void CreateStaticTree();
|
||||
|
||||
// !! dodac do session managera?
|
||||
time_t last_sessions_save;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
239
core/basethread.cpp
Executable file
239
core/basethread.cpp
Executable file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include "basethread.h"
|
||||
|
||||
|
||||
|
||||
BaseThread::BaseThread() : thread_signal(PTHREAD_COND_INITIALIZER)
|
||||
{
|
||||
synchro = 0;
|
||||
thread_id = 0;
|
||||
work_mode = 0;
|
||||
wake_up_was_called = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BaseThread::SetSynchro(Synchro * psynchro)
|
||||
{
|
||||
synchro = psynchro;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BaseThread::Mode(int mode)
|
||||
{
|
||||
work_mode = mode;
|
||||
}
|
||||
|
||||
|
||||
pthread_t BaseThread::ThreadId()
|
||||
{
|
||||
return thread_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool BaseThread::Lock()
|
||||
{
|
||||
return synchro->Lock();
|
||||
}
|
||||
|
||||
|
||||
void BaseThread::Unlock()
|
||||
{
|
||||
synchro->Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool BaseThread::IsExitSignal()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
if( Lock() )
|
||||
{
|
||||
res = synchro->was_stop_signal;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool BaseThread::BaseInit()
|
||||
{
|
||||
bool init_status = false;
|
||||
|
||||
if( Lock() )
|
||||
{
|
||||
init_status = Init(); // your virtual method
|
||||
Unlock();
|
||||
}
|
||||
|
||||
return init_status;
|
||||
}
|
||||
|
||||
|
||||
void BaseThread::BaseUninit()
|
||||
{
|
||||
if( Lock() )
|
||||
{
|
||||
Uninit(); // your virtual method
|
||||
Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool BaseThread::BaseSignalReceived()
|
||||
{
|
||||
bool make_do = false;
|
||||
|
||||
wake_up_was_called = false;
|
||||
|
||||
try
|
||||
{
|
||||
make_do = SignalReceived(); // your short-time virtual method (objects are locked)
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
|
||||
return make_do;
|
||||
}
|
||||
|
||||
|
||||
// this is called only if your SignalReceived() returned true
|
||||
void BaseThread::BaseDo()
|
||||
{
|
||||
try
|
||||
{
|
||||
Do(); // your long-time virtual method (objects are *not* locked)
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// use it with Lock and Unlock
|
||||
bool BaseThread::WaitForSignal()
|
||||
{
|
||||
if( synchro->was_stop_signal || wake_up_was_called )
|
||||
return true;
|
||||
|
||||
return pthread_cond_wait(&thread_signal, &synchro->mutex) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// you should use this method with: synchro->Lock() and Unlock()
|
||||
void BaseThread::WakeUpThread()
|
||||
{
|
||||
wake_up_was_called = true;
|
||||
pthread_cond_signal(&thread_signal);
|
||||
}
|
||||
|
||||
|
||||
// use it with Lock and Unlock
|
||||
// it breaks only if there was a stop signal or the time has expired
|
||||
bool BaseThread::WaitForSignalSleep(time_t second)
|
||||
{
|
||||
timespec t;
|
||||
int res;
|
||||
|
||||
if( synchro->was_stop_signal )
|
||||
return true;
|
||||
|
||||
t.tv_sec = time(0) + second;
|
||||
t.tv_nsec = 0;
|
||||
|
||||
do
|
||||
{
|
||||
res = pthread_cond_timedwait(&thread_signal, &synchro->mutex, &t);
|
||||
}
|
||||
while( res == 0 && !synchro->was_stop_signal );
|
||||
// above condition means there was a signal
|
||||
// but it was not a stop signal so we should still wait
|
||||
|
||||
return res == 0 || res == ETIMEDOUT;
|
||||
}
|
||||
|
||||
|
||||
void BaseThread::WaitForThread()
|
||||
{
|
||||
pthread_join(thread_id, 0);
|
||||
}
|
||||
|
||||
|
||||
void BaseThread::SignalLoop()
|
||||
{
|
||||
bool make_do;
|
||||
|
||||
do
|
||||
{
|
||||
if( Lock() )
|
||||
{
|
||||
make_do = false;
|
||||
|
||||
if( WaitForSignal() ) // automatically unlock, wait and lock again when signal comes
|
||||
if( !synchro->was_stop_signal )
|
||||
make_do = BaseSignalReceived(); // your short-time virtual method will be called (objects locked)
|
||||
|
||||
Unlock(); // unlocking from WaitForSignal()
|
||||
|
||||
if( make_do )
|
||||
BaseDo(); // your long-time virtual method will be called (objects *not* locked)
|
||||
}
|
||||
}
|
||||
while( !IsExitSignal() );
|
||||
}
|
||||
|
||||
|
||||
void * BaseThread::StartRoutine(void * this_object)
|
||||
{
|
||||
BaseThread * base = reinterpret_cast<BaseThread*>(this_object);
|
||||
|
||||
if( base->synchro )
|
||||
{
|
||||
if( base->BaseInit() )
|
||||
{
|
||||
if( base->work_mode == 0 )
|
||||
base->SignalLoop();
|
||||
else
|
||||
base->Work();
|
||||
|
||||
base->BaseUninit();
|
||||
}
|
||||
}
|
||||
|
||||
pthread_exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool BaseThread::StartThread()
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
int res = pthread_create(&thread_id, &attr, StartRoutine, this);
|
||||
|
||||
pthread_attr_destroy(&attr);
|
||||
|
||||
return res == 0;
|
||||
}
|
||||
|
||||
125
core/basethread.h
Executable file
125
core/basethread.h
Executable file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_basethread
|
||||
#define headerfile_winix_core_basethread
|
||||
|
||||
#include <pthread.h>
|
||||
#include "synchro.h"
|
||||
|
||||
|
||||
|
||||
class BaseThread
|
||||
{
|
||||
public:
|
||||
|
||||
BaseThread();
|
||||
|
||||
// synchro object (must be set)
|
||||
void SetSynchro(Synchro * psynchro);
|
||||
|
||||
// work mode
|
||||
// we have two modes:
|
||||
// 0 - there is a loop with SignalReceived() and Do()
|
||||
// if SignalReceived() returns true then Do() is called
|
||||
// 1 - only Work() method is called
|
||||
// the thread exits after Work() has finished
|
||||
// default: 0
|
||||
void Mode(int mode);
|
||||
|
||||
// starting the second thread
|
||||
bool StartThread();
|
||||
|
||||
|
||||
// virtual methods which should/can be inherited by your class
|
||||
// the methods will be called from the other thread
|
||||
|
||||
// wake up the second thread
|
||||
// (if it waits for the signal)
|
||||
// you should use it with: synchro->Lock() and Unlock()
|
||||
// if the thread doesn't wait on a signal then nothing is done
|
||||
virtual void WakeUpThread();
|
||||
|
||||
// waiting until the thread exits
|
||||
// you should call WakeUpThread() before
|
||||
virtual void WaitForThread();
|
||||
|
||||
// initialize the thread
|
||||
// (global objects are locked)
|
||||
// if it returns false then the thread immediately exits
|
||||
// default: true
|
||||
virtual bool Init() { return true; }
|
||||
|
||||
// uninitialize the thread
|
||||
// this is called before the thread is prepare to detach
|
||||
// (global objects are locked)
|
||||
// it's called only if Init() returned true
|
||||
virtual void Uninit() {}
|
||||
|
||||
// returns the thread id
|
||||
// this identifier is set by StartThread() metdhod
|
||||
pthread_t ThreadId();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
// signal came (work mode = 0 - default)
|
||||
// signal comes when an other thread calls WakeUpThread() method
|
||||
// check specific job and return true to call Do() next
|
||||
// (global objects are locked -- copy some global objects to local variables)
|
||||
virtual bool SignalReceived() { return false; };
|
||||
|
||||
// if SignalReceived() returned true then this method is called
|
||||
// global objects are *not* locked -- use only your local variables
|
||||
// if you have to do something on global objects use synchro->Lock() and synchro->Unlock()
|
||||
virtual void Do() {}
|
||||
|
||||
// this method is called after Init() when Mode(1) is used
|
||||
// this is for long-time job
|
||||
// this method is called only once
|
||||
// global objects are *not* locked
|
||||
virtual void Work() {}
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
Synchro * synchro;
|
||||
pthread_t thread_id; // thread id - set by StartThread()
|
||||
pthread_cond_t thread_signal;
|
||||
int work_mode;
|
||||
bool wake_up_was_called;
|
||||
|
||||
void SignalLoop();
|
||||
static void * StartRoutine(void *);
|
||||
bool BaseInit();
|
||||
void BaseUninit();
|
||||
bool BaseSignalReceived();
|
||||
void BaseDo();
|
||||
bool WaitForSignal();
|
||||
bool WaitForSignalSleep(time_t second);
|
||||
|
||||
bool Lock();
|
||||
void Unlock();
|
||||
|
||||
// if the work done by Do() is long time consuming you should periodically check
|
||||
// wheter there was a signal for exiting, and if it was just simply return from Do()
|
||||
// (it's checking with locking and unlocking)
|
||||
bool IsExitSignal();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
592
core/bbcodeparser.cpp
Executable file
592
core/bbcodeparser.cpp
Executable file
@@ -0,0 +1,592 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bbcodeparser.h"
|
||||
|
||||
|
||||
|
||||
|
||||
bool BBCODEParser::Equal(const wchar_t * str1, const wchar_t * str2)
|
||||
{
|
||||
while( *str1 == *str2 && *str1 != 0 )
|
||||
{
|
||||
str1 += 1;
|
||||
str2 += 1;
|
||||
}
|
||||
|
||||
return *str1 == *str2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool BBCODEParser::IsValidCharForName(int c)
|
||||
{
|
||||
if( (c>='a' && c<='z') ||
|
||||
(c>='A' && c<='Z') ||
|
||||
c=='*' || c=='_')
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool BBCODEParser::IsOpeningTagMark()
|
||||
{
|
||||
return (*pchar == '[');
|
||||
}
|
||||
|
||||
|
||||
// there are no commentaries in bbcode
|
||||
bool BBCODEParser::IsOpeningCommentaryTagMark()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool BBCODEParser::SkipCommentaryTagIfExists()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool BBCODEParser::IsClosingTagMark()
|
||||
{
|
||||
return (*pchar == ']');
|
||||
}
|
||||
|
||||
|
||||
bool BBCODEParser::IsClosingXmlSimpleTagMark()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// one enter will generate one <br>
|
||||
// two enters or more will generate only two br (<br><br>)
|
||||
void BBCODEParser::PutNormalText(const wchar_t * str, const wchar_t * end)
|
||||
{
|
||||
int br_len;
|
||||
|
||||
if( *pchar == 0 )
|
||||
{
|
||||
// trimming last white characters at end of the user text
|
||||
while( str<end && (IsWhite(*(end-1)) || *(end-1)==10) )
|
||||
--end;
|
||||
}
|
||||
|
||||
|
||||
while( str < end )
|
||||
{
|
||||
if( *str == 10 )
|
||||
{
|
||||
++str;
|
||||
br_len = 1;
|
||||
|
||||
// skipping white characters without a new line character
|
||||
while( str < end && IsWhite(*str) )
|
||||
++str;
|
||||
|
||||
if( str < end && *str == 10 )
|
||||
{
|
||||
br_len = 2;
|
||||
|
||||
// skipping white characters with new line characters
|
||||
while( str < end && (IsWhite(*str) || *str==10) )
|
||||
++str;
|
||||
}
|
||||
|
||||
if( !has_open_ol_tag && !has_open_ul_tag && !has_open_li_tag )
|
||||
{
|
||||
for(int i=0 ; i < br_len ; ++i)
|
||||
(*out_string) += L"<br>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintEscape(*str);
|
||||
++str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::CheckExceptions()
|
||||
{
|
||||
if( stack_len >= 2 )
|
||||
{
|
||||
if( pstack[stack_len-1].type == Item::opening &&
|
||||
pstack[stack_len-2].type == Item::opening &&
|
||||
IsNameEqual(L"*", pstack[stack_len-1].name) &&
|
||||
IsNameEqual(L"*", pstack[stack_len-2].name) )
|
||||
{
|
||||
// removing the last [*] from the stack
|
||||
// </li> was put automatically
|
||||
PopStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
bbcode format:
|
||||
[bbcodetag=value]some text[/bbcodetag]
|
||||
the value can be quoted, e.g.
|
||||
[bbcodetag="value"]some text[/bbcodetag], or
|
||||
[bbcodetag='value']some text[/bbcodetag]
|
||||
|
||||
the third string below (in tags table) is 'html_argument' from Tags,
|
||||
it can contain a special character % followed by a string which means:
|
||||
%1 - "value" escaped as for html
|
||||
%2 - "some text" escaped as for html
|
||||
%u1 - "value" trimmed and escaped as for url-es
|
||||
%u2 - "some text" trimmed and escaped as for url-es
|
||||
%% - one %
|
||||
|
||||
if you are using %2 or %u2 then "some text" is not treated as bbcode, e.g.
|
||||
[bbcodetag=value]some [b]text[/b][/bbcodetag] will produce:
|
||||
<htmltag arg="value">some [b]text[/b]</htmltag> (the inner tags [b][/b] were not parsed)
|
||||
|
||||
also when using %2 or %u2 the closing bbcode tag is skipped
|
||||
(if you want this tag then you can put it in 'html_argument')
|
||||
|
||||
and when using u (%u1 or %u2) the argument is trimmed from whitespaces and new lines
|
||||
at the beginning and at the end
|
||||
(because otherwise a space would be changed to %20 and this were probably not what you really wanted)
|
||||
*/
|
||||
const BBCODEParser::Tags * BBCODEParser::FindTag(const wchar_t * tag)
|
||||
{
|
||||
static Tags tags[] = {
|
||||
{L"*", L"li", L">", false},
|
||||
{L"b", L"em", L">", true},
|
||||
{L"i", L"span", L" class=\"bbitalic\">", true},
|
||||
{L"u", L"span", L" class=\"bbunderline\">", true},
|
||||
{L"s", L"span", L" class=\"bbstrike\">", true},
|
||||
{L"code", L"code", L" class=\"bbcode\">", false},
|
||||
{L"list", L"ul", L" class=\"bblist\">", false},
|
||||
{L"color", L"span", L" class=\"bbcol%1\">", true},
|
||||
{L"url", L"a", L" href=\"%u1\">", true},
|
||||
{L"img", L"img", L" alt=\"%1\" src=\"%u2\">", true},
|
||||
{L"quote", L"div", L" class=\"bbquote\">\n<span class=\"bbquotewho\">%1</span><br>\n", false},
|
||||
};
|
||||
|
||||
size_t i;
|
||||
size_t len = sizeof(tags) / sizeof(Tags);
|
||||
|
||||
for(i=0 ; i<len ; ++i)
|
||||
{
|
||||
if( Equal(tag, tags[i].bbcode) )
|
||||
return &tags[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const BBCODEParser::Tags * BBCODEParser::FindTag(const std::wstring & tag)
|
||||
{
|
||||
return FindTag(tag.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PrintArgumentCheckQuotes(const wchar_t * & start, const wchar_t * & end)
|
||||
{
|
||||
// skipping white characters from the argument
|
||||
while( start<end && IsWhite(*start) )
|
||||
++start;
|
||||
|
||||
// skipping first '=' character if exists
|
||||
if( start<end && *start == '=' )
|
||||
++start;
|
||||
|
||||
// skipping white characters from the argument
|
||||
// at the beginning
|
||||
while( start<end && IsWhite(*start) )
|
||||
++start;
|
||||
|
||||
// and at the end
|
||||
while( start<end && IsWhite(*(end-1)) )
|
||||
--end;
|
||||
|
||||
|
||||
if( start<end && (*start=='\'' || *start=='\"') )
|
||||
{
|
||||
++start;
|
||||
|
||||
if( start<end && *(start-1) == *(end-1) )
|
||||
--end;
|
||||
|
||||
// skipping white characters after a first quote char [url = " ww...."]
|
||||
while( start<end && IsWhite(*start) )
|
||||
++start;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PrintEncode(int c)
|
||||
{
|
||||
if( c == '&' )
|
||||
{
|
||||
(*out_string) += L"&";
|
||||
}
|
||||
else
|
||||
if( (c>='a' && c<='z') ||
|
||||
(c>='A' && c<='Z') ||
|
||||
(c>='0' && c<='9') ||
|
||||
(c=='_' || c=='?' || c=='.' || c==',' || c=='/' || c=='-' ||
|
||||
c=='+' || c=='*' || c=='(' || c==')' || c=='=' || c==':')
|
||||
)
|
||||
{
|
||||
(*out_string) += c;
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t buffer[20];
|
||||
swprintf(buffer, 20, L"%02X", c);
|
||||
|
||||
(*out_string) += '%';
|
||||
(*out_string) += buffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PrintEscape(int c, bool change_quote)
|
||||
{
|
||||
if( c == '<' )
|
||||
{
|
||||
(*out_string) += L"<";
|
||||
}
|
||||
else
|
||||
if( c == '>' )
|
||||
{
|
||||
(*out_string) += L">";
|
||||
}
|
||||
else
|
||||
if( c == '&' )
|
||||
{
|
||||
(*out_string) += L"&";
|
||||
}
|
||||
else
|
||||
if( c == '\"' && change_quote )
|
||||
{
|
||||
(*out_string) += L""";
|
||||
}
|
||||
else
|
||||
{
|
||||
(*out_string) += c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PrintArgumentEncode(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
PrintArgumentCheckQuotes(start, end);
|
||||
TrimWhiteWithNewLines(start, end);
|
||||
|
||||
for( ; start<end ; ++start )
|
||||
PrintEncode(*start);
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PrintArgumentEscape(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
PrintArgumentCheckQuotes(start, end);
|
||||
|
||||
for( ; start<end ; ++start )
|
||||
PrintEscape(*start, true); // quotes are escaped as well here
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::CheckOpeningTag(const Tags * tag, const wchar_t * tag_name, bool & condition)
|
||||
{
|
||||
if( Equal(tag->html_tag, tag_name) )
|
||||
{
|
||||
if( condition )
|
||||
{
|
||||
PutClosingTag(tag);
|
||||
(*out_string) += '\n';
|
||||
}
|
||||
|
||||
condition = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::CheckOpeningTag(const Tags * tag)
|
||||
{
|
||||
bool has_list_tag = has_open_ul_tag || has_open_ol_tag;
|
||||
|
||||
CheckOpeningTag(tag, L"li", has_open_li_tag);
|
||||
CheckOpeningTag(tag, L"ul", has_open_ul_tag);
|
||||
CheckOpeningTag(tag, L"ol", has_open_ol_tag);
|
||||
|
||||
if( has_open_li_tag && !has_list_tag )
|
||||
{
|
||||
(*out_string) += L"<ul>\n";
|
||||
has_open_ul_tag = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PrintEscape(const wchar_t * start, const wchar_t * end, bool change_quote)
|
||||
{
|
||||
for( ; start < end ; ++start)
|
||||
PrintEscape(*start, change_quote);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PrintEncode(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
for( ; start < end ; ++start)
|
||||
PrintEncode(*start);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PutOpeningTagFromEzc()
|
||||
{
|
||||
// this can be a tag from Ezc templates system
|
||||
(*out_string) += '[';
|
||||
(*out_string) += LastItem().name;
|
||||
|
||||
const wchar_t * start = pchar;
|
||||
|
||||
while( *pchar && *pchar!=']' )
|
||||
++pchar;
|
||||
|
||||
if( *pchar == ']' )
|
||||
++pchar;
|
||||
|
||||
Put(start, pchar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PutHtmlArgument1(const wchar_t * arg_start, const wchar_t * arg_end, bool has_u)
|
||||
{
|
||||
if( has_u )
|
||||
PrintArgumentEncode(arg_start, arg_end);
|
||||
else
|
||||
PrintArgumentEscape(arg_start, arg_end);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::TrimWhiteWithNewLines(const wchar_t * & start, const wchar_t * & end)
|
||||
{
|
||||
while( start < end && (IsWhite(*start) || *start==10) )
|
||||
++start;
|
||||
|
||||
while( start < end && (IsWhite(*(end-1)) || *(end-1)==10) )
|
||||
--end;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PutHtmlArgument2(const Tags * tag, bool has_u)
|
||||
{
|
||||
const wchar_t * start = pchar;
|
||||
const wchar_t * end = pchar;
|
||||
bool first_tag_removed = false;
|
||||
|
||||
while( *pchar != 0 )
|
||||
{
|
||||
if( IsOpeningTagMark() )
|
||||
{
|
||||
if( IsClosingTagForLastItem() )
|
||||
{
|
||||
// the last tag is skipped when using patterns with %2 or %u2
|
||||
|
||||
PopStack(); // removing opening tag from the stack
|
||||
first_tag_removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pchar += 1;
|
||||
end = pchar;
|
||||
}
|
||||
}
|
||||
|
||||
if( !first_tag_removed )
|
||||
PopStack(); // user has forgotten to close the tag
|
||||
|
||||
if( has_u )
|
||||
{
|
||||
TrimWhiteWithNewLines(start, end);
|
||||
PrintEncode(start, end);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintEscape(start, end);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PutHtmlArgument(const Tags * tag, const wchar_t * arg_start, const wchar_t * arg_end)
|
||||
{
|
||||
const wchar_t * pattern = tag->html_argument;
|
||||
bool has_u;
|
||||
|
||||
while( *pattern )
|
||||
{
|
||||
if( *pattern == '%' )
|
||||
{
|
||||
++pattern;
|
||||
has_u = false;
|
||||
|
||||
if( *pattern == 'u' )
|
||||
{
|
||||
++pattern;
|
||||
has_u = true;
|
||||
}
|
||||
|
||||
if( *pattern == '1' )
|
||||
{
|
||||
++pattern;
|
||||
PutHtmlArgument1(arg_start, arg_end, has_u);
|
||||
}
|
||||
else
|
||||
if( *pattern == '2' )
|
||||
{
|
||||
++pattern;
|
||||
PutHtmlArgument2(tag, has_u);
|
||||
}
|
||||
else
|
||||
if( *pattern == '%' )
|
||||
{
|
||||
(*out_string) += '%';
|
||||
++pattern;
|
||||
}
|
||||
// else unrecognized, will be printed next time as a normal character
|
||||
}
|
||||
else
|
||||
{
|
||||
(*out_string) += *pattern;
|
||||
++pattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PutOpeningTagFromBBCode(const Tags * tag)
|
||||
{
|
||||
CheckOpeningTag(tag);
|
||||
PutOpeningTagMark();
|
||||
Put(tag->html_tag);
|
||||
|
||||
const wchar_t * start = pchar;
|
||||
|
||||
while( *pchar && *pchar != ']' )
|
||||
++pchar;
|
||||
|
||||
PutHtmlArgument(tag, start, pchar);
|
||||
|
||||
if( *pchar == ']' )
|
||||
++pchar;
|
||||
|
||||
if( !tag->inline_tag )
|
||||
{
|
||||
Put(10);
|
||||
SkipWhiteLines();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool BBCODEParser::PutOpeningTag()
|
||||
{
|
||||
const Tags * tag = FindTag(LastItem().name);
|
||||
|
||||
if( !tag )
|
||||
PutOpeningTagFromEzc();
|
||||
else
|
||||
PutOpeningTagFromBBCode(tag);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PutClosingTag(const Tags * tag)
|
||||
{
|
||||
if( !tag )
|
||||
return; // skipping the tag
|
||||
|
||||
PutOpeningTagMark();
|
||||
(*out_string) += '/';
|
||||
(*out_string) += tag->html_tag;
|
||||
PutClosingTagMark();
|
||||
|
||||
if( !tag->inline_tag )
|
||||
{
|
||||
(*out_string) += L"\n";
|
||||
SkipWhiteLines();
|
||||
}
|
||||
|
||||
if( Equal(tag->html_tag, L"li") )
|
||||
has_open_li_tag = false;
|
||||
|
||||
if( Equal(tag->html_tag, L"ol") )
|
||||
has_open_ol_tag = false;
|
||||
|
||||
if( Equal(tag->html_tag, L"ul") )
|
||||
has_open_ul_tag = false;
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PutClosingTag(const wchar_t * tag_name)
|
||||
{
|
||||
const Tags * tag = FindTag(tag_name);
|
||||
PutClosingTag(tag);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::Init()
|
||||
{
|
||||
has_open_li_tag = false;
|
||||
has_open_ol_tag = false;
|
||||
has_open_ul_tag = false;
|
||||
|
||||
SkipWhiteLines();
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::Uninit()
|
||||
{
|
||||
if( has_open_li_tag )
|
||||
(*out_string) += L"</li>\n";
|
||||
|
||||
if( has_open_ol_tag )
|
||||
(*out_string) += L"</ol>\n";
|
||||
|
||||
if( has_open_ul_tag )
|
||||
(*out_string) += L"</ul>\n";
|
||||
}
|
||||
93
core/bbcodeparser.h
Executable file
93
core/bbcodeparser.h
Executable file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_bbcodeparser
|
||||
#define headerfile_winix_core_bbcodeparser
|
||||
|
||||
#include "htmlfilter.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class BBCODEParser : public HTMLFilter
|
||||
{
|
||||
|
||||
struct Tags
|
||||
{
|
||||
const wchar_t * bbcode;
|
||||
const wchar_t * html_tag;
|
||||
const wchar_t * html_argument; // with closing '>'
|
||||
bool inline_tag;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
virtual methods
|
||||
(from HTMLFilter class)
|
||||
*/
|
||||
virtual void Init();
|
||||
virtual void Uninit();
|
||||
|
||||
virtual bool IsOpeningTagMark();
|
||||
virtual bool IsOpeningCommentaryTagMark();
|
||||
virtual bool IsClosingTagMark();
|
||||
virtual bool IsClosingXmlSimpleTagMark();
|
||||
|
||||
virtual bool IsValidCharForName(int c);
|
||||
virtual void CheckExceptions();
|
||||
virtual bool SkipCommentaryTagIfExists();
|
||||
|
||||
virtual bool PutOpeningTag();
|
||||
virtual void PutClosingTag(const wchar_t * tag);
|
||||
|
||||
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
|
||||
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
others
|
||||
*/
|
||||
bool Equal(const wchar_t * str1, const wchar_t * str2);
|
||||
|
||||
void PutHtmlArgument1(const wchar_t * arg_start, const wchar_t * arg_end, bool has_u);
|
||||
void PutHtmlArgument2(const Tags * tag, bool has_u);
|
||||
void PutHtmlArgument(const Tags * tag, const wchar_t * arg_start, const wchar_t * arg_end);
|
||||
|
||||
void PutOpeningTagFromEzc();
|
||||
void PutOpeningTagFromBBCode(const Tags * tag);
|
||||
|
||||
const Tags * FindTag(const wchar_t * tag);
|
||||
const Tags * FindTag(const std::wstring & tag);
|
||||
void PrintArgumentCheckQuotes(const wchar_t * & start, const wchar_t * & end);
|
||||
|
||||
void PrintEscape(int c, bool change_quote = false);
|
||||
void PrintEncode(int c);
|
||||
|
||||
void PrintEscape(const wchar_t * start, const wchar_t * end, bool change_quote = false);
|
||||
void PrintEncode(const wchar_t * start, const wchar_t * end);
|
||||
|
||||
void PrintArgumentEncode(const wchar_t * start, const wchar_t * end);
|
||||
void PrintArgumentEscape(const wchar_t * start, const wchar_t * end);
|
||||
|
||||
void PutClosingTag(const Tags * tag);
|
||||
|
||||
void CheckOpeningTag(const Tags * tag, const wchar_t * tag_name, bool & condition);
|
||||
void CheckOpeningTag(const Tags * tag);
|
||||
|
||||
void TrimWhiteWithNewLines(const wchar_t * & start, const wchar_t * & end);
|
||||
|
||||
|
||||
|
||||
bool has_open_ol_tag; // has open html <ol> tag
|
||||
bool has_open_ul_tag; // has open html <ul> tag
|
||||
bool has_open_li_tag; // has open html <li> tag
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,172 +1,392 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "compress.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
|
||||
Compress::Compress()
|
||||
{
|
||||
buffer = 0;
|
||||
buffer_max_len = 65536; // 64KB
|
||||
ready_for_compress = false;
|
||||
}
|
||||
|
||||
|
||||
Compress::~Compress()
|
||||
{
|
||||
if( buffer )
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
|
||||
bool Compress::AllocateMemory()
|
||||
{
|
||||
if( buffer )
|
||||
delete [] buffer;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
buffer = new char[buffer_max_len];
|
||||
}
|
||||
catch(const std::bad_alloc &)
|
||||
{
|
||||
log << log1 << "Compress: can't allocate memory" << logend;
|
||||
|
||||
buffer = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
return:
|
||||
0 - ok;
|
||||
1 - can't allocate memory
|
||||
100 - unknown
|
||||
*/
|
||||
int Compress::Init(int compress_level)
|
||||
{
|
||||
if( buffer == 0 )
|
||||
if( !AllocateMemory() )
|
||||
return 1;
|
||||
|
||||
strm.zalloc = Z_NULL;
|
||||
strm.zfree = Z_NULL;
|
||||
strm.opaque = Z_NULL;
|
||||
int ret = deflateInit(&strm, compress_level);
|
||||
|
||||
if( ret != Z_OK )
|
||||
log << log1 << "Compress: problem with deflateInit()" << logend;
|
||||
|
||||
if( ret == Z_MEM_ERROR )
|
||||
return 1;
|
||||
|
||||
if( ret != Z_OK )
|
||||
return 100;
|
||||
|
||||
ready_for_compress = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Compress::MakeCompress(const char * source, size_t source_len, FCGX_Stream * out_stream)
|
||||
{
|
||||
int ret, flush;
|
||||
size_t have;
|
||||
|
||||
do
|
||||
{
|
||||
strm.avail_in = (source_len > buffer_max_len) ? buffer_max_len : source_len;
|
||||
source_len -= strm.avail_in;
|
||||
flush = (source_len == 0) ? Z_FINISH : Z_NO_FLUSH;
|
||||
strm.next_in = (Bytef*)source;
|
||||
source += strm.avail_in;
|
||||
|
||||
do
|
||||
{
|
||||
strm.avail_out = buffer_max_len;
|
||||
strm.next_out = (Bytef*)buffer;
|
||||
ret = deflate(&strm, flush);
|
||||
|
||||
if( ret == Z_STREAM_ERROR || ret == Z_BUF_ERROR )
|
||||
{
|
||||
log << log1 << "Compress: problem with deflate()" << logend;
|
||||
return 2;
|
||||
}
|
||||
|
||||
have = buffer_max_len - strm.avail_out;
|
||||
last_out_size += have;
|
||||
FCGX_PutStr(buffer, have, out_stream);
|
||||
}
|
||||
while( strm.avail_out == 0 );
|
||||
|
||||
if( strm.avail_in != 0 )
|
||||
{
|
||||
log << log1 << "Compress: problem with deflate() - not all input is used" << logend;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
while( flush != Z_FINISH );
|
||||
|
||||
|
||||
if( ret != Z_STREAM_END )
|
||||
{
|
||||
log << log1 << "Compress: problem with deflate() - stream not complete" << logend;
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
return:
|
||||
0 - ok;
|
||||
1 - can't allocate memory
|
||||
2 - error during compressing
|
||||
3 - not inited (use Init() first)
|
||||
100 - unknown
|
||||
*/
|
||||
int Compress::CompressAndPut(const char * source, size_t source_len, FCGX_Stream * out_stream, int level)
|
||||
{
|
||||
int ret;
|
||||
|
||||
last_out_size = 0;
|
||||
|
||||
if( !ready_for_compress )
|
||||
{
|
||||
log << log1 << "Compress: not ready yet" << logend;
|
||||
return 3;
|
||||
}
|
||||
|
||||
if( source_len == 0 )
|
||||
return 0;
|
||||
|
||||
ret = MakeCompress(source, source_len, out_stream);
|
||||
|
||||
if( deflateReset(&strm) != Z_OK )
|
||||
log << log1 << "Compress: problem with deflateReset()" << logend;
|
||||
|
||||
double ratio = (double(last_out_size) / double(source_len) * 100.0);
|
||||
log << log2 << "Compress: original size: " << source_len << ", compress size: " << (int)last_out_size << ", ratio: " << ratio << "%" << logend;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "compress.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
|
||||
Compress::Compress()
|
||||
{
|
||||
buffer_in = 0;
|
||||
buffer_out = 0;
|
||||
buffer_max_len = 65536; // 64KB
|
||||
ready_for_compress = false;
|
||||
compress_level = 6;
|
||||
raw_deflate_inited = false;
|
||||
deflate_inited = false;
|
||||
gzip_inited = false;
|
||||
}
|
||||
|
||||
|
||||
Compress::~Compress()
|
||||
{
|
||||
delete [] buffer_in;
|
||||
delete [] buffer_out;
|
||||
|
||||
if( raw_deflate_inited )
|
||||
deflateEnd(&strm_raw_deflate);
|
||||
|
||||
if( deflate_inited )
|
||||
deflateEnd(&strm_deflate);
|
||||
|
||||
if( gzip_inited )
|
||||
deflateEnd(&strm_gzip);
|
||||
}
|
||||
|
||||
|
||||
bool Compress::AllocateMemory()
|
||||
{
|
||||
if( buffer_in )
|
||||
delete [] buffer_in;
|
||||
|
||||
if( buffer_out )
|
||||
delete [] buffer_out;
|
||||
|
||||
buffer_in = 0;
|
||||
buffer_out = 0;
|
||||
|
||||
try
|
||||
{
|
||||
buffer_in = new char[buffer_max_len];
|
||||
buffer_out = new char[buffer_max_len];
|
||||
}
|
||||
catch(const std::bad_alloc &)
|
||||
{
|
||||
log << log1 << "Compress: can't allocate memory" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Compress::InitRawDeflate()
|
||||
{
|
||||
raw_deflate_inited = false;
|
||||
|
||||
strm_raw_deflate.next_in = 0;
|
||||
strm_raw_deflate.zalloc = Z_NULL;
|
||||
strm_raw_deflate.zfree = Z_NULL;
|
||||
strm_raw_deflate.opaque = Z_NULL;
|
||||
|
||||
int ret = deflateInit2(&strm_raw_deflate, compress_level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
|
||||
|
||||
if( ret != Z_OK )
|
||||
log << log1 << "Compress: problem with deflateInit2() for raw deflate" << logend;
|
||||
else
|
||||
raw_deflate_inited = true;
|
||||
|
||||
return ret == Z_OK;
|
||||
}
|
||||
|
||||
|
||||
bool Compress::InitDeflate()
|
||||
{
|
||||
deflate_inited = false;
|
||||
|
||||
strm_deflate.next_in = 0;
|
||||
strm_deflate.zalloc = Z_NULL;
|
||||
strm_deflate.zfree = Z_NULL;
|
||||
strm_deflate.opaque = Z_NULL;
|
||||
|
||||
int ret = deflateInit2(&strm_deflate, compress_level, Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY);
|
||||
|
||||
if( ret != Z_OK )
|
||||
log << log1 << "Compress: problem with deflateInit2() for deflate" << logend;
|
||||
else
|
||||
deflate_inited = true;
|
||||
|
||||
return ret == Z_OK;
|
||||
}
|
||||
|
||||
|
||||
bool Compress::InitGzip()
|
||||
{
|
||||
gzip_inited = false;
|
||||
|
||||
strm_gzip.next_in = 0;
|
||||
strm_gzip.zalloc = Z_NULL;
|
||||
strm_gzip.zfree = Z_NULL;
|
||||
strm_gzip.opaque = Z_NULL;
|
||||
|
||||
int ret = deflateInit2(&strm_gzip, compress_level, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY);
|
||||
|
||||
if( ret != Z_OK )
|
||||
log << log1 << "Compress: problem with deflateInit2() for gzip" << logend;
|
||||
else
|
||||
gzip_inited = true;
|
||||
|
||||
return ret == Z_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
return:
|
||||
0 - ok
|
||||
1 - can't allocate memory
|
||||
100 - unknown error
|
||||
*/
|
||||
int Compress::Init(int compress_level_)
|
||||
{
|
||||
compress_level = compress_level_;
|
||||
|
||||
if( !AllocateMemory() )
|
||||
return 1;
|
||||
|
||||
if( InitRawDeflate() && InitDeflate() && InitGzip() )
|
||||
ready_for_compress = true;
|
||||
else
|
||||
return 100;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Compress::MakeCompress(z_stream & strm, const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding)
|
||||
{
|
||||
int ret, flush;
|
||||
size_t have;
|
||||
|
||||
do
|
||||
{
|
||||
strm.avail_in = (source_len > buffer_max_len) ? buffer_max_len : source_len;
|
||||
source_len -= strm.avail_in;
|
||||
flush = (source_len == 0) ? Z_FINISH : Z_NO_FLUSH;
|
||||
strm.next_in = (Bytef*)source;
|
||||
source += strm.avail_in;
|
||||
|
||||
do
|
||||
{
|
||||
strm.avail_out = buffer_max_len;
|
||||
strm.next_out = (Bytef*)buffer_out;
|
||||
ret = deflate(&strm, flush);
|
||||
|
||||
if( ret == Z_STREAM_ERROR || ret == Z_BUF_ERROR )
|
||||
{
|
||||
log << log1 << "Compress: problem with deflate()" << logend;
|
||||
return 2;
|
||||
}
|
||||
|
||||
have = buffer_max_len - strm.avail_out;
|
||||
last_out_size += have;
|
||||
FCGX_PutStr(buffer_out, have, out_stream);
|
||||
}
|
||||
while( strm.avail_out == 0 );
|
||||
|
||||
if( strm.avail_in != 0 )
|
||||
{
|
||||
log << log1 << "Compress: problem with deflate() - not all input is used" << logend;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
while( flush != Z_FINISH );
|
||||
|
||||
|
||||
if( ret != Z_STREAM_END )
|
||||
{
|
||||
log << log1 << "Compress: problem with deflate() - stream not complete" << logend;
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Compress::CopyToInputBuffer(BinaryPage::const_iterator & i, size_t len)
|
||||
{
|
||||
for(size_t a=0 ; a<len ; ++a, ++i)
|
||||
buffer_in[a] = *i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// new way
|
||||
int Compress::MakeCompress(z_stream & strm, const BinaryPage & page, BinaryPage & out, int encoding)
|
||||
{
|
||||
int ret, flush;
|
||||
size_t have;
|
||||
BinaryPage::const_iterator i = page.begin();
|
||||
|
||||
size_t source_len = page.size();
|
||||
|
||||
do
|
||||
{
|
||||
strm.avail_in = (source_len > buffer_max_len) ? buffer_max_len : source_len;
|
||||
source_len -= strm.avail_in;
|
||||
flush = (source_len == 0) ? Z_FINISH : Z_NO_FLUSH;
|
||||
strm.next_in = (Bytef*)buffer_in;
|
||||
CopyToInputBuffer(i, strm.avail_in);
|
||||
|
||||
do
|
||||
{
|
||||
strm.avail_out = buffer_max_len;
|
||||
strm.next_out = (Bytef*)buffer_out;
|
||||
ret = deflate(&strm, flush);
|
||||
|
||||
if( ret == Z_STREAM_ERROR || ret == Z_BUF_ERROR )
|
||||
{
|
||||
log << log1 << "Compress: problem with deflate()" << logend;
|
||||
return 2;
|
||||
}
|
||||
|
||||
have = buffer_max_len - strm.avail_out;
|
||||
last_out_size += have;
|
||||
out.write(buffer_out, have);
|
||||
}
|
||||
while( strm.avail_out == 0 );
|
||||
|
||||
if( strm.avail_in != 0 )
|
||||
{
|
||||
log << log1 << "Compress: problem with deflate() - not all input is used" << logend;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
while( flush != Z_FINISH );
|
||||
|
||||
|
||||
if( ret != Z_STREAM_END )
|
||||
{
|
||||
log << log1 << "Compress: problem with deflate() - stream not complete" << logend;
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
z_stream * Compress::SelectStream(int encoding)
|
||||
{
|
||||
z_stream * pstrm;
|
||||
|
||||
if( encoding == 0 )
|
||||
pstrm = &strm_raw_deflate;
|
||||
else
|
||||
if( encoding == 1 )
|
||||
pstrm = &strm_deflate;
|
||||
else
|
||||
pstrm = &strm_gzip;
|
||||
|
||||
return pstrm;
|
||||
}
|
||||
|
||||
|
||||
void Compress::ResetStream(z_stream * pstrm, int encoding)
|
||||
{
|
||||
if( deflateReset(pstrm) != Z_OK )
|
||||
{
|
||||
log << log1 << "Compress: problem with deflateReset()" << logend;
|
||||
|
||||
deflateEnd(pstrm);
|
||||
|
||||
if( encoding == 0 )
|
||||
InitRawDeflate();
|
||||
else
|
||||
if( encoding == 1 )
|
||||
InitDeflate();
|
||||
else
|
||||
InitGzip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Compress::PutLog(size_t source_len, int encoding)
|
||||
{
|
||||
double ratio = 100.0 - (double(last_out_size) / double(source_len) * 100.0);
|
||||
char buffer[30];
|
||||
sprintf(buffer, "%.1f", ratio);
|
||||
|
||||
log << log2 << "Compress: ";
|
||||
|
||||
if( encoding == 0 )
|
||||
log << "raw deflate";
|
||||
else
|
||||
if( encoding == 1 )
|
||||
log << "deflate";
|
||||
else
|
||||
log << "gzip";
|
||||
|
||||
log << ", original size: " << source_len << ", size after compressing: "
|
||||
<< (int)last_out_size << ", ratio: " << buffer << "%" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
return:
|
||||
0 - ok;
|
||||
1 - can't allocate memory
|
||||
2 - error during compressing
|
||||
3 - not inited (use Init() first)
|
||||
100 - unknown
|
||||
*/
|
||||
int Compress::CompressAndPut(const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding)
|
||||
{
|
||||
int ret;
|
||||
z_stream * pstrm;
|
||||
|
||||
last_out_size = 0;
|
||||
|
||||
if( !ready_for_compress )
|
||||
{
|
||||
log << log1 << "Compress: not ready yet" << logend;
|
||||
return 3;
|
||||
}
|
||||
|
||||
if( source_len == 0 )
|
||||
return 0;
|
||||
|
||||
pstrm = SelectStream(encoding);
|
||||
ret = MakeCompress(*pstrm, source, source_len, out_stream, encoding);
|
||||
ResetStream(pstrm, encoding);
|
||||
PutLog(source_len, encoding);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
return:
|
||||
0 - ok;
|
||||
1 - can't allocate memory
|
||||
2 - error during compressing
|
||||
3 - not inited (use Init() first)
|
||||
100 - unknown
|
||||
*/
|
||||
int Compress::Compressing(const BinaryPage & in, BinaryPage & out, int encoding)
|
||||
{
|
||||
int ret;
|
||||
z_stream * pstrm;
|
||||
|
||||
last_out_size = 0;
|
||||
out.clear();
|
||||
|
||||
if( !ready_for_compress )
|
||||
{
|
||||
log << log1 << "Compress: not ready yet" << logend;
|
||||
return 3;
|
||||
}
|
||||
|
||||
if( in.empty() )
|
||||
return 0;
|
||||
|
||||
pstrm = SelectStream(encoding);
|
||||
ret = MakeCompress(*pstrm, in, out, encoding);
|
||||
ResetStream(pstrm, encoding);
|
||||
PutLog(in.size(), encoding);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,43 +1,70 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorecompress
|
||||
#define headerfilecmslucorecompress
|
||||
|
||||
#include <cstring>
|
||||
#include <fcgiapp.h>
|
||||
#include <zlib.h>
|
||||
|
||||
|
||||
class Compress
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Compress();
|
||||
~Compress();
|
||||
|
||||
int Init(int compress_level = 6);
|
||||
int CompressAndPut(const char * source, size_t source_len, FCGX_Stream * out_stream, int level = 6);
|
||||
size_t last_out_size;
|
||||
|
||||
private:
|
||||
|
||||
bool AllocateMemory();
|
||||
int MakeCompress(const char * source, size_t source_len, FCGX_Stream * out_stream);
|
||||
|
||||
size_t buffer_max_len;
|
||||
char * buffer;
|
||||
z_stream strm;
|
||||
bool ready_for_compress;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef headerfile_winix_core_compress
|
||||
#define headerfile_winix_core_compress
|
||||
|
||||
#include <cstring>
|
||||
#include <fcgiapp.h>
|
||||
#include <zlib.h>
|
||||
#include "requesttypes.h"
|
||||
|
||||
|
||||
|
||||
class Compress
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Compress();
|
||||
~Compress();
|
||||
|
||||
int Init(int compress_level_ = 6);
|
||||
|
||||
/*
|
||||
encoding:
|
||||
0 - raw deflate data with no zlib header or trailer, and will not compute an adler32 check value
|
||||
(for Internet Explorer)
|
||||
1 - deflate
|
||||
2 - gzip
|
||||
*/
|
||||
int CompressAndPut(const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding = 2);
|
||||
int Compressing(const BinaryPage & in, BinaryPage & out, int encoding = 2);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
bool AllocateMemory();
|
||||
bool InitRawDeflate();
|
||||
bool InitDeflate();
|
||||
bool InitGzip();
|
||||
|
||||
int MakeCompress(z_stream & strm, const char * source, size_t source_len, FCGX_Stream * out_stream, int encoding);
|
||||
int MakeCompress(z_stream & strm, const BinaryPage & page, BinaryPage & out, int encoding);
|
||||
z_stream * SelectStream(int encoding);
|
||||
void ResetStream(z_stream * pstrm, int encoding);
|
||||
void PutLog(size_t source_len, int encoding);
|
||||
void CopyToInputBuffer(BinaryPage::const_iterator & i, size_t len);
|
||||
|
||||
int compress_level;
|
||||
size_t buffer_max_len;
|
||||
|
||||
// size of the last compressed page
|
||||
size_t last_out_size;
|
||||
|
||||
char * buffer_in;
|
||||
char * buffer_out;
|
||||
z_stream strm_raw_deflate, strm_deflate, strm_gzip;
|
||||
bool raw_deflate_inited, deflate_inited, gzip_inited;
|
||||
bool ready_for_compress;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
447
core/config.cpp
447
core/config.cpp
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "data.h"
|
||||
#include "plugin.h"
|
||||
#include "misc.h"
|
||||
#include "crypt.h"
|
||||
|
||||
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
default_int = 0;
|
||||
default_bool = false;
|
||||
|
||||
errors_to_stdout = true;
|
||||
}
|
||||
|
||||
@@ -29,24 +29,28 @@ Config::Config()
|
||||
void Config::ShowError()
|
||||
{
|
||||
|
||||
switch( conf_parser.status )
|
||||
switch( parser.status )
|
||||
{
|
||||
case ConfParser::ok:
|
||||
case PT::SpaceParser::no_space:
|
||||
log << log2 << "Config: space not set" << logend;
|
||||
break;
|
||||
|
||||
case PT::SpaceParser::ok:
|
||||
log << log2 << "Config: syntax ok" << logend;
|
||||
break;
|
||||
|
||||
case ConfParser::cant_open_file:
|
||||
case PT::SpaceParser::cant_open_file:
|
||||
if( errors_to_stdout )
|
||||
std::cout << "Config: cant open a config file: " << data.config_file << std::endl;
|
||||
std::cout << "Config: cant open a config file: " << config_file << std::endl;
|
||||
|
||||
log << log1 << "Config: cant open a config file: " << data.config_file << logend;
|
||||
log << log1 << "Config: cant open a config file: " << config_file << logend;
|
||||
break;
|
||||
|
||||
case ConfParser::syntax_error:
|
||||
case PT::SpaceParser::syntax_error:
|
||||
if( errors_to_stdout )
|
||||
std::cout << "Config: syntax error, line: " << conf_parser.line << std::endl;
|
||||
std::cout << "Config: syntax error, line: " << parser.line << std::endl;
|
||||
|
||||
log << log1 << "Config: syntax error, line: " << conf_parser.line << logend;
|
||||
log << log1 << "Config: syntax error, line: " << parser.line << logend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -56,11 +60,11 @@ void Config::ShowError()
|
||||
|
||||
|
||||
|
||||
bool Config::ReadConfig(bool errors_to_stdout_)
|
||||
bool Config::ReadConfig(bool errors_to_stdout_, bool stdout_is_closed)
|
||||
{
|
||||
errors_to_stdout = errors_to_stdout_;
|
||||
|
||||
if( data.config_file.empty() )
|
||||
if( config_file.empty() )
|
||||
{
|
||||
log << log2 << "Config: name of the config file is empty" << logend;
|
||||
return false;
|
||||
@@ -68,14 +72,16 @@ bool Config::ReadConfig(bool errors_to_stdout_)
|
||||
|
||||
log << log2 << "Config: reading a config file" << logend;
|
||||
|
||||
ConfParser::Status status = conf_parser.Parse( data.config_file.c_str() );
|
||||
parser.SplitSingle(true);
|
||||
parser.UTF8(true); // config is always read in UTF-8
|
||||
parser.SetSpace(space);
|
||||
|
||||
PT::SpaceParser::Status status = parser.Parse(config_file);
|
||||
|
||||
if( status == ConfParser::ok )
|
||||
if( status == PT::SpaceParser::ok )
|
||||
{
|
||||
AssignValues();
|
||||
|
||||
data.SetAdditionalVariables();
|
||||
AssignValues(stdout_is_closed);
|
||||
SetAdditionalVariables();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -87,113 +93,349 @@ bool Config::ReadConfig(bool errors_to_stdout_)
|
||||
|
||||
|
||||
|
||||
void Config::AssignValues()
|
||||
|
||||
void Config::AssignValues(bool stdout_is_closed)
|
||||
{
|
||||
data.log_file = Text("log_file");
|
||||
data.log_notify_file = Text("log_notify_file");
|
||||
data.fcgi_socket = Text("fcgi_socket");
|
||||
data.fcgi_socket_chmod = Int("fcgi_socket_chmod");
|
||||
data.fcgi_socket_user = Text("fcgi_socket_user");
|
||||
data.fcgi_socket_group = Text("fcgi_socket_group");
|
||||
data.log_level = Int("log_level");
|
||||
demonize = Bool(L"demonize", true);
|
||||
|
||||
user = AText(L"user");
|
||||
group = AText(L"group");
|
||||
additional_groups = Bool(L"additional_groups", true);
|
||||
|
||||
log_file = AText(L"log_file");
|
||||
log_notify_file = AText(L"log_notify_file");
|
||||
log_delimiter = Text(L"log_delimiter", L"---------------------------------------------------------------------------------");
|
||||
fcgi_socket = AText(L"fcgi_socket");
|
||||
fcgi_socket_chmod = Int(L"fcgi_socket_chmod", 0770);
|
||||
fcgi_socket_user = AText(L"fcgi_socket_user");
|
||||
fcgi_socket_group = AText(L"fcgi_socket_group");
|
||||
log_level = Int(L"log_level", 1);
|
||||
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_stdout = Bool(L"log_stdout", false);
|
||||
log_db_query = Bool(L"log_db_query", false);
|
||||
log_plugin_call = Bool(L"log_plugin_call", false);
|
||||
log_post_value_size = Size(L"log_post_value_size", 80);
|
||||
|
||||
post_file_max = Size(L"post_file_max", 8388608); // 8 MB
|
||||
|
||||
upload_dir = Text(L"upload_dir");
|
||||
common_dir = Text(L"common_dir");
|
||||
NoLastSlash(upload_dir);
|
||||
NoLastSlash(common_dir);
|
||||
|
||||
upload_dirs_chmod = Int(L"upload_dirs_chmod", 0750);
|
||||
upload_files_chmod = Int(L"upload_files_chmod", 0640);
|
||||
ListText(L"static_dirs", static_dirs);
|
||||
dont_use_static_dirs = Bool(L"dont_use_static_dirs", false);
|
||||
create_thumb = Bool(L"create_thumb", true);
|
||||
thumb_mode = Int(L"thumb_mode", 2);
|
||||
thumb_cx = Size(L"thumb_cx", 150);
|
||||
thumb_cy = Size(L"thumb_cy", 150);
|
||||
thumb_quality = Int(L"thumb_quality", 92);
|
||||
image_resize = Bool(L"image_resize", true);
|
||||
image_mode = Int(L"image_mode", 6);
|
||||
image_cx = Size(L"image_cx", 1000);
|
||||
image_cy = Size(L"image_cy", 800);
|
||||
image_quality = Int(L"image_quality", 92);
|
||||
convert_cmd = Text(L"convert_cmd", L"/usr/local/bin/convert");
|
||||
|
||||
templates_dir = Text(L"templates_dir");
|
||||
templates_dir_default = Text(L"templates_dir_default");
|
||||
txt_templates_dir = Text(L"txt_templates_dir");
|
||||
txt_templates_dir_default = Text(L"txt_templates_dir_default");
|
||||
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
|
||||
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
|
||||
templates_index = Text(L"templates_index", L"index.html");
|
||||
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
|
||||
|
||||
http_session_id_name = AText(L"http_session_id_name");
|
||||
db_database = AText(L"db_database");
|
||||
db_user = AText(L"db_user");
|
||||
db_pass = AText(L"db_pass");
|
||||
item_url_empty = Text(L"item_url_empty");
|
||||
|
||||
url_proto = Text(L"url_proto", L"http://");
|
||||
url_ssl_proto = Text(L"url_ssl_proto", L"https://");
|
||||
|
||||
use_ssl = Bool(L"use_ssl", false);
|
||||
use_ssl_static = Bool(L"use_ssl_static", false);
|
||||
use_ssl_common = Bool(L"use_ssl_common", false);
|
||||
use_ssl_only_for_logged_users = Bool(L"use_ssl_only_for_logged_users", true);
|
||||
use_ssl_redirect_code = Int(L"use_ssl_redirect_code", 303);
|
||||
|
||||
base_url = Text(L"base_url");
|
||||
base_url_static = Text(L"base_url_static");
|
||||
base_url_common = Text(L"base_url_common");
|
||||
|
||||
base_url_redirect = Bool(L"base_url_redirect", false);
|
||||
base_url_redirect_code = Int(L"base_url_redirect_code", 301);
|
||||
|
||||
NoLastSlash(base_url);
|
||||
NoLastSlash(base_url_static);
|
||||
NoLastSlash(base_url_common);
|
||||
|
||||
priv_no_user = Text(L"priv_no_user", L"-- no user --");
|
||||
priv_no_group = Text(L"priv_no_group", L"-- no group --");
|
||||
|
||||
if( !data.stdout_is_closed )
|
||||
data.log_stdout = Bool("log_stdout");
|
||||
session_max_idle = Int(L"session_max_idle", 10800); // 3h
|
||||
session_remember_max_idle = Int(L"session_remember_max_idle", 16070400); // 3 months
|
||||
session_file = AText(L"session_file");
|
||||
session_max = Size(L"session_max", 1000000);
|
||||
|
||||
compression = Bool(L"compression", true);
|
||||
compression_page_min_size = Size(L"compression_page_min_size", 512);
|
||||
compression_encoding = Int(L"compression_encoding", 20);
|
||||
|
||||
html_filter = Bool(L"html_filter", true);
|
||||
html_filter_trim_white = Bool(L"html_filter_trim_white", true);
|
||||
html_filter_break_word = Int(L"html_filter_break_word", 60);
|
||||
html_filter_wrap_line = Int(L"html_filter_wrap_line", 110);
|
||||
html_filter_tabs = Size(L"html_filter_tabs", 2);
|
||||
html_filter_orphans = Bool(L"html_filter_orphans", true);
|
||||
html_filter_orphans_mode_str = Text(L"html_filter_orphans_mode_str", L"nbsp");
|
||||
|
||||
locale_dir = Text(L"locale_dir");
|
||||
locale_dir_default = Text(L"locale_dir_default");
|
||||
locale_max_id = Size(L"locale_max_id", 100);
|
||||
locale_default_id = Size(L"locale_default_id", 0);
|
||||
ListText(L"locale_files", locale_files);
|
||||
|
||||
title_separator = Text(L"title_separator", L" / ");
|
||||
|
||||
http_header_send_file = Text(L"http_header_send_file", L"X-LIGHTTPD-send-file");
|
||||
debug_info = Bool(L"debug_info", false);
|
||||
|
||||
editors_html_safe_mode = Bool(L"editors_html_safe_mode", true);
|
||||
editors_html_safe_mode_skip_root = Bool(L"editors_html_safe_mode_skip_root", true);
|
||||
|
||||
plugins_dir = Text(L"plugins_dir", L"/usr/local/winix/plugins");
|
||||
NoLastSlash(plugins_dir);
|
||||
ListText(L"plugins", plugin_file);
|
||||
|
||||
utf8 = Bool(L"utf8", true);
|
||||
symlinks_follow_max = Size(L"symlinks_follow_max", 20);
|
||||
|
||||
ticket_form_prefix = Text(L"ticket_form_prefix", L"ticketparam");
|
||||
|
||||
pass_min_size = Size(L"pass_min_size", 5);
|
||||
pass_type = Int(L"pass_type", 12);
|
||||
pass_hash_use_salt = Bool(L"pass_hash_use_salt", false);
|
||||
pass_hash_salt = Text(L"pass_hash_salt");
|
||||
pass_use_rsa = Bool(L"pass_use_rsa", false);
|
||||
pass_rsa_private_key = Text(L"pass_rsa_private_key");
|
||||
|
||||
opensll_path = Text(L"opensll_path", L"/usr/bin/openssl");
|
||||
|
||||
pattern_cacher_when_delete = Size(L"pattern_cacher_when_delete", 130);
|
||||
pattern_cacher_how_many_delete = Size(L"pattern_cacher_how_many_delete", 30);
|
||||
|
||||
content_type_header = Int(L"content_type_header", 0);
|
||||
umask = Int(L"umask", 0222);
|
||||
|
||||
ezc_max_elements = Size(L"ezc_max_elements", 50000);
|
||||
ezc_max_loop_elements = Size(L"ezc_max_loop_elements", 5000);
|
||||
|
||||
account_need_email_verification = Bool(L"account_need_email_verification", true);
|
||||
reset_password_code_expiration_time = Long(L"reset_password_code_expiration_time", 86400);
|
||||
|
||||
time_zone_default_id = Size(L"time_zone_default_id", 34);
|
||||
time_zone_max_id = Size(L"time_zone_max_id", 130);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Config::SetAdditionalVariables()
|
||||
{
|
||||
if( html_filter_orphans_mode_str == L"160" )
|
||||
html_filter_orphans_mode = HTMLFilter::orphan_160space;
|
||||
else
|
||||
data.log_stdout = false;
|
||||
|
||||
data.templates = Text("templates");
|
||||
data.default_index = Text("default_index");
|
||||
data.http_session_id_name = Text("http_session_id_name");
|
||||
data.db_database = Text("db_database");
|
||||
data.db_user = Text("db_user");
|
||||
data.db_pass = Text("db_pass");
|
||||
data.base_url = Text("base_url");
|
||||
html_filter_orphans_mode = HTMLFilter::orphan_nbsp;
|
||||
|
||||
NoLastSlash(data.base_url);
|
||||
for(size_t i=0 ; i<static_dirs.size() ; ++i)
|
||||
NoLastSlash(static_dirs[i]);
|
||||
|
||||
data.one_item_is_showed = Bool("one_item_is_showed");
|
||||
CheckPasswd();
|
||||
|
||||
data.priv_no_user = Text("priv_no_user");
|
||||
data.priv_no_group = Text("priv_no_group");
|
||||
|
||||
data.session_max_iddle = Int("session_max_iddle");
|
||||
data.compression = Bool("compression");
|
||||
if( content_type_header < 0 || content_type_header > 2 )
|
||||
content_type_header = 0;
|
||||
|
||||
if( locale_default_id > locale_max_id )
|
||||
locale_default_id = locale_max_id;
|
||||
|
||||
if( locale_files.empty() )
|
||||
locale_files.push_back(L"en");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// !! mozna dodac drugi argument -- wartosc domyslna
|
||||
std::string & Config::Text(const char * name)
|
||||
|
||||
void Config::CheckPasswd()
|
||||
{
|
||||
ConfParser::Table::iterator i = conf_parser.table.find(name);
|
||||
|
||||
if( i == conf_parser.table.end() )
|
||||
switch(pass_type)
|
||||
{
|
||||
log << log2 << "Config: warning: " << name << " is not defined in the config, default will be: \"" << default_str << "\"" << logend;
|
||||
return default_str;
|
||||
case WINIX_CRYPT_HASH_NONE:
|
||||
case WINIX_CRYPT_HASH_MD4:
|
||||
case WINIX_CRYPT_HASH_MD5:
|
||||
case WINIX_CRYPT_HASH_SHA1:
|
||||
case WINIX_CRYPT_HASH_SHA224:
|
||||
case WINIX_CRYPT_HASH_SHA256:
|
||||
case WINIX_CRYPT_HASH_SHA384:
|
||||
case WINIX_CRYPT_HASH_SHA512:
|
||||
break;
|
||||
|
||||
default:
|
||||
pass_type = WINIX_CRYPT_HASH_SHA256;
|
||||
}
|
||||
|
||||
log << log3 << "Config: " << name << "=" << i->second << logend;
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! mozna dodac drugi argument -- wartosc domyslna
|
||||
int Config::Int(const char * name)
|
||||
|
||||
std::wstring & Config::Text(const wchar_t * name)
|
||||
{
|
||||
ConfParser::Table::iterator i = conf_parser.table.find(name);
|
||||
|
||||
if( i == conf_parser.table.end() || i->second.empty() )
|
||||
{
|
||||
log << log2 << "Config: warning: " << name << " is not defined in the config, default will be: " << default_int << logend;
|
||||
return default_int;
|
||||
}
|
||||
|
||||
long res = (i->second[0] == '0')? strtol(i->second.c_str() + 1, 0, 8) : strtol(i->second.c_str(), 0, 10);
|
||||
log << log3 << "Config: " << name << "=" << res << logend;
|
||||
|
||||
return res;
|
||||
return space.Text(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! mozna dodac drugi argument -- wartosc domyslna
|
||||
bool Config::Bool(const char * name)
|
||||
std::wstring & Config::Text(const wchar_t * name, const wchar_t * def)
|
||||
{
|
||||
ConfParser::Table::iterator i = conf_parser.table.find(name);
|
||||
|
||||
if( i == conf_parser.table.end() )
|
||||
{
|
||||
log << log2 << "Config: warning: " << name << " is not defined in the config, default will be: " << (default_bool?"true":"false") << logend;
|
||||
return default_int;
|
||||
}
|
||||
|
||||
bool res = default_int;
|
||||
|
||||
if( i->second == "true" || i->second == "1" || i->second == "yes" )
|
||||
res = true;
|
||||
|
||||
log << log3 << "Config: " << name << "=" << (res?"true":"false") << logend;
|
||||
|
||||
return res;
|
||||
return space.Text(name, def);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Config::NoLastSlash(std::string & s)
|
||||
std::wstring & Config::Text(const std::wstring & name, const wchar_t * def)
|
||||
{
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
log << log2 << "Config: removing the last slash from: " << s << logend;
|
||||
|
||||
if( *(--s.end()) == '/' )
|
||||
s.erase(--s.end());
|
||||
return space.Text(name, def);
|
||||
}
|
||||
|
||||
|
||||
std::string & Config::AText(const wchar_t * name)
|
||||
{
|
||||
return space.AText(name);
|
||||
}
|
||||
|
||||
|
||||
std::string & Config::AText(const wchar_t * name, const char * def)
|
||||
{
|
||||
return space.AText(name, def);
|
||||
}
|
||||
|
||||
|
||||
std::string & Config::AText(const std::wstring & name, const char * def)
|
||||
{
|
||||
return space.AText(name, def);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Config::Int(const wchar_t * name)
|
||||
{
|
||||
return space.Int(name);
|
||||
}
|
||||
|
||||
|
||||
int Config::Int(const wchar_t * name, int def)
|
||||
{
|
||||
return space.Int(name, def);
|
||||
}
|
||||
|
||||
|
||||
int Config::Int(const std::wstring & name, int def)
|
||||
{
|
||||
return space.Int(name, def);
|
||||
}
|
||||
|
||||
|
||||
long Config::Long(const wchar_t * name)
|
||||
{
|
||||
return space.Long(name);
|
||||
}
|
||||
|
||||
long Config::Long(const wchar_t * name, long def)
|
||||
{
|
||||
return space.Long(name, def);
|
||||
}
|
||||
|
||||
long Config::Long(const std::wstring & name, long def)
|
||||
{
|
||||
return space.Long(name, def);
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t Config::Size(const wchar_t * name)
|
||||
{
|
||||
return space.Size(name);
|
||||
}
|
||||
|
||||
|
||||
size_t Config::Size(const wchar_t * name, size_t def)
|
||||
{
|
||||
return space.Size(name, def);
|
||||
}
|
||||
|
||||
|
||||
size_t Config::Size(const std::wstring & name, size_t def)
|
||||
{
|
||||
return space.Size(name, def);
|
||||
}
|
||||
|
||||
|
||||
bool Config::Bool(const wchar_t * name)
|
||||
{
|
||||
return space.Bool(name);
|
||||
}
|
||||
|
||||
|
||||
bool Config::Bool(const wchar_t * name, bool def)
|
||||
{
|
||||
return space.Bool(name, def);
|
||||
}
|
||||
|
||||
|
||||
bool Config::Bool(const std::wstring & name, bool def)
|
||||
{
|
||||
return space.Bool(name, def);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Config::ListText(const wchar_t * name, std::vector<std::wstring> & list)
|
||||
{
|
||||
return space.ListText(name, list);
|
||||
}
|
||||
|
||||
|
||||
bool Config::ListText(const std::wstring & name, std::vector<std::wstring> & list)
|
||||
{
|
||||
return space.ListText(name, list);
|
||||
}
|
||||
|
||||
|
||||
void Config::Print(std::wostream & out)
|
||||
{
|
||||
space.Serialize(out);
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +444,3 @@ void Config::NoLastSlash(std::string & s)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
632
core/config.h
632
core/config.h
@@ -1,52 +1,640 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoreconfig
|
||||
#define headerfilecmslucoreconfig
|
||||
#ifndef headerfile_winix_core_config
|
||||
#define headerfile_winix_core_config
|
||||
|
||||
#include <string>
|
||||
#include "space/spaceparser.h"
|
||||
#include "htmlfilter.h"
|
||||
|
||||
|
||||
#include "../confparser/confparser.h"
|
||||
|
||||
|
||||
|
||||
class Config
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// name of the config file
|
||||
// this is the parameter passed to winix programm
|
||||
std::string config_file;
|
||||
|
||||
// start as a demon (in the background)
|
||||
// default: true
|
||||
bool demonize;
|
||||
|
||||
// system user name (to which drop privileges)
|
||||
// used only if winix is started as the root
|
||||
std::string user;
|
||||
|
||||
// system group name (to which drop privileges)
|
||||
// used only if winix is started as the root
|
||||
std::string group;
|
||||
|
||||
// setting additional effective groups from /etc/group
|
||||
// by using initgroups()
|
||||
// used only if winix is started as the root
|
||||
// default: true
|
||||
bool additional_groups;
|
||||
|
||||
// log file name, log file name for notifications (sending emails, etc)
|
||||
std::string log_file, log_notify_file;
|
||||
|
||||
// 1 - minimum
|
||||
// 2 - (default)
|
||||
// 3 - maximum - all logs
|
||||
int log_level;
|
||||
|
||||
// logging to stdout too
|
||||
// only if demonize is 'false'
|
||||
// default: false
|
||||
bool log_stdout;
|
||||
|
||||
// how many requests should be saved in the same time
|
||||
// default: 1
|
||||
int log_request;
|
||||
|
||||
// whether to save each line of the config (use it for debug purposes)
|
||||
// default: false
|
||||
bool log_save_each_line;
|
||||
|
||||
// time zone identifier used in log messages
|
||||
// this affects only the first line of logs (where there is IP address, request method etc)
|
||||
// see time_zone_default_id below for more info
|
||||
// default: 34 (Coordinated Universal Time UTC+00:00)
|
||||
size_t log_time_zone_id;
|
||||
|
||||
// logging db queries
|
||||
// default: false
|
||||
bool log_db_query;
|
||||
|
||||
// logging when a plugin function is called
|
||||
// default: false
|
||||
bool log_plugin_call;
|
||||
|
||||
// how many characters in values should be logged from POST parameters
|
||||
// default: 80
|
||||
// set to 0 to turn off
|
||||
size_t log_post_value_size;
|
||||
|
||||
// request delimiter in the log file, default "---------"
|
||||
std::wstring log_delimiter;
|
||||
|
||||
// fast cgi: socket (unix domain)
|
||||
std::string fcgi_socket;
|
||||
|
||||
// fast cgi: socket permissions
|
||||
int fcgi_socket_chmod;
|
||||
|
||||
// fast cgi: owner of the socket
|
||||
std::string fcgi_socket_user;
|
||||
|
||||
// fast cgi: group of the socket
|
||||
std::string fcgi_socket_group;
|
||||
|
||||
std::wstring templates_dir;
|
||||
std::wstring templates_dir_default; // html templates from winix
|
||||
|
||||
std::wstring txt_templates_dir;
|
||||
std::wstring txt_templates_dir_default; // txt (notifications) templates from winix
|
||||
|
||||
// prefix and postfix for functions templates
|
||||
// default:
|
||||
// prefix: "fun_"
|
||||
// postfix: ".html"
|
||||
std::wstring templates_fun_prefix;
|
||||
std::wstring templates_fun_postfix;
|
||||
|
||||
// main html template
|
||||
// default: index.html
|
||||
std::wstring templates_index;
|
||||
|
||||
// if true then only root can use 'template' function
|
||||
// default: false
|
||||
bool template_only_root_use_template_fun;
|
||||
|
||||
std::string db_database;
|
||||
std::string db_user;
|
||||
std::string db_pass;
|
||||
|
||||
std::string http_session_id_name;
|
||||
|
||||
// string used in a place where is a user (or group) selected
|
||||
std::wstring priv_no_user;
|
||||
std::wstring priv_no_group;
|
||||
|
||||
// time in seconds when the user will be automatically logged out (iddle time)
|
||||
int session_max_idle;
|
||||
|
||||
// time in seconds when the user will be automatically logged out (when he selected 'remember me' option)
|
||||
// this time is usually greater than session_max_idle
|
||||
int session_remember_max_idle;
|
||||
|
||||
// this file is used when the program is starting and ending
|
||||
std::string session_file;
|
||||
|
||||
// how many sessions can be (zero turn off this checking)
|
||||
// default: 1000000 (one milion)
|
||||
size_t session_max;
|
||||
|
||||
// allow the html output to be compressed
|
||||
// default: true
|
||||
bool compression;
|
||||
|
||||
// if the output is shorter than this value then it will not be compressed
|
||||
// default: 512 bytes
|
||||
size_t compression_page_min_size;
|
||||
|
||||
// 1 - use deflate if available (or raw deflate for Internet Explorer) or don't compress
|
||||
// 2 - use gzip if available or don't compress
|
||||
// 10 - prefer deflate -- use deflate (or raw deflate for IE) if both deflate and gzip are available
|
||||
// 20 - prefer gzip -- use gzip if both deflate and gzip are available
|
||||
// default: 20
|
||||
int compression_encoding;
|
||||
|
||||
// plugins directory
|
||||
// default: /usr/local/winix/plugins
|
||||
std::wstring plugins_dir;
|
||||
|
||||
// plugins
|
||||
// you can provide either a relative path (plugins_dir will be used)
|
||||
// or a full path to a plugin
|
||||
std::vector<std::wstring> plugin_file;
|
||||
|
||||
// should the html code be cleaned by the html filter
|
||||
bool html_filter;
|
||||
|
||||
// should white characters be trimmed
|
||||
bool html_filter_trim_white;
|
||||
|
||||
// when long words should be broken (a space will be inserted)
|
||||
// default: after 60 non white characters will be put a space
|
||||
// set zero to turn off
|
||||
size_t html_filter_break_word;
|
||||
|
||||
// when long lines should be broken (a new line character will be inserted)
|
||||
// default: 80
|
||||
// set zero to turn off
|
||||
size_t html_filter_wrap_line;
|
||||
|
||||
// how many spaces will be put at one tree level
|
||||
// default: 2
|
||||
size_t html_filter_tabs;
|
||||
|
||||
// use checking for 'orphans' for a specicic language
|
||||
// default: true
|
||||
bool html_filter_orphans;
|
||||
|
||||
// orphans mode
|
||||
// either: "nbsp" or "160"
|
||||
// default: "nbsp"
|
||||
std::wstring html_filter_orphans_mode_str;
|
||||
HTMLFilter::OrphanMode html_filter_orphans_mode;
|
||||
|
||||
// the url of a new empty item (if there is not the subject too)
|
||||
std::wstring item_url_empty;
|
||||
|
||||
// maximum length of a file send by post multipart form
|
||||
// 0 - not used
|
||||
size_t post_file_max;
|
||||
|
||||
// directory for static files
|
||||
std::wstring upload_dir;
|
||||
|
||||
// additional static directories *not* managed by winix
|
||||
// you can refer to this directories by using 'static' mount point
|
||||
// e.g.
|
||||
// let we say in the config you have:
|
||||
// static_dirs = ("/home/a", "/home/b", "/home/c")
|
||||
// and in /etc/fstab (in winix) you have such a line:
|
||||
// "static /my/dir simplefs static(2)"
|
||||
// above line in /etc/fstab means that when a user enters http://domain.com/my/dir/file.txt
|
||||
// then "file.txt" will be taken from "/home/c/file.txt"
|
||||
// this is useful for some javascript files which are protected from running from other domains
|
||||
std::vector<std::wstring> static_dirs;
|
||||
|
||||
// sometimes you can have trouble when you have set an incorrect static path in /etc/fstab
|
||||
// in such a case set dont_use_static_dirs to true
|
||||
// and winix will behave as there are not any static directories
|
||||
// so you can correct your mistake and then set this value to false
|
||||
bool dont_use_static_dirs;
|
||||
|
||||
// static common directory
|
||||
// this is a place where there are some common javascripts, images, css files
|
||||
// winix is allowed to read some files from there
|
||||
// for example ckeditor config, vim config and so on
|
||||
// winix read it as a ezc template and put it into database
|
||||
// default: empty
|
||||
std::wstring common_dir;
|
||||
|
||||
// chmod of newly created directories (under upload_dir)
|
||||
// default: 0750
|
||||
int upload_dirs_chmod;
|
||||
|
||||
// chmod of newly created files (under upload_dir)
|
||||
// default: 0640
|
||||
int upload_files_chmod;
|
||||
|
||||
// create a thumbnail from an image
|
||||
// default: true
|
||||
bool create_thumb;
|
||||
|
||||
// the mode of creating a thumbnail
|
||||
// width means thumb_cx, height means thumb_cy
|
||||
// 1: Width given, height automagically selected to preserve aspect ratio.
|
||||
// 2: Height given, width automagically selected to preserve aspect ratio.
|
||||
// 3: Maximum values of height and width given, aspect ratio preserved.
|
||||
// 4: Minimum values of width and height given, aspect ratio preserved.
|
||||
// 5: Width and height emphatically given, original aspect ratio ignored.
|
||||
// 6: Change as per widthxheight (3) but only if an image dimension exceeds a specified dimension.
|
||||
// 7: Change dimensions only if both image dimensions are less than specified dimensions.
|
||||
// default: 2
|
||||
int thumb_mode;
|
||||
|
||||
// width of thumbnails
|
||||
// default: 150
|
||||
size_t thumb_cx;
|
||||
|
||||
// height of thumbnails
|
||||
// default: 150
|
||||
size_t thumb_cy;
|
||||
|
||||
// quality of thumbnails
|
||||
// from 0 (the worst) to 100 (the best)
|
||||
// more info: http://www.imagemagick.org/script/command-line-options.php?ImageMagick=p4jtel7557hovd34ui3tgb54h6#quality
|
||||
// default: 92
|
||||
int thumb_quality;
|
||||
|
||||
// resizing images
|
||||
// this not affects thumbnails
|
||||
// default: true
|
||||
bool image_resize;
|
||||
|
||||
// the mode of resizing an image
|
||||
// the same as 'thumb_mode' above
|
||||
// default: 6
|
||||
int image_mode;
|
||||
|
||||
// width of images
|
||||
// default: 1000
|
||||
size_t image_cx;
|
||||
|
||||
// height of images
|
||||
// default: 800
|
||||
size_t image_cy;
|
||||
|
||||
// quality of an image (the same as in thumbnails)
|
||||
// from 0 (the worst) to 100 (the best)
|
||||
// default: 92
|
||||
int image_quality;
|
||||
|
||||
// the convert program (ImageMagic) (for images and thumbnails)
|
||||
// default: /usr/local/bin/convert
|
||||
std::wstring convert_cmd;
|
||||
|
||||
// directory with locale files
|
||||
std::wstring locale_dir;
|
||||
|
||||
// directory with default locale files (those from winix)
|
||||
std::wstring locale_dir_default;
|
||||
|
||||
// locale files (e.g. "en", "pl")
|
||||
// default: only one item: en
|
||||
std::vector<std::wstring> locale_files;
|
||||
|
||||
// a maximum value of a locale identifier
|
||||
// default: 100 (maximum: 1000)
|
||||
// each locale files should have its own identifier (in "winix_locale_id" field)
|
||||
// from zero to this value
|
||||
size_t locale_max_id;
|
||||
|
||||
// locale for not logged users
|
||||
// or for newly created accounts
|
||||
// default: 0
|
||||
size_t locale_default_id;
|
||||
|
||||
// url protocol
|
||||
// default: http://
|
||||
std::wstring url_proto;
|
||||
|
||||
// url protocol when using SSL
|
||||
// default: https://
|
||||
std::wstring url_ssl_proto;
|
||||
|
||||
// enables SSL
|
||||
// it means this site should be accessed through SSL encrypted connection
|
||||
// default: false
|
||||
bool use_ssl;
|
||||
|
||||
// enables SSL for static content
|
||||
// used mainly in templates, look at doc_base_url_static ezc function
|
||||
// default: false
|
||||
bool use_ssl_static;
|
||||
|
||||
// enables SSL for common content
|
||||
// used mainly in templates, look at doc_base_url_common ezc function
|
||||
// default: false
|
||||
bool use_ssl_common;
|
||||
|
||||
// if SSL is enabled then if this is true the SSL will be used
|
||||
// only for logged users
|
||||
// default: true
|
||||
bool use_ssl_only_for_logged_users;
|
||||
|
||||
// if current connection is without SSL and should be made through SSL
|
||||
// or if is via SSL and should be done in plain text
|
||||
// then we make a redirect
|
||||
// default: 303
|
||||
int use_ssl_redirect_code;
|
||||
|
||||
// when the HOST_HTTP environment variable is not equal to 'base_url'
|
||||
// (the part 'http://' and the last slash is removed)
|
||||
// the server will redirect into base_url + 'REQUEST_URI'
|
||||
// it's useful when you want to redirect from 'mydomain.tld' into 'www.mydomain.tld' etc.
|
||||
// set this option to false if you have multiple subdomains
|
||||
// default: false
|
||||
bool base_url_redirect;
|
||||
|
||||
// the HTTP code used during the base redirect
|
||||
// default: 301
|
||||
int base_url_redirect_code;
|
||||
|
||||
// the main address of the site (e.g. www.someserver.com)
|
||||
// (without http:// prefix)
|
||||
std::wstring base_url;
|
||||
|
||||
// static content not authorized by winix
|
||||
// (e.g. static.someserver.com)
|
||||
std::wstring base_url_static;
|
||||
|
||||
// additional static server for common content (not authorized)
|
||||
// (e.g. common.someserver.com)
|
||||
std::wstring base_url_common;
|
||||
|
||||
// separator used in <title> html tag
|
||||
std::wstring title_separator;
|
||||
|
||||
// http header recognized by www server as a file to send back
|
||||
// default: X-LIGHTTPD-send-file
|
||||
std::wstring http_header_send_file;
|
||||
|
||||
// prints additional information (in the end of the html page as a commentary)
|
||||
bool debug_info;
|
||||
|
||||
// in editors (emacs, ckeditor,...) the html will be filtered and unsafe tags
|
||||
// will be dropped (script, frame, etc.)
|
||||
// default: true;
|
||||
bool editors_html_safe_mode;
|
||||
|
||||
// don't filter the html code for root
|
||||
// default: true
|
||||
// (if true the html code for root is not filtered)
|
||||
bool editors_html_safe_mode_skip_root;
|
||||
|
||||
// charset used in templates, locales, logs etc.
|
||||
// default: true (UTF-8)
|
||||
// if false it means 8-bit ASCII
|
||||
bool utf8;
|
||||
|
||||
// how many maximum symlinks can be followed
|
||||
// (symlinks on directories as well)
|
||||
// default: 20
|
||||
size_t symlinks_follow_max;
|
||||
|
||||
// the prefix of a name of html form controls used in the ticket plugin
|
||||
// default: ticketparam
|
||||
std::wstring ticket_form_prefix;
|
||||
|
||||
// the minimal size of a user's password
|
||||
// default: 5
|
||||
size_t pass_min_size;
|
||||
|
||||
// how passwords should be stored
|
||||
// 0 - plain text
|
||||
// 1 - md4 hash
|
||||
// 2 - md5 hash
|
||||
// 10 - sha1 hash
|
||||
// 11 - sha224 hash
|
||||
// 12 - sha256 hash (default)
|
||||
// 13 - sha384 hash
|
||||
// 14 - sha512 hash
|
||||
int pass_type;
|
||||
|
||||
// whether the passwords' hashes should be salted or not
|
||||
// this affects newly created accounts
|
||||
// default: false
|
||||
bool pass_hash_use_salt;
|
||||
|
||||
// salt to a password's hash
|
||||
// default empty
|
||||
// !! once you set this salt don't change it any more (people wouldn't be allowed to login)
|
||||
std::wstring pass_hash_salt;
|
||||
|
||||
// whether the passwords' hashes should be encrypted
|
||||
// this affects newly created accounts
|
||||
// default: false
|
||||
bool pass_use_rsa;
|
||||
|
||||
// path to a RSA private key
|
||||
// this is actually private + public key in one file
|
||||
// generated by "openssl genrsa"
|
||||
// default empty which means encryption will not be used
|
||||
// !! once you set these keys don't change it any more (people wouldn't be allowed to login)
|
||||
std::wstring pass_rsa_private_key;
|
||||
|
||||
// path to 'openssl'
|
||||
// default: /usr/bin/openssl
|
||||
std::wstring opensll_path;
|
||||
|
||||
// setting when we should delete patterns (EZC patterns)
|
||||
// we are deleting when we have more (or equal) patterns than 'when_delete'
|
||||
// and then we are deleting 'how_many_del' patterns
|
||||
// those patterns comes from items (pages) with executable bit set
|
||||
size_t pattern_cacher_when_delete;
|
||||
size_t pattern_cacher_how_many_delete;
|
||||
|
||||
// header "Content-Type" send to the client
|
||||
// 0 - text/html - for HTML
|
||||
// 1 - application/xhtml+xml - for XHTML 1.0
|
||||
// 2 - application/xml - for XHTML 1.0 or for XHTML 1.1
|
||||
// default: 0
|
||||
// if utf8 is true then "; charset=UTF-8" will also be appended
|
||||
int content_type_header;
|
||||
|
||||
// global umask
|
||||
// it is used when an user doesn't have your own umask or for guests (not logged users)
|
||||
// default: 0222
|
||||
int umask;
|
||||
|
||||
// maximum number for elements through the whole template
|
||||
// default: 50000
|
||||
size_t ezc_max_elements;
|
||||
|
||||
// maximum number of each [for] loop
|
||||
// default: 5000 (from ezc generator)
|
||||
size_t ezc_max_loop_elements;
|
||||
|
||||
// when true then when a user want to create a new account
|
||||
// he has to provide his email and a message will be sent back to him
|
||||
// with a link to activate the account
|
||||
// default: true
|
||||
bool account_need_email_verification;
|
||||
|
||||
// when a user forgot his password we are able to send an email to him
|
||||
// with a link to the page where there is a html form for setting a new password
|
||||
// this option tells how long (in seconds) the link is valid
|
||||
// default: 86400 (24 hours)
|
||||
long reset_password_code_expiration_time;
|
||||
|
||||
// time zone identifier for not logged users
|
||||
// or for newly created accounts
|
||||
// those identifiers you can see in etc/time_zones.conf file
|
||||
// or by using timezone winix function with 'a' parameter (timezone/a) (!!IMPROVE ME NOT IMPLEMENTED YET)
|
||||
// default: 34 (Coordinated Universal Time UTC+00:00)
|
||||
size_t time_zone_default_id;
|
||||
|
||||
// a maximum value of a time zone identifier
|
||||
// time zones with an id greater than this will be skipped
|
||||
// default: 130 (maximum: 1000)
|
||||
size_t time_zone_max_id;
|
||||
|
||||
// a directory in which there are some config files
|
||||
// used mainly when winix starts
|
||||
// default: empty (means not for using)
|
||||
std::wstring etc_dir;
|
||||
|
||||
// a file in etc_dir with time zones info
|
||||
// default: time_zones.conf
|
||||
// this is a Space structure with all time zones
|
||||
// with following format:
|
||||
// "tz_-12:00" ( # the name of a space is also a key to the locale files
|
||||
// tz_offset_str = "-12:00" # a string representing the offset from UTC in a format: [+|-]HH:MM
|
||||
// tz_has_dst = "false" # whether the time zone has daylight saving time (bool)
|
||||
// tz_dst_offset = "" # offset of the daylight saving time
|
||||
// tz_dst_start = "" # when the daylight saving time starts, format: MM:DD HH:MM:SS
|
||||
// tz_dst_end = "") # when the daylight saving time ends, format: MM:DD HH:MM:SS
|
||||
// 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();
|
||||
bool ReadConfig(bool errors_to_stdout_);
|
||||
bool ReadConfig(bool errors_to_stdout_, bool stdout_is_closed = true);
|
||||
|
||||
std::wstring & Text(const wchar_t * name);
|
||||
std::wstring & Text(const wchar_t * name, const wchar_t * def);
|
||||
std::wstring & Text(const std::wstring & name, const wchar_t * def);
|
||||
std::string & AText(const wchar_t * name);
|
||||
std::string & AText(const wchar_t * name, const char * def);
|
||||
std::string & AText(const std::wstring & name, const char * def);
|
||||
|
||||
int Int(const wchar_t *);
|
||||
int Int(const wchar_t * name, int def);
|
||||
int Int(const std::wstring & name, int def);
|
||||
long Long(const wchar_t *);
|
||||
long Long(const wchar_t * name, long def);
|
||||
long Long(const std::wstring & name, long def);
|
||||
size_t Size(const wchar_t *);
|
||||
size_t Size(const wchar_t * name, size_t def);
|
||||
size_t Size(const std::wstring & name, size_t def);
|
||||
bool Bool(const wchar_t *);
|
||||
bool Bool(const wchar_t * name, bool def);
|
||||
bool Bool(const std::wstring & name, bool def);
|
||||
bool ListText(const wchar_t * name, std::vector<std::wstring> & list);
|
||||
bool ListText(const std::wstring & name, std::vector<std::wstring> & list);
|
||||
|
||||
// for debug
|
||||
void Print(std::wostream & out);
|
||||
|
||||
// raw access to the config
|
||||
PT::Space space;
|
||||
|
||||
|
||||
private:
|
||||
ConfParser conf_parser;
|
||||
void ShowError();
|
||||
void AssignValues();
|
||||
|
||||
|
||||
std::string & Text(const char *);
|
||||
int Int(const char *);
|
||||
bool Bool(const char *);
|
||||
|
||||
PT::SpaceParser parser;
|
||||
std::string default_str;
|
||||
int default_int;
|
||||
bool default_bool;
|
||||
|
||||
|
||||
bool errors_to_stdout;
|
||||
|
||||
void NoLastSlash(std::string & s);
|
||||
|
||||
|
||||
void ShowError();
|
||||
void AssignValues(bool stdout_is_closed);
|
||||
void SetAdditionalVariables();
|
||||
void CheckPasswd();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorecookieparser
|
||||
#define headerfilecmslucorecookieparser
|
||||
#ifndef headerfile_winix_core_cookieparser
|
||||
#define headerfile_winix_core_cookieparser
|
||||
|
||||
#include <fcgiapp.h>
|
||||
#include "httpsimpleparser.h"
|
||||
@@ -21,7 +21,7 @@ class CookieParser : public HttpSimpleParser
|
||||
{
|
||||
|
||||
const char * cookie_string;
|
||||
CookieTable & cookie_table;
|
||||
CookieTab * cookie_tab;
|
||||
|
||||
|
||||
protected:
|
||||
@@ -41,21 +41,24 @@ protected:
|
||||
// Cookie names are case insensitive according to section 3.1 of RFC 2965
|
||||
ToLower(name);
|
||||
|
||||
std::pair<CookieTable::iterator, bool> res = cookie_table.insert( std::make_pair(name, value) );
|
||||
std::pair<CookieTab::iterator, bool> res = cookie_tab->insert( std::make_pair(name, value) );
|
||||
|
||||
log << log2 << "Cookie, name: \"" << name << "\", value: \"" << value << "\"";
|
||||
|
||||
if( res.second == false )
|
||||
log << log2 << " (skipped)";
|
||||
{
|
||||
res.first->second = value;
|
||||
log << " (overwritten)";
|
||||
}
|
||||
|
||||
log << log2 << logend;
|
||||
log << logend;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
CookieParser(const char * cookie_string_, CookieTable & cookie_table_) : cookie_string(cookie_string_), cookie_table(cookie_table_)
|
||||
CookieParser()
|
||||
{
|
||||
HttpSimpleParser::separator = ';';
|
||||
HttpSimpleParser::value_can_be_quoted = true;
|
||||
@@ -63,6 +66,16 @@ public:
|
||||
HttpSimpleParser::recognize_special_chars = false;
|
||||
}
|
||||
|
||||
|
||||
// cookie_string can be null
|
||||
void Parse(const char * cookie_string_, CookieTab & cookie_tab_)
|
||||
{
|
||||
cookie_string = cookie_string_;
|
||||
cookie_tab = &cookie_tab_;
|
||||
|
||||
HttpSimpleParser::Parse();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
314
core/crypt.cpp
Executable file
314
core/crypt.cpp
Executable file
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include "crypt.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
void Crypt::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char Crypt::ConvertToHexForm(int val)
|
||||
{
|
||||
if( val < 10 )
|
||||
return val + '0';
|
||||
|
||||
return val - 10 + 'a';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Crypt::HashBin(int hash, const char * in, size_t inlen, std::string & out)
|
||||
{
|
||||
out.clear();
|
||||
|
||||
if( !config )
|
||||
return false;
|
||||
|
||||
run.Clear();
|
||||
PT::WideToUTF8(config->opensll_path, command);
|
||||
run.Cmd(command);
|
||||
run.Par("dgst");
|
||||
run.Par("-binary");
|
||||
|
||||
switch(hash)
|
||||
{
|
||||
case WINIX_CRYPT_HASH_MD4: run.Par("-md4"); break;
|
||||
case WINIX_CRYPT_HASH_MD5: run.Par("-md5"); break;
|
||||
case WINIX_CRYPT_HASH_SHA1: run.Par("-sha1"); break;
|
||||
case WINIX_CRYPT_HASH_SHA224: run.Par("-sha224"); break;
|
||||
case WINIX_CRYPT_HASH_SHA256: run.Par("-sha256"); break;
|
||||
case WINIX_CRYPT_HASH_SHA384: run.Par("-sha384"); break;
|
||||
case WINIX_CRYPT_HASH_SHA512: run.Par("-sha512"); break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return run.Go(in, inlen, out) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::HashBin(int hash, const char * in, std::string & out)
|
||||
{
|
||||
size_t len = strlen(in);
|
||||
return HashBin(hash, in, len, out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::HashBin(int hash, const std::string & in, std::string & out)
|
||||
{
|
||||
return HashBin(hash, in.c_str(), in.size(), out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::HashBin(int hash, const wchar_t * in, size_t inlen, std::string & out)
|
||||
{
|
||||
PT::WideToUTF8(in, inlen, bufina);
|
||||
int res = HashBin(hash, bufina.c_str(), bufina.size(), out);
|
||||
bufina.clear();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool Crypt::HashBin(int hash, const wchar_t * in, std::string & out)
|
||||
{
|
||||
size_t len = wcslen(in);
|
||||
return HashBin(hash, in, len, out);
|
||||
}
|
||||
|
||||
|
||||
bool Crypt::HashBin(int hash, const std::wstring & in, std::string & 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);
|
||||
}
|
||||
|
||||
|
||||
bool IsAllWhite(const char * str)
|
||||
{
|
||||
for( ; *str ; ++str)
|
||||
{
|
||||
if( !(IsWhite(*str) || *str==10) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::RSA(bool encrypt, const char * keypath, const char * in, size_t inlen, std::string & out)
|
||||
{
|
||||
out.clear();
|
||||
|
||||
if( !config || IsAllWhite(keypath) )
|
||||
return false;
|
||||
|
||||
run.Clear();
|
||||
PT::WideToUTF8(config->opensll_path, command);
|
||||
run.Cmd(command);
|
||||
|
||||
run.Par("rsautl");
|
||||
run.Par("-inkey");
|
||||
run.Par(keypath);
|
||||
|
||||
if(encrypt)
|
||||
run.Par("-encrypt");
|
||||
else
|
||||
run.Par("-decrypt");
|
||||
|
||||
return run.Go(in, inlen, out) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::RSA(bool encrypt, const char * keypath, const std::string & in, std::string & out)
|
||||
{
|
||||
return RSA(encrypt, keypath, in.c_str(), in.size(), out);
|
||||
}
|
||||
|
||||
|
||||
bool Crypt::RSA(bool encrypt, const std::string & keypath, const std::string & in, std::string & out)
|
||||
{
|
||||
return RSA(encrypt, keypath.c_str(), in.c_str(), in.size(), out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::RSA(bool encrypt, const wchar_t * keypath, const char * in, size_t inlen, std::string & out)
|
||||
{
|
||||
PT::WideToUTF8(keypath, keypatha);
|
||||
return RSA(encrypt, keypatha.c_str(), in, inlen, out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::RSA(bool encrypt, const wchar_t * keypath, const std::string & in, std::string & out)
|
||||
{
|
||||
return RSA(encrypt, keypath, in.c_str(), in.size(), out);
|
||||
}
|
||||
|
||||
|
||||
bool Crypt::RSA(bool encrypt, const std::wstring & keypath, const std::string & in, std::string & out)
|
||||
{
|
||||
return RSA(encrypt, keypath.c_str(), in.c_str(), in.size(), out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool Crypt::PassHash(const std::wstring & salt, UserPass & up)
|
||||
{
|
||||
bool result = true;
|
||||
up.pass_hash_salted = false;
|
||||
|
||||
if( up.pass_type != WINIX_CRYPT_HASH_NONE )
|
||||
{
|
||||
pass_org = up.pass;
|
||||
pass_salted = up.pass;
|
||||
pass_salted += salt;
|
||||
|
||||
if( HashHex(up.pass_type, pass_salted, up.pass) )
|
||||
{
|
||||
if( !salt.empty() )
|
||||
up.pass_hash_salted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Crypt: problem with generating a hash, the password will not be hashed" << logend;
|
||||
|
||||
up.pass = pass_org;
|
||||
up.pass_type = WINIX_CRYPT_HASH_NONE;
|
||||
result = false;
|
||||
}
|
||||
|
||||
ClearString(pass_salted);
|
||||
ClearString(pass_org);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Crypt::PassCrypt(const std::wstring & path_to_rsa_private_key, UserPass & up)
|
||||
{
|
||||
bool result = false;
|
||||
ClearString(up.pass_encrypted);
|
||||
|
||||
if( !path_to_rsa_private_key.empty() )
|
||||
{
|
||||
PT::WideToUTF8(up.pass, passa);
|
||||
|
||||
if( RSA(true, path_to_rsa_private_key, passa, up.pass_encrypted) )
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearString(up.pass_encrypted);
|
||||
log << log1 << "AddUser: problem with encrypting, the password will not be encrypted!" << logend;
|
||||
}
|
||||
|
||||
ClearString(passa);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void Crypt::PassHashCrypt(const std::wstring & salt, const std::wstring & path_to_rsa_private_key, UserPass & up)
|
||||
{
|
||||
PassHash(salt, up);
|
||||
PassCrypt(path_to_rsa_private_key, up);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Crypt::PassHashCrypt(UserPass & up)
|
||||
{
|
||||
up.pass_type = config->pass_type;
|
||||
empty.clear();
|
||||
|
||||
if( config->pass_hash_use_salt && !config->pass_hash_salt.empty() )
|
||||
PassHash(config->pass_hash_salt, up);
|
||||
else
|
||||
PassHash(empty, up);
|
||||
|
||||
|
||||
if( config->pass_use_rsa && !config->pass_rsa_private_key.empty() )
|
||||
PassCrypt(config->pass_rsa_private_key, up);
|
||||
}
|
||||
|
||||
262
core/crypt.h
Executable file
262
core/crypt.h
Executable file
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_crypt
|
||||
#define headerfile_winix_core_crypt
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "run.h"
|
||||
#include "config.h"
|
||||
#include "user.h"
|
||||
|
||||
|
||||
/*
|
||||
the kind of hashes we are able to obtain in winix
|
||||
*/
|
||||
#define WINIX_CRYPT_HASH_NONE 0
|
||||
#define WINIX_CRYPT_HASH_MD4 1
|
||||
#define WINIX_CRYPT_HASH_MD5 2
|
||||
#define WINIX_CRYPT_HASH_SHA1 10
|
||||
#define WINIX_CRYPT_HASH_SHA224 11
|
||||
#define WINIX_CRYPT_HASH_SHA256 12
|
||||
#define WINIX_CRYPT_HASH_SHA384 13
|
||||
#define WINIX_CRYPT_HASH_SHA512 14
|
||||
|
||||
|
||||
|
||||
/*
|
||||
calculating hashes, encrypting and decrypting with RSA
|
||||
*/
|
||||
class Crypt
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
void SetConfig(Config * pconfig);
|
||||
|
||||
|
||||
/*
|
||||
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 binary form
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
/*
|
||||
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 binary form
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
/*
|
||||
encrypt/decrypt by using RSA algorithm
|
||||
|
||||
input:
|
||||
encrypt - true means encrypting, false means decrypting
|
||||
keypath - path to a RSA private key (this is a private and public key in one file)
|
||||
in - input buffer
|
||||
inlen - the size of the buffer
|
||||
|
||||
output:
|
||||
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);
|
||||
bool RSA(bool encrypt, const std::string & keypath, const std::string & in, std::string & out);
|
||||
bool RSA(bool encrypt, const wchar_t * keypath, const char * in, size_t inlen, std::string & out);
|
||||
bool RSA(bool encrypt, const wchar_t * keypath, const std::string & in, std::string & out);
|
||||
bool RSA(bool encrypt, const std::wstring & keypath, const std::string & in, std::string & out);
|
||||
|
||||
|
||||
/*
|
||||
this method creates a hash from the given plain text password
|
||||
|
||||
input.
|
||||
salt - salt for the hash
|
||||
up.pass_type - what kind of hash do you want - look at WINIX_CRYPT_HASH_* macros (in crypt.h)
|
||||
up.pass - plain text password
|
||||
|
||||
if salt is empty then the hash will not be salted
|
||||
|
||||
output:
|
||||
up.pass_type - (can be changed to 0 when there is a problem with generating a hash)
|
||||
up.pass - hash from the password (or plain text if up.pass_type was zero)
|
||||
up.pass_hash_salted (true if the hash is salted - when salt was not empty)
|
||||
|
||||
if there is a problem with generating a hash the method stores a plain text password
|
||||
and changes up.pass_type to zero (plain text passwords are not salted)
|
||||
*/
|
||||
bool PassHash(const std::wstring & salt, UserPass & up);
|
||||
|
||||
|
||||
/*
|
||||
this method encrypts the given password
|
||||
|
||||
input:
|
||||
path_to_rsa_private_key - a path to rsa private key (this are a private and public keys both in one file)
|
||||
up.pass - given password (can be a plain text or a hash)
|
||||
|
||||
if path_to_rsa_private_key is empty then the password will not be encrypted
|
||||
|
||||
output:
|
||||
up.pass_encrypted
|
||||
|
||||
if there is a problem (or the path to the key is empty) then up.pass_encrypted will be empty
|
||||
and the method returns false
|
||||
*/
|
||||
bool PassCrypt(const std::wstring & path_to_rsa_private_key, UserPass & up);
|
||||
|
||||
|
||||
/*
|
||||
this method creates a hash from the given plain text password and then encrypts it
|
||||
|
||||
input:
|
||||
salt - salt for the hash
|
||||
path_to_rsa_private_key - a path to rsa private key (this are a private and public keys both in one file)
|
||||
up.pass_type - what kind of hash do you want - look at WINIX_CRYPT_HASH_* macros (in crypt.h)
|
||||
up.pass - plain text password
|
||||
|
||||
if salt is empty then the hash will not be salted
|
||||
if path_to_rsa_private_key is empty then the password will not be encrypted
|
||||
|
||||
output:
|
||||
up.pass_type - (can be changed to 0 when there is a problem with generating a hash)
|
||||
up.pass - hash from the password (or plain text if up.pass_type was zero)
|
||||
up.pass_hash_salted (true if the hash is salted - when salt was not empty)
|
||||
up.pass_encrypted - encrypted password (if not empty)
|
||||
|
||||
*/
|
||||
void PassHashCrypt(const std::wstring & salt, const std::wstring & path_to_rsa_private_key, UserPass & up);
|
||||
|
||||
|
||||
/*
|
||||
this method creates a hash from the given plain text password and then encrypts it
|
||||
|
||||
input:
|
||||
up.pass - plain text password
|
||||
|
||||
output:
|
||||
up.pass_type - what kind of hash there is in up.pass
|
||||
up.pass - hash from the password (or plain text if up.pass_type is zero)
|
||||
up.pass_hash_salted - true if the hash is salted (plain text are never salted)
|
||||
up.pass_encrypted - encrypted password (if not empty)
|
||||
*/
|
||||
void PassHashCrypt(UserPass & up);
|
||||
|
||||
|
||||
/*
|
||||
putting some characters into the string and then calling clear()
|
||||
*/
|
||||
template<class StringType>
|
||||
void ClearString(StringType & str);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Config * config;
|
||||
Run run;
|
||||
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, out_temp;
|
||||
std::wstring empty;
|
||||
|
||||
|
||||
template<typename StringType>
|
||||
void ConvertToHexForm(const std::string & in, StringType & out);
|
||||
|
||||
char ConvertToHexForm(int val);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename StringType>
|
||||
void Crypt::ClearString(StringType & str)
|
||||
{
|
||||
for(size_t i=0 ; i<str.size() ; ++i)
|
||||
str[i] = 0x0c;
|
||||
|
||||
str.clear();
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
36
core/cur.h
Executable file
36
core/cur.h
Executable file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_cur
|
||||
#define headerfile_winix_core_cur
|
||||
|
||||
#include "request.h"
|
||||
#include "session.h"
|
||||
#include "mount.h"
|
||||
|
||||
|
||||
/*
|
||||
current request and session
|
||||
*/
|
||||
struct Cur
|
||||
{
|
||||
Request * request;
|
||||
Session * session;
|
||||
Mount * mount;
|
||||
|
||||
// those pointers are never null, if there is no a session for the user
|
||||
// the 'session' pointer pointers at a special temporary session
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "data.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Data::Data()
|
||||
{
|
||||
signal_hup = false;
|
||||
stdout_is_closed = false;
|
||||
|
||||
// the rest will be read from a config file
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Data::SetAdditionalVariables()
|
||||
{
|
||||
SetHttpHost();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Data::SetHttpHost()
|
||||
{
|
||||
if( strncmp(base_url.c_str(), "http://", 7) == 0 )
|
||||
base_url_http_host = base_url.substr(7);
|
||||
else
|
||||
if( strncmp(base_url.c_str(), "https://", 8) == 0 )
|
||||
base_url_http_host = base_url.substr(8);
|
||||
else
|
||||
base_url_http_host.clear(); // if empty the RequestController::BaseUrlRedirect() returns false and no redirecting will be done
|
||||
}
|
||||
142
core/data.h
142
core/data.h
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoredata
|
||||
#define headerfilecmslucoredata
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string.h>
|
||||
|
||||
#include "dirs.h"
|
||||
#include "users.h"
|
||||
#include "groups.h"
|
||||
#include "functions.h"
|
||||
#include "lastcontainer.h"
|
||||
#include "mounts.h"
|
||||
|
||||
|
||||
|
||||
class Data
|
||||
{
|
||||
public:
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// members read from a config file
|
||||
|
||||
// name of the config file (full path can be)
|
||||
std::string config_file;
|
||||
|
||||
// log file name, log file name for notifications (sending emails, etc)
|
||||
std::string log_file, log_notify_file;
|
||||
|
||||
// 1 - minimum
|
||||
// 2 - (default)
|
||||
// 3 - maximum - all logs
|
||||
int log_level;
|
||||
|
||||
// logging to stdout too
|
||||
bool log_stdout;
|
||||
|
||||
|
||||
// fast cgi: socket (unix domain)
|
||||
std::string fcgi_socket;
|
||||
|
||||
// fast cgi: socket permissions
|
||||
int fcgi_socket_chmod;
|
||||
|
||||
// fast cgi: owner of the socket
|
||||
std::string fcgi_socket_user;
|
||||
|
||||
// fast cgi: group of the socket
|
||||
std::string fcgi_socket_group;
|
||||
|
||||
std::string templates;
|
||||
std::string default_index;
|
||||
|
||||
std::string db_database;
|
||||
std::string db_user;
|
||||
std::string db_pass;
|
||||
std::string base_url;
|
||||
std::string http_session_id_name;
|
||||
|
||||
// when the HOST_HTTP environment variable doesn't point into 'base_url' (the part 'http://' and the last slash is removed)
|
||||
// the server will redirect into 'base_url' + 'REQUEST_URI'
|
||||
// it's useful when you want to redirect from 'mydomain.tld' into 'www.mydomain.tld' etc.
|
||||
bool base_url_redirect;
|
||||
|
||||
// if there is one item in a directory
|
||||
// it will be showed
|
||||
// (instead of showing directory contents)
|
||||
// !! wywalic to, nie bedzie uzywane
|
||||
bool one_item_is_showed;
|
||||
|
||||
// string used in a place where is a user (or group) selected
|
||||
std::string priv_no_user;
|
||||
std::string priv_no_group;
|
||||
|
||||
// time in second when the user will be automatically logged out (iddle time)
|
||||
int session_max_iddle;
|
||||
|
||||
bool compression;
|
||||
|
||||
// end config members
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
|
||||
// false at the beginning
|
||||
bool stdout_is_closed;
|
||||
|
||||
// true if there was SIGHUP signal
|
||||
volatile bool signal_hup;
|
||||
|
||||
// contains current directories tree
|
||||
Dirs dirs;
|
||||
|
||||
// based on base_url
|
||||
// set by SetAdditionalVariables()
|
||||
std::string base_url_http_host;
|
||||
|
||||
// call this method after the config file is read
|
||||
void SetAdditionalVariables();
|
||||
|
||||
|
||||
|
||||
// users
|
||||
Users users;
|
||||
|
||||
// groups
|
||||
Groups groups;
|
||||
|
||||
// functions (ls, cat, etc)
|
||||
Functions functions;
|
||||
|
||||
// for 'last' function
|
||||
LastContainer last;
|
||||
|
||||
// mount points
|
||||
Mounts mounts;
|
||||
|
||||
|
||||
|
||||
Data();
|
||||
|
||||
|
||||
private:
|
||||
void SetHttpHost();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
extern Data data;
|
||||
|
||||
|
||||
#endif
|
||||
1640
core/db.cpp
1640
core/db.cpp
File diff suppressed because it is too large
Load Diff
145
core/db.h
145
core/db.h
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoredb
|
||||
#define headerfilecmslucoredb
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <libpq-fe.h>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
|
||||
#include "item.h"
|
||||
#include "user.h"
|
||||
#include "group.h"
|
||||
#include "thread.h"
|
||||
#include "error.h"
|
||||
#include "dircontainer.h"
|
||||
#include "ugcontainer.h"
|
||||
|
||||
|
||||
|
||||
class Db
|
||||
{
|
||||
public:
|
||||
|
||||
Db(bool close_at_end_ = true);
|
||||
~Db();
|
||||
|
||||
// !! przerobic tak aby GetItem zwracalo wszystkie pozycja
|
||||
// !! GetFile tylko dla plikow
|
||||
// !! GetDir tylko dla katalogow
|
||||
// !! GetFile i GetDir beda uzywac GetItem
|
||||
|
||||
void Init(const std::string & database, const std::string & user, const std::string & pass);
|
||||
bool CheckUser(std::string & login, std::string & password, long & user_id);
|
||||
Error AddItem(Item & item);
|
||||
Error EditItemById(Item & item, bool with_url = true);
|
||||
Error EditItemByUrl(Item & item, bool with_url = true);
|
||||
void CheckAllUrlSubject();
|
||||
|
||||
void GetItems(std::vector<Item> & item_table, long parent_id, Item::Type type, bool with_subject, bool with_content, bool sort_asc);
|
||||
|
||||
void GetItem(std::vector<Item> & item_table, long id);
|
||||
|
||||
|
||||
bool GetPriv(Item & item, long id);
|
||||
Error EditPrivById(Item & item, long id);
|
||||
|
||||
Error DelDirById(long id);
|
||||
|
||||
bool DelItem(const Item & item);
|
||||
void GetDirs(DirContainer & dir_table);
|
||||
void GetUsers(UGContainer<User> & user_table);
|
||||
void GetGroups(UGContainer<Group> & group_table);
|
||||
|
||||
// !! nowy interfejs
|
||||
Error GetItem(long parent_id, const std::string & url, Item & item);
|
||||
Error EditDefaultItem(long id, long new_default_item);
|
||||
|
||||
long GetItemId(long parent_id, const std::string & url, Item::Type type);
|
||||
long GetFileId(long parent_id, const std::string & url);
|
||||
long GetDirId(long parent_id, const std::string & url);
|
||||
|
||||
static tm ConvertTime(const char * str);
|
||||
static const char * ConvertTime(const tm & t);
|
||||
|
||||
PGconn * GetPGconn();
|
||||
|
||||
virtual void Connect();
|
||||
|
||||
|
||||
Error AddThread(Thread & thread);
|
||||
Error GetThreadByDirId(long dir_id, Thread & thread);
|
||||
Error GetThreads(long parent_id, std::vector<Thread> & thread_tab);
|
||||
Error EditThreadAddItem(long dir_id, long item_id);
|
||||
Error EditThreadRemoveItem(long dir_id);
|
||||
Error RemoveThread(long dir_id);
|
||||
|
||||
protected:
|
||||
|
||||
PGconn * pg_conn;
|
||||
std::string db_database, db_user, db_pass;
|
||||
bool close_at_end;
|
||||
|
||||
void SetDbParameters();
|
||||
|
||||
void Close();
|
||||
|
||||
void AssertConnection();
|
||||
std::string Escape(const std::string & s);
|
||||
std::string Escape(const char * s);
|
||||
PGresult * AssertQuery(const std::string & q);
|
||||
void AssertResultStatus(PGresult * r, ExecStatusType t);
|
||||
static int AssertColumn(PGresult * r, const char * column_name);
|
||||
static const char * AssertValue(PGresult * r, int row, int col);
|
||||
void ClearResult(PGresult * r);
|
||||
long AssertCurrval(const char * table);
|
||||
bool AddItemCreateUrlSubject(Item & item);
|
||||
|
||||
Error AddItemIntoContent(Item & item);
|
||||
Error AddItemIntoItem(Item & item);
|
||||
|
||||
Error EditItemInItem(Item & item, bool with_url);
|
||||
Error EditItemInContent(Item & item);
|
||||
Error EditItemGetId(Item & item);
|
||||
Error EditItemGetContentId(Item & item);
|
||||
|
||||
void CheckAllUrlSubjectModifyItem(Item & item);
|
||||
|
||||
PGresult * GetItemsQuery(long parent_id, Item::Type type, bool with_subject, bool with_content, bool sort_asc);
|
||||
|
||||
bool DelItemDelItem(const Item & item);
|
||||
void DelItemDelContent(const Item & item);
|
||||
Error DelItemCountContents(const Item & item, long & contents);
|
||||
|
||||
|
||||
struct ItemColumns
|
||||
{
|
||||
int id, user_id, group_id, privileges, date_creation, date_modification, url, type, parent_id, content_id, default_item, subject, content, content_type, guest_name;
|
||||
|
||||
|
||||
void SetColumns(PGresult * r);
|
||||
void SetItem(PGresult * r, long row, Item & item);
|
||||
};
|
||||
|
||||
|
||||
}; // class Db
|
||||
|
||||
|
||||
extern Db db;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "db.h"
|
||||
|
||||
|
||||
|
||||
void Db::ItemColumns::SetColumns(PGresult * r)
|
||||
{
|
||||
// PQfnumber returns -1 if there is no such a column
|
||||
id = PQfnumber(r, "id");
|
||||
user_id = PQfnumber(r, "user_id");
|
||||
group_id = PQfnumber(r, "group_id");
|
||||
privileges = PQfnumber(r, "privileges");
|
||||
date_creation = PQfnumber(r, "date_creation");
|
||||
date_modification = PQfnumber(r, "date_modification");
|
||||
url = PQfnumber(r, "url");
|
||||
type = PQfnumber(r, "type");
|
||||
parent_id = PQfnumber(r, "parent_id");
|
||||
content_id = PQfnumber(r, "content_id");
|
||||
default_item = PQfnumber(r, "default_item");
|
||||
subject = PQfnumber(r, "subject");
|
||||
content = PQfnumber(r, "content");
|
||||
content_type = PQfnumber(r, "content_type");
|
||||
guest_name = PQfnumber(r, "guest_name");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Db::ItemColumns::SetItem(PGresult * r, long row, Item & item)
|
||||
{
|
||||
if( id != -1 ) item.id = atol( Db::AssertValue(r, row, id) );
|
||||
if( user_id != -1 ) item.user_id = atol( Db::AssertValue(r, row, user_id) );
|
||||
if( group_id != -1 ) item.group_id = atol( Db::AssertValue(r, row, group_id) );
|
||||
if( privileges != -1 ) item.privileges = atoi( Db::AssertValue(r, row, privileges) );
|
||||
if( date_creation != -1 ) item.date_creation = ConvertTime( Db::AssertValue(r, row, date_creation) );
|
||||
if( date_modification != -1 ) item.date_modification = ConvertTime( Db::AssertValue(r, row, date_modification) );
|
||||
if( url != -1 ) item.url = Db::AssertValue(r, row, url);
|
||||
if( type != -1 ) item.type = static_cast<Item::Type>( atoi( Db::AssertValue(r, row, type) ) );
|
||||
if( parent_id != -1 ) item.parent_id = atol( Db::AssertValue(r, row, parent_id) );
|
||||
if( content_id != -1 ) item.content_id = atol( Db::AssertValue(r, row, content_id) );
|
||||
if( default_item != -1 ) item.default_item = atol( Db::AssertValue(r, row, default_item) );
|
||||
if( subject != -1 ) item.subject = Db::AssertValue(r, row, subject);
|
||||
if( content != -1 ) item.content = Db::AssertValue(r, row, content);
|
||||
if( content_type != -1 ) item.content_type = atoi( Db::AssertValue(r, row, content_type) );
|
||||
if( guest_name != -1 ) item.guest_name = Db::AssertValue(r, row, guest_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -11,9 +11,15 @@
|
||||
#include "log.h"
|
||||
|
||||
|
||||
std::wstring DirContainer::dir_etc = L"etc";
|
||||
std::wstring DirContainer::dir_var = L"var";
|
||||
|
||||
|
||||
DirContainer::DirContainer()
|
||||
{
|
||||
is_root = false;
|
||||
is_etc = false;
|
||||
is_var = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +33,23 @@ return root_iter;
|
||||
}
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::GetEtc()
|
||||
{
|
||||
if( !is_etc )
|
||||
return table.end();
|
||||
|
||||
return etc_iter;
|
||||
}
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::GetVar()
|
||||
{
|
||||
if( !is_var )
|
||||
return table.end();
|
||||
|
||||
return var_iter;
|
||||
}
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::Begin()
|
||||
{
|
||||
@@ -42,7 +65,7 @@ DirContainer::Iterator DirContainer::End()
|
||||
|
||||
DirContainer::SizeType DirContainer::Size()
|
||||
{
|
||||
return table.size();
|
||||
return table.size(); // !! warning: it has O(n)
|
||||
}
|
||||
|
||||
bool DirContainer::Empty()
|
||||
@@ -51,6 +74,70 @@ bool DirContainer::Empty()
|
||||
}
|
||||
|
||||
|
||||
bool DirContainer::IsNameOfSpecialFolder(const std::wstring & name)
|
||||
{
|
||||
return name == dir_etc || name == dir_var;
|
||||
}
|
||||
|
||||
|
||||
// looking for '/etc'
|
||||
// 'root' is found beforehand
|
||||
// CheckSpecialFolder() may not find everything (when the first is a special folder and then the root)
|
||||
void DirContainer::FindSpecialFolders()
|
||||
{
|
||||
is_etc = false;
|
||||
is_var = false;
|
||||
|
||||
if( !is_root )
|
||||
return;
|
||||
|
||||
DirContainer::ParentIterator i = FindFirstChild(root_iter->id);
|
||||
|
||||
for( ; i!=ParentEnd() ; i = NextChild(i) )
|
||||
{
|
||||
if( i->second->url == dir_etc )
|
||||
{
|
||||
is_etc = true;
|
||||
etc_iter = i->second;
|
||||
}
|
||||
else
|
||||
if( i->second->url == dir_var )
|
||||
{
|
||||
is_var = true;
|
||||
var_iter = i->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// this is used with PushBack() method
|
||||
void DirContainer::CheckSpecialFolder(const Item & item, Iterator iter)
|
||||
{
|
||||
if( item.parent_id == -1 )
|
||||
{
|
||||
is_root = true;
|
||||
root_iter = iter;
|
||||
}
|
||||
|
||||
if( !is_root )
|
||||
return;
|
||||
|
||||
if( item.parent_id==root_iter->id && item.url==dir_etc )
|
||||
{
|
||||
is_etc = true;
|
||||
etc_iter = iter;
|
||||
log << log2 << "DirCont: added special folder: /etc" << logend;
|
||||
}
|
||||
|
||||
if( item.parent_id==root_iter->id && item.url==dir_var )
|
||||
{
|
||||
is_var = true;
|
||||
var_iter = iter;
|
||||
log << log2 << "DirCont: added special folder: /var" << logend;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::PushBack(const Item & item)
|
||||
{
|
||||
@@ -61,12 +148,7 @@ DirContainer::Iterator DirContainer::PushBack(const Item & item)
|
||||
}
|
||||
|
||||
Iterator last_iter = table.insert(table.end(), item);
|
||||
|
||||
if( item.parent_id == -1 )
|
||||
{
|
||||
is_root = true;
|
||||
root_iter = last_iter;
|
||||
}
|
||||
CheckSpecialFolder(item, last_iter);
|
||||
|
||||
log << log2 << "DirCont: added dir, url: " << item.url << ", id: " << item.id << ", parent_id: " << item.parent_id << logend;
|
||||
|
||||
@@ -80,6 +162,45 @@ return last_iter;
|
||||
|
||||
|
||||
|
||||
bool DirContainer::ChangeParent(long dir_id, long new_parent_id)
|
||||
{
|
||||
Iterator i = FindId(dir_id);
|
||||
|
||||
if( i == table.end() )
|
||||
return false;
|
||||
|
||||
if( i->parent_id == new_parent_id )
|
||||
return true; // nothing to do
|
||||
|
||||
ParentIterator p = FindFirstChild(i->parent_id);
|
||||
bool found = false;
|
||||
|
||||
for( ; p != table_parent.end() ; p = NextChild(p) )
|
||||
{
|
||||
if( p->second->id == dir_id )
|
||||
{
|
||||
table_parent.erase(p);
|
||||
log << log3 << "DirCont: removed parent index to dir: " << i->id << logend;
|
||||
|
||||
i->parent_id = new_parent_id;
|
||||
table_parent.insert( std::make_pair(new_parent_id, i) );
|
||||
log << log3 << "DirCont: added parent index to dir, id: " << i->id << ", parent_id: " << i->parent_id << logend;
|
||||
|
||||
found = true;
|
||||
|
||||
if( IsNameOfSpecialFolder(i->url) )
|
||||
FindSpecialFolders();
|
||||
|
||||
break; // that iterator (p) is only one
|
||||
}
|
||||
}
|
||||
|
||||
if( !found )
|
||||
log << log1 << "DirCont: cannot find parent_id: " << i->parent_id << " in parent indexes" << logend;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DirContainer::Clear()
|
||||
@@ -130,7 +251,7 @@ bool DirContainer::ParentEmpty()
|
||||
}
|
||||
|
||||
|
||||
DirContainer::ParentIterator DirContainer::FindFirstParent(long parent)
|
||||
DirContainer::ParentIterator DirContainer::FindFirstChild(long parent)
|
||||
{
|
||||
ParentIterator i = table_parent.lower_bound(parent);
|
||||
|
||||
@@ -141,7 +262,7 @@ return i;
|
||||
}
|
||||
|
||||
|
||||
DirContainer::ParentIterator DirContainer::NextParent(ParentIterator i)
|
||||
DirContainer::ParentIterator DirContainer::NextChild(ParentIterator i)
|
||||
{
|
||||
if( i == table_parent.end() )
|
||||
return table_parent.end();
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoredircontainer
|
||||
#define headerfilecmslucoredircontainer
|
||||
#ifndef headerfile_winix_core_dircontainer
|
||||
#define headerfile_winix_core_dircontainer
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
@@ -33,28 +33,35 @@ public:
|
||||
DirContainer();
|
||||
|
||||
Iterator GetRoot();
|
||||
Iterator GetEtc();
|
||||
Iterator GetVar();
|
||||
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
bool Empty();
|
||||
Iterator PushBack(const Item & item);
|
||||
bool ChangeParent(long dir_id, long new_parent_id);
|
||||
void Clear();
|
||||
|
||||
Iterator FindId(long id);
|
||||
|
||||
bool DelById(long id);
|
||||
|
||||
ParentIterator ParentBegin();
|
||||
ParentIterator ParentBegin(); // IMPROVE ME: may it should be renamed to ChildBegin() similarly as FindFirstChild() ?
|
||||
ParentIterator ParentEnd();
|
||||
ParentSizeType ParentSize();
|
||||
bool ParentEmpty();
|
||||
ParentIterator FindFirstParent(long parent);
|
||||
ParentIterator NextParent(ParentIterator pi);
|
||||
ParentIterator FindFirstChild(long parent);
|
||||
ParentIterator NextChild(ParentIterator pi);
|
||||
|
||||
bool IsNameOfSpecialFolder(const std::wstring & name);
|
||||
void FindSpecialFolders();
|
||||
|
||||
private:
|
||||
|
||||
void CheckSpecialFolder(const Item & item, Iterator iter);
|
||||
|
||||
// main table with dirs
|
||||
Table table;
|
||||
|
||||
@@ -64,9 +71,24 @@ private:
|
||||
// root
|
||||
Iterator root_iter;
|
||||
|
||||
// true if there is a etc dir in the table
|
||||
bool is_etc;
|
||||
|
||||
// etc
|
||||
Iterator etc_iter;
|
||||
|
||||
// true if there is a var dir in the table
|
||||
bool is_var;
|
||||
|
||||
// var
|
||||
Iterator var_iter;
|
||||
|
||||
// indexes
|
||||
TableId table_id;
|
||||
TableParent table_parent;
|
||||
|
||||
// names of folders
|
||||
static std::wstring dir_etc, dir_var;
|
||||
};
|
||||
|
||||
|
||||
|
||||
762
core/dirs.cpp
762
core/dirs.cpp
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,25 +10,59 @@
|
||||
#include "dirs.h"
|
||||
#include "error.h"
|
||||
#include "log.h"
|
||||
#include "db.h"
|
||||
#include "data.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void Dirs::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
|
||||
void Dirs::SetCur(Cur * pcur)
|
||||
{
|
||||
cur = pcur;
|
||||
}
|
||||
|
||||
|
||||
void Dirs::SetNotify(Notify * pnotify)
|
||||
{
|
||||
notify = pnotify;
|
||||
}
|
||||
|
||||
|
||||
void Dirs::Clear()
|
||||
{
|
||||
dir_table.Clear();
|
||||
dir_tab.Clear();
|
||||
}
|
||||
|
||||
|
||||
bool Dirs::HasReadExecAccessForRoot(const Item & item)
|
||||
{
|
||||
// there must be at least one 'x' (for the root)
|
||||
return (item.privileges & 01111) != 0;
|
||||
}
|
||||
|
||||
|
||||
void Dirs::CheckRootDir()
|
||||
{
|
||||
DirContainer::Iterator i = dir_table.GetRoot();
|
||||
DirContainer::Iterator i = dir_tab.GetRoot();
|
||||
|
||||
if( i != dir_tab.End() )
|
||||
{
|
||||
if( !HasReadExecAccessForRoot(*i) )
|
||||
{
|
||||
i->privileges = 07555;
|
||||
log << log1 << "Dirs: there is no access for a root (admin) to the root dir, setting 07555 for the root directory" << logend;
|
||||
db->EditPrivById(*i, i->id);
|
||||
}
|
||||
|
||||
if( i != dir_table.End() )
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
log << log1 << "Dirs: there is no a root dir in the database (creating one)" << logend;
|
||||
log << log1 << "Dirs: there is no a root directory in the database (creating one)" << logend;
|
||||
|
||||
Item root;
|
||||
|
||||
@@ -36,14 +70,13 @@ void Dirs::CheckRootDir()
|
||||
root.parent_id = -1;
|
||||
root.user_id = -1;
|
||||
root.group_id = -1;
|
||||
root.privileges = 0755;
|
||||
root.default_item = -1;
|
||||
root.privileges = 07555;
|
||||
|
||||
// !! upewnic sie ze baza nie zmieni url (gdyby wczesniej juz byl w bazie pusty url)
|
||||
// !! zrobic jakis wyjatek do wprowadzania roota?
|
||||
if( db.AddItem(root) == Error::ok )
|
||||
if( db->AddItem(root) == WINIX_ERR_OK )
|
||||
{
|
||||
dir_table.PushBack(root);
|
||||
dir_tab.PushBack(root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,40 +87,13 @@ void Dirs::ReadDirs()
|
||||
{
|
||||
Clear();
|
||||
|
||||
db.GetDirs(dir_table);
|
||||
db->GetDirs(dir_tab);
|
||||
CheckRootDir();
|
||||
dir_tab.FindSpecialFolders();
|
||||
}
|
||||
|
||||
|
||||
bool Dirs::GetRootDir(Item ** item)
|
||||
{
|
||||
DirContainer::Iterator root = dir_table.GetRoot();
|
||||
|
||||
if( root == dir_table.End() )
|
||||
return false;
|
||||
|
||||
*item = &(*root);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Dirs::GetDir(const std::string & name, long parent, Item ** item)
|
||||
{
|
||||
DirContainer::ParentIterator i = dir_table.FindFirstParent(parent);
|
||||
|
||||
for( ; i!=dir_table.ParentEnd() ; i = dir_table.NextParent(i) )
|
||||
if( i->second->url == name )
|
||||
{
|
||||
*item = &(*i->second);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Dirs::ExtractName(const char * & s, std::string & name)
|
||||
bool Dirs::ExtractName(const wchar_t * & s, std::wstring & name)
|
||||
{
|
||||
name.clear();
|
||||
|
||||
@@ -102,69 +108,13 @@ return !name.empty();
|
||||
|
||||
|
||||
|
||||
// !! moze lepiej zwracac wskaznik do Item i kiedy nie ma katalogu to zwracac 0 ?
|
||||
bool Dirs::GetDir(const std::string & path, Item ** item)
|
||||
{
|
||||
DirContainer::Iterator root = dir_table.GetRoot();
|
||||
|
||||
if( root == dir_table.End() )
|
||||
// ops, we do not have a root dir
|
||||
return false;
|
||||
|
||||
Item * pitem = &(*root);
|
||||
|
||||
std::string name;
|
||||
const char * s = path.c_str();
|
||||
|
||||
while( ExtractName(s, name) )
|
||||
{
|
||||
if( !GetDir(name, pitem->id, &pitem) )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
*item = pitem;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! ten interfejs jes bylejaki
|
||||
// !! moze lepiej zwracac id i kiedy nie ma katalogu to -1 (przeciez to jest wartosc ktora nie moze pojawic sie w indeksie)
|
||||
bool Dirs::GetDirId(const std::string & path, long * id)
|
||||
{
|
||||
Item * pitem;
|
||||
|
||||
if( !GetDir(path, &pitem) )
|
||||
return false;
|
||||
|
||||
*id = pitem->id;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Dirs::GetDirId(const std::string & name, long parent, long * id)
|
||||
{
|
||||
Item * pitem;
|
||||
|
||||
if( !GetDir(name, parent, &pitem) )
|
||||
return false;
|
||||
|
||||
*id = pitem->id;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Dirs::IsDir(long id)
|
||||
{
|
||||
DirContainer::Iterator i = dir_table.FindId(id);
|
||||
DirContainer::Iterator i = dir_tab.FindId(id);
|
||||
|
||||
if( i == dir_table.End() )
|
||||
if( i == dir_tab.End() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -172,133 +122,240 @@ return true;
|
||||
|
||||
|
||||
|
||||
|
||||
bool Dirs::GetDirChilds(long parent, std::vector<Item> & childs_table)
|
||||
// !! dac clearowanie childs_tab
|
||||
// !! ewentualnie mozna dodac trzeci domyslny parametr bool clear_tab = true
|
||||
bool Dirs::GetDirChilds(long parent, std::vector<Item*> & childs_tab)
|
||||
{
|
||||
if( parent != -1 && !IsDir(parent) )
|
||||
return false;
|
||||
|
||||
DirContainer::ParentIterator i = dir_table.FindFirstParent(parent);
|
||||
DirContainer::ParentIterator i = dir_tab.FindFirstChild(parent);
|
||||
|
||||
for( ; i != dir_table.ParentEnd() ; i = dir_table.NextParent(i) )
|
||||
childs_table.push_back( *i->second );
|
||||
for( ; i != dir_tab.ParentEnd() ; i = dir_tab.NextChild(i) )
|
||||
childs_tab.push_back( &(*i->second) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Dirs::GetDirChilds(long parent, std::vector<Item*> & childs_table)
|
||||
DirContainer::ParentIterator Dirs::FindFirstChild(long parent_id)
|
||||
{
|
||||
if( parent != -1 && !IsDir(parent) )
|
||||
return false;
|
||||
|
||||
DirContainer::ParentIterator i = dir_table.FindFirstParent(parent);
|
||||
|
||||
for( ; i != dir_table.ParentEnd() ; i = dir_table.NextParent(i) )
|
||||
childs_table.push_back( &(*i->second) );
|
||||
|
||||
return true;
|
||||
DirContainer::ParentIterator i = dir_tab.FindFirstChild(parent_id);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
DirContainer::ParentIterator Dirs::NextChild(DirContainer::ParentIterator i)
|
||||
{
|
||||
return dir_tab.NextChild(i);
|
||||
}
|
||||
|
||||
// dodatkowo moze metoda AppendPath dodajaca sciezke do biezacego stringa?
|
||||
|
||||
DirContainer::ParentIterator Dirs::ParentEnd()
|
||||
{
|
||||
return dir_tab.ParentEnd();
|
||||
}
|
||||
|
||||
|
||||
// !! dodatkowo moze metoda AppendPath dodajaca sciezke do biezacego stringa?
|
||||
// albo tutaj stringa nie czyscic?
|
||||
// O(m * log n) (m- how many parts are in 'id')
|
||||
bool Dirs::MakePath(long id, std::string & path)
|
||||
// path with a slash at the end and at the beginning
|
||||
bool Dirs::MakePath(long id, std::wstring & path, bool clear_path)
|
||||
{
|
||||
DirContainer::Iterator i;
|
||||
|
||||
path = '/';
|
||||
if( clear_path )
|
||||
path.clear();
|
||||
|
||||
temp_path = '/';
|
||||
|
||||
while( true )
|
||||
{
|
||||
i = dir_table.FindId(id);
|
||||
i = dir_tab.FindId(id);
|
||||
|
||||
if( i == dir_table.End() )
|
||||
if( i == dir_tab.End() ||
|
||||
i->parent_id == id ) // means a loop (something wrong in the db)
|
||||
{
|
||||
// we don't change path if there is no such a directory
|
||||
return false;
|
||||
}
|
||||
|
||||
if( i->parent_id == -1 )
|
||||
{
|
||||
path += temp_path;
|
||||
return true;
|
||||
}
|
||||
|
||||
id = i->parent_id;
|
||||
|
||||
|
||||
path.insert(0, i->url);
|
||||
path.insert(path.begin(), '/');
|
||||
temp_path.insert(0, i->url);
|
||||
temp_path.insert(temp_path.begin(), '/');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// with exceptions
|
||||
|
||||
Item * Dirs::GetDirT(const std::string & path)
|
||||
void Dirs::MakePath(const std::vector<Item*> dir_tab, std::wstring & path, bool clear_path)
|
||||
{
|
||||
Item * pitem;
|
||||
|
||||
if( !GetDir(path, &pitem) )
|
||||
throw Error(Error::incorrect_dir);
|
||||
|
||||
return pitem;
|
||||
}
|
||||
if( clear_path )
|
||||
path.clear();
|
||||
|
||||
|
||||
Item * Dirs::GetDirT(const std::string & name, long parent)
|
||||
{
|
||||
Item * pitem;
|
||||
|
||||
if( !GetDir(name, parent, &pitem) )
|
||||
throw Error(Error::incorrect_dir);
|
||||
|
||||
return pitem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
long Dirs::GetDirIdT(const std::string & path)
|
||||
{
|
||||
long id;
|
||||
|
||||
if( !GetDirId(path, &id) )
|
||||
throw Error(Error::incorrect_dir);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
long Dirs::GetDirIdT(const std::string & name, long parent)
|
||||
{
|
||||
long id;
|
||||
|
||||
if( !GetDirId(name, parent, &id) )
|
||||
throw Error(Error::incorrect_dir);
|
||||
|
||||
return id;
|
||||
for(size_t i=0 ; i<dir_tab.size() ; ++i)
|
||||
{
|
||||
path += dir_tab[i]->url;
|
||||
path += '/';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! nowy interfejs
|
||||
size_t Dirs::DirLevel(long id)
|
||||
{
|
||||
DirContainer::Iterator i;
|
||||
size_t level = 0;
|
||||
|
||||
while( true )
|
||||
{
|
||||
i = dir_tab.FindId(id);
|
||||
|
||||
if( i == dir_tab.End() ||
|
||||
i->parent_id == id ) // means a loop (something wrong in the db)
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
if( i->parent_id == -1 )
|
||||
return level;
|
||||
|
||||
id = i->parent_id;
|
||||
level += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Dirs::IsChild(long parent_id, long child_id)
|
||||
{
|
||||
if( child_id == parent_id )
|
||||
return false;
|
||||
|
||||
DirContainer::Iterator i;
|
||||
|
||||
while( child_id != -1 )
|
||||
{
|
||||
i = dir_tab.FindId(child_id);
|
||||
|
||||
if( i == dir_tab.End() )
|
||||
return false;
|
||||
|
||||
if( i->parent_id == parent_id )
|
||||
return true;
|
||||
|
||||
child_id = i->parent_id;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Dirs::ChangeParent(long dir_id, long new_parent_id)
|
||||
{
|
||||
return dir_tab.ChangeParent(dir_id, new_parent_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
checking whether dir_id has a parent parent_id (somewhere in the path)
|
||||
*/
|
||||
bool Dirs::HasParent(long dir_id, long parent_id)
|
||||
{
|
||||
DirContainer::Iterator i;
|
||||
|
||||
while( true )
|
||||
{
|
||||
i = dir_tab.FindId(dir_id);
|
||||
|
||||
if( i==dir_tab.End() || i->parent_id==-1 )
|
||||
return false;
|
||||
|
||||
if( i->parent_id == parent_id )
|
||||
return true;
|
||||
|
||||
dir_id = i->parent_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Dirs::CreateDirTab(long dir_id, std::vector<Item*> & out_dir_tab)
|
||||
{
|
||||
DirContainer::Iterator i;
|
||||
|
||||
out_dir_tab.clear();
|
||||
|
||||
do
|
||||
{
|
||||
i = dir_tab.FindId(dir_id);
|
||||
|
||||
if( i == dir_tab.End() )
|
||||
return false;
|
||||
|
||||
if( out_dir_tab.empty() )
|
||||
out_dir_tab.insert(out_dir_tab.end(), &(*i)); // !! I am not sure whether begin() can be used on an empty container
|
||||
else
|
||||
out_dir_tab.insert(out_dir_tab.begin(), &(*i));
|
||||
|
||||
dir_id = i->parent_id;
|
||||
}
|
||||
while( dir_id != -1 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Item * Dirs::GetRootDir()
|
||||
{
|
||||
DirContainer::Iterator root = dir_table.GetRoot();
|
||||
DirContainer::Iterator root = dir_tab.GetRoot();
|
||||
|
||||
if( root == dir_table.End() )
|
||||
if( root == dir_tab.End() )
|
||||
return 0;
|
||||
|
||||
return &(*root);
|
||||
}
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::string & name, long parent)
|
||||
Item * Dirs::GetEtcDir()
|
||||
{
|
||||
DirContainer::ParentIterator i = dir_table.FindFirstParent(parent);
|
||||
DirContainer::Iterator etc = dir_tab.GetEtc();
|
||||
|
||||
for( ; i!=dir_table.ParentEnd() ; i = dir_table.NextParent(i) )
|
||||
if( etc == dir_tab.End() )
|
||||
return 0;
|
||||
|
||||
return &(*etc);
|
||||
}
|
||||
|
||||
|
||||
Item * Dirs::GetVarDir()
|
||||
{
|
||||
DirContainer::Iterator etc = dir_tab.GetVar();
|
||||
|
||||
if( etc == dir_tab.End() )
|
||||
return 0;
|
||||
|
||||
return &(*etc);
|
||||
}
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const wchar_t * name, long parent)
|
||||
{
|
||||
DirContainer::ParentIterator i = dir_tab.FindFirstChild(parent);
|
||||
|
||||
for( ; i!=dir_tab.ParentEnd() ; i = dir_tab.NextChild(i) )
|
||||
if( i->second->url == name )
|
||||
return &(*i->second);
|
||||
|
||||
@@ -306,38 +363,51 @@ return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::string & path)
|
||||
Item * Dirs::GetDir(const std::wstring & name, long parent)
|
||||
{
|
||||
DirContainer::Iterator root = dir_table.GetRoot();
|
||||
return GetDir(name.c_str(), parent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const wchar_t * path)
|
||||
{
|
||||
if( *path == 0 )
|
||||
return 0;
|
||||
|
||||
DirContainer::Iterator root = dir_tab.GetRoot();
|
||||
|
||||
if( root == dir_table.End() )
|
||||
if( root == dir_tab.End() )
|
||||
// ops, we do not have a root dir
|
||||
return 0;
|
||||
|
||||
Item * pitem = &(*root);
|
||||
|
||||
std::string name;
|
||||
const char * s = path.c_str();
|
||||
Item * pitem = &(*root);
|
||||
const wchar_t * s = path;
|
||||
|
||||
while( ExtractName(s, name) )
|
||||
while( ExtractName(s, get_dir_temp) )
|
||||
{
|
||||
pitem = GetDir(name, pitem->id);
|
||||
pitem = GetDir(get_dir_temp, pitem->id);
|
||||
|
||||
if( !pitem )
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return pitem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::wstring & path)
|
||||
{
|
||||
return GetDir(path.c_str());
|
||||
}
|
||||
|
||||
|
||||
Item * Dirs::GetDir(long id)
|
||||
{
|
||||
DirContainer::Iterator i = dir_table.FindId(id);
|
||||
DirContainer::Iterator i = dir_tab.FindId(id);
|
||||
|
||||
if( i == dir_table.End() )
|
||||
if( i == dir_tab.End() )
|
||||
return 0;
|
||||
|
||||
return &(*i);
|
||||
@@ -348,16 +418,241 @@ return &(*i);
|
||||
|
||||
Item * Dirs::AddDir(const Item & item)
|
||||
{
|
||||
return &(*dir_table.PushBack(item));
|
||||
return &(*dir_tab.PushBack(item));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
size_t Dirs::AnalyzeDir(Item * pdir, const std::wstring & path, long & dir_id, std::wstring & dir)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t old_i;
|
||||
|
||||
while( true )
|
||||
{
|
||||
dir_id = pdir->id;
|
||||
|
||||
// skipping slashes
|
||||
for( ; i<path.size() && path[i] == '/' ; ++i );
|
||||
|
||||
if( i == path.size() )
|
||||
return i; // end of the path
|
||||
|
||||
// creating a name
|
||||
old_i = i;
|
||||
analyze_temp.clear();
|
||||
|
||||
for( ; i<path.size() && path[i] != '/' ; ++i)
|
||||
analyze_temp += path[i];
|
||||
|
||||
pdir = GetDir(analyze_temp, pdir->id);
|
||||
|
||||
if( !pdir )
|
||||
return old_i; // analyze_temp is not a directory
|
||||
|
||||
dir += analyze_temp;
|
||||
dir += '/';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
the path should begin with a slash
|
||||
|
||||
return values:
|
||||
0 - directory exists
|
||||
dir_id - id of the directory
|
||||
dir - the path to the directory (with a slash at the end)
|
||||
file - if not empty means a file name (we don't check if the file really exists)
|
||||
1 - there is not a root dir
|
||||
2 - the path is empty
|
||||
3 - there is not such a directory
|
||||
*/
|
||||
int Dirs::AnalyzePath(const std::wstring & path, long & dir_id, std::wstring & dir, std::wstring & file)
|
||||
{
|
||||
Item * pdir = GetRootDir();
|
||||
dir = '/';
|
||||
file.clear();
|
||||
|
||||
if( !pdir )
|
||||
return 1;
|
||||
|
||||
if( path.empty() )
|
||||
return 2;
|
||||
|
||||
if( path[0] != '/' )
|
||||
return 3;
|
||||
|
||||
size_t i = AnalyzeDir(pdir, path, dir_id, dir);
|
||||
|
||||
if( i < path.size() )
|
||||
{
|
||||
// checking if at least one slash has left
|
||||
for(size_t a=i ; a < path.size() ; ++a)
|
||||
if( path[a] == '/' )
|
||||
return 3; // there is not such a directory
|
||||
|
||||
// the rest of the path is a file name
|
||||
file = path.c_str() + i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// current_dir_tab can be the same container as out_dir_tab
|
||||
void Dirs::CopyDirTab(const std::vector<Item*> & in, std::vector<Item*> & out)
|
||||
{
|
||||
if( &in != &out )
|
||||
{
|
||||
out.resize(in.size());
|
||||
|
||||
for(size_t i=0 ; i<in.size() ; ++i)
|
||||
out[i] = in[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Dirs::AnalyzeDir(std::vector<Item*> & dir_tab, const std::wstring & link_to, size_t & i)
|
||||
{
|
||||
size_t old_i;
|
||||
i = 0;
|
||||
|
||||
if( dir_tab.empty() )
|
||||
return false;
|
||||
|
||||
while( true )
|
||||
{
|
||||
// skipping slashes
|
||||
for( ; i<link_to.size() && link_to[i] == '/' ; ++i);
|
||||
|
||||
if( i == link_to.size() )
|
||||
return true; // end of the path
|
||||
|
||||
// creating a name
|
||||
old_i = i;
|
||||
analyze_temp.clear();
|
||||
|
||||
for( ; i<link_to.size() && link_to[i] != '/' ; ++i)
|
||||
analyze_temp += link_to[i];
|
||||
|
||||
if( analyze_temp == L".." )
|
||||
{
|
||||
if( dir_tab.size() <= 1 )
|
||||
return false;
|
||||
|
||||
dir_tab.pop_back();
|
||||
}
|
||||
else
|
||||
if( analyze_temp != L"." )
|
||||
{
|
||||
Item * pdir = GetDir(analyze_temp, dir_tab.back()->id);
|
||||
|
||||
if( !pdir )
|
||||
{
|
||||
i = old_i;
|
||||
return true; // analyze_temp is not a directory
|
||||
}
|
||||
|
||||
dir_tab.push_back(pdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Dirs::SplitPath(const std::string & path, std::string & dir, std::string & file)
|
||||
|
||||
int Dirs::FollowLink(std::vector<Item*> & dir_tab, const std::wstring & link_to, std::wstring & out_item)
|
||||
{
|
||||
std::string::size_type i;
|
||||
size_t i;
|
||||
|
||||
if( !AnalyzeDir(dir_tab, link_to, i) )
|
||||
return 2; // incorrect link_to
|
||||
|
||||
if( i < link_to.size() )
|
||||
{
|
||||
// checking if at least one slash has left
|
||||
for(size_t a=i ; a < link_to.size() ; ++a)
|
||||
if( link_to[a] == '/' )
|
||||
return 2; // there is not such a directory
|
||||
|
||||
// the rest of the path is a file name
|
||||
out_item = link_to.c_str() + i;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
return codes:
|
||||
ok:
|
||||
0 - the link_to is a path to a directory (out_item skipped, out_dir_tab will not be empty)
|
||||
1 - the link_to is a path to a file (out_item is used, out_dir_tab will not be empty)
|
||||
|
||||
error:
|
||||
2 - incorrect link_to
|
||||
3 - there is not a root dir
|
||||
4 - current_dir_tab was empty
|
||||
|
||||
current_dir_tab can be the same container as out_dir_tab
|
||||
link_to can be a relative path (without the first slash) and can contain ".." or "."
|
||||
*/
|
||||
int Dirs::FollowLink(const std::vector<Item*> & current_dir_tab, const std::wstring & link_to,
|
||||
std::vector<Item*> & out_dir_tab, std::wstring & out_item)
|
||||
{
|
||||
temp_link_to = link_to; // link_to can be from the out_item and would be cleared next
|
||||
out_item.clear();
|
||||
|
||||
if( current_dir_tab.empty() )
|
||||
return 4;
|
||||
|
||||
if( temp_link_to.empty() )
|
||||
{
|
||||
CopyDirTab(current_dir_tab, out_dir_tab);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( temp_link_to[0] == '/' )
|
||||
{
|
||||
// temp_link_to is an absolute path
|
||||
Item * pdir = GetRootDir();
|
||||
|
||||
if( !pdir )
|
||||
return 3;
|
||||
|
||||
out_dir_tab.clear();
|
||||
out_dir_tab.push_back(pdir);
|
||||
}
|
||||
else
|
||||
{
|
||||
// temp_link_to is a relative path
|
||||
CopyDirTab(current_dir_tab, out_dir_tab);
|
||||
}
|
||||
|
||||
return FollowLink(out_dir_tab, temp_link_to, out_item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Dirs::SplitPath(const std::wstring & path, std::wstring & dir, std::wstring & file)
|
||||
{
|
||||
std::wstring::size_type i;
|
||||
|
||||
dir.clear();
|
||||
file.clear();
|
||||
@@ -382,31 +677,78 @@ void Dirs::SplitPath(const std::string & path, std::string & dir, std::string &
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Dirs::DeleteDir(long id)
|
||||
// !! dodac kasowanie z bazy
|
||||
bool Dirs::DelDir(long dir_id)
|
||||
{
|
||||
DirContainer::ParentIterator pnext, p = dir_table.FindFirstParent(id);
|
||||
|
||||
for( ; p != dir_table.ParentEnd() ; p = pnext )
|
||||
{
|
||||
// this iterator p will be deleted by the next DeleteDir(p->second->id)
|
||||
// (the next iterator we must calculate beforehand)
|
||||
pnext = dir_table.NextParent(p);
|
||||
|
||||
DeleteDir(p->second->id);
|
||||
}
|
||||
|
||||
if( db.DelDirById(id) == Error::ok )
|
||||
dir_table.DelById(id);
|
||||
|
||||
if( data.mounts.CurrentMountType() == Mount::thread )
|
||||
db.RemoveThread(id);
|
||||
return dir_tab.DelById(dir_id);
|
||||
}
|
||||
|
||||
|
||||
Error Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir, int notify_code)
|
||||
{
|
||||
if( pdir )
|
||||
*pdir = 0;
|
||||
|
||||
if( item.type != Item::dir )
|
||||
return WINIX_ERR_DIR_EXPECTED;
|
||||
|
||||
Error status = db->AddItem(item);
|
||||
|
||||
if( status == WINIX_ERR_OK )
|
||||
{
|
||||
Item * d = AddDir(item);
|
||||
|
||||
if( add_to_dir_tab && !cur->request->dir_tab.empty() && cur->request->dir_tab.back()->id == item.parent_id )
|
||||
cur->request->dir_tab.push_back(d);
|
||||
|
||||
if( pdir )
|
||||
*pdir = d;
|
||||
|
||||
if( notify_code )
|
||||
notify->ItemChanged(notify_code, item);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Item * Dirs::CreateVarDir()
|
||||
{
|
||||
Item * var = GetVarDir();
|
||||
|
||||
if( var )
|
||||
return var;
|
||||
|
||||
Item v;
|
||||
Item * root = GetRootDir();
|
||||
|
||||
if( root )
|
||||
{
|
||||
v.parent_id = root->id;
|
||||
v.user_id = root->user_id;
|
||||
v.group_id = root->group_id;
|
||||
v.privileges = root->privileges;
|
||||
v.subject = L"var";
|
||||
v.url = L"var";
|
||||
v.type = Item::dir;
|
||||
|
||||
AddDirectory(v, false, &var);
|
||||
}
|
||||
|
||||
return var;
|
||||
}
|
||||
|
||||
|
||||
// printing first and last slash
|
||||
void Dirs::LogDir(const std::vector<Item*> & dir_tab)
|
||||
{
|
||||
log << '/';
|
||||
|
||||
// skipping the first (root) directory
|
||||
for(size_t i=1 ; i<dir_tab.size() ; ++i)
|
||||
log << dir_tab[i]->url << '/';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
119
core/dirs.h
119
core/dirs.h
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoredirs
|
||||
#define headerfilecmslucoredirs
|
||||
#ifndef headerfile_winix_core_dirs
|
||||
#define headerfile_winix_core_dirs
|
||||
|
||||
|
||||
#include <vector>
|
||||
@@ -17,8 +17,13 @@
|
||||
|
||||
#include "item.h"
|
||||
#include "dircontainer.h"
|
||||
#include "db/db.h"
|
||||
#include "request.h"
|
||||
#include "notify/notify.h"
|
||||
|
||||
|
||||
// we do not support '..' in a path (for simplicity and security reasons)
|
||||
|
||||
|
||||
class Dirs
|
||||
{
|
||||
@@ -27,63 +32,85 @@ public:
|
||||
void Clear();
|
||||
void ReadDirs();
|
||||
|
||||
// without any exceptions
|
||||
// these methods return false in a case the path or name (with a specific parent) are invalid
|
||||
// we do not support '..' in a path (for security reason)
|
||||
|
||||
bool IsDir(long id);
|
||||
|
||||
bool GetRootDir(Item ** item);
|
||||
|
||||
bool GetDir(const std::string & path, Item ** item);
|
||||
bool GetDir(const std::string & name, long parent, Item ** item);
|
||||
|
||||
bool GetDirId(const std::string & path, long * id);
|
||||
bool GetDirId(const std::string & name, long parent, long * id);
|
||||
void SetCur(Cur * pcur);
|
||||
void SetDb(Db * pdb);
|
||||
void SetNotify(Notify * pnotify);
|
||||
|
||||
//!! ta nie bedzie chyba potrzebna
|
||||
bool GetDirChilds(long parent, std::vector<Item> & childs_table); // only returns dir-children
|
||||
// these methods return false if there is no such a dir
|
||||
bool IsDir(long dir_id);
|
||||
bool GetDirChilds(long parent_id, std::vector<Item*> & childs_tab); // !! zamienic na GetChilds()
|
||||
bool MakePath(long dir_id, std::wstring & path, bool clear_path = true);
|
||||
void MakePath(const std::vector<Item*> dir_tab, std::wstring & path, bool clear_path = true);
|
||||
bool ChangeParent(long dir_id, long new_parent_id);
|
||||
|
||||
bool GetDirChilds(long parent, std::vector<Item*> & childs_table); // only returns dir-children
|
||||
bool HasParent(long dir_id, long parent_id);
|
||||
|
||||
bool MakePath(long id, std::string & path);
|
||||
bool DelDir(long dir_id);
|
||||
|
||||
// if returns true then out_dir_tab is not empty
|
||||
bool CreateDirTab(long dir_id, std::vector<Item*> & out_dir_tab);
|
||||
|
||||
void LogDir(const std::vector<Item*> & dir_tab);
|
||||
|
||||
int AnalyzePath(const std::wstring & path, long & dir_id, std::wstring & dir, std::wstring & file);
|
||||
int FollowLink(const std::vector<Item*> & current_dir_tab, const std::wstring & link_to,
|
||||
std::vector<Item*> & out_dir_tab, std::wstring & out_item);
|
||||
static void SplitPath(const std::wstring & path, std::wstring & dir, std::wstring & file);
|
||||
|
||||
DirContainer::ParentIterator FindFirstChild(long parent_id);
|
||||
DirContainer::ParentIterator NextChild(DirContainer::ParentIterator i);
|
||||
DirContainer::ParentIterator ParentEnd(); // !! pozostalo do zamiany na child
|
||||
|
||||
|
||||
// with an Error exception
|
||||
// if the path or name are invalid these methods throw an exception
|
||||
Item * GetDirT(const std::string & path);
|
||||
Item * GetDirT(const std::string & name, long parent);
|
||||
long GetDirIdT(const std::string & path);
|
||||
long GetDirIdT(const std::string & name, long parent);
|
||||
|
||||
|
||||
|
||||
// !! nowy interfejs
|
||||
|
||||
// returns null if there is no a root dir
|
||||
// these methods return null if there is no such a dir
|
||||
// !! zmienic nazwy wskazujace ze operujemy tylko na lokalnej tablicy
|
||||
Item * GetRootDir();
|
||||
Item * GetDir(const std::string & name, long parent);
|
||||
Item * GetDir(const std::string & path);
|
||||
Item * GetDir(long id);
|
||||
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);
|
||||
|
||||
|
||||
static void SplitPath(const std::string & path, std::string & dir, std::string & file);
|
||||
|
||||
|
||||
void DeleteDir(long id);
|
||||
|
||||
|
||||
void CheckRootDir();
|
||||
|
||||
Item * CreateVarDir();
|
||||
|
||||
// !! jak juz wczesniejsze nazwy beda zmienione to tutaj damy AddDir() /AddDir() juz istnieje przeciez?/
|
||||
Error AddDirectory(Item & item, bool add_to_dir_tab = false, Item ** pdir = 0, int notify_code = 0);
|
||||
|
||||
// returns how many levels of directories there are
|
||||
// "/" -> 0 (root dir)
|
||||
// "/abc" -> 1
|
||||
// "/abc/def" -> 2
|
||||
size_t DirLevel(long id);
|
||||
|
||||
// checking if child_id is really a child of parent_id
|
||||
bool IsChild(long parent_id, long child_id);
|
||||
|
||||
private:
|
||||
|
||||
DirContainer dir_table;
|
||||
Cur * cur;
|
||||
Db * db;
|
||||
Notify * notify;
|
||||
|
||||
bool ExtractName(const char * & s, std::string & name);
|
||||
|
||||
DirContainer dir_tab;
|
||||
std::wstring temp_path;
|
||||
std::wstring temp_link_to;
|
||||
|
||||
size_t AnalyzeDir(Item * pdir, const std::wstring & path, long & dir_id, std::wstring & dir);
|
||||
bool AnalyzeDir(std::vector<Item*> & dir_tab, const std::wstring & link_to, size_t & i);
|
||||
std::wstring analyze_temp;
|
||||
std::wstring get_dir_temp;
|
||||
|
||||
void CopyDirTab(const std::vector<Item*> & in, std::vector<Item*> & out);
|
||||
int FollowLink(std::vector<Item*> & dir_tab, const std::wstring & link_to, std::wstring & out_item);
|
||||
|
||||
bool ExtractName(const wchar_t * & s, std::wstring & name);
|
||||
bool HasReadExecAccessForRoot(const Item & item);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "done.h"
|
||||
|
||||
|
||||
Done::Done()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Done::Done(Code c) : code(c)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Done & Done::operator=(Code c)
|
||||
{
|
||||
code = c;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool Done::operator==(Code c) const
|
||||
{
|
||||
return code == c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Done::operator!=(Code c) const
|
||||
{
|
||||
return code != c;
|
||||
}
|
||||
|
||||
|
||||
Done::operator int()
|
||||
{
|
||||
return static_cast<int>( code );
|
||||
}
|
||||
51
core/done.h
51
core/done.h
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoredone
|
||||
#define headerfilecmslucoredone
|
||||
|
||||
|
||||
|
||||
// what has been done
|
||||
class Done
|
||||
{
|
||||
public:
|
||||
|
||||
enum Code
|
||||
{
|
||||
none = 0,
|
||||
added_item,
|
||||
edited_item,
|
||||
deleted_item,
|
||||
deleted_dir,
|
||||
privileged_item,
|
||||
added_dir,
|
||||
added_thread,
|
||||
defaulted_dir,
|
||||
loggedout
|
||||
};
|
||||
|
||||
|
||||
Done();
|
||||
Done(Code c);
|
||||
Done & operator=(Code c);
|
||||
bool operator==(Code c) const;
|
||||
bool operator!=(Code c) const;
|
||||
|
||||
operator int();
|
||||
|
||||
private:
|
||||
|
||||
Code code;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "error.h"
|
||||
|
||||
|
||||
|
||||
Error::Error()
|
||||
{
|
||||
code = unknown;
|
||||
}
|
||||
|
||||
|
||||
Error::Error(Code c) : code(c)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Error::Error(int i)
|
||||
{
|
||||
code = static_cast<Code>(i);
|
||||
}
|
||||
|
||||
|
||||
Error::Error(const Error & e)
|
||||
{
|
||||
code = e.code;
|
||||
}
|
||||
|
||||
|
||||
Error::operator int() const
|
||||
{
|
||||
return static_cast<int>(code);
|
||||
}
|
||||
|
||||
|
||||
Error & Error::operator=(Code c)
|
||||
{
|
||||
code = c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Error & Error::operator=(const Error & e)
|
||||
{
|
||||
code = e.code;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Error::operator==(Code c) const
|
||||
{
|
||||
return code == c;
|
||||
}
|
||||
|
||||
|
||||
bool Error::operator!=(Code c) const
|
||||
{
|
||||
return code != c;
|
||||
}
|
||||
|
||||
bool Error::operator==(const Error & e) const
|
||||
{
|
||||
return code == e.code;
|
||||
}
|
||||
|
||||
|
||||
bool Error::operator!=(const Error & e) const
|
||||
{
|
||||
return code != e.code;
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream & out, const Error & e)
|
||||
{
|
||||
out << static_cast<int>(e.code);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Log & operator<<(Log & out, const Error & e)
|
||||
{
|
||||
out << static_cast<int>(e.code);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
119
core/error.h
119
core/error.h
@@ -1,86 +1,79 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoreerror
|
||||
#define headerfilecmslucoreerror
|
||||
|
||||
#include <iostream>
|
||||
#include "log.h"
|
||||
#ifndef headerfile_winix_core_error
|
||||
#define headerfile_winix_core_error
|
||||
|
||||
|
||||
|
||||
|
||||
class Error
|
||||
{
|
||||
#define WINIX_ERR_OK 0
|
||||
//#define WINIX_ERR_INCORRECT_PATH 1
|
||||
|
||||
public:
|
||||
//#define WINIX_ERR_NO_POSTVAR 2
|
||||
#define WINIX_ERR_INCORRECT_DIR 3
|
||||
#define WINIX_ERR_CANT_CHANGE_USER 4
|
||||
#define WINIX_ERR_CANT_CHANGE_GROUP 5
|
||||
#define WINIX_ERR_CANT_CHANGE_PRIVILEGES 6
|
||||
#define WINIX_ERR_PERMISSION_DENIED 7
|
||||
#define WINIX_ERR_NO_ROOT_DIR 8
|
||||
#define WINIX_ERR_NO_FUNCTION 9
|
||||
|
||||
enum Code
|
||||
{
|
||||
ok = 0,
|
||||
incorrect_path,
|
||||
db_fatal_error_during_connecting,
|
||||
db_incorrect_query,
|
||||
db_incorrent_result_status,
|
||||
db_no_column,
|
||||
db_no_item, // !! zamienic na no_item
|
||||
db_incorrect_login,
|
||||
db_more_than_one_login,
|
||||
db_err_currval,
|
||||
no_postvar,
|
||||
incorrect_dir,
|
||||
cant_change_user,
|
||||
cant_change_group,
|
||||
cant_change_privileges,
|
||||
permision_denied, // !! permission_denied (dwa ss)
|
||||
no_root_dir,
|
||||
no_function, // !! zamienic na no_function
|
||||
|
||||
item_required, // !! zamienic na no_item (i usunac db_no_item)
|
||||
unknown_param,
|
||||
|
||||
mount_unknown,
|
||||
no_mountpoint,
|
||||
mount_no_param,
|
||||
|
||||
no_thread,
|
||||
|
||||
unknown = 1000
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
Error();
|
||||
Error(Code c);
|
||||
Error(int i);
|
||||
Error(const Error & e);
|
||||
Error & operator=(Code c);
|
||||
Error & operator=(const Error & e);
|
||||
#define WINIX_ERR_NO_ITEM 10
|
||||
#define WINIX_ERR_UNKNOWN_PARAM 11
|
||||
|
||||
operator int() const;
|
||||
|
||||
bool operator==(Code c) const;
|
||||
bool operator!=(Code c) const;
|
||||
bool operator==(const Error & e) const;
|
||||
bool operator!=(const Error & e) const;
|
||||
|
||||
friend std::ostream & operator<<(std::ostream & out, const Error & e);
|
||||
friend Log & operator<<(Log & out, const Error & e);
|
||||
#define WINIX_ERR_MOUNT_UNKNOWN 12
|
||||
#define WINIX_ERR_UNKNOWN_FILESYSTEM 13
|
||||
#define WINIX_ERR_NO_MOUNTPOINT 14
|
||||
//#define WINIX_ERR_MOUNT_NO_PARAM 15
|
||||
|
||||
#define WINIX_ERR_NO_THREAD 16
|
||||
#define WINIX_ERR_EMPTY 17
|
||||
#define WINIX_ERR_SPAM 18
|
||||
#define WINIX_ERR_INCORRECT_REBUS 19
|
||||
|
||||
|
||||
|
||||
private:
|
||||
#define WINIX_ERR_NO_BOUNDARY 20
|
||||
#define WINIX_ERR_BROKEN_INPUT 21
|
||||
#define WINIX_ERR_INPUT_TOO_LARGE 22
|
||||
#define WINIX_ERR_CANT_CREATE_FILE 23
|
||||
|
||||
Code code;
|
||||
#define WINIX_ERR_NO_TICKET 24
|
||||
|
||||
};
|
||||
//#define WINIX_ERR_PASSWORDS_DIFFERENT 25
|
||||
//#define WINIX_ERR_PASSWORD_TOO_SHORT 26
|
||||
//#define WINIX_ERR_USER_EXISTS 27
|
||||
//#define WINIX_ERR_LOGIN_EMPTY 28
|
||||
#define WINIX_DIFFERENT_MOUNT_POINTS 29
|
||||
|
||||
|
||||
#define WINIX_ERR_DB_FATAL_ERROR_DURING_CONNECTING 100
|
||||
#define WINIX_ERR_DB_INCORRECT_QUERY 101
|
||||
#define WINIX_ERR_DB_INCORRENT_RESULT_STATUS 102
|
||||
#define WINIX_ERR_DB_NO_COLUMN 103
|
||||
#define WINIX_ERR_DB_INCORRECT_LOGIN 104
|
||||
#define WINIX_ERR_DB_MORE_THAN_ONE_LOGIN 105
|
||||
#define WINIX_ERR_DB_ERR_CURRVAL 106
|
||||
|
||||
#define WINIX_ERR_FILE_EXPECTED 107
|
||||
#define WINIX_ERR_DIR_EXPECTED 108
|
||||
|
||||
//#define WINIX_ERR_UNKNOWN 1000
|
||||
#define WINIX_NOTHING_TO_DO 109
|
||||
#define WINIX_ERR_INCORRECT_URI 110
|
||||
|
||||
#define WINIX_ERR_INTERNAL_ERROR 2000
|
||||
|
||||
|
||||
typedef int Error;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "function.h"
|
||||
|
||||
|
||||
|
||||
Function::Function()
|
||||
{
|
||||
code = FUN_NONE;
|
||||
}
|
||||
|
||||
void Function::Clear()
|
||||
{
|
||||
code = FUN_NONE;
|
||||
item.Clear();
|
||||
}
|
||||
|
||||
|
||||
Function::Function(const Function & f)
|
||||
{
|
||||
code = f.code;
|
||||
item = f.item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Function & Function::operator=(const Function & f)
|
||||
{
|
||||
code = f.code;
|
||||
item = f.item;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorefunction
|
||||
#define headerfilecmslucorefunction
|
||||
|
||||
#include <iostream>
|
||||
#include "item.h"
|
||||
|
||||
|
||||
#define FUN_NONE 0
|
||||
#define FUN_LS 1
|
||||
#define FUN_CAT 2
|
||||
#define FUN_NODE 3
|
||||
#define FUN_EMACS 4
|
||||
#define FUN_MKDIR 5
|
||||
#define FUN_DEFAULT 6
|
||||
#define FUN_PRIV 7
|
||||
#define FUN_RM 8
|
||||
#define FUN_LOGIN 9
|
||||
#define FUN_LOGOUT 10
|
||||
#define FUN_RUN 11
|
||||
#define FUN_WHO 12
|
||||
#define FUN_LAST 13
|
||||
#define FUN_CREATETHREAD 14
|
||||
#define FUN_THREAD 15
|
||||
|
||||
|
||||
|
||||
|
||||
class Function
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
enum Code
|
||||
{
|
||||
none,
|
||||
ls,
|
||||
cat,
|
||||
node,
|
||||
emacs,
|
||||
mkdir,
|
||||
default,
|
||||
priv,
|
||||
rm,
|
||||
login,
|
||||
logout,
|
||||
run,
|
||||
who
|
||||
};
|
||||
|
||||
|
||||
Code code;
|
||||
*/
|
||||
/*
|
||||
we do not use enum etc. because the code will be used with an application too
|
||||
(application can set others values)
|
||||
*/
|
||||
int code;
|
||||
Item item;
|
||||
|
||||
void Clear();
|
||||
|
||||
Function();
|
||||
Function(const Function & f);
|
||||
Function & operator=(const Function & f);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "functioncodeparser.h"
|
||||
#include "function.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
bool FunctionCodeParser::ContentHasOneRow(const Item & item)
|
||||
{
|
||||
for(size_t i=0 ; i<item.content.size() ; ++i)
|
||||
if( item.content[i] == '\n' )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int FunctionCodeParser::ParseValue(const char * s)
|
||||
{
|
||||
if( strncmp(s, "[fun:", 5) != 0 )
|
||||
return FUN_NONE;
|
||||
|
||||
const char * send;
|
||||
int result = strtol(s+5, (char**)&send, 10);
|
||||
|
||||
if( send==s+5 || strcmp(send, "]") != 0 )
|
||||
return FUN_NONE;
|
||||
|
||||
log << log2 << "FCP: function code: " << result << logend;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int FunctionCodeParser::Parse(const Item & item)
|
||||
{
|
||||
// format: [fun:1]
|
||||
// minimum size: 7 characters
|
||||
if( item.content.size() < 7 )
|
||||
return FUN_NONE;
|
||||
|
||||
if( !ContentHasOneRow(item) )
|
||||
return FUN_NONE;
|
||||
|
||||
return ParseValue(item.content.c_str());
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorefunctioncodeparser
|
||||
#define headerfilecmslucorefunctioncodeparser
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "item.h"
|
||||
|
||||
|
||||
class FunctionCodeParser
|
||||
{
|
||||
bool ContentHasOneRow(const Item & item);
|
||||
int ParseValue(const char * s);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
int Parse(const Item & item);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "functionparser.h"
|
||||
#include "log.h"
|
||||
#include "item.h"
|
||||
#include "error.h"
|
||||
#include "data.h"
|
||||
#include "db.h"
|
||||
#include "request.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void FunctionParser::SkipEmptyString(const char * msg)
|
||||
{
|
||||
for( ; get_index != get_table_len && request.get_table[get_index].empty() ; ++get_index )
|
||||
log << log3 << msg << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FunctionParser::ParseDirectories()
|
||||
{
|
||||
Item * pdir = data.dirs.GetRootDir();
|
||||
|
||||
if( !pdir )
|
||||
{
|
||||
// there is no the root dir
|
||||
request.status = Error::no_root_dir;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while( true )
|
||||
{
|
||||
request.dir_table.push_back( pdir );
|
||||
log << log3 << "FP: Directory: ";
|
||||
|
||||
if( pdir->parent_id == -1 )
|
||||
log << "(root)" << logend;
|
||||
else
|
||||
log << pdir->url << logend;
|
||||
|
||||
SkipEmptyString("FP: Directory: skipped empty string");
|
||||
|
||||
if( get_index == get_table_len )
|
||||
break;
|
||||
|
||||
pdir = data.dirs.GetDir(request.get_table[get_index], pdir->id);
|
||||
|
||||
if( !pdir )
|
||||
break;
|
||||
|
||||
++get_index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunctionParser::ParseItem()
|
||||
{
|
||||
SkipEmptyString("FP: Item: skipped empty string");
|
||||
|
||||
if( get_index == get_table_len )
|
||||
return;
|
||||
|
||||
// request.dir_table has at least one element
|
||||
long parent_id = request.dir_table.back()->id;
|
||||
const std::string & url = request.get_table[get_index];
|
||||
|
||||
request.status = db.GetItem(parent_id, url, request.item);
|
||||
|
||||
if( request.status == Error::ok )
|
||||
{
|
||||
++get_index;
|
||||
request.is_item = true;
|
||||
log << log3 << "FP: Item: id: " << request.item.id << ", url: " << request.item.url << logend;
|
||||
}
|
||||
else
|
||||
log << log3 << "FP: No Item: url: " << url << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunctionParser::ParseFunction()
|
||||
{
|
||||
SkipEmptyString("FP: Function: skipped empty string");
|
||||
|
||||
if( get_index == get_table_len )
|
||||
return;
|
||||
|
||||
request.pfunction = data.functions.GetFunction(request.get_table[get_index]);
|
||||
|
||||
|
||||
if( request.pfunction )
|
||||
{
|
||||
++get_index;
|
||||
log << log3 << "FP: Function: " << request.pfunction->item.url << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::ParseParams()
|
||||
{
|
||||
while( true )
|
||||
{
|
||||
SkipEmptyString("FP: Params: skipped empty string");
|
||||
|
||||
if( get_index == get_table_len )
|
||||
break;
|
||||
|
||||
request.param_table.push_back( &request.get_table[get_index] );
|
||||
log << log3 << "FP: Params: " << request.get_table[get_index] << logend;
|
||||
|
||||
++get_index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FunctionParser::Parse()
|
||||
{
|
||||
request.status = Error::ok;
|
||||
get_index = 0;
|
||||
get_table_len = request.get_table.size();
|
||||
request.pfunction = 0;
|
||||
request.is_item = false;
|
||||
|
||||
ParseDirectories();
|
||||
|
||||
if( request.status != Error::ok )
|
||||
return;
|
||||
|
||||
ParseFunction();
|
||||
|
||||
if( !request.pfunction )
|
||||
{
|
||||
ParseItem();
|
||||
|
||||
if( request.status != Error::ok )
|
||||
return;
|
||||
|
||||
ParseFunction();
|
||||
|
||||
if( !request.pfunction && get_index != get_table_len )
|
||||
{
|
||||
request.status = Error::no_function;
|
||||
log << log3 << "FP: Parse: unknown function: \"" << request.get_table[get_index] << "\"" << logend;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ParseParams();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorefunctionparser
|
||||
#define headerfilecmslucorefunctionparser
|
||||
|
||||
#include "requesttypes.h"
|
||||
|
||||
#ifdef APPFUNCTIONS
|
||||
#include "../app/content.h"
|
||||
#endif
|
||||
|
||||
class FunctionParser
|
||||
{
|
||||
GetTable::size_type get_index;
|
||||
GetTable::size_type get_table_len;
|
||||
|
||||
void SkipEmptyString(const char * msg);
|
||||
|
||||
void ParseDirectories();
|
||||
void ParseItem();
|
||||
bool IsAppFunction();
|
||||
void ParseFunction();
|
||||
void ParseParams();
|
||||
|
||||
public:
|
||||
|
||||
|
||||
void Parse();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "functions.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Functions::Clear()
|
||||
{
|
||||
table.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Functions::ReadFunctions()
|
||||
{
|
||||
Clear();
|
||||
|
||||
Function f;
|
||||
|
||||
f.item.user_id = -1;
|
||||
f.item.group_id = -1;
|
||||
f.item.privileges = 0644;
|
||||
f.item.parent_id = -1; // !! temporarily doesn't matter
|
||||
f.item.id = -1;
|
||||
f.item.type = Item::file;
|
||||
|
||||
// in the future we will read these functions from the database
|
||||
f.code = FUN_LS;
|
||||
f.item.url = "ls";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_CAT;
|
||||
f.item.url = "cat";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_NODE;
|
||||
f.item.url = "node";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_EMACS;
|
||||
f.item.url = "emacs";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_MKDIR;
|
||||
f.item.url = "mkdir";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_DEFAULT;
|
||||
f.item.url = "default";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_PRIV;
|
||||
f.item.url = "priv";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_RM;
|
||||
f.item.url = "rm";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_LOGOUT;
|
||||
f.item.url = "logout";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_LOGIN;
|
||||
f.item.url = "login";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_RUN;
|
||||
f.item.url = "run";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_WHO;
|
||||
f.item.url = "who";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_LAST;
|
||||
f.item.url = "last";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_CREATETHREAD;
|
||||
f.item.url = "createthread";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
f.code = FUN_THREAD;
|
||||
f.item.url = "thread";
|
||||
table.insert( std::make_pair(f.item.url, f) );
|
||||
|
||||
// -----------
|
||||
// FunctionCodeParser fc;
|
||||
// fc.Parse(Item()); // temporary for linking
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Function * Functions::GetFunction(const std::string & name)
|
||||
{
|
||||
Table::iterator i = table.find(name);
|
||||
|
||||
if( i == table.end() )
|
||||
return 0;
|
||||
|
||||
return &(i->second);
|
||||
}
|
||||
|
||||
|
||||
// !! in the future there will be a special container where we can search through the Code object
|
||||
Function * Functions::GetFunction(int code)
|
||||
{
|
||||
Table::iterator i = table.begin();
|
||||
|
||||
for( ; i != table.end() ; ++i )
|
||||
{
|
||||
if( i->second.code == code )
|
||||
return &(i->second);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorefunctions
|
||||
#define headerfilecmslucorefunctions
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "function.h"
|
||||
|
||||
|
||||
|
||||
class Functions
|
||||
{
|
||||
|
||||
typedef std::map<std::string, Function> Table;
|
||||
Table table;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
void Clear();
|
||||
void ReadFunctions();
|
||||
|
||||
Function * GetFunction(const std::string & name);
|
||||
Function * GetFunction(int code);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoregetparser
|
||||
#define headerfilecmslucoregetparser
|
||||
|
||||
#include "httpsimpleparser.h"
|
||||
#include "requesttypes.h"
|
||||
|
||||
|
||||
class GetParser : public HttpSimpleParser
|
||||
{
|
||||
|
||||
const char * get_string;
|
||||
GetTable & get_table;
|
||||
|
||||
protected:
|
||||
|
||||
virtual int GetChar()
|
||||
{
|
||||
if( !get_string || *get_string == 0 )
|
||||
return -1;
|
||||
|
||||
return (int)(unsigned char)*(get_string++);
|
||||
}
|
||||
|
||||
|
||||
virtual void Parameter(std::string &, std::string & value)
|
||||
{
|
||||
get_table.push_back(value);
|
||||
|
||||
log << log2 << "Get, value: \"" << value << "\"" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
GetParser(const char * get_string_, GetTable & get_table_) : get_string(get_string_), get_table(get_table_)
|
||||
{
|
||||
HttpSimpleParser::separator = '/';
|
||||
HttpSimpleParser::read_name = false;
|
||||
|
||||
if( get_string && *get_string == separator ) // one '/' at the beginning
|
||||
++get_string;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
10
core/group.h
10
core/group.h
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoregroup
|
||||
#define headerfilecmslucoregroup
|
||||
#ifndef headerfile_winix_core_group
|
||||
#define headerfile_winix_core_group
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -18,7 +18,7 @@
|
||||
struct Group
|
||||
{
|
||||
long id;
|
||||
std::string name; // group name
|
||||
std::wstring name; // group name
|
||||
std::vector<long> members; // users id
|
||||
|
||||
Group()
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "groups.h"
|
||||
#include "db.h"
|
||||
|
||||
|
||||
|
||||
@@ -25,11 +24,11 @@ void Groups::Clear()
|
||||
}
|
||||
|
||||
|
||||
void Groups::ReadGroups()
|
||||
void Groups::ReadGroups(Db * db)
|
||||
{
|
||||
Clear();
|
||||
|
||||
db.GetGroups(table);
|
||||
db->GetGroups(table);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +43,7 @@ return &(*i);
|
||||
}
|
||||
|
||||
|
||||
Group * Groups::GetGroup(const std::string & name)
|
||||
Group * Groups::GetGroup(const std::wstring & name)
|
||||
{
|
||||
Table::Iterator i = table.FindName(name);
|
||||
|
||||
@@ -55,7 +54,7 @@ return &(*i);
|
||||
}
|
||||
|
||||
|
||||
long Groups::GetGroupId(const std::string & name)
|
||||
long Groups::GetGroupId(const std::wstring & name)
|
||||
{
|
||||
Group * pgroup = GetGroup(name);
|
||||
|
||||
@@ -87,9 +86,9 @@ Groups::SizeType Groups::Size()
|
||||
}
|
||||
|
||||
|
||||
Group & Groups::operator[](Groups::SizeType pos)
|
||||
bool Groups::Remove(long group_id)
|
||||
{
|
||||
return table[pos];
|
||||
return table.Remove(group_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoregroups
|
||||
#define headerfilecmslucoregroups
|
||||
#ifndef headerfile_winix_core_groups
|
||||
#define headerfile_winix_core_groups
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "group.h"
|
||||
#include "ugcontainer.h"
|
||||
#include "db/db.h"
|
||||
|
||||
|
||||
|
||||
class Groups
|
||||
@@ -29,14 +31,14 @@ public:
|
||||
|
||||
Groups();
|
||||
void Clear();
|
||||
void ReadGroups();
|
||||
void ReadGroups(Db * db);
|
||||
Group * GetGroup(long group_id);
|
||||
Group * GetGroup(const std::string & name);
|
||||
long GetGroupId(const std::string & name);
|
||||
Group * GetGroup(const std::wstring & name);
|
||||
long GetGroupId(const std::wstring & name);
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
Group & operator[](SizeType pos);
|
||||
bool Remove(long group_id);
|
||||
|
||||
};
|
||||
|
||||
|
||||
1400
core/htmlfilter.cpp
Executable file
1400
core/htmlfilter.cpp
Executable file
File diff suppressed because it is too large
Load Diff
299
core/htmlfilter.h
Executable file
299
core/htmlfilter.h
Executable file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_htmlfilter
|
||||
#define headerfile_winix_core_htmlfilter
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
|
||||
|
||||
// max length of a name of a html tag (with terminating null)
|
||||
#define WINIX_HTMLFILTER_ITEM_NAME_MAXLEN 30
|
||||
|
||||
// max length of a html lang attribute (e.g. "en", "pl")
|
||||
#define WINIX_HTMLFILTER_ITEM_LANG_MAXLEN 10
|
||||
|
||||
|
||||
#define WINIX_HTMLFILTER_ATTR_NAME_MAXLEN 40
|
||||
|
||||
|
||||
#define WINIX_HTMLFILTER_ATTR_VALUE_MAXLEN 500
|
||||
|
||||
|
||||
// depth of the html tree
|
||||
#define WINIX_HTMLFILTER_STACK_MAXLEN 100
|
||||
|
||||
// length of a buffer used for printing
|
||||
// it should be at least: WINIX_HTMLFILTER_ITEM_NAME_MAXLEN+3
|
||||
#define WINIX_HTMLFILTER_BUFFER_MAXLEN 2048
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
very lightweight filter for html
|
||||
(without using any dynamic memory - some memory is allocated only at the beginning - in ctors)
|
||||
this filter has O(n) complexity over the whole html string
|
||||
|
||||
such tags as: <script> <pre> <textarea> are treated in a special way
|
||||
all characters between the opening and closing tag (<script>....</script>) are untouched
|
||||
|
||||
if the filter finds that there are not closed tags it will close them,
|
||||
if the filter finds a closing tag which doesn't have an opening tag - it will skip it
|
||||
|
||||
tags which don't need to be closed: meta, input, br, img, link
|
||||
look at CheckExceptions() method
|
||||
|
||||
the filter recognizes xml simple tags (with / at the end) such as: <br />
|
||||
*/
|
||||
class HTMLFilter
|
||||
{
|
||||
public:
|
||||
|
||||
enum OrphanMode
|
||||
{
|
||||
orphan_nbsp, // putting " " string
|
||||
orphan_160space // putting 160 ascii code
|
||||
};
|
||||
|
||||
HTMLFilter();
|
||||
HTMLFilter(const HTMLFilter & f);
|
||||
HTMLFilter & operator=(const HTMLFilter & f);
|
||||
~HTMLFilter();
|
||||
|
||||
|
||||
// main methods used for filtering
|
||||
void Filter(const wchar_t * in, std::wstring & out);
|
||||
void Filter(const std::wstring & in, std::wstring & out);
|
||||
|
||||
|
||||
// insert a white space into long words
|
||||
// (only between html tags)
|
||||
// skipped in such tags: script, pre, textarea
|
||||
// break_after - after how many characters insert a space (0 - off)
|
||||
void BreakWord(size_t break_after_);
|
||||
|
||||
// insert a new line character into long lines
|
||||
// (only between html tags)
|
||||
// skipped in such tags: script, pre, textarea
|
||||
// wrap_line - after how many characters wrap a line (0 - off)
|
||||
// lines are wrapped only in 'body' tag (useful for text in 'title' tag which is in 'head' section)
|
||||
void WrapLine(size_t wrap_line_);
|
||||
|
||||
// trimming white characters (with new lines)
|
||||
// at the beginning, at the end and in the middle of a string
|
||||
// only between html tags
|
||||
// at the beginning and at the end only one space is left
|
||||
// skipped in such tags: script, pre, textarea
|
||||
// false by default
|
||||
void TrimWhite(bool trim);
|
||||
|
||||
|
||||
// first tabs in a tree
|
||||
// default: 2 (spaces)
|
||||
// set 0 to turn off
|
||||
void InsertTabs(size_t tabsize);
|
||||
|
||||
|
||||
// orphans are checked only in 'body' tag
|
||||
void AssignOrphans(const wchar_t * lang_code, const std::vector<std::wstring> & otab);
|
||||
void AssignOrphans(const std::wstring & lang_code, const std::vector<std::wstring> & otab);
|
||||
void ClearOrphans();
|
||||
|
||||
|
||||
// check 'orphans' for the specicic language
|
||||
// if an orphan is detected then the non-break space (" " or ascii 160 code) will be put
|
||||
// default disable (lang_none)
|
||||
void OrphansMode(OrphanMode mode = orphan_nbsp);
|
||||
|
||||
|
||||
// skipping some unsafe tags
|
||||
// (script, iframe, frame, frameset, applet, head, meta, html, link, body, ...)
|
||||
void SafeMode(bool safe_mode_);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// orphans for one language
|
||||
struct Orphans
|
||||
{
|
||||
std::vector<std::wstring> tab;
|
||||
size_t max_len;
|
||||
};
|
||||
|
||||
|
||||
// orphans for all languages
|
||||
// map<language_code, Orphans>
|
||||
typedef std::map<std::wstring, Orphans> OrphansTab;
|
||||
OrphansTab orphans_tab;
|
||||
|
||||
|
||||
struct Item
|
||||
{
|
||||
std::wstring name; // max size: WINIX_HTMLFILTER_ITEM_NAME_MAXLEN
|
||||
|
||||
enum Type
|
||||
{
|
||||
opening, /* sample: <h1> */
|
||||
closing, /* sample: </h1> */
|
||||
simple, /* sample: <br/> */
|
||||
special, /* sample: <!doctype> */
|
||||
none
|
||||
} type;
|
||||
|
||||
// is there a new line after this tag
|
||||
bool new_line;
|
||||
|
||||
// current orphans table
|
||||
// (will be propagated)
|
||||
Orphans * porphans;
|
||||
|
||||
// this item or one from its parents is a 'body' html tag
|
||||
// (will be propagated)
|
||||
bool has_body_tag;
|
||||
|
||||
void Clear();
|
||||
Item();
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
virtual methods
|
||||
*/
|
||||
virtual void Init();
|
||||
virtual void Uninit();
|
||||
|
||||
virtual bool IsOpeningTagMark();
|
||||
virtual bool IsOpeningCommentaryTagMark();
|
||||
virtual bool IsClosingTagMark();
|
||||
virtual bool IsClosingXmlSimpleTagMark();
|
||||
|
||||
virtual bool IsValidCharForName(int c);
|
||||
virtual bool IsValidCharForAttrName(int c);
|
||||
virtual void CheckExceptions();
|
||||
virtual bool SkipCommentaryTagIfExists();
|
||||
|
||||
virtual void Put(wchar_t c);
|
||||
virtual void Put(const wchar_t * str);
|
||||
virtual void Put(const wchar_t * str, const wchar_t * end);
|
||||
virtual void Put(const std::wstring & str);
|
||||
|
||||
virtual void PutOpeningTagMark();
|
||||
virtual void PutClosingTagMark();
|
||||
virtual bool PutOpeningTag();
|
||||
virtual void PutClosingTag(const wchar_t * tag);
|
||||
|
||||
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
|
||||
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
|
||||
|
||||
|
||||
/*
|
||||
others
|
||||
*/
|
||||
Item & GetItem(size_t i);
|
||||
Item & LastItem();
|
||||
|
||||
wchar_t ToLower(wchar_t c);
|
||||
void ToLower(std::wstring & str);
|
||||
|
||||
bool IsNameEqual(const wchar_t * name1, const wchar_t * name2);
|
||||
bool IsNameEqual(const wchar_t * name1, const std::wstring & name2);
|
||||
bool IsNameEqual(const std::wstring & name1, const wchar_t * name2);
|
||||
bool IsNameEqual(const std::wstring & name1, const std::wstring & name2);
|
||||
|
||||
bool IsNameEqual(const wchar_t * name1, const wchar_t * name2, size_t len);
|
||||
bool IsNameEqual(const wchar_t * name1, const std::wstring & name2, size_t len);
|
||||
bool IsNameEqual(const std::wstring & name1, const wchar_t * name2, size_t len);
|
||||
bool IsNameEqual(const std::wstring & name1, const std::wstring & name2, size_t len);
|
||||
|
||||
bool IsLastTag(const wchar_t * name);
|
||||
bool IsTagSafe(const wchar_t * tag);
|
||||
bool IsTagSafe(const std::wstring & tag);
|
||||
|
||||
int CheckOrphan(const wchar_t * str, const wchar_t * end, const std::wstring & orphan_str);
|
||||
bool CheckOrphan(const wchar_t * str, const wchar_t * end, const std::vector<std::wstring> & orphans);
|
||||
bool CheckOrphan(const wchar_t * str, const wchar_t * end);
|
||||
|
||||
bool IsWhite(int c);
|
||||
void SkipWhite();
|
||||
void SkipWhiteLines();
|
||||
void SkipWhiteWithFirstNewLine();
|
||||
void SkipWhiteLines(const wchar_t * & str, const wchar_t * end);
|
||||
bool IsClosingTagForLastItem();
|
||||
size_t OpeningCommentaryTagMarkSize();
|
||||
void SkipAndCheckClosingTag();
|
||||
|
||||
void PopStack();
|
||||
bool PushStack();
|
||||
void CheckNewLine();
|
||||
void CheckStackPrintRest();
|
||||
void AddForgottenTags();
|
||||
void CheckClosingTags();
|
||||
void ReadNormalText();
|
||||
bool PrintRest();
|
||||
bool PrintOpeningItem();
|
||||
void ReadItemName();
|
||||
void ReadItemAttrName();
|
||||
void ReadItemAttrValue(bool has_quote);
|
||||
|
||||
bool ReadItemAttr();
|
||||
bool CheckItemAttr();
|
||||
void PrinItemAttr();
|
||||
|
||||
void ReadItemClosing();
|
||||
void ReadItemSpecial();
|
||||
void ReadItemOpening();
|
||||
bool ReadItem();
|
||||
void ReadLoop();
|
||||
void Read();
|
||||
|
||||
void CheckChar(wchar_t c);
|
||||
|
||||
void CheckLineWrap();
|
||||
bool HasSemiloconAround(const wchar_t * str, const wchar_t * end);
|
||||
void PutNormalNonWhite(const wchar_t * & str, const wchar_t * end);
|
||||
void PutNormalWhite(const wchar_t * & str, const wchar_t * end);
|
||||
void PutLastTagWithClosingTag();
|
||||
void PutTabs(size_t len);
|
||||
void PutNonBreakingSpace();
|
||||
void PutNewLine();
|
||||
void CalcOrphansMaxLen(Orphans & orphans);
|
||||
|
||||
const wchar_t * pchar;
|
||||
Item empty;
|
||||
Item * pstack; // stack pointer
|
||||
size_t stack_len; // length of the stack
|
||||
wchar_t * buffer; // buffer used when printing
|
||||
std::wstring * out_string;
|
||||
bool last_new_line;
|
||||
size_t break_after; // insert a space into long words after 'break_after' characters
|
||||
size_t wrap_line; // insert a new line character into long lines
|
||||
bool trim_white; // trimming white characters
|
||||
size_t tab_size;
|
||||
OrphanMode orphan_mode;
|
||||
std::wstring attr_name;
|
||||
std::wstring attr_value;
|
||||
std::wstring attr_value_lower;
|
||||
bool attr_has_value;
|
||||
std::wstring lang_code_lower;
|
||||
size_t line_len; //length of the current line (without first spaces which create the html tree)
|
||||
bool safe_mode; // skipping some unsafe tags
|
||||
Orphans orphans_temp;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorehttpsimpleparser
|
||||
#define headerfilecmslucorehttpsimpleparser
|
||||
#ifndef headerfile_winix_core_httpsimpleparser
|
||||
#define headerfile_winix_core_httpsimpleparser
|
||||
|
||||
|
||||
#include <string>
|
||||
@@ -46,7 +46,7 @@ protected:
|
||||
void TrimWhiteChars(std::string & s);
|
||||
void CheckSpecialChar();
|
||||
|
||||
|
||||
void Parse();
|
||||
|
||||
|
||||
public:
|
||||
@@ -60,12 +60,6 @@ public:
|
||||
skip_white_chars = false;
|
||||
recognize_special_chars = true;
|
||||
}
|
||||
|
||||
|
||||
void Parse();
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
415
core/image.cpp
Executable file
415
core/image.cpp
Executable file
@@ -0,0 +1,415 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctime>
|
||||
#include "image.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "log.h"
|
||||
#include "system.h"
|
||||
#include "plugin.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void Image::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
|
||||
void Image::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
|
||||
|
||||
void Image::SetSystem(System * psystem)
|
||||
{
|
||||
system = psystem;
|
||||
}
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void Image::Resize(const Item & item, size_t cx, size_t cy, int aspect_mode, int quality)
|
||||
{
|
||||
item_temp.type = WINIX_IMAGE_TYPE_RESIZE;
|
||||
item_temp.file = item;
|
||||
item_temp.cx = cx;
|
||||
item_temp.cy = cy;
|
||||
item_temp.aspect_mode = aspect_mode;
|
||||
item_temp.quality = quality;
|
||||
|
||||
CheckParam(item_temp);
|
||||
image_tab.insert(image_tab.end(), item_temp);
|
||||
WakeUpThread();
|
||||
}
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void Image::CreateThumb(const Item & item, size_t cx, size_t 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.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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread (objects locked)
|
||||
bool Image::SignalReceived()
|
||||
{
|
||||
return !image_tab.empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread (objects not locked)
|
||||
void Image::Do()
|
||||
{
|
||||
ImageTab::iterator i;
|
||||
bool end;
|
||||
|
||||
Lock();
|
||||
i = image_tab.begin();
|
||||
Unlock();
|
||||
|
||||
do
|
||||
{
|
||||
Lock();
|
||||
|
||||
if( i != image_tab.end() )
|
||||
{
|
||||
item_work = *i;
|
||||
image_tab.erase(i++);
|
||||
end = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
end = true;
|
||||
}
|
||||
|
||||
Unlock();
|
||||
|
||||
if( !end )
|
||||
CreateImage();
|
||||
|
||||
}
|
||||
while( !end && !IsExitSignal() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Image::Add(const std::wstring & in, TextStream<std::string> & out)
|
||||
{
|
||||
PT::WideToUTF8(in, add_tempa);
|
||||
out << add_tempa;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Image::EscapePath(const std::string & path, TextStream<std::string> & out, bool clear_stream)
|
||||
{
|
||||
if( clear_stream )
|
||||
out.Clear();
|
||||
|
||||
out << '"';
|
||||
|
||||
for(size_t i=0 ; i<path.size() ; ++i)
|
||||
{
|
||||
if( path[i] == '"' )
|
||||
out << '\\';
|
||||
|
||||
out << path[i];
|
||||
}
|
||||
|
||||
out << '\"';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
from: http://www.imagemagick.org/script/command-line-processing.php#geometry
|
||||
|
||||
scale% Height and width both scaled by specified percentage.
|
||||
scale-x%xscale-y% Height and width individually scaled by specified percentages. (Only one % symbol needed.)
|
||||
width Width given, height automagically selected to preserve aspect ratio.
|
||||
xheight Height given, width automagically selected to preserve aspect ratio.
|
||||
widthxheight Maximum values of height and width given, aspect ratio preserved.
|
||||
widthxheight^ Minimum values of width and height given, aspect ratio preserved.
|
||||
widthxheight! Width and height emphatically given, original aspect ratio ignored.
|
||||
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()
|
||||
{
|
||||
switch( item_work.aspect_mode )
|
||||
{
|
||||
case WINIX_IMAGE_MODE_1:
|
||||
command << item_work.cx;
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_3:
|
||||
command << item_work.cx << "x" << item_work.cy;
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_4:
|
||||
command << '"' << item_work.cx << "x" << item_work.cy << "^\"";
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_5:
|
||||
command << '"' << item_work.cx << "x" << item_work.cy << "!\"";
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_6:
|
||||
command << '"' << item_work.cx << "x" << item_work.cy << ">\"";
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_7:
|
||||
command << '"' << item_work.cx << "x" << item_work.cy << "<\"";
|
||||
break;
|
||||
|
||||
case WINIX_IMAGE_MODE_2:
|
||||
default:
|
||||
command << "x" << item_work.cy;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread (objects locked)
|
||||
bool Image::CreateInputFileName()
|
||||
{
|
||||
if( system->MakeFilePath(item_work.file, src_path) )
|
||||
{
|
||||
PT::WideToUTF8(src_path, input_file_name);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Image: cannot create a source path" << logend;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// second thread (objects locked)
|
||||
void Image::CreateTmpFileName()
|
||||
{
|
||||
stream_tmp_path.Clear();
|
||||
stream_tmp_path << config->upload_dir << L"/tmp/image_" << std::time(0);
|
||||
PT::WideToUTF8(stream_tmp_path.Str(), tmp_file_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread (objects are not locked)
|
||||
bool Image::CreateCommand()
|
||||
{
|
||||
Lock();
|
||||
|
||||
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)
|
||||
|
||||
// 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();
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !CreateInputFileName() )
|
||||
{
|
||||
Unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
command.Clear();
|
||||
Add(config->convert_cmd, command);
|
||||
|
||||
command << " ";
|
||||
EscapePath(input_file_name, command, false);
|
||||
command << " -quiet -quality " << item_work.quality;
|
||||
|
||||
if( item_work.type == WINIX_IMAGE_TYPE_RESIZE )
|
||||
command << " -resize ";
|
||||
else
|
||||
command << " -strip -thumbnail ";
|
||||
|
||||
SelectAspect();
|
||||
CreateTmpFileName();
|
||||
|
||||
command << " ";
|
||||
EscapePath(tmp_file_name, command, false);
|
||||
|
||||
log << log4 << "Image: running: " << command.Str() << logend;
|
||||
|
||||
Unlock();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// second thread (objects are not locked)
|
||||
void Image::SaveImage()
|
||||
{
|
||||
bool moved = false;
|
||||
|
||||
Lock();
|
||||
|
||||
// the file could have been changed especially when creating the image lasted too long
|
||||
iq.SetAll(true, false);
|
||||
iq.WhereId(item_work.file.id);
|
||||
|
||||
if( db->GetItem(item_work.file, iq) == WINIX_ERR_OK )
|
||||
{
|
||||
bool thumb = (item_work.type == WINIX_IMAGE_TYPE_CREATE_THUMB);
|
||||
|
||||
if( system->MakeFilePath(item_work.file, 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log3 << "Image: image resized: " << dst_path << logend;
|
||||
plugin.Call((Session*)0, WINIX_IMAGE_RESIZED, &item_work.file);
|
||||
}
|
||||
|
||||
moved = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Image: cannot move a temporary file: " << stream_tmp_path.Str() << ", to: " << dst_path << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Image: cannot create a destination path" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
if( !moved )
|
||||
::RemoveFile(stream_tmp_path.Str());
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread (objects are not locked)
|
||||
void Image::CreateImage()
|
||||
{
|
||||
if( !CreateCommand() )
|
||||
return;
|
||||
|
||||
int res = std::system(command.CStr());
|
||||
|
||||
if( res == 0 )
|
||||
{
|
||||
SaveImage();
|
||||
}
|
||||
else
|
||||
{
|
||||
Lock();
|
||||
log << log3 << "Image: some problems with creating an image"
|
||||
<< ", 'convert' process returned: " << res << logend;
|
||||
Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// second thread (objects are not locked)
|
||||
// !! there is a problem with GIF files
|
||||
// Bus error (core dumped)
|
||||
/*
|
||||
#include "wand/MagickWand.h"
|
||||
|
||||
// compiler options:
|
||||
// include: -I/usr/local/include/ImageMagick
|
||||
// link with: `MagickWand-config --ldflags --libs`
|
||||
|
||||
void Image::CreateThumbnail()
|
||||
{
|
||||
PT::WideToUTF8(item_work.source, sourcea);
|
||||
PT::WideToUTF8(item_work.dst, dsta);
|
||||
|
||||
MagickWandGenesis();
|
||||
|
||||
MagickWand * wand = NewMagickWand();
|
||||
|
||||
if( MagickReadImage(wand, sourcea.c_str()) )
|
||||
{
|
||||
MagickThumbnailImage(wand, item_work.cx, item_work.cy);
|
||||
|
||||
if( MagickWriteImage(wand, dsta.c_str()) )
|
||||
{
|
||||
Lock();
|
||||
log << log3 << "Image: created a thumbnail: " << dsta << logend;
|
||||
Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
DestroyMagickWand(wand);
|
||||
|
||||
MagickWandTerminus();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
114
core/image.h
Executable file
114
core/image.h
Executable file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_image
|
||||
#define headerfile_winix_core_image
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include "basethread.h"
|
||||
#include "textstream.h"
|
||||
#include "db/db.h"
|
||||
#include "core/item.h"
|
||||
#include "core/config.h"
|
||||
|
||||
|
||||
class System;
|
||||
|
||||
|
||||
|
||||
// Width given, height automagically selected to preserve aspect ratio.
|
||||
#define WINIX_IMAGE_MODE_1 1
|
||||
|
||||
// Height given, width automagically selected to preserve aspect ratio.
|
||||
#define WINIX_IMAGE_MODE_2 2
|
||||
|
||||
// Maximum values of height and width given, aspect ratio preserved.
|
||||
#define WINIX_IMAGE_MODE_3 3
|
||||
|
||||
// Minimum values of width and height given, aspect ratio preserved.
|
||||
#define WINIX_IMAGE_MODE_4 4
|
||||
|
||||
// Width and height emphatically given, original aspect ratio ignored.
|
||||
#define WINIX_IMAGE_MODE_5 5
|
||||
|
||||
// Change as per widthxheight but only if an image dimension exceeds a specified dimension.
|
||||
#define WINIX_IMAGE_MODE_6 6
|
||||
|
||||
// Change dimensions only if both image dimensions are less than specified dimensions.
|
||||
#define WINIX_IMAGE_MODE_7 7
|
||||
|
||||
|
||||
// resizing
|
||||
#define WINIX_IMAGE_TYPE_RESIZE 1
|
||||
|
||||
// generating a thumbnail
|
||||
#define WINIX_IMAGE_TYPE_CREATE_THUMB 2
|
||||
|
||||
|
||||
|
||||
|
||||
class Image : public BaseThread
|
||||
{
|
||||
public:
|
||||
|
||||
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);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Db * db;
|
||||
Config * config;
|
||||
System * system;
|
||||
|
||||
struct ImageItem
|
||||
{
|
||||
int type; // WINIX_IMAGE_TYPE_*
|
||||
Item file;
|
||||
size_t cx;
|
||||
size_t cy;
|
||||
int aspect_mode;
|
||||
int quality;
|
||||
};
|
||||
|
||||
// queue of thumbnails to create
|
||||
typedef std::list<ImageItem> ImageTab;
|
||||
ImageTab image_tab;
|
||||
ImageItem item_temp;
|
||||
|
||||
// only for second thread
|
||||
ImageItem item_work;
|
||||
std::wstring src_path, dst_path;
|
||||
TextStream<std::string> command;
|
||||
TextStream<std::wstring> stream_tmp_path;
|
||||
DbItemQuery iq;
|
||||
std::string add_tempa;
|
||||
std::string input_file_name;
|
||||
std::string tmp_file_name;
|
||||
|
||||
virtual bool SignalReceived();
|
||||
virtual void Do();
|
||||
bool CreateCommand();
|
||||
bool CreateInputFileName();
|
||||
void CreateTmpFileName();
|
||||
void SaveImage();
|
||||
void CreateImage();
|
||||
void SelectAspect();
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
148
core/ipban.h
Normal file
148
core/ipban.h
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_ipban
|
||||
#define headerfile_winix_core_ipban
|
||||
|
||||
|
||||
// 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
|
||||
221
core/ipbancontainer.cpp
Normal file
221
core/ipbancontainer.cpp
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
58
core/ipbancontainer.h
Normal file
58
core/ipbancontainer.h
Normal file
@@ -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
|
||||
|
||||
82
core/item.cpp
Executable file
82
core/item.cpp
Executable file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "item.h"
|
||||
#include "misc.h"
|
||||
#include "crypt.h"
|
||||
|
||||
|
||||
|
||||
Item::Item()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
// !! IMPROVE ME
|
||||
// now we have Request::start_time and Request::start_date
|
||||
// we can somehow get the current time from the request
|
||||
// may setting the date should be completetly removed from here?
|
||||
void Item::SetDateToNow()
|
||||
{
|
||||
date_creation = std::time(0);
|
||||
date_modification = date_creation;
|
||||
}
|
||||
|
||||
|
||||
void Item::SetDateModifyToNow()
|
||||
{
|
||||
date_modification = std::time(0);
|
||||
}
|
||||
|
||||
|
||||
void Item::Clear()
|
||||
{
|
||||
id = -1;
|
||||
|
||||
user_id = -1;
|
||||
group_id = -1;
|
||||
privileges = 0;
|
||||
modification_user_id = -1;
|
||||
|
||||
guest_name.clear();
|
||||
|
||||
subject.clear();
|
||||
content.clear();
|
||||
modify_index = 0;
|
||||
url.clear();
|
||||
|
||||
content_type = ct_formatted_text;
|
||||
|
||||
type = none;
|
||||
parent_id = -1;
|
||||
|
||||
link_to.clear();
|
||||
link_redirect = false;
|
||||
|
||||
content_id = -1;
|
||||
ref = 1;
|
||||
|
||||
file_path.clear();
|
||||
file_fs = -1;
|
||||
file_type = WINIX_ITEM_FILETYPE_NONE;
|
||||
hash.clear();
|
||||
hash_type = WINIX_CRYPT_HASH_NONE;
|
||||
file_size = 0;
|
||||
has_thumb = false;
|
||||
|
||||
html_template.clear();
|
||||
sort_index = 0;
|
||||
meta.Clear();
|
||||
ameta.Clear();
|
||||
|
||||
SetDateToNow();
|
||||
}
|
||||
|
||||
|
||||
139
core/item.h
139
core/item.h
@@ -1,109 +1,120 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoreitem
|
||||
#define headerfilecmslucoreitem
|
||||
#ifndef headerfile_winix_core_item
|
||||
#define headerfile_winix_core_item
|
||||
|
||||
#include <string>
|
||||
#include "space/space.h"
|
||||
#include "date/date.h"
|
||||
|
||||
|
||||
|
||||
#define WINIX_ITEM_FILETYPE_NONE 0
|
||||
#define WINIX_ITEM_FILETYPE_IMAGE 1
|
||||
#define WINIX_ITEM_FILETYPE_DOCUMENT 2
|
||||
#define WINIX_ITEM_FILETYPE_VIDEO 3
|
||||
#define WINIX_ITEM_FILETYPE_UNKNOWN 10
|
||||
|
||||
|
||||
|
||||
|
||||
struct Item
|
||||
{
|
||||
long id;
|
||||
long id;
|
||||
long parent_id;
|
||||
|
||||
|
||||
long user_id;
|
||||
long group_id;
|
||||
int privileges;
|
||||
long user_id;
|
||||
long group_id;
|
||||
std::wstring guest_name; // used as a user name when user_id is equal -1
|
||||
|
||||
// used as a user name when user_id is equal -1
|
||||
std::string guest_name;
|
||||
long modification_user_id; // who has modified the item last (not taken into account when checking permissions)
|
||||
|
||||
tm date_creation;
|
||||
tm date_modification;
|
||||
int privileges;
|
||||
|
||||
std::string subject;
|
||||
std::string content;
|
||||
std::string url;
|
||||
PT::Date date_creation;
|
||||
PT::Date date_modification;
|
||||
|
||||
std::wstring subject;
|
||||
std::wstring content;
|
||||
|
||||
// 0 - simple txt
|
||||
// 1 - formatted txt
|
||||
// 2 - html
|
||||
// 3 - bbcode
|
||||
int content_type;
|
||||
std::wstring url;
|
||||
int modify_index;
|
||||
|
||||
enum ContentType
|
||||
{
|
||||
ct_text = 0,
|
||||
ct_formatted_text,
|
||||
ct_html,
|
||||
ct_bbcode,
|
||||
ct_raw
|
||||
};
|
||||
|
||||
ContentType content_type;
|
||||
|
||||
|
||||
|
||||
enum Type
|
||||
{
|
||||
dir = 0,
|
||||
file = 1,
|
||||
enum Type
|
||||
{
|
||||
dir = 0,
|
||||
file = 1,
|
||||
symlink = 2,
|
||||
|
||||
none = 1000
|
||||
};
|
||||
none = 1000
|
||||
};
|
||||
|
||||
|
||||
Type type;
|
||||
|
||||
//item_type;
|
||||
|
||||
long parent_id;
|
||||
long default_item;
|
||||
Type type;
|
||||
|
||||
|
||||
// used by the database
|
||||
// !! moze da sie w ogole z tego zrezygnowac?
|
||||
long content_id;
|
||||
// used when type is symlink or to a directory too (function 'default')
|
||||
std::wstring link_to;
|
||||
int link_redirect;
|
||||
|
||||
|
||||
Item()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
// static file (if exists)
|
||||
std::wstring file_path; // relative file path
|
||||
int file_fs; // file system type where the file was saved
|
||||
int file_type; // file type (none, image, doc, etc)
|
||||
bool has_thumb; // whether or not we have a thumbnail
|
||||
std::wstring hash; // file hash (md4, md5, ...)
|
||||
int hash_type; // hash type WINIX_CRYPT_HASH_* (see crypt.h)
|
||||
size_t file_size; // size of the file
|
||||
|
||||
|
||||
std::wstring html_template;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
id = -1;
|
||||
|
||||
user_id = -1;
|
||||
group_id = -1;
|
||||
privileges = 0;
|
||||
|
||||
guest_name.clear();
|
||||
|
||||
subject.clear();
|
||||
content.clear();
|
||||
url.clear();
|
||||
|
||||
content_type = 0;
|
||||
|
||||
type = none;
|
||||
parent_id = -1;
|
||||
default_item = -1;
|
||||
|
||||
content_id = -1;
|
||||
|
||||
time_t t = std::time(0);
|
||||
date_creation = *std::localtime( &t );
|
||||
date_modification = date_creation;
|
||||
}
|
||||
// sort index used when displaying a group of items
|
||||
int sort_index;
|
||||
|
||||
|
||||
// meta information
|
||||
PT::Space meta;
|
||||
PT::Space ameta;
|
||||
|
||||
|
||||
// methods
|
||||
Item();
|
||||
void SetDateToNow();
|
||||
void SetDateModifyToNow();
|
||||
void Clear();
|
||||
|
||||
|
||||
private:
|
||||
// used by the database
|
||||
long content_id; // content id in 'content' table
|
||||
int ref; // content references
|
||||
|
||||
friend class Db;
|
||||
friend struct DbItemColumns;
|
||||
};
|
||||
|
||||
|
||||
|
||||
165
core/job.cpp
Executable file
165
core/job.cpp
Executable file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "job.h"
|
||||
#include "plugin.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
Job::Job()
|
||||
{
|
||||
jobs_queue_tab.resize(WINIX_JOBS_HOW_MANY_PRIORITIES);
|
||||
}
|
||||
|
||||
|
||||
void Job::CheckPriority(int & priority) const
|
||||
{
|
||||
if( priority < 0 )
|
||||
priority = 0;
|
||||
|
||||
if( priority >= WINIX_JOBS_HOW_MANY_PRIORITIES )
|
||||
priority = WINIX_JOBS_HOW_MANY_PRIORITIES - 1;
|
||||
}
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void Job::Add(PT::Space & job, int priority)
|
||||
{
|
||||
CheckPriority(priority);
|
||||
jobs_queue_tab[priority].push(job);
|
||||
WakeUpThread();
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t Job::Size(int priority) const
|
||||
{
|
||||
CheckPriority(priority);
|
||||
return jobs_queue_tab[priority].size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t Job::Size() const
|
||||
{
|
||||
size_t sum = 0;
|
||||
|
||||
for(size_t i=0 ; i<WINIX_JOBS_HOW_MANY_PRIORITIES ; ++i)
|
||||
sum += Size(i);
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
bool Job::Empty(int priority) const
|
||||
{
|
||||
CheckPriority(priority);
|
||||
return jobs_queue_tab[priority].empty();
|
||||
}
|
||||
|
||||
|
||||
bool Job::Empty() const
|
||||
{
|
||||
for(size_t i=0 ; i<WINIX_JOBS_HOW_MANY_PRIORITIES ; ++i)
|
||||
if( !Empty(i) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
second thread
|
||||
*/
|
||||
|
||||
// second thread (objects locked)
|
||||
bool Job::SignalReceived()
|
||||
{
|
||||
return !Empty();
|
||||
}
|
||||
|
||||
|
||||
// second thread (objects not locked)
|
||||
void Job::Do()
|
||||
{
|
||||
size_t i = WINIX_JOBS_HOW_MANY_PRIORITIES;
|
||||
bool is_empty;
|
||||
|
||||
while( i-- > 0 && !IsExitSignal() )
|
||||
{
|
||||
do
|
||||
{
|
||||
Lock();
|
||||
is_empty = Empty(i);
|
||||
Unlock();
|
||||
|
||||
if( !is_empty )
|
||||
DoQueue(jobs_queue_tab[i]);
|
||||
}
|
||||
while( !is_empty && !IsExitSignal() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// second thread (objects not locked, jobs_queue is not empty)
|
||||
void Job::DoQueue(JobsQueue & jobs_queue)
|
||||
{
|
||||
bool is_empty;
|
||||
|
||||
do
|
||||
{
|
||||
Lock();
|
||||
// references will not be invalidated after insertion to jobs_queue
|
||||
// (jobs_queue is std::queue and it uses std::deque by default)
|
||||
PT::Space & job = jobs_queue.front();
|
||||
Unlock();
|
||||
|
||||
DoJob(job);
|
||||
|
||||
Lock();
|
||||
jobs_queue.pop();
|
||||
is_empty = jobs_queue.empty();
|
||||
Unlock();
|
||||
}
|
||||
while( !is_empty && !IsExitSignal() );
|
||||
}
|
||||
|
||||
|
||||
// second thread (objects not locked)
|
||||
void Job::DoJob(PT::Space & job)
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginRes res = plugin.Call((Session*)0, WINIX_JOB, &job);
|
||||
|
||||
if( res.res_true == 0 )
|
||||
DoWinixJob(job);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// second thread (objects not locked)
|
||||
void Job::DoWinixJob(PT::Space & job)
|
||||
{
|
||||
Lock();
|
||||
//log << log1 << "standard winix job: " << job.Text(L"type") << logend;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
82
core/job.h
Executable file
82
core/job.h
Executable file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_jobs
|
||||
#define headerfile_winix_core_jobs
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include "basethread.h"
|
||||
#include "space/space.h"
|
||||
|
||||
|
||||
|
||||
#define WINIX_JOBS_HOW_MANY_PRIORITIES 32
|
||||
|
||||
|
||||
|
||||
|
||||
class Job : public BaseThread
|
||||
{
|
||||
public:
|
||||
|
||||
Job();
|
||||
|
||||
/*
|
||||
add a new job to the queue
|
||||
priority: 0-31 (0 - the lowest priority, 31 - the highest priority)
|
||||
*/
|
||||
void Add(PT::Space & job, int priority = 0);
|
||||
|
||||
|
||||
/*
|
||||
queue size, and size of all jobs in any priority
|
||||
*/
|
||||
size_t Size(int priority) const;
|
||||
size_t Size() const;
|
||||
|
||||
|
||||
/*
|
||||
true if specified queue is empty
|
||||
or if all queues are empty
|
||||
*/
|
||||
bool Empty(int priority) const;
|
||||
bool Empty() const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
typedef std::queue<PT::Space> JobsQueue;
|
||||
typedef std::vector<JobsQueue> JobsQueueTab;
|
||||
JobsQueueTab jobs_queue_tab;
|
||||
|
||||
void CheckPriority(int & priority) const;
|
||||
void SaveToFile();
|
||||
void ReadFromFile();
|
||||
|
||||
|
||||
/*
|
||||
second thread
|
||||
*/
|
||||
|
||||
// standard winix jobs
|
||||
// Image image;
|
||||
// sending emails
|
||||
// etc.
|
||||
|
||||
bool SignalReceived();
|
||||
void Do();
|
||||
void DoQueue(JobsQueue & jobs_queue);
|
||||
void DoJob(PT::Space & job);
|
||||
void DoWinixJob(PT::Space & job);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "lastcontainer.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
LastItem::LastItem()
|
||||
@@ -18,23 +18,12 @@ LastItem::LastItem()
|
||||
user_id = 0;
|
||||
ip = 0;
|
||||
session_id = 0;
|
||||
memset((char*)&start, 0, sizeof(start));
|
||||
memset((char*)&end, 0, sizeof(end));
|
||||
}
|
||||
|
||||
|
||||
bool LastItem::IsLoggedOut()
|
||||
{
|
||||
if( end.tm_sec == 0 &&
|
||||
end.tm_min == 0 &&
|
||||
end.tm_hour == 0 &&
|
||||
end.tm_mday == 0 &&
|
||||
end.tm_mon == 0 &&
|
||||
end.tm_year == 0 )
|
||||
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return end.year > 1970;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +57,7 @@ return last_tab.end();
|
||||
|
||||
|
||||
|
||||
void LastContainer::UserLogin(long user_id, const std::string & name, unsigned int ip, long session_id)
|
||||
void LastContainer::UserLogin(long user_id, const std::wstring & name, unsigned int ip, long session_id)
|
||||
{
|
||||
LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
|
||||
|
||||
@@ -78,7 +67,7 @@ LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
|
||||
return;
|
||||
}
|
||||
|
||||
if( last_tab.size() >= LAST_TABLE_SIZE )
|
||||
if( last_tab.size() >= WINIX_LASTCONTAINER_TABLE_SIZE ) // last_tab has O(n) complexity
|
||||
last_tab.erase(last_tab.begin());
|
||||
|
||||
LastItem li;
|
||||
@@ -87,9 +76,7 @@ LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
|
||||
li.name = name;
|
||||
li.ip = ip;
|
||||
li.session_id = session_id;
|
||||
|
||||
time_t t = std::time(0);
|
||||
li.start = *localtime(&t);
|
||||
li.start = std::time(0);
|
||||
|
||||
last_tab.insert(last_tab.end(), li);
|
||||
|
||||
@@ -105,11 +92,17 @@ LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
|
||||
|
||||
if( i != last_tab.end() )
|
||||
{
|
||||
time_t t = std::time(0);
|
||||
i->end = *localtime(&t);
|
||||
i->end = std::time(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "LC: there is no such a user to log out" << logend;
|
||||
/*
|
||||
!! IMPROVE ME
|
||||
users read from the session file (at boot time)
|
||||
are not added to LastContainer
|
||||
*/
|
||||
|
||||
log << log4 << "LC: there is no such a user to log out: user_id: "
|
||||
<< user_id << " ses_id: " << session_id << logend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
@@ -7,18 +7,19 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorelastcontainer
|
||||
#define headerfilecmslucorelastcontainer
|
||||
#ifndef headerfile_winix_core_lastcontainer
|
||||
#define headerfile_winix_core_lastcontainer
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include "date/date.h"
|
||||
|
||||
|
||||
|
||||
// how many items we store in the 'last' function
|
||||
#define LAST_TABLE_SIZE 100
|
||||
#define WINIX_LASTCONTAINER_TABLE_SIZE 100
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +29,7 @@ struct LastItem
|
||||
|
||||
// additional we store the whole string-name
|
||||
// (you can delete a user from the database but we can still print the name)
|
||||
std::string name;
|
||||
std::wstring name;
|
||||
|
||||
// ip address
|
||||
unsigned int ip;
|
||||
@@ -37,8 +38,8 @@ struct LastItem
|
||||
long session_id;
|
||||
|
||||
// start logging and end logging
|
||||
tm start;
|
||||
tm end;
|
||||
PT::Date start;
|
||||
PT::Date end;
|
||||
|
||||
|
||||
LastItem();
|
||||
@@ -62,7 +63,7 @@ public:
|
||||
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
void UserLogin(long user_id, const std::string & name, unsigned int ip, long session_id);
|
||||
void UserLogin(long user_id, const std::wstring & name, unsigned int ip, long session_id);
|
||||
void UserLogout(long user_id, long session_id);
|
||||
|
||||
|
||||
|
||||
372
core/loadavg.cpp
Executable file
372
core/loadavg.cpp
Executable file
@@ -0,0 +1,372 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "loadavg.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
LoadAvg::LoadAvg()
|
||||
{
|
||||
current1.Clear();
|
||||
current5.Clear();
|
||||
current15.Clear();
|
||||
|
||||
cache_load1 = 0.0;
|
||||
cache_load5 = 0.0;
|
||||
cache_load15 = 0.0;
|
||||
|
||||
cache_req_per_sec1 = 0.0;
|
||||
cache_req_per_sec5 = 0.0;
|
||||
cache_req_per_sec15 = 0.0;
|
||||
|
||||
was_stop_request = false;
|
||||
|
||||
CreateTable();
|
||||
}
|
||||
|
||||
|
||||
LoadAvg & LoadAvg::operator=(const LoadAvg & l)
|
||||
{
|
||||
current1 = l.current1;
|
||||
current5 = l.current5;
|
||||
current15 = l.current15;
|
||||
|
||||
cache_load1 = l.cache_load1;
|
||||
cache_load5 = l.cache_load5;
|
||||
cache_load15 = l.cache_load15;
|
||||
|
||||
cache_req_per_sec1 = l.cache_req_per_sec1;
|
||||
cache_req_per_sec5 = l.cache_req_per_sec5;
|
||||
cache_req_per_sec15 = l.cache_req_per_sec15;
|
||||
|
||||
was_stop_request = l.was_stop_request;
|
||||
|
||||
CreateTable();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
LoadAvg::LoadAvg(const LoadAvg & l)
|
||||
{
|
||||
operator=(l);
|
||||
}
|
||||
|
||||
|
||||
LoadAvg::~LoadAvg()
|
||||
{
|
||||
delete [] tab1;
|
||||
delete [] tab5;
|
||||
delete [] tab15;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LoadAvg::CreateTable(size_t seconds, size_t granularity, Times* & tab, size_t & len)
|
||||
{
|
||||
len = (seconds / granularity) + 1; // rounding up (len mininum is 1)
|
||||
tab = new Times[len];
|
||||
|
||||
for(size_t i=0 ; i<len ; ++i)
|
||||
{
|
||||
tab[i].Clear();
|
||||
tab[i].dp = granularity; // at the beginning we assume the pause for all items
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoadAvg::CreateTable()
|
||||
{
|
||||
CreateTable(60, WINIX_LOADAVG_GRANULARITY1, tab1, len1);
|
||||
CreateTable(60 * 5, WINIX_LOADAVG_GRANULARITY5, tab5, len5);
|
||||
CreateTable(60 * 15, WINIX_LOADAVG_GRANULARITY15, tab15, len15);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LoadAvg::MoveTab(Times * tab, size_t len)
|
||||
{
|
||||
if( len > 1 )
|
||||
{
|
||||
for(size_t i=0 ; i<len-1 ; ++i)
|
||||
tab[i] = tab[i+1];
|
||||
}
|
||||
|
||||
tab[len-1].Clear();
|
||||
}
|
||||
|
||||
|
||||
void LoadAvg::UpdateTimer1()
|
||||
{
|
||||
MoveTab(tab1, len1);
|
||||
|
||||
tab1[len1-1] = current1;
|
||||
current1.Clear();
|
||||
cache_load1 = 0.0;
|
||||
cache_req_per_sec1 = 0.0;
|
||||
}
|
||||
|
||||
|
||||
void LoadAvg::UpdateTimer5()
|
||||
{
|
||||
MoveTab(tab5, len5);
|
||||
|
||||
tab5[len5-1] = current5;
|
||||
current5.Clear();
|
||||
cache_load5 = 0.0;
|
||||
cache_req_per_sec5 = 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LoadAvg::UpdateTimer15()
|
||||
{
|
||||
MoveTab(tab15, len15);
|
||||
|
||||
tab15[len15-1] = current15;
|
||||
current15.Clear();
|
||||
cache_load15 = 0.0;
|
||||
cache_req_per_sec15 = 0.0;
|
||||
}
|
||||
|
||||
|
||||
void LoadAvg::CheckTimers()
|
||||
{
|
||||
if( current1.dr + current1.dp > (double)WINIX_LOADAVG_GRANULARITY1 )
|
||||
UpdateTimer1();
|
||||
|
||||
if( current5.dr + current5.dp > (double)WINIX_LOADAVG_GRANULARITY5 )
|
||||
UpdateTimer5();
|
||||
|
||||
if( current15.dr + current15.dp > (double)WINIX_LOADAVG_GRANULARITY15 )
|
||||
UpdateTimer15();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void LoadAvg::StartRequest()
|
||||
{
|
||||
clock_gettime(CLOCK_REALTIME, &start_req);
|
||||
|
||||
if( was_stop_request )
|
||||
{
|
||||
double dp = (start_req.tv_sec - stop_req.tv_sec);
|
||||
dp += double(start_req.tv_nsec - stop_req.tv_nsec) / 1000000000.0; // make sure that tv_nsec has signed type
|
||||
|
||||
current1.dp += dp;
|
||||
current5.dp += dp;
|
||||
current15.dp += dp;
|
||||
|
||||
CheckTimers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LoadAvg::StopRequest()
|
||||
{
|
||||
clock_gettime(CLOCK_REALTIME, &stop_req);
|
||||
|
||||
double dr = (stop_req.tv_sec - start_req.tv_sec);
|
||||
dr += double(stop_req.tv_nsec - start_req.tv_nsec) / 1000000000.0; // make sure that tv_nsec has signed type
|
||||
|
||||
current1.dr += dr;
|
||||
current5.dr += dr;
|
||||
current15.dr += dr;
|
||||
|
||||
current1.req += 1;
|
||||
current5.req += 1;
|
||||
current15.req += 1;
|
||||
|
||||
log << log2 << "LA: request took: " << dr << "s" << logend;
|
||||
was_stop_request = true;
|
||||
}
|
||||
|
||||
|
||||
void LoadAvg::SumTab(Times * tab, size_t len, double expected, Times & t)
|
||||
{
|
||||
size_t i = len;
|
||||
|
||||
while( i-- > 0 && t.dr+t.dp < expected )
|
||||
{
|
||||
t.dr += tab[i].dr;
|
||||
t.dp += tab[i].dp;
|
||||
t.req += tab[i].req;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoadAvg::Calculate1()
|
||||
{
|
||||
Times t = current1;
|
||||
|
||||
SumTab(tab1, len1, 60.0, t);
|
||||
|
||||
if( t.dr+t.dp == 0.0 )
|
||||
{
|
||||
cache_load1 = 0.0;
|
||||
cache_req_per_sec1 = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cache_load1 = t.dr / (t.dr+t.dp);
|
||||
cache_req_per_sec1 = t.req / (t.dr+t.dp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoadAvg::Calculate5()
|
||||
{
|
||||
Times t = current5;
|
||||
|
||||
SumTab(tab5, len5, 60.0 * 5, t);
|
||||
|
||||
if( t.dr+t.dp == 0.0 )
|
||||
{
|
||||
cache_load5 = 0.0;
|
||||
cache_req_per_sec5 = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cache_load5 = t.dr / (t.dr+t.dp);
|
||||
cache_req_per_sec5 = t.req / (t.dr+t.dp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoadAvg::Calculate15()
|
||||
{
|
||||
Times t = current15;
|
||||
|
||||
SumTab(tab15, len15, 60.0 * 15, t);
|
||||
|
||||
if( t.dr+t.dp == 0.0 )
|
||||
{
|
||||
cache_load15 = 0.0;
|
||||
cache_req_per_sec15 = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cache_load15 = t.dr / (t.dr+t.dp);
|
||||
cache_req_per_sec15 = t.req / (t.dr+t.dp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double LoadAvg::LoadAvgNow()
|
||||
{
|
||||
double load = 0.0;
|
||||
|
||||
double dr = current1.dr;
|
||||
double dp = current1.dp;
|
||||
|
||||
if( tab1[len1-1].dr + tab1[len1-1].dp < WINIX_LOADAVG_GRANULARITY1 * 2 )
|
||||
{
|
||||
dr += tab1[len1-1].dr;
|
||||
dp += tab1[len1-1].dp;
|
||||
}
|
||||
|
||||
if( dr + dp != 0.0 )
|
||||
load = dr / (dr + dp);
|
||||
|
||||
return load;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double LoadAvg::LoadAvg1()
|
||||
{
|
||||
if( cache_load1 != 0.0 )
|
||||
return cache_load1;
|
||||
|
||||
Calculate1();
|
||||
|
||||
return cache_load1;
|
||||
}
|
||||
|
||||
|
||||
double LoadAvg::LoadAvg5()
|
||||
{
|
||||
if( cache_load5 != 0.0 )
|
||||
return cache_load5;
|
||||
|
||||
Calculate5();
|
||||
|
||||
return cache_load5;
|
||||
}
|
||||
|
||||
|
||||
double LoadAvg::LoadAvg15()
|
||||
{
|
||||
if( cache_load15 != 0.0 )
|
||||
return cache_load15;
|
||||
|
||||
Calculate15();
|
||||
|
||||
return cache_load15;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double LoadAvg::ReqPerSecNow()
|
||||
{
|
||||
double req_per_sec = 0.0;
|
||||
|
||||
double dr = current1.dr;
|
||||
double dp = current1.dp;
|
||||
double req = current1.req;
|
||||
|
||||
if( tab1[len1-1].dr + tab1[len1-1].dp < WINIX_LOADAVG_GRANULARITY1 * 2 )
|
||||
{
|
||||
dr += tab1[len1-1].dr;
|
||||
dp += tab1[len1-1].dp;
|
||||
req += tab1[len1-1].req;
|
||||
}
|
||||
|
||||
if( dr + dp != 0.0 )
|
||||
req_per_sec = req / (dr + dp);
|
||||
|
||||
return req_per_sec;
|
||||
}
|
||||
|
||||
|
||||
double LoadAvg::ReqPerSec1()
|
||||
{
|
||||
if( cache_req_per_sec1 != 0.0 )
|
||||
return cache_req_per_sec1;
|
||||
|
||||
Calculate1();
|
||||
|
||||
return cache_req_per_sec1;
|
||||
}
|
||||
|
||||
|
||||
double LoadAvg::ReqPerSec5()
|
||||
{
|
||||
if( cache_req_per_sec5 != 0.0 )
|
||||
return cache_req_per_sec5;
|
||||
|
||||
Calculate5();
|
||||
|
||||
return cache_req_per_sec5;
|
||||
}
|
||||
|
||||
|
||||
double LoadAvg::ReqPerSec15()
|
||||
{
|
||||
if( cache_req_per_sec15 != 0.0 )
|
||||
return cache_req_per_sec15;
|
||||
|
||||
Calculate15();
|
||||
|
||||
return cache_req_per_sec15;
|
||||
}
|
||||
114
core/loadavg.h
Executable file
114
core/loadavg.h
Executable file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_loadavg
|
||||
#define headerfile_winix_core_loadavg
|
||||
|
||||
#include <ctime>
|
||||
|
||||
|
||||
|
||||
|
||||
// in seconds
|
||||
#define WINIX_LOADAVG_GRANULARITY1 2
|
||||
#define WINIX_LOADAVG_GRANULARITY5 15
|
||||
#define WINIX_LOADAVG_GRANULARITY15 45
|
||||
|
||||
|
||||
|
||||
class LoadAvg
|
||||
{
|
||||
public:
|
||||
LoadAvg();
|
||||
~LoadAvg();
|
||||
LoadAvg & operator=(const LoadAvg & l);
|
||||
LoadAvg(const LoadAvg & l);
|
||||
|
||||
void StartRequest();
|
||||
void StopRequest();
|
||||
|
||||
double LoadAvgNow(); // load average withing last WINIX_LOADAVG_GRANULARITY1 seconds
|
||||
double LoadAvg1();
|
||||
double LoadAvg5();
|
||||
double LoadAvg15();
|
||||
|
||||
double ReqPerSecNow();
|
||||
double ReqPerSec1();
|
||||
double ReqPerSec5();
|
||||
double ReqPerSec15();
|
||||
|
||||
private:
|
||||
|
||||
struct Times
|
||||
{
|
||||
double dr; // time for the request (in seconds)
|
||||
double dp; // time for the pause between requestes (in seconds)
|
||||
long req; // how many requests
|
||||
|
||||
void Clear()
|
||||
{
|
||||
dr = 0.0;
|
||||
dp = 0.0;
|
||||
req = 0;
|
||||
}
|
||||
|
||||
Times & operator=(const Times & t)
|
||||
{
|
||||
dr = t.dr;
|
||||
dp = t.dp;
|
||||
req = t.req;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
void CheckTimers();
|
||||
void UpdateTimer1();
|
||||
void UpdateTimer5();
|
||||
void UpdateTimer15();
|
||||
|
||||
Times current1;
|
||||
Times current5;
|
||||
Times current15;
|
||||
|
||||
void CreateTable(size_t seconds, size_t granulatiry, Times* & tab, size_t & len);
|
||||
void CreateTable();
|
||||
|
||||
void MoveTab(Times * tab, size_t len);
|
||||
void SumTab(Times * tab, size_t len, double expected, Times & t);
|
||||
|
||||
void Calculate1();
|
||||
void Calculate5();
|
||||
void Calculate15();
|
||||
|
||||
bool was_stop_request;
|
||||
timespec start_req, stop_req;
|
||||
|
||||
Times * tab1;
|
||||
size_t len1;
|
||||
|
||||
Times * tab5;
|
||||
size_t len5;
|
||||
|
||||
Times * tab15;
|
||||
size_t len15;
|
||||
|
||||
double cache_load1;
|
||||
double cache_load5;
|
||||
double cache_load15;
|
||||
|
||||
double cache_req_per_sec1;
|
||||
double cache_req_per_sec5;
|
||||
double cache_req_per_sec15;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
49
core/lock.cpp
Executable file
49
core/lock.cpp
Executable file
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
37
core/lock.h
Executable file
37
core/lock.h
Executable file
@@ -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
|
||||
386
core/log.cpp
386
core/log.cpp
@@ -1,52 +1,116 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include <ctime>
|
||||
#include <string.h>
|
||||
#include "utf8/utf8.h"
|
||||
#include "timezones.h"
|
||||
|
||||
|
||||
Log::Log()
|
||||
{
|
||||
log_level = 3;
|
||||
current_level = 4; // nothing to log (call Init() first)
|
||||
log_level = 1;
|
||||
current_level = 100; // nothing to log (call Init() first)
|
||||
request = 0;
|
||||
max_requests = 1;
|
||||
lines = 0;
|
||||
max_lines = 5000;
|
||||
log_file_open = false;
|
||||
time_zones = 0;
|
||||
}
|
||||
|
||||
|
||||
void Log::Init(int log_l, const std::string & log_f, bool log_std)
|
||||
Log::~Log()
|
||||
{
|
||||
log_level = log_l;
|
||||
log_file = log_f;
|
||||
log_stdout = log_std;
|
||||
SaveLogAndClear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Log::PutDate(Manipulators m)
|
||||
|
||||
void Log::SetTimeZones(TimeZones * ptime_zones)
|
||||
{
|
||||
time_t t = std::time(0);
|
||||
std::tm * loct = std::localtime(&t);
|
||||
|
||||
char buffer[70];
|
||||
sprintf(buffer, "%d.%02d.%02d %02d:%02d:%02d ", int(loct->tm_year + 1900),
|
||||
int(loct->tm_mon + 1),
|
||||
int(loct->tm_mday),
|
||||
int(loct->tm_hour),
|
||||
int(loct->tm_min),
|
||||
int(loct->tm_sec));
|
||||
|
||||
(*this) << m << buffer;
|
||||
time_zones = ptime_zones;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Log::LogLevel()
|
||||
{
|
||||
return log_level;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Log::Init(int log_level_, bool save_each_line_, const std::string & log_file_, bool log_std, int log_max_requests)
|
||||
{
|
||||
log_level = log_level_;
|
||||
log_file = log_file_;
|
||||
log_stdout = log_std;
|
||||
max_requests = log_max_requests;
|
||||
save_each_line = save_each_line_;
|
||||
|
||||
// don't open the file here
|
||||
// because it would be created with the root as an owner
|
||||
}
|
||||
|
||||
|
||||
void Log::OpenFile()
|
||||
{
|
||||
if( !log_file.empty() )
|
||||
{
|
||||
file.open( log_file.c_str(), std::ios_base::out | std::ios_base::app );
|
||||
log_file_open = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Log::PrintDate(const PT::Date & date, size_t time_zone_id)
|
||||
{
|
||||
if( time_zones )
|
||||
{
|
||||
TimeZone * tz = time_zones->GetZone(time_zone_id);
|
||||
|
||||
if( tz )
|
||||
{
|
||||
PT::Date local_date = tz->ToLocal(date);
|
||||
log << local_date;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this) << date << " UTC"; // unknown time zone identifier
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this) << date << " UTC"; // time_zones object was not set
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const void * s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
|
||||
buffer << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const char * s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
|
||||
if( !s )
|
||||
return *this;
|
||||
|
||||
@@ -56,25 +120,89 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::string & s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
|
||||
buffer << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::string * s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
|
||||
buffer << *s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const wchar_t * s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
if( s )
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::wstring & s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::wstring * s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << *s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(int s)
|
||||
{
|
||||
buffer << s;
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(long s)
|
||||
{
|
||||
buffer << s;
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -84,7 +212,21 @@ Log & Log::operator<<(long s)
|
||||
|
||||
Log & Log::operator<<(char s)
|
||||
{
|
||||
buffer << s;
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(wchar_t s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -92,26 +234,74 @@ Log & Log::operator<<(char s)
|
||||
|
||||
Log & Log::operator<<(size_t s)
|
||||
{
|
||||
buffer << s;
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(double s)
|
||||
{
|
||||
buffer << s;
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Log & Log::operator<<(Manipulators m)
|
||||
|
||||
|
||||
Log & Log::operator<<(const PT::Space & s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const PT::Date & date)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << date;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(LogManipulators m)
|
||||
{
|
||||
switch(m)
|
||||
{
|
||||
case logend:
|
||||
SaveLog();
|
||||
buffer.str( "" );
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << '\n';
|
||||
lines += 1;
|
||||
|
||||
if( save_each_line )
|
||||
SaveLogAndClear();
|
||||
}
|
||||
break;
|
||||
|
||||
case logsave:
|
||||
SaveLogAndClear();
|
||||
break;
|
||||
|
||||
case logendrequest:
|
||||
if( ++request >= max_requests || lines > max_lines )
|
||||
SaveLogAndClear();
|
||||
break;
|
||||
|
||||
case log1:
|
||||
@@ -125,6 +315,13 @@ Log & Log::operator<<(Manipulators m)
|
||||
case log3:
|
||||
current_level = 3;
|
||||
break;
|
||||
|
||||
case log4:
|
||||
current_level = 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -132,35 +329,124 @@ return *this;
|
||||
|
||||
|
||||
|
||||
|
||||
char Log::GetHEXdigit(unsigned char c)
|
||||
{
|
||||
if( c < 10 )
|
||||
return c + '0';
|
||||
|
||||
return c - 10 + 'A';
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Log::ToHEX(char * buf, unsigned char c)
|
||||
{
|
||||
buf[0] = GetHEXdigit(c >> 4);
|
||||
buf[1] = GetHEXdigit(c & 0xf);
|
||||
buf[2] = 0;
|
||||
}
|
||||
|
||||
|
||||
void Log::LogBinary(const char * blob, size_t blob_len)
|
||||
{
|
||||
size_t i=0;
|
||||
char buf[3];
|
||||
|
||||
|
||||
while( i < blob_len )
|
||||
{
|
||||
size_t oldi = i;
|
||||
|
||||
for(size_t a=0 ; a<16 ; ++a)
|
||||
{
|
||||
if( i < blob_len )
|
||||
{
|
||||
ToHEX(buf, blob[i]);
|
||||
buffer << buf << ' ';
|
||||
++i;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer << " ";
|
||||
}
|
||||
|
||||
if( a == 7 )
|
||||
{
|
||||
if( i < blob_len )
|
||||
buffer << "- ";
|
||||
else
|
||||
buffer << " ";
|
||||
}
|
||||
}
|
||||
|
||||
i = oldi;
|
||||
buffer << ' ';
|
||||
|
||||
for(size_t a=0 ; a<16 && i<blob_len ; ++a, ++i)
|
||||
{
|
||||
if( blob[i] > 31 && blob[i] < 127 )
|
||||
buffer << blob[i];
|
||||
else
|
||||
buffer << '.';
|
||||
}
|
||||
|
||||
(*this) << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Log::LogBinary(const std::string & blob)
|
||||
{
|
||||
LogBinary(blob.c_str(), blob.size());
|
||||
}
|
||||
|
||||
|
||||
void Log::SystemErr(int err)
|
||||
{
|
||||
(*this) << "errno: " << err;
|
||||
|
||||
const char * err_msg = strerror(err);
|
||||
|
||||
if( err_msg )
|
||||
(*this) << " (" << err_msg << ")";
|
||||
}
|
||||
|
||||
|
||||
void Log::SaveLogAndClear()
|
||||
{
|
||||
SaveLog();
|
||||
|
||||
buffer.Clear();
|
||||
request = 0;
|
||||
lines = 0;
|
||||
}
|
||||
|
||||
|
||||
void Log::SaveLog()
|
||||
{
|
||||
int attempt = 2;
|
||||
|
||||
if( current_level > log_level )
|
||||
return;
|
||||
if( buffer.Str().empty() )
|
||||
return;
|
||||
|
||||
if( log_stdout )
|
||||
std::cout << buffer.str() << std::endl;
|
||||
|
||||
PT::WideToUTF8(buffer.Str(), std::cout);
|
||||
|
||||
if( log_file.empty() )
|
||||
return;
|
||||
|
||||
std::ofstream file;
|
||||
if( !log_file_open || !file )
|
||||
{
|
||||
file.close();
|
||||
file.clear();
|
||||
|
||||
do
|
||||
{
|
||||
file.open( log_file.c_str(), std::ios_base::out | std::ios_base::app );
|
||||
OpenFile();
|
||||
|
||||
// if( !file )
|
||||
// sleep(1);
|
||||
}
|
||||
while( --attempt > 0 && !file );
|
||||
if( !file )
|
||||
return;
|
||||
}
|
||||
|
||||
if( !file )
|
||||
return;
|
||||
|
||||
file << buffer.str() << std::endl;
|
||||
PT::WideToUTF8(buffer.Str(), file);
|
||||
file.flush();
|
||||
}
|
||||
|
||||
|
||||
|
||||
141
core/log.h
141
core/log.h
@@ -1,59 +1,162 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorelog
|
||||
#define headerfilecmslucorelog
|
||||
#ifndef headerfile_winix_core_log
|
||||
#define headerfile_winix_core_log
|
||||
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "textstream.h"
|
||||
#include "logmanipulators.h"
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
// !! dodac manipulator logsave, logi zostana zapisane pod koniec wykonywania jednego requesta (albo po kilku w zaleznosci od jakiejs opcji w konfigu)
|
||||
// logsave zostanie wywolane w requestcontroller.cpp przy konczeniu wykonywania requesta
|
||||
enum Manipulators { logend, log1, log2, log3 };
|
||||
class TimeZones;
|
||||
|
||||
|
||||
|
||||
class Log
|
||||
{
|
||||
std::ostringstream buffer;
|
||||
int log_level, current_level;
|
||||
std::string log_file;
|
||||
bool log_stdout;
|
||||
|
||||
public:
|
||||
|
||||
Log();
|
||||
|
||||
void Init(int log_l, const std::string & log_f, bool log_std);
|
||||
|
||||
void PutDate(Manipulators m);
|
||||
Log();
|
||||
~Log();
|
||||
|
||||
void SetTimeZones(TimeZones * ptime_zones);
|
||||
void Init(int log_level_, bool save_each_line_, const std::string & log_file_, bool log_std, int log_max_requests);
|
||||
|
||||
Log & operator<<(const void * s);
|
||||
Log & operator<<(const char * s);
|
||||
Log & operator<<(const std::string * s);
|
||||
Log & operator<<(const std::string & s);
|
||||
Log & operator<<(const wchar_t * s);
|
||||
Log & operator<<(const std::wstring * s);
|
||||
Log & operator<<(const std::wstring & s);
|
||||
Log & operator<<(int s);
|
||||
Log & operator<<(long s);
|
||||
Log & operator<<(char s);
|
||||
Log & operator<<(wchar_t s);
|
||||
Log & operator<<(size_t s);
|
||||
Log & operator<<(double s);
|
||||
Log & operator<<(Manipulators m);
|
||||
|
||||
Log & operator<<(const PT::Space & space);
|
||||
Log & operator<<(LogManipulators m);
|
||||
Log & operator<<(const PT::Date & date);
|
||||
|
||||
void PrintDate(const PT::Date & date, size_t time_zone_id);
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
Log & operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf);
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void LogString(const StringType & value, size_t max_size);
|
||||
|
||||
void LogBinary(const char * blob, size_t blob_len);
|
||||
void LogBinary(const std::string & blob);
|
||||
|
||||
|
||||
void SystemErr(int err);
|
||||
void SaveLog();
|
||||
void SaveLogAndClear();
|
||||
|
||||
int LogLevel();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// time zones for printing the time in the log file
|
||||
TimeZones * time_zones;
|
||||
|
||||
// buffer for the log
|
||||
TextStream<std::wstring> buffer;
|
||||
|
||||
// log lovel from the config file
|
||||
int log_level;
|
||||
|
||||
// current level set by a modifier (e.g. log << log3)
|
||||
int current_level;
|
||||
|
||||
// current request for logging
|
||||
// starts from zero and incremented after logendrequest modifier
|
||||
int request;
|
||||
|
||||
// how many request to save at once
|
||||
int max_requests;
|
||||
|
||||
// file log
|
||||
std::string log_file;
|
||||
std::ofstream file;
|
||||
|
||||
// logging to stdout
|
||||
bool log_stdout;
|
||||
|
||||
// how many lines there are in the buffer
|
||||
int lines;
|
||||
|
||||
// is the config file already open
|
||||
bool log_file_open;
|
||||
|
||||
// how many lines can be in the config buffer
|
||||
// default: 5000
|
||||
int max_lines;
|
||||
|
||||
// whether to save each line (for debug)
|
||||
bool save_each_line;
|
||||
|
||||
void OpenFile();
|
||||
char GetHEXdigit(unsigned char c);
|
||||
void ToHEX(char * buf, unsigned char c);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void Log::LogString(const StringType & value, size_t max_size)
|
||||
{
|
||||
size_t min_size = value.size() < max_size ? value.size() : max_size;
|
||||
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
for(size_t i=0 ; i<min_size ; ++i)
|
||||
{
|
||||
if( value[i] < 32 )
|
||||
buffer << '.';
|
||||
else
|
||||
buffer << value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 )
|
||||
buffer << buf;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern Log log;
|
||||
extern Log nlog;
|
||||
|
||||
// for convenience, we have to use only #include "log.h" in the winix
|
||||
#include "slog.h"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
48
core/logmanipulators.h
Executable file
48
core/logmanipulators.h
Executable file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_logmanipulators
|
||||
#define headerfile_winix_core_logmanipulators
|
||||
|
||||
|
||||
/*
|
||||
log1 - the first level
|
||||
log2
|
||||
log3
|
||||
log4 - the last level (debug level)
|
||||
logend - the end of a line
|
||||
logendrequest - end of a current request
|
||||
logsave - current log buffer is saved and cleared
|
||||
|
||||
manipulators used by the session logger (SLog)
|
||||
loginfo - normal info to a user
|
||||
logerror - we are reporting an error
|
||||
logwarning - we are reporting a warning
|
||||
|
||||
make sure that loginfo, logerror and logwarning have values less than 32 (space)
|
||||
their are used as control codes in a string
|
||||
*/
|
||||
enum LogManipulators
|
||||
{
|
||||
log1,
|
||||
log2,
|
||||
log3,
|
||||
log4,
|
||||
logend,
|
||||
logendrequest,
|
||||
logsave,
|
||||
|
||||
loginfo,
|
||||
logerror,
|
||||
logwarning
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
124
core/main.cpp
124
core/main.cpp
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <signal.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "requestcontroller.h"
|
||||
#include "data.h"
|
||||
#include "log.h"
|
||||
#include "request.h"
|
||||
#include "db.h"
|
||||
#include "config.h"
|
||||
#include "notify.h"
|
||||
|
||||
|
||||
// singletons
|
||||
// first 'data' then 'log' then 'request'
|
||||
Data data;
|
||||
Log log;
|
||||
Log nlog; // notify log (used by another thread)
|
||||
Request request;
|
||||
Db db;
|
||||
Config config;
|
||||
RequestController req_controller;
|
||||
Notify notify;
|
||||
|
||||
|
||||
|
||||
void signal_term(int)
|
||||
{
|
||||
log << log1 << "cmslu stopped" << logend;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void signal_hup(int)
|
||||
{
|
||||
log << log1 << "SIGHUP received" << logend;
|
||||
data.signal_hup = true;
|
||||
config.ReadConfig(false); /* errors not to stdout */
|
||||
}
|
||||
|
||||
|
||||
|
||||
void print_syntax()
|
||||
{
|
||||
std::cout << "Syntax:" << std::endl;
|
||||
std::cout << " cmslu.fcgi config_file" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argv, char ** argc)
|
||||
{
|
||||
std::srand(std::time(0));
|
||||
|
||||
if( argv != 2 )
|
||||
{
|
||||
print_syntax();
|
||||
return 1;
|
||||
}
|
||||
|
||||
data.config_file = argc[1];
|
||||
|
||||
|
||||
|
||||
if( !config.ReadConfig(true) ) /* errors to stdout */
|
||||
return 2;
|
||||
|
||||
|
||||
// closing descriptors only at the beginning
|
||||
// !! temporary we do not close standard output for errors
|
||||
// client postgresql uses it for reporting warnings (I don't know why)
|
||||
//close(2);
|
||||
|
||||
if( !data.log_stdout )
|
||||
{
|
||||
close(1);
|
||||
data.stdout_is_closed = true;
|
||||
}
|
||||
|
||||
|
||||
log.Init(data.log_level, data.log_file, data.log_stdout);
|
||||
nlog.Init(data.log_level, data.log_notify_file, false);
|
||||
db.Init(data.db_database, data.db_user, data.db_pass);
|
||||
request.Init();
|
||||
|
||||
if( !req_controller.Init() )
|
||||
return 1;
|
||||
|
||||
if( !notify.Init(data.templates) )
|
||||
return 2;
|
||||
|
||||
signal(SIGTERM, signal_term);
|
||||
signal(SIGINT, signal_term);
|
||||
signal(SIGHUP, signal_hup);
|
||||
|
||||
|
||||
while( true )
|
||||
{
|
||||
//log << log2 << "checking for table consistency:" << logend;
|
||||
// !! zrobic wyjatek dla root
|
||||
//db.CheckAllUrlSubject();
|
||||
|
||||
log << log1 << "cmslu started" << logend;
|
||||
|
||||
req_controller.Loop();
|
||||
|
||||
if( data.signal_hup )
|
||||
data.signal_hup = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
1321
core/misc.cpp
1321
core/misc.cpp
File diff suppressed because it is too large
Load Diff
978
core/misc.h
978
core/misc.h
File diff suppressed because it is too large
Load Diff
193
core/mount.cpp
193
core/mount.cpp
@@ -1,124 +1,111 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* Copyright (c) 2009-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mount.h"
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
|
||||
Mount::Mount()
|
||||
{
|
||||
type = cms;
|
||||
dir_id = -1;
|
||||
type = -1;
|
||||
fs = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * Mount::TypeToStr()
|
||||
{
|
||||
static char buffer[30];
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case cms:
|
||||
sprintf(buffer, "cms");
|
||||
break;
|
||||
|
||||
case thread:
|
||||
sprintf(buffer, "thread");
|
||||
break;
|
||||
|
||||
default:
|
||||
sprintf(buffer, "the name is not set");
|
||||
break;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
bool Mount::ParseStrParam(const std::string & param, const std::vector<int> & args)
|
||||
{
|
||||
Param p = none;
|
||||
|
||||
if( param == "asc" )
|
||||
p = asc;
|
||||
else
|
||||
if( param == "desc" )
|
||||
p = desc;
|
||||
else
|
||||
if( param == "withheader" )
|
||||
p = withheader;
|
||||
else
|
||||
if( param == "withinfo" )
|
||||
p = withinfo;
|
||||
else
|
||||
if( param == "thread_with_header" )
|
||||
p = thread_with_header;
|
||||
else
|
||||
if( param == "thread_with_info" )
|
||||
p = thread_with_info;
|
||||
else
|
||||
if( param == "restrictcreatethread" )
|
||||
p = restrictcreatethread;
|
||||
else
|
||||
if( param == "only_root_can_remove" )
|
||||
p = only_root_can_remove;
|
||||
else
|
||||
if( param == "can_use_emacs_on" )
|
||||
p = can_use_emacs_on;
|
||||
else
|
||||
if( param == "can_use_mkdir_on" )
|
||||
p = can_use_mkdir_on;
|
||||
else
|
||||
if( param == "none" )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
param_table.insert( std::make_pair(p, args) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Mount::IsParam(Param p)
|
||||
{
|
||||
ParamTable::iterator i = param_table.find(p);
|
||||
|
||||
if( i == param_table.end() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Mount::IsParam(Param p, int * first_arg)
|
||||
{
|
||||
ParamTable::iterator i = param_table.find(p);
|
||||
|
||||
if( i == param_table.end() )
|
||||
{
|
||||
*first_arg = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !i->second.empty() )
|
||||
*first_arg = i->second[0];
|
||||
else
|
||||
*first_arg = -1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Mount::ClearParams()
|
||||
{
|
||||
param_table.clear();
|
||||
size_t i;
|
||||
|
||||
for(i=0 ; i<param.size() ; ++i)
|
||||
param[i].Clear();
|
||||
}
|
||||
|
||||
|
||||
bool Mount::IsPar(int code)
|
||||
{
|
||||
if( code < 0 || code >= (int)param.size() )
|
||||
return false;
|
||||
|
||||
if( !param[code].defined )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Mount::IsArg(int code, const wchar_t * arg)
|
||||
{
|
||||
ParamRow::ParamArg::iterator i;
|
||||
|
||||
if( code < 0 || code >= (int)param.size() )
|
||||
return false;
|
||||
|
||||
if( !param[code].defined )
|
||||
return false;
|
||||
|
||||
for(i=param[code].arg.begin() ; i!=param[code].arg.end() ; ++i)
|
||||
{
|
||||
if( *i == arg )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Mount::IsArg(int code, const std::wstring & arg)
|
||||
{
|
||||
return IsArg(code, arg.c_str());
|
||||
}
|
||||
|
||||
|
||||
bool Mount::IsArg(int code, int arg)
|
||||
{
|
||||
ParamRow::ParamArg::iterator i;
|
||||
|
||||
if( code < 0 || code >= (int)param.size() )
|
||||
return false;
|
||||
|
||||
if( !param[code].defined )
|
||||
return false;
|
||||
|
||||
for(i=param[code].arg.begin() ; i!=param[code].arg.end() ; ++i)
|
||||
{
|
||||
if( Toi(*i) == arg )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const std::wstring & Mount::Arg(int code, int arg) const
|
||||
{
|
||||
if( code < 0 || code >= (int)param.size() )
|
||||
return empty_str;
|
||||
|
||||
if( !param[code].defined )
|
||||
return empty_str;
|
||||
|
||||
if( arg >= (int)param[code].arg.size() )
|
||||
return empty_str;
|
||||
|
||||
return param[code].arg[arg];
|
||||
}
|
||||
|
||||
|
||||
const std::wstring & Mount::FirstArg(int code) const
|
||||
{
|
||||
return Arg(code, 0);
|
||||
}
|
||||
|
||||
|
||||
74
core/mount.h
74
core/mount.h
@@ -1,65 +1,69 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* Copyright (c) 2009-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef headerfilecmslucoremount
|
||||
#define headerfilecmslucoremount
|
||||
#ifndef headerfile_winix_core_mount
|
||||
#define headerfile_winix_core_mount
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
class Mount
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
enum Type
|
||||
struct ParamRow
|
||||
{
|
||||
cms = 0,
|
||||
thread
|
||||
typedef std::vector<std::wstring> ParamArg;
|
||||
|
||||
bool defined;
|
||||
ParamArg arg;
|
||||
|
||||
ParamRow() { defined = false; }
|
||||
void Clear() { defined = false; arg.clear(); }
|
||||
};
|
||||
|
||||
|
||||
enum Param
|
||||
{
|
||||
none = 0,
|
||||
asc,
|
||||
desc,
|
||||
withheader,
|
||||
withinfo,
|
||||
thread_with_header,
|
||||
thread_with_info,
|
||||
restrictcreatethread,
|
||||
only_root_can_remove,
|
||||
can_use_emacs_on,
|
||||
can_use_mkdir_on
|
||||
};
|
||||
typedef std::vector<ParamRow> Param;
|
||||
|
||||
|
||||
long dir_id;
|
||||
int type;
|
||||
int fs;
|
||||
Param param;
|
||||
|
||||
|
||||
|
||||
long dir_id;
|
||||
Type type;
|
||||
|
||||
Mount();
|
||||
const char * TypeToStr();
|
||||
bool ParseStrParam(const std::string & param, const std::vector<int> & args);
|
||||
bool IsParam(Param p);
|
||||
bool IsParam(Param p, int * first_arg);
|
||||
void ClearParams();
|
||||
|
||||
private:
|
||||
typedef std::map<Param, std::vector<int> > ParamTable;
|
||||
ParamTable param_table;
|
||||
|
||||
};
|
||||
|
||||
bool IsPar(int code);
|
||||
|
||||
bool IsArg(int code, const wchar_t * arg);
|
||||
bool IsArg(int code, const std::wstring & arg);
|
||||
bool IsArg(int code, int arg);
|
||||
|
||||
// returning the arg argument if defined (or an empty string)
|
||||
const std::wstring & Arg(int code, int arg) const;
|
||||
|
||||
// returning the first argument (arg=0) if defined (or an empty string)
|
||||
const std::wstring & FirstArg(int code) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// for Arg() methods when the argument is not defined
|
||||
const std::wstring empty_str;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +1,69 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mountparser.h"
|
||||
#include "data.h"
|
||||
#include "log.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
MountParser::MountParser()
|
||||
{
|
||||
dirs = 0;
|
||||
skip_static = false;
|
||||
mount_type_tab = 0;
|
||||
mount_fs_tab = 0;
|
||||
mount_par_tab = 0;
|
||||
static_mount_id = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::SkipStaticDirs(bool skip)
|
||||
{
|
||||
skip_static = skip;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::SetStaticMountId(int id)
|
||||
{
|
||||
static_mount_id = id;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::SetDirs(Dirs * pdirs)
|
||||
{
|
||||
dirs = pdirs;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::SetMountTypeTab(const std::vector<std::wstring> & tab)
|
||||
{
|
||||
mount_type_tab = &tab;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::SetMountFsTab(const std::vector<std::wstring> & tab)
|
||||
{
|
||||
mount_fs_tab = &tab;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::SetMountParTab(const std::vector<std::wstring> & tab)
|
||||
{
|
||||
mount_par_tab = &tab;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MountParser::IsWhite(int c)
|
||||
{
|
||||
if( c==' ' || c=='\t' || c==13 )
|
||||
if( c==' ' || c=='\t' || c==13 || c==160 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -39,11 +87,38 @@ void MountParser::SkipLine()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadWord(std::string & res)
|
||||
void MountParser::ReadWordQuote(std::wstring & res)
|
||||
{
|
||||
++pinput;
|
||||
|
||||
while( *pinput && *pinput!=10 && *pinput!='\"' )
|
||||
{
|
||||
if( pinput[0]=='\\' && pinput[1]=='\"' )
|
||||
{
|
||||
res += '\"';
|
||||
pinput += 2;
|
||||
}
|
||||
else
|
||||
if( pinput[0]=='\\' && pinput[1]=='\\' )
|
||||
{
|
||||
res += '\\';
|
||||
pinput += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
res += *pinput;
|
||||
pinput += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( *pinput == '"' )
|
||||
++pinput;
|
||||
}
|
||||
|
||||
|
||||
// a white character is the separator
|
||||
void MountParser::ReadWordWhite(std::wstring & res)
|
||||
{
|
||||
res.clear();
|
||||
|
||||
while( *pinput && *pinput!=10 && !IsWhite(*pinput) )
|
||||
{
|
||||
res += *pinput;
|
||||
@@ -52,64 +127,71 @@ void MountParser::ReadWord(std::string & res)
|
||||
}
|
||||
|
||||
|
||||
bool MountParser::ReadParamArg(int & out)
|
||||
// the comma or the second bracket ')' are the separators
|
||||
void MountParser::ReadWordComma(std::wstring & res)
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
char * new_pos;
|
||||
long temp = strtol(pinput, &new_pos, 10);
|
||||
while( *pinput && *pinput!=10 && *pinput!=',' && *pinput!=')' )
|
||||
{
|
||||
res += *pinput;
|
||||
++pinput;
|
||||
}
|
||||
|
||||
if( pinput == new_pos )
|
||||
return false;
|
||||
|
||||
pinput = new_pos;
|
||||
SkipWhite();
|
||||
|
||||
// here can we make a test whether the temp is greater from 'int' type
|
||||
out = (int)temp;
|
||||
|
||||
return true;
|
||||
// trimming last white characters
|
||||
// (white characters can be in the middle of the string)
|
||||
TrimWhite(res);
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadParamArgs(std::vector<int> & args)
|
||||
void MountParser::ReadWord(std::wstring & res, bool comma_bracket_separator)
|
||||
{
|
||||
int arg;
|
||||
res.clear();
|
||||
SkipWhite();
|
||||
|
||||
while( ReadParamArg(arg) )
|
||||
if( *pinput == '"' )
|
||||
{
|
||||
args.push_back(arg);
|
||||
|
||||
log << log3 << "MP: mount param arg: " << arg << logend;
|
||||
|
||||
ReadWordQuote(res);
|
||||
}
|
||||
else
|
||||
if( comma_bracket_separator )
|
||||
{
|
||||
ReadWordComma(res);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadWordWhite(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadParamArgsLoop(Mount::ParamRow::ParamArg & args)
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
while( *pinput && *pinput!=10 && *pinput!=')' )
|
||||
{
|
||||
ReadWord(temp_arg, true);
|
||||
|
||||
if( !temp_arg.empty() )
|
||||
args.push_back(temp_arg);
|
||||
|
||||
if( *pinput == ',' )
|
||||
++pinput;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadParam(std::string & res, std::vector<int> & args)
|
||||
void MountParser::ReadParamArgs(Mount::ParamRow::ParamArg & args)
|
||||
{
|
||||
SkipWhite();
|
||||
res.clear();
|
||||
args.clear();
|
||||
|
||||
while( *pinput && *pinput!=10 && *pinput!=',' && *pinput!='(' && !IsWhite(*pinput) )
|
||||
{
|
||||
res += *pinput;
|
||||
++pinput;
|
||||
}
|
||||
|
||||
if( res.empty() )
|
||||
return;
|
||||
|
||||
|
||||
// reading arguments
|
||||
SkipWhite();
|
||||
|
||||
|
||||
if( *pinput == '(' )
|
||||
{
|
||||
++pinput;
|
||||
ReadParamArgs(args);
|
||||
ReadParamArgsLoop(args);
|
||||
|
||||
if( *pinput != ')' )
|
||||
{
|
||||
@@ -121,57 +203,135 @@ void MountParser::ReadParam(std::string & res, std::vector<int> & args)
|
||||
++pinput;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadParamName(std::wstring & res)
|
||||
{
|
||||
SkipWhite();
|
||||
res.clear();
|
||||
|
||||
while( *pinput && *pinput!=10 && *pinput!=',' && *pinput!='(' && !IsWhite(*pinput) )
|
||||
{
|
||||
res += *pinput;
|
||||
++pinput;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadParam(std::wstring & res, Mount::ParamRow::ParamArg & args)
|
||||
{
|
||||
ReadParamName(res);
|
||||
|
||||
if( res.empty() )
|
||||
return;
|
||||
|
||||
ReadParamArgs(args);
|
||||
|
||||
SkipWhite();
|
||||
|
||||
if( *pinput == ',' )
|
||||
++pinput;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadMountType()
|
||||
int MountParser::FindIndex(const std::vector<std::wstring> * tab, const std::wstring & value)
|
||||
{
|
||||
for(size_t i=0 ; i < tab->size() ; ++i)
|
||||
{
|
||||
if( (*tab)[i] == value )
|
||||
return static_cast<int>(i);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
bool MountParser::ReadMountType()
|
||||
{
|
||||
SkipWhite();
|
||||
ReadWord(temp);
|
||||
|
||||
if( temp == "cms" )
|
||||
if( temp.empty() )
|
||||
{
|
||||
mount.type = Mount::cms;
|
||||
log << log3 << "MP: mount type: cms" << logend;
|
||||
// an empty line (some white characters only)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if( temp == "thread" )
|
||||
|
||||
mount.type = FindIndex(mount_type_tab, temp);
|
||||
|
||||
if( mount.type != -1 )
|
||||
{
|
||||
mount.type = Mount::thread;
|
||||
log << log3 << "MP: mount type: thread" << logend;
|
||||
log << log3 << "MP: mount type: " << (*mount_type_tab)[mount.type] << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = Error::mount_unknown;
|
||||
log << log1 << "MP: unknown mount type: " << temp << logend;
|
||||
slog << logerror << T("unknown_mount_type") << ": " << temp << logend;
|
||||
}
|
||||
|
||||
return mount.type != -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadMountPoint()
|
||||
bool MountParser::ReadMountPoint()
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
// !! narazie bez cudzyslowow
|
||||
ReadWord(temp);
|
||||
ReadWord(last_dir);
|
||||
|
||||
pdir = data.dirs.GetDir(temp);
|
||||
pdir = dirs->GetDir(last_dir);
|
||||
|
||||
if( pdir )
|
||||
{
|
||||
mount.dir_id = pdir->id;
|
||||
log << log3 << "MP: mount point: " << temp << logend;
|
||||
log << log3 << "MP: mount point (directory): " << last_dir << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = Error::no_mountpoint;
|
||||
log << log1 << "MP: there is no such a mount point: " << temp << logend;
|
||||
log << log1 << "MP: there is no such a mount point (directory): " << last_dir << logend;
|
||||
slog << logerror << T("no_such_dir") << ": " << last_dir << logend;
|
||||
}
|
||||
|
||||
return pdir != 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MountParser::ReadFs()
|
||||
{
|
||||
ReadWord(temp);
|
||||
mount.fs = FindIndex(mount_fs_tab, temp);
|
||||
|
||||
if( mount.fs != -1 )
|
||||
{
|
||||
log << log2 << "MP: file system: " << (*mount_fs_tab)[mount.fs] << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "MP: unknown filesystem: " << temp << logend;
|
||||
slog << logerror << T("unknown_filesystem") << ": " << temp << " (" << last_dir << ")" << logend;
|
||||
}
|
||||
|
||||
return mount.fs != -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::LogMountParams()
|
||||
{
|
||||
size_t i;
|
||||
|
||||
log << log3 << "MP: mount param: " << temp << "(";
|
||||
|
||||
for(i=0 ; i<param_args.size() ; ++i)
|
||||
{
|
||||
log << param_args[i];
|
||||
|
||||
if( i != param_args.size()-1 )
|
||||
log << ",";
|
||||
}
|
||||
|
||||
log << ")" << logend;
|
||||
}
|
||||
|
||||
|
||||
@@ -182,53 +342,152 @@ void MountParser::ReadMountParams()
|
||||
|
||||
for( ReadParam(temp, param_args) ; !temp.empty() ; ReadParam(temp, param_args) )
|
||||
{
|
||||
if( !mount.ParseStrParam(temp, param_args) )
|
||||
int code = FindIndex(mount_par_tab, temp);
|
||||
|
||||
if( code != -1 )
|
||||
{
|
||||
log << log1 << "MP: unknown mount param: " << temp << logend;
|
||||
err = Error::mount_no_param;
|
||||
return;
|
||||
mount.param[code].defined = true;
|
||||
mount.param[code].arg = param_args;
|
||||
LogMountParams();
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log3 << "MP: mount param: " << temp << logend;
|
||||
log << log1 << "MP: unknown mount param: " << temp << logend;
|
||||
slog << logwarning << T("unknown_mount_param") << ": " << temp << " (" << T("skipped") << ")" << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadRow(std::map<long, Mount> & output)
|
||||
void MountParser::AddParams(Mount::Param & src, Mount::Param & dst)
|
||||
{
|
||||
ReadMountType();
|
||||
|
||||
if( err == Error::ok )
|
||||
ReadMountPoint();
|
||||
|
||||
if( err == Error::ok )
|
||||
ReadMountParams();
|
||||
|
||||
if( err == Error::ok )
|
||||
if( src.size() != dst.size() )
|
||||
{
|
||||
output.insert( std::make_pair(mount.dir_id, mount) );
|
||||
log << log1 << "MP: addparams: incorrect sizes" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
for(size_t p=0 ; p < src.size() ; ++p)
|
||||
{
|
||||
if( src[p].defined && !dst[p].defined )
|
||||
dst[p] = src[p];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool MountParser::AddParamsBefore(long dir_id)
|
||||
{
|
||||
std::map<long, Mount>::iterator i = poutput->find(dir_id);
|
||||
|
||||
if( i == poutput->end() )
|
||||
return false;
|
||||
|
||||
AddParams(i->second.param, mount_inserted.first->second.param);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
adding all non-existing parameters to this mount point from parents
|
||||
*/
|
||||
void MountParser::AddParamsBefore()
|
||||
{
|
||||
if( !pdir )
|
||||
return;
|
||||
|
||||
Item * dir;
|
||||
long dir_id = pdir->parent_id;
|
||||
|
||||
while( dir_id != -1 )
|
||||
{
|
||||
if( AddParamsBefore(dir_id) )
|
||||
{
|
||||
// we don't have to check others parents
|
||||
// the parameters are already copied
|
||||
break;
|
||||
}
|
||||
|
||||
dir = dirs->GetDir(dir_id);
|
||||
|
||||
if( !dir )
|
||||
break;
|
||||
|
||||
dir_id = dir->parent_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
adding all non-existing parameters to childs (childs to this mount point)
|
||||
*/
|
||||
void MountParser::AddParamsAfter()
|
||||
{
|
||||
std::map<long, Mount>::iterator i = poutput->begin();
|
||||
|
||||
for( ; i != poutput->end() ; ++i)
|
||||
{
|
||||
if( dirs->IsChild(mount_inserted.first->second.dir_id, i->first) )
|
||||
AddParams(mount_inserted.first->second.param, i->second.param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadRow()
|
||||
{
|
||||
if( ReadMountType() && ReadMountPoint() && ReadFs() )
|
||||
{
|
||||
ReadMountParams();
|
||||
|
||||
if( skip_static && mount.type==static_mount_id )
|
||||
{
|
||||
log << log1 << "MP: static mount points are skipped (dont_use_static_dirs in config is true)" << logend;
|
||||
slog << logwarning << T("skipped_static_mount") << ": " << last_dir << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
mount_inserted = poutput->insert( std::make_pair(mount.dir_id, mount) );
|
||||
|
||||
if( mount_inserted.second )
|
||||
{
|
||||
AddParamsBefore();
|
||||
AddParamsAfter();
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "MP: this mount point exists (skipped)" << logend;
|
||||
slog << logwarning << T("mount_exists") << ": " << last_dir << " (" << T("skipped") << ")" << logend;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SkipLine();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Error MountParser::Parse(const std::string & input, std::map<long, Mount> & output)
|
||||
void MountParser::Parse(const std::wstring & input, std::map<long, Mount> & output)
|
||||
{
|
||||
pinput = input.c_str();
|
||||
err = Error::ok;
|
||||
output.clear();
|
||||
if( !dirs || !mount_type_tab || !mount_fs_tab || !mount_par_tab )
|
||||
{
|
||||
log << log1 << "MP: input tables not set" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
pinput = input.c_str();
|
||||
poutput = &output;
|
||||
mount.param.resize(mount_par_tab->size());
|
||||
mount.ClearParams();
|
||||
poutput->clear();
|
||||
|
||||
while( *pinput && err == Error::ok )
|
||||
ReadRow(output);
|
||||
|
||||
return err;
|
||||
while( *pinput )
|
||||
ReadRow();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* Copyright (c) 2010-2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoremountparser
|
||||
#define headerfilecmslucoremountparser
|
||||
#ifndef headerfile_winix_core_mountparser
|
||||
#define headerfile_winix_core_mountparser
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "mount.h"
|
||||
#include "item.h"
|
||||
#include "error.h"
|
||||
#include "dirs.h"
|
||||
|
||||
|
||||
|
||||
@@ -26,32 +26,59 @@ class MountParser
|
||||
{
|
||||
public:
|
||||
|
||||
Error Parse(const std::string & input, std::map<long, Mount> & output);
|
||||
MountParser();
|
||||
|
||||
void SkipStaticDirs(bool skip);
|
||||
void SetStaticMountId(int id);
|
||||
|
||||
void Parse(const std::wstring & input, std::map<long, Mount> & output);
|
||||
void SetDirs(Dirs * pdirs);
|
||||
void SetMountTypeTab(const std::vector<std::wstring> & tab);
|
||||
void SetMountFsTab(const std::vector<std::wstring> & tab);
|
||||
void SetMountParTab(const std::vector<std::wstring> & tab);
|
||||
|
||||
private:
|
||||
|
||||
Dirs * dirs;
|
||||
bool skip_static;
|
||||
int static_mount_id;
|
||||
|
||||
const std::vector<std::wstring> * mount_type_tab;
|
||||
const std::vector<std::wstring> * mount_fs_tab;
|
||||
const std::vector<std::wstring> * mount_par_tab;
|
||||
|
||||
bool IsWhite(int c);
|
||||
void SkipWhite();
|
||||
void SkipLine();
|
||||
void ReadWord(std::string & res);
|
||||
bool ReadParamArg(int & out);
|
||||
void ReadParamArgs(std::vector<int> & args);
|
||||
void ReadParam(std::string & res, std::vector<int> & args);
|
||||
void ReadMountType();
|
||||
void ReadMountPoint();
|
||||
void ReadWordQuote(std::wstring & res);
|
||||
void ReadWordWhite(std::wstring & res);
|
||||
void ReadWordComma(std::wstring & res);
|
||||
void ReadWord(std::wstring & res, bool comma_bracket_separator = false);
|
||||
void ReadParamArgsLoop(Mount::ParamRow::ParamArg & args);
|
||||
void ReadParamArgs(Mount::ParamRow::ParamArg & args);
|
||||
void ReadParamName(std::wstring & res);
|
||||
void ReadParam(std::wstring & res, Mount::ParamRow::ParamArg & args);
|
||||
int FindIndex(const std::vector<std::wstring> * tab, const std::wstring & value);
|
||||
bool ReadMountType();
|
||||
bool ReadMountPoint();
|
||||
bool ReadFs();
|
||||
void LogMountParams();
|
||||
void ReadMountParams();
|
||||
void ReadRow(std::map<long, Mount> & output);
|
||||
void ReadRow();
|
||||
void AddParams(Mount::Param & src, Mount::Param & dst);
|
||||
bool AddParamsBefore(long dir_id);
|
||||
void AddParamsBefore();
|
||||
void AddParamsAfter();
|
||||
|
||||
const char * pinput;
|
||||
std::string temp;
|
||||
std::vector<int> param_args;
|
||||
|
||||
|
||||
const wchar_t * pinput;
|
||||
std::wstring temp;
|
||||
std::wstring last_dir;
|
||||
std::wstring temp_arg;
|
||||
Mount::ParamRow::ParamArg param_args;
|
||||
Mount mount;
|
||||
|
||||
Item * pdir;
|
||||
Error err;
|
||||
std::map<long, Mount> * poutput;
|
||||
std::pair<std::map<long, Mount>::iterator, bool> mount_inserted;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user