This commit is contained in:
Virtuworks 2013-11-21 12:15:02 -05:00
commit 26c941dcef
2 changed files with 42 additions and 23 deletions

View file

@ -47,17 +47,32 @@ namespace WebsitePanel.AWStats.Viewer
{ {
private void Page_Load(object sender, EventArgs e) private void Page_Load(object sender, EventArgs e)
{ {
string username = Request["username"];
string password = Request["password"];
if (Request.IsAuthenticated) if (Request.IsAuthenticated)
{ {
string identity = Context.User.Identity.Name; string identity = Context.User.Identity.Name;
string domain = identity.Split('=')[0]; string domain = identity.Split('=')[0];
if (String.Compare(Request["config"], domain, true) != 0) if (String.Compare(Request["config"], domain, true) != 0)
{ {
FormsAuthentication.SignOut(); FormsAuthentication.SignOut();
Response.Redirect(Request.Url.AbsolutePath); domain = Request["domain"];
if (!String.IsNullOrEmpty(domain)
&& !String.IsNullOrEmpty(username)
&& !String.IsNullOrEmpty(password))
{
// perform login
txtUsername.Text = username;
txtDomain.Text = domain;
Login(domain, username, password);
}
else
{
Response.Redirect(Request.Url.AbsolutePath);
}
} }
Response.Clear(); Response.Clear();
string queryParams = Request.Url.Query; string queryParams = Request.Url.Query;
@ -74,39 +89,36 @@ namespace WebsitePanel.AWStats.Viewer
// replace links // replace links
awStatsPage = awStatsPage.Replace(AWStatsScript, Request.Url.AbsolutePath); awStatsPage = awStatsPage.Replace(AWStatsScript, Request.Url.AbsolutePath);
Response.Write(awStatsPage); Response.Write(awStatsPage);
Response.End(); Response.End();
} }
else else
{ {
lblMessage.Visible = false; lblMessage.Visible = false;
if (!IsPostBack) if (!IsPostBack)
{ {
string domain = Request["domain"]; string domain = Request["domain"];
string username = Request["username"];
string password = Request["password"];
if (String.IsNullOrEmpty(domain)) if (String.IsNullOrEmpty(domain))
domain = Request["config"]; domain = Request["config"];
txtDomain.Text = domain; txtDomain.Text = domain;
if (!String.IsNullOrEmpty(username)) if (!String.IsNullOrEmpty(username))
txtUsername.Text = username; txtUsername.Text = username;
// check for autologin // check for autologin
if (!String.IsNullOrEmpty(domain) if (!String.IsNullOrEmpty(domain)
&& !String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(username)
&& !String.IsNullOrEmpty(password)) && !String.IsNullOrEmpty(password))
{ {
// perform login // perform login
Login(domain, username, password); Login(domain, username, password);
} }
} }
} }
} }
protected void btnView_Click(object sender, EventArgs e) protected void btnView_Click(object sender, EventArgs e)

View file

@ -136,7 +136,7 @@ namespace WebsitePanel.Providers.Utils
if (String.IsNullOrEmpty(str)) if (String.IsNullOrEmpty(str))
return str; return str;
Regex re = new Regex("%(.+)%", RegexOptions.IgnoreCase); Regex re = new Regex("%([^\\s\\%]+)%", RegexOptions.IgnoreCase);
return re.Replace(str, new MatchEvaluator(EvaluateSystemVariable)); return re.Replace(str, new MatchEvaluator(EvaluateSystemVariable));
} }
@ -185,7 +185,15 @@ namespace WebsitePanel.Providers.Utils
private static string EvaluateSystemVariable(Match match) private static string EvaluateSystemVariable(Match match)
{ {
return Environment.GetEnvironmentVariable(match.Groups[1].Value); string EnvVar = Environment.GetEnvironmentVariable(match.Groups[1].Value);
if (string.IsNullOrEmpty(EnvVar))
{
return @"%" + match.Groups[1].Value + @"%";
}
else
{
return EnvVar;
}
} }
public static bool FileExists(string path) public static bool FileExists(string path)
@ -967,8 +975,7 @@ namespace WebsitePanel.Providers.Utils
catch catch
{ } { }
} }
#region Advanced Delete
#region Advanced Delete
/// <summary> /// <summary>
/// Deletes the specified file. /// Deletes the specified file.
/// </summary> /// </summary>