The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. December 05, 2008, 10:57:35 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Nattsurfarens Curl testing form  (Read 173 times)
nattsurfaren
Journeyman
***
Offline Offline

Posts: 52


View Profile
« on: July 22, 2008, 10:58:48 AM »

This is my php curl testing form. If you see something important that I'm missing then Please let me know.

Code:
<?php

$agent 
$_POST['agent'];
$linkget $_POST['linkget'];
$linkpost $_POST['linkpost'];
$headers $_POST['headers'];
$postdata $_POST['postdata'];

if (empty(
$agent))
{
    
$agent 'Mozilla/5.0 (Windows; U; Windows NT 5.1; sv-SE; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16';
}

$arrpost = array();

$arrheaders = array();
$lines explode(chr(10), $headers);
foreach (
$lines as $line)
{
    
$arrheaders[] = str_replace(chr(13), ""$line);
}
?>

 <form action="CheckLink.php" method="post">

 your get url: <input type="text" name="linkget" value="<?php echo $linkget?>" size="100">
 <input type="submit" name="subm" value="Get">
<br>
 your post url: <input type="text" name="linkpost" value="<?php echo $linkpost?>" size="100">
 <input type="submit" name="subm" value="Post">
<br>
 Your agent: <input type="text" name="agent" value="<?php echo $agent?>" size="100">
 <br>
 headers: <textarea rows="10" wrap="off" style="width: 500px;" name="headers"><?php echo $headers?></textarea>
 postdata: <textarea rows="10"  wrap="off"  style="width: 500px;" name="postdata"><?php echo $postdata?></textarea>
<br>
</form>
<hr>

<?php
if (function_exists("curl_init"))
{

    if (
$_POST['subm'] == 'Post')
    {
        
$ch curl_init($linkpost);
        
$docurl true;
    }
    if (
$_POST['subm'] == 'Get')
    {
        
$ch curl_init($linkget);
        
$docurl true;
    }
    if (
$docurl)
    {
        
//curl_setopt($ch, CURLOPT_PROXY, "http://127.0.0.1");//Use this if you use fiddler http debugging proxy locally
        //curl_setopt($ch, CURLOPT_PROXYPORT, 8888);//Use this if you use fiddler http debugging proxy locally
        
curl_setopt($chCURLOPT_USERAGENT$agent);
        
curl_setopt($chCURLOPT_CONNECTTIMEOUT2);
        
curl_setopt($chCURLOPT_TIMEOUT4);
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
curl_setopt($chCURLOPT_COOKIEFILE'cookie.txt');
        
curl_setopt($chCURLOPT_COOKIEJAR'cookie.txt');

        if (
$_POST['subm'] == 'Post')
        {
            if (!empty(
$postdata))
            {
                
curl_setopt($chCURLOPT_POSTtrue);
                
curl_setopt($chCURLOPT_POSTFIELDS$postdata);
            }
        }
        else
        {
            
curl_setopt($chCURLOPT_POSTfalse);
        }
        if (
count($arrheaders) > && $arrheaders[0] != null)
        {
            
curl_setopt($chCURLOPT_HTTPHEADER$arrheaders);
        }

        
$data curl_exec($ch);
        echo 
$data;
        echo 
"<hr>";
    }
}

?>




« Last Edit: July 22, 2008, 11:02:29 AM by nattsurfaren » Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!