Beispiel #1
0
        public static bool keylib_activate_get(
            string prod,
            string sregid,
            string email,
            out string keycode,
            out string reason)
        {
            string str1    = "netwinsite.com";
            string str2    = MyKey.keylib_host_new(MyKey.get_host());
            string postUrl = string.Format("http://{0}/cgi-bin/keycgi.exe", (object)str1);

            keycode           = "failed";
            MyKey.robot_email = string.Format("{{host: {0}}}\r\n{{regid: {1}}}\r\n{{email: {2}}}\r\n{{product: {3}}}\r\n{{build: {4}}}\r\n{{hostid: {5}}}\r\n", (object)str2, (object)sregid, (object)email, (object)prod, (object)MyKey.keylib_build_date(), (object)MyKey.s_hostid);
            if (email.Length > 0)
            {
                MyKey.s_email = email;
            }
            reason = "";
            sregid = sregid.ToLower();
            if (sregid.StartsWith("n"))
            {
                sregid = sregid.Substring(1);
            }
            Dictionary <string, object> postParameters = new Dictionary <string, object>();

            postParameters.Add("cmd", (object)"activate");
            postParameters.Add("regid", (object)sregid);
            postParameters.Add(nameof(email), (object)email);
            postParameters.Add("host", (object)str2);
            postParameters.Add("product", (object)prod);
            postParameters.Add("build", (object)MyKey.keylib_build_date());
            postParameters.Add("hostid", (object)MyKey.s_hostid);
            string end;

            try
            {
                string          userAgent       = "ftpdav";
                HttpWebResponse httpWebResponse = WebHelpers.MultipartFormDataPost(postUrl, userAgent, postParameters, "", "");
                end = new StreamReader(httpWebResponse.GetResponseStream()).ReadToEnd();
                httpWebResponse.Close();
                stat.imsg("image post response {0}", (object)end);
            }
            catch (Exception ex)
            {
                stat.imsg("image post failed to connect {0}", (object)ex.ToString());
                return(false);
            }
            keycode = "";
            string str3 = "";

            foreach (string str4 in end.string_lines_any())
            {
                clib.imsg("Response: {0}", (object)str4);
                if (str4.StartsWith("key: "))
                {
                    keycode = str4.Substring(5);
                }
                if (str4.StartsWith("key_state: "))
                {
                    str3 = str4.Substring(1);
                }
                if (str4.StartsWith("error: "))
                {
                    reason = str4.Substring(7);
                }
            }
            if (reason.Length > 0)
            {
                return(false);
            }
            clib.imsg("key state {0}", (object)str3);
            MyKey.s_code = keycode;
            return(true);
        }
Beispiel #2
0
 public static string show()
 {
     return(string.Format("Regid={0} regdate={1} host={2} prodid={3} flags={4} ulimit={5} istemp={6} host={7} expires={8}", (object)MyKey.regid, (object)MyKey.regdate, (object)MyKey.host, (object)MyKey.prodid, (object)MyKey.flags, (object)MyKey.ulimit, (object)MyKey.istemp, (object)MyKey.keylib_host_new(MyKey.get_host()), (object)clib.nice_unix_date(MyKey.expdate)));
 }