Compare commits
458 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d7ece15f8 | |||
| 541597f355 | |||
| 5fe843d76b | |||
| 3191369ece | |||
| a4de11d69c | |||
| 4832c7db4b | |||
| be83d62f96 | |||
| 3fd2ef1da4 | |||
| d861384889 | |||
| cfd8e88e57 | |||
| 8169cb5a7e | |||
| 8c85cd7346 | |||
| 4e202833b2 | |||
| 4a163bd170 | |||
| 85fbc1b882 | |||
| 61810ff6f9 | |||
| 3a4a29f56d | |||
| 1fb7ece1b3 | |||
| f3879dd3a4 | |||
| 561014886f | |||
| a2b19547a3 | |||
| 93477091d1 | |||
| 64d3c62945 | |||
| 134e27f70a | |||
| 5205aa089b | |||
| b5b9655c1e | |||
| 173d0894fa | |||
| de6b050fb5 | |||
| 37da5e81c5 | |||
| ae8637d455 | |||
| 22a45697fa | |||
| 55462fca9f | |||
| 2799a66c16 | |||
| 9832b17fc2 | |||
| 8146f42492 | |||
| 9df146af3b | |||
| a7629f638f | |||
| e75918f5ed | |||
| 9698c25bc4 | |||
| bbe2bd48d8 | |||
| 0cc565ae80 | |||
| aa74d96fed | |||
| ac6ede6aef | |||
| 10e291bb39 | |||
| 7a25e333db | |||
| a9b9d0badf | |||
| a69e160f85 | |||
| 56d53a455d | |||
| 572afd360a | |||
| ec6f946b97 | |||
| acfd87e548 | |||
| aa228732e3 | |||
| 840c222190 | |||
| 4408957770 | |||
| 89814cbc2e | |||
| fdcefae264 | |||
| 0139919d14 | |||
| 9476bcc7b6 | |||
| 4625451c85 | |||
| 1e345f5010 | |||
| 31befcba44 | |||
| f6077da614 | |||
| 499db7e3eb | |||
| 50da49a3ed | |||
| 6afd5c637e | |||
| 31a6aac9d3 | |||
| 3c3660914f | |||
| cd0ae231dc | |||
| a8bc741883 | |||
| 05b3525863 | |||
| 337f563bd4 | |||
| c9fe09ebe3 | |||
| db1c63a350 | |||
| 7cc2dcd1fc | |||
| 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 |
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.cproject
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
winixd/winix
|
||||||
64
Makefile
64
Makefile
@@ -1,64 +0,0 @@
|
|||||||
# Makefile for GNU make
|
|
||||||
|
|
||||||
ifndef CXX
|
|
||||||
CXX = g++
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef CXXFLAGS
|
|
||||||
CXXFLAGS = -fPIC -Wall -pedantic -O2 -I/usr/local/include -I/home/tomek/roboczy/winix -I/home/tomek/roboczy/ezc/src -L/usr/local/lib -DEZC_USE_WINIX_LOGGER
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
export CXX
|
|
||||||
export CXXFLAGS
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
all: winix
|
|
||||||
|
|
||||||
winix: FORCE
|
|
||||||
@cd core ; $(MAKE) -e
|
|
||||||
@cd content ; $(MAKE) -e
|
|
||||||
@cd confparser ; $(MAKE) -e
|
|
||||||
@cd templates ; $(MAKE) -e
|
|
||||||
@cd templatesnotify ; $(MAKE) -e
|
|
||||||
@cd plugins/stats ; $(MAKE) -e
|
|
||||||
@cd ../ezc/src ; $(MAKE) -e
|
|
||||||
$(CXX) -shared -o winix.so $(CXXFLAGS) core/*.o content/*.o templates/*.o templatesnotify/*.o confparser/*.o ../ezc/src/ezc.a -lfcgi -lpq -lz -lpthread
|
|
||||||
@cd main ; $(MAKE) -e
|
|
||||||
# use the full path with winix.so
|
|
||||||
$(CXX) -o winix $(CXXFLAGS) main/*.o /home/tomek/roboczy/winix/winix.so
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
@cd plugins/stats ; $(MAKE) -e clean
|
|
||||||
@cd ../ezc/src ; $(MAKE) -e clean
|
|
||||||
@cd main ; $(MAKE) -e clean
|
|
||||||
rm -f winix.so
|
|
||||||
rm -f winix
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
@cd plugins/stats ; $(MAKE) -e depend
|
|
||||||
@cd ../ezc/src ; $(MAKE) -e depend
|
|
||||||
@cd main ; $(MAKE) -e depend
|
|
||||||
|
|
||||||
#install: all
|
|
||||||
# mkdir -p bin
|
|
||||||
# rm -f bin/winix.so
|
|
||||||
# rm -f bin/winix
|
|
||||||
# cp winix.so bin/
|
|
||||||
# cp winix bin/
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
include Makefile.o.dep
|
|
||||||
|
|
||||||
|
|
||||||
all: $(o)
|
|
||||||
|
|
||||||
|
|
||||||
.SUFFIXES: .cpp .o
|
|
||||||
|
|
||||||
.cpp.o:
|
|
||||||
$(CXX) -c $(CXXFLAGS) $<
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
depend:
|
|
||||||
makedepend -Y. -I.. -I../../ezc/src -f- *.cpp > Makefile.dep
|
|
||||||
echo -n "o = " > Makefile.o.dep
|
|
||||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
|
||||||
|
|
||||||
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,379 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "confparser.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ConfParser::ConfParser()
|
|
||||||
{
|
|
||||||
// you can change this separators to what you want
|
|
||||||
// you shoud not use only white characters here (as expected by IsWhite() method)
|
|
||||||
// and new line characters ('\n')
|
|
||||||
separator = '=';
|
|
||||||
commentary = '#';
|
|
||||||
list_start = '(';
|
|
||||||
list_end = ')';
|
|
||||||
list_delimiter = ',';
|
|
||||||
split_single = false;
|
|
||||||
skip_empty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ConfParser::SplitSingle(bool split)
|
|
||||||
{
|
|
||||||
split_single = split;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ConfParser::SkipEmpty(bool skip)
|
|
||||||
{
|
|
||||||
skip_empty = skip;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ConfParser::Status ConfParser::Parse(const char * file_name)
|
|
||||||
{
|
|
||||||
line = 1;
|
|
||||||
table.clear();
|
|
||||||
table_single.clear();
|
|
||||||
|
|
||||||
file.clear();
|
|
||||||
file.open( file_name );
|
|
||||||
|
|
||||||
if( file )
|
|
||||||
{
|
|
||||||
status = ParseFile();
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status = cant_open_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ConfParser::Status ConfParser::Parse(const std::string & file_name)
|
|
||||||
{
|
|
||||||
return Parse(file_name.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ConfParser::Status ConfParser::ParseFile()
|
|
||||||
{
|
|
||||||
ReadChar();
|
|
||||||
SkipWhiteLines();
|
|
||||||
|
|
||||||
while( lastc != -1 )
|
|
||||||
{
|
|
||||||
if( !ReadVariable() )
|
|
||||||
return syntax_error;
|
|
||||||
|
|
||||||
if( lastc != separator )
|
|
||||||
return syntax_error;
|
|
||||||
|
|
||||||
if( !ReadValue() )
|
|
||||||
return syntax_error;
|
|
||||||
|
|
||||||
AddOption();
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
if( lastc != -1 && lastc != '\n' )
|
|
||||||
return syntax_error; // some characters have left at the end of an option
|
|
||||||
|
|
||||||
SkipWhiteLines();
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ConfParser::AddOption()
|
|
||||||
{
|
|
||||||
if( value.empty() && skip_empty )
|
|
||||||
{
|
|
||||||
DeleteFromTable(variable);
|
|
||||||
DeleteFromTableSingle(variable);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( split_single && value.size() == 1 )
|
|
||||||
{
|
|
||||||
table_single[variable] = value[0];
|
|
||||||
DeleteFromTable(variable);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
table[variable] = value;
|
|
||||||
DeleteFromTableSingle(variable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ConfParser::DeleteFromTable(const std::string & var)
|
|
||||||
{
|
|
||||||
Table::iterator i = table.find(var);
|
|
||||||
|
|
||||||
if( i != table.end() )
|
|
||||||
table.erase(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ConfParser::DeleteFromTableSingle(const std::string & var)
|
|
||||||
{
|
|
||||||
TableSingle::iterator i = table_single.find(var);
|
|
||||||
|
|
||||||
if( i != table_single.end() )
|
|
||||||
table_single.erase(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ConfParser::ReadVariable()
|
|
||||||
{
|
|
||||||
variable.clear();
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
while( IsVariableChar(lastc) )
|
|
||||||
{
|
|
||||||
variable += lastc;
|
|
||||||
ReadChar();
|
|
||||||
}
|
|
||||||
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
return !variable.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ConfParser::ReadValue()
|
|
||||||
{
|
|
||||||
value.clear();
|
|
||||||
ReadChar(); // skipping separator '='
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
if( lastc == list_start )
|
|
||||||
return ReadValueList();
|
|
||||||
else
|
|
||||||
return ReadValueNoList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ConfParser::ReadValueList()
|
|
||||||
{
|
|
||||||
ReadChar(); // skipping first list character '('
|
|
||||||
SkipWhiteLines(); // lists can be split into several lines
|
|
||||||
|
|
||||||
while( lastc != -1 && lastc != list_end )
|
|
||||||
{
|
|
||||||
if( !ReadValueNoList(true) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if( lastc == list_delimiter )
|
|
||||||
ReadChar();
|
|
||||||
|
|
||||||
SkipWhiteLines();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( lastc != list_end )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ReadChar(); // skipping last list character ')'
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ConfParser::ReadValueNoList(bool use_list_delimiter)
|
|
||||||
{
|
|
||||||
bool res;
|
|
||||||
|
|
||||||
value_item.clear();
|
|
||||||
|
|
||||||
if( lastc == '"' )
|
|
||||||
{
|
|
||||||
res = ReadValueQuoted(); // quoted value
|
|
||||||
|
|
||||||
if( res )
|
|
||||||
value.push_back(value_item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = ReadValueSimple(use_list_delimiter);
|
|
||||||
|
|
||||||
if( res && !value_item.empty() )
|
|
||||||
value.push_back(value_item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ConfParser::ReadValueQuoted()
|
|
||||||
{
|
|
||||||
ReadChar(); // skipping the first quote
|
|
||||||
|
|
||||||
while( lastc != '"' && lastc != -1 )
|
|
||||||
{
|
|
||||||
if( lastc == '\\' )
|
|
||||||
ReadChar();
|
|
||||||
|
|
||||||
value_item += lastc;
|
|
||||||
ReadChar();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( lastc != '"' )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ReadChar(); // skipping the last quote
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ConfParser::ReadValueSimple(bool use_list_delimiter)
|
|
||||||
{
|
|
||||||
int list_delimiter1 = -1;
|
|
||||||
int list_delimiter2 = -1;
|
|
||||||
|
|
||||||
if( use_list_delimiter )
|
|
||||||
{
|
|
||||||
list_delimiter1 = list_delimiter;
|
|
||||||
list_delimiter2 = list_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
while( lastc!=-1 && lastc!='\n' && lastc!=commentary &&
|
|
||||||
lastc!=list_delimiter1 && lastc!=list_delimiter2 )
|
|
||||||
{
|
|
||||||
value_item += lastc;
|
|
||||||
ReadChar();
|
|
||||||
}
|
|
||||||
|
|
||||||
Trim(value_item);
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int ConfParser::ReadChar()
|
|
||||||
{
|
|
||||||
lastc = file.get();
|
|
||||||
|
|
||||||
if( lastc == '\n' )
|
|
||||||
++line;
|
|
||||||
|
|
||||||
return lastc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool ConfParser::IsWhite(int c)
|
|
||||||
{
|
|
||||||
// dont use '\n' here
|
|
||||||
// 13 (\r) is at the end of a line in a dos file \r\n
|
|
||||||
// 160 is an unbreakable space
|
|
||||||
if( c==' ' || c=='\t' || c==13 || c==160 )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ConfParser::SkipWhite()
|
|
||||||
{
|
|
||||||
while( IsWhite(lastc) || lastc == commentary )
|
|
||||||
{
|
|
||||||
if( lastc == commentary )
|
|
||||||
SkipLine();
|
|
||||||
else
|
|
||||||
ReadChar();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ConfParser::SkipWhiteLines()
|
|
||||||
{
|
|
||||||
while( IsWhite(lastc) || lastc == commentary || lastc=='\n' )
|
|
||||||
{
|
|
||||||
if( lastc == commentary )
|
|
||||||
SkipLine();
|
|
||||||
else
|
|
||||||
ReadChar();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ConfParser::SkipLine()
|
|
||||||
{
|
|
||||||
while( lastc != -1 && lastc != '\n' )
|
|
||||||
ReadChar();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ConfParser::Trim(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,311 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfileconfparser
|
|
||||||
#define headerfileconfparser
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
A parser for parsing config files.
|
|
||||||
|
|
||||||
A config file can look like this:
|
|
||||||
variable1 = value 1
|
|
||||||
variable2 = " value 2 "
|
|
||||||
variable3 = (value 1, value 2)
|
|
||||||
variable4 = (" value 1 " , "value2", value 3)
|
|
||||||
|
|
||||||
sample of use:
|
|
||||||
ConfParser parser;
|
|
||||||
parser.Parse("/path/to/config");
|
|
||||||
|
|
||||||
if( parser.status == ConfParser::ok )
|
|
||||||
{
|
|
||||||
// the whole config we have in parser.table (parser.table_single)
|
|
||||||
}
|
|
||||||
|
|
||||||
config syntax:
|
|
||||||
option = list
|
|
||||||
|
|
||||||
list can consists of any number of items, if you're using more than one item you should
|
|
||||||
use brackets ()
|
|
||||||
|
|
||||||
for one item the brackets can be ommited:
|
|
||||||
option = value
|
|
||||||
white characters at the beginning of the value (and at the end) will be trimmed,
|
|
||||||
or you can use quotes:
|
|
||||||
option = "value"
|
|
||||||
option2 = "value with spaces at the end "
|
|
||||||
|
|
||||||
the form without quotes:
|
|
||||||
option = value
|
|
||||||
should be written in one line, so this is not allowed:
|
|
||||||
option =
|
|
||||||
value
|
|
||||||
you can use a new line characters only between brackets and quotes:
|
|
||||||
option = "this is
|
|
||||||
a multiline string"
|
|
||||||
option = ( value1,
|
|
||||||
value2 )
|
|
||||||
|
|
||||||
but there is one requirement: the first character " or ( should be in the same line,
|
|
||||||
so this is not allowed
|
|
||||||
option =
|
|
||||||
"this is wrong"
|
|
||||||
but this is ok:
|
|
||||||
option = "
|
|
||||||
that is ok"
|
|
||||||
|
|
||||||
empty lists:
|
|
||||||
option = ()
|
|
||||||
this creates an empty list: parser.table['option'].empty() == true
|
|
||||||
|
|
||||||
option =
|
|
||||||
this creates an empty list too (the same as previously)
|
|
||||||
|
|
||||||
option = ""
|
|
||||||
but this doesn't create an empty list, it creates a list with one (empty) item
|
|
||||||
|
|
||||||
commentaries:
|
|
||||||
# this is a commentary (until the end of the line)
|
|
||||||
option = value # this is a commentary too
|
|
||||||
|
|
||||||
commentaries are treated as white characters, other example:
|
|
||||||
option = ( # this is my list
|
|
||||||
"value 1" # this is a value one
|
|
||||||
value 2 # and this is a value two
|
|
||||||
) # end of my list
|
|
||||||
|
|
||||||
overwriting:
|
|
||||||
option1 = some value
|
|
||||||
option1 = other value
|
|
||||||
# always the last option is used so option1 is "other value"
|
|
||||||
|
|
||||||
list delimiter:
|
|
||||||
option1 = (value1, value2, value3)
|
|
||||||
option2 = ("value1", "value2", "value3")
|
|
||||||
above we're using a comma ',' as a list delimiter but when using quotes (second line)
|
|
||||||
the commas can be omitted:
|
|
||||||
option2 = ("value1" "value2" "value3")
|
|
||||||
|
|
||||||
white characters:
|
|
||||||
the name of an option cannot consist of white characters
|
|
||||||
some option = value # this is wrong
|
|
||||||
some_option = value # this is ok
|
|
||||||
|
|
||||||
which characters are allowed in an option name is defined by IsVariableChar() method
|
|
||||||
|
|
||||||
you can use white characters in values
|
|
||||||
option = value with spaces or tabs
|
|
||||||
white characters at the beginning and at the end will be trimmed,
|
|
||||||
so if you want them use quotes:
|
|
||||||
option = " other value with spaces "
|
|
||||||
|
|
||||||
special characters in quoted strings:
|
|
||||||
option = "this is a string with \" a quote inside"
|
|
||||||
the option will be: this is a string with " a quote inside
|
|
||||||
\\ - means one \
|
|
||||||
basically: \char produces char
|
|
||||||
so:
|
|
||||||
"\a" gives "a"
|
|
||||||
"\\" gives "\"
|
|
||||||
"\Z" gives "Z" and so on
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
class ConfParser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
ConfParser();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
status of parsing
|
|
||||||
*/
|
|
||||||
enum Status { ok, cant_open_file, syntax_error };
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
the last status of parsing, set by Parse() methods
|
|
||||||
*/
|
|
||||||
Status status;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
the main methods used to parse
|
|
||||||
file_name is the path to a file
|
|
||||||
*/
|
|
||||||
Status Parse(const char * file_name);
|
|
||||||
Status Parse(const std::string & file_name);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
a number of a line in which there is a syntax_error
|
|
||||||
*/
|
|
||||||
int line;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
this is the table which represents your config file
|
|
||||||
in the Table map: the first (key) is your 'option' and the second is 'list'
|
|
||||||
*/
|
|
||||||
typedef std::vector<std::string> Value;
|
|
||||||
typedef std::map<std::string, Value> Table;
|
|
||||||
Table table;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if your config file consists mainly of single forms such as:
|
|
||||||
option = value
|
|
||||||
option2 = value2
|
|
||||||
then you can call SplitSingle(true) for not inserting single values to
|
|
||||||
previous 'table' but instead to 'table_single'
|
|
||||||
table_single as the second parameter takes only std::string (instead of the whole std::vector)
|
|
||||||
so you can save a little memory from not using std::vector
|
|
||||||
*/
|
|
||||||
typedef std::map<std::string, std::string> TableSingle;
|
|
||||||
TableSingle table_single;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if your list consists of only one item, e.g:
|
|
||||||
option1 = value 1
|
|
||||||
option2 = "value 2"
|
|
||||||
option3 = ( "value 3" )
|
|
||||||
then if you call SplitSingle(true) then such values will be stored in
|
|
||||||
'table_single' instead of 'table' map
|
|
||||||
default: false
|
|
||||||
*/
|
|
||||||
void SplitSingle(bool split);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if true then empty lists, e.g:
|
|
||||||
option =
|
|
||||||
option2 = ()
|
|
||||||
will be omitted (not inserted to 'table' or 'table_single')
|
|
||||||
default: false
|
|
||||||
*/
|
|
||||||
void SkipEmpty(bool skip);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/*
|
|
||||||
last read variable (option)
|
|
||||||
*/
|
|
||||||
std::string variable;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
last read list item
|
|
||||||
*/
|
|
||||||
std::string value_item;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
last read list
|
|
||||||
*/
|
|
||||||
Value value;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
separator between a variable and a value, default: '='
|
|
||||||
*/
|
|
||||||
int separator;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
commentary char, default: '#'
|
|
||||||
*/
|
|
||||||
int commentary;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
list starting character, default: '('
|
|
||||||
*/
|
|
||||||
int list_start;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
list ending character, default: ')'
|
|
||||||
*/
|
|
||||||
int list_end;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
list delimiter, default: ','
|
|
||||||
*/
|
|
||||||
int list_delimiter;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
last read char
|
|
||||||
*/
|
|
||||||
int lastc;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
current file
|
|
||||||
*/
|
|
||||||
std::ifstream file;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if true then lists with one item will be put into 'table_single' table
|
|
||||||
default: false
|
|
||||||
*/
|
|
||||||
bool split_single;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if true then empty lists, e.g:
|
|
||||||
option =
|
|
||||||
option2 = ()
|
|
||||||
will be omitted (not inserted to 'table' or 'table_single')
|
|
||||||
default: false
|
|
||||||
*/
|
|
||||||
bool skip_empty;
|
|
||||||
|
|
||||||
|
|
||||||
Status ParseFile();
|
|
||||||
void AddOption();
|
|
||||||
|
|
||||||
void DeleteFromTable(const std::string & var);
|
|
||||||
void DeleteFromTableSingle(const std::string & var);
|
|
||||||
|
|
||||||
bool ReadVariable();
|
|
||||||
bool ReadValue();
|
|
||||||
bool ReadValueList();
|
|
||||||
bool ReadValueNoList(bool use_list_delimiter = false);
|
|
||||||
bool ReadValueQuoted();
|
|
||||||
bool ReadValueSimple(bool use_list_delimiter = false);
|
|
||||||
|
|
||||||
int ReadChar();
|
|
||||||
bool IsWhite(int c);
|
|
||||||
bool IsVariableChar(int c);
|
|
||||||
void SkipWhite();
|
|
||||||
void SkipWhiteLines();
|
|
||||||
void SkipLine();
|
|
||||||
void Trim(std::string & s);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
include Makefile.o.dep
|
|
||||||
|
|
||||||
|
|
||||||
all: $(o)
|
|
||||||
|
|
||||||
|
|
||||||
.SUFFIXES: .cpp .o
|
|
||||||
|
|
||||||
.cpp.o:
|
|
||||||
$(CXX) -c $(CXXFLAGS) $<
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
depend:
|
|
||||||
makedepend -Y. -I.. -I../../ezc/src -f- *.cpp > Makefile.dep
|
|
||||||
echo -n "o = " > Makefile.o.dep
|
|
||||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o
|
|
||||||
|
|
||||||
include Makefile.dep
|
|
||||||
@@ -1,455 +0,0 @@
|
|||||||
# DO NOT DELETE
|
|
||||||
|
|
||||||
adduser.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
adduser.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
adduser.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
adduser.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
adduser.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
adduser.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
adduser.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
adduser.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
adduser.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
adduser.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
adduser.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
adduser.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
adduser.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
adduser.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h
|
|
||||||
adduser.o: ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
adduser.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
adduser.o: ../core/loadavg.h
|
|
||||||
cat.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
|
||||||
cat.o: ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
cat.o: ../templates/localefilter.h ../core/locale.h
|
|
||||||
cat.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
cat.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
|
|
||||||
cat.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h
|
|
||||||
cat.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h
|
|
||||||
cat.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h
|
|
||||||
cat.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h
|
|
||||||
cat.o: ../core/session.h ../core/rebus.h ../core/plugindata.h
|
|
||||||
cat.o: ../core/function.h ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
cat.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
cat.o: ../core/postmultiparser.h ../core/error.h ../core/data.h
|
|
||||||
cat.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
cat.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
cat.o: ../core/loadavg.h
|
|
||||||
content.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
content.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
content.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
content.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
content.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
content.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
content.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
content.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
content.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
content.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
content.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
content.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
content.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
content.o: ../core/postmultiparser.h ../core/error.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 ../core/loadavg.h ../core/misc.h ../core/plugin.h
|
|
||||||
content.o: ../core/request.h ../core/data.h ../core/pluginmsg.h
|
|
||||||
cp.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
|
||||||
cp.o: ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
cp.o: ../templates/localefilter.h ../core/locale.h ../confparser/confparser.h
|
|
||||||
cp.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
|
||||||
cp.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h
|
|
||||||
cp.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h
|
|
||||||
cp.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
cp.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
cp.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
cp.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
cp.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
cp.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
cp.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h ../core/users.h
|
|
||||||
cp.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
|
|
||||||
cp.o: ../core/mounts.h ../core/mount.h ../core/loadavg.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: ../templates/misc.h ../templates/localefilter.h
|
|
||||||
createthread.o: ../core/locale.h ../confparser/confparser.h
|
|
||||||
createthread.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
|
||||||
createthread.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h
|
|
||||||
createthread.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h
|
|
||||||
createthread.o: ../core/group.h ../core/thread.h ../core/error.h
|
|
||||||
createthread.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h
|
|
||||||
createthread.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h
|
|
||||||
createthread.o: ../core/session.h ../core/rebus.h ../core/plugindata.h
|
|
||||||
createthread.o: ../core/function.h ../core/compress.h
|
|
||||||
createthread.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h
|
|
||||||
createthread.o: ../core/htmlfilter.h ../core/postmultiparser.h
|
|
||||||
createthread.o: ../core/error.h ../core/mount.h ../core/data.h ../core/dirs.h
|
|
||||||
createthread.o: ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
createthread.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
createthread.o: ../core/loadavg.h
|
|
||||||
createticket.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
createticket.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
createticket.o: ../templates/misc.h ../templates/localefilter.h
|
|
||||||
createticket.o: ../core/locale.h ../confparser/confparser.h
|
|
||||||
createticket.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
|
||||||
createticket.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h
|
|
||||||
createticket.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h
|
|
||||||
createticket.o: ../core/group.h ../core/thread.h ../core/error.h
|
|
||||||
createticket.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h
|
|
||||||
createticket.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h
|
|
||||||
createticket.o: ../core/session.h ../core/rebus.h ../core/plugindata.h
|
|
||||||
createticket.o: ../core/function.h ../core/compress.h
|
|
||||||
createticket.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h
|
|
||||||
createticket.o: ../core/htmlfilter.h ../core/postmultiparser.h
|
|
||||||
createticket.o: ../core/error.h ../core/mount.h ../core/data.h ../core/dirs.h
|
|
||||||
createticket.o: ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
createticket.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
createticket.o: ../core/loadavg.h
|
|
||||||
default.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
default.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
default.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
default.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
default.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
default.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
default.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
default.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
default.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
default.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
default.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
default.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
default.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
default.o: ../core/postmultiparser.h ../core/error.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 ../core/loadavg.h
|
|
||||||
download.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
download.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
download.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
download.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
download.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
download.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
download.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
download.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
download.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
download.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
download.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
download.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
download.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
download.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h
|
|
||||||
download.o: ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
download.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
download.o: ../core/loadavg.h
|
|
||||||
editticket.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
editticket.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
editticket.o: ../templates/misc.h ../templates/localefilter.h
|
|
||||||
editticket.o: ../core/locale.h ../confparser/confparser.h
|
|
||||||
editticket.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
|
||||||
editticket.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h
|
|
||||||
editticket.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h
|
|
||||||
editticket.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
editticket.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
editticket.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
editticket.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
editticket.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
editticket.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
editticket.o: ../core/postmultiparser.h ../core/error.h ../core/mount.h
|
|
||||||
editticket.o: ../core/data.h ../core/dirs.h ../core/users.h ../core/groups.h
|
|
||||||
editticket.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
|
|
||||||
editticket.o: ../core/mount.h ../core/loadavg.h
|
|
||||||
emacs.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
emacs.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
emacs.o: ../templates/localefilter.h ../core/locale.h
|
|
||||||
emacs.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
emacs.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
emacs.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
emacs.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
emacs.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
emacs.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
emacs.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
emacs.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
emacs.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
emacs.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
emacs.o: ../core/postmultiparser.h ../core/error.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/loadavg.h ../core/notify.h
|
|
||||||
emacs.o: ../templatesnotify/templatesnotify.h ../core/mount.h
|
|
||||||
emacs.o: ../templates/misc.h ../core/misc.h
|
|
||||||
last.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
|
||||||
last.o: ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
last.o: ../templates/localefilter.h ../core/locale.h
|
|
||||||
last.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
last.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
|
|
||||||
last.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h
|
|
||||||
last.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h
|
|
||||||
last.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h
|
|
||||||
last.o: ../core/ticket.h
|
|
||||||
login.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
login.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
login.o: ../templates/localefilter.h ../core/locale.h
|
|
||||||
login.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
login.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
login.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
login.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
login.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
login.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
login.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
login.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
login.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
login.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
login.o: ../core/postmultiparser.h ../core/error.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
|
|
||||||
login.o: ../core/loadavg.h
|
|
||||||
logout.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
logout.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
logout.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
logout.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
logout.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
logout.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
logout.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
logout.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
logout.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
logout.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
logout.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
logout.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
logout.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
logout.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h
|
|
||||||
logout.o: ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
logout.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
logout.o: ../core/loadavg.h
|
|
||||||
ls.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
|
||||||
ls.o: ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
ls.o: ../templates/localefilter.h ../core/locale.h ../confparser/confparser.h
|
|
||||||
ls.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
|
||||||
ls.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h
|
|
||||||
ls.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h
|
|
||||||
ls.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
ls.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
ls.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
ls.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
ls.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
ls.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
ls.o: ../core/postmultiparser.h
|
|
||||||
misc_item.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
misc_item.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
misc_item.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
misc_item.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
misc_item.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
misc_item.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
misc_item.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
misc_item.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
misc_item.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
misc_item.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
misc_item.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
misc_item.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
misc_item.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
misc_item.o: ../core/postmultiparser.h ../core/misc.h
|
|
||||||
misc_specialfile.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
misc_specialfile.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
misc_specialfile.o: ../templates/misc.h ../templates/localefilter.h
|
|
||||||
misc_specialfile.o: ../core/locale.h ../confparser/confparser.h
|
|
||||||
misc_specialfile.o: ../templates/ckeditorgetparser.h
|
|
||||||
misc_specialfile.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
misc_specialfile.o: ../templates/indexpatterns.h ../core/thread.h
|
|
||||||
misc_specialfile.o: ../core/ticket.h ../core/db.h ../core/item.h
|
|
||||||
misc_specialfile.o: ../core/user.h ../core/group.h ../core/thread.h
|
|
||||||
misc_specialfile.o: ../core/error.h ../core/log.h ../core/dircontainer.h
|
|
||||||
misc_specialfile.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h
|
|
||||||
misc_specialfile.o: ../core/requesttypes.h ../core/session.h ../core/rebus.h
|
|
||||||
misc_specialfile.o: ../core/plugindata.h ../core/function.h
|
|
||||||
misc_specialfile.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
misc_specialfile.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
misc_specialfile.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h
|
|
||||||
misc_specialfile.o: ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
misc_specialfile.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
misc_specialfile.o: ../core/loadavg.h
|
|
||||||
mkdir.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
mkdir.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
mkdir.o: ../templates/localefilter.h ../core/locale.h
|
|
||||||
mkdir.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
mkdir.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
mkdir.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
mkdir.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
mkdir.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
mkdir.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
mkdir.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
mkdir.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
mkdir.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
mkdir.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
mkdir.o: ../core/postmultiparser.h ../core/error.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/loadavg.h ../core/notify.h
|
|
||||||
mkdir.o: ../templatesnotify/templatesnotify.h ../core/mount.h
|
|
||||||
mkdir.o: ../templates/misc.h
|
|
||||||
mv.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
|
||||||
mv.o: ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
mv.o: ../templates/localefilter.h ../core/locale.h ../confparser/confparser.h
|
|
||||||
mv.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
|
||||||
mv.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h
|
|
||||||
mv.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h
|
|
||||||
mv.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
mv.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
mv.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
mv.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
mv.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
mv.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
mv.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h ../core/users.h
|
|
||||||
mv.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
|
|
||||||
mv.o: ../core/mounts.h ../core/mount.h ../core/loadavg.h
|
|
||||||
node.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
|
||||||
node.o: ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
node.o: ../templates/localefilter.h ../core/locale.h
|
|
||||||
node.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
node.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
|
|
||||||
node.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h
|
|
||||||
node.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h
|
|
||||||
node.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h
|
|
||||||
node.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h
|
|
||||||
node.o: ../core/session.h ../core/rebus.h ../core/plugindata.h
|
|
||||||
node.o: ../core/function.h ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
node.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
node.o: ../core/postmultiparser.h
|
|
||||||
priv.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
|
||||||
priv.o: ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
priv.o: ../templates/localefilter.h ../core/locale.h
|
|
||||||
priv.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
priv.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
|
|
||||||
priv.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h
|
|
||||||
priv.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h
|
|
||||||
priv.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h
|
|
||||||
priv.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h
|
|
||||||
priv.o: ../core/session.h ../core/rebus.h ../core/plugindata.h
|
|
||||||
priv.o: ../core/function.h ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
priv.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
priv.o: ../core/postmultiparser.h ../core/error.h ../core/data.h
|
|
||||||
priv.o: ../core/dirs.h ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
priv.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
priv.o: ../core/loadavg.h
|
|
||||||
reload.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
reload.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
reload.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
reload.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
reload.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
reload.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
reload.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
reload.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
reload.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
reload.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
reload.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
reload.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
reload.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
reload.o: ../core/postmultiparser.h ../core/error.h ../core/notify.h
|
|
||||||
reload.o: ../templatesnotify/templatesnotify.h ../core/mount.h
|
|
||||||
reload.o: ../templates/misc.h
|
|
||||||
rm.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
|
||||||
rm.o: ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
rm.o: ../templates/localefilter.h ../core/locale.h ../confparser/confparser.h
|
|
||||||
rm.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
|
||||||
rm.o: ../core/log.h ../templates/indexpatterns.h ../core/thread.h
|
|
||||||
rm.o: ../core/ticket.h ../core/db.h ../core/item.h ../core/user.h
|
|
||||||
rm.o: ../core/group.h ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
rm.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
rm.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
rm.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
rm.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
rm.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
rm.o: ../core/postmultiparser.h ../core/error.h ../core/data.h ../core/dirs.h
|
|
||||||
rm.o: ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
rm.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
rm.o: ../core/loadavg.h ../core/plugin.h ../core/request.h ../core/data.h
|
|
||||||
rm.o: ../core/pluginmsg.h
|
|
||||||
run.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
|
||||||
run.o: ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
run.o: ../templates/localefilter.h ../core/locale.h
|
|
||||||
run.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
run.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
|
|
||||||
run.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h
|
|
||||||
run.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h
|
|
||||||
run.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h
|
|
||||||
run.o: ../core/ticket.h ../core/request.h ../core/requesttypes.h
|
|
||||||
run.o: ../core/session.h ../core/rebus.h ../core/plugindata.h
|
|
||||||
run.o: ../core/function.h ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
run.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
run.o: ../core/postmultiparser.h ../core/error.h
|
|
||||||
subject.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
subject.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
subject.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
subject.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
subject.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
subject.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
subject.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
subject.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
subject.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
subject.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
subject.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
subject.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
subject.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
subject.o: ../core/postmultiparser.h
|
|
||||||
thread.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
thread.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
thread.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
thread.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
thread.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
thread.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
thread.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
thread.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
thread.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
thread.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
thread.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
thread.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
thread.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
thread.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h
|
|
||||||
thread.o: ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
thread.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
thread.o: ../core/loadavg.h ../core/mount.h
|
|
||||||
ticket.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
ticket.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
ticket.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
ticket.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
ticket.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
ticket.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
ticket.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
ticket.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
ticket.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
ticket.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
ticket.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
ticket.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
ticket.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
ticket.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h
|
|
||||||
ticket.o: ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
ticket.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
ticket.o: ../core/loadavg.h ../core/mount.h
|
|
||||||
uname.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
uname.o: ../../ezc/src/ezc.h ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
uname.o: ../templates/localefilter.h ../core/locale.h
|
|
||||||
uname.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
uname.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
uname.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
uname.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
uname.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
uname.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
upload.o: content.h ../core/item.h ../templates/templates.h
|
|
||||||
upload.o: ../../ezc/src/ezc.h ../templates/patterncacher.h
|
|
||||||
upload.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h
|
|
||||||
upload.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
upload.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
upload.o: ../templates/indexpatterns.h ../core/thread.h ../core/ticket.h
|
|
||||||
upload.o: ../core/db.h ../core/item.h ../core/user.h ../core/group.h
|
|
||||||
upload.o: ../core/thread.h ../core/error.h ../core/log.h
|
|
||||||
upload.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h
|
|
||||||
upload.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
|
||||||
upload.o: ../core/rebus.h ../core/plugindata.h ../core/function.h
|
|
||||||
upload.o: ../core/compress.h ../core/acceptencodingparser.h
|
|
||||||
upload.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
|
||||||
upload.o: ../core/postmultiparser.h ../core/data.h ../core/dirs.h
|
|
||||||
upload.o: ../core/users.h ../core/groups.h ../core/functions.h
|
|
||||||
upload.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
|
||||||
upload.o: ../core/loadavg.h ../core/misc.h
|
|
||||||
who.o: content.h ../core/item.h ../templates/templates.h ../../ezc/src/ezc.h
|
|
||||||
who.o: ../templates/patterncacher.h ../templates/misc.h
|
|
||||||
who.o: ../templates/localefilter.h ../core/locale.h
|
|
||||||
who.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
|
|
||||||
who.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
|
|
||||||
who.o: ../core/thread.h ../core/ticket.h ../core/db.h ../core/item.h
|
|
||||||
who.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h
|
|
||||||
who.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h
|
|
||||||
who.o: ../core/ticket.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
o = adduser.o cat.o content.o cp.o createthread.o createticket.o default.o download.o editticket.o emacs.o last.o login.o logout.o ls.o misc_item.o misc_specialfile.o mkdir.o mv.o node.o priv.o reload.o rm.o run.o subject.o thread.o ticket.o uname.o upload.o who.o
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/data.h"
|
|
||||||
#include "../core/db.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass)
|
|
||||||
{
|
|
||||||
if( !login || !pass || !conf_pass )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( login->empty() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_LOGIN_EMPTY;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( *pass != *conf_pass )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PASSWORDS_DIFFERENT;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( pass->size() < 5 )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PASSWORD_TOO_SHORT;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( data.users.IsUser(*login) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_USER_EXISTS;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunAddUser()
|
|
||||||
{
|
|
||||||
User user;
|
|
||||||
|
|
||||||
std::string * login = request.PostVar("login");
|
|
||||||
std::string * pass = request.PostVar("password");
|
|
||||||
std::string * conf_pass = request.PostVar("confirmpassword");
|
|
||||||
std::string * email = request.PostVar("email");
|
|
||||||
|
|
||||||
if( !CheckAddUserVars(login, pass, conf_pass) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
user.name = *login;
|
|
||||||
|
|
||||||
if( email )
|
|
||||||
user.email = *email;
|
|
||||||
|
|
||||||
request.status = db.AddUser(user, *pass);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
if( data.users.AddUser(user) )
|
|
||||||
{
|
|
||||||
if( !request.session->puser )
|
|
||||||
LoginUser(user.id, false);
|
|
||||||
|
|
||||||
log << log2 << "Content: added a new user: " << user.name << logend;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "Content: I can't add to data.users: " << user.name
|
|
||||||
<< " but the user was added to the db correctly" << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( request.is_item )
|
|
||||||
RedirectTo(request.item);
|
|
||||||
else
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunAddUser()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/error.h"
|
|
||||||
#include "../core/data.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunCat()
|
|
||||||
{
|
|
||||||
if( !request.is_item )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: cat function requires an item" << logend;
|
|
||||||
request.status = WINIX_ERR_NO_ITEM;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( !request.HasReadAccess(request.item) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
request.send_as_attachment = request.IsParam("attachment");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,580 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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/misc.h"
|
|
||||||
#include "../core/plugin.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::Init()
|
|
||||||
{
|
|
||||||
templates.ReadIndexFileNames();
|
|
||||||
templates.ReadTemplates();
|
|
||||||
templates.CreateFunctions();
|
|
||||||
|
|
||||||
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.item.auth != Item::auth_none )
|
|
||||||
request.pfunction = data.functions.GetFunction(FUN_DOWNLOAD);
|
|
||||||
else
|
|
||||||
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 )
|
|
||||||
{
|
|
||||||
log << log3 << "Content: Default item: id: " << default_item << logend;
|
|
||||||
RedirectTo(default_item);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( data.mounts.pmount->type == Mount::thread )
|
|
||||||
{
|
|
||||||
request.pfunction = data.functions.GetFunction(FUN_THREAD);
|
|
||||||
|
|
||||||
if( request.pfunction )
|
|
||||||
log << log3 << "Content: default function: " << request.pfunction->item.url << logend;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( data.mounts.pmount->type == Mount::ticket )
|
|
||||||
{
|
|
||||||
request.pfunction = data.functions.GetFunction(FUN_TICKET);
|
|
||||||
|
|
||||||
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::FunNothing()
|
|
||||||
{
|
|
||||||
/* do nothing */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CallFunction()
|
|
||||||
{
|
|
||||||
static FunItem tab[] = {
|
|
||||||
{FUN_LOGOUT, &Content::FunLogout},
|
|
||||||
{FUN_CAT, &Content::FunCat},
|
|
||||||
{FUN_LS, &Content::FunLs},
|
|
||||||
{FUN_EMACS, &Content::FunEmacs},
|
|
||||||
{FUN_MKDIR, &Content::FunMkdir},
|
|
||||||
{FUN_DEFAULT, &Content::FunDefault},
|
|
||||||
{FUN_PRIV, &Content::FunPriv},
|
|
||||||
{FUN_RM, &Content::FunRm},
|
|
||||||
{FUN_RUN, &Content::FunRun},
|
|
||||||
{FUN_NODE, &Content::FunNode},
|
|
||||||
{FUN_WHO, &Content::FunWho},
|
|
||||||
{FUN_LAST, &Content::FunLast},
|
|
||||||
{FUN_THREAD, &Content::FunThread},
|
|
||||||
{FUN_RELOAD, &Content::FunReload},
|
|
||||||
{FUN_UPLOAD, &Content::FunUpload},
|
|
||||||
{FUN_TICKET, &Content::FunTicket},
|
|
||||||
{FUN_CKEDITOR, &Content::FunEmacs},
|
|
||||||
{FUN_TINYMCE, &Content::FunEmacs},
|
|
||||||
{FUN_LOGIN, &Content::FunLogin},
|
|
||||||
{FUN_MV, &Content::FunMv},
|
|
||||||
{FUN_UNAME, &Content::FunUname},
|
|
||||||
{FUN_CHMOD, &Content::FunPriv},
|
|
||||||
{FUN_CHOWN, &Content::FunPriv},
|
|
||||||
{FUN_DOWNLOAD, &Content::FunDownload},
|
|
||||||
{FUN_ADDUSER, &Content::FunAddUser},
|
|
||||||
{FUN_SUBJECT, &Content::FunSubject},
|
|
||||||
{FUN_CP, &Content::FunCp},
|
|
||||||
{FUN_UPTIME, &Content::FunNothing},
|
|
||||||
{FUN_EDITTICKET,&Content::FunEditTicket},
|
|
||||||
{FUN_CREATETHREAD, &Content::FunCreateThread},
|
|
||||||
{FUN_CREATETICKET, &Content::FunCreateTicket}
|
|
||||||
};
|
|
||||||
|
|
||||||
size_t len = sizeof(tab) / sizeof(FunItem);
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for(i=0 ; i<len ; ++i)
|
|
||||||
{
|
|
||||||
if( tab[i].code == request.pfunction->code )
|
|
||||||
{
|
|
||||||
(this->*tab[i].fun)();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::MakeStandardFunction()
|
|
||||||
{
|
|
||||||
if( request.role == Request::authorizer )
|
|
||||||
{
|
|
||||||
// in authorizer mode only cat function is available
|
|
||||||
// (and must be default)
|
|
||||||
|
|
||||||
if( request.pfunction )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_NO_ITEM;
|
|
||||||
log << log1 << "Content: in authorizer mode only 'cat' funtion is available and must "
|
|
||||||
"be default (not in the url)" << logend;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
request.pfunction = data.functions.GetFunction(FUN_CAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !request.pfunction )
|
|
||||||
SetDefaultFunction();
|
|
||||||
|
|
||||||
if( !request.redirect_to.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( !request.pfunction )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_NO_FUNCTION;
|
|
||||||
log << log1 << "Content: no function (neither cat nor ls)" << logend;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CallFunction();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CallPostFunction()
|
|
||||||
{
|
|
||||||
static FunItem tab[] = {
|
|
||||||
{FUN_RUN, &Content::PostFunRun},
|
|
||||||
{FUN_EMACS, &Content::PostFunEmacs},
|
|
||||||
{FUN_MKDIR, &Content::PostFunMkdir},
|
|
||||||
{FUN_DEFAULT, &Content::PostFunDefault},
|
|
||||||
{FUN_PRIV, &Content::PostFunPriv},
|
|
||||||
{FUN_CHMOD, &Content::PostFunPriv},
|
|
||||||
{FUN_CHOWN, &Content::PostFunPriv},
|
|
||||||
{FUN_LOGIN, &Content::PostFunLogin},
|
|
||||||
{FUN_UPLOAD, &Content::PostFunUpload},
|
|
||||||
{FUN_EDITTICKET,&Content::PostFunEditTicket},
|
|
||||||
{FUN_CKEDITOR, &Content::PostFunEmacs},
|
|
||||||
{FUN_TINYMCE, &Content::PostFunEmacs},
|
|
||||||
{FUN_ADDUSER, &Content::PostFunAddUser},
|
|
||||||
{FUN_MV, &Content::PostFunMv},
|
|
||||||
{FUN_SUBJECT, &Content::PostFunSubject},
|
|
||||||
{FUN_CP, &Content::PostFunCp},
|
|
||||||
{FUN_CREATETHREAD, &Content::PostFunCreateThread},
|
|
||||||
{FUN_CREATETICKET, &Content::PostFunCreateTicket}
|
|
||||||
};
|
|
||||||
|
|
||||||
size_t len = sizeof(tab) / sizeof(FunItem);
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for(i=0 ; i<len ; ++i)
|
|
||||||
{
|
|
||||||
if( tab[i].code == request.pfunction->code )
|
|
||||||
{
|
|
||||||
(this->*tab[i].fun)();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log << log1 << "Content: unknown post function" << logend;
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::MakePost()
|
|
||||||
{
|
|
||||||
if( request.role == Request::authorizer )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !request.pfunction )
|
|
||||||
SetDefaultFunction();
|
|
||||||
|
|
||||||
if( !request.pfunction )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_NO_FUNCTION;
|
|
||||||
log << log1 << "Content: MakePost: no function" << logend;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CallPostFunction();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::MakePage()
|
|
||||||
{
|
|
||||||
bool sent = false;
|
|
||||||
|
|
||||||
if( !request.redirect_to.empty() ||
|
|
||||||
!request.x_sendfile.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
if( request.is_item && request.item.auth == Item::auth_none &&
|
|
||||||
request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK && request.pfunction )
|
|
||||||
{
|
|
||||||
if( request.pfunction->code == FUN_CAT )
|
|
||||||
{
|
|
||||||
request.page << request.item.content;
|
|
||||||
sent = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( request.pfunction->code == FUN_RUN )
|
|
||||||
{
|
|
||||||
templates.GenerateRunRaw();
|
|
||||||
sent = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !sent )
|
|
||||||
{
|
|
||||||
templates.Generate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
if( DirsHaveReadExecPerm() )
|
|
||||||
{
|
|
||||||
if( request.method == Request::post )
|
|
||||||
MakePost();
|
|
||||||
|
|
||||||
if( request.redirect_to.empty() && request.status == WINIX_ERR_OK )
|
|
||||||
MakeStandardFunction();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( request.session->spam_score > 0 )
|
|
||||||
log << log1 << "Content: spam score: " << request.session->spam_score << logend;
|
|
||||||
|
|
||||||
if( request.IsParam("noredirect") )
|
|
||||||
request.redirect_to.clear();
|
|
||||||
|
|
||||||
if( !request.redirect_to.empty() )
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.Call(WINIX_CONTENT_MAKE);
|
|
||||||
MakePage();
|
|
||||||
|
|
||||||
// !! dodac parametr do konfiga wlaczajacy te informacje
|
|
||||||
//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, const char * postfix)
|
|
||||||
{
|
|
||||||
std::string path;
|
|
||||||
|
|
||||||
request.redirect_to = data.base_url;
|
|
||||||
|
|
||||||
|
|
||||||
if( item.type == Item::dir )
|
|
||||||
{
|
|
||||||
// item_id is pointing to a directory
|
|
||||||
data.dirs.MakePath(item.id, path);
|
|
||||||
request.redirect_to += 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.redirect_to += path;
|
|
||||||
request.redirect_to += item.url;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( postfix )
|
|
||||||
request.redirect_to += postfix;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::RedirectTo(long item_id, const char * postfix)
|
|
||||||
{
|
|
||||||
std::string path;
|
|
||||||
Item * pdir;
|
|
||||||
|
|
||||||
request.redirect_to = 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.redirect_to += 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.redirect_to += path + request.item_table[0].url;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "Content: Can't redirect: no such item: id: " << item_id << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( postfix )
|
|
||||||
request.redirect_to += postfix;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::RedirectToLastDir()
|
|
||||||
{
|
|
||||||
RedirectTo( *request.dir_table.back() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ReadAdditionalInfo()
|
|
||||||
{
|
|
||||||
if( request.dir_table.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( data.mounts.pmount->type == Mount::thread )
|
|
||||||
{
|
|
||||||
if( db.GetThreadByDirId(request.dir_table.back()->id, request.thread) == WINIX_ERR_OK )
|
|
||||||
request.is_thread = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( data.mounts.pmount->type == Mount::ticket )
|
|
||||||
{
|
|
||||||
if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
request.is_ticket = true;
|
|
||||||
|
|
||||||
if( !request.is_item && (!request.pfunction || request.pfunction->code == FUN_TICKET) )
|
|
||||||
{
|
|
||||||
db.GetItemById(request.ticket.item_id, request.item);
|
|
||||||
// don't set request.is_item here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 CorrectUrlOnlyAllowedChar()
|
|
||||||
|
|
||||||
CorrectUrlOnlyAllowedChar(item.url);
|
|
||||||
|
|
||||||
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(), '_');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::CheckRebus()
|
|
||||||
{
|
|
||||||
if( request.session->puser )
|
|
||||||
// logged user don't have to use the rebus
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if( request.session->rebus_checked )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
request.session->rebus_checked = true;
|
|
||||||
|
|
||||||
if( !request.session->rebus_item )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: rebus not set" << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::string * answer = request.PostVar("rebus");
|
|
||||||
|
|
||||||
if( answer && data.rebus.IsAnswerOk(request.session->rebus_item, *answer) )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch(const Error &)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
log << log1 << "Content: rebus has an incorrect answer" << logend;
|
|
||||||
// don't add request.session->spam_score when the rebus has incorrect answer
|
|
||||||
// a user could have made a mistake
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::SetUser(Item & item)
|
|
||||||
{
|
|
||||||
if( request.session->puser )
|
|
||||||
{
|
|
||||||
item.user_id = request.session->puser->id;
|
|
||||||
item.guest_name.clear();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
item.user_id = -1;
|
|
||||||
request.PostVar("guestname", item.guest_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
item.group_id = request.dir_table.back()->group_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CheckGetPostTimes(time_t difference)
|
|
||||||
{
|
|
||||||
time_t now = std::time(0);
|
|
||||||
|
|
||||||
if( request.session->puser )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( request.method != Request::post )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( now - request.session->last_time_get >= (time_t)difference )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( request.AllPostVarEmpty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
request.session->spam_score += 1;
|
|
||||||
log << log1 << "Content: spam +1: POST after GET sent too fast" << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
bool Content::CreateFile(const std::string & path, const std::string & content)
|
|
||||||
{
|
|
||||||
std::ofstream file(path.c_str(), std::ios_base::binary | std::ios_base::out);
|
|
||||||
|
|
||||||
if( !file )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: can't create file: " << path << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
file << content;
|
|
||||||
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
// !! dodac sprawdzenie prawidlowosci zapisania pliku
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,295 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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"
|
|
||||||
#include "../core/ticket.h"
|
|
||||||
#include "../core/db.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Content
|
|
||||||
{
|
|
||||||
Templates templates;
|
|
||||||
|
|
||||||
std::string temp;
|
|
||||||
|
|
||||||
void FunDownload();
|
|
||||||
|
|
||||||
void CheckSpecialFile();
|
|
||||||
|
|
||||||
void PrepareUrl(Item & item);
|
|
||||||
|
|
||||||
|
|
||||||
bool CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass);
|
|
||||||
void PostFunAddUser();
|
|
||||||
void FunAddUser();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
mv
|
|
||||||
*/
|
|
||||||
bool MoveIsTheSameFile(const Item & item);
|
|
||||||
void MoveAuth(Item & item);
|
|
||||||
void MoveFile(Item & item, bool redirect = true);
|
|
||||||
void MoveDir(Item & item, bool redirect = true);
|
|
||||||
void MoveAuthPrepareQuery();
|
|
||||||
void MoveAuthContentOfDir(const Item & item);
|
|
||||||
bool MoveParseDir(long & dir_id, std::string & dir, std::string & file);
|
|
||||||
bool MoveCheckAccessFromToDir();
|
|
||||||
bool MoveCheckAccessFrom();
|
|
||||||
bool MoveCheckAccessTo(long dir_id);
|
|
||||||
bool MoveCheckMountPoints(long dir_id);
|
|
||||||
void MoveContentOfDir();
|
|
||||||
void PostFunMv();
|
|
||||||
void FunMv();
|
|
||||||
std::string mv_dir;
|
|
||||||
std::string mv_file;
|
|
||||||
std::string mv_new_path;
|
|
||||||
long mv_dir_id;
|
|
||||||
std::vector<Item> mv_auth;
|
|
||||||
Db::ItemQuery mv_auth_iq;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
cp
|
|
||||||
*/
|
|
||||||
bool CpCheckAccessFrom();
|
|
||||||
void CpAuth(Item & item);
|
|
||||||
void CpSetNewAttributes(Item & item);
|
|
||||||
void CpItem(Item & item, long dst_dir_id);
|
|
||||||
void CpFilesInDir(const Item & dir, long dst_dir_id);
|
|
||||||
void CpContentOfDir(const Item & item, long dst_dir_id);
|
|
||||||
long CpDir(const Item & item, long dst_dir_id);
|
|
||||||
void CpItemCheck(Item & item, bool redirect = true);
|
|
||||||
void CpContentOfDirCheck(const Item & item, bool redirect = true);
|
|
||||||
void CpDirCheck(const Item & item, bool redirect = true);
|
|
||||||
void PostFunCp();
|
|
||||||
void FunCp();
|
|
||||||
void CpPrepare();
|
|
||||||
Item cp_temp;
|
|
||||||
Db::ItemQuery cp_iq;
|
|
||||||
bool cp_remove_defaults;
|
|
||||||
bool cp_preserve_attr;
|
|
||||||
long cp_new_user;
|
|
||||||
long cp_new_group;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SetDefaultFunctionForFile();
|
|
||||||
void SetDefaultFunctionForDir();
|
|
||||||
void SetDefaultFunction();
|
|
||||||
bool DirsHaveReadExecPerm();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
calling functions (standard, post)
|
|
||||||
*/
|
|
||||||
typedef void (Content::*Fun)();
|
|
||||||
|
|
||||||
struct FunItem
|
|
||||||
{
|
|
||||||
int code;
|
|
||||||
Fun fun;
|
|
||||||
};
|
|
||||||
|
|
||||||
void FunNothing();
|
|
||||||
void CallFunction();
|
|
||||||
void MakeStandardFunction();
|
|
||||||
void CallPostFunction();
|
|
||||||
void MakePost();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SetUser(Item & item);
|
|
||||||
bool CheckRebus();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FunCat();
|
|
||||||
void FunLogout();
|
|
||||||
void FunLs();
|
|
||||||
void FunEmacs();
|
|
||||||
|
|
||||||
|
|
||||||
void AddPathToAuth(std::string & path);
|
|
||||||
|
|
||||||
void FunCKEditor();
|
|
||||||
|
|
||||||
|
|
||||||
void FunUname();
|
|
||||||
|
|
||||||
bool SubjectCheckAccess();
|
|
||||||
void EditDirSubject();
|
|
||||||
void EditFileSubject();
|
|
||||||
void PostFunSubject();
|
|
||||||
void FunSubject();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
rm
|
|
||||||
*/
|
|
||||||
bool RemoveCheckAccess();
|
|
||||||
void RemoveAllDirs();
|
|
||||||
void RemoveAllDirs(long dir_id);
|
|
||||||
void RemoveDir();
|
|
||||||
void RemoveAuthPrepareQuery();
|
|
||||||
void RemoveAuth(Item & item);
|
|
||||||
void RemoveFile();
|
|
||||||
void FunRm();
|
|
||||||
Db::ItemQuery rm_auth_iq;
|
|
||||||
|
|
||||||
|
|
||||||
void FunNode();
|
|
||||||
void FunMkdir();
|
|
||||||
void FunDefault();
|
|
||||||
void FunRun();
|
|
||||||
void PostFunRun();
|
|
||||||
void FunWho();
|
|
||||||
void FunLast();
|
|
||||||
|
|
||||||
void FunReloadTemplates();
|
|
||||||
void FunReload();
|
|
||||||
|
|
||||||
static bool FunThreadSort(const Thread & t1, const Thread & t2);
|
|
||||||
void FunThread();
|
|
||||||
void FunCreateThread();
|
|
||||||
|
|
||||||
bool FunUploadCheckAccess();
|
|
||||||
void FunUpload();
|
|
||||||
|
|
||||||
bool ReadItemUrlSubject(Item & item, Item::Type item_type);
|
|
||||||
bool ReadItem(Item & item, Item::Type item_type);
|
|
||||||
|
|
||||||
void CheckAccessToItems();
|
|
||||||
|
|
||||||
void LoginUser(long user_id, bool remember_me);
|
|
||||||
void FunLogin();
|
|
||||||
void PostFunLogin();
|
|
||||||
|
|
||||||
|
|
||||||
void ReadItemContentWithType(Item & item);
|
|
||||||
bool FunEmacsCheckAccess();
|
|
||||||
void PostFunEmacsAdd(Item & item);
|
|
||||||
void PostFunEmacsEdit(bool with_url);
|
|
||||||
bool PostEmacsCheckAbuse(bool adding);
|
|
||||||
void PostFunEmacsModifyMountPoint(bool adding);
|
|
||||||
void PostFunEmacs();
|
|
||||||
|
|
||||||
bool FunMkdirCheckAccess();
|
|
||||||
void PostFunMkdir(bool add_to_dir_table, int privileges);
|
|
||||||
void PostFunMkdir();
|
|
||||||
|
|
||||||
void Mkdir(Item & item, bool add_to_dir_table);
|
|
||||||
long PostFunDefaultParsePath();
|
|
||||||
void PostFunDefault();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
function: priv, chmod, chown
|
|
||||||
*/
|
|
||||||
bool PrivCheckAccess();
|
|
||||||
void PrivLogStart(const char * what, long user, long group, int priv);
|
|
||||||
void PrivLog(const char * what, long id, const std::string & url);
|
|
||||||
bool ChangeOwner(Item & item, long user_id, long group_id);
|
|
||||||
bool ChangePrivileges(Item & item, int privileges);
|
|
||||||
void ChangePriv(Item & item, long user_id, long group_id, int privileges);
|
|
||||||
void PostFunPriv();
|
|
||||||
void PrivFilesInDir(long parent_id);
|
|
||||||
void PrivDir(long parent_id);
|
|
||||||
|
|
||||||
|
|
||||||
bool ReadPriv(const char * user_in, const char * group_in, const char * priv_in, long & user_id, long & group_id, int & priv);
|
|
||||||
void PrivDir();
|
|
||||||
void PrivOneItem();
|
|
||||||
void FunPriv();
|
|
||||||
|
|
||||||
long user_id_file, group_id_file, user_id_dir, group_id_dir;
|
|
||||||
int priv_file, priv_dir;
|
|
||||||
bool subdirectories;
|
|
||||||
bool change_owner, change_priv;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool FunCreateThreadCheckAccess();
|
|
||||||
bool FunCreateThreadCheckAbuse();
|
|
||||||
void ReadThread(Thread & thread);
|
|
||||||
void AddThread();
|
|
||||||
void PostFunCreateThreadLogAndRedirect();
|
|
||||||
void PostFunCreateThread();
|
|
||||||
|
|
||||||
bool UploadCreatePath();
|
|
||||||
void UploadSaveFile(const std::string & tmp_filename, const std::string & destination);
|
|
||||||
void UploadMulti();
|
|
||||||
void UploadSingle();
|
|
||||||
bool FunUploadCheckAbuse();
|
|
||||||
void PostFunUpload();
|
|
||||||
|
|
||||||
|
|
||||||
bool FunCreateTicketCheckAccess();
|
|
||||||
void FunCreateTicket();
|
|
||||||
bool FunCreateTicketCheckAbuse();
|
|
||||||
void PostFunCreateTicketLogAndRedirect();
|
|
||||||
void PostFunCreateTicket();
|
|
||||||
void FunTicket();
|
|
||||||
void TicketDeleteFirst();
|
|
||||||
|
|
||||||
bool FunEditTicketCheckAccess();
|
|
||||||
void PostFunEditTicketLogAndRedirect();
|
|
||||||
void EditTicketCheckFirstItem();
|
|
||||||
void EditTicketModTicket();
|
|
||||||
void EditTicketModDir();
|
|
||||||
void EditTicketModFirstItem();
|
|
||||||
void PostFunEditTicket();
|
|
||||||
void FunEditTicket();
|
|
||||||
|
|
||||||
void AddTicket();
|
|
||||||
void ReadTicket(Ticket & ticket);
|
|
||||||
void ReadTicketType(Ticket & ticket);
|
|
||||||
void ReadTicketStatus(Ticket & ticket);
|
|
||||||
void ReadTicketPriority(Ticket & ticket);
|
|
||||||
void ReadTicketCategory(Ticket & ticket);
|
|
||||||
void ReadTicketExpected(Ticket & ticket);
|
|
||||||
void ReadTicketProgress(Ticket & ticket);
|
|
||||||
|
|
||||||
void RedirectTo(const Item & item, const char * postfix = 0);
|
|
||||||
void RedirectTo(long item_id, const char * postfix = 0);
|
|
||||||
void RedirectToLastDir();
|
|
||||||
|
|
||||||
void CheckGetPostTimes(time_t difference = 10);
|
|
||||||
// bool CreateFile(const std::string & path, const std::string & content);
|
|
||||||
void MakePage();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool Init();
|
|
||||||
|
|
||||||
void ReadAdditionalInfo();
|
|
||||||
void Make();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
261
content/cp.cpp
261
content/cp.cpp
@@ -1,261 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/data.h"
|
|
||||||
#include "../core/misc.h"
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::CpCheckAccessFrom()
|
|
||||||
{
|
|
||||||
if( request.is_item )
|
|
||||||
{
|
|
||||||
if( !request.HasReadAccess(request.item) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( !request.IsParam("r") )
|
|
||||||
{
|
|
||||||
// directories need 'r' parameter
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CpAuth(Item & item)
|
|
||||||
{
|
|
||||||
if( !request.MakePath(item, mv_new_path, true) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( CopyFile(item.auth_path, mv_new_path) )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: copied static file from: " << item.auth_path << ", to: " << mv_new_path << logend;
|
|
||||||
item.auth_path = mv_new_path;
|
|
||||||
request.status = db.EditAuthById(item, item.id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "Content: can't copy a file from: " << item.auth_path << ", to: " << mv_new_path << logend;
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CpSetNewAttributes(Item & item)
|
|
||||||
{
|
|
||||||
item.user_id = cp_new_user;
|
|
||||||
item.group_id = cp_new_group;
|
|
||||||
item.SetDateModifyToNow();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CpItem(Item & item, long dst_dir_id)
|
|
||||||
{
|
|
||||||
if( !request.HasReadAccess(item) )
|
|
||||||
return; // !! w przyszlosci bedziemy dodawac komunikaty do specjalnej tablicy (narazie nie zaimplementowane)
|
|
||||||
|
|
||||||
item.parent_id = dst_dir_id;
|
|
||||||
|
|
||||||
if( !cp_preserve_attr )
|
|
||||||
CpSetNewAttributes(item);
|
|
||||||
|
|
||||||
PostFunEmacsAdd(item);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
if( item.auth != Item::auth_none )
|
|
||||||
CpAuth(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CpPrepare()
|
|
||||||
{
|
|
||||||
cp_iq.SetAll(true, false);
|
|
||||||
cp_iq.WhereType(Item::file);
|
|
||||||
|
|
||||||
cp_new_user = -1;
|
|
||||||
cp_new_group = -1;
|
|
||||||
|
|
||||||
if( request.session->puser )
|
|
||||||
cp_new_user = request.session->puser->id;
|
|
||||||
|
|
||||||
Item * pdir = data.dirs.GetDir(mv_dir_id);
|
|
||||||
|
|
||||||
if( pdir )
|
|
||||||
cp_new_group = pdir->group_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CpFilesInDir(const Item & dir, long dst_dir_id)
|
|
||||||
{
|
|
||||||
cp_iq.WhereParentId(dir.id);
|
|
||||||
db.GetItems(request.item_table, cp_iq);
|
|
||||||
|
|
||||||
for(size_t i=0 ; i<request.item_table.size() ; ++i)
|
|
||||||
CpItem(request.item_table[i], dst_dir_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CpContentOfDir(const Item & item, long dst_dir_id)
|
|
||||||
{
|
|
||||||
DirContainer::ParentIterator i = data.dirs.FindFirstParent(item.id);
|
|
||||||
|
|
||||||
// go through all directories
|
|
||||||
for( ; i != data.dirs.ParentEnd() ; i = data.dirs.NextParent(i) )
|
|
||||||
CpDir(*(i->second), dst_dir_id);
|
|
||||||
|
|
||||||
CpFilesInDir(item, dst_dir_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// we shouldn't change 'item' because we have references to our data.dirs objects
|
|
||||||
long Content::CpDir(const Item & item, long dst_dir_id)
|
|
||||||
{
|
|
||||||
cp_temp = item;
|
|
||||||
cp_temp.parent_id = dst_dir_id;
|
|
||||||
|
|
||||||
if( !mv_file.empty() )
|
|
||||||
{
|
|
||||||
cp_temp.url = mv_file;
|
|
||||||
mv_file.clear();
|
|
||||||
PrepareUrl(cp_temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !cp_preserve_attr )
|
|
||||||
CpSetNewAttributes(cp_temp);
|
|
||||||
|
|
||||||
if( cp_remove_defaults )
|
|
||||||
cp_temp.default_item = -1;
|
|
||||||
|
|
||||||
Mkdir(cp_temp, false);
|
|
||||||
long new_dir_id = cp_temp.id; // remember the new dir_id
|
|
||||||
|
|
||||||
if( request.HasReadExecAccess(item) )
|
|
||||||
CpContentOfDir(item, cp_temp.id);
|
|
||||||
|
|
||||||
return new_dir_id; // and return it
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// here 'item' can be changed in place
|
|
||||||
void Content::CpItemCheck(Item & item, bool redirect)
|
|
||||||
{
|
|
||||||
if( MoveIsTheSameFile(item) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( !mv_file.empty() )
|
|
||||||
{
|
|
||||||
item.url = mv_file;
|
|
||||||
PrepareUrl(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
CpItem(item, mv_dir_id);
|
|
||||||
|
|
||||||
if( request.status==WINIX_ERR_OK && redirect )
|
|
||||||
RedirectTo(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CpContentOfDirCheck(const Item & item, bool redirect)
|
|
||||||
{
|
|
||||||
if( !mv_file.empty() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_INCORRECT_DIR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mv_dir_id == item.id )
|
|
||||||
return; // nothing to do
|
|
||||||
|
|
||||||
if( data.dirs.HasParent(mv_dir_id, item.id) )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: cannot copy directory to inside it" << logend;
|
|
||||||
request.status = WINIX_ERR_INCORRECT_DIR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CpContentOfDir(item, mv_dir_id);
|
|
||||||
|
|
||||||
if( request.status==WINIX_ERR_OK && redirect )
|
|
||||||
RedirectTo(mv_dir_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CpDirCheck(const Item & item, bool redirect)
|
|
||||||
{
|
|
||||||
if( mv_file.empty() && mv_dir_id == item.id )
|
|
||||||
return; // nothing to do
|
|
||||||
|
|
||||||
if( mv_dir_id == item.id || data.dirs.HasParent(mv_dir_id, item.id) )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: cannot copy directory to inside it" << logend;
|
|
||||||
request.status = WINIX_ERR_INCORRECT_DIR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long new_dir_id = CpDir(item, mv_dir_id);
|
|
||||||
|
|
||||||
if( request.status==WINIX_ERR_OK && redirect )
|
|
||||||
RedirectTo(new_dir_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunCp()
|
|
||||||
{
|
|
||||||
if( CpCheckAccessFrom() &&
|
|
||||||
MoveParseDir(mv_dir_id, mv_dir, mv_file) &&
|
|
||||||
MoveCheckAccessTo(mv_dir_id) )
|
|
||||||
{
|
|
||||||
CpPrepare();
|
|
||||||
cp_preserve_attr = request.IsPostVar("preserveattr");
|
|
||||||
|
|
||||||
if( request.is_item )
|
|
||||||
{
|
|
||||||
CpItemCheck(request.item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cp_remove_defaults = request.IsPostVar("removedefaults");
|
|
||||||
|
|
||||||
if( request.IsPostVar("onlycontent") )
|
|
||||||
CpContentOfDirCheck(*request.dir_table.back());
|
|
||||||
else
|
|
||||||
CpDirCheck(*request.dir_table.back());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunCp()
|
|
||||||
{
|
|
||||||
CpCheckAccessFrom();
|
|
||||||
}
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::FunCreateThreadCheckAbuse()
|
|
||||||
{
|
|
||||||
if( !CheckRebus() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_INCORRECT_REBUS;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckGetPostTimes();
|
|
||||||
|
|
||||||
if( request.session->spam_score > 0 )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_SPAM;
|
|
||||||
log << log1 << "Content: ignoring due to suspected spamming" << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ReadThread(Thread & thread)
|
|
||||||
{
|
|
||||||
thread.parent_id = request.dir_table.back()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::AddThread()
|
|
||||||
{
|
|
||||||
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 PostFunEmacsAdd()
|
|
||||||
|
|
||||||
request.status = db.AddThread(request.thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunCreateThreadLogAndRedirect()
|
|
||||||
{
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
log << log2 << "Content: added a new thread" << logend;
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "Content: problem with adding a new thread, error code: "
|
|
||||||
<< request.status << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunCreateThread()
|
|
||||||
{
|
|
||||||
if( !FunCreateThreadCheckAccess() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
ReadItem(request.item, Item::dir);
|
|
||||||
SetUser(request.item);
|
|
||||||
ReadThread(request.thread);
|
|
||||||
request.item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty
|
|
||||||
|
|
||||||
if( !FunCreateThreadCheckAbuse() )
|
|
||||||
{
|
|
||||||
ReadItemContentWithType(request.item); // for correctly displaying the form
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Mkdir(request.item, true);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
ReadItemContentWithType(request.item);
|
|
||||||
request.item.type = Item::file;
|
|
||||||
request.item.privileges = 0644; // !! tymczasowo
|
|
||||||
request.item.parent_id = request.dir_table.back()->id;
|
|
||||||
PostFunEmacsAdd(request.item);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
AddThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
PostFunCreateThreadLogAndRedirect();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunCreateThread()
|
|
||||||
{
|
|
||||||
FunCreateThreadCheckAccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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::FunCreateTicketCheckAccess()
|
|
||||||
{
|
|
||||||
if( !request.CanCreateTicket() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::FunCreateTicketCheckAbuse()
|
|
||||||
{
|
|
||||||
if( !CheckRebus() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_INCORRECT_REBUS;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckGetPostTimes();
|
|
||||||
|
|
||||||
if( request.session->spam_score > 0 )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_SPAM;
|
|
||||||
log << log1 << "Content: ignoring due to suspected spamming" << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ReadTicketType(Ticket & ticket)
|
|
||||||
{
|
|
||||||
static std::string temp;
|
|
||||||
|
|
||||||
request.PostVar("type", temp);
|
|
||||||
ticket.type = atoi(temp.c_str());
|
|
||||||
|
|
||||||
if( ticket.type >= data.mounts.pmount->param[Mount::par_ticket_type].arg.size() )
|
|
||||||
ticket.type = data.mounts.pmount->param[Mount::par_ticket_type].arg.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ReadTicketStatus(Ticket & ticket)
|
|
||||||
{
|
|
||||||
static std::string temp;
|
|
||||||
|
|
||||||
request.PostVar("status", temp);
|
|
||||||
ticket.status = atoi(temp.c_str());
|
|
||||||
|
|
||||||
if( ticket.status >= data.mounts.pmount->param[Mount::par_ticket_status].arg.size() )
|
|
||||||
ticket.status = data.mounts.pmount->param[Mount::par_ticket_status].arg.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ReadTicketPriority(Ticket & ticket)
|
|
||||||
{
|
|
||||||
static std::string temp;
|
|
||||||
|
|
||||||
request.PostVar("priority", temp);
|
|
||||||
ticket.priority = atoi(temp.c_str());
|
|
||||||
|
|
||||||
if( ticket.priority >= data.mounts.pmount->param[Mount::par_ticket_priority].arg.size() )
|
|
||||||
ticket.priority = data.mounts.pmount->param[Mount::par_ticket_priority].arg.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ReadTicketCategory(Ticket & ticket)
|
|
||||||
{
|
|
||||||
static std::string temp;
|
|
||||||
|
|
||||||
request.PostVar("category", temp);
|
|
||||||
ticket.category = atoi(temp.c_str());
|
|
||||||
|
|
||||||
if( ticket.category >= data.mounts.pmount->param[Mount::par_ticket_category].arg.size() )
|
|
||||||
ticket.category = data.mounts.pmount->param[Mount::par_ticket_category].arg.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ReadTicketExpected(Ticket & ticket)
|
|
||||||
{
|
|
||||||
static std::string temp;
|
|
||||||
|
|
||||||
request.PostVar("expected", temp);
|
|
||||||
ticket.expected = atoi(temp.c_str());
|
|
||||||
|
|
||||||
if( ticket.expected >= data.mounts.pmount->param[Mount::par_ticket_expected].arg.size() )
|
|
||||||
ticket.expected = data.mounts.pmount->param[Mount::par_ticket_expected].arg.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ReadTicketProgress(Ticket & ticket)
|
|
||||||
{
|
|
||||||
static std::string temp;
|
|
||||||
|
|
||||||
request.PostVar("progress", temp);
|
|
||||||
int p = atoi(temp.c_str());
|
|
||||||
|
|
||||||
if( p < 0 )
|
|
||||||
p = 0;
|
|
||||||
|
|
||||||
if( p > 100 )
|
|
||||||
p = 100;
|
|
||||||
|
|
||||||
ticket.progress = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ReadTicket(Ticket & ticket)
|
|
||||||
{
|
|
||||||
ticket.parent_id = request.dir_table.back()->id;
|
|
||||||
|
|
||||||
ReadTicketType(ticket);
|
|
||||||
ReadTicketStatus(ticket);
|
|
||||||
ReadTicketPriority(ticket);
|
|
||||||
ReadTicketCategory(ticket);
|
|
||||||
ReadTicketExpected(ticket);
|
|
||||||
ReadTicketProgress(ticket);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::AddTicket()
|
|
||||||
{
|
|
||||||
static std::string temp;
|
|
||||||
|
|
||||||
request.ticket.dir_id = request.dir_table.back()->id; // a new directory created by Mkdir()
|
|
||||||
request.ticket.item_id = request.item.id; // this id is set by PostFunEmacsAdd()
|
|
||||||
|
|
||||||
request.status = db.AddTicket(request.ticket);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunCreateTicketLogAndRedirect()
|
|
||||||
{
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
log << log2 << "Content: added a new ticket" << logend;
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "Content: problem with adding a new ticket, error code: "
|
|
||||||
<< request.status << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunCreateTicket()
|
|
||||||
{
|
|
||||||
if( !FunCreateTicketCheckAccess() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
ReadItem(request.item, Item::dir);
|
|
||||||
SetUser(request.item);
|
|
||||||
ReadTicket(request.ticket);
|
|
||||||
request.item.privileges = 0777; // !! tymczasowo 777 aby wszyscy mogli wysylac posty
|
|
||||||
|
|
||||||
if( !FunCreateTicketCheckAbuse() )
|
|
||||||
{
|
|
||||||
ReadItemContentWithType(request.item); // for correctly displaying the form
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Mkdir(request.item, true);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
ReadItemContentWithType(request.item);
|
|
||||||
request.item.type = Item::file;
|
|
||||||
request.item.privileges = 0644; // !! tymczasowo
|
|
||||||
request.item.parent_id = request.dir_table.back()->id;
|
|
||||||
PostFunEmacsAdd(request.item);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
AddTicket();
|
|
||||||
}
|
|
||||||
|
|
||||||
PostFunCreateTicketLogAndRedirect();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunCreateTicket()
|
|
||||||
{
|
|
||||||
FunCreateTicketCheckAccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 && !path->empty() )
|
|
||||||
{
|
|
||||||
std::string dir, file;
|
|
||||||
Dirs::SplitPath(*path, dir, file);
|
|
||||||
|
|
||||||
pdir = data.dirs.GetDir(dir);
|
|
||||||
|
|
||||||
if( !pdir )
|
|
||||||
throw Error(WINIX_ERR_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(WINIX_ERR_NO_ITEM);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// file is a directory
|
|
||||||
defaultid = pdir2->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunDefault()
|
|
||||||
{
|
|
||||||
if( !request.HasWriteAccess(*request.dir_table.back()) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
long defaultid = PostFunDefaultParsePath();
|
|
||||||
request.status = db.EditDefaultItem(request.dir_table.back()->id, defaultid);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
request.dir_table.back()->default_item = defaultid;
|
|
||||||
}
|
|
||||||
catch(const Error & e)
|
|
||||||
{
|
|
||||||
request.status = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
RedirectTo(*request.dir_table.back());
|
|
||||||
else
|
|
||||||
log << log1 << "Content: PostFunDefaultItem: Error: " << request.status << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunDefault()
|
|
||||||
{
|
|
||||||
if( !request.HasWriteAccess(*request.dir_table.back()) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/data.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunDownload()
|
|
||||||
{
|
|
||||||
// !! moze wywalic to no_item i wszedzie w takich miejscach dac poprostu permission_denied?
|
|
||||||
if( !request.is_item )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: download function requires an item" << logend;
|
|
||||||
request.status = WINIX_ERR_NO_ITEM;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( !request.HasReadAccess(request.item) ||
|
|
||||||
request.item.auth == Item::auth_none ||
|
|
||||||
request.item.auth_path.empty() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
request.send_as_attachment = request.IsParam("attachment");
|
|
||||||
request.x_sendfile = request.item.auth_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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::FunEditTicketCheckAccess()
|
|
||||||
{
|
|
||||||
if( !request.CanEditTicket() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::EditTicketCheckFirstItem()
|
|
||||||
{
|
|
||||||
if( request.status != WINIX_ERR_OK )
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
if( request.ticket.item_id == -1 )
|
|
||||||
{
|
|
||||||
// creating a new item (the item was deleted by a user)
|
|
||||||
|
|
||||||
Item item;
|
|
||||||
item.parent_id = request.dir_table.back()->id;
|
|
||||||
item.subject = request.dir_table.back()->subject;
|
|
||||||
item.type = Item::file;
|
|
||||||
item.privileges = 0644; // !! tymczasowo
|
|
||||||
SetUser(item);
|
|
||||||
PrepareUrl(item);
|
|
||||||
|
|
||||||
request.status = db.AddItem(item);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
log << log2 << "Content: added the first item with content for the ticket, item.id: " << item.id << logend;
|
|
||||||
request.ticket.item_id = item.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::EditTicketModTicket()
|
|
||||||
{
|
|
||||||
if( request.status != WINIX_ERR_OK )
|
|
||||||
return;
|
|
||||||
|
|
||||||
Ticket ticket;
|
|
||||||
ReadTicket(ticket);
|
|
||||||
|
|
||||||
request.ticket.type = ticket.type;
|
|
||||||
request.ticket.status = ticket.status;
|
|
||||||
request.ticket.priority = ticket.priority;
|
|
||||||
request.ticket.category = ticket.category;
|
|
||||||
request.ticket.expected = ticket.expected;
|
|
||||||
request.ticket.progress = ticket.progress;
|
|
||||||
|
|
||||||
request.status = db.EditTicketById(request.ticket);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::EditTicketModDir()
|
|
||||||
{
|
|
||||||
if( request.status != WINIX_ERR_OK )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// we don't modify the url
|
|
||||||
|
|
||||||
Item & dir = *request.dir_table.back();
|
|
||||||
bool edit_dir_subject = (dir.subject != request.item.subject);
|
|
||||||
|
|
||||||
if( edit_dir_subject )
|
|
||||||
{
|
|
||||||
dir.subject = request.item.subject;
|
|
||||||
request.status = db.EditItemById(dir, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::EditTicketModFirstItem()
|
|
||||||
{
|
|
||||||
if( request.status != WINIX_ERR_OK )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// modyfing the first item (the one with content)
|
|
||||||
ReadItemContentWithType(request.item);
|
|
||||||
|
|
||||||
Item item;
|
|
||||||
db.GetItemById(request.ticket.item_id, item);
|
|
||||||
item.subject = request.item.subject;
|
|
||||||
item.content = request.item.content;
|
|
||||||
item.content_type = request.item.content_type;
|
|
||||||
// the url doesn't matter
|
|
||||||
|
|
||||||
db.EditItemById(item, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunEditTicketLogAndRedirect()
|
|
||||||
{
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
log << log2 << "Content: edited a ticket" << logend;
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "Content: problem with editing a ticket, error code: "
|
|
||||||
<< request.status << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunEditTicket()
|
|
||||||
{
|
|
||||||
if( !FunEditTicketCheckAccess() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
ReadItem(request.item, Item::dir);
|
|
||||||
// co z uzytkownikiem i grup¹? chyba nie wczytane? !!! (wczesniej bylo SetUser() w ReadItem() - teraz nie ma)
|
|
||||||
// dodac informacje o modyfikacji !!!
|
|
||||||
|
|
||||||
if( !FunCreateTicketCheckAbuse() )
|
|
||||||
{
|
|
||||||
ReadItemContentWithType(request.item); // for correctly displaying the form
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) != WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EditTicketCheckFirstItem();
|
|
||||||
EditTicketModTicket();
|
|
||||||
EditTicketModDir();
|
|
||||||
EditTicketModFirstItem();
|
|
||||||
PostFunEditTicketLogAndRedirect();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunEditTicket()
|
|
||||||
{
|
|
||||||
FunEditTicketCheckAccess();
|
|
||||||
|
|
||||||
db.GetItemById(request.ticket.item_id, request.item);
|
|
||||||
|
|
||||||
// the subject we get from the last directory
|
|
||||||
request.item.subject = request.dir_table.back()->subject;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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"
|
|
||||||
#include "../core/misc.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::FunEmacsCheckAccess()
|
|
||||||
{
|
|
||||||
if( !request.is_item )
|
|
||||||
{
|
|
||||||
// adding a new item
|
|
||||||
if( !request.CanUseEmacs(*request.dir_table.back()) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // editing an existing item
|
|
||||||
if( !request.CanUseEmacs(request.item) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunEmacsAdd(Item & item)
|
|
||||||
{
|
|
||||||
request.status = db.AddItem(item);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
log << log2 << "Content: added a new item, url: " << item.url << ", id: " << item.id
|
|
||||||
<< ", parent_id: " << item.parent_id << logend;
|
|
||||||
|
|
||||||
request.notify_code |= WINIX_NOTIFY_ITEM_ADD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunEmacsEdit(bool with_url)
|
|
||||||
{
|
|
||||||
if( request.session->puser )
|
|
||||||
request.item.modification_user_id = request.session->puser->id;
|
|
||||||
else
|
|
||||||
request.item.modification_user_id = -1;
|
|
||||||
|
|
||||||
request.item.SetDateModifyToNow();
|
|
||||||
request.status = db.EditItemById(request.item, with_url);
|
|
||||||
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
TemplatesFunctions::pattern_cacher.UpdatePattern(request.item);
|
|
||||||
log << log2 << "Content: modified an item" << logend;
|
|
||||||
|
|
||||||
request.notify_code |= WINIX_NOTIFY_ITEM_EDIT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::PostEmacsCheckAbuse(bool adding)
|
|
||||||
{
|
|
||||||
if( !CheckRebus() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_INCORRECT_REBUS;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// !! is tested in createthread once
|
|
||||||
CheckGetPostTimes();
|
|
||||||
|
|
||||||
if( request.session->spam_score > 0 )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_SPAM;
|
|
||||||
log << log1 << "Content: ignoring due to suspected spamming" << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunEmacsModifyMountPoint(bool adding)
|
|
||||||
{
|
|
||||||
if( data.mounts.pmount->type == Mount::thread )
|
|
||||||
{
|
|
||||||
if( adding )
|
|
||||||
db.EditThreadAddItem(request.dir_table.back()->id, request.item.id);
|
|
||||||
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( data.mounts.pmount->type == Mount::ticket )
|
|
||||||
{
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Mount::cms
|
|
||||||
RedirectTo(request.item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunEmacs()
|
|
||||||
{
|
|
||||||
if( !FunEmacsCheckAccess() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool adding = !request.is_item;
|
|
||||||
bool edit_with_url = ReadItem(request.item, Item::file);
|
|
||||||
|
|
||||||
if( adding )
|
|
||||||
SetUser(request.item); // set user before checking the rebus
|
|
||||||
|
|
||||||
if( !PostEmacsCheckAbuse(adding) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( adding )
|
|
||||||
{
|
|
||||||
request.is_item = true;
|
|
||||||
request.item.privileges = 0644; // !! tymczasowo, bedzie uzyte umask
|
|
||||||
PostFunEmacsAdd(request.item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PostFunEmacsEdit(edit_with_url);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
PostFunEmacsModifyMountPoint(adding);
|
|
||||||
CheckSpecialFile();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "Content: PostFunEmacs: Error: "
|
|
||||||
<< request.status << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunEmacs()
|
|
||||||
{
|
|
||||||
FunEmacsCheckAccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunLast()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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::LoginUser(long user_id, bool remember_me)
|
|
||||||
{
|
|
||||||
request.session->puser = data.users.GetUser(user_id);
|
|
||||||
request.session->spam_score = 0;
|
|
||||||
|
|
||||||
if( !request.session->puser )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: user id: " << user_id << " is not in data.users" << logend;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
request.session->remember_me = remember_me;
|
|
||||||
|
|
||||||
data.last.UserLogin(user_id, request.session->puser->name, inet_addr(request.env_remote_addr), request.session->id);
|
|
||||||
data.how_many_logged += 1;
|
|
||||||
|
|
||||||
log << log2 << "User " << request.session->puser->name << " (id: " << user_id << ") logged" << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunLogin()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::string * login = request.PostVar("login");
|
|
||||||
std::string * pass = request.PostVar("password");
|
|
||||||
std::string * remem = request.PostVar("rememberme");
|
|
||||||
long user_id;
|
|
||||||
|
|
||||||
if( login && pass && db.CheckUser(*login, *pass, user_id) )
|
|
||||||
LoginUser(user_id, remem != 0);
|
|
||||||
|
|
||||||
// !! moze zglosic komunikat o nie poprawnym logowaniu
|
|
||||||
}
|
|
||||||
catch(const Error &)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( request.is_item )
|
|
||||||
RedirectTo(request.item);
|
|
||||||
else
|
|
||||||
RedirectTo(*request.dir_table.back());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunLogin()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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);
|
|
||||||
|
|
||||||
if( data.how_many_logged > 0 ) // for safety
|
|
||||||
data.how_many_logged -= 1;
|
|
||||||
|
|
||||||
request.session->puser = 0;
|
|
||||||
request.session->remember_me = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string path;
|
|
||||||
data.dirs.MakePath(request.dir_table.back()->id, path);
|
|
||||||
request.redirect_to = data.base_url + path;
|
|
||||||
|
|
||||||
if( request.is_item )
|
|
||||||
request.redirect_to += request.item.url;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/db.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunLs()
|
|
||||||
{
|
|
||||||
if( !request.is_item )
|
|
||||||
{
|
|
||||||
Db::ItemQuery iq;
|
|
||||||
|
|
||||||
iq.sel_content = false;
|
|
||||||
|
|
||||||
iq.WhereParentId(request.dir_table.back()->id);
|
|
||||||
iq.WhereType(Item::file);
|
|
||||||
|
|
||||||
if( request.IsParam("ckeditor_browse") )
|
|
||||||
{
|
|
||||||
iq.WhereAuth(Item::auth_image);
|
|
||||||
db.GetItems(request.item_table, iq);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
db.GetItems(request.item_table, iq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/misc.h"
|
|
||||||
#include "../core/db.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// returning true if the 'url' has to be changed
|
|
||||||
bool Content::ReadItemUrlSubject(Item & item, Item::Type item_type)
|
|
||||||
{
|
|
||||||
bool with_url = false;
|
|
||||||
|
|
||||||
std::string * new_url = request.PostVar("url");
|
|
||||||
std::string * new_subject = request.PostVar("subject");
|
|
||||||
|
|
||||||
if( item_type == Item::file )
|
|
||||||
{
|
|
||||||
if( !request.is_item || (new_url && *new_url != item.url) )
|
|
||||||
with_url = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
with_url = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( new_url )
|
|
||||||
item.url = *new_url;
|
|
||||||
|
|
||||||
if( new_subject )
|
|
||||||
item.subject = *new_subject;
|
|
||||||
|
|
||||||
|
|
||||||
if( item.subject.empty() )
|
|
||||||
{
|
|
||||||
item.subject = request.dir_table.back()->subject;
|
|
||||||
item.subject += "_msg_";
|
|
||||||
item.subject += ToStr(db.Size(request.dir_table.back()->id, Item::file));
|
|
||||||
}
|
|
||||||
|
|
||||||
// if item.url is empty then it will be set from item.subject
|
|
||||||
PrepareUrl(item);
|
|
||||||
|
|
||||||
return with_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ReadItemContentWithType(Item & item)
|
|
||||||
{
|
|
||||||
item.content_type = Item::ct_formatted_text; // default is formatted text
|
|
||||||
request.PostVar("itemcontent", request.item.content);
|
|
||||||
request.PostVar("contenttype", temp);
|
|
||||||
|
|
||||||
// ct_text and ct_formatted_text can use everyone
|
|
||||||
|
|
||||||
if( temp == "0" )
|
|
||||||
item.content_type = Item::ct_text;
|
|
||||||
else
|
|
||||||
if( temp == "1" )
|
|
||||||
item.content_type = Item::ct_formatted_text;
|
|
||||||
|
|
||||||
|
|
||||||
// those below need special privileges
|
|
||||||
|
|
||||||
if( !request.session->puser )
|
|
||||||
return;
|
|
||||||
|
|
||||||
long user_id = request.session->puser->id;
|
|
||||||
|
|
||||||
|
|
||||||
if( temp == "2" )
|
|
||||||
{
|
|
||||||
if( request.CanUseHtml(user_id) )
|
|
||||||
item.content_type = Item::ct_html;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( temp == "3" )
|
|
||||||
{
|
|
||||||
if( request.CanUseBBCode(user_id) )
|
|
||||||
item.content_type = Item::ct_bbcode;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( temp == "4" )
|
|
||||||
{
|
|
||||||
if( request.CanUseRaw(user_id) )
|
|
||||||
item.content_type = Item::ct_raw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// item_type - the type of an item you are expecting to read
|
|
||||||
// returns true if the url has to be changed
|
|
||||||
// at the moment this is only checked for Item::file - for Item::dir it returns always true
|
|
||||||
bool Content::ReadItem(Item & item, Item::Type item_type)
|
|
||||||
{
|
|
||||||
if( item_type == Item::none )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
item.type = item_type;
|
|
||||||
item.parent_id = request.dir_table.back()->id;
|
|
||||||
|
|
||||||
bool edit_with_url = ReadItemUrlSubject(item, item_type);
|
|
||||||
|
|
||||||
if( item_type == Item::file )
|
|
||||||
ReadItemContentWithType(item);
|
|
||||||
|
|
||||||
return edit_with_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if we don't have access we only remove the item from the table
|
|
||||||
void Content::CheckAccessToItems()
|
|
||||||
{
|
|
||||||
size_t i = 0;
|
|
||||||
|
|
||||||
while( i < request.item_table.size() )
|
|
||||||
{
|
|
||||||
if( !request.HasReadAccess(request.item_table[i]) )
|
|
||||||
{
|
|
||||||
request.item_table.erase(request.item_table.begin() + i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/data.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::CheckSpecialFile()
|
|
||||||
{
|
|
||||||
static std::string fstab = "fstab";
|
|
||||||
|
|
||||||
Item * etc = data.dirs.GetEtcDir();
|
|
||||||
|
|
||||||
if( !etc )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( request.item.parent_id != etc->id )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( request.item.url == fstab )
|
|
||||||
{
|
|
||||||
log << log3 << "Content: reloading mount points" << logend;
|
|
||||||
|
|
||||||
request.status = data.mounts.ReadMounts(request.item.content);
|
|
||||||
templates.ReadNewIndexTemplates();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::FunMkdirCheckAccess()
|
|
||||||
{
|
|
||||||
if( request.is_item || !request.CanUseMkdir(*request.dir_table.back()) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::Mkdir(Item & item, bool add_to_dir_table)
|
|
||||||
{
|
|
||||||
request.status = db.AddItem(item);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
Item * pdir = data.dirs.AddDir(item);
|
|
||||||
|
|
||||||
if( add_to_dir_table )
|
|
||||||
request.dir_table.push_back(pdir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunMkdir(bool add_to_dir_table, int privileges)
|
|
||||||
{
|
|
||||||
if( !FunMkdirCheckAccess() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
ReadItem(request.item, Item::dir);
|
|
||||||
SetUser(request.item);
|
|
||||||
request.item.privileges = privileges;
|
|
||||||
|
|
||||||
Mkdir(request.item, add_to_dir_table);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
request.notify_code |= WINIX_NOTIFY_DIR_ADD;
|
|
||||||
RedirectTo(request.item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "Content: PostFunMkdir: Error: " << request.status << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunMkdir()
|
|
||||||
{
|
|
||||||
PostFunMkdir(false, 0755);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunMkdir()
|
|
||||||
{
|
|
||||||
FunMkdirCheckAccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
364
content/mv.cpp
364
content/mv.cpp
@@ -1,364 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/data.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::MoveCheckAccessFromToDir()
|
|
||||||
{
|
|
||||||
Item * last;
|
|
||||||
Item * last_but_one = 0;
|
|
||||||
|
|
||||||
last = request.dir_table[request.dir_table.size()-1];
|
|
||||||
|
|
||||||
if( request.dir_table.size() >= 2 )
|
|
||||||
last_but_one = request.dir_table[request.dir_table.size()-2];
|
|
||||||
|
|
||||||
if( request.method != Request::post )
|
|
||||||
{
|
|
||||||
// used in GET (HEAD in the future?)
|
|
||||||
|
|
||||||
if( !request.HasWriteAccess(*last) &&
|
|
||||||
(!last_but_one || !request.HasWriteAccess(*last_but_one)) )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// used in POST when the moving is performed
|
|
||||||
|
|
||||||
if( request.IsPostVar("onlycontent") )
|
|
||||||
return request.HasWriteAccess(*last);
|
|
||||||
else
|
|
||||||
if( last_but_one )
|
|
||||||
return request.HasWriteAccess(*last_but_one);
|
|
||||||
else
|
|
||||||
return false; // you cannot move the root directory
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::MoveCheckAccessFrom()
|
|
||||||
{
|
|
||||||
if( request.is_item )
|
|
||||||
{
|
|
||||||
// moving a file
|
|
||||||
|
|
||||||
if( !request.HasWriteAccess(*request.dir_table.back()) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( !MoveCheckAccessFromToDir() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::MoveCheckAccessTo(long dir_id)
|
|
||||||
{
|
|
||||||
Item * pdir = data.dirs.GetDir(dir_id);
|
|
||||||
|
|
||||||
if( !pdir )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_INCORRECT_DIR;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !request.HasReadExecAccessToPath(dir_id) || !request.HasWriteAccess(*pdir) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::MoveCheckMountPoints(long dir_id)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Mount * new_mount = data.mounts.CalcMount(dir_id);
|
|
||||||
|
|
||||||
if( !new_mount )
|
|
||||||
{
|
|
||||||
if( data.mounts.pmount->type != Mount::cms )
|
|
||||||
{
|
|
||||||
request.status = WINIX_DIFFERENT_MOUNT_POINTS;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( new_mount->type != data.mounts.pmount->type )
|
|
||||||
{
|
|
||||||
request.status = WINIX_DIFFERENT_MOUNT_POINTS;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::MoveParseDir(long & dir_id, std::string & dir, std::string & file)
|
|
||||||
{
|
|
||||||
std::string * move_to = request.PostVar("to");
|
|
||||||
|
|
||||||
if( !move_to )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int res = data.dirs.AnalyzePath(*move_to, dir_id, dir, file);
|
|
||||||
|
|
||||||
if( res == 1 )
|
|
||||||
request.status = WINIX_ERR_NO_ROOT_DIR;
|
|
||||||
else
|
|
||||||
if( res != 0 )
|
|
||||||
request.status = WINIX_ERR_INCORRECT_DIR;
|
|
||||||
|
|
||||||
return res == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::MoveAuth(Item & item)
|
|
||||||
{
|
|
||||||
if( !request.MakePath(item, mv_new_path, true) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( rename(item.auth_path.c_str(), mv_new_path.c_str()) == 0 )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: moved static file from: " << item.auth_path << ", to: " << mv_new_path << logend;
|
|
||||||
item.auth_path = mv_new_path;
|
|
||||||
request.status = db.EditAuthById(item, item.id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int err = errno;
|
|
||||||
|
|
||||||
log << log1 << "Content: can't move a file from: " << item.auth_path << ", to: " << mv_new_path << ", ";
|
|
||||||
log.SystemErr(err);
|
|
||||||
log << logend;
|
|
||||||
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::MoveIsTheSameFile(const Item & item)
|
|
||||||
{
|
|
||||||
if( mv_file.empty() )
|
|
||||||
{
|
|
||||||
if( item.parent_id == mv_dir_id )
|
|
||||||
return true; // nothing to do
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( item.parent_id == mv_dir_id && item.url == mv_file )
|
|
||||||
return true; // nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::MoveFile(Item & item, bool redirect)
|
|
||||||
{
|
|
||||||
if( MoveIsTheSameFile(item) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( !mv_file.empty() )
|
|
||||||
{
|
|
||||||
item.url = mv_file;
|
|
||||||
PrepareUrl(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
item.parent_id = mv_dir_id;
|
|
||||||
request.status = db.EditParentUrlById(item, item.id);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
log << log2 << "Content: the file was moved to: " << mv_dir << item.url << logend;
|
|
||||||
|
|
||||||
if( item.auth != Item::auth_none )
|
|
||||||
MoveAuth(item);
|
|
||||||
|
|
||||||
if( redirect )
|
|
||||||
RedirectTo(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::MoveContentOfDir()
|
|
||||||
{
|
|
||||||
Db::ItemQuery iq;
|
|
||||||
|
|
||||||
iq.sel_parent_id = true;
|
|
||||||
iq.sel_type = true;
|
|
||||||
iq.sel_url = true;
|
|
||||||
iq.sel_auth = true;
|
|
||||||
iq.WhereParentId(request.dir_table.back()->id);
|
|
||||||
|
|
||||||
db.GetItems(request.item_table, iq);
|
|
||||||
|
|
||||||
for(size_t i=0 ; i<request.item_table.size() ; ++i)
|
|
||||||
{
|
|
||||||
if( request.item_table[i].type == Item::dir )
|
|
||||||
MoveDir(request.item_table[i], false);
|
|
||||||
else
|
|
||||||
MoveFile(request.item_table[i], false);
|
|
||||||
}
|
|
||||||
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::MoveAuthPrepareQuery()
|
|
||||||
{
|
|
||||||
mv_auth_iq.SetAll(false, false);
|
|
||||||
|
|
||||||
mv_auth_iq.sel_parent_id = true;
|
|
||||||
mv_auth_iq.sel_type = true;
|
|
||||||
mv_auth_iq.sel_url = true;
|
|
||||||
mv_auth_iq.sel_auth = true;
|
|
||||||
|
|
||||||
mv_auth_iq.WhereType(Item::file);
|
|
||||||
mv_auth_iq.WhereAuth(Item::auth_none, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::MoveAuthContentOfDir(const Item & item)
|
|
||||||
{
|
|
||||||
DirContainer::ParentIterator i = data.dirs.FindFirstParent(item.id);
|
|
||||||
|
|
||||||
// go through all directories
|
|
||||||
for( ; i != data.dirs.ParentEnd() ; i = data.dirs.NextParent(i) )
|
|
||||||
MoveAuthContentOfDir(*(i->second));
|
|
||||||
|
|
||||||
mv_auth_iq.WhereParentId(item.id);
|
|
||||||
|
|
||||||
// don't use request.item here (is used in MoveContentOfDir())
|
|
||||||
db.GetItems(mv_auth, mv_auth_iq);
|
|
||||||
|
|
||||||
for(size_t i=0 ; i<mv_auth.size() ; ++i)
|
|
||||||
MoveAuth(mv_auth[i]);
|
|
||||||
|
|
||||||
mv_auth.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::MoveDir(Item & item, bool redirect)
|
|
||||||
{
|
|
||||||
if( mv_file.empty() && mv_dir_id == item.id )
|
|
||||||
return; // nothing to do
|
|
||||||
|
|
||||||
if( mv_dir_id == item.id || data.dirs.HasParent(mv_dir_id, item.id) )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: cannot move directory to inside it" << logend;
|
|
||||||
request.status = WINIX_ERR_INCORRECT_DIR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !data.dirs.ChangeParent(item.id, mv_dir_id) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_INCORRECT_DIR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
item.parent_id = mv_dir_id;
|
|
||||||
|
|
||||||
if( !mv_file.empty() )
|
|
||||||
{
|
|
||||||
item.url = mv_file;
|
|
||||||
PrepareUrl(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
request.status = db.EditParentUrlById(item, item.id);
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
log << log2 << "Content: the directory was moved to: " << mv_dir << item.url << logend;
|
|
||||||
MoveAuthContentOfDir(item);
|
|
||||||
|
|
||||||
if( redirect )
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunMv()
|
|
||||||
{
|
|
||||||
if( MoveCheckAccessFrom() &&
|
|
||||||
MoveParseDir(mv_dir_id, mv_dir, mv_file) &&
|
|
||||||
MoveCheckAccessTo(mv_dir_id) &&
|
|
||||||
MoveCheckMountPoints(mv_dir_id) )
|
|
||||||
{
|
|
||||||
if( request.is_item )
|
|
||||||
{
|
|
||||||
MoveFile(request.item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveAuthPrepareQuery();
|
|
||||||
|
|
||||||
if( request.IsPostVar("onlycontent") )
|
|
||||||
{
|
|
||||||
if( mv_file.empty() )
|
|
||||||
MoveContentOfDir();
|
|
||||||
else
|
|
||||||
request.status = WINIX_ERR_INCORRECT_DIR;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveDir(*request.dir_table.back());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunMv()
|
|
||||||
{
|
|
||||||
MoveCheckAccessFrom();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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].name.c_str() );
|
|
||||||
|
|
||||||
RedirectTo(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
311
content/priv.cpp
311
content/priv.cpp
@@ -1,311 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/error.h"
|
|
||||||
#include "../core/db.h"
|
|
||||||
#include "../core/data.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::PrivCheckAccess()
|
|
||||||
{
|
|
||||||
// we do not check permissions here
|
|
||||||
// permissions depends on the user, group, and privileges
|
|
||||||
// but we cannot use parameter 'r' on files
|
|
||||||
// and only logged users can change permissions
|
|
||||||
|
|
||||||
if( !request.session->puser || (request.is_item && request.IsParam("r")) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::ChangeOwner(Item & item, long user_id, long group_id)
|
|
||||||
{
|
|
||||||
if( user_id!=item.user_id || group_id!=item.group_id )
|
|
||||||
{
|
|
||||||
if( !request.CanChangeUser(item, user_id) )
|
|
||||||
{
|
|
||||||
log << log3 << "Content: can't change the user" << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !request.CanChangeGroup(item, group_id) )
|
|
||||||
{
|
|
||||||
log << log3 << "Content: can't change the group" << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item.user_id = user_id;
|
|
||||||
item.group_id = group_id;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::ChangePrivileges(Item & item, int privileges)
|
|
||||||
{
|
|
||||||
if( privileges != item.privileges )
|
|
||||||
{
|
|
||||||
if( !request.CanChangePrivileges(item, privileges) )
|
|
||||||
{
|
|
||||||
log << log3 << "Content: can't change privileges" << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item.privileges = privileges;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::ChangePriv(Item & item, long user_id, long group_id, int privileges)
|
|
||||||
{
|
|
||||||
if( change_owner )
|
|
||||||
{
|
|
||||||
if( !ChangeOwner(item, user_id, group_id) )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( change_priv )
|
|
||||||
{
|
|
||||||
if( !ChangePrivileges(item, privileges) )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
request.status = db.EditPrivById(item, item.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PrivLogStart(const char * what, long user, long group, int priv)
|
|
||||||
{
|
|
||||||
log << log2 << what;
|
|
||||||
|
|
||||||
if( change_owner )
|
|
||||||
{
|
|
||||||
User * puser = data.users.GetUser(user);
|
|
||||||
Group * pgroup = data.groups.GetGroup(group);
|
|
||||||
|
|
||||||
log << "new user: ";
|
|
||||||
|
|
||||||
if( puser )
|
|
||||||
log << puser->name;
|
|
||||||
else
|
|
||||||
log << "id: " << user;
|
|
||||||
|
|
||||||
log << ", new group: ";
|
|
||||||
|
|
||||||
if( pgroup )
|
|
||||||
log << pgroup->name;
|
|
||||||
else
|
|
||||||
log << "id: " << group;
|
|
||||||
|
|
||||||
if( change_priv )
|
|
||||||
log << ", ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if( change_priv )
|
|
||||||
{
|
|
||||||
char buf[30];
|
|
||||||
sprintf(buf, "0%o", priv);
|
|
||||||
log << "privileges: " << buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
log << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PrivLog(const char * what, long id, const std::string & url)
|
|
||||||
{
|
|
||||||
Item * root = 0;
|
|
||||||
|
|
||||||
if( id != -1 )
|
|
||||||
root = data.dirs.GetRootDir();
|
|
||||||
|
|
||||||
log << log3 << "Content: " << what;
|
|
||||||
|
|
||||||
if( root && root->id == id )
|
|
||||||
log << "(root)";
|
|
||||||
else
|
|
||||||
log << url;
|
|
||||||
|
|
||||||
log << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PrivFilesInDir(long parent_id)
|
|
||||||
{
|
|
||||||
Db::ItemQuery iq;
|
|
||||||
|
|
||||||
iq.SetAll(false, false);
|
|
||||||
iq.sel_user_id = iq.sel_group_id = iq.sel_guest_name = iq.sel_privileges = true;
|
|
||||||
|
|
||||||
iq.WhereParentId(parent_id);
|
|
||||||
iq.WhereType(Item::file);
|
|
||||||
|
|
||||||
db.GetItems(request.item_table, iq);
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<Item>::iterator i = request.item_table.begin();
|
|
||||||
|
|
||||||
for( ; i != request.item_table.end() ; ++i)
|
|
||||||
{
|
|
||||||
PrivLog("changed file: ", -1, i->url);
|
|
||||||
ChangePriv(*i, user_id_file, group_id_file, priv_file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// recurrence
|
|
||||||
void Content::PrivDir(long parent_id)
|
|
||||||
{
|
|
||||||
PrivFilesInDir(parent_id);
|
|
||||||
|
|
||||||
|
|
||||||
DirContainer::ParentIterator i = data.dirs.FindFirstParent(parent_id);
|
|
||||||
|
|
||||||
for( ; i != data.dirs.ParentEnd() ; i = data.dirs.NextParent(i) )
|
|
||||||
{
|
|
||||||
PrivLog("changed dir: ", -1, i->second->url);
|
|
||||||
ChangePriv(*(i->second), user_id_dir, group_id_dir, priv_dir);
|
|
||||||
|
|
||||||
if( subdirectories )
|
|
||||||
PrivDir(i->second->id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::ReadPriv(const char * user_in, const char * group_in, const char * priv_in,
|
|
||||||
long & user_id, long & group_id, int & priv)
|
|
||||||
{
|
|
||||||
std::string * user_str = request.PostVar(user_in);
|
|
||||||
std::string * group_str = request.PostVar(group_in);
|
|
||||||
std::string * priv_str = request.PostVar(priv_in);
|
|
||||||
|
|
||||||
if( change_owner && (!user_str || !group_str) )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: PostFunPriv: there is no some post variables for changing the owner" << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( change_priv && !priv_str )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: PostFunPriv: there is no some post variables for changing privileges" << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( change_owner )
|
|
||||||
{
|
|
||||||
user_id = data.users.GetUserId( *user_str );
|
|
||||||
group_id = data.groups.GetGroupId( *group_str );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( change_priv )
|
|
||||||
priv = strtol( priv_str->c_str() , 0, 8);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PrivDir()
|
|
||||||
{
|
|
||||||
if( !ReadPriv("userfile", "groupfile", "privilegesfile", user_id_file, group_id_file, priv_file) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( !ReadPriv("userdir", "groupdir", "privilegesdir", user_id_dir, group_id_dir, priv_dir) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
PrivLogStart("Content: changes for files: ", user_id_file, group_id_file, priv_file);
|
|
||||||
PrivLogStart("Content: changes for dirs: ", user_id_dir, group_id_dir, priv_dir);
|
|
||||||
|
|
||||||
|
|
||||||
if( request.IsPostVar("changecurrentdir") )
|
|
||||||
{
|
|
||||||
Item & last_dir = *request.dir_table.back();
|
|
||||||
PrivLog("changed dir: ", last_dir.id, last_dir.url);
|
|
||||||
ChangePriv(*request.dir_table.back(), user_id_dir, group_id_dir, priv_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
subdirectories = request.IsPostVar("changesubdirs");
|
|
||||||
|
|
||||||
// go through all directories
|
|
||||||
PrivDir(request.dir_table.back()->id);
|
|
||||||
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// changing only one item (either a dir or file)
|
|
||||||
void Content::PrivOneItem()
|
|
||||||
{
|
|
||||||
if( !ReadPriv("user", "group", "privileges", user_id_file, group_id_file, priv_file) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
PrivLogStart("Content: changes: ", user_id_file, group_id_file, priv_file);
|
|
||||||
|
|
||||||
if( request.is_item )
|
|
||||||
{
|
|
||||||
ChangePriv(request.item, user_id_file, group_id_file, priv_file);
|
|
||||||
RedirectTo(request.item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ChangePriv(*request.dir_table.back(), user_id_file, group_id_file, priv_file);
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunPriv()
|
|
||||||
{
|
|
||||||
if( !PrivCheckAccess() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
change_owner = (request.pfunction->code == FUN_PRIV || request.pfunction->code == FUN_CHOWN);
|
|
||||||
change_priv = (request.pfunction->code == FUN_PRIV || request.pfunction->code == FUN_CHMOD);
|
|
||||||
|
|
||||||
if( request.IsParam("r") )
|
|
||||||
{
|
|
||||||
PrivDir();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PrivOneItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
data.dirs.CheckRootDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunPriv()
|
|
||||||
{
|
|
||||||
PrivCheckAccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/error.h"
|
|
||||||
#include "../core/notify.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunReloadTemplates()
|
|
||||||
{
|
|
||||||
log << log1 << "Content: reloading html templates" << logend;
|
|
||||||
|
|
||||||
templates.ReadTemplates();
|
|
||||||
notify.ReadTemplates(); // make sure that ReadTemplates() is using some kind of locking
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunReload()
|
|
||||||
{
|
|
||||||
// !! temporarily only an admin has access
|
|
||||||
|
|
||||||
if( !request.session->puser || !request.session->puser->super_user )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: Only an admin has access to reload function" << logend;
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( request.IsParam("templates") )
|
|
||||||
FunReloadTemplates();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
210
content/rm.cpp
210
content/rm.cpp
@@ -1,210 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <errno.h>
|
|
||||||
#include "content.h"
|
|
||||||
#include "core/request.h"
|
|
||||||
#include "core/error.h"
|
|
||||||
#include "core/data.h"
|
|
||||||
#include "core/plugin.h"
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::RemoveCheckAccess()
|
|
||||||
{
|
|
||||||
if( !request.is_item )
|
|
||||||
{
|
|
||||||
if( !request.CanRemove(*request.dir_table.back()) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( !request.CanRemove(request.item) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::RemoveAuthPrepareQuery()
|
|
||||||
{
|
|
||||||
rm_auth_iq.SetAll(true, false);
|
|
||||||
|
|
||||||
rm_auth_iq.sel_parent_id = true;
|
|
||||||
rm_auth_iq.sel_type = true;
|
|
||||||
rm_auth_iq.sel_auth = true;
|
|
||||||
|
|
||||||
rm_auth_iq.WhereType(Item::file);
|
|
||||||
rm_auth_iq.WhereAuth(Item::auth_none, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::RemoveAllDirs(long dir_id)
|
|
||||||
{
|
|
||||||
DirContainer::ParentIterator pnext, p = data.dirs.FindFirstParent(dir_id);
|
|
||||||
|
|
||||||
for( ; p != data.dirs.ParentEnd() ; p = pnext )
|
|
||||||
{
|
|
||||||
// this iterator p will be deleted by the next DeleteDir(p->second->id)
|
|
||||||
// (the next iterator we must calculate beforehand)
|
|
||||||
pnext = data.dirs.NextParent(p);
|
|
||||||
RemoveAllDirs(p->second->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.Call(WINIX_DIR_PREPARE_TO_REMOVE, dir_id);
|
|
||||||
|
|
||||||
rm_auth_iq.WhereParentId(dir_id);
|
|
||||||
db.GetItems(request.item_table, rm_auth_iq);
|
|
||||||
|
|
||||||
for(size_t i=0 ; i<request.item_table.size() ; ++i)
|
|
||||||
RemoveAuth(request.item_table[i]);
|
|
||||||
|
|
||||||
if( db.DelDirById(dir_id) == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
data.dirs.DelDir(dir_id);
|
|
||||||
|
|
||||||
db.RemoveThread(dir_id);
|
|
||||||
db.RemoveTicket(dir_id);
|
|
||||||
|
|
||||||
plugin.Call(WINIX_DIR_REMOVED, dir_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::RemoveAllDirs()
|
|
||||||
{
|
|
||||||
RemoveAuthPrepareQuery();
|
|
||||||
|
|
||||||
// this method deletes recursively all directories
|
|
||||||
RemoveAllDirs(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(); // adding a new root dir
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::RemoveDir()
|
|
||||||
{
|
|
||||||
if( request.param_table.empty() )
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED; // use parameter "r" for removing a directory
|
|
||||||
else
|
|
||||||
if( request.IsParam("r") )
|
|
||||||
RemoveAllDirs();
|
|
||||||
else
|
|
||||||
request.status = WINIX_ERR_UNKNOWN_PARAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::RemoveAuth(Item & item)
|
|
||||||
{
|
|
||||||
if( item.auth_path.empty() )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: can't remove a static file: auth_path is empty" << logend;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( remove(item.auth_path.c_str()) == 0 )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: removed static file: " << item.auth_path << logend;
|
|
||||||
item.auth_path.clear();
|
|
||||||
item.auth = Item::auth_none;
|
|
||||||
// we don't store it to db (will be removed or is removed already)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int err = errno;
|
|
||||||
|
|
||||||
log << log1 << "Content: can't remove a file: " << item.auth_path;
|
|
||||||
log.SystemErr(err);
|
|
||||||
log << logend;
|
|
||||||
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::RemoveFile()
|
|
||||||
{
|
|
||||||
// for safety we check if param_table is empty
|
|
||||||
// a user can use "confirm" but can make a mistake when typing
|
|
||||||
if( !request.param_table.empty() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_UNKNOWN_PARAM;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( db.DelItem( request.item ) )
|
|
||||||
{
|
|
||||||
log << log2 << "Content: deleted item: subject: " << request.item.subject << ", id: " << request.item.id << logend;
|
|
||||||
TemplatesFunctions::pattern_cacher.DeletePattern(request.item);
|
|
||||||
|
|
||||||
plugin.Call(WINIX_FILE_REMOVED, request.item.id);
|
|
||||||
|
|
||||||
if( data.mounts.pmount->type == Mount::thread )
|
|
||||||
db.EditThreadRemoveItem(request.item.parent_id);
|
|
||||||
else
|
|
||||||
if( data.mounts.pmount->type == Mount::ticket )
|
|
||||||
db.EditTicketRemoveItem(request.item.id);
|
|
||||||
|
|
||||||
if( request.item.auth != Item::auth_none )
|
|
||||||
RemoveAuth(request.item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_NO_ITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunRm()
|
|
||||||
{
|
|
||||||
if( !RemoveCheckAccess() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( request.IsParam("confirm") )
|
|
||||||
return; // show confirmation dialog
|
|
||||||
|
|
||||||
if( request.is_item )
|
|
||||||
RemoveFile();
|
|
||||||
else
|
|
||||||
RemoveDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 = WINIX_ERR_NO_ITEM;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !request.HasReadExecAccess(request.item) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunRun()
|
|
||||||
{
|
|
||||||
FunRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/db.h"
|
|
||||||
#include "../core/log.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::SubjectCheckAccess()
|
|
||||||
{
|
|
||||||
// super user can always
|
|
||||||
if( request.session->puser && request.session->puser->super_user )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
bool access;
|
|
||||||
|
|
||||||
if( request.is_item )
|
|
||||||
access = request.HasWriteAccess(request.item);
|
|
||||||
else
|
|
||||||
access = request.HasWriteAccess(*request.dir_table.back());
|
|
||||||
|
|
||||||
if( !access )
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
|
|
||||||
return access;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::EditDirSubject()
|
|
||||||
{
|
|
||||||
Item & dir = *request.dir_table.back();
|
|
||||||
|
|
||||||
request.PostVar("subject", dir.subject);
|
|
||||||
db.EditSubjectById(dir, dir.id);
|
|
||||||
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::EditFileSubject()
|
|
||||||
{
|
|
||||||
request.PostVar("subject", request.item.subject);
|
|
||||||
db.EditSubjectById(request.item, request.item.id);
|
|
||||||
|
|
||||||
RedirectTo(request.item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::PostFunSubject()
|
|
||||||
{
|
|
||||||
if( !SubjectCheckAccess() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( request.is_item )
|
|
||||||
EditFileSubject();
|
|
||||||
else
|
|
||||||
EditDirSubject();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunSubject()
|
|
||||||
{
|
|
||||||
SubjectCheckAccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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()
|
|
||||||
{
|
|
||||||
if( request.is_item )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Db::ItemQuery iq;
|
|
||||||
|
|
||||||
if( data.mounts.pmount->IsArg(Mount::par_thread, "sort_desc") )
|
|
||||||
iq.sort_asc = false;
|
|
||||||
|
|
||||||
iq.WhereParentId(request.dir_table.back()->id);
|
|
||||||
iq.WhereType(Item::file);
|
|
||||||
iq.WhereAuth(Item::auth_none);
|
|
||||||
|
|
||||||
db.GetItems(request.item_table, iq);
|
|
||||||
db.GetThreads(request.dir_table.back()->id, request.thread_tab);
|
|
||||||
|
|
||||||
CheckAccessToItems();
|
|
||||||
|
|
||||||
std::sort(request.thread_tab.begin(), request.thread_tab.end(), FunThreadSort);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/db.h"
|
|
||||||
#include "../core/data.h"
|
|
||||||
#include "../core/mount.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::TicketDeleteFirst()
|
|
||||||
{
|
|
||||||
if( !request.is_ticket )
|
|
||||||
return;
|
|
||||||
|
|
||||||
for(size_t i=0 ; i<request.item_table.size() ; ++i)
|
|
||||||
{
|
|
||||||
if( request.item_table[i].id == request.ticket.item_id )
|
|
||||||
{
|
|
||||||
// this is the first item with the content for the ticket
|
|
||||||
|
|
||||||
if( !request.HasReadAccess(request.item_table[i]) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
request.item_table.erase(request.item_table.begin() + i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunTicket()
|
|
||||||
{
|
|
||||||
if( request.is_item || data.mounts.pmount->type != Mount::ticket )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Db::ItemQuery iq;
|
|
||||||
|
|
||||||
iq.WhereParentId(request.dir_table.back()->id);
|
|
||||||
iq.WhereType(Item::file);
|
|
||||||
iq.WhereAuth(Item::auth_none);
|
|
||||||
|
|
||||||
db.GetItems(request.item_table, iq);
|
|
||||||
db.GetTickets(request.dir_table.back()->id, request.ticket_tab);
|
|
||||||
|
|
||||||
TicketDeleteFirst();
|
|
||||||
CheckAccessToItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "content.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunUname()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,200 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <errno.h>
|
|
||||||
#include "content.h"
|
|
||||||
#include "../core/request.h"
|
|
||||||
#include "../core/data.h"
|
|
||||||
#include "../core/misc.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::FunUploadCheckAccess()
|
|
||||||
{
|
|
||||||
if( request.is_item || !request.CanUseUpload(*request.dir_table.back()) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::UploadCreatePath()
|
|
||||||
{
|
|
||||||
if( !request.MakePath(request.item, true) )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::UploadSaveFile(const std::string & tmp_filename, const std::string & destination)
|
|
||||||
{
|
|
||||||
if( rename(tmp_filename.c_str(), destination.c_str()) == 0 )
|
|
||||||
{
|
|
||||||
log << log1 << "Content: uploaded a new file: " << destination << logend;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int err = errno;
|
|
||||||
|
|
||||||
// !! skasowac takze plik z bazy danych?
|
|
||||||
log << log1 << "Content: can't move the tmp file from: " << tmp_filename << ", to: " << destination << ", ";
|
|
||||||
log.SystemErr(err);
|
|
||||||
log << logend;
|
|
||||||
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Content::FunUploadCheckAbuse()
|
|
||||||
{
|
|
||||||
if( !CheckRebus() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_INCORRECT_REBUS;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckGetPostTimes(4);
|
|
||||||
|
|
||||||
if( request.session->spam_score > 0 )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_SPAM;
|
|
||||||
log << log1 << "Content: ignoring due to suspected spamming" << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::UploadMulti()
|
|
||||||
{
|
|
||||||
request.item.Clear(); // clearing and setting date
|
|
||||||
request.item.parent_id = request.dir_table.back()->id;
|
|
||||||
request.item.type = Item::file;
|
|
||||||
request.item.privileges = 0644; // !! tymczasowo
|
|
||||||
SetUser(request.item);
|
|
||||||
|
|
||||||
PostFileTable::iterator i = request.post_file_table.begin();
|
|
||||||
|
|
||||||
for( ; i != request.post_file_table.end() ; ++i)
|
|
||||||
{
|
|
||||||
const char * file_name = i->second.filename.c_str();
|
|
||||||
|
|
||||||
request.item.subject = file_name;
|
|
||||||
request.item.url = file_name;
|
|
||||||
request.item.auth = SelectFileType(file_name);
|
|
||||||
|
|
||||||
PrepareUrl(request.item);
|
|
||||||
PostFunEmacsAdd(request.item); // always adding a new item
|
|
||||||
|
|
||||||
if( !UploadCreatePath() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
UploadSaveFile(i->second.tmp_filename, request.item.auth_path);
|
|
||||||
request.status = db.EditAuthById(request.item, request.item.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RedirectToLastDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Content::UploadSingle()
|
|
||||||
{
|
|
||||||
std::string * new_subject = request.PostVar("subject");
|
|
||||||
std::string * new_url = request.PostVar("url");
|
|
||||||
bool has_subject = (new_subject && (*new_subject)[0] != 0 );
|
|
||||||
bool has_url = (new_url && (*new_url)[0] != 0 );
|
|
||||||
|
|
||||||
ReadItem(request.item, Item::file); // ReadItem() changes the url if it is empty
|
|
||||||
SetUser(request.item);
|
|
||||||
request.item.privileges = 0644; // !! tymczasowo
|
|
||||||
|
|
||||||
const char * file_name = request.post_file_table.begin()->second.filename.c_str();
|
|
||||||
request.item.auth = SelectFileType(file_name);
|
|
||||||
|
|
||||||
if( !has_subject )
|
|
||||||
request.item.subject = file_name;
|
|
||||||
|
|
||||||
if( !has_url )
|
|
||||||
{
|
|
||||||
request.item.url = file_name;
|
|
||||||
PrepareUrl(request.item);
|
|
||||||
}
|
|
||||||
|
|
||||||
PostFunEmacsAdd(request.item); // always adding a new item
|
|
||||||
|
|
||||||
// url can be changed by PostFunEmacsAdd()
|
|
||||||
if( !UploadCreatePath() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
const std::string & tmp_filename = request.post_file_table.begin()->second.tmp_filename;
|
|
||||||
UploadSaveFile(tmp_filename, request.item.auth_path);
|
|
||||||
request.status = db.EditAuthById(request.item, request.item.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( request.status == WINIX_ERR_OK )
|
|
||||||
RedirectTo(request.item, "/cat");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// !! dodac usuwanie plikow statycznych przez rm
|
|
||||||
void Content::PostFunUpload()
|
|
||||||
{
|
|
||||||
if( !FunUploadCheckAccess() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( request.post_file_table.empty() )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !FunUploadCheckAbuse() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( request.post_file_table.size() > 1 )
|
|
||||||
UploadMulti();
|
|
||||||
else
|
|
||||||
UploadSingle();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Content::FunUpload()
|
|
||||||
{
|
|
||||||
FunUploadCheckAccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 -Y. -I.. -I../../ezc/src -f- *.cpp > Makefile.dep
|
|
||||||
echo -n "o = " > Makefile.o.dep
|
|
||||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o
|
|
||||||
|
|
||||||
include Makefile.dep
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
# DO NOT DELETE
|
|
||||||
|
|
||||||
acceptbaseparser.o: acceptbaseparser.h
|
|
||||||
bbcodeparser.o: bbcodeparser.h htmlfilter.h
|
|
||||||
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 error.h
|
|
||||||
config.o: rebus.h loadavg.h plugin.h request.h requesttypes.h session.h
|
|
||||||
config.o: plugindata.h thread.h compress.h acceptencodingparser.h
|
|
||||||
config.o: acceptbaseparser.h htmlfilter.h postmultiparser.h ticket.h
|
|
||||||
config.o: pluginmsg.h misc.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 error.h rebus.h loadavg.h
|
|
||||||
db.o: db.h item.h user.h group.h thread.h error.h log.h dircontainer.h
|
|
||||||
db.o: ugcontainer.h ticket.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 ticket.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 ticket.h data.h users.h groups.h functions.h
|
|
||||||
dirs.o: function.h lastcontainer.h mounts.h mount.h rebus.h loadavg.h
|
|
||||||
dirs.o: request.h requesttypes.h session.h plugindata.h compress.h
|
|
||||||
dirs.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
|
||||||
dirs.o: postmultiparser.h
|
|
||||||
function.o: function.h item.h
|
|
||||||
functioncodeparser.o: functioncodeparser.h item.h function.h log.h
|
|
||||||
functionparser.o: functionparser.h requesttypes.h log.h item.h error.h data.h
|
|
||||||
functionparser.o: dirs.h dircontainer.h users.h user.h ugcontainer.h groups.h
|
|
||||||
functionparser.o: group.h functions.h function.h lastcontainer.h mounts.h
|
|
||||||
functionparser.o: mount.h rebus.h loadavg.h db.h thread.h ticket.h request.h
|
|
||||||
functionparser.o: session.h plugindata.h compress.h acceptencodingparser.h
|
|
||||||
functionparser.o: acceptbaseparser.h htmlfilter.h postmultiparser.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 ticket.h
|
|
||||||
htmlfilter.o: htmlfilter.h
|
|
||||||
httpsimpleparser.o: httpsimpleparser.h
|
|
||||||
lastcontainer.o: lastcontainer.h log.h
|
|
||||||
loadavg.o: loadavg.h log.h
|
|
||||||
locale.o: locale.h ../confparser/confparser.h log.h
|
|
||||||
log.o: log.h
|
|
||||||
misc.o: misc.h item.h log.h data.h dirs.h dircontainer.h users.h user.h
|
|
||||||
misc.o: ugcontainer.h groups.h group.h functions.h function.h lastcontainer.h
|
|
||||||
misc.o: mounts.h mount.h error.h rebus.h loadavg.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 rebus.h
|
|
||||||
mountparser.o: loadavg.h misc.h
|
|
||||||
mounts.o: mounts.h mount.h error.h log.h data.h dirs.h item.h dircontainer.h
|
|
||||||
mounts.o: users.h user.h ugcontainer.h groups.h group.h functions.h
|
|
||||||
mounts.o: function.h lastcontainer.h rebus.h loadavg.h request.h
|
|
||||||
mounts.o: requesttypes.h session.h plugindata.h thread.h compress.h
|
|
||||||
mounts.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
|
||||||
mounts.o: postmultiparser.h ticket.h mountparser.h db.h
|
|
||||||
notify.o: log.h notify.h ../templatesnotify/templatesnotify.h ../core/mount.h
|
|
||||||
notify.o: ../core/locale.h ../confparser/confparser.h ../templates/misc.h
|
|
||||||
notify.o: ../templates/localefilter.h ../../ezc/src/ezc.h data.h dirs.h
|
|
||||||
notify.o: item.h dircontainer.h users.h user.h ugcontainer.h groups.h group.h
|
|
||||||
notify.o: functions.h function.h lastcontainer.h mounts.h mount.h error.h
|
|
||||||
notify.o: rebus.h loadavg.h misc.h request.h requesttypes.h session.h
|
|
||||||
notify.o: plugindata.h thread.h compress.h acceptencodingparser.h
|
|
||||||
notify.o: acceptbaseparser.h htmlfilter.h postmultiparser.h ticket.h
|
|
||||||
plugin.o: plugin.h request.h requesttypes.h session.h item.h error.h log.h
|
|
||||||
plugin.o: user.h rebus.h plugindata.h function.h thread.h compress.h
|
|
||||||
plugin.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
|
||||||
plugin.o: postmultiparser.h ticket.h data.h dirs.h dircontainer.h users.h
|
|
||||||
plugin.o: ugcontainer.h groups.h group.h functions.h lastcontainer.h mounts.h
|
|
||||||
plugin.o: mount.h loadavg.h pluginmsg.h
|
|
||||||
plugindata.o: plugindata.h plugin.h request.h requesttypes.h session.h item.h
|
|
||||||
plugindata.o: error.h log.h user.h rebus.h function.h thread.h compress.h
|
|
||||||
plugindata.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
|
||||||
plugindata.o: postmultiparser.h ticket.h data.h dirs.h dircontainer.h users.h
|
|
||||||
plugindata.o: ugcontainer.h groups.h group.h functions.h lastcontainer.h
|
|
||||||
plugindata.o: mounts.h mount.h loadavg.h pluginmsg.h
|
|
||||||
postmultiparser.o: postmultiparser.h error.h log.h requesttypes.h data.h
|
|
||||||
postmultiparser.o: dirs.h item.h dircontainer.h users.h user.h ugcontainer.h
|
|
||||||
postmultiparser.o: groups.h group.h functions.h function.h lastcontainer.h
|
|
||||||
postmultiparser.o: mounts.h mount.h rebus.h loadavg.h
|
|
||||||
rebus.o: log.h rebus.h misc.h item.h
|
|
||||||
request.o: request.h requesttypes.h session.h item.h error.h log.h user.h
|
|
||||||
request.o: rebus.h plugindata.h function.h thread.h compress.h
|
|
||||||
request.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
|
||||||
request.o: postmultiparser.h ticket.h getparser.h httpsimpleparser.h
|
|
||||||
request.o: postparser.h cookieparser.h data.h dirs.h dircontainer.h users.h
|
|
||||||
request.o: ugcontainer.h groups.h group.h functions.h lastcontainer.h
|
|
||||||
request.o: mounts.h mount.h loadavg.h plugin.h pluginmsg.h misc.h db.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 misc.h item.h
|
|
||||||
requestcontroller.o: ../templates/ckeditorgetparser.h
|
|
||||||
requestcontroller.o: ../core/httpsimpleparser.h ../core/log.h
|
|
||||||
requestcontroller.o: ../core/locale.h ../confparser/confparser.h
|
|
||||||
requestcontroller.o: ../templates/indexpatterns.h ../templates/localefilter.h
|
|
||||||
requestcontroller.o: ../core/thread.h ../core/ticket.h ../core/db.h user.h
|
|
||||||
requestcontroller.o: group.h thread.h error.h log.h dircontainer.h
|
|
||||||
requestcontroller.o: ugcontainer.h ticket.h sessionmanager.h
|
|
||||||
requestcontroller.o: sessioncontainer.h session.h rebus.h plugindata.h
|
|
||||||
requestcontroller.o: functionparser.h requesttypes.h data.h dirs.h users.h
|
|
||||||
requestcontroller.o: groups.h functions.h function.h lastcontainer.h mounts.h
|
|
||||||
requestcontroller.o: mount.h loadavg.h request.h compress.h
|
|
||||||
requestcontroller.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
|
||||||
requestcontroller.o: postmultiparser.h postparser.h httpsimpleparser.h
|
|
||||||
requestcontroller.o: cookieparser.h notify.h
|
|
||||||
requestcontroller.o: ../templatesnotify/templatesnotify.h ../core/mount.h
|
|
||||||
requestcontroller.o: ../templates/misc.h
|
|
||||||
session.o: session.h item.h error.h log.h user.h rebus.h plugindata.h
|
|
||||||
sessioncontainer.o: sessioncontainer.h session.h item.h error.h log.h user.h
|
|
||||||
sessioncontainer.o: rebus.h plugindata.h data.h dirs.h dircontainer.h users.h
|
|
||||||
sessioncontainer.o: ugcontainer.h groups.h group.h functions.h function.h
|
|
||||||
sessioncontainer.o: lastcontainer.h mounts.h mount.h loadavg.h
|
|
||||||
sessionmanager.o: sessionmanager.h sessioncontainer.h session.h item.h
|
|
||||||
sessionmanager.o: error.h log.h user.h rebus.h plugindata.h request.h
|
|
||||||
sessionmanager.o: requesttypes.h function.h thread.h compress.h
|
|
||||||
sessionmanager.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
|
||||||
sessionmanager.o: postmultiparser.h ticket.h data.h dirs.h dircontainer.h
|
|
||||||
sessionmanager.o: users.h ugcontainer.h groups.h group.h functions.h
|
|
||||||
sessionmanager.o: lastcontainer.h mounts.h mount.h loadavg.h sessionparser.h
|
|
||||||
sessionmanager.o: plugin.h pluginmsg.h
|
|
||||||
sessionparser.o: sessionparser.h session.h item.h error.h log.h user.h
|
|
||||||
sessionparser.o: rebus.h plugindata.h sessioncontainer.h data.h dirs.h
|
|
||||||
sessionparser.o: dircontainer.h users.h ugcontainer.h groups.h group.h
|
|
||||||
sessionparser.o: functions.h function.h lastcontainer.h mounts.h mount.h
|
|
||||||
sessionparser.o: loadavg.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 ticket.h
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
o = acceptbaseparser.o bbcodeparser.o compress.o config.o data.o db.o db_itemcolumns.o dircontainer.o dirs.o function.o functioncodeparser.o functionparser.o functions.o groups.o htmlfilter.o httpsimpleparser.o lastcontainer.o loadavg.o locale.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o plugindata.o postmultiparser.o rebus.o request.o requestcontroller.o session.o sessioncontainer.o sessionmanager.o sessionparser.o users.o
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "acceptbaseparser.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool AcceptBaseParser::IsWhite(int c)
|
|
||||||
{
|
|
||||||
if( c==' ' || c=='\t' )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AcceptBaseParser::SkipWhite()
|
|
||||||
{
|
|
||||||
while( IsWhite(*text) )
|
|
||||||
++text;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AcceptBaseParser::RemoveWhiteFromEnd(std::string & str)
|
|
||||||
{
|
|
||||||
if( str.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
size_t i = str.size() - 1;
|
|
||||||
|
|
||||||
for( ; i!=0 && IsWhite(str[i]) ; --i);
|
|
||||||
|
|
||||||
if( !IsWhite(str[i]) )
|
|
||||||
++i;
|
|
||||||
|
|
||||||
if( i < str.size() )
|
|
||||||
str.erase(i); // erasing until the end of the string
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AcceptBaseParser::ReadParameter()
|
|
||||||
{
|
|
||||||
param.clear();
|
|
||||||
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
while( *text!=0 && *text!=',' && *text!=';' )
|
|
||||||
{
|
|
||||||
param += *text;
|
|
||||||
++text;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoveWhiteFromEnd(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AcceptBaseParser::ReadQ()
|
|
||||||
{
|
|
||||||
q = 1.0;
|
|
||||||
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
if( *text != ';' )
|
|
||||||
return;
|
|
||||||
|
|
||||||
++text; // skipping a semicolon
|
|
||||||
|
|
||||||
while( *text!=0 && *text!=',' && *text!='=' )
|
|
||||||
// skipping until ',' or '='
|
|
||||||
++text;
|
|
||||||
|
|
||||||
if( *text==0 || *text==',' )
|
|
||||||
return;
|
|
||||||
|
|
||||||
++text; // skipping '='
|
|
||||||
|
|
||||||
SkipWhite();
|
|
||||||
q = strtod(text, (char**)&text);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AcceptBaseParser::SkipParam()
|
|
||||||
{
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
if( *text == ',' )
|
|
||||||
++text;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AcceptBaseParser::Parse(const char * str)
|
|
||||||
{
|
|
||||||
text = str;
|
|
||||||
Init();
|
|
||||||
|
|
||||||
while( *text != 0 )
|
|
||||||
{
|
|
||||||
ReadParameter();
|
|
||||||
ReadQ();
|
|
||||||
SkipParam();
|
|
||||||
Param(param, q);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucoreacceptbaseparser
|
|
||||||
#define headerfilecmslucoreacceptbaseparser
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// sample (you must create your own class derived from this one):
|
|
||||||
// object.Parse(" text/html ; , ; q = 45, application / xhtml+xml ; q = 0.4 , application/xml ; q = 0.9 , */* ; q = 0.8 ");
|
|
||||||
class AcceptBaseParser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
void Parse(const char * str);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
virtual void Init() {} ;
|
|
||||||
virtual void Param(const std::string & param, double q) = 0;
|
|
||||||
|
|
||||||
bool IsWhite(int c);
|
|
||||||
void SkipWhite();
|
|
||||||
void RemoveWhiteFromEnd(std::string & str);
|
|
||||||
void ReadParameter();
|
|
||||||
void ReadQ();
|
|
||||||
void SkipParam();
|
|
||||||
|
|
||||||
|
|
||||||
const char * text;
|
|
||||||
std::string param;
|
|
||||||
double q;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucoreacceptencodingparser
|
|
||||||
#define headerfilecmslucoreacceptencodingparser
|
|
||||||
|
|
||||||
#include "acceptbaseparser.h"
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
|
|
||||||
class AcceptEncodingParser : public AcceptBaseParser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool AcceptDeflate()
|
|
||||||
{
|
|
||||||
return accept_deflate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void Init()
|
|
||||||
{
|
|
||||||
accept_deflate = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Param(const std::string & param, double q)
|
|
||||||
{
|
|
||||||
if( param=="deflate" && q!=0 )
|
|
||||||
{
|
|
||||||
accept_deflate = true;
|
|
||||||
log << log3 << "AEP: accept deflate" << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool accept_deflate;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucorebbcodeparser
|
|
||||||
#define headerfilecmslucorebbcodeparser
|
|
||||||
|
|
||||||
#include "htmlfilter.h"
|
|
||||||
|
|
||||||
|
|
||||||
class BBCODEParser : public HTMLFilter
|
|
||||||
{
|
|
||||||
|
|
||||||
//using HTMLFilter::pchar;
|
|
||||||
|
|
||||||
|
|
||||||
struct Tags
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
const char * bbcode;
|
|
||||||
const char * html_tag;
|
|
||||||
const char * html_arg_prefix;
|
|
||||||
const char * html_arg_postfix;
|
|
||||||
const char * additional_html_tag_prefix;
|
|
||||||
const char * additional_html_tag_postfix;
|
|
||||||
bool inline_tag;
|
|
||||||
*/
|
|
||||||
const char * bbcode;
|
|
||||||
const char * html_tag;
|
|
||||||
const char * html_argument; // with closing '>'
|
|
||||||
bool inline_tag;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual bool IsValidCharForName(int c);
|
|
||||||
|
|
||||||
virtual bool IsOpeningTagMark();
|
|
||||||
virtual bool IsOpeningCommentaryTagMark();
|
|
||||||
virtual bool SkipCommentaryTagIfExists();
|
|
||||||
virtual bool IsClosingTagMark();
|
|
||||||
virtual bool IsClosingXmlSimpleTagMark();
|
|
||||||
|
|
||||||
|
|
||||||
void PutHtmlArgument1(const char * arg_start, const char * arg_end, bool has_u);
|
|
||||||
void PutHtmlArgument2(const Tags * tag, bool has_u);
|
|
||||||
void PutHtmlArgument(const Tags * tag, const char * arg_start, const char * arg_end);
|
|
||||||
|
|
||||||
void PutOpeningTagFromEzc(const char * start, const char * end);
|
|
||||||
void PutOpeningTagFromBBCode(const Tags * tag, const char * start, const char * end);
|
|
||||||
|
|
||||||
virtual void PutOpeningTag(const char * start, const char * end);
|
|
||||||
virtual void PutClosingTag(const char * tag);
|
|
||||||
|
|
||||||
const Tags * FindTag(const char * tag);
|
|
||||||
void PrintArgumentCheckQuotes(const char * & start, const char * & end);
|
|
||||||
|
|
||||||
|
|
||||||
void PrintEscape(int c, bool change_quote = false);
|
|
||||||
void PrintEncode(int c);
|
|
||||||
|
|
||||||
void PrintEscape(const char * start, const char * end, bool change_quote = false);
|
|
||||||
void PrintEncode(const char * start, const char * end);
|
|
||||||
|
|
||||||
void PrintArgumentEncode(const char * start, const char * end);
|
|
||||||
void PrintArgumentEscape(const char * start, const char * end);
|
|
||||||
|
|
||||||
virtual void ReadNormalTextSkipWhite(const char * & start, const char * & last_non_white);
|
|
||||||
virtual void PutNormalText(const char * str, const char * end);
|
|
||||||
virtual void PutNormalTextTrim(const char * str, const char * end);
|
|
||||||
|
|
||||||
virtual void CheckExceptions();
|
|
||||||
|
|
||||||
virtual void Init();
|
|
||||||
virtual void Deinit();
|
|
||||||
|
|
||||||
void PutClosingTag(const Tags * tag);
|
|
||||||
|
|
||||||
|
|
||||||
void CheckOpeningTag(const Tags * tag, const char * tag_name, bool & condition);
|
|
||||||
void CheckOpeningTag(const Tags * tag);
|
|
||||||
|
|
||||||
void TrimWhiteWithNewLines(const char * & start, const char * & end);
|
|
||||||
|
|
||||||
bool has_open_ol_tag; // has open html <ol> tag
|
|
||||||
bool has_open_ul_tag; // has open html <ul> tag
|
|
||||||
bool has_open_li_tag; // has open html <li> tag
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 = 100.0 - (double(last_out_size) / double(source_len) * 100.0);
|
|
||||||
char buffer[30];
|
|
||||||
sprintf(buffer, "%.1f", ratio);
|
|
||||||
|
|
||||||
log << log2 << "Compress: original size: " << source_len << ", compress size: " << (int)last_out_size << ", ratio: " << buffer << "%" << logend;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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
|
|
||||||
311
core/config.cpp
311
core/config.cpp
@@ -1,311 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "data.h"
|
|
||||||
#include "plugin.h"
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Config::Config()
|
|
||||||
{
|
|
||||||
default_str.clear();
|
|
||||||
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;
|
|
||||||
|
|
||||||
conf_parser.SplitSingle(true);
|
|
||||||
ConfParser::Status status = conf_parser.Parse( data.config_file );
|
|
||||||
|
|
||||||
|
|
||||||
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", 0770);
|
|
||||||
data.fcgi_socket_user = Text("fcgi_socket_user");
|
|
||||||
data.fcgi_socket_group = Text("fcgi_socket_group");
|
|
||||||
data.log_level = Int("log_level", 1);
|
|
||||||
data.log_request = Int("log_request", 1);
|
|
||||||
|
|
||||||
if( !data.stdout_is_closed )
|
|
||||||
data.log_stdout = Bool("log_stdout", false);
|
|
||||||
else
|
|
||||||
data.log_stdout = false;
|
|
||||||
|
|
||||||
data.post_file_max = Int("post_file_max", 8388608); // 8 MB
|
|
||||||
data.auth_simplefs_dir = Text("auth_simplefs_dir");
|
|
||||||
data.auth_hashfs_dir = Text("auth_hashfs_dir");
|
|
||||||
data.auth_tmp_dir = Text("auth_tmp_dir");
|
|
||||||
|
|
||||||
data.templates_dir = Text("templates_dir");
|
|
||||||
data.templates_dir_default = Text("templates_dir_default");
|
|
||||||
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.item_url_empty = Text("item_url_empty");
|
|
||||||
|
|
||||||
data.base_server = Text("base_server");
|
|
||||||
data.base_url = Text("base_url");
|
|
||||||
data.base_url_auth = Text("base_url_auth");
|
|
||||||
data.base_url_static = Text("base_url_static");
|
|
||||||
data.base_url_common = Text("base_url_common");
|
|
||||||
|
|
||||||
NoLastSlash(data.base_server);
|
|
||||||
NoLastSlash(data.base_url);
|
|
||||||
NoLastSlash(data.base_url_auth);
|
|
||||||
NoLastSlash(data.base_url_static);
|
|
||||||
NoLastSlash(data.base_url_common);
|
|
||||||
|
|
||||||
data.priv_no_user = Text("priv_no_user", "-- no user --");
|
|
||||||
data.priv_no_group = Text("priv_no_group", "-- no group --");
|
|
||||||
|
|
||||||
data.session_max_idle = Int("session_max_idle", 10800); // 3h
|
|
||||||
data.session_remember_max_idle = Int("session_remember_max_idle", 16070400); // 3 months
|
|
||||||
data.session_file = Text("session_file");
|
|
||||||
|
|
||||||
data.compression = Bool("compression", true);
|
|
||||||
data.html_filter = Bool("html_filter", true);
|
|
||||||
|
|
||||||
data.locale_str = Text("locale", "en");
|
|
||||||
data.locale_dir = Text("locale_dir");
|
|
||||||
data.locale_dir_default = Text("locale_dir_default");
|
|
||||||
|
|
||||||
data.title_separator = Text("title_separator", " / ");
|
|
||||||
|
|
||||||
|
|
||||||
ListText(data.plugin_file, "plugins");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string Config::Text(const char * name)
|
|
||||||
{
|
|
||||||
return Text(std::string(name), default_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string Config::Text(const char * name, const char * def)
|
|
||||||
{
|
|
||||||
return Text(std::string(name), std::string(def));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Config::Text(const std::string & name, const std::string & def)
|
|
||||||
{
|
|
||||||
ConfParser::TableSingle::iterator i = conf_parser.table_single.find(name);
|
|
||||||
|
|
||||||
if( i == conf_parser.table_single.end() )
|
|
||||||
return def;
|
|
||||||
|
|
||||||
return i->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int Config::Int(const char * name)
|
|
||||||
{
|
|
||||||
return Int(std::string(name), default_int);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int Config::Int(const char * name, int def)
|
|
||||||
{
|
|
||||||
return Int(std::string(name), def);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int Config::Int(const std::string & name, int def)
|
|
||||||
{
|
|
||||||
ConfParser::TableSingle::iterator i = conf_parser.table_single.find(name);
|
|
||||||
|
|
||||||
if( i == conf_parser.table_single.end() || i->second.empty() )
|
|
||||||
return def;
|
|
||||||
|
|
||||||
long res = (i->second[0] == '0')? strtol(i->second.c_str() + 1, 0, 8) : strtol(i->second.c_str(), 0, 10);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Config::Bool(const char * name)
|
|
||||||
{
|
|
||||||
return Bool(std::string(name), default_bool);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Config::Bool(const char * name, bool def)
|
|
||||||
{
|
|
||||||
return Bool(std::string(name), def);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Config::Bool(const std::string & name, bool def)
|
|
||||||
{
|
|
||||||
ConfParser::TableSingle::iterator i = conf_parser.table_single.find(name);
|
|
||||||
|
|
||||||
if( i == conf_parser.table_single.end() || i->second.empty() )
|
|
||||||
return def;
|
|
||||||
|
|
||||||
bool res = false;
|
|
||||||
|
|
||||||
if( EqualNoCase(i->second.c_str(), "true") ||
|
|
||||||
EqualNoCase(i->second.c_str(), "yes") ||
|
|
||||||
EqualNoCase(i->second.c_str(), "1")
|
|
||||||
)
|
|
||||||
res = true;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// in lists we don't use default values
|
|
||||||
void Config::ListText(std::vector<std::string> & list, const char * name)
|
|
||||||
{
|
|
||||||
ListText(list, std::string(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Config::ListText(std::vector<std::string> & list, const std::string & name)
|
|
||||||
{
|
|
||||||
list.clear();
|
|
||||||
|
|
||||||
ConfParser::TableSingle::iterator i = conf_parser.table_single.find(name);
|
|
||||||
|
|
||||||
if( i != conf_parser.table_single.end() )
|
|
||||||
{
|
|
||||||
list.push_back(i->second);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfParser::Table::iterator z = conf_parser.table.find(name);
|
|
||||||
|
|
||||||
if( z != conf_parser.table.end() )
|
|
||||||
{
|
|
||||||
list = z->second;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Config::NoLastSlash(std::string & s)
|
|
||||||
{
|
|
||||||
if( s.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
size_t i = s.size();
|
|
||||||
|
|
||||||
for( ; i>0 && s[i-1]=='/' ; --i);
|
|
||||||
|
|
||||||
if( i < s.size() )
|
|
||||||
s.erase(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Config::NoFirstHttp(std::string & s)
|
|
||||||
{
|
|
||||||
if( s.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
const char http[] = "http://";
|
|
||||||
const char https[] = "https://";
|
|
||||||
|
|
||||||
if( IsSubStringNoCase(http, s.c_str()) )
|
|
||||||
{
|
|
||||||
s.erase(0, sizeof(http)/sizeof(char));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( IsSubStringNoCase(https, s.c_str()) )
|
|
||||||
{
|
|
||||||
s.erase(0, sizeof(https)/sizeof(char));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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_);
|
|
||||||
|
|
||||||
|
|
||||||
std::string Text(const char * name);
|
|
||||||
std::string Text(const char * name, const char * def);
|
|
||||||
std::string Text(const std::string & name, const std::string & def);
|
|
||||||
|
|
||||||
int Int(const char *);
|
|
||||||
int Int(const char * name, int def);
|
|
||||||
int Int(const std::string & name, int def);
|
|
||||||
|
|
||||||
bool Bool(const char *);
|
|
||||||
bool Bool(const char * name, bool def);
|
|
||||||
bool Bool(const std::string & name, bool def);
|
|
||||||
|
|
||||||
void ListText(std::vector<std::string> & list, const char * name);
|
|
||||||
void ListText(std::vector<std::string> & list, const std::string & name);
|
|
||||||
|
|
||||||
void NoLastSlash(std::string & s);
|
|
||||||
void NoFirstHttp(std::string & s);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
ConfParser conf_parser;
|
|
||||||
void ShowError();
|
|
||||||
void AssignValues();
|
|
||||||
|
|
||||||
std::string default_str;
|
|
||||||
int default_int;
|
|
||||||
bool default_bool;
|
|
||||||
|
|
||||||
bool errors_to_stdout;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
extern Config config;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 )
|
|
||||||
{
|
|
||||||
res.first->second = value;
|
|
||||||
log << " (overwritten)";
|
|
||||||
}
|
|
||||||
|
|
||||||
log << 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,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "data.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Data::Data()
|
|
||||||
{
|
|
||||||
signal_hup = false;
|
|
||||||
stdout_is_closed = false;
|
|
||||||
how_many_logged = 0;
|
|
||||||
|
|
||||||
// the rest will be read from a config file
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Data::SetAdditionalVariables()
|
|
||||||
{
|
|
||||||
SetHttpHost(base_url, base_url_http_host);
|
|
||||||
SetHttpHost(base_url_auth, base_url_auth_http_host);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Data::SetHttpHost(const std::string & in, std::string & out)
|
|
||||||
{
|
|
||||||
if( strncmp(in.c_str(), "http://", 7) == 0 )
|
|
||||||
out = in.substr(7);
|
|
||||||
else
|
|
||||||
if( strncmp(in.c_str(), "https://", 8) == 0 )
|
|
||||||
out = in.substr(8);
|
|
||||||
else
|
|
||||||
out.clear(); // if empty the RequestController::BaseUrlRedirect() returns false and no redirecting will be done
|
|
||||||
}
|
|
||||||
213
core/data.h
213
core/data.h
@@ -1,213 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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"
|
|
||||||
#include "rebus.h"
|
|
||||||
#include "loadavg.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;
|
|
||||||
|
|
||||||
// how many requests should be logged in the same time
|
|
||||||
// default: 1
|
|
||||||
int log_request;
|
|
||||||
|
|
||||||
// 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_dir;
|
|
||||||
std::string templates_dir_default; // templates from winix
|
|
||||||
|
|
||||||
std::string db_database;
|
|
||||||
std::string db_user;
|
|
||||||
std::string db_pass;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
// string used in a place where is a user (or group) selected
|
|
||||||
std::string priv_no_user;
|
|
||||||
std::string priv_no_group;
|
|
||||||
|
|
||||||
// time in seconds when the user will be automatically logged out (iddle time)
|
|
||||||
int session_max_idle;
|
|
||||||
|
|
||||||
// time in seconds when the user will be automatically logged out (when he selected 'remember me' option)
|
|
||||||
// this time is usually greater than session_max_idle
|
|
||||||
int session_remember_max_idle;
|
|
||||||
|
|
||||||
// this file is used when the program is starting and ending
|
|
||||||
std::string session_file;
|
|
||||||
|
|
||||||
// allow the html ouput to be compressed
|
|
||||||
bool compression;
|
|
||||||
|
|
||||||
// plugins
|
|
||||||
std::vector<std::string> plugin_file;
|
|
||||||
|
|
||||||
// the html code is cleaned by our filter
|
|
||||||
bool html_filter;
|
|
||||||
|
|
||||||
// the url of a new empty item (if there is not the subject too)
|
|
||||||
std::string item_url_empty;
|
|
||||||
|
|
||||||
// maximum length of a file send by post multipart form
|
|
||||||
// 0 - not used
|
|
||||||
int post_file_max;
|
|
||||||
|
|
||||||
// directories for static files
|
|
||||||
std::string auth_simplefs_dir;
|
|
||||||
std::string auth_hashfs_dir;
|
|
||||||
|
|
||||||
// temporary directory for static content used by the upload function
|
|
||||||
// should be on the same partition as auth_simplefs_dir and auth_hashfs_dir
|
|
||||||
std::string auth_tmp_dir;
|
|
||||||
|
|
||||||
// default locale: en pl
|
|
||||||
std::string locale_str;
|
|
||||||
|
|
||||||
// directory with locale files
|
|
||||||
std::string locale_dir;
|
|
||||||
|
|
||||||
// directory with default locale files (those from winix)
|
|
||||||
std::string locale_dir_default;
|
|
||||||
|
|
||||||
// the main address of the server (e.g. someserver.com) (without the 'www' part etc)
|
|
||||||
std::string base_server;
|
|
||||||
|
|
||||||
// the main address of the site (e.g. http://www.someserver.com)
|
|
||||||
std::string base_url;
|
|
||||||
|
|
||||||
// static content authorized by winix
|
|
||||||
std::string base_url_auth;
|
|
||||||
|
|
||||||
// static content not authorized by winix
|
|
||||||
std::string base_url_static;
|
|
||||||
|
|
||||||
// additional static server for common content (not authorized)
|
|
||||||
std::string base_url_common;
|
|
||||||
|
|
||||||
// separator used in <title> html tag
|
|
||||||
std::string title_separator;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 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()
|
|
||||||
// without the first part http:// (or https://) or the whole string is empty
|
|
||||||
std::string base_url_http_host;
|
|
||||||
std::string base_url_auth_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;
|
|
||||||
|
|
||||||
// rebus (captcha)
|
|
||||||
Rebus rebus;
|
|
||||||
|
|
||||||
// the time when the winix starts
|
|
||||||
time_t system_start;
|
|
||||||
|
|
||||||
// how many logged users
|
|
||||||
long how_many_logged;
|
|
||||||
|
|
||||||
// load averages
|
|
||||||
LoadAvg load_avg;
|
|
||||||
|
|
||||||
Data();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SetHttpHost(const std::string & in, std::string & out);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern Data data;
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
2168
core/db.cpp
2168
core/db.cpp
File diff suppressed because it is too large
Load Diff
256
core/db.h
256
core/db.h
@@ -1,256 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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"
|
|
||||||
#include "ticket.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 AddUser(User & user, const std::string & password);
|
|
||||||
|
|
||||||
Error AddItem(Item & item);
|
|
||||||
Error EditItemById(Item & item, bool with_url = true);
|
|
||||||
Error EditItemByUrl(Item & item, bool with_url = true);
|
|
||||||
void CheckAllUrlSubject();
|
|
||||||
|
|
||||||
|
|
||||||
struct ItemQuery
|
|
||||||
{
|
|
||||||
// id is selected always
|
|
||||||
bool sel_parent_id; // parent_id
|
|
||||||
bool sel_user_id; // user_id, modification_user_id
|
|
||||||
bool sel_group_id; // group_id
|
|
||||||
bool sel_guest_name; // guest_name
|
|
||||||
bool sel_privileges; // privileges
|
|
||||||
bool sel_date; // date_creation, date_modification
|
|
||||||
bool sel_subject; // subject
|
|
||||||
bool sel_content; // content, content_type, (content_id)
|
|
||||||
bool sel_url; // url
|
|
||||||
bool sel_type; // type (dir, file, none)
|
|
||||||
bool sel_default_item; // default_item
|
|
||||||
bool sel_auth; // auth, auth_path
|
|
||||||
|
|
||||||
bool where_id; //
|
|
||||||
bool where_parent_id; //
|
|
||||||
bool where_type;
|
|
||||||
bool where_auth;
|
|
||||||
|
|
||||||
long id; // if where_id is true
|
|
||||||
long parent_id; // if where_parent_id is true
|
|
||||||
Item::Type type;
|
|
||||||
Item::Auth auth;
|
|
||||||
bool auth_equal; // if true means auth should be equal
|
|
||||||
|
|
||||||
bool sort_asc;
|
|
||||||
|
|
||||||
|
|
||||||
void SetAllSel(bool sel)
|
|
||||||
{
|
|
||||||
sel_parent_id = sel;
|
|
||||||
sel_user_id = sel;
|
|
||||||
sel_group_id = sel;
|
|
||||||
sel_guest_name = sel;
|
|
||||||
sel_privileges = sel;
|
|
||||||
sel_date = sel;
|
|
||||||
sel_subject = sel;
|
|
||||||
sel_content = sel;
|
|
||||||
sel_url = sel;
|
|
||||||
sel_type = sel;
|
|
||||||
sel_default_item= sel;
|
|
||||||
sel_auth = sel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetAllWhere(bool where_)
|
|
||||||
{
|
|
||||||
where_id = where_;
|
|
||||||
where_parent_id = where_;
|
|
||||||
where_type = where_;
|
|
||||||
where_auth = where_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetAll(bool sel, bool where_)
|
|
||||||
{
|
|
||||||
SetAllSel(sel);
|
|
||||||
SetAllWhere(where_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WhereId(long id_) { where_id = true; id = id_; }
|
|
||||||
void WhereParentId(long parent_id_) { where_parent_id = true; parent_id = parent_id_; }
|
|
||||||
void WhereType(Item::Type type_) { where_type = true; type = type_; }
|
|
||||||
void WhereAuth(Item::Auth st,
|
|
||||||
bool equal = true) { where_auth = true; auth = st; auth_equal = equal; }
|
|
||||||
|
|
||||||
ItemQuery()
|
|
||||||
{
|
|
||||||
sort_asc = true;
|
|
||||||
auth_equal = true;
|
|
||||||
|
|
||||||
SetAll(true, false);
|
|
||||||
|
|
||||||
id = -1;
|
|
||||||
parent_id = -1;
|
|
||||||
type = Item::none;
|
|
||||||
auth = Item::auth_none;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void GetItems(std::vector<Item> & item_table, const ItemQuery & item_query);
|
|
||||||
void GetItems(std::vector<long> & item_table, const ItemQuery & item_query);
|
|
||||||
|
|
||||||
|
|
||||||
// !! pobiera tylko jeden item (cos wymyslec innego z nazwa albo argumentem)
|
|
||||||
void GetItem(std::vector<Item> & item_table, long id);
|
|
||||||
|
|
||||||
|
|
||||||
bool GetPriv(Item & item, long id);
|
|
||||||
Error EditPrivById(Item & item, long id);
|
|
||||||
Error EditParentUrlById(Item & item, long id);
|
|
||||||
Error EditAuthById(Item & item, long id);
|
|
||||||
Error DelDirById(long id);
|
|
||||||
|
|
||||||
Error EditSubjectById(Item & item, 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
|
|
||||||
long Size(long parent_id, Item::Type type = Item::none);
|
|
||||||
|
|
||||||
Error GetItemById(long item_id, Item & item);
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
Error GetTicketByDirId(long dir_id, Ticket & ticket);
|
|
||||||
Error GetTickets(long parent_id, std::vector<Ticket> & ticket_tab);
|
|
||||||
//bool IsTicket(long dir_id);
|
|
||||||
Error AddTicket(Ticket & ticket);
|
|
||||||
Error EditTicketById(Ticket & ticket);
|
|
||||||
Error EditTicketRemoveItem(long item_id);
|
|
||||||
Error RemoveTicket(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(const ItemQuery & iq, bool skip_other_sel = false);
|
|
||||||
|
|
||||||
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, auth, auth_path, modification_user_id;
|
|
||||||
|
|
||||||
void SetColumns(PGresult * r);
|
|
||||||
void SetItem(PGresult * r, long row, Item & item);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct TicketColumns
|
|
||||||
{
|
|
||||||
int id, dir_id, parent_id, type, status, priority, category, expected, progress, item_id;
|
|
||||||
|
|
||||||
void SetColumns(PGresult * r);
|
|
||||||
void SetTicket(PGresult * r, long row, Ticket & ticket);
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // class Db
|
|
||||||
|
|
||||||
|
|
||||||
extern Db db;
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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");
|
|
||||||
auth = PQfnumber(r, "auth");
|
|
||||||
auth_path = PQfnumber(r, "auth_path");
|
|
||||||
modification_user_id = PQfnumber(r, "modification_user_id");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 = static_cast<Item::ContentType>( atoi(Db::AssertValue(r, row, content_type)) );
|
|
||||||
if( guest_name != -1 ) item.guest_name = Db::AssertValue(r, row, guest_name);
|
|
||||||
if( auth != -1 ) item.auth = static_cast<Item::Auth>( atoi(Db::AssertValue(r, row, auth)) );
|
|
||||||
if( auth_path != -1 ) item.auth_path = Db::AssertValue(r, row, auth_path);
|
|
||||||
if( modification_user_id != -1 ) item.modification_user_id = atol( Db::AssertValue(r, row, modification_user_id) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Db::TicketColumns::SetColumns(PGresult * r)
|
|
||||||
{
|
|
||||||
// PQfnumber returns -1 if there is no such a column
|
|
||||||
id = PQfnumber(r, "id");
|
|
||||||
dir_id = PQfnumber(r, "dir_id");
|
|
||||||
parent_id = PQfnumber(r, "parent_id");
|
|
||||||
type = PQfnumber(r, "type");
|
|
||||||
status = PQfnumber(r, "status");
|
|
||||||
priority = PQfnumber(r, "priority");
|
|
||||||
category = PQfnumber(r, "category");
|
|
||||||
expected = PQfnumber(r, "expected");
|
|
||||||
progress = PQfnumber(r, "progress");
|
|
||||||
item_id = PQfnumber(r, "item_id");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Db::TicketColumns::SetTicket(PGresult * r, long row, Ticket & ticket)
|
|
||||||
{
|
|
||||||
if( id != -1 ) ticket.id = atol( Db::AssertValue(r, row, id) );
|
|
||||||
if( dir_id != -1 ) ticket.dir_id = atol( Db::AssertValue(r, row, dir_id) );
|
|
||||||
if( parent_id != -1 ) ticket.parent_id = atol( Db::AssertValue(r, row, parent_id) );
|
|
||||||
if( type != -1 ) ticket.type = atoi( Db::AssertValue(r, row, type) );
|
|
||||||
if( status != -1 ) ticket.status = atoi( Db::AssertValue(r, row, status) );
|
|
||||||
if( priority != -1 ) ticket.priority = atoi( Db::AssertValue(r, row, priority) );
|
|
||||||
if( category != -1 ) ticket.category = atoi( Db::AssertValue(r, row, category) );
|
|
||||||
if( expected != -1 ) ticket.expected = atoi( Db::AssertValue(r, row, expected) );
|
|
||||||
if( progress != -1 ) ticket.progress = atoi( Db::AssertValue(r, row, progress) );
|
|
||||||
if( item_id != -1 ) ticket.item_id = atol( Db::AssertValue(r, row, item_id) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 GetEtc();
|
|
||||||
|
|
||||||
Iterator Begin();
|
|
||||||
Iterator End();
|
|
||||||
SizeType Size();
|
|
||||||
bool Empty();
|
|
||||||
Iterator PushBack(const Item & item);
|
|
||||||
bool ChangeParent(long dir_id, long new_parent_id);
|
|
||||||
void Clear();
|
|
||||||
|
|
||||||
Iterator FindId(long id);
|
|
||||||
|
|
||||||
bool DelById(long id);
|
|
||||||
|
|
||||||
ParentIterator ParentBegin();
|
|
||||||
ParentIterator ParentEnd();
|
|
||||||
ParentSizeType ParentSize();
|
|
||||||
bool ParentEmpty();
|
|
||||||
ParentIterator FindFirstParent(long parent);
|
|
||||||
ParentIterator NextParent(ParentIterator pi);
|
|
||||||
|
|
||||||
void FindSpecialFolders();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void CheckSpecialFolder(const Item & item, Iterator iter);
|
|
||||||
|
|
||||||
// main table with dirs
|
|
||||||
Table table;
|
|
||||||
|
|
||||||
// true if there is a root dir in the table
|
|
||||||
bool is_root;
|
|
||||||
|
|
||||||
// root
|
|
||||||
Iterator root_iter;
|
|
||||||
|
|
||||||
// true if there is a etc dir in the table
|
|
||||||
bool is_etc;
|
|
||||||
|
|
||||||
// etc
|
|
||||||
Iterator etc_iter;
|
|
||||||
|
|
||||||
// indexes
|
|
||||||
TableId table_id;
|
|
||||||
TableParent table_parent;
|
|
||||||
|
|
||||||
// names of folders
|
|
||||||
static std::string dir_etc;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
400
core/dirs.cpp
400
core/dirs.cpp
@@ -1,400 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "dirs.h"
|
|
||||||
#include "error.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "db.h"
|
|
||||||
#include "data.h"
|
|
||||||
#include "request.h"
|
|
||||||
|
|
||||||
|
|
||||||
void Dirs::Clear()
|
|
||||||
{
|
|
||||||
dir_table.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Dirs::CheckRootDir()
|
|
||||||
{
|
|
||||||
DirContainer::Iterator i = dir_table.GetRoot();
|
|
||||||
|
|
||||||
if( i != dir_table.End() )
|
|
||||||
{
|
|
||||||
if( !request.HasReadExecAccessForRoot(*i) )
|
|
||||||
{
|
|
||||||
i->privileges = 0755;
|
|
||||||
log << log1 << "Dirs: there is no access for root (admin) to the root dir, setting 0755 for root dir" << logend;
|
|
||||||
db.EditPrivById(*i, i->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
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) == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
dir_table.PushBack(root);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Dirs::ReadDirs()
|
|
||||||
{
|
|
||||||
Clear();
|
|
||||||
|
|
||||||
db.GetDirs(dir_table);
|
|
||||||
CheckRootDir();
|
|
||||||
dir_table.FindSpecialFolders();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DirContainer::ParentIterator Dirs::FindFirstParent(long parent_id)
|
|
||||||
{
|
|
||||||
DirContainer::ParentIterator i = dir_table.FindFirstParent(parent_id);
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DirContainer::ParentIterator Dirs::NextParent(DirContainer::ParentIterator i)
|
|
||||||
{
|
|
||||||
return dir_table.NextParent(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DirContainer::ParentIterator Dirs::ParentEnd()
|
|
||||||
{
|
|
||||||
return dir_table.ParentEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// dodatkowo moze metoda AppendPath dodajaca sciezke do biezacego stringa?
|
|
||||||
// albo tutaj stringa nie czyscic?
|
|
||||||
// O(m * log n) (m- how many parts are in 'id')
|
|
||||||
// path with a slash at the end
|
|
||||||
bool Dirs::MakePath(long id, std::string & path)
|
|
||||||
{
|
|
||||||
DirContainer::Iterator i;
|
|
||||||
|
|
||||||
path = '/';
|
|
||||||
|
|
||||||
while( true )
|
|
||||||
{
|
|
||||||
i = dir_table.FindId(id);
|
|
||||||
|
|
||||||
if( i == dir_table.End() ||
|
|
||||||
i->parent_id == id ) // means a loop (something wrong in the db)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if( i->parent_id == -1 )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
id = i->parent_id;
|
|
||||||
|
|
||||||
|
|
||||||
path.insert(0, i->url);
|
|
||||||
path.insert(path.begin(), '/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Dirs::ChangeParent(long dir_id, long new_parent_id)
|
|
||||||
{
|
|
||||||
return dir_table.ChangeParent(dir_id, new_parent_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
checking whether dir_id has a parent parent_id (somewhere in the path)
|
|
||||||
*/
|
|
||||||
bool Dirs::HasParent(long dir_id, long parent_id)
|
|
||||||
{
|
|
||||||
DirContainer::Iterator i;
|
|
||||||
|
|
||||||
while( true )
|
|
||||||
{
|
|
||||||
i = dir_table.FindId(dir_id);
|
|
||||||
|
|
||||||
if( i==dir_table.End() || i->parent_id==-1 )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if( i->parent_id == parent_id )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
dir_id = i->parent_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Item * Dirs::GetRootDir()
|
|
||||||
{
|
|
||||||
DirContainer::Iterator root = dir_table.GetRoot();
|
|
||||||
|
|
||||||
if( root == dir_table.End() )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return &(*root);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Item * Dirs::GetEtcDir()
|
|
||||||
{
|
|
||||||
DirContainer::Iterator etc = dir_table.GetEtc();
|
|
||||||
|
|
||||||
if( etc == dir_table.End() )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return &(*etc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t Dirs::AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, std::string & dir)
|
|
||||||
{
|
|
||||||
size_t i = 0;
|
|
||||||
size_t old_i;
|
|
||||||
|
|
||||||
while( true )
|
|
||||||
{
|
|
||||||
dir_id = pdir->id;
|
|
||||||
|
|
||||||
// skipping slashes
|
|
||||||
for( ; i<path.size() && path[i] == '/' ; ++i );
|
|
||||||
|
|
||||||
if( i == path.size() )
|
|
||||||
return i; // end of the path
|
|
||||||
|
|
||||||
// creating a name
|
|
||||||
old_i = i;
|
|
||||||
analyze_temp.clear();
|
|
||||||
|
|
||||||
for( ; i<path.size() && path[i] != '/' ; ++i)
|
|
||||||
analyze_temp += path[i];
|
|
||||||
|
|
||||||
pdir = data.dirs.GetDir(analyze_temp, pdir->id);
|
|
||||||
|
|
||||||
if( !pdir )
|
|
||||||
return old_i; // analyze_temp is not a directory
|
|
||||||
|
|
||||||
dir += analyze_temp;
|
|
||||||
dir += '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
the path should begin with a slash
|
|
||||||
|
|
||||||
return values:
|
|
||||||
0 - directory exists
|
|
||||||
dir_id - id of the directory
|
|
||||||
dir - the path to the directory (with a slash at the end)
|
|
||||||
file - if not empty means a file name (we don't check if the file really exists)
|
|
||||||
1 - there is not a root dir
|
|
||||||
2 - the path is empty
|
|
||||||
3 - there is not such a directory
|
|
||||||
*/
|
|
||||||
int Dirs::AnalyzePath(const std::string & path, long & dir_id, std::string & dir, std::string & file)
|
|
||||||
{
|
|
||||||
Item * pdir = data.dirs.GetRootDir();
|
|
||||||
dir = '/';
|
|
||||||
file.clear();
|
|
||||||
|
|
||||||
if( !pdir )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if( path.empty() )
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
if( path[0] != '/' )
|
|
||||||
return 3;
|
|
||||||
|
|
||||||
size_t i = AnalyzeDir(pdir, path, dir_id, dir);
|
|
||||||
|
|
||||||
if( i < path.size() )
|
|
||||||
{
|
|
||||||
// checking if at least one slash has left
|
|
||||||
for(size_t a=i ; a < path.size() ; ++a)
|
|
||||||
if( path[a] == '/' )
|
|
||||||
return 3; // there is not such a directory
|
|
||||||
|
|
||||||
// the rest of the path is a file name
|
|
||||||
file = path.c_str() + i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Dirs::DelDir(long dir_id)
|
|
||||||
{
|
|
||||||
return dir_table.DelById(dir_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
73
core/dirs.h
73
core/dirs.h
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucoredirs
|
|
||||||
#define headerfilecmslucoredirs
|
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "item.h"
|
|
||||||
#include "dircontainer.h"
|
|
||||||
|
|
||||||
|
|
||||||
// we do not support '..' in a path (for simplicity and security reasons)
|
|
||||||
|
|
||||||
|
|
||||||
class Dirs
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
void Clear();
|
|
||||||
void ReadDirs();
|
|
||||||
|
|
||||||
|
|
||||||
// these methods return false if there is no such a dir
|
|
||||||
bool IsDir(long dir_id);
|
|
||||||
bool GetDirChilds(long parent_id, std::vector<Item*> & childs_table);
|
|
||||||
bool MakePath(long dir_id, std::string & path);
|
|
||||||
bool ChangeParent(long dir_id, long new_parent_id);
|
|
||||||
bool HasParent(long dir_id, long parent_id);
|
|
||||||
bool DelDir(long dir_id);
|
|
||||||
|
|
||||||
int AnalyzePath(const std::string & path, long & dir_id, std::string & dir, std::string & file);
|
|
||||||
static void SplitPath(const std::string & path, std::string & dir, std::string & file);
|
|
||||||
|
|
||||||
DirContainer::ParentIterator FindFirstParent(long parent_id);
|
|
||||||
DirContainer::ParentIterator NextParent(DirContainer::ParentIterator i);
|
|
||||||
DirContainer::ParentIterator ParentEnd();
|
|
||||||
|
|
||||||
|
|
||||||
// these methods return null if there is no such a dir
|
|
||||||
Item * GetRootDir();
|
|
||||||
Item * GetEtcDir();
|
|
||||||
Item * GetDir(const std::string & name, long parent);
|
|
||||||
Item * GetDir(const std::string & path);
|
|
||||||
Item * GetDir(long id);
|
|
||||||
Item * AddDir(const Item & item);
|
|
||||||
|
|
||||||
void CheckRootDir();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
DirContainer dir_table;
|
|
||||||
|
|
||||||
size_t AnalyzeDir(Item * pdir, const std::string & path, long & dir_id, std::string & dir);
|
|
||||||
std::string analyze_temp;
|
|
||||||
|
|
||||||
bool ExtractName(const char * & s, std::string & name);
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
75
core/error.h
75
core/error.h
@@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucoreerror
|
|
||||||
#define headerfilecmslucoreerror
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
#define WINIX_ERR_OK 0
|
|
||||||
//#define WINIX_ERR_INCORRECT_PATH 1
|
|
||||||
|
|
||||||
//#define WINIX_ERR_NO_POSTVAR 2
|
|
||||||
#define WINIX_ERR_INCORRECT_DIR 3
|
|
||||||
#define WINIX_ERR_CANT_CHANGE_USER 4
|
|
||||||
#define WINIX_ERR_CANT_CHANGE_GROUP 5
|
|
||||||
#define WINIX_ERR_CANT_CHANGE_PRIVILEGES 6
|
|
||||||
#define WINIX_ERR_PERMISSION_DENIED 7
|
|
||||||
#define WINIX_ERR_NO_ROOT_DIR 8
|
|
||||||
#define WINIX_ERR_NO_FUNCTION 9
|
|
||||||
|
|
||||||
|
|
||||||
#define WINIX_ERR_NO_ITEM 10
|
|
||||||
#define WINIX_ERR_UNKNOWN_PARAM 11
|
|
||||||
|
|
||||||
#define WINIX_ERR_MOUNT_UNKNOWN 12
|
|
||||||
#define WINIX_ERR_UNKNOWN_FILESYSTEM 13
|
|
||||||
#define WINIX_ERR_NO_MOUNTPOINT 14
|
|
||||||
//#define WINIX_ERR_MOUNT_NO_PARAM 15
|
|
||||||
|
|
||||||
#define WINIX_ERR_NO_THREAD 16
|
|
||||||
#define WINIX_ERR_EMPTY 17
|
|
||||||
#define WINIX_ERR_SPAM 18
|
|
||||||
#define WINIX_ERR_INCORRECT_REBUS 19
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define WINIX_ERR_NO_BOUNDARY 20
|
|
||||||
#define WINIX_ERR_BROKEN_INPUT 21
|
|
||||||
#define WINIX_ERR_INPUT_TOO_LARGE 22
|
|
||||||
#define WINIX_ERR_CANT_CREATE_FILE 23
|
|
||||||
|
|
||||||
#define WINIX_ERR_NO_TICKET 24
|
|
||||||
|
|
||||||
#define WINIX_ERR_PASSWORDS_DIFFERENT 25
|
|
||||||
#define WINIX_ERR_PASSWORD_TOO_SHORT 26
|
|
||||||
#define WINIX_ERR_USER_EXISTS 27
|
|
||||||
#define WINIX_ERR_LOGIN_EMPTY 28
|
|
||||||
#define WINIX_DIFFERENT_MOUNT_POINTS 29
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define WINIX_ERR_DB_FATAL_ERROR_DURING_CONNECTING 100
|
|
||||||
#define WINIX_ERR_DB_INCORRECT_QUERY 101
|
|
||||||
#define WINIX_ERR_DB_INCORRENT_RESULT_STATUS 102
|
|
||||||
#define WINIX_ERR_DB_NO_COLUMN 103
|
|
||||||
#define WINIX_ERR_DB_INCORRECT_LOGIN 104
|
|
||||||
#define WINIX_ERR_DB_MORE_THAN_ONE_LOGIN 105
|
|
||||||
#define WINIX_ERR_DB_ERR_CURRVAL 106
|
|
||||||
|
|
||||||
|
|
||||||
//#define WINIX_ERR_UNKNOWN 1000
|
|
||||||
|
|
||||||
|
|
||||||
typedef int Error;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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
|
|
||||||
#define FUN_RELOAD 16
|
|
||||||
#define FUN_UPLOAD 17
|
|
||||||
#define FUN_CREATETICKET 18
|
|
||||||
#define FUN_EDITTICKET 19
|
|
||||||
#define FUN_TICKET 20
|
|
||||||
#define FUN_UPTIME 21
|
|
||||||
#define FUN_MV 23
|
|
||||||
#define FUN_UNAME 24
|
|
||||||
#define FUN_CHMOD 25
|
|
||||||
#define FUN_CHOWN 26
|
|
||||||
#define FUN_CKEDITOR 27
|
|
||||||
#define FUN_DOWNLOAD 28
|
|
||||||
#define FUN_ADDUSER 29
|
|
||||||
#define FUN_SUBJECT 30
|
|
||||||
#define FUN_CP 31
|
|
||||||
#define FUN_TINYMCE 32
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Function
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
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 Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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,230 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 = WINIX_ERR_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 == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
if( request.role == Request::authorizer && request.item.auth == Item::auth_none )
|
|
||||||
{
|
|
||||||
log << log1 << "FP: item.url: " << url << " exists but has not a static content (authorizer role)" << logend;
|
|
||||||
request.status = WINIX_ERR_NO_ITEM;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
++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(const std::string & par)
|
|
||||||
{
|
|
||||||
Param param;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if( par.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// looking for the first colon ':'
|
|
||||||
for(i=0 ; i<par.size() && par[i] != ':' ; ++i);
|
|
||||||
|
|
||||||
if( i == par.size() )
|
|
||||||
{
|
|
||||||
// there is no a colon
|
|
||||||
param.name = par;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( i > 0 )
|
|
||||||
param.name = par.substr(0, i);
|
|
||||||
|
|
||||||
if( i < par.size() - 1 )
|
|
||||||
param.value = par.substr(i+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
request.param_table.push_back(param);
|
|
||||||
|
|
||||||
log << log3 << "FP: Param: name=" << param.name;
|
|
||||||
|
|
||||||
if( !param.value.empty() )
|
|
||||||
log << ", value=" << param.value;
|
|
||||||
|
|
||||||
log << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FunctionParser::ParseParams()
|
|
||||||
{
|
|
||||||
for( ; true ; ++get_index )
|
|
||||||
{
|
|
||||||
SkipEmptyString("FP: Params: skipped empty string");
|
|
||||||
|
|
||||||
if( get_index == get_table_len )
|
|
||||||
break;
|
|
||||||
|
|
||||||
ParseParams(request.get_table[get_index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FunctionParser::Parse()
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_OK;
|
|
||||||
get_index = 0;
|
|
||||||
get_table_len = request.get_table.size();
|
|
||||||
request.pfunction = 0;
|
|
||||||
request.is_item = false;
|
|
||||||
|
|
||||||
ParseDirectories();
|
|
||||||
|
|
||||||
if( request.status != WINIX_ERR_OK )
|
|
||||||
return;
|
|
||||||
|
|
||||||
ParseFunction();
|
|
||||||
|
|
||||||
if( !request.pfunction )
|
|
||||||
{
|
|
||||||
ParseItem();
|
|
||||||
|
|
||||||
if( request.status != WINIX_ERR_OK )
|
|
||||||
return;
|
|
||||||
|
|
||||||
ParseFunction();
|
|
||||||
|
|
||||||
if( !request.pfunction && get_index != get_table_len )
|
|
||||||
{
|
|
||||||
request.status = WINIX_ERR_NO_FUNCTION;
|
|
||||||
log << log3 << "FP: Parse: unknown function: \"" << request.get_table[get_index] << "\"" << logend;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ParseParams();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucorefunctionparser
|
|
||||||
#define headerfilecmslucorefunctionparser
|
|
||||||
|
|
||||||
#include "requesttypes.h"
|
|
||||||
|
|
||||||
|
|
||||||
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(const std::string & par);
|
|
||||||
void ParseParams();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
void Parse();
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "functions.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Functions::Clear()
|
|
||||||
{
|
|
||||||
table.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Functions::AddFun(int code, const char * url)
|
|
||||||
{
|
|
||||||
fun.code = code;
|
|
||||||
fun.item.url = url;
|
|
||||||
table.insert( std::make_pair(fun.item.url, fun) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// in the future we will read these functions from the database
|
|
||||||
void Functions::ReadFunctions()
|
|
||||||
{
|
|
||||||
Clear();
|
|
||||||
|
|
||||||
fun.item.user_id = -1;
|
|
||||||
fun.item.group_id = -1;
|
|
||||||
fun.item.privileges = 0755;
|
|
||||||
fun.item.parent_id = -1; // !! temporarily doesn't matter
|
|
||||||
fun.item.id = -1;
|
|
||||||
fun.item.type = Item::file;
|
|
||||||
|
|
||||||
|
|
||||||
AddFun(FUN_LS, "ls");
|
|
||||||
AddFun(FUN_CAT, "cat");
|
|
||||||
AddFun(FUN_NODE, "node");
|
|
||||||
AddFun(FUN_EMACS, "emacs");
|
|
||||||
AddFun(FUN_MKDIR, "mkdir");
|
|
||||||
AddFun(FUN_DEFAULT, "default");
|
|
||||||
AddFun(FUN_PRIV, "priv");
|
|
||||||
AddFun(FUN_RM, "rm");
|
|
||||||
AddFun(FUN_LOGOUT, "logout");
|
|
||||||
AddFun(FUN_LOGIN, "login");
|
|
||||||
AddFun(FUN_RUN, "run");
|
|
||||||
AddFun(FUN_WHO, "who");
|
|
||||||
AddFun(FUN_LAST, "last");
|
|
||||||
AddFun(FUN_CREATETHREAD, "createthread");
|
|
||||||
AddFun(FUN_THREAD, "thread");
|
|
||||||
AddFun(FUN_UPLOAD, "upload");
|
|
||||||
AddFun(FUN_CREATETICKET, "createticket");
|
|
||||||
AddFun(FUN_EDITTICKET, "editticket");
|
|
||||||
AddFun(FUN_TICKET, "ticket");
|
|
||||||
AddFun(FUN_UPTIME, "uptime");
|
|
||||||
AddFun(FUN_MV, "mv");
|
|
||||||
AddFun(FUN_UNAME, "uname");
|
|
||||||
AddFun(FUN_CHMOD, "chmod");
|
|
||||||
AddFun(FUN_CHOWN, "chown");
|
|
||||||
AddFun(FUN_CKEDITOR, "ckeditor");
|
|
||||||
AddFun(FUN_DOWNLOAD, "download");
|
|
||||||
AddFun(FUN_ADDUSER, "adduser");
|
|
||||||
AddFun(FUN_SUBJECT, "subject");
|
|
||||||
AddFun(FUN_CP, "cp");
|
|
||||||
AddFun(FUN_TINYMCE, "tinymce");
|
|
||||||
|
|
||||||
|
|
||||||
// functions which need more privileges
|
|
||||||
fun.item.privileges = 0700;
|
|
||||||
|
|
||||||
AddFun(FUN_RELOAD, "reload");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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;
|
|
||||||
|
|
||||||
Function fun;
|
|
||||||
|
|
||||||
void AddFun(int code, const char * url);
|
|
||||||
|
|
||||||
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 Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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
|
|
||||||
1208
core/htmlfilter.cpp
1208
core/htmlfilter.cpp
File diff suppressed because it is too large
Load Diff
@@ -1,221 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucorehtmlfilter
|
|
||||||
#define headerfilecmslucorehtmlfilter
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// max length of a name of a html tag (with terminating null)
|
|
||||||
#define WINIX_HTMLFILTER_ITEM_MAXLEN 30
|
|
||||||
|
|
||||||
// depth of the html tree
|
|
||||||
#define WINIX_HTMLFILTER_STACK_MAXLEN 100
|
|
||||||
|
|
||||||
// length of a buffer used for printing
|
|
||||||
// it should be at least: WINIX_HTMLFILTER_ITEM_MAXLEN+3
|
|
||||||
#define WINIX_HTMLFILTER_BUFFER_MAXLEN 2048
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
very lightweight filter for html
|
|
||||||
(without using any dynamic memory - some memory is allocated only at the beginning - in ctors)
|
|
||||||
this filter has O(n) complexity over the whole html string
|
|
||||||
|
|
||||||
such tags as: <script> <pre> <textarea> are treated in a special way
|
|
||||||
all characters between the opening and closing tag (<script>....</script>) are untouched
|
|
||||||
|
|
||||||
if the filter finds that there are not closed tags it will close them,
|
|
||||||
if the filter finds a closing tag which doesn't have an opening tag - it will skip it
|
|
||||||
|
|
||||||
tags which don't need to be closed: meta, input, br, img, link
|
|
||||||
look at CheckExceptions() method
|
|
||||||
|
|
||||||
the filter recognizes xml simple tags (with / at the end) such as: <br />
|
|
||||||
*/
|
|
||||||
class HTMLFilter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
// for checking orphans
|
|
||||||
enum Lang
|
|
||||||
{
|
|
||||||
lang_pl,
|
|
||||||
lang_cz,
|
|
||||||
lang_sk,
|
|
||||||
lang_none
|
|
||||||
};
|
|
||||||
|
|
||||||
enum OrphanMode
|
|
||||||
{
|
|
||||||
orphan_nbsp, // putting " " string
|
|
||||||
orphan_160space // putting 160 ascii code
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
HTMLFilter();
|
|
||||||
HTMLFilter(const HTMLFilter & f);
|
|
||||||
HTMLFilter & operator=(const HTMLFilter & f);
|
|
||||||
~HTMLFilter();
|
|
||||||
|
|
||||||
|
|
||||||
// main methods used for filtering
|
|
||||||
void Filter(const char * in, std::string & out);
|
|
||||||
void Filter(const std::string & in, std::string & out);
|
|
||||||
|
|
||||||
|
|
||||||
// insert a white space into long lines
|
|
||||||
// only between html tags
|
|
||||||
// skipped in such tags: script, pre, textarea
|
|
||||||
// break_after - after how many characters insert a space (0 - off)
|
|
||||||
void BreakLines(size_t break_after_);
|
|
||||||
|
|
||||||
|
|
||||||
// trimming white characters (with new lines)
|
|
||||||
// at the beginning, at the end and in the middle of a string
|
|
||||||
// only between html tags
|
|
||||||
// at the beginning and at the end only one space is left
|
|
||||||
// skipped in such tags: script, pre, textarea
|
|
||||||
// false by default
|
|
||||||
void TrimWhite(bool trim);
|
|
||||||
|
|
||||||
|
|
||||||
// first tabs in a tree
|
|
||||||
// default: 2 (spaces)
|
|
||||||
// set 0 to turn off
|
|
||||||
void InsertTabs(size_t tabsize);
|
|
||||||
|
|
||||||
|
|
||||||
// check 'orphans' for the specicic language
|
|
||||||
// if an orphan is detected then the non-break space (" " or ascii 160 code) will be put
|
|
||||||
// default disable (lang_none)
|
|
||||||
void CheckOrphans(Lang lang_, OrphanMode mode = orphan_nbsp);
|
|
||||||
|
|
||||||
|
|
||||||
// skipping some unsafe tags
|
|
||||||
// (script, iframe, frame, frameset, applet, head, meta, html, link, body, ...)
|
|
||||||
void SafeMode(bool safe_mode_);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
struct Item
|
|
||||||
{
|
|
||||||
char name[WINIX_HTMLFILTER_ITEM_MAXLEN];
|
|
||||||
size_t name_len;
|
|
||||||
|
|
||||||
enum Type
|
|
||||||
{
|
|
||||||
opening,
|
|
||||||
closing,
|
|
||||||
simple,
|
|
||||||
special,
|
|
||||||
none
|
|
||||||
} type;
|
|
||||||
|
|
||||||
// is there a new line after this tag
|
|
||||||
bool new_line;
|
|
||||||
|
|
||||||
void Clear();
|
|
||||||
Item();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// only this method have direct access to the output string
|
|
||||||
// you can easily change the output from a std::string to something else
|
|
||||||
virtual void Put(const char * str, const char * end);
|
|
||||||
|
|
||||||
|
|
||||||
Item & GetItem(size_t i);
|
|
||||||
Item & LastItem();
|
|
||||||
|
|
||||||
int ToLower(int c);
|
|
||||||
bool IsNameEqual(const char * name1, const char * name2);
|
|
||||||
bool IsNameEqual(const char * name1, const char * name2, size_t len);
|
|
||||||
bool IsLastTag(const char * name);
|
|
||||||
bool IsTagSafe(const char * tag);
|
|
||||||
|
|
||||||
int CheckOrphan(const char * str, const char * end, const char * orphan);
|
|
||||||
bool CheckOrphanTable(const char * str, const char * end, const char ** table, size_t o1, size_t o2);
|
|
||||||
bool CheckOrphanLangPl(const char * str, const char * end);
|
|
||||||
bool CheckOrphanLangCz(const char * str, const char * end);
|
|
||||||
bool CheckOrphan(const char * str, const char * end);
|
|
||||||
|
|
||||||
bool IsWhite(int c);
|
|
||||||
void SkipWhite();
|
|
||||||
void SkipWhiteLines();
|
|
||||||
void SkipWhiteWithFirstNewLine();
|
|
||||||
bool IsClosingTagForLastItem();
|
|
||||||
virtual bool IsOpeningTagMark();
|
|
||||||
virtual bool IsOpeningCommentaryTagMark();
|
|
||||||
size_t OpeningCommentaryTagMarkSize();
|
|
||||||
virtual bool IsClosingTagMark();
|
|
||||||
virtual bool IsClosingXmlSimpleTagMark();
|
|
||||||
bool SkipCommentaryTagIfExists();
|
|
||||||
const char * SkipItemCheckXmlSimple();
|
|
||||||
|
|
||||||
void PopStack();
|
|
||||||
bool PushStack();
|
|
||||||
virtual bool IsValidCharForName(int c);
|
|
||||||
void CheckNewLine();
|
|
||||||
virtual void CheckExceptions();
|
|
||||||
void CheckStackPrintRest();
|
|
||||||
void AddForgottenTags();
|
|
||||||
void CheckClosingTags();
|
|
||||||
virtual void ReadNormalTextSkipWhite(const char * & start, const char * & last_non_white);
|
|
||||||
void ReadNormalText();
|
|
||||||
bool PrintRest();
|
|
||||||
void PrintItem(const char * start, const char * end);
|
|
||||||
void ReadItemName();
|
|
||||||
bool ReadItem();
|
|
||||||
virtual void Init();
|
|
||||||
virtual void Deinit();
|
|
||||||
void Read();
|
|
||||||
|
|
||||||
size_t PutNormalTextTrimFillBuffer(const char * & str, const char * & end);
|
|
||||||
size_t PutNormalTextFillBuffer(const char * & str, const char * & end);
|
|
||||||
virtual void PutNormalText(const char * str, const char * end);
|
|
||||||
virtual void PutNormalTextTrim(const char * str, const char * end);
|
|
||||||
void PutLastTagWithClosingTag();
|
|
||||||
virtual void PutOpeningTagMark();
|
|
||||||
virtual void PutClosingTagMark();
|
|
||||||
virtual void PutTagName(const char * name);
|
|
||||||
virtual void PutOpeningTag(const char * start, const char * end);
|
|
||||||
virtual void PutClosingTag(const char * tag);
|
|
||||||
size_t PutTabsToBuffer(size_t index, size_t len);
|
|
||||||
size_t PutNonBreakSpaceToBuffer(size_t index);
|
|
||||||
void PutTabs(size_t len);
|
|
||||||
void PutNewLine();
|
|
||||||
|
|
||||||
const char * pchar;
|
|
||||||
Item empty;
|
|
||||||
Item * pstack; // stack pointer
|
|
||||||
size_t stack_len; // length of the stack
|
|
||||||
char * buffer; // buffer used when printing
|
|
||||||
std::string * out_string;
|
|
||||||
bool last_new_line;
|
|
||||||
size_t break_after; // insert a space into long lines after break_after characters
|
|
||||||
bool trim_white; // trimming white characters
|
|
||||||
size_t tab_size;
|
|
||||||
Lang lang; // current language for checking orphans
|
|
||||||
OrphanMode orphan_mode;
|
|
||||||
bool safe_mode; // skipping some unsafe tags
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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
|
|
||||||
145
core/item.h
145
core/item.h
@@ -1,145 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucoreitem
|
|
||||||
#define headerfilecmslucoreitem
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Item
|
|
||||||
{
|
|
||||||
long id;
|
|
||||||
long parent_id;
|
|
||||||
|
|
||||||
|
|
||||||
long user_id;
|
|
||||||
long group_id;
|
|
||||||
std::string guest_name; // used as a user name when user_id is equal -1
|
|
||||||
|
|
||||||
long modification_user_id; // who has modified the item last (not taken into account when checking permissions)
|
|
||||||
|
|
||||||
int privileges;
|
|
||||||
|
|
||||||
tm date_creation;
|
|
||||||
tm date_modification;
|
|
||||||
|
|
||||||
std::string subject;
|
|
||||||
std::string content;
|
|
||||||
long content_id; // used by the database
|
|
||||||
std::string url;
|
|
||||||
|
|
||||||
enum ContentType
|
|
||||||
{
|
|
||||||
ct_text = 0,
|
|
||||||
ct_formatted_text,
|
|
||||||
ct_html,
|
|
||||||
ct_bbcode,
|
|
||||||
ct_raw
|
|
||||||
};
|
|
||||||
|
|
||||||
ContentType content_type;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum Type
|
|
||||||
{
|
|
||||||
dir = 0,
|
|
||||||
file = 1,
|
|
||||||
|
|
||||||
none = 1000 // !! pozbyc sie tego
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Type type;
|
|
||||||
|
|
||||||
|
|
||||||
long default_item;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// external static file authorized by winix
|
|
||||||
enum Auth
|
|
||||||
{
|
|
||||||
auth_none = 0, /* there is not an external file */
|
|
||||||
auth_image = 1, /* png, gif, jpg - only types available to render by a web browser*/
|
|
||||||
auth_document = 2, /* pdf doc xls txt */
|
|
||||||
auth_other = 3 /* other file */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Auth auth;
|
|
||||||
std::string auth_path; // path to a file (if auth!=auth_none)
|
|
||||||
|
|
||||||
|
|
||||||
// methods
|
|
||||||
|
|
||||||
Item()
|
|
||||||
{
|
|
||||||
Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SetDateToNow()
|
|
||||||
{
|
|
||||||
time_t t = std::time(0);
|
|
||||||
date_creation = *std::localtime( &t );
|
|
||||||
date_modification = date_creation;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SetDateModifyToNow()
|
|
||||||
{
|
|
||||||
time_t t = std::time(0);
|
|
||||||
date_modification = *std::localtime( &t );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Clear()
|
|
||||||
{
|
|
||||||
id = -1;
|
|
||||||
|
|
||||||
user_id = -1;
|
|
||||||
group_id = -1;
|
|
||||||
privileges = 0;
|
|
||||||
modification_user_id = -1;
|
|
||||||
|
|
||||||
guest_name.clear();
|
|
||||||
|
|
||||||
subject.clear();
|
|
||||||
content.clear();
|
|
||||||
url.clear();
|
|
||||||
|
|
||||||
content_type = ct_formatted_text;
|
|
||||||
|
|
||||||
type = none;
|
|
||||||
parent_id = -1;
|
|
||||||
default_item = -1;
|
|
||||||
|
|
||||||
content_id = -1;
|
|
||||||
|
|
||||||
auth = auth_none;
|
|
||||||
auth_path.clear();
|
|
||||||
|
|
||||||
SetDateToNow();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* 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 Winix
|
|
||||||
* 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
|
|
||||||
234
core/locale.cpp
234
core/locale.cpp
@@ -1,234 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "locale.h"
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
|
|
||||||
Locale::Locale()
|
|
||||||
{
|
|
||||||
loc_tab.resize(lang_unknown);
|
|
||||||
default_lang = lang_en;
|
|
||||||
current_lang = lang_en;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Locale::AddLocale(Lang lang)
|
|
||||||
{
|
|
||||||
ConfParser::TableSingle::iterator i = loc_parser.table_single.begin();
|
|
||||||
|
|
||||||
for( ; i != loc_parser.table_single.end() ; ++i)
|
|
||||||
loc_tab[lang][i->first] = i->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Locale::ReadFile(const char * dir, const char * dir_def, Lang lang, const char * file)
|
|
||||||
{
|
|
||||||
if( static_cast<size_t>(lang) >= loc_tab.size() )
|
|
||||||
{
|
|
||||||
// ops, something wrong
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
loc_tab[lang].clear();
|
|
||||||
bool read = false;
|
|
||||||
|
|
||||||
if( dir_def && ReadFile(dir_def, lang, file) )
|
|
||||||
read = true;
|
|
||||||
|
|
||||||
if( dir && ReadFile(dir, lang, file) )
|
|
||||||
read = true;
|
|
||||||
|
|
||||||
if( !read )
|
|
||||||
log << log1 << "Locale: can't open locale's file: " << file << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Locale::ReadFile(const char * dir, Lang lang, const char * file)
|
|
||||||
{
|
|
||||||
bool read = false;
|
|
||||||
|
|
||||||
file_name = dir;
|
|
||||||
file_name += '/';
|
|
||||||
file_name += file;
|
|
||||||
|
|
||||||
loc_parser.SplitSingle(true);
|
|
||||||
|
|
||||||
if( loc_parser.Parse(file_name) == ConfParser::ok )
|
|
||||||
{
|
|
||||||
read = true;
|
|
||||||
AddLocale(lang);
|
|
||||||
log << log3 << "Locale: read locale from: " << file_name << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
return read;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Locale::Read(const char * dir, const char * dir_def)
|
|
||||||
{
|
|
||||||
ReadFile(dir, dir_def, lang_pl, "pl");
|
|
||||||
ReadFile(dir, dir_def, lang_en, "en");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Locale::Read(const std::string & dir, const std::string & dir_def)
|
|
||||||
{
|
|
||||||
if( dir_def.empty() )
|
|
||||||
Read(dir.c_str());
|
|
||||||
else
|
|
||||||
Read(dir.c_str(), dir_def.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Locale::SetLang(Lang lang)
|
|
||||||
{
|
|
||||||
current_lang = lang;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Locale::Lang Locale::GetLang()
|
|
||||||
{
|
|
||||||
return current_lang;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Locale::SetLangDef(Lang lang)
|
|
||||||
{
|
|
||||||
default_lang = lang_en;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Locale::IsKey(const std::string & key) const
|
|
||||||
{
|
|
||||||
return IsKey(key, current_lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Locale::IsKey(const std::string & key, Lang lang) const
|
|
||||||
{
|
|
||||||
if( static_cast<size_t>(lang) >= loc_tab.size() )
|
|
||||||
{
|
|
||||||
// ops, something wrong
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// looking in the lang language
|
|
||||||
ConfParser::TableSingle::const_iterator i = loc_tab[lang].find(key);
|
|
||||||
|
|
||||||
if( i != loc_tab[lang].end() )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if( lang == default_lang )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
|
||||||
if( static_cast<size_t>(default_lang) >= loc_tab.size() )
|
|
||||||
{
|
|
||||||
// ops, something wrong
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// looking in a default language
|
|
||||||
i = loc_tab[default_lang].find(key);
|
|
||||||
|
|
||||||
if( i != loc_tab[default_lang].end() )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// there is no such a key
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const std::string & Locale::Get(const std::string & key) const
|
|
||||||
{
|
|
||||||
return Get(key, current_lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const std::string & Locale::Get(const std::string & key, Lang lang) const
|
|
||||||
{
|
|
||||||
if( static_cast<size_t>(lang) >= loc_tab.size() )
|
|
||||||
{
|
|
||||||
// ops, something wrong
|
|
||||||
return empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
// looking in the lang language
|
|
||||||
ConfParser::TableSingle::const_iterator i = loc_tab[lang].find(key);
|
|
||||||
|
|
||||||
if( i != loc_tab[lang].end() )
|
|
||||||
return i->second;
|
|
||||||
|
|
||||||
if( lang == default_lang )
|
|
||||||
return empty;
|
|
||||||
|
|
||||||
|
|
||||||
if( static_cast<size_t>(default_lang) >= loc_tab.size() )
|
|
||||||
{
|
|
||||||
// ops, something wrong
|
|
||||||
return empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
// looking in a default language
|
|
||||||
i = loc_tab[default_lang].find(key);
|
|
||||||
|
|
||||||
if( i != loc_tab[default_lang].end() )
|
|
||||||
return i->second;
|
|
||||||
|
|
||||||
// there is no such a key
|
|
||||||
return empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Locale::Lang Locale::StrToLang(const std::string & str)
|
|
||||||
{
|
|
||||||
if( str == "en" )
|
|
||||||
return lang_en;
|
|
||||||
else
|
|
||||||
if( str == "pl" )
|
|
||||||
return lang_pl;
|
|
||||||
|
|
||||||
return lang_unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char * Locale::LangToStr(Lang lang)
|
|
||||||
{
|
|
||||||
static char buffer[30];
|
|
||||||
|
|
||||||
switch(lang)
|
|
||||||
{
|
|
||||||
case lang_en:
|
|
||||||
sprintf(buffer, "en");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case lang_pl:
|
|
||||||
sprintf(buffer, "pl");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
sprintf(buffer, "unknown");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t Locale::Size()
|
|
||||||
{
|
|
||||||
return loc_tab.size();
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucorelocale
|
|
||||||
#define headerfilecmslucorelocale
|
|
||||||
|
|
||||||
#include "../confparser/confparser.h"
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Locale
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
enum Lang
|
|
||||||
{
|
|
||||||
lang_en = 0,
|
|
||||||
lang_pl,
|
|
||||||
|
|
||||||
lang_unknown // should be last
|
|
||||||
};
|
|
||||||
|
|
||||||
Locale();
|
|
||||||
|
|
||||||
void Read(const char * dir, const char * dir_def = 0);
|
|
||||||
void Read(const std::string & dir, const std::string & dir_def);
|
|
||||||
|
|
||||||
bool IsKey(const std::string & key) const;
|
|
||||||
bool IsKey(const std::string & key, Lang lang) const;
|
|
||||||
const std::string & Get(const std::string & key) const;
|
|
||||||
const std::string & Get(const std::string & key, Lang lang) const;
|
|
||||||
|
|
||||||
// default is english
|
|
||||||
void SetLang(Lang lang);
|
|
||||||
Lang GetLang();
|
|
||||||
|
|
||||||
// which language is used instead if there is no a key in an other language
|
|
||||||
// default: lang_en
|
|
||||||
void SetLangDef(Lang lang);
|
|
||||||
|
|
||||||
|
|
||||||
static Lang StrToLang(const std::string & str);
|
|
||||||
static const char * LangToStr(Lang lang);
|
|
||||||
|
|
||||||
size_t Size();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void AddLocale(Lang lang);
|
|
||||||
void ReadFile(const char * dir, const char * dir_def, Lang lang, const char * file);
|
|
||||||
bool ReadFile(const char * dir, Lang lang, const char * file);
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<ConfParser::TableSingle> loc_tab;
|
|
||||||
ConfParser loc_parser;
|
|
||||||
std::string file_name;
|
|
||||||
std::string empty;
|
|
||||||
Lang default_lang;
|
|
||||||
Lang current_lang;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
259
core/log.cpp
259
core/log.cpp
@@ -1,259 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "log.h"
|
|
||||||
#include <ctime>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
Log::Log()
|
|
||||||
{
|
|
||||||
log_level = 3;
|
|
||||||
current_level = 4; // nothing to log (call Init() first)
|
|
||||||
item = 0;
|
|
||||||
item_save = 1;
|
|
||||||
lines = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Log::Init(int log_l, const std::string & log_f, bool log_std, int log_request)
|
|
||||||
{
|
|
||||||
log_level = log_l;
|
|
||||||
log_file = log_f;
|
|
||||||
log_stdout = log_std;
|
|
||||||
item_save = log_request;
|
|
||||||
|
|
||||||
OpenFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Log::OpenFile()
|
|
||||||
{
|
|
||||||
if( !log_file.empty() )
|
|
||||||
file.open( log_file.c_str(), std::ios_base::out | std::ios_base::app );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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<<(const std::string * s)
|
|
||||||
{
|
|
||||||
buffer << *s;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Log & Log::operator<<(const void * 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:
|
|
||||||
buffer << '\n';
|
|
||||||
lines += 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case logsavenow:
|
|
||||||
SaveLog();
|
|
||||||
buffer.str( "" );
|
|
||||||
item = 0;
|
|
||||||
lines = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case logsave:
|
|
||||||
item += 1;
|
|
||||||
|
|
||||||
if( item >= item_save || lines > 3000 )
|
|
||||||
{
|
|
||||||
SaveLog();
|
|
||||||
buffer.str( "" );
|
|
||||||
item = 0;
|
|
||||||
lines = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case log1:
|
|
||||||
current_level = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case log2:
|
|
||||||
current_level = 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case log3:
|
|
||||||
current_level = 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Log::SystemErr(int err)
|
|
||||||
{
|
|
||||||
(*this) << "errno: " << err;
|
|
||||||
|
|
||||||
const char * err_msg = strerror(err);
|
|
||||||
|
|
||||||
if( err_msg )
|
|
||||||
(*this) << " (" << err_msg << ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Log::SaveLog()
|
|
||||||
{
|
|
||||||
if( current_level > log_level )
|
|
||||||
return;
|
|
||||||
|
|
||||||
const std::string & source = buffer.str();
|
|
||||||
|
|
||||||
if( source.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( log_stdout )
|
|
||||||
std::cout << source;
|
|
||||||
|
|
||||||
if( log_file.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( !file )
|
|
||||||
{
|
|
||||||
file.close();
|
|
||||||
file.clear();
|
|
||||||
|
|
||||||
OpenFile();
|
|
||||||
|
|
||||||
if( !file )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
file << source << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
69
core/log.h
69
core/log.h
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 { logsave, logsavenow, logend, log1, log2, log3 };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Log
|
|
||||||
{
|
|
||||||
std::ostringstream buffer;
|
|
||||||
int log_level, current_level;
|
|
||||||
int item, item_save;
|
|
||||||
std::string log_file;
|
|
||||||
bool log_stdout;
|
|
||||||
std::ofstream file;
|
|
||||||
int lines;
|
|
||||||
|
|
||||||
void OpenFile();
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Log();
|
|
||||||
|
|
||||||
void Init(int log_l, const std::string & log_f, bool log_std, int log_request);
|
|
||||||
|
|
||||||
void PutDate(Manipulators m);
|
|
||||||
Log & operator<<(const char * s);
|
|
||||||
Log & operator<<(const void * s);
|
|
||||||
Log & operator<<(const std::string * 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 SystemErr(int err);
|
|
||||||
|
|
||||||
void SaveLog();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern Log log;
|
|
||||||
extern Log nlog;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
783
core/misc.cpp
783
core/misc.cpp
@@ -1,783 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include "misc.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "data.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// this function checks how many dots there are in the url
|
|
||||||
// if there are more than one (last) dot then the first dots will be changed into '_'
|
|
||||||
void CorrectUrlDots(std::string & url)
|
|
||||||
{
|
|
||||||
size_t i = url.size();
|
|
||||||
bool was_dot = false;
|
|
||||||
|
|
||||||
while( i-- > 0 )
|
|
||||||
{
|
|
||||||
if( url[i] == '.' )
|
|
||||||
{
|
|
||||||
if( was_dot )
|
|
||||||
// only one dot is allowed
|
|
||||||
url[i] = '_';
|
|
||||||
|
|
||||||
was_dot = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CorrectUrlChars(std::string & url)
|
|
||||||
{
|
|
||||||
std::string::iterator i;
|
|
||||||
|
|
||||||
for(i=url.begin(); i != url.end() ; ++i)
|
|
||||||
{
|
|
||||||
if( !CorrectUrlChar(*i) )
|
|
||||||
{
|
|
||||||
int c = ChangeLocalChar(*i);
|
|
||||||
|
|
||||||
if( CorrectUrlChar(c) )
|
|
||||||
*i = c;
|
|
||||||
else
|
|
||||||
*i = '_';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CorrectUrlOnlyAllowedChar(std::string & url)
|
|
||||||
{
|
|
||||||
CorrectUrlDots(url);
|
|
||||||
CorrectUrlChars(url);
|
|
||||||
ToSmall(url);
|
|
||||||
Trim(url, '_');
|
|
||||||
|
|
||||||
if( url.empty() || url == "." )
|
|
||||||
{
|
|
||||||
if( data.item_url_empty.empty() )
|
|
||||||
url = "unnamed";
|
|
||||||
else
|
|
||||||
{
|
|
||||||
url = data.item_url_empty;
|
|
||||||
|
|
||||||
CorrectUrlDots(url);
|
|
||||||
CorrectUrlChars(url);
|
|
||||||
ToSmall(url);
|
|
||||||
// we don't trim here and the string will not be empty
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( url[0] >= '0' && url[0] <= '9' )
|
|
||||||
// url must begin with a letter
|
|
||||||
url.insert(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
|
|
||||||
|
|
||||||
if( in.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
out << "<p>";
|
|
||||||
|
|
||||||
// skipping first new line characters
|
|
||||||
for(i = in.begin() ; i != in.end() && (*i==13 || *i==10) ; ++i);
|
|
||||||
|
|
||||||
for( ; i != in.end() ; ++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>";
|
|
||||||
|
|
||||||
was_enter = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !HtmlTryChar(out, *i) )
|
|
||||||
out << *i;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
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", month_letter[month], day);
|
|
||||||
else
|
|
||||||
sprintf(buffer, "%02d %s %02d", year, month_letter[month], day);
|
|
||||||
|
|
||||||
// warning: not thread safe (we do not use threads)
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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 * DateToStrWithoutHours(tm * ptm)
|
|
||||||
{
|
|
||||||
return DateToStr(ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char * DateToStrWithoutHours(time_t t)
|
|
||||||
{
|
|
||||||
tm * ptm = std::localtime(&t);
|
|
||||||
|
|
||||||
return DateToStrWithoutHours(ptm);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// this format is used with cookies
|
|
||||||
const char * DateToStrCookie(int year, int month, int day, int hour, int min, int sec)
|
|
||||||
{
|
|
||||||
static const char * month_str[]={ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
|
||||||
static char buffer[100];
|
|
||||||
|
|
||||||
--month;
|
|
||||||
|
|
||||||
if( month < 0 )
|
|
||||||
month = 0;
|
|
||||||
|
|
||||||
if( month > 11 )
|
|
||||||
month = 11;
|
|
||||||
|
|
||||||
sprintf(buffer, "%02d-%s-%04d %02d:%02d:%02d", day, month_str[month], year, hour, min, sec);
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char * DateToStrCookie(tm * ptm)
|
|
||||||
{
|
|
||||||
return DateToStrCookie(ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char * DateToStrCookie(time_t t)
|
|
||||||
{
|
|
||||||
tm * ptm = std::localtime(&t);
|
|
||||||
|
|
||||||
return DateToStrCookie(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char * ToStr(int value)
|
|
||||||
{
|
|
||||||
static char buffer[100];
|
|
||||||
|
|
||||||
sprintf(buffer, "%d", value);
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool IsWhite(int s)
|
|
||||||
{
|
|
||||||
if( s==' ' || s=='\t' || s==13 || s==160 )
|
|
||||||
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 Trim(std::string & s, char c)
|
|
||||||
{
|
|
||||||
std::string::size_type i;
|
|
||||||
|
|
||||||
if( s.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// looking for the 'c' characters at the end
|
|
||||||
for(i=s.size()-1 ; i>0 && s[i]==c ; --i);
|
|
||||||
|
|
||||||
if( i==0 && s[i]==c )
|
|
||||||
{
|
|
||||||
// the whole string has the 'c' characters
|
|
||||||
s.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// deleting 'c' characters at the end
|
|
||||||
if( i != s.size() - 1 )
|
|
||||||
s.erase(i+1, std::string::npos);
|
|
||||||
|
|
||||||
// looking for the 'c' characters at the beginning
|
|
||||||
for(i=0 ; i<s.size() && s[i]==c ; ++i);
|
|
||||||
|
|
||||||
// deleting the 'c' characters at the beginning
|
|
||||||
if( i != 0 )
|
|
||||||
s.erase(0, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char * SkipWhite(const char * s)
|
|
||||||
{
|
|
||||||
while( IsWhite(*s) )
|
|
||||||
++s;
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int ToSmall(int c)
|
|
||||||
{
|
|
||||||
if( c>='A' && c<='Z' )
|
|
||||||
c = c - 'A' + 'a';
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ToSmall(std::string & s)
|
|
||||||
{
|
|
||||||
std::string::size_type i;
|
|
||||||
|
|
||||||
for(i=0 ; i<s.size() ; ++i)
|
|
||||||
s[i] = ToSmall(s[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool IsSubString(const char * short_str, const char * long_str)
|
|
||||||
{
|
|
||||||
while( *short_str && *long_str && *short_str == *long_str )
|
|
||||||
{
|
|
||||||
++short_str;
|
|
||||||
++long_str;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( *short_str == 0 )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool IsSubStringNoCase(const char * short_str, const char * long_str)
|
|
||||||
{
|
|
||||||
while( *short_str && *long_str && ToSmall(*short_str) == ToSmall(*long_str) )
|
|
||||||
{
|
|
||||||
++short_str;
|
|
||||||
++long_str;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( *short_str == 0 )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool EqualNoCase(const char * str1, const char * str2)
|
|
||||||
{
|
|
||||||
while( *str1 && *str2 && ToSmall(*str1) == ToSmall(*str2) )
|
|
||||||
{
|
|
||||||
++str1;
|
|
||||||
++str2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( *str1 == 0 && *str2 == 0 )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool IsFile(const char * file)
|
|
||||||
{
|
|
||||||
struct stat sb;
|
|
||||||
|
|
||||||
return (stat(file, &sb) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsFile(const std::string & file)
|
|
||||||
{
|
|
||||||
return IsFile(file.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool CreateDir(const char * dir, int priv)
|
|
||||||
{
|
|
||||||
if( !IsFile(dir) )
|
|
||||||
{
|
|
||||||
if( mkdir(dir, priv) < 0 )
|
|
||||||
{
|
|
||||||
log << log1 << "Can't create a directory on fs: " << dir << logend;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool CreateDir(const std::string & dir, int priv)
|
|
||||||
{
|
|
||||||
return CreateDir(dir.c_str(), priv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// creating directories (can be more than one)
|
|
||||||
// 'dirs' can begin with a slash (will be skipped)
|
|
||||||
bool CreateDirs(const char * base_dir, const char * dirs, int priv)
|
|
||||||
{
|
|
||||||
static std::string temp;
|
|
||||||
const char * p = dirs;
|
|
||||||
|
|
||||||
temp = base_dir; // we start creating from 'base_dir'
|
|
||||||
|
|
||||||
if( temp.empty() )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if( temp[temp.size()-1] != '/' )
|
|
||||||
temp += '/';
|
|
||||||
|
|
||||||
while( true )
|
|
||||||
{
|
|
||||||
// skipping slashes
|
|
||||||
for( ; *p=='/' ; ++p );
|
|
||||||
|
|
||||||
if( *p == 0 )
|
|
||||||
break;
|
|
||||||
|
|
||||||
// taking the name
|
|
||||||
for( ; *p && *p!='/' ; ++p )
|
|
||||||
temp += *p;
|
|
||||||
|
|
||||||
if( !CreateDir(temp.c_str(), priv) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
temp += '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CreateDirs(const std::string & base_dir, const std::string & dirs, int priv)
|
|
||||||
{
|
|
||||||
return CreateDirs(base_dir.c_str(), dirs.c_str(), priv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CopyFile(FILE * in, FILE * out)
|
|
||||||
{
|
|
||||||
char buf[1024];
|
|
||||||
size_t buflen = sizeof(buf)/sizeof(char);
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
len = fread(buf, 1, buflen, in);
|
|
||||||
|
|
||||||
if( len > 0 )
|
|
||||||
fwrite(buf, 1, len, out);
|
|
||||||
|
|
||||||
if( ferror(in) || ferror(out) )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
while( !feof(in) );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool CopyFile(const char * src, const char * dst)
|
|
||||||
{
|
|
||||||
FILE * in, * out;
|
|
||||||
|
|
||||||
in = fopen(src, "rb");
|
|
||||||
|
|
||||||
if( !in )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
out = fopen(dst, "wb");
|
|
||||||
|
|
||||||
if( !out )
|
|
||||||
{
|
|
||||||
fclose(in);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool res = CopyFile(in, out);
|
|
||||||
|
|
||||||
fclose(in);
|
|
||||||
fclose(out);
|
|
||||||
|
|
||||||
if( res && ferror(out) )
|
|
||||||
res = false;
|
|
||||||
|
|
||||||
if( !res )
|
|
||||||
remove(dst);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool CopyFile(const std::string & src, const std::string & dst)
|
|
||||||
{
|
|
||||||
return CopyFile(src.c_str(), dst.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// if there is not an extension it returns a pointer to the last '\0' character
|
|
||||||
const char * GetFileExt(const char * name)
|
|
||||||
{
|
|
||||||
size_t i, ilast;
|
|
||||||
|
|
||||||
// looking for the end of the name
|
|
||||||
for(i=0 ; name[i] != 0 ; ++i);
|
|
||||||
|
|
||||||
if( i == 0 )
|
|
||||||
return name; // ops, the name is empty
|
|
||||||
|
|
||||||
// remember the end of the string
|
|
||||||
ilast = i;
|
|
||||||
|
|
||||||
// looking for the last dot
|
|
||||||
for(--i ; i>0 && name[i] != '.' ; --i);
|
|
||||||
|
|
||||||
if( name[i] != '.' )
|
|
||||||
return name + ilast; // ops, there is not a dot
|
|
||||||
|
|
||||||
// the extensions starts from i+1
|
|
||||||
// and can be empty (if the last character is a dot)
|
|
||||||
|
|
||||||
return name + i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Item::Auth SelectFileType(const char * file_name)
|
|
||||||
{
|
|
||||||
const char * ext = GetFileExt(file_name);
|
|
||||||
|
|
||||||
// as an image we're using only those types which can be rendered
|
|
||||||
// by a web browser
|
|
||||||
if( EqualNoCase(ext, "jpg") ||
|
|
||||||
EqualNoCase(ext, "jpeg") ||
|
|
||||||
EqualNoCase(ext, "jpe") ||
|
|
||||||
EqualNoCase(ext, "pic") ||
|
|
||||||
EqualNoCase(ext, "tga") ||
|
|
||||||
EqualNoCase(ext, "gif") ||
|
|
||||||
EqualNoCase(ext, "bmp") ||
|
|
||||||
EqualNoCase(ext, "png") )
|
|
||||||
return Item::auth_image;
|
|
||||||
|
|
||||||
if( EqualNoCase(ext, "pdf") ||
|
|
||||||
EqualNoCase(ext, "doc") ||
|
|
||||||
EqualNoCase(ext, "xls") ||
|
|
||||||
EqualNoCase(ext, "txt") ||
|
|
||||||
EqualNoCase(ext, "ods") ||
|
|
||||||
EqualNoCase(ext, "odt") )
|
|
||||||
return Item::auth_document;
|
|
||||||
|
|
||||||
return Item::auth_other;
|
|
||||||
}
|
|
||||||
|
|
||||||
76
core/misc.h
76
core/misc.h
@@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucoremisc
|
|
||||||
#define headerfilecmslucoremisc
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
#include <ctime>
|
|
||||||
#include "item.h"
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
|
|
||||||
void ToString(std::string & s, int value);
|
|
||||||
void ToString(std::string & s, long value);
|
|
||||||
int ChangeLocalChar(unsigned char c);
|
|
||||||
|
|
||||||
bool CorrectUrlChar(char c);
|
|
||||||
void CorrectUrlDots(std::string & url);
|
|
||||||
void CorrectUrlChars(std::string & url);
|
|
||||||
void CorrectUrlOnlyAllowedChar(std::string & url);
|
|
||||||
|
|
||||||
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);
|
|
||||||
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 * DateToStrWithoutHours(tm * ptm);
|
|
||||||
const char * DateToStrWithoutHours(time_t t);
|
|
||||||
|
|
||||||
const char * DateToStrCookie(int year, int month, int day, int hour, int min, int sec);
|
|
||||||
const char * DateToStrCookie(tm * ptm);
|
|
||||||
const char * DateToStrCookie(time_t t);
|
|
||||||
|
|
||||||
const char * IpToStr(unsigned int ip_);
|
|
||||||
|
|
||||||
bool IsWhite(int s);
|
|
||||||
void TrimWhite(std::string & s);
|
|
||||||
void Trim(std::string & s, char c);
|
|
||||||
int ToSmall(int c);
|
|
||||||
void ToSmall(std::string & s);
|
|
||||||
const char * SkipWhite(const char * s);
|
|
||||||
const char * ToStr(int value);
|
|
||||||
|
|
||||||
bool IsSubString(const char * short_str, const char * long_str);
|
|
||||||
bool IsSubStringNoCase(const char * short_str, const char * long_str);
|
|
||||||
bool EqualNoCase(const char * str1, const char * str2);
|
|
||||||
|
|
||||||
bool ValidateEmail(const std::string & email);
|
|
||||||
|
|
||||||
bool IsFile(const char * file);
|
|
||||||
bool IsFile(const std::string & file);
|
|
||||||
bool CreateDir(const char * dir, int priv);
|
|
||||||
bool CreateDir(const std::string & dir, int priv);
|
|
||||||
bool CreateDirs(const char * base_dir, const char * dirs, int priv);
|
|
||||||
bool CreateDirs(const std::string & base_dir, const std::string & dirs, int priv);
|
|
||||||
|
|
||||||
bool CopyFile(FILE * in, FILE * out);
|
|
||||||
bool CopyFile(const char * src, const char * dst);
|
|
||||||
bool CopyFile(const std::string & src, const std::string & dst);
|
|
||||||
|
|
||||||
const char * GetFileExt(const char * name);
|
|
||||||
Item::Auth SelectFileType(const char * file_name);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
191
core/mount.cpp
191
core/mount.cpp
@@ -1,191 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2009, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "mount.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Mount::Mount()
|
|
||||||
{
|
|
||||||
type = cms;
|
|
||||||
dir_id = -1;
|
|
||||||
fs = simplefs;
|
|
||||||
|
|
||||||
param.resize(par_none);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char * Mount::TypeToStr()
|
|
||||||
{
|
|
||||||
static char buffer[30];
|
|
||||||
|
|
||||||
switch( type )
|
|
||||||
{
|
|
||||||
case cms:
|
|
||||||
sprintf(buffer, "cms");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case thread:
|
|
||||||
sprintf(buffer, "thread");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ticket:
|
|
||||||
sprintf(buffer, "ticket");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
sprintf(buffer, "unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char * Mount::FsToStr()
|
|
||||||
{
|
|
||||||
static char buffer[30];
|
|
||||||
|
|
||||||
switch( fs )
|
|
||||||
{
|
|
||||||
case simplefs:
|
|
||||||
sprintf(buffer, "simplefs");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case hashfs:
|
|
||||||
sprintf(buffer, "hashfs");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
sprintf(buffer, "unknown");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Mount::ParamCode Mount::ParseParam(const char * param_name)
|
|
||||||
{
|
|
||||||
struct ParName
|
|
||||||
{
|
|
||||||
ParamCode param_code;
|
|
||||||
const char * name;
|
|
||||||
};
|
|
||||||
|
|
||||||
static ParName par_name_tab[] = {
|
|
||||||
{ par_page, "page" },
|
|
||||||
{ par_thread, "thread" },
|
|
||||||
{ par_ticket, "ticket" },
|
|
||||||
{ par_ticket_type, "ticket_type" },
|
|
||||||
{ par_ticket_type_default, "ticket_type_default" },
|
|
||||||
{ par_ticket_status, "ticket_status" },
|
|
||||||
{ par_ticket_status_default, "ticket_status_default" },
|
|
||||||
{ par_ticket_priority, "ticket_priority" },
|
|
||||||
{ par_ticket_priority_default, "ticket_priority_default" },
|
|
||||||
{ par_ticket_category, "ticket_category" },
|
|
||||||
{ par_ticket_category_default, "ticket_category_default" },
|
|
||||||
{ par_ticket_expected, "ticket_expected" },
|
|
||||||
{ par_ticket_expected_default, "ticket_expected_default" },
|
|
||||||
{ par_createthread_on, "createthread_on" },
|
|
||||||
{ par_createticket_on, "createticket_on" },
|
|
||||||
{ par_only_root_remove, "only_root_remove" },
|
|
||||||
{ par_emacs_on, "emacs_on" },
|
|
||||||
{ par_mkdir_on, "mkdir_on" },
|
|
||||||
{ par_app, "app" },
|
|
||||||
{ par_html_template, "html_template" },
|
|
||||||
};
|
|
||||||
|
|
||||||
size_t i, len = sizeof(par_name_tab) / sizeof(ParName);
|
|
||||||
|
|
||||||
for(i=0 ; i<len ; ++i)
|
|
||||||
{
|
|
||||||
if( strcmp(par_name_tab[i].name, param_name) == 0 )
|
|
||||||
return par_name_tab[i].param_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
return par_none;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Mount::ClearParams()
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for(i=0 ; i<param.size() ; ++i)
|
|
||||||
param[i].Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Mount::IsPar(Mount::ParamCode code)
|
|
||||||
{
|
|
||||||
if( !param[code].defined )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Mount::IsArg(Mount::ParamCode code, const char * arg)
|
|
||||||
{
|
|
||||||
ParamArg::iterator i;
|
|
||||||
|
|
||||||
if( !param[code].defined )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for(i=param[code].arg.begin() ; i!=param[code].arg.end() ; ++i)
|
|
||||||
{
|
|
||||||
if( *i == arg )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Mount::IsArg(Mount::ParamCode code, const std::string & arg)
|
|
||||||
{
|
|
||||||
return IsArg(code, arg.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Mount::IsArg(Mount::ParamCode code, int arg)
|
|
||||||
{
|
|
||||||
ParamArg::iterator i;
|
|
||||||
|
|
||||||
if( !param[code].defined )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for(i=param[code].arg.begin() ; i!=param[code].arg.end() ; ++i)
|
|
||||||
{
|
|
||||||
if( atoi(i->c_str()) == arg )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const std::string * Mount::HtmlTemplate() const
|
|
||||||
{
|
|
||||||
if( !param[par_html_template].defined )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if( param[par_html_template].arg.size() != 1 )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return & param[par_html_template].arg[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
111
core/mount.h
111
core/mount.h
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* 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,
|
|
||||||
ticket
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Fs
|
|
||||||
{
|
|
||||||
simplefs = 0,
|
|
||||||
hashfs
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// the first should be with 0 index
|
|
||||||
// the last should be 'none'
|
|
||||||
enum ParamCode
|
|
||||||
{
|
|
||||||
par_page = 0,
|
|
||||||
par_thread,
|
|
||||||
par_ticket,
|
|
||||||
par_ticket_type,
|
|
||||||
par_ticket_type_default,
|
|
||||||
par_ticket_status,
|
|
||||||
par_ticket_status_default,
|
|
||||||
par_ticket_priority,
|
|
||||||
par_ticket_priority_default,
|
|
||||||
par_ticket_category,
|
|
||||||
par_ticket_category_default,
|
|
||||||
par_ticket_expected,
|
|
||||||
par_ticket_expected_default,
|
|
||||||
par_createthread_on,
|
|
||||||
par_createticket_on,
|
|
||||||
par_only_root_remove,
|
|
||||||
par_emacs_on,
|
|
||||||
par_mkdir_on,
|
|
||||||
par_app,
|
|
||||||
par_html_template,
|
|
||||||
|
|
||||||
par_none
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::vector<std::string> ParamArg;
|
|
||||||
|
|
||||||
|
|
||||||
struct ParamRow
|
|
||||||
{
|
|
||||||
bool defined;
|
|
||||||
ParamArg arg;
|
|
||||||
|
|
||||||
ParamRow() { defined = false; }
|
|
||||||
void Clear() { defined = false; arg.clear(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::vector<ParamRow> Param;
|
|
||||||
Param param;
|
|
||||||
|
|
||||||
long dir_id;
|
|
||||||
Type type;
|
|
||||||
Fs fs;
|
|
||||||
|
|
||||||
|
|
||||||
Mount();
|
|
||||||
const char * TypeToStr();
|
|
||||||
const char * FsToStr();
|
|
||||||
static ParamCode ParseParam(const char * param);
|
|
||||||
|
|
||||||
|
|
||||||
void ClearParams();
|
|
||||||
|
|
||||||
|
|
||||||
bool IsPar(Mount::ParamCode code);
|
|
||||||
|
|
||||||
bool IsArg(Mount::ParamCode code, const char * arg);
|
|
||||||
bool IsArg(Mount::ParamCode code, const std::string & arg);
|
|
||||||
bool IsArg(Mount::ParamCode code, int arg);
|
|
||||||
|
|
||||||
// returning a name to html template (can be null if not defined)
|
|
||||||
const std::string * HtmlTemplate() const;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,369 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "mountparser.h"
|
|
||||||
#include "data.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
|
|
||||||
bool MountParser::IsWhite(int c)
|
|
||||||
{
|
|
||||||
if( c==' ' || c=='\t' || c==13 || c==160 )
|
|
||||||
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::ReadWordQuote(std::string & res)
|
|
||||||
{
|
|
||||||
++pinput;
|
|
||||||
|
|
||||||
while( *pinput && *pinput!=10 && *pinput!='\"' )
|
|
||||||
{
|
|
||||||
if( pinput[0]=='\\' && pinput[1]=='\"' )
|
|
||||||
{
|
|
||||||
res += '\"';
|
|
||||||
pinput += 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( pinput[0]=='\\' && pinput[1]=='\\' )
|
|
||||||
{
|
|
||||||
res += '\\';
|
|
||||||
pinput += 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res += *pinput;
|
|
||||||
pinput += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( *pinput == '"' )
|
|
||||||
++pinput;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// a white character is the separator
|
|
||||||
void MountParser::ReadWordWhite(std::string & res)
|
|
||||||
{
|
|
||||||
while( *pinput && *pinput!=10 && !IsWhite(*pinput) )
|
|
||||||
{
|
|
||||||
res += *pinput;
|
|
||||||
++pinput;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// the comma or the second bracket ')' are the separators
|
|
||||||
void MountParser::ReadWordComma(std::string & res)
|
|
||||||
{
|
|
||||||
while( *pinput && *pinput!=10 && *pinput!=',' && *pinput!=')' )
|
|
||||||
{
|
|
||||||
res += *pinput;
|
|
||||||
++pinput;
|
|
||||||
}
|
|
||||||
|
|
||||||
// trimming last white characters
|
|
||||||
// (white characters can be in the middle of the string)
|
|
||||||
TrimWhite(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::ReadWord(std::string & res, bool comma_bracket_separator)
|
|
||||||
{
|
|
||||||
res.clear();
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
if( *pinput == '"' )
|
|
||||||
{
|
|
||||||
ReadWordQuote(res);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( comma_bracket_separator )
|
|
||||||
{
|
|
||||||
ReadWordComma(res);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ReadWordWhite(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::ReadParamArgsLoop(Mount::ParamArg & args)
|
|
||||||
{
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
while( *pinput && *pinput!=10 && *pinput!=')' )
|
|
||||||
{
|
|
||||||
ReadWord(temp_arg, true);
|
|
||||||
|
|
||||||
if( !temp_arg.empty() )
|
|
||||||
args.push_back(temp_arg);
|
|
||||||
|
|
||||||
if( *pinput == ',' )
|
|
||||||
++pinput;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::ReadParamArgs(Mount::ParamArg & args)
|
|
||||||
{
|
|
||||||
SkipWhite();
|
|
||||||
args.clear();
|
|
||||||
|
|
||||||
|
|
||||||
if( *pinput == '(' )
|
|
||||||
{
|
|
||||||
++pinput;
|
|
||||||
ReadParamArgsLoop(args);
|
|
||||||
|
|
||||||
if( *pinput != ')' )
|
|
||||||
{
|
|
||||||
// there should be ')' at the end
|
|
||||||
// temporarily we do nothing
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
++pinput;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::ReadParamName(std::string & res)
|
|
||||||
{
|
|
||||||
SkipWhite();
|
|
||||||
res.clear();
|
|
||||||
|
|
||||||
while( *pinput && *pinput!=10 && *pinput!=',' && *pinput!='(' && !IsWhite(*pinput) )
|
|
||||||
{
|
|
||||||
res += *pinput;
|
|
||||||
++pinput;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::ReadParam(std::string & res, Mount::ParamArg & args)
|
|
||||||
{
|
|
||||||
ReadParamName(res);
|
|
||||||
|
|
||||||
if( res.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
ReadParamArgs(args);
|
|
||||||
|
|
||||||
SkipWhite();
|
|
||||||
|
|
||||||
if( *pinput == ',' )
|
|
||||||
++pinput;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::ReadMountType()
|
|
||||||
{
|
|
||||||
ReadWord(temp);
|
|
||||||
|
|
||||||
if( temp.empty() )
|
|
||||||
{
|
|
||||||
// an empty line (some white characters only)
|
|
||||||
err = WINIX_ERR_EMPTY;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
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
|
|
||||||
if( temp == "ticket" )
|
|
||||||
{
|
|
||||||
mount.type = Mount::ticket;
|
|
||||||
log << log3 << "MP: mount type: ticket" << logend;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
err = WINIX_ERR_MOUNT_UNKNOWN;
|
|
||||||
log << log1 << "MP: unknown mount type: " << temp << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::ReadMountPoint()
|
|
||||||
{
|
|
||||||
ReadWord(temp);
|
|
||||||
|
|
||||||
pdir = data.dirs.GetDir(temp);
|
|
||||||
|
|
||||||
if( pdir )
|
|
||||||
{
|
|
||||||
mount.dir_id = pdir->id;
|
|
||||||
log << log3 << "MP: mount point: " << temp << logend;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
err = WINIX_ERR_NO_MOUNTPOINT;
|
|
||||||
log << log1 << "MP: there is no such a mount point: " << temp << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::ReadFs()
|
|
||||||
{
|
|
||||||
ReadWord(temp);
|
|
||||||
|
|
||||||
if( temp == "simplefs" )
|
|
||||||
{
|
|
||||||
mount.fs = Mount::simplefs;
|
|
||||||
log << log1 << "MP: file system: simplefs" << logend;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( temp == "hashfs" )
|
|
||||||
{
|
|
||||||
mount.fs = Mount::hashfs;
|
|
||||||
log << log1 << "MP: file system: hashfs" << logend;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
err = WINIX_ERR_UNKNOWN_FILESYSTEM;
|
|
||||||
log << log1 << "MP: unknown filesystem: " << temp << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::LogMountParams()
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
log << log3 << "MP: mount param: " << temp << "(";
|
|
||||||
|
|
||||||
for(i=0 ; i<param_args.size() ; ++i)
|
|
||||||
{
|
|
||||||
log << param_args[i];
|
|
||||||
|
|
||||||
if( i != param_args.size()-1 )
|
|
||||||
log << ",";
|
|
||||||
}
|
|
||||||
|
|
||||||
log << ")" << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::ReadMountParams()
|
|
||||||
{
|
|
||||||
mount.ClearParams();
|
|
||||||
|
|
||||||
for( ReadParam(temp, param_args) ; !temp.empty() ; ReadParam(temp, param_args) )
|
|
||||||
{
|
|
||||||
Mount::ParamCode p = Mount::ParseParam(temp.c_str());
|
|
||||||
|
|
||||||
if( p != Mount::par_none )
|
|
||||||
{
|
|
||||||
mount.param[p].defined = true;
|
|
||||||
mount.param[p].arg = param_args;
|
|
||||||
LogMountParams();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "MP: unknown mount param: " << temp << " (skipped)" << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MountParser::ReadRow(std::map<long, Mount> & output)
|
|
||||||
{
|
|
||||||
ReadMountType();
|
|
||||||
|
|
||||||
if( err == WINIX_ERR_EMPTY )
|
|
||||||
{
|
|
||||||
err = WINIX_ERR_OK;
|
|
||||||
SkipLine();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( err == WINIX_ERR_OK )
|
|
||||||
ReadMountPoint();
|
|
||||||
|
|
||||||
if( err == WINIX_ERR_OK )
|
|
||||||
ReadFs();
|
|
||||||
|
|
||||||
if( err == WINIX_ERR_OK )
|
|
||||||
ReadMountParams();
|
|
||||||
|
|
||||||
if( err == WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
std::pair<std::map<long, Mount>::iterator, bool> res = output.insert( std::make_pair(mount.dir_id, mount) );
|
|
||||||
|
|
||||||
if( !res.second )
|
|
||||||
log << log1 << "MP: this mount point exists (skipped)" << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkipLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Error MountParser::Parse(const std::string & input, std::map<long, Mount> & output)
|
|
||||||
{
|
|
||||||
pinput = input.c_str();
|
|
||||||
err = WINIX_ERR_OK;
|
|
||||||
output.clear();
|
|
||||||
|
|
||||||
while( *pinput && err == WINIX_ERR_OK )
|
|
||||||
ReadRow(output);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, 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 ReadWordQuote(std::string & res);
|
|
||||||
void ReadWordWhite(std::string & res);
|
|
||||||
void ReadWordComma(std::string & res);
|
|
||||||
void ReadWord(std::string & res, bool comma_bracket_separator = false);
|
|
||||||
void ReadParamArgsLoop(Mount::ParamArg & args);
|
|
||||||
void ReadParamArgs(Mount::ParamArg & args);
|
|
||||||
void ReadParamName(std::string & res);
|
|
||||||
void ReadParam(std::string & res, Mount::ParamArg & args);
|
|
||||||
void ReadMountType();
|
|
||||||
void ReadMountPoint();
|
|
||||||
void ReadFs();
|
|
||||||
void LogMountParams();
|
|
||||||
void ReadMountParams();
|
|
||||||
void ReadRow(std::map<long, Mount> & output);
|
|
||||||
|
|
||||||
const char * pinput;
|
|
||||||
std::string temp;
|
|
||||||
std::string temp_arg;
|
|
||||||
Mount::ParamArg param_args;
|
|
||||||
|
|
||||||
|
|
||||||
Mount mount;
|
|
||||||
|
|
||||||
Item * pdir;
|
|
||||||
Error err;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
158
core/mounts.cpp
158
core/mounts.cpp
@@ -1,158 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* 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"
|
|
||||||
#include "db.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Mounts::Mounts()
|
|
||||||
{
|
|
||||||
pmount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// reading from 'mounts'
|
|
||||||
Error Mounts::ReadMounts(const std::string & mounts)
|
|
||||||
{
|
|
||||||
MountParser mp;
|
|
||||||
Error err = mp.Parse(mounts, mount_tab);
|
|
||||||
|
|
||||||
if( err != WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
log << log1 << "M: some problems with mountpoints (mountpoints table will be empty)" << logend;
|
|
||||||
mount_tab.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
CalcCurMount();
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// reading from /etc/fstab
|
|
||||||
Error Mounts::ReadMounts()
|
|
||||||
{
|
|
||||||
static std::string file = "fstab";
|
|
||||||
|
|
||||||
Item * etc = data.dirs.GetEtcDir();
|
|
||||||
|
|
||||||
if( !etc )
|
|
||||||
{
|
|
||||||
log << log1 << "M: there is no /etc directory" << logend;
|
|
||||||
return WINIX_ERR_NO_ITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
Item fstab;
|
|
||||||
Error err = db.GetItem(etc->id, file, fstab);
|
|
||||||
|
|
||||||
if( err == WINIX_ERR_NO_ITEM )
|
|
||||||
{
|
|
||||||
log << log1 << "M: there is no /etc/fstab file" << logend;
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( err != WINIX_ERR_OK )
|
|
||||||
{
|
|
||||||
log << log1 << "M: cannot read /etc/fstab" << logend;
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ReadMounts(fstab.content);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Mounts::MountCmsForRoot()
|
|
||||||
{
|
|
||||||
Mount mount;
|
|
||||||
mount.type = Mount::cms;
|
|
||||||
mount.fs = Mount::simplefs;
|
|
||||||
|
|
||||||
Item * proot = data.dirs.GetRootDir();
|
|
||||||
|
|
||||||
if( proot )
|
|
||||||
mount.dir_id = proot->id;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mount.dir_id = -1;
|
|
||||||
log << log1 << "M: there is no a root dir" << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::pair<MountTab::iterator, bool> res = mount_tab.insert( std::make_pair(mount.dir_id, mount) );
|
|
||||||
pmount = &(res.first->second);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Mounts::CalcCurMount()
|
|
||||||
{
|
|
||||||
std::vector<Item*>::reverse_iterator i;
|
|
||||||
|
|
||||||
// when the program starts (when the dir_table is empty()
|
|
||||||
// we don't want to call MountCmsForRoot()
|
|
||||||
if( request.dir_table.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
for(i = request.dir_table.rbegin() ; i!=request.dir_table.rend() ; ++i)
|
|
||||||
{
|
|
||||||
std::map<long, Mount>::iterator m = mount_tab.find( (*i)->id );
|
|
||||||
|
|
||||||
if( m != mount_tab.end() )
|
|
||||||
{
|
|
||||||
pmount = &(m->second);
|
|
||||||
log << log2 << "M: current mount point is: " << pmount->TypeToStr()
|
|
||||||
<< ", fs: " << pmount->FsToStr() << logend;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if nothing was found
|
|
||||||
// we assume that 'cms' mount point is used
|
|
||||||
MountCmsForRoot();
|
|
||||||
log << log2 << "M: current mount point is: " << pmount->TypeToStr() << " (default)"
|
|
||||||
<< ", fs: " << pmount->FsToStr() << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// can return null pointer
|
|
||||||
// and we don't assume cms as a default mount point if nothing is found
|
|
||||||
Mount * Mounts::CalcMount(long dir_id)
|
|
||||||
{
|
|
||||||
while( true )
|
|
||||||
{
|
|
||||||
Item * pdir = data.dirs.GetDir(dir_id);
|
|
||||||
|
|
||||||
if( !pdir )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
std::map<long, Mount>::iterator m = mount_tab.find( pdir->id );
|
|
||||||
|
|
||||||
if( m != mount_tab.end() )
|
|
||||||
return &(m->second);
|
|
||||||
|
|
||||||
dir_id = pdir->parent_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const Mounts::MountTab * Mounts::GetMountTab()
|
|
||||||
{
|
|
||||||
return &mount_tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2009, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucorecoremounts
|
|
||||||
#define headerfilecmslucorecoremounts
|
|
||||||
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
#include "mount.h"
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
|
|
||||||
class Mounts
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
// dir_id, mount_point
|
|
||||||
typedef std::map<long, Mount> MountTab;
|
|
||||||
|
|
||||||
Mounts();
|
|
||||||
Error ReadMounts(const std::string & mounts);
|
|
||||||
Error ReadMounts();
|
|
||||||
|
|
||||||
void CalcCurMount();
|
|
||||||
Mount * CalcMount(long dir_id);
|
|
||||||
|
|
||||||
// current mount point
|
|
||||||
// will not be null after calling CalcCurMount() or ReadMounts([...])
|
|
||||||
Mount * pmount;
|
|
||||||
|
|
||||||
|
|
||||||
const MountTab * GetMountTab();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
MountTab mount_tab;
|
|
||||||
|
|
||||||
void MountCmsForRoot();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
265
core/notify.cpp
265
core/notify.cpp
@@ -1,265 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, 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 the second thread
|
|
||||||
|
|
||||||
the thread can reference to 'this' by using 'obj' pointer
|
|
||||||
*/
|
|
||||||
|
|
||||||
void * Notify::ThreadRoutine(void * arg)
|
|
||||||
{
|
|
||||||
obj = (Notify*)arg;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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->Lock(); // templates can be reloaded from the first thread
|
|
||||||
obj->templates_notify.Generate(n.lang);
|
|
||||||
obj->Unlock();
|
|
||||||
|
|
||||||
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;
|
|
||||||
nlog << logsave;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Notify::ReadTemplates()
|
|
||||||
{
|
|
||||||
// we are in the first thread here
|
|
||||||
// the second thread can use our templates and we must Lock()
|
|
||||||
// (the second thread is using Lock() too)
|
|
||||||
Lock();
|
|
||||||
templates_notify.Read();
|
|
||||||
Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Notify::Init()
|
|
||||||
{
|
|
||||||
templates_notify.CreateFunctions();
|
|
||||||
|
|
||||||
|
|
||||||
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.pmount->type;
|
|
||||||
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.pmount->type == Mount::thread )
|
|
||||||
{
|
|
||||||
if( (i->thread_notify & notify_code) != 0 )
|
|
||||||
sending = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( data.mounts.pmount->type == Mount::cms )
|
|
||||||
{
|
|
||||||
if( (i->cms_notify & notify_code) != 0 )
|
|
||||||
sending = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( sending )
|
|
||||||
{
|
|
||||||
n.email = i->email;
|
|
||||||
n.lang = Locale::StrToLang(data.locale_str);// !! bedzie osobno dla kazdego uzytkownika
|
|
||||||
|
|
||||||
if( n.lang == Locale::lang_unknown )
|
|
||||||
n.lang = Locale::lang_en;
|
|
||||||
|
|
||||||
notify_pool.insert(notify_pool.end(), n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
Unlock();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslunotify
|
|
||||||
#define headerfilecmslunotify
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <string>
|
|
||||||
#include <cstdio>
|
|
||||||
#include "../templatesnotify/templatesnotify.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define WINIX_NOTIFY_ITEM_ADD 1
|
|
||||||
#define WINIX_NOTIFY_ITEM_EDIT 2
|
|
||||||
#define WINIX_NOTIFY_ITEM_DELETE 4
|
|
||||||
#define WINIX_NOTIFY_DIR_ADD 8
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Notify
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
Notify();
|
|
||||||
~Notify();
|
|
||||||
|
|
||||||
void ReadTemplates();
|
|
||||||
|
|
||||||
bool Init();
|
|
||||||
|
|
||||||
/*
|
|
||||||
this method addes 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;
|
|
||||||
TemplatesNotify templates_notify;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
extern Notify notify;
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
238
core/plugin.cpp
238
core/plugin.cpp
@@ -1,238 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#include "plugin.h"
|
|
||||||
#include "pluginmsg.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Plugin::UnloadPlugins()
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
slots.clear();
|
|
||||||
|
|
||||||
for(i=0 ; i<plugins.size() ; ++i)
|
|
||||||
dlclose(plugins[i].handle);
|
|
||||||
|
|
||||||
plugins.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Plugin::Plugin()
|
|
||||||
{
|
|
||||||
current_plugin = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Plugin::~Plugin()
|
|
||||||
{
|
|
||||||
UnloadPlugins();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Plugin::LoadPlugins(const std::vector<std::string> & plugins)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for(i=0 ; i<plugins.size() ; ++i)
|
|
||||||
LoadPlugin(plugins[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Plugin::LoadPlugin(const std::string & filename)
|
|
||||||
{
|
|
||||||
LoadPlugin(filename.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void * Plugin::LoadInitFun(const char * filename, Fun1 & fun_init)
|
|
||||||
{
|
|
||||||
void * p = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
|
||||||
|
|
||||||
if( !p )
|
|
||||||
{
|
|
||||||
log << log1 << "Plugin: cannot load a plugin: " << filename << logend;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
fun_init = (Fun1)dlfunc(p, "Init");
|
|
||||||
|
|
||||||
if( !fun_init )
|
|
||||||
{
|
|
||||||
log << log1 << "Plugin: cannot load a plugin: " << filename
|
|
||||||
<< " (there is no Init() function)" << logend;
|
|
||||||
|
|
||||||
dlclose(p);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
log << log1 << "Plugin: plugin loaded"
|
|
||||||
<< ", file: " << filename
|
|
||||||
<< ", index: " << plugins.size() << logend;
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Plugin::LoadPlugin(const char * filename)
|
|
||||||
{
|
|
||||||
Fun1 fun_init;
|
|
||||||
void * plugin_handle;
|
|
||||||
int old_current_plugin;
|
|
||||||
|
|
||||||
if( !(plugin_handle = LoadInitFun(filename, fun_init)) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
info.Clear();
|
|
||||||
old_current_plugin = current_plugin;
|
|
||||||
current_plugin = (int)plugins.size();
|
|
||||||
info.plugin_id = current_plugin;
|
|
||||||
|
|
||||||
fun_init(info);
|
|
||||||
|
|
||||||
PluginsItem item;
|
|
||||||
item.handle = plugin_handle;
|
|
||||||
item.plugin_name = (const char *)info.p1;
|
|
||||||
|
|
||||||
plugins.push_back(item);
|
|
||||||
|
|
||||||
current_plugin = old_current_plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Plugin::Call(int message, Slots::iterator & slot)
|
|
||||||
{
|
|
||||||
current_plugin = slot->second.index;
|
|
||||||
info.plugin_id = current_plugin;
|
|
||||||
|
|
||||||
if( request.session && current_plugin != -1 )
|
|
||||||
info.plugin_data_base = request.session->plugin_data.Get(current_plugin);
|
|
||||||
else
|
|
||||||
info.plugin_data_base = 0;
|
|
||||||
|
|
||||||
if( !slot->second.is_running )
|
|
||||||
{
|
|
||||||
slot->second.is_running = true;
|
|
||||||
|
|
||||||
if( slot->second.fun1 )
|
|
||||||
slot->second.fun1(info);
|
|
||||||
|
|
||||||
if( slot->second.fun2 )
|
|
||||||
slot->second.fun2();
|
|
||||||
|
|
||||||
slot->second.is_running = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "Plugin: id: " << slot->second.index
|
|
||||||
<< ", message: " << message
|
|
||||||
<< ", recurrences are not allowed" << logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Plugin::Call(int message, void * p1_, void * p2_, long l1_, long l2_)
|
|
||||||
{
|
|
||||||
Slots::iterator i = slots.lower_bound(message);
|
|
||||||
int old_current_plugin = current_plugin;
|
|
||||||
|
|
||||||
for( ; i!=slots.end() && i->first==message ; ++i )
|
|
||||||
{
|
|
||||||
info.Clear();
|
|
||||||
info.p1 = p1_;
|
|
||||||
info.p2 = p2_;
|
|
||||||
info.l1 = l1_;
|
|
||||||
info.l2 = l2_;
|
|
||||||
|
|
||||||
Call(message, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
current_plugin = old_current_plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Plugin::Call(int message)
|
|
||||||
{
|
|
||||||
Call(message, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Plugin::Call(int message, void * p1_)
|
|
||||||
{
|
|
||||||
Call(message, p1_, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Plugin::Call(int message, void * p1_, void * p2_)
|
|
||||||
{
|
|
||||||
Call(message, p1_, p2_, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Plugin::Call(int message, long l1_)
|
|
||||||
{
|
|
||||||
Call(message, 0, 0, l1_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Plugin::Call(int message, long l1_, long l2_)
|
|
||||||
{
|
|
||||||
Call(message, 0, 0, l1_, l2_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Plugin::Call(int message, void * p1_, long l1_)
|
|
||||||
{
|
|
||||||
Call(message, p1_, 0, l1_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Plugin::Call(int message, void * p1_, long l1_, long l2_)
|
|
||||||
{
|
|
||||||
Call(message, p1_, 0, l1_, l2_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Plugin::Call(int message, void * p1_, void * p2_, long l1_)
|
|
||||||
{
|
|
||||||
Call(message, p1_, p2_, l1_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t Plugin::Size()
|
|
||||||
{
|
|
||||||
return plugins.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Plugin::Assign(int message, Fun1 fun1)
|
|
||||||
{
|
|
||||||
Slot s;
|
|
||||||
|
|
||||||
s.fun1 = fun1;
|
|
||||||
s.index = current_plugin;
|
|
||||||
|
|
||||||
slots.insert( std::make_pair(message, s) );
|
|
||||||
log << log3 << "Plugin: added function for message: " << message << ", plugin index: " << s.index << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Plugin::Assign(int message, Fun2 fun2)
|
|
||||||
{
|
|
||||||
Slot s;
|
|
||||||
|
|
||||||
s.fun2 = fun2;
|
|
||||||
s.index = current_plugin;
|
|
||||||
|
|
||||||
slots.insert( std::make_pair(message, s) );
|
|
||||||
log << log3 << "Plugin: added function for message: " << message << ", plugin index: " << s.index << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
162
core/plugin.h
162
core/plugin.h
@@ -1,162 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef headerfilecmsluplugin
|
|
||||||
#define headerfilecmsluplugin
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include "request.h"
|
|
||||||
#include "data.h"
|
|
||||||
#include "pluginmsg.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "plugindata.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
all your plugin functions can have signature either:
|
|
||||||
void my_function(PluginInfo & info); or
|
|
||||||
void my_function();
|
|
||||||
|
|
||||||
only the main Init should have:
|
|
||||||
extern "C" void Init(PluginFunction & info);
|
|
||||||
|
|
||||||
in the Init you can add your own functions by using plugin.Assign() method
|
|
||||||
and you can set the name of the plugin by setting info.p1 pointer
|
|
||||||
to a string buffer (const char *)
|
|
||||||
(this buffer will not be copied so it should not be destroyed after Init finishes)
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct PluginInfo
|
|
||||||
{
|
|
||||||
// these variables are used for some purposes
|
|
||||||
// depending on a hook in which they are used
|
|
||||||
void * p1;
|
|
||||||
void * p2;
|
|
||||||
long l1;
|
|
||||||
long l2;
|
|
||||||
|
|
||||||
// unique plugin identifier
|
|
||||||
int plugin_id;
|
|
||||||
|
|
||||||
// pointer to the plugin session (can be null if not set by the plugin)
|
|
||||||
// you should use WINIX_SESSION_CREATED and WINIX_SESSION_REMOVE
|
|
||||||
// to create your plugin's session data
|
|
||||||
PluginDataBase * plugin_data_base;
|
|
||||||
|
|
||||||
// function return status
|
|
||||||
// default: false (if not set by the plugin)
|
|
||||||
bool ret;
|
|
||||||
|
|
||||||
|
|
||||||
void Clear()
|
|
||||||
{
|
|
||||||
p1 = 0;
|
|
||||||
p2 = 0;
|
|
||||||
l1 = 0;
|
|
||||||
l2 = 0;
|
|
||||||
|
|
||||||
plugin_id = -1;
|
|
||||||
plugin_data_base = 0;
|
|
||||||
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Plugin
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
// index of a plugin which is called by Call() method
|
|
||||||
// normally: -1
|
|
||||||
int current_plugin;
|
|
||||||
|
|
||||||
// Fun is a type of a function you should provide in your plugin
|
|
||||||
typedef void (*Fun1)(PluginInfo &);
|
|
||||||
typedef void (*Fun2)(void);
|
|
||||||
|
|
||||||
|
|
||||||
struct Slot
|
|
||||||
{
|
|
||||||
Fun1 fun1;
|
|
||||||
Fun2 fun2;
|
|
||||||
int index; // plugin index (which plugin has inserted the slot)
|
|
||||||
bool is_running;
|
|
||||||
|
|
||||||
Slot()
|
|
||||||
{
|
|
||||||
fun1 = 0;
|
|
||||||
fun2 = 0;
|
|
||||||
index = -1;
|
|
||||||
is_running = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Plugin();
|
|
||||||
~Plugin();
|
|
||||||
|
|
||||||
void LoadPlugin(const char * filename);
|
|
||||||
void LoadPlugin(const std::string & filename);
|
|
||||||
void LoadPlugins(const std::vector<std::string> & plugins);
|
|
||||||
void UnloadPlugins();
|
|
||||||
|
|
||||||
void Call(int message);
|
|
||||||
void Call(int message, void * p1_);
|
|
||||||
void Call(int message, void * p1_, void * p2_);
|
|
||||||
void Call(int message, long l1_);
|
|
||||||
void Call(int message, long l1_, long l2_);
|
|
||||||
void Call(int message, void * p1_, long l1_);
|
|
||||||
void Call(int message, void * p1_, long l1_, long l2_);
|
|
||||||
void Call(int message, void * p1_, void * p2_, long l1_);
|
|
||||||
void Call(int message, void * p1_, void * p2_, long l1_, long l2_);
|
|
||||||
|
|
||||||
// how many plugins there are
|
|
||||||
size_t Size();
|
|
||||||
|
|
||||||
// assign a function to a message
|
|
||||||
// you can assign more than one function to a specific message
|
|
||||||
void Assign(int message, Fun1);
|
|
||||||
void Assign(int message, Fun2);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
struct PluginsItem
|
|
||||||
{
|
|
||||||
void * handle;
|
|
||||||
const char * plugin_name; // plugin name (can be null if was not set by the plugin)
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::vector<PluginsItem> Plugins;
|
|
||||||
Plugins plugins;
|
|
||||||
|
|
||||||
typedef std::multimap<int, Slot> Slots;
|
|
||||||
Slots slots;
|
|
||||||
|
|
||||||
PluginInfo info;
|
|
||||||
|
|
||||||
void * LoadInitFun(const char * filename, Fun1 & fun_init);
|
|
||||||
void Call(int message, Slots::iterator & slot);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern Plugin plugin;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "plugindata.h"
|
|
||||||
#include "plugin.h"
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PluginData::Assign(size_t index, PluginDataBase * data)
|
|
||||||
{
|
|
||||||
if( index >= table.size() )
|
|
||||||
Resize(index+1);
|
|
||||||
|
|
||||||
table[index] = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PluginData::Assign(PluginDataBase * data)
|
|
||||||
{
|
|
||||||
if( plugin.current_plugin == -1 )
|
|
||||||
{
|
|
||||||
log << log1 << "PD: Assign(PluginDataBase*) should be called only from plugins" << logend;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Assign(plugin.current_plugin, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PluginDataBase * PluginData::Get(size_t index)
|
|
||||||
{
|
|
||||||
if( index >= table.size() )
|
|
||||||
Resize(index+1);
|
|
||||||
|
|
||||||
return table[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PluginDataBase * PluginData::Get()
|
|
||||||
{
|
|
||||||
if( plugin.current_plugin == -1 )
|
|
||||||
{
|
|
||||||
log << log1 << "PD: Get() should be called only from plugins" << logend;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Get(plugin.current_plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PluginData::DeleteAll()
|
|
||||||
{
|
|
||||||
if( table.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
plugin.Call(WINIX_SESSION_REMOVE);
|
|
||||||
|
|
||||||
for(size_t i=0 ; i<table.size() ; ++i)
|
|
||||||
table[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PluginData::PluginData()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PluginData::PluginData(const PluginData & p)
|
|
||||||
{
|
|
||||||
operator=(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PluginData & PluginData::operator=(const PluginData & p)
|
|
||||||
{
|
|
||||||
// we don't copy all pointers - only resize the table
|
|
||||||
// pointers will be set to zero
|
|
||||||
Resize(p.Size());
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PluginData::~PluginData()
|
|
||||||
{
|
|
||||||
DeleteAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t PluginData::Size() const
|
|
||||||
{
|
|
||||||
return table.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PluginData::Resize(size_t new_size)
|
|
||||||
{
|
|
||||||
size_t old_size = table.size();
|
|
||||||
|
|
||||||
if( old_size == new_size )
|
|
||||||
return;
|
|
||||||
|
|
||||||
table.resize(new_size);
|
|
||||||
|
|
||||||
for(size_t i = old_size ; i<new_size ; ++i)
|
|
||||||
table[i] = 0;
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucoreplugindata
|
|
||||||
#define headerfilecmslucoreplugindata
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct PluginDataBase
|
|
||||||
{
|
|
||||||
virtual ~PluginDataBase() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PluginData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
void Assign(size_t index, PluginDataBase * data);
|
|
||||||
void Assign(PluginDataBase * data);
|
|
||||||
|
|
||||||
PluginDataBase * Get(size_t index);
|
|
||||||
PluginDataBase * Get();
|
|
||||||
|
|
||||||
void DeleteAll();
|
|
||||||
|
|
||||||
PluginData();
|
|
||||||
PluginData(const PluginData & p);
|
|
||||||
PluginData & operator=(const PluginData & p);
|
|
||||||
~PluginData();
|
|
||||||
|
|
||||||
size_t Size() const;
|
|
||||||
void Resize(size_t new_size);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
std::vector<PluginDataBase*> table;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef headerfilecmslupluginmsg
|
|
||||||
#define headerfilecmslupluginmsg
|
|
||||||
|
|
||||||
// here you can add your own EZC functions ([function])
|
|
||||||
// PluginInfo.p1 is a pointer to Ezc::Functions object
|
|
||||||
#define WINIX_TEMPLATES_CREATEFUNCTIONS 999
|
|
||||||
|
|
||||||
#define WINIX_REQUEST_CLEAR 1000
|
|
||||||
|
|
||||||
#define WINIX_CONTENT_MAKE 2000
|
|
||||||
|
|
||||||
|
|
||||||
// here you can attach your own session data (based on PluginDataBase class)
|
|
||||||
// call request.session->plugin_data.Assign(pointer)
|
|
||||||
#define WINIX_SESSION_CREATED 3000
|
|
||||||
|
|
||||||
// here you should remove your session data
|
|
||||||
#define WINIX_SESSION_REMOVE 3001
|
|
||||||
|
|
||||||
// when a session is changed (you can save a pointer to your data here)
|
|
||||||
#define WINIX_SESSION_CHANGED 3002
|
|
||||||
|
|
||||||
// all plugins have been started, now you can init
|
|
||||||
#define WINIX_PLUGIN_INIT 3003
|
|
||||||
|
|
||||||
// the winix is closing
|
|
||||||
#define WINIX_CLOSE 3004
|
|
||||||
|
|
||||||
// item was removed (rm function)
|
|
||||||
// PluginInfo::l1 is the file (item) id
|
|
||||||
#define WINIX_FILE_REMOVED 3005
|
|
||||||
|
|
||||||
// directory was removed (rm function)
|
|
||||||
// PluginInfo::l1 is the dir id
|
|
||||||
#define WINIX_DIR_REMOVED 3006
|
|
||||||
|
|
||||||
// preparing to remove a directory (rm function)
|
|
||||||
// PluginInfo::l1 is the dir id
|
|
||||||
#define WINIX_DIR_PREPARE_TO_REMOVE 3007
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of Winix
|
|
||||||
* and is not publicly distributed
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef headerfilecmslucorepostmultiparser
|
|
||||||
#define headerfilecmslucorepostmultiparser
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <fcgiapp.h>
|
|
||||||
#include <fstream>
|
|
||||||
#include "error.h"
|
|
||||||
#include "requesttypes.h"
|
|
||||||
|
|
||||||
// 2 MB
|
|
||||||
#define WINIX_POSTMULTI_INPUT_BUFFER 2097152
|
|
||||||
#define WINIX_POSTMULTI_OUTPUT_BUFFER 2097152
|
|
||||||
|
|
||||||
|
|
||||||
class PostMultiParser
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
PostMultiParser();
|
|
||||||
PostMultiParser(const PostMultiParser &);
|
|
||||||
PostMultiParser & operator=(const PostMultiParser &);
|
|
||||||
~PostMultiParser();
|
|
||||||
|
|
||||||
Error Parse(FCGX_Stream * in_, PostTable & post_table_, PostFileTable & post_file_table_);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
FCGX_Stream * in;
|
|
||||||
unsigned char * in_buffer;
|
|
||||||
std::ofstream tmp_file;
|
|
||||||
std::string tmp_filename;
|
|
||||||
int tmp_filename_postfix;
|
|
||||||
size_t in_buffer_ind;
|
|
||||||
size_t in_buffer_len;
|
|
||||||
|
|
||||||
PostTable * post_table;
|
|
||||||
PostFileTable * post_file_table;
|
|
||||||
|
|
||||||
int last; // last read character
|
|
||||||
|
|
||||||
bool line_end_dos;
|
|
||||||
std::string boundary;
|
|
||||||
std::string content;
|
|
||||||
size_t content_len;
|
|
||||||
|
|
||||||
std::string header_name, header_value;
|
|
||||||
Error err;
|
|
||||||
|
|
||||||
std::string name, filename;
|
|
||||||
PostFile post_file_temp;
|
|
||||||
|
|
||||||
void LogFirst(const std::string & to_log, size_t len);
|
|
||||||
|
|
||||||
bool IsWhite(int c);
|
|
||||||
void SkipWhite();
|
|
||||||
|
|
||||||
void AddNormalPostVar();
|
|
||||||
void AddFilePostVar();
|
|
||||||
void AddPostVar();
|
|
||||||
|
|
||||||
void ReadBoundary();
|
|
||||||
|
|
||||||
bool IsHeader();
|
|
||||||
void ReadHeaderName();
|
|
||||||
void ReadHeaderValue();
|
|
||||||
void ReadPartHeader();
|
|
||||||
|
|
||||||
void CreateTmpFile();
|
|
||||||
bool HasBoundary();
|
|
||||||
void ReadContentSkipBoundary(bool has_boundary);
|
|
||||||
void ReadContentToFileLoop();
|
|
||||||
void ReadContentToFile();
|
|
||||||
void ReadContentLoop();
|
|
||||||
void ReadContent();
|
|
||||||
void CheckBoundaryEnd();
|
|
||||||
void ReadPart();
|
|
||||||
|
|
||||||
void ReadChar();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user