Advertisement
Guest User

Untitled

a guest
Oct 18th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. package pl.waw.patyki.twistthewebmobile;
  2.  
  3. import org.jsoup.Connection;
  4. import org.jsoup.Jsoup;
  5. import org.jsoup.nodes.Document;
  6.  
  7. import java.io.IOException;
  8.  
  9. public class webhandler {
  10.  
  11. static String sessionid = null;
  12.  
  13. private static Connection.Response get(String urlend){
  14. Connection.Response pdl = null;
  15. try {
  16. if(sessionid==null) {
  17. pdl = Jsoup.connect("http://www.twisttheweb.com/" + urlend).referrer("http://www.twisttheweb.com/").execute();
  18. }
  19. else{
  20. pdl = Jsoup.connect("http://www.twisttheweb.com/" + urlend).referrer("http://www.twisttheweb.com/").cookie("PHPSESSID",sessionid).execute();
  21. }
  22. } catch (IOException e) {
  23. e.printStackTrace();
  24.  
  25. }
  26. return pdl;
  27. }
  28. private static Document getDoc(String urlend){
  29. Document doc = null;
  30. Connection.Response pdl = get(urlend);
  31. try {
  32. doc=pdl.parse();
  33. } catch (IOException e) {
  34. e.printStackTrace();
  35. } catch (NullPointerException n){
  36. n.printStackTrace();
  37. }
  38. return doc;
  39. }
  40. public static Document login(String name,String pass){
  41. Document doc = null;
  42. Connection.Response pdl = get("login.php?user=" + name + "&password=" + pass + "&rememberme=no");
  43. sessionid = pdl.cookie("PHPSESSID");
  44. try {
  45. doc=pdl.parse();
  46. } catch (IOException e) {
  47. e.printStackTrace();
  48. }
  49. return doc;
  50. }
  51. public static Document salas(){
  52. return getDoc("salas.php");
  53. }
  54. public static Document unirse(String roomid,String pass){
  55. return getDoc("unirse.php?juego="+roomid+"&clave="+pass);
  56. }
  57. public static Document bajardatos(String kon){
  58. return getDoc("bajardatos.php?linea="+kon);
  59. }
  60. public static Document subirdatos(String start, String end){
  61. return getDoc("subirdatos.php?cmd=" + start + "&texto=" + end);
  62. }
  63. public static Document logout(){
  64. return getDoc("login.php?logout=yes");
  65. }
  66. public static Document nuevo(String hall, String publik, String key, String reqs, String intro){
  67. return getDoc("nuevo.php?hall=" + hall + "&public=" + publik + "&keyword=" + key +"&requisites=" + reqs + "&presentation=" + intro);
  68. }
  69. public static void removeCookie(){
  70. sessionid = null;
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement