function _validateFields($password) { //Check Perms first $rider = new RDrider($this->conn, $this->units); if (!$rider->checkPerms($this->f_riderID, $password)) { return "Invalid password"; } //Allow for length w/o hours if (preg_match('/^[^:]*:[^:]*$/', $this->f_time)) { $this->f_time = "00:" . $this->f_time; } return ""; }
$ride->f_riderID = (int) $HTTP_POST_VARS["rider"]; $ride->f_date = unFixQuotes($HTTP_POST_VARS["date"]) . " " . unFixQuotes($HTTP_POST_VARS["hour"]); $ride->f_distance = (double) $HTTP_POST_VARS["distance"]; $ride->f_maxSpeed = (double) $HTTP_POST_VARS["maxSpeed"]; $ride->f_time = unFixQuotes($HTTP_POST_VARS["time"]); $ride->f_locationID = (int) $HTTP_POST_VARS["location"]; $ride->f_temperature = (double) $HTTP_POST_VARS["temperature"]; $ride->f_wind = unFixQuotes($HTTP_POST_VARS["wind"]); $ride->f_sky = unFixQuotes($HTTP_POST_VARS["sky"]); $ride->f_effortLevel = unFixQuotes($HTTP_POST_VARS["effort"]); $ride->f_bikeID = (int) $HTTP_POST_VARS["bike"]; $ride->f_notes = unFixQuotes($HTTP_POST_VARS["notes"]); //Check for password $fixedPassword = unFixQuotes($HTTP_POST_VARS["password"]); $riderTest = new RDrider(DBConnect(), $units); if (!$riderTest->checkPerms($ride->f_riderID, $fixedPassword)) { $errMsg = "Invalid Password"; } if (!$errMsg && $HTTP_POST_VARS["bike"] == 0) { //New Bike, create it $newBike = new RDbike(DBConnect()); $newBike->f_bike = unFixQuotes($HTTP_POST_VARS["newBike"]); $newBike->f_computerSetting = (int) $HTTP_POST_VARS["computerSetting"]; $newBike->f_riderID = $ride->f_riderID; $errMsg = $newBike->insertNew(); $ride->f_bikeID = $newBike->f_bikeID; } if (!$errMsg && $HTTP_POST_VARS["location"] == 0) { $newLocation = new RDlocation(DBConnect()); $newLocation->f_location = unFixQuotes($HTTP_POST_VARS["newLocation"]); $newLocation->f_description = unFixQuotes($HTTP_POST_VARS["newDescription"]);
function _validateFields($password) { //Check Perms first $rider = new RDrider($this->conn, $this->units); if (!$rider->checkPerms($this->f_riderID, $password)) { return "Invalid password"; } //Allow for length w/o hours if (preg_match('/^([^:]*):([^:]*)$/', $this->f_time, $matches)) { //Do a computation to try and decide if they //left off hours or seconds. Assume hours //left off and see if average speed is reasonable $seconds = $matches[2] + $matches[1] * 60; $avg = $this->f_distance * 3600.0 / $seconds; if ($avg > C_MAX_SPEED) { $this->f_time = $this->f_time . ":00"; } else { $this->f_time = "00:" . $this->f_time; } } return ""; }
function update($password) { //Check Perms first $rider = new RDrider($this->conn, $this->units); if (!$rider->checkPerms($this->f_riderID, $password)) { return "Invalid password"; } $result = normalQuery($this->conn, "update rides set " . "date=\"" . addSlashes($this->f_date) . "\", distance=" . $this->units->settingToKM((double) $this->f_distance) . ", maxSpeed=" . $this->units->settingToKM((double) $this->f_maxSpeed) . ", time=\"" . addSlashes($this->f_time) . "\", locationID=" . (int) $this->f_locationID . ", temperature=" . $this->units->settingToCelsius((double) $this->f_temperature) . ", wind=\"" . addSlashes($this->f_wind) . "\", sky=\"" . addSlashes($this->f_sky) . "\", effortLevel=\"" . addSlashes($this->f_effortLevel) . "\", bikeID=" . (int) $this->f_bikeID . ", notes=\"" . addSlashes($this->f_notes) . "\" where rideID=" . (int) $this->f_rideID . " and riderID=" . (int) $this->f_riderID); $rows = mysql_affected_rows($this->conn); if (!$rows) { return "Error updating, perhaps rider changed?"; } }