PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   Mod Submissions (http://www.phpdig.net/forum/forumdisplay.php?f=24)
-   -   Mod Proxy (Version française) (http://www.phpdig.net/forum/showthread.php?t=70)

Iltud 09-13-2003 02:05 PM

Mod Proxy (Version française)
 
Ce mod permet Ã* phpDig d'indexer des sites Ã* travers un proxy.

MAIS, il y a quelques contraintes fortes : [list=1][*] la base de données doit être en local[*] les fonctions FTP de phpDig ne sont pas supportées[*] la fonctionnalité "proxy" fonctionne en mode exclusif : soit on l'utilise, soit pas. La détection de site locaux ne se fait pas automatiquement.[*] peut-être que phpDig ne gère plus les coockies et l'authentification sur les sites distants (Ã* vérifier ?)[/list=1]

Les numéros de lignes donnés ici sont approximatifs et se basent sur la version 1.6.2 de phpDig.

Dans le fichier /includes/config.php : [list=2][*]Ajoutez ces 3 lignes (n'importe où) :

PHP Code:

define('PHPDIG_USE_PROXY',false); // Use proxy-mode ? true or false
define('PHPDIG_PROXY_URL','my.proxy.net'); // Proxy url
define('PHPDIG_PROXY_PORT',3128); // Proxy port 

[/list=2]

Dans le fichier /admin/robot_functions.php :
[list=3][*]Remplacez la ligne 264 :

PHP Code:

$fp = @fsockopen($host,$port); 

Par ce bloc :

PHP Code:

if(PHPDIG_USE_PROXY==true && PHPDIG_PROXY_URL!="")
{
  
$fp = @fsockopen(PHPDIG_PROXY_URL,PHPDIG_PROXY_PORT);  
} else {
  
$fp = @fsockopen($host,$port);  


[*]Aux lignes 285-287, remplacez :

PHP Code:

$request =
  
"HEAD $path HTTP/1.1\\n"
  
."Host: $host$sport\\n" 

Par :

PHP Code:

$request =
  
"HEAD ".(PHPDIG_USE_PROXY==true?$url:$path)." HTTP/1.0\\r\\n"
  
.(PHPDIG_USE_PROXY==true?"":"Host: $host$sport\\r\\n"

[*]Aux lignes 352-353, remplacez :
PHP Code:

$req1 "HEAD $path HTTP/1.1\\n"
        
."Host: $host$sport\\n" 

Par :

PHP Code:

$req1 "HEAD ".(PHPDIG_USE_PROXY==true?$newpath:$path)." HTTP/1.0\\r\\n"
        
.(PHPDIG_USE_PROXY==true?"":"Host: $host$sport\\r\\n"

[*]Effacez la ligne 630 :

PHP Code:

$file_content = @file($uri); 

[*]Aux lignes 638-641, remplacez :

PHP Code:

if (is_array($file_content)) {
   
fwrite($f_handler,implode('',$file_content));
}
fclose($f_handler); 

Par ce bloc :

PHP Code:

if(PHPDIG_USE_PROXY==true && PHPDIG_PROXY_URL!="")
{
  
$request "GET $uri HTTP/1.0\\r\\n"
            
."Accept: */*\\r\\n"
            
."Accept-Charset: iso-8859-1\\r\\n"
            
."Accept-Encoding: identity\\r\\n"
            
."User-Agent: PhpDig/".PHPDIG_VERSION." (PHP; MySql)\\r\\n\\r\\n";
  
$fp fsockopen(PHPDIG_PROXY_URL,PHPDIG_PROXY_PORT);
  if (
$fp) {
    
fputs($fp,$request);
  
    
$c "\\0";
    while (!
feof($fp) && $c != "\\r\\n")
      
$c fgets($fp512); // 512 can be changed
  
    
while (!feof($fp))
    {
      
$answer fgets($fp,255);  // 255 can be changed
      
$answer str_replace("\\r\\n","\\n",$answer);
      
fwrite($f_handler,$answer);
    } 
    
fclose($fp);
    
fclose($f_handler);
  }
}
else
{
  
$file_content = @file($uri);
  if (
is_array($file_content)) {
     
fwrite($f_handler,implode('',$file_content));
  }
  
fclose($f_handler);


[/list=3]

C'est tout. J'espère ne rien avoir oublié.
Tous commentaires et corrections/améliorations sont les bienvenus.

Iltud 09-20-2003 11:53 AM

Corrections des retours chariot dans les requêtes HTTP/1.0

( \n --> \r\n )


All times are GMT -8. The time now is 08:47 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.