Skip to content

Commit

Permalink
fix SSL redirect by Google
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre committed Sep 5, 2013
1 parent 312d60b commit 3e071c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Serposcope changelog

## UPCOMING
## 1.0.5 - 05/09/2013

* fix SSL redirection introduced by Google in september
* fix export image highcharts
* fix import bug with format SERPOSCOPE_CSV
* run cron for a specific group `/usr/bin/php cron.php _ID_GROUP_
Expand Down
3 changes: 2 additions & 1 deletion inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ function buildCurlOptions($proxy){
CURLOPT_HTTPHEADER => array(
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"
)
),
CURLOPT_SSL_VERIFYPEER => false
);

if(is_array($proxy)){
Expand Down
16 changes: 10 additions & 6 deletions modules/Google/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ public function check($group) {
do{

if($start_index==0){
$url="http://$domain/search?q=".urlencode($keyword);
$referrer= "http://$domain/";
$url="https://$domain/search?q=".urlencode($keyword);
$referrer= "https://$domain/";
}else{
$referrer=$url;
$url="http://$domain/search?q=".urlencode($keyword)."&start=".($start_index);
$url="https://$domain/search?q=".urlencode($keyword)."&start=".($start_index);
}

if(!empty($group['options']['parameters'])){
Expand All @@ -184,11 +184,14 @@ public function check($group) {
case 302:{

$redir = $curlout['redir'];
if(strncmp($redir, "http://www.google.com/sorry/?continue=", 38) !== 0){
$this->w("Invalid redir ");
if(
strncmp($redir, "http://www.google.com/sorry/?continue=", 38) !== 0 &&
strncmp($redir, "https://www.google.com/sorry/?continue=", 38) !== 0
){
$this->w("Invalid redir");
$error = true;
}else{
$redir = str_replace("http://www.google.com/sorry/?continue=", "http://".$domain."/sorry/?continue=", $redir);
$redir = str_replace("://www.google.com/sorry/?continue=", "://".$domain."/sorry/?continue=", $redir);

$opts = array(
CURLOPT_URL => $redir,
Expand Down Expand Up @@ -448,6 +451,7 @@ private function handleCaptcha($html, $proxy, $dc, $origUrl){

if($data['status'] != 200 ){
$this->w("Bad redirection after captcha solving");
print_r($data);
return null;
}else if(empty($data['data'])){
$this->w("Bad content after captcha solving");
Expand Down

0 comments on commit 3e071c9

Please sign in to comment.