Forum Moderators: coopster
<?php
// This is the custom header that needs to be sent to post to your blog.
// Use curl to post to your blog.
$ch = curl_init();
$header[] = "Server: Apache-Coyote/1.1";
$header[] = "Pragma: No-cache"; // browsers keep this blank.
$header[] = "Cache-Control: no-cache";
$header[] = "Expires: Wed, 31 Dec 1969 18:00:00 CST";
$header[] = "Content-Type: text/xml";
$header[] = "Transfer-Encoding: chunked";
curl_setopt($ch, CURLOPT_URL, "http://Ipaddress/login.htm");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('j_usertzoffset=-0400&j_username=user&j_password=encpass&button=Login'));
curl_setopt ($ch, CURLOPT_COOKIEJAR, "/tmp/cookiejarchandar");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
ob_start();
curl_exec ($ch);
ob_end_clean();
print_r(curl_getinfo($ch));
curl_close($ch);
print "================secondone ====================================================";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookiejarchandar");
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_URL, "http://ipaddress/report_results.htm?id=report1id");
print "=========================thdddff========================\n";
$data3 = curl_exec($ch);
print_r(curl_getinfo($ch));
print "\n";
curl_close($ch);
echo $data3;
print "=========================thirdone===========================================\n";
print "\n";
?>
===============Output===============================================
[root@nmcsrvnwk0902 chandar]# php test.php
Content-type: text/html
X-Powered-By: PHP/4.3.9
Array
(
[url] => [ipaddress...]
[content_type] => text/html
[http_code] => 200
[header_size] => 201
[request_size] => 84
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.004803
[namelookup_time] => 7.6E-05
[connect_time] => 0.001118
[pretransfer_time] => 0.001153
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0.004775
[redirect_time] => 0
)
================secondone ====================================thdddff=====
Array
(
[url] => [ipaddress...]
[content_type] => text/html
[http_code] => 200
[header_size] => 219
[request_size] => 159
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.311563
[namelookup_time] => 2.6E-05
[connect_time] => 0.001108
[pretransfer_time] => 0.001143
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0.311548
[redirect_time] => 0
)
[/Code]
[edited by: jatar_k at 6:05 pm (utc) on June 10, 2009]
[edit reason] sidescroll [/edit]
it looks like it doesn't like it isn't quite logging in and then bouncing you to a login page
if this is correct
curl_setopt($ch, CURLOPT_POSTFIELDS, array('j_usertzoffset=-0400&j_username=user&j_password=encpass&button=Login'));
then you should look at the script it is targetting
Will this code has anything to do with sessions?
Do you want me to post the login page too?