Web Publication System
A simple, clean web publication system built with PHP and MariaDB. This system allows you to create, manage, and publish articles or blog posts with categories, search functionality, and a responsive admin interface.
Features
- Admin Panel: Secure login and dashboard for managing publications
- Publication Management: Create, edit, delete, and publish articles
- Categories: Organize publications with categories
- Search: Full-text search across publications
- Responsive Design: Mobile-friendly interface for both admin and public sites
- User Authentication: Secure login system with password hashing
- LDAP Integration: Optional LDAP directory authentication for enterprise environments
- User Management: Import and manage LDAP users in the system
- SEO Friendly: Clean URLs and meta information
Requirements
- PHP 7.4 or higher
- MariaDB 10.3+ or MySQL 5.7+
- Web server (Apache, Nginx, or PHP built-in server)
- PHP extensions: PDO, PDO_MySQL, mbstring
- For LDAP support: PHP LDAP extension (optional)
Installation
1. Setup Database
Create a database and user for the system:
CREATE DATABASE webpub;
CREATE USER 'webpub_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON webpub.* TO 'webpub_user'@'localhost';
FLUSH PRIVILEGES;
2. Web Server Setup
Place the files in your web root or a subdirectory. For example:
/var/www/html/web-pub-system/
3. Run Setup Script
- Ensure the
setup/ directory is accessible via web browser
- Navigate to:
http://your-domain.com/setup/
- Follow the installation wizard:
- Enter database connection details
- Set site title and admin credentials
- Optional: Configure LDAP authentication (see LDAP section below)
- Complete the installation
LDAP Authentication
The system supports optional LDAP directory authentication for enterprise environments.
LDAP Setup During Installation
When running the setup script, you can enable LDAP authentication by checking the "Enable LDAP Authentication" option. You'll need to provide:
- LDAP Server Host: Your LDAP server hostname or IP address
- LDAP Port: Usually 389 (standard) or 636 (LDAPS)
- LDAP Base DN: The base distinguished name for your directory (e.g.,
dc=example,dc=com)
- User Search Filter: Filter to find users (default:
(uid={username}))
- Bind DN/Password: Optional service account for LDAP queries
- Attribute Mapping: Email and name attributes from your directory
LDAP Configuration Examples
Active Directory
LDAP Server Host: ldap://ad.example.com
LDAP Port: 389
LDAP Base DN: dc=example,dc=com
User Search Filter: (sAMAccountName={username})
Email Attribute: mail
Name Attribute: cn
OpenLDAP
LDAP Server Host: ldap://ldap.example.com
LDAP Port: 389
LDAP Base DN: ou=users,dc=example,dc=com
User Search Filter: (uid={username})
Email Attribute: mail
Name Attribute: cn
LDAP User Management
After enabling LDAP authentication:
- Access LDAP Users: Navigate to Admin Panel > LDAP Users
- Search Users: Use the search interface to find directory users
- Import Users: Select users and import them into the system
- Authentication: Users can now login with their directory credentials
LDAP Authentication Flow
- User enters directory username and password
- System searches LDAP directory for the user
- System attempts to bind with user credentials
- If successful, user is authenticated and session is created
- User information is synchronized with local database
LDAP Troubleshooting
Common Issues
- Connection Failed: Check LDAP server hostname, port, and network connectivity
- Bind Failed: Verify bind DN and password if using service account
- User Not Found: Check base DN and user search filter
- Authentication Failed: Ensure user exists in directory and password is correct
Debug Steps
- Enable PHP error logging
- Test LDAP connection with external tools (ldapsearch, Apache Directory Studio)
- Check system logs for LDAP connection errors
- Verify LDAP server accessibility from web server
Security Considerations
- Use LDAPS (port 636) for secure connections in production
- Store bind passwords securely in configuration
- Limit LDAP service account permissions
- Monitor LDAP authentication logs
- Regularly review imported user accounts
4. Secure Installation
After successful installation:
Delete the setup directory for security:
rm -rf /path/to/web-pub-system/setup/
Set proper file permissions:
chmod 755 /path/to/web-pub-system/
chmod 644 /path/to/web-pub-system/includes/config.php
Directory Structure
website/
|-- admin/ # Admin interface files
| |-- index.php # Dashboard
| |-- login.php # Login page (supports LDAP)
| |-- edit.php # Create/edit publications
| |-- logout.php # Logout handler
| |-- publications.php # Publication management
| |-- categories.php # Category management
| |-- ldap-users.php # LDAP user management
|-- public/ # Public-facing pages
| |-- index.php # Homepage with publication list
| |-- publication.php # Individual publication view
| |-- search.php # Search results
| |-- categories.php # Category listings
|-- includes/ # Core PHP classes
| |-- config.php # Configuration (created during setup)
| |-- database.php # Database connection class
| |-- auth.php # Authentication class (supports LDAP)
| |-- ldap.php # LDAP authentication class
| |-- publication.php # Publication model class
|-- css/ # Stylesheets
| |-- style.css # Main stylesheet (includes LDAP styles)
|-- setup/ # Installation files (delete after use)
| |-- setup.php # Setup wizard (includes LDAP config)
| |-- database.sql # Database schema (supports LDAP)
|-- README.md # This file
Usage
Admin Panel
- Access the admin panel at:
http://your-domain.com/admin/
- Login with your credentials (local or LDAP)
- From the dashboard you can:
- Create new publications
- Edit existing publications
- Manage categories
- View statistics
- If LDAP enabled: Manage LDAP users (import, search, sync)
LDAP User Management
If LDAP authentication is enabled:
- Import Users: Navigate to Admin Panel > LDAP Users
- Search Directory: Find users by username, name, or email
- Bulk Import: Select multiple users and import them
- User Roles: Imported users get default "editor" role
- Login: Users authenticate with directory credentials
Creating Publications
- Click "Create New Publication" from the dashboard
- Fill in the publication details:
- Title (required)
- Summary (optional, for preview)
- Content (required)
- Author (defaults to logged-in user)
- Status (Draft, Published, or Archived)
- Categories (optional)
- Save the publication
Public Site
The public site is available at: http://your-domain.com/public/
Features:
- Browse all published publications
- Filter by categories
- Search publications
- View individual publications
- Responsive design for mobile devices
Configuration
The main configuration is stored in includes/config.php and is created during setup. Key settings include:
// Database configuration
define('DB_HOST', 'localhost');
define('DB_NAME', 'webpub');
define('DB_USER', 'your_db_user');
define('DB_PASS', 'your_db_password');
// Site configuration
define('SITE_TITLE', 'Web Publication System');
define('SITE_URL', 'http://your-domain.com/');
define('ADMIN_EMAIL', 'admin@example.com');
// LDAP configuration (if enabled)
define('LDAP_ENABLED', true);
define('LDAP_HOST', 'ldap.example.com');
define('LDAP_PORT', '389');
define('LDAP_BASE_DN', 'dc=example,dc=com');
define('LDAP_USER_FILTER', '(uid={username})');
define('LDAP_BIND_DN', 'cn=admin,dc=example,dc=com');
define('LDAP_BIND_PASSWORD', 'bind_password');
define('LDAP_EMAIL_ATTRIBUTE', 'mail');
define('LDAP_NAME_ATTRIBUTE', 'cn');
Security Considerations
- Delete setup directory: Always remove the
setup/ directory after installation
- Strong passwords: Use strong admin passwords
- File permissions: Ensure proper file permissions on sensitive files
- HTTPS: Use HTTPS in production for secure login
- Regular updates: Keep PHP and MariaDB updated
- LDAP Security:
- Use LDAPS for secure LDAP connections
- Limit LDAP service account permissions
- Securely store LDAP bind credentials
- Monitor LDAP authentication logs
Customization
Styling
Edit css/style.css to customize the appearance. The CSS is organized with clear sections for:
- Base styles and typography
- Admin interface styles
- Public site styles
- Responsive design breakpoints
Database Schema
The database schema is defined in setup/database.sql. You can extend it by:
- Adding new tables to the SQL file
- Updating the Publication model class
- Modifying forms and templates as needed
Adding Features
The system is built with an object-oriented approach, making it easy to extend:
- New Models: Create new model classes in the
includes/ directory
- Admin Pages: Add new admin pages in the
admin/ directory
- Public Pages: Add new public pages in the
public/ directory
Troubleshooting
Common Issues
Database Connection Error
- Check database credentials in
includes/config.php
- Ensure database server is running
- Verify user permissions
Blank Pages
- Check PHP error logs
- Ensure all required PHP extensions are installed
- Verify file permissions
Login Issues
- Clear browser cookies and session
- Check if sessions are properly configured
- Verify password was correctly hashed
Error Logging
Enable PHP error logging for debugging:
// Add to top of index.php or config.php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
License
This project is open source and available under the MIT License.
Support
For issues and questions:
- Check this README file
- Review the code comments
- Test with the sample data provided during setup
Version History
- v1.0.0: Initial release with basic publication management
- Admin interface with authentication
- Publication CRUD operations
- Category system
- Search functionality
- Responsive design
- Setup wizard