note 62597 added to features.http-auth

From: Date: Sat, 04 Mar 2006 12:04:46 +0000
Subject: note 62597 added to features.http-auth
Groups: php.notes 
Request: Send a blank email to php-notes+get-104824@lists.php.net to get a copy of this message
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!"; } ?> ---- Server IP: 130.206.1.5 Probable Submitter: 83.180.151.96 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/features.http-auth.php Edit -- http://master.php.net/note/edit/62597 Del: integrated -- http://master.php.net/note/delete/62597/integrated Del: useless -- http://master.php.net/note/delete/62597/useless Del: bad code -- http://master.php.net/note/delete/62597/bad+code Del: spam -- http://master.php.net/note/delete/62597/spam Del: non-english -- http://master.php.net/note/delete/62597/non-english Del: in docs -- http://master.php.net/note/delete/62597/in+docs Del: other reasons-- http://master.php.net/note/delete/62597 Reject -- http://master.php.net/note/reject/62597 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104824) next »