예제 #1
0
    $wsoma = 0;
    $wresto = 0;
    $ind = 0;
    $posfinal = 0;
    $dac = 0;
    $ind = 2;
    $wsoma = 0;
    $posfinal = strlen($strVerif) - 2;
    for ($i = $posfinal; $i >= 0; $i--) {
        $chr = substr($strVerif, $i, 1);
        $wsoma = $wsoma + $chr * $ind;
        $ind = $ind + 1;
        if ($ind == 11) {
            $ind = 1;
        }
    }
    $wresto = 11 - $wsoma % 11;
    if ($wresto == 10) {
        $dac = "1";
    } else {
        if ($wresto == 11) {
            $dac = "0";
        } else {
            $dac = $wresto;
        }
    }
    if (substr($strVerif, 10, 1) != $dac) {
    }
}
verificaDac();
function getPage($s, $q, $lmin, $lmax)
{
    require_once 'simpletest/browser.php';
    $browser = new SimpleBrowser();
    $browser->useCookies();
    for ($r = $lmin; $r <= $lmax; $r++) {
        $browser->get('https://www3.prefeitura.sp.gov.br/sf8663/formsinternet/Principal.aspx');
        $viewstate = $browser->getField('__VIEWSTATE');
        $setor = $s;
        $quadra = $q;
        $lote = leading_zeros(number_format($r, 0, '', ''), 4);
        //$lote = number_format($r);
        $browser->setField('txtSetor', $setor);
        $browser->setField('txtQuadra', $quadra);
        $browser->setField('txtLote', $lote);
        $browser->setField('txtDigito', verificaDac($setor, $quadra, $lote));
        $browser->clickSubmitByName('_BtnAvancarDasii');
        $results = $browser->getContent();
        $dom = new simple_html_dom();
        $dom->load($results);
        $arrName = array();
        foreach ($dom->find('input') as $input) {
            array_push($arrName, $input->name);
        }
        $arrValue = array();
        foreach ($dom->find('input') as $input) {
            array_push($arrValue, $input->value);
        }
        if (empty($arrValue)) {
        } else {
            if ($arrValue[6] == "") {
                var_dump($lote);
            } else {
                $arr = array($arrName[5] => $arrValue[5], $arrName[6] => $arrValue[6], $arrName[7] => $arrValue[7], $arrName[8] => $arrValue[8], $arrName[9] => $arrValue[9], $arrName[11] => $arrValue[11]);
                scraperwiki::save(array('txtNumIPTU'), $arr);
            }
        }
    }
}