Guest User

Untitled

a guest
Apr 8th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. -(void)connection:(CPURLConnection)aConnection didFailWithError:(CPException)anException
  2. {
  3. alert("write failed");
  4. }
  5. -(void)connection:(CPURLConnection)aConnection didReceiveResponse:(CPHTTPURLResponse)aResponse
  6. {
  7. // If we got this far and it wasn't an HTTP request, then everything is fine.
  8. if (![aResponse isKindOfClass:[CPHTTPURLResponse class]])
  9. return;
  10.  
  11. var statusCode = [aResponse statusCode];
  12.  
  13. // Nothing to do if everything is hunky dory.
  14. if (statusCode === 200)
  15. return;
  16. else
  17. alert("Write failed: server error");
  18.  
  19. //console.log("code: " + statusCode);
  20. }
  21.  
  22. -(void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
  23. {
  24. console.log(data);
  25.  
  26. [progress_window close];
  27.  
  28. if(aConnection == theCon)
  29. {
  30. //Authentication results are back
  31.  
  32.  
  33. if ([data isEqualToString:"VALID"])
  34. {
  35. [self OpenDesktop];
  36. }
  37. else
  38. {
  39. [login_window center];
  40. [login_window makeKeyAndOrderFront:nil];
  41. }
  42.  
  43. }
  44. }
  45.  
  46. - (void)Authenticate:(CPString)uss Password:(CPString)pa
  47. {
  48. var pg_url = document.location.href;
  49. var request = [CPURLRequest requestWithURL:[CPString stringWithFormat:@"%@file_system.php", pg_url]];
  50.  
  51. console.log([CPString stringWithFormat:@"%@file_system.php", pg_url]);
  52.  
  53. var postData = "action=authenticate&user=" + uss + "&pass=" + pa;
  54.  
  55. [request setHTTPMethod:@"POST"];
  56. [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
  57. [request setHTTPBody:postData];
  58.  
  59. theCon = [CPURLConnection connectionWithRequest:request delegate:self];
  60. }
Add Comment
Please, Sign In to add comment