Ejemplo n.º 1
0
        public static string AddHTMLPage(string html, string urlToAppend, string methodName,
                                         Dictionary <string, object> variables, HTTPReturned eventDelegate)
        {
            string secret  = Util.RandomClass.Next(0, int.MaxValue).ToString();
            string secret2 = Util.RandomClass.Next(0, int.MaxValue).ToString();
            string navUrl  = MainServer.Instance.ServerURI +
                             (urlToAppend == "" ? "" : "/") + urlToAppend + "/index.php?method=" + methodName + secret2;
            string url = MainServer.Instance.ServerURI +
                         (urlToAppend == "" ? "" : "/") + urlToAppend + "/index.php?method=" + methodName + secret;

            MainServer.Instance.RemoveStreamHandler("GET", "/index.php?method=" + methodName + secret);
            MainServer.Instance.RemoveStreamHandler("GET", "/index.php?method=" + methodName + secret2);

            variables["url"] = url;
            MainServer.Instance.AddStreamHandler(new GenericStreamHandler("GET", "/index.php?method=" + methodName + secret2,
                                                                          delegate(string path, Stream request,
                                                                                   OSHttpRequest httpRequest,
                                                                                   OSHttpResponse httpResponse)
            {
                MainServer.Instance.RemoveStreamHandler
                    ("GET", "/index.php?method=" + methodName + secret2);
                return(SetUpWebpage(httpResponse, url,
                                    html, variables));
            }));
            MainServer.Instance.AddStreamHandler(new GenericStreamHandler("GET",
                                                                          "/index.php?method=" + methodName + secret,
                                                                          delegate(string path, Stream request,
                                                                                   OSHttpRequest httpRequest,
                                                                                   OSHttpResponse httpResponse)
            {
                MainServer.Instance.RemoveStreamHandler(
                    "GET", "/index.php?method=" + methodName +
                    secret);
                return(HandleResponse(httpRequest,
                                      httpResponse,
                                      request,
                                      urlToAppend,
                                      variables,
                                      eventDelegate));
            }));
            return(navUrl);
        }
Ejemplo n.º 2
0
        public static string AddHTMLPage(string html, string urlToAppend, string methodName,
                                         Dictionary<string, object> variables, HTTPReturned eventDelegate)
        {
            string secret = Util.RandomClass.Next(0, int.MaxValue).ToString();
            string secret2 = Util.RandomClass.Next(0, int.MaxValue).ToString();
            string navUrl = MainServer.Instance.ServerURI +
                            (urlToAppend == "" ? "" : "/") + urlToAppend + "/index.php?method=" + methodName + secret2;
            string url = MainServer.Instance.ServerURI +
                         (urlToAppend == "" ? "" : "/") + urlToAppend + "/index.php?method=" + methodName + secret;
            MainServer.Instance.RemoveStreamHandler("GET", "/index.php?method=" + methodName + secret);
            MainServer.Instance.RemoveStreamHandler("GET", "/index.php?method=" + methodName + secret2);

            variables["url"] = url;
            MainServer.Instance.AddStreamHandler(new GenericStreamHandler("GET", "/index.php?method=" + methodName + secret2,
                                                                        delegate(string path, Stream request,
                                                                                 OSHttpRequest httpRequest,
                                                                                 OSHttpResponse httpResponse)
                                                                            {
                                                                                MainServer.Instance.RemoveStreamHandler
                                                                                    ("GET", "/index.php?method=" + methodName + secret2);
                                                                                return SetUpWebpage(httpResponse, url,
                                                                                                    html, variables);
                                                                            }));
            MainServer.Instance.AddStreamHandler(new GenericStreamHandler("GET",
                                                                        "/index.php?method=" + methodName + secret,
                                                                        delegate(string path, Stream request,
                                                                                 OSHttpRequest httpRequest,
                                                                                 OSHttpResponse httpResponse)
                                                                            {
                                                                                MainServer.Instance.RemoveStreamHandler(
                                                                                    "GET", "/index.php?method=" + methodName +
                                                                                    secret);
                                                                                return HandleResponse(httpRequest,
                                                                                                      httpResponse,
                                                                                                      request,
                                                                                                      urlToAppend,
                                                                                                      variables,
                                                                                                      eventDelegate);
                                                                            }));
            return navUrl;
        }
Ejemplo n.º 3
0
        private static Hashtable HandleResponse(Hashtable request, string urlToAppend, Dictionary<string, object> variables, HTTPReturned eventHandler)
        {
            Uri myUri = new Uri("http://localhost/index.php?" + request["body"]);
            Dictionary<string, string> newVars = new Dictionary<string, string>();
            foreach (string key in variables.Keys)
            {
                newVars[key] = HttpUtility.ParseQueryString(myUri.Query).Get(key);
            }
            string url = eventHandler(newVars);

            Hashtable reply = new Hashtable();
            string html = "<html>" +
                (url == "" ? "" :
("<head>" +
"<meta http-equiv=\"REFRESH\" content=\"0;url=" + url + "\"></HEAD>")) +
"</HTML>";
            reply["str_response_string"] = html;
            reply["int_response_code"] = 200;
            reply["content_type"] = "text/html";

            return reply;
        }
