Archive for November, 2008

Output buffering PHP Apache mod gzip mod deflate

Till recently most of my php scripts were working fine on the servers with instantaneous outputs as and when a echo statement came. One issue that popped a lot on localhost was that of chunky outputs; that is the outputs of big scripts came out in chunks rather than smoothly with every echo or print [...]

Remote Login with Curl PHP

The Curl Library of PHP can be used to open remote web pages and also logging in where a login is required.
Code

$login_url = ‘http://www.somesite.com/login.php’;
#These are the post data username and password
$post_data = ‘username=someusername&password=somepassword’;
#Create a curl object
$ch = curl_init();
#Set the useragent
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
#Set the URL
curl_setopt($ch, CURLOPT_URL, $login_url );
#This is a POST query
curl_setopt($ch, CURLOPT_POST, 1 [...]