[Tutorial] Curl Login

This is a discussion on [Tutorial] Curl Login within the PHP forums, part of the Program Your Site category; YouTube - Curl Login Tutorial PHP Code: function  curl_login ( $url , $data , $proxy , $proxystatus ){      $fp  ...


Go Back   Scriptasy > Program Your Site > PHP
51 Online Register Projects Products Members List Calendar Today's Posts

Reply

 

LinkBack (19) Thread Tools Display Modes
  18 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 05-30-2007, 09:55 PM
[Administrator]
 
Join Date: May 2007
Posts: 383
[Tutorial] Curl Login

PHP Code:
function curl_login($url,$data,$proxy,$proxystatus){
    
$fp fopen("cookie.txt""w");
    
fclose($fp);
    
$login curl_init();
    
curl_setopt($loginCURLOPT_COOKIEJAR"cookie.txt");
    
curl_setopt($loginCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($loginCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    
curl_setopt($loginCURLOPT_TIMEOUT40);
    
curl_setopt($loginCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'on') {
        
curl_setopt($loginCURLOPT_SSL_VERIFYHOSTFALSE);
        
curl_setopt($loginCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($loginCURLOPT_PROXY$proxy);
    }
    
curl_setopt($loginCURLOPT_URL$url);
    
curl_setopt($loginCURLOPT_HEADERTRUE);
    
curl_setopt($loginCURLOPT_USERAGENT$_SERVER['HTTP_USER_AGENT']);
    
curl_setopt($loginCURLOPT_FOLLOWLOCATIONTRUE);
    
curl_setopt($loginCURLOPT_POSTTRUE);
    
curl_setopt($loginCURLOPT_POSTFIELDS$data);
    
ob_start();      // prevent any output
    
return curl_exec ($login); // execute the curl command
    
ob_end_clean();  // stop preventing output
    
curl_close ($login);
    unset(
$login);    
}                  

function 
curl_grab_page($site,$proxy,$proxystatus){
    
$ch curl_init();
    
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'on') {
        
curl_setopt($chCURLOPT_SSL_VERIFYHOSTFALSE);
        
curl_setopt($chCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($chCURLOPT_PROXY$proxy);
    }
    
curl_setopt($chCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($chCURLOPT_URL$site);
    
ob_start();      // prevent any output
    
return curl_exec ($ch); // execute the curl command
    
ob_end_clean();  // stop preventing output
    
curl_close ($ch);

Hope you liked.
Reply With Quote
  #2 (permalink)  
Old 06-20-2007, 04:58 PM
Junior Member
 
Join Date: Jun 2007
Posts: 4
I lied at youtube :P (Mads18)
It didn't work perfectly after all *emberassed*.

I added this: curl_login('http://www.root.no/forum/index.php?act=Login&CODE=01','referer=http%3A%2F%2Fwww.root.no%2Fforum %2Findex.php%3Fact%3DLogin%26CODE%3D00&UserName=test&PassWord=test&CookieDate=1','','off')

And didn't change anything on this:
function curl_login($url,$data,$proxy,$proxystatus){

And I get this error: Parse error: syntax error, unexpected T_FUNCTION in C:\Programfiler\xampp\htdocs\Hacking\Root.no attack - test.php on line 5


PS: I checked the script in the very start without editing anything, and it was all blank; as if everything was working correctly.
Reply With Quote
  #3 (permalink)  
Old 06-20-2007, 11:52 PM
[Administrator]
 
Join Date: May 2007
Posts: 383
can you show me the full source of your test file and the error.

also we have php tags just do this [php]CODE[/php]
Reply With Quote
  #4 (permalink)  
Old 06-23-2007, 11:46 AM
[Administrator]
 
Join Date: May 2007
Posts: 383
Quote:
Originally Posted by mads16 View Post
I lied at youtube :P (Mads18)
It didn't work perfectly after all *emberassed*.

I added this: curl_login('http://www.root.no/forum/index.php?act=Login&CODE=01','referer=http%3A%2F%2Fwww.root.no%2Fforum %2Findex.php%3Fact%3DLogin%26CODE%3D00&UserName=test&PassWord=test&CookieDate=1','','off')

And didn't change anything on this:
function curl_login($url,$data,$proxy,$proxystatus){

And I get this error: Parse error: syntax error, unexpected T_FUNCTION in C:\Programfiler\xampp\htdocs\Hacking\Root.no attack - test.php on line 5


PS: I checked the script in the very start without editing anything, and it was all blank; as if everything was working correctly.
you forgot to end your line, and you need to use the curl grab page to get the contents of a blocked page after logging in.
PHP Code:
<?
curl_login
('http://www.root.no/forum/index.php?act=Login&CODE=01','UserName=test&PassWord=test&CookieDate=1','','off');
echo 
curl_grab_page('http://www.root.no/forum/index.php','','off');

function 
curl_login($url,$data,$proxy,$proxystatus){
    
$fp fopen("cookie.txt""w");
    
fclose($fp);
    
$login curl_init();
    
curl_setopt($loginCURLOPT_COOKIEJAR"cookie.txt");
    
curl_setopt($loginCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($loginCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    
curl_setopt($loginCURLOPT_TIMEOUT40);
    
curl_setopt($loginCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'on') {
        
curl_setopt($loginCURLOPT_SSL_VERIFYHOSTFALSE);
        
curl_setopt($loginCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($loginCURLOPT_PROXY$proxy);
    }
    
curl_setopt($loginCURLOPT_URL$url);
    
curl_setopt($loginCURLOPT_HEADERTRUE);
    
curl_setopt($loginCURLOPT_USERAGENT$_SERVER['HTTP_USER_AGENT']);
    
curl_setopt($loginCURLOPT_FOLLOWLOCATIONTRUE);
    
curl_setopt($loginCURLOPT_POSTTRUE);
    
curl_setopt($loginCURLOPT_POSTFIELDS$data);
    
ob_start();      // prevent any output
    
return curl_exec ($login); // execute the curl command
    
ob_end_clean();  // stop preventing output
    
curl_close ($login);
    unset(
$login);    
}                   

function 
curl_grab_page($site,$proxy,$proxystatus){
    
$ch curl_init();
    
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'on') {
        
curl_setopt($chCURLOPT_SSL_VERIFYHOSTFALSE);
        
curl_setopt($chCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($chCURLOPT_PROXY$proxy);
    }
    
curl_setopt($chCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($chCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    
curl_setopt($chCURLOPT_URL$site);
    
ob_start();      // prevent any output
    
return curl_exec ($ch); // execute the curl command
    
ob_end_clean();  // stop preventing output
    
curl_close ($ch);

?>
Reply With Quote
  #5 (permalink)  
Old 06-24-2007, 02:08 AM
Junior Member
 
Join Date: Jun 2007
Posts: 4
Ahh, have had much to do lately~
New error now thought:
Fatal error: Call to undefined function curl_init() in C:\Programfiler\xampp\htdocs\Hacking\Root.no attack - test.php on line 8

PS: I knew I didn't do curl_grab_page, but because I knew it wasn't affecting the error, I skipped it until I found out how to fix the error.
Thanks for your help Chad.
Reply With Quote
  #6 (permalink)  
Old 06-24-2007, 09:29 AM
[Administrator]
 
Join Date: May 2007
Posts: 383
thats a simple error, you don't have curl on your server.
Reply With Quote
  #7 (permalink)  
Old 06-24-2007, 06:50 PM
Junior Member
 
Join Date: Jun 2007
Posts: 4
And how do I install it?
I've unzipped it, started the buildconf.bat once, and I still get the same error, and dunno what to do.
Reply With Quote
  #8 (permalink)  
Old 06-24-2007, 09:44 PM
[Administrator]
 
Join Date: May 2007
Posts: 383
i have never installed curl, my server came with it.

cURL and libcurl
Reply With Quote
  #9 (permalink)  
Old 06-25-2007, 03:19 AM
Junior Member
 
Join Date: Jun 2007
Posts: 4
Well, then I'm in trouble. Allready been at that site, and downloaded several versions for testing if I may have downloaded wrong version, but none of them worked. I use the newest version of apache for Windows XP.
Reply With Quote
  #10 (permalink)  
Old 07-05-2007, 02:19 AM
Junior Member
 
Join Date: Jul 2007
Posts: 2
Post

to get thise thing running do i need to uploaded im new to this and i made this
PHP Code:
<?php
curl_login
('http://www.taultunleashed.com/phpBB2/login.php','username=hillwaka&password=061867&autologin=on&redirect=&login=Log+in','','off');
echo 
curl_grab_page('http://www.taultunleashed.com/phpBB2/about27946_EVE_Guide_The_mercenary_in_you_Ship_fitting_guide_.html','','off');





 function 
curl_login($url,$data,$proxy,$proxystatus){
    
$fp fopen("cookie.txt""w");
    
fclose($fp);
    
$login curl_init();
    
curl_setopt($loginCURLOPT_COOKIEJAR"cookie.txt");
    
curl_setopt($loginCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($loginCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    
curl_setopt($loginCURLOPT_TIMEOUT40);
    
curl_setopt($loginCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'on') {
        
curl_setopt($loginCURLOPT_SSL_VERIFYHOSTFALSE);
        
curl_setopt($loginCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($loginCURLOPT_PROXY$proxy);
    }
    
curl_setopt($loginCURLOPT_URL$url);
    
curl_setopt($loginCURLOPT_HEADERTRUE);
    
curl_setopt($loginCURLOPT_USERAGENT$_SERVER['HTTP_USER_AGENT']);
    
curl_setopt($loginCURLOPT_FOLLOWLOCATIONTRUE);
    
curl_setopt($loginCURLOPT_POSTTRUE);
    
curl_setopt($loginCURLOPT_POSTFIELDS$data);
    
ob_start();      // prevent any output
    
return curl_exec ($login); // execute the curl command
    
ob_end_clean();  // stop preventing output
    
curl_close ($login);
    unset(
$login);    
}                  

function 
curl_grab_page($site,$proxy,$proxystatus){
    
$ch curl_init();
    
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'on') {
        
curl_setopt($chCURLOPT_SSL_VERIFYHOSTFALSE);
        
curl_setopt($chCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($chCURLOPT_PROXY$proxy);
    }
    
curl_setopt($chCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($chCURLOPT_URL$site);
    
ob_start();      // prevent any output
    
return curl_exec ($ch); // execute the curl command
    
ob_end_clean();  // stop preventing output
    
curl_close ($ch);

?>
How do i make it run or work? does it have to be on a uploaded somewhere or something? thanks for the help if u can im a newb
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://scriptasy.com/request-site-changes_11/tutorial-curl-login_44.html

Posted By For Type Date
Can a website block the use of file_get_contents ? - PHWinfo This thread Refback 08-22-2008 01:13 AM
Can a website block the use of file_get_contents ? - comp.lang.php | Google Groups This thread Refback 04-26-2008 11:12 AM
Can a website block the use of file_get_contents ? - comp.lang.php | Google Groupes This thread Refback 04-23-2008 04:43 AM
Live website statistieken - Ulco.nl This thread Pingback 03-31-2008 11:37 AM
Can a website block the use of file_get_contents ? - comp.lang.php | Google Groups This thread Refback 03-31-2008 08:03 AM
Can a website block the use of file_get_contents ? - comp.lang.php | Google Groups This thread Refback 03-29-2008 03:21 AM
Can a website block the use of file_get_contents ? - Object Mix This thread Refback 03-29-2008 03:10 AM
Can a website block the use of file_get_contents ? - Usenet Forums This thread Refback 03-28-2008 10:45 AM
Web Link This thread Refback 09-05-2007 07:15 PM
amob005's bookmarks tagged with "php_curl_video_tutorial" on del.icio.us This thread Refback 08-12-2007 12:41 AM
digg / blizzedout / news / dugg This thread Refback 06-17-2007 02:14 AM
digg / beasttoast / news / submitted This thread Refback 06-02-2007 02:02 PM
YouTube - Curl Login Tutorial This thread Refback 05-31-2007 04:37 PM
Digg / Programming / Upcoming This thread Refback 05-31-2007 01:36 PM
Digg / Programming / Upcoming This thread Refback 05-31-2007 09:16 AM
Digg / News / Upcoming This thread Refback 05-30-2007 10:08 PM
Digg / News / Upcoming This thread Refback 05-30-2007 10:05 PM
Digg / News / Upcoming This thread Refback 05-30-2007 10:00 PM
Digg - [Tutorial] PHP Curl Login This thread Refback 05-30-2007 10:00 PM


All times are GMT -8. The time now is 11:38 AM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48