From 67e4b234d31626976ad630043814235c936f8bbf Mon Sep 17 00:00:00 2001 From: Lizzy Hunt Date: Sat, 9 Mar 2024 21:29:25 -0700 Subject: finish static page --- html/public/css/style.css | 77 ++++++++++++++++++++++++++++++++++ html/public/fruitvote/GoPage.php | 88 +++++++++++++++++++++++++++++++++++++++ html/public/fruitvote/index.php | 7 ++++ html/public/img/penguin.gif | Bin 0 -> 53409 bytes html/public/index.php | 54 ++++++++++++++++++------ html/public/template.html | 38 +++++++++++++++++ 6 files changed, 252 insertions(+), 12 deletions(-) create mode 100644 html/public/css/style.css create mode 100644 html/public/fruitvote/GoPage.php create mode 100644 html/public/fruitvote/index.php create mode 100644 html/public/img/penguin.gif create mode 100644 html/public/template.html (limited to 'html/public') diff --git a/html/public/css/style.css b/html/public/css/style.css new file mode 100644 index 0000000..a4f243f --- /dev/null +++ b/html/public/css/style.css @@ -0,0 +1,77 @@ +/* Basic Reset */ +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +body { + background-color: #2a2a2a; /* Dark background */ + color: #f4c2c2; /* Soft pink text, typical of a girly 90s vibe */ + font-family: "Comic Sans MS", "Chalkboard SE", sans-serif; /* Retro, playful font */ + + padding: 20px; +} + +a { + color: #ff47da; /* Bright pink for links */ + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +button, +input[type="submit"], +input[type="button"] { + background-color: #ff69b4; /* Bright pink for buttons */ + border: none; + color: white; + padding: 10px 20px; + text-transform: uppercase; + font-family: "Comic Sans MS", "Chalkboard SE", sans-serif; + cursor: pointer; + transition: background-color 0.3s ease; +} + +button:hover, +input[type="submit"]:hover, +input[type="button"]:hover { + background-color: #ff1493; /* Darker pink on hover */ +} + +input[type="text"], +input[type="password"], +textarea { + background-color: #333; /* Darker elements for inputs */ + border: 1px solid #f4c2c2; /* Soft pink border */ + color: #f4c2c2; /* Soft pink text */ + padding: 10px; +} + +/* Example of styling a specific component differently */ +.special-button { + background-color: #ff47da; /* A different shade of pink */ + border-radius: 20px; /* Rounded edges for a more playful look */ +} + +h1, +h2, +h3, +h4, +h5, +h6 { + color: #ff69b4; + margin-bottom: 20px; +} + +p { + margin-bottom: 20px; +} + +li { + margin-left: 20px; +} diff --git a/html/public/fruitvote/GoPage.php b/html/public/fruitvote/GoPage.php new file mode 100644 index 0000000..c3a7d34 --- /dev/null +++ b/html/public/fruitvote/GoPage.php @@ -0,0 +1,88 @@ +page = $page; + $this->socket = $socket; + $this->template = $template; + + // test if socket exists + if (!file_exists($socket)) { + // start the server + exec($start_cmd); + } + + for ($i = 0; $i < 10; $i++) { + if (file_exists($socket)) { + break; + } + usleep(100_000); // wait 100ms + } + + if (!file_exists($socket)) { + throw new Exception("Could not start server"); + } + } + public function go() { + $ch = curl_init(); + $url = "http://localhost".$this->page; + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_UNIX_SOCKET_PATH, $this->socket); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + // forward headers + $headers = array(); + foreach ($_SERVER as $key => $value) { + if (substr($key, 0, 5) == "HTTP_") { + $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5))))); + $headers[] = "$key: $value"; + } + } + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + + // forward params depending on http method + if ($_SERVER['REQUEST_METHOD'] == "POST" || $_SERVER['REQUEST_METHOD'] == "PUT" || $_SERVER['REQUEST_METHOD'] == "DELETE") { + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('php://input')); + } else { + $url .= "?".$_SERVER['QUERY_STRING']; + } + + // forward cookies + $cookie = array(); + foreach ($_COOKIE as $key => $value) { + $cookie[] = "$key=$value"; + } + + $output = curl_exec($ch); + curl_close($ch); + + // forward headers back to client + $headers = explode("\n", $output); + foreach ($headers as $header) { + if (strpos($header, "HTTP/") === false) { + header($header); + } + } + + // forward cookies back to client + $cookie = explode("\n", $output); + foreach ($cookie as $cookie) { + if (strpos($cookie, "Set-Cookie:") !== false) { + header($cookie); + } + } + + return $output; + } + + public function render() { + $response = $this->go(); + $template = file_get_contents($this->template); + return str_replace("{{content}}", $response, $template); + } +} diff --git a/html/public/fruitvote/index.php b/html/public/fruitvote/index.php new file mode 100644 index 0000000..1abfb0c --- /dev/null +++ b/html/public/fruitvote/index.php @@ -0,0 +1,7 @@ +render(); +?> diff --git a/html/public/img/penguin.gif b/html/public/img/penguin.gif new file mode 100644 index 0000000..48bd0e2 Binary files /dev/null and b/html/public/img/penguin.gif differ diff --git a/html/public/index.php b/html/public/index.php index 3ed5805..004a131 100644 --- a/html/public/index.php +++ b/html/public/index.php @@ -1,19 +1,49 @@ you are at my tilde.club page right now! hi!

-$ch = curl_init(); -$url = "http:/localhost"; -$unix = "/home/simponic/http.sock"; +a penguin +

this is a penguin

-if (defined('CURLOPT_UNIX_SOCKET_PATH')) { - curl_setopt($ch, CURLOPT_UNIX_SOCKET_PATH, $unix); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +

here you can:

- $response = curl_exec($ch); - echo $response; -} + -curl_close($ch); +
+
+ +

+here are some stuffs i like: +

+

+ +

+here are some stuffs i don\'t like: +

+

+'; + +$template = file_get_contents('template.html'); + +echo str_replace("{{content}}", $content, $template); ?> diff --git a/html/public/template.html b/html/public/template.html new file mode 100644 index 0000000..4867c55 --- /dev/null +++ b/html/public/template.html @@ -0,0 +1,38 @@ + + + + + + + ~simponic + + + + + +
+

~simponic

+ +
+
+ + {{content}} + +
+
+
+ + +
+ + + -- cgit v1.3