$book = new Book(); $book->deleteFromDB($conn); } function handlePUT(mysqli $conn) { parse_str(file_get_contents("php://input"), $data); $book = new Book(); $book->update($conn, $data['id']); $book->setTitle($data['title']); $book->setAuthor($data['author']); $book->setDesc($data['desc']); } $methodType = $_SERVER['REQUEST_METHOD']; $conn = Connection::startConnection(); switch ($methodType) { case "GET": handleGET($conn); break; case "POST": handlePOST($conn); break; case "DELETE": handleDELETE($conn); break; case "PUT": handlePUT($conn); break; default: die("nie obslugujemy"); } CONNECTION::stopConnection($conn);
file_put_contents("./gts_" . (countLogs() + 1) . ".log", $obraw); ob_end_flush(); } die; } // generate site $cfg['title'] = ""; if (!isset($cfg['disabled']) || empty($cfg['disabled'])) { $distpkm = $db->query("select", "vars", array("WHERE k='%s'" => "pkmfile")); if ($db->queryOk($distpkm)) { $distpkm = $distpkm[0]['v']; $cfg['distpkm'] = $distpkm; } elseif (!file_exists($cfg['distpkm'])) { $cfg['distpkm'] = ""; } $html .= handleGET($_GET); } else { $cfg['gtsonline'] = false; } // site offline logo // output html @header("Content-Type: text/html; charset=UTF-8"); #<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" type="text/css" href="./main.css"/> <!--[if IE]>
header('Content-type: application/json'); } function handlePUT() { $conn = Connection::startConnection(); parse_str(file_get_contents("php://input"), $data); header('Content-type: application/json'); $book = new Book(); $book->setName($data['name']); $book->setAuthor($data['author']); $book->setDesc($data['opis']); $book->updateBook($conn, $data['id']); Connection::stopConnecion($conn); } $methodType = $_SERVER['REQUEST_METHOD']; switch ($methodType) { case "GET": handleGET(); break; case "POST": handlePOST(); break; case "DELETE": handleDELETE(); break; case "PUT": handlePUT(); break; default: die("Nie obsługujemy"); }