public static string host() { string str = Ini.getstring(En.host); if (str == null || str.Length == 0) { str = MyKey.get_host(); } return(str); }
public static bool decode(string key, out string reason) { byte[] xin = clib.hex_to_byte(key); int index1 = 0; int mon = 0; reason = ""; if (key.Length < 30) { reason = "tooshort: Keys are 30 char long"; return(false); } MyKey.regid = (int)xin[index1] + (int)xin[index1 + 1] * 256 + (int)xin[index1 + 2] * 65536; int index2 = index1 + 3; MyKey.regdate = (int)xin[index2] + (int)xin[index2 + 1] * 256; int index3 = index2 + 2; MyKey.host = (int)xin[index3] + (int)xin[index3 + 1] * 256; int num1 = index3 + 2; byte[] numArray1 = xin; int index4 = num1; int num2 = index4 + 1; MyKey.prodid = (int)numArray1[index4]; byte[] numArray2 = xin; int index5 = num2; int num3 = index5 + 1; MyKey.flags = (int)numArray2[index5]; byte[] numArray3 = xin; int index6 = num3; int index7 = index6 + 1; MyKey.ulimit = MyKey.keylib_ulimit_decode((int)numArray3[index6]); int num4 = MyKey.keylib_crc(xin, MyKey.PRE_CRC); int num5 = (int)xin[index7] + (int)xin[index7 + 1] * 256; int num6 = index7 + 2; clib.imsg("crc {0} {1}", (object)num4, (object)num5); MyKey.reg_day1 = (int)xin[12]; MyKey.reg_day2 = (int)xin[13]; MyKey.fromdate = MyKey.keylib_fromdate(MyKey.regdate, MyKey.reg_day1, MyKey.reg_day2, out mon); if (MyKey.host != 0) { string host = MyKey.get_host(); if (MyKey.keylib_host(host) != MyKey.host && MyKey.keylib_host(MyKey.keylib_host_trim(host)) != MyKey.host) { reason = string.Format("Key for wrong host=({0}) ({1}) , try activate again", (object)host, (object)MyKey.keylib_host_trim(host)); return(false); } } DateTime date = clib.unix_to_date(MyKey.fromdate); MyKey.expdate = date.AddMonths(mon).to_unix_date(); if (mon == 0) { date = clib.unix_to_date(MyKey.fromdate); MyKey.expdate = date.AddMonths(12).to_unix_date(); } MyKey.istemp = true; if (mon == 0) { MyKey.istemp = false; } clib.imsg("Fromdate is {0} {1} Expires {2}", (object)MyKey.fromdate, (object)clib.nice_unix_date(MyKey.fromdate), (object)clib.nice_unix_date(MyKey.expdate)); if (num4 == num5) { return(true); } reason = "bad crc"; return(false); }
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); }
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))); }