From 3b655f39e13265bd55c3b60cf2aadd273477a84b Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Tue, 17 Aug 2010 22:32:47 +0000 Subject: [PATCH] added: plugins_dir to config small changes in makefiles git-svn-id: svn://ttmath.org/publicrep/winix/trunk@643 e52654a7-88a9-db11-a3e9-0013d4bc506e --- Makefile | 34 +++++++++++++++++++++++++--------- core/app.cpp | 2 +- core/config.cpp | 2 ++ core/config.h | 6 ++++++ core/plugin.cpp | 20 +++++++++++++++----- core/plugin.h | 3 ++- functions/createthread.cpp | 10 ++++++++-- functions/createthread.h | 1 + functions/createticket.cpp | 9 ++++++--- functions/createticket.h | 1 + html/fun_ckeditor.html | 3 +-- main/main.cpp | 4 ++-- static/layout1/winix.css | 1 + templates/thread.cpp | 3 +-- templates/ticket.cpp | 3 +-- 15 files changed, 73 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 05ab6f4..bfa00c6 100755 --- a/Makefile +++ b/Makefile @@ -5,16 +5,16 @@ CXX = g++ endif ifndef CXXFLAGS -#CXXFLAGS = -fPIC -Wall -pedantic -O2 -I/usr/local/include -I/home/tomek/roboczy/winix -I/home/tomek/roboczy/ezc/src -L/usr/local/lib -DEZC_USE_WINIX_LOGGER -CXXFLAGS = -fPIC -Wall -pedantic -O0 -g -I/usr/local/include -I/home/tomek/roboczy/winix -I/home/tomek/roboczy/ezc/src -L/usr/local/lib -DEZC_USE_WINIX_LOGGER +CXXFLAGS = -fPIC -Wall -pedantic -O2 -I/usr/local/include -I/home/tomek/roboczy/winix -I/home/tomek/roboczy/ezc/src -L/usr/local/lib -DEZC_USE_WINIX_LOGGER endif - export CXX export CXXFLAGS + + all: winix winix: FORCE @@ -30,6 +30,7 @@ winix: FORCE $(CXX) -o winix $(CXXFLAGS) main/*.o /home/tomek/roboczy/winix/winix.so + clean: @cd core ; $(MAKE) -e clean @cd functions ; $(MAKE) -e clean @@ -54,9 +55,24 @@ depend: @cd ../ezc/src ; $(MAKE) -e depend @cd main ; $(MAKE) -e depend -#install: all -# mkdir -p bin -# rm -f bin/winix.so -# rm -f bin/winix -# cp winix.so bin/ -# cp winix bin/ + +install: all + # binaries + mkdir -p /usr/local/winix/bin + mkdir -p /usr/local/winix/lib + cp winix.so /usr/local/winix/lib/ + # use the full path with winix.so (we have to recompile winix with a new path to winix.so) + $(CXX) -o /usr/local/winix/bin/winix $(CXXFLAGS) main/*.o /usr/local/winix/lib/winix.so + # html templates + mkdir -p /usr/local/winix/html + cp -rf html/ /usr/local/winix/html/ + find /usr/local/winix/html/ -type d -name ".svn" | xargs -I foo rm -fr foo + # locales + mkdir -p /usr/local/winix/locale + cp -rf locale/ /usr/local/winix/locale/ + find /usr/local/winix/locale/ -type d -name ".svn" | xargs -I foo rm -fr foo + # plugins + mkdir -p /usr/local/winix/plugins + find plugins/ -name "*.so" | xargs -I foo cp foo /usr/local/winix/plugins/ + # removed provileges for others + find /usr/local/winix -exec chmod o-r,o-x,o-w "{}" "+" diff --git a/core/app.cpp b/core/app.cpp index 805d6ad..32921b9 100755 --- a/core/app.cpp +++ b/core/app.cpp @@ -74,7 +74,7 @@ bool App::CreateFCGISocket() - int s = FCGX_OpenSocket(sock, 10); + int s = FCGX_OpenSocket(sock, 100); if( s < 0 ) { diff --git a/core/config.cpp b/core/config.cpp index c1a1a5f..e2ea44a 100755 --- a/core/config.cpp +++ b/core/config.cpp @@ -161,6 +161,8 @@ void Config::AssignValues(bool stdout_is_closed) editors_html_safe_mode = Bool("editors_html_safe_mode", true); editors_html_safe_mode_skip_root = Bool("editors_html_safe_mode_skip_root", true); + plugins_dir = Text("plugins_dir", "/usr/local/winix/plugins"); + NoLastSlash(plugins_dir); parser.ListText("plugins", plugin_file); } diff --git a/core/config.h b/core/config.h index 2f72238..3a5924f 100755 --- a/core/config.h +++ b/core/config.h @@ -103,7 +103,13 @@ public: // if the output is shorter than this value then it will not be compressed int compression_page_min_size; + // plugins directory + // default: /usr/local/winix/plugins + std::string plugins_dir; + // plugins + // you can provide either a relative path (plugins_dir will be used) + // or a full path to a plugin std::vector plugin_file; // should the html code be cleaned by the html filter diff --git a/core/plugin.cpp b/core/plugin.cpp index 1ce5cc8..26830b8 100755 --- a/core/plugin.cpp +++ b/core/plugin.cpp @@ -109,12 +109,22 @@ return res; } -void Plugin::LoadPlugins(const std::vector & plugins) +void Plugin::LoadPlugins(const std::string & plugins_dir, const std::vector & plugins) { -size_t i; - - for(i=0 ; i & plugins); + void LoadPlugins(const std::string & plugins_dir, const std::vector & plugins); void UnloadPlugins(); void Call(int message); @@ -167,6 +167,7 @@ private: Templates * templates; SessionManager * session_manager; + std::string temp_path; struct PluginsItem { diff --git a/functions/createthread.cpp b/functions/createthread.cpp index 169d4d5..cbe5c17 100755 --- a/functions/createthread.cpp +++ b/functions/createthread.cpp @@ -21,8 +21,9 @@ CreateThread::CreateThread() + // returning true if we can create a thread in the current directory -bool CreateThread::HasAccess() +bool CreateThread::HasAccess(bool check_root) { if( request->dir_tab.empty() ) return false; @@ -36,7 +37,7 @@ bool CreateThread::HasAccess() if( !system->mounts.pmount || system->mounts.pmount->type != Mount::thread ) return false; - if( request->session && request->session->puser && request->session->puser->super_user ) + if( !check_root && request->session && request->session->puser && request->session->puser->super_user ) // super can create thread regardless of the restrictcreatethread option return true; @@ -50,6 +51,11 @@ return false; } +bool CreateThread::HasAccess() +{ + return HasAccess(false); +} + bool CreateThread::FunCreateThreadCheckAbuse() { diff --git a/functions/createthread.h b/functions/createthread.h index cbb0e67..064087e 100755 --- a/functions/createthread.h +++ b/functions/createthread.h @@ -23,6 +23,7 @@ class CreateThread : public FunctionBase public: CreateThread(); + bool HasAccess(bool check_root); bool HasAccess(); void MakePost(); diff --git a/functions/createticket.cpp b/functions/createticket.cpp index 7016c4c..31af555 100755 --- a/functions/createticket.cpp +++ b/functions/createticket.cpp @@ -27,7 +27,7 @@ void CreateTicket::Clear() } // returning true if we can create a ticket in the current directory -bool CreateTicket::HasAccess() +bool CreateTicket::HasAccess(bool check_root) { if( request->dir_tab.empty() ) return false; @@ -44,7 +44,7 @@ bool CreateTicket::HasAccess() // checking for par_createticket_on mount option - if( request->session && request->session->puser && request->session->puser->super_user ) + if( !check_root && request->session && request->session->puser && request->session->puser->super_user ) // super can create tickets regardless of the createticket_on option return true; @@ -58,7 +58,10 @@ return false; } - +bool CreateTicket::HasAccess() +{ + return HasAccess(false); +} bool CreateTicket::FunCreateTicketCheckAbuse() { diff --git a/functions/createticket.h b/functions/createticket.h index e37e28f..a2ac7c2 100755 --- a/functions/createticket.h +++ b/functions/createticket.h @@ -24,6 +24,7 @@ public: CreateTicket(); void Clear(); + bool HasAccess(bool check_root); bool HasAccess(); void MakePost(); diff --git a/html/fun_ckeditor.html b/html/fun_ckeditor.html index d2c8c75..a6e6d56 100755 --- a/html/fun_ckeditor.html +++ b/html/fun_ckeditor.html @@ -1,7 +1,6 @@ [if-one item_is]

