Skip to content

Instantly share code, notes, and snippets.

@zaigham
Created June 6, 2012 21:03
Show Gist options
  • Save zaigham/2884745 to your computer and use it in GitHub Desktop.
Save zaigham/2884745 to your computer and use it in GitHub Desktop.
<?php
/*echo '<pre>';
print_r($_GET);
echo '</pre>';*/
if (empty($_GET['api'])) {
return 'Empty Request. No data saved.';
}
else {
$db_water_flow = filter_var($_GET[waterFlow], FILTER_SANITIZE_STRING);
$db_water_level = filter_var($_GET[waterLevel], FILTER_SANITIZE_STRING);
$db_water_location = filter_var($_GET[location], FILTER_SANITIZE_STRING);
}
/* Add fmsData package and throw an error if fail */
$path = MODX_CORE_PATH . 'components/fmsData/';
$result = $modx->addPackage('fmsData',$path . 'model/','fms_');
/* Create new posting object & check if object was
created or else throw an error. Name of class in
schema is the name of the Object */
$fmsEntry = $modx->newObject('FmsData');
$db_timestamp = date('r');
$fmsEntry->set('time_stamp', $db_timestamp);
$fmsEntry->set('water_location', $db_water_location);
$fmsEntry->set('water_flow', $db_water_flow);
$fmsEntry->set('water_level', $db_water_level);
/* Save data from form and throw out errors if fails */
if (!$fmsEntry->save()) {
$output='Failed to save data.';
}
else {
$output = 'Data Saved Successfully. ' . $db_timestamp;
}
return $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment