evgip/w3a

A custom modular PHP MVC forum matching the HMVC pattern.

Maintainers

Package info

github.com/evgip/w3a

Type:project

pkg:composer/evgip/w3a

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 0

v0.2.1-alpha 2026-06-21 13:17 UTC

This package is auto-updated.

Last update: 2026-06-25 01:45:34 UTC


README

πŸ‡·πŸ‡Ί Русский | πŸ‡¬πŸ‡§ English

A modern, lightweight news aggregator built with PHP 8.1+ and MySQL, inspired by Hacker News and Lobste.rs. Features a modular HMVC architecture, a custom DI container, an event-driven system, real-time updates, and comprehensive moderation tools.

W3A home

W3A admin

W3A setting

πŸš€ Features

Core Functionality

  • News Stories β€” Submit stories with a URL or plain text
  • Threaded Comments β€” Nested, infinitely replyable comment trees
  • Voting System β€” Upvote / downvote stories and comments; downvotes require minimum karma
  • User Authentication β€” Registration, login, "Remember me", email activation, password recovery
  • User Profiles β€” Bio, avatar, activity feed, submitted stories, comment history
  • Private Messages β€” One-to-one conversations between users
  • Notifications β€” In-app notifications for replies, comments on followed stories, moderator actions

Ranking & Discovery

  • Hotness Algorithm β€” Custom ranking formula combining vote score, age, and per-tag weight modifiers
  • Wilson Score Interval β€” Statistically sound confidence ranking for comments
  • Tag System β€” Stories can be tagged; tags belong to categories
  • Tag Filters β€” Users can hide stories by tags they don't want to see
  • Full-text Search β€” Search across stories and comments
  • Read Ribbons β€” Track which comments you've already read; highlights new ones

Moderation & Trust

  • Invitation System β€” Toggle open registration on/off; only users with enough karma can send invites
  • Flag / Report System β€” Users can flag content (spam, offensive, duplicate, etc.); auto-hides at threshold
  • Domain Management β€” Ban entire domains; stories from banned domains are auto-rejected
  • User Bans β€” Temporary or permanent bans with reason, issued by moderators
  • IP Bans β€” Block abusive IP addresses
  • Moderator Notes β€” Private notes attached to user accounts, visible only to staff
  • Moderator Activity Log β€” Daily statistics of moderation actions
  • Audit Log β€” Full trail of every administrative action

Architecture & DX

  • DI Container β€” Lightweight service container for dependency injection
  • Event Dispatcher β€” Observer pattern: StoryCreated, CommentCreated, UserBanned, FlagResolved, etc.
  • Middleware Pipeline β€” HTTP middleware for auth, CSRF, rate-limiting, security headers
  • Modular HMVC β€” Each feature is a self-contained module (Controllers / Models / Views / routes)
  • Service Providers β€” Per-module service registration

Security

  • Password Hashing β€” bcrypt with automatic salt
  • CSRF Protection β€” Token validation on every state-changing form
  • SQL Injection Prevention β€” PDO prepared statements everywhere
  • XSS Protection β€” Output escaping via htmlspecialchars()
  • Rate Limiting β€” Configurable per-action, per-IP limits
  • Session Security β€” HTTP-only cookies, session regeneration
  • Input Validation β€” Server-side validation on every endpoint
  • Security Headers β€” Strict-Transport-Security, X-Frame-Options, etc.
  • CAPTCHA β€” Built-in CAPTCHA for sensitive actions
  • Firewall β€” Request filtering and IP reputation checks

User Experience

  • Responsive Design β€” Mobile-friendly layout
  • Dark Mode β€” System-aware theme switching
  • Keyboard Shortcuts β€” Power-user navigation
  • Markdown Support β€” Rich text formatting in comments and stories (via Parsedown)
  • User Settings β€” Granular notification preferences (email, in-app, per-event)

πŸ› οΈ Technology Stack

