Ho letto la pillola di daniele_dll sui socket perchè devono rendere disponibile alcune pagine del televideo sul sito della mia intranet aziendale.

Il problema è che la richiesta deve passare attraverso un proxy server (che fa passare unicamente gli utenti autenticati ed autorizzati ad accedere ad internet) e per questo la pagina continua a caricarsi senza dare alcun output.

Mi hanno dato questo codice per passare il proxy ma non va:

Codice PHP:
function getthroughproxy($myfiles$proxyhost="nomeserver"$proxyport=8080){

            
$errno="";
            
$errstr="";
            
$datei = @fsockopen($proxyhost$proxyport$errno$errstr,300); 
            if( !
$datei ) {
                
// fclose($resultfile); 
                
return array('headers'=>false,
                             
'content'=>false,
                             
'errno'=>$errno,
                             
'errstr'=>$errstr,
                             
'online'=>false);
                
// ^^^ proxy not available
                // You'll probably want to change this with return false;
                // to use in an 
                // if($file=getthroughproxy){} manner.
                // Well, it's up to You
            
} else { 
                
fputs($datei,"GET $myfiles HTTP/1.0\n\n"); 
                while (!
feof($datei)) {
                    
$zeile =$zeile.fread($datei,4096);
                }
            }
            
fclose($datei);
            
            
$online=true;
            
$net=substr($zeile,0,12);
            if (
$net!="HTTP/1.0 200") {
                
$online=false;
            } else {
                if(
substr($zeile,strpos($zeile,"\r\n\r\n")+4)==false) {
                    
$online=false;
                }
            }
            
            return array(    
'headers'=>substr($zeile,0,strpos($zeile,"\r\n\r\n")),
                            
'content'=>substr($zeile,strpos($zeile,"\r\n\r\n")+4),
                            
'errno'=>$errno,
                            
'errstr'=>$errstr,
                            
'online'=>$online);
        }