<?php /* ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); */ session_start(); include('config.php'); include('habit.php'); $error = ""; if(isset($_REQUEST['password']) && md5($_REQUEST['password']) == $password){ $_SESSION['loggedin'] = true; } if( $_SERVER['HTTP_USER_AGENT'] == $password) $_SESSION['loggedin'] = true; function getMyUrl(){ $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST']; $port = $_SERVER['SERVER_PORT']; // Exclude standard ports to prevent redundancy in the URL if (($protocol === 'http' && $port != 80) || ($protocol === 'https' && $port != 443)) { $url = "$protocol://$host"; } else { $url = "$protocol://$host"; } return $url; } ?> <html> <head> <link rel="stylesheet" href="/deps/all.css" > <script type="text/javascript" src="/deps/d3.v3.min.js"></script> <script type="text/javascript" src="/deps/cal-heatmap.min.js"></script> <link rel="stylesheet" href="/deps/cal-heatmap.css" /> <link href="/deps/google-fonts.css" rel="stylesheet"> <link rel="stylesheet" href="/deps/jquery-ui.css"> <link rel="stylesheet" href="/deps/fa.css"> <script src="/deps/jquery-1.12.4.js"></script> <script src="/deps/jquery-ui.js"></script> <link rel="stylesheet" href="habit_ui_style.css" > <script src="habit_ui_script.js"></script> </head> <body> <center> <?php if($error <> ""){echo $error; } ?> <div class="habit-container-wrapper"> <?php $fileContent = file_get_contents($habitlog); if ($fileContent === false) { die("Error reading the file."); } $resultArray = habit_parse_file($fileContent); foreach ($resultArray as $section) { $align = ""; $buttonClass = ""; $buttText = ""; if($section['Category'][0] == "d"){ $type = "day"; $cat = "(daily)"; if($section['Category'][1] == "+"){ $align = "good"; $calCol = "#58e81b"; $title1 = "Streak"; $title2 = "Missed"; $title3 = "Top"; $result1 = habit_get_stat_streak($section['Activity'], $moodlog); $result2 = habit_get_stat_missed($section['Activity'], $moodlog); $result3 = habit_get_stat_top($section['Activity'], $moodlog); } if($section['Category'][1] == "-"){ $align = "bad"; $calCol = "#e81b1b"; $title1 = "Streak"; $title2 = "Total"; $title3 = "Top"; $result1 = habit_get_stat_missed($section['Activity'], $moodlog); $result2 = habit_get_stat_year($section['Activity'], $moodlog); $result3 = habit_get_stat_top_missing($section['Activity'], $moodlog); } $todayCheck = habit_check_daily($section['Activity'], $moodlog); $last10 = habit_last_10_daily($section['Activity'], $moodlog); foreach ($last10 as $key => $value) { $last10_conv[$key] = "neut"; if ($section['Category'][1] == "+" && $value == 1) $last10_conv[$key] = "green"; if ($section['Category'][1] == "+" && $value == 0) $last10_conv[$key] = "red"; if ($section['Category'][1] == "-" && $value == 1) $last10_conv[$key] = "red"; if ($section['Category'][1] == "-" && $value == 0) $last10_conv[$key] = "green"; } if ($todayCheck) { $buttonClass = 'button-'.$align; } } if($section['Category'][0] == "w"){ $multiplier = $section['Category'][1]; $type = "week"; $cat = "(weekly x $multiplier)"; $align = "good"; $title1 = "Streak"; $title2 = "Missed"; $title3 = "Top"; $result1 = habit_get_stat_streak_week($section['Activity'], $multiplier, $moodlog); $result2 = habit_get_stat_missed_week($section['Activity'], $multiplier, $moodlog); $result3 = habit_get_stat_top_week($section['Activity'], $multiplier, $moodlog); $todayCheck = habit_check_daily($section['Activity'], $moodlog); $weekCount = habit_count_weekly($section['Activity'], $moodlog); $last10 = habit_last_10_weekly($section['Activity'], $moodlog); foreach ($last10 as $key => $value) { $last10_conv[$key] = "neut"; if ($value >= $multiplier) $last10_conv[$key] = "green"; if ($value < $multiplier) $last10_conv[$key] = "yellow"; if ($value === "x") $last10_conv[$key] = "neut"; if ($value === 0) $last10_conv[$key] = "red"; } if ($weekCount < $multiplier) { $buttText = $weekCount; $buttonClass = 'button-yellow'; } elseif ($weekCount >= $multiplier) { $buttonClass = 'button-done'; if($todayCheck){ $buttonClass= 'button-good'; $buttText = ""; } } if ($todayCheck) { $buttonClass = 'button-neut'; if ($weekCount >= $multiplier) { $buttonClass = 'button-good'; } } } echo ' <div class="habit-container" id="'.$section['Activity'].'"> <div class="habit-log"> <button class="habit-log-button '.$buttonClass.'" onClick="updateHabit(\''.$section['Activity'].'\')">'.$buttText.'</button> </div> <div class="habit-main"> <div class="'.$align.' habit-title">#'.$section['Activity'].' <div class="habit-timescale">'.$cat.'</div></div> <div class="habit-desc">'.$section['Description'].'</div> </div> <div class="habit-info"> <div class="habit-score"><div class="score-title">'.$title1.'</div><div class="score-result result1">'.$result1.'</div></div> <div class="habit-score"><div class="score-title">'.$title2.'</div><div class="score-result result2">'.$result2.'</div></div> <div class="habit-score"><div class="score-title">'.$title3.'</div><div class="score-result result3">'.$result3.'</div></div> </div> <div class="habit_long_container"> <div class="long_tick lt'.$last10_conv['last_10_1'].'"></div> <div class="long_tick lt'.$last10_conv['last_10_2'].'"></div> <div class="long_tick lt'.$last10_conv['last_10_3'].'"></div> <div class="long_tick lt'.$last10_conv['last_10_4'].'"></div> <div class="long_tick lt'.$last10_conv['last_10_5'].'"></div> <div class="long_tick lt'.$last10_conv['last_10_6'].'"></div> <div class="long_tick lt'.$last10_conv['last_10_7'].'"></div> <div class="long_tick lt'.$last10_conv['last_10_8'].'"></div> <div class="long_tick lt'.$last10_conv['last_10_9'].'"></div> <div class="long_tick lt'.$last10_conv['last_10_10'].'"></div> </div> </div> '; } ?> </div> </div> </center> </body> </html>