{edit}

[else]

{add}

[end] -[include "err_abuse.html"] - +[include "error.html"]
diff --git a/main/main.cpp b/main/main.cpp index 6497bf0..15c0736 100755 --- a/main/main.cpp +++ b/main/main.cpp @@ -49,7 +49,7 @@ void signal_term(int) void print_syntax() { std::cout << "Syntax:" << std::endl; - std::cout << " cmslu.fcgi config_file" << std::endl; + std::cout << " winix config_file" << std::endl; } @@ -93,7 +93,7 @@ int main(int argv, char ** argc) // load plugins before loading sessions - session_manager.LoadSessions() // because some of the plugins can init its own sessions dates - plugin.LoadPlugins(app.config.plugin_file); + plugin.LoadPlugins(app.config.plugins_dir, app.config.plugin_file); if( !app.Init() ) return 1; diff --git a/static/layout1/winix.css b/static/layout1/winix.css index c26c16e..124ed52 100755 --- a/static/layout1/winix.css +++ b/static/layout1/winix.css @@ -350,6 +350,7 @@ line-height: 1.5em; p.withnext { margin: 1em 0 0 0; +width: 520px; } diff --git a/templates/thread.cpp b/templates/thread.cpp index 519935d..77e8377 100755 --- a/templates/thread.cpp +++ b/templates/thread.cpp @@ -173,8 +173,7 @@ void thread_tab_last_item_user(Info & i) void thread_can_create(Info & i) { - //i.res = request->CanCreateThread(true); - i.res = true; // temporarily + i.res = functions->fun_createthread.HasAccess(true); } diff --git a/templates/ticket.cpp b/templates/ticket.cpp index 13738fd..75b628b 100755 --- a/templates/ticket.cpp +++ b/templates/ticket.cpp @@ -61,8 +61,7 @@ void ticket_item_print_content(Info & i) void ticket_can_create(Info & i) { - //i.res = request->CanCreateTicket(true); - i.res = functions->fun_createticket.HasAccess(); + i.res = functions->fun_createticket.HasAccess(true); }