为什么 cURL 会进入无限循环?
我在发布 URL 表单时遇到问题。当我运行 cURL 时,看起来它进入了无限循环;它根本没有停止。当我执行简单的表单时,例如:
<form action="#" method="post">
Name: <input type="text" name="na" />
<input type="submit" value="Send" />
</form>
但是当我尝试在 PHPBB3 论坛脚本上提交帖子时,其中有一些类似的表单,脚本不会停止。
即使有 2 个表单并且我只想提交其中之一,我是否必须确定每个输入的变量?
cURL 代码:
<form action="zd.php" method="post">
Link: <input type="text" name="linko" /><br />
<input type="submit" value="Salji" />
<input type="hidden" name="sad" value="sad" />
</form>
<?php
if (isset($_POST['sad'])) {
$imos = trim($_POST['linko']);
$koja = curl_init("http://link/index.php");
$kooky = "PHPSESSID=9opvpblp3govbrfg27t0a8jki6";
$po = array(
'link'=>$imos,
'referer'=>' ',
'submit'=>'Transload File');
curl_setopt($koja, CURLOPT_COOKIE, $kooky);
curl_setopt($koja, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($koja, CURLOPT_POST, 1);
curl_setopt($koja, CULROPT_POSTFIELDS, $po);
curl_exec($koja);
echo "<br />ERROR: ".curl_error($koja);
}
?>
我要发布到的页面(完整表单):
<form action="/index.php" name="transload" method="post">
<table class="tab-content" id="tb1" cellspacing="5" width="100%">
<tbody>
<tr>
<td align="left">
<b>Link to Transload:</b><br /> <input type="text" name="link" id="link" size="50" /><br /><br />
<b>Referrer:</b><br /> <input type="text" name="referer" id="referer" size="50" />
</td>
<td align="center">
<input value="Transload File" type="submit" />
</td>
</tr>
<tr>
<td align="left"><input type="checkbox" name="user_pass" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('usernpass').style.display=displ;" value="on" /> User & Pass (HTTP/FTP)</td>
</tr>
<tr id="usernpass" style="display: none;">
<td align="center">
User: <input type="text" name="iuser" value="" /><br />
Pass: <input type="text" name="ipass" value="" />
</td>
</tr>
<tr>
<td align="left"><input type="checkbox" name="add_comment" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('comment').style.display=displ;" /> Add Comments</td>
</tr>
<tr id="comment" style="display: none;">
<td>
<textarea name="comment" rows="4" cols="50"></textarea>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="left">
<small style="color:#55bbff">PluginOptions:</small><hr />
<label><input type="checkbox" name="dis_plug" /> <small>Disable All Plugins</small></label>
</td>
</tr>
<tr>
<td align="left">
<label><input type="checkbox" name="ytube_mp4" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('ytubeopt').style.display=displ;" /> <small>YouTube Video Format Selector</small></label>
<table width="150" border="0" id="ytubeopt" style="display: none;">
<tr>
<td colspan="2" style="white-space: nowrap;"><input type="checkbox" name="ytdirect" /><small> Direct Link</small></td>
</tr>
<tr>
<td align="left"><small>&fmt=</small></td>
<td align="left">
<select name="yt_fmt" id="yt_fmt">
<option value="highest" selected="selected">Auto-get the highest quality format available</option>
<option value="0">0 [Video: FLV H263 251kbps 320x180 @ 29.896fps | Audio: MP3 64kbps 1ch @ 22.05kHz]</option>
<option value="5">5 [Video: FLV H263 251kbps 320x180 @ 29.885fps | Audio: MP3 64kbps 1ch @ 22.05kHz]</option>
<option value="6">6 [Video: FLV H263 892kbps 480x270 @ 29.887fps | Audio: MP3 96kbps 1ch @ 44.10kHz]</option>
<option value="13">13 [Video: 3GP H263 77kbps 176x144 @ 15.000fps | Audio: AMR 13kbps 1ch @ 8.000kHz]</option>
<option value="17">17 [Video: 3GP XVID 55kbps 176x144 @ 12.000fps | Audio: AAC 29kbps 1ch @ 22.05kHz]</option>
<option value="18">18 [Video: MP4 H264 505kbps 480x270 @ 29.886fps | Audio: AAC 125kbps 2ch @ 44.10kHz]</option>
<option value="22">22 [Video: MP4 H264 2001kbps 1280x720 @ 29.918fps | Audio: AAC 198kbps 2ch @ 44.10kHz]</option>
<option value="34">34 [Video: FLV H264 256kbps 320x180 @ 29.906fps | Audio: AAC 62kbps 2ch @ 22.05kHz]</option>
<option value="35">35 [Video: FLV H264 831kbps 640x360 @ 29.942fps | Audio: AAC 107kbps 2ch @ 44.10kHz]</option>
<option value="37">37 [Video: MP4 1920×1080 | Audio: AAC 2ch 44.10kHz]</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left"><label><input type="checkbox" name="imageshack_tor" id="imageshack_tor" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('torpremiumblock').style.display=displ;" /> <small>ImageShack® TorrentService</small></label><table width="150" border="0" id="torpremiumblock" style="display: none;">
<tr><td>Username: </td><td><input type="text" name="tor_user" id="tor_user" size="15" value="" /></td></tr>
<tr><td>Password: </td><td><input type="password" name="tor_pass" id="tor_pass" size="15" value="" /></td></tr>
</table>
</td>
</tr>
<tr>
<td align="left">
<label><input type="checkbox" name="mu_acc" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('mupremiumblock').style.display=displ;" /> <small>Megaupload.com Cookie Value</small></label>
<table width="150" border="0" id="mupremiumblock" style="display: none;">
<tr><td>user=</td><td><input type="text" name="mu_cookie" id="mu_cookie" size="25" value="" /></td></tr>
</table>
</td>
</tr>
<tr>
<td align="left">
<label><input type="checkbox" name="vBulletin_plug" /> <small>Use vBulletin Plugin</small></label>
</td>
</tr>
<tr>
<td align="left">
<label><input type="checkbox" name="cookieuse" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('cookieblock').style.display=displ;" /> <small>Additional Cookie Value</small></label>
<table width="150" border="0" id="cookieblock" style="display: none;">
<tr><td>Key=Value;</td><td><input type="text" name="cookie" id="cookie" size="25" value="" /></td></tr>
</table>
</td>
</tr>
</tbody>
</table>
<table class="hide-table" id="tb2" cellspacing="5" width="100%">
<tbody>
<tr>
<td align="center">
<table align="center" style="text-align: justify;">
<tr>
<td><input type="checkbox" name="domail" id="domail" onclick="document.getElementById('emailtd').style.display=document.getElementById('splittd').style.display=this.checked?'':'none';document.getElementById('methodtd').style.display=(document.getElementById('splitchkbox').checked ? (this.checked ? '' : 'none') : 'none');" /> Send File to Email</td>
<td> </td>
<td id="emailtd" style="display: none;">Email: <input type="text" name="email" id="email" /></td>
</tr>
<tr>
<td></td>
</tr>
<tr id="splittd" style="display: none;">
<td>
<input id="splitchkbox" type="checkbox" name="split" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('methodtd').style.display=displ;" /> Split Files</td>
<td> </td>
<td id="methodtd" style="display: none;">
<table>
<tr>
<td>Method: <select name="method"><option value="tc">Total Commander</option><option value="rfc">RFC 2046</option></select></td>
</tr>
<tr>
<td>Parts Size: <input type="text" name="partSize" size="2" value="10" /> MB</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><input type="checkbox" id="useproxy" name="useproxy" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('proxy').style.display=displ;" /> Use Proxy Settings</td>
<td> </td>
<td id="proxy" style="display: none;">
<table width="150" border="0">
<tr><td>Proxy: </td><td><input type="text" name="proxy" id="proxyproxy" size="20" /></td></tr>
<tr><td>Username: </td><td><input type="text" name="proxyuser" id="proxyuser" size="20" /></td></tr>
<tr><td>Password: </td><td><input type="text" name="proxypass" id="proxypass" size="20" /></td></tr>
</table>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><input type="checkbox" name="premium_acc" id="premium_acc" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('premiumblock').style.display=displ;" checked="checked" /> Use Premium Account</td>
<td> </td>
<td id="premiumblock" style="display: none;">
<table width="150" border="0">
<tr><td>Username: </td><td><input type="text" name="premium_user" id="premium_user" size="15" value="" /></td></tr>
<tr><td>Password: </td><td><input type="password" name="premium_pass" id="premium_pass" size="15" value="" /></td></tr>
</table>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr style="display:none;">
<td><input type="checkbox" name="saveto" id="saveto" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('path').style.display=displ;" /> Save To</td>
<td> </td>
<td id="path" style="display: none;">Path: <input type="text" name="path" size="40" value="/home/zdorian/public_html/files" /></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><input type="checkbox" name="savesettings" id="savesettings" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('clearsettings').style.display=displ;" /> Save Settings</td>
<td> </td>
<td id="clearsettings" style="display: none;"><a href="javascript:clearSettings();">Clear Current Settings</a></td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</form>
I have problems with posting a URL form. When I run cURL, it looks like it goes into an infinite loop; it doesn't stop at all. It's OK when I do simple forms like:
<form action="#" method="post">
Name: <input type="text" name="na" />
<input type="submit" value="Send" />
</form>
But when I try submitting a post on a PHPBB3 forum script, where there are some similar forms, the script doesn't stop.
Do I have to determine the variables for every input, even if there are 2 forms and I just want to submit one of them?
cURL code:
<form action="zd.php" method="post">
Link: <input type="text" name="linko" /><br />
<input type="submit" value="Salji" />
<input type="hidden" name="sad" value="sad" />
</form>
<?php
if (isset($_POST['sad'])) {
$imos = trim($_POST['linko']);
$koja = curl_init("http://link/index.php");
$kooky = "PHPSESSID=9opvpblp3govbrfg27t0a8jki6";
$po = array(
'link'=>$imos,
'referer'=>' ',
'submit'=>'Transload File');
curl_setopt($koja, CURLOPT_COOKIE, $kooky);
curl_setopt($koja, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($koja, CURLOPT_POST, 1);
curl_setopt($koja, CULROPT_POSTFIELDS, $po);
curl_exec($koja);
echo "<br />ERROR: ".curl_error($koja);
}
?>
The page I'm posting to (whole form):
<form action="/index.php" name="transload" method="post">
<table class="tab-content" id="tb1" cellspacing="5" width="100%">
<tbody>
<tr>
<td align="left">
<b>Link to Transload:</b><br /> <input type="text" name="link" id="link" size="50" /><br /><br />
<b>Referrer:</b><br /> <input type="text" name="referer" id="referer" size="50" />
</td>
<td align="center">
<input value="Transload File" type="submit" />
</td>
</tr>
<tr>
<td align="left"><input type="checkbox" name="user_pass" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('usernpass').style.display=displ;" value="on" /> User & Pass (HTTP/FTP)</td>
</tr>
<tr id="usernpass" style="display: none;">
<td align="center">
User: <input type="text" name="iuser" value="" /><br />
Pass: <input type="text" name="ipass" value="" />
</td>
</tr>
<tr>
<td align="left"><input type="checkbox" name="add_comment" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('comment').style.display=displ;" /> Add Comments</td>
</tr>
<tr id="comment" style="display: none;">
<td>
<textarea name="comment" rows="4" cols="50"></textarea>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="left">
<small style="color:#55bbff">PluginOptions:</small><hr />
<label><input type="checkbox" name="dis_plug" /> <small>Disable All Plugins</small></label>
</td>
</tr>
<tr>
<td align="left">
<label><input type="checkbox" name="ytube_mp4" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('ytubeopt').style.display=displ;" /> <small>YouTube Video Format Selector</small></label>
<table width="150" border="0" id="ytubeopt" style="display: none;">
<tr>
<td colspan="2" style="white-space: nowrap;"><input type="checkbox" name="ytdirect" /><small> Direct Link</small></td>
</tr>
<tr>
<td align="left"><small>&fmt=</small></td>
<td align="left">
<select name="yt_fmt" id="yt_fmt">
<option value="highest" selected="selected">Auto-get the highest quality format available</option>
<option value="0">0 [Video: FLV H263 251kbps 320x180 @ 29.896fps | Audio: MP3 64kbps 1ch @ 22.05kHz]</option>
<option value="5">5 [Video: FLV H263 251kbps 320x180 @ 29.885fps | Audio: MP3 64kbps 1ch @ 22.05kHz]</option>
<option value="6">6 [Video: FLV H263 892kbps 480x270 @ 29.887fps | Audio: MP3 96kbps 1ch @ 44.10kHz]</option>
<option value="13">13 [Video: 3GP H263 77kbps 176x144 @ 15.000fps | Audio: AMR 13kbps 1ch @ 8.000kHz]</option>
<option value="17">17 [Video: 3GP XVID 55kbps 176x144 @ 12.000fps | Audio: AAC 29kbps 1ch @ 22.05kHz]</option>
<option value="18">18 [Video: MP4 H264 505kbps 480x270 @ 29.886fps | Audio: AAC 125kbps 2ch @ 44.10kHz]</option>
<option value="22">22 [Video: MP4 H264 2001kbps 1280x720 @ 29.918fps | Audio: AAC 198kbps 2ch @ 44.10kHz]</option>
<option value="34">34 [Video: FLV H264 256kbps 320x180 @ 29.906fps | Audio: AAC 62kbps 2ch @ 22.05kHz]</option>
<option value="35">35 [Video: FLV H264 831kbps 640x360 @ 29.942fps | Audio: AAC 107kbps 2ch @ 44.10kHz]</option>
<option value="37">37 [Video: MP4 1920×1080 | Audio: AAC 2ch 44.10kHz]</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left"><label><input type="checkbox" name="imageshack_tor" id="imageshack_tor" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('torpremiumblock').style.display=displ;" /> <small>ImageShack® TorrentService</small></label><table width="150" border="0" id="torpremiumblock" style="display: none;">
<tr><td>Username: </td><td><input type="text" name="tor_user" id="tor_user" size="15" value="" /></td></tr>
<tr><td>Password: </td><td><input type="password" name="tor_pass" id="tor_pass" size="15" value="" /></td></tr>
</table>
</td>
</tr>
<tr>
<td align="left">
<label><input type="checkbox" name="mu_acc" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('mupremiumblock').style.display=displ;" /> <small>Megaupload.com Cookie Value</small></label>
<table width="150" border="0" id="mupremiumblock" style="display: none;">
<tr><td>user=</td><td><input type="text" name="mu_cookie" id="mu_cookie" size="25" value="" /></td></tr>
</table>
</td>
</tr>
<tr>
<td align="left">
<label><input type="checkbox" name="vBulletin_plug" /> <small>Use vBulletin Plugin</small></label>
</td>
</tr>
<tr>
<td align="left">
<label><input type="checkbox" name="cookieuse" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('cookieblock').style.display=displ;" /> <small>Additional Cookie Value</small></label>
<table width="150" border="0" id="cookieblock" style="display: none;">
<tr><td>Key=Value;</td><td><input type="text" name="cookie" id="cookie" size="25" value="" /></td></tr>
</table>
</td>
</tr>
</tbody>
</table>
<table class="hide-table" id="tb2" cellspacing="5" width="100%">
<tbody>
<tr>
<td align="center">
<table align="center" style="text-align: justify;">
<tr>
<td><input type="checkbox" name="domail" id="domail" onclick="document.getElementById('emailtd').style.display=document.getElementById('splittd').style.display=this.checked?'':'none';document.getElementById('methodtd').style.display=(document.getElementById('splitchkbox').checked ? (this.checked ? '' : 'none') : 'none');" /> Send File to Email</td>
<td> </td>
<td id="emailtd" style="display: none;">Email: <input type="text" name="email" id="email" /></td>
</tr>
<tr>
<td></td>
</tr>
<tr id="splittd" style="display: none;">
<td>
<input id="splitchkbox" type="checkbox" name="split" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('methodtd').style.display=displ;" /> Split Files</td>
<td> </td>
<td id="methodtd" style="display: none;">
<table>
<tr>
<td>Method: <select name="method"><option value="tc">Total Commander</option><option value="rfc">RFC 2046</option></select></td>
</tr>
<tr>
<td>Parts Size: <input type="text" name="partSize" size="2" value="10" /> MB</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><input type="checkbox" id="useproxy" name="useproxy" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('proxy').style.display=displ;" /> Use Proxy Settings</td>
<td> </td>
<td id="proxy" style="display: none;">
<table width="150" border="0">
<tr><td>Proxy: </td><td><input type="text" name="proxy" id="proxyproxy" size="20" /></td></tr>
<tr><td>Username: </td><td><input type="text" name="proxyuser" id="proxyuser" size="20" /></td></tr>
<tr><td>Password: </td><td><input type="text" name="proxypass" id="proxypass" size="20" /></td></tr>
</table>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><input type="checkbox" name="premium_acc" id="premium_acc" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('premiumblock').style.display=displ;" checked="checked" /> Use Premium Account</td>
<td> </td>
<td id="premiumblock" style="display: none;">
<table width="150" border="0">
<tr><td>Username: </td><td><input type="text" name="premium_user" id="premium_user" size="15" value="" /></td></tr>
<tr><td>Password: </td><td><input type="password" name="premium_pass" id="premium_pass" size="15" value="" /></td></tr>
</table>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr style="display:none;">
<td><input type="checkbox" name="saveto" id="saveto" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('path').style.display=displ;" /> Save To</td>
<td> </td>
<td id="path" style="display: none;">Path: <input type="text" name="path" size="40" value="/home/zdorian/public_html/files" /></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><input type="checkbox" name="savesettings" id="savesettings" onclick="javascript:var displ=this.checked?'':'none';document.getElementById('clearsettings').style.display=displ;" /> Save Settings</td>
<td> </td>
<td id="clearsettings" style="display: none;"><a href="javascript:clearSettings();">Clear Current Settings</a></td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已将行中的“CURLOPT_POSTFIELDS”拼写错误为 CULROPT_POSTFIELDS -
请更正拼写,它将起作用。
You have misspelled - "CURLOPT_POSTFIELDS" as CULROPT_POSTFIELDS in line -
Please correct the spelling it will work.