This is my php curl testing form. If you see something important that I'm missing then Please let me know.
<?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($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
if ($_POST['subm'] == 'Post')
{
if (!empty($postdata))
{
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
}
}
else
{
curl_setopt($ch, CURLOPT_POST, false);
}
if (count($arrheaders) > 0 && $arrheaders[0] != null)
{
curl_setopt($ch, CURLOPT_HTTPHEADER, $arrheaders);
}
$data = curl_exec($ch);
echo $data;
echo "<hr>";
}
}
?>