if ($key + 1 < sizeof($res)) {
             echo ",";
         }
     }
     echo "]},";
     $cnt++;
     continue;
 }
 foreach ($labels as $key => $label) {
     if ($comma) {
         echo ",";
     }
     //  $samples = getResultsData($label, $startDateTime, $endDateTime, $resolution, $result);
     echo "{\"job\": \"" . $resultArrayKey . "\",\"label\": \"" . $resultArrayKey . " - " . $key . "\", \"data\": [";
     if ($resolution > 1) {
         getResultsData($label, $startDateTime, $endDateTime, $resolution, $res);
     } else {
         foreach ($res as $key => $r) {
             $d = $r['Date'];
             echo "[" . $d . "," . $r[$label] . "]";
             if ($key + 1 < sizeof($res)) {
                 echo ",";
             }
         }
     }
     //  foreach($samples as $key => $sample){
     //    echo "[".$key.",".$sample."],";
     //  }
     echo "]}";
     if (!$comma) {
         $comma = true;
Example #2
0
    $foundData = substr($data, $foundLocBegin, $foundLocEnd - $foundLocBegin);
    return $foundData;
}
if (!isset($_GET['term'])) {
    mt_srand();
    $max = 1249179;
    $rand = mt_rand(0, $max);
    $file = fopen('urbandom.lst', 'r');
    $line = '';
    $i = 0;
    while (!feof($file)) {
        if ($i++ == $rand) {
            $line = fgets($file);
            break;
        } else {
            fgets($file);
        }
    }
} else {
    $line = strip_tags($_GET['term']);
}
$query = urlencode(trim($line));
$data = file_get_contents('http://www.urbandictionary.com/define.php?term=' . $query);
$term = rawurldecode($query);
$definition = getResultsData($data, '<div class="definition">', '</div>');
$example = getResultsData($data, '<div class="example">', '</div>');
$definition = str_replace($term, '<b>' . $term . '</b>', $definition);
$example = str_replace($term, '<b>' . $term . '</b>', $example);
echo 'Term: <b><a href="?term=' . urlencode($term) . '">' . $term . '</a></b><br>';
echo 'Definition: ' . $definition . '<br>';
echo 'Example: ' . $example . '';