docs(docblock): Added default doc blocks and updated code formats

parent a8faa259
......@@ -28,28 +28,27 @@
nxr(1, "...Completed");
}
function cleanUpDownlods($dir, $now)
function cleanUpDownlods( $dir, $now )
{
$files = scandir($dir);
foreach ($files as $file) {
if ($file != "." && $file != "..") {
if (is_file($dir . DIRECTORY_SEPARATOR . $file)) {
if ($now - filemtime($dir . DIRECTORY_SEPARATOR . $file) >= 60 * 20) { // 2 days
foreach ( $files as $file ) {
if ( $file != "." && $file != ".." ) {
if ( is_file($dir . DIRECTORY_SEPARATOR . $file) ) {
if ( $now - filemtime($dir . DIRECTORY_SEPARATOR . $file) >= 60 * 20 ) { // 2 days
nxr(2, "Deleting " . $dir . DIRECTORY_SEPARATOR . $file);
unlink($dir . DIRECTORY_SEPARATOR . $file);
}
} else if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
} else if ( is_dir($dir . DIRECTORY_SEPARATOR . $file) ) {
cleanUpDownlods($dir . DIRECTORY_SEPARATOR . $file, $now);
}
}
}
}
function RemoveEmptySubFolders($path)
function RemoveEmptySubFolders( $path )
{
$empty=true;
foreach (glob($path.DIRECTORY_SEPARATOR."*") as $file)
{
$empty = TRUE;
foreach ( glob($path . DIRECTORY_SEPARATOR . "*") as $file ) {
$empty &= is_dir($file) && RemoveEmptySubFolders($file);
}
return $empty && rmdir($path);
......
......@@ -20,6 +20,10 @@
require_once( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "autoloader.php" );
/**
* Class Config
* @package SkizImport
*/
class Config
{
......@@ -54,14 +58,14 @@
* Main function called to query settings for value. Default value can be provided, if not NULL is returned.
* Values can be queried in the database or limited to config file and 'live' values
*
* @param string $key Setting to query
* @param string $default Default value to return
* @param string $key Setting to query
* @param string $default Default value to return
*
* @return string Setting value, or default as per defined
*/
public function get( $key, $default = NULL )
{
if (array_key_exists($key, $this->settings)) {
if ( array_key_exists($key, $this->settings) ) {
return $this->settings[ $key ];
} else {
return $default;
......@@ -72,8 +76,8 @@
* Set setting value
* Function to store/change setting values. Values can be stored in the database or held in memory.
*
* @param string $key Setting to query
* @param string $value Value to store
* @param string $key Setting to query
* @param string $value Value to store
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*
* @return bool was data stored correctly
......
......@@ -21,12 +21,15 @@
require_once( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "autoloader.php" );
use djchen\OAuth2\Client\Provider\Fitbit;
use GuzzleHttp\Exception\BadResponseException;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Token\AccessToken;
define("FITBIT_COM", "https://api.fitbit.com");
/**
* Class SkizImport
* @package SkizImport
*/
class SkizImport
{
/**
......@@ -39,38 +42,19 @@
*/
protected $fitbitLibrary;
/**
* @var
*/
private $activitId;
/**
* SkizImport constructor.
*/
public function __construct( )
public function __construct()
{
$this->setSettings(new Config());
}
/**
* @return \SkizImport\Config
*/
public function getSettings()
{
return $this->settings;
}
/**
* Get settings from config class
*
* @param string $key Settings key to return
* @param null $default Default value, if nothing already held in settings
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*
* @return string
*/
public function getSetting( $key, $default = NULL )
{
return $this->getSettings()->get($key, $default);
}
/**
* @param \SkizImport\Config $settings
*/
......@@ -79,9 +63,14 @@
$this->settings = $settings;
}
public function pullFitbit( $path, $returnObject = false )
/**
* @param $path
* @param bool $returnObject
* @return mixed|null
*/
public function pullFitbit( $path, $returnObject = FALSE )
{
if (is_null($this->fitbitLibrary)) {
if ( is_null($this->fitbitLibrary) ) {
if ( $_COOKIE[ '_nx_skiz_usr' ] == $this->getSetting("ownerFuid") ) {
// nxr(0, "Private Keys Used");
$personal = "_personal";
......@@ -107,8 +96,8 @@
try {
$response = $this->fitbitLibrary->getParsedResponse($request);
} catch (IdentityProviderException $e) {
return null;
} catch ( IdentityProviderException $e ) {
return NULL;
}
if ( $returnObject ) {
......@@ -118,13 +107,35 @@
return $response;
}
/**
* Get settings from config class
*
* @param string $key Settings key to return
* @param null $default Default value, if nothing already held in settings
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*
* @return string
*/
public function getSetting( $key, $default = NULL )
{
return $this->getSettings()->get($key, $default);
}
/**
* @return \SkizImport\Config
*/
public function getSettings()
{
return $this->settings;
}
/**
* @SuppressWarnings(PHPMD.ExitExpression)
* @return AccessToken
*/
private function getAccessToken()
{
$userArray = json_decode($_SESSION['accessToken'], true);
$userArray = json_decode($_SESSION[ 'accessToken' ], TRUE);
if ( is_array($userArray) ) {
$accessToken = new AccessToken([
'access_token' => $userArray[ 'access_token' ],
......@@ -150,31 +161,46 @@
}
}
public function setActivitId( $key, $id )
/**
* @param $string
* @return mixed|null
*/
public function getActivitId( $string )
{
if (is_null($this->activitId)) {
if ( is_null($this->activitId) ) {
$this->activitId = [];
}
$this->activitId[$key] = $id;
if ( array_key_exists($string, $this->activitId) ) {
return $this->activitId[ $string ];
} else {
return NULL;
}
}
public function getActivitId( $string )
/**
* @param $key
* @param $id
*/
public function setActivitId( $key, $id )
{
if (is_null($this->activitId)) {
if ( is_null($this->activitId) ) {
$this->activitId = [];
}
if ( array_key_exists($string, $this->activitId) ) {
return $this->activitId[$string];
} else {
return null;
}
$this->activitId[ $key ] = $id;
}
/**
* @param $path
* @param $pushObject
* @param bool $returnObject
* @param bool $parseResponse
* @return array|mixed|\Psr\Http\Message\ResponseInterface
*/
public function pushFitbit( $path, $pushObject, $returnObject = FALSE, $parseResponse = FALSE )
{
if (is_null($this->fitbitLibrary)) {
if ( is_null($this->fitbitLibrary) ) {
if ( $_COOKIE[ '_nx_skiz_usr' ] == $this->getSetting("ownerFuid") ) {
// nxr(0, "Private Keys Used");
$personal = "_personal";
......
This diff is collapsed.
This diff is collapsed.
......@@ -23,7 +23,7 @@
$appClass = new SkizImport\SkizImport();
/** @var SkizImport\Upload\Receive $receiver */
$receiver = unserialize($_SESSION['SkizImport\Upload\Receive']);
$receiver = unserialize($_SESSION[ 'SkizImport\Upload\Receive' ]);
date_default_timezone_set($receiver->getTimezoneName());
$receiver->getStatsClass()->recordNewTimeZone($receiver->getTimezoneName());
......@@ -37,8 +37,8 @@
nxr(1, "Processing runs");
foreach ( $receiver->getSkiRuns() as $index => $skiRun ) {
nxr(2, "Run $index");
$searchActivity = $skiRun['ACTIVITY_FITBIT'];
if (is_null($appClass->getActivitId($searchActivity))) {
$searchActivity = $skiRun[ 'ACTIVITY_FITBIT' ];
if ( is_null($appClass->getActivitId($searchActivity)) ) {
foreach ( $fitbitActivities->categories as $userActivity ) {
if ( $userActivity->name == "Sports and Workouts" ) {
if ( !empty($userActivity->subCategories) ) {
......@@ -56,22 +56,22 @@
}
}
$durationMillis = (strtotime($skiRun['END_ZONE']) - strtotime($skiRun['START_ZONE']));
$durationMillis = ( strtotime($skiRun[ 'END_ZONE' ]) - strtotime($skiRun[ 'START_ZONE' ]) );
$receiver->getStatsClass()->recordRunDuration($durationMillis);
$startTime = date("H:i:s", strtotime($skiRun['START_ZONE']));
$date = date("Y-m-d", strtotime($skiRun['START_ZONE']));
$startTime = date("H:i:s", strtotime($skiRun[ 'START_ZONE' ]));
$date = date("Y-m-d", strtotime($skiRun[ 'START_ZONE' ]));
$postArray = [
'activityId' => $appClass->getActivitId($searchActivity),
'startTime' => $startTime,
'activityId' => $appClass->getActivitId($searchActivity),
'startTime' => $startTime,
'durationMillis' => $durationMillis * 1000,
'date' => $date
'date' => $date
];
nxr(3, "Sending activity to Fitbit");
$apiReturnActivity = $appClass->pushFitbit('user/-/activities.json', $postArray, TRUE, TRUE);
if (strtotime((string)$apiReturnActivity->activityLog->lastModified) < strtotime("-10 minutes")) {
if ( strtotime((string)$apiReturnActivity->activityLog->lastModified) < strtotime("-10 minutes") ) {
$receiver->getStatsClass()->recordUpdatedRun();
} else {
$receiver->getStatsClass()->recordNewRun();
......@@ -79,15 +79,15 @@
$apiReturnActivity = json_encode($apiReturnActivity);
if ($receiver->getResourceOwner('encodedId') == $appClass->getSetting("ownerFuid")) {
if ( $receiver->getResourceOwner('encodedId') == $appClass->getSetting("ownerFuid") ) {
nxr(3, "Downloading Heart Rate Data");
$apiReturnHeartRate = json_encode($appClass->pullFitbit('user/-/activities/heart/date/'.date("Y-m-d", strtotime($skiRun['START_ZONE'])).'/1d/1sec/time/'.date("H:i", strtotime($skiRun['START_ZONE'])).'/'.date("H:i", strtotime($skiRun['END_ZONE'])).'.json', TRUE));
$apiReturnHeartRate = json_encode($appClass->pullFitbit('user/-/activities/heart/date/' . date("Y-m-d", strtotime($skiRun[ 'START_ZONE' ])) . '/1d/1sec/time/' . date("H:i", strtotime($skiRun[ 'START_ZONE' ])) . '/' . date("H:i", strtotime($skiRun[ 'END_ZONE' ])) . '.json', TRUE));
} else {
nxr(3, "Skipping Heart Rate Data");
$apiReturnHeartRate = NULL;
}
if (!is_null($apiReturnHeartRate)) {
if ( !is_null($apiReturnHeartRate) ) {
$receiver->getStatsClass()->recordHeartRateAvailable();
}
......@@ -104,7 +104,7 @@
$receiver->cleanUp();
$_SESSION['SkizImport\Upload\Receive'] = serialize($receiver);
$_SESSION[ 'SkizImport\Upload\Receive' ] = serialize($receiver);
header("Location: /upload/finished");
die();
\ No newline at end of file
......@@ -37,11 +37,11 @@
*/
function nxr( $indentation, $msg, $includeDate = TRUE, $newline = TRUE, $echoLine = TRUE )
{
if ($indentation >= 0) {
if ( $indentation >= 0 ) {
$_SESSION[ 'indentation' ] = $indentation;
} else if ($indentation < -1) {
$indentation = $_SESSION[ 'indentation' ] + (($indentation * -1) - 1);
} else if ($indentation == -1) {
} else if ( $indentation < -1 ) {
$indentation = $_SESSION[ 'indentation' ] + ( ( $indentation * -1 ) - 1 );
} else if ( $indentation == -1 ) {
$indentation = $_SESSION[ 'indentation' ];
}
......@@ -97,7 +97,8 @@
}
}
function getNameSpace() {
function getNameSpace()
{
if ( array_key_exists("REDIRECT_URL", $_SERVER) ) {
$inputURL = $_SERVER[ 'REDIRECT_URL' ];
} else {
......@@ -123,13 +124,14 @@
/**
* @return bool
*/
function isloggedIn() {
function isloggedIn()
{
$appClass = new SkizImport\SkizImport();
if (!filter_input(INPUT_COOKIE, '_nx_skiz', FILTER_SANITIZE_STRING) ||
if ( !filter_input(INPUT_COOKIE, '_nx_skiz', FILTER_SANITIZE_STRING) ||
!filter_input(INPUT_COOKIE, '_nx_skiz_usr', FILTER_SANITIZE_STRING) ||
filter_input(INPUT_COOKIE, '_nx_skiz', FILTER_SANITIZE_STRING) !=
gen_cookie_hash( $appClass->getSetting("salt"), filter_input(INPUT_COOKIE, '_nx_skiz_usr', FILTER_SANITIZE_STRING) ) ) {
gen_cookie_hash($appClass->getSetting("salt"), filter_input(INPUT_COOKIE, '_nx_skiz_usr', FILTER_SANITIZE_STRING)) ) {
return FALSE;
} else {
return TRUE;
......@@ -149,6 +151,6 @@
*/
function gen_cookie_hash( $salt, $fuid )
{
return hash("sha256", $salt . $fuid . $_SERVER[ 'SERVER_NAME' ] . $_SERVER[ 'SERVER_ADDR' ] );
return hash("sha256", $salt . $fuid . $_SERVER[ 'SERVER_NAME' ] . $_SERVER[ 'SERVER_ADDR' ]);
}
}
......@@ -45,49 +45,79 @@
</head>
<body class="app flex-row align-items-center">
<span class="d-md-down-none"><a href="https://nxfifteen.me.uk/gitlab/rocks/skiz" class="github-corner" aria-label="View source on Gitlab" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style></span>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-10">
<div class="card-group mb-0">
<div class="card card-inverse card-primary py-5">
<div class="card-block text-center">
<div>
<h2>Sign in with Fitbit</h2>
<p>
Use this service to convert your <strong><a style="color: #FFF" href="https://www.corecoders.com/ski-tracks-app/" target="_blank">SkiTracks</a></strong>
SKIZ export files into <strong><a style="color: #FFF" href="https://www.fitbit.com" target="_blank">Fitbit</a></strong> activity
</p>
<a href="./register.php" class="btn btn-primary active mt-3" title="Sign in using Fitbit">Sign in Now!</a>
<?php /*<a href="./private.php" class="btn btn-danger active mt-3" title="Owners sign in here, this will not work for anyone else due to Fitbit OAuth rules">Site owner sign in here!</a>*/ ?>
</div>
<span class="d-md-down-none"><a href="https://nxfifteen.me.uk/gitlab/rocks/skiz" class="github-corner"
aria-label="View source on Gitlab" target="_blank"><svg width="80" height="80"
viewBox="0 0 250 250"
style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;"
aria-hidden="true"><path
d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm {animation : octocat-wave 560ms ease-in-out}
@keyframes octocat-wave {
0%, 100% {transform : rotate(0)}
20%, 60% {transform : rotate(-25deg)}
40%, 80% {transform : rotate(10deg)}
}
@media (max-width : 500px) {
.github-corner:hover .octo-arm {animation : none}
.github-corner .octo-arm {animation : octocat-wave 560ms ease-in-out}
}</style></span>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-10">
<div class="card-group mb-0">
<div class="card card-inverse card-primary py-5">
<div class="card-block text-center">
<div>
<h2>Sign in with Fitbit</h2>
<p>
Use this service to convert your <strong><a style="color: #FFF"
href="https://www.corecoders.com/ski-tracks-app/"
target="_blank">SkiTracks</a></strong>
SKIZ export files into <strong><a style="color: #FFF" href="https://www.fitbit.com"
target="_blank">Fitbit</a></strong> activity
</p>
<a href="./register.php" class="btn btn-primary active mt-3" title="Sign in using Fitbit">Sign
in Now!</a>
<?php /*<a href="./private.php" class="btn btn-danger active mt-3" title="Owners sign in here, this will not work for anyone else due to Fitbit OAuth rules">Site owner sign in here!</a>*/ ?>
</div>
</div>
<div class="card card-inverse card-info py-5 d-md-down-none">
<div class="card-block text-center">
<div>
<h2>Proudly Open Source</h2>
<p>This is an <strong><a style="color: #FFF" href="https://nxfifteen.me.uk/rocks">NxFIFTEEN Rocks</a></strong> project. The service is offered as a free service to anyone who wants to use it and is a freely available open source project</p>
<a href="https://nxfifteen.me.uk/gitlab/rocks/skiz" class="btn btn-primary active mt-3">View source on Gitlab</a>
<a href="https://nxfifteen.me.uk/gitlab/rocks/skiz/wikis/privacy-policy" class="btn btn-primary active mt-3">Privacy Policy</a>
</div>
</div>
<div class="card card-inverse card-info py-5 d-md-down-none">
<div class="card-block text-center">
<div>
<h2>Proudly Open Source</h2>
<p>This is an <strong><a style="color: #FFF" href="https://nxfifteen.me.uk/rocks">NxFIFTEEN
Rocks</a></strong> project. The service is offered as a free service to anyone
who wants to use it and is a freely available open source project</p>
<a href="https://nxfifteen.me.uk/gitlab/rocks/skiz" class="btn btn-primary active mt-3">View
source on Gitlab</a>
<a href="https://nxfifteen.me.uk/gitlab/rocks/skiz/wikis/privacy-policy"
class="btn btn-primary active mt-3">Privacy Policy</a>
</div>
</div>
</div>
</div>
</div>
<footer class="app-footer">
<strong>Cookie Consent</strong> This site requires the use of cookies to improve your experience. <a href="https://nxfifteen.me.uk/gitlab/rocks/skiz/wikis/privacy-policy">Read more</a>.
</footer>
</div>
<!-- Bootstrap and necessary plugins -->
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/tether/dist/js/tether.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<footer class="app-footer">
<strong>Cookie Consent</strong> This site requires the use of cookies to improve your experience. <a
href="https://nxfifteen.me.uk/gitlab/rocks/skiz/wikis/privacy-policy">Read more</a>.
</footer>
</div>
<!-- Bootstrap and necessary plugins -->
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/tether/dist/js/tether.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
......
......@@ -16,7 +16,7 @@
* @license https://license.nxfifteen.rocks/gpl-3/2018/ GNU GPLv3
*/
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "autoloader.php");
require_once( dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "autoloader.php" );
setcookie('_nx_skiz_usr', '', time() - 60 * 60 * 24 * 365, '/', $_SERVER[ 'SERVER_NAME' ]);
setcookie('_nx_skiz', '', time() - 60 * 60 * 24 * 365, '/', $_SERVER[ 'SERVER_NAME' ]);
......
......@@ -16,16 +16,15 @@
* @license https://license.nxfifteen.rocks/gpl-3/2018/ GNU GPLv3
*/
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use SkizImport\Stats;
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "autoloader.php");
require_once( dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "autoloader.php" );
// Setup the App
$appClass = new SkizImport\SkizImport();
$stateGet = filter_input(INPUT_GET, 'state', FILTER_SANITIZE_STRING);
if (empty($stateGet) || $stateGet !== $_SESSION[ 'oauth2state' ] ) {
if ( empty($stateGet) || $stateGet !== $_SESSION[ 'oauth2state' ] ) {
// Authorise a user against Fitbit's OAuth AIP
nxr(0, "New PRIVATE user registration started");
......@@ -69,15 +68,15 @@
// Find out who the new OAuth keys belong too
$resourceOwner = $helper->getResourceOwner($accessToken);
$_SESSION['accessToken'] = json_encode($accessToken);
$_SESSION['resourceOwner'] = json_encode($resourceOwner->toArray());
$_SESSION[ 'accessToken' ] = json_encode($accessToken);
$_SESSION[ 'resourceOwner' ] = json_encode($resourceOwner->toArray());
setcookie(
'_nx_skiz_usr',
$resourceOwner->getId(),
0,
'/',
filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_STRING),true, false
filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_STRING), TRUE, FALSE
);
setcookie(
......@@ -85,7 +84,7 @@
gen_cookie_hash($appClass->getSetting("salt"), $resourceOwner->getId()),
0,
'/',
filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_STRING),true, false
filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_STRING), TRUE, FALSE
);
$stats = new Stats();
......
......@@ -16,16 +16,15 @@
* @license https://license.nxfifteen.rocks/gpl-3/2018/ GNU GPLv3
*/
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use SkizImport\Stats;
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "autoloader.php");
require_once( dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "autoloader.php" );
// Setup the App
$appClass = new SkizImport\SkizImport();
$stateGet = filter_input(INPUT_GET, 'state', FILTER_SANITIZE_STRING);
if (empty($stateGet) || $stateGet !== $_SESSION[ 'oauth2state' ] ) {
if ( empty($stateGet) || $stateGet !== $_SESSION[ 'oauth2state' ] ) {
// Authorise a user against Fitbit's OAuth AIP
nxr(0, "New GUEST user registration started");
......@@ -69,15 +68,15 @@
// Find out who the new OAuth keys belong too
$resourceOwner = $helper->getResourceOwner($accessToken);
$_SESSION['accessToken'] = json_encode($accessToken);
$_SESSION['resourceOwner'] = json_encode($resourceOwner->toArray());
$_SESSION[ 'accessToken' ] = json_encode($accessToken);
$_SESSION[ 'resourceOwner' ] = json_encode($resourceOwner->toArray());
setcookie(
'_nx_skiz_usr',
$resourceOwner->getId(),
0,
'/',
filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_STRING),true, false
filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_STRING), TRUE, FALSE
);
setcookie(
......@@ -85,7 +84,7 @@
gen_cookie_hash($appClass->getSetting("salt"), $resourceOwner->getId()),
0,
'/',
filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_STRING),true, false
filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_STRING), TRUE, FALSE
);
$stats = new Stats();
......
......@@ -20,6 +20,6 @@
echo '<ol class="breadcrumb">';
foreach ( $breadcrums as $breadcrum ) {
echo '<li class="breadcrumb-item">'.ucwords($breadcrum).'</li>';
echo '<li class="breadcrumb-item">' . ucwords($breadcrum) . '</li>';
}
echo '</ol>';
......@@ -18,9 +18,11 @@
?>
<ul class="nav navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle nav-link" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
<span class="d-md-down-none"><?php echo $resourceOwner['fullName'] ;?></span>
<img src="<?php echo $resourceOwner['avatar150'] ;?>" class="img-avatar" alt="<?php echo $resourceOwner['displayName'] ;?>">
<a class="nav-link dropdown-toggle nav-link" data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
aria-expanded="false">
<span class="d-md-down-none"><?php echo $resourceOwner[ 'fullName' ]; ?></span>
<img src="<?php echo $resourceOwner[ 'avatar150' ]; ?>" class="img-avatar"
alt="<?php echo $resourceOwner[ 'displayName' ]; ?>">
</a>
<div class="dropdown-menu dropdown-menu-right">
<div class="dropdown-header text-center">
......
......@@ -91,10 +91,16 @@
<div>
<h2 class="text-center">We've Processed..</h2>
<ul>
<li><?php echo $siteStats->getCreatedFitbitActivities(); ?> new Fitbit activities for <?php echo $siteStats->getUniqueUsers(); ?> users</li>
<li>Produced a further <?php echo $siteStats->getUpdatedFitbitActivities(); ?> TCX files</li>
<li><?php echo $siteStats->getCreatedFitbitActivities(); ?> new Fitbit activities
for <?php echo $siteStats->getUniqueUsers(); ?> users
</li>
<li>Produced a further <?php echo $siteStats->getUpdatedFitbitActivities(); ?> TCX
files
</li>
<li>Received <?php echo $siteStats->getTotalUploadedFiles(); ?> worth of SKIZ files</li>
<li>Provided <?php echo $siteStats->getTotalDownloadedFiles(); ?> with of zip'd TCX file</li>
<li>Provided <?php echo $siteStats->getTotalDownloadedFiles(); ?> with of zip'd TCX
file
</li>
</ul>
</div>
</div>
......@@ -104,7 +110,9 @@
<div>
<h2 class="text-center">&amp;</h2>
<ul>
<li><?php echo $siteStats->getSkiTracksRuns(); ?> SkiTrack runs over <?php echo $siteStats->getSkiTracksSession(); ?> session</li>
<li><?php echo $siteStats->getSkiTracksRuns(); ?> SkiTrack runs
over <?php echo $siteStats->getSkiTracksSession(); ?> session
</li>
<li><?php echo $siteStats->getTotalSkiTime(); ?> of slope time</li>
<li>Covering <?php echo $siteStats->getTotalSkiDistance(); ?></li>
</ul>
......
......@@ -32,7 +32,8 @@
<div class="col-12">
<div class="form-group">