├── VERSION ├── thanks.md ├── .dockerignore ├── src ├── .gitignore ├── index.php ├── resources │ ├── svg │ │ ├── faridoon.png │ │ └── faridoon.svg │ ├── javascript │ │ └── main.js │ └── stylesheets │ │ ├── app.css │ │ └── theme.css ├── includes │ ├── templates │ │ ├── list.tpl │ │ ├── quoteEdited.tpl │ │ ├── quoteApproved.tpl │ │ ├── register.tpl │ │ ├── logout.tpl │ │ ├── quoteAdded.tpl │ │ ├── loggedin.tpl │ │ ├── approveHeader.tpl │ │ ├── quoteDeleted.tpl │ │ ├── account.tpl │ │ ├── form.tpl │ │ ├── formElements.tpl │ │ ├── quote.tpl │ │ ├── users.tpl │ │ └── header.tpl │ ├── widgets │ │ ├── quote.php │ │ ├── header.php │ │ └── footer.php │ ├── classes │ │ ├── FormUsergroupCreate.php │ │ ├── FormAddUserToGroup.php │ │ ├── FormUsergroupGrant.php │ │ ├── Quote.php │ │ └── FormQuote.php │ ├── startup.php │ ├── common.php │ └── functionality.php ├── account.php ├── logout.php ├── user-edit.php ├── usergroup-create.php ├── usergroup-grant.php ├── delete.php ├── add.php ├── show.php ├── edit.php ├── login.php ├── approvals.php ├── register.php ├── list.php ├── users.php └── vote.php ├── var ├── container-include-path.ini ├── screenshot.png ├── mockupLaptop.png ├── mockupLaptop.xcf ├── socialBanner.png ├── screenshot_edit.png ├── mockupMobilePhone.png ├── mockupMobilePhone.xcf ├── screenshot_approvals.png ├── svg-sources │ ├── add.svg │ ├── delete.svg │ ├── edit.svg │ └── approve.svg └── faridoon-fedora.spec ├── .env.dev ├── logo.png ├── .gitignore ├── docs ├── faridoon.png ├── security │ ├── moderators.png │ └── index.md ├── installation │ ├── index.md │ ├── docker.md │ ├── docker-compose.md │ ├── docker-compose.yml │ └── migrations.md ├── contact-support.md ├── index.md └── configuration │ └── index.md ├── config.dist.ini ├── database ├── dbconfig.yml └── migrations │ ├── 1.groups.sql │ ├── 2.permissions.sql │ └── 0.base.sql ├── phpstan.neon ├── .releaserc.yaml ├── SECURITY.md ├── phpcs.xml ├── .pre-commit-config.yaml ├── .github ├── ISSUE_TEMPLATE │ ├── support_request.md │ ├── bug_report.md │ └── feature_request.md ├── workflows │ ├── docs.yml │ ├── composer-jobs.yml │ └── release-pipeline.yml └── PULL_REQUEST_TEMPLATE.md ├── composer.json ├── Dockerfile ├── mkdocs.yml ├── CONTRIBUTING.md ├── tests └── TestHighlightUsernames.php ├── Makefile ├── README.md ├── logo.svg ├── CODE_OF_CONDUCT.md └── LICENSE /VERSION: -------------------------------------------------------------------------------- 1 | 2.0.0 2 | -------------------------------------------------------------------------------- /thanks.md: -------------------------------------------------------------------------------- 1 | www.minimalmockups.com -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | src/includes/settings.php 2 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | includes/settings.php 2 | -------------------------------------------------------------------------------- /src/index.php: -------------------------------------------------------------------------------- 1 | more random quotes... 2 | -------------------------------------------------------------------------------- /config.dist.ini: -------------------------------------------------------------------------------- 1 | DB_HOST=mysql 2 | DB_NAME=faridoon 3 | DB_USER=user 4 | DB_PASS=password 5 | ADMIN_PASSWORD=admin 6 | SITE_TITLE=My Quotes Page 7 | -------------------------------------------------------------------------------- /src/includes/templates/quoteEdited.tpl: -------------------------------------------------------------------------------- 1 |
2 |

Quote edited

3 |

Your freshly updated quote is below.

4 |
5 | 6 | -------------------------------------------------------------------------------- /src/includes/widgets/quote.php: -------------------------------------------------------------------------------- 1 | assign('quote', $quote); 4 | $tpl->assign('isVotingEnabled', $cfg->getBool('ENABLE_VOTING')); 5 | $tpl->display('quote.tpl'); 6 | -------------------------------------------------------------------------------- /database/dbconfig.yml: -------------------------------------------------------------------------------- 1 | development: 2 | dialect: mysql 3 | datasource: ${DB_USER}:${DB_PASS}@tcp(${DB_HOST})/${DB_NAME}?parseTime=true 4 | dir: migrations 5 | table: migrations 6 | -------------------------------------------------------------------------------- /src/includes/templates/quoteApproved.tpl: -------------------------------------------------------------------------------- 1 |
2 |

Quote Approved

3 | 4 |

You probably just made somebody very happy.

5 |
6 | -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | parameters: 2 | level: 5 3 | paths: 4 | - src/ 5 | 6 | ignoreErrors: 7 | - '#might not be defined#' 8 | - '#Path in require_once#' 9 | - '#Path in include_once#' 10 | -------------------------------------------------------------------------------- /src/includes/templates/register.tpl: -------------------------------------------------------------------------------- 1 |
2 |

Register as a new user

3 | 4 |

Register as a new user to access the site.

5 |
6 | 7 | -------------------------------------------------------------------------------- /src/includes/templates/logout.tpl: -------------------------------------------------------------------------------- 1 |
2 |

Logged out

3 |

You have been logged out. Hope to see you again soon, that would be really nice.

4 |

5 | Log back in again 6 |

7 |
8 | -------------------------------------------------------------------------------- /src/account.php: -------------------------------------------------------------------------------- 1 | assign('isAdmin', isAdmin()); 6 | $tpl->assign('isAddEnabled', isAddEnabled()); 7 | $tpl->display('account.tpl'); 8 | 9 | require_once 'includes/widgets/footer.php'; 10 | -------------------------------------------------------------------------------- /docs/installation/index.md: -------------------------------------------------------------------------------- 1 | # Installation options 2 | 3 | This section includes information on the various different installation options available for Faridoon. At the moment, it is strongly recommended to use the [Docker Compose](docker-compose.md) installation method. 4 | -------------------------------------------------------------------------------- /src/includes/templates/quoteAdded.tpl: -------------------------------------------------------------------------------- 1 |
2 |

Quote Added

3 |

Oh goodie. Another quote!

4 | 5 | {if !isAdmin()} 6 |

Your quote needs approval before it shows up in the list.

7 | {/if} 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /src/includes/templates/loggedin.tpl: -------------------------------------------------------------------------------- 1 |
2 |

Logged In

3 | 4 |

You have been logged in.

5 | 6 | 10 |
11 | -------------------------------------------------------------------------------- /src/includes/templates/approveHeader.tpl: -------------------------------------------------------------------------------- 1 |
2 | {if $count == 0} 3 |

Nothing to approve

4 |

Perhaps you would like a crumpet instead?

5 | {else} 6 |

Approval queue

7 |

There are {$count} quote(s) to approve.

8 | {/if} 9 |
10 | -------------------------------------------------------------------------------- /var/svg-sources/add.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/logout.php: -------------------------------------------------------------------------------- 1 | display('logout.tpl'); 12 | 13 | require_once 'includes/widgets/footer.php'; 14 | -------------------------------------------------------------------------------- /src/includes/templates/quoteDeleted.tpl: -------------------------------------------------------------------------------- 1 |
2 |

Quote Deleted

3 | 4 |

Easy come, easy go.

5 | 6 | 10 | 11 |
12 | 13 | -------------------------------------------------------------------------------- /database/migrations/1.groups.sql: -------------------------------------------------------------------------------- 1 | -- +migrate Up 2 | INSERT INTO `groups` (id, title) VALUES (1, 'Admins'); 3 | INSERT INTO `groups` (id, title) VALUES (2, 'Users'); 4 | INSERT INTO permissions (id, `key`) VALUES (1, 'SUPERUSER'); 5 | INSERT INTO privileges_g (`group`, `permission`) VALUES (1, 1); 6 | 7 | -- +migrate Down 8 | -------------------------------------------------------------------------------- /.releaserc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | branches: 3 | - main 4 | plugins: 5 | - '@semantic-release/commit-analyzer' 6 | - '@semantic-release/github' 7 | - '@semantic-release/git' 8 | - - "@semantic-release/exec" 9 | - publishCmd: | 10 | RELEASE_VERSION=${nextRelease.version} make release 11 | 12 | tagFormat: '${version}' 13 | -------------------------------------------------------------------------------- /src/user-edit.php: -------------------------------------------------------------------------------- 1 | validate()) { 10 | $f->process(); 11 | 12 | redirect('users.php'); 13 | } 14 | 15 | require_once 'includes/widgets/header.php'; 16 | 17 | $tpl->displayForm($f); 18 | -------------------------------------------------------------------------------- /src/usergroup-create.php: -------------------------------------------------------------------------------- 1 | validate()) { 10 | $f->process(); 11 | 12 | redirect('users.php'); 13 | } 14 | 15 | require_once 'includes/widgets/header.php'; 16 | 17 | $tpl->displayForm($f); 18 | -------------------------------------------------------------------------------- /src/usergroup-grant.php: -------------------------------------------------------------------------------- 1 | validate()) { 10 | $f->process(); 11 | 12 | redirect('users.php'); 13 | } 14 | 15 | require_once 'includes/widgets/header.php'; 16 | 17 | $tpl->displayForm($f); 18 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | latest | :white_check_mark: | 8 | | other | :x: | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | Please report security issues via GitHub issues, or contacting jamesread via http://jread.com. 13 | -------------------------------------------------------------------------------- /phpcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | src/ 4 | **/*.js 5 | 6 | 7 | src/* 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /database/migrations/2.permissions.sql: -------------------------------------------------------------------------------- 1 | -- +migrate Up 2 | 3 | UPDATE permissions SET `description` = "Has all permissions" WHERE `key` = "SUPERUSER"; 4 | INSERT INTO permissions (`key`, `description`) VALUES ('BYPASS_APPROVAL', 'New quotes will be auto-approved'); 5 | INSERT INTO permissions (`key`, `description`) VALUES ('APPROVE_QUOTES', 'Approve quotes in the approval queue'); 6 | 7 | -- +migrate Down 8 | -------------------------------------------------------------------------------- /docs/contact-support.md: -------------------------------------------------------------------------------- 1 | # Contact & Support 2 | 3 | Faridoon is an open source project and is maintained by [jamesread](https://jread.com). However, please use the [GitHub issue tracker](https://github.com/jamesread/Faridoon/issues) to report bugs and request features. You can also use it for support tickets. 4 | 5 | You can also get in touch via the [OliveTin Discord server](https://discord.gg/jhYWWpNJ3v). 6 | -------------------------------------------------------------------------------- /src/delete.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 11 | $stmt->bindValue(':id', filter('id')); 12 | $stmt->execute(); 13 | 14 | $tpl->display('quoteDeleted.tpl'); 15 | 16 | require_once 'includes/widgets/footer.php'; 17 | -------------------------------------------------------------------------------- /var/svg-sources/delete.svg: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | repos: 3 | - repo: https://github.com/pre-commit/pre-commit-hooks 4 | rev: v3.2.0 5 | hooks: 6 | - id: trailing-whitespace 7 | - id: end-of-file-fixer 8 | - id: check-yaml 9 | - id: check-added-large-files 10 | 11 | - repo: https://github.com/compilerla/conventional-pre-commit 12 | rev: v4.0.0 13 | hooks: 14 | - id: conventional-pre-commit 15 | stages: [commit-msg] 16 | args: [] 17 | -------------------------------------------------------------------------------- /src/add.php: -------------------------------------------------------------------------------- 1 | validate()) { 12 | $f->process(); 13 | 14 | $tpl->display('quoteAdded.tpl'); 15 | 16 | include_once 'includes/widgets/footer.php'; 17 | } 18 | 19 | $tpl->displayForm($f); 20 | 21 | require_once 'includes/widgets/footer.php'; 22 | -------------------------------------------------------------------------------- /var/svg-sources/edit.svg: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /var/faridoon-fedora.spec: -------------------------------------------------------------------------------- 1 | Name: faridoon 2 | Version: 1.0.0 3 | Release: 1%{?dist} 4 | Summary: A really simple PHP based quotes system. 5 | 6 | Group: Web 7 | License: GPL 8 | URL: http://github.com/faridoon 9 | Source0: ../build/distributions/faridoon.zip 10 | 11 | BuildRequires: make 12 | Requires: php5 13 | 14 | %description 15 | A really simple PHP based quotes system. 16 | 17 | %prep 18 | %setup -q 19 | 20 | 21 | %build 22 | unzip faridoon.zip 23 | 24 | %install 25 | 26 | 27 | %files 28 | %doc 29 | 30 | 31 | 32 | %changelog 33 | 34 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Faridoon 2 | 3 | Welcome! Faridoon is a web app to publish your favourite chat quotes. This is the documentation site that should tell you how to set it up and use it. 4 | 5 | You can learn more about Faridoon on it's GitHub site; [jamesread/Faridoon](https://github.com/jamesread/Faridoon). 6 | 7 | * [Docker Compose](installation/docker-compose.md) - this is the preferred way to run Faridoon. 8 | 9 | If you need help understanding something that is not documented, or just need other help with Faridoon, please check the [contact & support](contact-support.md) page. 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support request 3 | about: Need some help? Got an error message? 4 | title: "" 5 | labels: 6 | - "type: support" 7 | - "waiting-on-developer" 8 | assignees: '' 9 | --- 10 | 11 | **What seems to be the problem?!** 12 | 13 | If you are getting an error message, then please copy/paste, or better, provide 14 | a screenshot to show us exactly what is wrong. 15 | 16 | **How did you install?** 17 | 18 | eg: Container image with compose, version 1.0.0 19 | 20 | **Anything else?** 21 | 22 | Add any other context about the problem here. 23 | -------------------------------------------------------------------------------- /docs/configuration/index.md: -------------------------------------------------------------------------------- 1 | # Configuration 2 | 3 | ## Database Settings 4 | 5 | - `DB_HOST`: Database host 6 | - `DB_USER`: Database user 7 | - `DB_PASS`: Database password 8 | - `DB_NAME`: Database name 9 | 10 | ## Feature Flags 11 | 12 | - `ENABLE_VOTING`: Enable voting feature, set to "1" to enable voting. (default: 0). 13 | - `ENABLE_SYNTAX_HIGHLIGHTING`: Enable the ability to set a code style for syntax highlighting (admin only). 14 | 15 | ## Guest settings 16 | 17 | - `GUESTS_DISABLE_ADD`: Set to "true" to disable guests from adding new quotes (default: unset - guests can submit quotes). 18 | -------------------------------------------------------------------------------- /docs/security/index.md: -------------------------------------------------------------------------------- 1 | # Security 2 | 3 | # Superusers 4 | 5 | The first registered user in Faridoon is granted superuser permissions. All registrations after that are given standard permissions (which can later be upgraded). 6 | 7 | ## Setting up a moderators usergroup 8 | 9 | You can create a usergroup for moderators, it should look something like this; 10 | 11 | ![Moderators Usergroup](./moderators.png) 12 | 13 | ## Guests 14 | 15 | Guests exist ourside of the users and permissions system. All guest permissions must be set through environment variables. See the [configuration](../configuration/index.md) section for more information. 16 | -------------------------------------------------------------------------------- /docs/installation/docker.md: -------------------------------------------------------------------------------- 1 | # Install Faridoon with Docker 2 | 3 | The container image for Faridoon can be found on GitHub Container Registry, and can be pulled using the following commands: 4 | 5 | ```bash 6 | docker pull ghcr.io/jamesread/faridoon:latest 7 | ``` 8 | 9 | Faridoon container images are build for the **amd64** and **arm64** architectures. 10 | 11 | The container can be run using the following command: 12 | 13 | ```bash 14 | docker run -it --name faridoon --port 8080:8080 -e DB_HOST=mysql -e DB_PASS=hunter2 -e DB_USER=faridoon ghcr.io/jamesread/faridoon:latest 15 | ``` 16 | 17 | Consider using [Docker Compose](docker-compose.md) instead though, it's a lot easier. 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "" 5 | labels: 6 | - "type: bug" 7 | - "waiting-on-developer" 8 | assignees: '' 9 | 10 | --- 11 | 12 | **Describe the bug** 13 | A clear and concise description of what the bug is. 14 | 15 | **To Reproduce** 16 | Steps to reproduce the behavior: 17 | 1. Go to '...' 18 | 2. Click on '....' 19 | 3. Scroll down to '....' 20 | 4. See error 21 | 22 | **Expected behavior** 23 | A clear and concise description of what you expected to happen. 24 | 25 | **Screenshots** 26 | If applicable, add screenshots to help explain your problem. 27 | 28 | **Additional context** 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: build docs 3 | 4 | on: 5 | push: 6 | branches: ["main"] 7 | paths: 8 | - "docs/**" 9 | - "mkdocs.yml" 10 | 11 | jobs: 12 | docs: 13 | runs-on: ubuntu-latest 14 | name: Build docs to pretty HTML! 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v4 18 | 19 | - name: Deploy docs 20 | uses: mhausenblas/mkdocs-deploy-gh-pages@master 21 | env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 23 | # CUSTOM_DOMAIN: optionaldomain.com 24 | CONFIG_FILE: mkdocs.yml 25 | # EXTRA_PACKAGES: build-base 26 | # GITHUB_DOMAIN: github.myenterprise.com 27 | # REQUIREMENTS: folder/requirements.txt 28 | -------------------------------------------------------------------------------- /src/includes/templates/account.tpl: -------------------------------------------------------------------------------- 1 |
2 | {if $isLoggedIn} 3 |