Component Technology
Backend PHP 8.1+ (no framework, custom HMVC + DI)
Database MySQL 8.0+ with PDO
Frontend Vanilla JavaScript, CSS3
Architecture Modular HMVC, Event Dispatcher, Service Provider
Mail PHPMailer 7.x
Markdown Parsedown 1.8+
Security CSRF tokens, rate limiting, bcrypt, CAPTCHA
Server Apache / Nginx with URL rewriting

πŸ“¦ Installation

Install via Composer:

composer create-project evgip/w3a

Requirements

  • PHP 8.1 or higher
  • MySQL 8.0 or higher
  • Apache / Nginx with URL rewriting enabled
  • Composer (optional, for development)

Step 1 β€” Clone the Repository

git clone https://github.com/evgip/w3a.git
cd w3a

Step 2 β€” Creating a database

  1. Create a MySQL database:
CREATE DATABASE w3a CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  1. Import the schema:
mysql -u your_username -p w3a < db/schema.sql

Step 3 β€” Configure the Application

Rename the .env.example file to .env and fill it in.

Step 4 β€” Set Permissions

chmod -R 755 storage/
chmod -R 755 public/

Step 5 β€” Configure the Web Server

Apache (.htaccess is included):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

Nginx:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Step 6 β€” Default Accounts

Role Email Password
Admin admin@example.com password
User test@test.ru password

⚠️ Change these credentials immediately after the first login.

πŸ“ Project Structure

w3a/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ Config/
β”‚   β”‚   └── config.php              # Application settings
β”‚   β”œβ”€β”€ Core/
β”‚   β”‚   β”œβ”€β”€ Container.php           # DI container
β”‚   β”‚   β”œβ”€β”€ Router.php              # URL routing
β”‚   β”‚   β”œβ”€β”€ Controller.php          # Base controller
β”‚   β”‚   β”œβ”€β”€ Model.php               # Base model
β”‚   β”‚   β”œβ”€β”€ Database.php            # PDO wrapper
β”‚   β”‚   β”œβ”€β”€ Session.php             # Session management
β”‚   β”‚   β”œβ”€β”€ Request.php             # HTTP request handling
β”‚   β”‚   β”œβ”€β”€ Security.php            # Security headers
β”‚   β”‚   β”œβ”€β”€ View.php                # Template rendering
β”‚   β”‚   β”œβ”€β”€ Validator.php           # Input validation
β”‚   β”‚   β”œβ”€β”€ Audit.php               # Audit logging
β”‚   β”‚   β”œβ”€β”€ RateLimiter.php         # Rate limiting
β”‚   β”‚   β”œβ”€β”€ Firewall.php            # Request firewall
β”‚   β”‚   β”œβ”€β”€ Logger.php              # Application logger
β”‚   β”‚   β”œβ”€β”€ Benchmark.php           # Performance benchmarking
β”‚   β”‚   β”œβ”€β”€ SvgChart.php            # SVG chart generator
β”‚   β”‚   β”œβ”€β”€ ModuleServiceProvider.php
β”‚   β”‚   β”œβ”€β”€ Events/                 # Event system
β”‚   β”‚   β”‚   β”œβ”€β”€ Event.php
β”‚   β”‚   β”‚   β”œβ”€β”€ EventDispatcher.php
β”‚   β”‚   β”‚   β”œβ”€β”€ StoryCreated.php
β”‚   β”‚   β”‚   β”œβ”€β”€ StoryDeleted.php
β”‚   β”‚   β”‚   β”œβ”€β”€ CommentCreated.php
β”‚   β”‚   β”‚   β”œβ”€β”€ CommentDeleted.php
β”‚   β”‚   β”‚   β”œβ”€β”€ UserBanned.php
β”‚   β”‚   β”‚   β”œβ”€β”€ FlagResolved.php
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   └── Middleware/             # HTTP middleware
β”‚   β”‚
β”‚   β”œβ”€β”€ Providers/
β”‚   β”‚   └── EventServiceProvider.php
β”‚   β”‚
β”‚   β”œβ”€β”€ Lang/                       # Localization files
β”‚   β”‚
β”‚   β”œβ”€β”€ Modules/                    # Feature modules (HMVC)
β”‚   β”‚   β”œβ”€β”€ Admin/                  # Administration panel
β”‚   β”‚   β”œβ”€β”€ Stories/                # News stories
β”‚   β”‚   β”œβ”€β”€ Auth/               	# Auth
β”‚   β”‚   β”œβ”€β”€ Captcha/               	# Captcha/
β”‚   β”‚   β”œβ”€β”€ Content/               	# Markdown
β”‚   β”‚   β”œβ”€β”€ Mail/               	# Mail
β”‚   β”‚   β”œβ”€β”€ Comments/               # Comments
β”‚   β”‚   β”œβ”€β”€ Votes/                  # Voting system
β”‚   β”‚   β”œβ”€β”€ Tags/                   # Tags & categories
β”‚   β”‚   β”œβ”€β”€ Users/                  # User profiles & settings
β”‚   β”‚   β”œβ”€β”€ Messages/               # Private messages
β”‚   β”‚   β”œβ”€β”€ Notifications/          # User notifications
β”‚   β”‚   β”œβ”€β”€ Flags/                  # Content reporting
β”‚   β”‚   β”œβ”€β”€ Invitations/            # Invitation system
β”‚   β”‚   β”œβ”€β”€ Origins/                # Domain management
β”‚   β”‚   β”œβ”€β”€ Moderations/            # Moderation tools
β”‚   β”‚   β”œβ”€β”€ Search/                 # Full-text search
β”‚   β”‚   β”œβ”€β”€ Pages/                  # Static pages
β”‚   β”‚   β”œβ”€β”€ Errors/                 # Error handling
β”‚   β”‚   └── Common/                 # Shared views & components
β”‚   β”‚
β”‚   └── helpers.php                 # Global helper functions
β”‚
β”œβ”€β”€ public/                         # Web root
β”‚   β”œβ”€β”€ index.php                   # Entry point
β”‚   β”œβ”€β”€ css/
β”‚   β”œβ”€β”€ js/
β”‚   └── images/
β”‚
β”œβ”€β”€ storage/                        # Writable storage
β”‚   β”œβ”€β”€ logs/                       # Application logs
β”‚   └── cache/                      # Cache files
β”‚
β”œβ”€β”€ db/
β”‚   └── schema.sql                  # Database schema
β”‚
β”œβ”€β”€ composer.json
└── README.md

