diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 035d0f0..8eb7bc4 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -822 \ No newline at end of file +830 \ No newline at end of file diff --git a/Common/Common.csproj b/Common/Common.csproj index 8434f7f..64c176c 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -106,6 +106,7 @@ + diff --git a/Common/Config.cs b/Common/Config.cs index 472eeba..84f9b3e 100644 --- a/Common/Config.cs +++ b/Common/Config.cs @@ -27,6 +27,8 @@ namespace FLocal.Common { public readonly TimeSpan ActivityThreshold; + public readonly string AdminUserName = "inga-lovinde"; + protected Config(NameValueCollection data) : base(data) { this.InitTime = DateTime.Now.ToLongTimeString(); this.mainConnection = new MySQLConnector.Connection(data["ConnectionString"], MySQLConnector.PostgresDBTraits.instance); diff --git a/Common/TableManager.cs b/Common/TableManager.cs new file mode 100644 index 0000000..9b34730 --- /dev/null +++ b/Common/TableManager.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using FLocal.Core; + +namespace FLocal.Common { + public static class TableManager { + + private static List _TABLES = new List { + dataobjects.Account.TableSpec.instance, + dataobjects.AccountIndicator.TableSpec.instance, + dataobjects.AccountSettings.TableSpec.instance, + dataobjects.Board.TableSpec.instance, + dataobjects.Category.TableSpec.instance, + dataobjects.PMConversation.TableSpec.instance, + dataobjects.PMMessage.TableSpec.instance, + dataobjects.Poll.TableSpec.instance, + dataobjects.Post.TableSpec.instance, + dataobjects.PostLayer.TableSpec.instance, + dataobjects.QuickLink.TableSpec.instance, + dataobjects.Revision.TableSpec.instance, + dataobjects.Session.TableSpec.instance, + dataobjects.Skin.TableSpec.instance, + dataobjects.Thread.TableSpec.instance, + dataobjects.Upload.TableSpec.instance, + dataobjects.User.TableSpec.instance, + dataobjects.UserGroup.TableSpec.instance, + }; + + public static Dictionary TABLES = (from table in _TABLES select new KeyValuePair(table.name, table)).ToDictionary(); + + } +} diff --git a/Common/dataobjects/Post.cs b/Common/dataobjects/Post.cs index f06c4d5..bb4c07d 100644 --- a/Common/dataobjects/Post.cs +++ b/Common/dataobjects/Post.cs @@ -214,7 +214,7 @@ namespace FLocal.Common.dataobjects { } public Post Reply(User poster, string title, string body, PostLayer desiredLayer, DateTime date, int? forcedPostId) { - if(this.thread.isLocked && poster.name != "inga-lovinde") { + if(this.thread.isLocked && poster.name != Config.instance.AdminUserName) { throw new FLocalException("thread locked"); } diff --git a/IISMainHandler/HandlersFactory.cs b/IISMainHandler/HandlersFactory.cs index c47b5dc..e0904a1 100644 --- a/IISMainHandler/HandlersFactory.cs +++ b/IISMainHandler/HandlersFactory.cs @@ -132,6 +132,16 @@ namespace FLocal.IISHandler { default: return new handlers.WrongUrlHandler(); } + case "maintenance": + if(context.requestParts.Length < 2) { + return new handlers.WrongUrlHandler(); + } + switch(context.requestParts[1].ToLower()) { + case "cleancache": + return new handlers.response.maintenance.CleanCacheHandler(); + default: + return new handlers.WrongUrlHandler(); + } case "poll": if(context.requestParts.Length < 2) { return new handlers.WrongUrlHandler(); @@ -173,6 +183,16 @@ namespace FLocal.IISHandler { return new handlers.request.CreatePollHandler(); case "vote": return new handlers.request.VoteHandler(); + case "maintenance": + if(context.requestParts.Length < 3) { + return new handlers.WrongUrlHandler(); + } + switch(context.requestParts[2].ToLower()) { + case "cleancache": + return new handlers.request.maintenance.CleanCacheHandler(); + default: + return new handlers.WrongUrlHandler(); + } default: return new handlers.WrongUrlHandler(); } diff --git a/IISMainHandler/IISMainHandler.csproj b/IISMainHandler/IISMainHandler.csproj index 411c8c5..f3397b3 100644 --- a/IISMainHandler/IISMainHandler.csproj +++ b/IISMainHandler/IISMainHandler.csproj @@ -66,6 +66,7 @@ + @@ -85,6 +86,7 @@ + diff --git a/IISMainHandler/handlers/request/maintenance/CleanCacheHandler.cs b/IISMainHandler/handlers/request/maintenance/CleanCacheHandler.cs new file mode 100644 index 0000000..30fe372 --- /dev/null +++ b/IISMainHandler/handlers/request/maintenance/CleanCacheHandler.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Linq; +using FLocal.Core; +using FLocal.Common; + +namespace FLocal.IISHandler.handlers.request.maintenance { + class CleanCacheHandler : AbstractNewMessageHandler { + + protected override string templateName { + get { + return "result/maintenance/CacheCleaned.xslt"; + } + } + + protected override XElement[] Do(WebContext context) { + if(context.account.user.name != Config.instance.AdminUserName) { + throw new FLocalException("access denied"); + } + string table = context.httprequest.Form["table"].Trim(); + int start = int.Parse(context.httprequest.Form["start"]); + int length = int.Parse(context.httprequest.Form["length"]); + ISqlObjectTableSpec tableSpec = TableManager.TABLES[table]; + for(int i=0; i + + + Î÷èñòêà êýøà + + + + + +
+ + + + + + + + + + +
+ Î÷èñòêà êýøà +
+ Âûáåðèòå òàáëèöó è íîìåðà +
+
+ Òàáëèöà
+ +
+ Íà÷àòü ñ ID
+
+ Êîëè÷åñòâî
+
+ +
+
+
+
+ + + + + +
\ No newline at end of file diff --git a/templates/Full/result/maintenance/CacheCleaned.xslt b/templates/Full/result/maintenance/CacheCleaned.xslt new file mode 100644 index 0000000..2bf67f5 --- /dev/null +++ b/templates/Full/result/maintenance/CacheCleaned.xslt @@ -0,0 +1,37 @@ + + + + Êýø î÷èùåí + + + + + + + + +
+ + + + +
+ Î÷èñòêà êýøà +
+
+ + + + +
+

Âûáðàííûå äàííûå îáíîâëåíû

+
+ + /Maintenance/CleanCache/ + Âåðíóòüñÿ ê î÷èñòêå êýøà + +
+
+
+ +
\ No newline at end of file