Fixed all redirections with appropriate host (as configured).
This commit is contained in:
parent
8c35eed690
commit
191d903b2d
13 changed files with 149 additions and 124 deletions
|
@ -238,7 +238,7 @@ namespace ScrewTurn.Wiki {
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.Remove(match.Index, match.Length);
|
sb.Remove(match.Index, match.Length);
|
||||||
string prov = match.Groups[1].Value.StartsWith(":") ? match.Value.Substring(4, match.Value.Length - 5) : match.Value.Substring(3, match.Value.Length - 4);
|
string prov = match.Groups[1].Value.StartsWith(":") ? match.Value.Substring(4, match.Value.Length - 5) : match.Value.Substring(3, match.Value.Length - 4);
|
||||||
string page = null;
|
string page = null;
|
||||||
// prov - Full.Provider.Type.Name(PageName)
|
// prov - Full.Provider.Type.Name(PageName)
|
||||||
// (PageName) is optional, but it can contain brackets, for example (Page(WithBrackets))
|
// (PageName) is optional, but it can contain brackets, for example (Page(WithBrackets))
|
||||||
|
@ -250,7 +250,7 @@ namespace ScrewTurn.Wiki {
|
||||||
}
|
}
|
||||||
if(page == null) {
|
if(page == null) {
|
||||||
// Normal file
|
// Normal file
|
||||||
sb.Insert(match.Index, ExtendedUpReplacement.Replace("$", (prov != "") ? "Provider=" + prov + "&" : ""));
|
sb.Insert(match.Index, ExtendedUpReplacement.Replace("$", (prov != "") ? "Provider=" + prov + "&" : ""));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Page attachment
|
// Page attachment
|
||||||
|
@ -795,9 +795,9 @@ namespace ScrewTurn.Wiki {
|
||||||
|
|
||||||
// This check allows to ignore special tags (especially Phase3)
|
// This check allows to ignore special tags (especially Phase3)
|
||||||
if(!internalSnippet.ToLowerInvariant().StartsWith("{s:")) {
|
if(!internalSnippet.ToLowerInvariant().StartsWith("{s:")) {
|
||||||
internalSnippet = internalSnippet.Replace("{", "$$$$$$$$OPEN$$$$$$$$").Replace("}", "$$$$$$$$CLOSE$$$$$$$$");
|
internalSnippet = internalSnippet.Replace("{", "$$$$$$$$OPEN$$$$$$$$").Replace("}", "$$$$$$$$CLOSE$$$$$$$$");
|
||||||
balanced = balanced.Insert(lastOpen, internalSnippet);
|
balanced = balanced.Insert(lastOpen, internalSnippet);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string formattedInternalSnippet = FormatSnippet(internalSnippet, tocString);
|
string formattedInternalSnippet = FormatSnippet(internalSnippet, tocString);
|
||||||
|
@ -2196,8 +2196,8 @@ namespace ScrewTurn.Wiki {
|
||||||
// Header
|
// Header
|
||||||
if(lines[i].Length < 3) continue;
|
if(lines[i].Length < 3) continue;
|
||||||
|
|
||||||
// only if ! is found in the first row of the table, it is an header
|
// only if ! is found in the first row of the table, it is an header
|
||||||
if(lines[i + 1] == "|-") thAdded = true;
|
if(lines[i + 1] == "|-") thAdded = true;
|
||||||
|
|
||||||
item = lines[i].Substring(2);
|
item = lines[i].Substring(2);
|
||||||
if(item.IndexOf(" !! ") != -1) {
|
if(item.IndexOf(" !! ") != -1) {
|
||||||
|
@ -2233,16 +2233,16 @@ namespace ScrewTurn.Wiki {
|
||||||
int thIndex = sb.ToString().IndexOf("<th");
|
int thIndex = sb.ToString().IndexOf("<th");
|
||||||
//if(thIndex >= 4) sb.Insert(thIndex - 4, "<thead>");
|
//if(thIndex >= 4) sb.Insert(thIndex - 4, "<thead>");
|
||||||
sb.Insert(thIndex - 4, "<thead>");
|
sb.Insert(thIndex - 4, "<thead>");
|
||||||
|
|
||||||
// search for the last </th> tag in the first row of the table
|
// search for the last </th> tag in the first row of the table
|
||||||
int thCloseIndex = -1;
|
int thCloseIndex = -1;
|
||||||
int thCloseIndex_temp = -1;
|
int thCloseIndex_temp = -1;
|
||||||
do {
|
do {
|
||||||
thCloseIndex = thCloseIndex_temp;
|
thCloseIndex = thCloseIndex_temp;
|
||||||
thCloseIndex_temp = sb.ToString().IndexOf("</th>", thCloseIndex + 1);
|
thCloseIndex_temp = sb.ToString().IndexOf("</th>", thCloseIndex + 1);
|
||||||
}
|
}
|
||||||
while (thCloseIndex_temp != -1/* && thCloseIndex_temp < sb.ToString().IndexOf("</tr>") #443, but disables row-header support */);
|
while (thCloseIndex_temp != -1/* && thCloseIndex_temp < sb.ToString().IndexOf("</tr>") #443, but disables row-header support */);
|
||||||
|
|
||||||
sb.Insert(thCloseIndex + 10, "</thead><tbody>");
|
sb.Insert(thCloseIndex + 10, "</thead><tbody>");
|
||||||
sb.Insert(sb.Length - 8, "</tbody>");
|
sb.Insert(sb.Length - 8, "</tbody>");
|
||||||
}
|
}
|
||||||
|
@ -2601,7 +2601,7 @@ namespace ScrewTurn.Wiki {
|
||||||
string login = Exchanger.ResourceExchanger.GetResource("Login");
|
string login = Exchanger.ResourceExchanger.GetResource("Login");
|
||||||
StringBuilder sb = new StringBuilder(200);
|
StringBuilder sb = new StringBuilder(200);
|
||||||
sb.Append("<a href=\"");
|
sb.Append("<a href=\"");
|
||||||
sb.Append(UrlTools.BuildUrl("Login.aspx?Redirect=", Tools.UrlEncode(HttpContext.Current.Request.Url.ToString())));
|
sb.Append(UrlTools.BuildUrl("Login.aspx?Redirect=", Tools.UrlEncode(Tools.GetCurrentUrlFixed())));
|
||||||
sb.Append("\" class=\"systemlink\" title=\"");
|
sb.Append("\" class=\"systemlink\" title=\"");
|
||||||
sb.Append(login);
|
sb.Append(login);
|
||||||
sb.Append("\">");
|
sb.Append("\">");
|
||||||
|
@ -2618,7 +2618,7 @@ namespace ScrewTurn.Wiki {
|
||||||
string login = Exchanger.ResourceExchanger.GetResource("Logout");
|
string login = Exchanger.ResourceExchanger.GetResource("Logout");
|
||||||
StringBuilder sb = new StringBuilder(200);
|
StringBuilder sb = new StringBuilder(200);
|
||||||
sb.Append("<a href=\"");
|
sb.Append("<a href=\"");
|
||||||
sb.Append(UrlTools.BuildUrl("Login.aspx?ForceLogout=1&Redirect=", Tools.UrlEncode(HttpContext.Current.Request.Url.ToString())));
|
sb.Append(UrlTools.BuildUrl("Login.aspx?ForceLogout=1&Redirect=", Tools.UrlEncode(Tools.GetCurrentUrlFixed())));
|
||||||
sb.Append("\" class=\"systemlink\" title=\"");
|
sb.Append("\" class=\"systemlink\" title=\"");
|
||||||
sb.Append(login);
|
sb.Append(login);
|
||||||
sb.Append("\">");
|
sb.Append("\">");
|
||||||
|
|
|
@ -1019,7 +1019,7 @@ namespace ScrewTurn.Wiki {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The URL.</returns>
|
/// <returns>The URL.</returns>
|
||||||
private static string GetCurrentRequestMainUrl() {
|
private static string GetCurrentRequestMainUrl() {
|
||||||
string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path);
|
string url = HttpContext.Current.Request.Url.FixHost().GetLeftPart(UriPartial.Path);
|
||||||
if(!url.EndsWith("/")) {
|
if(!url.EndsWith("/")) {
|
||||||
int index = url.LastIndexOf("/");
|
int index = url.LastIndexOf("/");
|
||||||
if(index != -1) url = url.Substring(0, index + 1);
|
if(index != -1) url = url.Substring(0, index + 1);
|
||||||
|
|
157
Core/Tools.cs
157
Core/Tools.cs
|
@ -14,27 +14,27 @@ using System.Net;
|
||||||
|
|
||||||
namespace ScrewTurn.Wiki {
|
namespace ScrewTurn.Wiki {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains useful Tools.
|
/// Contains useful Tools.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Tools {
|
public static class Tools {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all the included files for the HTML Head, such as CSS, JavaScript and Icon pluginAssemblies, for a namespace.
|
/// Gets all the included files for the HTML Head, such as CSS, JavaScript and Icon pluginAssemblies, for a namespace.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="nspace">The namespace (<c>null</c> for the root).</param>
|
/// <param name="nspace">The namespace (<c>null</c> for the root).</param>
|
||||||
/// <returns>The includes.</returns>
|
/// <returns>The includes.</returns>
|
||||||
public static string GetIncludes(string nspace) {
|
public static string GetIncludes(string nspace) {
|
||||||
string theme = Settings.GetTheme(nspace);
|
string theme = Settings.GetTheme(nspace);
|
||||||
string themePath = Settings.GetThemePath(nspace);
|
string themePath = Settings.GetThemePath(nspace);
|
||||||
|
|
||||||
StringBuilder result = new StringBuilder(300);
|
StringBuilder result = new StringBuilder(300);
|
||||||
|
|
||||||
result.Append(GetJavaScriptIncludes());
|
result.Append(GetJavaScriptIncludes());
|
||||||
|
|
||||||
string[] css = Directory.GetFiles(Settings.ThemesDirectory + theme, "*.css");
|
string[] css = Directory.GetFiles(Settings.ThemesDirectory + theme, "*.css");
|
||||||
string firstChunk;
|
string firstChunk;
|
||||||
for(int i = 0; i < css.Length; i++) {
|
for(int i = 0; i < css.Length; i++) {
|
||||||
if(Path.GetFileName(css[i]).IndexOf("_") != -1) {
|
if(Path.GetFileName(css[i]).IndexOf("_") != -1) {
|
||||||
firstChunk = Path.GetFileName(css[i]).Substring(0, Path.GetFileName(css[i]).IndexOf("_")).ToLower(CultureInfo.CurrentCulture);
|
firstChunk = Path.GetFileName(css[i]).Substring(0, Path.GetFileName(css[i]).IndexOf("_")).ToLower(CultureInfo.CurrentCulture);
|
||||||
if(firstChunk.Equals("screen") || firstChunk.Equals("print") || firstChunk.Equals("all") ||
|
if(firstChunk.Equals("screen") || firstChunk.Equals("print") || firstChunk.Equals("all") ||
|
||||||
|
@ -49,7 +49,7 @@ namespace ScrewTurn.Wiki {
|
||||||
else {
|
else {
|
||||||
result.Append(@"<link rel=""stylesheet"" href=""" + themePath + Path.GetFileName(css[i]) + @""" type=""text/css"" />" + "\n");
|
result.Append(@"<link rel=""stylesheet"" href=""" + themePath + Path.GetFileName(css[i]) + @""" type=""text/css"" />" + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string customEditorCss = Path.Combine(Settings.ThemesDirectory, theme);
|
string customEditorCss = Path.Combine(Settings.ThemesDirectory, theme);
|
||||||
customEditorCss = Path.Combine(customEditorCss, "Editor.css");
|
customEditorCss = Path.Combine(customEditorCss, "Editor.css");
|
||||||
|
@ -61,9 +61,9 @@ namespace ScrewTurn.Wiki {
|
||||||
Settings.MainUrl, Settings.WikiTitle + " - Search");
|
Settings.MainUrl, Settings.WikiTitle + " - Search");
|
||||||
|
|
||||||
string[] js = Directory.GetFiles(Settings.ThemesDirectory + theme, "*.js");
|
string[] js = Directory.GetFiles(Settings.ThemesDirectory + theme, "*.js");
|
||||||
for(int i = 0; i < js.Length; i++) {
|
for(int i = 0; i < js.Length; i++) {
|
||||||
result.Append(@"<script src=""" + themePath + Path.GetFileName(js[i]) + @""" type=""text/javascript""></script>" + "\n");
|
result.Append(@"<script src=""" + themePath + Path.GetFileName(js[i]) + @""" type=""text/javascript""></script>" + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] icons = Directory.GetFiles(Settings.ThemesDirectory + theme, "Icon.*");
|
string[] icons = Directory.GetFiles(Settings.ThemesDirectory + theme, "Icon.*");
|
||||||
if(icons.Length > 0) {
|
if(icons.Length > 0) {
|
||||||
|
@ -85,8 +85,8 @@ namespace ScrewTurn.Wiki {
|
||||||
// Include HTML Head
|
// Include HTML Head
|
||||||
result.Append(Settings.Provider.GetMetaDataItem(MetaDataItem.HtmlHead, nspace));
|
result.Append(Settings.Provider.GetMetaDataItem(MetaDataItem.HtmlHead, nspace));
|
||||||
|
|
||||||
return result.ToString();
|
return result.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all the JavaScript files to include.
|
/// Gets all the JavaScript files to include.
|
||||||
|
@ -102,52 +102,52 @@ namespace ScrewTurn.Wiki {
|
||||||
return buffer.ToString();
|
return buffer.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts a byte number into a string, formatted using KB, MB or GB.
|
/// Converts a byte number into a string, formatted using KB, MB or GB.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bytes">The # of bytes.</param>
|
/// <param name="bytes">The # of bytes.</param>
|
||||||
/// <returns>The formatted string.</returns>
|
/// <returns>The formatted string.</returns>
|
||||||
public static string BytesToString(long bytes) {
|
public static string BytesToString(long bytes) {
|
||||||
if(bytes < 1024) return bytes.ToString() + " B";
|
if(bytes < 1024) return bytes.ToString() + " B";
|
||||||
else if(bytes < 1048576) return string.Format("{0:N2} KB", (float)bytes / 1024F);
|
else if(bytes < 1048576) return string.Format("{0:N2} KB", (float)bytes / 1024F);
|
||||||
else if(bytes < 1073741824) return string.Format("{0:N2} MB", (float)bytes / 1048576F);
|
else if(bytes < 1073741824) return string.Format("{0:N2} MB", (float)bytes / 1048576F);
|
||||||
else return string.Format("{0:N2} GB", (float)bytes / 1073741824F);
|
else return string.Format("{0:N2} GB", (float)bytes / 1073741824F);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Computes the Disk Space Usage of a directory.
|
/// Computes the Disk Space Usage of a directory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dir">The directory.</param>
|
/// <param name="dir">The directory.</param>
|
||||||
/// <returns>The used Disk Space, in bytes.</returns>
|
/// <returns>The used Disk Space, in bytes.</returns>
|
||||||
public static long DiskUsage(string dir) {
|
public static long DiskUsage(string dir) {
|
||||||
string[] files = Directory.GetFiles(dir);
|
string[] files = Directory.GetFiles(dir);
|
||||||
string[] directories = Directory.GetDirectories(dir);
|
string[] directories = Directory.GetDirectories(dir);
|
||||||
long result = 0;
|
long result = 0;
|
||||||
|
|
||||||
FileInfo file;
|
FileInfo file;
|
||||||
for(int i = 0; i < files.Length; i++) {
|
for(int i = 0; i < files.Length; i++) {
|
||||||
file = new FileInfo(files[i]);
|
file = new FileInfo(files[i]);
|
||||||
result += file.Length;
|
result += file.Length;
|
||||||
}
|
}
|
||||||
for(int i = 0; i < directories.Length; i++) {
|
for(int i = 0; i < directories.Length; i++) {
|
||||||
result += DiskUsage(directories[i]);
|
result += DiskUsage(directories[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates the standard 5-digit Page Version string.
|
/// Generates the standard 5-digit Page Version string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="version">The Page version.</param>
|
/// <param name="version">The Page version.</param>
|
||||||
/// <returns>The 5-digit Version string.</returns>
|
/// <returns>The 5-digit Version string.</returns>
|
||||||
public static string GetVersionString(int version) {
|
public static string GetVersionString(int version) {
|
||||||
string result = version.ToString();
|
string result = version.ToString();
|
||||||
int len = result.Length;
|
int len = result.Length;
|
||||||
for(int i = 0; i < 5 - len; i++) {
|
for(int i = 0; i < 5 - len; i++) {
|
||||||
result = "0" + result;
|
result = "0" + result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the available Themes.
|
/// Gets the available Themes.
|
||||||
|
@ -235,17 +235,17 @@ namespace ScrewTurn.Wiki {
|
||||||
else return "";
|
else return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current culture.
|
/// Gets the current culture.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string CurrentCulture {
|
public static string CurrentCulture {
|
||||||
get { return CultureInfo.CurrentUICulture.Name; }
|
get { return CultureInfo.CurrentUICulture.Name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the direction of the current culture.
|
/// Get the direction of the current culture.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> if the current culture is RTL, <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if the current culture is RTL, <c>false</c> otherwise.</returns>
|
||||||
public static bool IsRightToLeftCulture() {
|
public static bool IsRightToLeftCulture() {
|
||||||
return new CultureInfo(CurrentCulture).TextInfo.IsRightToLeft;
|
return new CultureInfo(CurrentCulture).TextInfo.IsRightToLeft;
|
||||||
}
|
}
|
||||||
|
@ -326,6 +326,31 @@ namespace ScrewTurn.Wiki {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Automatically replaces the host in the URL with that obtained from <see cref="Settings.GetMainUrl"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url">The URL.</param>
|
||||||
|
/// <returns>The URL with fixed host.</returns>
|
||||||
|
public static Uri FixHost(this Uri url) {
|
||||||
|
// Make sure the host is replaced only once
|
||||||
|
string originalUrl = url.ToString();
|
||||||
|
string originalHost = url.Host;
|
||||||
|
string newHost = Settings.GetMainUrl().Host;
|
||||||
|
|
||||||
|
int hostIndex = originalUrl.IndexOf(originalHost);
|
||||||
|
string newUrl = originalUrl.Substring(0, hostIndex) + newHost + originalUrl.Substring(hostIndex + originalHost.Length + 1);
|
||||||
|
|
||||||
|
return new Uri(newUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current request's URL, with the host already fixed.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current URL.</returns>
|
||||||
|
public static string GetCurrentUrlFixed() {
|
||||||
|
return HttpContext.Current.Request.Url.FixHost().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes URL-encoding, avoiding to use '+' for spaces.
|
/// Executes URL-encoding, avoiding to use '+' for spaces.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace ScrewTurn.Wiki {
|
||||||
string queryString = ""; // Empty or begins with ampersand, not question mark
|
string queryString = ""; // Empty or begins with ampersand, not question mark
|
||||||
try {
|
try {
|
||||||
// This might throw exceptions if 3rd-party modules interfer with the request pipeline
|
// This might throw exceptions if 3rd-party modules interfer with the request pipeline
|
||||||
queryString = HttpContext.Current.Request.Url.Query.Replace("?", "&");
|
queryString = HttpContext.Current.Request.Url.Query.Replace("?", "&"); // Host not used
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace ScrewTurn.Wiki {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void RedirectToLoginIfNeeded() {
|
public static void RedirectToLoginIfNeeded() {
|
||||||
if(SessionFacade.LoginKey == null) {
|
if(SessionFacade.LoginKey == null) {
|
||||||
UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(HttpContext.Current.Request.Url.ToString()));
|
UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,8 +230,8 @@ namespace ScrewTurn.Wiki {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void LoadSecurityConfig() {
|
private void LoadSecurityConfig() {
|
||||||
chkAllowUsersToRegister.Checked = Settings.UsersCanRegister;
|
chkAllowUsersToRegister.Checked = Settings.UsersCanRegister;
|
||||||
txtPasswordRegEx.Text = Settings.PasswordRegex;
|
txtPasswordRegEx.Text = Settings.PasswordRegex;
|
||||||
txtUsernameRegEx.Text = Settings.UsernameRegex;
|
txtUsernameRegEx.Text = Settings.UsernameRegex;
|
||||||
PopulateAccountActivationMode(Settings.AccountActivationMode);
|
PopulateAccountActivationMode(Settings.AccountActivationMode);
|
||||||
PopulateDefaultGroups(Settings.UsersGroup,
|
PopulateDefaultGroups(Settings.UsersGroup,
|
||||||
Settings.AdministratorsGroup,
|
Settings.AdministratorsGroup,
|
||||||
|
@ -276,7 +276,7 @@ namespace ScrewTurn.Wiki {
|
||||||
txtMaxFileSize.Text = Settings.MaxFileSize.ToString();
|
txtMaxFileSize.Text = Settings.MaxFileSize.ToString();
|
||||||
chkAllowScriptTags.Checked = Settings.ScriptTagsAllowed;
|
chkAllowScriptTags.Checked = Settings.ScriptTagsAllowed;
|
||||||
txtMaxLogSize.Text = Settings.MaxLogSize.ToString();
|
txtMaxLogSize.Text = Settings.MaxLogSize.ToString();
|
||||||
txtIpHostFilter.Text = Settings.IpHostFilter;
|
txtIpHostFilter.Text = Settings.IpHostFilter;
|
||||||
switch(Settings.LoggingLevel) {
|
switch(Settings.LoggingLevel) {
|
||||||
case LoggingLevel.DisableLog:
|
case LoggingLevel.DisableLog:
|
||||||
rdoDisableLog.Checked = true;
|
rdoDisableLog.Checked = true;
|
||||||
|
@ -306,7 +306,7 @@ namespace ScrewTurn.Wiki {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void btnAutoWikiUrl_Click(object sender, EventArgs e) {
|
protected void btnAutoWikiUrl_Click(object sender, EventArgs e) {
|
||||||
string url = Request.Url.ToString();
|
string url = Tools.GetCurrentUrlFixed();
|
||||||
// Assume the URL contains AdminConfig.aspx
|
// Assume the URL contains AdminConfig.aspx
|
||||||
url = url.Substring(0, url.ToLowerInvariant().IndexOf("adminconfig.aspx"));
|
url = url.Substring(0, url.ToLowerInvariant().IndexOf("adminconfig.aspx"));
|
||||||
txtMainUrl.Text = url;
|
txtMainUrl.Text = url;
|
||||||
|
@ -351,27 +351,27 @@ namespace ScrewTurn.Wiki {
|
||||||
e.IsValid = true;
|
e.IsValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void cvUsernameRegEx_ServerValidate(object sender, ServerValidateEventArgs e) {
|
protected void cvUsernameRegEx_ServerValidate(object sender, ServerValidateEventArgs e) {
|
||||||
try {
|
try {
|
||||||
var r = new Regex(txtUsernameRegEx.Text);
|
var r = new Regex(txtUsernameRegEx.Text);
|
||||||
r.IsMatch("Test String to validate Regular Expression");
|
r.IsMatch("Test String to validate Regular Expression");
|
||||||
e.IsValid = true;
|
e.IsValid = true;
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
e.IsValid = false;
|
e.IsValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void cvPasswordRegEx_ServerValidate(object sender, ServerValidateEventArgs e) {
|
protected void cvPasswordRegEx_ServerValidate(object sender, ServerValidateEventArgs e) {
|
||||||
try {
|
try {
|
||||||
var r = new Regex(txtPasswordRegEx.Text);
|
var r = new Regex(txtPasswordRegEx.Text);
|
||||||
r.IsMatch("Test String to validate Regular Expression");
|
r.IsMatch("Test String to validate Regular Expression");
|
||||||
e.IsValid = true;
|
e.IsValid = true;
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
e.IsValid = false;
|
e.IsValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void cvDateTimeFormat_ServerValidate(object sender, ServerValidateEventArgs e) {
|
protected void cvDateTimeFormat_ServerValidate(object sender, ServerValidateEventArgs e) {
|
||||||
try {
|
try {
|
||||||
|
@ -430,7 +430,7 @@ namespace ScrewTurn.Wiki {
|
||||||
Settings.SenderEmail = txtSenderEmail.Text;
|
Settings.SenderEmail = txtSenderEmail.Text;
|
||||||
Settings.ErrorsEmails = GetErrorsEmails();
|
Settings.ErrorsEmails = GetErrorsEmails();
|
||||||
Settings.SmtpServer = txtSmtpServer.Text;
|
Settings.SmtpServer = txtSmtpServer.Text;
|
||||||
|
|
||||||
txtSmtpPort.Text = txtSmtpPort.Text.Trim();
|
txtSmtpPort.Text = txtSmtpPort.Text.Trim();
|
||||||
if(txtSmtpPort.Text.Length > 0) Settings.SmtpPort = int.Parse(txtSmtpPort.Text);
|
if(txtSmtpPort.Text.Length > 0) Settings.SmtpPort = int.Parse(txtSmtpPort.Text);
|
||||||
else Settings.SmtpPort = -1;
|
else Settings.SmtpPort = -1;
|
||||||
|
@ -468,8 +468,8 @@ namespace ScrewTurn.Wiki {
|
||||||
|
|
||||||
// Save security configuration
|
// Save security configuration
|
||||||
Settings.UsersCanRegister = chkAllowUsersToRegister.Checked;
|
Settings.UsersCanRegister = chkAllowUsersToRegister.Checked;
|
||||||
Settings.UsernameRegex = txtUsernameRegEx.Text;
|
Settings.UsernameRegex = txtUsernameRegEx.Text;
|
||||||
Settings.PasswordRegex = txtPasswordRegEx.Text;
|
Settings.PasswordRegex = txtPasswordRegEx.Text;
|
||||||
AccountActivationMode mode = AccountActivationMode.Email;
|
AccountActivationMode mode = AccountActivationMode.Email;
|
||||||
switch(lstAccountActivationMode.SelectedValue.ToLowerInvariant()) {
|
switch(lstAccountActivationMode.SelectedValue.ToLowerInvariant()) {
|
||||||
case "email":
|
case "email":
|
||||||
|
@ -507,7 +507,7 @@ namespace ScrewTurn.Wiki {
|
||||||
else level = LoggingLevel.DisableLog;
|
else level = LoggingLevel.DisableLog;
|
||||||
Settings.LoggingLevel = level;
|
Settings.LoggingLevel = level;
|
||||||
Settings.MaxLogSize = int.Parse(txtMaxLogSize.Text);
|
Settings.MaxLogSize = int.Parse(txtMaxLogSize.Text);
|
||||||
Settings.IpHostFilter = txtIpHostFilter.Text;
|
Settings.IpHostFilter = txtIpHostFilter.Text;
|
||||||
|
|
||||||
// Save advanced configuration
|
// Save advanced configuration
|
||||||
Settings.DisableAutomaticVersionCheck = !chkEnableAutomaticUpdateChecks.Checked;
|
Settings.DisableAutomaticVersionCheck = !chkEnableAutomaticUpdateChecks.Checked;
|
||||||
|
|
|
@ -115,7 +115,7 @@ namespace ScrewTurn.Wiki {
|
||||||
currentUsername, currentGroups);
|
currentUsername, currentGroups);
|
||||||
|
|
||||||
if(!canViewNamespace) {
|
if(!canViewNamespace) {
|
||||||
if(SessionFacade.CurrentUsername == null) UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(HttpContext.Current.Request.Url.ToString()));
|
if(SessionFacade.CurrentUsername == null) UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed()));
|
||||||
else UrlTools.Redirect("AccessDenied.aspx");
|
else UrlTools.Redirect("AccessDenied.aspx");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace ScrewTurn.Wiki {
|
||||||
bool canManageDiscussion = AuthChecker.CheckActionForPage(currentPage, Actions.ForPages.ManageDiscussion, currentUsername, currentGroups);
|
bool canManageDiscussion = AuthChecker.CheckActionForPage(currentPage, Actions.ForPages.ManageDiscussion, currentUsername, currentGroups);
|
||||||
|
|
||||||
if(!canView) {
|
if(!canView) {
|
||||||
if(SessionFacade.LoginKey == null) UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Request.Url.ToString()));
|
if(SessionFacade.LoginKey == null) UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed()));
|
||||||
else UrlTools.Redirect(UrlTools.BuildUrl("AccessDenied.aspx"));
|
else UrlTools.Redirect(UrlTools.BuildUrl("AccessDenied.aspx"));
|
||||||
}
|
}
|
||||||
attachmentViewer.Visible = canDownloadAttachments;
|
attachmentViewer.Visible = canDownloadAttachments;
|
||||||
|
|
|
@ -180,14 +180,14 @@ namespace ScrewTurn.Wiki {
|
||||||
if(currentPage == null) {
|
if(currentPage == null) {
|
||||||
// Check permissions for creating new pages
|
// Check permissions for creating new pages
|
||||||
if(!canCreateNewPages) {
|
if(!canCreateNewPages) {
|
||||||
if(SessionFacade.LoginKey == null) UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Request.Url.ToString()));
|
if(SessionFacade.LoginKey == null) UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed()));
|
||||||
else UrlTools.Redirect("AccessDenied.aspx");
|
else UrlTools.Redirect("AccessDenied.aspx");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Check permissions for editing current page
|
// Check permissions for editing current page
|
||||||
if(!canEdit && !canEditWithApproval) {
|
if(!canEdit && !canEditWithApproval) {
|
||||||
if(SessionFacade.LoginKey == null) UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Request.Url.ToString()));
|
if(SessionFacade.LoginKey == null) UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed()));
|
||||||
else UrlTools.Redirect("AccessDenied.aspx");
|
else UrlTools.Redirect("AccessDenied.aspx");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace ScrewTurn.Wiki {
|
||||||
private void LogError(Exception ex) {
|
private void LogError(Exception ex) {
|
||||||
//if(ex.InnerException != null) ex = ex.InnerException;
|
//if(ex.InnerException != null) ex = ex.InnerException;
|
||||||
try {
|
try {
|
||||||
ScrewTurn.Wiki.Log.LogEntry(HttpContext.Current.Request.Url.ToString() + "\n" +
|
ScrewTurn.Wiki.Log.LogEntry(Tools.GetCurrentUrlFixed() + "\n" +
|
||||||
ex.Source + " thrown " + ex.GetType().FullName + "\n" + ex.Message + "\n" + ex.StackTrace,
|
ex.Source + " thrown " + ex.GetType().FullName + "\n" + ex.Message + "\n" + ex.StackTrace,
|
||||||
ScrewTurn.Wiki.PluginFramework.EntryType.Error, ScrewTurn.Wiki.Log.SystemUsername);
|
ScrewTurn.Wiki.PluginFramework.EntryType.Error, ScrewTurn.Wiki.Log.SystemUsername);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ namespace ScrewTurn.Wiki {
|
||||||
LogError(ex);
|
LogError(ex);
|
||||||
string url = "";
|
string url = "";
|
||||||
try {
|
try {
|
||||||
url = HttpContext.Current.Request.Url.ToString();
|
url = Tools.GetCurrentUrlFixed();
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
EmailTools.NotifyError(ex, url);
|
EmailTools.NotifyError(ex, url);
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace ScrewTurn.Wiki {
|
||||||
languageSelector.SelectedLanguage = lang;
|
languageSelector.SelectedLanguage = lang;
|
||||||
|
|
||||||
if(Request["Redirect"] != null) UrlTools.Redirect(UrlTools.BuildUrl(Request["Redirect"]));
|
if(Request["Redirect"] != null) UrlTools.Redirect(UrlTools.BuildUrl(Request["Redirect"]));
|
||||||
else if(Request.UrlReferrer != null && !string.IsNullOrEmpty(Request.UrlReferrer.ToString())) UrlTools.Redirect(UrlTools.BuildUrl(Request.UrlReferrer.ToString()));
|
else if(Request.UrlReferrer != null && !string.IsNullOrEmpty(Request.UrlReferrer.ToString())) UrlTools.Redirect(UrlTools.BuildUrl(Request.UrlReferrer.FixHost().ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace ScrewTurn.Wiki {
|
||||||
lnkMainPage.NavigateUrl = nspace + "Default.aspx";
|
lnkMainPage.NavigateUrl = nspace + "Default.aspx";
|
||||||
|
|
||||||
if(!Page.IsPostBack) {
|
if(!Page.IsPostBack) {
|
||||||
string referrer = Request.UrlReferrer != null ? Request.UrlReferrer.ToString() : "";
|
string referrer = Request.UrlReferrer != null ? Request.UrlReferrer.FixHost().ToString() : "";
|
||||||
if(!string.IsNullOrEmpty(referrer)) {
|
if(!string.IsNullOrEmpty(referrer)) {
|
||||||
lnkPreviousPage.Visible = true;
|
lnkPreviousPage.Visible = true;
|
||||||
lnkPreviousPage.NavigateUrl = referrer;
|
lnkPreviousPage.NavigateUrl = referrer;
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace ScrewTurn.Wiki {
|
||||||
lblTitle.Text = lblTitle.Text.Replace("##NAME##", Users.GetDisplayName(currentUser));
|
lblTitle.Text = lblTitle.Text.Replace("##NAME##", Users.GetDisplayName(currentUser));
|
||||||
|
|
||||||
txtSubject.Text = Request["Subject"];
|
txtSubject.Text = Request["Subject"];
|
||||||
if(txtSubject.Text != "" && SessionFacade.LoginKey == null) UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Request.Url.ToString()));
|
if(txtSubject.Text != "" && SessionFacade.LoginKey == null) UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SessionFacade.LoginKey == null) pnlMessage.Visible = false;
|
if(SessionFacade.LoginKey == null) pnlMessage.Visible = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue