-1

好的,所以我们来这里是我的 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×1 的数组回显

4

1 回答 1

0

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

文件

<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>

你的脚本.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";
    }
于 2013-06-20T21:18:17.447 回答