πŸ“Š Database Schema

Content

Table Description
stories News stories (URL or text), with hotness score
comments Threaded comments with confidence score
votes Polymorphic upvotes / downvotes
tags Tag definitions with hotness modifier
taggings Many-to-many link between stories and tags
categories Tag categories
tag_filters Per-user tag exclusions

Users & Auth

Table Description
users User accounts (role: user / moderator / admin)
user_profiles Bio, avatar
user_settings Notification preferences
user_bans Temporary / permanent bans
banned_ips IP-based blocks
password_resets Password recovery tokens
email_activations Email verification tokens
invitations Invitation codes
invitation_requests Public invite requests

Social

Table Description
conversations Private message threads
messages Individual messages
user_notifications In-app notifications
read_ribbons Tracks last-read comment per story

Moderation

Table Description
flags Content reports (spam, offensive, etc.)
domains Banned / allowed domains
mod_notes Private moderator notes on users
mod_activity Daily moderation action counts
audit_logs Full administrative audit trail

Infrastructure

Table Description
sessions Active user sessions
rate_limits Rate-limiting counters

See db/schema.sql for the complete schema with indexes and foreign keys.

🀝 Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License β€” see the LICENSE file for details.

πŸ™ Acknowledgments

  • Inspired by the functionality and design of Hacker News and Lobste.rs
  • Speed and simplicity of the HLEB framework philosophy
  • Built with vanilla PHP β€” no heavy frameworks
  • Modular HMVC architecture with DI and events

πŸ“§ Contact

⭐ If you find this project useful, please consider giving it a star on GitHub!