/*--------------------------データベースにセンサデータと識別乱数を書き込む---------------------*/ $sql_insert = "INSERT INTO " . $tableName . " (sensorData1,sensorData2,sensorData3,sensorData4,sensorData5,sensorData6,randID) VALUES (:s1,:s2,:s3,:s4,:s5,:s6,:randID)"; $stmt_insert = $pdo->prepare($sql_insert); $stmt_insert->bindValue(':s1', $send_arr["d1"], PDO::PARAM_INT); $stmt_insert->bindValue(':s2', $send_arr["d2"], PDO::PARAM_INT); $stmt_insert->bindValue(':s3', $send_arr["d3"], PDO::PARAM_INT); $stmt_insert->bindValue(':s4', $send_arr["d4"], PDO::PARAM_INT); $stmt_insert->bindValue(':s5', $send_arr["d5"], PDO::PARAM_INT); $stmt_insert->bindValue(':s6', $send_arr["d6"], PDO::PARAM_INT); $stmt_insert->bindValue(':randID', $randID, PDO::PARAM_INT); $stmt_insert->execute(); $new_arr = getNewData(); //先ほど格納した最新のデータ $newRandId = $new_arr[6]; //data1,data2,data3,data4,data5,data6,randID $base_arr = getBaseData($newRandId); //最新のrandIdからキャリブレーション用の基準値を取得 $cali_arr = doCalibration($new_arr, $base_arr); //キャリブレーションを行う $ws_for_send = calcWorkingState($cali_arr, $isSitting_num, $isWorking_num, $newRandId); //現在のworkingStateを取得 /*--------------------------データベースに作業レベルのデータを書き込む---------------------*/ $sql_insert_ws = "INSERT INTO " . $tableName_ws . " (ws,diff) VALUES(:ws,:diff)"; $stmt_insert_ws = $pdo->prepare($sql_insert_ws); $stmt_insert_ws->bindValue(':ws', $ws_for_send, PDO::PARAM_INT); $stmt_insert_ws->bindValue(':diff', getMovementDiff($newRandId), PDO::PARAM_INT); $stmt_insert_ws->execute(); //DBに格納してある自分と相手の最新10個のworkingStateデータを取得 function getWorkingState($num) { global $tableName_ws;
function parseData($counterPosition) { global $cookie1, $cookie2, $cookie3, $cookie4, $cookie5; # Store a timestamp of our start point $startTime = mktime(); # Variable used for post backs $dropdowndsAndSearchText = '&ctl00%24ContentPlaceHolder1%24ddlRegion=0&ctl00%24ContentPlaceHolder1%24ddlAlphabet=0&ctl00%24ContentPlaceHolder1%24txtKeywords='; # Get our first set of data $info = ''; $result = ''; getBaseData($info, $result); # We need this for our next two post backs $url = $info['url']; // write here the url of your form # Our base HTML from the healthunit site $html = str_get_html($result); # Require for our Next PostBack(s) $viewstate = $html->find('#__VIEWSTATE'); $viewstate = $viewstate[0]->attr['value']; $validation = $html->find('#__EVENTVALIDATION'); $validation = $validation[0]->attr['value']; # Our looping variable & break variable $break = false; $i = 0; foreach($html->find('#ctl00_ContentPlaceHolder1_tblSearchResults') as $el) { # Our primary loop foreach($el->find('tr') as $row) { # Counter Position Check if ($i < $counterPosition) { $i++; continue; } # TimeCheck # If were over 25minutes - then we break out and restart if ($startTime + 60 * 25 < mktime()) { $break = true; break; } echo 'in our process'; # Increment our counter $i++; # Start processing our records $location = strip_tags($row->childNodes(0)->innertext); //estID is parameter of a tag $location_link = $row->childNodes(0)->find('a'); $location_id = $location_link[0]->attr['estid']; $location_linkid = $location_link[0]->attr['id']; $address = $row->childNodes(1)->innertext; $city = $row->childNodes(2)->innertext; $date = $row->childNodes(4)->innertext; //njs - 10-27-10 - column changes $critical = $row->childNodes(5)->innertext; //njs - 10-27-10 - column changes $noncritical = $row->childNodes(6)->innertext; //njs - 10-27-10 - column changes echo 'location ' . $location . '<br>'; echo 'location link id'.$location_linkid.'<br />'; echo 'location link ' . $location_link . '<br />'; echo 'location id ' . $location_id . '<br>'; echo 'address ' . $address . '<br>'; echo 'city ' . $city . '<br>'; echo 'date ' . $date . '<br>'; echo 'critical ' . $critical . '<br>'; echo 'noncritical ' . $noncritical . '<br>'; if ($date != '') { $inspected = date('Y-m-d', strtotime($date)); //njs - 10-28-10 //reset closures if reinspections have occurred boolReInspection($location_id, $inspected); } else { $inspected = '0000-00-00'; } $location_id = updateLocation($location, $address, $city, $inspected, $critical, $noncritical); //njs - 10-28-10 //update inspection was returning false positives on infractions //changed to only check inspection date //$update_inspect = boolUpdateInspection($location_id, $inspected, $critical, $noncritical); $update_inspect = boolUpdateInspection($location_id, $inspected); if ($update_inspect) { try { # Get any of the inspection information $ch = curl_init(); // Initiating the Curl Handler curl_setopt($ch, CURLOPT_URL,$url); // Url a donde se va a postear. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'); //I set the user Agent. In this case is Firefox 2 browser curl_setopt($ch, CURLOPT_FAILONERROR, 1); //finish in case of error curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirections curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Return the result page in a variable curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout. curl_setopt($ch, CURLOPT_POST, 1); // I set the POST Method curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie3); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie4); $post = '__EVENTTARGET='.str_replace('_','%24',$location_linkid); $post.= '&__EVENTARGUMENT=&__VIEWSTATE='.urlencode($viewstate); $post.= '&__EVENTVALIDATION='.urlencode($validation); $post.= $dropdowndsAndSearchText; curl_setopt($ch, CURLOPT_POSTFIELDS, $post); //change it with your own field name and value $result2 = curl_exec($ch); // Execute and send the data. $info = curl_getinfo($ch); curl_close($ch); # Parse the results & loop through each inspection date $html2 = str_get_html($result2); $viewstate2 = $html2->find('#__VIEWSTATE'); $viewstate2 = $viewstate2[0]->attr['value']; $validation2 = $html2->find('#__EVENTVALIDATION'); $validation2 = $validation2[0]->attr['value']; $divLocation2 = strpos($result2, '<div id="ctl00_ContentPlaceHolder1_pnlViolations"'); $pos2 = substr($result2, $divLocation2, strpos($result2, '</div>', $divLocation2) - $divLocation2); $html2->clear(); unset($html2); $htmldata2 = str_get_html('<html><body>'.$pos2.'</body></html>'); $skip2 = false; } catch (Exception $e) { error_log('Error processing document ' . $e->getMessage()); die('Error processing document ' . $e->getMessage()); } echo '<br/>process rows '.date('h:i:s'); foreach($htmldata2->find('tr') as $row2) { # Skip the header row if (!$skip2) { $skip2 = true; continue; } # Grab our data $inspectionLink = $row2->childNodes(0)->find('a'); if ($inspectionLink[0]->innertext != '') { $inspectionDate = date('Y-m-d', strtotime($inspectionLink[0]->innertext)); } else { $inspectionDate = '0000-00-00'; } $estid = $inspectionLink[0]->attr['estid']; $inspectionId = $inspectionLink[0]->attr['inspectionid']; $inspectionLinkId = $inspectionLink[0]->attr['id']; $inspectionType = $row2->childNodes(2)->innertext; // rtraction djm - Nov.2 2010 - blank row added $critical = $row2->childNodes(3)->innertext; // rtraction djm - Nov.2 2010 - blank row added $nonCritical = $row2->childNodes(4)->innertext; // rtraction djm - Nov.2 2010 - blank row added # Testing echo 'Inspecd:'.$inspectionDate.'<br />'; echo 'ESTID:'.$estid.'<br />'; echo 'InspecId:'.$inspectionId.'<br />'; echo 'InspecT:'.$inspectionType.'<br />'; echo 'Critical:'.$critical.'<br />'; echo 'NonCritical:'.$nonCritical.'<br />'; echo '<br />'; # Grab the text $ch = curl_init(); // Initiating the Curl Handler curl_setopt($ch, CURLOPT_URL,$url); // Url a donde se va a postear. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'); //I set the user Agent. In this case is Firefox 2 browser curl_setopt($ch, CURLOPT_FAILONERROR, 1); //finish in case of error curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirections curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Return the result page in a variable curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout. curl_setopt($ch, CURLOPT_POST, 1); // I set the POST Method curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie4); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie5); $post = '__EVENTTARGET='.str_replace('_','%24',$inspectionLinkId); $post.= '&__EVENTARGUMENT=&__VIEWSTATE='.urlencode($viewstate2); $post.= '&__EVENTVALIDATION='.urlencode($validation2); $post.= $dropdowndsAndSearchText; curl_setopt($ch, CURLOPT_POSTFIELDS, $post); //change it with your own field name and value $result3 = curl_exec($ch); // Execute and send the data. $info = curl_getinfo($ch); curl_close($ch); # Parse the results & loop through each item $divLocation3 = strpos($result3, '<div id="ctl00_ContentPlaceHolder1_pnlViolationDetails"'); $pos3 = substr($result3, $divLocation3, strpos($result3, '</div>', $divLocation3) - $divLocation3); $htmldata3 = str_get_html('<html><body>'.$pos3.'</body></html>'); $skip3 = false; foreach($htmldata3->find('tr') as $row3) { # Skip any header rows if ($row3->class == "inspectionTableHeader") { continue; } # Grab our data for all normal rows if (isset($row3->childNodes(2)->innertext)) { //severity can be critical, noncritical, satisfactory $severity = strip_tags($row3->childNodes(0)->innertext); $desc = $row3->childNodes(1)->innertext; $resultText = $row3->childNodes(2)->innertext; # Testing echo 'Severity:'.$severity.'<br />'; echo 'Desc:'.$desc.'<br />'; echo 'Res:'.$resultText.'<br />'; echo '<br />'; $details = ''; $category = ''; if ($desc != '') { $desc = strip_tags($desc); $failPos = stripos($desc, 'Fail'); $category = substr($desc, 0, $failPos); $details = substr($desc, $failPos, strlen($desc)); } # Update details in db updateInspection($location_id, $inspectionDate, $severity, $resultText, $details, $category, $inspected); } else { // Do we have an order 13? $text = $row3->childNodes(0)->innertext; if (strpos(strtolower($text), 'section 13 order served') !== FALSE) { echo 'Order 13 Served!<br />'; // We found an Order 13 - so lets capture that information updateInspection($location_id, $inspectionDate, 'Closed', 'No', strip_tags($text), 'Order 13 Served', $inspected); } else if (strpos(strtolower($text), 'section 13 order revoked') !== FALSE) { echo 'Order 13 Revoked!<br />'; // We found an Order 13 - so lets capture that information updateInspection($location_id, $inspectionDate, 'Closed', 'No', strip_tags($text), 'Order 13 Revoked', $inspected); } else { echo 'No infractions - record note!<br />'; // We record a simple note as there was no infractions updateInspection($location_id, $inspectionDate, 'Note', 'No', ' ', strip_tags($text), $inspected); } } } $htmldata3->clear(); unset($htmldata3); # Only process one inspection ///break; Process all inspections - Aug. 5, 2010 - rtraction djm } $htmldata2->clear(); unset($htmldata2); } } # We've hit our timelimit above so we want to break out if ($break) { break; } } $html->clear(); unset($html); // updated log table if (!$break) { updateLog(); } else { # We hit a time block above and broke out of our loops # We're starting the process again but jumping ahead parseData($i); } }
<!-- CONTENT START --> <body class="detail"> <?php //print_r($musicData); //print_r($versionList); $d = getBaseData($musicData, $versionList); $bpm = $d['bpm_min'] == $d['bpm_max'] ? $d['bpm_max'] : $d['bpm_min'] . "-" . $d['bpm_max']; $v = getVersion($versionList); $verAC = $v['ac']; $verCS = $v['cs']; $html = <<<HTML_STR <div class="article"> <div class="d_t"> <div id="mdetail_head"><a class="close">close</a></div> <table id="mdetail_base"> <tr><th class="name" colspan="6">{$d['music_name']}</th></tr> <tr><th>verAC</th><td colspan="5">{$verAC}</td></tr> <tr><th>verCS</th><td colspan="5">{$verCS}</td></tr> <tr><th>bpm</th><td colspan="5">{$bpm}</td> <tr><th>bpm詳細</th><td colspan="5">{$d['bpm_detail']}</td></tr> <tr><th>ジャンル</th><td colspan="5">{$d['genre_name']}</td></tr> <tr><th>作者</th><td colspan="5">{$d['artist_name']}</td></tr> </table> <table id="mdetail_notes"> <tr><th class="SP" colspan="3">Single</th><th class="DP" colspan="3">Double</th></tr> <tr><th>N7</th><td>{$d['spn']}</td><td>{$d['n7']}</td><th>N14</th><td>{$d['dpn']}</td><td>{$d['n14']}</td></tr> <tr><th>H7</th><td>{$d['sph']}</td><td>{$d['h7']}</td><th>H14</th><td>{$d['dph']}</td><td>{$d['h14']}</td></tr> <tr><th>A7</th><td>{$d['spa']}</td><td>{$d['a7']}</td><th>A14</th><td>{$d['dpa']}</td><td>{$d['a14']}</td></tr> </table> <table id="mdetail_dif_change"> <tr><th colspan="2">難度変更履歴</th></tr>
<?php // call php data.php > results.json to get an up-to-date local copy of a the // "master" results. Or adjust the save-results endpoint in slickspeed.js, // and use that as the $data url. // this is the "master" collected data. Adjust for your own purposes. $data = file("http://dante.dojotoolkit.org/taskspeed/results.dat"); $results = array(); foreach ($data as $line) { // wow, really? $d = json_decode(stripslashes(unserialize($line))); $results[] = $d; } $total_tests = count($results); // the results by browser $byBrowser = getBaseData($results); $uas = array_keys($byBrowser["browsers"]); $counts = array(); $perbrowser = array(); foreach ($uas as $browser) { // just to see how good of coverage each browser got $tests = $byBrowser["browsers"][$browser]["tests"]; $counts[$browser] = count($tests); if (!is_array($perbrowser[$browser])) { $perbrowser[$browser] = array(); } foreach ($tests as $test) { foreach ($test as $library => $score) { if (!is_array($perbrowser[$browser][$library])) { $perbrowser[$browser][$library] = array(); $perbrowser[$browser][$library]['total'] = 0;