note 62597 deleted from features.http-auth by cmb

From: Date: Sun, 13 Oct 2019 08:18:55 +0000
Subject: note 62597 deleted from features.http-auth by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212641@lists.php.net to get a copy of this message
Note Submitter: ZyX ---- Simple PHP Script to login on a Basic Authentication page. <?php /* Access Configuration */ define ('x401_host', 'www.example.com'); define ('x401_port', 80); define ('x401_user', 'your_username'); define ('x401_pass', 'your_password'); /* Function */ function get401Page($file) { $out = "GET $file HTTP/1.1\r\n"; $out .= "Host: ".x401_host."t\r\n"; $out .= "Connection: Close\r\n"; $out .= "Authorization: Basic ".base64_encode(x401_user.":".x401_pass)."\r\n"; $out .= "\r\n"; if (!$conex = @fsockopen(x401_host, x401_port, $errno, $errstr, 10)) return 0; fwrite($conex, $out); $data = ''; while (!feof($conex)) { $data .= fgets($conex, 512); } fclose($conex); return $data; } /* Code */ if ($source = get401Page('/absolute/path/file.php?get=value')) { echo $source; } else { echo "I can't connect!"; } ?>

« previous php.notes (#212641) next »