A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 575
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/system/core/Exceptions.php:271)

Filename: view/rss.php

Line Number: 2

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/themes/geocities/views/view/rss.php
Line: 2
Function: header

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 173
Function: include

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 43
Function: _ci_load

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 579
Function: view

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Re: Re: Untitled - Stikked Re: Re: Untitled - Stikked http://geopaste.scratchbook.ch/ en Re: Re: Re: Untitled http://geopaste.scratchbook.ch/view/30d97222 Tue, 21 Apr 2015 10:51:36 +0200 Silly Guinea Pig http://geopaste.scratchbook.ch/view/30d97222
  1. public class AutomaticLogin {
  2.  
  3.     private List<String> cookies;
  4.     private HttpsURLConnection conn;
  5.  
  6.     private final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  7.  
  8.     public static void main(String[] args) throws Exception {
  9.  
  10.         String url = "https://accounts.craigslist.org/login";
  11.         String gmail = "https://accounts.craigslist.org/login/home?show_tab=postings";
  12.  
  13.  
  14.         AutomaticLogin http = new AutomaticLogin();
  15.  
  16.  
  17.         CookieHandler.setDefault(new CookieManager());
  18.  
  19.         String page = http.GetPageContent(url);
  20.  
  21.         String postParams = http.getFormParams(page, "username", "password");
  22.  
  23.         String anotherString = null;
  24.         anotherString = postParams.substring(0, 93);
  25.  
  26.         System.out.println(postParams);
  27.         System.out.println();
  28.  
  29.  
  30.         http.sendPost(url, postParams);
  31.  
  32.         String result = http.GetPageContent(gmail);
  33.         System.out.println(result);
  34.  
  35.     }
  36.  
  37.     private void sendPost(String url, String postParams) throws Exception {
  38.  
  39.         URL obj = new URL(url);
  40.         conn = (HttpsURLConnection) obj.openConnection();
  41.  
  42.  
  43.  
  44.         conn.setUseCaches(false);
  45.         conn.setRequestMethod("POST");
  46.         conn.setRequestProperty("Host", "craigslist.org");
  47.         conn.setRequestProperty("User-Agent", USER_AGENT);
  48.         conn.setRequestProperty("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  49.         conn.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  50.         conn.setAllowUserInteraction(true);
  51.  
  52.         conn.setRequestProperty("Connection", "keep-alive");
  53.         conn.setRequestProperty("Referer", "https://accounts.craigslist.org/login/home");
  54.         conn.setRequestProperty("Content-Type", "x-www-form-urlencoded");
  55.  
  56.         conn.setFixedLengthStreamingMode(postParams.getBytes().length);
  57.  
  58.         conn.setInstanceFollowRedirects(false);
  59.  
  60.         conn.setDoOutput(true);
  61.         conn.setDoInput(true);
  62.         if (cookies != null) {
  63.             for (String cookie : this.cookies) {
  64.                 conn.addRequestProperty("Cookie", cookie.split(" ", 2)[0]);
  65.             }
  66.         }
  67.  
  68.  
  69.         DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
  70.         wr.writeBytes(postParams);
  71.         wr.flush();
  72.         wr.close();
  73.  
  74.         int responseCode = conn.getResponseCode();
  75.         String msg = conn.getResponseMessage();
  76.         System.out.println("\nSending 'POST' request to URL : " + url);
  77.         System.out.println("Post parameters : " + postParams);
  78.         System.out.println("Response Code : " + responseCode);
  79.         System.out.println(msg);
  80.  
  81.  
  82.         BufferedReader in =
  83.                 new BufferedReader(new InputStreamReader(conn.getInputStream()));
  84.         String inputLine;
  85.         StringBuffer response = new StringBuffer();
  86.  
  87.         while ((inputLine = in.readLine()) != null) {
  88.             response.append(inputLine);
  89.  
  90.  
  91.         }
  92.         in.close();
  93.         System.out.println(response.toString());
  94.  
  95.     }
  96.  
  97.     private String GetPageContent(String url) throws UnexpectedException, Exception  {
  98.  
  99.         URL obj = new URL(url);
  100.         conn = (HttpsURLConnection) obj.openConnection();
  101.  
  102.         conn.setRequestMethod("GET");
  103.  
  104.         conn.setUseCaches(false);
  105.  
  106.         // act like a browser
  107.         conn.setRequestProperty("User-Agent", USER_AGENT);
  108.         conn.setRequestProperty("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  109.         conn.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  110.         if (cookies != null) {
  111.             for (String cookie : this.cookies) {
  112.                 conn.addRequestProperty("Cookie", cookie.split(" ", 1)[0]);
  113.             }
  114.         }
  115.         int responseCode = conn.getResponseCode();
  116.         String msg = conn.getResponseMessage();
  117.         System.out.println("\nSending 'GET' request to URL : " + url);
  118.         System.out.println("Response Code : " + responseCode);
  119.         System.out.println(msg);
  120.  
  121.         BufferedReader in =
  122.                 new BufferedReader(new InputStreamReader(conn.getInputStream()));
  123.         String inputLine;
  124.         StringBuffer response = new StringBuffer();
  125.  
  126.  
  127.         while ((inputLine = in.readLine()) != null) {
  128.             response.append(inputLine);
  129.         }
  130.  
  131.         in.close();
  132.  
  133.         // Get the response cookies
  134.  
  135.         setCookies(conn.getHeaderFields().get("Set-Cookie"));
  136.  
  137.         return response.toString();
  138.  
  139.     }
  140.  
  141.     public String getFormParams(String html, String username, String password)
  142.             throws UnsupportedEncodingException {
  143.  
  144.         System.out.println("Extracting form's data...");
  145.  
  146.         Document doc = Jsoup.parse(html);
  147.  
  148.         // Google form id
  149.         Element loginform = doc.getElementById("pagecontainer");
  150.         Elements inputElements = loginform.getElementsByTag("input");
  151.         int count = 0;
  152.         List<String> paramList = new ArrayList<String>();
  153.         for (Element inputElement : inputElements) {
  154.             String key = inputElement.attr("name");
  155.             String value = inputElement.attr("value");
  156.  
  157.             if(key.equals("emailAddress"))
  158.                 break;
  159.             if (key.equals("inputEmailHandle"))
  160.                 value = username;
  161.             else if (key.equals("inputPassword"))
  162.                 value = password;
  163.  
  164.             paramList.add(key + "=" + URLEncoder.encode(value, "UTF-8"));
  165.         }
  166.  
  167.  
  168.         // build parameters list
  169.         StringBuilder result = new StringBuilder();
  170.  
  171.         for (String param : paramList) {
  172.  
  173.             if (result.length() == 0) {
  174.                 result.append(param);
  175.             } else {
  176.                 result.append("&" + param);
  177.             }
  178.         }
  179.         return result.toString();
  180.     }
  181.     public List<String> getCookies() {
  182.         return cookies;
  183.     }
  184.     public void setCookies(List<String> cookies) {
  185.         this.cookies = cookies;
  186.     }
  187. }
]]>