Pushing all files from my usb

This commit is contained in:
goom
2025-11-22 23:57:26 -08:00
commit 457d8a0d4c
48 changed files with 4262 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/vendor/
config.inc.php

8
.htaccess Normal file
View File

@@ -0,0 +1,8 @@
RewriteEngine On
RewriteBase /
RewriteRule ^images/(.*) /views/images/$1 [L]
RewriteRule ^styles/(.*) /views/styles/$1 [L]
RewriteRule ^scripts/(.*) /views/scripts/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

201
LICENSE Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

12
README.md Normal file
View File

@@ -0,0 +1,12 @@
# MallardNet
MallardNet is a marcoblogging site created in 2025.
<h2 align="left">what is use</h2>
<uL>
<li><a href="https://getcomposer.org/">composer</a></li>
<li><a href="https://github.com/bramus/router">bramus/router</a></li>
</uL>
<h2 align="left">how to get it running in your web environment</h2>
<p align="left">i made these instructions because it has composer, so it needs the steps in either not to have errors without the /vendor/ folder <br><br>1. have composer installed on your computer<br>2. put all of this stuff in your www folder <br>3. run composer update to establish /vendor/ folder (requires because it uses a router)<br>4. install. sql file in a new database<br>5. change config.sample.inc.php to config.inc.php and then change the database details to your. database and db account details. <br>6. done, . its running, can code yipee</p>

5
composer.json Normal file
View File

@@ -0,0 +1,5 @@
{
"require": {
"bramus/router": "~1.6"
}
}

70
composer.lock generated Normal file
View File

