-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated version of submission + layer
- Loading branch information
Showing
50 changed files
with
17,176 additions
and
1,040 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/* GET THE CONTENT OF THE WEB PAGE */ | ||
$url = $_GET['url']; | ||
|
||
// Cookie Jar | ||
$ckfile = tempnam ("/tmp", "CURLCOOKIE"); | ||
|
||
// Clean the URL | ||
$url = isset($_GET['url'])?$_GET['url']:""; | ||
$url = substr($url,0,7) == "http://"?$url:"http://".$url; | ||
$url = getFinalUrl($url); | ||
|
||
// CURL | ||
$ch = curl_init(); | ||
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" ); | ||
curl_setopt($ch,CURLOPT_URL,$url); | ||
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile); | ||
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8'); | ||
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); | ||
$html = curl_exec($ch); | ||
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); | ||
$data = 'data:'.$content_type.';base64,'.base64_encode($html); | ||
curl_close($ch); | ||
|
||
|
||
/* EXTRACT THE TEXT */ | ||
$Readability = new Readability($html); // default charset is utf-8 | ||
$readabilityData = $Readability->getContent(); // throws an exception when no suitable content is found | ||
|
||
$collectionJSON = '{ | ||
"html": '.DBConn::clean($readabilityData['content']).' | ||
}'; | ||
|
||
$callback = $_REQUEST['callback']; | ||
if($callback) | ||
echo($callback.'('.$collectionJSON.');'); | ||
else | ||
echo($collectionJSON); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
function getFinalUrl( $url, $timeout = 5 ) { | ||
$url = str_replace( "&", "&", urldecode(trim($url)) ); | ||
|
||
$cookie = tempnam ("/tmp", "CURLCOOKIE"); | ||
$ch = curl_init(); | ||
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" ); | ||
curl_setopt( $ch, CURLOPT_URL, $url ); | ||
curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie ); | ||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); | ||
curl_setopt( $ch, CURLOPT_ENCODING, "" ); | ||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); | ||
curl_setopt( $ch, CURLOPT_AUTOREFERER, true ); | ||
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout ); | ||
curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout ); | ||
curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 ); | ||
$content = curl_exec( $ch ); | ||
$response = curl_getinfo( $ch ); | ||
curl_close ( $ch ); | ||
|
||
if ($response['http_code'] == 301 || $response['http_code'] == 302) | ||
{ | ||
ini_set("user_agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1"); | ||
$headers = get_headers($response['url']); | ||
|
||
$location = ""; | ||
foreach( $headers as $value ) | ||
{ | ||
if ( substr( strtolower($value), 0, 9 ) == "location:" ) | ||
return get_final_url( trim( substr( $value, 9, strlen($value) ) ) ); | ||
} | ||
} | ||
|
||
if ( preg_match("/window\.location\.replace\('(.*)'\)/i", $content, $value) || | ||
preg_match("/window\.location\=\"(.*)\"/i", $content, $value) | ||
) | ||
{ | ||
return get_final_url ( $value[1] ); | ||
} | ||
else | ||
{ | ||
return $response['url']; | ||
} | ||
} | ||
?> |
Oops, something went wrong.