Example #1
0
File: sql.php Project: gepuro/smt2
     //
     $clicks[] = $cl;
     //
     $fps[] = (int) $log['fps'];
     $hovered .= $log['hovered'];
     $clicked .= $log['clicked'];
     $timestamp = mask_client($log['client_id']) . '\\n' . date("h:i A", strtotime($log['sess_date']));
     $hn = new Hypernote($_GET['pid'], $_SESSION['login']);
     $hypernotes = $hn->getData(false);
     // build JavaScript object
     $JSON[] = '{' . '"id": ' . $log['id'] . ', ' . '"xcoords": [' . $log['coords_x'] . '], ' . '"ycoords": [' . $log['coords_y'] . '], ' . '"clicks":  [' . $log['clicks'] . '], ' . '"timestamp": "' . $timestamp . '", ' . '"hypernotes": ' . json_encode($hypernotes) . ', ' . '"wprev": ' . $vpw . ', ' . '"hprev": ' . $vph . ', ' . '"time": ' . $log['sess_time'] . '' . '}';
 }
 // set a common frame rate for all tracks
 $fps = ceil(array_avg($fps));
 $viewportWidth = ceil(array_avg($viewportWidth));
 $viewportHeight = ceil(array_avg($viewportHeight));
 // compute the average user path, if need be ---------------------------------
 if (db_option(TBL_PREFIX . TBL_CMS, "displayAvgTrack")) {
     // preprocess: pad all mouse vectors
     $maxWeight = max($weights);
     foreach ($weights as $i => $w) {
         $items = count($coordsX[$i]);
         $diff = $maxWeight - $items;
         if ($diff > 0) {
             $coordsX[$i] = array_pad($coordsX[$i], $items + $diff, 0);
             $coordsY[$i] = array_pad($coordsY[$i], $items + $diff, 0);
             $clicks[$i] = array_pad($clicks[$i], $items + $diff, 0);
         }
     }
     $users = count($logs);
     // chek logs count to access coordinates index
     $pvalue = $pempty;
     $pempty = $tmp;
 }
 $w = $config['percent_graph_width'] + 2;
 if (empty($ci['istotal'])) {
     $graph = freeblock_to_graph($ci['free_blocks'], $ci['size']);
     $blocksgraph = "<div class=\"blocksgraph\" style=\"width: {$w}px\">{$graph}</div>";
 } else {
     $blocksgraph = '';
 }
 $ci_slots = size($ci['slots']);
 $ci_size = size($ci['size']);
 $ci_avail = size($ci['avail']);
 $ci = number_formats($ci, $numkeys);
 $hits_avg_h = number_format(array_avg($ci['hits_by_hour']), 2);
 $hits_avg_s = number_format(array_avg($ci['hits_by_second']), 2);
 $hits_graph_h = get_cache_hits_graph($ci, 'hits_by_hour');
 if (!empty($ci['istotal'])) {
     $ci['status'] = '-';
     $ci['can_readonly'] = '-';
 } else {
     if ($ci['disabled']) {
         $ci['status'] = $l_disabled . sprintf("(%s)", age($ci['disabled']));
     } else {
         if ($ci['type'] == XC_TYPE_PHP) {
             $ci['status'] = $ci['compiling'] ? $l_compiling . sprintf("(%s)", age($ci['compiling'])) : $l_normal;
         } else {
             $ci['status'] = '-';
         }
     }
     $ci['can_readonly'] = $ci['can_readonly'] ? 'yes' : 'no';
Example #3
0
/**
 * Computes the average sum of a matrix, assuming that each row is a numeric array.
 * @param   array $matrix a set of arrays (matrix)
 * @return  float         matrix average value
 */
function matrix_avg($matrix)
{
    $sum = 0;
    $count = 0;
    foreach ($matrix as $arrItem) {
        //if (!is_array($arrItem)) $arrItem = explode(",", $arrItem);
        $sum += array_avg($arrItem);
        ++$count;
    }
    return round($sum / $count, 2);
}
Example #4
0
 public function __construct(array $track)
 {
     $x = $track['x'];
     $y = $track['y'];
     $c = $track['c'];
     // Ensure real arrays
     if (!is_array($x)) {
         $x = explode(",", $x);
     }
     if (!is_array($y)) {
         $y = explode(",", $y);
     }
     if (!is_array($c)) {
         $c = explode(",", $c);
     }
     $f = (int) $track['f'];
     $n = count($x);
     $distCoords = convert_points($x, $y, true);
     // Distance study
     $dc_x = array();
     $dc_y = array();
     foreach ($x as $j => $val) {
         if ($j >= $n - 1) {
             break;
         }
         $dx = abs($x[$j] - $x[$j + 1]);
         $dy = abs($y[$j] - $y[$j + 1]);
         $dc_x[] = $dx;
         $dc_y[] = $dy;
         $dc_t[] = $dx * $dx + $dy * $dy;
     }
     // Kinematics study
     $stop = 0;
     foreach ($distCoords as $dist) {
         if ($dist > 0) {
             continue;
         }
         ++$stop;
     }
     $clean_x = array_unique($x);
     $clean_y = array_unique($y);
     // Horizontal components
     $entry_x = $x[0];
     $exit_x = $x[$n - 1];
     $min_x = min($clean_x);
     $max_x = max($clean_x);
     $range_x = $max_x - $min_x;
     $scroll_x = 100 * round($range_x / $track['w'], 4);
     $centroid_x = array_avg($clean_x);
     $len_x = array_sum($dc_x);
     $dist_x = array_avg($dc_x);
     // Vertical components
     $entry_y = $y[0];
     $exit_y = $y[$n - 1];
     $min_y = min($clean_y);
     $max_y = max($clean_y);
     $range_y = $max_y - $min_y;
     $scroll_y = 100 * round($range_y / $track['h'], 4);
     $centroid_y = array_avg($clean_y);
     $len_y = array_sum($dc_y);
     $dist_y = array_avg($dc_y);
     // Total components
     $dist_t = array_avg($dc_t);
     $len_t = array_sum($dc_t);
     // save features
     $this->time = round($n / $f, 2);
     $this->numClicks = count_clicks($c);
     $this->activity = 100 * (1 - round($stop / count($distCoords), 4));
     $this->entry = array('x' => $entry_x, 'y' => $entry_y);
     $this->exit = array('x' => $exit_x, 'y' => $exit_y);
     $this->range = array('x' => $range_x, 'y' => $range_y);
     $this->scrollReach = array('x' => $scroll_x, 'y' => $scroll_y);
     $this->centroid = array('x' => $centroid_x, 'y' => $centroid_y);
     $this->trackLen = array('x' => $len_x, 'y' => $len_y, 't' => $len_t);
     $this->distance = array('x' => $dist_x, 'y' => $dist_y, 't' => $dist_t);
 }
Example #5
0
$list .= array_avg($allLenX) . ",<br />" . array_avg($allLenY);
$list .= '</td>' . PHP_EOL;
$list .= '<td>' . PHP_EOL;
$list .= array_avg($allRangeX) . ",<br />" . array_avg($allRangeY);
$list .= '</td>' . PHP_EOL;
$list .= '<td>' . PHP_EOL;
$list .= array_avg($allScrollX) . ",<br />" . array_avg($allScrollY);
$list .= '</td>' . PHP_EOL;
$list .= '<td>' . PHP_EOL;
$list .= array_avg($allEntryX) . ",<br />" . array_avg($allEntryY);
$list .= '</td>' . PHP_EOL;
$list .= '<td>' . PHP_EOL;
$list .= array_avg($allExitX) . ",<br />" . array_avg($allExitY);
$list .= '</td>' . PHP_EOL;
$list .= '<td>' . PHP_EOL;
$list .= array_avg($allCenX) . ",<br />" . array_avg($allCenY);
$list .= '</td>' . PHP_EOL;
$list .= '</tr>' . PHP_EOL;
// standard deviations of log data
$list .= '<tr class="odd">' . PHP_EOL;
//$list .= '<td><abbr title="Sample Standard Deviation">&sigma;</abbr></td>'.PHP_EOL;
$list .= '<td>' . PHP_EOL;
$list .= array_sd($allTime);
$list .= '</td>' . PHP_EOL;
$list .= '<td>' . PHP_EOL;
$list .= array_sd($allActivity);
$list .= '</td>' . PHP_EOL;
$list .= '<td>' . PHP_EOL;
$list .= array_sd($allClicks);
$list .= '</td>' . PHP_EOL;
$list .= '<td>' . PHP_EOL;
Example #6
0
function loop_setup($file_type, $target_array)
{
    $api_return = api_call($target_array[id], $target_array[info]);
    if ($target_array[object] === 'effort') {
        $ride_name = $api_return->{$target_array}[object]->segment->name;
    } else {
        $ride_name = $api_return->{$target_array}[object]->name;
    }
    $offset_date = $api_return->{$target_array}[object]->startDate;
    $utc_offset = $api_return->{$target_array}[object]->timeZoneOffset;
    $total_time = $api_return->{$target_array}[object]->elapsedTime;
    $total_dist = $api_return->{$target_array}[object]->distance;
    //TCX FORMAT REQUIRES AVG HR, MAX HR, AVG CADENCE
    if ($file_type === 'TCX' and $target_array[object] !== 'segment') {
        $stream_return = api_call($target_array[id], $target_array[stream]);
        if ($stream_return->heartrate !== NULL) {
            $hr_avg = array_avg($stream_return->heartrate);
            $hr_max = max($stream_return->heartrate);
        }
        if ($stream_return->cadence !== NULL) {
            $cadence = array_avg($stream_return->cadence);
        }
    }
    $start_epoch = gps_to_epoch($offset_date) - $utc_offset;
    $ride_date = gps_date($start_epoch);
    $export_date = gps_date(time());
    if ($target_array[object] === 'segment') {
        $ride_date = $export_date;
        $total_time = 0;
        $hr_avg = NULL;
        $hr_max = NULL;
        $cadence = NULL;
    }
    $ride_data_array = array('export_date' => $export_date, 'ride_name' => $ride_name, 'ride_date' => $ride_date, 'total_time' => $total_time, 'total_distance' => $total_dist, 'hr_avg' => $hr_avg, 'hr_max' => $hr_max, 'cadence' => $cadence);
    return $ride_data_array;
}
Example #7
0
require_once "Wicker.php";
require_once "Scan.class.php";
$scan = Scan::fromDB(1);
$statement = $wicker->db->con()->prepare("SELECT * FROM `aps` WHERE `scan_id` = ? GROUP BY `latitude` ORDER BY `id`");
$statement->execute(array(1));
$a = 0;
while ($info = $statement->fetchObject()) {
    $coords[$a]["lat"] = $info->latitude;
    $coords[$a]["long"] = $info->longitude;
    $array_lat[] = $info->latitude;
    $array_long[] = $info->longitude;
    $a++;
}
$avg_lat = array_avg($array_lat);
$avg_long = array_avg($array_long);
$coord_data = <<<COORD
var latlng = new google.maps.LatLng({$avg_lat}, {$avg_long});
var myOptions = {
    zoom: 14,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
    myOptions);
COORD;
$coord_data .= "\n";
$a = 0;
$multiple = true;
foreach ($coords as $coord) {
    $statement = $wicker->db->con()->query("SELECT * FROM `aps` WHERE `scan_id` = 1 AND `essid` <> ' ' AND `latitude` = " . $coord['lat'] . " AND `longitude` = " . $coord['long']);