Compare commits
537 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c32ed6ce28
|
|||
|
6631ba0641
|
|||
|
98320fe174
|
|||
|
b8105cf9cc
|
|||
|
d7a93916e3
|
|||
|
cec9dfc0e1
|
|||
|
893b3d9fff
|
|||
|
7de9d1a819
|
|||
|
8748a63532
|
|||
|
5eed025419
|
|||
|
f2e416b0f8
|
|||
|
1c7043fa3e
|
|||
|
2bd4c5b35e
|
|||
|
f4481a84f4
|
|||
|
4c740690e0
|
|||
|
128c79cdc4
|
|||
|
7082677b2f
|
|||
|
257d8bbade
|
|||
|
a6ca71b131
|
|||
|
8634716aa7
|
|||
|
8a12629740
|
|||
|
b07f2f7a59
|
|||
|
da90ef8e40
|
|||
|
197f684488
|
|||
|
e63838faeb
|
|||
|
89b37db48e
|
|||
|
68e7f44a76
|
|||
|
2490e2cc68
|
|||
|
b2f4c065ea
|
|||
|
20b40597fd
|
|||
|
7df78838aa
|
|||
|
b3bd9c6cf0
|
|||
|
dadff8329e
|
|||
|
c30b7db041
|
|||
|
6aa100f12c
|
|||
|
5d457f3d4b
|
|||
|
af0d34beb9
|
|||
|
d122917f83
|
|||
|
612501217c
|
|||
|
d86ab8f9c0
|
|||
|
5a33563722
|
|||
|
1c850b12ec
|
|||
|
140b4495df
|
|||
|
8b0b25ed0a
|
|||
|
eacdcfb980
|
|||
|
132e7aa937
|
|||
|
d9f3b69dde
|
|||
|
de753070a8
|
|||
|
c1c6e6a588
|
|||
|
291147503f
|
|||
|
dbf7dfab82
|
|||
|
b753464608
|
|||
|
544ef298aa
|
|||
|
065a2d182f
|
|||
|
f4470ccbe7
|
|||
|
71ad4869ce
|
|||
|
09dc6782c8
|
|||
|
0cebb2dc52
|
|||
|
0724ca8eb3
|
|||
|
53991e54e1
|
|||
|
df7ae1c6ea
|
|||
|
d1f5d9aa88
|
|||
|
a54d70bed4
|
|||
|
bcde5c628a
|
|||
|
f241eb0a18
|
|||
|
74c0c936f6
|
|||
|
79babc916a
|
|||
|
a08bf9f804
|
|||
|
966577cd58
|
|||
|
8f20c8f67c
|
|||
|
f6c04b2d00
|
|||
|
0474c76a3d
|
|||
|
7a29a072be
|
|||
|
24c2ecb8dd
|
|||
|
7a1cea63bf
|
|||
|
e600aebaae
|
|||
|
5e45ad3417
|
|||
|
79e971cb76
|
|||
|
edee581ecf
|
|||
|
f7e077a7c5
|
|||
|
6a9504fd5f
|
|||
|
6d256e6512
|
|||
|
cf383fa026
|
|||
|
c86536d660
|
|||
|
dba87d6213
|
|||
|
52f9d399ca
|
|||
|
7b7a962f19
|
|||
|
c37722c29a
|
|||
|
ca509d3a86
|
|||
|
bf79e46411
|
|||
|
08821eb440
|
|||
|
d7878b5564
|
|||
|
0b52ae80dd
|
|||
|
3e46d8b4b4
|
|||
|
1655ae3562
|
|||
|
dda325bbbf
|
|||
|
c326c2a095
|
|||
|
bf386e2286
|
|||
|
e822e13dc8
|
|||
|
cc2c008bfd
|
|||
|
b8a8013d4c
|
|||
|
12ed77aeb1
|
|||
|
7476048da6
|
|||
|
8a307790c0
|
|||
|
a49b10ed2d
|
|||
|
6a2da642b0
|
|||
|
b836c77950
|
|||
|
2aa4eee20d
|
|||
|
9ada82c4aa
|
|||
|
aa9b83f740
|
|||
|
4ddfd2cd3a
|
|||
|
d15f5e4fa4
|
|||
|
2e455f97ac
|
|||
|
f664cc1a53
|
|||
|
ae505f3201
|
|||
|
d5433cddf1
|
|||
|
52773a271c
|
|||
|
e9311989ab
|
|||
|
7b63c01033
|
|||
| 5972b2bb39 | |||
| f182978ea5 | |||
| ebb8132808 | |||
| 1bd1762258 | |||
| 00b0e251f4 | |||
| 14e32df8c9 | |||
| aa938f05ca | |||
| 4583ab28ed | |||
| 9c0cd6eb5e | |||
| 32c30cf536 | |||
| a8b7a9e122 | |||
| d07ff5b881 | |||
| 66fae598c2 | |||
| 589e889822 | |||
| 89249f1297 | |||
| 2bd56c87e4 | |||
| 204688464e | |||
| 1d0956abab | |||
| c2013ff47f | |||
| 624bf47c8d | |||
| cdd395efa5 | |||
| 47f6e2234c | |||
| 1648092cd5 | |||
| 99fbf6ca27 | |||
| f050fc2316 | |||
| 1015baf111 | |||
| 04f0a2f808 | |||
| 1da240afb9 | |||
| 77a00f5989 | |||
| f3d6494ae5 | |||
| 8edd0ef07a | |||
| 3855ea9fa7 | |||
| a81839fd9c | |||
| 03035f038f | |||
| baa870edbd | |||
| c8bc23312b | |||
| d5e6fb7c54 | |||
| 6138497fe0 | |||
| 05ecac8426 | |||
| 222a1c8a1f | |||
| 04164ff967 | |||
| 9f64692ede | |||
| 8b9ad5d079 | |||
| bff435db9a | |||
| e09a93bd72 | |||
| e378fcfe3b | |||
| a7a338f28e | |||
| a19158cb62 | |||
| 778ed01a55 | |||
| 217f42b7c6 | |||
| a34db6505d | |||
| 7dc117da5e | |||
| b1441366f4 | |||
| c730b85629 | |||
| d3a440fa0a | |||
| 5f77ce619e | |||
| 5dd34c802e | |||
| 3609d94c09 | |||
| 5dc00e95e7 | |||
| e88615226b | |||
| ca1a854fd1 | |||
| ceb5336ca1 | |||
| f651df6e1f | |||
| 6266eac729 | |||
| de972de948 | |||
| 55f48e4f3a | |||
| 39ab07508f | |||
| 968660e8ca | |||
| 4b46ba1fe3 | |||
| a164e6e21e | |||
| 82281b4363 | |||
| 9d8d35b64f | |||
| 33f6a9a213 | |||
| e5ed1d6ae8 | |||
| 9e6a5b2d37 | |||
| c85a724fec | |||
| 2e8f4d1a26 | |||
| 522b57ade4 | |||
| d4da6aa518 | |||
| 979ef907fe | |||
| b2d92b85a0 | |||
| 8d6d0ddbf8 | |||
| 8da76134ce | |||
| 179daf743e | |||
| bcb009b606 | |||
| 327c215e5d | |||
| b484071818 | |||
| 31e826d893 | |||
| e29f912358 | |||
| 26226de865 | |||
| 56d87c4410 | |||
| ebfa5f7405 | |||
| ba16cf41fe | |||
| 01c10bad0e | |||
| 7d1fb3c04e | |||
| 9e222f5b80 | |||
| 3b5658ff8f | |||
| 5e89c4004a | |||
| 9602c28d96 | |||
| 0fd680b496 | |||
| 37d3a44b24 | |||
| da2dec447b | |||
| c6c50a5d23 | |||
| 98c1e8daad | |||
| f99191aa6f | |||
| df04075f1c | |||
| 3d2a635e34 | |||
| aad5db9a6a | |||
| 43ebbdaa33 | |||
| 92c7f90b95 | |||
| aae93d018b | |||
| 7a115a3970 | |||
| 64e5114947 | |||
| 4f8b5e649a | |||
| e0d9989d74 | |||
| 0fe680ef4a | |||
| e182c0a21b | |||
| c8edd241d5 | |||
| a544ccd1a7 | |||
| 7df2205b40 | |||
| 265e843d02 | |||
| 22a8a97389 | |||
| bb74f2a423 | |||
| 2033168db2 | |||
| e377f144fd | |||
| 234ebf8ce8 | |||
| 09cf3c9fa9 | |||
| df32899581 | |||
| 33e8df11c5 | |||
| 75daf37bbd | |||
| d0d2cfb22c | |||
| f7b5ac0dc8 | |||
| 227dd923d6 | |||
| f6cb9a8aed | |||
| b615dc7e6e | |||
| 944560dd2b | |||
| 1d6d29e24d | |||
| ff8e9e6b32 | |||
| 557555c4b3 | |||
| f8e1037476 | |||
| 35cb54324f | |||
| 119497bb01 | |||
| dfd6475a81 | |||
| d6d5236a03 | |||
| a327a26bd5 | |||
| d5ebb7ca12 | |||
| 3e46c5674c | |||
| c4b5565995 | |||
| 3f5eabeaa1 | |||
| 9b8e48e7b2 | |||
| c3122fb82f | |||
| 1741597d52 | |||
| 9c5c74ba84 | |||
| 26ed7b80be | |||
| 55ac9a61ed | |||
| 7673264fe1 | |||
| 42dc43b036 | |||
| ef22d951a0 | |||
| e95dc834a3 | |||
| b424988d1b | |||
| 22134b6cc0 | |||
| f861c0761e | |||
| 1899d5ee17 | |||
| 17bd48ece3 | |||
| c5c02d7f44 | |||
| ba6159964b | |||
| b834971f5e | |||
| 9dc15d536c | |||
| 2e45cb6ac9 | |||
| 2dcfeaa688 | |||
| 9d65d931d0 | |||
| 746aa41111 | |||
| 175dd17416 | |||
| 619936c12e | |||
| 732144df01 | |||
| df3f04a951 | |||
| 0f78968579 | |||
| 66173c7a31 | |||
| 3f934d9aec | |||
| df0cc131fe | |||
| ba60f9da8a | |||
| 4569198b9d | |||
| ccbbb59af7 | |||
| 3a5af25eaf | |||
| 1d18b7fa12 | |||
| 472490c239 | |||
| b6340a30d2 | |||
| bf1f0954b9 | |||
| 2f1cdcf379 | |||
| 443c2023d9 | |||
| 2c5062ba22 | |||
| 99df807095 | |||
| 8ab07d11b1 | |||
| a1c0f6f7f0 | |||
| 672737a0d8 | |||
| ade96bf6d3 | |||
| 801fc062ef | |||
| f35840e7de | |||
| 79eda7abb0 | |||
| e7c7324058 | |||
| d8c1a81bcb | |||
| 94f96c11cb | |||
| ec94dff7d7 | |||
| ebd791a256 | |||
| 4db421d6c3 | |||
| ab89ffe096 | |||
| 53fe5c35b9 | |||
| f2f2c851df | |||
| 6dddc5e948 | |||
| 9688b1a26a | |||
| 81df52f6ca | |||
| 6e4f8f5191 | |||
| 22de3322ae | |||
| e6fae4598c | |||
| ba331dea4a | |||
| 1292a56d1b | |||
| 6a452ffed0 | |||
| fc24570062 | |||
| aa71abd725 | |||
| fb64f5e456 | |||
| 61fe6ea219 | |||
| d30c7254eb | |||
| 06be33ba5f | |||
| b2cffa39e1 | |||
| 86ef2529b1 | |||
| f1b9d1b870 | |||
| fe67b5d72a | |||
| 27720afaf2 | |||
| 8bb585d97d | |||
| 8c523ce8b9 | |||
| e48a28a5c8 | |||
| d66a36cf21 | |||
| a94e09f0aa | |||
| 4df10de6b7 | |||
| 6d07535dad | |||
| ee354d2ded | |||
| e64bd1fba8 | |||
| 031e673c51 | |||
| 801c9a2cda | |||
| 685b3ca5ee | |||
| f1af7e2eeb | |||
| 85f9fda984 | |||
| bb513b0187 | |||
| 4277f90bad | |||
| ccda2bc2fd | |||
| 4b71530f4c | |||
| a8a9db53be | |||
| 634cf07d44 | |||
| 0e0c006d5a | |||
| 486067a4b2 | |||
| 35e10ed469 | |||
| 00b980e74b | |||
| efdc0e7c97 | |||
| 8b64d2066f | |||
| 8d87d9a875 | |||
| 8fc1848ecc | |||
| bbc0a67153 | |||
| e8ba2a7bd1 | |||
| 23f1c112a4 | |||
| 4d76e53554 | |||
| 73352e680e | |||
| 57aad8b454 | |||
| ab5c44a2cb | |||
| 3e84eb9dbf | |||
| afbe82e9f4 | |||
| 51b1aed483 | |||
| 32e93a04c5 | |||
| 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 |
@@ -0,0 +1,21 @@
|
||||
# EditorConfig
|
||||
# https://editorconfig.org/
|
||||
# https://editorconfig-specification.readthedocs.io/
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
# 4 space indentation
|
||||
[*.{h,cpp,html,css,js,conf,txt}]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
# Tab indentation (no size specified)
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
.cproject
|
||||
.project
|
||||
.settings/
|
||||
*.o
|
||||
*.so
|
||||
/winixd/winix
|
||||
/winixcli/src/winix
|
||||
/winixcli/m
|
||||
/.clangd
|
||||
/.qtcreator/
|
||||
/.qtc_clangd/
|
||||
@@ -0,0 +1,2 @@
|
||||
CompileFlags:
|
||||
Add: [-pthread, -std=c++20, -I%%%CURRENT_DIR%%%/winixd, -I%%%GLOBAL_WORKING_DIR%%%/pikotools/src, -I%%%GLOBAL_WORKING_DIR%%%/ezc/src, -I%%%GLOBAL_WORKING_DIR%%%/morm/src, -I%%%GLOBAL_WORKING_DIR%%%/tito/src, -I/usr/include, -I/usr/local/include, -I/usr/local/include/postgresql, -DPT_HAS_MORM_LIBRARY, -DEZC_HAS_MORM_LIBRARY, -DMORM_HAS_EZC_LIBRARY]
|
||||
@@ -0,0 +1 @@
|
||||
-std=c20
|
||||
@@ -0,0 +1,4 @@
|
||||
#define PT_HAS_MORM_LIBRARY 1
|
||||
#define EZC_HAS_MORM_LIBRARY 1
|
||||
#define MORM_HAS_EZC_LIBRARY 1
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
[General]
|
||||
@@ -0,0 +1,184 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 14.0.1, 2024-09-20T16:21:10. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">%%%QT_ENVIRONMENT_ID%%%</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="qlonglong">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
|
||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">2</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<value type="bool" key="AutoTest.ApplyFilter">false</value>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">3</value>
|
||||
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">%%%QT_DEFAULT_PROFILE_ID%%%</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">%%%CURRENT_DIR%%%</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
|
||||
<value type="QString">all</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand">/usr/local/bin/gmake</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand">/usr/local/bin/gmake</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Default</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="qlonglong">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
@@ -0,0 +1 @@
|
||||
-std=c++20
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
CURRENT_DIR=$(pwd)
|
||||
GLOBAL_WORKING_DIR=$(realpath ${CURRENT_DIR}/..)
|
||||
|
||||
# ----------
|
||||
|
||||
# make sure the current directory is correct
|
||||
if [ ! -d ${CURRENT_DIR}/.templates ] ; then
|
||||
echo "this script should be called by make: make clangd (one level up)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# change / to \/ in paths
|
||||
CURRENT_DIR_FOR_SED=$(echo ${CURRENT_DIR} | sed 's/\//\\\//g')
|
||||
GLOBAL_WORKING_DIR_FOR_SED=$(echo ${GLOBAL_WORKING_DIR} | sed 's/\//\\\//g')
|
||||
|
||||
|
||||
if [ -f "${CURRENT_DIR}/.templates/.clangd" ] ; then
|
||||
if [ ! -f "${CURRENT_DIR}/.clangd" ] ; then
|
||||
cat "${CURRENT_DIR}/.templates/.clangd" | \
|
||||
sed -e "s/%%%CURRENT_DIR%%%/${CURRENT_DIR_FOR_SED}/g" \
|
||||
-e "s/%%%GLOBAL_WORKING_DIR%%%/${GLOBAL_WORKING_DIR_FOR_SED}/g" > \
|
||||
${CURRENT_DIR}/.clangd
|
||||
|
||||
echo "added a ${CURRENT_DIR}/.clangd file"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Executable
+105
@@ -0,0 +1,105 @@
|
||||
#!/bin/sh
|
||||
|
||||
CURRENT_DIR=$(pwd)
|
||||
GLOBAL_WORKING_DIR=$(realpath ${CURRENT_DIR}/..)
|
||||
QTCREATOR_DIR=${CURRENT_DIR}/.qtcreator
|
||||
|
||||
# ----------
|
||||
|
||||
# make sure the current directory is correct
|
||||
if [ ! -d ${CURRENT_DIR}/.templates ] ; then
|
||||
echo "this script should be called by make: make qtcreator (one level up)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
qtcreatorini=~/.config/QtProject/QtCreator.ini
|
||||
qtprofiles=~/.config/QtProject/qtcreator/profiles.xml
|
||||
|
||||
if [ ! -f "$qtcreatorini" ] ; then
|
||||
echo "I cannot find a $qtcreatorini file"
|
||||
echo "this file is needed to take an EnvironmentId parameter"
|
||||
echo "if QTCreator was recently installed make sure you have opened it at least once"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ ! -f "$qtprofiles" ] ; then
|
||||
echo "I cannot find a $qtprofiles file"
|
||||
echo "this file is needed to take a default profile id parameter"
|
||||
echo "if QTCreator was recently installed make sure you have opened it at least once"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
qtenvironmentid=`grep -F 'Settings\EnvironmentId' "$qtcreatorini" | grep -Eo '\{[a-zA-Z0-9-]+\}'`
|
||||
qtdefaultprofileid=`grep -A 1 -F '<variable>Profile.Default</variable>' "$qtprofiles" | tail -n 1 | grep -Eo '\{[a-zA-Z0-9-]+\}'`
|
||||
|
||||
if [ -z "$qtenvironmentid" ] ; then
|
||||
echo "I cannot read a Settings\EnvironmentId parameter from $qtcreatorini file"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
if [ -z "$qtdefaultprofileid" ] ; then
|
||||
echo "I cannot read a Profile.Default parameter from $qtprofiles file"
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# change / to \/ in paths
|
||||
CURRENT_DIR_FOR_SED=$(echo ${CURRENT_DIR} | sed 's/\//\\\//g')
|
||||
GLOBAL_WORKING_DIR_FOR_SED=$(echo ${GLOBAL_WORKING_DIR} | sed 's/\//\\\//g')
|
||||
|
||||
was_qtcreator_dir=0
|
||||
|
||||
if [ -d "${QTCREATOR_DIR}" ] ; then
|
||||
was_qtcreator_dir=1
|
||||
else
|
||||
echo "Your QTCreator EnvironmentId is: $qtenvironmentid"
|
||||
echo "Your QTCreator default profile id is: $qtdefaultprofileid"
|
||||
mkdir -p "${QTCREATOR_DIR}"
|
||||
fi
|
||||
|
||||
if [ -d "${QTCREATOR_DIR}" ] ; then
|
||||
|
||||
if [ -d ${CURRENT_DIR}/.templates/.qtcreator ] ; then
|
||||
cd ${CURRENT_DIR}/.templates/.qtcreator
|
||||
|
||||
if [ $? -eq 0 ] ; then
|
||||
|
||||
for i in * ; do
|
||||
if [ ! -f "${QTCREATOR_DIR}/$i" ] ; then
|
||||
cat "$i" | \
|
||||
sed -e "s/%%%CURRENT_DIR%%%/${CURRENT_DIR_FOR_SED}/g" \
|
||||
-e "s/%%%GLOBAL_WORKING_DIR%%%/${GLOBAL_WORKING_DIR_FOR_SED}/g" \
|
||||
-e "s/%%%QT_ENVIRONMENT_ID%%%/${qtenvironmentid}/g" \
|
||||
-e "s/%%%QT_DEFAULT_PROFILE_ID%%%/${qtdefaultprofileid}/g" > \
|
||||
"${QTCREATOR_DIR}/$i"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $was_qtcreator_dir -eq 0 ] ; then
|
||||
echo "QTCreator files generated to ${QTCREATOR_DIR} directory"
|
||||
echo "select an 'open project...' option and find a ${QTCREATOR_DIR}/*.creator file"
|
||||
fi
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
find ${QTCREATOR_DIR} -name "*.files" | while read projectfiles ; do
|
||||
|
||||
cd ${CURRENT_DIR}/winixd
|
||||
|
||||
if [ $? -eq 0 ] ; then
|
||||
find ../winixd -type f \( -iname "*.cpp" -o -iname "*.h" \) | sort > ${projectfiles}
|
||||
echo "file ${projectfiles} has been updated"
|
||||
fi
|
||||
|
||||
cd ${CURRENT_DIR}/winixcli
|
||||
|
||||
if [ $? -eq 0 ] ; then
|
||||
find ../winixcli -type f \( -iname "*.cpp" -o -iname "*.h" \) | sort >> ${projectfiles}
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
Copyright (c) 2012-2022, Tomasz Sowa
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,161 +1,62 @@
|
||||
# Makefile for GNU make
|
||||
|
||||
include Makefile.dep
|
||||
|
||||
|
||||
ifeq ($(OSTYPE), FreeBSD)
|
||||
CXX = clang++
|
||||
else
|
||||
CXX = g++-4.8
|
||||
endif
|
||||
|
||||
|
||||
|
||||
ifndef CXXFLAGS
|
||||
CXXFLAGS = -Wall -O0 -g -fPIC -pthread -std=c++11 -I/usr/local/include -I/usr/include/postgresql -DEZC_USE_WINIX_LOGGER -DEZC_HAS_SPECIAL_STREAM
|
||||
endif
|
||||
|
||||
ifndef AR
|
||||
AR = ar
|
||||
endif
|
||||
|
||||
ifndef CXXWINIXINCLUDEFLAGS
|
||||
# these flags are used for compiling and making dependencies (make depend)
|
||||
# it's better to not using any system directories like -I/usr/local/include here
|
||||
CXXWINIXINCLUDEFLAGS = -I../../winix -I../../../winix -I../../ezc/src -I../../../ezc/src -I../../tito/src -I../../../tito/src -I../../pikotools -I../../../pikotools
|
||||
endif
|
||||
|
||||
ifndef LDFLAGS
|
||||
LDFLAGS = -L/usr/local/lib
|
||||
endif
|
||||
|
||||
# this macro is used in ezc's Makefile
|
||||
EZC_USE_WINIX_LOGGER = yes
|
||||
|
||||
|
||||
# for make install
|
||||
winix_install_dir = /usr/local/winix
|
||||
|
||||
|
||||
export CXX
|
||||
export CXXFLAGS
|
||||
export CXXWINIXINCLUDEFLAGS
|
||||
export LDFLAGS
|
||||
export EZC_USE_WINIX_LOGGER
|
||||
|
||||
|
||||
all: winix.so plugins winix
|
||||
all: winixd winixcli
|
||||
|
||||
|
||||
|
||||
winix.so: $(winix.src.files)
|
||||
@cd core ; $(MAKE) -e
|
||||
@cd db ; $(MAKE) -e
|
||||
@cd functions ; $(MAKE) -e
|
||||
@cd notify ; $(MAKE) -e
|
||||
@cd templates ; $(MAKE) -e
|
||||
@cd ../ezc/src ; $(MAKE) -e
|
||||
@cd ../tito/src ; $(MAKE) -e
|
||||
@cd ../pikotools ; $(MAKE) -e
|
||||
$(CXX) -shared -rdynamic -Wl,-whole-archive -o winix.so $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) core/*.o db/*.o functions/*.o templates/*.o notify/*.o ../ezc/src/ezc.a ../tito/src/tito.a ../pikotools/utf8/utf8.a ../pikotools/space/space.a ../pikotools/mainparser/mainparser.a ../pikotools/date/date.a $(LDFLAGS) -lfcgi -lpq -lz -lpthread -lcurl -Wl,-no-whole-archive
|
||||
winixd: FORCE
|
||||
$(MAKE) -C winixd
|
||||
|
||||
|
||||
winix: winix.so $(winix.src.files)
|
||||
@cd main ; $(MAKE) -e
|
||||
$(CXX) -o winix $(CXXFLAGS) $(LDFLAGS) main/*.o winix.so -lfcgi
|
||||
winixcli: FORCE
|
||||
$(MAKE) -C winixcli
|
||||
|
||||
|
||||
clean: FORCE
|
||||
$(MAKE) -C winixd clean
|
||||
$(MAKE) -C winixcli clean
|
||||
|
||||
plugins: FORCE
|
||||
@cd plugins/stats ; $(MAKE) -e
|
||||
@cd plugins/thread ; $(MAKE) -e
|
||||
@cd plugins/ticket ; $(MAKE) -e
|
||||
@cd plugins/gallery ; $(MAKE) -e
|
||||
@cd plugins/group ; $(MAKE) -e
|
||||
@cd plugins/menu ; $(MAKE) -e
|
||||
@cd plugins/export ; $(MAKE) -e
|
||||
|
||||
cleanall: FORCE
|
||||
$(MAKE) -C winixd cleanall
|
||||
$(MAKE) -C winixcli clean
|
||||
|
||||
|
||||
depend: FORCE
|
||||
$(MAKE) -C winixd depend
|
||||
$(MAKE) -C winixcli depend
|
||||
|
||||
|
||||
install: FORCE
|
||||
$(MAKE) -C winixd install
|
||||
#$(MAKE) -C winixcli depend
|
||||
|
||||
|
||||
clangd: FORCE
|
||||
@.templates/install_clangd.sh
|
||||
|
||||
|
||||
clangdall: clangd
|
||||
@$(MAKE) -C ../pikotools clangd
|
||||
@$(MAKE) -C ../morm clangd
|
||||
@$(MAKE) -C ../ezc clangd
|
||||
@$(MAKE) -C ../tito clangd
|
||||
|
||||
|
||||
qtcreator: clangd
|
||||
@.templates/install_qtcreator.sh
|
||||
|
||||
|
||||
qtcreatorall: qtcreator
|
||||
@$(MAKE) -C ../pikotools qtcreator
|
||||
@$(MAKE) -C ../morm qtcreator
|
||||
@$(MAKE) -C ../ezc qtcreator
|
||||
@$(MAKE) -C ../tito qtcreator
|
||||
|
||||
|
||||
FORCE:
|
||||
|
||||
|
||||
clean:
|
||||
@cd core ; $(MAKE) -e clean
|
||||
@cd db ; $(MAKE) -e clean
|
||||
@cd functions ; $(MAKE) -e clean
|
||||
@cd templates ; $(MAKE) -e clean
|
||||
@cd notify ; $(MAKE) -e clean
|
||||
@cd plugins/stats ; $(MAKE) -e clean
|
||||
@cd plugins/thread ; $(MAKE) -e clean
|
||||
@cd plugins/ticket ; $(MAKE) -e clean
|
||||
@cd plugins/gallery ; $(MAKE) -e clean
|
||||
@cd plugins/group ; $(MAKE) -e clean
|
||||
@cd plugins/menu ; $(MAKE) -e clean
|
||||
@cd plugins/export ; $(MAKE) -e clean
|
||||
@cd ../ezc/src ; $(MAKE) -e clean
|
||||
@cd ../tito/src ; $(MAKE) -e clean
|
||||
@cd ../pikotools ; $(MAKE) -e clean
|
||||
@cd main ; $(MAKE) -e clean
|
||||
rm -f winix.so
|
||||
rm -f winix
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
depend:
|
||||
@cd core ; $(MAKE) -e depend
|
||||
@cd db ; $(MAKE) -e depend
|
||||
@cd functions ; $(MAKE) -e depend
|
||||
@cd templates ; $(MAKE) -e depend
|
||||
@cd notify ; $(MAKE) -e depend
|
||||
@cd plugins/stats ; $(MAKE) -e depend
|
||||
@cd plugins/thread ; $(MAKE) -e depend
|
||||
@cd plugins/ticket ; $(MAKE) -e depend
|
||||
@cd plugins/gallery ; $(MAKE) -e depend
|
||||
@cd plugins/group ; $(MAKE) -e depend
|
||||
@cd plugins/menu ; $(MAKE) -e depend
|
||||
@cd plugins/export ; $(MAKE) -e depend
|
||||
@cd ../ezc/src ; $(MAKE) -e depend
|
||||
@cd ../tito/src ; $(MAKE) -e depend
|
||||
@cd ../pikotools ; $(MAKE) -e depend
|
||||
@cd main ; $(MAKE) -e depend
|
||||
echo -n "winix.src.files = " > Makefile.dep
|
||||
find -E . -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
|
||||
find -E ../ezc/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
|
||||
find -E ../tito/src -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
|
||||
find -E ../pikotools -type f -regex ".*\.h|.*\.cpp" | xargs -I foo echo -n foo " " >> Makefile.dep
|
||||
|
||||
|
||||
|
||||
install: all
|
||||
# installing binaries
|
||||
rm -Rf $(winix_install_dir)/bin
|
||||
mkdir -p $(winix_install_dir)/bin
|
||||
cp winix $(winix_install_dir)/bin
|
||||
cp winix.so $(winix_install_dir)/bin
|
||||
# etc configs
|
||||
rm -Rf $(winix_install_dir)/etc
|
||||
mkdir -p $(winix_install_dir)/etc
|
||||
cp -rf etc/* $(winix_install_dir)/etc/
|
||||
# html templates
|
||||
rm -Rf $(winix_install_dir)/html
|
||||
mkdir -p $(winix_install_dir)/html
|
||||
cp -rf html/* $(winix_install_dir)/html/
|
||||
# txt templates
|
||||
rm -Rf $(winix_install_dir)/txt
|
||||
mkdir -p $(winix_install_dir)/txt
|
||||
cp -rf txt/* $(winix_install_dir)/txt/
|
||||
# locales
|
||||
rm -Rf $(winix_install_dir)/locale
|
||||
mkdir -p $(winix_install_dir)/locale
|
||||
cp -rf locale/* $(winix_install_dir)/locale/
|
||||
# plugins
|
||||
rm -Rf $(winix_install_dir)/plugins
|
||||
mkdir -p $(winix_install_dir)/plugins
|
||||
find plugins/ -name "*.so" | xargs -I foo cp foo $(winix_install_dir)/plugins/
|
||||
# deleting subversion directories
|
||||
find $(winix_install_dir) -type d -name ".svn" | xargs -I foo rm -fr foo
|
||||
# removing privileges for others
|
||||
find $(winix_install_dir) -exec chmod o-r,o-x,o-w "{}" "+"
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,19 +0,0 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
|
||||
all: $(o)
|
||||
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $<
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. $(CXXWINIXINCLUDEFLAGS) -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
include Makefile.dep
|
||||
-1159
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o crypt.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o image.o ipbancontainer.o item.o job.o lastcontainer.o loadavg.o lock.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionidmanager.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o user.o users.o
|
||||
-1930
File diff suppressed because it is too large
Load Diff
@@ -1,626 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bbcodeparser.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
bool BBCODEParser::Equal(const wchar_t * str1, const wchar_t * str2)
|
||||
{
|
||||
while( *str1 == *str2 && *str1 != 0 )
|
||||
{
|
||||
str1 += 1;
|
||||
str2 += 1;
|
||||
}
|
||||
|
||||
return *str1 == *str2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool BBCODEParser::IsValidCharForName(int c)
|
||||
{
|
||||
if( (c>='a' && c<='z') ||
|
||||
(c>='A' && c<='Z') ||
|
||||
c=='*' || c=='_')
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool BBCODEParser::IsOpeningTagMark()
|
||||
{
|
||||
return (*pchar == '[');
|
||||
}
|
||||
|
||||
|
||||
// there are no commentaries in bbcode
|
||||
bool BBCODEParser::IsOpeningCommentaryTagMark()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool BBCODEParser::SkipCommentaryTagIfExists()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool BBCODEParser::IsClosingTagMark()
|
||||
{
|
||||
return (*pchar == ']');
|
||||
}
|
||||
|
||||
|
||||
bool BBCODEParser::IsClosingXmlSimpleTagMark()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// one enter will generate one <br>
|
||||
// two enters or more will generate only two br (<br><br>)
|
||||
void BBCODEParser::PutNormalText(const wchar_t * str, const wchar_t * end)
|
||||
{
|
||||
int br_len;
|
||||
|
||||
if( *pchar == 0 )
|
||||
{
|
||||
// trimming last white characters at end of the user text
|
||||
while( str<end && (IsWhite(*(end-1)) || *(end-1)==10) )
|
||||
--end;
|
||||
}
|
||||
|
||||
|
||||
while( str < end )
|
||||
{
|
||||
if( *str == 10 )
|
||||
{
|
||||
++str;
|
||||
br_len = 1;
|
||||
|
||||
// skipping white characters without a new line character
|
||||
while( str < end && IsWhite(*str) )
|
||||
++str;
|
||||
|
||||
if( str < end && *str == 10 )
|
||||
{
|
||||
br_len = 2;
|
||||
|
||||
// skipping white characters with new line characters
|
||||
while( str < end && (IsWhite(*str) || *str==10) )
|
||||
++str;
|
||||
}
|
||||
|
||||
if( !has_open_ol_tag && !has_open_ul_tag && !has_open_li_tag )
|
||||
{
|
||||
for(int i=0 ; i < br_len ; ++i)
|
||||
(*out_string) += L"<br>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintEscape(*str);
|
||||
++str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::CheckExceptions()
|
||||
{
|
||||
if( stack_len >= 2 )
|
||||
{
|
||||
if( pstack[stack_len-1].type == Item::opening &&
|
||||
pstack[stack_len-2].type == Item::opening &&
|
||||
IsNameEqual(L"*", pstack[stack_len-1].name) &&
|
||||
IsNameEqual(L"*", pstack[stack_len-2].name) )
|
||||
{
|
||||
// removing the last [*] from the stack
|
||||
// </li> was put automatically
|
||||
PopStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
bbcode format:
|
||||
[bbcodetag=value]some text[/bbcodetag]
|
||||
the value can be quoted, e.g.
|
||||
[bbcodetag="value"]some text[/bbcodetag], or
|
||||
[bbcodetag='value']some text[/bbcodetag]
|
||||
|
||||
the third string below (in tags table) is 'html_argument' from Tags,
|
||||
it can contain a special character % followed by a string which means:
|
||||
%1 - "value" escaped as for html
|
||||
%2 - "some text" escaped as for html
|
||||
%u1 - "value" trimmed and escaped as for url-es
|
||||
%u2 - "some text" trimmed and escaped as for url-es
|
||||
%% - one %
|
||||
|
||||
if you are using %2 or %u2 then "some text" is not treated as bbcode, e.g.
|
||||
[bbcodetag=value]some [b]text[/b][/bbcodetag] will produce:
|
||||
<htmltag arg="value">some [b]text[/b]</htmltag> (the inner tags [b][/b] were not parsed)
|
||||
|
||||
also when using %2 or %u2 the closing bbcode tag is skipped
|
||||
(if you want this tag then you can put it in 'html_argument')
|
||||
|
||||
and when using u (%u1 or %u2) the argument is trimmed from whitespaces and new lines
|
||||
at the beginning and at the end
|
||||
(because otherwise a space would be changed to %20 and this were probably not what you really wanted)
|
||||
*/
|
||||
const BBCODEParser::Tags * BBCODEParser::FindTag(const wchar_t * tag)
|
||||
{
|
||||
static Tags tags[] = {
|
||||
{L"*", L"li", L">", false},
|
||||
{L"b", L"em", L">", true},
|
||||
{L"i", L"span", L" class=\"bbitalic\">", true},
|
||||
{L"u", L"span", L" class=\"bbunderline\">", true},
|
||||
{L"s", L"span", L" class=\"bbstrike\">", true},
|
||||
{L"code", L"code", L" class=\"bbcode\">", false},
|
||||
{L"list", L"ul", L" class=\"bblist\">", false},
|
||||
{L"color", L"span", L" class=\"bbcol%1\">", true},
|
||||
{L"url", L"a", L" href=\"%u1\">", true},
|
||||
{L"img", L"img", L" alt=\"%1\" src=\"%u2\">", true},
|
||||
{L"quote", L"div", L" class=\"bbquote\">\n<span class=\"bbquotewho\">%1</span><br>\n", false},
|
||||
};
|
||||
|
||||
size_t i;
|
||||
size_t len = sizeof(tags) / sizeof(Tags);
|
||||
|
||||
for(i=0 ; i<len ; ++i)
|
||||
{
|
||||
if( Equal(tag, tags[i].bbcode) )
|
||||
return &tags[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const BBCODEParser::Tags * BBCODEParser::FindTag(const std::wstring & tag)
|
||||
{
|
||||
return FindTag(tag.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PrintArgumentCheckQuotes(const wchar_t * & start, const wchar_t * & end)
|
||||
{
|
||||
// skipping white characters from the argument
|
||||
while( start<end && IsWhite(*start) )
|
||||
++start;
|
||||
|
||||
// skipping first '=' character if exists
|
||||
if( start<end && *start == '=' )
|
||||
++start;
|
||||
|
||||
// skipping white characters from the argument
|
||||
// at the beginning
|
||||
while( start<end && IsWhite(*start) )
|
||||
++start;
|
||||
|
||||
// and at the end
|
||||
while( start<end && IsWhite(*(end-1)) )
|
||||
--end;
|
||||
|
||||
|
||||
if( start<end && (*start=='\'' || *start=='\"') )
|
||||
{
|
||||
++start;
|
||||
|
||||
if( start<end && *(start-1) == *(end-1) )
|
||||
--end;
|
||||
|
||||
// skipping white characters after a first quote char [url = " ww...."]
|
||||
while( start<end && IsWhite(*start) )
|
||||
++start;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PrintEncode(int c)
|
||||
{
|
||||
if( c == '&' )
|
||||
{
|
||||
(*out_string) += L"&";
|
||||
}
|
||||
else
|
||||
if( (c>='a' && c<='z') ||
|
||||
(c>='A' && c<='Z') ||
|
||||
(c>='0' && c<='9') ||
|
||||
(c=='_' || c=='?' || c=='.' || c==',' || c=='/' || c=='-' ||
|
||||
c=='+' || c=='*' || c=='(' || c==')' || c=='=' || c==':')
|
||||
)
|
||||
{
|
||||
(*out_string) += c;
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t buffer[20];
|
||||
swprintf(buffer, 20, L"%02X", c);
|
||||
|
||||
(*out_string) += '%';
|
||||
(*out_string) += buffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PrintEscape(int c, bool change_quote)
|
||||
{
|
||||
if( c == '<' )
|
||||
{
|
||||
(*out_string) += L"<";
|
||||
}
|
||||
else
|
||||
if( c == '>' )
|
||||
{
|
||||
(*out_string) += L">";
|
||||
}
|
||||
else
|
||||
if( c == '&' )
|
||||
{
|
||||
(*out_string) += L"&";
|
||||
}
|
||||
else
|
||||
if( c == '\"' && change_quote )
|
||||
{
|
||||
(*out_string) += L""";
|
||||
}
|
||||
else
|
||||
{
|
||||
(*out_string) += c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PrintArgumentEncode(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
PrintArgumentCheckQuotes(start, end);
|
||||
TrimWhiteWithNewLines(start, end);
|
||||
|
||||
for( ; start<end ; ++start )
|
||||
PrintEncode(*start);
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PrintArgumentEscape(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
PrintArgumentCheckQuotes(start, end);
|
||||
|
||||
for( ; start<end ; ++start )
|
||||
PrintEscape(*start, true); // quotes are escaped as well here
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::CheckOpeningTag(const Tags * tag, const wchar_t * tag_name, bool & condition)
|
||||
{
|
||||
if( Equal(tag->html_tag, tag_name) )
|
||||
{
|
||||
if( condition )
|
||||
{
|
||||
PutClosingTag(tag);
|
||||
(*out_string) += '\n';
|
||||
}
|
||||
|
||||
condition = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::CheckOpeningTag(const Tags * tag)
|
||||
{
|
||||
bool has_list_tag = has_open_ul_tag || has_open_ol_tag;
|
||||
|
||||
CheckOpeningTag(tag, L"li", has_open_li_tag);
|
||||
CheckOpeningTag(tag, L"ul", has_open_ul_tag);
|
||||
CheckOpeningTag(tag, L"ol", has_open_ol_tag);
|
||||
|
||||
if( has_open_li_tag && !has_list_tag )
|
||||
{
|
||||
(*out_string) += L"<ul>\n";
|
||||
has_open_ul_tag = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PrintEscape(const wchar_t * start, const wchar_t * end, bool change_quote)
|
||||
{
|
||||
for( ; start < end ; ++start)
|
||||
PrintEscape(*start, change_quote);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PrintEncode(const wchar_t * start, const wchar_t * end)
|
||||
{
|
||||
for( ; start < end ; ++start)
|
||||
PrintEncode(*start);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PutOpeningTagFromEzc()
|
||||
{
|
||||
// this can be a tag from Ezc templates system
|
||||
(*out_string) += '[';
|
||||
(*out_string) += LastItem().name;
|
||||
|
||||
const wchar_t * start = pchar;
|
||||
|
||||
while( *pchar && *pchar!=']' )
|
||||
++pchar;
|
||||
|
||||
if( *pchar == ']' )
|
||||
++pchar;
|
||||
|
||||
Put(start, pchar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PutHtmlArgument1(const wchar_t * arg_start, const wchar_t * arg_end, bool has_u)
|
||||
{
|
||||
if( has_u )
|
||||
PrintArgumentEncode(arg_start, arg_end);
|
||||
else
|
||||
PrintArgumentEscape(arg_start, arg_end);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::TrimWhiteWithNewLines(const wchar_t * & start, const wchar_t * & end)
|
||||
{
|
||||
while( start < end && (IsWhite(*start) || *start==10) )
|
||||
++start;
|
||||
|
||||
while( start < end && (IsWhite(*(end-1)) || *(end-1)==10) )
|
||||
--end;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PutHtmlArgument2(const Tags * tag, bool has_u)
|
||||
{
|
||||
const wchar_t * start = pchar;
|
||||
const wchar_t * end = pchar;
|
||||
bool first_tag_removed = false;
|
||||
|
||||
while( *pchar != 0 )
|
||||
{
|
||||
if( IsOpeningTagMark() )
|
||||
{
|
||||
if( IsClosingTagForLastItem() )
|
||||
{
|
||||
// the last tag is skipped when using patterns with %2 or %u2
|
||||
|
||||
PopStack(); // removing opening tag from the stack
|
||||
first_tag_removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pchar += 1;
|
||||
end = pchar;
|
||||
}
|
||||
}
|
||||
|
||||
if( !first_tag_removed )
|
||||
PopStack(); // user has forgotten to close the tag
|
||||
|
||||
if( has_u )
|
||||
{
|
||||
TrimWhiteWithNewLines(start, end);
|
||||
PrintEncode(start, end);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintEscape(start, end);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::PutHtmlArgument(const Tags * tag, const wchar_t * arg_start, const wchar_t * arg_end)
|
||||
{
|
||||
const wchar_t * pattern = tag->html_argument;
|
||||
bool has_u;
|
||||
|
||||
while( *pattern )
|
||||
{
|
||||
if( *pattern == '%' )
|
||||
{
|
||||
++pattern;
|
||||
has_u = false;
|
||||
|
||||
if( *pattern == 'u' )
|
||||
{
|
||||
++pattern;
|
||||
has_u = true;
|
||||
}
|
||||
|
||||
if( *pattern == '1' )
|
||||
{
|
||||
++pattern;
|
||||
PutHtmlArgument1(arg_start, arg_end, has_u);
|
||||
}
|
||||
else
|
||||
if( *pattern == '2' )
|
||||
{
|
||||
++pattern;
|
||||
PutHtmlArgument2(tag, has_u);
|
||||
}
|
||||
else
|
||||
if( *pattern == '%' )
|
||||
{
|
||||
(*out_string) += '%';
|
||||
++pattern;
|
||||
}
|
||||
// else unrecognized, will be printed next time as a normal character
|
||||
}
|
||||
else
|
||||
{
|
||||
(*out_string) += *pattern;
|
||||
++pattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PutOpeningTagFromBBCode(const Tags * tag)
|
||||
{
|
||||
CheckOpeningTag(tag);
|
||||
PutOpeningTagMark();
|
||||
Put(tag->html_tag);
|
||||
|
||||
const wchar_t * start = pchar;
|
||||
|
||||
while( *pchar && *pchar != ']' )
|
||||
++pchar;
|
||||
|
||||
PutHtmlArgument(tag, start, pchar);
|
||||
|
||||
if( *pchar == ']' )
|
||||
++pchar;
|
||||
|
||||
if( !tag->inline_tag )
|
||||
{
|
||||
Put(10);
|
||||
SkipWhiteLines();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool BBCODEParser::PutOpeningTag()
|
||||
{
|
||||
const Tags * tag = FindTag(LastItem().name);
|
||||
|
||||
if( !tag )
|
||||
PutOpeningTagFromEzc();
|
||||
else
|
||||
PutOpeningTagFromBBCode(tag);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PutClosingTag(const Tags * tag)
|
||||
{
|
||||
if( !tag )
|
||||
return; // skipping the tag
|
||||
|
||||
PutOpeningTagMark();
|
||||
(*out_string) += '/';
|
||||
(*out_string) += tag->html_tag;
|
||||
PutClosingTagMark();
|
||||
|
||||
if( !tag->inline_tag )
|
||||
{
|
||||
(*out_string) += L"\n";
|
||||
SkipWhiteLines();
|
||||
}
|
||||
|
||||
if( Equal(tag->html_tag, L"li") )
|
||||
has_open_li_tag = false;
|
||||
|
||||
if( Equal(tag->html_tag, L"ol") )
|
||||
has_open_ol_tag = false;
|
||||
|
||||
if( Equal(tag->html_tag, L"ul") )
|
||||
has_open_ul_tag = false;
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::PutClosingTag(const wchar_t * tag_name)
|
||||
{
|
||||
const Tags * tag = FindTag(tag_name);
|
||||
PutClosingTag(tag);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBCODEParser::Init()
|
||||
{
|
||||
has_open_li_tag = false;
|
||||
has_open_ol_tag = false;
|
||||
has_open_ul_tag = false;
|
||||
|
||||
SkipWhiteLines();
|
||||
}
|
||||
|
||||
|
||||
void BBCODEParser::Uninit()
|
||||
{
|
||||
if( has_open_li_tag )
|
||||
(*out_string) += L"</li>\n";
|
||||
|
||||
if( has_open_ol_tag )
|
||||
(*out_string) += L"</ol>\n";
|
||||
|
||||
if( has_open_ul_tag )
|
||||
(*out_string) += L"</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_bbcodeparser
|
||||
#define headerfile_winix_core_bbcodeparser
|
||||
|
||||
#include "htmlfilter.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class BBCODEParser : public HTMLFilter
|
||||
{
|
||||
|
||||
struct Tags
|
||||
{
|
||||
const wchar_t * bbcode;
|
||||
const wchar_t * html_tag;
|
||||
const wchar_t * html_argument; // with closing '>'
|
||||
bool inline_tag;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
virtual methods
|
||||
(from HTMLFilter class)
|
||||
*/
|
||||
virtual void Init();
|
||||
virtual void Uninit();
|
||||
|
||||
virtual bool IsOpeningTagMark();
|
||||
virtual bool IsOpeningCommentaryTagMark();
|
||||
virtual bool IsClosingTagMark();
|
||||
virtual bool IsClosingXmlSimpleTagMark();
|
||||
|
||||
virtual bool IsValidCharForName(int c);
|
||||
virtual void CheckExceptions();
|
||||
virtual bool SkipCommentaryTagIfExists();
|
||||
|
||||
virtual bool PutOpeningTag();
|
||||
virtual void PutClosingTag(const wchar_t * tag);
|
||||
|
||||
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
|
||||
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
others
|
||||
*/
|
||||
bool Equal(const wchar_t * str1, const wchar_t * str2);
|
||||
|
||||
void PutHtmlArgument1(const wchar_t * arg_start, const wchar_t * arg_end, bool has_u);
|
||||
void PutHtmlArgument2(const Tags * tag, bool has_u);
|
||||
void PutHtmlArgument(const Tags * tag, const wchar_t * arg_start, const wchar_t * arg_end);
|
||||
|
||||
void PutOpeningTagFromEzc();
|
||||
void PutOpeningTagFromBBCode(const Tags * tag);
|
||||
|
||||
const Tags * FindTag(const wchar_t * tag);
|
||||
const Tags * FindTag(const std::wstring & tag);
|
||||
void PrintArgumentCheckQuotes(const wchar_t * & start, const wchar_t * & end);
|
||||
|
||||
void PrintEscape(int c, bool change_quote = false);
|
||||
void PrintEncode(int c);
|
||||
|
||||
void PrintEscape(const wchar_t * start, const wchar_t * end, bool change_quote = false);
|
||||
void PrintEncode(const wchar_t * start, const wchar_t * end);
|
||||
|
||||
void PrintArgumentEncode(const wchar_t * start, const wchar_t * end);
|
||||
void PrintArgumentEscape(const wchar_t * start, const wchar_t * end);
|
||||
|
||||
void PutClosingTag(const Tags * tag);
|
||||
|
||||
void CheckOpeningTag(const Tags * tag, const wchar_t * tag_name, bool & condition);
|
||||
void CheckOpeningTag(const Tags * tag);
|
||||
|
||||
void TrimWhiteWithNewLines(const wchar_t * & start, const wchar_t * & end);
|
||||
|
||||
|
||||
|
||||
bool has_open_ol_tag; // has open html <ol> tag
|
||||
bool has_open_ul_tag; // has open html <ul> tag
|
||||
bool has_open_li_tag; // has open html <li> tag
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
-1524
File diff suppressed because it is too large
Load Diff
@@ -1,346 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_htmlfilter
|
||||
#define headerfile_winix_core_htmlfilter
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// max length of a name of a html tag (with terminating null)
|
||||
#define WINIX_HTMLFILTER_ITEM_NAME_MAXLEN 30
|
||||
|
||||
// max length of a html lang attribute (e.g. "en", "pl")
|
||||
#define WINIX_HTMLFILTER_ITEM_LANG_MAXLEN 10
|
||||
|
||||
|
||||
#define WINIX_HTMLFILTER_ATTR_NAME_MAXLEN 40
|
||||
|
||||
|
||||
#define WINIX_HTMLFILTER_ATTR_VALUE_MAXLEN 500
|
||||
|
||||
|
||||
// depth of the html tree
|
||||
#define WINIX_HTMLFILTER_STACK_MAXLEN 100
|
||||
|
||||
// length of a buffer used for printing
|
||||
// it should be at least: WINIX_HTMLFILTER_ITEM_NAME_MAXLEN+3
|
||||
#define WINIX_HTMLFILTER_BUFFER_MAXLEN 2048
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
very lightweight filter for html
|
||||
(without using any dynamic memory - some memory is allocated only at the beginning - in ctors)
|
||||
this filter has O(n) complexity over the whole html string
|
||||
|
||||
such tags as: <script> <pre> <textarea> are treated in a special way
|
||||
all characters between the opening and closing tag (<script>....</script>) are untouched
|
||||
|
||||
if the filter finds that there are not closed tags it will close them,
|
||||
if the filter finds a closing tag which doesn't have an opening tag - it will skip it
|
||||
|
||||
tags which don't need to be closed: meta, input, br, img, link
|
||||
look at CheckExceptions() method
|
||||
|
||||
the filter recognizes xml simple tags (with / at the end) such as: <br />
|
||||
*/
|
||||
class HTMLFilter
|
||||
{
|
||||
public:
|
||||
|
||||
enum OrphanMode
|
||||
{
|
||||
orphan_nbsp, // putting " " string
|
||||
orphan_160space // putting 160 ascii code
|
||||
};
|
||||
|
||||
HTMLFilter();
|
||||
HTMLFilter(const HTMLFilter & f);
|
||||
HTMLFilter & operator=(const HTMLFilter & f);
|
||||
~HTMLFilter();
|
||||
|
||||
|
||||
// main methods used for filtering
|
||||
void Filter(const wchar_t * in, std::wstring & out);
|
||||
void Filter(const std::wstring & in, std::wstring & out);
|
||||
|
||||
|
||||
// insert a white space into long words
|
||||
// (only between html tags)
|
||||
// skipped in such tags: script, pre, textarea
|
||||
// break_after - after how many characters insert a space (0 - off)
|
||||
void BreakWord(size_t break_after_);
|
||||
|
||||
// insert a new line character into long lines
|
||||
// (only between html tags)
|
||||
// skipped in such tags: script, pre, textarea
|
||||
// wrap_line - after how many characters wrap a line (0 - off)
|
||||
// lines are wrapped only in 'body' tag (useful for text in 'title' tag which is in 'head' section)
|
||||
void WrapLine(size_t wrap_line_);
|
||||
|
||||
// trimming white characters (with new lines)
|
||||
// at the beginning, at the end and in the middle of a string
|
||||
// only between html tags
|
||||
// at the beginning and at the end only one space is left
|
||||
// skipped in such tags: script, pre, textarea
|
||||
// false by default
|
||||
void TrimWhite(bool trim);
|
||||
|
||||
|
||||
// first tabs in a tree
|
||||
// default: 2 (spaces)
|
||||
// set 0 to turn off
|
||||
void InsertTabs(size_t tabsize);
|
||||
|
||||
|
||||
// set a name of a html tag which will be used as 'nofilter' tag
|
||||
// elements between such tags are not filtered (similarly as in <pre> and <textarea>)
|
||||
// these tags (opening and closing) will no be placed in the html output
|
||||
void SetNoFilterTag(const std::wstring & tag_name);
|
||||
|
||||
// orphans are checked only in 'body' tag
|
||||
void AssignOrphans(const wchar_t * lang_code, const std::vector<std::wstring> & otab);
|
||||
void AssignOrphans(const std::wstring & lang_code, const std::vector<std::wstring> & otab);
|
||||
void ClearOrphans();
|
||||
|
||||
|
||||
// check 'orphans' for the specicic language
|
||||
// if an orphan is detected then the non-break space (" " or ascii 160 code) will be put
|
||||
// default disable (lang_none)
|
||||
void OrphansMode(OrphanMode mode = orphan_nbsp);
|
||||
|
||||
|
||||
// skipping some unsafe tags
|
||||
// (script, iframe, frame, frameset, applet, head, meta, html, link, body, ...)
|
||||
void SafeMode(bool safe_mode_);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// orphans for one language
|
||||
struct Orphans
|
||||
{
|
||||
std::vector<std::wstring> tab;
|
||||
size_t max_len;
|
||||
};
|
||||
|
||||
|
||||
// orphans for all languages
|
||||
// map<language_code, Orphans>
|
||||
typedef std::map<std::wstring, Orphans> OrphansTab;
|
||||
OrphansTab orphans_tab;
|
||||
|
||||
// html <nofilter> tag name
|
||||
std::wstring no_filter_tag;
|
||||
|
||||
|
||||
struct Item
|
||||
{
|
||||
std::wstring name; // max size: WINIX_HTMLFILTER_ITEM_NAME_MAXLEN
|
||||
|
||||
enum Type
|
||||
{
|
||||
opening, /* sample: <h1> */
|
||||
closing, /* sample: </h1> */
|
||||
simple, /* sample: <br/> */
|
||||
special, /* sample: <!doctype> */
|
||||
none
|
||||
} type;
|
||||
|
||||
// is there a new line after this tag
|
||||
bool new_line;
|
||||
|
||||
// current orphans table
|
||||
// (will be propagated)
|
||||
Orphans * porphans;
|
||||
|
||||
// this item or one from its parents is a 'body' html tag
|
||||
// (will be propagated)
|
||||
bool has_body_tag;
|
||||
|
||||
void Clear();
|
||||
Item();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
virtual methods
|
||||
*/
|
||||
virtual void Init();
|
||||
virtual void Uninit();
|
||||
|
||||
virtual bool IsOpeningTagMark();
|
||||
virtual bool IsOpeningCommentaryTagMark();
|
||||
virtual bool IsClosingTagMark();
|
||||
virtual bool IsClosingXmlSimpleTagMark();
|
||||
|
||||
virtual bool IsValidCharForName(int c);
|
||||
virtual bool IsValidCharForAttrName(int c);
|
||||
virtual void CheckExceptions();
|
||||
virtual bool SkipCommentaryTagIfExists();
|
||||
|
||||
virtual void Put(wchar_t c);
|
||||
virtual void Put(const wchar_t * str);
|
||||
virtual void Put(const wchar_t * str, const wchar_t * end);
|
||||
virtual void Put(const std::wstring & str);
|
||||
|
||||
virtual void PutOpeningTagMark();
|
||||
virtual void PutClosingTagMark();
|
||||
virtual bool PutOpeningTag();
|
||||
virtual void PutClosingTag(const wchar_t * tag);
|
||||
|
||||
virtual void PutNormalText(const wchar_t * str, const wchar_t * end);
|
||||
virtual void ReadNormalTextSkipWhite(const wchar_t * & start, const wchar_t * & last_non_white);
|
||||
|
||||
|
||||
/*
|
||||
others
|
||||
*/
|
||||
Item & GetItem(size_t i);
|
||||
Item & LastItem();
|
||||
|
||||
wchar_t ToLower(wchar_t c);
|
||||
void ToLower(std::wstring & str);
|
||||
|
||||
bool IsNameEqual(const wchar_t * name1, const wchar_t * name2);
|
||||
bool IsNameEqual(const wchar_t * name1, const std::wstring & name2);
|
||||
bool IsNameEqual(const std::wstring & name1, const wchar_t * name2);
|
||||
bool IsNameEqual(const std::wstring & name1, const std::wstring & name2);
|
||||
|
||||
bool IsNameEqual(const wchar_t * name1, const wchar_t * name2, size_t len);
|
||||
bool IsNameEqual(const wchar_t * name1, const std::wstring & name2, size_t len);
|
||||
bool IsNameEqual(const std::wstring & name1, const wchar_t * name2, size_t len);
|
||||
bool IsNameEqual(const std::wstring & name1, const std::wstring & name2, size_t len);
|
||||
|
||||
bool IsLastTag(const wchar_t * name);
|
||||
bool IsLastTag(const std::wstring & name);
|
||||
bool IsTagSafe(const wchar_t * tag);
|
||||
bool IsTagSafe(const std::wstring & tag);
|
||||
|
||||
int CheckOrphan(const wchar_t * str, const wchar_t * end, const std::wstring & orphan_str);
|
||||
bool CheckOrphan(const wchar_t * str, const wchar_t * end, const std::vector<std::wstring> & orphans);
|
||||
bool CheckOrphan(const wchar_t * str, const wchar_t * end);
|
||||
|
||||
bool IsWhite(int c);
|
||||
void SkipWhite();
|
||||
void SkipWhiteLines();
|
||||
void SkipWhiteWithFirstNewLine();
|
||||
void SkipWhiteLines(const wchar_t * & str, const wchar_t * end);
|
||||
bool IsClosingTagForLastItem();
|
||||
size_t OpeningCommentaryTagMarkSize();
|
||||
void SkipAndCheckClosingTag();
|
||||
|
||||
void PopStack();
|
||||
bool PushStack();
|
||||
void CheckNewLine();
|
||||
void CheckStackPrintRest();
|
||||
void AddForgottenTags();
|
||||
void CheckClosingTags();
|
||||
void ReadNormalText();
|
||||
bool PrintRest();
|
||||
bool PrintOpeningItem();
|
||||
void ReadItemName();
|
||||
void ReadItemAttrName();
|
||||
void ReadItemAttrValue(bool has_quote);
|
||||
|
||||
bool ReadItemAttr();
|
||||
bool CheckItemAttr();
|
||||
void PrintItemAttr();
|
||||
|
||||
void ReadItemClosing();
|
||||
void ReadItemSpecial();
|
||||
void ReadItemOpening();
|
||||
bool ReadItem();
|
||||
void ReadLoop();
|
||||
void Read();
|
||||
|
||||
void CheckChar(wchar_t c);
|
||||
|
||||
void CheckLineWrap();
|
||||
bool HasSemiloconAround(const wchar_t * str, const wchar_t * end);
|
||||
void PutNormalNonWhite(const wchar_t * & str, const wchar_t * end);
|
||||
void PutNormalWhite(const wchar_t * & str, const wchar_t * end);
|
||||
void PutLastTagWithClosingTag();
|
||||
void PutTextBetweenLastTagWithClosingTag();
|
||||
void PutTabs(size_t len);
|
||||
void PutNonBreakingSpace();
|
||||
void PutNewLine();
|
||||
void CalcOrphansMaxLen(Orphans & orphans);
|
||||
|
||||
const wchar_t * pchar;
|
||||
Item empty;
|
||||
Item * pstack; // stack pointer
|
||||
size_t stack_len; // length of the stack
|
||||
wchar_t * buffer; // buffer used when printing
|
||||
std::wstring * out_string;
|
||||
bool last_new_line;
|
||||
size_t break_after; // insert a space into long words after 'break_after' characters
|
||||
size_t wrap_line; // insert a new line character into long lines
|
||||
bool trim_white; // trimming white characters
|
||||
size_t tab_size;
|
||||
OrphanMode orphan_mode;
|
||||
std::wstring attr_name;
|
||||
std::vector<std::wstring> attr_value;
|
||||
std::wstring attr_value_temp;
|
||||
std::wstring attr_value_lower;
|
||||
bool attr_has_value;
|
||||
std::wstring lang_code_lower;
|
||||
size_t line_len; //length of the current line (without first spaces which create the html tree)
|
||||
bool safe_mode; // skipping some unsafe tags
|
||||
Orphans orphans_temp;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "item.h"
|
||||
#include "misc.h"
|
||||
#include "crypt.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
Item::Item()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
// !! IMPROVE ME
|
||||
// now we have Request::start_time and Request::start_date
|
||||
// we can somehow get the current time from the request
|
||||
// may setting the date should be completetly removed from here?
|
||||
void Item::SetDateToNow()
|
||||
{
|
||||
date_creation = std::time(0);
|
||||
date_modification = date_creation;
|
||||
}
|
||||
|
||||
|
||||
void Item::SetDateModifyToNow()
|
||||
{
|
||||
date_modification = std::time(0);
|
||||
}
|
||||
|
||||
|
||||
void Item::Clear()
|
||||
{
|
||||
id = -1;
|
||||
|
||||
user_id = -1;
|
||||
group_id = -1;
|
||||
privileges = 0;
|
||||
modification_user_id = -1;
|
||||
|
||||
guest_name.clear();
|
||||
|
||||
subject.clear();
|
||||
content.clear();
|
||||
modify_index = 0;
|
||||
url.clear();
|
||||
|
||||
content_type = ct_formatted_text;
|
||||
|
||||
type = none;
|
||||
parent_id = -1;
|
||||
|
||||
link_to.clear();
|
||||
link_redirect = false;
|
||||
|
||||
content_id = -1;
|
||||
ref = 1;
|
||||
|
||||
file_path.clear();
|
||||
file_fs = -1;
|
||||
file_type = WINIX_ITEM_FILETYPE_NONE;
|
||||
hash.clear();
|
||||
hash_type = WINIX_CRYPT_HASH_NONE;
|
||||
file_size = 0;
|
||||
has_thumb = false;
|
||||
|
||||
html_template.clear();
|
||||
sort_index = 0;
|
||||
meta.Clear();
|
||||
ameta.Clear();
|
||||
|
||||
SetDateToNow();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
-153
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_item
|
||||
#define headerfile_winix_core_item
|
||||
|
||||
#include <string>
|
||||
#include "space/space.h"
|
||||
#include "date/date.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
#define WINIX_ITEM_FILETYPE_NONE 0
|
||||
#define WINIX_ITEM_FILETYPE_IMAGE 1
|
||||
#define WINIX_ITEM_FILETYPE_DOCUMENT 2
|
||||
#define WINIX_ITEM_FILETYPE_VIDEO 3
|
||||
#define WINIX_ITEM_FILETYPE_UNKNOWN 10
|
||||
|
||||
|
||||
|
||||
|
||||
struct Item
|
||||
{
|
||||
long id;
|
||||
long parent_id;
|
||||
|
||||
|
||||
long user_id;
|
||||
long group_id;
|
||||
std::wstring 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;
|
||||
|
||||
PT::Date date_creation;
|
||||
PT::Date date_modification;
|
||||
|
||||
std::wstring subject;
|
||||
std::wstring content;
|
||||
|
||||
std::wstring url;
|
||||
int modify_index;
|
||||
|
||||
enum ContentType
|
||||
{
|
||||
ct_text = 0,
|
||||
ct_formatted_text,
|
||||
ct_html,
|
||||
ct_bbcode,
|
||||
ct_raw
|
||||
};
|
||||
|
||||
ContentType content_type;
|
||||
|
||||
|
||||
|
||||
enum Type
|
||||
{
|
||||
dir = 0,
|
||||
file = 1,
|
||||
symlink = 2,
|
||||
|
||||
none = 1000
|
||||
};
|
||||
|
||||
|
||||
Type type;
|
||||
|
||||
|
||||
// used when type is symlink or to a directory too (function 'default')
|
||||
std::wstring link_to;
|
||||
int link_redirect; // !! IMPROVE ME should it be 'bool'?
|
||||
|
||||
|
||||
// static file (if exists)
|
||||
std::wstring file_path; // relative file path
|
||||
int file_fs; // file system type where the file was saved
|
||||
int file_type; // file type (none, image, doc, etc)
|
||||
bool has_thumb; // whether or not we have a thumbnail
|
||||
std::wstring hash; // file hash (md4, md5, ...)
|
||||
int hash_type; // hash type WINIX_CRYPT_HASH_* (see crypt.h)
|
||||
size_t file_size; // size of the file
|
||||
|
||||
|
||||
std::wstring html_template;
|
||||
|
||||
|
||||
// sort index used when displaying a group of items
|
||||
int sort_index;
|
||||
|
||||
|
||||
// meta information
|
||||
PT::Space meta;
|
||||
PT::Space ameta;
|
||||
|
||||
|
||||
// methods
|
||||
Item();
|
||||
void SetDateToNow();
|
||||
void SetDateModifyToNow();
|
||||
void Clear();
|
||||
|
||||
|
||||
private:
|
||||
// used by the database
|
||||
long content_id; // content id in 'content' table
|
||||
int ref; // content references
|
||||
|
||||
friend class Db;
|
||||
friend struct DbItemColumns;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
-198
@@ -1,198 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "job.h"
|
||||
#include "plugin.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
Job::Job()
|
||||
{
|
||||
jobs_queue_tab.resize(WINIX_JOBS_HOW_MANY_PRIORITIES);
|
||||
}
|
||||
|
||||
|
||||
void Job::CheckPriority(int & priority) const
|
||||
{
|
||||
if( priority < 0 )
|
||||
priority = 0;
|
||||
|
||||
if( priority >= WINIX_JOBS_HOW_MANY_PRIORITIES )
|
||||
priority = WINIX_JOBS_HOW_MANY_PRIORITIES - 1;
|
||||
}
|
||||
|
||||
|
||||
// first thread (objects locked)
|
||||
void Job::Add(PT::Space & job, int priority)
|
||||
{
|
||||
CheckPriority(priority);
|
||||
jobs_queue_tab[priority].push(job);
|
||||
WakeUpThread();
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t Job::Size(int priority) const
|
||||
{
|
||||
CheckPriority(priority);
|
||||
return jobs_queue_tab[priority].size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t Job::Size() const
|
||||
{
|
||||
size_t sum = 0;
|
||||
|
||||
for(size_t i=0 ; i<WINIX_JOBS_HOW_MANY_PRIORITIES ; ++i)
|
||||
sum += Size(i);
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
bool Job::Empty(int priority) const
|
||||
{
|
||||
CheckPriority(priority);
|
||||
return jobs_queue_tab[priority].empty();
|
||||
}
|
||||
|
||||
|
||||
bool Job::Empty() const
|
||||
{
|
||||
for(size_t i=0 ; i<WINIX_JOBS_HOW_MANY_PRIORITIES ; ++i)
|
||||
if( !Empty(i) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
second thread
|
||||
*/
|
||||
|
||||
// second thread (objects locked)
|
||||
bool Job::SignalReceived()
|
||||
{
|
||||
return !Empty();
|
||||
}
|
||||
|
||||
|
||||
// second thread (objects not locked)
|
||||
void Job::Do()
|
||||
{
|
||||
size_t i = WINIX_JOBS_HOW_MANY_PRIORITIES;
|
||||
bool is_empty;
|
||||
|
||||
while( i-- > 0 && !IsExitSignal() )
|
||||
{
|
||||
do
|
||||
{
|
||||
Lock();
|
||||
is_empty = Empty(i);
|
||||
Unlock();
|
||||
|
||||
if( !is_empty )
|
||||
DoQueue(jobs_queue_tab[i]);
|
||||
}
|
||||
while( !is_empty && !IsExitSignal() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// second thread (objects not locked, jobs_queue is not empty)
|
||||
void Job::DoQueue(JobsQueue & jobs_queue)
|
||||
{
|
||||
bool is_empty;
|
||||
|
||||
do
|
||||
{
|
||||
Lock();
|
||||
// references will not be invalidated after insertion to jobs_queue
|
||||
// (jobs_queue is std::queue and it uses std::deque by default)
|
||||
PT::Space & job = jobs_queue.front();
|
||||
Unlock();
|
||||
|
||||
DoJob(job);
|
||||
|
||||
Lock();
|
||||
jobs_queue.pop();
|
||||
is_empty = jobs_queue.empty();
|
||||
Unlock();
|
||||
}
|
||||
while( !is_empty && !IsExitSignal() );
|
||||
}
|
||||
|
||||
|
||||
// second thread (objects not locked)
|
||||
void Job::DoJob(PT::Space & job)
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginRes res = plugin.Call((Session*)0, WINIX_JOB, &job);
|
||||
|
||||
if( res.res_true == 0 )
|
||||
DoWinixJob(job);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// second thread (objects not locked)
|
||||
void Job::DoWinixJob(PT::Space & job)
|
||||
{
|
||||
Lock();
|
||||
//log << log1 << "standard winix job: " << job.Text(L"type") << logend;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
-487
@@ -1,487 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include <ctime>
|
||||
#include <string.h>
|
||||
#include "utf8/utf8.h"
|
||||
#include "timezones.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
Log::Log()
|
||||
{
|
||||
log_level = 1;
|
||||
current_level = 100; // nothing to log (call Init() first)
|
||||
request = 0;
|
||||
max_requests = 1;
|
||||
lines = 0;
|
||||
max_lines = 5000;
|
||||
log_file_open = false;
|
||||
time_zones = 0;
|
||||
}
|
||||
|
||||
|
||||
Log::~Log()
|
||||
{
|
||||
SaveLogAndClear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Log::SetTimeZones(TimeZones * ptime_zones)
|
||||
{
|
||||
time_zones = ptime_zones;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Log::LogLevel()
|
||||
{
|
||||
return log_level;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Log::Init(int log_level_, bool save_each_line_, const std::wstring & log_file_, bool log_std, int log_max_requests)
|
||||
{
|
||||
log_level = log_level_;
|
||||
log_stdout = log_std;
|
||||
max_requests = log_max_requests;
|
||||
save_each_line = save_each_line_;
|
||||
|
||||
PT::WideToUTF8(log_file_, log_file);
|
||||
// don't open the file here
|
||||
// because it would be created with the root as an owner
|
||||
}
|
||||
|
||||
|
||||
void Log::OpenFile()
|
||||
{
|
||||
if( !log_file.empty() )
|
||||
{
|
||||
file.open( log_file.c_str(), std::ios_base::out | std::ios_base::app );
|
||||
log_file_open = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Log::PrintDate(const PT::Date & date, size_t time_zone_id)
|
||||
{
|
||||
if( time_zones )
|
||||
{
|
||||
TimeZone * tz = time_zones->GetZone(time_zone_id);
|
||||
|
||||
if( tz )
|
||||
{
|
||||
PT::Date local_date = tz->ToLocal(date);
|
||||
log << local_date;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this) << date << " UTC"; // unknown time zone identifier
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this) << date << " UTC"; // time_zones object was not set
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const void * s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
|
||||
buffer << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const char * s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
|
||||
if( !s )
|
||||
return *this;
|
||||
|
||||
buffer << s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::string & s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
|
||||
buffer << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::string * s)
|
||||
{
|
||||
if( current_level > log_level )
|
||||
return *this;
|
||||
|
||||
buffer << *s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const wchar_t * s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
if( s )
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::wstring & s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const std::wstring * s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << *s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(int s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(long s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(char s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(wchar_t s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Log & Log::operator<<(size_t s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(double s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const PT::Space & s)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << s;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(const PT::Date & date)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << date;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Log & Log::operator<<(LogManipulators m)
|
||||
{
|
||||
switch(m)
|
||||
{
|
||||
case logend:
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
buffer << '\n';
|
||||
lines += 1;
|
||||
|
||||
if( save_each_line )
|
||||
SaveLogAndClear();
|
||||
}
|
||||
break;
|
||||
|
||||
case logsave:
|
||||
SaveLogAndClear();
|
||||
break;
|
||||
|
||||
case logendrequest:
|
||||
if( ++request >= max_requests || lines > max_lines )
|
||||
SaveLogAndClear();
|
||||
break;
|
||||
|
||||
case log1:
|
||||
current_level = 1;
|
||||
break;
|
||||
|
||||
case log2:
|
||||
current_level = 2;
|
||||
break;
|
||||
|
||||
case log3:
|
||||
current_level = 3;
|
||||
break;
|
||||
|
||||
case log4:
|
||||
current_level = 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char Log::GetHEXdigit(unsigned char c)
|
||||
{
|
||||
if( c < 10 )
|
||||
return c + '0';
|
||||
|
||||
return c - 10 + 'A';
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Log::ToHEX(char * buf, unsigned char c)
|
||||
{
|
||||
buf[0] = GetHEXdigit(c >> 4);
|
||||
buf[1] = GetHEXdigit(c & 0xf);
|
||||
buf[2] = 0;
|
||||
}
|
||||
|
||||
|
||||
void Log::LogBinary(const char * blob, size_t blob_len)
|
||||
{
|
||||
size_t i=0;
|
||||
char buf[3];
|
||||
|
||||
|
||||
while( i < blob_len )
|
||||
{
|
||||
size_t oldi = i;
|
||||
|
||||
for(size_t a=0 ; a<16 ; ++a)
|
||||
{
|
||||
if( i < blob_len )
|
||||
{
|
||||
ToHEX(buf, blob[i]);
|
||||
buffer << buf << ' ';
|
||||
++i;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer << " ";
|
||||
}
|
||||
|
||||
if( a == 7 )
|
||||
{
|
||||
if( i < blob_len )
|
||||
buffer << "- ";
|
||||
else
|
||||
buffer << " ";
|
||||
}
|
||||
}
|
||||
|
||||
i = oldi;
|
||||
buffer << ' ';
|
||||
|
||||
for(size_t a=0 ; a<16 && i<blob_len ; ++a, ++i)
|
||||
{
|
||||
if( blob[i] > 31 && blob[i] < 127 )
|
||||
buffer << blob[i];
|
||||
else
|
||||
buffer << '.';
|
||||
}
|
||||
|
||||
(*this) << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Log::LogBinary(const std::string & blob)
|
||||
{
|
||||
LogBinary(blob.c_str(), blob.size());
|
||||
}
|
||||
|
||||
|
||||
void Log::SystemErr(int err)
|
||||
{
|
||||
(*this) << "errno: " << err;
|
||||
|
||||
const char * err_msg = strerror(err);
|
||||
|
||||
if( err_msg )
|
||||
(*this) << " (" << err_msg << ")";
|
||||
}
|
||||
|
||||
|
||||
void Log::SaveLogAndClear()
|
||||
{
|
||||
SaveLog();
|
||||
|
||||
buffer.Clear();
|
||||
request = 0;
|
||||
lines = 0;
|
||||
}
|
||||
|
||||
|
||||
void Log::SaveLog()
|
||||
{
|
||||
if( buffer.Str().empty() )
|
||||
return;
|
||||
|
||||
if( log_stdout )
|
||||
PT::WideToUTF8(buffer.Str(), std::cout);
|
||||
|
||||
if( log_file.empty() )
|
||||
return;
|
||||
|
||||
if( !log_file_open || !file )
|
||||
{
|
||||
file.close();
|
||||
file.clear();
|
||||
|
||||
OpenFile();
|
||||
|
||||
if( !file )
|
||||
return;
|
||||
}
|
||||
|
||||
PT::WideToUTF8(buffer.Str(), file);
|
||||
file.flush();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
-199
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_log
|
||||
#define headerfile_winix_core_log
|
||||
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "textstream.h"
|
||||
#include "logmanipulators.h"
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class TimeZones;
|
||||
|
||||
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
|
||||
Log();
|
||||
~Log();
|
||||
|
||||
void SetTimeZones(TimeZones * ptime_zones);
|
||||
void Init(int log_level_, bool save_each_line_, const std::wstring & log_file_, bool log_std, int log_max_requests);
|
||||
|
||||
Log & operator<<(const void * s);
|
||||
Log & operator<<(const char * s);
|
||||
Log & operator<<(const std::string * s);
|
||||
Log & operator<<(const std::string & s);
|
||||
Log & operator<<(const wchar_t * s);
|
||||
Log & operator<<(const std::wstring * s);
|
||||
Log & operator<<(const std::wstring & s);
|
||||
Log & operator<<(int s);
|
||||
Log & operator<<(long s);
|
||||
Log & operator<<(char s);
|
||||
Log & operator<<(wchar_t s);
|
||||
Log & operator<<(size_t s);
|
||||
Log & operator<<(double s);
|
||||
Log & operator<<(const PT::Space & space);
|
||||
Log & operator<<(LogManipulators m);
|
||||
Log & operator<<(const PT::Date & date);
|
||||
|
||||
void PrintDate(const PT::Date & date, size_t time_zone_id);
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
Log & operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf);
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void LogString(const StringType & value, size_t max_size);
|
||||
|
||||
void LogBinary(const char * blob, size_t blob_len);
|
||||
void LogBinary(const std::string & blob);
|
||||
|
||||
|
||||
void SystemErr(int err);
|
||||
void SaveLog();
|
||||
void SaveLogAndClear();
|
||||
|
||||
int LogLevel();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// time zones for printing the time in the log file
|
||||
TimeZones * time_zones;
|
||||
|
||||
// buffer for the log
|
||||
TextStream<std::wstring> buffer;
|
||||
|
||||
// log lovel from the config file
|
||||
int log_level;
|
||||
|
||||
// current level set by a modifier (e.g. log << log3)
|
||||
int current_level;
|
||||
|
||||
// current request for logging
|
||||
// starts from zero and incremented after logendrequest modifier
|
||||
int request;
|
||||
|
||||
// how many request to save at once
|
||||
int max_requests;
|
||||
|
||||
// file log
|
||||
std::string log_file;
|
||||
std::ofstream file;
|
||||
|
||||
// logging to stdout
|
||||
bool log_stdout;
|
||||
|
||||
// how many lines there are in the buffer
|
||||
int lines;
|
||||
|
||||
// is the config file already open
|
||||
bool log_file_open;
|
||||
|
||||
// how many lines can be in the config buffer
|
||||
// default: 5000
|
||||
int max_lines;
|
||||
|
||||
// whether to save each line (for debug)
|
||||
bool save_each_line;
|
||||
|
||||
void OpenFile();
|
||||
char GetHEXdigit(unsigned char c);
|
||||
void ToHEX(char * buf, unsigned char c);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void Log::LogString(const StringType & value, size_t max_size)
|
||||
{
|
||||
size_t min_size = value.size() < max_size ? value.size() : max_size;
|
||||
|
||||
if( current_level <= log_level )
|
||||
{
|
||||
for(size_t i=0 ; i<min_size ; ++i)
|
||||
{
|
||||
if( value[i] < 32 )
|
||||
buffer << '.';
|
||||
else
|
||||
buffer << value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
Log & Log::operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf)
|
||||
{
|
||||
if( current_level <= log_level )
|
||||
buffer << buf;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern Log log;
|
||||
extern Log nlog;
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
// for convenience, we have to use only #include "log.h" in the winix
|
||||
#include "slog.h"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_postparser
|
||||
#define headerfile_winix_core_postparser
|
||||
|
||||
#include <fcgiapp.h>
|
||||
#include <string>
|
||||
#include "httpsimpleparser.h"
|
||||
#include "requesttypes.h"
|
||||
#include "misc.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "log.h"
|
||||
#include "plugin.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class PostParser : public HttpSimpleParser
|
||||
{
|
||||
FCGX_Stream * in;
|
||||
PostTab * post_tab;
|
||||
size_t log_value_size;
|
||||
int var_index;
|
||||
bool has_winix_post_params_msg;
|
||||
bool has_winix_raw_post_msg;
|
||||
std::string raw_post;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual int GetChar()
|
||||
{
|
||||
int c = FCGX_GetChar(in);
|
||||
|
||||
if( c != -1 && has_winix_raw_post_msg )
|
||||
raw_post += c;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void CreateLog(bool param_added, const std::wstring & name, const std::wstring & value)
|
||||
{
|
||||
log << log2 << "Method POST, name: \"" << name << "\"";
|
||||
|
||||
if( log_value_size > 0 && !IsSubStringNoCase(L"pass", name.c_str()) )
|
||||
{
|
||||
log << ", value: ";
|
||||
|
||||
if( value.size() > log_value_size )
|
||||
log << "(first " << log_value_size << " characters) ";
|
||||
|
||||
log << "\"";
|
||||
log.LogString(value, log_value_size);
|
||||
log << "\" (size: " << value.size() << ")";
|
||||
}
|
||||
|
||||
if( param_added == false )
|
||||
log << log2 << " (skipped)";
|
||||
|
||||
log << log2 << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void Parameter(std::wstring & name, std::wstring & value)
|
||||
{
|
||||
bool added;
|
||||
std::pair<PostTab::iterator, bool> res;
|
||||
|
||||
if( has_winix_post_params_msg )
|
||||
plugin.Call(0, WINIX_POST_PARAMS, &name, &value);
|
||||
|
||||
res = post_tab->insert( std::make_pair(name, value) );
|
||||
added = res.second;
|
||||
|
||||
if( !added )
|
||||
{
|
||||
name += L"_inc";
|
||||
name += Toa(var_index);
|
||||
res = post_tab->insert( std::make_pair(name, value) );
|
||||
added = res.second;
|
||||
var_index += 1;
|
||||
}
|
||||
|
||||
CreateLog(added, name, value);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
PostParser()
|
||||
{
|
||||
log_value_size = 0;
|
||||
HttpSimpleParser::getchar_returns_utf8_chars = true;
|
||||
}
|
||||
|
||||
void LogValueSize(size_t s)
|
||||
{
|
||||
log_value_size = s;
|
||||
}
|
||||
|
||||
void Parse(FCGX_Stream * in_, PostTab & post_tab_)
|
||||
{
|
||||
in = in_;
|
||||
post_tab = &post_tab_;
|
||||
var_index = 1;
|
||||
raw_post.clear();
|
||||
|
||||
has_winix_post_params_msg = plugin.HasMessage(WINIX_POST_PARAMS);
|
||||
has_winix_raw_post_msg = plugin.HasMessage(WINIX_RAW_POST_STRING);
|
||||
|
||||
HttpSimpleParser::Parse();
|
||||
|
||||
if( has_winix_raw_post_msg )
|
||||
plugin.Call(0, WINIX_RAW_POST_STRING, &raw_post);
|
||||
|
||||
raw_post.clear();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,345 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "request.h"
|
||||
#include "log.h"
|
||||
#include "plugin.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Request::Request()
|
||||
{
|
||||
id = 0;
|
||||
config = 0;
|
||||
}
|
||||
|
||||
|
||||
void Request::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Request::ClearOutputStreams()
|
||||
{
|
||||
size_t len = 16;
|
||||
|
||||
if( config )
|
||||
len = config->ezc_out_streams_size;
|
||||
|
||||
if( len < 1 || len > 64 )
|
||||
len = 16;
|
||||
|
||||
if( out_streams.size() != len )
|
||||
out_streams.resize(len);
|
||||
|
||||
if( use_html_filter.size() != len )
|
||||
use_html_filter.resize(len);
|
||||
|
||||
for(size_t i=0 ; i<out_streams.size() ; ++i)
|
||||
{
|
||||
out_streams[i].Clear();
|
||||
out_streams[i].Escape(true);
|
||||
use_html_filter[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Request::Clear()
|
||||
{
|
||||
// id is never 0
|
||||
if( ++id == 0 )
|
||||
++id;
|
||||
|
||||
RemovePostFileTmp(post_file_tab);
|
||||
ClearOutputStreams();
|
||||
|
||||
post_tab.clear();
|
||||
post_file_tab.clear();
|
||||
cookie_tab.clear();
|
||||
|
||||
method = unknown_method;
|
||||
|
||||
out_headers.Clear();
|
||||
out_cookies.Clear();
|
||||
|
||||
page_generated = false;
|
||||
|
||||
env_request_method.clear();
|
||||
env_request_uri.clear();
|
||||
env_http_cookie.clear();
|
||||
env_remote_addr.clear();
|
||||
env_http_host.clear();
|
||||
env_http_user_agent.clear();
|
||||
env_http_accept_encoding.clear();
|
||||
env_fcgi_role.clear();
|
||||
env_content_type.clear();
|
||||
env_https.clear();
|
||||
|
||||
item_tab.clear();
|
||||
item.Clear();
|
||||
dir_tab.clear();
|
||||
last_item = &item;
|
||||
is_item = false;
|
||||
function = 0;
|
||||
param_tab.clear();
|
||||
anchor.clear();
|
||||
|
||||
status = WINIX_ERR_OK;
|
||||
|
||||
browser_msie = false;
|
||||
redirect_to.clear();
|
||||
redirect_type = 303;
|
||||
x_sendfile.clear();
|
||||
send_as_attachment = false;
|
||||
|
||||
using_ssl = false;
|
||||
|
||||
start_time = 0;
|
||||
start_date.Clear();
|
||||
|
||||
subdomain.clear();
|
||||
return_info_only = false;
|
||||
info.Clear();
|
||||
info_serializer = 0;
|
||||
return_json = false;
|
||||
|
||||
out_bin_stream.clear();
|
||||
send_bin_stream = false;
|
||||
|
||||
gen_trim_white = false;
|
||||
gen_skip_new_line = false;
|
||||
gen_use_special_chars = false;
|
||||
|
||||
ip = 0;
|
||||
use_200_status_for_not_found_and_permission_denied = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Request::RequestStarts()
|
||||
{
|
||||
// clearing it is better to use at the end of a request
|
||||
// so starting is much faster
|
||||
|
||||
start_time = std::time(0);
|
||||
start_date = start_time;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Request::IsPostVar(const wchar_t * var)
|
||||
{
|
||||
PostTab::iterator p;
|
||||
|
||||
p = post_tab.find(var);
|
||||
|
||||
if( p == post_tab.end() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Request::IsPostVar(const std::wstring & var)
|
||||
{
|
||||
PostTab::iterator p;
|
||||
|
||||
p = post_tab.find(var);
|
||||
|
||||
if( p == post_tab.end() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const std::wstring & Request::PostVar(const wchar_t * var)
|
||||
{
|
||||
PostTab::iterator p = post_tab.find(var);
|
||||
|
||||
if( p == post_tab.end() )
|
||||
return str_empty;
|
||||
|
||||
return p->second;
|
||||
}
|
||||
|
||||
|
||||
const std::wstring & Request::PostVar(const std::wstring & var)
|
||||
{
|
||||
PostTab::iterator p = post_tab.find(var);
|
||||
|
||||
if( p == post_tab.end() )
|
||||
return str_empty;
|
||||
|
||||
return p->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Request::PostVar(const wchar_t * var, std::wstring & result)
|
||||
{
|
||||
PostTab::iterator p = post_tab.find(var);
|
||||
|
||||
if( p == post_tab.end() )
|
||||
{
|
||||
result.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
result = p->second;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Request::PostVar(const std::wstring & var, std::wstring & result)
|
||||
{
|
||||
PostTab::iterator p = post_tab.find(var);
|
||||
|
||||
if( p == post_tab.end() )
|
||||
{
|
||||
result.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
result = p->second;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::wstring * Request::PostVarp(const wchar_t * var)
|
||||
{
|
||||
PostTab::iterator p = post_tab.find(var);
|
||||
|
||||
if( p == post_tab.end() )
|
||||
return 0;
|
||||
|
||||
return &p->second;
|
||||
}
|
||||
|
||||
|
||||
std::wstring * Request::PostVarp(const std::wstring & var)
|
||||
{
|
||||
PostTab::iterator p = post_tab.find(var);
|
||||
|
||||
if( p == post_tab.end() )
|
||||
return 0;
|
||||
|
||||
return &p->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Request::AllPostVarEmpty()
|
||||
{
|
||||
PostTab::iterator i;
|
||||
|
||||
for(i=post_tab.begin() ; i!=post_tab.end() ; ++i)
|
||||
if( !i->second.empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Request::IsParam(const wchar_t * param_name)
|
||||
{
|
||||
ParamTab::iterator i;
|
||||
|
||||
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
|
||||
{
|
||||
if( i->name == param_name )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Request::IsParam(const std::wstring & param_name)
|
||||
{
|
||||
ParamTab::iterator i;
|
||||
|
||||
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
|
||||
{
|
||||
if( i->name == param_name )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const std::wstring & Request::ParamValue(const wchar_t * param_name)
|
||||
{
|
||||
ParamTab::iterator i;
|
||||
|
||||
for(i=param_tab.begin() ; i!=param_tab.end() ; ++i)
|
||||
{
|
||||
if( i->name == param_name )
|
||||
return i->value;
|
||||
}
|
||||
|
||||
return str_empty;
|
||||
}
|
||||
|
||||
|
||||
const std::wstring & Request::ParamValue(const std::wstring & param_name)
|
||||
{
|
||||
return ParamValue(param_name.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
-428
@@ -1,428 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_request
|
||||
#define headerfile_winix_core_request
|
||||
|
||||
#include <fcgiapp.h>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include "requesttypes.h"
|
||||
#include "item.h"
|
||||
#include "error.h"
|
||||
#include "config.h"
|
||||
#include "textstream.h"
|
||||
#include "templates/htmltextstream.h"
|
||||
#include "date/date.h"
|
||||
#include "space/space.h"
|
||||
#include "space/spacetojson.h"
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class FunctionBase;
|
||||
|
||||
|
||||
|
||||
|
||||
struct Request
|
||||
{
|
||||
/*
|
||||
request id
|
||||
is incremented for each request and is never 0
|
||||
(from -1 will be incremented to one)
|
||||
it's used for some optimizations e.g. in templates
|
||||
*/
|
||||
size_t id;
|
||||
|
||||
|
||||
/*
|
||||
request start time
|
||||
Time() methods are very slow so it is better to directly use those two values
|
||||
they are set when a request starts
|
||||
*/
|
||||
time_t start_time;
|
||||
PT::Date start_date;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
* variables representing input from client's browser
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
the HTTP method
|
||||
!! IMPROVE ME add the rest methods here
|
||||
*/
|
||||
enum Method { get, post, head, unknown_method } method;
|
||||
|
||||
|
||||
/*
|
||||
subdomain
|
||||
subdomain = HTTP_HOST environment variable - config->base_url
|
||||
*/
|
||||
std::wstring subdomain;
|
||||
|
||||
|
||||
/*
|
||||
raw parameters
|
||||
!! CHECK ME may post_tab and cookie_tab should be changed to PT::Space now?
|
||||
or may change the name to cookie_in? or in_cookie?
|
||||
*/
|
||||
PostTab post_tab;
|
||||
PostFileTab post_file_tab;
|
||||
CookieTab cookie_tab;
|
||||
|
||||
|
||||
/*
|
||||
html anchor (those part of URI after '#' character)
|
||||
*/
|
||||
std::wstring anchor;
|
||||
|
||||
|
||||
// environment variables
|
||||
std::wstring env_request_method;
|
||||
std::wstring env_request_uri;
|
||||
std::wstring env_http_cookie;
|
||||
std::wstring env_remote_addr;
|
||||
std::wstring env_http_host;
|
||||
std::wstring env_http_user_agent;
|
||||
std::wstring env_http_accept_encoding;
|
||||
std::wstring env_fcgi_role;
|
||||
std::wstring env_content_type;
|
||||
std::wstring env_https;
|
||||
|
||||
// current IP address of the remote host (read from REMOTE_ADDR environment variable)
|
||||
// (at the moment only IPv4 are supported)
|
||||
int ip;
|
||||
|
||||
// true if the browser is Microsoft Internet Explorer
|
||||
bool browser_msie;
|
||||
|
||||
// true if the browser is Konqueror
|
||||
bool browser_konqueror;
|
||||
|
||||
// true if we are using an encrypted connection (SSL)
|
||||
bool using_ssl;
|
||||
|
||||
|
||||
/*
|
||||
request input variables representing the winix filesystem
|
||||
*/
|
||||
|
||||
// current directory
|
||||
std::vector<Item*> dir_tab;
|
||||
|
||||
// true if a file exists
|
||||
bool is_item;
|
||||
|
||||
// current file (valid if is_item is true)
|
||||
Item item;
|
||||
|
||||
// current winix function
|
||||
// null if there is no a function
|
||||
FunctionBase * function;
|
||||
|
||||
// parameters (name:value)
|
||||
ParamTab param_tab;
|
||||
|
||||
// this is a pointer either to the item (if exists) or to the last directory
|
||||
Item * last_item;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
* variables for generating output to the client's browser
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// request status
|
||||
// !! CHANGE ME it'll be better to use ordinary http result codes
|
||||
Error status;
|
||||
|
||||
// if not empty means an address for redirecting to
|
||||
// it should be url-encoded
|
||||
std::wstring redirect_to;
|
||||
|
||||
// a redirect type
|
||||
// following redirect types are supported:
|
||||
// 300 Multiple Choices
|
||||
// 301 Moved Permanently
|
||||
// 302 Found
|
||||
// 303 See Other (default)
|
||||
// 307 Temporary Redirect
|
||||
int redirect_type;
|
||||
|
||||
// send header X-LIGHTTPD-send-file with path to a file
|
||||
std::wstring x_sendfile;
|
||||
|
||||
// send as attachment (causes generating header: content-disposition: attachment)
|
||||
bool send_as_attachment;
|
||||
|
||||
// headers send to the client (without cookies)
|
||||
PT::Space out_headers;
|
||||
|
||||
// cookies send to the client
|
||||
// a value can be either a cookie value or the whole cookie string (with domain, date etc)
|
||||
PT::Space out_cookies;
|
||||
|
||||
// winix can return either a text answer or a binary answer
|
||||
// if send_bin_stream is true then the binary answer is sent (out_bin_stream)
|
||||
// or if send_bin_stream is false then the text answer is sent
|
||||
// default: false
|
||||
//
|
||||
//
|
||||
// winix answer send to the client's browser
|
||||
// |
|
||||
// |
|
||||
// depending on send_bin_stream
|
||||
// (if false) ------------------------------------------------- (if true)
|
||||
// | |
|
||||
// text answer binary answer
|
||||
// | |
|
||||
// depending on return_json sending out_bin_stream
|
||||
// (if false) ------------------------------------ (if true)
|
||||
// | |
|
||||
// normal request ajax request
|
||||
// | |
|
||||
// sending out_streams[0] |
|
||||
// |
|
||||
// |
|
||||
// depending on return_info_only
|
||||
// (if false) ------------------------------------------------------ (if true)
|
||||
// | |
|
||||
// generating JSON object from: generating JSON object only from info
|
||||
// out_streams and info, e.g.: e.g.:
|
||||
// { { info object serialized here }
|
||||
// "stream_1": "some html content",
|
||||
// "stream_2": "some other html content",
|
||||
// "info": { info object serialized here }
|
||||
// }
|
||||
// note that out_streams[0] is not sent
|
||||
// in JSON answers
|
||||
//
|
||||
//
|
||||
bool send_bin_stream;
|
||||
|
||||
// binary page sent to the client if send_bin_stream is true
|
||||
BinaryPage out_bin_stream;
|
||||
|
||||
// when returning the text answer we can either return the whole html page (normal requests)
|
||||
// or a JSON object (for requests generated from AJAX)
|
||||
// if return_json is false then we return the whole html page (which is in out_streams[0])
|
||||
// if return_json is true we are creating an JSON object from out_streams
|
||||
// (zero stream is ignored) and from info space (see above picture)
|
||||
// (or just only from info if return_info_only is true)
|
||||
// default: false
|
||||
// return_json is set to true by App at the beginning of a request
|
||||
// if reqtype:json parameter is present (in the url)
|
||||
// note: return_json is only valid if send_bin_stream is false
|
||||
bool return_json;
|
||||
|
||||
// main text output streams where the html otput is generated from ezc templates
|
||||
// the zero stream (out_streams[0]) is used as the main stream
|
||||
// to which the whole html page (with doctype, head, body) is generated
|
||||
// the rest streams can be only used in ajax requests (send in JSON format to the client)
|
||||
// in ezc templates you can use [ezc stream ...] keyword
|
||||
// to switch between streams e.g. [ezc stream "0" "2"]
|
||||
std::vector<HtmlTextStream> out_streams;
|
||||
|
||||
// if true the JSON object is generated only from info (out_streams are not used)
|
||||
// default: false
|
||||
bool return_info_only;
|
||||
|
||||
// additional info added when sending the JSON answer
|
||||
PT::Space info;
|
||||
|
||||
// info serializer
|
||||
// if not set then the json_generic_serializer from App will be used
|
||||
// default: null (json_generic_serializer used)
|
||||
PT::SpaceToJSON * info_serializer;
|
||||
|
||||
|
||||
|
||||
|
||||
// if set to true then the standard template system will not be used
|
||||
// default: false
|
||||
bool page_generated;
|
||||
|
||||
// whether or not the html filter should be used
|
||||
// the size of the table is the same as out_streams
|
||||
// default: all items true
|
||||
std::vector<bool> use_html_filter;
|
||||
|
||||
|
||||
|
||||
|
||||
// if this variable is true then winix always return 200 OK header
|
||||
// when the status would be 404 (not found) or 403 (permission denied)
|
||||
// default: false
|
||||
bool use_200_status_for_not_found_and_permission_denied;
|
||||
|
||||
// options used by ezc generators
|
||||
bool gen_trim_white;
|
||||
bool gen_skip_new_line;
|
||||
bool gen_use_special_chars;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
additional variables used for common uses
|
||||
*/
|
||||
|
||||
// usually items in the current directory (depends on the function)
|
||||
std::vector<Item> item_tab;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Request();
|
||||
void SetConfig(Config * pconfig);
|
||||
|
||||
void RequestStarts();
|
||||
void Clear();
|
||||
|
||||
|
||||
|
||||
bool IsParam(const wchar_t * param_name);
|
||||
bool IsParam(const std::wstring & param_name);
|
||||
const std::wstring & ParamValue(const wchar_t * param_name); // returns an empty string if there is no such a parameter
|
||||
const std::wstring & ParamValue(const std::wstring & param_name); // returns an empty string if there is no such a parameter
|
||||
|
||||
bool IsPostVar(const wchar_t * var);
|
||||
bool IsPostVar(const std::wstring & var);
|
||||
const std::wstring & PostVar(const wchar_t * var); // returns an empty string if there is no such a parameter
|
||||
const std::wstring & PostVar(const std::wstring & var); // returns an empty string if there is no such a parameter
|
||||
bool PostVar(const wchar_t * var, std::wstring & result);
|
||||
bool PostVar(const std::wstring & var, std::wstring & result);
|
||||
std::wstring * PostVarp(const wchar_t * var);
|
||||
std::wstring * PostVarp(const std::wstring & var);
|
||||
|
||||
bool AllPostVarEmpty(); // returning true if all post vars are empty
|
||||
|
||||
|
||||
// setting a cookie
|
||||
// name - cookie name (either const wchar_t, or std::wstring or PT::WTextStream)
|
||||
// value - cookie value (can be everything which can be put to PT::WTextStream stream)
|
||||
// the return std::wstring reference is a reference to the cookie inserted value (in out_cookies structure)
|
||||
template<typename NameType, typename ValueType>
|
||||
std::wstring & AddCookie(const NameType & name, const ValueType & value, PT::Date * expires = 0);
|
||||
|
||||
template<typename NameType, typename ValueType>
|
||||
std::wstring & AddCookie(const NameType & name, const ValueType & value, PT::Date & expires);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Config * config;
|
||||
|
||||
// used in ParamValue() and PostVar() when there is no such a param
|
||||
const std::wstring str_empty;
|
||||
|
||||
void ClearOutputStreams();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename NameType, typename ValueType>
|
||||
std::wstring & Request::AddCookie(const NameType & name, const ValueType & value, PT::Date * expires)
|
||||
{
|
||||
PT::WTextStream cookie;
|
||||
|
||||
cookie << value;
|
||||
|
||||
if( cookie.empty() )
|
||||
cookie << L"\"\""; // cookie empty value
|
||||
|
||||
if( expires )
|
||||
cookie << L"; expires=" << DateToStrCookie(*expires) << L" GMT";
|
||||
|
||||
cookie << L"; path=/; domain=" << config->base_url;
|
||||
|
||||
/*
|
||||
!! IMPROVE ME add an option to the config
|
||||
|
||||
don't use '; secure' flag if you are using both sites (with SSL
|
||||
and without SSL) -- with secure flag the cookie is sent only through
|
||||
SSL and if you accidentally open a new window without SSL (http://)
|
||||
then winix will create a new session for you and the previous session (https://)
|
||||
will be lost (the session cookie will be overwritten in the client's browser)
|
||||
*/
|
||||
|
||||
return out_cookies.Add(name, cookie);
|
||||
}
|
||||
|
||||
|
||||
template<typename NameType, typename ValueType>
|
||||
std::wstring & Request::AddCookie(const NameType & name, const ValueType & value, PT::Date & expires)
|
||||
{
|
||||
return AddCookie(name, value, &expires);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
||||
|
||||
-257
@@ -1,257 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "slog.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
SLog::SLog()
|
||||
{
|
||||
cur = 0;
|
||||
locale = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SLog::SetCur(Cur * pcur)
|
||||
{
|
||||
cur = pcur;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SLog::SetLocale(Locale * plocale)
|
||||
{
|
||||
locale = plocale;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const void * s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const char * s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const std::string * s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const std::string & s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const wchar_t * s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const std::wstring * s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const std::wstring & s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(int s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(long s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(char s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(wchar_t s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(size_t s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(double s)
|
||||
{
|
||||
return PutLog(s);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const PT::Date & date)
|
||||
{
|
||||
return PutLog(date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SLog & SLog::operator<<(LogManipulators m)
|
||||
{
|
||||
if( cur && cur->session )
|
||||
{
|
||||
TextStream<std::wstring> & buf = cur->session->log_buffer;
|
||||
|
||||
switch(m)
|
||||
{
|
||||
case logend:
|
||||
buf << '\n';
|
||||
|
||||
if( buf.Size() > WINIX_SLOG_MAX_LOG_SIZE )
|
||||
{
|
||||
buf.Clear();
|
||||
(*this) << logwarning << T("slog_turn_over") << " " << WINIX_SLOG_MAX_LOG_SIZE << logend;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case loginfo:
|
||||
case logwarning:
|
||||
case logerror:
|
||||
buf << (wchar_t)(int)m;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SLog & SLog::TranslateText(const char * str)
|
||||
{
|
||||
PT::UTF8ToWide(str, key_temp);
|
||||
return TranslateText(key_temp.c_str());
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::TranslateText(const wchar_t * str)
|
||||
{
|
||||
if( cur && cur->session )
|
||||
{
|
||||
const std::wstring * trans = 0;
|
||||
|
||||
if( locale )
|
||||
trans = &locale->Get(str);
|
||||
|
||||
// !! IMPROVE ME "Not translated" add to locale
|
||||
if( !trans || trans->empty() )
|
||||
cur->session->log_buffer << "Not translated: " << str;
|
||||
else
|
||||
cur->session->log_buffer << trans;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const TranslateTextHelper<const char*> & raw)
|
||||
{
|
||||
return TranslateText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(const TranslateTextHelper<const wchar_t*> & raw)
|
||||
{
|
||||
return TranslateText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(TranslateTextHelper<const std::string*> raw)
|
||||
{
|
||||
return TranslateText(raw.par->c_str());
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(TranslateTextHelper<const std::wstring*> raw)
|
||||
{
|
||||
return TranslateText(raw.par->c_str());
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(TranslateTextHelper<std::string> raw)
|
||||
{
|
||||
return TranslateText(raw.par.c_str());
|
||||
}
|
||||
|
||||
|
||||
SLog & SLog::operator<<(TranslateTextHelper<std::wstring> raw)
|
||||
{
|
||||
return TranslateText(raw.par.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
-175
@@ -1,175 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_slog
|
||||
#define headerfile_winix_core_slog
|
||||
|
||||
#include "cur.h"
|
||||
#include "logmanipulators.h"
|
||||
#include "templates/locale.h"
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
#define WINIX_SLOG_MAX_LOG_SIZE 10240
|
||||
|
||||
|
||||
/*
|
||||
session logger
|
||||
|
||||
sample:
|
||||
#include "log.h" (or slog.h)
|
||||
slog << logerror << "message" << "something" << logend;
|
||||
slog << logwarning << T("message_to_translate") << x << logend;
|
||||
|
||||
if the latter example "message_to_translate" will be taken from locales
|
||||
currently following manipulators are taken into account:
|
||||
loginfo - the message in a normal info
|
||||
logwarning - this is a warning
|
||||
logerror - this is an error
|
||||
logend - end of a line -- we have one kind of a message (info, warning, error) per line
|
||||
|
||||
loginfo, logwarning, logerror should be specified at the beginning of a line
|
||||
(other manipulators are skipped)
|
||||
*/
|
||||
class SLog
|
||||
{
|
||||
public:
|
||||
|
||||
SLog();
|
||||
|
||||
void SetCur(Cur * pcur);
|
||||
void SetLocale(Locale * plocale);
|
||||
|
||||
template<class RawType>
|
||||
struct TranslateTextHelper
|
||||
{
|
||||
const RawType & par;
|
||||
|
||||
TranslateTextHelper(const TranslateTextHelper<RawType> & p) : par(p.par) {}
|
||||
TranslateTextHelper(const RawType & p) : par(p) {}
|
||||
};
|
||||
|
||||
SLog & operator<<(const void * s);
|
||||
SLog & operator<<(const char * s);
|
||||
SLog & operator<<(const std::string * s);
|
||||
SLog & operator<<(const std::string & s);
|
||||
SLog & operator<<(const wchar_t * s);
|
||||
SLog & operator<<(const std::wstring * s);
|
||||
SLog & operator<<(const std::wstring & s);
|
||||
SLog & operator<<(int s);
|
||||
SLog & operator<<(long s);
|
||||
SLog & operator<<(char s);
|
||||
SLog & operator<<(wchar_t s);
|
||||
SLog & operator<<(size_t s);
|
||||
SLog & operator<<(double s);
|
||||
SLog & operator<<(LogManipulators m);
|
||||
SLog & operator<<(const PT::Date & date);
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
SLog & operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf);
|
||||
|
||||
|
||||
SLog & TranslateText(const char * str);
|
||||
SLog & TranslateText(const wchar_t * str);
|
||||
|
||||
template<size_t str_size>
|
||||
SLog & operator<<(const TranslateTextHelper<const char [str_size]> & raw) { return TranslateText(raw.par); }
|
||||
|
||||
template<size_t str_size>
|
||||
SLog & operator<<(const TranslateTextHelper<const wchar_t [str_size]> & raw){ return TranslateText(raw.par); }
|
||||
|
||||
template<size_t str_size>
|
||||
SLog & operator<<(const TranslateTextHelper<char [str_size]> & raw) { return TranslateText(raw.par); }
|
||||
|
||||
template<size_t str_size>
|
||||
SLog & operator<<(const TranslateTextHelper<wchar_t [str_size]> & raw){ return TranslateText(raw.par); }
|
||||
|
||||
SLog & operator<<(const TranslateTextHelper<const char*> & raw);
|
||||
SLog & operator<<(const TranslateTextHelper<const wchar_t*> & raw);
|
||||
SLog & operator<<(TranslateTextHelper<const std::string*> raw);
|
||||
SLog & operator<<(TranslateTextHelper<const std::wstring*> raw);
|
||||
SLog & operator<<(TranslateTextHelper<std::string> raw);
|
||||
SLog & operator<<(TranslateTextHelper<std::wstring> raw);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
template<class LogParam>
|
||||
SLog & PutLog(const LogParam & par);
|
||||
|
||||
Cur * cur;
|
||||
Locale * locale;
|
||||
std::wstring key_temp;
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<class RawType>
|
||||
SLog::TranslateTextHelper<RawType> T(const RawType & par)
|
||||
{
|
||||
return SLog::TranslateTextHelper<RawType>(par);
|
||||
}
|
||||
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
SLog & SLog::operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf)
|
||||
{
|
||||
return PutLog(buf);
|
||||
}
|
||||
|
||||
|
||||
template<class LogParam>
|
||||
SLog & SLog::PutLog(const LogParam & par)
|
||||
{
|
||||
if( cur && cur->session )
|
||||
cur->session->log_buffer << par;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
extern SLog slog;
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,556 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_textstream
|
||||
#define headerfile_winix_core_textstream
|
||||
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include "misc.h"
|
||||
#include "space/space.h"
|
||||
#include "date/date.h"
|
||||
#include "textstream/textstream.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
a special class representing a stream buffer
|
||||
similar to std::ostringstream
|
||||
|
||||
StringType can be either std::string or std::wstring
|
||||
|
||||
this class uses UTF-8 <-> wide characters conversions:
|
||||
if StringType is std::string:
|
||||
operator<<(const char*) only copies the input string
|
||||
operator<<(const wchar_t*) converts from wide characters to UTF-8
|
||||
(similary for an operator with std::string and std::wstring)
|
||||
if StringType is std::wstring:
|
||||
operator<<(const char*) converts from UTF-8 to wide characters
|
||||
operator<<(const wchar_t*) only copies the input string
|
||||
(similary for an operator with std::string and std::wstring)
|
||||
|
||||
*/
|
||||
template<class StringType>
|
||||
class TextStream
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename StringType::value_type CharType;
|
||||
typedef typename StringType::value_type char_type;
|
||||
|
||||
void Clear();
|
||||
bool Empty() const;
|
||||
size_t Size() const;
|
||||
void Reserve(size_t len);
|
||||
|
||||
const StringType & Str() const;
|
||||
const CharType * CStr() const;
|
||||
|
||||
void Str(const StringType & str);
|
||||
void Str(const StringType && str);
|
||||
|
||||
CharType operator[](size_t index);
|
||||
|
||||
TextStream & operator<<(const char * str);
|
||||
TextStream & operator<<(const std::string * str);
|
||||
TextStream & operator<<(const std::string & str);
|
||||
|
||||
TextStream & operator<<(const wchar_t * str);
|
||||
TextStream & operator<<(const std::wstring * str);
|
||||
TextStream & operator<<(const std::wstring & str);
|
||||
|
||||
TextStream & operator<<(char);
|
||||
TextStream & operator<<(wchar_t);
|
||||
TextStream & operator<<(int);
|
||||
TextStream & operator<<(long);
|
||||
TextStream & operator<<(unsigned int);
|
||||
TextStream & operator<<(unsigned long);
|
||||
TextStream & operator<<(double);
|
||||
TextStream & operator<<(const void *);// printing a pointer
|
||||
TextStream & operator<<(const PT::Space & space);
|
||||
TextStream & operator<<(const PT::Date & date);
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
TextStream & operator<<(const PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & arg);
|
||||
|
||||
TextStream & Write(const char * buf, size_t len);
|
||||
TextStream & Write(const wchar_t * buf, size_t len);
|
||||
TextStream & write(const char * buf, size_t len); // for compatibility with standard library (Ezc uses it)
|
||||
TextStream & write(const wchar_t * buf, size_t len);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
StringType buffer;
|
||||
|
||||
void Convert(wchar_t c, std::string & dst);
|
||||
void Convert(wchar_t c, std::wstring & dst);
|
||||
|
||||
void Convert(const char * src, size_t len, std::wstring & dst);
|
||||
void Convert(const char * src, std::wstring & dst);
|
||||
void Convert(const std::string & src, std::wstring & dst);
|
||||
|
||||
void Convert(const wchar_t * src, size_t len, std::string & dst);
|
||||
void Convert(const wchar_t * src, std::string & dst);
|
||||
void Convert(const std::wstring & src, std::string & dst);
|
||||
|
||||
void Convert(const char * src, size_t len, std::string & dst);
|
||||
void Convert(const char * src, std::string & dst);
|
||||
void Convert(const std::string & src, std::string & dst);
|
||||
|
||||
void Convert(const wchar_t * src, size_t len, std::wstring & dst);
|
||||
void Convert(const wchar_t * src, std::wstring & dst);
|
||||
void Convert(const std::wstring & src, std::wstring & dst);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Clear()
|
||||
{
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
template<class StringType>
|
||||
bool TextStream<StringType>::Empty() const
|
||||
{
|
||||
return buffer.empty();
|
||||
}
|
||||
|
||||
template<class StringType>
|
||||
size_t TextStream<StringType>::Size() const
|
||||
{
|
||||
return buffer.size();
|
||||
}
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Reserve(size_t len)
|
||||
{
|
||||
buffer.reserve(len);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
const StringType & TextStream<StringType>::Str() const
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
const typename TextStream<StringType>::CharType * TextStream<StringType>::CStr() const
|
||||
{
|
||||
return buffer.c_str();
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Str(const StringType & str)
|
||||
{
|
||||
buffer = str;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Str(const StringType && str)
|
||||
{
|
||||
buffer = str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
typename TextStream<StringType>::CharType TextStream<StringType>::operator[](size_t index)
|
||||
{
|
||||
return buffer[index];
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const char * str)
|
||||
{
|
||||
Convert(str, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const std::string * str)
|
||||
{
|
||||
Convert(*str, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const std::string & str)
|
||||
{
|
||||
Convert(str, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const wchar_t * str)
|
||||
{
|
||||
Convert(str, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const std::wstring * str)
|
||||
{
|
||||
Convert(*str, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const std::wstring & str)
|
||||
{
|
||||
Convert(str, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(char v)
|
||||
{
|
||||
/*
|
||||
* there is no any possibility to treat 'v' as UTF-8 character if we have got
|
||||
* only one character so we only copy it
|
||||
*/
|
||||
buffer += v;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(wchar_t v)
|
||||
{
|
||||
Convert(v, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(int v)
|
||||
{
|
||||
wchar_t buf[50];
|
||||
size_t len = sizeof(buf) / sizeof(wchar_t);
|
||||
|
||||
Toa(v, buf, len);
|
||||
Convert(buf, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(long v)
|
||||
{
|
||||
wchar_t buf[50];
|
||||
size_t len = sizeof(buf) / sizeof(wchar_t);
|
||||
|
||||
Toa(v, buf, len);
|
||||
Convert(buf, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(unsigned int v)
|
||||
{
|
||||
wchar_t buf[50];
|
||||
size_t len = sizeof(buf) / sizeof(wchar_t);
|
||||
|
||||
Toa(v, buf, len);
|
||||
Convert(buf, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(unsigned long v)
|
||||
{
|
||||
wchar_t buf[50];
|
||||
size_t len = sizeof(buf) / sizeof(wchar_t);
|
||||
|
||||
Toa(v, buf, len);
|
||||
Convert(buf, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(double v)
|
||||
{
|
||||
char buf[50];
|
||||
|
||||
sprintf(buf, "%f", v);
|
||||
Convert(buf, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const void * v)
|
||||
{
|
||||
wchar_t buf[50];
|
||||
size_t len = sizeof(buf) / sizeof(wchar_t);
|
||||
|
||||
buf[0] = '0';
|
||||
buf[1] = 'x';
|
||||
|
||||
Toa(reinterpret_cast<unsigned long>(v), buf+2, len-2, 16);
|
||||
Convert(buf, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::Write(const char * buf, size_t len)
|
||||
{
|
||||
Convert(buf, len, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::write(const char * buf, size_t len)
|
||||
{
|
||||
return Write(buf, len);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::Write(const wchar_t * buf, size_t len)
|
||||
{
|
||||
Convert(buf, len, buffer);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::write(const wchar_t * buf, size_t len)
|
||||
{
|
||||
return Write(buf, len);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const PT::Space & space)
|
||||
{
|
||||
space.Serialize(*this, true, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(const PT::Date & date)
|
||||
{
|
||||
date.Serialize(*this);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
TextStream<StringType> & TextStream<StringType>::operator<<(
|
||||
const PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & arg)
|
||||
{
|
||||
typename PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size>::const_iterator i;
|
||||
|
||||
for(i=arg.begin() ; i != arg.end() ; ++i)
|
||||
buffer += static_cast<char_type>(*i);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(wchar_t c, std::string & dst)
|
||||
{
|
||||
PT::IntToUTF8((int)c, dst, false);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(wchar_t c, std::wstring & dst)
|
||||
{
|
||||
dst += c;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const char * src, size_t len, std::wstring & dst)
|
||||
{
|
||||
PT::UTF8ToWide(src, len, dst, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const char * src, std::wstring & dst)
|
||||
{
|
||||
PT::UTF8ToWide(src, dst, false);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const std::string & src, std::wstring & dst)
|
||||
{
|
||||
PT::UTF8ToWide(src, dst, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const wchar_t * src, size_t len, std::string & dst)
|
||||
{
|
||||
PT::WideToUTF8(src, len, dst, false);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const wchar_t * src, std::string & dst)
|
||||
{
|
||||
PT::WideToUTF8(src, dst, false);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const std::wstring & src, std::string & dst)
|
||||
{
|
||||
PT::WideToUTF8(src, dst, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const char * src, size_t len, std::string & dst)
|
||||
{
|
||||
// we suppose that append is smart enough and we don't have to use reserve()
|
||||
dst.append(src, len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const char * src, std::string & dst)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
for(len=0 ; src[len] ; ++len){}
|
||||
|
||||
Convert(src, len, dst);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const std::string & src, std::string & dst)
|
||||
{
|
||||
dst.append(src);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const wchar_t * src, size_t len, std::wstring & dst)
|
||||
{
|
||||
// we suppose that append is smart enough and we don't have to use reserve()
|
||||
dst.append(src, len);
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const wchar_t * src, std::wstring & dst)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
for(len=0 ; src[len] ; ++len){}
|
||||
|
||||
Convert(src, len, dst);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StringType>
|
||||
void TextStream<StringType>::Convert(const std::wstring & src, std::wstring & dst)
|
||||
{
|
||||
dst.append(src);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include "threadmanager.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
ThreadManager::ThreadManager()
|
||||
{
|
||||
were_started = false;
|
||||
}
|
||||
|
||||
|
||||
void ThreadManager::SetSynchro(Synchro * psynchro)
|
||||
{
|
||||
synchro = psynchro;
|
||||
}
|
||||
|
||||
|
||||
void ThreadManager::Init()
|
||||
{
|
||||
sigset_t set;
|
||||
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set, SIGTERM);
|
||||
sigaddset(&set, SIGINT);
|
||||
|
||||
// blocking SIGTERM and SIGINT
|
||||
// new threads will have the signals blocked too
|
||||
pthread_sigmask(SIG_BLOCK, &set, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name)
|
||||
{
|
||||
ThreadItem item;
|
||||
|
||||
item.object = pbase;
|
||||
item.name = thread_name;
|
||||
thread_tab.push_back(item);
|
||||
|
||||
if( were_started )
|
||||
Start(thread_tab.size() - 1);
|
||||
else
|
||||
log << log4 << "TM: added a thread to the queue, number: " << (thread_tab.size()-1)
|
||||
<< ", name: " << thread_name << logend;
|
||||
}
|
||||
|
||||
|
||||
void ThreadManager::Add(BaseThread & pbase, const wchar_t * thread_name)
|
||||
{
|
||||
Add(&pbase, thread_name);
|
||||
}
|
||||
|
||||
|
||||
void ThreadManager::Add(BaseThread * pbase, const std::wstring & thread_name)
|
||||
{
|
||||
Add(pbase, thread_name.c_str());
|
||||
}
|
||||
|
||||
void ThreadManager::Add(BaseThread & pbase, const std::wstring & thread_name)
|
||||
{
|
||||
Add(&pbase, thread_name.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ThreadManager::StartAll()
|
||||
{
|
||||
synchro->Lock();
|
||||
|
||||
for(size_t i=0 ; i<thread_tab.size() ; ++i)
|
||||
Start(i);
|
||||
|
||||
synchro->Unlock();
|
||||
|
||||
were_started = true;
|
||||
}
|
||||
|
||||
|
||||
void ThreadManager::Start(size_t i)
|
||||
{
|
||||
if( i < thread_tab.size() )
|
||||
{
|
||||
thread_tab[i].object->SetSynchro(synchro);
|
||||
|
||||
if( thread_tab[i].object->StartThread() )
|
||||
{
|
||||
log << log4 << "TM: thread " << i << " (" << thread_tab[i].object->ThreadId() << ", name: "
|
||||
<< thread_tab[i].name << ") started" << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log4 << "TM: cannot run a thread, thread number: " << i
|
||||
<< ", name: " << thread_tab[i].name << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ThreadManager::StopAll()
|
||||
{
|
||||
if( !were_started )
|
||||
return;
|
||||
|
||||
// WakeUpThread() should be used with Lock/Unlock
|
||||
synchro->Lock();
|
||||
|
||||
for(size_t i=0 ; i<thread_tab.size() ; ++i)
|
||||
thread_tab[i].object->WakeUpThread();
|
||||
|
||||
synchro->Unlock();
|
||||
|
||||
|
||||
for(size_t i=0 ; i<thread_tab.size() ; ++i)
|
||||
{
|
||||
log << log4 << "TM: waiting for thread " << i << " (" << thread_tab[i].object->ThreadId()
|
||||
<< ", name: " << thread_tab[i].name << ")" << logend;
|
||||
|
||||
thread_tab[i].object->WaitForThread();
|
||||
|
||||
log << log4 << "TM: thread " << i << " terminated" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
@@ -1,322 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "timezone.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
TimeZone::Dst::Dst()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void TimeZone::Dst::Clear()
|
||||
{
|
||||
has_dst = false;
|
||||
start.Clear();
|
||||
end.Clear();
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
|
||||
bool TimeZone::Dst::IsDstUsed(const PT::Date & date) const
|
||||
{
|
||||
if( !has_dst )
|
||||
return false;
|
||||
|
||||
if( Compare(start, date) <= 0 ) // !! CHECK ME <= or < ? (what about the one second?)
|
||||
if( Compare(date, end) < 0 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int TimeZone::Dst::Compare(const PT::Date & date1, const PT::Date & date2) const
|
||||
{
|
||||
// year is ignored
|
||||
|
||||
if( date1.month != date2.month )
|
||||
return date1.month - date2.month;
|
||||
|
||||
if( date1.day != date2.day )
|
||||
return date1.day - date2.day;
|
||||
|
||||
if( date1.hour != date2.hour )
|
||||
return date1.hour - date2.hour;
|
||||
|
||||
if( date1.min != date2.min )
|
||||
return date1.min - date2.min;
|
||||
|
||||
if( date1.sec != date2.sec )
|
||||
return date1.sec - date2.sec;
|
||||
|
||||
// dates are equal
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TimeZone::TimeZone()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void TimeZone::Clear()
|
||||
{
|
||||
name.clear();
|
||||
id = 0;
|
||||
offset = 0;
|
||||
dst_map.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
TimeZone::Dst * TimeZone::FindDst(int year)
|
||||
{
|
||||
if( dst_map.empty() )
|
||||
return 0;
|
||||
|
||||
DstMap::iterator i = dst_map.lower_bound(year);
|
||||
|
||||
if( i == dst_map.begin() && i->first > year )
|
||||
return 0;
|
||||
|
||||
if( i == dst_map.end() )
|
||||
return &(--i)->second;
|
||||
|
||||
if( i != dst_map.begin() && i->first > year )
|
||||
return &(--i)->second;
|
||||
|
||||
return &i->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
time_t TimeZone::CalcLocalOffset(const PT::Date & utc_date)
|
||||
{
|
||||
time_t dst_offset = 0;
|
||||
|
||||
Dst * dst = FindDst(utc_date.year);
|
||||
|
||||
if( dst && dst->IsDstUsed(utc_date) )
|
||||
dst_offset = dst->offset;
|
||||
|
||||
return offset + dst_offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
time_t TimeZone::ToLocal(time_t utc_time)
|
||||
{
|
||||
time_t offset = CalcLocalOffset(PT::Date(utc_time));
|
||||
|
||||
return utc_time + offset;
|
||||
}
|
||||
|
||||
|
||||
PT::Date TimeZone::ToLocal(const PT::Date & utc_date)
|
||||
{
|
||||
PT::Date local(utc_date);
|
||||
local += CalcLocalOffset(utc_date);
|
||||
|
||||
return local;
|
||||
}
|
||||
|
||||
|
||||
time_t TimeZone::CalcUTCOffset(const PT::Date & local_date)
|
||||
{
|
||||
time_t dst_offset = 0;
|
||||
|
||||
Dst * dst = FindDst(local_date.year);
|
||||
|
||||
if( dst && dst->has_dst )
|
||||
{
|
||||
// dst date ranges we have in UTC
|
||||
PT::Date utc(local_date);
|
||||
utc -= (offset + dst->offset);
|
||||
|
||||
if( dst->IsDstUsed(utc) )
|
||||
dst_offset = dst->offset;
|
||||
}
|
||||
|
||||
return offset + dst_offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
time_t TimeZone::ToUTC(time_t local_time)
|
||||
{
|
||||
time_t offset = CalcUTCOffset(PT::Date(local_time));
|
||||
|
||||
return local_time - offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PT::Date TimeZone::ToUTC(const PT::Date & local_date)
|
||||
{
|
||||
time_t offset;
|
||||
PT::Date utc(local_date);
|
||||
|
||||
offset = CalcUTCOffset(local_date);
|
||||
utc -= offset;
|
||||
|
||||
return utc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
time_t TimeZone::ParseStrOffset(const wchar_t * str)
|
||||
{
|
||||
PT::Date date;
|
||||
bool is_sign = false;
|
||||
time_t offset = 0;
|
||||
|
||||
str = SkipWhite(str);
|
||||
|
||||
if( *str == '-' )
|
||||
{
|
||||
is_sign = true;
|
||||
str += 1;
|
||||
}
|
||||
else
|
||||
if( *str == '+' )
|
||||
{
|
||||
str += 1;
|
||||
}
|
||||
|
||||
if( date.ParseTime(str) )
|
||||
{
|
||||
offset = date.hour * 60 * 60 + date.min * 60 + date.sec;
|
||||
|
||||
if( is_sign )
|
||||
offset = -offset;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
time_t TimeZone::GetOffset(PT::Space & space)
|
||||
{
|
||||
std::wstring * offset_str = space.GetValue(L"offset_str");
|
||||
|
||||
if( offset_str )
|
||||
return ParseStrOffset(offset_str->c_str());
|
||||
|
||||
return space.Long(L"offset");
|
||||
}
|
||||
|
||||
|
||||
bool TimeZone::SetTzDst(PT::Space & year)
|
||||
{
|
||||
time_t h24 = 60 * 60 * 24; // 24 hours
|
||||
bool result = true;
|
||||
Dst dst;
|
||||
|
||||
int year_int = Toi(year.name);
|
||||
|
||||
if( year_int < 1970 && year_int > 10000 )
|
||||
return false;
|
||||
|
||||
dst.has_dst = year.Bool(L"has_dst", false);
|
||||
|
||||
if( dst.has_dst )
|
||||
{
|
||||
dst.start.year = year_int;
|
||||
dst.end.year = year_int;
|
||||
|
||||
if( !dst.start.ParseMonthDayTime(year.Text(L"start")) )
|
||||
result = false;
|
||||
|
||||
if( !dst.end.ParseMonthDayTime(year.Text(L"end")) )
|
||||
result = false;
|
||||
|
||||
dst.offset = GetOffset(year);
|
||||
|
||||
if( dst.offset < -h24 || dst.offset > h24 )
|
||||
result = false;
|
||||
}
|
||||
|
||||
if( result )
|
||||
dst_map[year_int] = dst;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool TimeZone::SetTz(PT::Space & space)
|
||||
{
|
||||
bool result = true;
|
||||
name = space.name;
|
||||
id = space.Int(L"id", -1);
|
||||
offset = GetOffset(space);
|
||||
time_t h24 = 60 * 60 * 24; // 24 hours
|
||||
|
||||
if( offset < -h24 || offset > h24 )
|
||||
result = false;
|
||||
|
||||
PT::Space & dst = space.FindAddSpace(L"dst");
|
||||
|
||||
for(size_t i=0 ; i<dst.spaces.size() ; ++i)
|
||||
{
|
||||
PT::Space & year = *dst.spaces[i];
|
||||
|
||||
if( !SetTzDst(year) )
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
-326
@@ -1,326 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include "users.h"
|
||||
#include "sessionmanager.h"
|
||||
#include "plugin.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
Users::Users()
|
||||
{
|
||||
how_many_logged = 0; // !! CHECK ME may it should be moved to Clear() method?
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void Users::SetCur(Cur * pcur)
|
||||
{
|
||||
cur = pcur;
|
||||
}
|
||||
|
||||
|
||||
void Users::SetSessionManager(SessionManager * sm)
|
||||
{
|
||||
session_manager = sm;
|
||||
}
|
||||
|
||||
|
||||
void Users::Clear()
|
||||
{
|
||||
table.Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Users::ReadUsers(Db * db)
|
||||
{
|
||||
Clear();
|
||||
db->GetUsers(table);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Users::AddUser(const User & user)
|
||||
{
|
||||
Table::Iterator i = table.PushBack(user);
|
||||
|
||||
return (i != table.End());
|
||||
}
|
||||
|
||||
|
||||
bool Users::IsUser(const std::wstring & name)
|
||||
{
|
||||
return table.Is(name);
|
||||
}
|
||||
|
||||
|
||||
User * Users::GetUser(long user_id)
|
||||
{
|
||||
Table::Iterator i = table.FindId(user_id);
|
||||
|
||||
if( i == table.End() )
|
||||
return 0;
|
||||
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
User * Users::GetUser(const std::wstring & name)
|
||||
{
|
||||
Table::Iterator i = table.FindName(name);
|
||||
|
||||
if( i == table.End() )
|
||||
return 0;
|
||||
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
long Users::GetUserId(const std::wstring & name)
|
||||
{
|
||||
User * puser = GetUser(name);
|
||||
|
||||
if( !puser )
|
||||
return -1;
|
||||
|
||||
return puser->id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Users::Iterator Users::Begin()
|
||||
{
|
||||
return table.Begin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Users::Iterator Users::End()
|
||||
{
|
||||
return table.End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Users::SizeType Users::Size()
|
||||
{
|
||||
return table.Size();
|
||||
}
|
||||
|
||||
|
||||
bool Users::Remove(long user_id)
|
||||
{
|
||||
bool result = false;
|
||||
User * puser = GetUser(user_id);
|
||||
|
||||
if( puser )
|
||||
{
|
||||
LogoutUser(user_id);
|
||||
plugin.Call(WINIX_PREPARE_TO_REMOVE_USER, puser);
|
||||
result = table.Remove(user_id);
|
||||
|
||||
if( result )
|
||||
plugin.Call(WINIX_USER_REMOVED, user_id);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// private
|
||||
bool Users::LoginUserCheckSession(bool use_ses_log)
|
||||
{
|
||||
if( !cur->session )
|
||||
return false;
|
||||
|
||||
if( cur->session->id == 0 )
|
||||
{
|
||||
log << log1 << "Users: I cannot login a user on a temporary session" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"service_unavailable") << logend;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// private
|
||||
User * Users::LoginUserCheckStatus(long user_id, bool use_ses_log)
|
||||
{
|
||||
User * puser = GetUser(user_id);
|
||||
|
||||
if( !puser )
|
||||
{
|
||||
log << log1 << "Users: user id: " << user_id << " is not in system.users table" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T(L"service_unavailable") << logend;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( puser->status != WINIX_ACCOUNT_READY )
|
||||
{
|
||||
log << log1 << "Users: user id: " << user_id << " is not ready for logging in (status: "
|
||||
<< puser->status << ")" << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
{
|
||||
if( puser->status == WINIX_ACCOUNT_NOT_ACTIVATED )
|
||||
slog << logerror << T(L"account_not_activated") << logend;
|
||||
else
|
||||
if( puser->status == WINIX_ACCOUNT_SUSPENDED )
|
||||
slog << logerror << T(L"account_suspended") << logend;
|
||||
else
|
||||
if( puser->status == WINIX_ACCOUNT_BLOCKED )
|
||||
slog << logerror << T(L"account_banned") << logend;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return puser;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Users::LoginUser(long user_id, bool remember_me, bool use_ses_log)
|
||||
{
|
||||
if( !LoginUserCheckSession(use_ses_log) )
|
||||
return false;
|
||||
|
||||
User * puser = LoginUserCheckStatus(user_id, use_ses_log);
|
||||
|
||||
if( !puser )
|
||||
return false;
|
||||
|
||||
PluginRes res = plugin.Call(WINIX_PREPARE_USER_TO_LOGIN, puser);
|
||||
|
||||
if( res.res_false > 0 )
|
||||
{
|
||||
log << log3 << "Users: login prevented by a plugin" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( cur->session->puser )
|
||||
LogoutCurrentUser();
|
||||
|
||||
cur->session->puser = puser;
|
||||
cur->session->spam_score = 0;
|
||||
cur->session->remember_me = remember_me;
|
||||
|
||||
// change session id before last.UserLogin()
|
||||
if( !cur->session->new_session )
|
||||
session_manager->ChangeSessionId(cur->session->id);
|
||||
|
||||
last.UserLogin(user_id, cur->session->puser->name, cur->request->ip, cur->session->id);
|
||||
how_many_logged += 1;
|
||||
|
||||
log << log2 << "Users: user " << cur->session->puser->name << " (id: " << user_id << ") logged" << logend;
|
||||
plugin.Call(WINIX_USER_LOGGED);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
size_t Users::LogoutUser(long user_id)
|
||||
{
|
||||
size_t how_many = 0;
|
||||
User * puser = GetUser(user_id);
|
||||
|
||||
if( puser )
|
||||
{
|
||||
log << log2 << "Users: logging out user " << puser->name << ", id: "
|
||||
<< puser->id << " from all sessions" << logend;
|
||||
|
||||
// WINIX_PREPARE_USER_TO_LOGOUT will be sent by MarkAllSessionsToRemove()
|
||||
how_many = session_manager->MarkAllSessionsToRemove(user_id);
|
||||
how_many_logged -= how_many;
|
||||
|
||||
if( how_many )
|
||||
log << log3 << "Users: " << how_many << " user(s) were logged out" << logend;
|
||||
}
|
||||
|
||||
return how_many;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Users::LogoutCurrentUser()
|
||||
{
|
||||
if( !cur->session || !cur->session->puser )
|
||||
return;
|
||||
|
||||
log << log2 << "Users: user " << cur->session->puser->name << ", id: "
|
||||
<< cur->session->puser->id << " logged out" << logend;
|
||||
|
||||
plugin.Call(WINIX_PREPARE_USER_TO_LOGOUT, cur->session->puser);
|
||||
last.UserLogout(cur->session->puser->id, cur->session->id);
|
||||
|
||||
if( how_many_logged > 0 ) // for safety
|
||||
how_many_logged -= 1;
|
||||
|
||||
cur->session->puser = 0;
|
||||
cur->session->remember_me = false;
|
||||
}
|
||||
|
||||
|
||||
void Users::IncrementLoggedUsers()
|
||||
{
|
||||
how_many_logged += 1;
|
||||
}
|
||||
|
||||
|
||||
long Users::HowManyLogged()
|
||||
{
|
||||
return how_many_logged;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
|
||||
all: $(o)
|
||||
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $<
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. $(CXXWINIXINCLUDEFLAGS) -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
include Makefile.dep
|
||||
@@ -1,74 +0,0 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
db.o: db.h dbbase.h dbconn.h dbtextstream.h ../../winix/core/textstream.h
|
||||
db.o: ../../winix/core/misc.h ../../winix/core/item.h
|
||||
db.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
db.o: ../../pikotools/date/date.h ../../winix/core/requesttypes.h
|
||||
db.o: ../../pikotools/textstream/textstream.h
|
||||
db.o: ../../pikotools/convert/convert.h ../../pikotools/convert/inttostr.h
|
||||
db.o: ../../pikotools/membuffer/membuffer.h
|
||||
db.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
db.o: ../../winix/core/winix_const.h ../../winix/core/error.h
|
||||
db.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
db.o: dbitemquery.h ../../winix/core/item.h dbitemcolumns.h
|
||||
db.o: ../../winix/core/user.h ../../winix/core/group.h
|
||||
db.o: ../../winix/core/dircontainer.h ../../winix/core/ugcontainer.h
|
||||
db.o: ../../winix/core/log.h ../../winix/core/textstream.h
|
||||
db.o: ../../winix/core/logmanipulators.h ../../winix/core/slog.h
|
||||
db.o: ../../winix/core/cur.h ../../winix/core/request.h
|
||||
db.o: ../../winix/core/error.h ../../winix/core/config.h
|
||||
db.o: ../../winix/core/htmlfilter.h ../../winix/templates/htmltextstream.h
|
||||
db.o: ../../pikotools/space/spacetojson.h ../../winix/core/session.h
|
||||
db.o: ../../winix/core/user.h ../../winix/core/plugindata.h
|
||||
db.o: ../../winix/core/rebus.h ../../winix/core/ipban.h
|
||||
db.o: ../../winix/core/mount.h ../../winix/templates/locale.h
|
||||
db.o: ../../winix/core/log.h ../../winix/core/misc.h
|
||||
dbbase.o: dbbase.h dbconn.h dbtextstream.h ../../winix/core/textstream.h
|
||||
dbbase.o: ../../winix/core/misc.h ../../winix/core/item.h
|
||||
dbbase.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
dbbase.o: ../../pikotools/date/date.h ../../winix/core/requesttypes.h
|
||||
dbbase.o: ../../pikotools/textstream/textstream.h
|
||||
dbbase.o: ../../pikotools/convert/convert.h
|
||||
dbbase.o: ../../pikotools/convert/inttostr.h
|
||||
dbbase.o: ../../pikotools/membuffer/membuffer.h
|
||||
dbbase.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
dbbase.o: ../../winix/core/winix_const.h ../../winix/core/error.h
|
||||
dbbase.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
|
||||
dbbase.o: ../../winix/core/log.h ../../winix/core/misc.h
|
||||
dbconn.o: dbconn.h dbtextstream.h ../../winix/core/textstream.h
|
||||
dbconn.o: ../../winix/core/misc.h ../../winix/core/item.h
|
||||
dbconn.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h
|
||||
dbconn.o: ../../pikotools/date/date.h ../../winix/core/requesttypes.h
|
||||
dbconn.o: ../../pikotools/textstream/textstream.h
|
||||
dbconn.o: ../../pikotools/convert/convert.h
|
||||
dbconn.o: ../../pikotools/convert/inttostr.h
|
||||
dbconn.o: ../../pikotools/membuffer/membuffer.h
|
||||
dbconn.o: ../../pikotools/textstream/types.h ../../pikotools/utf8/utf8.h
|
||||
dbconn.o: ../../winix/core/winix_const.h ../../winix/core/log.h
|
||||
dbconn.o: ../../winix/core/error.h
|
||||
dbitemcolumns.o: dbitemcolumns.h ../../winix/core/item.h dbbase.h dbconn.h
|
||||
dbitemcolumns.o: dbtextstream.h ../../winix/core/textstream.h
|
||||
dbitemcolumns.o: ../../winix/core/misc.h ../../winix/core/item.h
|
||||
dbitemcolumns.o: ../../pikotools/space/space.h
|
||||
dbitemcolumns.o: ../../pikotools/textstream/types.h
|
||||
dbitemcolumns.o: ../../pikotools/date/date.h ../../winix/core/requesttypes.h
|
||||
dbitemcolumns.o: ../../pikotools/textstream/textstream.h
|
||||
dbitemcolumns.o: ../../pikotools/convert/convert.h
|
||||
dbitemcolumns.o: ../../pikotools/convert/inttostr.h
|
||||
dbitemcolumns.o: ../../pikotools/membuffer/membuffer.h
|
||||
dbitemcolumns.o: ../../pikotools/textstream/types.h
|
||||
dbitemcolumns.o: ../../pikotools/utf8/utf8.h ../../winix/core/winix_const.h
|
||||
dbitemcolumns.o: ../../winix/core/error.h ../../pikotools/space/spaceparser.h
|
||||
dbitemcolumns.o: ../../pikotools/space/space.h ../../winix/core/log.h
|
||||
dbitemquery.o: dbitemquery.h ../../winix/core/item.h
|
||||
dbtextstream.o: dbtextstream.h ../../winix/core/textstream.h
|
||||
dbtextstream.o: ../../winix/core/misc.h ../../winix/core/item.h
|
||||
dbtextstream.o: ../../pikotools/space/space.h
|
||||
dbtextstream.o: ../../pikotools/textstream/types.h
|
||||
dbtextstream.o: ../../pikotools/date/date.h ../../winix/core/requesttypes.h
|
||||
dbtextstream.o: ../../pikotools/textstream/textstream.h
|
||||
dbtextstream.o: ../../pikotools/convert/convert.h
|
||||
dbtextstream.o: ../../pikotools/convert/inttostr.h
|
||||
dbtextstream.o: ../../pikotools/membuffer/membuffer.h
|
||||
dbtextstream.o: ../../pikotools/textstream/types.h
|
||||
dbtextstream.o: ../../pikotools/utf8/utf8.h ../../winix/core/winix_const.h
|
||||
@@ -1 +0,0 @@
|
||||
o = db.o dbbase.o dbconn.o dbitemcolumns.o dbitemquery.o dbtextstream.o
|
||||
@@ -1,175 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_db_db
|
||||
#define headerfile_winix_db_db
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
#include "dbbase.h"
|
||||
#include "dbitemquery.h"
|
||||
#include "dbitemcolumns.h"
|
||||
#include "core/item.h"
|
||||
#include "core/user.h"
|
||||
#include "core/group.h"
|
||||
#include "core/dircontainer.h"
|
||||
#include "core/ugcontainer.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
class Db : public DbBase
|
||||
{
|
||||
public:
|
||||
|
||||
// !! przerobic tak aby GetItem zwracalo wszystkie pozycja
|
||||
// !! GetFile tylko dla plikow
|
||||
// !! GetDir tylko dla katalogow
|
||||
// !! GetFile i GetDir beda uzywac GetItem
|
||||
|
||||
Db() : item_cols(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool GetUserPass(const std::wstring & login, long & user_id, UserPass & up);
|
||||
Error AddUser(User & user, const UserPass & up);
|
||||
Error ChangeUserPass(long user_id, const UserPass & up);
|
||||
Error ChangeUserEnv(long user_id, const PT::Space & space);
|
||||
Error ChangeUserAdminEnv(long user_id, const PT::Space & space);
|
||||
Error ChangeUserStatus(long user_id, int status);
|
||||
Error ChangeUserEmail(long user_id, const std::wstring & email);
|
||||
Error ChangeUserLocale(long user_id, size_t locale_id);
|
||||
Error ChangeUserTimeZone(long user_id, size_t time_zone_id);
|
||||
Error RemoveUser(long user_id);
|
||||
|
||||
Error AddItem(Item & item);
|
||||
Error EditItemById(Item & item, bool with_url = true);
|
||||
Error EditItemByUrl(Item & item, bool with_url = true);
|
||||
|
||||
|
||||
|
||||
// !! nie zwracac zadnych kodow bledow?
|
||||
void GetItems(std::vector<Item> & item_tab, const DbItemQuery & item_query);
|
||||
void GetItems(std::vector<long> & item_tab, const DbItemQuery & item_query);
|
||||
Error GetItem(Item & item, const DbItemQuery & item_query);
|
||||
|
||||
bool GetPriv(Item & item, long id);
|
||||
Error EditPrivById(Item & item, long id); // !! dlaczego tu nie ma const?
|
||||
Error EditParentUrlById(Item & item, long id);
|
||||
Error EditFileById(const Item & item, long id); // file_path, file_fs, file_type
|
||||
Error EditHasThumbById(bool has_thumb, long id);
|
||||
Error EditMetaById(const PT::Space & meta, long id);
|
||||
Error EditAdminMetaById(const PT::Space & meta, long id);
|
||||
|
||||
Error DelDirById(long id);
|
||||
Error DelFileById(long file_id);
|
||||
Error DelSymlinkById(long symlink_id);
|
||||
|
||||
Error EditSubjectById(Item & item, long id);
|
||||
|
||||
|
||||
Error DelItem(const Item & item);
|
||||
void GetDirs(DirContainer & dir_tab);
|
||||
void GetUsers(UGContainer<User> & user_tab);
|
||||
void GetGroups(UGContainer<Group> & group_tab);
|
||||
|
||||
// !! 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::wstring & url, Item & item);
|
||||
Error EditLinkItem(long id, const std::wstring & link_to, int link_redirect);
|
||||
Error EditTemplateItemById(long id, const std::wstring & new_html_template);
|
||||
|
||||
long GetItemId(long parent_id, const std::wstring & url, Item::Type type);
|
||||
long GetFileId(long parent_id, const std::wstring & url);
|
||||
long GetDirId(long parent_id, const std::wstring & url);
|
||||
|
||||
Error AddHardLink(Item & item);
|
||||
Error EditSortIndexItemById(long id, int sort_index);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
DbTextStream query, query_create_url;
|
||||
std::wstring temp_url;
|
||||
Item dir_temp;
|
||||
Item get_item_temp;
|
||||
std::wstring iq_id_list;
|
||||
DbItemColumns item_cols;
|
||||
|
||||
|
||||
bool AddItemCreateUrlSubject(Item & item);
|
||||
|
||||
Error AddItemIntoContent(Item & item);
|
||||
Error AddItemIntoItem(Item & item);
|
||||
|
||||
Error EditItemInItem(Item & item, bool with_url);
|
||||
Error EditItemInContent(Item & item);
|
||||
Error EditItemGetIdsByUrl(Item & item);
|
||||
long GetContentId(long item_id);
|
||||
|
||||
|
||||
Error DelItemDelItem(long item_id, int type);
|
||||
Error DelItemDelContent(long content_id);
|
||||
|
||||
Error IncrementContentRef(long content_id);
|
||||
Error DecrementContentRef(long content_id);
|
||||
|
||||
void GetItemsQuerySelect(const DbItemQuery & iq, DbTextStream & query, bool skip_other_sel);
|
||||
void GetItemsQueryJoin(const DbItemQuery & iq, DbTextStream & query);
|
||||
void GetItemsQueryWhere(const DbItemQuery & iq, DbTextStream & query);
|
||||
void GetItemsQueryOrder(const DbItemQuery & iq, DbTextStream & query);
|
||||
void GetItemsQueryLimit(const DbItemQuery & iq, DbTextStream & query);
|
||||
PGresult * GetItemsQuery(const DbItemQuery & iq, DbTextStream & query, bool skip_other_sel = false);
|
||||
PGresult * GetItemsQuery(const DbItemQuery & iq, bool skip_other_sel = false);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
-626
@@ -1,626 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <limits>
|
||||
#include "dbbase.h"
|
||||
#include "core/log.h"
|
||||
#include "core/error.h"
|
||||
#include "core/misc.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
DbBase::DbBase()
|
||||
{
|
||||
db_conn = 0;
|
||||
log_queries = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbBase::SetConn(DbConn * conn)
|
||||
{
|
||||
db_conn = conn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbBase::SetConn(DbConn & conn)
|
||||
{
|
||||
db_conn = &conn;
|
||||
}
|
||||
|
||||
|
||||
DbConn * DbBase::GetConn()
|
||||
{
|
||||
return db_conn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbBase::LogQueries(bool log_q)
|
||||
{
|
||||
log_queries = log_q;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PGresult * DbBase::AssertQuery(const char * q)
|
||||
{
|
||||
if( log_queries )
|
||||
log << log1 << "Db: executing query: " << q << logend;
|
||||
|
||||
bool bad_query = false;
|
||||
PGresult * r = PQexec(db_conn->GetPgConn(), q);
|
||||
|
||||
if( !r )
|
||||
{
|
||||
bad_query = true;
|
||||
|
||||
if( PQstatus(db_conn->GetPgConn()) != CONNECTION_OK )
|
||||
{
|
||||
db_conn->AssertConnection();
|
||||
r = PQexec(db_conn->GetPgConn(), q);
|
||||
|
||||
if( r )
|
||||
bad_query = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( bad_query )
|
||||
{
|
||||
log << log1 << "Db: Problem with this query: \"" << q << '\"' << logend;
|
||||
log << log1 << "Db: " << PQerrorMessage(db_conn->GetPgConn()) << logend;
|
||||
|
||||
throw Error(WINIX_ERR_DB_INCORRECT_QUERY);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
PGresult * DbBase::AssertQuery(const DbTextStream & query)
|
||||
{
|
||||
return AssertQuery(query.CStr());
|
||||
}
|
||||
|
||||
|
||||
|
||||
PGresult * DbBase::AssertQuery(const char * q, ExecStatusType t)
|
||||
{
|
||||
PGresult * r = AssertQuery(q);
|
||||
AssertResult(r, t);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
PGresult * DbBase::AssertQuery(const DbTextStream & query, ExecStatusType t)
|
||||
{
|
||||
return AssertQuery(query.CStr(), t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbBase::AssertResult(PGresult * r, ExecStatusType t)
|
||||
{
|
||||
if( PQresultStatus(r) != t )
|
||||
{
|
||||
log << log1 << "Db: Incorrect result status: " << PQerrorMessage(db_conn->GetPgConn()) << logend;
|
||||
|
||||
throw Error(WINIX_ERR_DB_INCORRENT_RESULT_STATUS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DbBase::AssertColumn(PGresult * r, const char * column_name)
|
||||
{
|
||||
int c = PQfnumber(r, column_name);
|
||||
|
||||
if( c == -1 )
|
||||
{
|
||||
log << log1 << "Db: there is no column: " << column_name << logend;
|
||||
throw Error(WINIX_ERR_DB_NO_COLUMN);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
const char * DbBase::AssertValue(PGresult * r, int row, int col)
|
||||
{
|
||||
const char * res = PQgetvalue(r, row, col);
|
||||
|
||||
if( !res )
|
||||
{
|
||||
log << log1 << "Db: there is no such an item in the result, row:" << row << ", col:" << col << logend;
|
||||
throw Error(WINIX_ERR_NO_ITEM);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
const std::wstring & DbBase::AssertValueWide(PGresult * r, int row, int col)
|
||||
{
|
||||
const char * res = AssertValue(r, row, col);
|
||||
static std::wstring temp_wide_value; // !! IMPROVE ME add as a class field (nonstatic)
|
||||
|
||||
PT::UTF8ToWide(res, temp_wide_value);
|
||||
|
||||
return temp_wide_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
|
||||
{
|
||||
result.clear();
|
||||
|
||||
const char * res = AssertValue(r, row, col);
|
||||
int len = PQgetlength(r, row, col);
|
||||
|
||||
if( len <= 0 )
|
||||
return;
|
||||
|
||||
UnescapeBin(res, len, result);
|
||||
}
|
||||
|
||||
|
||||
void DbBase::AssertValueWide(PGresult * r, int row, int col, std::wstring & result)
|
||||
{
|
||||
const char * res = AssertValue(r, row, col);
|
||||
PT::UTF8ToWide(res, result);
|
||||
}
|
||||
|
||||
|
||||
long DbBase::AssertValueLong(PGresult * r, int row, int col)
|
||||
{
|
||||
return strtol( AssertValue(r, row, col), 0, 10 );
|
||||
}
|
||||
|
||||
|
||||
int DbBase::AssertValueInt(PGresult * r, int row, int col)
|
||||
{
|
||||
return (int)strtol( AssertValue(r, row, col), 0, 10 );
|
||||
}
|
||||
|
||||
|
||||
bool DbBase::AssertValueBool(PGresult * r, int row, int col)
|
||||
{
|
||||
const char * s = AssertValue(r, row, col);
|
||||
return (s[0]=='t' || s[0]=='y' || s[0]=='1');
|
||||
}
|
||||
|
||||
|
||||
unsigned long DbBase::AssertValueULong(PGresult * r, int row, int col)
|
||||
{
|
||||
return strtoul( AssertValue(r, row, col), 0, 10 );
|
||||
}
|
||||
|
||||
|
||||
unsigned int DbBase::AssertValueUInt(PGresult * r, int row, int col)
|
||||
{
|
||||
return (unsigned int)strtoul( AssertValue(r, row, col), 0, 10 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
PT::Date DbBase::AssertValueDate(PGresult * r, int row, int col)
|
||||
{
|
||||
PT::Date date = AssertValue(r, row, col);
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
bool DbBase::AssertValueSpace(PGresult * r, int row, int col, PT::Space & space, bool split_single)
|
||||
{
|
||||
const char * res = AssertValue(r, row, col);
|
||||
|
||||
conf_parser.SplitSingle(split_single);
|
||||
conf_parser.SetSpace(space);
|
||||
space.Clear();
|
||||
|
||||
PT::SpaceParser::Status status = conf_parser.ParseString(res);
|
||||
|
||||
if( status != PT::SpaceParser::ok )
|
||||
{
|
||||
log << log1 << "Db: a problem with parsing a PT::Space";
|
||||
|
||||
if( status == PT::SpaceParser::syntax_error )
|
||||
log << ", syntax error at line: " << conf_parser.line;
|
||||
|
||||
log << logend;
|
||||
|
||||
space.Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DbBase::ClearResult(PGresult * r)
|
||||
{
|
||||
if( r )
|
||||
PQclear(r);
|
||||
}
|
||||
|
||||
|
||||
bool DbBase::IsNull(PGresult * r, int row, int col)
|
||||
{
|
||||
return PQgetisnull(r, row, col) == 1;
|
||||
}
|
||||
|
||||
|
||||
int DbBase::Rows(PGresult * r)
|
||||
{
|
||||
// PQntuples - Returns the number of rows (tuples) in the query result. Because it returns
|
||||
// an integer result, large result sets might overflow the return value on 32-bit operating systems.
|
||||
return PQntuples(r);
|
||||
}
|
||||
|
||||
|
||||
int DbBase::Cols(PGresult * r)
|
||||
{
|
||||
// PQnfields - Returns the number of columns (fields) in each row of the query result.
|
||||
return PQnfields(r);
|
||||
}
|
||||
|
||||
|
||||
long DbBase::AffectedRows(PGresult * r)
|
||||
{
|
||||
// PQcmdTuples - This function returns a string containing the number of rows affected by the SQL
|
||||
// statement that generated the PGresult. This function can only be used following the execution
|
||||
// of an INSERT, UPDATE, DELETE, MOVE, FETCH, or COPY statement, or [...]
|
||||
char * rows_str = PQcmdTuples(r); // can be an empty string
|
||||
long rows = 0;
|
||||
|
||||
if( rows_str )
|
||||
{
|
||||
rows = strtol(rows_str, 0, 10);
|
||||
// strtol - If an overflow or underflow occurs, errno is set to ERANGE
|
||||
// and the function return value is clamped according to the following table:
|
||||
// Function underflow overflow
|
||||
// strtol() LONG_MIN LONG_MAX
|
||||
|
||||
if( rows < 0 )
|
||||
rows = 0;
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
long DbBase::AssertCurrval(const char * table)
|
||||
{
|
||||
PGresult * r;
|
||||
|
||||
bquery.Clear();
|
||||
bquery << R("select currval(")
|
||||
<< table
|
||||
<< R(");");
|
||||
|
||||
r = AssertQuery(bquery);
|
||||
AssertResult(r, PGRES_TUPLES_OK);
|
||||
|
||||
if( Rows(r) != 1 )
|
||||
{
|
||||
log << log1 << "Db: error (currval) for table: " << table << ", " << PQerrorMessage(db_conn->GetPgConn()) << logend;
|
||||
throw Error(WINIX_ERR_DB_ERR_CURRVAL);
|
||||
}
|
||||
|
||||
return AssertValueLong(r, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void DbBase::CreateIdList(const std::vector<long> & id_tab, std::wstring & list, bool add_parentheses)
|
||||
{
|
||||
wchar_t buffer[50];
|
||||
size_t buffer_len = sizeof(buffer) / sizeof(wchar_t);
|
||||
|
||||
list.clear();
|
||||
|
||||
if( add_parentheses )
|
||||
list += '(';
|
||||
|
||||
for(size_t i=0 ; i<id_tab.size() ; ++i)
|
||||
{
|
||||
Toa((unsigned long)id_tab[i], buffer, buffer_len);
|
||||
list += buffer;
|
||||
|
||||
if( i+1 < id_tab.size() )
|
||||
list += ',';
|
||||
}
|
||||
|
||||
if( add_parentheses )
|
||||
list += ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Error DbBase::DoCommand(const DbTextStream & command)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
|
||||
try
|
||||
{
|
||||
r = AssertQuery(command);
|
||||
AssertResult(r, PGRES_COMMAND_OK);
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Error DbBase::DoCommand(const char * command)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
|
||||
try
|
||||
{
|
||||
r = AssertQuery(command);
|
||||
AssertResult(r, PGRES_COMMAND_OK);
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
status = e;
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Error DbBase::BeginTrans()
|
||||
{
|
||||
return DoCommand("BEGIN;");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Error DbBase::RollbackTrans()
|
||||
{
|
||||
return DoCommand("ROLLBACK;");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Error DbBase::CommitTrans()
|
||||
{
|
||||
return DoCommand("COMMIT;");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DbBase::EndTrans(bool everything_ok)
|
||||
{
|
||||
bool result;
|
||||
|
||||
if( everything_ok )
|
||||
{
|
||||
result = (CommitTrans() == WINIX_ERR_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
RollbackTrans();
|
||||
// we return the old err code
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Error DbBase::EndTrans(Error err)
|
||||
{
|
||||
if( err == WINIX_ERR_OK )
|
||||
{
|
||||
err = CommitTrans();
|
||||
}
|
||||
else
|
||||
{
|
||||
// we return the old err code
|
||||
RollbackTrans();
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
converting from a bytea
|
||||
the old way (escape format)
|
||||
*/
|
||||
/*
|
||||
int DbBase::CharToInt(char c)
|
||||
{
|
||||
return (int)(unsigned char)(c-'0');
|
||||
}
|
||||
|
||||
bool DbBase::IsCorrectOctalDigit(char c)
|
||||
{
|
||||
return c>='0' && c<='7';
|
||||
}
|
||||
|
||||
// moves 'i' at least once
|
||||
// return -1 if there is en error
|
||||
int DbBase::UnescapeBin(const char * str, size_t & i, size_t len)
|
||||
{
|
||||
if( str[i] != '\\' )
|
||||
return str[i++];
|
||||
|
||||
i += 1;
|
||||
|
||||
if( i >= len )
|
||||
return -1;
|
||||
|
||||
if( str[i] == '\\' )
|
||||
return str[i++];
|
||||
|
||||
if( i+2 >= len )
|
||||
{
|
||||
i = len;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( !IsCorrectOctalDigit(str[i]) ||
|
||||
!IsCorrectOctalDigit(str[i+1]) ||
|
||||
!IsCorrectOctalDigit(str[i+2]) )
|
||||
{
|
||||
i += 3;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int c = 8*8*CharToInt(str[i]) + 8*CharToInt(str[i+1]) + CharToInt(str[i+2]);
|
||||
|
||||
i += 3;
|
||||
|
||||
if( c<0 || c>255 )
|
||||
return -1;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void DbBase::UnescapeBin(const char * str, size_t len, std::string & out, bool clear_out)
|
||||
{
|
||||
int c;
|
||||
size_t i = 0;
|
||||
|
||||
if( clear_out )
|
||||
out.clear();
|
||||
|
||||
while( i < len )
|
||||
{
|
||||
c = UnescapeBin(str, i, len);
|
||||
|
||||
if( c != -1 )
|
||||
out += c;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
converting from a bytea
|
||||
the new way (hex format)
|
||||
*/
|
||||
|
||||
|
||||
char DbBase::UnescapeBinHexToDigit(char hex)
|
||||
{
|
||||
if( hex>='0' && hex<='9' )
|
||||
return hex - '0';
|
||||
|
||||
if( hex>='a' && hex<='z' )
|
||||
return hex - 'a' + 10;
|
||||
|
||||
if( hex>='A' && hex<='Z' )
|
||||
return hex - 'A' + 10;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void DbBase::UnescapeBin(const char * str, size_t len, std::string & out, bool clear_out)
|
||||
{
|
||||
if( clear_out )
|
||||
out.clear();
|
||||
|
||||
if( len < 2 || str[0]!='\\' || str[1]!='x' )
|
||||
{
|
||||
log << log1 << "Db: unsupported binary format (skipping)" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
for(size_t i=2 ; i + 1 < len ; i+=2 )
|
||||
{
|
||||
int c1 = UnescapeBinHexToDigit(str[i]);
|
||||
int c2 = UnescapeBinHexToDigit(str[i+1]);
|
||||
|
||||
out += ((c1 << 4) | c2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
end of converting from bytea
|
||||
*/
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
-143
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_db_dbbase
|
||||
#define headerfile_winix_db_dbbase
|
||||
|
||||
|
||||
#include "dbconn.h"
|
||||
#include "dbtextstream.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "core/error.h"
|
||||
#include "space/spaceparser.h"
|
||||
#include "date/date.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class DbBase
|
||||
{
|
||||
public:
|
||||
|
||||
DbBase();
|
||||
|
||||
void SetConn(DbConn * conn);
|
||||
void SetConn(DbConn & conn);
|
||||
DbConn * GetConn();
|
||||
|
||||
void LogQueries(bool log_q);
|
||||
|
||||
PGresult * AssertQuery(const char * query);
|
||||
PGresult * AssertQuery(const DbTextStream & query);
|
||||
PGresult * AssertQuery(const char * q, ExecStatusType t);
|
||||
PGresult * AssertQuery(const DbTextStream & query, ExecStatusType t);
|
||||
void AssertResult(PGresult * r, ExecStatusType t);
|
||||
static int AssertColumn(PGresult * r, const char * column_name);
|
||||
|
||||
// static assignments
|
||||
static const char * AssertValue(PGresult * r, int row, int col);
|
||||
static const std::wstring & AssertValueWide(PGresult * r, int row, int col); // warning: this method uses a static buffer
|
||||
static void AssertValueWide(PGresult * r, int row, int col, std::wstring & result);
|
||||
static void AssertValueBin(PGresult * r, int row, int col, std::string & result);
|
||||
static long AssertValueLong(PGresult * r, int row, int col);
|
||||
static int AssertValueInt(PGresult * r, int row, int col);
|
||||
static bool AssertValueBool(PGresult * r, int row, int col);
|
||||
static unsigned long AssertValueULong(PGresult * r, int row, int col);
|
||||
static unsigned int AssertValueUInt(PGresult * r, int row, int col);
|
||||
static PT::Date AssertValueDate(PGresult * r, int row, int col);
|
||||
|
||||
// non static assignments
|
||||
bool AssertValueSpace(PGresult * r, int row, int col, PT::Space & space, bool split_single = true);
|
||||
|
||||
void ClearResult(PGresult * r);
|
||||
long AssertCurrval(const char * table);
|
||||
|
||||
bool IsNull(PGresult * r, int row, int col);
|
||||
int Rows(PGresult * r);
|
||||
int Cols(PGresult * r);
|
||||
long AffectedRows(PGresult * r);
|
||||
|
||||
void CreateIdList(const std::vector<long> & id_tab, std::wstring & list, bool add_parentheses = true);
|
||||
|
||||
Error DoCommand(const DbTextStream & command);
|
||||
Error DoCommand(const char * command);
|
||||
Error BeginTrans();
|
||||
Error RollbackTrans();
|
||||
Error CommitTrans();
|
||||
Error EndTrans(Error err);
|
||||
|
||||
// new API (returns only bool)
|
||||
bool EndTrans(bool everything_ok);
|
||||
|
||||
static void UnescapeBin(const char * str, size_t len, std::string & out, bool clear_out = true);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// a helper method for escaping strings
|
||||
template<class RawType>
|
||||
DbTextStream::RawText<RawType> R(const RawType & par)
|
||||
{
|
||||
return DbTextStream::RawText<RawType>(par);
|
||||
}
|
||||
|
||||
DbConn * db_conn;
|
||||
bool log_queries;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// static int CharToInt(char c);
|
||||
// static bool IsCorrectOctalDigit(char c);
|
||||
// static int UnescapeBin(const char * str, size_t & i, size_t len);
|
||||
|
||||
static char UnescapeBinHexToDigit(char hex);
|
||||
|
||||
DbTextStream bquery;
|
||||
PT::SpaceParser conf_parser;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
-186
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "dbconn.h"
|
||||
#include "core/log.h"
|
||||
#include "core/error.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
DbConn::DbConn()
|
||||
{
|
||||
pg_conn = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DbConn::~DbConn()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
PGconn * DbConn::GetPgConn()
|
||||
{
|
||||
return pg_conn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbConn::SetConnParam(const std::wstring & d, const std::wstring & u, const std::wstring & p)
|
||||
{
|
||||
db_database = d;
|
||||
db_user = u;
|
||||
db_pass = p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbConn::Connect()
|
||||
{
|
||||
Close();
|
||||
|
||||
conn_info.Clear();
|
||||
conn_info.SetExtented(false);
|
||||
|
||||
conn_info << R("dbname=") << db_database
|
||||
<< R(" user=") << db_user
|
||||
<< R(" password=") << db_pass;
|
||||
|
||||
pg_conn = PQconnectdb(conn_info.CStr());
|
||||
|
||||
// warning! pg_conn can be not null but there cannnot be a connection established
|
||||
// use PQstatus(pg_conn) to check whether the connection works fine
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbConn::LogConnectionSocket()
|
||||
{
|
||||
log << log2 << "Db: connection to the database works fine" << logend;
|
||||
log << log3 << "Db: connection socket: " << PQsocket(pg_conn) << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbConn::WaitForConnection()
|
||||
{
|
||||
if( !pg_conn || PQstatus(pg_conn) != CONNECTION_OK )
|
||||
{
|
||||
log << log3 << "Db: waiting for the db to be ready...." << logend << logsave;
|
||||
|
||||
while( !AssertConnection(false, false) )
|
||||
sleep(5);
|
||||
|
||||
LogConnectionSocket();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbConn::Close()
|
||||
{
|
||||
if( pg_conn )
|
||||
{
|
||||
PQfinish(pg_conn);
|
||||
pg_conn = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DbConn::AssertConnection(bool put_log, bool throw_if_no_connection)
|
||||
{
|
||||
bool was_connection = true;
|
||||
|
||||
|
||||
if( !pg_conn )
|
||||
{
|
||||
was_connection = false;
|
||||
Connect();
|
||||
}
|
||||
else
|
||||
if( PQstatus(pg_conn) != CONNECTION_OK )
|
||||
{
|
||||
if( put_log )
|
||||
log << log2 << "Db: connection to the database is lost, trying to recover" << logend;
|
||||
|
||||
was_connection = false;
|
||||
PQreset(pg_conn);
|
||||
}
|
||||
|
||||
|
||||
if( pg_conn && PQstatus(pg_conn) == CONNECTION_OK )
|
||||
{
|
||||
if( !was_connection )
|
||||
{
|
||||
if( put_log )
|
||||
LogConnectionSocket();
|
||||
|
||||
SetDbParameters();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( put_log )
|
||||
log << log1 << "Db: connection to db server cannot be established" << logend;
|
||||
|
||||
if( throw_if_no_connection )
|
||||
throw Error(WINIX_ERR_DB_FATAL_ERROR_DURING_CONNECTING);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbConn::SetDbParameters()
|
||||
{
|
||||
if( PQsetClientEncoding(pg_conn, "UTF8") == -1 )
|
||||
log << log1 << "Db: Can't set the proper client encoding" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "dbitemcolumns.h"
|
||||
#include "dbbase.h"
|
||||
#include "core/log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
void DbItemColumns::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");
|
||||
link_to = PQfnumber(r, "link_to");
|
||||
link_redirect = PQfnumber(r, "link_redirect");
|
||||
subject = PQfnumber(r, "subject");
|
||||
content = PQfnumber(r, "content");
|
||||
content_type = PQfnumber(r, "content_type");
|
||||
guest_name = PQfnumber(r, "guest_name");
|
||||
html_template = PQfnumber(r, "template");
|
||||
modification_user_id = PQfnumber(r, "modification_user_id");
|
||||
file_path = PQfnumber(r, "file_path");
|
||||
file_fs = PQfnumber(r, "file_fs");
|
||||
file_type = PQfnumber(r, "file_type");
|
||||
has_thumb = PQfnumber(r, "has_thumb");
|
||||
hash = PQfnumber(r, "hash");
|
||||
hash_type = PQfnumber(r, "hash_type");
|
||||
file_size = PQfnumber(r, "file_size");
|
||||
ref = PQfnumber(r, "ref");
|
||||
modify_index = PQfnumber(r, "modify_index");
|
||||
sort_index = PQfnumber(r, "sort_index");
|
||||
meta = PQfnumber(r, "meta");
|
||||
ameta = PQfnumber(r, "ameta");
|
||||
}
|
||||
|
||||
|
||||
void DbItemColumns::SetItem(PGresult * r, long row, Item & item)
|
||||
{
|
||||
if( id != -1 ) item.id = DbBase::AssertValueLong(r, row, id);
|
||||
if( user_id != -1 ) item.user_id = DbBase::AssertValueLong(r, row, user_id);
|
||||
if( group_id != -1 ) item.group_id = DbBase::AssertValueLong(r, row, group_id);
|
||||
if( privileges != -1 ) item.privileges = DbBase::AssertValueInt(r, row, privileges);
|
||||
if( date_creation != -1 ) item.date_creation = DbBase::AssertValueDate(r, row, date_creation);
|
||||
if( date_modification != -1 ) item.date_modification = DbBase::AssertValueDate(r, row, date_modification);
|
||||
if( type != -1 ) item.type = static_cast<Item::Type>( DbBase::AssertValueInt(r, row, type) );
|
||||
if( parent_id != -1 ) item.parent_id = DbBase::AssertValueLong(r, row, parent_id);
|
||||
if( content_id != -1 ) item.content_id = DbBase::AssertValueLong(r, row, content_id);
|
||||
if( link_redirect != -1 ) item.link_redirect = DbBase::AssertValueInt(r, row, link_redirect);
|
||||
if( content_type != -1 ) item.content_type = static_cast<Item::ContentType>( DbBase::AssertValueInt(r, row, content_type) );
|
||||
if( modification_user_id != -1 ) item.modification_user_id = DbBase::AssertValueLong(r, row, modification_user_id);
|
||||
if( file_fs != -1 ) item.file_fs = DbBase::AssertValueInt(r, row, file_fs);
|
||||
if( file_type != -1 ) item.file_type = DbBase::AssertValueInt(r, row, file_type);
|
||||
if( has_thumb != -1 ) item.has_thumb = DbBase::AssertValueBool(r, row, has_thumb);
|
||||
if( hash != -1 ) DbBase::AssertValueWide(r, row, hash, item.hash);
|
||||
if( hash_type != -1 ) item.hash_type = DbBase::AssertValueInt(r, row, hash_type);
|
||||
if( file_size != -1 ) item.file_size = DbBase::AssertValueLong(r, row, file_size);
|
||||
|
||||
if( ref != -1 ) item.ref = DbBase::AssertValueInt(r, row, ref);
|
||||
if( modify_index != -1 ) item.modify_index = DbBase::AssertValueInt(r, row, modify_index);
|
||||
|
||||
if( url != -1 ) DbBase::AssertValueWide(r, row, url, item.url);
|
||||
if( content != -1 ) DbBase::AssertValueWide(r, row, content, item.content);
|
||||
if( subject != -1 ) DbBase::AssertValueWide(r, row, subject, item.subject);
|
||||
if( file_path != -1 ) DbBase::AssertValueWide(r, row, file_path, item.file_path);
|
||||
if( link_to != -1 ) DbBase::AssertValueWide(r, row, link_to, item.link_to);
|
||||
if( guest_name != -1 ) DbBase::AssertValueWide(r, row, guest_name, item.guest_name);
|
||||
if( html_template != -1 ) DbBase::AssertValueWide(r, row, html_template, item.html_template);
|
||||
if( sort_index != -1 ) item.sort_index = DbBase::AssertValueInt(r, row, sort_index);
|
||||
|
||||
if( meta != -1 ) db_base.AssertValueSpace(r, row, meta, item.meta);
|
||||
if( ameta != -1 ) db_base.AssertValueSpace(r, row, ameta, item.ameta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "dbitemquery.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
DbItemQuery::DbItemQuery()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void DbItemQuery::Clear()
|
||||
{
|
||||
sort_asc = true;
|
||||
|
||||
SetAll(true, false);
|
||||
|
||||
id = -1;
|
||||
id_tab = 0;
|
||||
parent_id = -1;
|
||||
type = Item::none;
|
||||
file_type = WINIX_ITEM_FILETYPE_NONE;
|
||||
|
||||
type_equal = true;
|
||||
file_type_equal = true;
|
||||
|
||||
limit = 0; // limit and offset not used by default
|
||||
offset = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbItemQuery::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_link = sel;
|
||||
sel_file = sel;
|
||||
sel_html_template = sel;
|
||||
sel_sort_index = sel;
|
||||
sel_meta = sel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbItemQuery::SetAllWhere(bool where_)
|
||||
{
|
||||
where_id = where_;
|
||||
where_parent_id = where_;
|
||||
where_type = where_;
|
||||
where_file_type = where_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbItemQuery::SetAll(bool sel, bool where_)
|
||||
{
|
||||
SetAllSel(sel);
|
||||
SetAllWhere(where_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbItemQuery::WhereId(long id_)
|
||||
{
|
||||
where_id = true;
|
||||
id = id_;
|
||||
}
|
||||
|
||||
|
||||
void DbItemQuery::WhereIdIn(const std::vector<long> & id_tab_list)
|
||||
{
|
||||
id_tab = &id_tab_list;
|
||||
}
|
||||
|
||||
|
||||
void DbItemQuery::WhereParentId(long parent_id_)
|
||||
{
|
||||
where_parent_id = true;
|
||||
parent_id = parent_id_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbItemQuery::WhereType(Item::Type type_, bool equal)
|
||||
{
|
||||
where_type = true;
|
||||
type = type_;
|
||||
type_equal = equal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DbItemQuery::WhereFileType(int file_t, bool equal)
|
||||
{
|
||||
where_file_type = true;
|
||||
file_type = file_t;
|
||||
file_type_equal = equal;
|
||||
}
|
||||
|
||||
|
||||
void DbItemQuery::Limit(long l)
|
||||
{
|
||||
limit = l;
|
||||
}
|
||||
|
||||
|
||||
void DbItemQuery::Offset(long o)
|
||||
{
|
||||
offset = o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_db_dbitemquery
|
||||
#define headerfile_winix_db_dbitemquery
|
||||
|
||||
#include <vector>
|
||||
#include "core/item.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
struct DbItemQuery
|
||||
{
|
||||
// id and content_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, ref, modify_index
|
||||
bool sel_url; // url
|
||||
bool sel_type; // type (dir, file, none)
|
||||
bool sel_link; // link_to, link_redirect
|
||||
bool sel_file; // file_path, file_fs, file_type, has_thumb, hash, hash_type, file_size
|
||||
bool sel_html_template; // template
|
||||
bool sel_sort_index; // sort_index
|
||||
bool sel_meta; // meta and ameta (PT::Space)
|
||||
|
||||
bool where_id; //
|
||||
bool where_parent_id; //
|
||||
bool where_type;
|
||||
bool where_file_type;
|
||||
|
||||
long id; // if where_id is true
|
||||
long parent_id; // if where_parent_id is true
|
||||
Item::Type type;
|
||||
bool type_equal;
|
||||
int file_type;
|
||||
bool file_type_equal; // if true means file_type should be equal
|
||||
bool sort_asc;
|
||||
|
||||
const std::vector<long> * id_tab; // != 0 if WhereIdIn was used
|
||||
|
||||
long limit;
|
||||
long offset;
|
||||
|
||||
DbItemQuery();
|
||||
void Clear();
|
||||
|
||||
void SetAllSel(bool sel);
|
||||
void SetAllWhere(bool where_);
|
||||
void SetAll(bool sel, bool where_);
|
||||
|
||||
void WhereId(long id_);
|
||||
void WhereIdIn(const std::vector<long> & id_tab_list);
|
||||
void WhereParentId(long parent_id_);
|
||||
void WhereType(Item::Type type_, bool equal = true);
|
||||
void WhereFileType(int file_t, bool equal = true);
|
||||
|
||||
void Limit(long l); // setting 0 turns off
|
||||
void Offset(long o); // setting 0 turns off
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,613 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "dbtextstream.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
DbTextStream::DbTextStream()
|
||||
{
|
||||
was_param = false;
|
||||
ext_escape = true;
|
||||
}
|
||||
|
||||
|
||||
void DbTextStream::SetExtented(bool ext)
|
||||
{
|
||||
ext_escape = ext;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
without escaping
|
||||
*/
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const char * str)
|
||||
{
|
||||
TextStream<std::string>::operator<<(str);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const std::string * str)
|
||||
{
|
||||
return PutText(str->c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const std::string & str)
|
||||
{
|
||||
return PutText(str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const wchar_t * str)
|
||||
{
|
||||
TextStream<std::string>::operator<<(str);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const std::wstring * str)
|
||||
{
|
||||
return PutText(str->c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const std::wstring & str)
|
||||
{
|
||||
return PutText(str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<const char*> raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<const wchar_t*> raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<const std::string*> raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<const std::wstring*> raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<std::string> raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<std::wstring> raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<bool> raw)
|
||||
{
|
||||
if( raw.par )
|
||||
PutText("true");
|
||||
else
|
||||
PutText("false");
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<char> raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<wchar_t> raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<int> raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<long> raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<unsigned int> raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<unsigned long> raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<double> raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<void*> raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<PT::Date> date)
|
||||
{
|
||||
tmp_stream.Clear();
|
||||
date.par.Serialize(tmp_stream);
|
||||
PT::WideToUTF8(tmp_stream.CStr(), buffer, false);
|
||||
tmp_stream.Clear();
|
||||
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
with escaping
|
||||
*/
|
||||
|
||||
|
||||
// get hex digit for c_ between <0, 15>
|
||||
char DbTextStream::EBinGetHex(char c)
|
||||
{
|
||||
if( c < 10 )
|
||||
return c + '0';
|
||||
|
||||
return c - 10 + 'A';
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EBinPutChar(char c)
|
||||
{
|
||||
buffer += EBinGetHex(((unsigned char)c) >> 4);
|
||||
buffer += EBinGetHex(((unsigned char)c) & 0x0f);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::ETextPutChar(char c)
|
||||
{
|
||||
if( c == '\\' )
|
||||
buffer += "\\\\";
|
||||
else
|
||||
if( c == '\'' )
|
||||
buffer += "\\\'"; // don't use "''" because we use the method for PQconnectdb too
|
||||
else
|
||||
if( c != 0 )
|
||||
buffer += c;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::ETextPutChar(wchar_t c)
|
||||
{
|
||||
if( c == '\\' )
|
||||
buffer += "\\\\";
|
||||
else
|
||||
if( c == '\'' )
|
||||
buffer += "\\\'"; // don't use "''" because we use the method for PQconnectdb too
|
||||
else
|
||||
if( c != 0 )
|
||||
PT::IntToUTF8(int(c), buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const char * str)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += '\'';
|
||||
|
||||
for( ; *str ; ++str )
|
||||
ETextPutChar(*str);
|
||||
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const std::string * str)
|
||||
{
|
||||
return EPutText(str->c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const std::string & str)
|
||||
{
|
||||
return EPutText(str.c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const wchar_t * str)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += '\'';
|
||||
|
||||
for( ; *str ; ++str )
|
||||
ETextPutChar(*str);
|
||||
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const std::wstring * str)
|
||||
{
|
||||
return EPutText(str->c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const std::wstring & str)
|
||||
{
|
||||
return EPutText(str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this method can escaped 0 in the middle of the string
|
||||
DbTextStream & DbTextStream::EPutBin(const char * str, size_t len)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += "\'\\\\x";
|
||||
|
||||
for(size_t i = 0 ; i < len ; ++i)
|
||||
EBinPutChar(str[i]);
|
||||
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutBin(const std::string * str)
|
||||
{
|
||||
return EPutBin(str->c_str(), str->size());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutBin(const std::string & str)
|
||||
{
|
||||
return EPutBin(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const char * str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const std::string * str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const std::string & str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const wchar_t * str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const std::wstring * str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const std::wstring & str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(bool v)
|
||||
{
|
||||
if( v )
|
||||
EPutText("true");
|
||||
else
|
||||
EPutText("false");
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(char v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += '\'';
|
||||
ETextPutChar(v);
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(wchar_t v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += '\'';
|
||||
ETextPutChar(v);
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(int v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(long v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(unsigned int v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(unsigned long v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(double v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const void * v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
buffer += '\''; // !! not needed here?
|
||||
TextStream<std::string>::operator<<(v);
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const std::vector<long> & tabid)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
buffer += '(';
|
||||
|
||||
for(size_t i=0 ; i<tabid.size(); ++i)
|
||||
{
|
||||
TextStream<std::string>::operator<<(tabid[i]);
|
||||
|
||||
if( i + 1 < tabid.size() )
|
||||
buffer += ',';
|
||||
}
|
||||
|
||||
buffer += ')';
|
||||
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const PT::Space & space)
|
||||
{
|
||||
tmp_stream.Clear();
|
||||
// !! IMPROVE ME
|
||||
// we can calculate how much memory is needed before serializing
|
||||
space.Serialize(tmp_stream, true, false);
|
||||
operator<<(tmp_stream.Str());
|
||||
tmp_stream.Clear();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const PT::Date & date)
|
||||
{
|
||||
tmp_stream.Clear();
|
||||
date.Serialize(tmp_stream);
|
||||
operator<<(tmp_stream.Str());
|
||||
tmp_stream.Clear();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
@@ -1,241 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_db_dbtextstream
|
||||
#define headerfile_winix_db_dbtextstream
|
||||
|
||||
#include <ctime>
|
||||
#include "core/textstream.h"
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
/*
|
||||
DbTextStream is used as a buffer for creating a database's query
|
||||
By default all operators<< escape its string artuments. If you don't want
|
||||
to escape an argument you should use a helper function R() (raw argument)
|
||||
note: you have to define the function yourself, we do not provide it
|
||||
because such a short name would make a mess in namespaces
|
||||
|
||||
sample:
|
||||
create a helper function R as follows:
|
||||
|
||||
template<class RawType>
|
||||
DbTextStream::RawText<RawType> R(const RawType & par)
|
||||
{
|
||||
return DbTextStream::RawText<RawType>(par);
|
||||
}
|
||||
|
||||
now you can use DbTextStream in an easy way:
|
||||
|
||||
DbTextStream query;
|
||||
std::string key = "some string";
|
||||
query << R("select * from table where key=") << key << R(";");
|
||||
|
||||
in above example only the key is escaped.
|
||||
|
||||
Also with escaping operators<< insert commas between parameters, e.g.:
|
||||
|
||||
query << R("insert into table (key1, key2, key3) values (")
|
||||
<< key1
|
||||
<< key2
|
||||
<< key3
|
||||
<< R(");");
|
||||
|
||||
between key1 key2 and key3 are commas inserted automatically
|
||||
*/
|
||||
class DbTextStream : public TextStream<std::string>
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
/*
|
||||
a helper struct to select a proper operator<<
|
||||
(for non-escaping versions of these operators)
|
||||
*/
|
||||
template<class RawType>
|
||||
struct RawText
|
||||
{
|
||||
const RawType & par;
|
||||
|
||||
RawText(const RawText<RawType> & p) : par(p.par) {}
|
||||
RawText(const RawType & p) : par(p) {}
|
||||
};
|
||||
|
||||
|
||||
DbTextStream();
|
||||
|
||||
// extented escaping: adding E character before the first quote e.g. E'string'
|
||||
// default: true
|
||||
void SetExtented(bool ext);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
without escaping
|
||||
*/
|
||||
|
||||
DbTextStream & PutText(const char *);
|
||||
DbTextStream & PutText(const std::string *);
|
||||
DbTextStream & PutText(const std::string &);
|
||||
DbTextStream & PutText(const wchar_t * str);
|
||||
DbTextStream & PutText(const std::wstring * str);
|
||||
DbTextStream & PutText(const std::wstring & str);
|
||||
|
||||
/*
|
||||
we need this template operator for such calling:
|
||||
dbtextstream_object << R("some string");
|
||||
"some string" is actually a table (not a pointer)
|
||||
*/
|
||||
template<size_t str_size>
|
||||
DbTextStream & operator<<(RawText<char [str_size]> raw) { return PutText(raw.par); }
|
||||
|
||||
template<size_t str_size>
|
||||
DbTextStream & operator<<(RawText<wchar_t [str_size]> raw) { return PutText(raw.par); }
|
||||
|
||||
DbTextStream & operator<<(RawText<const char*> raw);
|
||||
DbTextStream & operator<<(RawText<const wchar_t*> raw);
|
||||
DbTextStream & operator<<(RawText<const std::string*> raw);
|
||||
DbTextStream & operator<<(RawText<const std::wstring*> raw);
|
||||
DbTextStream & operator<<(RawText<std::string> raw);
|
||||
DbTextStream & operator<<(RawText<std::wstring> raw);
|
||||
DbTextStream & operator<<(RawText<bool> raw);
|
||||
DbTextStream & operator<<(RawText<char> raw);
|
||||
DbTextStream & operator<<(RawText<wchar_t> raw);
|
||||
DbTextStream & operator<<(RawText<int> raw);
|
||||
DbTextStream & operator<<(RawText<long> raw);
|
||||
DbTextStream & operator<<(RawText<unsigned int> raw);
|
||||
DbTextStream & operator<<(RawText<unsigned long> raw);
|
||||
DbTextStream & operator<<(RawText<double> raw);
|
||||
DbTextStream & operator<<(RawText<void*> raw);
|
||||
DbTextStream & operator<<(RawText<PT::Date> date);
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
DbTextStream & operator<<(RawText<PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> > raw);
|
||||
|
||||
/*
|
||||
with escaping
|
||||
*/
|
||||
|
||||
DbTextStream & EBinPutChar(char c);
|
||||
DbTextStream & ETextPutChar(char c);
|
||||
DbTextStream & ETextPutChar(wchar_t c);
|
||||
|
||||
DbTextStream & EPutText(const char * str);
|
||||
DbTextStream & EPutText(const std::string * str);
|
||||
DbTextStream & EPutText(const std::string & str);
|
||||
DbTextStream & EPutText(const wchar_t * str);
|
||||
DbTextStream & EPutText(const std::wstring * str);
|
||||
DbTextStream & EPutText(const std::wstring & str);
|
||||
|
||||
DbTextStream & EPutBin(const char * str, size_t len);
|
||||
DbTextStream & EPutBin(const std::string * str);
|
||||
DbTextStream & EPutBin(const std::string & str);
|
||||
|
||||
DbTextStream & operator<<(const char * str);
|
||||
DbTextStream & operator<<(const std::string * str);
|
||||
DbTextStream & operator<<(const std::string & str);
|
||||
DbTextStream & operator<<(const wchar_t * str);
|
||||
DbTextStream & operator<<(const std::wstring * str);
|
||||
DbTextStream & operator<<(const std::wstring & str);
|
||||
DbTextStream & operator<<(bool);
|
||||
DbTextStream & operator<<(char);
|
||||
DbTextStream & operator<<(wchar_t);
|
||||
DbTextStream & operator<<(int);
|
||||
DbTextStream & operator<<(long);
|
||||
DbTextStream & operator<<(unsigned int);
|
||||
DbTextStream & operator<<(unsigned long);
|
||||
DbTextStream & operator<<(double);
|
||||
DbTextStream & operator<<(const void *);
|
||||
DbTextStream & operator<<(const std::vector<long> & tabid);
|
||||
DbTextStream & operator<<(const PT::Space & space);
|
||||
DbTextStream & operator<<(const PT::Date & date);
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
DbTextStream & operator<<(const PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & arg);
|
||||
|
||||
private:
|
||||
|
||||
bool was_param;
|
||||
bool ext_escape;
|
||||
TextStream<std::wstring> tmp_stream;
|
||||
|
||||
char EBinGetHex(char c);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
DbTextStream & DbTextStream::operator<<(RawText<PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> > raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
DbTextStream & DbTextStream::operator<<(const PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & arg)
|
||||
{
|
||||
typename PT::TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size>::const_iterator i;
|
||||
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += '\'';
|
||||
|
||||
for(i=arg.begin() ; i != arg.end() ; ++i)
|
||||
ETextPutChar(*i);
|
||||
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
-1700
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
||||
include Makefile.o.dep
|
||||
|
||||
|
||||
all: $(o)
|
||||
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(CXXWINIXINCLUDEFLAGS) $<
|
||||
|
||||
|
||||
depend:
|
||||
makedepend -Y. $(CXXWINIXINCLUDEFLAGS) -f- *.cpp > Makefile.dep
|
||||
echo -n "o = " > Makefile.o.dep
|
||||
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
include Makefile.dep
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
o = account.o adduser.o cat.o chmod.o chown.o ckeditor.o cp.o default.o download.o emacs.o env.o functionbase.o functionparser.o functions.o imgcrop.o ipban.o last.o ln.o locale.o login.o logout.o ls.o man.o meta.o mkdir.o mount.o mv.o nicedit.o node.o passwd.o priv.o privchanger.o pw.o reload.o rm.o rmuser.o run.o sort.o specialdefault.o stat.o subject.o template.o timezone.o tinymce.o uname.o upload.o uptime.o vim.o who.o
|
||||
@@ -1,220 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "env.h"
|
||||
#include "core/log.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
Env::Env()
|
||||
{
|
||||
fun.url = L"env";
|
||||
puser = 0;
|
||||
req_id = 0;
|
||||
}
|
||||
|
||||
|
||||
bool Env::HasAccess()
|
||||
{
|
||||
if( !cur->session->puser )
|
||||
return false;
|
||||
|
||||
if( cur->request->IsParam(L"a") )
|
||||
{
|
||||
// show/change admin environment variables for a user
|
||||
|
||||
if( !cur->session->puser->super_user )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !GetUser() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Env::Parse(const std::wstring & env_str)
|
||||
{
|
||||
space.Clear();
|
||||
conf_parser.SetSpace(space);
|
||||
conf_parser.SplitSingle(true);
|
||||
|
||||
return (conf_parser.ParseString(env_str) == PT::SpaceParser::ok);
|
||||
}
|
||||
|
||||
|
||||
bool Env::EditAdminEnv(long user_id, const std::wstring & env_str, bool use_ses_log)
|
||||
{
|
||||
if( Parse(env_str) )
|
||||
{
|
||||
if( db->ChangeUserAdminEnv(user_id, space) == WINIX_ERR_OK )
|
||||
{
|
||||
User * puser = system->users.GetUser(user_id);
|
||||
|
||||
if( puser )
|
||||
puser->aenv = space;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Evn: a database problem with changing environment variables for user: "
|
||||
<< cur->session->puser->name << ", id: " << cur->session->puser->id << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Env: Syntax error in line: " << conf_parser.line << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Env::EditEnv(long user_id, const std::wstring & env_str, bool use_ses_log)
|
||||
{
|
||||
if( Parse(env_str) )
|
||||
{
|
||||
if( db->ChangeUserEnv(user_id, space) == WINIX_ERR_OK )
|
||||
{
|
||||
User * puser = system->users.GetUser(user_id);
|
||||
|
||||
if( puser )
|
||||
puser->env = space;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Evn: a database problem with changing admin environment variables for user: "
|
||||
<< cur->session->puser->name << ", id: " << cur->session->puser->id << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log2 << "Env: Syntax error in line: " << conf_parser.line << logend;
|
||||
|
||||
if( use_ses_log )
|
||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Env::SaveEnv()
|
||||
{
|
||||
if( GetUser() )
|
||||
{
|
||||
const std::wstring & env_str = cur->request->PostVar(L"envvar");
|
||||
long user_id = GetUser()->id;
|
||||
bool status = false;
|
||||
|
||||
if( cur->request->IsParam(L"a") )
|
||||
{
|
||||
if( cur->session->puser->super_user )
|
||||
status = EditAdminEnv(user_id, env_str, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = EditEnv(user_id, env_str, true);
|
||||
}
|
||||
|
||||
if( status )
|
||||
system->RedirectToLastItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
User * Env::GetUser()
|
||||
{
|
||||
if( cur->request->id != req_id )
|
||||
{
|
||||
req_id = cur->request->id;
|
||||
puser = 0;
|
||||
|
||||
if( cur->session->puser )
|
||||
{
|
||||
if( cur->session->puser->super_user && cur->request->IsPostVar(L"userid") )
|
||||
{
|
||||
long id = Tol(cur->request->PostVar(L"userid"));
|
||||
puser = system->users.GetUser(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
puser = cur->session->puser;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return puser;
|
||||
}
|
||||
|
||||
|
||||
void Env::MakePost()
|
||||
{
|
||||
if( cur->session->puser )
|
||||
{
|
||||
if( cur->request->IsPostVar(L"changeuser") )
|
||||
{
|
||||
// show environments variables for the specified user
|
||||
if( GetUser() )
|
||||
log << log2 << "Env: changing user to: " << GetUser()->name << ", id: " << GetUser()->id << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
// save environment variables
|
||||
SaveEnv();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_functions_functionbase
|
||||
#define headerfile_winix_functions_functionbase
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "core/item.h"
|
||||
#include "db/db.h"
|
||||
#include "core/request.h"
|
||||
#include "core/config.h"
|
||||
#include "core/system.h"
|
||||
#include "core/synchro.h"
|
||||
#include "notify/notify.h"
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
class Functions;
|
||||
class Templates;
|
||||
|
||||
|
||||
|
||||
|
||||
class FunctionBase
|
||||
{
|
||||
public:
|
||||
|
||||
FunctionBase();
|
||||
|
||||
// user, group, permissions, url (function name)
|
||||
Item fun;
|
||||
|
||||
// auto follow sym links, default: true
|
||||
bool follow_symlinks;
|
||||
|
||||
// html template index (for using with 'patterns' object)
|
||||
size_t template_index;
|
||||
|
||||
// try to use SSL
|
||||
// if in the config 'use_ssl' is true and 'use_ssl_only_for_logged_users' is true
|
||||
// then ssl is used only for logged users but sometimes there is a need to use
|
||||
// SSL even if noone is logged (for example for such functions like 'login' or 'adduser')
|
||||
// default: false
|
||||
// (this option is ignored if 'use_ssl' in the config is false)
|
||||
bool need_ssl;
|
||||
|
||||
virtual void Init();
|
||||
virtual bool HasAccess();
|
||||
virtual void MakePost();
|
||||
virtual void MakeGet();
|
||||
|
||||
void SetConfig(Config * pconfig);
|
||||
void SetCur(Cur * pcur);
|
||||
void SetDb(Db * pdb);
|
||||
void SetSystem(System * psystem);
|
||||
void SetFunctions(Functions * pfunctions);
|
||||
void SetTemplates(Templates * ptemplates);
|
||||
void SetSynchro(Synchro * psynchro);
|
||||
void SetSessionManager(SessionManager * pmanager);
|
||||
|
||||
protected:
|
||||
|
||||
Config * config;
|
||||
Cur * cur;
|
||||
Db * db;
|
||||
System * system;
|
||||
Functions * functions;
|
||||
Templates * templates;
|
||||
Synchro * synchro;
|
||||
SessionManager * session_manager;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
#endif
|
||||
@@ -1,414 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "functionparser.h"
|
||||
#include "core/log.h"
|
||||
#include "core/item.h"
|
||||
#include "core/error.h"
|
||||
#include "functions.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
FunctionParser::FunctionParser()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FunctionParser::Parse(Cur * pcur, Db * pdb, Functions * pfunctions, System * psystem)
|
||||
{
|
||||
db = pdb;
|
||||
cur = pcur;
|
||||
system = psystem;
|
||||
functions = pfunctions;
|
||||
last_dir = 0;
|
||||
path = cur->request->env_request_uri.c_str();
|
||||
|
||||
ParseDirsItemFunction();
|
||||
ParseParams();
|
||||
ParseAnchor();
|
||||
|
||||
return cur->request->status == WINIX_ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunctionParser::ParseDirsItemFunction()
|
||||
{
|
||||
if( !AddRootDir() )
|
||||
return;
|
||||
|
||||
ReadName();
|
||||
|
||||
while( IsDir() )
|
||||
{
|
||||
AddDir();
|
||||
ReadName();
|
||||
}
|
||||
|
||||
if( name.empty() )
|
||||
return;
|
||||
|
||||
if( CheckAddFunction() )
|
||||
return;
|
||||
|
||||
if( CheckAddItem() )
|
||||
{
|
||||
ReadName();
|
||||
|
||||
if( !name.empty() )
|
||||
{
|
||||
CheckAddFunction();
|
||||
|
||||
if( !cur->request->function )
|
||||
{
|
||||
log << log3 << "FP: unknown function: " << name << logend;
|
||||
cur->request->status = WINIX_ERR_NO_ITEM;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FunctionParser::AddRootDir()
|
||||
{
|
||||
last_dir = system->dirs.GetRootDir();
|
||||
|
||||
if( !last_dir )
|
||||
{
|
||||
log << log3 << "FP: there is not a root directory" << logend;
|
||||
cur->request->status = WINIX_ERR_INTERNAL_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
AddDir();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FunctionParser::IsDir()
|
||||
{
|
||||
// directory names should not be empty
|
||||
if( name.empty() || !last_dir )
|
||||
return false;
|
||||
|
||||
last_dir = system->dirs.GetDir(name, last_dir->id);
|
||||
|
||||
return last_dir != 0;
|
||||
}
|
||||
|
||||
|
||||
bool FunctionParser::CheckAddItem()
|
||||
{
|
||||
// cur->request->dir_tab has at least one element
|
||||
long parent_id = cur->request->dir_tab.back()->id;
|
||||
Error status = db->GetItem(parent_id, name, cur->request->item);
|
||||
|
||||
if( status == WINIX_ERR_OK )
|
||||
{
|
||||
log << log3 << "FP: Item: id: " << cur->request->item.id << ", url: " << cur->request->item.url << logend;
|
||||
cur->request->last_item = &cur->request->item;
|
||||
cur->request->is_item = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( status == WINIX_ERR_NO_ITEM )
|
||||
{
|
||||
log << log3 << "FP: No Item: url: " << name << logend;
|
||||
cur->request->status = WINIX_ERR_NO_ITEM;
|
||||
return false;
|
||||
}
|
||||
|
||||
log << log1 << "FP: db error" << logend;
|
||||
cur->request->status = WINIX_ERR_INTERNAL_ERROR;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FunctionParser::CheckAddFunction()
|
||||
{
|
||||
cur->request->function = functions->Find(name);
|
||||
|
||||
if( cur->request->function )
|
||||
{
|
||||
log << log3 << "FP: Function: " << cur->request->function->fun.url << logend;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::AddDir()
|
||||
{
|
||||
cur->request->dir_tab.push_back( last_dir );
|
||||
log << log3 << "FP: Directory: ";
|
||||
|
||||
if( last_dir->parent_id == -1 )
|
||||
log << "(root)" << logend;
|
||||
else
|
||||
log << last_dir->url << logend;
|
||||
|
||||
cur->request->last_item = cur->request->dir_tab.back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunctionParser::ParseParams()
|
||||
{
|
||||
SkipSlashes();
|
||||
|
||||
if( *path == '#' )
|
||||
{
|
||||
// there are not any parameters
|
||||
return;
|
||||
}
|
||||
|
||||
if( *path == '?' )
|
||||
ParseOrdinaryParams();
|
||||
else
|
||||
ParseWinixParams();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunctionParser::ParseOrdinaryParams()
|
||||
{
|
||||
if( *path == '?' )
|
||||
path += 1;
|
||||
|
||||
do
|
||||
{
|
||||
ReadOrdinaryParName();
|
||||
|
||||
if( name.empty() )
|
||||
break;
|
||||
|
||||
ReadOrdinaryParValue();
|
||||
|
||||
if( *path == '&' )
|
||||
path += 1;
|
||||
|
||||
AddParam();
|
||||
}
|
||||
while( true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunctionParser::ParseWinixParams()
|
||||
{
|
||||
do
|
||||
{
|
||||
SkipSlashes();
|
||||
ReadWinixParName();
|
||||
|
||||
if( name.empty() )
|
||||
break;
|
||||
|
||||
ReadWinixParValue();
|
||||
|
||||
AddParam();
|
||||
}
|
||||
while( true );
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::AddParam()
|
||||
{
|
||||
param.name = name;
|
||||
param.value = value;
|
||||
cur->request->param_tab.push_back(param);
|
||||
|
||||
log << log3 << "FP: Param: name=" << param.name;
|
||||
|
||||
if( !param.value.empty() )
|
||||
log << ", value=" << param.value;
|
||||
|
||||
log << logend;
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::ParseAnchor()
|
||||
{
|
||||
if( *path == 0 )
|
||||
return;
|
||||
|
||||
if( *path != '#' )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_INCORRECT_URI;
|
||||
return;
|
||||
}
|
||||
|
||||
path += 1;
|
||||
name_ascii.clear();
|
||||
|
||||
while( *path )
|
||||
name_ascii += GetChar();
|
||||
|
||||
PT::UTF8ToWide(name_ascii, cur->request->anchor);
|
||||
|
||||
if( !cur->request->anchor.empty() )
|
||||
log << log3 << "FP: anchor: " << cur->request->anchor << logend;
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::SkipSlashes()
|
||||
{
|
||||
while( *path == '/' )
|
||||
path += 1;
|
||||
}
|
||||
|
||||
|
||||
int FunctionParser::FromHex(int c)
|
||||
{
|
||||
if( c>='0' && c<='9' )
|
||||
return c - '0';
|
||||
else
|
||||
if( c>='a' && c<='f' )
|
||||
return c - 'a' + 10;
|
||||
else
|
||||
if( c>='A' && c<='F' )
|
||||
return c - 'A' + 10;
|
||||
else
|
||||
cur->request->status = WINIX_ERR_INCORRECT_URI;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int FunctionParser::GetChar()
|
||||
{
|
||||
int c;
|
||||
|
||||
if( *path == 0 )
|
||||
return 0;
|
||||
|
||||
if( *path == '%' && *(path+1)!=0 && *(path+2)!=0 )
|
||||
{
|
||||
c = (FromHex(*(path+1)) << 4) + FromHex(*(path+2));
|
||||
|
||||
if( c == 0 )
|
||||
cur->request->status = WINIX_ERR_INCORRECT_URI;
|
||||
|
||||
path += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = *path;
|
||||
path += 1;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunctionParser::ReadName()
|
||||
{
|
||||
SkipSlashes();
|
||||
name_ascii.clear();
|
||||
|
||||
while( *path && *path!='/' && *path!='?' && *path!='#' )
|
||||
name_ascii += GetChar();
|
||||
|
||||
PT::UTF8ToWide(name_ascii, name);
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::ReadOrdinaryParName()
|
||||
{
|
||||
name_ascii.clear();
|
||||
|
||||
while( *path && *path!='=' && *path!='&' && *path!='#' )
|
||||
name_ascii += GetChar();
|
||||
|
||||
PT::UTF8ToWide(name_ascii, name);
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::ReadOrdinaryParValue()
|
||||
{
|
||||
value_ascii.clear();
|
||||
|
||||
if( *path=='=' )
|
||||
path += 1;
|
||||
|
||||
while( *path && *path!='&' && *path!='#' )
|
||||
value_ascii += GetChar();
|
||||
|
||||
PT::UTF8ToWide(value_ascii, value);
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::ReadWinixParName()
|
||||
{
|
||||
name_ascii.clear();
|
||||
|
||||
while( *path && *path!='/' && *path!=':' && *path!='#' )
|
||||
name_ascii += GetChar();
|
||||
|
||||
PT::UTF8ToWide(name_ascii, name);
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::ReadWinixParValue()
|
||||
{
|
||||
value_ascii.clear();
|
||||
|
||||
if( *path == ':' )
|
||||
path += 1;
|
||||
|
||||
while( *path && *path!='/' && *path!='#' )
|
||||
value_ascii += GetChar();
|
||||
|
||||
PT::UTF8ToWide(value_ascii, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
@@ -1,641 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "functions.h"
|
||||
#include "core/log.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/plugin.h"
|
||||
#include "templates/templates.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
void Functions::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
|
||||
|
||||
void Functions::SetCur(Cur * pcur)
|
||||
{
|
||||
cur = pcur;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Functions::SetDb(Db * pdb)
|
||||
{
|
||||
db = pdb;
|
||||
}
|
||||
|
||||
|
||||
void Functions::SetSystem(System * psystem)
|
||||
{
|
||||
system = psystem;
|
||||
}
|
||||
|
||||
|
||||
void Functions::SetTemplates(Templates * ptemplates)
|
||||
{
|
||||
templates = ptemplates;
|
||||
}
|
||||
|
||||
|
||||
void Functions::SetSynchro(Synchro * psynchro)
|
||||
{
|
||||
synchro = psynchro;
|
||||
}
|
||||
|
||||
|
||||
void Functions::SetSessionManager(SessionManager * pmanager)
|
||||
{
|
||||
session_manager = pmanager;
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t Functions::FunctionsSize()
|
||||
{
|
||||
return table.size();
|
||||
}
|
||||
|
||||
|
||||
Functions::Iterator Functions::Begin()
|
||||
{
|
||||
return table.begin();
|
||||
}
|
||||
|
||||
|
||||
Functions::Iterator Functions::End()
|
||||
{
|
||||
return table.end();
|
||||
}
|
||||
|
||||
|
||||
FunctionBase * Functions::Find(const std::wstring & function_name)
|
||||
{
|
||||
Table::iterator i = table.find(function_name);
|
||||
|
||||
if( i == table.end() )
|
||||
return 0;
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
void Functions::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( Find(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(), '_');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Error Functions::CheckSpecialFile(const Item & item)
|
||||
{
|
||||
static std::wstring fstab = L"fstab";
|
||||
|
||||
Item * etc = system->dirs.GetEtcDir();
|
||||
|
||||
if( !etc )
|
||||
return WINIX_NOTHING_TO_DO;
|
||||
|
||||
if( item.parent_id != etc->id )
|
||||
return WINIX_NOTHING_TO_DO;
|
||||
|
||||
if( item.url == fstab )
|
||||
{
|
||||
log << log3 << "Functions: reloading mount points" << logend;
|
||||
|
||||
system->mounts.ReadMounts(item.content);
|
||||
templates->ReadNewIndexTemplates();
|
||||
templates->ReadNewChangeTemplates();
|
||||
|
||||
return WINIX_ERR_OK;
|
||||
}
|
||||
|
||||
return WINIX_NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Functions::SetObjects(FunctionBase * fun)
|
||||
{
|
||||
fun->SetConfig(config);
|
||||
fun->SetCur(cur);
|
||||
fun->SetDb(db);
|
||||
fun->SetSystem(system);
|
||||
fun->SetFunctions(this);
|
||||
fun->SetTemplates(templates);
|
||||
fun->SetSynchro(synchro);
|
||||
fun->SetSessionManager(session_manager);
|
||||
}
|
||||
|
||||
|
||||
void Functions::Add(FunctionBase * fun)
|
||||
{
|
||||
if( fun->fun.url.empty() )
|
||||
{
|
||||
log << log1 << "Functions: skipping a function with an empty url" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( Find(fun->fun.url) )
|
||||
{
|
||||
log << log1 << "Functions: function " << fun->fun.url << " already exists (skipped)" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
SetObjects(fun);
|
||||
table[fun->fun.url] = fun;
|
||||
}
|
||||
|
||||
|
||||
void Functions::Add(FunctionBase & fun)
|
||||
{
|
||||
Add(&fun);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Functions::CreateFunctions()
|
||||
{
|
||||
Add(fun_account);
|
||||
Add(fun_adduser);
|
||||
Add(fun_cat);
|
||||
Add(fun_chmod);
|
||||
Add(fun_chown);
|
||||
Add(fun_ckeditor);
|
||||
Add(fun_cp);
|
||||
Add(fun_default);
|
||||
Add(fun_download);
|
||||
Add(fun_emacs);
|
||||
Add(fun_env);
|
||||
Add(fun_imgcrop);
|
||||
Add(fun_last);
|
||||
Add(fun_locale);
|
||||
Add(fun_login);
|
||||
Add(fun_logout);
|
||||
Add(fun_ln);
|
||||
Add(fun_ls);
|
||||
Add(fun_ipban);
|
||||
Add(fun_man);
|
||||
Add(fun_meta);
|
||||
Add(fun_mkdir);
|
||||
Add(fun_mount);
|
||||
Add(fun_mv);
|
||||
Add(fun_nicedit);
|
||||
Add(fun_node);
|
||||
Add(fun_passwd);
|
||||
Add(fun_priv);
|
||||
Add(fun_pw);
|
||||
Add(fun_reload);
|
||||
Add(fun_rm);
|
||||
Add(fun_rmuser);
|
||||
Add(fun_run);
|
||||
Add(fun_sort);
|
||||
Add(fun_special_default);
|
||||
Add(fun_stat);
|
||||
Add(fun_subject);
|
||||
Add(fun_template);
|
||||
Add(fun_time_zone);
|
||||
Add(fun_tinymce);
|
||||
Add(fun_uname);
|
||||
Add(fun_upload);
|
||||
Add(fun_uptime);
|
||||
Add(fun_who);
|
||||
Add(fun_vim);
|
||||
|
||||
plugin.Call((Session*)0, WINIX_CREATE_FUNCTIONS);
|
||||
}
|
||||
|
||||
|
||||
void Functions::InitFunctions()
|
||||
{
|
||||
Table::iterator i = table.begin();
|
||||
|
||||
for( ; i!=table.end() ; ++i)
|
||||
i->second->Init();
|
||||
}
|
||||
|
||||
|
||||
void Functions::Init()
|
||||
{
|
||||
CreateFunctions();
|
||||
InitFunctions();
|
||||
}
|
||||
|
||||
|
||||
void Functions::Parse()
|
||||
{
|
||||
function_parser.Parse(cur, db, this, system);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Functions::SetDefaultFunctionForFile()
|
||||
{
|
||||
if( cur->request->item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
cur->request->function = &fun_download;
|
||||
else
|
||||
if( system->HasReadExecAccess(cur->request->item) )
|
||||
cur->request->function = &fun_run;
|
||||
else
|
||||
cur->request->function = &fun_cat;
|
||||
|
||||
log << log3 << "Functions: default function: " << cur->request->function->fun.url << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Functions::SetDefaultFunctionForDir()
|
||||
{
|
||||
// !! nie potrzebne
|
||||
// if( system->mounts.pmount->type == system->mounts.MountTypeThread() )
|
||||
// cur->request->function = &fun_thread;
|
||||
// else
|
||||
|
||||
cur->request->function = &fun_ls;
|
||||
|
||||
log << log3 << "Functions: default function: " << cur->request->function->fun.url << logend;
|
||||
}
|
||||
|
||||
|
||||
void Functions::SetDefaultFunction()
|
||||
{
|
||||
cur->request->function = 0;
|
||||
|
||||
plugin.Call(WINIX_SELECT_DEFAULT_FUNCTION);
|
||||
|
||||
if( cur->request->function )
|
||||
{
|
||||
log << log3 << "Functions: default function: " << cur->request->function->fun.url
|
||||
<< " (set by a plugin)" << logend;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( cur->request->is_item )
|
||||
SetDefaultFunctionForFile();
|
||||
else
|
||||
SetDefaultFunctionForDir();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Functions::CheckFunctionFollowDir(bool was_default_function)
|
||||
{
|
||||
// directory with 'default' flag
|
||||
|
||||
if( was_default_function )
|
||||
{
|
||||
if( cur->request->dir_tab.back()->link_redirect == 1 )
|
||||
{
|
||||
system->RedirectTo(cur->request->dir_tab.back()->link_to);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( system->FollowAllLinks(cur->request->dir_tab.back()->link_to, true, true) )
|
||||
SetDefaultFunction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Functions::CheckFunctionFollowSymlink(bool was_default_function)
|
||||
{
|
||||
if( cur->request->item.link_redirect == 1 )
|
||||
{
|
||||
if( was_default_function )
|
||||
system->RedirectTo(cur->request->item.link_to);
|
||||
else
|
||||
system->RedirectWithFunctionAndParamsTo(cur->request->item.link_to);
|
||||
}
|
||||
else
|
||||
if( system->FollowAllLinks(cur->request->item.link_to, true, true) )
|
||||
{
|
||||
if( was_default_function )
|
||||
SetDefaultFunction();
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK && !cur->request->redirect_to.empty() && !was_default_function && cur->request->function )
|
||||
{
|
||||
// !! nie jestem pewny dodania tej nowej funkcji do redirecta... (sprawdzic to)
|
||||
cur->request->redirect_to += '/';
|
||||
cur->request->redirect_to += cur->request->function->fun.url;
|
||||
system->AddParams(cur->request->param_tab, cur->request->redirect_to, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// making a proper redirection from a directory with 'default' flag
|
||||
// or from a symlink (or just loading it if there is no redirection flag set)
|
||||
void Functions::CheckFunctionAndSymlink()
|
||||
{
|
||||
bool was_default_function = false;
|
||||
|
||||
if( !cur->request->function || cur->request->function == &fun_special_default )
|
||||
{
|
||||
was_default_function = true;
|
||||
SetDefaultFunction();
|
||||
}
|
||||
|
||||
if( cur->request->status != WINIX_ERR_OK || !cur->request->redirect_to.empty() )
|
||||
return;
|
||||
|
||||
if( !cur->request->is_item && !cur->request->dir_tab.back()->link_to.empty() )
|
||||
CheckFunctionFollowDir(was_default_function);
|
||||
else
|
||||
if( cur->request->is_item && cur->request->item.type == Item::symlink && cur->request->function && cur->request->function->follow_symlinks )
|
||||
CheckFunctionFollowSymlink(was_default_function);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Functions::MakeFunction()
|
||||
{
|
||||
if( !cur->request->function )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_NO_FUNCTION;
|
||||
log << log1 << "Functions: no function (neither cat nor ls)" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !system->DirsHaveReadExecPerm() ||
|
||||
!system->HasReadExecAccess(cur->request->function->fun) ||
|
||||
!cur->request->function->HasAccess() )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
if( cur->request->method == Request::get )
|
||||
{
|
||||
if( cur->request->redirect_to.empty() )
|
||||
cur->request->function->MakeGet();
|
||||
}
|
||||
else
|
||||
if( cur->request->method == Request::post )
|
||||
{
|
||||
// we don't use post with redirecting (the post variables would be lost)
|
||||
|
||||
if( cur->request->redirect_to.empty() )
|
||||
cur->request->function->MakePost();
|
||||
else
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
else
|
||||
if( cur->request->method == Request::head )
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else
|
||||
log << log1 << "Functions: unknown request method (skipping)" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Functions::CheckGetPostTimes(time_t difference)
|
||||
{
|
||||
time_t now = std::time(0);
|
||||
|
||||
if( cur->session->puser )
|
||||
return;
|
||||
|
||||
if( cur->request->method != Request::post )
|
||||
return;
|
||||
|
||||
if( now - cur->session->last_time_get >= (time_t)difference )
|
||||
return;
|
||||
|
||||
if( cur->request->AllPostVarEmpty() )
|
||||
return;
|
||||
|
||||
cur->session->spam_score += 1;
|
||||
log << log1 << "Functions: spam +1: POST after GET sent too fast" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !!uwaga zwracana warto�� zmieniona (true/false)
|
||||
bool Functions::CheckAbuse()
|
||||
{
|
||||
if( !system->rebus.CheckRebus() )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_INCORRECT_REBUS;
|
||||
return true;
|
||||
}
|
||||
|
||||
CheckGetPostTimes();
|
||||
|
||||
if( cur->session->spam_score > 0 )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_SPAM;
|
||||
log << log1 << "Functions: ignoring due to suspected spamming" << logend;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// returning true if the 'url' has to be changed
|
||||
void Functions::ReadItemUrlSubject(Item & item, Item::Type item_type)
|
||||
{
|
||||
std::wstring * new_subject = cur->request->PostVarp(L"subject");
|
||||
std::wstring * new_url = cur->request->PostVarp(L"url");
|
||||
|
||||
if( new_subject )
|
||||
item.subject = *new_subject;
|
||||
|
||||
/*
|
||||
if( item.subject.empty() )
|
||||
{
|
||||
item.subject = cur->request->dir_tab.back()->subject;
|
||||
item.subject += L"_msg_";
|
||||
Toa(db->Size(cur->request->dir_tab.back()->id, Item::file), item.subject, 10, false);
|
||||
}
|
||||
*/
|
||||
|
||||
if( new_url )
|
||||
item.url = *new_url;
|
||||
|
||||
// if item.url is empty then it will be set from item.subject
|
||||
PrepareUrl(item);
|
||||
}
|
||||
|
||||
|
||||
void Functions::ReadItemFilterHtml(Item & item)
|
||||
{
|
||||
html_filter.BreakWord(0);
|
||||
html_filter.WrapLine(0);
|
||||
html_filter.TrimWhite(false);
|
||||
html_filter.InsertTabs(0);
|
||||
html_filter.SafeMode(true);
|
||||
html_filter.ClearOrphans();
|
||||
// SetNoFilterTag doesn't have to be called (default empty tag)
|
||||
|
||||
html_filter.Filter(cur->request->PostVar(L"itemcontent"), item.content);
|
||||
}
|
||||
|
||||
|
||||
void Functions::ReadItemContent(Item & item, const std::wstring & content_type)
|
||||
{
|
||||
bool is_root = cur->session->puser && cur->session->puser->super_user;
|
||||
bool filter_html = (content_type == L"2") && config->editors_html_safe_mode;
|
||||
|
||||
if( filter_html && is_root && config->editors_html_safe_mode_skip_root )
|
||||
filter_html = false;
|
||||
|
||||
if( filter_html )
|
||||
ReadItemFilterHtml(item);
|
||||
else
|
||||
cur->request->PostVar(L"itemcontent", item.content);
|
||||
}
|
||||
|
||||
|
||||
void Functions::ReadItemContentWithType(Item & item)
|
||||
{
|
||||
item.content_type = Item::ct_formatted_text; // default is formatted text
|
||||
cur->request->PostVar(L"contenttype", temp);
|
||||
|
||||
ReadItemContent(item, temp);
|
||||
|
||||
|
||||
// ct_text and ct_formatted_text can use everyone
|
||||
|
||||
if( temp == L"0" )
|
||||
item.content_type = Item::ct_text;
|
||||
else
|
||||
if( temp == L"1" )
|
||||
item.content_type = Item::ct_formatted_text;
|
||||
|
||||
|
||||
// those below need special privileges
|
||||
|
||||
if( !cur->session->puser )
|
||||
return;
|
||||
|
||||
long user_id = cur->session->puser->id;
|
||||
|
||||
|
||||
if( temp == L"2" )
|
||||
{
|
||||
if( system->CanUseHtml(user_id) )
|
||||
item.content_type = Item::ct_html;
|
||||
}
|
||||
else
|
||||
if( temp == L"3" )
|
||||
{
|
||||
if( system->CanUseBBCode(user_id) )
|
||||
item.content_type = Item::ct_bbcode;
|
||||
}
|
||||
else
|
||||
if( temp == L"4" )
|
||||
{
|
||||
if( system->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
|
||||
// !! zmienic nazwe na ReadUrlSubjectContent
|
||||
void Functions::ReadItem(Item & item, Item::Type item_type)
|
||||
{
|
||||
if( item_type == Item::none )
|
||||
return;
|
||||
|
||||
item.type = item_type;
|
||||
item.parent_id = cur->request->dir_tab.back()->id; // !! moze to dac jako parametr?
|
||||
|
||||
ReadItemUrlSubject(item, item_type);
|
||||
|
||||
if( item_type == Item::file )
|
||||
ReadItemContentWithType(item);
|
||||
}
|
||||
|
||||
|
||||
void Functions::SetUser(Item & item)
|
||||
{
|
||||
if( cur->session && cur->session->puser )
|
||||
{
|
||||
item.user_id = cur->session->puser->id;
|
||||
item.guest_name.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.user_id = -1;
|
||||
cur->request->PostVar(L"guestname", item.guest_name);
|
||||
}
|
||||
|
||||
item.group_id = cur->request->dir_tab.back()->group_id;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
@@ -1,362 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cstdio>
|
||||
#include <errno.h>
|
||||
#include "upload.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/plugin.h"
|
||||
#include "functions/functions.h"
|
||||
#include "templates/templates.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
Upload::Upload()
|
||||
{
|
||||
fun.url = L"upload";
|
||||
}
|
||||
|
||||
|
||||
void Upload::Init()
|
||||
{
|
||||
json_serializer.TreatAsTable(L"files");
|
||||
json_serializer.TreatAsNumeric(L"size");
|
||||
}
|
||||
|
||||
|
||||
bool Upload::HasAccess(const Item & item)
|
||||
{
|
||||
// you can use 'upload' only in a directory
|
||||
if( item.type != Item::dir )
|
||||
return false;
|
||||
|
||||
if( config->upload_dir.empty() )
|
||||
{
|
||||
log << log1 << "Request: can't use upload function, upload_dir must be set in the config file" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( cur->session->puser && cur->session->puser->super_user )
|
||||
// super user can use upload everywhere
|
||||
return true;
|
||||
|
||||
if( !system->HasWriteAccess(item) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Upload::HasAccess()
|
||||
{
|
||||
if( cur->request->is_item || !HasAccess(*cur->request->dir_tab.back()) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Upload::UploadSaveStaticFile(const Item & item, const std::wstring & tmp_filename)
|
||||
{
|
||||
if( !system->MakeFilePath(item, path, false, true, config->upload_dirs_chmod, config->upload_group_int) )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( RenameFile(tmp_filename, path) )
|
||||
{
|
||||
if( !SetPriv(path, config->upload_files_chmod, config->upload_group_int) )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return false;
|
||||
}
|
||||
|
||||
log << log2 << "Upload: uploaded a new file: " << path << logend;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Upload: can't move the tmp file from: " << tmp_filename << ", to: " << path << logend;
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Upload::ResizeImage(Item & item)
|
||||
{
|
||||
Image::Scale scale = system->image.GetImageScale(item.parent_id);
|
||||
system->image.Resize(item.id, scale.cx, scale.cy, scale.aspect_mode, scale.quality);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Upload::CreateThumb(Item & item)
|
||||
{
|
||||
Image::Scale scale = system->image.GetThumbScale(item.parent_id);
|
||||
system->image.CreateThumb(item.id, scale.cx, scale.cy, scale.aspect_mode, scale.quality);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
||||
{
|
||||
// we should add the file beforehand to get the proper item.id
|
||||
cur->request->status = system->AddFile(item, 0, false);
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
{
|
||||
if( system->CreateNewFile(item) )
|
||||
{
|
||||
if( UploadSaveStaticFile(item, tmp_filename) )
|
||||
{
|
||||
cur->request->status = db->EditFileById(item, item.id);
|
||||
|
||||
plugin.Call(WINIX_FILE_ADDED, &item);
|
||||
|
||||
if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
{
|
||||
if( config->image_resize )
|
||||
ResizeImage(item);
|
||||
|
||||
if( config->create_thumb )
|
||||
CreateThumb(item);
|
||||
}
|
||||
|
||||
if( is_jquery_upload )
|
||||
cur->request->item_tab.push_back(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
db->DelItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Upload::FunUploadCheckAbuse()
|
||||
{
|
||||
if( !system->rebus.CheckRebus() )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_INCORRECT_REBUS;
|
||||
return false;
|
||||
}
|
||||
|
||||
functions->CheckGetPostTimes(4);
|
||||
|
||||
if( cur->session->spam_score > 0 )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_SPAM;
|
||||
log << log1 << "Content: ignoring due to suspected spamming" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Upload::UploadMulti()
|
||||
{
|
||||
cur->request->item.Clear(); // clearing and setting date
|
||||
cur->request->item.parent_id = cur->request->dir_tab.back()->id;
|
||||
cur->request->item.type = Item::file;
|
||||
cur->request->item.privileges = system->NewFilePrivileges();
|
||||
functions->SetUser(cur->request->item);
|
||||
|
||||
PostFileTab::iterator i = cur->request->post_file_tab.begin();
|
||||
|
||||
for( ; i != cur->request->post_file_tab.end() ; ++i)
|
||||
{
|
||||
const wchar_t * file_name = i->second.filename.c_str();
|
||||
|
||||
cur->request->item.subject = file_name;
|
||||
cur->request->item.url = file_name;
|
||||
cur->request->item.file_type = SelectFileType(file_name);
|
||||
cur->request->item.file_size = i->second.file_size;
|
||||
|
||||
functions->PrepareUrl(cur->request->item);
|
||||
UploadFile(cur->request->item, i->second.tmp_filename);
|
||||
i->second.tmp_filename.clear();
|
||||
}
|
||||
|
||||
if( is_jquery_upload )
|
||||
CreateAnswer();
|
||||
else
|
||||
system->RedirectToLastDir();
|
||||
}
|
||||
|
||||
|
||||
void Upload::UploadSingle()
|
||||
{
|
||||
const std::wstring & new_subject = cur->request->PostVar(L"subject");
|
||||
const std::wstring & new_url = cur->request->PostVar(L"url");
|
||||
bool has_subject = !new_subject.empty();
|
||||
bool has_url = !new_url.empty();
|
||||
|
||||
functions->ReadItem(cur->request->item, Item::file); // ReadItem() changes the url if it is empty
|
||||
functions->SetUser(cur->request->item);
|
||||
cur->request->item.privileges = system->NewFilePrivileges();
|
||||
|
||||
PostFile & post_file = cur->request->post_file_tab.begin()->second;
|
||||
|
||||
const wchar_t * file_name = post_file.filename.c_str();
|
||||
cur->request->item.file_type = SelectFileType(file_name);
|
||||
cur->request->item.file_size = post_file.file_size;
|
||||
|
||||
if( !has_subject )
|
||||
cur->request->item.subject = file_name;
|
||||
|
||||
if( !has_url )
|
||||
{
|
||||
cur->request->item.url = file_name;
|
||||
functions->PrepareUrl(cur->request->item);
|
||||
}
|
||||
|
||||
UploadFile(cur->request->item, post_file.tmp_filename);
|
||||
post_file.tmp_filename.clear();
|
||||
|
||||
if( is_jquery_upload )
|
||||
CreateAnswer();
|
||||
else
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
system->RedirectTo(cur->request->item, L"/cat");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Upload::MakePost()
|
||||
{
|
||||
cur->request->item_tab.clear();
|
||||
is_jquery_upload = cur->request->IsParam(L"jquery_upload");
|
||||
|
||||
if( cur->request->post_file_tab.empty() )
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !FunUploadCheckAbuse() )
|
||||
return;
|
||||
|
||||
if( cur->request->post_file_tab.size() > 1 )
|
||||
UploadMulti();
|
||||
else
|
||||
UploadSingle();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Upload::CreateAnswer()
|
||||
{
|
||||
Request & req = *cur->request;
|
||||
PT::Space & files = req.info.AddSpace(L"files"); // 'files' will be serialized to an array
|
||||
|
||||
for(size_t i=0 ; i<req.item_tab.size() ; ++i)
|
||||
{
|
||||
PT::Space & file = files.AddSpace(L"");
|
||||
|
||||
file.Add(L"name", req.item_tab[i].url);
|
||||
file.Add(L"size", req.item_tab[i].file_size);
|
||||
|
||||
std::wstring & link = file.Add(L"url", L"");
|
||||
system->CreateItemLink(req.item_tab[i], link);
|
||||
|
||||
std::wstring & del_url = file.Add(L"deleteUrl", link);
|
||||
del_url += L"/rm/jquery_upload";
|
||||
|
||||
file.Add(L"deleteType", L"POST");
|
||||
|
||||
if( req.item_tab[i].file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
{
|
||||
std::wstring & thumb = file.Add(L"thumbnailUrl", link);
|
||||
|
||||
if( req.item_tab[i].has_thumb )
|
||||
thumb += L"/-/thumb";
|
||||
}
|
||||
|
||||
/*
|
||||
* if there was an error add "error" item e.g.
|
||||
* "error": "Filetype not allowed"
|
||||
*/
|
||||
}
|
||||
|
||||
cur->request->return_json = true;
|
||||
cur->request->return_info_only = true;
|
||||
cur->request->info_serializer = &json_serializer;
|
||||
|
||||
|
||||
//cur->request->out_headers.Add(L"Content-Type", L"text/html");
|
||||
}
|
||||
|
||||
|
||||
void Upload::MakeGet()
|
||||
{
|
||||
if( cur->request->IsParam(L"jquery_upload") )
|
||||
{
|
||||
query.Clear();
|
||||
query.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
query.WhereType(Item::file);
|
||||
query.WhereFileType(WINIX_ITEM_FILETYPE_NONE, false);
|
||||
|
||||
db->GetItems(cur->request->item_tab, query);
|
||||
|
||||
CreateAnswer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{error_404}</h1>
|
||||
|
||||
<p>{error_404_msg}</p>
|
||||
|
||||
</div>
|
||||
@@ -1,20 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>Account</h1>
|
||||
|
||||
[if user_logged]
|
||||
<p>You are logged as: [user_name]<br>
|
||||
[if user_super_user]
|
||||
You are the root
|
||||
[end]
|
||||
[# !! IMPROVE ME add info about groups, may other parameters like time zone, language?]
|
||||
</p>
|
||||
[else]
|
||||
<p>You are not logged in.</p>
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,41 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>[if user_logged]{adduser_header_add}[else]{adduser_header_register}[end]</h1>
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir]adduser">
|
||||
<fieldset>
|
||||
<legend>{adduser_form_legend}</legend>
|
||||
|
||||
<p class="withnext">{adduser_login}:</p>
|
||||
<input class="edit" type="text" name="login" value="[adduser_last_login]">
|
||||
|
||||
<p class="withnext">{adduser_password}:</p>
|
||||
<input class="edit" type="password" name="password" value="">
|
||||
|
||||
<p class="withnext">{adduser_confirm_password}:</p>
|
||||
<input class="edit" type="password" name="passwordconfirm" value="">
|
||||
|
||||
[if winix_account_need_email_verification]
|
||||
<p class="withnext">{adduser_need_email}<br>{adduser_need_email2}:</p>
|
||||
[else]
|
||||
<p class="withnext">{adduser_email}:</p>
|
||||
[end]
|
||||
<input class="edit" type="text" name="email" value="[adduser_last_email]">
|
||||
|
||||
[if user_super_user]
|
||||
<p>
|
||||
<input type="checkbox" name="autoactivate" id="autoactivate"><label style="display: inline;" for="autoactivate">{adduser_auto_activate}</label>
|
||||
</p>
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
|
||||
<input class="submit" type="submit" value="[if user_logged]{adduser_submit}[else]{register_user_submit}[end]">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
[if mount_page_arg_is "subject"][if mount_page_arg_is "info"]<h1 class="withinfo">[else]<h1>[end][item_subject]</h1>[end]
|
||||
[if mount_page_arg_is "info"][include "item_info.html"][end]
|
||||
|
||||
[if one item_filetype_is_image]
|
||||
|
||||
<a href="[item_link]"><img class="catimage" [if not item_has_thumb]height="100"[end] src="[item_link]/download[if item_has_thumb]/thumb[end]" alt="[item_subject]"></a>
|
||||
|
||||
[# we use pre.nowinixbreak to tell the html_filter not to put a blank space into those urles]
|
||||
|
||||
<div>
|
||||
<pre class="nowinixbreak">
|
||||
{cat_image_url}: [item_link]<br>
|
||||
{cat_image_thumb_url}: [item_link]/-/thumb
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
[item_print_content]
|
||||
|
||||
[else]
|
||||
|
||||
[if not item_filetype_is_none]
|
||||
{download}: <a href="[item_link]/download" title="[item_subject]">[item_subject]</a>
|
||||
<div>
|
||||
<pre class="nowinixbreak">
|
||||
{cat_file_url}: [item_link]<br>
|
||||
</pre>
|
||||
</div>
|
||||
[item_print_content]
|
||||
[else]
|
||||
[item_print_content]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[if item_is]<h1>{edit}</h1>[else]<h1>{add}</h1>[end]
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]ckeditor">
|
||||
|
||||
[if mount_type_is "cms"]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_title_id">{title}:</label>
|
||||
<input id="winix_title_id" type="text" name="subject" value="[item_subject]">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_url_id">{suggested_url}:</label>
|
||||
<input id="winix_url_id" type="text" name="url" value="[item_url]">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
[if any [mount_type_is "thread"] [thread_mount_arg_is "subject"]]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_title_id">{title}:</label>
|
||||
<input id="winix_title_id" type="text" name="subject" value="[item_subject]">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_url_id">{suggested_url}:</label>
|
||||
<input id="winix_url_id" type="text" name="url" value="[item_url]">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
<div class="winix_input_a">
|
||||
[if mount_type_is "cms"]<label for="winix_content_id">{form_emacs_content_cms}</label>[end]
|
||||
[if mount_type_is "thread"]<label for="winix_content_id">{form_emacs_content_thread}</label>[end]
|
||||
[if mount_type_is "ticket"]<label for="winix_content_id">{form_emacs_content_ticket}</label>[end]
|
||||
|
||||
[# template fun_ls.html uses the name: itemcontent to refer to this textarea item]
|
||||
<textarea id="winix_content_id" rows="[if mount_type_is "cms"]30[else]10[end]" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="contenttype" value="2">
|
||||
|
||||
[if winix_function_param_is "full"]
|
||||
<script type="text/javascript">CKEDITOR.replace('itemcontent', \{filebrowserUploadUrl: '[doc_base_url][dir]upload?noredirect&ckeditor_upload', filebrowserBrowseUrl: '[doc_base_url][dir]ls?ckeditor_browse&fullscreen', customConfig : '[doc_base_url]/var/ckeditor_full.js' \});</script>
|
||||
[else]
|
||||
<script type="text/javascript">CKEDITOR.replace('itemcontent', \{filebrowserUploadUrl: '[doc_base_url][dir]upload?noredirect&ckeditor_upload', filebrowserBrowseUrl: '[doc_base_url][dir]ls?ckeditor_browse&fullscreen', customConfig : '[doc_base_url]/var/ckeditor_winix.js' \});</script>
|
||||
|
||||
[end]
|
||||
|
||||
[if not user_logged]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_nick_id">{nick}:</label>
|
||||
<input id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_rebus_id">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input id="winix_rebus_id" type="text" name="rebus">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
<input type="submit" value="[if item_is]{change}[else]{add}[end]">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,39 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{cp_header}</h1>
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]cp[if not item_is]/r[end]">
|
||||
<fieldset>
|
||||
<legend>{cp_form_legend}</legend>
|
||||
|
||||
<p>
|
||||
[if item_is]{cp_page} "[item_url]":[else]{cp_dir} "[dir_without_slash]"[end]
|
||||
</p>
|
||||
|
||||
|
||||
<p class="withnext">{suggested_url}</p>
|
||||
<input class="edit" type="text" name="to" value="[dir_without_slash][if item_is]/[item_url][end]">
|
||||
|
||||
<p>
|
||||
<label><input type="checkbox" name="preserveattr">{cp_preserve_attr}</label>
|
||||
|
||||
[if not item_is]
|
||||
<label><input type="checkbox" name="onlycontent">{cp_only_content}</label>
|
||||
<label><input type="checkbox" name="removedefaults" checked="checked">{cp_remove_defaults}</label>
|
||||
<label><input type="checkbox" name="followsymlinks" checked="checked">{cp_follow_symlinks}</label>
|
||||
[end]
|
||||
</p>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
|
||||
<input class="submit" type="submit" value="{copy}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,37 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{create_thread_header}</h1>
|
||||
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir]createthread">
|
||||
<fieldset>
|
||||
<legend>{form_thread_legend}</legend>
|
||||
|
||||
<p class="withnext">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
|
||||
[if thread_mount_arg_is "subject"]
|
||||
<p class="withnext">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
[end]
|
||||
|
||||
[include "fun_emacs_post.html"]
|
||||
|
||||
[if not user_logged]
|
||||
<p class="withnext">{nick}:</p>
|
||||
<input class="edit" type="text" name="guestname" value="[item_guest_name]">
|
||||
|
||||
<p class="withnext">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input class="edit" type="text" name="rebus">
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="{button_thread_submit}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
@@ -1,136 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[# this template is used in fun_editticket.html as well]
|
||||
|
||||
[if item_is]<h1>{edit_ticket_header}</h1>[else]<h1>{create_ticket_header}</h1>[end]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<form method="post" action="[doc_base_url][dir][if item_is][item_url]/editticket[else]createticket[end]" enctype="multipart/form-data">
|
||||
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_title_id">{title}:</label>
|
||||
<input id="winix_title_id" type="text" name="subject" value="[item_subject]">
|
||||
</div>
|
||||
|
||||
|
||||
[if ticket_tab]
|
||||
<table class="winix_create_ticket">
|
||||
|
||||
[for ticket_tab]
|
||||
|
||||
<tr>
|
||||
<th>[filter fil_firstup][ticket_tab_param_name]:[end]</th>
|
||||
|
||||
<td>
|
||||
|
||||
[if ticket_tab_type_is "select"]
|
||||
<select name="ticketparam[ticket_tab_param_id]">
|
||||
[for ticket_tab_select_tab]
|
||||
<option [if ticket_tab_select_tab_is_selected]selected [end]value="[ticket_tab_select_tab_id]">[ticket_tab_select_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
[end]
|
||||
|
||||
|
||||
[if one [ticket_tab_type_is "integer"] [ticket_tab_type_is "progress"] [ticket_tab_type_is "string"]]
|
||||
<input type="text" name="ticketparam[ticket_tab_param_id]" value="[ticket_tab_value]">
|
||||
[end]
|
||||
|
||||
|
||||
[if ticket_tab_type_is "multistring"]
|
||||
<textarea name="ticketparam[ticket_tab_param_id]" rows="10" cols="60">[ticket_tab_value]</textarea>
|
||||
[end]
|
||||
|
||||
|
||||
[if ticket_tab_type_is "images"]
|
||||
[for ticket_tab_file_tab]
|
||||
<div class="winix_create_ticket_file_row">
|
||||
<img src="[doc_base_url][ticket_tab_file_tab_path]/-/thumb" alt="[ticket_tab_file_tab_path]" height="150">
|
||||
<input type="submit" name="ticketdeletefile_[ticket_tab_file_tab_itemid]" value="{ticket_delete_file}">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
<input size="30" type="file" name="ticketparam[ticket_tab_param_id]" multiple>
|
||||
<input type="submit" name="fileuploadsubmit" value="{add}">
|
||||
[end]
|
||||
|
||||
|
||||
[if ticket_tab_type_is "files"]
|
||||
[if ticket_tab_file_tab]
|
||||
<ul>
|
||||
[for ticket_tab_file_tab]
|
||||
<li>
|
||||
<a href="[doc_base_url][ticket_tab_file_tab_path]/download">[ticket_tab_file_tab_path]</a>
|
||||
[# !! CHECK ME how this look like -- css was not set]
|
||||
<input type="submit" name="ticketdeletefile_[ticket_tab_file_tab_itemid]" value="{ticket_delete_file}">
|
||||
</li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
|
||||
<input size="30" type="file" name="ticketparam[ticket_tab_param_id]" multiple>
|
||||
<input type="submit" name="fileuploadsubmit" value="{add}">
|
||||
[end]
|
||||
|
||||
[if any_not [ticket_tab_type_is "images"] [ticket_tab_type_is "files"] ticket_is_creating_new ticket_tab_has_value]
|
||||
{ticket_value_not_set}
|
||||
[end]
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
[end]
|
||||
|
||||
</table>
|
||||
[end]
|
||||
|
||||
|
||||
[# FIXME !! change names form_emacs_content_thread and form_emacs_content_ticket]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_content_id">{form_emacs_content_ticket}</label>
|
||||
<textarea id="winix_content_id" rows="10" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_content_type_id">{form_emacs_content_type}</label>
|
||||
<select id="winix_content_type_id" name="contenttype">
|
||||
<option[if item_content_type_is "text"] selected[end] value="0">{form_emacs_content_type_text}</option>
|
||||
<option[if item_content_type_is "formatted text"] selected[end] value="1">{form_emacs_content_type_formatted_text}</option>
|
||||
[if user_can_use_html]<option[if item_content_type_is "html"] selected[end] value="2">{form_emacs_content_type_html}</option>[end]
|
||||
[if user_can_use_bbcode]<option[if item_content_type_is "bbcode"] selected[end] value="3">{form_emacs_content_type_bbcode}</option>[end]
|
||||
[if user_can_use_raw]<option[if item_content_type_is "raw"] selected[end] value="4">{form_emacs_content_type_raw}</option>[end]
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
[if not user_logged]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_nick_id">{nick}:</label>
|
||||
<input id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_rebus_id">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input id="winix_rebus_id" type="text" name="rebus">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
|
||||
<input type="submit" value="[if item_is]{form_ticket_edit_submit}[else]{form_ticket_create_submit}[end]">
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,26 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{default_header}</h1>
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir]default">
|
||||
<fieldset>
|
||||
<legend>{form_default_legend}</legend>
|
||||
{url}:<br>
|
||||
<input class="edit" type="text" name="linkto" value="[dir_last_link_to]">
|
||||
|
||||
<p>
|
||||
<label><input class="" type="checkbox" name="makeredirect"[if dir_last_is_link_redirect] checked="checked"[end]>{default_make_redirect}</label>
|
||||
</p>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[if item_is]<h1>{edit}</h1>[else]<h1>{add}</h1>[end]
|
||||
|
||||
|
||||
|
||||
<form method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]emacs">
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_title_id">{title}:</label>
|
||||
<input id="winix_title_id" type="text" name="subject" value="[item_subject]" [if not item_is]autofocus [end]>
|
||||
</div>
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_url_id">{suggested_url}:</label>
|
||||
<input id="winix_url_id" type="text" name="url" value="[item_url]">
|
||||
</div>
|
||||
|
||||
[include "fun_emacs_post.html"]
|
||||
|
||||
[if not user_logged]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_nick_id">{nick}:</label>
|
||||
<input id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_rebus_id">{rebus_how_is_it} [rebus_question]?</label>
|
||||
<input id="winix_rebus_id" type="text" name="rebus">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input type="submit" value="[if item_is]{change}[else]{add}[end]">
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
<div class="winix_input_a">
|
||||
|
||||
[if winix_function_is "upload"]
|
||||
<label for="winix_content_id">{upload_content}</label>
|
||||
[else]
|
||||
[if mount_type_is "cms"]<label for="winix_content_id">{form_emacs_content_cms}</label>[end]
|
||||
[if mount_type_is "thread"]<label for="winix_content_id">{form_emacs_content_thread}</label>[end]
|
||||
[if mount_type_is "ticket"]<label for="winix_content_id">{form_emacs_content_ticket}</label>[end]
|
||||
[end]
|
||||
|
||||
<textarea [if item_is]autofocus [end]id="winix_content_id" rows="[if winix_function_is "upload"]7[else][if mount_type_is "cms"]30[else]10[end][end]" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_contenttype_id">{form_emacs_content_type}</label>
|
||||
<select name="contenttype" id="winix_contenttype_id">
|
||||
<option[if item_content_type_is "text"] selected[end] value="0">{form_emacs_content_type_text}</option>
|
||||
<option[if item_content_type_is "formatted text"] selected[end] value="1">{form_emacs_content_type_formatted_text}</option>
|
||||
[if user_can_use_html]<option[if item_content_type_is "html"] selected[end] value="2">{form_emacs_content_type_html}</option>[end]
|
||||
[if user_can_use_bbcode]<option[if item_content_type_is "bbcode"] selected[end] value="3">{form_emacs_content_type_bbcode}</option>[end]
|
||||
[if user_can_use_raw]<option[if item_content_type_is "raw"] selected[end] value="4">{form_emacs_content_type_raw}</option>[end]
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{env_header}</h1>
|
||||
|
||||
|
||||
[if user_super_user]
|
||||
|
||||
[if winix_function_param_is "a"]
|
||||
<p class="withnext">{env_change_admin_env_for_user}:</p>
|
||||
[else]
|
||||
<p class="withnext">{env_change_env_for_user}:</p>
|
||||
[end]
|
||||
|
||||
<form class="envchangeuser" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]env[if winix_function_param_is "a"]/a[end]">
|
||||
<fieldset>
|
||||
<legend>{form_env_legend}</legend>
|
||||
|
||||
<select name="userid">
|
||||
[for env_user_tab]
|
||||
<option value="[env_user_tab_id]" [if env_user_tab_is_current]selected="selected"[end]>[env_user_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
|
||||
<input type="hidden" name="changeuser">
|
||||
<input class="submit" type="submit" value="{env_change_user}">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]env[if winix_function_param_is "a"]/a[end]">
|
||||
<fieldset>
|
||||
<legend>{form_env_legend}</legend>
|
||||
|
||||
<textarea class="multitext" rows="30" cols="60" name="envvar">[if winix_function_param_is "a"][env_user_admin_env_str][else][env_user_env_str][end]</textarea>
|
||||
<input type="hidden" name="userid" value="[env_user_id]">
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,28 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{export_header}</h1>
|
||||
|
||||
|
||||
[if item_is]
|
||||
<p>{export_transer_file_info}</p>
|
||||
[else]
|
||||
<p>{export_transer_dir_info}</p>
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
<form action="[doc_base_url][dir][if item_is][item_url]/[end]export" method="post">
|
||||
|
||||
<input type="checkbox" name="staticfilestoo" id="nonstaticfiles"><label for="nonstaticfiles">{export_checkbox_static_file_too}</label>
|
||||
|
||||
<br><br>
|
||||
<input type="submit" value="Export">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,166 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[if mount_page_arg_is "subject"][if mount_page_arg_is "info"]<h1 class="withinfo">[else]<h1>[end][dir_last_subject]</h1>[end]
|
||||
[if mount_page_arg_is "info"][include "dir_last_info.html"][end]
|
||||
|
||||
|
||||
[if one gallery_has_not_mount_type [gallery_mount_type_arg_is "lightbox"]]
|
||||
|
||||
[if gallery_tab]
|
||||
<ul class="galleryimages">
|
||||
[for gallery_tab]
|
||||
<li><a rel="lightbox\[gallery\]" href="[gallery_tab_link]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
[if gallery_mount_type_arg_is "galleria"]
|
||||
|
||||
[if gallery_tab]
|
||||
<ul class="galleryimages" style="width: [gallery_width]; height: [gallery_height];">
|
||||
[for gallery_tab]
|
||||
<li><a href="[gallery_tab_link]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
|
||||
[if gallery_mount_theme_arg_is "transparent"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/aino-galleria/themes/transparent/galleria.transparent.js');</script>
|
||||
[else]
|
||||
[if gallery_mount_theme_arg_is "white"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/aino-galleria/themes/white/galleria.white.js');</script>
|
||||
[else]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/aino-galleria/themes/classic/galleria.classic.js');</script>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[if not [winix_function_param_is "image"]]
|
||||
<script type="text/javascript">$('.galleryimages').galleria();</script>
|
||||
[else]
|
||||
[# !! IMPROVE ME add this javascript code to the rest of galleria types]
|
||||
<script type="text/javascript">var url = window.document.URL.toString(); var num = 0; var re = /\/image:(\d+)/; var numarr = re.exec(url); if( numarr && numarr.length == 2 ) \{var num = numarr\[1\];\}; $('.galleryimages').galleria(\{show: num\});</script>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
[if gallery_mount_type_arg_is "galleria1.2.9"]
|
||||
|
||||
[if gallery_tab]
|
||||
|
||||
<ul class="galleryimages" style="width: [gallery_width]; height: [gallery_height];">
|
||||
[for gallery_tab]
|
||||
<li><a href="[gallery_tab_link]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
|
||||
|
||||
[if gallery_mount_theme_arg_is "transparent"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/galleria/themes/transparent/galleria.transparent.js');</script>
|
||||
|
||||
[if not [winix_function_param_is "image"]]
|
||||
<script type="text/javascript">Galleria.configure(\{showInfo:false\}); Galleria.run('.galleryimages');</script>
|
||||
[else]
|
||||
<script type="text/javascript">Galleria.configure(\{showInfo:false, show: [winix_function_param_value "image"]\}); Galleria.run('.galleryimages');</script>
|
||||
[end]
|
||||
|
||||
[else]
|
||||
[if gallery_mount_theme_arg_is "transparentinfo"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/galleria/themes/transparentinfo/galleria.transparent.js');</script>
|
||||
|
||||
[if not [winix_function_param_is "image"]]
|
||||
<script type="text/javascript">Galleria.configure(\{\}); Galleria.run('.galleryimages');</script>
|
||||
[else]
|
||||
<script type="text/javascript">Galleria.configure(\{show: [winix_function_param_value "image"]\}); Galleria.run('.galleryimages');</script>
|
||||
[end]
|
||||
[else]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/galleria/themes/classic/galleria.classic.js');</script>
|
||||
|
||||
[if not [winix_function_param_is "image"]]
|
||||
<script type="text/javascript">Galleria.configure(\{\}); Galleria.run('.galleryimages');</script>
|
||||
[else]
|
||||
<script type="text/javascript">Galleria.configure(\{show: [winix_function_param_value "image"]\}); Galleria.run('.galleryimages');</script>
|
||||
[end]
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
[if gallery_mount_type_arg_is "galleriathumb"]
|
||||
|
||||
[if not [winix_function_param_is "image"]]
|
||||
[if gallery_tab]
|
||||
<ul class="galleryimages">
|
||||
[for gallery_tab]
|
||||
<li><a href="[doc_base_url][dir]-/image:[gallery_tab_index]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
[else]
|
||||
[if gallery_tab]
|
||||
<ul class="galleryimages" style="width: [gallery_width]; height: [gallery_height];">
|
||||
[for gallery_tab]
|
||||
<li><a href="[gallery_tab_link]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
|
||||
[if gallery_mount_theme_arg_is "white"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/aino-galleria/themes/white/galleria.white.js');</script>
|
||||
[else]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/aino-galleria/themes/classic/galleria.classic.js');</script>
|
||||
[end]
|
||||
|
||||
<script type="text/javascript">$('.galleryimages').galleria(\{show_info:false, show: [winix_function_param_value "image"]\});</script>
|
||||
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
[if gallery_mount_type_arg_is "galleriathumb1.2.9"]
|
||||
|
||||
|
||||
[if not [winix_function_param_is "image"]]
|
||||
[if gallery_tab]
|
||||
<ul class="galleryimages">
|
||||
[for gallery_tab]
|
||||
<li><a href="[doc_base_url][dir]-/image:[gallery_tab_index]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
[else]
|
||||
|
||||
[if gallery_tab]
|
||||
|
||||
<ul class="galleryimages" style="width: [gallery_width]; height: [gallery_height];">
|
||||
[for gallery_tab]
|
||||
<li><a href="[gallery_tab_link]"><img src="[gallery_tab_link]/-/thumb" alt="[gallery_tab_subject]"></a></li>
|
||||
[end]
|
||||
</ul>
|
||||
|
||||
[if gallery_mount_theme_arg_is "transparent"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/galleria/themes/transparent/galleria.transparent.js');</script>
|
||||
<script type="text/javascript">Galleria.configure(\{showInfo:false, show: [winix_function_param_value "image"]\}); Galleria.run('.galleryimages');</script>
|
||||
[else]
|
||||
[if gallery_mount_theme_arg_is "transparentinfo"]
|
||||
<script type="text/javascript">Galleria.loadTheme('[doc_base_url_common]/galleria/themes/transparentinfo/galleria.transparent.js');</script>
|
||||
<script type="text/javascript">Galleria.configure(\{show: [winix_function_param_value "image"]\}); Galleria.run('.galleryimages');</script>
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,109 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
|
||||
<h1>Kadrowanie obrazów</h1>
|
||||
|
||||
[if item_is]
|
||||
|
||||
[if winix_function_param_is "thumb"]
|
||||
<p>Kadruj miniaturę zdjęcia, obraz oryginalny (duży) nie zostanie zmodyfikowany.</p>.
|
||||
[else]
|
||||
[if winix_function_param_is "newthumb"]
|
||||
<p>Zaznacz myszką kadr na zdjęciu, z tej części zostanie stworzona nowa miniatura, obraz oryginalny (duży) nie zostanie zmodyfikowany.</p>.
|
||||
[else]
|
||||
<p>Kadruj oryginalny obraz (miniatura nie zostanie zmodyfikowana).</p>.
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[if any item_is item_filetype_is_image]
|
||||
|
||||
<script type="text/javascript">
|
||||
var winix_jcrop;
|
||||
</script>
|
||||
|
||||
<img src="[item_link][if winix_function_param_is "thumb"]/-/thumb[end]" alt="" id="winix_imgcropper">
|
||||
|
||||
<form id="winix_cropform" action="[item_link]/imgcrop[if winix_function_param_is "thumb"]/thumb[end][if winix_function_param_is "newthumb"]/newthumb[end]" method="post">
|
||||
<input type="hidden" name="cropxtop" value="" id="winix_idcropxtop">
|
||||
<input type="hidden" name="cropytop" value="" id="winix_idcropytop">
|
||||
<input type="hidden" name="cropwidth" value="" id="winix_idcropwidth">
|
||||
<input type="hidden" name="cropheight" value="" id="winix_idcropheight">
|
||||
|
||||
[if any_not [winix_function_param_is "thumb"] [winix_function_param_is "newthumb"]]
|
||||
|
||||
[if false]
|
||||
<div class="winix_input_b">
|
||||
<input type="checkbox" name="createthumbtoo" id="winix_createthumbtooid">
|
||||
<label for="winix_createthumbtooid">Stwórz także nową miniaturę</label>
|
||||
</div>
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input type="submit" value="Kadruj">
|
||||
</form>
|
||||
|
||||
|
||||
[else]
|
||||
<p>To nie jest obrazek.</p>
|
||||
[end]
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#winix_imgcropper').Jcrop(\{boxWidth: 700, boxHeight: 450\}, function()\{winix_jcrop = this;\});
|
||||
|
||||
$('form#winix_cropform').submit(function()\{
|
||||
var c = winix_jcrop.tellSelect();
|
||||
$('form#winix_cropform input#winix_idcropxtop').val(c.x);
|
||||
$('form#winix_cropform input#winix_idcropytop').val(c.y);
|
||||
$('form#winix_cropform input#winix_idcropwidth').val(c.w);
|
||||
$('form#winix_cropform input#winix_idcropheight').val(c.h);
|
||||
|
||||
return c.w != 0 && c.h != 0;
|
||||
\});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
[else]
|
||||
|
||||
[if item_tab]
|
||||
<ul class="winix_imgcrop_list">
|
||||
[for item_tab]
|
||||
|
||||
<li>
|
||||
|
||||
<div class="winix_imgcrop_list_image">
|
||||
<img src="[item_tab_link][if item_tab_has_thumb]/-/thumb[end]" alt="[item_tab_subject]">
|
||||
</div>
|
||||
|
||||
<div class="winix_imgcrop_list_imageurl">
|
||||
[item_tab_url]
|
||||
</div>
|
||||
|
||||
<div class="winix_imgcrop_list_options">
|
||||
|
||||
<ul>
|
||||
<li><a href="[item_tab_link]/imgcrop/postredirect:[filter fil_urlencode][doc_base_url][dir]imgcrop[end]">Kadruj zdjęcie</a></li>
|
||||
<li><a href="[item_tab_link]/imgcrop/thumb/postredirect:[filter fil_urlencode][doc_base_url][dir]imgcrop[end]">Kadruj miniature</a></li>
|
||||
<li><a href="[item_tab_link]/imgcrop/newthumb/postredirect:[filter fil_urlencode][doc_base_url][dir]imgcrop[end]">Kadruj i stwórz nową miniature</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{ln_header}</h1>
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir]ln">
|
||||
<fieldset>
|
||||
<legend>{form_ln_legend}</legend>
|
||||
|
||||
<p>{ln_info}: [dir]</p>
|
||||
|
||||
<p class="withnext">{suggested_url}</p>
|
||||
<input class="edit" type="text" name="url" value="">
|
||||
|
||||
<p class="withnext">{ln_to}</p>
|
||||
<input class="edit" type="text" name="linkto" value="[dir][if item_is][item_url][end]">
|
||||
|
||||
<p>
|
||||
<label><input id="radiohard" type="radio" name="linktype" checked="checked" value="0">{ln_hardlink}</label>
|
||||
<label><input id="radiosymb" type="radio" name="linktype" value="1">{ln_symlink}</label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><input class="" type="checkbox" name="makeredirect">{ln_make_redirect}</label>
|
||||
</p>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{locale_header}</h1>
|
||||
|
||||
[if user_has_correct_locale]
|
||||
<p>{locale_your_locale}: [user_locale_name]</p>
|
||||
[else]
|
||||
<p>{locale_has_incorrect_id}</p>
|
||||
[end]
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]locale">
|
||||
<fieldset>
|
||||
<legend>{locale_form_legend}</legend>
|
||||
|
||||
<p class="withnext">{locale_select}:</p>
|
||||
|
||||
[# add to styles]
|
||||
<select name="localeid" style="width: 250px;">
|
||||
[for winix_locale_tab]
|
||||
<option value="[winix_locale_tab_id]" [if cmp user_locale_id winix_locale_tab_id]selected="selected"[end]>[winix_locale_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,51 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{login_header}</h1>
|
||||
|
||||
[if user_logged]
|
||||
<p>{logged_as_long}: [user_name]<br>
|
||||
<a href="[doc_base_url][if dir_can_read_exec][dir][if any item_is item_can_read][item_url]/[end][else]/[end]logout">{logout}</a></p>
|
||||
[else]
|
||||
|
||||
[if not ipban_is_login_allowed_from_this_ip]
|
||||
<p>{login_cannot_login_from_this_ip}<br>
|
||||
{login_cannot_login_available} [ipban_current_ip_expires_time]</p>
|
||||
[else]
|
||||
|
||||
<form method="post" action="[login_path]login">
|
||||
|
||||
<div class="winix_input_b">
|
||||
<input type="text" name="login">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_b">
|
||||
<input type="password" name="password">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_b">
|
||||
<input id="winix_login_rememberme_id" type="checkbox" name="rememberme">
|
||||
<label for="winix_login_rememberme_id">{remember_me}</label>
|
||||
</div>
|
||||
|
||||
[if login_should_use_captcha]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_rebus_id">{rebus_how_is_it} [rebus_question]?</label>
|
||||
<input id="winix_rebus_id" type="text" name="rebus">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
<input type="submit" value="{button_login}">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,137 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
|
||||
|
||||
[if winix_function_param_is "ckeditor_browse"]
|
||||
<script type="text/javascript">function select(link) \{ window.opener.CKEDITOR.tools.callFunction([ls_ckeditor_funnum_browse], link); window.close(); \} </script>
|
||||
|
||||
<div id="winix_ls_browse_leftcolumn">
|
||||
|
||||
[if dir_childs_tab "with_parent"]
|
||||
<h2>[for dir_tab]<a href="[doc_base_url][dir_tab_link]ls/ckeditor_browse/fullscreen/CKEditor:itemcontent/CKEditorFuncNum:[ls_ckeditor_funnum_browse]">[dir_tab_url]/</a>[end]</h2>
|
||||
|
||||
<ul>
|
||||
[for dir_childs_tab "with_parent"]
|
||||
<li>
|
||||
[if dir_childs_is_parent]
|
||||
[# make sure the name of the textarea in fun_ckeditor.html is called: itemcontent]
|
||||
[# is it needed?]
|
||||
<a href="[doc_base_url][dir_parent]ls/ckeditor_browse/fullscreen/CKEditor:itemcontent/CKEditorFuncNum:[ls_ckeditor_funnum_browse]">../</a>
|
||||
[else]
|
||||
<a href="[doc_base_url][dir][dir_childs_tab_url]/ls/ckeditor_browse/fullscreen/CKEditor:itemcontent/CKEditorFuncNum:[ls_ckeditor_funnum_browse]">[dir_childs_tab_url]/</a>
|
||||
[end]
|
||||
</li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
|
||||
</div>
|
||||
|
||||
<div id="winix_ls_browse_rightcolumn">
|
||||
|
||||
[if item_tab]
|
||||
|
||||
<h2>{ls_pictures_in_dir} [dir]</h2>
|
||||
<ul>
|
||||
|
||||
[for item_tab]
|
||||
<li><a href="javascript:select('[item_tab_link]')"><img src="[item_tab_link]/-/thumb" alt="[item_tab_subject]" height="120"></a></li>
|
||||
[end]
|
||||
|
||||
</ul>
|
||||
[else]
|
||||
<h2>{ls_no_picture}</h2>
|
||||
[end]
|
||||
|
||||
</div>
|
||||
|
||||
[else]
|
||||
|
||||
<h1>{ls_header}</h1>
|
||||
|
||||
[if not item_is]
|
||||
|
||||
[if winix_function_param_is "l"]
|
||||
|
||||
[# loading dir childs table with a parent directory]
|
||||
[# now the parameter can be passed directly to if-one]
|
||||
[dir_childs_tab "with_parent"]
|
||||
|
||||
[if one dir_childs_tab item_tab]
|
||||
|
||||
<table>
|
||||
[for dir_childs_tab]
|
||||
<tr>
|
||||
<td>d</td>
|
||||
<td>[dir_childs_tab_privileges]</td>
|
||||
<td>[dir_childs_tab_user]</td>
|
||||
<td>[dir_childs_tab_group]</td>
|
||||
<td>
|
||||
[if dir_childs_is_parent]
|
||||
<a href="[doc_base_url][dir_parent_without_slash][if winix_function_param_is "dirls"]/ls/l/dirls[end]">../</a>
|
||||
[else]
|
||||
<a href="[doc_base_url][dir][dir_childs_tab_url][if winix_function_param_is "dirls"]/ls/l/dirls[end]">[dir_childs_tab_url]/</a>
|
||||
[end]
|
||||
</td>
|
||||
</tr>
|
||||
[end]
|
||||
|
||||
[for item_tab]
|
||||
<tr>
|
||||
<td>[if item_tab_type_is_symlink]l[else][if item_tab_has_static_file]s[else]-[end][end]</td>
|
||||
<td>[item_tab_privileges]</td>
|
||||
<td>[item_tab_user]</td>
|
||||
<td>[item_tab_group]</td>
|
||||
<td><a href="[doc_base_url][dir][item_tab_url]">[item_tab_url]</a>[if item_tab_type_is_symlink] -> [item_tab_link_to][end]</td>
|
||||
</tr>
|
||||
[end]
|
||||
</table>
|
||||
|
||||
[end]
|
||||
|
||||
[else]
|
||||
|
||||
[# loading dir childs table with a parent directory]
|
||||
[dir_childs_tab "with_parent"]
|
||||
|
||||
[if dir_childs_tab]
|
||||
<ul>
|
||||
[for dir_childs_tab]
|
||||
<li>
|
||||
[if dir_childs_is_parent]
|
||||
<a href="[doc_base_url][dir_parent_without_slash][if winix_function_param_is "dirls"]/ls/dirls[end]">../</a>
|
||||
[else]
|
||||
<a href="[doc_base_url][dir][dir_childs_tab_url][if winix_function_param_is "dirls"]/ls/dirls[end]">[dir_childs_tab_url]/</a>
|
||||
[end]
|
||||
</li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
|
||||
[if item_tab]
|
||||
<ul>
|
||||
[for item_tab]
|
||||
<li><a href="[doc_base_url][dir][item_tab_url]">[item_tab_url]</a></li>
|
||||
[end]
|
||||
</ul>
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
[else]
|
||||
|
||||
<ul>
|
||||
<li><a href="[doc_base_url][dir][item_url]">[item_url]</a></li>
|
||||
</ul>
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{man_header}</h1>
|
||||
|
||||
<h2>{man_winix_funcions}</h2>
|
||||
|
||||
<table>
|
||||
|
||||
[for man_winixfun_tab]
|
||||
<tr>
|
||||
<td>[man_winixfun_tab_index]</td>
|
||||
<td>[man_winixfun_tab_name]</td>
|
||||
</tr>
|
||||
[end]
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<h2>{man_ezc_functions}</h2>
|
||||
|
||||
<table>
|
||||
|
||||
[for man_ezcfun_tab]
|
||||
<tr>
|
||||
<td>[man_ezcfun_tab_index]</td>
|
||||
<td>[man_ezcfun_tab_name]</td>
|
||||
</tr>
|
||||
[end]
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
@@ -1,62 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[if winix_function_param_is "a"]
|
||||
<h1>{meta_admin_header}</h1>
|
||||
|
||||
[if item_is]
|
||||
<form method="post" action="[doc_base_url][dir][item_url]/meta/a">
|
||||
|
||||
<textarea class="multitext" rows="30" cols="60" name="itemmeta">[item_admin_meta_str]</textarea>
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
</form>
|
||||
[else]
|
||||
<form method="post" action="[doc_base_url][dir]meta/a">
|
||||
|
||||
<textarea class="multitext" rows="30" cols="60" name="itemmeta">[dir_last_admin_meta_str]</textarea>
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
</form>
|
||||
[end]
|
||||
|
||||
|
||||
[else]
|
||||
|
||||
<h1>{meta_header}</h1>
|
||||
|
||||
[if item_is]
|
||||
<form method="post" action="[doc_base_url][dir][item_url]/meta">
|
||||
|
||||
<textarea class="multitext" rows="30" cols="60" name="itemmeta">[item_meta_str]</textarea>
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
</form>
|
||||
[else]
|
||||
<form method="post" action="[doc_base_url][dir]meta">
|
||||
|
||||
<textarea class="multitext" rows="30" cols="60" name="itemmeta">[dir_last_meta_str]</textarea>
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
</form>
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,25 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{mkdir_header}</h1>
|
||||
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir]mkdir">
|
||||
<fieldset>
|
||||
<legend>{mkdir_form_legend}</legend>
|
||||
<p class="withnext">{title}</p>
|
||||
<input class="edit" type="text" name="subject" value="">
|
||||
<p class="withnext">{suggested_url}</p>
|
||||
<input class="edit" type="text" name="url" value="">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="{add}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{mv_header}</h1>
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]mv">
|
||||
<fieldset>
|
||||
<legend>{mv_form_legend}</legend>
|
||||
|
||||
<p>
|
||||
[if item_is]{mv_page} [item_url]:[else]{mv_dir} [dir][end]
|
||||
</p>
|
||||
|
||||
|
||||
<p class="withnext">{suggested_url}</p>
|
||||
<input class="edit" type="text" name="dst_path" value="[dir_without_slash][if item_is]/[item_url][end]">
|
||||
|
||||
|
||||
[if not item_is]
|
||||
<label><input type="checkbox" name="c"[if winix_function_param_is "c"]checked="checked"[end]>{mv_only_content}</label>
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="{move}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[if item_is]<h1>{edit}</h1>[else]<h1>{add}</h1>[end]
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]nicedit">
|
||||
<fieldset>
|
||||
<legend>{form_emacs_legend}</legend>
|
||||
|
||||
[if mount_type_is "cms"]
|
||||
<p class="withnext">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
|
||||
<p class="withnext">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
[end]
|
||||
|
||||
[if any [mount_type_is "thread"] [thread_mount_arg_is "subject"]]
|
||||
<p class="withnext">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
|
||||
<p class="withnext">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
[end]
|
||||
|
||||
[if mount_type_is "cms"]<p class="withnext">{form_emacs_content_cms}</p>[end]
|
||||
[if mount_type_is "thread"]<p class="withnext">{form_emacs_content_thread}</p>[end]
|
||||
[if mount_type_is "ticket"]<p class="withnext">{form_emacs_content_ticket}</p>[end]
|
||||
|
||||
<textarea class="multitext" rows="[if mount_type_is "cms"]30[else]10[end]" cols="60" name="itemcontent" id="nicarea">[item_content]</textarea>
|
||||
|
||||
<input type="hidden" name="contenttype" value="2">
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
new nicEditor(\{fullPanel:true, iconsPath:'[doc_base_url_common]/nicedit/nicEditorIcons.gif', uploadURI:'[doc_base_url][dir]upload/' \}).panelInstance('nicarea');
|
||||
</script>
|
||||
|
||||
[if winix_function_param_is "full"]
|
||||
|
||||
[else]
|
||||
|
||||
[end]
|
||||
|
||||
[if not user_logged]
|
||||
<p class="withnext">{nick}:</p>
|
||||
<input class="edit" type="text" name="guestname" value="[item_guest_name]">
|
||||
|
||||
<p class="withnext">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input class="edit" type="text" name="rebus">
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="[if item_is]{change}[else]{add}[end]">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,71 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{passwd_header}</h1>
|
||||
|
||||
|
||||
[if winix_function_param_is "resetpassword"]
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir]passwd/resetpassword">
|
||||
<fieldset>
|
||||
<legend>{passwd_form_legend}</legend>
|
||||
|
||||
<input type="hidden" name="login" value="[passwd_resetpass_login]">
|
||||
<input type="hidden" name="code" value="[passwd_resetpass_code]">
|
||||
|
||||
<p class="withnext">{passwd_new_password}:</p>
|
||||
<input class="edit" type="password" name="passwordnew" value="">
|
||||
|
||||
<p class="withnext">{passwd_confirm_new_password}:</p>
|
||||
<input class="edit" type="password" name="passwordconfirm" value="">
|
||||
|
||||
<input class="submit" type="submit" value="{passwd_submit}">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
[else]
|
||||
|
||||
<form method="post" action="[doc_base_url][dir]passwd">
|
||||
|
||||
[if user_super_user]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_users_id">{passwd_login}:</label>
|
||||
<select name="login" id="winix_users_id">
|
||||
[for user_tab]
|
||||
<option [if user_tab_is_current]selected[end]>[user_tab_name]</option>
|
||||
[end]
|
||||
</div>
|
||||
</select>
|
||||
[else]
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_current_pass_id">{passwd_current_password}:</label>
|
||||
<input id="winix_current_pass_id" type="password" name="passwordcur" value="">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_pass_new_id">{passwd_new_password}:</label>
|
||||
<input id="winix_pass_new_id" type="password" name="passwordnew" value="">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_pass_new_confirm_id">{passwd_confirm_new_password}:</label>
|
||||
<input id="winix_pass_new_confirm_id" type="password" name="passwordconfirm" value="">
|
||||
</div>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input type="submit" value="{passwd_submit}">
|
||||
|
||||
</form>
|
||||
|
||||
[end]
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[# this template is for following functions: priv, chmod, chown]
|
||||
|
||||
|
||||
<h1>{priv_header}</h1>
|
||||
|
||||
|
||||
|
||||
[if not [winix_function_param_is "r"]]
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end][winix_function]">
|
||||
<fieldset>
|
||||
<legend>{priv_form_legend}</legend>
|
||||
|
||||
<table class="withoutborder">
|
||||
|
||||
[if priv_show_form_chown]
|
||||
|
||||
<tr><th>{user}:</th><td>
|
||||
<select name="user" class="users">
|
||||
[for priv_user_tab]
|
||||
<option[if priv_user_tab_isdefault] selected[end]>[priv_user_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><th>{group}: </th><td>
|
||||
<select name="group" class="groups">
|
||||
[for priv_group_tab]
|
||||
<option[if priv_group_tab_isdefault] selected[end]>[priv_group_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
[end]
|
||||
|
||||
[if priv_show_form_chmod]
|
||||
<tr><th>{permissions}:</th><td><input class="privileges" type="text" name="privileges" value="[priv_privileges]"></td></tr>
|
||||
[end]
|
||||
|
||||
</table>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
[else]
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][winix_function]/r">
|
||||
<fieldset>
|
||||
<legend>{priv_form_legend}</legend>
|
||||
<p class="withnext">{priv_change_in_dir}: [dir]</p>
|
||||
|
||||
<h2>{priv_for_all_files}:</h2>
|
||||
<table class="withoutborder">
|
||||
|
||||
[if priv_show_form_chown]
|
||||
<tr><th>{user}:</th><td>
|
||||
<select name="userfile" class="users">
|
||||
[for priv_user_tab]
|
||||
<option[if priv_user_tab_isdefault] selected[end]>[priv_user_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><th>{group}: </th><td>
|
||||
<select name="groupfile" class="groups">
|
||||
[for priv_group_tab]
|
||||
<option[if priv_group_tab_isdefault] selected[end]>[priv_group_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
</td></tr>
|
||||
[end]
|
||||
|
||||
[if priv_show_form_chmod]
|
||||
<tr><th>{permissions}:</th><td><input class="privileges" type="text" name="privilegesfile" value="[priv_privileges_for_files]"></td></tr>
|
||||
[end]
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<h2>{priv_for_all_dirs}:</h2>
|
||||
<table class="withoutborder">
|
||||
|
||||
[if priv_show_form_chown]
|
||||
<tr><th>{user}:</th><td>
|
||||
<select name="userdir" class="users">
|
||||
[for priv_user_tab]
|
||||
<option[if priv_user_tab_isdefault] selected[end]>[priv_user_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><th>{group}: </th><td>
|
||||
<select name="groupdir" class="groups">
|
||||
[for priv_group_tab]
|
||||
<option[if priv_group_tab_isdefault] selected[end]>[priv_group_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
</td></tr>
|
||||
[end]
|
||||
|
||||
[if priv_show_form_chmod]
|
||||
<tr><th>{permissions}:</th><td><input class="privileges" type="text" name="privilegesdir" value="[priv_privileges_for_dirs]"></td></tr>
|
||||
[end]
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
<label><input class="check" type="checkbox" name="changesubdirs">{priv_change_all}</label>
|
||||
<label><input class="check" type="checkbox" name="changecurrentdir">{priv_change_current_dir}: [dir_without_slash]</label>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{thread_header_reply}</h1>
|
||||
|
||||
|
||||
<form method="post" action="[doc_base_url][dir][item_url]/reply">
|
||||
|
||||
[if thread_mount_arg_is "subject"]
|
||||
<div class="winix_input_a">
|
||||
<label for="">{title}:</label>
|
||||
<input type="text" name="subject" value="">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="">{suggested_url}:</label>
|
||||
<input type="text" name="url" value="">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
|
||||
<div class="winix_input_a">
|
||||
[if mount_type_is "thread"]<label for="winix_content_id">{form_emacs_content_thread}</label>[end]
|
||||
<textarea id="winix_content_id" rows="10" cols="60" name="itemcontent"></textarea>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="">{form_emacs_content_type}</label>
|
||||
<select name="contenttype">
|
||||
<option value="0">{form_emacs_content_type_text}</option>
|
||||
<option selected value="1">{form_emacs_content_type_formatted_text}</option>
|
||||
[if user_can_use_html]<option value="2">{form_emacs_content_type_html}</option>[end]
|
||||
[if user_can_use_bbcode]<option value="3">{form_emacs_content_type_bbcode}</option>[end]
|
||||
[if user_can_use_raw]<option value="4">{form_emacs_content_type_raw}</option>[end]
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
[if not user_logged]
|
||||
<div class="winix_input_a">
|
||||
<label for="">{nick}:</label>
|
||||
<input type="text" name="guestname" value="">
|
||||
</div>
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input type="text" name="rebus">
|
||||
</div>
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
|
||||
<input type="submit" value="{add}">
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
@@ -1,45 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{rm_header}</h1>
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]rm[if not item_is]/r[end]">
|
||||
<fieldset>
|
||||
<legend>{rm_form_legend}</legend>
|
||||
|
||||
<p>
|
||||
[if item_is]
|
||||
|
||||
[if item_type_is_symlink]
|
||||
{rm_symlink}: [dir][item_url]
|
||||
[else]
|
||||
{rm_file}: [dir][item_url]
|
||||
[end]
|
||||
|
||||
[else]
|
||||
|
||||
[if dir_is_root]
|
||||
{rm_root}
|
||||
[else]
|
||||
{rm_dir}: [dir_without_slash]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
</p>
|
||||
|
||||
|
||||
[if not item_is]
|
||||
<p>
|
||||
<label><input type="checkbox" name="c" [if winix_function_param_is "c"]checked="checked"[end]>{rm_only_content}</label>
|
||||
</p>
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="{rm_submit}">
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
@@ -1,36 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{rmuser_header}</h1>
|
||||
|
||||
[if user_logged]
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]rmuser">
|
||||
<fieldset>
|
||||
<legend>{rmuser_legend}</legend>
|
||||
|
||||
[if user_super_user]
|
||||
|
||||
<p class="withnext">{rmuser_selectuser}:</p>
|
||||
<select name="userid">
|
||||
[for user_tab]
|
||||
<option value="[user_tab_id]">[user_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
|
||||
[else]
|
||||
<p>{rmuser_removecurrent}</p>
|
||||
<input type="hidden" value="[user_id]">
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input type="submit" value="{rmuser_submit}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
[end]
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<div>
|
||||
[if mount_page_arg_is "subject"]
|
||||
[if mount_page_arg_is "info"]
|
||||
<h1 class="withinfo">
|
||||
[else]
|
||||
<h1>
|
||||
[end]
|
||||
|
||||
[item_subject]
|
||||
</h1>
|
||||
|
||||
[end]
|
||||
|
||||
[if mount_page_arg_is "info"]
|
||||
[include "item_info.html"]
|
||||
[end]
|
||||
|
||||
[item_run]
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[if mount_page_arg_is "subject"]<h1[if mount_page_arg_is "info"] class="withinfo"[end]>[dir_last_subject]</h1>[end]
|
||||
[if mount_page_arg_is "info"][include "dir_last_info.html"][end]
|
||||
|
||||
|
||||
[if thread_can_create]
|
||||
<div class="winix_itemoptions_b">
|
||||
<ul>
|
||||
<li><a href="[doc_base_url][dir]createthread" rel="nofollow">{thread_create_new}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
[end]
|
||||
|
||||
|
||||
[if thread_sort_tab]
|
||||
<table class="winix_forum">
|
||||
<tr><th>{thread_tab_title}</th><th>{thread_tab_author}</th><th>{thread_tab_replies}</th><th>{thread_tab_last_post}</th></tr>
|
||||
[for thread_sort_tab]
|
||||
<tr>
|
||||
<td><a href="[doc_base_url][dir][thread_sort_tab_url]">[thread_sort_tab_subject]</a></td> [# dodac sprawdzanie subject empty]
|
||||
<td class="smallfont">[thread_sort_tab_user]</td><td class="smallfont">[thread_sort_tab_replies]</td>
|
||||
<td class="smallfont">[thread_sort_tab_last_item_date_modification_nice] ([thread_sort_tab_last_item_user])</td>
|
||||
</tr>
|
||||
[end]
|
||||
</table>
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{sort_header}</h1>
|
||||
|
||||
|
||||
[if item_is]
|
||||
|
||||
|
||||
|
||||
<form class="winix_sortable_form" action="[doc_base_url][dir][item_url]/sort" method="post">
|
||||
|
||||
<div class="winix_input_b">
|
||||
<label for="">{sort_current_sortindex}:</p>
|
||||
<input type="text" name="sortindex" value="[item_sort]">
|
||||
</div>
|
||||
|
||||
<input type="submit" value="{change}">
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
</form>
|
||||
|
||||
[else]
|
||||
|
||||
<p>{sort_info_multi}</p>
|
||||
|
||||
[if item_tab]
|
||||
<form class="winix_sortable_form" action="[doc_base_url][dir]sort" method="post">
|
||||
<ul id="winix_sort_items">
|
||||
[for item_tab]
|
||||
<li id="winix_sort_item_[item_tab_index]">
|
||||
<input type="text" name="sort[item_tab_id]" value="[item_tab_sort]">
|
||||
|
||||
[# is it correct? may give this 'if' only to /-/thumb param? ]
|
||||
[if item_tab_has_thumb]<img src="[item_tab_link]/-/thumb" alt="[item_tab_subject]">[end]
|
||||
|
||||
[item_tab_url] [if not [is item_tab_subject ""]]<span class="winix_sort_item_title">({sort_item_subject}: [item_tab_subject])</span>[end]
|
||||
</li>
|
||||
[end]
|
||||
</ul>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input type="submit" value="{change}">
|
||||
</form>
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
</div>
|
||||
@@ -1,23 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{subject_header}</h1>
|
||||
|
||||
|
||||
<form method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]subject">
|
||||
|
||||
<div class="winix_input_a">
|
||||
<label for="winix_title_id">{title}</label>
|
||||
<input id="winix_title_id" type="text" name="subject" value="[if item_is][item_subject][else][dir_last_subject][end]">
|
||||
</div>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,73 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{template_header}</h1>
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
[if item_is]
|
||||
|
||||
{template_info_file}:
|
||||
|
||||
[if item_has_html_template]
|
||||
[item_html_template]
|
||||
[else]
|
||||
{template_from_mount_point}
|
||||
|
||||
[if mount_has_html_template]
|
||||
([mount_first_html_template])
|
||||
[else]
|
||||
([template_index])
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[else]
|
||||
|
||||
{template_info_dir}:
|
||||
|
||||
[if dir_last_has_html_template]
|
||||
[dir_last_html_template]
|
||||
[else]
|
||||
{template_from_mount_point}
|
||||
|
||||
[if mount_has_html_template]
|
||||
([mount_first_html_template])
|
||||
[else]
|
||||
([template_index])
|
||||
[end]
|
||||
[end]
|
||||
|
||||
[end]
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]template">
|
||||
<fieldset>
|
||||
<legend>{template_form_legend}</legend>
|
||||
|
||||
{template_form_info}:
|
||||
|
||||
<select name="template" class="template">
|
||||
|
||||
[# the first should be an empty string (value="") which means: a first template from the mount point]
|
||||
<option value="-1">({template_form_from_mount_point})</option>
|
||||
|
||||
[for template_tab]
|
||||
<option value="[template_tab_index]"[if template_tab_isdefault] selected[end]>[template_tab_file_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[if mount_page_arg_is "subject"]<h1[if mount_page_arg_is "info"] class="winix_withinfo"[end]>[item_subject]</h1>[end]
|
||||
[if mount_page_arg_is "info"][include "item_info.html"][end]
|
||||
|
||||
|
||||
[if thread_can_reply]
|
||||
<div class="winix_itemoptions_b">
|
||||
<ul>
|
||||
<li><a href="[doc_base_url][dir][item_url]/reply" rel="nofollow">{thread_reply_in_this_thread}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
[end]
|
||||
|
||||
[if not [thread_mount_arg_is "sort_desc"]]
|
||||
<div class="winix_threadbox">
|
||||
[if item_can_write]<a class="winix_threadedit" href="[item_link]/emacs" rel="nofollow">\[{edit}\]</a>[end]
|
||||
[if thread_mount_arg_is "subject"]<h2[if thread_mount_arg_is "info"] class="winix_withinfo"[end]>[item_subject]</h2>[end]
|
||||
[if thread_mount_arg_is "info"][include "item_info.html"][end]
|
||||
[item_print_content]
|
||||
</div>
|
||||
[end]
|
||||
|
||||
|
||||
[for thread_sort_tab]
|
||||
<div class="winix_threadbox[if index "even"] winix_threadboxcolor[end]">
|
||||
[if thread_sort_tab_can_write]<a class="winix_threadedit" href="[thread_sort_tab_link]/emacs" rel="nofollow">\[{edit}\]</a>[end]
|
||||
[if thread_mount_arg_is "subject"]<h2[if thread_mount_arg_is "info"] class="winix_withinfo"[end]>[thread_sort_tab_subject]</h2>[end]
|
||||
[if thread_mount_arg_is "info"][include "thread_sort_tab_info.html"][end]
|
||||
[thread_sort_tab_print_content]
|
||||
</div>
|
||||
[end]
|
||||
|
||||
[if thread_mount_arg_is "sort_desc"]
|
||||
<div class="winix_threadbox">
|
||||
[if item_can_write]<a class="winix_threadedit" href="[item_link]/emacs" rel="nofollow">\[{edit}\]</a>[end]
|
||||
[if thread_mount_arg_is "subject"]<h2[if thread_mount_arg_is "info"] class="winix_withinfo"[end]>[item_subject]</h2>[end]
|
||||
[if thread_mount_arg_is "info"][include "item_info.html"][end]
|
||||
[item_print_content]
|
||||
</div>
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{timezone_header}</h1>
|
||||
|
||||
[if user_has_correct_time_zone]
|
||||
<p>{timezone_your_zone}: [user_time_zone_name] (UTC[user_time_zone_offset_hour_min])</p>
|
||||
[else]
|
||||
<p>{timezone_has_incorrect_id}</p>
|
||||
[end]
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]timezone">
|
||||
<fieldset>
|
||||
<legend>{timezone_form_legend}</legend>
|
||||
|
||||
<p class="withnext">{timezone_select}:</p>
|
||||
|
||||
[# add to styles]
|
||||
<select name="timezoneid" style="width: 250px;">
|
||||
[for winix_tz_tab]
|
||||
<option value="[winix_tz_tab_id]" [if cmp user_time_zone_id winix_tz_tab_id]selected="selected"[end]>UTC[winix_tz_tab_offset_hour_min] [winix_tz_tab_name]</option>
|
||||
[end]
|
||||
</select>
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="{change}">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[if item_is]<h1>{edit}</h1>[else]<h1>{add}</h1>[end]
|
||||
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]tinymce">
|
||||
<fieldset>
|
||||
<legend>{form_emacs_legend}</legend>
|
||||
|
||||
[if mount_type_is "cms"]
|
||||
<p class="withnext">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
|
||||
<p class="withnext">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
[end]
|
||||
|
||||
[if any [mount_type_is "thread"] [thread_mount_arg_is "subject"]]
|
||||
<p class="withnext">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
|
||||
<p class="withnext">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
[end]
|
||||
|
||||
|
||||
[if mount_type_is "cms"]<p class="withnext">{form_emacs_content_cms}</p>[end]
|
||||
[if mount_type_is "thread"]<p class="withnext">{form_emacs_content_thread}</p>[end]
|
||||
[if mount_type_is "ticket"]<p class="withnext">{form_emacs_content_ticket}</p>[end]
|
||||
|
||||
<textarea class="multitext" rows="[if mount_type_is "cms"]30[else]10[end]" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
|
||||
<input type="hidden" name="contenttype" value="2">
|
||||
|
||||
[if not user_logged]
|
||||
<p class="withnext">{nick}:</p>
|
||||
<input class="edit" type="text" name="guestname" value="[item_guest_name]">
|
||||
|
||||
<p class="withnext">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input class="edit" type="text" name="rebus">
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="[if item_is]{change}[else]{add}[end]">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,21 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{uname_header}</h1>
|
||||
|
||||
<p>Winix [sys_ver_major].[sys_ver_minor].[sys_ver_revision]</p>
|
||||
|
||||
[if sys_plugin_tab]
|
||||
|
||||
{uname_available_plugins}:
|
||||
<ul>
|
||||
|
||||
[for sys_plugin_tab]
|
||||
<li>[if sys_plugin_tab_has_name][sys_plugin_tab_name][else]<{uname_plugin_unknown}>[end]</li>
|
||||
[end]
|
||||
|
||||
</ul>
|
||||
|
||||
[end]
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,150 +0,0 @@
|
||||
|
||||
|
||||
[if winix_function_param_is "ckeditor_upload"]
|
||||
<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction([upload_ckeditor_funnum], '[item_link]');</script>
|
||||
[end]
|
||||
|
||||
|
||||
[if any_not [winix_function_param_is "ckeditor_upload"] [winix_function_param_is "jquery_upload"]]
|
||||
<div class="winix">
|
||||
|
||||
<h1>{upload_header}</h1>
|
||||
|
||||
[# the code below are copied from common/fileupload/jquery-ui.html]
|
||||
[# The file upload form used as target for the file upload widget]
|
||||
<form id="fileupload" action="[doc_base_url][dir]/upload" method="POST" enctype="multipart/form-data">
|
||||
|
||||
[# The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload]
|
||||
<div class="fileupload-buttonbar">
|
||||
<div class="fileupload-buttons">
|
||||
[# The fileinput-button span is used to style the file input field as button]
|
||||
<span class="fileinput-button">
|
||||
<span>{upload_button_add_files}</span>
|
||||
<input type="file" name="files\[\]" multiple>
|
||||
</span>
|
||||
<button type="submit" class="start">{upload_button_start_upload}</button>
|
||||
<button type="reset" class="cancel">{upload_button_cancel_upload}</button>
|
||||
<button type="button" class="delete">{upload_button_delete}</button>
|
||||
<input type="checkbox" class="toggle">
|
||||
[# The global file processing state]
|
||||
<span class="fileupload-process"></span>
|
||||
</div>
|
||||
[# The global progress state]
|
||||
<div class="fileupload-progress fade" style="display:none">
|
||||
[# The global progress bar]
|
||||
<div class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
[# The extended global progress state]
|
||||
<div class="progress-extended"> </div>
|
||||
</div>
|
||||
</div>
|
||||
[# The table listing the files available for upload/download]
|
||||
<table role="presentation"><tbody class="files"></tbody></table>
|
||||
</form>
|
||||
|
||||
|
||||
[# The blueimp Gallery widget]
|
||||
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-filter=":even">
|
||||
<div class="slides"></div>
|
||||
<h3 class="title"></h3>
|
||||
<a class="prev">‹</a>
|
||||
<a class="next">›</a>
|
||||
<a class="close">×</a>
|
||||
<a class="play-pause"></a>
|
||||
<ol class="indicator"></ol>
|
||||
</div>
|
||||
|
||||
[# The template to display files available for upload]
|
||||
<script id="template-upload" type="text/x-tmpl">
|
||||
\{% for (var i=0, file; file=o.files\[i\]; i++) \{ %\}
|
||||
<tr class="template-upload fade">
|
||||
<td>
|
||||
<span class="preview"></span>
|
||||
</td>
|
||||
<td>
|
||||
<p class="name">\{%=file.name%\}</p>
|
||||
<strong class="error"></strong>
|
||||
</td>
|
||||
<td>
|
||||
<p class="size">{upload_button_processing}</p>
|
||||
<div class="progress"></div>
|
||||
</td>
|
||||
<td>
|
||||
\{% if (!i && !o.options.autoUpload) \{ %\}
|
||||
<button class="start" disabled>{upload_button_start}</button>
|
||||
\{% \} %\}
|
||||
\{% if (!i) \{ %\}
|
||||
<button class="cancel">{upload_button_cancel}</button>
|
||||
\{% \} %\}
|
||||
</td>
|
||||
</tr>
|
||||
\{% \} %\}</script>
|
||||
|
||||
[# The template to display files available for download]
|
||||
<script id="template-download" type="text/x-tmpl">
|
||||
\{% for (var i=0, file; file=o.files\[i\]; i++) \{ %\}
|
||||
<tr class="template-download fade">
|
||||
<td>
|
||||
<span class="preview">
|
||||
\{% if (file.thumbnailUrl) \{ %\}
|
||||
<a href="\{%=file.url%\}" title="\{%=file.name%\}" download="\{%=file.name%\}" data-gallery><img src="\{%=file.thumbnailUrl%\}"></a>
|
||||
\{% \} %\}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<p class="name">
|
||||
<a href="\{%=file.url%\}" title="\{%=file.name%\}" download="\{%=file.name%\}" \{%=file.thumbnailUrl?'data-gallery':''%\}>\{%=file.name%\}</a>
|
||||
</p>
|
||||
\{% if (file.error) \{ %\}
|
||||
<div><span class="error">{upload_error}</span> \{%=file.error%\}</div>
|
||||
\{% \} %\}
|
||||
</td>
|
||||
<td>
|
||||
<span class="size">\{%=o.formatFileSize(file.size)%\}</span>
|
||||
</td>
|
||||
<td>
|
||||
<button class="delete" data-type="\{%=file.deleteType%\}" data-url="\{%=file.deleteUrl%\}"\{% if (file.deleteWithCredentials) \{ %\} data-xhr-fields='\{"withCredentials":true\}'\{% \} %\}>{upload_button_delete}</button>
|
||||
<input type="checkbox" name="delete" value="1" class="toggle">
|
||||
</td>
|
||||
</tr>
|
||||
\{% \} %\}</script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#fileupload button.start').css('display', 'none');
|
||||
|
||||
$('#fileupload').fileupload(\{
|
||||
"url": "[doc_base_url][dir]upload/jquery_upload",
|
||||
"autoUpload": true
|
||||
\});
|
||||
|
||||
$('#fileupload').fileupload(
|
||||
'option',
|
||||
'redirect',
|
||||
window.location.href.replace(
|
||||
/\/\[^\/\]*$/,
|
||||
'/cors/result.html?%s'
|
||||
));
|
||||
|
||||
$("div.winix #fileupload button.cancel").css('display','inline');
|
||||
|
||||
[# loading existing files]
|
||||
[# copied from common/fileupload/js/main.js]
|
||||
$('#fileupload').addClass('fileupload-processing');
|
||||
$.ajax(\{
|
||||
[# // Uncomment the following to send cross-domain cookies:]
|
||||
[# //xhrFields: \{withCredentials: true\},]
|
||||
url: $('#fileupload').fileupload('option', 'url'),
|
||||
dataType: 'json',
|
||||
context: $('#fileupload')\[0\]
|
||||
\}).always(function () \{
|
||||
$(this).removeClass('fileupload-processing');
|
||||
\}).done(function (result) \{
|
||||
$(this).fileupload('option', 'done')
|
||||
.call(this, $.Event('done'), \{result: result\});
|
||||
\});</script>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
[end]
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
<h1>{uptime_header}</h1>
|
||||
|
||||
<p>{uptime_current_time}: [winix_cur_time]<br>
|
||||
{uptime_up}:
|
||||
|
||||
[if uptime_more_than_one_day]
|
||||
[uptime_days] {uptime_days}
|
||||
[else]
|
||||
[uptime_hours]
|
||||
[end]
|
||||
<br>
|
||||
{uptime_how_many_sessions}: [winix_how_many_sessions]<br>
|
||||
{uptime_users_logged}: [winix_users_logged]<br>
|
||||
{load_avg}: [winix_loadavg_now], [winix_loadavg_1], [winix_loadavg_5], [winix_loadavg_15]<br>
|
||||
{req_per_sec}: [winix_req_per_sec_now], [winix_req_per_sec_1], [winix_req_per_sec_5], [winix_req_per_sec_15]
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,55 +0,0 @@
|
||||
<div class="winix">
|
||||
|
||||
[if item_is]<h1>{edit}</h1>[else]<h1>{add}</h1>[end]
|
||||
|
||||
|
||||
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]vim">
|
||||
<fieldset>
|
||||
<legend>{form_emacs_legend}</legend>
|
||||
|
||||
[if mount_type_is "cms"]
|
||||
<p class="withnext">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
|
||||
<p class="withnext">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
[end]
|
||||
|
||||
[if any [mount_type_is "thread"] [thread_mount_arg_is "subject"]]
|
||||
<p class="withnext">{title}:</p>
|
||||
<input class="edit" type="text" name="subject" value="[item_subject]">
|
||||
|
||||
<p class="withnext">{suggested_url}:</p>
|
||||
<input class="edit" type="text" name="url" value="[item_url]">
|
||||
[end]
|
||||
|
||||
[if mount_type_is "cms"]<p class="withnext">{form_emacs_content_cms}</p>[end]
|
||||
[if mount_type_is "thread"]<p class="withnext">{form_emacs_content_thread}</p>[end]
|
||||
[if mount_type_is "ticket"]<p class="withnext">{form_emacs_content_ticket}</p>[end]
|
||||
|
||||
<textarea class="multitext" rows="[if mount_type_is "cms"]30[else]10[end]" cols="60" name="itemcontent">[item_content]</textarea>
|
||||
|
||||
<input type="hidden" name="contenttype" value="2">
|
||||
|
||||
[if winix_function_param_is "full"]
|
||||
[else]
|
||||
[end]
|
||||
|
||||
[if not user_logged]
|
||||
<p class="withnext">{nick}:</p>
|
||||
<input class="edit" type="text" name="guestname" value="[item_guest_name]">
|
||||
|
||||
<p class="withnext">{rebus_how_is_it} [rebus_question]?</p>
|
||||
<input class="edit" type="text" name="rebus">
|
||||
[end]
|
||||
|
||||
[if winix_function_param_is "postredirect"]
|
||||
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
|
||||
[end]
|
||||
|
||||
<input class="submit" type="submit" value="[if item_is]{change}[else]{add}[end]">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user