Welcome, {$username}!

4 |

Hopefully you are having a marvelous day.

5 | 6 | 24 | 25 | {else} 26 |

You are not logged in.

27 |

Please log in to view your account.

28 | {/if} 29 |
30 | -------------------------------------------------------------------------------- /src/includes/classes/FormUsergroupCreate.php: -------------------------------------------------------------------------------- 1 | addElement(new ElementInput('title', 'Title')); 16 | 17 | $this->addDefaultButtons('Create'); 18 | } 19 | 20 | public function process() 21 | { 22 | $stmt = DatabaseFactory::getInstance()->prepare('INSERT INTO `groups` (title) VALUES (:title); '); 23 | $stmt->bindValue(':title', $this->getElementValue('title')); 24 | $stmt->execute(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jamesread/faridoon", 3 | "description": "Easily save and publish your favourite chat quotes for others to see.", 4 | "license": "AGPL-3.0-only", 5 | "type": "project", 6 | "require": { 7 | "jwread/lib-allure": "^8", 8 | "smarty/smarty": "^4.0" 9 | }, 10 | "autoload": { 11 | "psr-4": { 12 | "faridoon\\": "src/includes/classes/" 13 | } 14 | }, 15 | "authors": [ 16 | { 17 | "name": "jamesread", 18 | "email": "contact@jread.com" 19 | } 20 | ], 21 | "require-dev": { 22 | "friendsofphp/php-cs-fixer": "^3.66", 23 | "squizlabs/php_codesniffer": "^3.11", 24 | "phpstan/phpstan": "^2.1", 25 | "phpunit/phpunit": "^11" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/includes/templates/form.tpl: -------------------------------------------------------------------------------- 1 | {assign var = "excludeBox" value = $excludeBox|default:false} 2 | 3 | {if $excludeBox eq true} 4 | {if !empty($form->getTitle)} 5 |

{$form->getTitle()}

6 | {/if} 7 | {else} 8 |
9 |

{$form->getTitle()}

10 | {/if} 11 |

12 | 13 | 14 |
15 | {include file = "formElements.tpl" elements=$elements} 16 | 17 | {if isset($scripts)} 18 | {foreach from = $scripts item = script} 19 | 22 | {/foreach} 23 | {/if} 24 |
25 | 26 | {if not $excludeBox eq true} 27 |
28 | {/if} 29 | 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | description: Suggest an idea for something new 4 | title: 'Give your feature request a title' 5 | labels: ["type: feature-request", "waiting-on-developer"] 6 | labels: 7 | - "type: feature-request" 8 | - "waiting-on-developer" 9 | assignees: '' 10 | --- 11 | 12 | **Is your feature request related to a problem? Please describe.** 13 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 14 | 15 | **Describe the solution you'd like** 16 | A clear and concise description of what you want to happen. 17 | 18 | **Describe alternatives you've considered** 19 | A clear and concise description of any alternative solutions or features you've considered. 20 | 21 | **Additional context** 22 | Add any other context or screenshots about the feature request here. 23 | -------------------------------------------------------------------------------- /docs/installation/docker-compose.md: -------------------------------------------------------------------------------- 1 | # Install Faridoon with Docker Compose 2 | 3 | Docker compose is the recommended way to run Faridoon. This page assumes that you have a working understanding of Docker and Docker Compose. If you are new to Docker, please refer to the [Docker documentation](https://docs.docker.com/get-started/). 4 | 5 | You can use the following `docker-compose.yml` file to run Faridoon with Docker Compose: 6 | 7 | ```yaml title="docker-compose.yml" 8 | --8<-- 9 | docs/installation/docker-compose.yml 10 | --8<-- 11 | ``` 12 | 13 | Change your environment variables as necessary to set your passwords (`DB_PASS` should be the same as `MYSQL_PASSWORD`. `DB_USER` should be the same as `MYSQL_USER`, etc). 14 | 15 | Save this file as `docker-compose.yml` and run `docker-compose up -d` in the same directory. Faridoon will be available at `http://localhost:8080`. 16 | -------------------------------------------------------------------------------- /var/svg-sources/approve.svg: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /src/includes/widgets/header.php: -------------------------------------------------------------------------------- 1 | assign('isLoggedIn', Session::isLoggedIn()); 11 | $tpl->assign('countApprovals', 0); 12 | $tpl->assign('hasApprovalPermissions', false); 13 | 14 | if (Session::isLoggedIn()) { 15 | $tpl->assign('username', Session::getUser()->getUsername()); 16 | 17 | if (Session::getUser()->hasPriv('APPROVE_QUOTES')) { 18 | $tpl->assign('hasApprovalPermissions', true); 19 | $tpl->assign('countApprovals', getCountApprovals()); 20 | } 21 | } 22 | 23 | $tpl->assign('isVotingEnabled', $cfg->get('ENABLE_VOTING')); 24 | $tpl->assign('siteTitle', $cfg->get('SITE_TITLE')); 25 | $tpl->assign('inlineCss', getCustomCss()); 26 | $tpl->assign('isRegistrationEnabled', !$cfg->getBool('DISABLE_REGISTRATION')); 27 | $tpl->assign('isAddEnabled', isAddEnabled()); 28 | $tpl->display('header.tpl'); 29 | -------------------------------------------------------------------------------- /src/show.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 10 | $stmt->bindValue(':id', $id); 11 | $stmt->execute(); 12 | 13 | if ($stmt->numRows() == 0) { 14 | echo '

That quote does not exist.

'; 15 | } else { 16 | $dbquote = $stmt->fetchRow(); 17 | 18 | $quote = new Quote(); 19 | $quote->unmarshalFromDatabase($dbquote); 20 | 21 | include_once 'includes/widgets/quote.php'; 22 | 23 | echo '

More quotes...

There are many more quotes, just in case this was not as exciting as you expected.

'; 24 | } 25 | 26 | require_once 'includes/widgets/footer.php'; 27 | -------------------------------------------------------------------------------- /src/edit.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 9 | $stmt->bindValue('itemId', filter('id')); 10 | $stmt->execute(); 11 | $quote = $stmt->fetch(); 12 | 13 | if (empty($quote)) { 14 | echo '

Oh dear, I cannot find that quote. Ah, for that matter, I dont think I can find my marbles!

'; 15 | 16 | include_once 'includes/widgets/footer.php'; 17 | } else { 18 | $f = new FormQuote($quote); 19 | 20 | if ($f->validate()) { 21 | $f->process(); 22 | 23 | $tpl->assign('quoteId', $f->getElementValue('id')); 24 | $tpl->display('quoteEdited.tpl'); 25 | 26 | require_once 'show.php'; 27 | 28 | include_once 'includes/widgets/footer.php'; 29 | } 30 | 31 | $tpl->displayForm($f); 32 | } 33 | 34 | require_once 'includes/widgets/footer.php'; 35 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/php:8.3-apache AS base 2 | 3 | RUN apt-get update && apt-get install sql-migrate unzip -y --no-install-recommends && rm -rf /var/lib/apt/lists/* 4 | 5 | COPY --from=docker.io/composer:2 /usr/bin/composer /usr/bin/composer 6 | 7 | RUN sed -i 's/Listen 80/Listen 8080/' /etc/apache2/ports.conf && a2enmod rewrite 8 | 9 | RUN docker-php-ext-configure pdo_mysql \ 10 | && docker-php-ext-install pdo_mysql \ 11 | && docker-php-ext-enable pdo_mysql 12 | 13 | EXPOSE 8080 14 | 15 | COPY database/ /var/faridoon/database/ 16 | COPY src/ /var/faridoon/src/ 17 | COPY composer.json /var/faridoon/ 18 | 19 | WORKDIR /var/faridoon/ 20 | 21 | RUN composer install --no-dev --no-suggest 22 | RUN rm -rf /var/www/html && ln -s /var/faridoon/src/ /var/www/html 23 | 24 | RUN sed -i '3i cd /var/faridoon/database/ && sql-migrate up' /usr/local/bin/docker-php-entrypoint 25 | 26 | #COPY config.dist.ini /config/config.ini 27 | 28 | VOLUME ["/config"] 29 | 30 | USER www-data 31 | 32 | -------------------------------------------------------------------------------- /src/login.php: -------------------------------------------------------------------------------- 1 | display('loggedin.tpl'); 11 | 12 | include_once 'includes/widgets/footer.php'; 13 | die(); 14 | } 15 | 16 | if ($f->validate()) { 17 | try { 18 | $f->process(); 19 | 20 | include_once 'includes/widgets/header.php'; 21 | 22 | $tpl->display('loggedin.tpl'); 23 | 24 | include_once 'includes/widgets/footer.php'; 25 | } catch (Exception $e) { 26 | include_once 'includes/widgets/header.php'; 27 | var_dump($e); 28 | echo 'Wrong password. '; 29 | } 30 | } else { 31 | include_once 'includes/widgets/header.php'; 32 | 33 | $tpl->displayForm($f); 34 | 35 | if (!$cfg->getBool('DISABLE_REGISTRATION')) { 36 | $tpl->display('register.tpl'); 37 | } 38 | } 39 | 40 | require_once 'includes/widgets/footer.php'; 41 | -------------------------------------------------------------------------------- /src/approvals.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 12 | $stmt->bindValue(':itemId', $approveId); 13 | $stmt->execute(); 14 | 15 | $tpl->display('quoteApproved.tpl'); 16 | } 17 | 18 | $sql = 'SELECT id, "?" as voteCount, content, approval as approved, date_format(created, "%Y-%m-%d") AS created FROM quotes WHERE approval = 0'; 19 | $stmt = $db->prepare($sql); 20 | $stmt->execute(); 21 | $quotes = $stmt->fetchAll(); 22 | 23 | $tpl->assign('count', count($quotes)); 24 | $tpl->display('approveHeader.tpl'); 25 | 26 | foreach ($quotes as $dbquote) { 27 | $quote = new faridoon\Quote(); 28 | $quote->unmarshalFromDatabase($dbquote); 29 | 30 | include 'includes/widgets/quote.php'; 31 | } 32 | 33 | require_once 'includes/widgets/footer.php'; 34 | -------------------------------------------------------------------------------- /docs/installation/docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: faridoon 3 | 4 | services: 5 | faridoon: 6 | container_name: faridoon 7 | image: ghcr.io/jamesread/faridoon 8 | volumes: 9 | - faridoon-config:/config 10 | ports: 11 | - "8080:8080" 12 | environment: 13 | DB_HOST: faridoon-mysql 14 | DB_NAME: faridoon 15 | DB_USER: faridoon 16 | DB_PASS: toomanysecrets 17 | restart: unless-stopped 18 | networks: 19 | - faridoon-network 20 | depends_on: 21 | faridoon-mysql: 22 | condition: service_healthy 23 | 24 | faridoon-mysql: 25 | container_name: faridoon-mysql 26 | image: mysql 27 | volumes: 28 | - faridoon-mysql:/var/lib/mysql 29 | environment: 30 | MYSQL_ROOT_PASSWORD: hunter2 31 | MYSQL_DATABASE: faridoon 32 | MYSQL_USER: faridoon 33 | MYSQL_PASSWORD: toomanysecrets 34 | restart: unless-stopped 35 | networks: 36 | - faridoon-network 37 | healthcheck: 38 | test: ["CMD-SHELL", "mysqladmin ping -h localhost"] 39 | interval: 20s 40 | timeout: 5s 41 | retries: 10 42 | 43 | volumes: 44 | faridoon-config: 45 | faridoon-mysql: 46 | 47 | networks: 48 | faridoon-network: 49 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # PR Introduction 2 | 3 | 14 | 15 | # Checklist 16 | Please put a X in the boxes as evidence of reading through the checklist. 17 | 18 | - [ ] I have forked the project, and raised this PR on a feature branch. 19 | - [ ] I have read the [CONTRIBUTING](CONTRIBUTING.md) guide and understand the 3-line change suggestion. 20 | - [ ] The default `make` lint tasks run without any issues. 21 | - [ ] I understand and accept the [AGPL-3.0 license](LICENSE) and [code of conduct](CODE_OF_CONDUCT.md), and my contributions fall under these. 22 | -------------------------------------------------------------------------------- /docs/installation/migrations.md: -------------------------------------------------------------------------------- 1 | ## Database Migrations 2 | 3 | Faridoon automatically applies database upgrades (called "migrations" in database terminology) every time the container starts. If there are no changes to be made, the startup just continues. 4 | 5 | Therefore, it should not be necessary to run migrations manually. However, if you would like to do so, the instructions are below for how to do this. 6 | 7 | However, running migrations is easy. You will need to get a shell on the `faridoon` container. You can do this like this; 8 | 9 | ``` bash 10 | docker exec -it faridoon /bin/bash 11 | ``` 12 | 13 | This will give you a command prompt like this; 14 | 15 | ```bash 16 | www-data@70fc8f2b445c:/var/faridoon$ 17 | ``` 18 | 19 | Change to the database directory, and you should be able to run `sql-migrate up` without any problems - as the database username, password, and database name are all set in the environment variables. 20 | 21 | ```bash 22 | www-data@70fc8f2b445c:/var/faridoon$ cd database 23 | www-data@70fc8f2b445c:/var/faridoon$ sql-migrate up 24 | ``` 25 | 26 | This will run all the available migrations, and you should see output like this; 27 | 28 | ```bash 29 | www-data@70fc8f2b445c:/var/faridoon/database$ sql-migrate up 30 | Applied 1 migration 31 | ``` 32 | 33 | If you see this, then the migrations have been applied successfully. 34 | 35 | You can exit the container by typing `exit` at the command prompt. 36 | -------------------------------------------------------------------------------- /src/includes/startup.php: -------------------------------------------------------------------------------- 1 | 8 | Faridoon startup error 9 | 16 | 17 | 18 |

Faridoon startup error

19 | $message 20 | 21 | HTML; 22 | echo $message; 23 | 24 | exit; 25 | } 26 | 27 | function requireDatabaseVersion(string $requiredMigration) 28 | { 29 | try { 30 | $sql = 'SELECT id FROM migrations'; 31 | $stmt = libAllure\DatabaseFactory::getInstance()->query($sql); 32 | $versionRows = array_column($stmt->fetchAll(), 'id'); 33 | } catch (Exception $e) { 34 | startupError('Faridoon connected to the database, but the migrations table could not be queried.'); 35 | } 36 | 37 | natsort($versionRows); 38 | $latestVersion = end($versionRows); 39 | 40 | if ($latestVersion != $requiredMigration) { 41 | if ($latestVersion == '') { 42 | $latestVersion = 'null'; 43 | } 44 | 45 | startupError('Faridoon requires database version ' . $requiredMigration . ' but the database is at version ' . $latestVersion . '. Please run database migrations.'); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /.github/workflows/composer-jobs.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: PHP CodeStyle 3 | 4 | on: 5 | push: 6 | branches: ["main"] 7 | paths: 8 | - "src/**" 9 | - "/*.xml" 10 | - "composer.json" 11 | 12 | pull_request: 13 | branches: ["main"] 14 | paths: 15 | - "src/**" 16 | - "/*.xml" 17 | - "composer.json" 18 | 19 | 20 | permissions: 21 | contents: read 22 | 23 | jobs: 24 | build: 25 | runs-on: ubuntu-latest 26 | 27 | steps: 28 | - uses: actions/checkout@v4 29 | 30 | - name: Setup PHP Action 31 | uses: shivammathur/setup-php@2.32.0 32 | with: 33 | php-version: '8.3' 34 | 35 | - name: Validate composer.json and composer.lock 36 | run: composer validate --strict 37 | 38 | - name: Cache Composer packages 39 | id: composer-cache 40 | uses: actions/cache@v4.2.3 41 | with: 42 | path: vendor 43 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 44 | restore-keys: | 45 | ${{ runner.os }}-php- 46 | 47 | - name: Install dependencies 48 | run: composer install --prefer-dist --no-progress 49 | 50 | - name: add bin to $PATH 51 | run: | 52 | echo "$GITHUB_WORKSPACE/src/private/libraries/bin/" >> $GITHUB_PATH 53 | 54 | - name: Run phpcs 55 | run: make phpcs 56 | 57 | - name: Run phpstan 58 | run: make phpstan 59 | -------------------------------------------------------------------------------- /src/includes/common.php: -------------------------------------------------------------------------------- 1 | beGreedy(); 10 | 11 | $cfg = new \libAllure\ConfigFile(); 12 | $cfg->set( 13 | [ 14 | 'DB_NAME' => 'faridoon', 15 | 'DB_HOST' => 'mysql', 16 | 'SITE_TITLE' => 'Faridoon', 17 | ] 18 | ); 19 | $cfg->loadFromPaths( 20 | [ 21 | '/config/', 22 | '/var/www/html/faridoon/', 23 | '/etc/faridoon/config.ini', 24 | ] 25 | ); 26 | $cfg->loadFromEnv(); 27 | 28 | use libAllure\Database; 29 | use libAllure\DatabaseFactory; 30 | 31 | $db = new Database($cfg->getDsn(), $cfg->get('DB_USER'), $cfg->get('DB_PASS')); 32 | DatabaseFactory::registerInstance($db); 33 | 34 | require_once 'includes/startup.php'; 35 | 36 | requireDatabaseVersion('2.permissions.sql'); 37 | 38 | require_once 'includes/functionality.php'; 39 | 40 | \libAllure\Sanitizer::getInstance()->enableSearchingPrefixKeys(); 41 | 42 | use libAllure\AuthBackend; 43 | use libAllure\AuthBackendDatabase; 44 | 45 | $backend = new AuthBackendDatabase($db); 46 | $backend->register(); 47 | 48 | use libAllure\Session; 49 | 50 | Session::setSessionName('faridoon'); 51 | Session::start(); 52 | 53 | use libAllure\Template; 54 | 55 | $tpl = new Template(sys_get_temp_dir() . '/faridoon/' . 'includes/templates/'); 56 | $tpl->registerModifier('isAdmin', 'isAdmin'); 57 | -------------------------------------------------------------------------------- /src/includes/classes/FormAddUserToGroup.php: -------------------------------------------------------------------------------- 1 | filterUint('uid'); 19 | 20 | $this->addElementReadOnly('User', $uid, 'uid'); 21 | $this->addElementUsergroup(); 22 | 23 | $this->addDefaultButtons('Change group'); 24 | } 25 | 26 | private function addElementUsergroup() 27 | { 28 | $stmt = DatabaseFactory::getInstance()->prepare('SELECT g.id, g.title FROM `groups` g'); 29 | $stmt->execute(); 30 | 31 | $el = new ElementSelect('gid', 'Group'); 32 | 33 | foreach ($stmt->fetchAll() as $group) { 34 | $el->addOption($group['title'], $group['id']); 35 | } 36 | 37 | $this->addElement($el); 38 | } 39 | 40 | public function process() 41 | { 42 | $stmt = DatabaseFactory::getInstance()->prepare('UPDATE users u SET u.`group` = :gid WHERE u.id = :uid'); 43 | $stmt->bindValue(':uid', $this->getElementValue('uid')); 44 | $stmt->bindValue(':gid', $this->getElementValue('gid')); 45 | $stmt->execute(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /.github/workflows/release-pipeline.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: "Release Pipeline" 3 | 4 | on: [push, pull_request] 5 | 6 | jobs: 7 | snapshot: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v4 12 | with: 13 | fetch-depth: 0 14 | 15 | - name: Set up QEMU 16 | uses: docker/setup-qemu-action@v3 17 | with: 18 | image: tonistiigi/binfmt:latest 19 | platforms: arm64 20 | 21 | - name: Setup PHP Action 22 | uses: shivammathur/setup-php@2.33.0 23 | with: 24 | php-version: '8.3' 25 | 26 | - name: Login to ghcr 27 | uses: docker/login-action@v3.1.0 28 | with: 29 | registry: ghcr.io 30 | username: ${{ github.actor }} 31 | password: ${{ secrets.GITHUB_TOKEN }} 32 | 33 | - name: release 34 | if: github.ref_type != 'tag' 35 | uses: cycjimmy/semantic-release-action@v4 36 | with: 37 | extra_plugins: | 38 | @semantic-release/commit-analyzer 39 | @semantic-release/git 40 | @semantic-release/exec 41 | @semantic-release/github 42 | semantic_version: 24.2.3 # https://github.com/cycjimmy/semantic-release-action/issues/243 43 | 44 | env: 45 | GH_TOKEN: ${{ secrets.CONTAINER_TOKEN }} 46 | GITHUB_TOKEN: ${{ secrets.CONTAINER_TOKEN }} 47 | GITHUB_REF_NAME: ${{ github.ref_name }} 48 | -------------------------------------------------------------------------------- /src/includes/templates/formElements.tpl: -------------------------------------------------------------------------------- 1 | {foreach from = $elements item = "element"} 2 | {if is_array($element)} 3 | {include file = "formElements.tpl" elements=$element} 4 | {else} 5 | {if $element->getType() eq 'ElementHidden'} 6 | 7 | {elseif $element->getType() eq 'ElementButton'} 8 | 9 | {else} 10 | 11 | 12 |
13 | {$element->render()} 14 |
15 | 16 |
17 |

{$element->description}

18 |
19 | 20 |
21 | {if !empty($suggestedValues)} 22 | {foreach from = $suggestedValues key = sv item = caption} 23 | {$caption}'; 24 | {/foreach} 25 | {/if} 26 |
27 | 28 |
29 |

{$element->getValidationError()}

30 |
31 | {/if} 32 | {/if} 33 | {/foreach} 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/register.php: -------------------------------------------------------------------------------- 1 | getBool('DISABLE_REGISTRATION')) { 6 | require_once 'includes/widgets/header.php'; 7 | 8 | echo '
Registration is disabled.
'; 9 | 10 | include_once 'includes/widgets/footer.php'; 11 | exit; 12 | } 13 | 14 | use libAllure\util\FormRegister; 15 | 16 | $f = new FormRegister(); 17 | $f->setTitle('Register as a new user'); 18 | $f->getElement('submit')->setCaption('Register user'); 19 | 20 | if ($f->validate()) { 21 | $f->process(); 22 | 23 | $uid = $db->lastInsertId(); 24 | 25 | $sql = 'SELECT * FROM users'; 26 | $stmt = $db->prepare($sql); 27 | $stmt->execute(); 28 | 29 | 30 | require_once 'includes/widgets/header.php'; 31 | 32 | echo '
'; 33 | echo '

You have been registered. You can now login.

'; 34 | 35 | $sql = 'UPDATE users SET `group` = :gid WHERE id = :uid LIMIT 1'; 36 | $stmt = $db->prepare($sql); 37 | $stmt->bindValue('uid', $uid); 38 | 39 | 40 | if ($stmt->numRows() == 1) { 41 | $gid = 1; 42 | 43 | echo '

You have been promoted to admin as you are the first registered user.

'; 44 | } else { 45 | $gid = 2; 46 | } 47 | 48 | $stmt->bindValue('gid', $gid); 49 | $stmt->execute(); 50 | 51 | echo '

Login

'; 52 | echo '
'; 53 | } else { 54 | include_once 'includes/widgets/header.php'; 55 | 56 | $tpl->displayForm($f); 57 | 58 | include_once 'includes/widgets/footer.php'; 59 | } 60 | -------------------------------------------------------------------------------- /src/list.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 32 | $stmt->execute(); 33 | $quotes = $stmt->fetchAll(); 34 | 35 | $foundRows = intval($db->prepare('SELECT found_rows() AS count')->executeRet()->fetchColumn()); 36 | $numPages = ceil($foundRows / $limit); 37 | 38 | $navigable ? pagingLinks($start, $page, $numPages) : null; 39 | 40 | if (count($quotes) == 0) { 41 | echo '

This page intentionally left blank...?

There are no quotes in the database... yet. Click "Add" in the navigation to be the first!

'; 42 | } else { 43 | foreach ($quotes as $dbquote) { 44 | $quote = new Quote(); 45 | $quote->unmarshalFromDatabase($dbquote); 46 | 47 | include 'includes/widgets/quote.php'; 48 | } 49 | } 50 | 51 | $navigable ? pagingLinks($start, $page, $numPages) : null; 52 | 53 | require_once 'includes/widgets/footer.php'; 54 | -------------------------------------------------------------------------------- /src/includes/classes/FormUsergroupGrant.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 19 | $stmt->bindValue(':group', Shortcuts::san()->filterUint('gid')); 20 | $stmt->execute(); 21 | 22 | // var_dump(Shortcuts::san()->filterUint('gid')); exit; 23 | $group = $stmt->fetchRowNotNull(); 24 | 25 | $this->addElementReadOnly('Usergroup', $group['id'], 'gid'); 26 | 27 | $this->addElementPermission(); 28 | $this->addDefaultButtons('Grant'); 29 | } 30 | 31 | public function addElementPermission() 32 | { 33 | global $db; 34 | 35 | $el = new ElementSelect('permission', 'Permission'); 36 | 37 | $sql = 'SELECT p.key, p.id FROM permissions p ORDER BY p.key ASC'; 38 | $stmt = $db->prepare($sql); 39 | $stmt->execute(); 40 | 41 | foreach ($stmt->fetchAll() as $perm) { 42 | $el->addOption($perm['key'], $perm['id']); 43 | } 44 | 45 | $this->addElement($el); 46 | } 47 | 48 | public function process() 49 | { 50 | global $db; 51 | $stmt = $db->prepare('INSERT INTO privileges_g (permission, `group`) values (:permission, :group) '); 52 | $stmt->bindValue(':permission', $this->getElementValue('permission')); 53 | $stmt->bindValue(':group', $this->getElementValue('gid')); 54 | $stmt->execute(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | --- 2 | site_url: https://jamesread.github.io/Faridoon/ 3 | site_name: Faridoon Docs 4 | site_description: Publish your favourite chat quotes. 5 | repo_url: https://github.com/jamesread/Faridoon 6 | repo_name: jamesread/Faridoon 7 | edit_uri: edit/main/docs 8 | strict: true 9 | 10 | markdown_extensions: 11 | - codehilite 12 | - pymdownx.highlight: 13 | anchor_linenums: true 14 | line_spans: __span 15 | pygments_lang_class: true 16 | - pymdownx.inlinehilite 17 | - pymdownx.snippets 18 | - pymdownx.superfences 19 | - toc: 20 | permalink: true 21 | 22 | theme: 23 | name: material 24 | logo: faridoon.png 25 | favicon: faridoon.png 26 | language: en 27 | include_search_page: true 28 | search_index_only: true 29 | palette: 30 | primary: deep purple 31 | features: 32 | - search.suggest 33 | - search.highlight 34 | - search.share 35 | - content.code.copy 36 | - content.action.edit 37 | icon: 38 | repo: fontawesome/brands/github 39 | 40 | 41 | plugins: 42 | - search: 43 | - social: 44 | - minify: 45 | minify_html: true 46 | - tags: 47 | 48 | extra: 49 | social: 50 | - icon: fontawesome/brands/github 51 | link: https://github.com/jamesread/faridoon 52 | 53 | - icon: fontawesome/brands/mastodon 54 | link: https://mastodon.social/@jamesread 55 | 56 | - icon: fontawesome/brands/x-twitter 57 | link: https://twitter.com/jamesreadtweets 58 | 59 | nav: 60 | - Welcome: index.md 61 | - Installation: 62 | - Introduction: installation/index.md 63 | - Docker Compose (recommended): installation/docker-compose.md 64 | - Docker standalone: installation/docker.md 65 | - Run database migrations: installation/migrations.md 66 | - Configuration: configuration/index.md 67 | - "Security": security/index.md 68 | - "Contact & Support": contact-support.md 69 | -------------------------------------------------------------------------------- /src/includes/templates/quote.tpl: -------------------------------------------------------------------------------- 1 |
2 | {if $isVotingEnabled} 3 |
4 | 5 | {$quote->voteCount} 6 | 7 |
8 | {/if} 9 | 10 |
11 |
12 | #{$quote->id} 13 | 14 | {if $hasApprovalPermissions} 15 | 41 | {/if} 42 |
43 | 44 |
45 |

46 | {foreach $quote->lines as $line} 47 | 48 | {if isset($line.username)} 49 | {$line.username}: 50 | {/if} 51 | {$line.content} 52 | 53 | {/foreach} 54 |

55 |
56 |
57 |
58 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributions 2 | 3 | Contributions are very welcome - code, docs, whatever they might be! If this is 4 | your first contribution to an Open Source project or you're a core maintainer 5 | of multiple projects, your time and interest in contributing is most welcome. 6 | 7 | If you're not sure where to get started, raise an issue in the project. 8 | 9 | Ideas may be discussed, purely on their merits and issues. Our Code of Conduct 10 | (CoC) is straightforward - it's important that contributors feel comfortable in 11 | discussion throughout the whole process. This project has a 12 | [Code of Conduct](CODE_OF_CONDUCT.md). 13 | 14 | ## More than 3 lines - talk to someone first 15 | 16 | If you're planning on making a change that's more than a 3 lines, please talk to someone first. This is so that you don't waste your time on something that might not be accepted. It's also a good way to get some feedback on your idea and make sure you're on the right track. 17 | 18 | ## A PR should be one logical change 19 | 20 | Please try to keep your pull requests small and focused. It's almost impossible to review PRs that change lots of files for lots of different reasons. If you have a big change, it's probably best to break it down into smaller, more manageable chunks, otherwise it's likely to be rejected. 21 | 22 | ## If you're not sure, ask! 23 | 24 | Don't be afraid to ask for advice before working on a 25 | contribution. If you're thinking about a bigger change, especially that might 26 | affect the core working or architecture, it's almost essential to talk and ask 27 | about what you're planning might affect things. Some of the larger future plans may not be 28 | documented well so it's difficult to understand how your change might affect 29 | the general direction and roadmap of this project without asking. 30 | 31 | The preferred way to communicate is probably via Discord or GitHub issues. 32 | 33 | ## Mechanics of submitting a pull request 34 | 35 | When you are ready for a PR, please see the [pull request template](.github/PULL_REQUEST_TEMPLATE.md). 36 | -------------------------------------------------------------------------------- /src/resources/javascript/main.js: -------------------------------------------------------------------------------- 1 | function toggleFullscreen () { 2 | if (document.fullscreenElement) { 3 | document.exitFullscreen() 4 | } else { 5 | document.documentElement.requestFullscreen() 6 | } 7 | } 8 | 9 | window.logoClicks = 0 10 | 11 | function clickLogo () { 12 | window.logoClicks++ 13 | if (window.logoClicks >= 5) { 14 | document.getElementById('developer-links').hidden = false 15 | 16 | window.alert('You found the hidden developer links!') 17 | 18 | } 19 | } 20 | 21 | function voteUp (id) { 22 | return vote(id, 'up') 23 | } 24 | 25 | function voteDown (id) { 26 | return vote(id, 'down') 27 | } 28 | 29 | function vote (id, dir) { 30 | window.fetch('vote.php', { 31 | method: 'POST', 32 | headers: { 33 | 'Content-Type': 'application/json' 34 | }, 35 | body: JSON.stringify({ 36 | id: id, 37 | direction: dir 38 | }) 39 | }) 40 | .then(response => response.json()) 41 | .then(onVoteReply) 42 | .catch(onError) 43 | 44 | return false // prevent default 45 | } 46 | 47 | function onError (res) { 48 | console.log('err', res) 49 | 50 | document.querySelectorAll('p.error').forEach(function (el) { 51 | el.remove() 52 | }) 53 | 54 | if (typeof res.message !== 'undefined') { 55 | const p = document.createElement('p') 56 | p.classList.add('error') 57 | p.textContent = 'Error: ' + res.message 58 | p.addEventListener('click', function () { 59 | p.remove() 60 | }) 61 | 62 | document.body.appendChild(p) 63 | } 64 | } 65 | 66 | function onVoteReply (json) { 67 | if (json.type === 'error') { 68 | if (json.cause === 'needsLogin') { 69 | window.location = 'login.php' 70 | } else { 71 | onError(json) 72 | } 73 | } else { 74 | const voteCount = document.getElementById('quote' + json.id).querySelector('.voteCount') 75 | 76 | if (json.newVal === 0) { 77 | voteCount.classList.add('novotes') 78 | } else { 79 | voteCount.classList.remove('novotes') 80 | } 81 | 82 | voteCount.innerText = json.newVal 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /tests/TestHighlightUsernames.php: -------------------------------------------------------------------------------- 1 | unmarshalFromText($text); 14 | 15 | $this->assertEquals(count($quote->lines), 1); 16 | $this->assertEquals($quote->lines[0]['username'], 'james'); 17 | } 18 | 19 | public function testUsernamesInAngularBrackets() 20 | { 21 | $text = << hi 23 | EOQ; 24 | 25 | $quote = new faridoon\Quote(); 26 | $quote->unmarshalFromText($text); 27 | 28 | $this->assertEquals(count($quote->lines), 1); 29 | $this->assertEquals($quote->lines[0]['username'], 'James'); 30 | } 31 | 32 | public function testBashHunter2() { 33 | $text = << hey, if you type in your pw, it will show as stars 35 | ********* see! 36 | hunter2 37 | doesnt look like stars to me 38 | ******* 39 | thats what I see 40 | oh, really? 41 | Absolutely 42 | you can go hunter2 my hunter2-ing hunter2 43 | haha, does that look funny to you? 44 | lol, yes. See, when YOU type hunter2, it shows to us 45 | as ******* 46 | thats neat, I didnt know IRC did that 47 | yep, no matter how many times you type hunter2, it 48 | will show to us as ******* 49 | awesome! 50 | wait, how do you know my pw? 51 | er, I just copy pasted YOUR ******'s and it appears 52 | to YOU as hunter2 cause its your pw 53 | oh, ok. 54 | EOQ; 55 | 56 | $quote = new faridoon\Quote(); 57 | $quote->unmarshalFromText($text); 58 | 59 | $this->assertEquals(count($quote->lines), 20); 60 | $this->assertEquals($quote->lines[0]['username'], 'Cthon98'); 61 | $this->assertEquals($quote->lines[2]['username'], 'AzureDiamond'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/users.php: -------------------------------------------------------------------------------- 1 | prepare($sql); 13 | $stmt->bindParam(':id', $id); 14 | $stmt->execute(); 15 | 16 | redirect('users.php'); 17 | } 18 | 19 | if (isset($_GET['deleteGroup'])) { 20 | $id = intval($_GET['deleteGroup']); 21 | 22 | if ($id <= 2) { 23 | simpleFatalError('You cannot delete the default groups.'); 24 | } 25 | 26 | $sql = "DELETE FROM `groups` WHERE id = :id LIMIT 1"; 27 | $stmt = $db->prepare($sql); 28 | $stmt->bindParam(':id', $id); 29 | $stmt->execute(); 30 | 31 | redirect('users.php'); 32 | } 33 | 34 | if (isset($_GET['revokePermission'])) { 35 | $pid = intval($_GET['revokePermission']); 36 | $gid = intval($_GET['gid']); 37 | 38 | $sql = "DELETE FROM privileges_g WHERE `permission` = :pid AND `group` = :gid"; 39 | $stmt = $db->prepare($sql); 40 | $stmt->bindParam(':pid', $pid); 41 | $stmt->bindParam(':gid', $gid); 42 | $stmt->execute(); 43 | 44 | redirect('users.php'); 45 | } 46 | 47 | require_once 'includes/widgets/header.php'; 48 | 49 | $sql = "SELECT u.id, u.username, u.`group`, g.title AS groupTitle FROM users u LEFT JOIN `groups` g ON u.`group` = g.id"; 50 | $stmt = $db->prepare($sql); 51 | $stmt->execute(); 52 | 53 | $users = $stmt->fetchAll(); 54 | 55 | $tpl->assign('currentUid', Session::getUser()->getId()); 56 | $tpl->assign('users', $users); 57 | 58 | $sql = 'SELECT g.id, g.title FROM `groups` g'; 59 | $stmt = $db->prepare($sql); 60 | $stmt->execute(); 61 | 62 | $groups = array(); 63 | 64 | foreach ($stmt->fetchAll() as $usergroup) { 65 | $sql = 'SELECT gp.permission AS pid, p.`key`, p.description FROM privileges_g gp LEFT JOIN permissions p ON gp.permission = p.id WHERE gp.group = :gid'; 66 | $stmt = $db->prepare($sql); 67 | $stmt->bindParam(':gid', $usergroup['id']); 68 | $stmt->execute(); 69 | 70 | 71 | $groups[$usergroup['id']] = array ( 72 | 'id' => $usergroup['id'], 73 | 'title' => $usergroup['title'], 74 | 'permissions' => $stmt->fetchAll(), 75 | ); 76 | } 77 | 78 | $tpl->assign('usergroups', $groups); 79 | $tpl->display('users.tpl'); 80 | 81 | require_once 'includes/widgets/footer.php'; 82 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | RELEASE_VERSION ?= development 2 | 3 | lint: phpcs phpcbf phpstan 4 | 5 | phpcs: 6 | vendor/bin/phpcs src/ 7 | 8 | phpcbf: 9 | vendor/bin/phpcbf src/ 10 | 11 | phpstan: 12 | vendor/bin/phpstan analyse src/ 13 | 14 | phpunit: 15 | vendor/bin/phpunit tests/* 16 | 17 | clean: 18 | rm -rf build 19 | 20 | container-image: 21 | docker kill faridoon || true 22 | docker rm faridoon && docker rmi faridoon || true 23 | docker build -t faridoon:latest . 24 | 25 | container: container-image 26 | docker create --name faridoon -p 8080:8080 --env-file=.env.dev faridoon:latest 27 | docker start faridoon 28 | 29 | docker-amd64: 30 | docker buildx build --platform linux/amd64 -t ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-amd64 -f Dockerfile --output type=docker --load . 31 | docker push ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-amd64 32 | 33 | docker-arm64: 34 | docker buildx build --platform linux/arm64 -t ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-arm64 -f Dockerfile --output type=docker --load . 35 | docker push ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-arm64 36 | 37 | docker-manifest-latest: 38 | docker manifest create ghcr.io/jamesread/faridoon:latest \ 39 | ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-arm64 \ 40 | ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-amd64 41 | docker manifest annotate ghcr.io/jamesread/faridoon:latest \ 42 | ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-amd64 --os linux --arch amd64 43 | docker manifest annotate ghcr.io/jamesread/faridoon:latest \ 44 | ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-arm64 --os linux --arch arm64 45 | docker manifest push ghcr.io/jamesread/faridoon:latest 46 | 47 | docker-manifest-release-version: 48 | docker manifest create ghcr.io/jamesread/faridoon:${RELEASE_VERSION} \ 49 | ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-amd64 \ 50 | ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-arm64 51 | docker manifest annotate ghcr.io/jamesread/faridoon:${RELEASE_VERSION} \ 52 | ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-amd64 --os linux --arch amd64 53 | docker manifest annotate ghcr.io/jamesread/faridoon:${RELEASE_VERSION} \ 54 | ghcr.io/jamesread/faridoon:${RELEASE_VERSION}-arm64 --os linux --arch arm64 55 | docker manifest push ghcr.io/jamesread/faridoon:${RELEASE_VERSION} 56 | 57 | docker-manifest: docker-manifest-latest docker-manifest-release-version 58 | 59 | release: docker-amd64 docker-arm64 docker-manifest 60 | 61 | .PHONY: dist clean docker-container-image container 62 | -------------------------------------------------------------------------------- /src/includes/widgets/footer.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | project logo 3 |

Faridoon

4 | 5 | Easily save and publish your favourite chat quotes for others to see. 6 | 7 | [![Static Badge](https://img.shields.io/badge/maturity-Production-brightgreen)](#none) 8 | ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/jamesread/Faridoon/release-pipeline.yml?link=https%3A%2F%2Fgithub.com%2Fjamesread%2Ffaridoon%2Factions%2Fworkflows%2Frelease-pipeline.yml) 9 | [![Discord](https://img.shields.io/discord/846737624960860180?label=Discord%20Server)](https://discord.gg/jhYWWpNJ3v) 10 | 11 | Documentation for how to install and use Faridoon is available at https://jamesread.github.io/Faridoon/ 12 | 13 |
14 | 15 | ## Screenshots 16 | 17 | Note the screenshots below contain quotes from the site that inspired this self hosted project - bash.org - which is now offline. There are several mirrors available via search engines. These quotes were used because they've been shared wildly for over 2 decades, and they're pretty funny :-) 18 | 19 | ![Faridoon Mobile Phone Screenshot](var/mockupLaptop.png) 20 | 21 | ![Faridoon Desktop Screenshot](var/mockupMobilePhone.png) 22 | 23 | ## Getting Started 24 | 25 | Documentation is available at: https://jamesread.github.io/Faridoon/ , the recommended installation method is via **Docker**, connected to a **MySQL Database**. Faridoon runs just fine with low system resources - 1 vCPU and a 1 GB of RAM is plenty. 26 | 27 | ## Features 28 | 29 | * Automatic highlighting of usernames. 30 | * Semi-intelligent removal of line breaks and weird characters. 31 | * User login and registration, with support for admins and non-admins. 32 | * Approval system for guest and non-admin submissions. 33 | * Easy configuration via environment variables, or configuration file. 34 | 35 | ## **Faridoon is a No-Nonsense Open Source project;** 36 | 37 | - All code and assets are Open Source (AGPL). 38 | - No company is paying for development, there is no paid-for support from the developers. 39 | - No separate core and premium version, no plus/pro version or paid-for extra features. 40 | - No SaaS service or "special cloud version". 41 | - No "anonymous data collection", usage tracking, user tracking, telemetry or email address collection. 42 | - No requests for reviews in any "app store" or feedback surveys. 43 | - No prompts to "upgrade to the latest version". 44 | - No internet-connection required for any functionality. 45 | 46 | ## Docs 47 | 48 | Documentation for how to install and use Faridoon is available at https://jamesread.github.io/Faridoon/ 49 | -------------------------------------------------------------------------------- /src/vote.php: -------------------------------------------------------------------------------- 1 | getBool('VOTING_ENABLED')) { 9 | outputJson( 10 | array( 11 | "type" => "error", 12 | "message" => "Voting is disabled.", 13 | "cause" => "votingDisabled" 14 | ) 15 | ); 16 | } 17 | 18 | $cause = ""; 19 | 20 | try { 21 | $jsonData = file_get_contents('php://input'); 22 | $data = json_decode($jsonData, true); 23 | 24 | $dir = $data['direction']; 25 | $id = $data['id']; 26 | 27 | switch ($dir) { 28 | case 'up': 29 | $delta = 1; 30 | break; 31 | case 'down': 32 | $delta = -1; 33 | break; 34 | default: 35 | throw new Exception('What direction is that?! '); 36 | } 37 | 38 | if (!Session::isLoggedIn()) { 39 | $cause = 'needsLogin'; 40 | throw new Exception("You need to be logged in."); 41 | } else { 42 | $sql = 'SELECT v.delta FROM votes v WHERE v.quote = :quote AND v.user = :user LIMIT 1'; 43 | $stmt = DatabaseFactory::getInstance()->prepare($sql); 44 | $stmt->bindValue('quote', $id); 45 | $stmt->bindValue('user', Session::getUser()->getId()); 46 | $stmt->execute(); 47 | 48 | if ($stmt->numRows() > 0) { 49 | $currentRow = $stmt->fetchRow(); 50 | 51 | $sql = 'DELETE FROM votes WHERE quote = :quote AND user = :user'; 52 | $stmt = DatabaseFactory::getInstance()->prepare($sql); 53 | $stmt->bindValue('quote', $id); 54 | $stmt->bindValue('user', Session::getUser()->getId()); 55 | $stmt->execute(); 56 | } 57 | 58 | $sql = 'INSERT INTO votes (quote, user, delta) VALUES (:quote, :user, :delta1) ON DUPLICATE KEY UPDATE delta = :delta2'; 59 | $stmt = DatabaseFactory::getInstance()->prepare($sql); 60 | $stmt->bindValue('quote', $id); 61 | $stmt->bindValue('user', Session::getUser()->getId()); 62 | $stmt->bindValue('delta1', $delta); 63 | $stmt->bindValue('delta2', $delta); 64 | $stmt->execute(); 65 | 66 | $sql = 'SELECT SUM(v.delta) AS newVal FROM quotes q LEFT JOIN votes v ON v.quote = q.id WHERE q.id = :id GROUP BY q.id'; 67 | $stmt = DatabaseFactory::getInstance()->prepare($sql); 68 | $stmt->bindValue('id', $id); 69 | $stmt->execute(); 70 | 71 | $quote = $stmt->fetchRowNotNull(); 72 | $newVal = intval($quote['newVal']); 73 | } 74 | 75 | outputJson( 76 | array( 77 | "type" => "ok", 78 | "id" => $id, 79 | "newVal" => $newVal, 80 | ) 81 | ); 82 | } catch (Exception $e) { 83 | $error = array( 84 | "type" => "error", 85 | "message" => $e->getMessage(), 86 | "cause" => $cause 87 | ); 88 | 89 | outputJson($error); 90 | } 91 | -------------------------------------------------------------------------------- /src/includes/templates/users.tpl: -------------------------------------------------------------------------------- 1 |
2 |

Users

3 |

Here is a list of all users:

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {foreach from = $users item = $user} 15 | 16 | 17 | 18 | 19 | 26 | 27 | {/foreach} 28 | 29 |
IDUsernameUsergroupActions
{$user.id}{$user.username}{$user.groupTitle} 20 | {if $user.id == $currentUid} 21 | Cannot edit yourself 22 | {else} 23 | Edit 24 | {/if} 25 |
30 |
31 | 32 |
33 |

Usergroups

34 | 35 |

Note: People who a not logged in (ie: Guests) have zero permissions.

36 | Create a new usergroup 37 |
38 | 39 | {foreach from = $usergroups item = $usergroup} 40 |
41 |
42 |

Usergroup: {$usergroup.title}

43 | 54 |
55 | 56 |

Group ID: {$usergroup.id}

57 | 58 |
59 |

Permissions:

60 | 61 | {if $usergroup.id != 1} 62 | 71 | {/if} 72 |
73 | 74 | {if empty($usergroup.permissions)} 75 |

No extra permissions

76 | {else} 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | {foreach from = $usergroup.permissions item = $permission} 88 | 89 | 90 | 91 | 102 | {/foreach} 103 | 104 |
KeyDescriptionActions
{$permission.key}{$permission.description} 92 | {if $usergroup.id != 1} 93 | 94 | 95 | 96 | 97 | 98 | {else} 99 | Admins cannot have permissions revoked 100 | {/if} 101 |
105 | {/if} 106 |
107 | {/foreach} 108 | -------------------------------------------------------------------------------- /src/includes/templates/header.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {$siteTitle} 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 23 |
24 | 25 | 26 |

27 | {$siteTitle} 28 |

29 | 30 | 64 | 65 | 66 | 67 | 84 |
85 |
86 | -------------------------------------------------------------------------------- /src/includes/classes/Quote.php: -------------------------------------------------------------------------------- 1 | usernameColors[$username])) { 23 | return $this->usernameColors[$username]; 24 | } 25 | 26 | $col = $this->colorIndex; 27 | 28 | $this->colorIndex++; 29 | 30 | $this->usernameColors[$username] = $col; 31 | 32 | return $col; 33 | } 34 | 35 | public function unmarshalFromDatabase($dbquote) 36 | { 37 | $this->id = $dbquote['id']; 38 | $this->created = $dbquote['created']; 39 | $this->voteCount = $dbquote['voteCount']; 40 | $this->approved = $dbquote['approved']; 41 | $this->rawContent = $dbquote['content']; 42 | 43 | $this->parse(); 44 | } 45 | 46 | public function unmarshalFromText($text) 47 | { 48 | $this->id = 0; 49 | $this->voteCount = 0; 50 | $this->approved = true; 51 | $this->created = 'unknown'; 52 | $this->rawContent = $text; 53 | 54 | $this->parse(); 55 | } 56 | 57 | private function parse() 58 | { 59 | $c = $this->rawContent; 60 | $c = stripslashes($c); 61 | 62 | $this->explodeQuote($c); 63 | $this->findUsernames(); 64 | } 65 | 66 | public function explodeQuote($quoteContent) 67 | { 68 | $this->lines = []; 69 | 70 | foreach (explode("\n", $quoteContent) as $line) { 71 | $lineX = array( 72 | 'content' => $line, 73 | 'username' => null, 74 | 'bgColor' => null, 75 | ); 76 | 77 | $this->lines[] = $lineX; 78 | } 79 | } 80 | 81 | private function findUsernames() 82 | { 83 | $this->colorIndex = 1; 84 | $this->usernameColors = []; 85 | 86 | foreach ($this->lines as &$line) { 87 | $regex = '#^[\]\[\(\)\:\d ]*] (.*)#i'; 88 | 89 | preg_match($regex, $line['content'], $matches); 90 | 91 | switch (count($matches)) { 92 | case 3: 93 | $msg = str_replace('
', '', $matches[2]); 94 | $msg = trim($msg); 95 | 96 | if (empty($msg)) { 97 | break; 98 | } 99 | 100 | $line['username'] = htmlspecialchars($matches[1]); 101 | $line['usernameColor'] = $this->getUsernameColor($line['username']); 102 | $line['content'] = htmlspecialchars($matches[2]); 103 | 104 | break; 105 | default: 106 | break; 107 | } 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/includes/functionality.php: -------------------------------------------------------------------------------- 1 | 0) { 20 | list($prefix, $array) = array_pop($stack); 21 | 22 | foreach ($array as $key => $value) { 23 | $new_key = $prefix . strval($key); 24 | 25 | if (is_array($value)) { 26 | array_push($stack, array($new_key . '.', $value)); 27 | } else { 28 | $result[$new_key] = $value; 29 | } 30 | } 31 | } 32 | 33 | return $result; 34 | } 35 | 36 | function filter($name, $type = FILTER_DEFAULT) 37 | { 38 | $v = filter_input(INPUT_GET, $name, $type); 39 | 40 | if (empty($v)) { 41 | $v = filter_input(INPUT_POST, $name, $type); 42 | } 43 | 44 | return $v; 45 | } 46 | 47 | function isAdmin() 48 | { 49 | if (Session::isLoggedIn()) { 50 | $admin = Session::getUser()->hasPriv('ADMIN'); 51 | 52 | if ($admin) { 53 | return true; 54 | } 55 | } 56 | 57 | return false; 58 | } 59 | 60 | function pagingLinks($start, $page, $numPages) 61 | { 62 | if ($numPages > 0) { 63 | echo ''; 79 | } 80 | } 81 | 82 | function getCustomCss() 83 | { 84 | if (!file_exists('/config/custom.css')) { 85 | return ''; 86 | } else { 87 | return file_get_contents('/config/custom.css'); 88 | } 89 | } 90 | 91 | function randomLink() 92 | { 93 | } 94 | 95 | function outputJson($o) 96 | { 97 | header('Content-Type: application/json'); 98 | echo json_encode($o); 99 | exit; 100 | } 101 | 102 | function getCountApprovals() 103 | { 104 | $sql = 'SELECT count(q.id) countNew FROM quotes q WHERE q.approval = 0'; 105 | $stmt = libAllure\DatabaseFactory::getInstance()->prepare($sql); 106 | $stmt->execute(); 107 | $countNew = $stmt->fetch(); 108 | $countNew = $countNew['countNew']; 109 | $countNew = intval($countNew); 110 | 111 | return $countNew; 112 | } 113 | 114 | function requireAdmin() 115 | { 116 | if (!isAdmin()) { 117 | simpleFatalError('You are not an admin.'); 118 | 119 | exit; 120 | } 121 | } 122 | 123 | function simpleFatalError($message) 124 | { 125 | require_once 'includes/widgets/header.php'; 126 | 127 | echo '
'; 128 | echo '

Error

'; 129 | echo '

' . $message . '

'; 130 | echo '
'; 131 | 132 | include_once 'includes/widgets/footer.php'; 133 | 134 | exit; 135 | } 136 | 137 | function redirect($url) 138 | { 139 | header('Location: ' . $url); 140 | exit; 141 | } 142 | 143 | function isAddEnabled() 144 | { 145 | global $cfg; 146 | 147 | if (!Session::isLoggedIn()) { 148 | if ($cfg->getBool('GUESTS_DISABLE_ADD')) { 149 | return false; 150 | } else { 151 | return true; 152 | } 153 | } else { 154 | return true; 155 | } 156 | } 157 | 158 | function requirePriv($priv, $message) 159 | { 160 | if (!Session::getUser()->hasPriv($priv)) { 161 | simpleFatalError($message); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /src/includes/classes/FormQuote.php: -------------------------------------------------------------------------------- 1 | setFullyQualifiedElementNames(false); 20 | 21 | $this->isEdit = is_array($quote); 22 | 23 | if ($this->isEdit) { 24 | $this->addElementHidden('id', $quote['id']); 25 | $content = $quote['content']; 26 | $this->setTitle('Editing...'); 27 | } else { 28 | $content = 'Your quote here.'; 29 | } 30 | 31 | $tb = new ElementTextbox('content', 'Content', stripslashes($content), 'Note: Usernames are automatically highlighted. Timestamps are automatically stripped.'); 32 | $tb->rows = 8; 33 | $tb->cols = 20; 34 | $this->addElement($tb); 35 | 36 | global $cfg; 37 | if ($cfg->getBool('ENABLE_SYNTAX_HIGHLIGHTING')) { 38 | $this->addSyntaxHighlighting(); 39 | } else { 40 | $this->addElementHidden('syntaxHighlighting', ''); 41 | } 42 | 43 | $this->addElement(new ElementCheckbox('fixDiscordLinebreaks', 'Fix Discord linebreaks and remove timestamps?', false, 'If you paste a quote from Discord, it may have a lot of newlines around the username. This should fix that.')); 44 | 45 | if ($this->isEdit) { 46 | $this->addDefaultButtons('Save'); 47 | } else { 48 | $this->addDefaultButtons('Add'); 49 | } 50 | } 51 | 52 | private function addSyntaxHighlighting() 53 | { 54 | $el = $this->addElement(new ElementSelect('syntaxHighlighting', 'Syntax highlighting for code?', false, 'Is this quote mostly code? If so, it will have pretty formatting applied and usernames will not be highlighted.')); 55 | $el->addOption('Nope', ''); 56 | $el->addOption('C#', 'csharp'); 57 | $el->addOption('Javascript', 'javascript'); 58 | $el->addOption('PHP', 'php'); 59 | $el->addOption('Java', 'java'); 60 | $el->addOption('Python', 'python'); 61 | 62 | $this->addElement($el); 63 | } 64 | 65 | private function fixDiscordLinebreaks($content) 66 | { 67 | $content = preg_replace('#\[\n(?\d\d:\d\d)\n\]\n(?[\w\d_]+)\n:\n#i', "\\2: ", $content, -1, $count); 68 | 69 | return $content; 70 | } 71 | 72 | public function process() 73 | { 74 | $content = $this->getElementValue('content'); 75 | $content = preg_replace('#\r\n#', "\n", $content); 76 | 77 | if ($this->getElementValue('fixDiscordLinebreaks')) { 78 | $content = $this->fixDiscordLinebreaks($content); 79 | } 80 | 81 | if ($this->isEdit) { 82 | $this->processEdit($content); 83 | } else { 84 | $this->processAdd($content); 85 | } 86 | } 87 | 88 | public function processEdit($content) 89 | { 90 | global $db; 91 | global $cfg; 92 | 93 | if ($cfg->getBool('ENABLE_SYNTAX_HIGHLIGHTING')) { 94 | $syntaxHighlighting = $this->getElementValue('syntaxHighlighting'); 95 | } else { 96 | $syntaxHighlighting = ''; 97 | } 98 | 99 | $sql = 'UPDATE quotes SET content = :content, syntaxHighlighting = :syntaxHighlighting WHERE id = :id '; 100 | $stmt = $db->prepare($sql); 101 | $stmt->bindValue(':content', $content); 102 | $stmt->bindValue(':syntaxHighlighting', $syntaxHighlighting); 103 | $stmt->bindValue(':id', $this->getElementValue('id')); 104 | $stmt->execute(); 105 | } 106 | 107 | public function processAdd($content) 108 | { 109 | global $db; 110 | 111 | $sql = 'INSERT INTO quotes (content, created, approval) VALUES (:content, now(), :approval) '; 112 | $stmt = $db->prepare($sql); 113 | $stmt->bindValue(':content', $content); 114 | 115 | if (Session::isLoggedIn()) { 116 | $stmt->bindValue(':approval', Session::getUser()->hasPriv('BYPASS_APPROVAL') ? 1 : 0); 117 | } else { 118 | $stmt->bindValue(':approval', 0); 119 | } 120 | 121 | $stmt->execute(); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 21 | faridoon icon 23 | 25 | 28 | 32 | 36 | 37 | 46 | 47 | 66 | 81 | 82 | 88 | 94 | 101 | 108 | 110 | 111 | 113 | faridoon icon 114 | 115 | 116 | jamesread 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /src/resources/svg/faridoon.svg: -------------------------------------------------------------------------------- 1 | 2 | 21 | faridoon icon 23 | 25 | 28 | 32 | 36 | 37 | 46 | 47 | 66 | 81 | 82 | 88 | 94 | 101 | 108 | 110 | 111 | 113 | faridoon icon 114 | 115 | 116 | jamesread 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | contact@jread.com, or via Discord. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /database/migrations/0.base.sql: -------------------------------------------------------------------------------- 1 | -- +migrate Up 2 | 3 | -- MariaDB dump 10.19 Distrib 10.5.13-MariaDB, for Linux (x86_64) 4 | -- 5 | -- Host: mysql Database: faridoon 6 | -- ------------------------------------------------------ 7 | -- Server version 10.3.28-MariaDB 8 | 9 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 10 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 11 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 12 | /*!40101 SET NAMES utf8mb4 */; 13 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 14 | /*!40103 SET TIME_ZONE='+00:00' */; 15 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 16 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 17 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 18 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 19 | 20 | -- 21 | -- Table structure for table `group_memberships` 22 | -- 23 | 24 | DROP TABLE IF EXISTS `group_memberships`; 25 | /*!40101 SET @saved_cs_client = @@character_set_client */; 26 | /*!40101 SET character_set_client = utf8 */; 27 | CREATE TABLE `group_memberships` ( 28 | `id` int(11) NOT NULL AUTO_INCREMENT, 29 | `group` int(11) DEFAULT NULL, 30 | `user` int(11) DEFAULT NULL, 31 | PRIMARY KEY (`id`) 32 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 33 | /*!40101 SET character_set_client = @saved_cs_client */; 34 | 35 | -- 36 | -- Table structure for table `groups` 37 | -- 38 | 39 | DROP TABLE IF EXISTS `groups`; 40 | /*!40101 SET @saved_cs_client = @@character_set_client */; 41 | /*!40101 SET character_set_client = utf8 */; 42 | CREATE TABLE `groups` ( 43 | `id` int(11) NOT NULL AUTO_INCREMENT, 44 | `title` varchar(32) DEFAULT NULL, 45 | PRIMARY KEY (`id`) 46 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 47 | /*!40101 SET character_set_client = @saved_cs_client */; 48 | 49 | -- 50 | -- Table structure for table `permissions` 51 | -- 52 | 53 | DROP TABLE IF EXISTS `permissions`; 54 | /*!40101 SET @saved_cs_client = @@character_set_client */; 55 | /*!40101 SET character_set_client = utf8 */; 56 | CREATE TABLE `permissions` ( 57 | `id` int(11) NOT NULL AUTO_INCREMENT, 58 | `key` varchar(32) DEFAULT NULL, 59 | `description` longtext DEFAULT NULL, 60 | PRIMARY KEY (`id`) 61 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; 62 | /*!40101 SET character_set_client = @saved_cs_client */; 63 | 64 | -- 65 | -- Table structure for table `privileges_g` 66 | -- 67 | 68 | DROP TABLE IF EXISTS `privileges_g`; 69 | /*!40101 SET @saved_cs_client = @@character_set_client */; 70 | /*!40101 SET character_set_client = utf8 */; 71 | CREATE TABLE `privileges_g` ( 72 | `permission` int(11) DEFAULT NULL, 73 | `group` int(11) DEFAULT NULL 74 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 75 | /*!40101 SET character_set_client = @saved_cs_client */; 76 | 77 | -- 78 | -- Table structure for table `privileges_u` 79 | -- 80 | 81 | DROP TABLE IF EXISTS `privileges_u`; 82 | /*!40101 SET @saved_cs_client = @@character_set_client */; 83 | /*!40101 SET character_set_client = utf8 */; 84 | CREATE TABLE `privileges_u` ( 85 | `permission` int(11) DEFAULT NULL, 86 | `user` int(11) DEFAULT NULL 87 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 88 | /*!40101 SET character_set_client = @saved_cs_client */; 89 | 90 | -- 91 | -- Table structure for table `quotes` 92 | -- 93 | 94 | DROP TABLE IF EXISTS `quotes`; 95 | /*!40101 SET @saved_cs_client = @@character_set_client */; 96 | /*!40101 SET character_set_client = utf8 */; 97 | CREATE TABLE `quotes` ( 98 | `id` int(11) NOT NULL AUTO_INCREMENT, 99 | `content` text NOT NULL, 100 | `rating` int(11) NOT NULL DEFAULT 0, 101 | `approval` tinyint(4) NOT NULL DEFAULT 0, 102 | `check` int(11) NOT NULL DEFAULT 0, 103 | `created` datetime DEFAULT NULL, 104 | `syntaxHighlighting` varchar(255) DEFAULT NULL, 105 | PRIMARY KEY (`id`) 106 | ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; 107 | /*!40101 SET character_set_client = @saved_cs_client */; 108 | 109 | -- 110 | -- Table structure for table `users` 111 | -- 112 | 113 | DROP TABLE IF EXISTS `users`; 114 | /*!40101 SET @saved_cs_client = @@character_set_client */; 115 | /*!40101 SET character_set_client = utf8 */; 116 | CREATE TABLE `users` ( 117 | `id` int(11) NOT NULL AUTO_INCREMENT, 118 | `username` varchar(32) DEFAULT NULL, 119 | `password` varchar(64) DEFAULT NULL, 120 | `group` int(11) DEFAULT NULL, 121 | `lastLogin` datetime DEFAULT NULL, 122 | `registered` datetime DEFAULT NULL, 123 | `email` varchar(1024) DEFAULT NULL, 124 | PRIMARY KEY (`id`) 125 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; 126 | /*!40101 SET character_set_client = @saved_cs_client */; 127 | 128 | -- 129 | -- Table structure for table `votes` 130 | -- 131 | 132 | DROP TABLE IF EXISTS `votes`; 133 | /*!40101 SET @saved_cs_client = @@character_set_client */; 134 | /*!40101 SET character_set_client = utf8 */; 135 | CREATE TABLE `votes` ( 136 | `id` int(11) NOT NULL AUTO_INCREMENT, 137 | `delta` int(11) NOT NULL, 138 | `quote` int(11) NOT NULL, 139 | `user` int(11) NOT NULL, 140 | PRIMARY KEY (`id`) 141 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 142 | /*!40101 SET character_set_client = @saved_cs_client */; 143 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 144 | 145 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 146 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 147 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 148 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 149 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 150 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 151 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 152 | 153 | -- Dump completed on 2022-01-21 22:00:30 154 | 155 | -- +migrate Down 156 | -------------------------------------------------------------------------------- /src/resources/stylesheets/app.css: -------------------------------------------------------------------------------- 1 | nav { 2 | display: flex; 3 | flex-grow: 1; 4 | } 5 | 6 | form { 7 | display: grid; 8 | grid-template-columns: max-content auto auto auto auto; 9 | gap: 1em; 10 | } 11 | 12 | footer { 13 | text-align: center; 14 | padding: 1em; 15 | } 16 | 17 | section { 18 | max-width: 800px; 19 | margin-left: auto; 20 | margin-right: auto; 21 | } 22 | 23 | section.small { 24 | width: 30%; 25 | margin: auto; 26 | } 27 | 28 | section *:last-child { 29 | margin-bottom: 0; 30 | } 31 | 32 | .quoteContainer { 33 | flex-grow: 1; 34 | } 35 | 36 | ul.section-links { 37 | padding: 0; 38 | margin: 0; 39 | display: inline-block; 40 | } 41 | 42 | ul.section-links li { 43 | list-style-type: none; 44 | display: inline; 45 | } 46 | 47 | nav ul:first-child { 48 | flex-grow: 1; 49 | } 50 | 51 | textarea { 52 | place-self: stretch; 53 | } 54 | 55 | p.quote, .snippet-wrap { 56 | font-family: monospace; 57 | margin-top: .6em; 58 | } 59 | 60 | span.line { 61 | display: block; 62 | padding: .2em; 63 | } 64 | 65 | .formValidationError { 66 | color: red; 67 | } 68 | 69 | a, a:visited { 70 | color: #5f1a99; 71 | text-decoration: none; 72 | } 73 | 74 | a:hover .svg-icon { 75 | color: white; 76 | } 77 | 78 | header a, header a:visited { 79 | color: white; 80 | } 81 | 82 | header img.logo { 83 | margin-right: .3em; 84 | } 85 | 86 | header { 87 | color: white; 88 | background-color: #5f1a99; 89 | box-shadow: 0 0 1em #403636; 90 | place-items: center; 91 | } 92 | 93 | .svg-icon { 94 | width: 1.4em; 95 | height: 1.4em; 96 | vertical-align: bottom; 97 | fill: red; 98 | } 99 | 100 | div.pagination { 101 | text-align: center; 102 | padding: 1em; 103 | } 104 | 105 | span.currentPage { 106 | font-weight: bold; 107 | padding: 1em; 108 | } 109 | 110 | div.container { 111 | display: block; 112 | vertical-align: top; 113 | width: 50%; 114 | margin: auto; 115 | } 116 | 117 | section.quote { 118 | margin-bottom: 2.5em; 119 | display: flex; 120 | } 121 | 122 | .quoteContainer { 123 | display: flex; 124 | flex-direction: column; 125 | } 126 | 127 | div.voteContainer { 128 | flex: 0 1 auto; 129 | margin-right: 1em; 130 | vertical-align: top; 131 | text-align: center; 132 | min-width: 2em; 133 | } 134 | 135 | div.voteContainer button { 136 | display: block; 137 | color: lightgray; 138 | cursor: pointer; 139 | border: 0; 140 | font-size: 1.5em; 141 | text-decoration: none; 142 | background-color: transparent; 143 | } 144 | 145 | div.voteContainer button:hover { 146 | color: black; 147 | background-color: transparent; 148 | } 149 | 150 | div.section-header { 151 | display: flex; 152 | gap: .5em; 153 | } 154 | 155 | div.section-header .section-links { 156 | flex-grow: 2; 157 | text-align: end; 158 | } 159 | 160 | div.section-header ul.section-links a .svg-icon { 161 | padding: .2em; 162 | border-radius: 2em; 163 | } 164 | 165 | a:hover .svg-icon { 166 | background-color: #5f1a99; 167 | } 168 | 169 | span.voteCount.novotes { 170 | color: gray; 171 | } 172 | 173 | span.voteCount { 174 | font-weight: bold; 175 | display: inline-block; 176 | vertical-align: middle; 177 | font-size: 1.2em; 178 | text-align: center; 179 | } 180 | 181 | form#add { 182 | grid-template-columns: 1fr; 183 | } 184 | 185 | form#add button { 186 | justify-self: baseline; 187 | } 188 | 189 | div.empty { 190 | width: 0px; 191 | } 192 | 193 | form#add div.empty { 194 | display: none; 195 | } 196 | 197 | span.username { 198 | font-weight: bold; 199 | } 200 | 201 | nav li a:hover { 202 | background-color: #3a0b62; 203 | } 204 | 205 | ul.block-links { 206 | list-style: none; 207 | padding: 0; 208 | display: grid; 209 | grid-template-rows: auto auto; 210 | grid-template-columns: auto auto; 211 | gap: 1em; 212 | } 213 | 214 | ul.block-links a { 215 | padding: 1em; 216 | display: block; 217 | border: 1px solid #ccc; 218 | border-radius: 1em; 219 | box-shadow: 0 0 .5em #d2d2d2; 220 | } 221 | 222 | ul.block-links a:hover { 223 | background-color: #3a0b62; 224 | color: white; 225 | } 226 | 227 | #developer-links a { 228 | color: yellow; 229 | } 230 | 231 | @media (prefers-color-scheme: dark) { 232 | body { 233 | background-color: #333; 234 | color: #ddd; 235 | } 236 | 237 | ul.block-links a { 238 | border: 1px solid #666; 239 | box-shadow: 0 0 .5em #1c1c1c; 240 | } 241 | 242 | section { 243 | background-color: #444; 244 | color: #ddd; 245 | border-radius: 1em; 246 | box-shadow: 0 0 1em #261f1f; 247 | padding: 1em; 248 | } 249 | 250 | header { 251 | box-shadow: 0 0 1em #1c1c1c; 252 | } 253 | 254 | a, a:visited { 255 | color: #ccc; 256 | } 257 | 258 | a:hover { 259 | color: #fff; 260 | } 261 | 262 | form { 263 | background-color: #6a6a6a; 264 | } 265 | } 266 | 267 | .usernameColor1 { 268 | color: #D93989; 269 | } 270 | 271 | .usernameColor2 { 272 | color: #3399FF; 273 | } 274 | 275 | .usernameColor3 { 276 | color: green; 277 | } 278 | 279 | .usernameColor4 { 280 | color: orange; 281 | } 282 | 283 | .usernameColor5 { 284 | color: #FF00FF; 285 | } 286 | 287 | .usernameColor6 { 288 | color: #FF6600; 289 | } 290 | 291 | .usernameColor7 { 292 | color: #FFCC00; 293 | } 294 | 295 | .usernameColor8 { 296 | color: #00CC00; 297 | } 298 | 299 | #navigation-toggle { 300 | display: none; 301 | color: white; 302 | background-color: #5f1a99; 303 | border: 0; 304 | box-shadow: 0; 305 | font-size: 1.4em; 306 | padding: 0; 307 | padding-left: .4em; 308 | padding-right: .4em; 309 | margin: 0; 310 | } 311 | 312 | table { 313 | border-collapse: collapse; 314 | } 315 | 316 | td, th { 317 | padding: .5em; 318 | border: 1px solid #999; 319 | } 320 | 321 | @media screen and (max-width: 640px) { 322 | #content, #footer, body { 323 | width: auto; 324 | } 325 | 326 | h1 { 327 | margin-top: 0; 328 | border-radius: 0; 329 | flex-grow: 1; 330 | text-align: right; 331 | } 332 | 333 | div.navbar { 334 | width: auto; 335 | margin: 0; 336 | border-radius: 0; 337 | border-bottom: 1px solid #999; 338 | } 339 | 340 | ul.navigation.right { 341 | border-left: 1px dashed #999; 342 | } 343 | 344 | div.voteContainer { 345 | text-align: center; 346 | margin-right: 0.5em; 347 | } 348 | 349 | span.voteCount { 350 | display: block; 351 | padding: 0; 352 | text-align: center; 353 | } 354 | 355 | #navigation-toggle { 356 | z-index: 9; 357 | } 358 | 359 | nav { 360 | display: none; 361 | position: fixed; 362 | top: 0; 363 | width: 180px; 364 | height: 100vh; 365 | left: 0; 366 | flex-direction: column; 367 | background-color: black; 368 | padding-top: 4em; 369 | } 370 | 371 | nav.open { 372 | display: flex; 373 | } 374 | 375 | #navigation-toggle { 376 | display: block; 377 | } 378 | 379 | nav ul li { 380 | display: block; 381 | margin: 0; 382 | } 383 | 384 | nav ul li a { 385 | display: block; 386 | padding-left: 1em; 387 | padding-top: .4em; 388 | padding-bottom: .4em; 389 | border-radius: 0; 390 | } 391 | 392 | nav ul:first-child { 393 | padding-bottom: 2em; 394 | flex-grow: 0; 395 | } 396 | 397 | header { 398 | flex-direction: row-reverse; 399 | } 400 | } 401 | 402 | 403 | -------------------------------------------------------------------------------- /src/resources/stylesheets/theme.css: -------------------------------------------------------------------------------- 1 | /** https://github.com/jamesread/BrightAndSimpleTheme **/ 2 | html, body { 3 | display: flex; 4 | flex-direction: column; 5 | min-height: 100vh; 6 | } 7 | 8 | body { 9 | font-family: sans-serif; 10 | margin: 0; 11 | padding: 0; 12 | background-color: #dee3e7; 13 | color: rgb(51, 65, 85); 14 | } 15 | 16 | main { 17 | margin: 0; 18 | padding: 1em; 19 | flex-grow: 1; 20 | } 21 | 22 | section { 23 | background-color: white; 24 | padding: 1em; 25 | border-radius: .4em; 26 | margin-bottom: 1em; 27 | box-shadow: 0 0 .5em #9a9a9a; 28 | } 29 | 30 | header { 31 | background-color: #444; 32 | color: white; 33 | display: flex; 34 | box-shadow: 0px 0px 6px 5px #aaa; 35 | border-bottom: 1px solid #3f3f3f; 36 | align-items: center; 37 | gap: 1em; 38 | z-index: 1; /* So the header box-shadow shows over the top of the sidebar */ 39 | min-height: 3em; /* .logo 2em + .5em padding */ 40 | } 41 | 42 | header a, header a:visited { 43 | color: white; 44 | text-decoration: none; 45 | cursor: pointer; 46 | } 47 | 48 | header a.active { 49 | text-decoration: underline; 50 | } 51 | 52 | header img.logo { 53 | width: 2em; 54 | height: 2em; 55 | padding: .5em; 56 | } 57 | 58 | .icon { 59 | font-size: 2em; 60 | } 61 | 62 | header p { 63 | margin: 0; 64 | } 65 | 66 | h1 { 67 | margin: 0; 68 | margin-right: 1em; 69 | font-size: 1em; 70 | } 71 | 72 | h2 { 73 | font-weight: 800; 74 | font-size: 1.1em; 75 | letter-spacing: -.025em; 76 | margin-bottom: -.25em; 77 | } 78 | 79 | h2:first-child { 80 | margin-top: 0; 81 | } 82 | 83 | nav ul { 84 | list-style-type: none; 85 | padding: 0; 86 | margin: 0; 87 | } 88 | 89 | nav li { 90 | display: inline; 91 | margin-right: 1em; 92 | } 93 | 94 | nav li a { 95 | color: white; 96 | text-decoration: none; 97 | padding: .4em; 98 | border-radius: .4em; 99 | } 100 | 101 | nav li a:hover { 102 | background-color: #555; 103 | } 104 | 105 | pre { 106 | background-color: beige; 107 | padding: .5em; 108 | border-radius: .4em; 109 | text-align: left; 110 | } 111 | 112 | .br { 113 | border-radius: .4em; 114 | } 115 | 116 | .bs { 117 | box-shadow: 0 0 .5em #9a9a9a; 118 | } 119 | 120 | .annotation { 121 | font-size: 9pt; 122 | color: white; 123 | background-color: black; 124 | border-radius: .4em; 125 | display: inline-block; 126 | padding: .4em; 127 | margin: .4em; 128 | } 129 | 130 | .critical, .error, .bad { 131 | color: white !important; 132 | background-color: salmon; 133 | } 134 | 135 | .warning { 136 | background-color: moccasin; 137 | } 138 | 139 | .severe { 140 | background-color: lightsalmon; 141 | } 142 | 143 | .important { 144 | background-color: lightgoldenrodyellow; 145 | } 146 | 147 | .note { 148 | background-color: lightblue; 149 | } 150 | 151 | .info { 152 | background-color: #efefef; 153 | } 154 | 155 | .success, .good { 156 | background-color: lightgreen; 157 | color: black; 158 | } 159 | 160 | .old { 161 | background-color: wheat !important; 162 | } 163 | 164 | .inline-notification { 165 | border-radius: .4em; 166 | padding: .4em; 167 | box-shadow: 0 0 .4em #cacaca; 168 | } 169 | 170 | button { 171 | padding-top: .4em; 172 | padding-bottom: .4em; 173 | padding-left: 1em; 174 | padding-right: 1em; 175 | border-radius: .4em; 176 | background-color: #fff; 177 | font-weight: bold; 178 | font-family: sans-serif; 179 | color: black; 180 | border: 1px solid #ccc; 181 | cursor: pointer; 182 | font-size: 1em; 183 | font-family: sans-serif; 184 | } 185 | 186 | button:hover { 187 | background-color: #e9e9e9; 188 | } 189 | 190 | button[type="submit"] { 191 | background-color: #488448; 192 | color: white; 193 | border: 0; 194 | } 195 | 196 | button[type="submit"]:hover { 197 | background-color: #569d56; 198 | } 199 | 200 | .subtle { 201 | color: #999; 202 | font-size: .9em; 203 | } 204 | 205 | .stat { 206 | font-size: 1.4em; 207 | font-weight: bold; 208 | } 209 | 210 | form { 211 | display: grid; 212 | gap: 1em; 213 | grid-template-columns: max-content 1fr; 214 | grid-template-rows: auto; 215 | flex-direction: column; 216 | border-radius: .4em; 217 | align-items: center; 218 | } 219 | 220 | label { 221 | font-weight: bold; 222 | } 223 | 224 | select { 225 | padding: 1em; 226 | border-radius: .4em; 227 | border: 1px solid #ccc; 228 | font-family: sans-serif; 229 | background-color: white; 230 | } 231 | 232 | textarea { 233 | padding: 1em; 234 | border-radius: .4em; 235 | border: 1px solid #ccc; 236 | font-family: sans-serif; 237 | min-height: 6em; 238 | } 239 | 240 | textarea[readonly] { 241 | background-color: #f0f0f0; 242 | color: #666; 243 | font-style: italic; 244 | } 245 | 246 | input[type="text"], input[type="email"], input[type="password"] { 247 | padding: 1em; 248 | border-radius: .4em; 249 | border: 1px solid #ccc; 250 | font-family: sans-serif; 251 | } 252 | 253 | fieldset { 254 | border: 0; 255 | display: flex; 256 | flex-direction: row; 257 | grid-column: span 2; 258 | padding: 0; 259 | gap: 1em; 260 | font-family: sans-serif; 261 | align-items: start; 262 | } 263 | 264 | .grid { 265 | display: grid; 266 | gap: 1em; 267 | justify-content: center; 268 | } 269 | 270 | .grid-display { 271 | display: grid; 272 | } 273 | 274 | .grid-boxed { 275 | display: grid; 276 | gap: 0; 277 | background-color: #efefef; 278 | padding: 1em; 279 | border-radius: .4em; 280 | grid-template-columns: 1fr 1fr 1fr; 281 | } 282 | 283 | .gc-xl { 284 | grid-template-columns: repeat(auto-fit,minmax(500px,1fr)); 285 | } 286 | 287 | .grid-boxed div { 288 | border: 1px solid #ccc; 289 | border-right: 0; 290 | padding: 1em; 291 | background-color: #fff; 292 | } 293 | 294 | .grid-boxed div:last-child { 295 | border-right: 1px solid #ccc; 296 | } 297 | 298 | .stat-display span.subtle { 299 | display: block; 300 | } 301 | 302 | div[role="toolbar"] { 303 | display: flex; 304 | flex-direction: row; 305 | gap: 1em; 306 | align-items: center; 307 | margin-bottom: 1em; 308 | } 309 | 310 | table { 311 | width: 100%; 312 | } 313 | 314 | table, th, td { 315 | border: 0; 316 | border-bottom: 1px solid #ccc; 317 | border-collapse: collapse; 318 | } 319 | 320 | td,th { 321 | padding: .5em; 322 | } 323 | 324 | th { 325 | background-color: #EFF1F3; 326 | text-align: left; 327 | } 328 | 329 | td.uneditable { 330 | background-color: #f0f0f0; 331 | font-weight: bold; 332 | } 333 | 334 | ul.noListStyle { 335 | list-style-type: none; 336 | padding: 0; 337 | margin: 0; 338 | } 339 | 340 | ul[role=menubar] { 341 | list-style: none; 342 | padding: 0; 343 | margin: 0; 344 | } 345 | 346 | [role=menubar] li { 347 | display: inline-block; 348 | } 349 | 350 | ul[role=menubar] li div { 351 | position: absolute; 352 | display: none; 353 | box-shadow: 0 0 6px 0 #444; 354 | } 355 | 356 | ul[role=menubar] li:hover { 357 | background-color: beige; 358 | } 359 | 360 | header ul[role=menubar] li:hover { 361 | background-color: #555; 362 | } 363 | 364 | 365 | ul[role=menubar] li span { 366 | cursor: pointer; 367 | } 368 | 369 | ul[role=menubar] li:hover div { 370 | display: block; 371 | background-color: #fff; 372 | min-width: 12em; 373 | } 374 | 375 | header ul[role=menubar] li:hover ul { 376 | margin: 0; 377 | padding: 0; 378 | } 379 | 380 | ul[role=menubar] div ul { 381 | list-style: none; 382 | padding: 0; 383 | margin: 0; 384 | } 385 | 386 | ul[role=menubar] div ul li { 387 | display: block; 388 | margin-right: 0; 389 | } 390 | 391 | ul[role=menubar] div ul a { 392 | text-decoration: none; 393 | display: block; 394 | padding: .2em; 395 | } 396 | 397 | header ul[role=menubar] div li a { 398 | border-radius: 0; 399 | } 400 | 401 | ul[role=menubar] div ul a:hover { 402 | background-color: beige; 403 | } 404 | 405 | header ul[role=menubar] div ul a:hover { 406 | background-color: #555; 407 | } 408 | 409 | header ul[role=menubar] a, header ul[role=menubar] a:visited { 410 | color: white; 411 | background-color: #444; 412 | } 413 | 414 | header ul[role=menubar] a:hover { 415 | background-color: #555; 416 | } 417 | 418 | aside { 419 | position: fixed; 420 | background-color: #fff; 421 | box-shadow: 0 0 .5em #9a9a9a; 422 | transition: left .5s, visibility .5s, z-index .5s step-start; 423 | min-width: 14em; 424 | width: 14em; 425 | z-index: -1; 426 | visibility: hidden; 427 | left: -14em; 428 | height: 100vh; 429 | } 430 | 431 | aside.stuck { 432 | position: static; 433 | height: auto; /* flex element */ 434 | } 435 | 436 | aside.shown { 437 | visibility: visible; 438 | left: 0; 439 | z-index: 0; 440 | } 441 | 442 | aside ul { 443 | list-style: none; 444 | padding: 0; 445 | } 446 | 447 | aside ul li a { 448 | text-decoration: none; 449 | color: black; 450 | display: block; 451 | padding: .4em; 452 | padding: .4em 1em; 453 | } 454 | 455 | aside ul li a:hover { 456 | background-color: #c6d0d7; 457 | } 458 | 459 | footer { 460 | text-align: center; 461 | padding: .5em; 462 | } 463 | 464 | #layout { 465 | display: flex; 466 | flex-direction: row; 467 | flex-grow: 1; 468 | } 469 | 470 | #content { 471 | flex-grow: 1; 472 | display: flex; 473 | flex-direction: column; 474 | } 475 | 476 | footer span { 477 | padding: .5em 1em .5em 1em; 478 | border-radius: .5em; 479 | background-color: #c6d0d7; 480 | display: inline-block; 481 | } 482 | 483 | .a11yhidden { 484 | position: absolute; 485 | left: -500px; 486 | } 487 | 488 | .a11yhidden:focus { 489 | left: 1em; 490 | background-color: black; 491 | border: 2px solid #555; 492 | border-radius: .5em; 493 | padding: .5em; 494 | color: white; 495 | } 496 | 497 | #sidebar-button { 498 | width: 14em; 499 | cursor: pointer; 500 | border-right: 1px solid #333; 501 | background-color: #444; 502 | } 503 | 504 | #sidebar-button:hover { 505 | background-color: #666; 506 | } 507 | 508 | #sidebar-button .menu-icon { 509 | padding: .5em; 510 | } 511 | 512 | .vh { 513 | visibility: hidden; 514 | } 515 | 516 | .script-button { 517 | padding: .5em; 518 | cursor: pointer; 519 | } 520 | 521 | .fs2 { 522 | font-size: 2em; 523 | } 524 | 525 | .flex-row { 526 | display: flex; 527 | flex-direction: row; 528 | align-items: center; 529 | } 530 | 531 | .fg0 { 532 | flex-grow: 0; 533 | } 534 | 535 | .fg1 { 536 | flex-grow: 1; 537 | } 538 | 539 | .g1 { 540 | gap: 1em; 541 | } 542 | 543 | .g2 { 544 | gap: 2em; 545 | } 546 | 547 | .flex-spacer { 548 | flex-grow: 1; 549 | } 550 | 551 | @media (prefers-color-scheme: dark) { 552 | header { 553 | background-color: black; 554 | box-shadow: 0px 0px 6px 5px #121212; 555 | border-bottom: 1px solid #222; 556 | } 557 | 558 | body { 559 | background-color: #333; 560 | color: #ddd; 561 | } 562 | 563 | section { 564 | background-color: #111; 565 | box-shadow: 0 0 .5em #121212; 566 | } 567 | 568 | footer a, footer a:visited { 569 | color: #ddd; 570 | color: lightblue; 571 | } 572 | 573 | th { 574 | background-color: #333; 575 | } 576 | 577 | table, th, td { 578 | border: 1px solid #707079; 579 | } 580 | 581 | footer span { 582 | background-color: #444; 583 | } 584 | } 585 | 586 | @media (max-width: 600px) { 587 | header { 588 | gap: .5em; 589 | } 590 | 591 | header h1 { 592 | font-size: 1.2em; 593 | } 594 | 595 | header p { 596 | font-size: .8em; 597 | } 598 | 599 | header nav ul li { 600 | display: block; 601 | margin-right: 0; 602 | } 603 | 604 | main { 605 | padding: 0; 606 | } 607 | 608 | section { 609 | margin: 0; 610 | margin-top: 1em; 611 | border-radius: 0; 612 | padding: .75em; 613 | } 614 | } 615 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------