private void button1_Click(object sender, EventArgs e) { try { byte[] abc = System.Text.Encoding.GetEncoding("gb2312").GetBytes(this.serializeTextBox.Text); object obj = PHPSerializer.UnSerialize(abc, System.Text.Encoding.GetEncoding("gb2312")); //object obj = serializer.Deserialize(this.serializeTextBox.Text); Hashtable al = (Hashtable)obj; foreach (object o in al) { if (o.GetType() == typeof(Hashtable)) { Hashtable ht = (Hashtable)o; } else { System.Diagnostics.Debug.WriteLine(o.GetType() + ":" + o.ToString()); } } for (int i = 0; i < al.Count; i++) { Hashtable ht = (Hashtable)al[i]; //do something } } catch (Exception ex) { MessageBox.Show(this, "Error Deserializing: " + ex.Message, "Deserialization Error"); } }
public JetSetPro(string user, string password) { loginLock = new object(); loginWC = new CookieAwareWebClient(); _user = user; _password = password; serializer = new PHPSerializer(); }
public ProcessOnImportMembersResponse ProcessOnImportMembers(ProcessOnImportMembersRequest request) { EnsureValidRequest(request); var response = new ProcessOnImportMembersResponse(); using (var db = new CSSDataContext()) { int startingIndex = Convert.ToInt32(request.limit_a); int count = Convert.ToInt32(request.limit_b); var logins = db.Logins.Skip(startingIndex).Take(count); int complete = 0; if (logins.Count() < count) { complete = 1; } var members = new Hashtable(); foreach (var login in logins) { var member = new Hashtable(); member.Add("email_address", login.Email); member.Add("username", login.Username); member.Add("pass_salt", String.Empty); member.Add("password", login.Password); member.Add("ip_address", "0.0.0.0"); member.Add("join_date", ConvertToUnixTimestamp(login.DateCreated)); member.Add("extra", String.Empty); member.Add("flag", 1); members.Add(login.Id, member); } var data = new Hashtable(); data.Add("complete", complete); data.Add("members", members); PHPSerializer serializer = new PHPSerializer(); string serializedData = serializer.Serialize(data); File.AppendAllText(@"c:\php_requests.log", "ipConverge.importMembers serializedData = " + serializedData + "\r\n"); // string data = @" //Array( // ""complete"" => 1, // ""members"" => array ( // 5 => array( // ""email_address"" => ""*****@*****.**"", // ""username"" => ""backtrak"", // ""pass_salt"" => """", // ""password"" => ""12345abcdef"", // ""ip_address"" => ""1.1.1.1"", // ""join_date"" => 2000000, // ""extra"" => """", // ""flag"" => 1, // ), // 6 => array( // ""email_address"" => ""*****@*****.**"", // ""username"" => ""backtrak2"", // ""pass_salt"" => """", // ""password"" => ""12345abcdef222"", // ""ip_address"" => ""1.1.1.2"", // ""join_date"" => 2000002, // ""extra"" => """", // ""flag"" => 1, // ) // ) //) //"; //string encodedData = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(data)); //File.AppendAllText(@"c:\php_requests.log", "ipConverge.importMembers encodedData = " + encodedData + "\r\n"); //response.__serialized64__ = encodedData; //response.__serialized64__ = "YToyOntzOjg6ImNvbXBsZXRlIjtpOjE7czo3OiJtZW1iZXJzIjthOjI6e2k6MTthOjg6e3M6MTM6ImVtYWlsX2FkZHJlc3MiO3M6MTc6Im5pY2tAY2hpLXRvd24uY29tIjtzOjg6InVzZXJuYW1lIjtzOjg6ImJhY2t0cmFrIjtzOjk6InBhc3Nfc2FsdCI7czowOiIiO3M6ODoicGFzc3dvcmQiO3M6MTE6IjEyMzQ1YWJjZGVmIjtzOjEwOiJpcF9hZGRyZXNzIjtzOjc6IjEuMS4xLjEiO3M6OToiam9pbl9kYXRlIjtpOjIwMDAwMDA7czo1OiJleHRyYSI7czowOiIiO3M6NDoiZmxhZyI7aToxO31pOjI7YTo4OntzOjEzOiJlbWFpbF9hZGRyZXNzIjtzOjE4OiJuaWNrMkBjaGktdG93bi5jb20iO3M6ODoidXNlcm5hbWUiO3M6OToiYmFja3RyYWsyIjtzOjk6InBhc3Nfc2FsdCI7czowOiIiO3M6ODoicGFzc3dvcmQiO3M6MTQ6IjEyMzQ1YWJjZGVmMjIyIjtzOjEwOiJpcF9hZGRyZXNzIjtzOjc6IjEuMS4xLjIiO3M6OToiam9pbl9kYXRlIjtpOjIwMDAwMDI7czo1OiJleHRyYSI7czowOiIiO3M6NDoiZmxhZyI7aToxO319fQ=="; string encodedData = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(serializedData)); File.AppendAllText(@"c:\php_requests.log", "ipConverge.importMembers encodedData = " + encodedData + "\r\n"); response.__serialized64__ = encodedData; response.completed = 1; response.response = "SUCCESS"; } return(response); }