function process_code($code) { $url = null; if (empty($code)) { return -1; } $url = get_url($code); if (empty($url)) { return -1; } $response = verify_url($url); if ($response != null) { if ($response == 404) { return 2; } } else { return -1; } if (lookup_url_is_spam($url)) { return 1; } if (check4spam($url)) { add_bad_url_to_db($url); return 1; } return 0; }
function verify_domain_json($json) { $url = get_url($json); if (verify_url($url)) { return verify_domain_by_url($url); } else { return array('company_name' => '', 'company_url' => '', 'verification_result' => 'FAIL', 'url_matching' => 'false'); } }
$github_json = load_json('github'); $coinbase_json = load_json('coinbase'); $colu_json = load_json('colu'); $bcinfo_json = load_json('blockchaininfo'); $colu_2nd_asset_json = load_json('colu_2nd_asset'); $colu_fake_asset_json = load_json('colu_fake_asset'); // VARS $good_array = array('good', 'good', 'good'); $bad_array = array('good', 'good', 'bad'); $bofa_url = 'https://www.bankofamerica.com'; $urls = ['https://www.foo.bar', 'http://www.foo.bar', 'httx://www.foo.bar', 'https://wwwfoobar', 'blard', 'https:/www.foo.bar', 'https:///www.foo.bar', null, '', ' ', 'https://colu.co']; $expected = array(TRUE, false, false, false, false, false, false, false, false, false, TRUE); foreach ($urls as &$key) { // $pattern = "/https:\/\/(\w*\.+)+/i"; // preg_match($pattern, $key) ? $key = 1: $key = 0; $key = verify_url($key); } // var_dump($urls); // echo "<br/>urls: [".$urls."]"; // TESTS // $var_test = ()? PASS:FAIL; $verify_url_test = $urls == $expected ? PASS : FAIL; echo "<br/>verify_url_test: [" . $verify_url_test . "]"; $array_test = verify_chain($good_array) == 1 && verify_chain($bad_array) != 1 ? PASS : FAIL; echo "<br/>array_test: [" . $array_test . "]"; $get_url_test = get_url($bofa_json) == $bofa_url ? PASS : get_url($bofa_json); echo "<br/>get_url_test: [" . $get_url_test . "]"; $get_empty_url_test = get_url(null) == '' ? PASS : get_url(null); echo "<br/>get_empty_url_test: [" . $get_empty_url_test . "]"; $match_domains_test = match_urls('www.foo.bar', 'xxx.foo.bar') && match_urls('www.foo.bar', '*.foo.bar') && match_urls('foo.bar', '*.foo.bar') && match_urls('foo.bar', 'www.foo.bar') && match_urls('cert-002.blockchain.info', 'www.blockchain.info') ? PASS : FAIL; echo "<br/>match_domains_test: [" . $match_domains_test . "]";
$departUrl = NULL; $departDom = NULL; $departTree = NULL; } else { $departUrl = 'http://api.bart.gov/api/sched.aspx?cmd=depart&orig=' . $nowNextStop[0] . '&dest=' . $nowNextStop[1] . '&date=now&time=now&key=MW9S-E7SL-26DU-VV8V&b=0&a=4&l=1'; $arriveUrl = 'http://api.bart.gov/api/sched.aspx?cmd=arrive&orig=' . $nowNextStop[2] . '&dest=' . $nowNextStop[0] . '&date=now&time=now&key=MW9S-E7SL-26DU-VV8V&b=0&a=4&l=1'; // verify url, if it can't be reached, set a flag if (verify_url($departUrl)) { $departDom = simplexml_load_file($departUrl); $departTree = $departDom->xpath("schedule"); $departNoShow = false; } else { $departNoShow = true; } // verify url, if it can't be reached, set a flag if (verify_url($arriveUrl)) { $arriveDom = simplexml_load_file($arriveUrl); $arriveTree = $arriveDom->xpath("schedule"); $arriveNoShow = false; } else { $arriveNoShow = true; } } } ?> <section class='arrivals'> <!-- container to display data for next several arrivals --> <?php if (is_null($prevStopNumber)) { // if we're on stop 0, don't create any HTML to display