function register_inputs($userid, $nodeid, $datapairs, $time) { //-------------------------------------------------------------------------------------------------------------- // 2) Register incoming inputs //-------------------------------------------------------------------------------------------------------------- $inputs = array(); foreach ($datapairs as $datapair) { $datapair = explode(":", $datapair); $name = preg_replace('/[^\\w\\s-.]/', '', $datapair[0]); // filter out all except for alphanumeric white space and dash $value = floatval($datapair[1]); if ($nodeid) { $name = "node" . $nodeid . "_" . $name; } $id = get_input_id($userid, $name); // If input does not exist this return's a zero if ($id == 0) { $id = create_input_timevalue($userid, $name, $nodeid, $time, $value); // Create input if it does not exist // auto_configure_inputs($userid,$id,$name); } else { $inputs[] = array($id, $time, $value); set_input_timevalue($id, $time, $value); // Set time and value if it does } } return $inputs; }
function save_to_input($arg, $time, $value) { $name = $arg; $userid = $_SESSION['userid']; $id = get_input_id($userid, $name); // If input does not exist this return's a zero if ($id == 0) { create_input_timevalue($userid, $name, $time, $value); // Create input if it does not exist } else { set_input_timevalue($id, $time, $value); // Set time and value if it does } return $value; }