diff --git a/core/app.cpp b/core/app.cpp index 0c48f48..51590fe 100755 --- a/core/app.cpp +++ b/core/app.cpp @@ -175,13 +175,14 @@ void App::Close() bool App::BaseUrlRedirect() { - if( config.base_url_http_host.empty() ) + if( config.base_url.empty() ) return false; - if( Equal(config.base_url_http_host.c_str(), cur.request->env_http_host) ) + if( Equal(config.base_url.c_str(), cur.request->env_http_host) ) return false; - cur.request->redirect_to = config.base_url; + system.PutUrlProto(config.use_ssl, cur.request->redirect_to); + cur.request->redirect_to += config.base_url; AssignString(cur.request->env_request_uri, cur.request->redirect_to, false); // cur.request->env_request_uri should not be UrlEncoded cur.request->redirect_url_encoded = true; @@ -1164,7 +1165,10 @@ sigset_t set; app->Lock(); app->synchro.was_stop_signal = true; FCGX_ShutdownPending(); - Ezc::WideToUTF8(app->config.base_url, app->url_to_fetch_on_exit); + + // here we don't have to use SSL version so we always use config.url_proto + Ezc::WideToUTF8(app->config.url_proto, app->url_to_fetch_on_exit); + Ezc::WideToUTF8(app->config.base_url, app->url_to_fetch_on_exit, false); app->Unlock(); // this thread will hang on this method diff --git a/core/config.cpp b/core/config.cpp index 458e952..9443c43 100755 --- a/core/config.cpp +++ b/core/config.cpp @@ -144,12 +144,18 @@ void Config::AssignValues(bool stdout_is_closed) db_pass = AText(L"db_pass"); item_url_empty = Text(L"item_url_empty"); - base_server = Text(L"base_server"); + url_proto = Text(L"url_proto", L"http://"); + url_ssl_proto = Text(L"url_ssl_proto", L"https://"); + + use_ssl = Bool(L"use_ssl", false); + use_ssl_static = Bool(L"use_ssl_static", false); + use_ssl_common = Bool(L"use_ssl_common", false); + use_ssl_only_for_logged_users = Bool(L"use_ssl_only_for_logged_users", true); + base_url = Text(L"base_url"); base_url_static = Text(L"base_url_static"); base_url_common = Text(L"base_url_common"); - NoLastSlash(base_server); NoLastSlash(base_url); NoLastSlash(base_url_static); NoLastSlash(base_url_common); @@ -218,8 +224,6 @@ void Config::AssignValues(bool stdout_is_closed) void Config::SetAdditionalVariables() { - SetHttpHost(base_url, base_url_http_host); - if( html_filter_orphans_mode_str == "160" ) html_filter_orphans_mode = HTMLFilter::orphan_160space; else @@ -283,21 +287,6 @@ void Config::CheckPasswd() } -void Config::SetHttpHost(const std::wstring & in, std::wstring & out) -{ - const char http[] = "http://"; - const char https[] = "https://"; - size_t http_len = sizeof(http) / sizeof(char) - 1; - size_t https_len = sizeof(https) / sizeof(char) - 1; - - if( IsSubString(http, in.c_str()) ) - out = in.substr(http_len); - else - if( IsSubString(https, in.c_str()) ) - out = in.substr(https_len); - else - out.clear(); // if empty the RequestController::BaseUrlRedirect() returns false and no redirecting will be done -} std::wstring Config::Text(const wchar_t * name) diff --git a/core/config.h b/core/config.h index 79dcaaa..e9ea994 100755 --- a/core/config.h +++ b/core/config.h @@ -119,11 +119,6 @@ public: std::string http_session_id_name; - // when the HOST_HTTP environment variable doesn't point into 'base_url' (the part 'http://' and the last slash is removed) - // the server will redirect into 'base_url' + 'REQUEST_URI' - // it's useful when you want to redirect from 'mydomain.tld' into 'www.mydomain.tld' etc. - bool base_url_redirect; - // string used in a place where is a user (or group) selected std::wstring priv_no_user; std::wstring priv_no_group; @@ -286,16 +281,48 @@ public: // not available in config -- set automatically based on locale_default size_t locale_default_index; - // the main address of the server (e.g. someserver.com) (without the 'www' part etc) - std::wstring base_server; - // the main address of the site (e.g. http://www.someserver.com) + // url protocol + // default: http:// + std::wstring url_proto; + + // url protocol when using SSL + // default: https:// + std::wstring url_ssl_proto; + + // enables SSL + // this is related to [doc_base_url] ezc function + // default: false + bool use_ssl; + + // enables SSL with [doc_base_url_static] + // default: false + bool use_ssl_static; + + // enables SSL with [doc_base_url_common] + // default: false + bool use_ssl_common; + + // if SSL is enabled then if this is true the SSL will be used + // only for logged users + // default: true + bool use_ssl_only_for_logged_users; + + // when the HOST_HTTP environment variable doesn't point into 'base_url' (the part 'http://' and the last slash is removed) + // the server will redirect into 'base_url' + 'REQUEST_URI' + // it's useful when you want to redirect from 'mydomain.tld' into 'www.mydomain.tld' etc. + bool base_url_redirect; + + // the main address of the site (e.g. www.someserver.com) + // (without http:// prefix) std::wstring base_url; // static content not authorized by winix + // (e.g. static.someserver.com) std::wstring base_url_static; // additional static server for common content (not authorized) + // (e.g. common.someserver.com) std::wstring base_url_common; // separator used in html tag @@ -390,13 +417,10 @@ public: size_t pattern_cacher_how_many_delete; - /* - */ - // based on base_url - // set by SetAdditionalVariables() - // without the first part http:// (or https://) or the whole string is empty - std::wstring base_url_http_host; + + + Config(); @@ -427,7 +451,6 @@ public: private: void ShowError(); void AssignValues(bool stdout_is_closed); - void SetHttpHost(const std::wstring & in, std::wstring & out); void SetAdditionalVariables(); void CheckLocale(); void CheckPasswd(); diff --git a/core/request.cpp b/core/request.cpp index 10ec9dd..7893f5c 100755 --- a/core/request.cpp +++ b/core/request.cpp @@ -99,7 +99,7 @@ void Request::SetCookie(const char * name, const char * value, tm * expires) if( expires ) headers << "; expires=" << DateToStrCookie(expires) << " GMT"; - headers << "; path=/; domain=." << config->base_server << "\r\n"; + headers << "; path=/; domain=" << config->base_url << "\r\n"; } @@ -111,7 +111,7 @@ void Request::SetCookie(const char * name, long value, tm * expires) if( expires ) headers << "; expires=" << DateToStrCookie(expires) << " GMT"; - headers << "; path=/; domain=." << config->base_server << "\r\n"; + headers << "; path=/; domain=" << config->base_url << "\r\n"; } diff --git a/core/system.cpp b/core/system.cpp index 639177b..5909cfc 100755 --- a/core/system.cpp +++ b/core/system.cpp @@ -86,11 +86,33 @@ void System::Init() } +void System::PutUrlProto(bool can_use_ssl, std::wstring & str, bool clear_str) +{ +bool ssl = false; + + if( clear_str ) + str.clear(); + + if( can_use_ssl ) + { + if( !config->use_ssl_only_for_logged_users || cur->session->puser ) + { + str += config->url_ssl_proto; + ssl = true; + } + } + + if( !ssl ) + str += config->url_proto; +} + + // !! mozna zrobic jakas obsluge kiedy nie mozemy sie redirectnac, np gdy wystapil blad // !! moze zwracac jakas wartosc? void System::RedirectTo(const Item & item, const wchar_t * postfix) { - cur->request->redirect_to = config->base_url; + PutUrlProto(config->use_ssl, cur->request->redirect_to); + cur->request->redirect_to += config->base_url; if( item.type == Item::dir ) { @@ -112,7 +134,8 @@ void System::RedirectTo(const Item & item, const wchar_t * postfix) void System::RedirectTo(long item_id, const wchar_t * postfix) { - cur->request->redirect_to = config->base_url; + PutUrlProto(config->use_ssl, cur->request->redirect_to); + cur->request->redirect_to += config->base_url; Item * pdir = dirs.GetDir(item_id); if( pdir ) @@ -148,7 +171,8 @@ void System::RedirectTo(long item_id, const wchar_t * postfix) void System::RedirectTo(const std::wstring & url) { - cur->request->redirect_to = config->base_url; + PutUrlProto(config->use_ssl, cur->request->redirect_to); + cur->request->redirect_to += config->base_url; if( !url.empty() && url[0] == '/' ) { diff --git a/core/system.h b/core/system.h index 492ea7e..c238dcd 100755 --- a/core/system.h +++ b/core/system.h @@ -75,6 +75,7 @@ public: void AddParams(const ParamTab & param_tab, std::wstring & str, bool clear_str = true); + void PutUrlProto(bool can_use_ssl, std::wstring & str, bool clear_str = true); void RedirectTo(const Item & item, const wchar_t * postfix = 0); void RedirectTo(long item_id, const wchar_t * postfix = 0); void RedirectTo(const std::wstring & url); diff --git a/html/fun_ckeditor.html b/html/fun_ckeditor.html index 79f7149..2792300 100755 --- a/html/fun_ckeditor.html +++ b/html/fun_ckeditor.html @@ -31,10 +31,9 @@ <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> + <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> - <!--<script type="text/javascript" src="[doc_base_url_common]/ckeditor/skins/office2003/skin.js"></script>--> + <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] diff --git a/html/fun_emacs.html b/html/fun_emacs.html index c70144f..af3f479 100755 --- a/html/fun_emacs.html +++ b/html/fun_emacs.html @@ -7,13 +7,11 @@ <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] + <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]"> [include "fun_emacs_post.html"] diff --git a/html/fun_login.html b/html/fun_login.html index 0abafe1..d05fcf7 100755 --- a/html/fun_login.html +++ b/html/fun_login.html @@ -4,7 +4,7 @@ <p>{logged_as_long}: [user_name]<br> <a href="[doc_base_url][if-one dir_can_read_exec][dir][if-any item_is item_can_read][item_url]/[end][else]/[end]logout">{logout}</a></p> [else] - <form id="additem" method="post" action="[doc_base_url][if-one dir_can_read_exec][dir][if-any item_is item_can_read][item_url]/[end][else]/[end]login"> + <form id="additem" method="post" action="[login_path]login"> <fieldset> <legend>{form_login_legend}:</legend> <input class="editshort" type="text" name="login"> diff --git a/html/index_header.html b/html/index_header.html index 79a476b..6f583cf 100755 --- a/html/index_header.html +++ b/html/index_header.html @@ -4,7 +4,7 @@ <span id="winix_logged">{logged_as}: [user_name]<br> <a href="[doc_base_url][if-one dir_can_read_exec][dir][if-any item_is item_can_read][item_url]/[end][else]/[end]logout">{logout}</a></span> [else] - <form id="winix_login" method="post" action="[doc_base_url][if-one dir_can_read_exec][dir][if-any item_is item_can_read][item_url]/[end][else]/[end]login"> + <form id="winix_login" method="post" action="[login_path]login"> <fieldset> <legend>{form_login_legend}:</legend> <input class="edit" type="text" name="login"> diff --git a/locale/pl b/locale/pl index 3941186..746305e 100755 --- a/locale/pl +++ b/locale/pl @@ -128,11 +128,19 @@ html_lang_attr_value = "pl" # current limitation: winix is not allowed to convert polish capital letters to lower case # so we need to give both versions (small and capital letters) -language_orphans = ( "(np.", "a", "ale", "bo", "by", "co", "czy", "do", "go", "i", "ich", "ja", - "je", "jej", "jest", "już", "juŻ", "ją", "jĄ", "ku", "li", "mi", "na", "nie", - "np.", "nr", "o", "od", "po", "s.", "są", "sĄ", "ta", "to", "tu", "tą", "tĄ" - "tę", "tĘ", "u", "w", "we", "wy", "z", "za", "ze", "że", "Że", "ów", "Ów" ) +language_orphans = ( "(np.", "a", "al.", "ale", "bo", "bp", "by", "co", "cz.", "czy", "dn.", + "doc.", "dr", "dyr.", "dz.", "do", "ds.", "fot.", "go", "godz.", "i", + "ich", "im.", "inż.", "inŻ.", "ja", "je", "jej", "jest", "już", "juŻ", "ją", + "jĄ", "ks.", "ku", "li", "m.in.", "mgr", "mi", "na", "nie", "np.", "nr", + "o", "od", "os.", "ów", "Ów", "po", "prof.", "s.", "są", "sĄ", "ta", + "to", "tu", "tą", "tĄ", "tel.", "tę", "tĘ", "u", "ul.", "w", "we", "wg", + "woj.", "wy", "z", "za", "ze", "że", "Że" ) + + + + + # orphans for SK i CZ (winix for those languages are not translated yet) # ("a", "i", "k", "o", "s", "u", "v", "z") diff --git a/main/main.cpp b/main/main.cpp index 1b31e55..9c2f54a 100755 --- a/main/main.cpp +++ b/main/main.cpp @@ -114,9 +114,7 @@ int main(int argv, char ** argc) if( app.config.demonize && !app.Demonize() ) return 4; - // app.config.base_server can be changed (stripped from 'http://' or a last slash) - // it is done when the config is read - log << log3 << "base_server: " << app.config.base_server << logend; + log << log3 << "base_url: " << app.config.base_url << logend; // load plugins before loading sessions - session_manager.LoadSessions() // because some of the plugins can init its own sessions dates diff --git a/notify/notify.cpp b/notify/notify.cpp index 361571b..4387cf4 100755 --- a/notify/notify.cpp +++ b/notify/notify.cpp @@ -149,14 +149,16 @@ static std::wstring tmp_path; if( item.type == Item::dir ) { dirs->MakePath(item.id, tmp_path); - item_link = config->base_url; + item_link = config->url_proto; + item_link += config->base_url; item_link += tmp_path; dir_link = item_link; } else { dirs->MakePath(item.parent_id, tmp_path); - item_link = config->base_url; + item_link = config->url_proto; + item_link += config->base_url; item_link += tmp_path; dir_link = item_link; item_link += item.url; diff --git a/plugins/gallery/templates.cpp b/plugins/gallery/templates.cpp index 32e095d..293c256 100755 --- a/plugins/gallery/templates.cpp +++ b/plugins/gallery/templates.cpp @@ -77,6 +77,7 @@ void gallery_tab_subject(Info & i) void gallery_tab_link(Info & i) { + doc_proto(i); i.out << config->base_url; gallery_tab_dir(i); gallery_tab_url(i); diff --git a/plugins/thread/createthread.cpp b/plugins/thread/createthread.cpp index e736621..46efa62 100755 --- a/plugins/thread/createthread.cpp +++ b/plugins/thread/createthread.cpp @@ -55,7 +55,8 @@ void CreateThread::SendNotify(const Item & item) // sending notification notify_msg.code = WINIX_NOTIFY_CODE_ADD; notify_msg.template_index = thread_info->template_index; - notify_msg.dir_link = config->base_url; + notify_msg.dir_link = config->url_proto; + notify_msg.dir_link += config->base_url; system->dirs.MakePath(item.parent_id, notify_msg.dir_link, false); notify_msg.item_link = notify_msg.dir_link; notify_msg.item_link += item.url; diff --git a/plugins/thread/reply.cpp b/plugins/thread/reply.cpp index 301f59e..e9647b6 100755 --- a/plugins/thread/reply.cpp +++ b/plugins/thread/reply.cpp @@ -61,7 +61,8 @@ void Reply::SendNotify(const Item & item) // sending notification notify_msg.code = WINIX_NOTIFY_CODE_REPLY; notify_msg.template_index = thread_info->template_index; - notify_msg.dir_link = config->base_url; + notify_msg.dir_link = config->url_proto; + notify_msg.dir_link += config->base_url; system->dirs.MakePath(item.parent_id, notify_msg.dir_link, false); notify_msg.item_link = notify_msg.dir_link; notify_msg.item_link += item.url; diff --git a/plugins/thread/templates.cpp b/plugins/thread/templates.cpp index 284a73d..0e0b29a 100755 --- a/plugins/thread/templates.cpp +++ b/plugins/thread/templates.cpp @@ -192,6 +192,7 @@ void thread_sort_tab_link(Info & i) { if( item_sort_index < thread_info.item_sort_tab.size() ) { + doc_proto(i); i.out << config->base_url; thread_sort_tab_dir(i); thread_sort_tab_url(i); diff --git a/plugins/ticket/createticket.cpp b/plugins/ticket/createticket.cpp index 1b7feec..628abce 100755 --- a/plugins/ticket/createticket.cpp +++ b/plugins/ticket/createticket.cpp @@ -61,7 +61,8 @@ void CreateTicket::AddTicket(Ticket & ticket, Item & item) // sending notification notify_msg.code = WINIX_NOTIFY_CODE_ADD; notify_msg.template_index = ticket_info->template_index; - notify_msg.dir_link = config->base_url; + notify_msg.dir_link = config->url_proto; + notify_msg.dir_link += config->base_url; system->dirs.MakePath(item.parent_id, notify_msg.dir_link, false); notify_msg.item_link = notify_msg.dir_link; notify_msg.item_link += item.url; diff --git a/plugins/ticket/editticket.cpp b/plugins/ticket/editticket.cpp index 4daeb25..c98be85 100755 --- a/plugins/ticket/editticket.cpp +++ b/plugins/ticket/editticket.cpp @@ -66,7 +66,8 @@ void EditTicket::ChangeTicket(Ticket & ticket, Item & item) notify_msg.code = WINIX_NOTIFY_CODE_EDIT; notify_msg.template_index = ticket_info->template_index; - notify_msg.dir_link = config->base_url; + notify_msg.dir_link = config->url_proto; + notify_msg.dir_link += config->base_url; system->dirs.MakePath(item.parent_id, notify_msg.dir_link, false); notify_msg.item_link = notify_msg.dir_link; notify_msg.item_link += item.url; diff --git a/templates/Makefile.dep b/templates/Makefile.dep index c7c2057..7ee3944 100755 --- a/templates/Makefile.dep +++ b/templates/Makefile.dep @@ -26,6 +26,32 @@ adduser.o: ../core/group.h ../core/loadavg.h ../core/thumb.h adduser.o: ../core/basethread.h ../core/threadmanager.h adduser.o: ../core/sessionmanager.h ../core/sessioncontainer.h adduser.o: ../core/system.h ../core/htmlfilter.h ../core/request.h +config.o: templates.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h +config.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h +config.o: ../../ezc/src/item.h ../../ezc/src/funinfo.h +config.o: ../../ezc/src/functions.h ../../ezc/src/stringconv.h misc.h +config.o: localefilter.h locale.h ../core/confparser.h htmltextstream.h +config.o: ../core/textstream.h ../core/user.h patterncacher.h ../core/item.h +config.o: indexpatterns.h ../core/config.h ../core/confparser.h +config.o: ../core/htmlfilter.h ../core/cur.h ../core/request.h +config.o: ../core/requesttypes.h ../core/error.h ../core/config.h +config.o: ../core/textstream.h ../templates/htmltextstream.h +config.o: ../core/session.h ../core/user.h ../core/plugindata.h +config.o: ../core/rebus.h ../core/mount.h ../core/system.h ../core/dirs.h +config.o: ../core/dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h +config.o: ../db/dbtextstream.h ../core/error.h ../db/dbitemquery.h +config.o: ../db/dbitemcolumns.h ../core/group.h ../core/dircontainer.h +config.o: ../core/ugcontainer.h ../core/log.h ../core/logmanipulators.h +config.o: ../core/slog.h ../core/cur.h ../templates/locale.h +config.o: ../notify/notify.h ../notify/notifypool.h ../templates/misc.h +config.o: ../notify/notifythread.h ../core/basethread.h ../core/synchro.h +config.o: ../notify/templatesnotify.h ../core/users.h ../core/ugcontainer.h +config.o: ../core/lastcontainer.h ../core/mounts.h ../core/mountparser.h +config.o: ../core/crypt.h ../core/run.h ../core/users.h ../core/groups.h +config.o: ../core/group.h ../core/loadavg.h ../core/thumb.h +config.o: ../core/basethread.h ../core/threadmanager.h +config.o: ../core/sessionmanager.h ../core/sessioncontainer.h +config.o: ../core/system.h ../core/htmlfilter.h dir.o: templates.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h dir.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h ../../ezc/src/item.h dir.o: ../../ezc/src/funinfo.h ../../ezc/src/functions.h @@ -214,6 +240,31 @@ localefilter.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h localefilter.o: ../../ezc/src/item.h ../../ezc/src/funinfo.h localefilter.o: ../../ezc/src/functions.h ../../ezc/src/stringconv.h localefilter.o: ../core/misc.h ../core/requesttypes.h +login.o: templates.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h +login.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h +login.o: ../../ezc/src/item.h ../../ezc/src/funinfo.h +login.o: ../../ezc/src/functions.h ../../ezc/src/stringconv.h misc.h +login.o: localefilter.h locale.h ../core/confparser.h htmltextstream.h +login.o: ../core/textstream.h ../core/user.h patterncacher.h ../core/item.h +login.o: indexpatterns.h ../core/config.h ../core/confparser.h +login.o: ../core/htmlfilter.h ../core/cur.h ../core/request.h +login.o: ../core/requesttypes.h ../core/error.h ../core/config.h +login.o: ../core/textstream.h ../templates/htmltextstream.h ../core/session.h +login.o: ../core/user.h ../core/plugindata.h ../core/rebus.h ../core/mount.h +login.o: ../core/system.h ../core/dirs.h ../core/dircontainer.h ../db/db.h +login.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h ../core/error.h +login.o: ../db/dbitemquery.h ../db/dbitemcolumns.h ../core/group.h +login.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/log.h +login.o: ../core/logmanipulators.h ../core/slog.h ../core/cur.h +login.o: ../templates/locale.h ../notify/notify.h ../notify/notifypool.h +login.o: ../templates/misc.h ../notify/notifythread.h ../core/basethread.h +login.o: ../core/synchro.h ../notify/templatesnotify.h ../core/users.h +login.o: ../core/ugcontainer.h ../core/lastcontainer.h ../core/mounts.h +login.o: ../core/mountparser.h ../core/crypt.h ../core/run.h ../core/users.h +login.o: ../core/groups.h ../core/group.h ../core/loadavg.h ../core/thumb.h +login.o: ../core/basethread.h ../core/threadmanager.h +login.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/system.h +login.o: ../core/htmlfilter.h ls.o: templates.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h ls.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h ../../ezc/src/item.h ls.o: ../../ezc/src/funinfo.h ../../ezc/src/functions.h diff --git a/templates/Makefile.o.dep b/templates/Makefile.o.dep index 0f9ae87..e283049 100755 --- a/templates/Makefile.o.dep +++ b/templates/Makefile.o.dep @@ -1 +1 @@ -o = adduser.o dir.o doc.o filters.o htmltextstream.o indexpatterns.o insert.o item.o last.o locale.o localefilter.o ls.o misc.o mount.o patterncacher.o priv.o rebus.o slog.o stat.o sys.o template.o templates.o upload.o uptime.o user.o who.o winix.o +o = adduser.o config.o dir.o doc.o filters.o htmltextstream.o indexpatterns.o insert.o item.o last.o locale.o localefilter.o login.o ls.o misc.o mount.o patterncacher.o priv.o rebus.o slog.o stat.o sys.o template.o templates.o upload.o uptime.o user.o who.o winix.o diff --git a/templates/config.cpp b/templates/config.cpp new file mode 100755 index 0000000..c1fa6f5 --- /dev/null +++ b/templates/config.cpp @@ -0,0 +1,74 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2011, Tomasz Sowa + * All rights reserved. + * + */ + +#include "templates.h" + + + +namespace TemplatesFunctions +{ + +/* + some config options +*/ + + +void config_use_ssl(Info & i) +{ + i.res = config->use_ssl; +} + + +void config_use_ssl_static(Info & i) +{ + i.res = config->use_ssl_static; +} + + +void config_use_ssl_common(Info & i) +{ + i.res = config->use_ssl_common; +} + + +void config_url_proto(Info & i) +{ + i.out << config->url_proto; +} + + +void config_url_ssl_proto(Info & i) +{ + i.out << config->url_ssl_proto; +} + + +void config_base_url(Info & i) +{ + i.out << config->base_url; +} + + +void config_base_url_static(Info & i) +{ + i.out << config->base_url_static; +} + + +void config_base_url_common(Info & i) +{ + i.out << config->base_url_common; +} + + + + +} // namespace TemplatesFunctions + + diff --git a/templates/dir.cpp b/templates/dir.cpp index dbf898d..84dd3b4 100755 --- a/templates/dir.cpp +++ b/templates/dir.cpp @@ -73,18 +73,7 @@ void dir_parent_without_slash(Info & i) // bo inaczej i tak bylo by 'access denied' void dir_can_read_exec(Info & i) { -bool result = true; - - for(size_t a=0 ; a<cur->request->dir_tab.size() ; ++a) - { - if( !system->HasReadExecAccess(*cur->request->dir_tab[a]) ) - { - result = false; - break; - } - } - - i.res = result; + i.res = system->HasReadExecAccessToPath(cur->request->dir_tab); } @@ -249,6 +238,7 @@ void dir_tab_url(Info & i) void dir_tab_link(Info & i) { + doc_proto(i); i.out << config->base_url; for(size_t a = 0 ; a <= dir_index && a < cur->request->dir_tab.size() ; ++a) diff --git a/templates/doc.cpp b/templates/doc.cpp index c8ab9c8..0efca2d 100755 --- a/templates/doc.cpp +++ b/templates/doc.cpp @@ -17,7 +17,7 @@ namespace TemplatesFunctions { - +static std::wstring doc_proto_str; @@ -48,22 +48,44 @@ void doc_title(Info & i) +void doc_proto(Info & i) +{ + system->PutUrlProto(config->use_ssl, doc_proto_str); + i.out << doc_proto_str; +} + + +void doc_proto_static(Info & i) +{ + system->PutUrlProto(config->use_ssl_static, doc_proto_str); + i.out << doc_proto_str; +} + + +void doc_proto_common(Info & i) +{ + system->PutUrlProto(config->use_ssl_common, doc_proto_str); + i.out << doc_proto_str; +} void doc_base_url(Info & i) { + doc_proto(i); i.out << config->base_url; } void doc_base_url_static(Info & i) { + doc_proto_static(i); i.out << config->base_url_static; } void doc_base_url_common(Info & i) { + doc_proto_common(i); i.out << config->base_url_common; } diff --git a/templates/item.cpp b/templates/item.cpp index 0304712..46d5df1 100755 --- a/templates/item.cpp +++ b/templates/item.cpp @@ -163,6 +163,7 @@ void item_url_is(Info & i) void item_link(Info & i) { + doc_proto(i); i.out << config->base_url; item_dir(i); item_url(i); @@ -461,6 +462,7 @@ void item_tab_link(Info & i) { if( item_index < cur->request->item_tab.size() ) { + doc_proto(i); i.out << config->base_url; item_tab_dir(i); item_tab_url(i); diff --git a/templates/login.cpp b/templates/login.cpp new file mode 100755 index 0000000..d68dd29 --- /dev/null +++ b/templates/login.cpp @@ -0,0 +1,46 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2011, Tomasz Sowa + * All rights reserved. + * + */ + +#include "templates.h" + + + +namespace TemplatesFunctions +{ + + +void login_path(Info & i) +{ + if( config->use_ssl ) + i.out << config->url_ssl_proto; + else + i.out << config->url_proto; + + i.out << config->base_url; + + if( system->HasReadExecAccessToPath(cur->request->dir_tab) ) + { + dir(i); + + if( cur->request->is_item && system->HasReadAccess(cur->request->item) ) + i.out << cur->request->item.url << '/'; + } + else + { + i.out << '/'; + } +} + + + + + +} // namespace TemplatesFunctions + + diff --git a/templates/templates.cpp b/templates/templates.cpp index 6a9152e..5257fd8 100755 --- a/templates/templates.cpp +++ b/templates/templates.cpp @@ -142,6 +142,19 @@ void Templates::CreateFunctions() ezc_functions.Insert("adduser_last_email", adduser_last_email); + /* + config + */ + ezc_functions.Insert("config_use_ssl", config_use_ssl); + ezc_functions.Insert("config_use_ssl_static", config_use_ssl_static); + ezc_functions.Insert("config_use_ssl_common", config_use_ssl_common); + ezc_functions.Insert("config_url_proto", config_url_proto); + ezc_functions.Insert("config_url_ssl_proto", config_url_ssl_proto); + ezc_functions.Insert("config_base_url", config_base_url); + ezc_functions.Insert("config_base_url_static", config_base_url_static); + ezc_functions.Insert("config_base_url_common", config_base_url_common); + + /* dir */ @@ -198,6 +211,9 @@ void Templates::CreateFunctions() doc */ ezc_functions.Insert("doc_title", doc_title); + ezc_functions.Insert("doc_proto", doc_proto); + ezc_functions.Insert("doc_proto_static", doc_proto_static); + ezc_functions.Insert("doc_proto_common", doc_proto_common); ezc_functions.Insert("doc_base_url", doc_base_url); ezc_functions.Insert("doc_base_url_static", doc_base_url_static); ezc_functions.Insert("doc_base_url_common", doc_base_url_common); @@ -313,6 +329,12 @@ void Templates::CreateFunctions() ezc_functions.Insert("last_tab_end", last_tab_end); + /* + login + */ + ezc_functions.Insert("login_path", login_path); + + /* mount */ diff --git a/templates/templates.h b/templates/templates.h index 96e2088..06525cf 100755 --- a/templates/templates.h +++ b/templates/templates.h @@ -70,6 +70,19 @@ namespace TemplatesFunctions void adduser_last_email(Info & i); + /* + config + */ + void config_use_ssl(Info & i); + void config_use_ssl_static(Info & i); + void config_use_ssl_common(Info & i); + void config_url_proto(Info & i); + void config_url_ssl_proto(Info & i); + void config_base_url(Info & i); + void config_base_url_static(Info & i); + void config_base_url_common(Info & i); + + /* dir */ @@ -116,6 +129,9 @@ namespace TemplatesFunctions doc */ void doc_title(Info & i); + void doc_proto(Info & i); + void doc_proto_static(Info & i); + void doc_proto_common(Info & i); void doc_base_url(Info & i); void doc_base_url_static(Info & i); void doc_base_url_common(Info & i); @@ -242,6 +258,12 @@ namespace TemplatesFunctions void last_tab_end(Info & i); + /* + login + */ + void login_path(Info & i); + + /* mount */