Без опису

svalavuo 97e87d1643 Editing 4 днів тому
admin e33ebef68e Debug ajax_import 4 днів тому
css 97e87d1643 Editing 4 днів тому
database_migrations f67a3c51bf Fix to translations 5 днів тому
includes 9cbeab8903 FIx to wordpress_import 4 днів тому
js 83d25c1b17 Fix resizing image 5 днів тому
languages 97e87d1643 Editing 4 днів тому
public 97e87d1643 Editing 4 днів тому
setup 097982e639 Fixes to LDAP integration 6 днів тому
.gitignore abd116fcd8 Debugging wordpress_import 4 днів тому
INSTALL.md 5b51411ce0 Finetunes 6 днів тому
README.md 3e1c379f2e Fix to LDAP search 6 днів тому
fix_slug_issue.sql 17fcaf5eba Fix to publication 6 днів тому
index.php e0e3d700be init index.php 6 днів тому
run_migration.php 17fcaf5eba Fix to publication 6 днів тому
setup.sql 54a1d750ac Add wordpress import tool 4 днів тому
test_direct_language.php abd116fcd8 Debugging wordpress_import 4 днів тому
test_language_switching_complete.php abd116fcd8 Debugging wordpress_import 4 днів тому

README.md

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

  1. Ensure the setup/ directory is accessible via web browser
  2. Navigate to: http://your-domain.com/setup/
  3. 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:

  1. Access LDAP Users: Navigate to Admin Panel > LDAP Users
  2. Search Users: Use the search interface to find directory users
  3. Import Users: Select users and import them into the system
  4. Authentication: Users can now login with their directory credentials

LDAP Authentication Flow

  1. User enters directory username and password
  2. System searches LDAP directory for the user
  3. System attempts to bind with user credentials
  4. If successful, user is authenticated and session is created
  5. User information is synchronized with local database

LDAP Troubleshooting

Common Issues

  1. Connection Failed: Check LDAP server hostname, port, and network connectivity
  2. Bind Failed: Verify bind DN and password if using service account
  3. User Not Found: Check base DN and user search filter
  4. Authentication Failed: Ensure user exists in directory and password is correct

Debug Steps

  1. Enable PHP error logging
  2. Test LDAP connection with external tools (ldapsearch, Apache Directory Studio)
  3. Check system logs for LDAP connection errors
  4. 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:

  1. Delete the setup directory for security:

    rm -rf /path/to/web-pub-system/setup/
    
  2. 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

  1. Access the admin panel at: http://your-domain.com/admin/
  2. Login with your credentials (local or LDAP)
  3. 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:

  1. Import Users: Navigate to Admin Panel > LDAP Users
  2. Search Directory: Find users by username, name, or email
  3. Bulk Import: Select multiple users and import them
  4. User Roles: Imported users get default "editor" role
  5. Login: Users authenticate with directory credentials

Creating Publications

  1. Click "Create New Publication" from the dashboard
  2. 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)
  3. 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

  1. Delete setup directory: Always remove the setup/ directory after installation
  2. Strong passwords: Use strong admin passwords
  3. File permissions: Ensure proper file permissions on sensitive files
  4. HTTPS: Use HTTPS in production for secure login
  5. Regular updates: Keep PHP and MariaDB updated
  6. 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:

  1. Adding new tables to the SQL file
  2. Updating the Publication model class
  3. 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

  1. Database Connection Error

    • Check database credentials in includes/config.php
    • Ensure database server is running
    • Verify user permissions
  2. Blank Pages

    • Check PHP error logs
    • Ensure all required PHP extensions are installed
    • Verify file permissions
  3. 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:

  1. Check this README file
  2. Review the code comments
  3. 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