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: 693
Function: getPaste
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once
public class AutomaticLogin { private List<String> cookies; private HttpsURLConnection conn; private final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"; public static void main(String[] args) throws Exception { String url = "https://accounts.craigslist.org/login"; String gmail = "https://accounts.craigslist.org/login/home?show_tab=postings"; String page = http.GetPageContent(url); String postParams = http.getFormParams(page, "username", "password"); String anotherString = null; anotherString = postParams.substring(0, 93); System.out.println(postParams); System.out.println(); http.sendPost(url, postParams); String result = http.GetPageContent(gmail); System.out.println(result); } private void sendPost(String url, String postParams) throws Exception { conn = (HttpsURLConnection) obj.openConnection(); conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty("Host", "craigslist.org"); conn.setRequestProperty("User-Agent", USER_AGENT); conn.setRequestProperty("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); conn.setRequestProperty("Accept-Language", "en-US,en;q=0.5"); conn.setAllowUserInteraction(true); conn.setRequestProperty("Connection", "keep-alive"); conn.setRequestProperty("Referer", "https://accounts.craigslist.org/login/home"); conn.setRequestProperty("Content-Type", "x-www-form-urlencoded"); conn.setFixedLengthStreamingMode(postParams.getBytes().length); conn.setInstanceFollowRedirects(false); conn.setDoOutput(true); conn.setDoInput(true); if (cookies != null) { for (String cookie : this.cookies) { conn.addRequestProperty("Cookie", cookie.split(" ", 2)[0]); } } wr.writeBytes(postParams); wr.flush(); wr.close(); int responseCode = conn.getResponseCode(); String msg = conn.getResponseMessage(); System.out.println("\nSending 'POST' request to URL : " + url); System.out.println("Post parameters : " + postParams); System.out.println("Response Code : " + responseCode); System.out.println(msg); BufferedReader in = String inputLine; while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); } private String GetPageContent(String url) throws UnexpectedException, Exception { conn = (HttpsURLConnection) obj.openConnection(); conn.setRequestMethod("GET"); conn.setUseCaches(false); // act like a browser conn.setRequestProperty("User-Agent", USER_AGENT); conn.setRequestProperty("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); conn.setRequestProperty("Accept-Language", "en-US,en;q=0.5"); if (cookies != null) { for (String cookie : this.cookies) { conn.addRequestProperty("Cookie", cookie.split(" ", 1)[0]); } } int responseCode = conn.getResponseCode(); String msg = conn.getResponseMessage(); System.out.println("\nSending 'GET' request to URL : " + url); System.out.println("Response Code : " + responseCode); System.out.println(msg); BufferedReader in = String inputLine; while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); // Get the response cookies setCookies(conn.getHeaderFields().get("Set-Cookie")); return response.toString(); } public String getFormParams(String html, String username, String password) throws UnsupportedEncodingException { System.out.println("Extracting form's data..."); Document doc = Jsoup.parse(html); // Google form id Element loginform = doc.getElementById("pagecontainer"); Elements inputElements = loginform.getElementsByTag("input"); int count = 0; for (Element inputElement : inputElements) { String key = inputElement.attr("name"); String value = inputElement.attr("value"); if(key.equals("emailAddress")) break; if (key.equals("inputEmailHandle")) value = username; else if (key.equals("inputPassword")) value = password; paramList.add(key + "=" + URLEncoder.encode(value, "UTF-8")); } // build parameters list for (String param : paramList) { if (result.length() == 0) { result.append(param); } else { result.append("&" + param); } } return result.toString(); } public List<String> getCookies() { return cookies; } public void setCookies(List<String> cookies) { this.cookies = cookies; } }