@@ -0,0 +1,70 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "1c8a1ef3d6be7e51a0a9b9c991ff9fc9",
"packages": [
{
"name": "bramus/router",
"version": "1.6.1",
"source": {
"type": "git",
"url": "https://github.com/bramus/router.git",
"reference": "55657b76da8a0a509250fb55b9dd24e1aa237eba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bramus/router/zipball/55657b76da8a0a509250fb55b9dd24e1aa237eba",
"reference": "55657b76da8a0a509250fb55b9dd24e1aa237eba",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.14",
"phpunit/php-code-coverage": "~2.0",
"phpunit/phpunit": "~4.8"
},
"type": "library",
"autoload": {
"psr-0": {
"Bramus": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bram(us) Van Damme",
"email": "bramus@bram.us",
"homepage": "http://www.bram.us"
}
],
"description": "A lightweight and simple object oriented PHP Router",
"homepage": "https://github.com/bramus/router",
"keywords": [
"router",
"routing"
],
"support": {
"issues": "https://github.com/bramus/router/issues",
"source": "https://github.com/bramus/router/tree/1.6.1"
},
"time": "2021-11-18T19:24:07+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.3.0"
}

122
index.php Normal file
View File

@@ -0,0 +1,122 @@
<?php
session_start();
require __DIR__ . '/vendor/autoload.php';
require('lib/config.inc.php');
$router = new \Bramus\Router\Router();
$views_dir = __DIR__ . '/views/';
$class_dir = scandir("lib/classes");
/* these can't be defined as it breaks logging in hence vscode is displaying errors about them
being undefined */
@$website;
@$conn;
foreach ($class_dir as $class) {
if (preg_match("/.php/i", $class)) {
require("lib/classes/" . $class);
}
}
$router->all('/', function() use ($views_dir, $website, $conn) {
if (!isset($_SESSION["user"])) {
require($views_dir . 'main.php');
} else {
require($views_dir . "/dupes/home/feed_micros.php");
}
return;
});
$router->get('/feed/(\w+)', function($feed_type) use ($views_dir, $website, $conn) {
if (!isset($_SESSION["user"]) || htmlspecialchars($feed_type) == NULL) {
header("Location: /");
} else {
switch(htmlspecialchars($feed_type)) {
case "micros":
require($views_dir . "/dupes/home/feed_micros.php");
break;
case "marcos":
require($views_dir . "/dupes/home/feed_marcos.php");
break;
case "gallery":
require($views_dir . "/dupes/home/feed_gallery.php");
break;
default:
header("Location: /");
}
}
return;
});
$router->get('/quack/(\w+)', function($post_id) use ($views_dir, $website, $conn) {
if (!$post_id) {
header("Location: /");
} else {
require($views_dir . "/post.php");
}
});
$router->get('/delete_quack/(\w+)', function($post_id) use ($conn) {
$hasTitle = false;
if (!isset($_SESSION["user"])) {
header("Location: /");
} else {
$post = new Post($_SESSION["user"], $conn);
if ($post->getSpecifcPost(htmlspecialchars($post_id)) != NULL) {
$post_details = $post->getSpecifcPost(htmlspecialchars($post_id)) ;
if ($post_details["author"] == $_SESSION["user"])
if ($post_details["title"] != NULL)
$hasTitle = true;
$post->deletePost($post_id);
}
if ($hasTitle) {
header("Location: /feed/marcos");
} else {
header("Location: /");
}
}
return;
});
$router->all('/settings', function() use ($views_dir, $website, $conn) {
require($views_dir . 'settings.php');
return;
});
$router->all('/apply', function() use ($views_dir, $website) {
require($views_dir . 'apply.php');
return;
});
$router->all('/temp_register', function() use ($views_dir, $website, $conn) {
require($views_dir . 'temp_reg.php');
return;
});
$router->all('/login', function() use ($views_dir, $website, $conn) {
require($views_dir . 'login.php');
return;
});
$router->all('/logout', function() use ($views_dir, $website, $conn) {
session_destroy();
header("Location: /");
return;
});
$router->set404(function() {
header('HTTP/1.1 404 Not Found');
echo "Waddled to nowhere";
return;
});
$router->run();
?>

35
lib/classes/Account.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
class Account {
private $current_user;
private $conn;
public function __construct($current_user, $conn) {
$this->current_user = $current_user;
$this->conn = $conn;
}
public function isLoggedIn() {
return isset($_SESSION["user"]) && $_SESSION["user"] == $this->current_user;
}
public function accountExists() {
$stmt = $this->conn->prepare("SELECT username FROM accounts WHERE username = :username");
$stmt->bindParam(":username", $this->current_user);
$stmt->execute();
return $stmt->rowCount() > 0;
}
public function getDetails($info) {
if (!$this->accountExists() || !$this->isLoggedIn())
return NULL;
$stmt = $this->conn->prepare("SELECT * FROM accounts WHERE username = :username");
$stmt->bindParam(":username", $this->current_user);
$stmt->execute();
$current_user = $stmt->fetch(PDO::FETCH_ASSOC);
return $current_user[$info] ?? NULL;
}
}
?>

52
lib/classes/Login.php Normal file
View File

@@ -0,0 +1,52 @@
<?php
class Login {
private $username;
private $password;
private $conn;
public $error;
public function __construct($username, $password, $conn) {
$this->username = trim($username);
$this->password = trim($password);
$this->conn = $conn;
}
public function checkUsername() {
if (empty($this->username)) {
$this->error = "Please fill out all of the fields.";
} else {
$stmt = $this->conn->prepare("SELECT username FROM accounts WHERE username = :username");
$stmt->bindParam(":username", $this->username);
$stmt->execute();
if ($stmt->rowCount() == 0)
$this->error = "Incorrect username or password.";
}
return $this->error;
}
public function checkPassword() {
if (empty($this->password)) {
$this->error = "Please fill out all of the fields.";
} else {
$stmt = $this->conn->prepare("SELECT password FROM accounts WHERE username = :username");
$stmt->bindParam(":username", $this->username);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if ($user == NULL || !password_verify($this->password, $user["password"]))
$this->error = "Incorrect username or password.";
}
return $this->error;
}
public function authUser() {
session_regenerate_id(true);
$_SESSION['user'] = $this->username;
return true;
}
}
?>

87
lib/classes/Post.php Normal file
View File

@@ -0,0 +1,87 @@
<?php
class Post extends Account {
private $current_user;
private $title;
private $content;
private $conn;
public $error;
public function __construct($current_user, $conn) {
parent::__construct($current_user, $conn);
$this->current_user = $current_user;
$this->conn = $conn;
}
public function getForm($title, $content) {
$this->title = $title;
$this->content = $content;
}
public function postUpdate() {
if (!$this->isLoggedIn())
return;
switch(true) {
case empty($this->content):
$this->error = "Your post cannot be left empty.";
break;
case strlen($this->content) > 2500:
$this->error = "Post exceeds the character limit. Are you trying to bypass it?";
break;
}
return $this->error;
}
public function insertPost() {
if (!$this->isLoggedIn())
return;
$new_content = $this->content;
if (empty($this->title)) {
// micro post
$type = 1;
$new_content = substr($this->content, 0, 300);
} else {
// marco post
$type = 2;
}
$stmt = $this->conn->prepare("INSERT INTO posts (title, content, author, type) VALUES (:title, :content, :author, :type)");
$stmt->bindParam(":title", $this->title);
$stmt->bindParam(":content", $new_content);
$stmt->bindParam(":author", $this->getDetails("username"));
$stmt->bindParam(":type", $type);
$stmt->execute();
return true;
}
public function getPosts($type) {
$stmt = $this->conn->prepare("SELECT * FROM posts WHERE type = :type ORDER BY date DESC");
$stmt->bindParam(":type", $type);
$stmt->execute();
return $stmt;
}
public function getSpecifcPost($id) {
$stmt = $this->conn->prepare("SELECT * FROM posts WHERE id = :id");
$stmt->bindParam(":id", $id);
$stmt->execute();
$post_details = $stmt->fetch(PDO::FETCH_ASSOC);
return $post_details;
}
public function deletePost($id) {
$stmt = $this->conn->prepare("DELETE FROM posts WHERE id = :id");
$stmt->bindParam(":id", $id);
$stmt->execute();
return true;
}
}
?>

64
lib/classes/Register.php Normal file
View File

@@ -0,0 +1,64 @@
<?php
class Register {
private $username;
private $password;
private $conn;
public $error;
public function __construct($username, $password, $conn) {
$this->username = trim($username);
$this->password = trim($password);
$this->conn = $conn;
}
public function checkUsername() {
switch(true) {
case empty($this->username):
$this->error = "Please fill out all of the fields";
break;
case preg_match("/[^a-z0-9 ]/i", $this->username):
$this->error = "Username cannot have any special characters.";
break;
case strlen($this->username) > 16:
$this->error = "Username cannot be longer than 16 characters.";
break;
case strlen($this->username) < 3:
$this->error = "Your username cannot be shorter than 3 characters.";
break;
default:
$stmt = $this->conn->prepare("SELECT username FROM accounts WHERE username = :username");
$stmt->bindParam(":username", $this->username);
$stmt->execute();
if ($stmt->rowCount() > 0)
$this->error = "Username has been already taken.";
}
return $this->error;
}
public function checkPassword($passwordConfirm) {
if (empty($this->password)) {
$this->error = "Please fill out all of the fields.";
} else {
if ($this->password != $passwordConfirm)
$this->error = "Passwords don't match.";
}
return $this->error;
}
public function insertUser() {
$hashed_password = password_hash($this->password, PASSWORD_BCRYPT);
$stmt = $this->conn->prepare("INSERT INTO accounts (username, password) VALUES (:username, :password)");
$stmt->bindParam(":username", $this->username);
$stmt->bindParam(":password", $hashed_password);
$stmt->execute();
session_regenerate_id(true);
$_SESSION["user"] = $this->username;
return true;
}
}
?>

107
lib/classes/Settings.php Normal file
View File

@@ -0,0 +1,107 @@
<?php
class Settings extends Account {
private $current_user;
private $new_username;
private $new_bio;
private $new_password;
private $conn;
public $error;
public function __construct($current_user, $conn) {
parent::__construct($current_user, $conn);
$this->current_user = $current_user;
$this->conn = $conn;
}
public function getForm($username, $bio, $password) {
$this->new_username = $username;
$this->new_bio = $bio;
$this->new_password = $password;
}
public function updateUsername() {
if ($this->new_username == $this->getDetails("username"))
return NULL;
switch(true) {
case empty($this->new_username):
$this->error = "Your username cannot be left blank.";
break;
case preg_match("/[^a-z0-9 ]/i", $this->new_username):
$this->error = "Username cannot have any special characters.";
break;
case strlen($this->new_username) > 16:
$this->error = "Username cannot be longer than 16 characters.";
break;
case strlen($this->new_username) < 3:
$this->error = "Username cannot be shorter than 3 characters.";
break;
default:
$stmt = $this->conn->prepare("SELECT username FROM accounts WHERE username = :username");
$stmt->bindParam(":username", $this->new_username);
$stmt->execute();
if ($stmt->rowCount() > 0)
$this->error = "Username has been already taken.";
}
if ($this->error == NULL) {
$stmt = $this->conn->prepare("UPDATE accounts SET username = :username WHERE id = :id");
$stmt->bindParam(":username", $this->new_username);
$stmt->bindParam(":id", $this->getDetails("id"));
$stmt->execute();
session_regenerate_id(true);
$_SESSION["user"] = $this->new_username;
return true;
}
return $this->error;
}
public function updateBio() {
if ($this->new_bio == $this->getDetails("bio"))
return NULL;
if (strlen($this->new_bio) > 150)
$this->error = "Bio cannot be longer than 150 characters.";
if ($this->error == NULL) {
$stmt = $this->conn->prepare("UPDATE accounts SET bio = :bio WHERE id = :id");
$stmt->bindParam(":bio", $this->new_bio);
$stmt->bindParam(":id", $this->getDetails("id"));
$stmt->execute();
return true;
}
return $this->error;
}
public function updatePassword($passwordConfirm) {
if (empty($this->new_password)) {
return NULL;
} else {
if ($this->new_password != $passwordConfirm)
$this->error = "Passwords don't match.";
}
if ($this->error == NULL) {
$hashed_password = password_hash($this->new_password, PASSWORD_BCRYPT);
$stmt = $this->conn->prepare("UPDATE accounts SET password = :password WHERE id = :id");
$stmt->bindParam(":password", $hashed_password);
$stmt->bindParam(":id", $this->getDetails("id"));
$stmt->execute();
return true;
}
return $this->error;
}
}
?>

136
mallar.sql Normal file
View File

@@ -0,0 +1,136 @@
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Nov 19, 2025 at 08:57 AM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `mallar`
--
-- --------------------------------------------------------
--
-- Table structure for table `accounts`
--
CREATE TABLE `accounts` (
`id` int(11) NOT NULL,
`username` varchar(16) DEFAULT NULL,
`password` text DEFAULT NULL,
`bio` varchar(150) NOT NULL DEFAULT 'Hi! I''m new to quacking!',
`rank` int(11) DEFAULT 1,
`level_exp` int(11) DEFAULT 0,
`level` int(11) DEFAULT 1,
`date_created` timestamp NULL DEFAULT current_timestamp()
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `accounts`
--
INSERT INTO `accounts` (`id`, `username`, `password`, `bio`, `rank`, `level_exp`, `level`, `date_created`) VALUES
(1, 'goom', '$2y$10$Zn6Zb4msPzvvOoP.iM0WkuvmFnfAeczFWDLS7OEHjlJpo1qfL0c3W', '', 1, 0, 1, '2025-11-07 03:25:51'),
(2, 'poo', '$2y$10$DHs.Kc5YP.FUQQahXOV4LOAlsREMrSLBT73dyz4SfSQiSbt4mIaMa', 'Hi! I\'m new to quacking!', 1, 0, 1, '2025-11-12 23:20:34');
-- --------------------------------------------------------
--
-- Table structure for table `applications`
--
CREATE TABLE `applications` (
`id` int(11) NOT NULL,
`username` tinytext NOT NULL,
`email` varchar(320) NOT NULL DEFAULT '',
`context` text NOT NULL,
`where_heard` text NOT NULL,
`status` varchar(50) NOT NULL DEFAULT 'pending',
`reason` text DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- Table structure for table `posts`
--
CREATE TABLE `posts` (
`id` int(11) NOT NULL,
`title` varchar(60) DEFAULT NULL,
`content` varchar(2500) DEFAULT NULL,
`date` timestamp NULL DEFAULT current_timestamp(),
`author` varchar(16) NOT NULL,
`type` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Dumping data for table `posts`
--
INSERT INTO `posts` (`id`, `title`, `content`, `date`, `author`, `type`) VALUES
(12, '', 'I&#039;m eating eggs', '2025-11-12 23:23:21', 'goom', 1),
(15, '', 'Whats up', '2025-11-17 07:43:20', 'goom', 1),
(17, '', 'Poop', '2025-11-17 08:41:48', 'goom', 1);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `accounts`
--
ALTER TABLE `accounts`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `applications`
--
ALTER TABLE `applications`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `posts`
--
ALTER TABLE `posts`
ADD PRIMARY KEY (`id`) USING BTREE;
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `accounts`
--
ALTER TABLE `accounts`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `applications`
--
ALTER TABLE `applications`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `posts`
--
ALTER TABLE `posts`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

66
views/apply.php Normal file
View File

@@ -0,0 +1,66 @@
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require("includes/header.php"); ?>
<tr>
<td>
<table class="form-box big-box" align="center" border="1">
<tbody>
<tr>
<th align="left" colspan="2">Sign up application</th>
</tr>
<form action="/apply" method="POST">
<tr>
<td colspan="2">
To register for <b>MallardNet</b>, an application form is required in which our team determines and decides
if you are eligible to have an account before sending you a link that lets you create one. This is to prevent bad actors from
accessing the website. Below is this form you'll fill out to determine your account eligibility.
</td>
</tr>
<tr>
<td class="label-box" align="right">email: </td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td class="label-box" valign="top" align="right">Why do you want to join MallardNet? </td>
<td><textarea name="context" rows="10" cols="46"></textarea></td>
</tr>
<tr>
<td class="label-box" valign="top" align="right">From where did you hear about this site?</td>
<td><input type="text" name="from_where" /></td>
</tr>
<tr>
<td class="right-hidden-border"></td>
<td class="small-text">
By submitting this application, you agree that you have read and understood our
<a href="/site_guidelines">Site Use Guidelines</a>.
</td>
</tr>
<tr class="top-hidden-border">
<td class="right-hidden-border"></td>
<td class="submit-pad"><input type="submit" name="submit_form" value="submit" /></td>
</tr>
</form>
</tbody>
</table>
</td>
</tr>
<?php require("includes/footer.php"); ?>
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,177 @@
<?php
if (!isset($_SESSION["user"]))
header("Location: /");
$dirBump = dirname(__DIR__, 2); // weird folder bug
$post = new Post($_SESSION["user"], $conn);
$posts_fetch = $post->getPosts(3);
$rowIndex = 0;
if (isset($_POST["send"])) {
$form = (object) [
"title" => htmlspecialchars(trim($_POST["post-title"])),
"content" => htmlspecialchars(trim($_POST["post-content"])),
];
$post->getForm($form->title, $form->content);
$post->postUpdate();
if ($post->error == NULL) {
$post->insertPost();
header("Location: /feed/gallery");
}
}
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="/styles/main.css">
<script src="/scripts/from-now.js"></script>
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require($dirBump."/includes/header.php"); ?>
<tr>
<?php require($dirBump."/includes/left_sidebar.php"); ?>
<td valign="top" align="left">
<table class="post-container">
<tbody>
<?php
if (isset($_POST["send"]) && isset($post))
if ($post->error != NULL) echo "<font style=\"color: #831f1f\">$post->error</font> <br>";
?>
<form action="/" method="POST">
<tr>
<td class="speech-bubble">
<input id="text-title" type="text" placeholder="post title" name="post-title" class="post-text" maxlength="60"></textarea>
<textarea id="text-content" name="post-content" rows="2" class="post-text" placeholder="what's quacking?" maxlength=2500></textarea>
<span id="text-length" class="post-label">300</span>
</td>
<td valign="top" width="50">
<img src="/images/profile_pic/duck.gif" alt="duck" class="pfp">
<input type="submit" name="send" value="post">
</td>
</tr>
</form>
</tbody>
</table>
<table class="box-tab small-tabs feed">
<tbody>
<tr>
<th align="left">
<a href="/feed/micros" id="non-selected">micros</a>
<a href="/feed/marcos" id="non-selected">marcos</a>
<a href="/feed/gallery">gallery</a>
</th>
</tr>
<tr>
<td>
<table class="status-feed">
<tbody>
<tr>
<td>
<?php
if ($post->getPosts(3)->rowCount() <= 0)
echo "<p class=\"hint\">There are currently no quacks in this section.</p>"; // rare message
foreach ($post->getPosts(3) as $p) {
$rowIndex++;
if ($rowIndex != $post->getPosts(3)->rowCount()) {
echo "<table class=\"bottom-border status-box\">";
} else {
echo "<table class=\"status-box\">";
}
?>
<tbody>
<tr>
<td class="title">
<h1><?= $p["author"]; ?> <img src="/images/badges/user.gif" alt="user"></h1>
<h2>- <span id="date-time"><?= $p["date"]; ?></span></h2>
<?php
if ($_SESSION["user"] == $p["author"]) {
?>
(<a href="/delete_post/<?= $p["id"]; ?>">Delete</a>)
<?php
}
?>
</h2>
<div> </div>
</td>
</tr>
<tr>
<td>
<?= $p["content"]; ?>
</td>
</tr>
<tr>
</tr>
</tbody>
</table>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php require($dirBump."/includes/footer.php"); ?>
</tbody>
</table>
<script>
var alltimeStamps = document.querySelectorAll('#date-time');
var textTitle = document.getElementById('text-title');
var textContext = document.getElementById('text-content');
var textLength = document.getElementById('text-length');
var textLimit = 300;
// A little stack overflow-ish code?
for (var t=0;t<alltimeStamps.length; t++) {
const stringUTC = alltimeStamps[t].textContent.replace(' ', 'T') + 'Z';
const objUTC = new Date(stringUTC);
objUTC.setTime(objUTC.getTime() + objUTC.getTimezoneOffset()*60*1000);
console.log(alltimeStamps[t].textContent);
alltimeStamps[t].textContent = fromNow(objUTC);
}
function checkRed() {
if (textLength.textContent < 0) {
textLength.style.color = "red";
} else {
textLength.style.color = "";
}
}
textContext.addEventListener('input', function handleChange(event) {
console.log(textLimit);
textLength.textContent = textLimit - textContext.value.length;
checkRed();
});
textTitle.addEventListener('input', function handleChange(event) {
console.log(textLimit);
if (textTitle.value.trim() == "") {
textLimit = 300;
} else {
textLimit = 2500;
}
textContext.setAttribute('maxLength', textLimit);
textLength.textContent = textLimit - textContext.value.length;
checkRed();
});
</script>
</body>
</html>

View File

@@ -0,0 +1,175 @@
<?php
if (!isset($_SESSION["user"]))
header("Location: /");
$post = new Post($_SESSION["user"], $conn);
$posts_fetch = $post->getPosts();
$rowIndex = 0;
if (isset($_POST["send"])) {
$form = (object) [
"title" => htmlspecialchars(trim($_POST["post-title"])),
"content" => htmlspecialchars(trim($_POST["post-content"])),
];
$post->getForm($form->title, $form->content);
$post->postUpdate();
if ($post->error == NULL) {
$post->insertPost();
header("Location: /");
}
}
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="styles/main.css">
<script src="/scripts/from-now.js"></script>
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require("includes/header.php"); ?>
<tr>
<?php require("includes/left_sidebar.php"); ?>
<td valign="top" align="left">
<table class="post-container">
<tbody>
<?php
if (isset($_POST["send"]) && isset($post))
if ($post->error != NULL) echo "<font style=\"color: #831f1f\">$post->error</font> <br>";
?>
<form action="/" method="POST">
<tr>
<td class="speech-bubble">
<input id="text-title" type="text" placeholder="post title" name="post-title" class="post-text" maxlength="60"></textarea>
<textarea id="text-content" name="post-content" rows="2" class="post-text" placeholder="what's quacking?" maxlength=2500></textarea>
<span id="text-length" class="post-label">300</span>
</td>
<td valign="top" width="50">
<img src="/images/profile_pic/duck.gif" alt="duck" class="pfp">
<input type="submit" name="send" value="post">
</td>
</tr>
</form>
</tbody>
</table>
<table class="box-tab small-tabs feed">
<tbody>
<tr>
<th align="left">
<a href="/feed/micros">micros</a>
<a href="/feed/marcos" id="non-selected">macros</a>
<a href="/feed/gallery" id="non-selected">gallery</a>
</th>
</tr>
<tr>
<td>
<table class="status-feed">
<tbody>
<tr>
<td>
<?php
if ($post->getPosts()->rowCount() <= 0)
echo "<p class=\"hint\">There are currently no quacks in this feed.</p>"; // rare message
foreach ($post->getPosts() as $p) {
$rowIndex++;
if ($rowIndex != $post->getPosts()->rowCount()) {
echo "<table class=\"bottom-border status-box\">";
} else {
echo "<table class=\"status-box\">";
}
?>
<tbody>
<tr>
<td class="title">
<h1><?= $p["author"]; ?> <img src="/images/badges/user.gif" alt="user"></h1>
<h2>- <span id="date-time"><?= $p["date"]; ?></span></h2>
<?php
if ($_SESSION["user"] == $p["author"]) {
?>
(<a href="/delete_post/<?= $p["id"]; ?>">Delete</a>)
<?php
}
?>
</h2>
<div> </div>
</td>
</tr>
<tr>
<td>
<?= $p["content"]; ?>
</td>
</tr>
<tr>
</tr>
</tbody>
</table>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php require("includes/footer.php"); ?>
</tbody>
</table>
<script>
var alltimeStamps = document.querySelectorAll('#date-time');
var textTitle = document.getElementById('text-title');
var textContext = document.getElementById('text-content');
var textLength = document.getElementById('text-length');
var textLimit = 300;
// A little stack overflow-ish code?
for (var t=0;t<alltimeStamps.length; t++) {
const stringUTC = alltimeStamps[t].textContent.replace(' ', 'T') + 'Z';
const objUTC = new Date(stringUTC);
objUTC.setTime(objUTC.getTime() + objUTC.getTimezoneOffset()*60*1000);
console.log(alltimeStamps[t].textContent);
alltimeStamps[t].textContent = fromNow(objUTC);
}
function checkRed() {
if (textLength.textContent < 0) {
textLength.style.color = "red";
} else {
textLength.style.color = "";
}
}
textContext.addEventListener('input', function handleChange(event) {
console.log(textLimit);
textLength.textContent = textLimit - textContext.value.length;
checkRed();
});
textTitle.addEventListener('input', function handleChange(event) {
console.log(textLimit);
if (textTitle.value.trim() == "") {
textLimit = 300;
} else {
textLimit = 2500;
}
textContext.setAttribute('maxLength', textLimit);
textLength.textContent = textLimit - textContext.value.length;
checkRed();
});
</script>
</body>
</html>

View File

@@ -0,0 +1,177 @@
<?php
if (!isset($_SESSION["user"]))
header("Location: /");
$dirBump = dirname(__DIR__, 2); // weird folder bug
$post = new Post($_SESSION["user"], $conn);
$posts_fetch = $post->getPosts(2);
$rowIndex = 0;
if (isset($_POST["send"])) {
$form = (object) [
"title" => htmlspecialchars(trim($_POST["post-title"])),
"content" => htmlspecialchars(trim($_POST["post-content"])),
];
$post->getForm($form->title, $form->content);
$post->postUpdate();
if ($post->error == NULL) {
$post->insertPost();
if ($form->title == NULL) {
header("Location: /feed/micros");
} else {
header("Location: /feed/marcos");
}
}
}
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="/styles/main.css">
<script src="/scripts/from-now.js"></script>
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require($dirBump."/includes/header.php"); ?>
<tr>
<?php require($dirBump."/includes/left_sidebar.php"); ?>
<td valign="top" align="left">
<table class="post-container">
<tbody>
<?php
if (isset($_POST["send"]) && isset($post))
if ($post->error != NULL) echo "<font style=\"color: #831f1f\">$post->error</font> <br>";
?>
<form action="/" method="POST">
<tr>
<td class="speech-bubble">
<input id="text-title" type="text" placeholder="post title" name="post-title" class="post-text" maxlength="60"></textarea>
<textarea id="text-content" name="post-content" rows="2" class="post-text" placeholder="what's quacking?" maxlength=2500></textarea>
<span id="text-length" class="post-label">300</span>
</td>
<td valign="top" width="50">
<img src="/images/profile_pic/duck.gif" alt="duck" class="pfp">
<input type="submit" name="send" value="post">
</td>
</tr>
</form>
</tbody>
</table>
<table class="box-tab small-tabs feed">
<tbody>
<tr>
<th align="left">
<a href="/feed/micros" id="non-selected">micros</a>
<a href="/feed/marcos">marcos</a>
<a href="/feed/gallery" id="non-selected">gallery</a>
</th>
</tr>
<tr>
<td>
<table class="status-feed">
<tbody>
<tr>
<td>
<?php
if ($post->getPosts(2)->rowCount() <= 0)
echo "<p class=\"hint\">There are currently no quacks in this section.</p>"; // rare message
foreach ($post->getPosts(2) as $p) {
$rowIndex++;
if ($rowIndex != $post->getPosts(2)->rowCount()) {
echo "<table class=\"bottom-border status-box\">";
} else {
echo "<table class=\"status-box\">";
}
?>
<tbody>
<tr>
<td class="title">
<a href="/quack/<?= $p["id"]; ?>" class="blog-button"><h1><?= $p["title"]; ?></h1></a>
<?php
if ($_SESSION["user"] == $p["author"])
echo "<div class=\"right\">
<a href=\"/delete_quack/".$p["id"]."\"><img alt=\"Delete\" src=\"/images/buttons/del.gif\" \></a>
</div>";
?>
</td>
<td>
by
<h1><?= $p["author"]; ?> <img src="/images/badges/user.gif" alt="user"></h1>
<h2>- <span id="date-time"><?= $p["date"]; ?></span></h2>
</td>
</tr>
<tr>
</tr>
</tbody>
</table>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php require($dirBump."/includes/footer.php"); ?>
</tbody>
</table>
<script>
var alltimeStamps = document.querySelectorAll('#date-time');
var textTitle = document.getElementById('text-title');
var textContext = document.getElementById('text-content');
var textLength = document.getElementById('text-length');
var textLimit = 300;
// A little stack overflow-ish code?
for (var t=0;t<alltimeStamps.length; t++) {
const stringUTC = alltimeStamps[t].textContent.replace(' ', 'T') + 'Z';
const objUTC = new Date(stringUTC);
objUTC.setTime(objUTC.getTime() + objUTC.getTimezoneOffset()*60*1000);
console.log(alltimeStamps[t].textContent);
alltimeStamps[t].textContent = fromNow(objUTC);
}
function checkRed() {
if (textLength.textContent < 0) {
textLength.style.color = "red";
} else {
textLength.style.color = "";
}
}
textContext.addEventListener('input', function handleChange(event) {
console.log(textLimit);
textLength.textContent = textLimit - textContext.value.length;
checkRed();
});
textTitle.addEventListener('input', function handleChange(event) {
console.log(textLimit);
if (textTitle.value.trim() == "") {
textLimit = 300;
} else {
textLimit = 2500;
}
textContext.setAttribute('maxLength', textLimit);
textLength.textContent = textLimit - textContext.value.length;
checkRed();
});
</script>
</body>
</html>

View File

@@ -0,0 +1,197 @@
<?php
if (!isset($_SESSION["user"]))
header("Location: /");
$dirBump = dirname(__DIR__, 2); // weird folder bug
$pBump = 0;
$pagination = 1;
$post = new Post($_SESSION["user"], $conn);
$posts_fetch = $post->getPosts(1);
$rowIndex = 0;
if (isset($_POST["send"])) {
$form = (object) [
"title" => htmlspecialchars(trim($_POST["post-title"])),
"content" => htmlspecialchars(trim($_POST["post-content"])),
];
$post->getForm($form->title, $form->content);
$post->postUpdate();
if ($post->error == NULL) {
$post->insertPost();
if ($form->title == NULL) {
header("Location: /feed/micros");
} else {
header("Location: /feed/marcos");
}
}
}
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="/styles/main.css">
<script src="/scripts/from-now.js"></script>
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require($dirBump."/includes/header.php"); ?>
<tr>
<?php require($dirBump."/includes/left_sidebar.php"); ?>
<td valign="top" align="left">
<table class="post-container">
<tbody>
<?php
if (isset($_POST["send"]) && isset($post))
if ($post->error != NULL) echo "<font style=\"color: #831f1f\">$post->error</font> <br>";
?>
<form action="/" method="POST">
<tr>
<td class="speech-bubble">
<input id="text-title" type="text" placeholder="post title" name="post-title" class="post-text" maxlength="60"></textarea>
<textarea id="text-content" name="post-content" rows="2" class="post-text" placeholder="what's quacking?" maxlength=2500></textarea>
<span id="text-length" class="post-label">300</span>
</td>
<td valign="top" width="50">
<img src="/images/profile_pic/duck.gif" alt="duck" class="pfp">
<input type="submit" name="send" value="post">
</td>
</tr>
</form>
</tbody>
</table>
<table class="box-tab small-tabs feed">
<tbody>
<tr>
<th align="left">
<a href="/feed/micros">micros</a>
<a href="/feed/marcos" id="non-selected">marcos</a>
<a href="/feed/gallery" id="non-selected">gallery</a>
</th>
</tr>
<tr>
<td>
<table class="status-feed">
<tbody>
<tr>
<td>
<?php
if ($post->getPosts(1)->rowCount() <= 0)
echo "<p class=\"hint\">There are currently no quacks in this section.</p>"; // rare message
foreach ($post->getPosts(1) as $p) {
$pBump++;
if ($pBump > 5) {
$pBump = 0;
$pagination++;
}
if ($rowIndex < 5) {
$rowIndex++;
if ($rowIndex != $post->getPosts(1)->rowCount()) {
echo "<table class=\"bottom-border status-box\">";
} else {
echo "<table class=\"status-box\">";
}
?>
<tbody>
<tr>
<td class="title">
<h1><?= $p["author"]; ?> <img src="/images/badges/user.gif" alt="user"></h1>
<h2>- <span id="date-time"><?= $p["date"]; ?></span></h2>
<?php
if ($_SESSION["user"] == $p["author"])
echo "<div class=\"right\">
<a href=\"/delete_quack/".$p["id"]."\"><img alt=\"Delete\" src=\"/images/buttons/del.gif\" \></a>
</div>";
?>
</h2>
</td>
</tr>
<tr>
<td>
<?= $p["content"]; ?>
</td>
</tr>
<tr>
</tr>
</tbody>
</table>
<?php
}
}
?>
</td>
<td>
<?php
for ($p2=1;$p2<=$pagination;$p2++) {
echo $p2 . " ";
}
?>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php require($dirBump."/includes/footer.php"); ?>
</tbody>
</table>
<script>
var alltimeStamps = document.querySelectorAll('#date-time');
var textTitle = document.getElementById('text-title');
var textContext = document.getElementById('text-content');
var textLength = document.getElementById('text-length');
var textLimit = 300;
// A little stack overflow-ish code?
for (var t=0;t<alltimeStamps.length; t++) {
const stringUTC = alltimeStamps[t].textContent.replace(' ', 'T') + 'Z';
const objUTC = new Date(stringUTC);
objUTC.setTime(objUTC.getTime() + objUTC.getTimezoneOffset()*60*1000);
console.log(alltimeStamps[t].textContent);
alltimeStamps[t].textContent = fromNow(objUTC);
}
function checkRed() {
if (textLength.textContent < 0) {
textLength.style.color = "red";
} else {
textLength.style.color = "";
}
}
textContext.addEventListener('input', function handleChange(event) {
console.log(textLimit);
textLength.textContent = textLimit - textContext.value.length;
checkRed();
});
textTitle.addEventListener('input', function handleChange(event) {
console.log(textLimit);
if (textTitle.value.trim() == "") {
textLimit = 300;
} else {
textLimit = 2500;
}
textContext.setAttribute('maxLength', textLimit);
textLength.textContent = textLimit - textContext.value.length;
checkRed();
});
</script>
</body>
</html>

BIN
views/images/background.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
views/images/logo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

BIN
views/images/logo.pdn Normal file

Binary file not shown.

BIN
views/images/logo_alt.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

BIN
views/images/old_logo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

BIN
views/images/what.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,6 @@
<tr>
<td colspan="2">
<hr>
<img src="/images/footer_text.gif" alt="footer text">
</td>
</tr>

33
views/includes/header.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
if (isset($_SESSION["user"])) {
$account = new Account($_SESSION["user"], $conn);
if (!$account->accountExists()) {
session_destroy();
header('Location: /');
}
}
?>
<tr>
<td colspan="2">
<table align="center" border="0" class="header">
<tbody>
<tr>
<td><a href="/"><img src="/images/logo.gif" alt="<?= $website->title; ?>"></a></td>
<td class="slogan"><?= $website->slogan; ?></td>
<?php
if (!isset($_SESSION['user'])) {
?>
<td class="account-status">no account. <a href="/login">log in</a> or <a href="/apply">apply</a>?</td>
<?php
} else {
?>
<td class="account-status">welcome, <?= $account->getDetails("username"); ?> | <a href="/logout">log out</a></td>
<?php
}
?>
</tr>
</tbody>
</table>
</td>
</tr>

View File

@@ -0,0 +1,30 @@
<td valign="top" width="140">
<span class="tab-header">feed</span>
<table class="sidebar-tabs">
<tbody>
<tr>
<td><a href="/"><img src="/images/tab_icons/friends.gif" alt="friends" /> friends</a></td>
</tr>
<tr>
<td><a href="/"><img src="/images/tab_icons/everyone.gif" alt="everyone" /> everyone</a></td>
</tr>
</tbody>
</table>
<table class="sidebar-tabs">
<tbody>
<tr>
<td><a href="#"><img src="/images/tab_icons/profile.gif" alt="my profile" /> my profile</a></td>
</tr>
<tr>
<td><a href="#"><img src="/images/tab_icons/items.gif" alt="my items" /> my items</a></td>
</tr>
<tr>
<td><a href="/settings"><img src="/images/tab_icons/settings.gif" alt="settings" /> settings</a></td>
</tr>
</tbody>
</table>
</td>

77
views/login.php Normal file
View File

@@ -0,0 +1,77 @@
<?php
if (isset($_SESSION["user"]))
header("Location: /");
if (isset($_POST["login"])) {
$form = (object) [
"username" => htmlspecialchars($_POST["username"]),
"password" => htmlspecialchars($_POST["password"]),
];
$login = new Login($form->username, $form->password, $conn);
$login->checkUsername();
$login->checkPassword();
if ($login->error == NULL) {
$login->authUser();
header("Location: /");
}
}
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require("includes/header.php"); ?>
<tr>
<td>
<table class="form-box big-box login" align="center" border="1">
<tbody>
<tr>
<th align="left" colspan="2">Duck login</th>
</tr>
<form action="/login" method="POST">
<tr>
<td class="label-box" align="right">username: </td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td class="label-box" align="right">password: </td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td class="right-hidden-border"></td>
<td class="small-text">
<?php
if (isset($_POST["login"]) && isset($login))
if ($login->error != NULL) echo "<font style=\"color: #831f1f\">$login->error</font> <br>";
?>
Don't have an account? <a href="/apply">Apply here</a>.
</td>
</tr>
<tr class="top-hidden-border">
<td class="right-hidden-border"></td>
<td class="submit-pad"><input type="submit" name="login" value="login" /></td>
</tr>
</form>
</tbody>
</table>
</td>
</tr>
<?php require("includes/footer.php"); ?>
</tbody>
</table>
</body>
</html>

82
views/main.php Normal file
View File

@@ -0,0 +1,82 @@
<?php
if (isset($_POST["login"])) {
$form = (object) [
"username" => htmlspecialchars($_POST["username"]),
"password" => htmlspecialchars($_POST["password"]),
];
$login = new Login($form->username, $form->password, $conn);
$login->checkUsername();
$login->checkPassword();
if ($login->error == NULL) {
$login->authUser();
header("Location: /");
}
}
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require("includes/header.php"); ?>
<tr>
<td>
<table>
<tbody>
<tr>
<td><img src="/images/what.gif" alt="duck typing quack quack" /></td>
<td valign="top" class="introduction">
<h2>WHAT IS MALLARDNET?</h2>
<p>
MallardNet is a marcoblogging platform where you can post blog-like posts on a live feed.
users can not only marco post, but they can have their post in any of it's <b>three</b> categories.
</p>
<ul>
<li>marco posts - blog-type posts</li>
<li>mirco posts - teeny tiny updates</li>
<li>image posts - for photography users or creative users who wants to share their world and creativity</li>
</ul>
so what are you waiting for? <a href="/apply">apply now</a>
</td>
</tr>
</tbody>
</table>
</td>
<td class="login-container">
<table border="1" class="form-box login-box">
<tbody>
<tr>
<th>Duck login</th>
</tr>
<tr>
<td>
<form action="/" method="POST">
<label>username:</label> <input type="text" name="username" />
<label>password:</label> <input type="password" name="password" />
<?php
if (isset($_POST["login"]) && isset($login))
if ($login->error != NULL) echo "<font style=\"color: #831f1f\">$login->error</font> <br>";
?>
<input type="submit" name="login" value="login" />
</form>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php require("includes/footer.php"); ?>
</tbody>
</table>
</body>
</html>

70
views/post.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
$post = new Post($_SESSION["user"], $conn);
if (!$post->getSpecifcPost(htmlspecialchars($post_id)))
header("Location: /");
$post_details = $post->getSpecifcPost(htmlspecialchars($post_id));
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="/styles/main.css">
<script src="/scripts/from-now.js"></script>
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require("includes/header.php"); ?>
<tr>
<?php require("includes/left_sidebar.php"); ?>
<td valign="top" align="left">
<table class="quack-container">
<tbody>
<tr>
<td>
<h2><?= $post_details['title']; ?></h2>
</td>
</tr>
<tr>
<td class="status-box">
by <h1><?= $post_details["author"]; ?> <img src="/images/badges/user.gif" alt="user"></h1>
<h2>- <span id="date-time"><?= $post_details["date"]; ?></span></h2>
<?php
if ($_SESSION["user"] == $post_details["author"])
echo "<a href=\"/delete_quack/".$post_details["id"]."\"><img alt=\"Delete\" src=\"/images/buttons/del.gif\" \></a>";
?>
</td>
</tr>
<tr>
<td class="quack-content">
<?= $post_details['content']; ?>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php require("includes/footer.php"); ?>
</tbody>
</table>
<script>
var alltimeStamps = document.querySelectorAll('#date-time');
// A little stack overflow-ish code?
for (var t=0;t<alltimeStamps.length; t++) {
const stringUTC = alltimeStamps[t].textContent.replace(' ', 'T') + 'Z';
const objUTC = new Date(stringUTC);
objUTC.setTime(objUTC.getTime() + objUTC.getTimezoneOffset()*60*1000);
console.log(alltimeStamps[t].textContent);
alltimeStamps[t].textContent = fromNow(objUTC);
}
</script>
</body>
</html>

69
views/scripts/from-now.js Normal file
View File

@@ -0,0 +1,69 @@
/**
* Implements all the behaviors of moment.fromNow(). Pass a
* valid JavaScript Date object and the method will return the
* time that has passed since that date in a human-readable
* format. Passes the moment test suite for `fromNow()`.
* See: https://momentjs.com/docs/#/displaying/fromnow/
*
* @example
*
* var pastDate = new Date('2017-10-01T02:30');
* var message = fromNow(pastDate);
* //=> '2 days ago'
*
* @license
*
* Copyright 2023 David Leonard
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @param {Date} Native JavaScript Date object
* @return {string}
*/
function fromNow(date) {
var seconds = Math.floor((new Date() - date) / 1000);
var years = Math.floor(seconds / 31536000);
var months = Math.floor(seconds / 2592000);
var days = Math.floor(seconds / 86400);
if (days > 548) {
return years + " years ago";
}
if (days >= 320 && days <= 547) {
return "a year ago";
}
if (days >= 45 && days <= 319) {
return months + " months ago";
}
if (days >= 26 && days <= 45) {
return "a month ago";
}
var hours = Math.floor(seconds / 3600);
if (hours >= 36 && days <= 25) {
return days + " days ago";
}
if (hours >= 22 && hours <= 35) {
return "a day ago";
}
var minutes = Math.floor(seconds / 60);
if (minutes >= 90 && hours <= 21) {
return hours + " hours ago";
}
if (minutes >= 45 && minutes <= 89) {
return "an hour ago";
}
if (seconds >= 90 && minutes <= 44) {
return minutes + " minutes ago";
}
if (seconds >= 45 && seconds <= 89) {
return "a minute ago";
}
if (seconds >= 0 && seconds <= 45) {
return "a few seconds ago";
}
}

File diff suppressed because it is too large Load Diff

122
views/settings.php Normal file
View File

@@ -0,0 +1,122 @@
<?php
if (!isset($_SESSION["user"]))
header("Location: /");
if (isset($_GET["m"]) && htmlspecialchars($_GET["m"]) != "privacy")
header("Location: /settings");
if (isset($_POST["update"])) {
$form = (object) [
"username" => htmlspecialchars($_POST["username"]),
"bio" => htmlspecialchars($_POST["bio"]),
"password" => htmlspecialchars($_POST["password"]),
"password_confirm" => htmlspecialchars($_POST["password_2"]),
];
$settings = new Settings($_SESSION["user"], $conn);
$settings->getForm($form->username, $form->bio, $form->password);
$settings->updateUsername();
$settings->updateBio();
$settings->updatePassword($form->password_confirm);
}
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require("includes/header.php"); ?>
<tr>
<?php require("includes/left_sidebar.php"); ?>
<td valign="top">
<table class="box-tab">
<tbody>
<tr>
<th align="left">
<a <?php if (isset($_GET["m"])) echo "id=\"non-selected\""; ?> href="/settings">main settings</a>
<a <?php if (!isset($_GET["m"]) || htmlspecialchars($_GET["m"]) != "privacy") echo "id=\"non-selected\""; ?> href="/settings?m=privacy">privacy</a>
</th>
</tr>
<tr>
<td>
<?php
if (!isset($_GET["m"])) {
?>
<table align="center" class="open-form">
<tbody>
<form action="/settings" method="POST">
<tr>
<th class="form-header" align="left">account details</th>
</tr>
<tr>
<td class="label-box" align="right">username: </td>
<td><input type="text" name="username" value="<?= $account->getDetails("username"); ?>"></td>
</tr>
<tr>
<td class="label-box" valign="top" align="right">bio: </td>
<td><textarea name="bio" rows="5" cols="30"><?= $account->getDetails("bio"); ?></textarea></td>
</tr>
<tr>
<th class="form-header" align="left">security</th>
</tr>
<tr>
<td class="label-box" align="right">password: </td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td class="label-box" align="right">confirm password: </td>
<td><input type="password" name="password_2"></td>
</tr>
<tr>
<td></td>
<td class="small-text">
<?php
if (isset($_POST["update"]) && isset($settings))
if ($settings->error != NULL) echo "<font style=\"color: #831f1f\">$settings->error</font> <br>";
?>
</td>
</tr>
<tr>
<td></td>
<td class="submit-pad"><input type="submit" name="update" value="update"></td>
</tr>
</form>
</tbody>
</table>
<?php
}
?>
<?php
if (isset($_GET["m"]) && htmlspecialchars($_GET["m"]) == "privacy") {
?>
<p>Page under construction</p>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php require("includes/footer.php"); ?>
</tbody>
</table>
</body>
</html>

402
views/styles/main.css Normal file
View File

@@ -0,0 +1,402 @@
body {
background: url('/images/background.gif') no-repeat;
background-color: #9D9D82;
font-family: Comic Sans MS, Arial, sans-serif;
font-size: 10px;
text-align: center;
}
table {
border-collapse: collapse;
}
td.slogan {
padding: 5px;
font-size: 10px;
color: #5a5a4a;
width: 370px;
}
a {
color: #5a5a4b;
}
.header a:hover {
text-decoration: underline;
}
.header a {
text-decoration: none;
}
.container {
width: 740px;
}
.introduction {
font-size: 10px;
padding: 10px;
}
h1, h2, h3, p {
margin: 0;
padding: 0;
}
table.form-box {
width: 100px;
background-color: #838266;
border: 1px Solid black;
}
table.login-box {
width: 100px;
}
input {
border: 1px Solid black;
padding: 2px;
font-size: 10px;
}
label {
font-size: 10px;
}
input[type="submit"] {
font-weight: bold;
padding: 4px;
}
td.form-container {
padding: 0px 10px 0px 10px;
}
.form-box input[type="submit"] {
margin-top: 5px;
background-color: #6e6d55;
color: white;
}
.form-box form {
padding: 5px;
text-align: center;
margin: 0px;
}
.form-box label {
float: left;
}
.form-box input[type="text"], .form-box input[type="password"] {
width: 94px;
}
.form-box th {
font-size: 12px;
text-align: left;
padding: 4px;
background-color: #62624f;
color: white;
border-bottom: black;
}
hr {
border-top: 1px Solid #8c8c74;
border-bottom: none;
margin-bottom: 4px;
}
table.form-box.big-box {
width: 700px;
}
.big-box td {
padding: 4px;
font-size: 12px;
}
.big-box input[type="text"], .big-box input[type="password"] {
width: 200px;
}
td.label-box {
width: 120px;
font-weight: bold;
}
td.right-hidden-border {
border-right-style: hidden;
}
tr.top-hidden-border {
border-top-style: hidden;
}
td.small-text {
font-size: 10px;
}
td.submit-pad {
padding: 0 0 5 0;
}
table.form-box.big-box.login {
width: 390px;
}
td.account-status {
width: 200px;
font-size: 15px;
}
table.box-tab {
width: 500px;
}
.box-tab th a {
border-left: 1px Solid #808080;
border-right: 1px Solid #808080;
border-top: 1px Solid #808080;
border-bottom: 1px Solid #abab88;
padding: 0px 7px 0px 7px;
font-size: 14px;
text-decoration: none;
background-color: #abab88;
z-index: 2;
position: relative;
}
.box-tab th a:hover, #non-selected:hover {
background-color: #9f9f7d;
}
#non-selected {
display: inline-block;
z-index: 1;
background-color: #939373;
}
.box-tab th {
position: absolute;
margin-left: 5px;
}
.box-tab td, .quack-container {
border: 1px Solid #808080;
background-color: #abab88;
z-index: 1;
position: relative;
display: block;
margin-top: 23px;
padding: 5px;
}
table.open-form {
width: 480px;
}
.box-tab .open-form td {
display: inline-block;
margin: 0;
padding: 3px;
position: static;
width: 130px;
border: 0;
font-size: 12px;
}
th.form-header {
position: static;
border-bottom: 1px Solid #87876a;
color: #6f6f5b;
margin-bottom: 6px;
display: block;
}
.open-form td.small-text {
width: 200px;
font-size: 10px;
}
textarea {
border: 1px Solid black;
}
.form-box font {
font-size: 10px;
}
table.sidebar-tabs {
background-color: #adad94;
border: 1px Solid #888888;
width: 122px;
margin-bottom: 10px;
}
.sidebar-tabs td {
width: 120px;
}
.sidebar-tabs a {
text-decoration: none;
display: block;
padding: 2px 5px 2px 5px;
font-size: 14px;
}
.sidebar-tabs a:hover {
background-color: #999982;
}
span.tab-header {
font-size: 14px;
font-weight: bold;
color: #5a5a4a;
}
.sidebar-tabs img {
vertical-align: middle;
}
a, img {
border: none;
}
.post-container .speech-bubble {
width: 352px;
height: 100;
background: url("/images/speech_bubble_post.gif");
}
.post-container .pfp {
border: 1px Solid #888888;
}
textarea.post-text, input.post-text {
font-family: Comic Sans MS;
font-size: 12px;
margin-bottom: 2px;
border: 1px Solid #87873b;
background-color: #b7b750;
margin-left: 19px;
width: 293px;
resize: none;
}
span.post-label {
font-size: 9px;
font-weight: bold;
font-family: Verdana;
float: right;
margin-right: 40px;
}
.post-container input[type="submit"] {
width: 47px;
margin-top: 5px;
}
input[type="submit"]:hover {
background-color: #d1d1d1;
cursor: hand;
}
.form-box input[type="submit"]:hover {
background-color: #4d4c3c;
}
input.post-text {
font-weight: bold;
}
.box-tab.small-tabs a {
font-size: 12px;
}
.box-tab.small-tabs.feed {
width: 402px;
}
.status-feed, .status-box {
width: 100%;
}
.status-feed td, .status-box td {
margin: 0;
}
.status-box h1 {
font-size: 14px;
}
.status-box h2 {
font-size: 10px;
font-weight: normal;
margin-left: 3px;
color: #6c6c58;
}
.status-box .title {
display: inline-block;
width: 100%;
}
.status-box td {
font-size: 11px;
padding: 0px;
border: 0;
word-break: break-all;
}
.status-box h1, .status-box h2 {
/*! float: left; */
vertical-align: middle;
display: inline;
}
.status-box img {
vertical-align: middle;
}
.bottom-border.status-box {
border-bottom: 1px dashed gray;
padding-bottom: 5px;
margin-bottom: 5px;
display: block;
}
.hint {
color: #7b7b5a;
font-size: 11px;
}
.blog-button {
text-decoration: none;
color: black;
padding: 1px;
}
.blog-button:hover {
background-color: #91916e;
}
.right {
float: right;
}
.bottom-border tr, .bottom-border td, .bottom-border tbody {
display: block;
}
.quack-container {
width: 70%;
}
.quack-container td {
margin-top: 10px;
}
td.quack-content {
font-size: 12px;
word-break: break-word;
}

82
views/temp_reg.php Normal file
View File

@@ -0,0 +1,82 @@
<?php
if (isset($_SESSION["user"]))
header("Location: /");
if (isset($_POST["register"])) {
$form = (object) [
"username" => htmlspecialchars($_POST["username"]),
"password" => htmlspecialchars($_POST["password"]),
"password_confirm" => htmlspecialchars($_POST["password_2"]),
];
$register = new Register($form->username, $form->password, $conn);
$register->checkUsername();
$register->checkPassword($form->password_confirm);
if ($register->error == NULL) {
$register->insertUser();
header("Location: /");
}
}
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require("includes/header.php"); ?>
<tr>
<td>
<table class="form-box big-box login" align="center" border="1">
<tbody>
<tr>
<th align="left" colspan="2">Duck register</th>
</tr>
<form action="/temp_register" method="POST">
<tr>
<td class="label-box" align="right">username: </td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td class="label-box" align="right">password: </td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td class="label-box" align="right">confirm password: </td>
<td><input type="password" name="password_2" /></td>
</tr>
<tr>
<td class="right-hidden-border"></td>
<td class="small-text">
<?php
if (isset($_POST["register"]) && isset($register))
if ($register->error != NULL) echo "<font style=\"color: #831f1f\">$register->error</font> <br>";
?>
</td>
</tr>
<tr class="top-hidden-border">
<td class="right-hidden-border"></td>
<td class="submit-pad"><input type="submit" name="register" value="register" /></td>
</tr>
</form>
</tbody>
</table>
</td>
</tr>
<?php require("includes/footer.php"); ?>
</tbody>
</table>
</body>
</html>