Compare commits
455 Commits
0.3.0
...
bcde392ce3
| Author | SHA1 | Date | |
|---|---|---|---|
| bcde392ce3 | |||
| 8d046f6280 | |||
| 9a6696699f | |||
| 56f2eec597 | |||
| d29b33532d | |||
| a16e82bf54 | |||
| 46c17cc441 | |||
| 2099092e16 | |||
| 88b7517337 | |||
| 619236329c | |||
| 76160a5ba6 | |||
| e95f32231a | |||
| be81307faa | |||
| 177e58da4e | |||
| 4c2efc08fd | |||
| ae03922491 | |||
| ab005118ba | |||
| eec8635af4 | |||
| 5060997d2a | |||
| 0ac5a21a14 | |||
| def0f8d144 | |||
| 8895f0dcac | |||
| 4f8db81c85 | |||
| aa388e248d | |||
| e5d7403c54 | |||
| 4f57d6134c | |||
| 03f6b54a5b | |||
| 63ef007ca1 | |||
| 603e0679e7 | |||
| b90445de4a | |||
| 491dd27ebf | |||
| 89d303f375 | |||
| a2ffc1e81c | |||
| a7c47140ae | |||
| ebd7f85fdb | |||
| 833c04776f | |||
| 919c2f62f5 | |||
| 8f6004d444 | |||
| 1b8f5dc673 | |||
| 027a8ec428 | |||
| d1e7765e98 | |||
| 2d1b2e6b6e | |||
| 350fc551e5 | |||
| 1c05c31721 | |||
| 08123fe6ac | |||
| 35b93b1655 | |||
| 436a198c36 | |||
| aa58faf145 | |||
| dcc6d35cba | |||
| 3f29cdc01e | |||
| ba7d55b7c1 | |||
| 6252a0e732 | |||
| ca14b1a427 | |||
| b01db89942 | |||
| fd421c54e3 | |||
| 55992b5066 | |||
| a5dfc9974f | |||
| 7b4a17c934 | |||
| c2a1097dd5 | |||
| ccf78dcb02 | |||
| 3eff400d88 | |||
| 5ab816b5be | |||
| e57840faed | |||
| 240bf4dc5d | |||
| abd1500f07 | |||
| 42144bb31c | |||
| 7ed41a03ae | |||
| 1286ceeddf | |||
| 145efe937c | |||
| ed5adb3f23 | |||
| 7d0508961e | |||
| e53e2e6af9 | |||
| 4fafd2a478 | |||
| f15da4d049 | |||
| 057607f9e5 | |||
| c433b3fd41 | |||
| 632b49ab90 | |||
| f54df8d600 | |||
| d8451ceaa0 | |||
| 62f178c2ee | |||
| eb4e7343e7 | |||
| 5274e8e8ff | |||
| ae2a885d6c | |||
| 901663b145 | |||
| dc301d4c50 | |||
| 34f0535a26 | |||
| af0e2a778d | |||
| 904f1e70f2 | |||
| ddf7ef30ad | |||
| 0a43870e76 | |||
| f875bd2944 | |||
| c9bf20201b | |||
| 76314aab10 | |||
| 3547d326b8 | |||
| 0ecb2ac70e | |||
| 8f8defe0de | |||
| db5572e864 | |||
| 1100cf75d7 | |||
| 4fda06b547 | |||
| fb18b2238e | |||
| 5266a7e4e5 | |||
| 8196fb77d1 | |||
| 4abf6642f7 | |||
| e3284dcfbc | |||
| f064ff6b3d | |||
| bfa5d8cc05 | |||
| 6614919c13 | |||
| 8379acdb7f | |||
| 160ddc258d | |||
| 01892d2766 | |||
| 222955a2e7 | |||
| 37b22c3559 | |||
| afbd522362 | |||
| a4bed3ab14 | |||
| 7468e7a36c | |||
| 145445c713 | |||
| 7fa9314c6b | |||
| 5d37b6c6ae | |||
| fe1f84e29d | |||
| 83e27a6653 | |||
| ee9c68b04e | |||
| c04874397b | |||
| 375604edd6 | |||
| 3e32f3784f | |||
| 5c4a54d998 | |||
| 3af3ac3f6f | |||
| d801f53154 | |||
| a6b06f82e9 | |||
| b7f3f84080 | |||
| 26715bdd4c | |||
| 083fa7857f | |||
| 9ffda3e070 | |||
| 81160dbbe9 | |||
| 7c266b85e2 | |||
| 48cdca7549 | |||
| 1c401eae3b | |||
| 0e9eb30b5d | |||
| c10c9393c0 | |||
| 8705b3437c | |||
| aed891764a | |||
| 495499d12f | |||
| 8d9a021eab | |||
| be6e09c5af | |||
| 293e426ed4 | |||
| 60f2337b73 | |||
| ce8152de2f | |||
| 496a1979d2 | |||
| fd698ca7b9 | |||
| b4b368d324 | |||
| 825694c880 | |||
| 32750a7d50 | |||
| 0045c6c72c | |||
| 4809016b78 | |||
| 6e2ba65524 | |||
| 8033ac66c4 | |||
| 9ef3736989 | |||
| 099dd55d0c | |||
| 53b4175d00 | |||
| 8aa6f08e08 | |||
| c5024598cb | |||
| dfcf6b29c0 | |||
| 7f48d1eb2e | |||
| eaa97995d2 | |||
| 14f997b844 | |||
| 26e87b20b1 | |||
| 5cdf6eff36 | |||
| 4ed535a3b7 | |||
| da15323c2f | |||
| bd1f717b4c | |||
| 72013046fc | |||
| 14ae19143f | |||
| 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 |
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.cproject
|
||||
.project
|
||||
.settings/
|
||||
*.o
|
||||
*.so
|
||||
winixd/winix
|
||||
42
Makefile
42
Makefile
@@ -1,42 +0,0 @@
|
||||
# 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
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
FORCE:
|
||||
|
||||
|
||||
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
|
||||
@@ -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,22 +0,0 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
|
||||
all: $(o)
|
||||
|
||||
|
||||
.SUFFIXES: .cpp .o
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend $(DEPMACROS) -Y. -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
include Makefile.dep
|
||||
@@ -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,22 +0,0 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
|
||||
all: $(o)
|
||||
|
||||
|
||||
.SUFFIXES: .cpp .o
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend $(DEPMACROS) -Y. -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
include Makefile.dep
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
|
||||
all: $(o)
|
||||
|
||||
|
||||
.SUFFIXES: .cpp .o
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend $(DEPMACROS) -Y. -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
include Makefile.dep
|
||||
@@ -1,83 +0,0 @@
|
||||
# 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
|
||||
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
|
||||
@@ -1 +0,0 @@
|
||||
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
|
||||
@@ -1,172 +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 "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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,43 +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 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
|
||||
207
core/config.cpp
207
core/config.cpp
@@ -1,207 +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 "config.h"
|
||||
#include "log.h"
|
||||
#include "data.h"
|
||||
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
default_int = 0;
|
||||
default_bool = false;
|
||||
|
||||
errors_to_stdout = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//!! czy tu w ogole mozemy uzywac log << ?
|
||||
//!! przeciez jeszcze nie zostal przetworzony plik konfiguracyjny
|
||||
|
||||
|
||||
void Config::ShowError()
|
||||
{
|
||||
|
||||
switch( conf_parser.status )
|
||||
{
|
||||
case ConfParser::ok:
|
||||
log << log2 << "Config: syntax ok" << logend;
|
||||
break;
|
||||
|
||||
case ConfParser::cant_open_file:
|
||||
if( errors_to_stdout )
|
||||
std::cout << "Config: cant open a config file: " << data.config_file << std::endl;
|
||||
|
||||
log << log1 << "Config: cant open a config file: " << data.config_file << logend;
|
||||
break;
|
||||
|
||||
case ConfParser::syntax_error:
|
||||
if( errors_to_stdout )
|
||||
std::cout << "Config: syntax error, line: " << conf_parser.line << std::endl;
|
||||
|
||||
log << log1 << "Config: syntax error, line: " << conf_parser.line << logend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool Config::ReadConfig(bool errors_to_stdout_)
|
||||
{
|
||||
errors_to_stdout = errors_to_stdout_;
|
||||
|
||||
if( data.config_file.empty() )
|
||||
{
|
||||
log << log2 << "Config: name of the config file is empty" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
log << log2 << "Config: reading a config file" << logend;
|
||||
|
||||
ConfParser::Status status = conf_parser.Parse( data.config_file.c_str() );
|
||||
|
||||
|
||||
if( status == ConfParser::ok )
|
||||
{
|
||||
AssignValues();
|
||||
|
||||
data.SetAdditionalVariables();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Config::AssignValues()
|
||||
{
|
||||
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");
|
||||
|
||||
if( !data.stdout_is_closed )
|
||||
data.log_stdout = Bool("log_stdout");
|
||||
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");
|
||||
|
||||
NoLastSlash(data.base_url);
|
||||
|
||||
data.one_item_is_showed = Bool("one_item_is_showed");
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// !! mozna dodac drugi argument -- wartosc domyslna
|
||||
std::string & Config::Text(const char * name)
|
||||
{
|
||||
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_str << "\"" << logend;
|
||||
return default_str;
|
||||
}
|
||||
|
||||
log << log3 << "Config: " << name << "=" << i->second << logend;
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! mozna dodac drugi argument -- wartosc domyslna
|
||||
int Config::Int(const char * 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! mozna dodac drugi argument -- wartosc domyslna
|
||||
bool Config::Bool(const char * name)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Config::NoLastSlash(std::string & s)
|
||||
{
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
log << log2 << "Config: removing the last slash from: " << s << logend;
|
||||
|
||||
if( *(--s.end()) == '/' )
|
||||
s.erase(--s.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,52 +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 headerfilecmslucoreconfig
|
||||
#define headerfilecmslucoreconfig
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../confparser/confparser.h"
|
||||
|
||||
|
||||
|
||||
class Config
|
||||
{
|
||||
|
||||
public:
|
||||
Config();
|
||||
bool ReadConfig(bool errors_to_stdout_);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
ConfParser conf_parser;
|
||||
void ShowError();
|
||||
void AssignValues();
|
||||
|
||||
|
||||
std::string & Text(const char *);
|
||||
int Int(const char *);
|
||||
bool Bool(const char *);
|
||||
|
||||
std::string default_str;
|
||||
int default_int;
|
||||
bool default_bool;
|
||||
|
||||
|
||||
bool errors_to_stdout;
|
||||
|
||||
void NoLastSlash(std::string & s);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,70 +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 headerfilecmslucorecookieparser
|
||||
#define headerfilecmslucorecookieparser
|
||||
|
||||
#include <fcgiapp.h>
|
||||
#include "httpsimpleparser.h"
|
||||
#include "requesttypes.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
class CookieParser : public HttpSimpleParser
|
||||
{
|
||||
|
||||
const char * cookie_string;
|
||||
CookieTable & cookie_table;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual int GetChar()
|
||||
{
|
||||
if( !cookie_string || *cookie_string == 0 )
|
||||
return -1;
|
||||
|
||||
return (int)(unsigned char)*(cookie_string++);
|
||||
}
|
||||
|
||||
|
||||
virtual void Parameter(std::string & name, std::string & value)
|
||||
{
|
||||
// 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) );
|
||||
|
||||
log << log2 << "Cookie, name: \"" << name << "\", value: \"" << value << "\"";
|
||||
|
||||
if( res.second == false )
|
||||
log << log2 << " (skipped)";
|
||||
|
||||
log << log2 << logend;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
CookieParser(const char * cookie_string_, CookieTable & cookie_table_) : cookie_string(cookie_string_), cookie_table(cookie_table_)
|
||||
{
|
||||
HttpSimpleParser::separator = ';';
|
||||
HttpSimpleParser::value_can_be_quoted = true;
|
||||
HttpSimpleParser::skip_white_chars = true;
|
||||
HttpSimpleParser::recognize_special_chars = false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#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,209 +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 "dircontainer.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
DirContainer::DirContainer()
|
||||
{
|
||||
is_root = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::GetRoot()
|
||||
{
|
||||
if( !is_root )
|
||||
return table.end();
|
||||
|
||||
return root_iter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::Begin()
|
||||
{
|
||||
return table.begin();
|
||||
}
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::End()
|
||||
{
|
||||
return table.end();
|
||||
}
|
||||
|
||||
|
||||
DirContainer::SizeType DirContainer::Size()
|
||||
{
|
||||
return table.size();
|
||||
}
|
||||
|
||||
bool DirContainer::Empty()
|
||||
{
|
||||
return table.empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::PushBack(const Item & item)
|
||||
{
|
||||
if( item.parent_id == -1 && is_root )
|
||||
{
|
||||
log << log1 << "DirCont: more than one root dir - skipped, id: " << item.id << logend;
|
||||
return root_iter;
|
||||
}
|
||||
|
||||
Iterator last_iter = table.insert(table.end(), item);
|
||||
|
||||
if( item.parent_id == -1 )
|
||||
{
|
||||
is_root = true;
|
||||
root_iter = last_iter;
|
||||
}
|
||||
|
||||
log << log2 << "DirCont: added dir, url: " << item.url << ", id: " << item.id << ", parent_id: " << item.parent_id << logend;
|
||||
|
||||
table_id.insert( std::make_pair(last_iter->id, last_iter) );
|
||||
table_parent.insert( std::make_pair(last_iter->parent_id, last_iter) );
|
||||
|
||||
log << log3 << "DirCont: added indexes to dir, id: " << last_iter->id << ", parent_id: " << last_iter->parent_id << logend;
|
||||
|
||||
return last_iter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DirContainer::Clear()
|
||||
{
|
||||
table.clear();
|
||||
table_id.clear();
|
||||
table_parent.clear();
|
||||
is_root = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::FindId(long id)
|
||||
{
|
||||
TableId::iterator i = table_id.find(id);
|
||||
|
||||
if( i == table_id.end() )
|
||||
return table.end();
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DirContainer::ParentIterator DirContainer::ParentBegin()
|
||||
{
|
||||
return table_parent.begin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
DirContainer::ParentIterator DirContainer::ParentEnd()
|
||||
{
|
||||
return table_parent.end();
|
||||
}
|
||||
|
||||
|
||||
DirContainer::ParentSizeType DirContainer::ParentSize()
|
||||
{
|
||||
return table_parent.size();
|
||||
}
|
||||
|
||||
|
||||
bool DirContainer::ParentEmpty()
|
||||
{
|
||||
return table_parent.empty();
|
||||
}
|
||||
|
||||
|
||||
DirContainer::ParentIterator DirContainer::FindFirstParent(long parent)
|
||||
{
|
||||
ParentIterator i = table_parent.lower_bound(parent);
|
||||
|
||||
if( i == table_parent.end() || i->first != parent )
|
||||
return table_parent.end();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
DirContainer::ParentIterator DirContainer::NextParent(ParentIterator i)
|
||||
{
|
||||
if( i == table_parent.end() )
|
||||
return table_parent.end();
|
||||
|
||||
long parent = i->first;
|
||||
++i;
|
||||
|
||||
if( i == table_parent.end() || i->first != parent )
|
||||
return table_parent.end();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool DirContainer::DelById(long id)
|
||||
{
|
||||
TableId::iterator i = table_id.find(id);
|
||||
|
||||
if( i == table_id.end() )
|
||||
{
|
||||
log << log1 << "DirCont: delete: there is no directory with id: " << id << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
long parent_id = i->second->parent_id;
|
||||
TableParent::iterator z = table_parent.lower_bound(parent_id);
|
||||
bool found = false;
|
||||
|
||||
for( ; z != table_parent.end() && z->first == parent_id ; ++z )
|
||||
{
|
||||
if( z->second == i->second )
|
||||
{
|
||||
log << log2 << "DirCont: deleted directory id: " << id << ", url: " << i->second->url;
|
||||
|
||||
if( i->second->parent_id == -1 )
|
||||
{
|
||||
log << log2 << " (root directory)";
|
||||
is_root = false;
|
||||
}
|
||||
|
||||
log << log2 << logend;
|
||||
|
||||
table.erase(i->second);
|
||||
|
||||
log << log3 << "DirCont: deleted indexes into directory id: " << id << logend;
|
||||
table_id.erase(i);
|
||||
table_parent.erase(z);
|
||||
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !found )
|
||||
{
|
||||
log << log1 << "DirCont: can't find an index_parent into directory id: " << id << ", url: " << i->second->url << " (deleting skipped)" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,73 +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 headerfilecmslucoredircontainer
|
||||
#define headerfilecmslucoredircontainer
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include "item.h"
|
||||
|
||||
|
||||
|
||||
class DirContainer
|
||||
{
|
||||
|
||||
public:
|
||||
typedef std::list<Item> Table;
|
||||
typedef Table::iterator Iterator;
|
||||
typedef Table::size_type SizeType;
|
||||
|
||||
typedef std::map<long, Iterator> TableId;
|
||||
typedef std::multimap<long, Iterator> TableParent;
|
||||
typedef TableParent::iterator ParentIterator;
|
||||
typedef TableParent::size_type ParentSizeType;
|
||||
|
||||
|
||||
DirContainer();
|
||||
|
||||
Iterator GetRoot();
|
||||
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
bool Empty();
|
||||
Iterator PushBack(const Item & item);
|
||||
void Clear();
|
||||
|
||||
Iterator FindId(long id);
|
||||
|
||||
bool DelById(long id);
|
||||
|
||||
ParentIterator ParentBegin();
|
||||
ParentIterator ParentEnd();
|
||||
ParentSizeType ParentSize();
|
||||
bool ParentEmpty();
|
||||
ParentIterator FindFirstParent(long parent);
|
||||
ParentIterator NextParent(ParentIterator pi);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// main table with dirs
|
||||
Table table;
|
||||
|
||||
// true if there is a root dir in the table
|
||||
bool is_root;
|
||||
|
||||
// root
|
||||
Iterator root_iter;
|
||||
|
||||
// indexes
|
||||
TableId table_id;
|
||||
TableParent table_parent;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
412
core/dirs.cpp
412
core/dirs.cpp
@@ -1,412 +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 "dirs.h"
|
||||
#include "error.h"
|
||||
#include "log.h"
|
||||
#include "db.h"
|
||||
#include "data.h"
|
||||
|
||||
|
||||
void Dirs::Clear()
|
||||
{
|
||||
dir_table.Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Dirs::CheckRootDir()
|
||||
{
|
||||
DirContainer::Iterator i = dir_table.GetRoot();
|
||||
|
||||
if( i != dir_table.End() )
|
||||
return;
|
||||
|
||||
log << log1 << "Dirs: there is no a root dir in the database (creating one)" << logend;
|
||||
|
||||
Item root;
|
||||
|
||||
root.type = Item::dir;
|
||||
root.parent_id = -1;
|
||||
root.user_id = -1;
|
||||
root.group_id = -1;
|
||||
root.privileges = 0755;
|
||||
root.default_item = -1;
|
||||
|
||||
// !! 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 )
|
||||
{
|
||||
dir_table.PushBack(root);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Dirs::ReadDirs()
|
||||
{
|
||||
Clear();
|
||||
|
||||
db.GetDirs(dir_table);
|
||||
CheckRootDir();
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
name.clear();
|
||||
|
||||
// skipping first slashes (can be more than one)
|
||||
for( ; *s == '/' ; ++s);
|
||||
|
||||
for( ; *s != 0 && *s != '/' ; ++s)
|
||||
name += *s;
|
||||
|
||||
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);
|
||||
|
||||
if( i == dir_table.End() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Dirs::GetDirChilds(long parent, std::vector<Item> & childs_table)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
bool Dirs::GetDirChilds(long parent, std::vector<Item*> & childs_table)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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)
|
||||
{
|
||||
DirContainer::Iterator i;
|
||||
|
||||
path = '/';
|
||||
|
||||
while( true )
|
||||
{
|
||||
i = dir_table.FindId(id);
|
||||
|
||||
if( i == dir_table.End() )
|
||||
return false;
|
||||
|
||||
if( i->parent_id == -1 )
|
||||
return true;
|
||||
|
||||
id = i->parent_id;
|
||||
|
||||
|
||||
path.insert(0, i->url);
|
||||
path.insert(path.begin(), '/');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// with exceptions
|
||||
|
||||
Item * Dirs::GetDirT(const std::string & path)
|
||||
{
|
||||
Item * pitem;
|
||||
|
||||
if( !GetDir(path, &pitem) )
|
||||
throw Error(Error::incorrect_dir);
|
||||
|
||||
return pitem;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! nowy interfejs
|
||||
|
||||
|
||||
|
||||
Item * Dirs::GetRootDir()
|
||||
{
|
||||
DirContainer::Iterator root = dir_table.GetRoot();
|
||||
|
||||
if( root == dir_table.End() )
|
||||
return 0;
|
||||
|
||||
return &(*root);
|
||||
}
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::string & name, long parent)
|
||||
{
|
||||
DirContainer::ParentIterator i = dir_table.FindFirstParent(parent);
|
||||
|
||||
for( ; i!=dir_table.ParentEnd() ; i = dir_table.NextParent(i) )
|
||||
if( i->second->url == name )
|
||||
return &(*i->second);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::string & path)
|
||||
{
|
||||
DirContainer::Iterator root = dir_table.GetRoot();
|
||||
|
||||
if( root == dir_table.End() )
|
||||
// ops, we do not have a root dir
|
||||
return 0;
|
||||
|
||||
Item * pitem = &(*root);
|
||||
|
||||
std::string name;
|
||||
const char * s = path.c_str();
|
||||
|
||||
while( ExtractName(s, name) )
|
||||
{
|
||||
pitem = GetDir(name, pitem->id);
|
||||
|
||||
if( !pitem )
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return pitem;
|
||||
}
|
||||
|
||||
|
||||
Item * Dirs::GetDir(long id)
|
||||
{
|
||||
DirContainer::Iterator i = dir_table.FindId(id);
|
||||
|
||||
if( i == dir_table.End() )
|
||||
return 0;
|
||||
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Item * Dirs::AddDir(const Item & item)
|
||||
{
|
||||
return &(*dir_table.PushBack(item));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Dirs::SplitPath(const std::string & path, std::string & dir, std::string & file)
|
||||
{
|
||||
std::string::size_type i;
|
||||
|
||||
dir.clear();
|
||||
file.clear();
|
||||
|
||||
if( path.empty() )
|
||||
// !! moze dir ustawic na '/' ?
|
||||
return;
|
||||
|
||||
for( i=path.size()-1 ; i>0 && path[i]!='/' ; --i);
|
||||
|
||||
if( path[i] != '/' )
|
||||
{
|
||||
// we do not have any slashes '/'
|
||||
file = path;
|
||||
return;
|
||||
}
|
||||
|
||||
dir.assign(path, 0, i + 1); // +1 means with a slash at the end
|
||||
|
||||
if( i < path.size() - 1 )
|
||||
file.assign(path, i+1, path.size() - i - 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Dirs::DeleteDir(long 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);
|
||||
}
|
||||
|
||||
|
||||
91
core/dirs.h
91
core/dirs.h
@@ -1,91 +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 headerfilecmslucoredirs
|
||||
#define headerfilecmslucoredirs
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "item.h"
|
||||
#include "dircontainer.h"
|
||||
|
||||
|
||||
|
||||
class Dirs
|
||||
{
|
||||
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);
|
||||
|
||||
//!! ta nie bedzie chyba potrzebna
|
||||
bool GetDirChilds(long parent, std::vector<Item> & childs_table); // only returns dir-children
|
||||
|
||||
bool GetDirChilds(long parent, std::vector<Item*> & childs_table); // only returns dir-children
|
||||
|
||||
bool MakePath(long id, std::string & path);
|
||||
|
||||
|
||||
// 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
|
||||
Item * GetRootDir();
|
||||
Item * GetDir(const std::string & name, long parent);
|
||||
Item * GetDir(const std::string & 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();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
DirContainer dir_table;
|
||||
|
||||
bool ExtractName(const char * & s, std::string & name);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
87
core/error.h
87
core/error.h
@@ -1,87 +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 headerfilecmslucoreerror
|
||||
#define headerfilecmslucoreerror
|
||||
|
||||
#include <iostream>
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class Error
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Code code;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
43
core/group.h
43
core/group.h
@@ -1,43 +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 headerfilecmslucoregroup
|
||||
#define headerfilecmslucoregroup
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
struct Group
|
||||
{
|
||||
long id;
|
||||
std::string name; // group name
|
||||
std::vector<long> members; // users id
|
||||
|
||||
Group()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void Clear()
|
||||
{
|
||||
id = -1;
|
||||
name.clear();
|
||||
members.clear();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
117
core/groups.cpp
117
core/groups.cpp
@@ -1,117 +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 "groups.h"
|
||||
#include "db.h"
|
||||
|
||||
|
||||
|
||||
|
||||
Groups::Groups()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void Groups::Clear()
|
||||
{
|
||||
table.Clear();
|
||||
}
|
||||
|
||||
|
||||
void Groups::ReadGroups()
|
||||
{
|
||||
Clear();
|
||||
|
||||
db.GetGroups(table);
|
||||
}
|
||||
|
||||
|
||||
Group * Groups::GetGroup(long group_id)
|
||||
{
|
||||
Table::Iterator i = table.FindId(group_id);
|
||||
|
||||
if( i == table.End() )
|
||||
return 0;
|
||||
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
Group * Groups::GetGroup(const std::string & name)
|
||||
{
|
||||
Table::Iterator i = table.FindName(name);
|
||||
|
||||
if( i == table.End() )
|
||||
return 0;
|
||||
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
long Groups::GetGroupId(const std::string & name)
|
||||
{
|
||||
Group * pgroup = GetGroup(name);
|
||||
|
||||
if( !pgroup )
|
||||
return -1;
|
||||
|
||||
return pgroup->id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Groups::Iterator Groups::Begin()
|
||||
{
|
||||
return table.Begin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Groups::Iterator Groups::End()
|
||||
{
|
||||
return table.End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Groups::SizeType Groups::Size()
|
||||
{
|
||||
return table.Size();
|
||||
}
|
||||
|
||||
|
||||
Group & Groups::operator[](Groups::SizeType pos)
|
||||
{
|
||||
return table[pos];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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 headerfilecmslucoregroups
|
||||
#define headerfilecmslucoregroups
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "group.h"
|
||||
#include "ugcontainer.h"
|
||||
|
||||
|
||||
class Groups
|
||||
{
|
||||
typedef UGContainer<Group> Table;
|
||||
|
||||
Table table;
|
||||
|
||||
public:
|
||||
|
||||
typedef Table::Iterator Iterator;
|
||||
typedef Table::SizeType SizeType;
|
||||
|
||||
Groups();
|
||||
void Clear();
|
||||
void ReadGroups();
|
||||
Group * GetGroup(long group_id);
|
||||
Group * GetGroup(const std::string & name);
|
||||
long GetGroupId(const std::string & name);
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
Group & operator[](SizeType pos);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,235 +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 "httpsimpleparser.h"
|
||||
|
||||
|
||||
void HttpSimpleParser::ToLower(std::string & s)
|
||||
{
|
||||
std::string::iterator i;
|
||||
|
||||
for(i=s.begin() ; i!= s.end() ; ++i)
|
||||
{
|
||||
if( *i>='A' && *i<='Z' )
|
||||
*i = *i - 'A' + 'a';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool HttpSimpleParser::IsWhite(int c)
|
||||
{
|
||||
if( c==' ' || c=='\t' )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void HttpSimpleParser::SkipWhiteChars()
|
||||
{
|
||||
while( IsWhite(last_c) )
|
||||
last_c = GetChar();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void HttpSimpleParser::TrimWhiteChars(std::string & s)
|
||||
{
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
std::string::size_type i;
|
||||
|
||||
for(i = 0 ; i<s.size() && IsWhite(s[i]) ; ++i);
|
||||
|
||||
if( i == s.size() )
|
||||
{
|
||||
// all characters are white
|
||||
s.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if( i > 0 )
|
||||
// there are some white characters at the beginning
|
||||
s.erase(0, i);
|
||||
|
||||
|
||||
// s is not empty now (i was not equal s.size())
|
||||
// and we have some non white characters
|
||||
// we stops at the last non white character
|
||||
for(i = s.size()-1 ; i>0 && IsWhite(s[i]) ; --i);
|
||||
|
||||
if( i != s.size()-1 )
|
||||
// there are some white characters at the end
|
||||
// we're starting from i+1 even when i==0 (there are some non white characters)
|
||||
s.erase(i+1, s.size() - i - 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int HttpSimpleParser::ParseHalfHex(int c)
|
||||
{
|
||||
if( c>='a' && c<='z' )
|
||||
c += 'A' - 'a'; // to upper case
|
||||
|
||||
|
||||
if( c >= 'A' )
|
||||
c = c - 'A' + 10;
|
||||
else
|
||||
c = c - '0';
|
||||
|
||||
c &= 0xf;
|
||||
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void HttpSimpleParser::CheckSpecialChar()
|
||||
{
|
||||
if( last_c == '%' )
|
||||
{
|
||||
int c1 = GetChar();
|
||||
int c2 = GetChar();
|
||||
|
||||
if( c1==-1 || c2==-1 )
|
||||
{
|
||||
last_c = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
c1 = ParseHalfHex(c1);
|
||||
c2 = ParseHalfHex(c2);
|
||||
|
||||
last_c = (c1 << 4) + c2;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( last_c == '+' )
|
||||
{
|
||||
last_c = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void HttpSimpleParser::ReadName()
|
||||
{
|
||||
// we're checking 'separator' and '=' because the string is allowed not having '=' (the value is optional)
|
||||
|
||||
for( ; last_c!=-1 && last_c!=separator && last_c!='=' ; last_c = GetChar() )
|
||||
{
|
||||
if( recognize_special_chars )
|
||||
CheckSpecialChar();
|
||||
|
||||
if( last_c != -1 )
|
||||
last_name += last_c;
|
||||
}
|
||||
|
||||
|
||||
if( last_c == '=' )
|
||||
last_c = GetChar();
|
||||
}
|
||||
|
||||
|
||||
void HttpSimpleParser::ReadQuotedValue()
|
||||
{
|
||||
// skipping '"'
|
||||
last_c = GetChar();
|
||||
|
||||
|
||||
for( ; last_c!=-1 && last_c!='"' ; last_c = GetChar() )
|
||||
{
|
||||
if( recognize_special_chars )
|
||||
CheckSpecialChar();
|
||||
|
||||
if( last_c != -1 )
|
||||
last_value += last_c;
|
||||
}
|
||||
|
||||
|
||||
if( last_c == '"' )
|
||||
last_c = GetChar();
|
||||
|
||||
// looking for a separator (skipping)
|
||||
for( ; last_c!=-1 && last_c!=separator ; last_c = GetChar() );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void HttpSimpleParser::ReadValue()
|
||||
{
|
||||
if( skip_white_chars )
|
||||
SkipWhiteChars();
|
||||
|
||||
if( value_can_be_quoted && last_c == '"' )
|
||||
{
|
||||
ReadQuotedValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
for( ; last_c!=-1 && last_c!=separator ; last_c = GetChar() )
|
||||
{
|
||||
if( recognize_special_chars )
|
||||
CheckSpecialChar();
|
||||
|
||||
if( last_c != -1 )
|
||||
last_value += last_c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( last_c == separator )
|
||||
last_c = GetChar();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void HttpSimpleParser::Parse()
|
||||
{
|
||||
for( last_c = GetChar() ; last_c != -1 ; )
|
||||
{
|
||||
last_name.clear();
|
||||
last_value.clear();
|
||||
|
||||
if( read_name )
|
||||
ReadName();
|
||||
|
||||
ReadValue();
|
||||
|
||||
if( skip_white_chars )
|
||||
{
|
||||
TrimWhiteChars(last_name);
|
||||
TrimWhiteChars(last_value);
|
||||
}
|
||||
|
||||
Parameter(last_name, last_value); // user definied function
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,74 +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 headerfilecmslucorehttpsimpleparser
|
||||
#define headerfilecmslucorehttpsimpleparser
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
class HttpSimpleParser
|
||||
{
|
||||
protected:
|
||||
|
||||
bool read_name;
|
||||
bool value_can_be_quoted;
|
||||
bool skip_white_chars;
|
||||
bool recognize_special_chars;
|
||||
|
||||
int ParseHalfHex(int c);
|
||||
void ReadName();
|
||||
void ReadQuotedValue();
|
||||
void ReadValue();
|
||||
|
||||
std::string last_name;
|
||||
std::string last_value;
|
||||
|
||||
int last_c;
|
||||
int separator;
|
||||
|
||||
// '-1' means end (eof)
|
||||
virtual int GetChar() = 0;
|
||||
virtual void Parameter(std::string & last_name, std::string & last_value) = 0;
|
||||
|
||||
void ToLower(std::string & s);
|
||||
bool IsWhite(int c);
|
||||
|
||||
void SkipWhiteChars();
|
||||
void TrimWhiteChars(std::string & s);
|
||||
void CheckSpecialChar();
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
HttpSimpleParser()
|
||||
{
|
||||
separator = '&';
|
||||
read_name = true;
|
||||
value_can_be_quoted = false;
|
||||
skip_white_chars = false;
|
||||
recognize_special_chars = true;
|
||||
}
|
||||
|
||||
|
||||
void Parse();
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
111
core/item.h
111
core/item.h
@@ -1,111 +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 headerfilecmslucoreitem
|
||||
#define headerfilecmslucoreitem
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
|
||||
struct Item
|
||||
{
|
||||
long id;
|
||||
|
||||
|
||||
long user_id;
|
||||
long group_id;
|
||||
int privileges;
|
||||
|
||||
// used as a user name when user_id is equal -1
|
||||
std::string guest_name;
|
||||
|
||||
tm date_creation;
|
||||
tm date_modification;
|
||||
|
||||
std::string subject;
|
||||
std::string content;
|
||||
std::string url;
|
||||
|
||||
|
||||
// 0 - simple txt
|
||||
// 1 - formatted txt
|
||||
// 2 - html
|
||||
// 3 - bbcode
|
||||
int content_type;
|
||||
|
||||
|
||||
|
||||
enum Type
|
||||
{
|
||||
dir = 0,
|
||||
file = 1,
|
||||
|
||||
none = 1000
|
||||
};
|
||||
|
||||
|
||||
Type type;
|
||||
|
||||
//item_type;
|
||||
|
||||
long parent_id;
|
||||
long default_item;
|
||||
|
||||
|
||||
// used by the database
|
||||
// !! moze da sie w ogole z tego zrezygnowac?
|
||||
long content_id;
|
||||
|
||||
|
||||
Item()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "lastcontainer.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LastContainer::Iterator LastContainer::Begin()
|
||||
{
|
||||
return last_tab.begin();
|
||||
}
|
||||
|
||||
|
||||
LastContainer::Iterator LastContainer::End()
|
||||
{
|
||||
return last_tab.end();
|
||||
}
|
||||
|
||||
|
||||
LastContainer::Iterator LastContainer::FindNotLoggedOut(long user_id, long session_id)
|
||||
{
|
||||
LastTab::iterator i;
|
||||
|
||||
for(i=last_tab.begin() ; i!=last_tab.end() ; ++i)
|
||||
{
|
||||
if( i->user_id == user_id && i->session_id == session_id && !i->IsLoggedOut() )
|
||||
return i;
|
||||
}
|
||||
|
||||
return last_tab.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LastContainer::UserLogin(long user_id, const std::string & name, unsigned int ip, long session_id)
|
||||
{
|
||||
LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
|
||||
|
||||
if( i != last_tab.end() )
|
||||
{
|
||||
log << log1 << "LC: such a user and session_id exist, not added as a new one" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( last_tab.size() >= LAST_TABLE_SIZE )
|
||||
last_tab.erase(last_tab.begin());
|
||||
|
||||
LastItem li;
|
||||
|
||||
li.user_id = user_id;
|
||||
li.name = name;
|
||||
li.ip = ip;
|
||||
li.session_id = session_id;
|
||||
|
||||
time_t t = std::time(0);
|
||||
li.start = *localtime(&t);
|
||||
|
||||
last_tab.insert(last_tab.end(), li);
|
||||
|
||||
log << log2 << "LC: added user: " << name << " into the last table" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void LastContainer::UserLogout(long user_id, long session_id)
|
||||
{
|
||||
LastTab::iterator i = FindNotLoggedOut(user_id, session_id);
|
||||
|
||||
if( i != last_tab.end() )
|
||||
{
|
||||
time_t t = std::time(0);
|
||||
i->end = *localtime(&t);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "LC: there is no such a user to log out" << logend;
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorelastcontainer
|
||||
#define headerfilecmslucorelastcontainer
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
|
||||
|
||||
|
||||
// how many items we store in the 'last' function
|
||||
#define LAST_TABLE_SIZE 100
|
||||
|
||||
|
||||
|
||||
struct LastItem
|
||||
{
|
||||
long user_id;
|
||||
|
||||
// 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;
|
||||
|
||||
// ip address
|
||||
unsigned int ip;
|
||||
|
||||
// session id (used when logging out)
|
||||
long session_id;
|
||||
|
||||
// start logging and end logging
|
||||
tm start;
|
||||
tm end;
|
||||
|
||||
|
||||
LastItem();
|
||||
bool IsLoggedOut();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class LastContainer
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::list<LastItem> LastTab;
|
||||
typedef LastTab::iterator Iterator;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
void UserLogin(long user_id, const std::string & name, unsigned int ip, long session_id);
|
||||
void UserLogout(long user_id, long session_id);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
LastTab last_tab;
|
||||
Iterator FindNotLoggedOut(long user_id, long session_id);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
194
core/log.cpp
194
core/log.cpp
@@ -1,194 +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 "log.h"
|
||||
#include <ctime>
|
||||
|
||||
|
||||
Log::Log()
|
||||
{
|
||||
log_level = 3;
|
||||
current_level = 4; // nothing to log (call Init() first)
|
||||
}
|
||||
|
||||
|
||||
void Log::Init(int log_l, const std::string & log_f, bool log_std)
|
||||
{
|
||||
log_level = log_l;
|
||||
log_file = log_f;
|
||||
log_stdout = log_std;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Log::PutDate(Manipulators m)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const char * s)
|
||||
{
|
||||
if( !s )
|
||||
return *this;
|
||||
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::string & s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(int s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(long s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(char s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(size_t s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(double s)
|
||||
{
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Log & Log::operator<<(Manipulators m)
|
||||
{
|
||||
switch(m)
|
||||
{
|
||||
case logend:
|
||||
SaveLog();
|
||||
buffer.str( "" );
|
||||
break;
|
||||
|
||||
case log1:
|
||||
current_level = 1;
|
||||
break;
|
||||
|
||||
case log2:
|
||||
current_level = 2;
|
||||
break;
|
||||
|
||||
case log3:
|
||||
current_level = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Log::SaveLog()
|
||||
{
|
||||
int attempt = 2;
|
||||
|
||||
if( current_level > log_level )
|
||||
return;
|
||||
|
||||
if( log_stdout )
|
||||
std::cout << buffer.str() << std::endl;
|
||||
|
||||
|
||||
if( log_file.empty() )
|
||||
return;
|
||||
|
||||
std::ofstream file;
|
||||
|
||||
do
|
||||
{
|
||||
file.open( log_file.c_str(), std::ios_base::out | std::ios_base::app );
|
||||
|
||||
// if( !file )
|
||||
// sleep(1);
|
||||
}
|
||||
while( --attempt > 0 && !file );
|
||||
|
||||
if( !file )
|
||||
return;
|
||||
|
||||
file << buffer.str() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
60
core/log.h
60
core/log.h
@@ -1,60 +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 headerfilecmslucorelog
|
||||
#define headerfilecmslucorelog
|
||||
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
// !! 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 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 & operator<<(const char * s);
|
||||
Log & operator<<(const std::string & s);
|
||||
Log & operator<<(int s);
|
||||
Log & operator<<(long s);
|
||||
Log & operator<<(char s);
|
||||
Log & operator<<(size_t s);
|
||||
Log & operator<<(double s);
|
||||
Log & operator<<(Manipulators m);
|
||||
|
||||
void SaveLog();
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern Log log;
|
||||
extern Log nlog;
|
||||
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
404
core/misc.cpp
404
core/misc.cpp
@@ -1,404 +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 "misc.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void ToString(std::string & s, int value)
|
||||
{
|
||||
static char buffer[50];
|
||||
|
||||
sprintf(buffer, "%d", value);
|
||||
s = buffer;
|
||||
}
|
||||
|
||||
|
||||
void ToString(std::string & s, long value)
|
||||
{
|
||||
static char buffer[50];
|
||||
|
||||
sprintf(buffer, "%ld", value);
|
||||
s = buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool CorrectUrlChar(char c)
|
||||
{
|
||||
if( (c >= 'a' && c <='z') ||
|
||||
(c >= 'A' && c <='Z') ||
|
||||
(c >= '0' && c <='9') ||
|
||||
(c == '(' || c == ')' || c == '.' || c == ',' || c == '_' )
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CorrectUrl(Item & item)
|
||||
{
|
||||
std::string::iterator i;
|
||||
|
||||
for(i = item.url.begin(); i!=item.url.end() ; ++i)
|
||||
{
|
||||
if( !CorrectUrlChar(*i) )
|
||||
{
|
||||
int c = ChangeLocalChar(*i);
|
||||
|
||||
if( CorrectUrlChar(c) )
|
||||
*i = c;
|
||||
else
|
||||
*i = '_';
|
||||
}
|
||||
}
|
||||
|
||||
ToSmall(item.url);
|
||||
|
||||
if( item.url.empty() )
|
||||
item.url = "bez_nazwy"; // !! wrzucic do pliku konfiguracyjnego
|
||||
else
|
||||
if( item.url[0] >= '0' && item.url[0] <= '9' )
|
||||
// url must begin with a letter
|
||||
item.url.insert(item.url.begin(), '_');
|
||||
}
|
||||
|
||||
|
||||
void SetUrlFromSubject(Item & item)
|
||||
{
|
||||
item.url = item.subject;
|
||||
CorrectUrl(item);
|
||||
|
||||
/*
|
||||
std::string::iterator i;
|
||||
|
||||
item.url.clear();
|
||||
|
||||
for(i = item.subject.begin(); i!=item.subject.end() ; ++i)
|
||||
{
|
||||
int c = ChangeLocalChar(*i);
|
||||
|
||||
if( (c >= 'a' && c <='z') ||
|
||||
(c >= 'A' && c <='Z') ||
|
||||
(c >= '0' && c <='9') ||
|
||||
(c == '(' || c == ')' || c == '.' || c == ',' || c == '_' )
|
||||
)
|
||||
{
|
||||
item.url += c;
|
||||
}
|
||||
else
|
||||
item.url += '_';
|
||||
}
|
||||
|
||||
if( item.url.empty() )
|
||||
item.url = "bez_nazwy"; // !! wrzucic do pliku konfiguracyjnego
|
||||
else
|
||||
if( item.url[0] >= '0' && item.url[0] <= '9' )
|
||||
// url must begin with a letter
|
||||
item.url.insert(item.url.begin(), '_');
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int polish_letters_simple[] =
|
||||
{ 'a', 'A',
|
||||
'c', 'C',
|
||||
's', 'S',
|
||||
'e', 'E',
|
||||
'l', 'L',
|
||||
'o', 'O',
|
||||
'z', 'Z',
|
||||
'z', 'Z',
|
||||
'n', 'N', 0 }; // 0 - terminating
|
||||
|
||||
|
||||
int polish_letters_iso88592[] =
|
||||
{ 0xb1, 0xa1,
|
||||
0xe6, 0xc6,
|
||||
0xb6, 0xa6,
|
||||
0xea, 0xca,
|
||||
0xb3, 0xa3,
|
||||
0xf3, 0xd3,
|
||||
0xbf, 0xaf,
|
||||
0xbc, 0xac,
|
||||
0xf1, 0xd1, 0 };
|
||||
|
||||
|
||||
|
||||
int ChangeLocalChar(unsigned char c)
|
||||
{
|
||||
// if( language == polish_iso88592 )
|
||||
|
||||
for(int i = 0 ; polish_letters_iso88592[i] ; ++i)
|
||||
{
|
||||
if( polish_letters_simple[i] == 0 )
|
||||
{
|
||||
log << log1 << "localization tables don't have the same size" << logend;
|
||||
return c;
|
||||
}
|
||||
|
||||
if( polish_letters_iso88592[i] == c )
|
||||
return polish_letters_simple[i];
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
bool HtmlTryChar(std::ostringstream & out, int c)
|
||||
{
|
||||
if( c == '<' )
|
||||
{
|
||||
out << "<";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if( c == '>' )
|
||||
{
|
||||
out << ">";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if( c == '&' )
|
||||
{
|
||||
out << "&";
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void HtmlEscape(std::ostringstream & out, const std::string & in)
|
||||
{
|
||||
std::string::const_iterator i;
|
||||
|
||||
for(i = in.begin() ; i != in.end() ; ++i)
|
||||
{
|
||||
if( !HtmlTryChar(out, *i) )
|
||||
out << *i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string HtmlEscape(const std::string & in)
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
||||
HtmlEscape(out, in);
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
||||
void HtmlEscapeFormTxt(std::ostringstream & out, const std::string & in)
|
||||
{
|
||||
std::string::const_iterator i;
|
||||
int was_enter = 0; // how many enteres there were before
|
||||
|
||||
out << "<p>";
|
||||
|
||||
for(i = in.begin() ; i != in.end() ; ++i)
|
||||
{
|
||||
if( !HtmlTryChar(out, *i) )
|
||||
{
|
||||
if( *i == 13 )
|
||||
// skipping stupid characters (\r\n\ in dos mode)
|
||||
continue;
|
||||
|
||||
if( *i == 10 )
|
||||
{
|
||||
++was_enter;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( was_enter == 1 )
|
||||
out << "<br>\n";
|
||||
else
|
||||
if( was_enter > 1 )
|
||||
out << "</p>\n<p>";
|
||||
|
||||
out << *i;
|
||||
was_enter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out << "</p>\n";
|
||||
}
|
||||
|
||||
|
||||
std::string HtmlEscapeFormTxt(const std::string & in)
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
||||
HtmlEscapeFormTxt(out, in);
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStr(int year, int month, int day, int hour, int min, int sec)
|
||||
{
|
||||
static const char * month_letter[] = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII" };
|
||||
static char buffer[100];
|
||||
|
||||
--month;
|
||||
|
||||
if( month < 0 )
|
||||
month = 0;
|
||||
|
||||
if( month > 11 )
|
||||
month = 11;
|
||||
|
||||
if( year == 0 )
|
||||
sprintf(buffer, "%s.%02d %02d:%02d:%02d", month_letter[month], day, hour, min, sec);
|
||||
else
|
||||
sprintf(buffer, "%02d.%s.%02d %02d:%02d:%02d", year, month_letter[month], day, hour, min, sec);
|
||||
|
||||
// warning: not thread safe (we do not use threads)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStr(tm * ptm)
|
||||
{
|
||||
return DateToStr(ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStr(time_t t)
|
||||
{
|
||||
tm * ptm = std::localtime(&t);
|
||||
|
||||
return DateToStr(ptm);
|
||||
}
|
||||
|
||||
|
||||
const char * IpToStr(unsigned int ip_)
|
||||
{
|
||||
static char buffer[100];
|
||||
|
||||
union
|
||||
{
|
||||
unsigned int ip;
|
||||
unsigned char c[4];
|
||||
} ip;
|
||||
|
||||
ip.ip = ip_;
|
||||
|
||||
sprintf(buffer, "%u.%u.%u.%u", (int)ip.c[0], (int)ip.c[1], (int)ip.c[2], (int)ip.c[3]);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
bool IsWhite(int s)
|
||||
{
|
||||
if( s==' ' || s=='\t' || s==13 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrimWhite(std::string & s)
|
||||
{
|
||||
std::string::size_type i;
|
||||
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
// looking for white characters at the end
|
||||
for(i=s.size()-1 ; i>0 && IsWhite(s[i]) ; --i);
|
||||
|
||||
if( i==0 && IsWhite(s[i]) )
|
||||
{
|
||||
// the whole string has white characters
|
||||
s.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// deleting white characters at the end
|
||||
if( i != s.size() - 1 )
|
||||
s.erase(i+1, std::string::npos);
|
||||
|
||||
// looking for white characters at the beginning
|
||||
for(i=0 ; i<s.size() && IsWhite(s[i]) ; ++i);
|
||||
|
||||
// deleting white characters at the beginning
|
||||
if( i != 0 )
|
||||
s.erase(0, i);
|
||||
}
|
||||
|
||||
|
||||
void ToSmall(std::string & s)
|
||||
{
|
||||
std::string::size_type i;
|
||||
|
||||
for(i=0 ; i<s.size() ; ++i)
|
||||
{
|
||||
if( s[i]>='A' && s[i]<='Z' )
|
||||
s[i] = s[i] - 'A' + 'a';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ValidateEmail(const std::string & email)
|
||||
{
|
||||
if( email.empty() )
|
||||
return false;
|
||||
|
||||
bool correct = true;
|
||||
size_t i;
|
||||
char allowed_chars[] = "!#$%&'*+-/=?^_`{|}~.@";
|
||||
int at = 0;
|
||||
|
||||
for(i=0 ; i<email.length() && correct ; ++i)
|
||||
{
|
||||
correct = false;
|
||||
|
||||
if( (email[i] >= 'A' && email[i]<='Z') ||
|
||||
(email[i] >= 'a' && email[i]<='z') ||
|
||||
(email[i] >= '0' && email[i]<='9') )
|
||||
{
|
||||
correct = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t a=0 ; a < sizeof(allowed_chars)-1 ; ++a)
|
||||
{
|
||||
if( email[i] == allowed_chars[a] )
|
||||
{
|
||||
correct = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( email[i] == '@' )
|
||||
++at;
|
||||
}
|
||||
|
||||
if( at != 1 )
|
||||
return false;
|
||||
|
||||
return correct;
|
||||
}
|
||||
48
core/misc.h
48
core/misc.h
@@ -1,48 +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 headerfilecmslucoremisc
|
||||
#define headerfilecmslucoremisc
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <ctime>
|
||||
#include "item.h"
|
||||
|
||||
#define MAJOR_VER 0
|
||||
#define MINOR_VER 2
|
||||
#define REVISION_VER 0
|
||||
|
||||
|
||||
void ToString(std::string & s, int value);
|
||||
void ToString(std::string & s, long value);
|
||||
int ChangeLocalChar(unsigned char c);
|
||||
|
||||
bool CorrectUrlChar(char c);
|
||||
void CorrectUrl(Item & item);
|
||||
void SetUrlFromSubject(Item & item);
|
||||
|
||||
void HtmlEscape(std::ostringstream & out, const std::string & in);
|
||||
void HtmlEscapeFormTxt(std::ostringstream & out, const std::string & in);
|
||||
std::string HtmlEscape(const std::string & in);
|
||||
std::string HtmlEscapeFormTxt(const std::string & in);
|
||||
|
||||
const char * DateToStr(int year, int month, int day, int hour, int min, int sec);
|
||||
const char * DateToStr(tm * ptm);
|
||||
const char * DateToStr(time_t t);
|
||||
const char * IpToStr(unsigned int ip_);
|
||||
|
||||
bool IsWhite(int s);
|
||||
void TrimWhite(std::string & s);
|
||||
void ToSmall(std::string & s);
|
||||
|
||||
bool ValidateEmail(const std::string & email);
|
||||
|
||||
#endif
|
||||
124
core/mount.cpp
124
core/mount.cpp
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mount.h"
|
||||
|
||||
|
||||
|
||||
|
||||
Mount::Mount()
|
||||
{
|
||||
type = cms;
|
||||
dir_id = -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();
|
||||
}
|
||||
67
core/mount.h
67
core/mount.h
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef headerfilecmslucoremount
|
||||
#define headerfilecmslucoremount
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class Mount
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
enum Type
|
||||
{
|
||||
cms = 0,
|
||||
thread
|
||||
};
|
||||
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mountparser.h"
|
||||
#include "data.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
bool MountParser::IsWhite(int c)
|
||||
{
|
||||
if( c==' ' || c=='\t' || c==13 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::SkipWhite()
|
||||
{
|
||||
while( IsWhite(*pinput) )
|
||||
++pinput;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::SkipLine()
|
||||
{
|
||||
while( *pinput && *pinput != 10 )
|
||||
++pinput;
|
||||
|
||||
if( *pinput == 10 )
|
||||
++pinput;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadWord(std::string & res)
|
||||
{
|
||||
res.clear();
|
||||
|
||||
while( *pinput && *pinput!=10 && !IsWhite(*pinput) )
|
||||
{
|
||||
res += *pinput;
|
||||
++pinput;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MountParser::ReadParamArg(int & out)
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
char * new_pos;
|
||||
long temp = strtol(pinput, &new_pos, 10);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadParamArgs(std::vector<int> & args)
|
||||
{
|
||||
int arg;
|
||||
|
||||
while( ReadParamArg(arg) )
|
||||
{
|
||||
args.push_back(arg);
|
||||
|
||||
log << log3 << "MP: mount param arg: " << arg << logend;
|
||||
|
||||
if( *pinput == ',' )
|
||||
++pinput;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadParam(std::string & res, std::vector<int> & 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);
|
||||
|
||||
if( *pinput != ')' )
|
||||
{
|
||||
// there should be ')' at the end
|
||||
// temporarily we do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
++pinput;
|
||||
}
|
||||
}
|
||||
|
||||
if( *pinput == ',' )
|
||||
++pinput;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MountParser::ReadMountType()
|
||||
{
|
||||
SkipWhite();
|
||||
ReadWord(temp);
|
||||
|
||||
if( temp == "cms" )
|
||||
{
|
||||
mount.type = Mount::cms;
|
||||
log << log3 << "MP: mount type: cms" << logend;
|
||||
}
|
||||
else
|
||||
if( temp == "thread" )
|
||||
{
|
||||
mount.type = Mount::thread;
|
||||
log << log3 << "MP: mount type: thread" << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = Error::mount_unknown;
|
||||
log << log1 << "MP: unknown mount type: " << temp << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadMountPoint()
|
||||
{
|
||||
SkipWhite();
|
||||
|
||||
// !! narazie bez cudzyslowow
|
||||
ReadWord(temp);
|
||||
|
||||
pdir = data.dirs.GetDir(temp);
|
||||
|
||||
if( pdir )
|
||||
{
|
||||
mount.dir_id = pdir->id;
|
||||
log << log3 << "MP: mount point: " << temp << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = Error::no_mountpoint;
|
||||
log << log1 << "MP: there is no such a mount point: " << temp << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadMountParams()
|
||||
{
|
||||
mount.ClearParams();
|
||||
|
||||
for( ReadParam(temp, param_args) ; !temp.empty() ; ReadParam(temp, param_args) )
|
||||
{
|
||||
if( !mount.ParseStrParam(temp, param_args) )
|
||||
{
|
||||
log << log1 << "MP: unknown mount param: " << temp << logend;
|
||||
err = Error::mount_no_param;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log3 << "MP: mount param: " << temp << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MountParser::ReadRow(std::map<long, Mount> & output)
|
||||
{
|
||||
ReadMountType();
|
||||
|
||||
if( err == Error::ok )
|
||||
ReadMountPoint();
|
||||
|
||||
if( err == Error::ok )
|
||||
ReadMountParams();
|
||||
|
||||
if( err == Error::ok )
|
||||
{
|
||||
output.insert( std::make_pair(mount.dir_id, mount) );
|
||||
}
|
||||
|
||||
|
||||
SkipLine();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Error MountParser::Parse(const std::string & input, std::map<long, Mount> & output)
|
||||
{
|
||||
pinput = input.c_str();
|
||||
err = Error::ok;
|
||||
output.clear();
|
||||
|
||||
while( *pinput && err == Error::ok )
|
||||
ReadRow(output);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucoremountparser
|
||||
#define headerfilecmslucoremountparser
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "mount.h"
|
||||
#include "item.h"
|
||||
#include "error.h"
|
||||
|
||||
|
||||
|
||||
class MountParser
|
||||
{
|
||||
public:
|
||||
|
||||
Error Parse(const std::string & input, std::map<long, Mount> & output);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
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 ReadMountParams();
|
||||
void ReadRow(std::map<long, Mount> & output);
|
||||
|
||||
const char * pinput;
|
||||
std::string temp;
|
||||
std::vector<int> param_args;
|
||||
|
||||
|
||||
Mount mount;
|
||||
|
||||
Item * pdir;
|
||||
Error err;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
106
core/mounts.cpp
106
core/mounts.cpp
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mounts.h"
|
||||
#include "data.h"
|
||||
#include "request.h"
|
||||
#include "log.h"
|
||||
#include "mountparser.h"
|
||||
|
||||
|
||||
void Mounts::ReadMounts()
|
||||
{
|
||||
MountParser mp;
|
||||
|
||||
// !! tymczasowo - bedzie odczyt z bazy z /etc/fstab
|
||||
|
||||
std::string temp =
|
||||
"cms / withheader, withinfo \n"
|
||||
"thread /news desc, withheader, thread_with_header, thread_with_info, restrictcreatethread(-1) \n"
|
||||
"thread /forum asc, withheader, withinfo, thread_with_info, restrictcreatethread(3), only_root_can_remove, can_use_emacs_on(4), can_use_mkdir_on(3)";
|
||||
|
||||
|
||||
|
||||
|
||||
Error err = mp.Parse(temp, mount_table);
|
||||
|
||||
if( err != Error::ok )
|
||||
{
|
||||
log << log1 << "M: some problems with mountpoints (mountpoints table will be empty)" << logend;
|
||||
mount_table.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Mount Mounts::GetCurrentMountPoint()
|
||||
{
|
||||
return current_dir;
|
||||
}
|
||||
*/
|
||||
|
||||
Mount::Type Mounts::CurrentMountType()
|
||||
{
|
||||
return current_dir.type;
|
||||
}
|
||||
|
||||
bool Mounts::CurrentMountIsParam(Mount::Param p)
|
||||
{
|
||||
return current_dir.IsParam(p);
|
||||
}
|
||||
|
||||
bool Mounts::CurrentMountIsParam(Mount::Param p, int * first_arg)
|
||||
{
|
||||
return current_dir.IsParam(p, first_arg);
|
||||
}
|
||||
|
||||
|
||||
void Mounts::MountCmsForRoot()
|
||||
{
|
||||
current_dir.type = Mount::cms;
|
||||
|
||||
Item * proot = data.dirs.GetRootDir();
|
||||
|
||||
if( proot )
|
||||
current_dir.dir_id = proot->id;
|
||||
else
|
||||
{
|
||||
current_dir.dir_id = -1;
|
||||
log << log1 << "M: there is no a root dir" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Mounts::CalculateCurrentMountType()
|
||||
{
|
||||
std::vector<Item*>::reverse_iterator i;
|
||||
|
||||
|
||||
for(i = request.dir_table.rbegin() ; i!=request.dir_table.rend() ; ++i)
|
||||
{
|
||||
std::map<long, Mount>::iterator m = mount_table.find( (*i)->id );
|
||||
|
||||
if( m != mount_table.end() )
|
||||
{
|
||||
current_dir = m->second;
|
||||
log << log2 << "M: current mount point is: " << current_dir.TypeToStr() << logend;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// we assume that 'cms' mount point is used
|
||||
MountCmsForRoot();
|
||||
log << log2 << "M: current mount point is: cms (default)" << logend;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef headerfilecmslucorecoremounts
|
||||
#define headerfilecmslucorecoremounts
|
||||
|
||||
|
||||
#include <map>
|
||||
#include "mount.h"
|
||||
|
||||
|
||||
|
||||
class Mounts
|
||||
{
|
||||
public:
|
||||
|
||||
void ReadMounts();
|
||||
|
||||
void CalculateCurrentMountType();
|
||||
|
||||
// !! nie lepiej aby zwracal tutaj referencje albo wskaznik na biezacy punkt?
|
||||
// !! w Mount mamy strukture std::set
|
||||
//Mount GetCurrentMountPoint();
|
||||
|
||||
Mount::Type CurrentMountType();
|
||||
bool CurrentMountIsParam(Mount::Param p);
|
||||
bool CurrentMountIsParam(Mount::Param p, int * first_arg);
|
||||
|
||||
void MountCmsForRoot();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Mount current_dir;
|
||||
|
||||
// dir_id, mount_point
|
||||
std::map<long, Mount> mount_table;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
245
core/notify.cpp
245
core/notify.cpp
@@ -1,245 +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 <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "notify.h"
|
||||
#include "data.h"
|
||||
#include "misc.h"
|
||||
#include "request.h"
|
||||
|
||||
|
||||
|
||||
// the second thread uses this pointer to reference to 'this'
|
||||
// (methods for the thread should be static)
|
||||
Notify * Notify::obj;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
methods for second thread
|
||||
|
||||
second thread can reference to 'this' by using 'obj' pointer
|
||||
*/
|
||||
|
||||
void * Notify::ThreadRoutine(void * arg)
|
||||
{
|
||||
obj = (Notify*)arg;
|
||||
obj->templates_notify.Read(obj->templates_dir);
|
||||
|
||||
|
||||
while( true )
|
||||
{
|
||||
CheckQueue();
|
||||
sleep(30);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Notify::CheckQueue()
|
||||
{
|
||||
std::list<NotifyMsg>::iterator i = obj->notify_pool.begin();
|
||||
|
||||
|
||||
while( i != obj->notify_pool.end() )
|
||||
{
|
||||
SendEmail(*i);
|
||||
|
||||
obj->Lock();
|
||||
i = obj->notify_pool.erase(i);
|
||||
obj->Unlock();
|
||||
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Notify::SendEmail(NotifyMsg & n)
|
||||
{
|
||||
TemplatesNotifyFunctions::notify_msg = &n;
|
||||
|
||||
obj->templates_notify.Generate();
|
||||
SendEmail(n.email, obj->templates_notify.notify_str.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Notify::SendEmail(const std::string & email, const std::string & message)
|
||||
{
|
||||
nlog.PutDate(log1);
|
||||
|
||||
if( !ValidateEmail(email) )
|
||||
{
|
||||
nlog << "Notify: email: " << email << " is not correct" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
obj->command = "sendmail " + email;
|
||||
FILE * sendmail = popen(obj->command.c_str(), "w");
|
||||
|
||||
if( !sendmail )
|
||||
{
|
||||
|
||||
nlog << "Notify: can't run sendmail" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
SendMessage(sendmail, message);
|
||||
pclose(sendmail);
|
||||
|
||||
nlog << "Notify: email to: " << email << " has been sent" << logend;
|
||||
}
|
||||
|
||||
|
||||
void Notify::SendMessage(FILE * sendmail, const std::string & message)
|
||||
{
|
||||
for(size_t i=0 ; i<message.length() ; ++i)
|
||||
{
|
||||
if( message[i] == '\n' )
|
||||
fprintf(sendmail, "\r\n");
|
||||
else
|
||||
fputc(message[i], sendmail);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
methods for main thread
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
Notify::Notify() : mutex(PTHREAD_MUTEX_INITIALIZER)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Notify::~Notify()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Notify::Init(const std::string & tdir)
|
||||
{
|
||||
templates_dir = tdir;
|
||||
|
||||
int t = pthread_create(&thread, 0, ThreadRoutine, (void*)this);
|
||||
|
||||
if( t != 0 )
|
||||
{
|
||||
// log (not nlog) here
|
||||
log << log1 << "Notify: can't create a thread" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Notify::Lock()
|
||||
{
|
||||
if( pthread_mutex_lock(&mutex) != 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Notify::Unlock()
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Notify::CreateItemDir(std::string & dir, bool clear)
|
||||
{
|
||||
if( clear )
|
||||
dir.clear();
|
||||
|
||||
for(size_t a=0 ; a<request.dir_table.size() ; ++a)
|
||||
{
|
||||
dir += request.dir_table[a]->url;
|
||||
dir += '/';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Notify::CreateItemLink(std::string & link)
|
||||
{
|
||||
link = data.base_url;
|
||||
CreateItemDir(link, false);
|
||||
link += request.item.url;
|
||||
}
|
||||
|
||||
|
||||
void Notify::ItemChanged(int notify_code)
|
||||
{
|
||||
bool sending;
|
||||
Users::Iterator i;
|
||||
|
||||
if( notify_code == 0 )
|
||||
return;
|
||||
|
||||
n.notify_code = notify_code;
|
||||
n.current_mount_type = data.mounts.CurrentMountType();
|
||||
n.doc_base_url = data.base_url;
|
||||
CreateItemDir(n.item_dir);
|
||||
CreateItemLink(n.item_link);
|
||||
|
||||
|
||||
Lock();
|
||||
|
||||
try
|
||||
{
|
||||
// don't clear notify_pool here -- it is used (and will be cleared) by the second thread
|
||||
|
||||
for(i=data.users.Begin() ; i != data.users.End() ; ++i)
|
||||
{
|
||||
sending = false;
|
||||
|
||||
if( data.mounts.CurrentMountType() == Mount::thread )
|
||||
{
|
||||
if( (i->thread_notify & notify_code) != 0 )
|
||||
sending = true;
|
||||
}
|
||||
else
|
||||
if( data.mounts.CurrentMountType() == Mount::cms )
|
||||
{
|
||||
if( (i->cms_notify & notify_code) != 0 )
|
||||
sending = true;
|
||||
}
|
||||
|
||||
if( sending )
|
||||
{
|
||||
n.email = i->email;
|
||||
notify_pool.insert(notify_pool.end(), n);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
Unlock();
|
||||
throw;
|
||||
}
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,76 +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 headerfilecmslunotify
|
||||
#define headerfilecmslunotify
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "../templatesnotify/templatesnotify.h"
|
||||
|
||||
|
||||
#define CMSLU_NOTIFY_ITEM_ADD 1
|
||||
#define CMSLU_NOTIFY_ITEM_EDIT 2
|
||||
#define CMSLU_NOTIFY_ITEM_DELETE 4
|
||||
#define CMSLU_NOTIFY_DIR_ADD 8
|
||||
|
||||
|
||||
|
||||
class Notify
|
||||
{
|
||||
public:
|
||||
|
||||
Notify();
|
||||
~Notify();
|
||||
|
||||
bool Init(const std::string & tdir);
|
||||
|
||||
/*
|
||||
this method added an item to our special pool
|
||||
the pool is used by a second thread
|
||||
*/
|
||||
void ItemChanged(int notify_code);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
static void * ThreadRoutine(void * arg);
|
||||
bool Lock();
|
||||
void Unlock();
|
||||
static void CheckQueue();
|
||||
static void SendEmail(NotifyMsg & n);
|
||||
static void SendEmail(const std::string & email);
|
||||
static void SendEmail(const std::string & email, const std::string & message);
|
||||
static void SendMessage(FILE * sendmail, const std::string & message);
|
||||
void CreateItemDir(std::string & dir, bool clear = true);
|
||||
void CreateItemLink(std::string & link);
|
||||
|
||||
pthread_t thread;
|
||||
pthread_mutex_t mutex;
|
||||
NotifyMsg n;
|
||||
|
||||
|
||||
/*
|
||||
objects accessed by the second thread
|
||||
*/
|
||||
std::list<NotifyMsg> notify_pool;
|
||||
static Notify * obj;
|
||||
std::string command;
|
||||
std::string templates_dir;
|
||||
TemplatesNotify templates_notify;
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern Notify notify;
|
||||
|
||||
|
||||
#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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorepostparser
|
||||
#define headerfilecmslucorepostparser
|
||||
|
||||
#include <fcgiapp.h>
|
||||
#include <string>
|
||||
#include "httpsimpleparser.h"
|
||||
#include "requesttypes.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class PostParser : public HttpSimpleParser
|
||||
{
|
||||
|
||||
FCGX_Stream * in;
|
||||
PostTable & post_table;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual int GetChar()
|
||||
{
|
||||
return FCGX_GetChar(in);
|
||||
}
|
||||
|
||||
|
||||
virtual void Parameter(std::string & name, std::string & value)
|
||||
{
|
||||
std::pair<PostTable::iterator, bool> res = post_table.insert( std::make_pair(name, value) );
|
||||
|
||||
log << log2 << "Method POST, name: \"" << name << "\", value: \"" << value << "\"";
|
||||
|
||||
if( res.second == false )
|
||||
log << log2 << " (skipped)";
|
||||
|
||||
log << log2 << logend;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
PostParser(FCGX_Stream * in_, PostTable & post_table_) : in(in_), post_table(post_table_)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
665
core/request.cpp
665
core/request.cpp
@@ -1,665 +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 "request.h"
|
||||
#include "getparser.h"
|
||||
#include "postparser.h"
|
||||
#include "cookieparser.h"
|
||||
#include "log.h"
|
||||
#include "data.h"
|
||||
|
||||
Request::Request() : char_empty(0)
|
||||
{
|
||||
id = 0;
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Request::Init()
|
||||
{
|
||||
compress.Init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Request::Clear()
|
||||
{
|
||||
// warning: don't clear: in, out, err, env
|
||||
|
||||
// id is never 0
|
||||
if( ++id == 0 )
|
||||
++id;
|
||||
|
||||
get_table.clear();
|
||||
post_table.clear();
|
||||
cookie_table.clear();
|
||||
|
||||
method = none;
|
||||
|
||||
headers.str("");
|
||||
page.str("");
|
||||
debug.str("");
|
||||
notify.str("");
|
||||
|
||||
env_request_method = &char_empty;
|
||||
env_request_uri = &char_empty;
|
||||
env_http_cookie = &char_empty;
|
||||
env_remote_addr = &char_empty;
|
||||
env_http_host = &char_empty;
|
||||
|
||||
|
||||
session = 0;
|
||||
|
||||
result = err404; // !! tutaj moze cos lepszego, cos w stylu 'not implemented'
|
||||
|
||||
// dir = -1;
|
||||
// cur_dir_table.clear();
|
||||
item_table.clear();
|
||||
// dir_table2.clear();
|
||||
|
||||
item.Clear();
|
||||
str.clear();
|
||||
|
||||
dir_table.clear();
|
||||
is_item = false;
|
||||
pfunction = 0;
|
||||
param_table.clear();
|
||||
|
||||
status = Error::ok;
|
||||
|
||||
is_thread = false;
|
||||
thread.Clear();
|
||||
|
||||
thread_tab.clear();
|
||||
|
||||
notify_code = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Request::CopyFirstItem()
|
||||
{
|
||||
if( !request.item_table.empty() )
|
||||
request.item = request.item_table[0];
|
||||
else
|
||||
{
|
||||
request.item.Clear();
|
||||
|
||||
log << log1 << "Request::CopyFirstItem: item_table is empty" << logend;
|
||||
request.result = err_internal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// value can be null
|
||||
void Request::SetCookie(const char * name, const char * value)
|
||||
{
|
||||
request.headers << "Set-Cookie: " << name << "=";
|
||||
|
||||
if( value && value[0]!=0 )
|
||||
request.headers << value;
|
||||
else
|
||||
request.headers << "\"\"";
|
||||
|
||||
request.headers << "; path=/\r\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Request::SetCookie(const char * name, long value)
|
||||
{
|
||||
request.headers << "Set-Cookie: " << name << "=" << value << "; path=/\r\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool Request::IsPostVar(const char * var)
|
||||
{
|
||||
PostTable::iterator p;
|
||||
|
||||
p = post_table.find(var);
|
||||
|
||||
if( p == post_table.end() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string & Request::PostVar(const char * var)
|
||||
{
|
||||
PostTable::iterator p;
|
||||
|
||||
p = post_table.find(var);
|
||||
|
||||
if( p == post_table.end() )
|
||||
{
|
||||
throw Error(Error::no_postvar);
|
||||
}
|
||||
|
||||
return p->second;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
bool Request::PostVar(const char * var, std::string & result)
|
||||
{
|
||||
PostTable::iterator p;
|
||||
|
||||
p = post_table.find(var);
|
||||
|
||||
if( p == post_table.end() )
|
||||
return false;
|
||||
|
||||
result = p->second;
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
void Request::PrintGetTable()
|
||||
{
|
||||
debug << "get_table: " << get_table.size() << "\n";
|
||||
|
||||
for(GetTable::iterator i = get_table.begin() ; i != get_table.end() ; ++i)
|
||||
debug << " \"" << *i << "\"\n";
|
||||
|
||||
debug << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void Request::PrintEnv()
|
||||
{
|
||||
char ** e;
|
||||
|
||||
debug << "environment variables:\n";
|
||||
|
||||
for( e = env ; *e ; ++e )
|
||||
debug << ' ' << *e << "\n";
|
||||
|
||||
debug << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Request::PrintIn()
|
||||
{
|
||||
char buf[100];
|
||||
int buf_len = sizeof(buf) / sizeof(char);
|
||||
int len;
|
||||
|
||||
debug << "fcgi input:\n";
|
||||
|
||||
do
|
||||
{
|
||||
len = FCGX_GetStr(buf, buf_len - 1, in);
|
||||
|
||||
if( len != 0 )
|
||||
{
|
||||
buf[len] = 0;
|
||||
debug << buf;
|
||||
}
|
||||
}
|
||||
while( len == buf_len - 1 );
|
||||
|
||||
debug << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * Request::SetEnvVar(const char * var)
|
||||
{
|
||||
const char * v = FCGX_GetParam(var, env);
|
||||
|
||||
if( v )
|
||||
return v;
|
||||
|
||||
// char_empty contains '\0'
|
||||
return &char_empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Request::ReadEnvVariables()
|
||||
{
|
||||
// we store that values because FCGX_GetParam has O(n) complexity
|
||||
// with this variables (env_*) we have O(1)
|
||||
|
||||
env_request_method = SetEnvVar("REQUEST_METHOD");
|
||||
env_request_uri = SetEnvVar("REQUEST_URI");
|
||||
env_http_cookie = SetEnvVar("HTTP_COOKIE");
|
||||
env_remote_addr = SetEnvVar("REMOTE_ADDR");
|
||||
env_http_host = SetEnvVar("HTTP_HOST");
|
||||
env_http_user_agent = SetEnvVar("HTTP_USER_AGENT");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Request::CheckMethod()
|
||||
{
|
||||
method = none;
|
||||
|
||||
if( env_request_method[0] == 'G' )
|
||||
method = get;
|
||||
else
|
||||
if( env_request_method[0] == 'P' )
|
||||
method = post;
|
||||
}
|
||||
|
||||
|
||||
void Request::ReadParameters()
|
||||
{
|
||||
// !!some parameters (get) we have always
|
||||
// if( method == get )
|
||||
{
|
||||
GetParser get_parser(env_request_uri, get_table);
|
||||
get_parser.Parse();
|
||||
}
|
||||
|
||||
if( method == post )
|
||||
{
|
||||
PostParser post_parser(in, post_table);
|
||||
post_parser.Parse();
|
||||
}
|
||||
|
||||
CookieParser cookie_parser(env_http_cookie, cookie_table);
|
||||
cookie_parser.Parse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Request::StandardLog()
|
||||
{
|
||||
log.PutDate(log1);
|
||||
log << env_remote_addr << ' ' << env_request_method << ' ' << env_request_uri << ' ' << env_http_user_agent << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// reading everything
|
||||
void Request::Read()
|
||||
{
|
||||
ReadEnvVariables();
|
||||
StandardLog();
|
||||
CheckMethod();
|
||||
ReadParameters();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Request::SendAll()
|
||||
{
|
||||
if( result == redirect )
|
||||
{
|
||||
FCGX_PutS("Status: 301 Moved Permanently\r\n", out);
|
||||
FCGX_FPrintF(out, "Location: %s\r\n", str.c_str());
|
||||
|
||||
log << log2 << "Redirect to: " << str << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
FCGX_PutS("Status: 200 OK\r\n", out);
|
||||
FCGX_PutS("Content-Type: Text/Html\r\n", out);
|
||||
}
|
||||
|
||||
if( data.compression )
|
||||
FCGX_PutS("Content-Encoding: deflate\r\n", out);
|
||||
|
||||
FCGX_PutS(headers.str().c_str(), out);
|
||||
FCGX_PutS("\r\n", out);
|
||||
|
||||
|
||||
if( result == redirect )
|
||||
// if there is a redirect we do not send a content
|
||||
return;
|
||||
//
|
||||
|
||||
const std::string & source = page.str();
|
||||
|
||||
if( !data.compression || compress.CompressAndPut(source.c_str(), source.length(), out) != 0 )
|
||||
{
|
||||
// there were problems during compressing, or we don't use compression at all
|
||||
FCGX_PutS(source.c_str(), out);
|
||||
}
|
||||
|
||||
const std::string & d = debug.str();
|
||||
|
||||
if( !d.empty() )
|
||||
{
|
||||
FCGX_PutS("\n<!--\n", out);
|
||||
FCGX_PutS(d.c_str(), out);
|
||||
FCGX_PutS("\n-->\n", out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool Request::IsParam(const char * s)
|
||||
{
|
||||
std::vector<std::string*>::iterator i;
|
||||
|
||||
for(i=param_table.begin() ; i!=param_table.end() ; ++i)
|
||||
{
|
||||
if( **i == s )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Request::CanChangeUser(const Item & item, long new_user_id)
|
||||
{
|
||||
if( !session )
|
||||
// session must be set
|
||||
return false;
|
||||
|
||||
if( session->puser && session->puser->super_user )
|
||||
// super user is allowed everything
|
||||
return true;
|
||||
|
||||
if( item.user_id != new_user_id )
|
||||
// only super user can change the owner of an item
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Request::CanChangeGroup(const Item & item, long new_group_id)
|
||||
{
|
||||
if( !session )
|
||||
// session must be set
|
||||
return false;
|
||||
|
||||
if( session->puser && session->puser->super_user )
|
||||
// super user is allowed everything
|
||||
return true;
|
||||
|
||||
if( item.group_id != new_group_id )
|
||||
{
|
||||
// user is allowed to change the group only if he is an owner of the item
|
||||
// he can change only into a group in which he is a member of, or into a 'no_group'
|
||||
|
||||
if( !session->puser )
|
||||
return false;
|
||||
|
||||
if( session->puser->id != item.user_id )
|
||||
return false;
|
||||
|
||||
if( new_group_id == -1 )
|
||||
return true;
|
||||
|
||||
if( !session->puser->IsMemberOf(new_group_id) )
|
||||
return false;
|
||||
|
||||
// is logged, is the owner of the item, is the member of the new group
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Request::CanChangePrivileges(const Item & item, int new_priv)
|
||||
{
|
||||
if( !session )
|
||||
// session must be set
|
||||
return false;
|
||||
|
||||
if( session->puser && session->puser->super_user )
|
||||
// super user is allowed everything
|
||||
return true;
|
||||
|
||||
if( item.privileges != new_priv )
|
||||
{
|
||||
// the owner of an item is allowed to change the privileges
|
||||
|
||||
if( !session->puser )
|
||||
return false;
|
||||
|
||||
if( session->puser->id != item.user_id )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Request::HasAccess(const Item & item, int mask)
|
||||
{
|
||||
if( !session )
|
||||
// session must be set
|
||||
return false;
|
||||
|
||||
if( session->puser && session->puser->super_user )
|
||||
// super user is allowed everything
|
||||
return true;
|
||||
|
||||
if( session->puser && session->puser->id == item.user_id )
|
||||
{
|
||||
// the owner
|
||||
return ((item.privileges >> 6) & mask) == mask;
|
||||
}
|
||||
|
||||
if( session->puser && session->puser->IsMemberOf(item.group_id) )
|
||||
{
|
||||
// group
|
||||
return ((item.privileges >> 3) & mask) == mask;
|
||||
}
|
||||
|
||||
// others
|
||||
|
||||
return (item.privileges & mask) == mask;
|
||||
}
|
||||
|
||||
|
||||
bool Request::HasReadAccess(const Item & item)
|
||||
{
|
||||
return HasAccess(item, 4);
|
||||
}
|
||||
|
||||
|
||||
bool Request::HasWriteAccess(const Item & item)
|
||||
{
|
||||
return HasAccess(item, 2);
|
||||
}
|
||||
|
||||
|
||||
bool Request::HasReadWriteAccess(const Item & item)
|
||||
{
|
||||
return HasAccess(item, 6); // r+w
|
||||
}
|
||||
|
||||
|
||||
bool Request::HasReadExecAccess(const Item & item)
|
||||
{
|
||||
if( session && session->puser && session->puser->super_user )
|
||||
{
|
||||
// there must be at least one 'x' (for the root)
|
||||
|
||||
return (item.privileges & 0111) != 0;
|
||||
}
|
||||
|
||||
return HasAccess(item, 5); // r+x
|
||||
}
|
||||
|
||||
|
||||
// returning true if we can create a thread in the current directory
|
||||
bool Request::CanCreateThread(bool check_root)
|
||||
{
|
||||
if( request.dir_table.empty() )
|
||||
return false;
|
||||
|
||||
if( request.is_item )
|
||||
return false;
|
||||
|
||||
if( !HasWriteAccess(*request.dir_table.back()) )
|
||||
return false;
|
||||
|
||||
if( data.mounts.CurrentMountType() != Mount::thread )
|
||||
return false;
|
||||
|
||||
if( !check_root && session && session->puser && session->puser->super_user )
|
||||
// super can create thread regardless of the restrictcreatethread option
|
||||
return true;
|
||||
|
||||
|
||||
// !! w przyszlosci mozna odczytywac wiecej parametrow od restrictcreatethread
|
||||
// tymczasowo wykorzystujemy tylko pierwszy
|
||||
int level;
|
||||
if( data.mounts.CurrentMountIsParam(Mount::restrictcreatethread, &level) )
|
||||
{
|
||||
if( level == -1 )
|
||||
return false;
|
||||
|
||||
// we can only allow on a specific level
|
||||
if( int(request.dir_table.size()) != level )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Request::CanRemove(const Item & item)
|
||||
{
|
||||
if( item.parent_id == -1 )
|
||||
{
|
||||
// rm for the root dir
|
||||
// only the superuser can do it
|
||||
if( !request.session->puser || !request.session->puser->super_user )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Item * last_but_one_dir = data.dirs.GetDir(item.parent_id);
|
||||
|
||||
if( !last_but_one_dir )
|
||||
// ops, there is no a parent dir
|
||||
return false;
|
||||
|
||||
if( !request.HasWriteAccess(*last_but_one_dir) )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( data.mounts.CurrentMountIsParam(Mount::only_root_can_remove) )
|
||||
// this can be deleted only be a root
|
||||
if( !request.session->puser || !request.session->puser->super_user )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Request::CanUseEmacs(const Item & item, bool check_root)
|
||||
{
|
||||
if( !check_root && request.session->puser && request.session->puser->super_user )
|
||||
// super user can use emacs everywhere
|
||||
return true;
|
||||
|
||||
if( !request.HasWriteAccess(item) )
|
||||
return false;
|
||||
|
||||
int level;
|
||||
if( data.mounts.CurrentMountIsParam(Mount::can_use_emacs_on, &level) )
|
||||
if( level != int(request.dir_table.size()) )
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Request::CanUseMkdir(const Item & item, bool check_root)
|
||||
{
|
||||
// you can create a directory only in a directory
|
||||
if( item.type != Item::dir )
|
||||
return false;
|
||||
|
||||
if( !check_root && request.session->puser && request.session->puser->super_user )
|
||||
// super user can use mkdir everywhere
|
||||
return true;
|
||||
|
||||
if( !request.HasWriteAccess(item) )
|
||||
return false;
|
||||
|
||||
int level;
|
||||
if( data.mounts.CurrentMountIsParam(Mount::can_use_mkdir_on, &level) )
|
||||
if( level != int(request.dir_table.size()) )
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Request::CanUseHtml(long user_id)
|
||||
{
|
||||
User * puser = data.users.GetUser(user_id);
|
||||
|
||||
if( !puser )
|
||||
return false;
|
||||
|
||||
if( puser->super_user )
|
||||
// super user can use html
|
||||
return true;
|
||||
|
||||
long group = data.groups.GetGroupId("allow_html");
|
||||
|
||||
if( group == -1 )
|
||||
// there is no such a group
|
||||
return false;
|
||||
|
||||
if( puser->IsMemberOf(group) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Request::CanUseBBCode(long user_id)
|
||||
{
|
||||
User * puser = data.users.GetUser(user_id);
|
||||
|
||||
if( !puser )
|
||||
return false;
|
||||
|
||||
if( puser->super_user )
|
||||
// super user can use bbcode
|
||||
return true;
|
||||
|
||||
long group = data.groups.GetGroupId("allow_bbcode");
|
||||
|
||||
if( group == -1 )
|
||||
// there is no such a group
|
||||
return false;
|
||||
|
||||
if( puser->IsMemberOf(group) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
196
core/request.h
196
core/request.h
@@ -1,196 +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 headerfilecmslucorerequest
|
||||
#define headerfilecmslucorerequest
|
||||
|
||||
#include <fcgiapp.h>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <iomanip>
|
||||
|
||||
#include "requesttypes.h"
|
||||
#include "session.h"
|
||||
#include "item.h"
|
||||
#include "error.h"
|
||||
#include "function.h"
|
||||
#include "thread.h"
|
||||
#include "compress.h"
|
||||
|
||||
|
||||
|
||||
struct Request
|
||||
{
|
||||
// request id
|
||||
// is incremented for each request and is never 0
|
||||
// (from -1 will be incremented twice)
|
||||
// it's used for some optimalization e.g. in templates
|
||||
size_t id;
|
||||
|
||||
|
||||
FCGX_Stream * in, * out, * err;
|
||||
FCGX_ParamArray env; // defined as 'char **'
|
||||
|
||||
|
||||
enum Method { get, post, none } method;
|
||||
|
||||
|
||||
// headers, page and debug
|
||||
// notify (for mailing)
|
||||
std::ostringstream headers, page, debug, notify;
|
||||
|
||||
|
||||
GetTable get_table;
|
||||
PostTable post_table;
|
||||
CookieTable cookie_table;
|
||||
|
||||
// environment variables
|
||||
// they are not null -- when the server doesn't have such a variable it will be pointing into 'char_empty' which is default '\0'
|
||||
const char * env_request_method;
|
||||
const char * env_request_uri;
|
||||
const char * env_http_cookie;
|
||||
const char * env_remote_addr;
|
||||
const char * env_http_host;
|
||||
const char * env_http_user_agent;
|
||||
|
||||
// current session
|
||||
// is set after calling session_manager.SetSession()
|
||||
Session * session;
|
||||
|
||||
|
||||
// 'done_status' is set if 'done' is different than 'nothing'
|
||||
Error done_status; // !! wywalic - jest przeciez w session
|
||||
|
||||
// what to do
|
||||
// !! wywalic?
|
||||
enum Result { err_internal, err404, err_per_denied, show_dir, show_item, show_item_by_id, add_item, edit_item, del_item, del_item_confirm, confirm, redirect, logout } result; // zamienic na to_do
|
||||
|
||||
|
||||
|
||||
// !! nowe skladowe
|
||||
|
||||
// current directory
|
||||
// !! zapewnic aby byl minimum jeden katalog (root)
|
||||
|
||||
// !! moze nazwac to poprostu dir?
|
||||
std::vector<Item*> dir_table;
|
||||
|
||||
bool is_item;
|
||||
|
||||
// this item is used for many purposes such as editing, adding an item etc.
|
||||
Item item;
|
||||
|
||||
// null if there is no a function
|
||||
Function * pfunction;
|
||||
|
||||
// !! moze nazwac to poprostu param?
|
||||
std::vector<std::string*> param_table;
|
||||
|
||||
Error status;
|
||||
|
||||
// last notify
|
||||
int notify_code;
|
||||
|
||||
|
||||
// ------------------
|
||||
|
||||
// !! stare skladowe
|
||||
// current directory e.g. /foo/bar
|
||||
//std::vector<Item> cur_dir_table;
|
||||
// id of the last directory (bar) or -1
|
||||
//long dir;
|
||||
|
||||
// ------------------
|
||||
|
||||
// items in the current directory
|
||||
// maybe without contents?
|
||||
std::vector<Item> item_table;
|
||||
|
||||
// directories in the current directory
|
||||
//std::vector<Item> dir_table2;
|
||||
|
||||
// current thread (if exists)
|
||||
|
||||
bool is_thread;
|
||||
Thread thread;
|
||||
|
||||
std::vector<Thread> thread_tab;
|
||||
|
||||
// this string is used for many purposes such as redirecting
|
||||
std::string str;
|
||||
|
||||
// for debugging
|
||||
void PrintGetTable();
|
||||
void PrintEnv();
|
||||
void PrintIn();
|
||||
|
||||
Request();
|
||||
void Clear();
|
||||
|
||||
void Init();
|
||||
|
||||
bool IsParam(const char * s);
|
||||
|
||||
void SetCookie(const char * name, const char * value);
|
||||
void SetCookie(const char * name, long value);
|
||||
|
||||
bool IsPostVar(const char * var);
|
||||
std::string & PostVar(const char * var); // with a throw !!! wywalic te wyjatki ztad, niech zwraca pusty string jak nie znajdzie nic, albo referencje na jakis statyczny pusty string
|
||||
//bool PostVar(const char * var, std::string & result);
|
||||
|
||||
// item_table[0] -> item
|
||||
// !! to tez nie bedzie potrzebne
|
||||
void CopyFirstItem();
|
||||
|
||||
|
||||
void ReadEnvVariables();
|
||||
void CheckMethod();
|
||||
void ReadParameters();
|
||||
void Read();
|
||||
void SendAll();
|
||||
void SendNotify();
|
||||
|
||||
bool CanChangeUser(const Item & item, long new_user_id);
|
||||
bool CanChangeGroup(const Item & item, long new_group_id);
|
||||
bool CanChangePrivileges(const Item & item, int new_priv);
|
||||
|
||||
bool HasAccess(const Item & item, int mask);
|
||||
bool HasReadAccess(const Item & item);
|
||||
bool HasWriteAccess(const Item & item);
|
||||
bool HasReadWriteAccess(const Item & item);
|
||||
bool HasReadExecAccess(const Item & item);
|
||||
|
||||
bool CanCreateThread(bool check_root = false);
|
||||
bool CanRemove(const Item & item);
|
||||
bool CanUseEmacs(const Item & item, bool check_root = false);
|
||||
bool CanUseMkdir(const Item & item, bool check_root = false);
|
||||
|
||||
bool CanUseHtml(long user_id);
|
||||
bool CanUseBBCode(long user_id);
|
||||
|
||||
private:
|
||||
// used to set some env_* variables into it, when the server didn't set that variable
|
||||
// it contains '\0'
|
||||
const char char_empty;
|
||||
|
||||
const char * SetEnvVar(const char * var);
|
||||
|
||||
void StandardLog();
|
||||
|
||||
Compress compress;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern Request request;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,205 +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 "requestcontroller.h"
|
||||
#include "data.h"
|
||||
#include "log.h"
|
||||
#include "request.h"
|
||||
#include "postparser.h"
|
||||
#include "cookieparser.h"
|
||||
#include "notify.h"
|
||||
|
||||
|
||||
|
||||
RequestController::RequestController()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RequestController::~RequestController()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
void RequestController::Close()
|
||||
{
|
||||
// don't call close(0)
|
||||
// it will be closed next time during dup(s,0)
|
||||
|
||||
// if you closed the descriptor here
|
||||
// then the database would have that descriptor (during connecting)
|
||||
// and there'll be a problem in the next loop (after SIGHUP)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool RequestController::Init()
|
||||
{
|
||||
const char * sock = data.fcgi_socket.c_str();
|
||||
|
||||
unlink(sock);
|
||||
|
||||
|
||||
|
||||
int s = FCGX_OpenSocket(sock, 10);
|
||||
|
||||
if( s < 0 )
|
||||
{
|
||||
log << log1 << "An error during creating a socket" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
chmod(sock, data.fcgi_socket_chmod);
|
||||
|
||||
passwd * pw = getpwnam(data.fcgi_socket_user.c_str());
|
||||
|
||||
if( !pw )
|
||||
{
|
||||
log << log1 << "There is no user: " << data.fcgi_socket_user << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
group * gr = getgrnam(data.fcgi_socket_group.c_str());
|
||||
|
||||
if( !gr )
|
||||
{
|
||||
log << log1 << "There is no group: " << data.fcgi_socket_group << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
chown(sock, pw->pw_uid, gr->gr_gid);
|
||||
|
||||
|
||||
|
||||
if( setuid(pw->pw_uid) < 0 )
|
||||
{
|
||||
log << log1 << "I can't change the user into: " << data.fcgi_socket_user << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if( setgid(gr->gr_gid) < 0 )
|
||||
{
|
||||
int e = errno;
|
||||
|
||||
log << log1 << "I can't change the group into: " << data.fcgi_socket_group << " " << gr->gr_gid << logend;
|
||||
log << log1 << "errno: " << e << logend;
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
dup2(s, 0);
|
||||
|
||||
//
|
||||
data.dirs.ReadDirs();
|
||||
data.users.ReadUsers();
|
||||
data.groups.ReadGroups();
|
||||
data.functions.ReadFunctions();
|
||||
data.mounts.ReadMounts();
|
||||
//
|
||||
|
||||
|
||||
|
||||
if( !content.Init() )
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RequestController::BaseUrlRedirect()
|
||||
{
|
||||
if( data.base_url_http_host.empty() )
|
||||
return false;
|
||||
|
||||
if( data.base_url_http_host == request.env_http_host )
|
||||
return false;
|
||||
|
||||
request.result = Request::redirect;
|
||||
request.str = data.base_url + request.env_request_uri;
|
||||
|
||||
log << log3 << "RC: BaseUrlRedirect from: " << request.env_http_host << logend;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RequestController::Loop()
|
||||
{
|
||||
while( FCGX_Accept(&request.in, &request.out, &request.err, &request.env) == 0 )
|
||||
{
|
||||
log << log2 << "---------------------------------------------------------------------------------" << logend;
|
||||
|
||||
try
|
||||
{
|
||||
request.Clear();
|
||||
request.Read();
|
||||
|
||||
// when BaseUrlRedirect() return true we didn't have to set everything in request.Read()
|
||||
// in the future request.Read() can be split and at the beginning only environment variables will be read
|
||||
// and then BaseUrlRedirect() will be called (for performance)
|
||||
if( !BaseUrlRedirect() )
|
||||
{
|
||||
session_manager.DeleteOldSessions();
|
||||
session_manager.SetSession(); // set request.session as well
|
||||
request.session->CheckTimers();
|
||||
|
||||
function_parser.Parse();
|
||||
data.mounts.CalculateCurrentMountType();
|
||||
|
||||
content.ReadAdditionalInfo();
|
||||
content.Make();
|
||||
}
|
||||
|
||||
request.SendAll();
|
||||
notify.ItemChanged(request.notify_code);
|
||||
}
|
||||
catch(const std::exception & e)
|
||||
{
|
||||
log << log1 << "uncaught std exception: " << e.what() << logend;
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
log << log1 << "uncaught exception: Error: " << e << logend;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
log << log1 << "uncaught exception" << logend;
|
||||
}
|
||||
|
||||
|
||||
// !! this should be immediately after FCGX_Accept() but signals don't want to break FCGX_Accept
|
||||
if( data.signal_hup )
|
||||
{
|
||||
FCGX_Finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
SessionContainer::Iterator RequestController::SessionBegin()
|
||||
{
|
||||
return session_manager.SessionBegin();
|
||||
}
|
||||
|
||||
|
||||
SessionContainer::Iterator RequestController::SessionEnd()
|
||||
{
|
||||
return session_manager.SessionEnd();
|
||||
}
|
||||
@@ -1,54 +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 headerfilecmslucorerequestcontroller
|
||||
#define headerfilecmslucorerequestcontroller
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <iostream>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../content/content.h"
|
||||
#include "sessionmanager.h"
|
||||
#include "functionparser.h"
|
||||
#include "sessioncontainer.h"
|
||||
|
||||
|
||||
class RequestController
|
||||
{
|
||||
Content content;
|
||||
SessionManager session_manager;
|
||||
|
||||
bool BaseUrlRedirect();
|
||||
|
||||
FunctionParser function_parser;
|
||||
|
||||
public:
|
||||
|
||||
RequestController();
|
||||
~RequestController();
|
||||
|
||||
bool Init();
|
||||
void Close();
|
||||
void Loop();
|
||||
|
||||
|
||||
SessionContainer::Iterator SessionBegin();
|
||||
SessionContainer::Iterator SessionEnd();
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern RequestController req_controller;
|
||||
|
||||
#endif
|
||||
@@ -1,26 +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 headerfilecmslucorerequesttypes
|
||||
#define headerfilecmslucorerequesttypes
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
||||
// some global types used by Request class
|
||||
typedef std::vector<std::string> GetTable;
|
||||
typedef std::map<std::string, std::string> PostTable;
|
||||
typedef std::map<std::string, std::string> CookieTable;
|
||||
|
||||
|
||||
|
||||
|
||||
#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 "session.h"
|
||||
|
||||
|
||||
|
||||
Session::Session()
|
||||
{
|
||||
Clear();
|
||||
|
||||
time = std::time(0);
|
||||
tm_time = *std::localtime(&time);
|
||||
|
||||
last_time = time;
|
||||
tm_last_time = tm_time;
|
||||
}
|
||||
|
||||
|
||||
void Session::Clear()
|
||||
{
|
||||
id = 0;
|
||||
time = 0;
|
||||
puser = 0;
|
||||
done = Done::none;
|
||||
done_status = Error::ok;
|
||||
item.Clear();
|
||||
done_timer = 0;
|
||||
|
||||
dir_old.clear();
|
||||
}
|
||||
|
||||
|
||||
bool Session::operator==(const Session & s) const
|
||||
{
|
||||
return id == s.id;
|
||||
}
|
||||
|
||||
|
||||
bool Session::operator<(const Session & s) const
|
||||
{
|
||||
return id < s.id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Session::DecTimer(int & timer)
|
||||
{
|
||||
if( timer == 0 )
|
||||
return false;
|
||||
|
||||
--timer;
|
||||
|
||||
if( timer == 0 )
|
||||
return true; // we must clear our variables
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Session::CheckTimers()
|
||||
{
|
||||
if( DecTimer(done_timer) )
|
||||
{
|
||||
done = Done::none;
|
||||
done_status = Error::ok;
|
||||
}
|
||||
}
|
||||
|
||||
void Session::IncrementTimersIfExist()
|
||||
{
|
||||
if( done_timer != 0 )
|
||||
++done_timer;
|
||||
}
|
||||
@@ -1,73 +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 headerfilecmslucoresession
|
||||
#define headerfilecmslucoresession
|
||||
|
||||
#include <ctime>
|
||||
#include "done.h"
|
||||
#include "item.h"
|
||||
#include "error.h"
|
||||
#include "user.h"
|
||||
|
||||
|
||||
|
||||
struct Session
|
||||
{
|
||||
// 0 - means that there is no session
|
||||
long id;
|
||||
|
||||
// when this session was created
|
||||
// (the same values)
|
||||
time_t time;
|
||||
tm tm_time;
|
||||
|
||||
// when this session was last used
|
||||
// (the same values)
|
||||
time_t last_time;
|
||||
tm tm_last_time;
|
||||
|
||||
|
||||
// 0 - means that nobody is logged
|
||||
User * puser;
|
||||
|
||||
// what is done
|
||||
Done done;
|
||||
Error done_status;
|
||||
|
||||
int done_timer;
|
||||
|
||||
|
||||
// used for many purposes, depending on 'done'
|
||||
Item item;
|
||||
|
||||
|
||||
std::string dir_old;
|
||||
|
||||
// -------------------
|
||||
|
||||
Session();
|
||||
virtual void Clear();
|
||||
bool operator==(const Session & s) const;
|
||||
bool operator<(const Session & s) const;
|
||||
bool DecTimer(int & timer);
|
||||
void CheckTimers();
|
||||
void IncrementTimersIfExist();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,144 +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 "sessioncontainer.h"
|
||||
#include "data.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
void SessionContainer::Clear()
|
||||
{
|
||||
table.clear();
|
||||
index_id.clear();
|
||||
index_time.clear();
|
||||
}
|
||||
|
||||
|
||||
SessionContainer::Iterator SessionContainer::Begin()
|
||||
{
|
||||
return table.begin();
|
||||
}
|
||||
|
||||
|
||||
SessionContainer::Iterator SessionContainer::End()
|
||||
{
|
||||
return table.end();
|
||||
}
|
||||
|
||||
|
||||
Session & SessionContainer::Back()
|
||||
{
|
||||
return table.back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool SessionContainer::PushBack(const Session & session)
|
||||
{
|
||||
if( index_id.find(session.id) != index_id.end() )
|
||||
// that element already exists
|
||||
return false;
|
||||
|
||||
Iterator last = table.insert(table.end(), session);
|
||||
index_id.insert( std::make_pair(session.id, last) );
|
||||
index_time.insert( std::make_pair(session.last_time, last) );
|
||||
|
||||
log << log3 << "SC: added session, id: " << session.id << logend;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SessionContainer::Iterator SessionContainer::FindById(long id)
|
||||
{
|
||||
IndexId::iterator i;
|
||||
|
||||
i = index_id.find(id);
|
||||
|
||||
if( i == index_id.end() )
|
||||
return table.end();
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionContainer::DelFirstByTimeInterval(time_t interval)
|
||||
{
|
||||
IndexTime::iterator i = index_time.begin();
|
||||
IndexTime::iterator iold;
|
||||
time_t limit = std::time(0) - interval;
|
||||
|
||||
for( ; i != index_time.end() && i->second->last_time < limit ; )
|
||||
{
|
||||
long id = i->second->id;
|
||||
iold = i;
|
||||
++i; // incrementing before deleting old one
|
||||
|
||||
if( iold->second->puser )
|
||||
data.last.UserLogout(iold->second->puser->id, iold->second->id);
|
||||
|
||||
// we're logging session.id (call this before table.erase())
|
||||
DelFromIdIndex(iold->second);
|
||||
|
||||
table.erase(iold->second);
|
||||
index_time.erase(iold);
|
||||
|
||||
log << log3 << "SC: deleted index_time for session id: " << id << logend;
|
||||
log << log3 << "SC: deleted session, id: " << id << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SessionContainer::DelFromIdIndex(SessionContainer::Iterator iter)
|
||||
{
|
||||
IndexId::iterator i;
|
||||
|
||||
for( i = index_id.begin() ; i!=index_id.end() ; ++i)
|
||||
{
|
||||
if( i->second == iter )
|
||||
{
|
||||
index_id.erase(i);
|
||||
log << log3 << "SC: deleted index_id for session id: " << iter->id << logend;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SessionContainer::UpdateLastTime(SessionContainer::Iterator iter, time_t new_time)
|
||||
{
|
||||
IndexTime::iterator i = index_time.lower_bound(iter->last_time);
|
||||
bool found = false;
|
||||
|
||||
for( ; i != index_time.end() ; ++i)
|
||||
{
|
||||
if( i->second == iter )
|
||||
{
|
||||
index_time.erase(i);
|
||||
index_time.insert( std::make_pair(new_time, iter) );
|
||||
|
||||
iter->last_time = new_time;
|
||||
iter->tm_last_time = *std::localtime(&new_time);
|
||||
|
||||
log << log3 << "SC: last time and the time index for session id: " << iter->id << " updated" << logend;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( !found )
|
||||
log << log1 << "SC: cannot update the time, time index not found for session id: " << iter->id << logend;
|
||||
}
|
||||
@@ -1,60 +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 headerfilecmslucoresessioncontainer
|
||||
#define headerfilecmslucoresessioncontainer
|
||||
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <ctime>
|
||||
|
||||
#include "session.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class SessionContainer
|
||||
{
|
||||
public:
|
||||
typedef std::list<Session> Table;
|
||||
typedef Table::iterator Iterator;
|
||||
|
||||
typedef std::map<long, Iterator> IndexId;
|
||||
typedef std::multimap<time_t, Iterator> IndexTime;
|
||||
|
||||
private:
|
||||
|
||||
Table table;
|
||||
IndexId index_id;
|
||||
IndexTime index_time;
|
||||
|
||||
void DelFromIdIndex(Iterator iter);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
void Clear();
|
||||
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
|
||||
Session & Back();
|
||||
|
||||
bool PushBack(const Session & session);
|
||||
Iterator FindById(long);
|
||||
|
||||
void DelFirstByTimeInterval(time_t interval);
|
||||
|
||||
void UpdateLastTime(Iterator iter, time_t new_time);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,174 +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 "sessionmanager.h"
|
||||
#include "request.h"
|
||||
#include "log.h"
|
||||
#include "data.h"
|
||||
#include "session.h"
|
||||
|
||||
|
||||
|
||||
bool SessionManager::IsSession(long id)
|
||||
{
|
||||
if( session_table.FindById(id) == session_table.End() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
long SessionManager::CreateSessionId()
|
||||
{
|
||||
long id;
|
||||
|
||||
// make sure to call std::srand() somewhere at the beginning
|
||||
// id must be != 0 (0 is reserved)
|
||||
do
|
||||
{
|
||||
if( sizeof(long) == 8 )
|
||||
{
|
||||
id = ((unsigned long)std::rand()) << 32 + std::rand();
|
||||
}
|
||||
else
|
||||
{
|
||||
id = std::rand();
|
||||
}
|
||||
|
||||
id += std::time(0);
|
||||
|
||||
if( id < 0 )
|
||||
id = -id;
|
||||
|
||||
}
|
||||
while( id == 0 ); // 0 reserved for a temporary session
|
||||
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
void SessionManager::CreateTemporarySession()
|
||||
{
|
||||
SessionContainer::Iterator i = session_table.FindById( 0 );
|
||||
|
||||
if( i == session_table.End() )
|
||||
{
|
||||
Session s;
|
||||
s.id = 0;
|
||||
|
||||
session_table.PushBack(s);
|
||||
request.session = &session_table.Back();
|
||||
}
|
||||
else
|
||||
{
|
||||
request.session = &(*i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SessionManager::CreateSession()
|
||||
{
|
||||
Session s;
|
||||
int attempts = 100;
|
||||
|
||||
for( ; attempts > 0 ; --attempts )
|
||||
{
|
||||
s.id = CreateSessionId();
|
||||
|
||||
bool added = session_table.PushBack(s);
|
||||
|
||||
if( added )
|
||||
{
|
||||
request.session = &session_table.Back();
|
||||
request.SetCookie(data.http_session_id_name.c_str(), request.session->id);
|
||||
log << log2 << "SM: created a new session: " << request.session->id << logend;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// there is a problem with generating a new session id
|
||||
// we do not set a session cookie
|
||||
CreateTemporarySession();
|
||||
log << log1 << "SM: cannot create a session id (temporary used: with id 0)" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionManager::SetSession()
|
||||
{
|
||||
CookieTable::iterator i = request.cookie_table.find(data.http_session_id_name);
|
||||
|
||||
if( i == request.cookie_table.end() )
|
||||
{
|
||||
CreateSession();
|
||||
}
|
||||
else
|
||||
{
|
||||
long id = atol(i->second.c_str());
|
||||
SessionContainer::Iterator s = session_table.FindById(id);
|
||||
|
||||
if( s != session_table.End() )
|
||||
{
|
||||
// that session is in the table
|
||||
request.session = &(*s);
|
||||
|
||||
session_table.UpdateLastTime(s, std::time(0));
|
||||
|
||||
log << log2 << "SM: session: " << s->id;
|
||||
|
||||
if( request.session->puser )
|
||||
log << log2 << ", user: " << request.session->puser->name << ", id: " << request.session->puser->id;
|
||||
|
||||
log << log2 << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is no such a session
|
||||
// deleting the old cookie
|
||||
request.cookie_table.erase(i);
|
||||
|
||||
// and creating a new one
|
||||
CreateSession();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// request.session is set now
|
||||
}
|
||||
|
||||
|
||||
|
||||
SessionContainer::Iterator SessionManager::SessionBegin()
|
||||
{
|
||||
return session_table.Begin();
|
||||
}
|
||||
|
||||
SessionContainer::Iterator SessionManager::SessionEnd()
|
||||
{
|
||||
return session_table.End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SessionManager::DeleteOldSessions()
|
||||
{
|
||||
session_table.DelFirstByTimeInterval(data.session_max_iddle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,43 +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 headerfilecmslucoresessionmanager
|
||||
#define headerfilecmslucoresessionmanager
|
||||
|
||||
#include <set>
|
||||
#include <ctime>
|
||||
|
||||
#include "sessioncontainer.h"
|
||||
|
||||
|
||||
|
||||
class SessionManager
|
||||
{
|
||||
SessionContainer session_table;
|
||||
|
||||
|
||||
|
||||
bool IsSession(long s);
|
||||
|
||||
long CreateSessionId();
|
||||
void CreateTemporarySession();
|
||||
void CreateSession();
|
||||
|
||||
public:
|
||||
|
||||
|
||||
void SetSession();
|
||||
void DeleteOldSessions();
|
||||
|
||||
SessionContainer::Iterator SessionBegin();
|
||||
SessionContainer::Iterator SessionEnd();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2009, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorecorethread
|
||||
#define headerfilecmslucorecorethread
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
class Thread
|
||||
{
|
||||
public:
|
||||
|
||||
long id;
|
||||
|
||||
// !! parent_id potrzebne w ogole jest?
|
||||
long parent_id;
|
||||
|
||||
long dir_id;
|
||||
bool closed;
|
||||
|
||||
// how many items there are inside
|
||||
long items;
|
||||
|
||||
// last item in the directory (this variable is mainly for reading)
|
||||
// at the moment only used: id, date_modification, user_id
|
||||
Item last_item;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
id = parent_id = dir_id = -1;
|
||||
last_item.Clear();
|
||||
closed = false;
|
||||
items = 0;
|
||||
}
|
||||
|
||||
Thread()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,192 +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 headerfilecmslucoreugcontainer
|
||||
#define headerfilecmslucoreugcontainer
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
class UGContainer
|
||||
{
|
||||
|
||||
public:
|
||||
typedef typename std::vector<Type> Table;
|
||||
typedef typename Table::iterator Iterator;
|
||||
typedef typename Table::size_type SizeType;
|
||||
|
||||
typedef typename std::map<long, SizeType> TableId;
|
||||
typedef typename std::map<std::string, SizeType> TableName;
|
||||
|
||||
|
||||
UGContainer();
|
||||
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
bool Empty();
|
||||
Iterator PushBack(const Type & type);
|
||||
void Clear();
|
||||
|
||||
Iterator FindId(long id);
|
||||
Iterator FindName(const std::string & name);
|
||||
|
||||
Type & operator[](SizeType pos);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void AddIndexes(SizeType pos);
|
||||
void RebuildIndexes();
|
||||
|
||||
// main table
|
||||
Table table;
|
||||
|
||||
// indexes
|
||||
TableId table_id;
|
||||
TableName table_name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
UGContainer<Type>::UGContainer() // : table(100)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename UGContainer<Type>::Iterator UGContainer<Type>::Begin()
|
||||
{
|
||||
return table.begin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename UGContainer<Type>::Iterator UGContainer<Type>::End()
|
||||
{
|
||||
return table.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename UGContainer<Type>::SizeType UGContainer<Type>::Size()
|
||||
{
|
||||
return table.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool UGContainer<Type>::Empty()
|
||||
{
|
||||
return table.empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename UGContainer<Type>::Iterator UGContainer<Type>::PushBack(const Type & type)
|
||||
{
|
||||
table.push_back(type);
|
||||
log << log2 << "UGCont: added, id: " << type.id << ", name: " << type.name << logend;
|
||||
|
||||
AddIndexes( table.size() - 1 );
|
||||
|
||||
return --table.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
void UGContainer<Type>::Clear()
|
||||
{
|
||||
table.clear();
|
||||
table_id.clear();
|
||||
table_name.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename UGContainer<Type>::Iterator UGContainer<Type>::FindId(long id)
|
||||
{
|
||||
typename TableId::iterator i = table_id.find(id);
|
||||
|
||||
if( i == table_id.end() )
|
||||
return table.end();
|
||||
|
||||
return table.begin() + i->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename UGContainer<Type>::Iterator UGContainer<Type>::FindName(const std::string & name)
|
||||
{
|
||||
typename TableName::iterator i = table_name.find(name);
|
||||
|
||||
if( i == table_name.end() )
|
||||
return table.end();
|
||||
|
||||
return table.begin() + i->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
void UGContainer<Type>::AddIndexes(UGContainer<Type>::SizeType pos)
|
||||
{
|
||||
table_id.insert( std::make_pair(table[pos].id, pos) );
|
||||
table_name.insert( std::make_pair(table[pos].name, pos) );
|
||||
|
||||
log << log2 << "UGCont: added indexes to: id: " << table[pos].id << ", name: " << table[pos].name << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
void UGContainer<Type>::RebuildIndexes()
|
||||
{
|
||||
log << log2 << "UGCont: rebuilding indexes" << logend;
|
||||
|
||||
table_id.clear();
|
||||
table_name.clear();
|
||||
|
||||
SizeType i, len = table.size();
|
||||
|
||||
|
||||
for(i=0 ; i!=len ; ++i)
|
||||
AddIndexes( i );
|
||||
|
||||
log << log2 << "UGCont: indexes rebuilt, table.size: " << table.size() << ", table_id.size: "
|
||||
<< table_id.size() << ", table_name.size: " << table_name.size() << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type & UGContainer<Type>::operator[](UGContainer<Type>::SizeType pos)
|
||||
{
|
||||
if( pos >= table.size() )
|
||||
throw std::out_of_range("UGContainer: operator[]: index is out of range");
|
||||
|
||||
return table[pos];
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
62
core/user.h
62
core/user.h
@@ -1,62 +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 headerfilecmslucoreuser
|
||||
#define headerfilecmslucoreuser
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
struct User
|
||||
{
|
||||
long id;
|
||||
std::string name;
|
||||
bool super_user;
|
||||
std::vector<long> groups;
|
||||
std::string email;
|
||||
|
||||
int cms_notify;
|
||||
int thread_notify;
|
||||
|
||||
|
||||
|
||||
User()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void Clear()
|
||||
{
|
||||
id = -1;
|
||||
name.clear();
|
||||
super_user = false;
|
||||
groups.clear();
|
||||
email.clear();
|
||||
cms_notify = 0;
|
||||
thread_notify = 0;
|
||||
}
|
||||
|
||||
|
||||
bool IsMemberOf(long group)
|
||||
{
|
||||
std::vector<long>::iterator i;
|
||||
|
||||
for(i=groups.begin() ; i!=groups.end() ; ++i)
|
||||
if( *i == group )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
110
core/users.cpp
110
core/users.cpp
@@ -1,110 +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 "users.h"
|
||||
#include "db.h"
|
||||
|
||||
|
||||
|
||||
Users::Users()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Users::Clear()
|
||||
{
|
||||
table.Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Users::ReadUsers()
|
||||
{
|
||||
Clear();
|
||||
|
||||
db.GetUsers(table);
|
||||
}
|
||||
|
||||
|
||||
|
||||
User * Users::GetUser(long user_id)
|
||||
{
|
||||
Table::Iterator i = table.FindId(user_id);
|
||||
|
||||
if( i == table.End() )
|
||||
return 0;
|
||||
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
User * Users::GetUser(const std::string & name)
|
||||
{
|
||||
Table::Iterator i = table.FindName(name);
|
||||
|
||||
if( i == table.End() )
|
||||
return 0;
|
||||
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
long Users::GetUserId(const std::string & name)
|
||||
{
|
||||
User * puser = GetUser(name);
|
||||
|
||||
if( !puser )
|
||||
return -1;
|
||||
|
||||
return puser->id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Users::Iterator Users::Begin()
|
||||
{
|
||||
return table.Begin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Users::Iterator Users::End()
|
||||
{
|
||||
return table.End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Users::SizeType Users::Size()
|
||||
{
|
||||
return table.Size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
User & Users::operator[](Users::SizeType pos)
|
||||
{
|
||||
return table[pos];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
53
core/users.h
53
core/users.h
@@ -1,53 +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 headerfilecmslucoreusers
|
||||
#define headerfilecmslucoreusers
|
||||
|
||||
#include <map>
|
||||
#include "user.h"
|
||||
#include "ugcontainer.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class Users
|
||||
{
|
||||
|
||||
typedef UGContainer<User> Table;
|
||||
Table table;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
typedef Table::Iterator Iterator;
|
||||
typedef Table::SizeType SizeType;
|
||||
|
||||
|
||||
Users();
|
||||
void Clear();
|
||||
void ReadUsers();
|
||||
User * GetUser(long user_id);
|
||||
User * GetUser(const std::string & name);
|
||||
long GetUserId(const std::string & name);
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
User & operator[](SizeType pos);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,22 +0,0 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
|
||||
all: $(o)
|
||||
|
||||
|
||||
.SUFFIXES: .cpp .o
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) $<
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
makedepend $(DEPMACROS) -Y. -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
include Makefile.dep
|
||||
@@ -1,108 +0,0 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
dir.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
dir.o: ../app/templates.h ../core/request.h ../core/requesttypes.h
|
||||
dir.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
|
||||
dir.o: ../core/log.h ../core/user.h ../core/function.h ../core/thread.h
|
||||
dir.o: ../core/compress.h ../core/data.h ../core/dirs.h
|
||||
dir.o: ../core/dircontainer.h ../core/users.h ../core/ugcontainer.h
|
||||
dir.o: ../core/groups.h ../core/group.h ../core/functions.h
|
||||
dir.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h ../core/db.h
|
||||
dir.o: ../core/log.h ../core/misc.h
|
||||
doc.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
doc.o: ../app/templates.h ../core/data.h ../core/dirs.h ../core/item.h
|
||||
doc.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
doc.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h
|
||||
doc.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h
|
||||
doc.o: ../core/mounts.h ../core/mount.h ../core/request.h
|
||||
doc.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
doc.o: ../core/error.h ../core/thread.h ../core/compress.h ../core/misc.h
|
||||
done.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
done.o: ../app/templates.h ../core/request.h ../core/requesttypes.h
|
||||
done.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
|
||||
done.o: ../core/log.h ../core/user.h ../core/function.h ../core/thread.h
|
||||
done.o: ../core/compress.h ../core/misc.h
|
||||
item.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
item.o: ../app/templates.h ../core/data.h ../core/dirs.h ../core/item.h
|
||||
item.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
item.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h
|
||||
item.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h
|
||||
item.o: ../core/mounts.h ../core/mount.h ../core/request.h
|
||||
item.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
item.o: ../core/error.h ../core/thread.h ../core/compress.h ../core/misc.h
|
||||
last.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
last.o: ../app/templates.h ../core/lastcontainer.h ../core/data.h
|
||||
last.o: ../core/dirs.h ../core/item.h ../core/dircontainer.h ../core/users.h
|
||||
last.o: ../core/user.h ../core/ugcontainer.h ../core/log.h ../core/groups.h
|
||||
last.o: ../core/group.h ../core/functions.h ../core/function.h
|
||||
last.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
last.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
last.o: ../core/done.h ../core/error.h ../core/thread.h ../core/compress.h
|
||||
last.o: ../core/misc.h
|
||||
mount.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
mount.o: ../app/templates.h ../core/data.h ../core/dirs.h ../core/item.h
|
||||
mount.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
mount.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h
|
||||
mount.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h
|
||||
mount.o: ../core/mounts.h ../core/mount.h
|
||||
patterncacher.o: patterncacher.h ../core/item.h ../../ezc/src/ezc.h
|
||||
patterncacher.o: ../core/data.h ../core/dirs.h ../core/item.h
|
||||
patterncacher.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
patterncacher.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h
|
||||
patterncacher.o: ../core/group.h ../core/functions.h ../core/function.h
|
||||
patterncacher.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
patterncacher.o: ../core/log.h
|
||||
priv.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
priv.o: ../app/templates.h ../core/data.h ../core/dirs.h ../core/item.h
|
||||
priv.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
priv.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h
|
||||
priv.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h
|
||||
priv.o: ../core/mounts.h ../core/mount.h ../core/request.h
|
||||
priv.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
priv.o: ../core/error.h ../core/thread.h ../core/compress.h ../core/misc.h
|
||||
sys.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
sys.o: ../app/templates.h ../core/data.h ../core/dirs.h ../core/item.h
|
||||
sys.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
sys.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h
|
||||
sys.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h
|
||||
sys.o: ../core/mounts.h ../core/mount.h ../core/request.h
|
||||
sys.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
sys.o: ../core/error.h ../core/thread.h ../core/compress.h ../core/misc.h
|
||||
templates.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
templates.o: ../app/templates.h ../core/data.h ../core/dirs.h ../core/item.h
|
||||
templates.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
templates.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h
|
||||
templates.o: ../core/group.h ../core/functions.h ../core/function.h
|
||||
templates.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
templates.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
templates.o: ../core/done.h ../core/error.h ../core/thread.h
|
||||
templates.o: ../core/compress.h ../core/misc.h
|
||||
thread.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
thread.o: ../app/templates.h ../core/data.h ../core/dirs.h ../core/item.h
|
||||
thread.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
thread.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h
|
||||
thread.o: ../core/group.h ../core/functions.h ../core/function.h
|
||||
thread.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
thread.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
thread.o: ../core/done.h ../core/error.h ../core/thread.h ../core/compress.h
|
||||
thread.o: ../core/misc.h
|
||||
user.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
user.o: ../app/templates.h ../core/data.h ../core/dirs.h ../core/item.h
|
||||
user.o: ../core/dircontainer.h ../core/users.h ../core/user.h
|
||||
user.o: ../core/ugcontainer.h ../core/log.h ../core/groups.h ../core/group.h
|
||||
user.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h
|
||||
user.o: ../core/mounts.h ../core/mount.h ../core/request.h
|
||||
user.o: ../core/requesttypes.h ../core/session.h ../core/done.h
|
||||
user.o: ../core/error.h ../core/thread.h ../core/compress.h ../core/misc.h
|
||||
who.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h
|
||||
who.o: ../app/templates.h ../core/sessioncontainer.h ../core/session.h
|
||||
who.o: ../core/done.h ../core/item.h ../core/error.h ../core/log.h
|
||||
who.o: ../core/user.h ../core/requestcontroller.h ../content/content.h
|
||||
who.o: ../templates/templates.h ../core/thread.h ../core/sessionmanager.h
|
||||
who.o: ../core/sessioncontainer.h ../core/functionparser.h
|
||||
who.o: ../core/requesttypes.h ../app/content.h ../core/data.h ../core/dirs.h
|
||||
who.o: ../core/dircontainer.h ../core/users.h ../core/ugcontainer.h
|
||||
who.o: ../core/groups.h ../core/group.h ../core/functions.h
|
||||
who.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h
|
||||
who.o: ../core/mount.h ../core/request.h ../core/thread.h ../core/compress.h
|
||||
who.o: ../core/misc.h
|
||||
@@ -1 +0,0 @@
|
||||
o = dir.o doc.o done.o item.o last.o mount.o patterncacher.o priv.o sys.o templates.o thread.o user.o who.o
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user