【问题标题】:my php curl script works i now need to send users:pass in array [duplicate]我的 php curl 脚本有效我现在需要发送用户:传入数组 [重复]
【发布时间】:2013-06-17 17:49:20
【问题描述】:

好的,我们来这里是我的 curl 脚本

<?php
// Function file
include('func.php');

//Data for Check function

$user = "username goes here";
$password = "password goes here";

//Data for boundary values

$upper_boundary = "999.99";
$lower_boundary = "0.00";

//Login script 

checkcpu($user, $password);

//Check  script

$html = check('https://example/home.aspx');
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$value = $xpath->query('//label[@id="ctl00_ctl00_PageContainer_MyAccountCpuContainer_symPercent"]/following-sibling::text()')->item(0)->nodeValue;



//Checking for value and echo results

if (($value >= $lower_boundary) && ($value <= $upper_boundary)) {
$result_string = "Checked ". $user .  " : " . $password . " cpu cooling rat:";                
echo "Live - $result_string $value"; 
//Erase Cookie Content
signout();
}else{ 
checkcpu($user, $password);

//Check  script

$html = check('https://example/home.aspx');
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$value = $xpath->query('//label[@id="ctl00_ctl00_PageContainer_MyAccountCpuContainer_symPercent"]/following-sibling::text()')->item(0)->nodeValue;

if (($value >= $lower_boundary) && ($value <= $upper_boundary)) {
$result_string = "Checked ". $user .  " : " . $password . " cpu cool rate:";                
echo "Live - $result_string $value"; 
//Erase Cookie Content
signout();
}else{ 
echo "Die - $user $password $value"; 
}
}


?>

我想发送一个数据数组,我复制并粘贴到这样的文本框中

user:pass
user:pass
user:pass
user:pass
user:pass
user:pass
user:pass
user:pass
user:pass
user:pass

我希望使用 ajax 将此数组发送到我的 php 文件,以便用户进入用户名进入我的 curl 脚本,输入密码的密码进入此处,然后将我的结果以 1 x 1 的数组回显

【问题讨论】:

  • 那么问题出在哪里?
  • 我需要使用 ajax 将数组中的数据发送到我的 curl 脚本,正如我在帖子中所说的那样
  • 很好。祝你好运。
  • marc b 有什么方法你知道我如何发送数组中的用户
  • @AshleyGraham - 如果您能证明您自己尝试过这样做,您可能会获得更多帮助。

标签: php ajax arrays curl


【解决方案1】:

您的帖子没有说明您是否使用 jQuery,但我强烈推荐它。有了它,您可以执行以下操作:

HTML 文件

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

<form id="userpass">
    <textarea name="userpass"></textarea><br />
    <input type="submit" />
</form>

<script>
    (function($) {
        $('#userpass').submit(function() {
            $.post('yourscript.php', $(this).serialize())
             .done(function(response){
                 // Do something with the response if you want.
             })
        ));
    })(jQuery);
</script>

yourscript.php

<?php
    // Parse the user:pass string
    preg_match_all('|(.*):(.*)|', $_POST['userpass'], $matches, PREG_SET_ORDER);

    foreach ($matches as $match) {
        // loop through all of the matches and do something with the username/password
        list(, $username, $password) = $match;

        echo $username . ' - ' . $password . "\n";
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    • 2012-05-08
    • 2020-11-16
    • 2010-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多