connect_error) return log_sql_error("connect: ".$dbhost."[".$dbuser."]", $sql->connect_error); if (!$sql->select_db($dbname)) return log_sql_error("select_db: ".$dbname, $sql->error); if (isset($_GET['comment'])) { $query = "SELECT d, c FROM Comments WHERE y=".$y." AND m=".$m; if (isset($_GET['d'])) $query .= " AND d=".$_GET['d']; $result = $sql->query($query); if (!$result) return log_sql_error($query, $sql->error); if (isset($_GET['d'])) { $row = $result->fetch_array(); if ($row) print($row[1]); return; } while ($row = $result->fetch_array()) { printf("%04d%02d%s", strlen($row[1]), $row[0], $row[1]); } return; } if (isset($_GET['d'])) { if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) { header('WWW-Authenticate: Basic realm="Shift schedule"'); header('HTTP/1.0 401 Unauthorized'); return; } $rc = login(); if ($rc!="") { header('HTTP/1.0 401 '.$rc); return; } $d = $_GET['d']; if (isset($_GET['c'])) { $c = $_GET['c']; $query = "DELETE FROM Comments WHERE y=".$y." AND m=".$m." AND d=".$d; if (!$sql->query($query)) return log_sql_error($query, $sql->error); if (strlen($c)<=0) return; $query = "INSERT Comments SET y=".$y.", m=".$m.", d=".$d.", c='".$c."'"; if (!$sql->query($query)) return log_sql_error($query, $sql->error); return; } $u = isset($_GET['u']) ? $_GET['u'] : $_SERVER['PHP_AUTH_USER']; $query = "DELETE FROM Data WHERE y=".$y." AND m=".$m." AND d=".$d." AND u='".$u."'"; if (!$sql->query($query)) return log_sql_error($query, $sql->error); if ($sql->affected_rows==0) { $x = $_GET['x']; $query = "INSERT Data SET y=".$y.", m=".$m.", d=".$d.", x=".$x.", u='".$u."'"; if (!$sql->query($query)) return log_sql_error($query, $sql->error); } } $query = "SELECT d, u, x FROM Data WHERE y=".$y." AND m=".$m; if (isset($_GET['d'])) $query .= " AND d=".$_GET['d']; $result = $sql->query($query); if (!$result) if (!$sql->query($query)) return log_sql_error($query, $sql->error); while ($row = $result->fetch_array()) print($row[0]."\t".$row[1]."\t".$row[2]."\n"); ?>