Example #1
0
                            }
                        }
                        $file = $username . "_sleeps.xml";
                        if (substr($file, -4) == ".xml") {
                            $doc = new DOMDocument();
                            if ($doc->load($file)) {
                                $sleeps = $doc->getElementsByTagName("sleep");
                                foreach ($sleeps as $sleep) {
                                    $usernames = $sleep->getElementsByTagName("username");
                                    $username = $usernames->item(0)->nodeValue;
                                    $createdays = $sleep->getElementsByTagName("createday");
                                    $createday = $createdays->item(0)->nodeValue;
                                    $deeps = $sleep->getElementsByTagName("deep");
                                    $deep = $deeps->item(0)->nodeValue;
                                    $shallows = $sleep->getElementsByTagName("shallow");
                                    $shallow = $shallows->item(0)->nodeValue;
                                    $clears = $sleep->getElementsByTagName("clear");
                                    $clear = $clears->item(0)->nodeValue;
                                    $totals = $sleep->getElementsByTagName("total");
                                    $total = $totals->item(0)->nodeValue;
                                    $res = HealthService::addSleep($username, $createday, $deep, $shallow, $clear, $total);
                                }
                            }
                        }
                        header("Location: http://localhost/healthyone/view/health.php?isLoad=1");
                    }
                }
            }
        }
    }
}
Example #2
0
    if (isset($_GET["date"])) {
        if ($_GET['date'] != "") {
            $res = HealthService::findExerciseByDate($username, $_GET['date']);
            if ($item = $res->fetchArray(SQLITE3_ASSOC)) {
                $runTime = $item['RUNTIME'];
                $distance = $item['DISTANCE'];
                $heat = $item['HEAT'];
            } else {
                $runTime = 0;
                $distance = 0;
                $heat = 0;
            }
        }
    }
}
$res = HealthService::findAllExercise($username);
if ($item = $res->fetchArray(SQLITE3_ASSOC)) {
    $sumRunTime = $item['RUNTIME'];
    $sumDistance = $item['DISTANCE'];
    $sumHeat = $item['HEAT'];
}
if ($sumRunTime == null) {
    $sumRunTime = 0;
}
if ($sumDistance == null) {
    $sumDistance = 0;
}
if ($sumHeat == null) {
    $sumHeat = 0;
}
?>
Example #3
0
$height = 0;
$weight = 0;
$bmi = 0;
$perfectWeight = 0;
$condition = "";
require '../model/healthService.class.php';
$res = HealthService::findHW($username);
if ($item = $res->fetchArray(SQLITE3_ASSOC)) {
    $height = $item['HEIGHT'];
    $weight = $item['WEIGHT'];
}
$perfectWeight = round(22.0 * $height * $height / 10000, 1);
if ($height > 0) {
    $bmi = round($weight / ($height * $height) * 10000.0, 1);
}
$weightChange = HealthService::weightChange($username);
if ($bmi != 0) {
    if ($bmi < 18.5) {
        $condition = "(偏轻)";
    } elseif ($bmi >= 18.5 && $bmi < 24) {
        $condition = "(健康)";
    } elseif ($bmi >= 24 && $bmi < 28) {
        $condition = "(超重)";
    } elseif ($bmi >= 28) {
        $condition = "(肥胖)";
    }
}
?>
<div class="wraper">
    <div class="nav">
        <ul>
Example #4
0
$deep = 0;
$shallow = 0;
$clear = 0;
$rate = 0;
require '../model/healthService.class.php';
$res = HealthService::findSleep($username);
if ($item = $res->fetchArray(SQLITE3_ASSOC)) {
    $total = $item['TOTAL'];
    $deep = $item['DEEP'];
    $shallow = $item['SHALLOW'];
    $clear = $item['CLEAR'];
}
if (is_array($_GET) && count($_GET) > 0) {
    if (isset($_GET["date"])) {
        if ($_GET['date'] != "") {
            $res = HealthService::findSleepByDate($username, $_GET['date']);
            if ($item = $res->fetchArray(SQLITE3_ASSOC)) {
                $total = $item['TOTAL'];
                $deep = $item['DEEP'];
                $shallow = $item['SHALLOW'];
                $clear = $item['CLEAR'];
            }
        }
    }
}
if ($total > 0) {
    $rate = round(($deep + $shallow) * 1.0 / $total, 2) * 100;
}
?>
<div class="wraper">
    <div class="nav">