Ejemplo n.º 4
0
        private static byte[] HandleResponse(OSHttpRequest httpRequest, OSHttpResponse response, Stream stream,
                                             string urlToAppend, Dictionary<string, object> variables,
                                             HTTPReturned eventHandler)
        {
            Uri myUri = new Uri("http://localhost/index.php?" + stream.ReadUntilEnd());
            Dictionary<string, string> newVars = new Dictionary<string, string>();
            foreach (string key in variables.Keys)
            {
                newVars[key] = HttpUtility.ParseQueryString(myUri.Query).Get(key);
            }
            string url = eventHandler(newVars);

            string html = "<html>" +
                          (url == ""
                               ? ""
                               : ("<head>" +
                                  "<meta http-equiv=\"REFRESH\" content=\"0;url=" + url + "\"></HEAD>")) +
                          "</HTML>";
            response.ContentType = "text/html";

            return Encoding.UTF8.GetBytes(html);
        }
Ejemplo n.º 5
0
 public static string AddHTMLPage(string html, string urlToAppend, string methodName, Dictionary<string, object> variables, HTTPReturned eventDelegate)
 {
     string secret = Util.RandomClass.Next(0, int.MaxValue).ToString();
     string secret2 = Util.RandomClass.Next(0, int.MaxValue).ToString();
     string navUrl = MainServer.Instance.ServerURI +
         (urlToAppend == "" ? "" : "/") + urlToAppend + "/index.php?method=" + methodName + secret2;
     string url = MainServer.Instance.ServerURI +
         (urlToAppend == "" ? "" : "/") + urlToAppend + "/index.php?method=" + methodName + secret;
     MainServer.Instance.RemoveHTTPHandler(null, methodName + secret);
     MainServer.Instance.RemoveHTTPHandler(null, methodName + secret2);
     variables["url"] = url;
     MainServer.Instance.AddHTTPHandler(methodName + secret2, delegate(Hashtable t)
     {
         MainServer.Instance.RemoveHTTPHandler(null, methodName + secret2);
         return SetUpWebpage(t, url, html, variables);
     });
     MainServer.Instance.AddHTTPHandler(methodName + secret, delegate(Hashtable t)
     {
         MainServer.Instance.RemoveHTTPHandler(null, methodName + secret);
         return HandleResponse(t, urlToAppend, variables, eventDelegate);
     });
     return navUrl;
 }
Ejemplo n.º 6
0
        private static byte[] HandleResponse(OSHttpRequest httpRequest, OSHttpResponse response, Stream stream,
                                             string urlToAppend, Dictionary <string, object> variables,
                                             HTTPReturned eventHandler)
        {
            Uri myUri = new Uri("http://localhost/index.php?" + HttpServerHandlerHelpers.ReadString(stream));
            Dictionary <string, string> newVars = new Dictionary <string, string>();

            foreach (string key in variables.Keys)
            {
                newVars[key] = HttpUtility.ParseQueryString(myUri.Query).Get(key);
            }
            string url = eventHandler(newVars);

            string html = "<html>" +
                          (url == ""
                               ? ""
                               : ("<head>" +
                                  "<meta http-equiv=\"REFRESH\" content=\"0;url=" + url + "\"></HEAD>")) +
                          "</HTML>";

            response.ContentType = "text/html";

            return(Encoding.UTF8.GetBytes(html));
        }
Ejemplo n.º 7
0
        private static Hashtable HandleResponse(Hashtable request, string urlToAppend, Dictionary <string, string> variables, HTTPReturned eventHandler)
        {
            Uri myUri = new Uri("http://localhost/index.php?" + request["body"]);
            Dictionary <string, string> newVars = new Dictionary <string, string>();

            foreach (string key in variables.Keys)
            {
                newVars[key] = HttpUtility.ParseQueryString(myUri.Query).Get(key);
            }
            string url = eventHandler(newVars);

            Hashtable reply = new Hashtable();
            string    html  = "<html>" +
                              (url == "" ? "" :
                               ("<head>" +
                                "<meta http-equiv=\"REFRESH\" content=\"0;url=" + url + "\"></HEAD>")) +
                              "</HTML>";

            reply["str_response_string"] = html;
            reply["int_response_code"]   = 200;
            reply["content_type"]        = "text/html";

            return(reply);
        }
Ejemplo n.º 8
0
        public static string AddHTMLPage(string html, string urlToAppend, string methodName, Dictionary <string, string> variables, HTTPReturned eventDelegate)
        {
            string secret  = Util.RandomClass.Next(0, int.MaxValue).ToString();
            string secret2 = Util.RandomClass.Next(0, int.MaxValue).ToString();
            string navUrl  = MainServer.Instance.ServerURI +
                             (urlToAppend == "" ? "" : "/") + urlToAppend + "/index.php?method=" + methodName + secret2;
            string url = MainServer.Instance.ServerURI +
                         (urlToAppend == "" ? "" : "/") + urlToAppend + "/index.php?method=" + methodName + secret;

            MainServer.Instance.RemoveHTTPHandler(null, methodName + secret);
            MainServer.Instance.RemoveHTTPHandler(null, methodName + secret2);
            variables["url"] = url;
            MainServer.Instance.AddHTTPHandler(methodName + secret2, delegate(Hashtable t)
            {
                MainServer.Instance.RemoveHTTPHandler(null, methodName + secret2);
                return(SetUpWebpage(t, url, html, variables));
            });
            MainServer.Instance.AddHTTPHandler(methodName + secret, delegate(Hashtable t)
            {
                MainServer.Instance.RemoveHTTPHandler(null, methodName + secret);
                return(HandleResponse(t, urlToAppend, variables, eventDelegate));
            });
            return(navUrl);
        }