From 4e2f1a28663bb7037cddfb7f8e5bd0339edb44af Mon Sep 17 00:00:00 2001 From: jonsowman Date: Sun, 30 May 2010 12:29:29 +0100 Subject: [PATCH] Timestamp is now part of , default ascent rate 5m/s --- predict/ajax.php | 18 ++++++------------ predict/includes/functions.inc.php | 11 ++++++++++- predict/index.php | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/predict/ajax.php b/predict/ajax.php index 08ef904..9bd9e1d 100644 --- a/predict/ajax.php +++ b/predict/ajax.php @@ -33,9 +33,12 @@ case "submitForm": if ( isset($_POST['submit'])) { // form was submitted, let's run a pred! // first, make a model from the form data - $pred_model = createModel($_POST); + if ( !$pred_model = createModel($_POST)) { + echo false; + break; + } - // verify the model here + // verify the model if ( !verifyModel($pred_model, $software_available) ) { echo false; break; @@ -44,18 +47,9 @@ case "submitForm": // make a sha1 hash of the model for uuid $pred_model['uuid'] = makesha1hash($pred_model); - // make a timestamp of the form data - $pred_model['timestamp'] = mktime($_pred_model['hour'], $_pred_model['min'], $_pred_model['sec'], (int)$_pred_model['month'] + 1, $_pred_model['day'], (int)$_pred_model['year'] - 2000); - - // and check that it's within range - if ($pred_model['timestamp'] > (time() + 180*3600)) { - echo false; - break; - } - // now we have a populated model, run the predictor runPred($pred_model); - echo true . "|" . $pred_model['uuid']; + echo true . "|" . $pred_model['uuid'] . "|" . $pred_model['timestamp']; } else { echo "The form submit function was called without any data"; echo false; diff --git a/predict/includes/functions.inc.php b/predict/includes/functions.inc.php index e60be20..048080f 100644 --- a/predict/includes/functions.inc.php +++ b/predict/includes/functions.inc.php @@ -9,7 +9,7 @@ function createModel($post_array) { $pred_model = array(); // first, populate the prediction model - $pred_model['hour'] = $post_array['hour']; + $pred_model['hour'] = $post_array['hour'] + 1; //adjust for GMT $pred_model['min'] = $post_array['min']; $pred_model['sec'] = $post_array['sec']; @@ -29,6 +29,15 @@ function createModel($post_array) { $pred_model['software'] = $post_array['software']; + // make a timestamp of the form data + $pred_model['timestamp'] = mktime($pred_model['hour'], $pred_model['min'], $pred_model['sec'], (int)$pred_model['month'], $pred_model['day'], (int)$pred_model['year'] - 2000); + + // and check that it's within range + if ($pred_model['timestamp'] > (time() + 180*3600)) { + return false; + break; + } + return $pred_model; } diff --git a/predict/index.php b/predict/index.php index 8ae8a05..61f3148 100644 --- a/predict/index.php +++ b/predict/index.php @@ -271,7 +271,7 @@ function parseCSV(lines) { Ascent Rate (m/s): - + Descent Rate (sea level m/s):