Compare commits
3 Commits
3385954624
...
968964e3fe
| Author | SHA1 | Date | |
|---|---|---|---|
| 968964e3fe | |||
| d41519ba91 | |||
| 513017d3cb |
@@ -1000,3 +1000,31 @@ function templateselect($techid, $operation)
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
function fix_date($datestring)
|
||||
{
|
||||
// accepts a string as an argument
|
||||
// returns a valid date string in the format YYYY-MM-DD
|
||||
// if input string is not a valid date, return the current date
|
||||
global $db, $today;
|
||||
|
||||
if (!$datestring) $datestring = $today;
|
||||
$datepatt = '/^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/';
|
||||
if (!preg_match($datepatt,$datestring)) $datestring = $today;
|
||||
$datestring = mysqli_real_escape_string($db, $datestring);
|
||||
return $datestring;
|
||||
}
|
||||
|
||||
function fix_time($timestring)
|
||||
{
|
||||
// accepts a string as an argument
|
||||
// returns a valid time string in the format HH:MM:SS
|
||||
// if input string is not a valid time, return the current time
|
||||
global $db, $now;
|
||||
|
||||
if (!$timestring) $timestring = $now;
|
||||
$timepatt = '/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/';
|
||||
if (!preg_match($timepatt,$timestring)) $timestring = $now;
|
||||
$timestring = mysqli_real_escape_string($db, $timestring);
|
||||
return $timestring;
|
||||
}
|
||||
|
||||
@@ -96,10 +96,9 @@ if ($add) {
|
||||
// add the entry if submit is pressed
|
||||
if ($note) {
|
||||
// sanitize and fix blank date and time
|
||||
$date = mysqli_real_escape_string($db, $date);
|
||||
$time = mysqli_real_escape_string($db, $time);
|
||||
if (!$date) $date = $today;
|
||||
if (!$time) $time = $now;
|
||||
$date = fix_date($date);
|
||||
$time = fix_time($time);
|
||||
|
||||
// determine whether supplied date is future or past
|
||||
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$date\",CURRENT_DATE)"));
|
||||
// if future, set time to 00:00:01, if past, set to 23:59:59
|
||||
@@ -263,6 +262,10 @@ if ($edit) {
|
||||
if ($removepart && $authorized) mysqli_query($db, "delete from logparts where lognoteid=\"$noteid\" and logpartid=\"$removepart\"");
|
||||
if ($submit) {
|
||||
if ($note) {
|
||||
// sanitize and fix blank date and time
|
||||
$date = fix_date($date);
|
||||
$time = fix_time($time);
|
||||
|
||||
// remove cruft from note text
|
||||
$note = strip_tags($note, "<a>");
|
||||
$note = mysqli_real_escape_string($db, $note);
|
||||
|
||||
@@ -135,6 +135,9 @@ if ($mfadd) {
|
||||
if ($mfsubmit) {
|
||||
// add the entry if submit is pressed
|
||||
if ($mfmalfunction && ($uid || ($partnum && $sernum))) {
|
||||
// sanitize and fix blank date and time
|
||||
$mfdate = fix_date($mfdate);
|
||||
$mftime = fix_time($mftime);
|
||||
// determine whether supplied date is future or past
|
||||
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$mfdate\",CURRENT_DATE)"));
|
||||
// if future, set time to 00:00:01, if past, set to 23:59:59
|
||||
@@ -236,6 +239,9 @@ if ($mfdelete && $mfauthorized) {
|
||||
if ($actionadd) {
|
||||
if ($actionaddsubmit) {
|
||||
if ($action) {
|
||||
// sanitize and fix blank date and time
|
||||
$actiondate = fix_date($actiondate);
|
||||
$actiontime = fix_time($actiontime);
|
||||
// determine whether supplied date is future or past
|
||||
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$actiondate\",CURRENT_DATE)"));
|
||||
// if future, set time to 00:00:01, if past, set to 23:59:59
|
||||
@@ -260,6 +266,9 @@ if ($actionadd) {
|
||||
if ($actionedit) {
|
||||
if ($actioneditsubmit && $actionauthorized) {
|
||||
// update the action
|
||||
// sanitize and fix blank date and time
|
||||
$actiondate = fix_date($actiondate);
|
||||
$actiontime = fix_time($actiontime);
|
||||
// remove cruft from action text
|
||||
$action = htmlentities($action);
|
||||
$action = addslashes($action);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
blankpage.php
|
||||
schedmaint.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
@@ -73,7 +73,7 @@ $errorstack = array();
|
||||
if ($action) {
|
||||
if ($complete) {
|
||||
// sanitize user input
|
||||
$completedate = mysqli_real_escape_string($db, $completedate);
|
||||
$completedate = fix_date($completedate);
|
||||
// update events
|
||||
mysqli_query($db, "update events set last_date=\"$completedate\", deferred_flag=0, deferred_date=\"0000-00-00\" where eventid=\"$id\"");
|
||||
if ($addlognote) {
|
||||
@@ -88,6 +88,7 @@ if ($action) {
|
||||
}
|
||||
}
|
||||
if ($defer) {
|
||||
$deferuntil = fix_date($deferuntil);
|
||||
// update events
|
||||
mysqli_query($db, "update events set deferred_flag=1, deferred_date=\"$deferuntil\" where eventid=\"$id\"");
|
||||
}
|
||||
@@ -110,9 +111,12 @@ if ($add) {
|
||||
$errorstack[] = "<img src=\"icons/exclamation-red.png\" border=\"0\"> You didn't select a device.<br>";
|
||||
}
|
||||
// sanitize text data
|
||||
$start_date = mysqli_real_escape_string($db, $start_date);
|
||||
$last_date = mysqli_real_escape_string($db, $last_date);
|
||||
$deferred_date = mysqli_real_escape_string($db, $deferred_date);
|
||||
if ($start_date == NULL) $start_date = $today;
|
||||
if ($last_date == NULL) $last_date = "0001-01-01";
|
||||
if ($deferred_date == NULL) $deferred_date = "0001-01-01";
|
||||
$start_date = fix_date($start_date);
|
||||
$last_date = fix_date($last_date);
|
||||
$deferred_date = fix_date($deferred_date);
|
||||
if ($taskselected && $deviceselected) {
|
||||
// determine if device represents a group and break out individual devices
|
||||
if (dblookup($db, "devices", "deviceid", "group_flag", $device)) {
|
||||
@@ -126,9 +130,7 @@ if ($add) {
|
||||
}
|
||||
// run through the memberlist and modify the table
|
||||
foreach ($memberlist as $memberdev) {
|
||||
if ($start_date == NULL) $start_date = $today;
|
||||
if ($last_date == NULL) $last_date = "0000-00-00";
|
||||
if ($deferred_date == NULL) $deferred_date = "0000-00-00";
|
||||
|
||||
$addqry = ("insert into events(task,device,start_date,last_date,deferred_flag,deferred_date,active_flag)
|
||||
values(\"$task\",\"$memberdev\",\"$start_date\",\"$last_date\",\"$deferred_flag\",\"$deferred_date\",\"$active_flag\")");
|
||||
mysqli_query($db, $addqry);
|
||||
@@ -199,13 +201,13 @@ if ($edit) {
|
||||
if ($update) {
|
||||
// do error checking
|
||||
// sanitize text data
|
||||
$start_date = mysqli_real_escape_string($db, $start_date);
|
||||
$last_date = mysqli_real_escape_string($db, $last_date);
|
||||
$deferred_date = mysqli_real_escape_string($db, $deferred_date);
|
||||
// update the tasks table
|
||||
if ($start_date == NULL) $start_date = $today;
|
||||
if ($last_date == NULL) $last_date = "0000-00-00";
|
||||
if ($deferred_date == NULL) $deferred_date = "0000-00-00";
|
||||
if ($last_date == NULL) $last_date = "0001-01-01";
|
||||
if ($deferred_date == NULL) $deferred_date = "0001-01-01";
|
||||
$start_date = fix_date($start_date);
|
||||
$last_date = fix_date($last_date);
|
||||
$deferred_date = fix_date($deferred_date);
|
||||
// update the tasks table
|
||||
mysqli_query($db, "update events
|
||||
set task=\"$task\",device=\"$device\",start_date=\"$start_date\",last_date=\"$last_date\",deferred_flag=\"$deferred_flag\",
|
||||
deferred_date=\"$deferred_date\",active_flag=\"$active_flag\"
|
||||
@@ -404,9 +406,9 @@ if ($action) {
|
||||
} else {
|
||||
$deferredtag = "<input type=\"checkbox\" name=\"deferred_flag\" value=\"1\">";
|
||||
}
|
||||
if ($start_date == "0000-00-00") $start_date = $today;
|
||||
if ($last_date == "0000-00-00") $last_date = "";
|
||||
if ($deferred_date == "0000-00-00") $deferred_date = $tomorrow;
|
||||
if ($start_date == "0001-01-01") $start_date = $today;
|
||||
//if ($last_date == "0001-01-01") $last_date = "";
|
||||
if ($deferred_date == "0001-01-01") $deferred_date = $tomorrow;
|
||||
$deferuntiltag = "<input type=\"text\" name=\"deferred_date\" id=\"deferdatepicker\" size=\"10\" maxlength=\"10\" value=\"$deferred_date\" title=\"Format: YYYY-MM-DD\">";
|
||||
$startdatetag = "<input type=\"text\" name=\"start_date\" id=\"startdatepicker\" size=\"10\" maxlength=\"10\" value=\"$start_date\" title=\"Format: YYYY-MM-DD\">";
|
||||
$lastdatetag = "<input type=\"text\" name=\"last_date\" id=\"completedatepicker\" size=\"10\" maxlength=\"10\" value=\"$last_date\" title=\"Format: YYYY-MM-DD\">";
|
||||
@@ -487,7 +489,7 @@ if ($action) {
|
||||
";
|
||||
while ($tablerow = mysqli_fetch_assoc($existingdata)) {
|
||||
extract($tablerow);
|
||||
if ($start_date == "0000-00-00") $start_date = $today;
|
||||
if ($start_date == "0001-01-01") $start_date = $today;
|
||||
if ($last_date == "0000-00-00") $last_date = "";
|
||||
if ($deferred_date == "0000-00-00") $deferred_date = "";
|
||||
if ($active_flag) {
|
||||
|
||||
Reference in New Issue
Block a user