function convertSessions($ss, $distUnit, $timeUnit) { $sessions = array(); foreach ($ss as $sess) { $s = DcUnitConverter::convertSession($sess, $distUnit, $timeUnit); array_push($sessions, $s); } return $sessions; }
{ //make sure session belongs to user $err[0] = "You do not have permission to view this session."; $smarty->assign('errors', $err ); $smarty->display('error.tpl'); } else { $device = $manager->getDevice($s->deviceId); $distUnit = "km"; $timeUnit = "h"; $velUnit = $distUnit . "/" . $timeUnit; $session = DcUnitConverter::convertSession($s, $distUnit, $timeUnit); $smarty->assign('sessId', $session->sessionId); $smarty->assign('deviceName', $device->name); $smarty->assign('lastName', $user->lastName); $smarty->assign('firstName', $user->firstName); $smarty->assign('startTime', $session->startTime); $smarty->assign('endTime', $session->endTime); $smarty->assign('duration', $session->elapsed); $smarty->assign('distUnit', $distUnit); $smarty->assign('velUnit', $velUnit); $smarty->assign('totalDist', $session->distance); $smarty->assign('averageVel', $session->averageVelocity); $smarty->display('viewSession.tpl'); }
{ $fullProfile = false; //no effect yet if (!$fm->isFriend($userId, $usr)) //trying to view someone elses profile { header("Location: profile.php"); } } $manager = new DcWebManager(); $user = $manager->loadUser($usr); $smarty = smartyInit(); $distUnit = "km"; $totalDist = $manager->getDistanceSince($usr, 0); $totalDist = DcUnitConverter::convertDistance($totalDist, $distUnit); $firstSession = $manager->getFirstSession($usr); $firstTime = $firstSession->startTime; $totalTime = $manager->getTotalTimeSince($usr, 0); $totalTime = formatHms(sec2hms($totalTime),1); if (!$firstTime) $firstTime = "n/a"; $smarty->assign('distUnit', $distUnit); $smarty->assign('totalDist', $totalDist); $smarty->assign('firstTime', $firstTime); $smarty->assign('totalTime', $totalTime); $smarty->assign('user', $user); $smarty->display('profile.tpl'); ?>
$day = 1; //set timestamp to the start of the month $startDate = $startStamp; $prevMonth = mktime(0, 0, 0, $month-1, $day, $year); $nextMonth = mktime(0, 0, 0, $month+1, $day, $year); $totalDist = 0; $totalVel = 0; $averageVel = 0; $totalTime = array(); $days = daysInMonth($month, $year); for ($i=0; $i<$days; $i++) { $dayStamp = mktime(0, 0, 0, $month, $day+$i, $year); $ss = $manager->getDaysSessions($uId, $dayStamp); $sessions = DcUnitConverter::convertSessions($ss, $distUnit, $timeUnit); $content = ""; $dayDist = 0; $numSessions = count($sessions); for ($j=0; $j<$numSessions; $j++) { $session = $sessions[$j]; $ts = strtotime($session->startTime); $dateFrmtd = date("g:ia", $ts); $sTime = $session->startTime; $eTime = $session->endTime; $diff = getTimeDifference($sTime, $eTime); $totalTime['hours'] += $diff['hours']; $totalTime['minutes'] += $diff['minutes']; $totalTime['seconds'] += $diff['seconds'];
require("include/graph/jpgraph_line.php"); require("include/main/DcWebManager.inc.php"); require("include/main/DcUnitConverter.inc.php"); $sessId = $_GET['s']; if (!$sessId) { die(); } $manager = new DcWebManager(); $session = $manager->getSession($sessId); //TODO: make sure session belongs to user $session = DcUnitConverter::convertSession($session, "km", "h"); $ydata = $session->velPoints; if (count($ydata) > 1) { // Create the graph. These two calls are always required $graph = new Graph(350,180,"auto"); $graph->SetScale("textlin"); // Create the linear plot $lineplot=new LinePlot($ydata); $lineplot->SetColor("green"); // Add the plot to the graph $graph->Add($lineplot); $title = new Text("Session Velocity"); //$title->SetFont(FF_ARIAL); $graph->title = $title; $graph->yaxis->SetTitle("Velocity (km/h)",'middle');