Esempio n. 1
0
 public void Welcome()
 {
     if (CheckRight())
     {
         if (User != null && User.Identity.IsAuthenticated && User.Identity.IsAdmin)
         {
             if (CheckPost("welcome", () =>
             {
                 StringBuilder sb = new StringBuilder();
                 List <ModuleInfo> list = ModuleInfo.GetAllList(Context);
                 foreach (ModuleInfo info in list)
                 {
                     sb.Append("<li><i class=\"dll\">");
                     sb.Append(info.Name);
                     sb.Append("</i><i class=\"ii\">&nbsp;v</i><i class=\"ver\">");
                     sb.Append(info.Version);
                     sb.Append("</i><i class=\"up\"></i></li>");
                 }
                 this["Version"] = sb.ToString();
                 string loginArea = User.Identity.LastIp;
                 using (IPArea area = new IPArea())
                 {
                     IPLocation ip = area.Search(loginArea);
                     if (ip != null)
                     {
                         loginArea = ip.ToString();
                     }
                 }
                 this["LoginArea"] = loginArea;
             }))
             {
                 NotFound();
             }
         }
         else
         {
             Unauthorized();
         }
     }
 }
Esempio n. 2
0
 public void Upgrade()
 {
     if (CheckAjax())
     {
         if (CheckRight())
         {
             try
             {
                 byte[]         data    = Encoding.UTF8.GetBytes(JsonValue.Serialize(ModuleInfo.GetAllList(Context)));
                 HttpWebRequest request = WebRequest.CreateHttp("http://upgrade.cnaws.com/upgrade/check.html");
                 request.AllowAutoRedirect = true;
                 request.Method            = "POST";
                 request.ContentType       = "application/x-javascript";
                 using (Stream input = request.GetRequestStream())
                     input.Write(data, 0, data.Length);
                 using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                 {
                     using (Stream output = response.GetResponseStream())
                     {
                         using (StreamReader reader = new StreamReader(output, Encoding.UTF8))
                             SetResult(JsonValue.Deserialize <Dictionary <string, string> >(reader.ReadToEnd()));
                     }
                 }
             }
             catch (Exception)
             {
                 SetResult(false);
             }
         }
     }
 }