Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.waw.patyki.twistthewebmobile;
- import org.jsoup.Connection;
- import org.jsoup.Jsoup;
- import org.jsoup.nodes.Document;
- import java.io.IOException;
- public class webhandler {
- static String sessionid = null;
- private static Connection.Response get(String urlend){
- Connection.Response pdl = null;
- try {
- if(sessionid==null) {
- pdl = Jsoup.connect("http://www.twisttheweb.com/" + urlend).referrer("http://www.twisttheweb.com/").execute();
- }
- else{
- pdl = Jsoup.connect("http://www.twisttheweb.com/" + urlend).referrer("http://www.twisttheweb.com/").cookie("PHPSESSID",sessionid).execute();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return pdl;
- }
- private static Document getDoc(String urlend){
- Document doc = null;
- Connection.Response pdl = get(urlend);
- try {
- doc=pdl.parse();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (NullPointerException n){
- n.printStackTrace();
- }
- return doc;
- }
- public static Document login(String name,String pass){
- Document doc = null;
- Connection.Response pdl = get("login.php?user=" + name + "&password=" + pass + "&rememberme=no");
- sessionid = pdl.cookie("PHPSESSID");
- try {
- doc=pdl.parse();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return doc;
- }
- public static Document salas(){
- return getDoc("salas.php");
- }
- public static Document unirse(String roomid,String pass){
- return getDoc("unirse.php?juego="+roomid+"&clave="+pass);
- }
- public static Document bajardatos(String kon){
- return getDoc("bajardatos.php?linea="+kon);
- }
- public static Document subirdatos(String start, String end){
- return getDoc("subirdatos.php?cmd=" + start + "&texto=" + end);
- }
- public static Document logout(){
- return getDoc("login.php?logout=yes");
- }
- public static Document nuevo(String hall, String publik, String key, String reqs, String intro){
- return getDoc("nuevo.php?hall=" + hall + "&public=" + publik + "&keyword=" + key +"&requisites=" + reqs + "&presentation=" + intro);
- }
- public static void removeCookie(){
- sessionid = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement