commit 457d8a0d4c30669f74fa707709a6c3f7e1422ec5 Author: goom <30990201+MarkMrGamer@users.noreply.github.com> Date: Sat Nov 22 23:57:26 2025 -0800 Pushing all files from my usb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c172dc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +config.inc.php \ No newline at end of file diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..b03b653 --- /dev/null +++ b/.htaccess @@ -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] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..31172f7 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# MallardNet +MallardNet is a marcoblogging site created in 2025. + +

what is use

+ + +

how to get it running in your web environment

+ +

i made these instructions because it has composer, so it needs the steps in either not to have errors without the /vendor/ folder

1. have composer installed on your computer
2. put all of this stuff in your www folder
3. run composer update to establish /vendor/ folder (requires because it uses a router)
4. install. sql file in a new database
5. change config.sample.inc.php to config.inc.php and then change the database details to your. database and db account details.
6. done, . its running, can code yipee

diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a2c1ad0 --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "bramus/router": "~1.6" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..9bedf2f --- /dev/null +++ b/composer.lock @@ -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" +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..45844e7 --- /dev/null +++ b/index.php @@ -0,0 +1,122 @@ +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(); +?> \ No newline at end of file diff --git a/lib/classes/Account.php b/lib/classes/Account.php new file mode 100644 index 0000000..3187c74 --- /dev/null +++ b/lib/classes/Account.php @@ -0,0 +1,35 @@ +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; + } + } +?> \ No newline at end of file diff --git a/lib/classes/Login.php b/lib/classes/Login.php new file mode 100644 index 0000000..dfae798 --- /dev/null +++ b/lib/classes/Login.php @@ -0,0 +1,52 @@ +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; + } + } +?> \ No newline at end of file diff --git a/lib/classes/Post.php b/lib/classes/Post.php new file mode 100644 index 0000000..33b3f73 --- /dev/null +++ b/lib/classes/Post.php @@ -0,0 +1,87 @@ +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; + } + } +?> \ No newline at end of file diff --git a/lib/classes/Register.php b/lib/classes/Register.php new file mode 100644 index 0000000..65c81fb --- /dev/null +++ b/lib/classes/Register.php @@ -0,0 +1,64 @@ +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; + } + } +?> \ No newline at end of file diff --git a/lib/classes/Settings.php b/lib/classes/Settings.php new file mode 100644 index 0000000..fbb9e84 --- /dev/null +++ b/lib/classes/Settings.php @@ -0,0 +1,107 @@ +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; + } + } +?> \ No newline at end of file diff --git a/mallar.sql b/mallar.sql new file mode 100644 index 0000000..f8da43e --- /dev/null +++ b/mallar.sql @@ -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'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 */; diff --git a/views/apply.php b/views/apply.php new file mode 100644 index 0000000..bd64f52 --- /dev/null +++ b/views/apply.php @@ -0,0 +1,66 @@ + + + <?= $website->title; ?>: <?= $website->slogan; ?> + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sign up application
+ To register for MallardNet, 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. +
email:
Why do you want to join MallardNet?
From where did you hear about this site?
+ By submitting this application, you agree that you have read and understood our + Site Use Guidelines. +
+
+ + \ No newline at end of file diff --git a/views/dupes/home/feed_gallery.php b/views/dupes/home/feed_gallery.php new file mode 100644 index 0000000..7145ec1 --- /dev/null +++ b/views/dupes/home/feed_gallery.php @@ -0,0 +1,177 @@ +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"); + } + } +?> + + + <?= $website->title; ?>: <?= $website->slogan; ?> + + + + + + + + + + + + + + + + + +
+ + + error != NULL) echo "$post->error
"; + ?> + + + + + + + +
+ + + + + duck + +
+ + + + + + + + + + +
+ micros + marcos + gallery +
+ + + + + + +
+ getPosts(3)->rowCount() <= 0) + echo "

There are currently no quacks in this section.

"; // rare message + + foreach ($post->getPosts(3) as $p) { + $rowIndex++; + if ($rowIndex != $post->getPosts(3)->rowCount()) { + echo ""; + } else { + echo "
"; + } + ?> + + + + + + + + + + +
+

user

+

-

+ + (">Delete) + + +
+
+ +
+ +
+
+
+ + + + \ No newline at end of file diff --git a/views/dupes/home/feed_macros.php b/views/dupes/home/feed_macros.php new file mode 100644 index 0000000..ea640c7 --- /dev/null +++ b/views/dupes/home/feed_macros.php @@ -0,0 +1,175 @@ +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: /"); + } + } +?> + + + <?= $website->title; ?>: <?= $website->slogan; ?> + + + + + + + + + + + + + + + + + +
+ + + error != NULL) echo "$post->error
"; + ?> + + + + + + + +
+ + + + + duck + +
+ + + + + + + + + + +
+ micros + macros + gallery +
+ + + + + + +
+ getPosts()->rowCount() <= 0) + echo "

There are currently no quacks in this feed.

"; // rare message + + foreach ($post->getPosts() as $p) { + $rowIndex++; + if ($rowIndex != $post->getPosts()->rowCount()) { + echo ""; + } else { + echo "
"; + } + ?> + + + + + + + + + + +
+

user

+

-

+ + (">Delete) + + +
+
+ +
+ +
+
+
+ + + + \ No newline at end of file diff --git a/views/dupes/home/feed_marcos.php b/views/dupes/home/feed_marcos.php new file mode 100644 index 0000000..e0b8aff --- /dev/null +++ b/views/dupes/home/feed_marcos.php @@ -0,0 +1,177 @@ +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"); + } + } + } +?> + + + <?= $website->title; ?>: <?= $website->slogan; ?> + + + + + + + + + + + + + + + + + +
+ + + error != NULL) echo "$post->error
"; + ?> + + + + + + + +
+ + + + + duck + +
+ + + + + + + + + + +
+ micros + marcos + gallery +
+ + + + + + +
+ getPosts(2)->rowCount() <= 0) + echo "

There are currently no quacks in this section.

"; // rare message + + foreach ($post->getPosts(2) as $p) { + $rowIndex++; + if ($rowIndex != $post->getPosts(2)->rowCount()) { + echo ""; + } else { + echo "
"; + } + ?> + + + + + + + + +
+ " class="blog-button">

+ + \"Delete\" + "; + ?> +
+ by +

user

+

-

+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/views/dupes/home/feed_micros.php b/views/dupes/home/feed_micros.php new file mode 100644 index 0000000..e0e0598 --- /dev/null +++ b/views/dupes/home/feed_micros.php @@ -0,0 +1,197 @@ +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"); + } + } + } +?> + + + <?= $website->title; ?>: <?= $website->slogan; ?> + + + + + + + + + + + + + + + + + +
+ + + error != NULL) echo "$post->error
"; + ?> + + + + + + + +
+ + + + + duck + +
+ + + + + + + + + + +
+ micros + marcos + gallery +
+ + + + + + + +
+ getPosts(1)->rowCount() <= 0) + echo "

There are currently no quacks in this section.

"; // 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 ""; + } else { + echo "
"; + } + ?> + + + + + + + + + + +
+

user

+

-

+ + \"Delete\" + "; + ?> + +
+ +
+ +
+ +
+
+
+ + + + \ No newline at end of file diff --git a/views/images/background.gif b/views/images/background.gif new file mode 100644 index 0000000..e1dd9a0 Binary files /dev/null and b/views/images/background.gif differ diff --git a/views/images/badges/moderator.gif b/views/images/badges/moderator.gif new file mode 100644 index 0000000..15ee178 Binary files /dev/null and b/views/images/badges/moderator.gif differ diff --git a/views/images/badges/owner.gif b/views/images/badges/owner.gif new file mode 100644 index 0000000..147b3cf Binary files /dev/null and b/views/images/badges/owner.gif differ diff --git a/views/images/badges/user.gif b/views/images/badges/user.gif new file mode 100644 index 0000000..416d58a Binary files /dev/null and b/views/images/badges/user.gif differ diff --git a/views/images/buttons/del.gif b/views/images/buttons/del.gif new file mode 100644 index 0000000..0e27e67 Binary files /dev/null and b/views/images/buttons/del.gif differ diff --git a/views/images/footer_text.gif b/views/images/footer_text.gif new file mode 100644 index 0000000..1ec2f0e Binary files /dev/null and b/views/images/footer_text.gif differ diff --git a/views/images/logo.gif b/views/images/logo.gif new file mode 100644 index 0000000..f35cdde Binary files /dev/null and b/views/images/logo.gif differ diff --git a/views/images/logo.pdn b/views/images/logo.pdn new file mode 100644 index 0000000..fd546c8 Binary files /dev/null and b/views/images/logo.pdn differ diff --git a/views/images/logo_alt.gif b/views/images/logo_alt.gif new file mode 100644 index 0000000..6d0d3ea Binary files /dev/null and b/views/images/logo_alt.gif differ diff --git a/views/images/old_logo.gif b/views/images/old_logo.gif new file mode 100644 index 0000000..93dcae5 Binary files /dev/null and b/views/images/old_logo.gif differ diff --git a/views/images/posting_bg_3.gif b/views/images/posting_bg_3.gif new file mode 100644 index 0000000..bbfca3b Binary files /dev/null and b/views/images/posting_bg_3.gif differ diff --git a/views/images/profile_pic/duck.gif b/views/images/profile_pic/duck.gif new file mode 100644 index 0000000..1b9c654 Binary files /dev/null and b/views/images/profile_pic/duck.gif differ diff --git a/views/images/speech_bubble_post.gif b/views/images/speech_bubble_post.gif new file mode 100644 index 0000000..1d043c5 Binary files /dev/null and b/views/images/speech_bubble_post.gif differ diff --git a/views/images/tab_icons/everyone.gif b/views/images/tab_icons/everyone.gif new file mode 100644 index 0000000..979199d Binary files /dev/null and b/views/images/tab_icons/everyone.gif differ diff --git a/views/images/tab_icons/friends.gif b/views/images/tab_icons/friends.gif new file mode 100644 index 0000000..2854a4f Binary files /dev/null and b/views/images/tab_icons/friends.gif differ diff --git a/views/images/tab_icons/items.gif b/views/images/tab_icons/items.gif new file mode 100644 index 0000000..1f1cf8c Binary files /dev/null and b/views/images/tab_icons/items.gif differ diff --git a/views/images/tab_icons/profile.gif b/views/images/tab_icons/profile.gif new file mode 100644 index 0000000..10bc70c Binary files /dev/null and b/views/images/tab_icons/profile.gif differ diff --git a/views/images/tab_icons/settings.gif b/views/images/tab_icons/settings.gif new file mode 100644 index 0000000..658554e Binary files /dev/null and b/views/images/tab_icons/settings.gif differ diff --git a/views/images/what.gif b/views/images/what.gif new file mode 100644 index 0000000..9199c2b Binary files /dev/null and b/views/images/what.gif differ diff --git a/views/includes/footer.php b/views/includes/footer.php new file mode 100644 index 0000000..1fcceb0 --- /dev/null +++ b/views/includes/footer.php @@ -0,0 +1,6 @@ + + +
+ footer text + + \ No newline at end of file diff --git a/views/includes/header.php b/views/includes/header.php new file mode 100644 index 0000000..dec910d --- /dev/null +++ b/views/includes/header.php @@ -0,0 +1,33 @@ +accountExists()) { + session_destroy(); + header('Location: /'); + } + } +?> + + + + + + + + + + + + + + +
<?= $website->title; ?>slogan; ?>
+ + \ No newline at end of file diff --git a/views/includes/left_sidebar.php b/views/includes/left_sidebar.php new file mode 100644 index 0000000..b051e73 --- /dev/null +++ b/views/includes/left_sidebar.php @@ -0,0 +1,30 @@ + + feed + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/views/login.php b/views/login.php new file mode 100644 index 0000000..a431853 --- /dev/null +++ b/views/login.php @@ -0,0 +1,77 @@ + 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: /"); + } + } +?> + + + <?= $website->title; ?>: <?= $website->slogan; ?> + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + \ No newline at end of file diff --git a/views/main.php b/views/main.php new file mode 100644 index 0000000..688bbf7 --- /dev/null +++ b/views/main.php @@ -0,0 +1,82 @@ + 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: /"); + } + } +?> + + + <?= $website->title; ?>: <?= $website->slogan; ?> + + + + + + + + + + + + + + + + +
+ + + + + + + +
duck typing quack quack +

WHAT IS MALLARDNET?

+

+ 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 three categories. +

+
    +
  • marco posts - blog-type posts
  • +
  • mirco posts - teeny tiny updates
  • +
  • image posts - for photography users or creative users who wants to share their world and creativity
  • +
+ so what are you waiting for? apply now +
+
+ + \ No newline at end of file diff --git a/views/post.php b/views/post.php new file mode 100644 index 0000000..03a6e99 --- /dev/null +++ b/views/post.php @@ -0,0 +1,70 @@ +getSpecifcPost(htmlspecialchars($post_id))) + header("Location: /"); + + $post_details = $post->getSpecifcPost(htmlspecialchars($post_id)); +?> + + + <?= $website->title; ?>: <?= $website->slogan; ?> + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+

+
+ by

user

+

-

+ \"Delete\""; + ?> +
+ +
+
+ + + + \ No newline at end of file diff --git a/views/scripts/from-now.js b/views/scripts/from-now.js new file mode 100644 index 0000000..7ebcd96 --- /dev/null +++ b/views/scripts/from-now.js @@ -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"; + } +} diff --git a/views/scripts/humanize-duration.js b/views/scripts/humanize-duration.js new file mode 100644 index 0000000..ad077b3 --- /dev/null +++ b/views/scripts/humanize-duration.js @@ -0,0 +1,1596 @@ +// HumanizeDuration.js - https://git.io/j0HgmQ + +/** + * @typedef {string | ((unitCount: number) => string)} Unit + */ + +/** + * @typedef {"y" | "mo" | "w" | "d" | "h" | "m" | "s" | "ms"} UnitName + */ + +/** + * @typedef {Object} UnitMeasures + * @prop {number} y + * @prop {number} mo + * @prop {number} w + * @prop {number} d + * @prop {number} h + * @prop {number} m + * @prop {number} s + * @prop {number} ms + */ + +/** + * @internal + * @typedef {[string, string, string, string, string, string, string, string, string, string]} DigitReplacements + */ + +/** + * @typedef {Object} Language + * @prop {Unit} y + * @prop {Unit} mo + * @prop {Unit} w + * @prop {Unit} d + * @prop {Unit} h + * @prop {Unit} m + * @prop {Unit} s + * @prop {Unit} ms + * @prop {string} [decimal] + * @prop {string} [delimiter] + * @prop {DigitReplacements} [_digitReplacements] + * @prop {boolean} [_numberFirst] + * @prop {boolean} [_hideCountIf2] + */ + +/** + * @typedef {Object} Options + * @prop {string} [language] + * @prop {Record} [languages] + * @prop {string[]} [fallbacks] + * @prop {string} [delimiter] + * @prop {string} [spacer] + * @prop {boolean} [round] + * @prop {number} [largest] + * @prop {UnitName[]} [units] + * @prop {string} [decimal] + * @prop {string} [conjunction] + * @prop {number} [maxDecimalPoints] + * @prop {UnitMeasures} [unitMeasures] + * @prop {boolean} [serialComma] + * @prop {DigitReplacements} [digitReplacements] + */ + +/** + * @internal + * @typedef {Required} NormalizedOptions + */ + +(function () { + // Fallback for `Object.assign` if relevant. + var assign = + Object.assign || + /** @param {...any} destination */ + function (destination) { + var source; + for (var i = 1; i < arguments.length; i++) { + source = arguments[i]; + for (var prop in source) { + if (has(source, prop)) { + destination[prop] = source[prop]; + } + } + } + return destination; + }; + + // Fallback for `Array.isArray` if relevant. + var isArray = + Array.isArray || + function (arg) { + return Object.prototype.toString.call(arg) === "[object Array]"; + }; + + // This has to be defined separately because of a bug: we want to alias + // `gr` and `el` for backwards-compatiblity. In a breaking change, we can + // remove `gr` entirely. + // See https://github.com/EvanHahn/HumanizeDuration.js/issues/143 for more. + var GREEK = onesLanguage( + ["χρόνος", "χρόνια"], + ["μήνας", "μήνες"], + ["εβδομάδα", "εβδομάδες"], + ["μέρα", "μέρες"], + ["ώρα", "ώρες"], + ["λεπτό", "λεπτά"], + ["δευτερόλεπτο", "δευτερόλεπτα"], + ["χιλιοστό του δευτερολέπτου", "χιλιοστά του δευτερολέπτου"], + "," + ); + + /** + * @internal + * @type {Record} + */ + var LANGUAGES = { + af: onesLanguage( + ["jaar", "jaar"], + ["maand", "maande"], + ["week", "weke"], + ["dag", "dae"], + ["uur", "ure"], + ["minuut", "minute"], + ["sekonde", "sekondes"], + ["millisekonde", "millisekondes"], + "," + ), + am: language("ዓመት", "ወር", "ሳምንት", "ቀን", "ሰዓት", "ደቂቃ", "ሰከንድ", "ሚሊሰከንድ"), + ar: assign( + language( + function (c) { + return ["سنة", "سنتان", "سنوات"][getArabicForm(c)]; + }, + function (c) { + return ["شهر", "شهران", "أشهر"][getArabicForm(c)]; + }, + function (c) { + return ["أسبوع", "أسبوعين", "أسابيع"][getArabicForm(c)]; + }, + function (c) { + return ["يوم", "يومين", "أيام"][getArabicForm(c)]; + }, + function (c) { + return ["ساعة", "ساعتين", "ساعات"][getArabicForm(c)]; + }, + function (c) { + return ["دقيقة", "دقيقتان", "دقائق"][getArabicForm(c)]; + }, + function (c) { + return ["ثانية", "ثانيتان", "ثواني"][getArabicForm(c)]; + }, + function (c) { + return ["جزء من الثانية", "جزآن من الثانية", "أجزاء من الثانية"][ + getArabicForm(c) + ]; + }, + "," + ), + { + delimiter: " ﻭ ", + _hideCountIf2: true, + _digitReplacements: ["۰", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"] + } + ), + bg: slavicLanguage( + ["години", "година", "години"], + ["месеца", "месец", "месеца"], + ["седмици", "седмица", "седмици"], + ["дни", "ден", "дни"], + ["часа", "час", "часа"], + ["минути", "минута", "минути"], + ["секунди", "секунда", "секунди"], + ["милисекунди", "милисекунда", "милисекунди"] + ), + bn: language( + "বছর", + "মাস", + "সপ্তাহ", + "দিন", + "ঘন্টা", + "মিনিট", + "সেকেন্ড", + "মিলিসেকেন্ড" + ), + ca: onesLanguage( + ["any", "anys"], + ["mes", "mesos"], + ["setmana", "setmanes"], + ["dia", "dies"], + ["hora", "hores"], + ["minut", "minuts"], + ["segon", "segons"], + ["milisegon", "milisegons"], + "," + ), + ckb: language( + "ساڵ", + "مانگ", + "هەفتە", + "ڕۆژ", + "کاژێر", + "خولەک", + "چرکە", + "میلی چرکە", + "." + ), + cs: language( + function (c) { + return ["rok", "roku", "roky", "let"][getCzechOrSlovakForm(c)]; + }, + function (c) { + return ["měsíc", "měsíce", "měsíce", "měsíců"][getCzechOrSlovakForm(c)]; + }, + function (c) { + return ["týden", "týdne", "týdny", "týdnů"][getCzechOrSlovakForm(c)]; + }, + function (c) { + return ["den", "dne", "dny", "dní"][getCzechOrSlovakForm(c)]; + }, + function (c) { + return ["hodina", "hodiny", "hodiny", "hodin"][getCzechOrSlovakForm(c)]; + }, + function (c) { + return ["minuta", "minuty", "minuty", "minut"][getCzechOrSlovakForm(c)]; + }, + function (c) { + return ["sekunda", "sekundy", "sekundy", "sekund"][ + getCzechOrSlovakForm(c) + ]; + }, + function (c) { + return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][ + getCzechOrSlovakForm(c) + ]; + }, + "," + ), + cy: language( + "flwyddyn", + "mis", + "wythnos", + "diwrnod", + "awr", + "munud", + "eiliad", + "milieiliad" + ), + da: onesLanguage( + ["år", "år"], + ["måned", "måneder"], + ["uge", "uger"], + ["dag", "dage"], + ["time", "timer"], + ["minut", "minutter"], + ["sekund", "sekunder"], + ["millisekund", "millisekunder"], + "," + ), + de: onesLanguage( + ["Jahr", "Jahre"], + ["Monat", "Monate"], + ["Woche", "Wochen"], + ["Tag", "Tage"], + ["Stunde", "Stunden"], + ["Minute", "Minuten"], + ["Sekunde", "Sekunden"], + ["Millisekunde", "Millisekunden"], + "," + ), + el: GREEK, + en: onesLanguage( + ["year", "years"], + ["month", "months"], + ["week", "weeks"], + ["day", "days"], + ["hour", "hours"], + ["minute", "minutes"], + ["second", "seconds"], + ["millisecond", "milliseconds"] + ), + eo: onesLanguage( + ["jaro", "jaroj"], + ["monato", "monatoj"], + ["semajno", "semajnoj"], + ["tago", "tagoj"], + ["horo", "horoj"], + ["minuto", "minutoj"], + ["sekundo", "sekundoj"], + ["milisekundo", "milisekundoj"], + "," + ), + es: onesLanguage( + ["año", "años"], + ["mes", "meses"], + ["semana", "semanas"], + ["día", "días"], + ["hora", "horas"], + ["minuto", "minutos"], + ["segundo", "segundos"], + ["milisegundo", "milisegundos"], + "," + ), + et: onesLanguage( + ["aasta", "aastat"], + ["kuu", "kuud"], + ["nädal", "nädalat"], + ["päev", "päeva"], + ["tund", "tundi"], + ["minut", "minutit"], + ["sekund", "sekundit"], + ["millisekund", "millisekundit"], + "," + ), + eu: language( + "urte", + "hilabete", + "aste", + "egun", + "ordu", + "minutu", + "segundo", + "milisegundo", + "," + ), + fa: language( + "سال", + "ماه", + "هفته", + "روز", + "ساعت", + "دقیقه", + "ثانیه", + "میلی ثانیه" + ), + fi: onesLanguage( + ["vuosi", "vuotta"], + ["kuukausi", "kuukautta"], + ["viikko", "viikkoa"], + ["päivä", "päivää"], + ["tunti", "tuntia"], + ["minuutti", "minuuttia"], + ["sekunti", "sekuntia"], + ["millisekunti", "millisekuntia"], + "," + ), + fo: onesLanguage( + ["ár", "ár"], + ["mánaður", "mánaðir"], + ["vika", "vikur"], + ["dagur", "dagar"], + ["tími", "tímar"], + ["minuttur", "minuttir"], + ["sekund", "sekund"], + ["millisekund", "millisekund"], + "," + ), + fr: language( + function (c) { + return "an" + (c >= 2 ? "s" : ""); + }, + "mois", + function (c) { + return "semaine" + (c >= 2 ? "s" : ""); + }, + function (c) { + return "jour" + (c >= 2 ? "s" : ""); + }, + function (c) { + return "heure" + (c >= 2 ? "s" : ""); + }, + function (c) { + return "minute" + (c >= 2 ? "s" : ""); + }, + function (c) { + return "seconde" + (c >= 2 ? "s" : ""); + }, + function (c) { + return "milliseconde" + (c >= 2 ? "s" : ""); + }, + "," + ), + gr: GREEK, + he: onesLanguage( + ["שנה", "שנים"], + ["חודש", "חודשים"], + ["שבוע", "שבועות"], + ["יום", "ימים"], + ["שעה", "שעות"], + ["דקה", "דקות"], + ["שניה", "שניות"], + ["מילישנייה", "מילישניות"] + ), + hr: language( + function (c) { + if (c % 10 === 2 || c % 10 === 3 || c % 10 === 4) { + return "godine"; + } + return "godina"; + }, + function (c) { + if (c === 1) { + return "mjesec"; + } else if (c === 2 || c === 3 || c === 4) { + return "mjeseca"; + } + return "mjeseci"; + }, + function (c) { + if (c % 10 === 1 && c !== 11) { + return "tjedan"; + } + return "tjedna"; + }, + onesUnit(["dan", "dana"]), + function (c) { + if (c === 1) { + return "sat"; + } else if (c === 2 || c === 3 || c === 4) { + return "sata"; + } + return "sati"; + }, + function (c) { + var mod10 = c % 10; + if ((mod10 === 2 || mod10 === 3 || mod10 === 4) && (c < 10 || c > 14)) { + return "minute"; + } + return "minuta"; + }, + function (c) { + var mod10 = c % 10; + if (mod10 === 5 || (Math.floor(c) === c && c >= 10 && c <= 19)) { + return "sekundi"; + } else if (mod10 === 1) { + return "sekunda"; + } else if (mod10 === 2 || mod10 === 3 || mod10 === 4) { + return "sekunde"; + } + return "sekundi"; + }, + function (c) { + if (c === 1) { + return "milisekunda"; + } else if (c % 10 === 2 || c % 10 === 3 || c % 10 === 4) { + return "milisekunde"; + } + return "milisekundi"; + }, + "," + ), + hi: language( + "साल", + onesUnit(["महीना", "महीने"]), + onesUnit(["हफ़्ता", "हफ्ते"]), + "दिन", + onesUnit(["घंटा", "घंटे"]), + "मिनट", + "सेकंड", + "मिलीसेकंड" + ), + hu: language( + "év", + "hónap", + "hét", + "nap", + "óra", + "perc", + "másodperc", + "ezredmásodperc", + "," + ), + id: language( + "tahun", + "bulan", + "minggu", + "hari", + "jam", + "menit", + "detik", + "milidetik" + ), + is: onesLanguage( + ["ár", "ár"], + ["mánuður", "mánuðir"], + ["vika", "vikur"], + ["dagur", "dagar"], + ["klukkutími", "klukkutímar"], + ["mínúta", "mínútur"], + ["sekúnda", "sekúndur"], + ["millisekúnda", "millisekúndur"] + ), + it: onesLanguage( + ["anno", "anni"], + ["mese", "mesi"], + ["settimana", "settimane"], + ["giorno", "giorni"], + ["ora", "ore"], + ["minuto", "minuti"], + ["secondo", "secondi"], + ["millisecondo", "millisecondi"], + "," + ), + ja: language("年", "ヶ月", "週間", "日", "時間", "分", "秒", "ミリ秒"), + km: language( + "ឆ្នាំ", + "ខែ", + "សប្តាហ៍", + "ថ្ងៃ", + "ម៉ោង", + "នាទី", + "វិនាទី", + "មិល្លីវិនាទី" + ), + kn: onesLanguage( + ["ವರ್ಷ", "ವರ್ಷಗಳು"], + ["ತಿಂಗಳು", "ತಿಂಗಳುಗಳು"], + ["ವಾರ", "ವಾರಗಳು"], + ["ದಿನ", "ದಿನಗಳು"], + ["ಗಂಟೆ", "ಗಂಟೆಗಳು"], + ["ನಿಮಿಷ", "ನಿಮಿಷಗಳು"], + ["ಸೆಕೆಂಡ್", "ಸೆಕೆಂಡುಗಳು"], + ["ಮಿಲಿಸೆಕೆಂಡ್", "ಮಿಲಿಸೆಕೆಂಡುಗಳು"] + ), + ko: language("년", "개월", "주일", "일", "시간", "분", "초", "밀리 초"), + ku: language( + "sal", + "meh", + "hefte", + "roj", + "seet", + "deqe", + "saniye", + "mîlîçirk", + "," + ), + lo: language( + "ປີ", + "ເດືອນ", + "ອາທິດ", + "ມື້", + "ຊົ່ວໂມງ", + "ນາທີ", + "ວິນາທີ", + "ມິນລິວິນາທີ", + "," + ), + lt: language( + function (c) { + return c % 10 === 0 || (c % 100 >= 10 && c % 100 <= 20) + ? "metų" + : "metai"; + }, + function (c) { + return ["mėnuo", "mėnesiai", "mėnesių"][getLithuanianForm(c)]; + }, + function (c) { + return ["savaitė", "savaitės", "savaičių"][getLithuanianForm(c)]; + }, + function (c) { + return ["diena", "dienos", "dienų"][getLithuanianForm(c)]; + }, + function (c) { + return ["valanda", "valandos", "valandų"][getLithuanianForm(c)]; + }, + function (c) { + return ["minutė", "minutės", "minučių"][getLithuanianForm(c)]; + }, + function (c) { + return ["sekundė", "sekundės", "sekundžių"][getLithuanianForm(c)]; + }, + function (c) { + return ["milisekundė", "milisekundės", "milisekundžių"][ + getLithuanianForm(c) + ]; + }, + "," + ), + lv: language( + function (c) { + return getLatvianForm(c) ? "gads" : "gadi"; + }, + function (c) { + return getLatvianForm(c) ? "mēnesis" : "mēneši"; + }, + function (c) { + return getLatvianForm(c) ? "nedēļa" : "nedēļas"; + }, + function (c) { + return getLatvianForm(c) ? "diena" : "dienas"; + }, + function (c) { + return getLatvianForm(c) ? "stunda" : "stundas"; + }, + function (c) { + return getLatvianForm(c) ? "minūte" : "minūtes"; + }, + function (c) { + return getLatvianForm(c) ? "sekunde" : "sekundes"; + }, + function (c) { + return getLatvianForm(c) ? "milisekunde" : "milisekundes"; + }, + "," + ), + mk: onesLanguage( + ["година", "години"], + ["месец", "месеци"], + ["недела", "недели"], + ["ден", "дена"], + ["час", "часа"], + ["минута", "минути"], + ["секунда", "секунди"], + ["милисекунда", "милисекунди"], + "," + ), + mn: language( + "жил", + "сар", + "долоо хоног", + "өдөр", + "цаг", + "минут", + "секунд", + "миллисекунд" + ), + mr: language( + onesUnit(["वर्ष", "वर्षे"]), + onesUnit(["महिना", "महिने"]), + onesUnit(["आठवडा", "आठवडे"]), + "दिवस", + "तास", + onesUnit(["मिनिट", "मिनिटे"]), + "सेकंद", + "मिलिसेकंद" + ), + ms: language( + "tahun", + "bulan", + "minggu", + "hari", + "jam", + "minit", + "saat", + "milisaat" + ), + nl: onesLanguage( + ["jaar", "jaar"], + ["maand", "maanden"], + ["week", "weken"], + ["dag", "dagen"], + ["uur", "uur"], + ["minuut", "minuten"], + ["seconde", "seconden"], + ["milliseconde", "milliseconden"], + "," + ), + no: onesLanguage( + ["år", "år"], + ["måned", "måneder"], + ["uke", "uker"], + ["dag", "dager"], + ["time", "timer"], + ["minutt", "minutter"], + ["sekund", "sekunder"], + ["millisekund", "millisekunder"], + "," + ), + pl: language( + function (c) { + return ["rok", "roku", "lata", "lat"][getPolishForm(c)]; + }, + function (c) { + return ["miesiąc", "miesiąca", "miesiące", "miesięcy"][ + getPolishForm(c) + ]; + }, + function (c) { + return ["tydzień", "tygodnia", "tygodnie", "tygodni"][getPolishForm(c)]; + }, + function (c) { + return ["dzień", "dnia", "dni", "dni"][getPolishForm(c)]; + }, + function (c) { + return ["godzina", "godziny", "godziny", "godzin"][getPolishForm(c)]; + }, + function (c) { + return ["minuta", "minuty", "minuty", "minut"][getPolishForm(c)]; + }, + function (c) { + return ["sekunda", "sekundy", "sekundy", "sekund"][getPolishForm(c)]; + }, + function (c) { + return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][ + getPolishForm(c) + ]; + }, + "," + ), + pt: onesLanguage( + ["ano", "anos"], + ["mês", "meses"], + ["semana", "semanas"], + ["dia", "dias"], + ["hora", "horas"], + ["minuto", "minutos"], + ["segundo", "segundos"], + ["milissegundo", "milissegundos"], + "," + ), + ro: onesLanguage( + ["an", "ani"], + ["lună", "luni"], + ["săptămână", "săptămâni"], + ["zi", "zile"], + ["oră", "ore"], + ["minut", "minute"], + ["secundă", "secunde"], + ["milisecundă", "milisecunde"], + "," + ), + ru: slavicLanguage( + ["лет", "год", "года"], + ["месяцев", "месяц", "месяца"], + ["недель", "неделя", "недели"], + ["дней", "день", "дня"], + ["часов", "час", "часа"], + ["минут", "минута", "минуты"], + ["секунд", "секунда", "секунды"], + ["миллисекунд", "миллисекунда", "миллисекунды"] + ), + sq: language( + onesUnit(["vit", "vjet"]), + "muaj", + "javë", + "ditë", + "orë", + function (c) { + return "minut" + (c === 1 ? "ë" : "a"); + }, + function (c) { + return "sekond" + (c === 1 ? "ë" : "a"); + }, + function (c) { + return "milisekond" + (c === 1 ? "ë" : "a"); + }, + "," + ), + sr: slavicLanguage( + ["години", "година", "године"], + ["месеци", "месец", "месеца"], + ["недељи", "недеља", "недеље"], + ["дани", "дан", "дана"], + ["сати", "сат", "сата"], + ["минута", "минут", "минута"], + ["секунди", "секунда", "секунде"], + ["милисекунди", "милисекунда", "милисекунде"] + ), + sr_Latn: slavicLanguage( + ["godini", "godina", "godine"], + ["meseci", "mesec", "meseca"], + ["nedelji", "nedelja", "nedelje"], + ["dani", "dan", "dana"], + ["sati", "sat", "sata"], + ["minuta", "minut", "minuta"], + ["sekundi", "sekunda", "sekunde"], + ["milisekundi", "milisekunda", "milisekunde"] + ), + ta: onesLanguage( + ["வருடம்", "ஆண்டுகள்"], + ["மாதம்", "மாதங்கள்"], + ["வாரம்", "வாரங்கள்"], + ["நாள்", "நாட்கள்"], + ["மணி", "மணிநேரம்"], + ["நிமிடம்", "நிமிடங்கள்"], + ["வினாடி", "வினாடிகள்"], + ["மில்லி விநாடி", "மில்லி விநாடிகள்"] + ), + te: onesLanguage( + ["సంవత్సరం", "సంవత్సరాల"], + ["నెల", "నెలల"], + ["వారం", "వారాలు"], + ["రోజు", "రోజులు"], + ["గంట", "గంటలు"], + ["నిమిషం", "నిమిషాలు"], + ["సెకను", "సెకన్లు"], + ["మిల్లీసెకన్", "మిల్లీసెకన్లు"] + ), + uk: slavicLanguage( + ["років", "рік", "роки"], + ["місяців", "місяць", "місяці"], + ["тижнів", "тиждень", "тижні"], + ["днів", "день", "дні"], + ["годин", "година", "години"], + ["хвилин", "хвилина", "хвилини"], + ["секунд", "секунда", "секунди"], + ["мілісекунд", "мілісекунда", "мілісекунди"] + ), + ur: language( + "سال", + onesUnit(["مہینہ", "مہینے"]), + onesUnit(["ہفتہ", "ہفتے"]), + "دن", + onesUnit(["گھنٹہ", "گھنٹے"]), + "منٹ", + "سیکنڈ", + "ملی سیکنڈ" + ), + sk: language( + function (c) { + return ["rok", "roky", "roky", "rokov"][getCzechOrSlovakForm(c)]; + }, + function (c) { + return ["mesiac", "mesiace", "mesiace", "mesiacov"][ + getCzechOrSlovakForm(c) + ]; + }, + function (c) { + return ["týždeň", "týždne", "týždne", "týždňov"][ + getCzechOrSlovakForm(c) + ]; + }, + function (c) { + return ["deň", "dni", "dni", "dní"][getCzechOrSlovakForm(c)]; + }, + function (c) { + return ["hodina", "hodiny", "hodiny", "hodín"][getCzechOrSlovakForm(c)]; + }, + function (c) { + return ["minúta", "minúty", "minúty", "minút"][getCzechOrSlovakForm(c)]; + }, + function (c) { + return ["sekunda", "sekundy", "sekundy", "sekúnd"][ + getCzechOrSlovakForm(c) + ]; + }, + function (c) { + return ["milisekunda", "milisekundy", "milisekundy", "milisekúnd"][ + getCzechOrSlovakForm(c) + ]; + }, + "," + ), + sl: language( + function (c) { + if (c % 10 === 1) { + return "leto"; + } else if (c % 100 === 2) { + return "leti"; + } else if ( + c % 100 === 3 || + c % 100 === 4 || + (Math.floor(c) !== c && c % 100 <= 5) + ) { + return "leta"; + } else { + return "let"; + } + }, + function (c) { + if (c % 10 === 1) { + return "mesec"; + } else if (c % 100 === 2 || (Math.floor(c) !== c && c % 100 <= 5)) { + return "meseca"; + } else if (c % 10 === 3 || c % 10 === 4) { + return "mesece"; + } else { + return "mesecev"; + } + }, + function (c) { + if (c % 10 === 1) { + return "teden"; + } else if (c % 10 === 2 || (Math.floor(c) !== c && c % 100 <= 4)) { + return "tedna"; + } else if (c % 10 === 3 || c % 10 === 4) { + return "tedne"; + } else { + return "tednov"; + } + }, + function (c) { + return c % 100 === 1 ? "dan" : "dni"; + }, + function (c) { + if (c % 10 === 1) { + return "ura"; + } else if (c % 100 === 2) { + return "uri"; + } else if (c % 10 === 3 || c % 10 === 4 || Math.floor(c) !== c) { + return "ure"; + } else { + return "ur"; + } + }, + function (c) { + if (c % 10 === 1) { + return "minuta"; + } else if (c % 10 === 2) { + return "minuti"; + } else if ( + c % 10 === 3 || + c % 10 === 4 || + (Math.floor(c) !== c && c % 100 <= 4) + ) { + return "minute"; + } else { + return "minut"; + } + }, + function (c) { + if (c % 10 === 1) { + return "sekunda"; + } else if (c % 100 === 2) { + return "sekundi"; + } else if (c % 100 === 3 || c % 100 === 4 || Math.floor(c) !== c) { + return "sekunde"; + } else { + return "sekund"; + } + }, + function (c) { + if (c % 10 === 1) { + return "milisekunda"; + } else if (c % 100 === 2) { + return "milisekundi"; + } else if (c % 100 === 3 || c % 100 === 4 || Math.floor(c) !== c) { + return "milisekunde"; + } else { + return "milisekund"; + } + }, + "," + ), + sv: onesLanguage( + ["år", "år"], + ["månad", "månader"], + ["vecka", "veckor"], + ["dag", "dagar"], + ["timme", "timmar"], + ["minut", "minuter"], + ["sekund", "sekunder"], + ["millisekund", "millisekunder"], + "," + ), + sw: assign( + onesLanguage( + ["mwaka", "miaka"], + ["mwezi", "miezi"], + ["wiki", "wiki"], + ["siku", "masiku"], + ["saa", "masaa"], + ["dakika", "dakika"], + ["sekunde", "sekunde"], + ["milisekunde", "milisekunde"] + ), + { _numberFirst: true } + ), + tr: language( + "yıl", + "ay", + "hafta", + "gün", + "saat", + "dakika", + "saniye", + "milisaniye", + "," + ), + th: language( + "ปี", + "เดือน", + "สัปดาห์", + "วัน", + "ชั่วโมง", + "นาที", + "วินาที", + "มิลลิวินาที" + ), + uz: language( + "yil", + "oy", + "hafta", + "kun", + "soat", + "minut", + "sekund", + "millisekund" + ), + uz_CYR: language( + "йил", + "ой", + "ҳафта", + "кун", + "соат", + "минут", + "секунд", + "миллисекунд" + ), + vi: language( + "năm", + "tháng", + "tuần", + "ngày", + "giờ", + "phút", + "giây", + "mili giây", + "," + ), + zh_CN: language("年", "个月", "周", "天", "小时", "分钟", "秒", "毫秒"), + zh_TW: language("年", "個月", "周", "天", "小時", "分鐘", "秒", "毫秒") + }; + + /** + * Helper function for creating language definitions. + * + * @internal + * @param {Unit} y + * @param {Unit} mo + * @param {Unit} w + * @param {Unit} d + * @param {Unit} h + * @param {Unit} m + * @param {Unit} s + * @param {Unit} ms + * @param {string} [decimal] + * @returns {Language} + */ + function language(y, mo, w, d, h, m, s, ms, decimal) { + /** @type {Language} */ + var result = { y: y, mo: mo, w: w, d: d, h: h, m: m, s: s, ms: ms }; + if (decimal) { + result.decimal = decimal; + } + return result; + } + + /** + * @internal + * @param {[string, string]} unit + * @returns {(c: number) => string} + */ + function onesUnit(unit) { + return function (c) { + return c === 1 ? unit[0] : unit[1]; + }; + } + + /** + * Helper for generating languages where the word varies if the count is 1. + * + * @internal + * @param {[string, string]} y + * @param {[string, string]} mo + * @param {[string, string]} w + * @param {[string, string]} d + * @param {[string, string]} h + * @param {[string, string]} m + * @param {[string, string]} s + * @param {[string, string]} ms + * @param {string} [decimal] + * @returns {Language} + */ + function onesLanguage(y, mo, w, d, h, m, s, ms, decimal) { + return language( + onesUnit(y), + onesUnit(mo), + onesUnit(w), + onesUnit(d), + onesUnit(h), + onesUnit(m), + onesUnit(s), + onesUnit(ms), + decimal + ); + } + + /** + * @internal + * @param {[string, string, string]} unit + * @returns {(c: number) => string} + */ + function slavicUnit(unit) { + return function (c) { + if (Math.floor(c) !== c) { + return unit[2]; + } + if ( + (c % 100 >= 5 && c % 100 <= 20) || + (c % 10 >= 5 && c % 10 <= 9) || + c % 10 === 0 + ) { + return unit[0]; + } + if (c % 10 === 1) { + return unit[1]; + } + if (c > 1) { + return unit[2]; + } + return unit[1]; + }; + } + + /** + * Helper for generating Slavic languages. + * + * @internal + * @param {[string, string, string]} y + * @param {[string, string, string]} mo + * @param {[string, string, string]} w + * @param {[string, string, string]} d + * @param {[string, string, string]} h + * @param {[string, string, string]} m + * @param {[string, string, string]} s + * @param {[string, string, string]} ms + * @returns {Language} + */ + function slavicLanguage(y, mo, w, d, h, m, s, ms) { + return language( + slavicUnit(y), + slavicUnit(mo), + slavicUnit(w), + slavicUnit(d), + slavicUnit(h), + slavicUnit(m), + slavicUnit(s), + slavicUnit(ms), + "," + ); + } + + /** + * Helper function for Arabic. + * + * @internal + * @param {number} c + * @returns {0 | 1 | 2} + */ + function getArabicForm(c) { + if (c === 2) { + return 1; + } + if (c > 2 && c < 11) { + return 2; + } + return 0; + } + + /** + * Helper function for Polish. + * + * @internal + * @param {number} c + * @returns {0 | 1 | 2 | 3} + */ + function getPolishForm(c) { + if (c === 1) { + return 0; + } + if (Math.floor(c) !== c) { + return 1; + } + if (c % 10 >= 2 && c % 10 <= 4 && !(c % 100 > 10 && c % 100 < 20)) { + return 2; + } + return 3; + } + + /** + * Helper function for Czech or Slovak. + * + * @internal + * @param {number} c + * @returns {0 | 1 | 2 | 3} + */ + function getCzechOrSlovakForm(c) { + if (c === 1) { + return 0; + } + if (Math.floor(c) !== c) { + return 1; + } + if (c % 10 >= 2 && c % 10 <= 4 && c % 100 < 10) { + return 2; + } + return 3; + } + + /** + * Helper function for Lithuanian. + * + * @internal + * @param {number} c + * @returns {0 | 1 | 2} + */ + function getLithuanianForm(c) { + if (c === 1 || (c % 10 === 1 && c % 100 > 20)) { + return 0; + } + if ( + Math.floor(c) !== c || + (c % 10 >= 2 && c % 100 > 20) || + (c % 10 >= 2 && c % 100 < 10) + ) { + return 1; + } + return 2; + } + + /** + * Helper function for Latvian. + * + * @internal + * @param {number} c + * @returns {boolean} + */ + function getLatvianForm(c) { + return c % 10 === 1 && c % 100 !== 11; + } + + /** + * @internal + * @template T + * @param {T} obj + * @param {keyof T} key + * @returns {boolean} + */ + function has(obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); + } + + /** + * @internal + * @param {Pick, "language" | "fallbacks" | "languages">} options + * @throws {Error} Throws an error if language is not found. + * @returns {Language} + */ + function getLanguage(options) { + var possibleLanguages = [options.language]; + + if (has(options, "fallbacks")) { + if (isArray(options.fallbacks) && options.fallbacks.length) { + possibleLanguages = possibleLanguages.concat(options.fallbacks); + } else { + throw new Error("fallbacks must be an array with at least one element"); + } + } + + for (var i = 0; i < possibleLanguages.length; i++) { + var languageToTry = possibleLanguages[i]; + if (has(options.languages, languageToTry)) { + return options.languages[languageToTry]; + } + if (has(LANGUAGES, languageToTry)) { + return LANGUAGES[languageToTry]; + } + } + + throw new Error("No language found."); + } + + /** + * @internal + * @param {Piece} piece + * @param {Language} language + * @param {Pick, "decimal" | "spacer" | "maxDecimalPoints" | "digitReplacements">} options + */ + function renderPiece(piece, language, options) { + var unitName = piece.unitName; + var unitCount = piece.unitCount; + + var spacer = options.spacer; + var maxDecimalPoints = options.maxDecimalPoints; + + /** @type {string} */ + var decimal; + if (has(options, "decimal")) { + decimal = options.decimal; + } else if (has(language, "decimal")) { + decimal = language.decimal; + } else { + decimal = "."; + } + + /** @type {undefined | DigitReplacements} */ + var digitReplacements; + if ("digitReplacements" in options) { + digitReplacements = options.digitReplacements; + } else if ("_digitReplacements" in language) { + digitReplacements = language._digitReplacements; + } + + /** @type {string} */ + var formattedCount; + var normalizedUnitCount = + maxDecimalPoints === void 0 + ? unitCount + : Math.floor(unitCount * Math.pow(10, maxDecimalPoints)) / + Math.pow(10, maxDecimalPoints); + var countStr = normalizedUnitCount.toString(); + + if (language._hideCountIf2 && unitCount === 2) { + formattedCount = ""; + spacer = ""; + } else { + if (digitReplacements) { + formattedCount = ""; + for (var i = 0; i < countStr.length; i++) { + var character = countStr[i]; + if (character === ".") { + formattedCount += decimal; + } else { + formattedCount += + digitReplacements[ + /** @type {"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"} */ ( + character + ) + ]; + } + } + } else { + formattedCount = countStr.replace(".", decimal); + } + } + + var languageWord = language[unitName]; + var word; + if (typeof languageWord === "function") { + word = languageWord(unitCount); + } else { + word = languageWord; + } + + if (language._numberFirst) { + return word + spacer + formattedCount; + } + return formattedCount + spacer + word; + } + + /** + * @internal + * @typedef {Object} Piece + * @prop {UnitName} unitName + * @prop {number} unitCount + */ + + /** + * @internal + * @param {number} ms + * @param {Pick, "units" | "unitMeasures" | "largest" | "round">} options + * @returns {Piece[]} + */ + function getPieces(ms, options) { + /** @type {UnitName} */ + var unitName; + + /** @type {number} */ + var i; + + /** @type {number} */ + var unitCount; + + /** @type {number} */ + var msRemaining; + + var units = options.units; + var unitMeasures = options.unitMeasures; + var largest = "largest" in options ? options.largest : Infinity; + + if (!units.length) return []; + + // Get the counts for each unit. Doesn't round or truncate anything. + // For example, might create an object like `{ y: 7, m: 6, w: 0, d: 5, h: 23.99 }`. + /** @type {Partial>} */ + var unitCounts = {}; + msRemaining = ms; + for (i = 0; i < units.length; i++) { + unitName = units[i]; + var unitMs = unitMeasures[unitName]; + + var isLast = i === units.length - 1; + unitCount = isLast + ? msRemaining / unitMs + : Math.floor(msRemaining / unitMs); + unitCounts[unitName] = unitCount; + + msRemaining -= unitCount * unitMs; + } + + if (options.round) { + // Update counts based on the `largest` option. + // For example, if `largest === 2` and `unitCount` is `{ y: 7, m: 6, w: 0, d: 5, h: 23.99 }`, + // updates to something like `{ y: 7, m: 6.2 }`. + var unitsRemainingBeforeRound = largest; + for (i = 0; i < units.length; i++) { + unitName = units[i]; + unitCount = unitCounts[unitName]; + + if (unitCount === 0) continue; + + unitsRemainingBeforeRound--; + + // "Take" the rest of the units into this one. + if (unitsRemainingBeforeRound === 0) { + for (var j = i + 1; j < units.length; j++) { + var smallerUnitName = units[j]; + var smallerUnitCount = unitCounts[smallerUnitName]; + unitCounts[unitName] += + (smallerUnitCount * unitMeasures[smallerUnitName]) / + unitMeasures[unitName]; + unitCounts[smallerUnitName] = 0; + } + break; + } + } + + // Round the last piece (which should be the only non-integer). + // + // This can be a little tricky if the last piece "bubbles up" to a larger + // unit. For example, "3 days, 23.99 hours" should be rounded to "4 days". + // It can also require multiple passes. For example, "6 days, 23.99 hours" + // should become "1 week". + for (i = units.length - 1; i >= 0; i--) { + unitName = units[i]; + unitCount = unitCounts[unitName]; + + if (unitCount === 0) continue; + + var rounded = Math.round(unitCount); + unitCounts[unitName] = rounded; + + if (i === 0) break; + + var previousUnitName = units[i - 1]; + var previousUnitMs = unitMeasures[previousUnitName]; + var amountOfPreviousUnit = Math.floor( + (rounded * unitMeasures[unitName]) / previousUnitMs + ); + if (amountOfPreviousUnit) { + unitCounts[previousUnitName] += amountOfPreviousUnit; + unitCounts[unitName] = 0; + } else { + break; + } + } + } + + /** @type {Piece[]} */ + var result = []; + for (i = 0; i < units.length && result.length < largest; i++) { + unitName = units[i]; + unitCount = unitCounts[unitName]; + if (unitCount) { + result.push({ unitName: unitName, unitCount: unitCount }); + } + } + return result; + } + + /** + * @internal + * @param {Piece[]} pieces + * @param {Pick, "units" | "language" | "languages" | "fallbacks" | "delimiter" | "spacer" | "decimal" | "conjunction" | "maxDecimalPoints" | "serialComma" | "digitReplacements">} options + * @returns {string} + */ + function formatPieces(pieces, options) { + var language = getLanguage(options); + + if (!pieces.length) { + var units = options.units; + var smallestUnitName = units[units.length - 1]; + return renderPiece( + { unitName: smallestUnitName, unitCount: 0 }, + language, + options + ); + } + + var conjunction = options.conjunction; + var serialComma = options.serialComma; + + var delimiter; + if (has(options, "delimiter")) { + delimiter = options.delimiter; + } else if (has(language, "delimiter")) { + delimiter = language.delimiter; + } else { + delimiter = ", "; + } + + /** @type {string[]} */ + var renderedPieces = []; + for (var i = 0; i < pieces.length; i++) { + renderedPieces.push(renderPiece(pieces[i], language, options)); + } + + if (!conjunction || pieces.length === 1) { + return renderedPieces.join(delimiter); + } + + if (pieces.length === 2) { + return renderedPieces.join(conjunction); + } + + return ( + renderedPieces.slice(0, -1).join(delimiter) + + (serialComma ? "," : "") + + conjunction + + renderedPieces.slice(-1) + ); + } + + /** + * Create a humanizer, which lets you change the default options. + * + * @param {Options} [passedOptions] Options to customize the humanizer + * @returns {(ms: number, humanizerOptions: Options) => string} A function that humanizes durations + */ + function humanizer(passedOptions) { + /** + * @param {number} ms + * @param {Options} [humanizerOptions] + * @returns {string} + */ + var result = function humanizer(ms, humanizerOptions) { + // Make sure we have a positive number. + // + // Has the nice side-effect of converting things to numbers. For example, + // converts `"123"` and `Number(123)` to `123`. + ms = Math.abs(ms); + + var options = assign({}, result, humanizerOptions || {}); + + var pieces = getPieces(ms, options); + + return formatPieces(pieces, options); + }; + + return assign( + result, + { + language: "en", + spacer: " ", + conjunction: "", + serialComma: true, + units: ["y", "mo", "w", "d", "h", "m", "s"], + languages: {}, + round: false, + unitMeasures: { + y: 31557600000, + mo: 2629800000, + w: 604800000, + d: 86400000, + h: 3600000, + m: 60000, + s: 1000, + ms: 1 + } + }, + passedOptions + ); + } + + /** + * Humanize a duration. + * + * This is a wrapper around the default humanizer. + */ + var humanizeDuration = assign(humanizer({}), { + /** + * Get a list of supported languages. + * + * @returns {string[]} An array of language codes + */ + getSupportedLanguages: function getSupportedLanguages() { + var result = []; + for (var language in LANGUAGES) { + if (has(LANGUAGES, language) && language !== "gr") { + result.push(language); + } + } + return result; + }, + humanizer: humanizer + }); + + // @ts-ignore + if (typeof define === "function" && define.amd) { + // @ts-ignore + define(function () { + return humanizeDuration; + }); + } else if (typeof module !== "undefined" && module.exports) { + module.exports = humanizeDuration; + } else { + this.humanizeDuration = humanizeDuration; + } +})(); diff --git a/views/settings.php b/views/settings.php new file mode 100644 index 0000000..6e5b457 --- /dev/null +++ b/views/settings.php @@ -0,0 +1,122 @@ + 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); + } +?> + + + <?= $website->title; ?>: <?= $website->slogan; ?> + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ href="/settings">main settings + href="/settings?m=privacy">privacy +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
account details
username: ">
bio:
security
password:
confirm password:
+ error != NULL) echo "$settings->error
"; + ?> +
+ + + +

Page under construction

+ +
+
+ + \ No newline at end of file diff --git a/views/styles/main.css b/views/styles/main.css new file mode 100644 index 0000000..19e241e --- /dev/null +++ b/views/styles/main.css @@ -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; +} \ No newline at end of file diff --git a/views/temp_reg.php b/views/temp_reg.php new file mode 100644 index 0000000..5d79426 --- /dev/null +++ b/views/temp_reg.php @@ -0,0 +1,82 @@ + 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: /"); + } + } +?> + + + <?= $website->title; ?>: <?= $website->slogan; ?> + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + \ No newline at end of file