|
@@ -1,387 +0,0 @@
|
|
|
-<?php
|
|
|
|
|
-// Simplified WordPress import interface - bypass problematic components
|
|
|
|
|
-error_reporting(E_ALL);
|
|
|
|
|
-ini_set('display_errors', 0);
|
|
|
|
|
-ini_set('max_execution_time', 120);
|
|
|
|
|
-ini_set('memory_limit', '512M');
|
|
|
|
|
-
|
|
|
|
|
-// Start session for basic functionality
|
|
|
|
|
-if (session_status() === PHP_SESSION_NONE) {
|
|
|
|
|
- session_start();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-require_once '../includes/config.php';
|
|
|
|
|
-require_once '../includes/database.php';
|
|
|
|
|
-
|
|
|
|
|
-// Simple auth check - just check if user is logged in without complex auth system
|
|
|
|
|
-$isAdmin = false;
|
|
|
|
|
-if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true && isset($_SESSION['role']) && $_SESSION['role'] === 'admin') {
|
|
|
|
|
- $isAdmin = true;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// Redirect if not admin
|
|
|
|
|
-if (!$isAdmin) {
|
|
|
|
|
- header('Location: login.php');
|
|
|
|
|
- exit;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-$message = '';
|
|
|
|
|
-$importResults = null;
|
|
|
|
|
-$connectionTest = null;
|
|
|
|
|
-
|
|
|
|
|
-// Handle form submission with simplified processing
|
|
|
|
|
-if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
|
- try {
|
|
|
|
|
- // Get WordPress database configuration
|
|
|
|
|
- $wpConfig = [
|
|
|
|
|
- 'host' => trim($_POST['wp_host'] ?? ''),
|
|
|
|
|
- 'database' => trim($_POST['wp_database'] ?? ''),
|
|
|
|
|
- 'username' => trim($_POST['wp_username'] ?? ''),
|
|
|
|
|
- 'password' => $_POST['wp_password'] ?? ''
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- // Validate required fields
|
|
|
|
|
- if (empty($wpConfig['host']) || empty($wpConfig['database']) || empty($wpConfig['username'])) {
|
|
|
|
|
- throw new Exception("WordPress database configuration is required. Please provide host, database, and username.");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Direct WordPress connection test (bypass WordPressImport class)
|
|
|
|
|
- try {
|
|
|
|
|
- // Set timeout options
|
|
|
|
|
- $options = [
|
|
|
|
|
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
|
|
|
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
|
|
|
|
- PDO::ATTR_TIMEOUT => 10,
|
|
|
|
|
- PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4"
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- $dsn = "mysql:host={$wpConfig['host']};dbname={$wpConfig['database']};charset=utf8mb4";
|
|
|
|
|
- $wpDb = new PDO($dsn, $wpConfig['username'], $wpConfig['password'], $options);
|
|
|
|
|
-
|
|
|
|
|
- // Test connection
|
|
|
|
|
- $wpDb->query("SELECT 1");
|
|
|
|
|
-
|
|
|
|
|
- if (isset($_POST['test_connection'])) {
|
|
|
|
|
- // Get stats with direct queries
|
|
|
|
|
- $stats = [];
|
|
|
|
|
- try {
|
|
|
|
|
- $stats['posts'] = $wpDb->query("SELECT COUNT(*) FROM wp_posts WHERE post_type = 'post'")->fetchColumn();
|
|
|
|
|
- } catch (Exception $e) {
|
|
|
|
|
- $stats['posts'] = 0;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- $stats['categories'] = $wpDb->query("SELECT COUNT(*) FROM wp_term_taxonomy WHERE taxonomy = 'category'")->fetchColumn();
|
|
|
|
|
- } catch (Exception $e) {
|
|
|
|
|
- $stats['categories'] = 0;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- $stats['users'] = $wpDb->query("SELECT COUNT(*) FROM wp_users")->fetchColumn();
|
|
|
|
|
- } catch (Exception $e) {
|
|
|
|
|
- $stats['users'] = 0;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- $stats['comments'] = $wpDb->query("SELECT COUNT(*) FROM wp_comments")->fetchColumn();
|
|
|
|
|
- } catch (Exception $e) {
|
|
|
|
|
- $stats['comments'] = 0;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $message = "WordPress connection successful: " .
|
|
|
|
|
- "Posts: " . $stats['posts'] . ", " .
|
|
|
|
|
- "Categories: " . $stats['categories'] . ", " .
|
|
|
|
|
- "Users: " . $stats['users'] . ", " .
|
|
|
|
|
- "Comments: " . $stats['comments'];
|
|
|
|
|
- }
|
|
|
|
|
- } catch (Exception $e) {
|
|
|
|
|
- throw new Exception("WordPress connection failed: " . $e->getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (isset($_POST['start_import'])) {
|
|
|
|
|
- // For now, just show a message that import is not implemented in this simplified version
|
|
|
|
|
- throw new Exception("Import functionality is temporarily disabled. Please use the AJAX import tool for importing data.");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } catch (Exception $e) {
|
|
|
|
|
- $message = $e->getMessage();
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-?>
|
|
|
|
|
-<!DOCTYPE html>
|
|
|
|
|
-<html lang="en">
|
|
|
|
|
-<head>
|
|
|
|
|
- <meta charset="UTF-8">
|
|
|
|
|
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
- <title>WordPress Import - <?php echo SITE_TITLE; ?></title>
|
|
|
|
|
- <link rel="stylesheet" href="../css/style.css">
|
|
|
|
|
- <link rel="stylesheet" href="../css/admin-import.css">
|
|
|
|
|
-</head>
|
|
|
|
|
-<body>
|
|
|
|
|
- <div class="admin-layout">
|
|
|
|
|
- <header class="admin-header">
|
|
|
|
|
- <div class="header-content">
|
|
|
|
|
- <h1><a href="/index.php"><?php echo SITE_TITLE; ?></a></h1>
|
|
|
|
|
- <nav class="admin-nav">
|
|
|
|
|
- <a href="index.php" class="nav-link">Dashboard</a>
|
|
|
|
|
- <a href="publications.php" class="nav-link">Publications</a>
|
|
|
|
|
- <a href="categories.php" class="nav-link">Categories</a>
|
|
|
|
|
- <a href="comments.php" class="nav-link">Comments</a>
|
|
|
|
|
- <a href="users.php" class="nav-link">Users</a>
|
|
|
|
|
- <a href="wordpress_import.php" class="nav-link active">WordPress Import</a>
|
|
|
|
|
- <?php if (LDAP_ENABLED): ?>
|
|
|
|
|
- <a href="ldap-users.php" class="nav-link">LDAP Users</a>
|
|
|
|
|
- <?php endif; ?>
|
|
|
|
|
- <a href="logout.php" class="nav-link">Logout</a>
|
|
|
|
|
- </nav>
|
|
|
|
|
- <div class="user-info">
|
|
|
|
|
- Welcome, <?php echo htmlspecialchars($_SESSION['username'] ?? 'Admin'); ?>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </header>
|
|
|
|
|
-
|
|
|
|
|
- <main class="admin-main">
|
|
|
|
|
- <div class="page-header">
|
|
|
|
|
- <h2>WordPress Import</h2>
|
|
|
|
|
- <p class="page-description">Import WordPress data into your system.</p>
|
|
|
|
|
- <p class="page-description">Import posts, categories, users, and comments from a WordPress database to your publication system.</p>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <?php if ($message): ?>
|
|
|
|
|
- <div class="alert alert-<?php echo strpos($message, 'Error') === false && strpos($message, 'failed') === false ? 'success' : 'error'; ?>">
|
|
|
|
|
- <?php echo $message; ?>
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php endif; ?>
|
|
|
|
|
-
|
|
|
|
|
- <!-- Import Form -->
|
|
|
|
|
- <div class="import-form-container">
|
|
|
|
|
- <form method="post" class="import-form">
|
|
|
|
|
- <div class="form-section">
|
|
|
|
|
- <h3>WordPress Database Configuration</h3>
|
|
|
|
|
-
|
|
|
|
|
- <div class="form-row">
|
|
|
|
|
- <div class="form-group">
|
|
|
|
|
- <label for="wp_host">Database Host *</label>
|
|
|
|
|
- <input type="text" id="wp_host" name="wp_host"
|
|
|
|
|
- value="<?php echo htmlspecialchars($_POST['wp_host'] ?? 'localhost'); ?>"
|
|
|
|
|
- placeholder="localhost" required>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="form-group">
|
|
|
|
|
- <label for="wp_database">Database Name *</label>
|
|
|
|
|
- <input type="text" id="wp_database" name="wp_database"
|
|
|
|
|
- value="<?php echo htmlspecialchars($_POST['wp_database'] ?? ''); ?>"
|
|
|
|
|
- placeholder="wordpress_database" required>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="form-row">
|
|
|
|
|
- <div class="form-group">
|
|
|
|
|
- <label for="wp_username">Database Username *</label>
|
|
|
|
|
- <input type="text" id="wp_username" name="wp_username"
|
|
|
|
|
- value="<?php echo htmlspecialchars($_POST['wp_username'] ?? ''); ?>"
|
|
|
|
|
- placeholder="wp_username" required>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="form-group">
|
|
|
|
|
- <label for="wp_password">Database Password</label>
|
|
|
|
|
- <input type="password" id="wp_password" name="wp_password"
|
|
|
|
|
- value="<?php echo htmlspecialchars($_POST['wp_password'] ?? ''); ?>"
|
|
|
|
|
- placeholder="Leave empty if no password">
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="form-section">
|
|
|
|
|
- <h3>Import Options</h3>
|
|
|
|
|
-
|
|
|
|
|
- <div class="form-row">
|
|
|
|
|
- <div class="form-group">
|
|
|
|
|
- <label class="checkbox-label">
|
|
|
|
|
- <input type="checkbox" name="import_categories" checked>
|
|
|
|
|
- Import Categories
|
|
|
|
|
- </label>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="form-group">
|
|
|
|
|
- <label class="checkbox-label">
|
|
|
|
|
- <input type="checkbox" name="import_users" checked>
|
|
|
|
|
- Import Users
|
|
|
|
|
- </label>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="form-row">
|
|
|
|
|
- <div class="form-group">
|
|
|
|
|
- <label class="checkbox-label">
|
|
|
|
|
- <input type="checkbox" name="import_posts" checked>
|
|
|
|
|
- Import Posts
|
|
|
|
|
- </label>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="form-group">
|
|
|
|
|
- <label class="checkbox-label">
|
|
|
|
|
- <input type="checkbox" name="import_comments" checked>
|
|
|
|
|
- Import Comments
|
|
|
|
|
- </label>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="form-actions">
|
|
|
|
|
- <button type="submit" name="test_connection" class="btn btn-primary">
|
|
|
|
|
- Test Connection
|
|
|
|
|
- </button>
|
|
|
|
|
- <button type="submit" name="start_import" class="btn btn-success"
|
|
|
|
|
- onclick="return confirm('Are you sure you want to start the import? This will import data from WordPress into your system.')">
|
|
|
|
|
- Start Import
|
|
|
|
|
- </button>
|
|
|
|
|
- </div>
|
|
|
|
|
- </form>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <!-- Import Results -->
|
|
|
|
|
- <?php if ($importResults): ?>
|
|
|
|
|
- <div class="import-results">
|
|
|
|
|
- <h3>Import Results</h3>
|
|
|
|
|
-
|
|
|
|
|
- <?php if ($importResults['success']): ?>
|
|
|
|
|
- <div class="success-summary">
|
|
|
|
|
- <p class="success-message">WordPress import completed successfully!</p>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="results-details">
|
|
|
|
|
- <?php foreach ($importResults['results'] as $type => $result): ?>
|
|
|
|
|
- <div class="result-item">
|
|
|
|
|
- <h4><?php echo ucfirst($type); ?></h4>
|
|
|
|
|
- <div class="result-stats">
|
|
|
|
|
- <span class="stat success">
|
|
|
|
|
- Imported: <strong><?php echo $result['imported']; ?></strong>
|
|
|
|
|
- </span>
|
|
|
|
|
- <span class="stat warning">
|
|
|
|
|
- Skipped: <strong><?php echo $result['skipped']; ?></strong>
|
|
|
|
|
- </span>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php endforeach; ?>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <?php if (!empty($importResults['log'])): ?>
|
|
|
|
|
- <div class="import-log">
|
|
|
|
|
- <h4>Import Log</h4>
|
|
|
|
|
- <div class="log-container">
|
|
|
|
|
- <?php foreach ($importResults['log'] as $logEntry): ?>
|
|
|
|
|
- <div class="log-entry log-<?php echo $logEntry['level']; ?>">
|
|
|
|
|
- <span class="log-time"><?php echo $logEntry['timestamp']; ?></span>
|
|
|
|
|
- <span class="log-message"><?php echo htmlspecialchars($logEntry['message']); ?></span>
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php endforeach; ?>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php endif; ?>
|
|
|
|
|
-
|
|
|
|
|
- <?php if (!empty($importResults['errors'])): ?>
|
|
|
|
|
- <div class="import-errors">
|
|
|
|
|
- <h4>Import Errors</h4>
|
|
|
|
|
- <div class="error-list">
|
|
|
|
|
- <?php foreach ($importResults['errors'] as $error): ?>
|
|
|
|
|
- <div class="error-item">
|
|
|
|
|
- <?php echo htmlspecialchars($error); ?>
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php endforeach; ?>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php endif; ?>
|
|
|
|
|
-
|
|
|
|
|
- <?php else: ?>
|
|
|
|
|
- <div class="error-summary">
|
|
|
|
|
- <p class="error-message"><?php echo htmlspecialchars($importResults['error']); ?></p>
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php endif; ?>
|
|
|
|
|
- </div>
|
|
|
|
|
- <?php endif; ?>
|
|
|
|
|
-
|
|
|
|
|
- <!-- Information Section -->
|
|
|
|
|
- <div class="info-section">
|
|
|
|
|
- <h3>WordPress Import Information</h3>
|
|
|
|
|
- <div class="info-content">
|
|
|
|
|
- <div class="info-item">
|
|
|
|
|
- <h4>What Gets Imported</h4>
|
|
|
|
|
- <ul>
|
|
|
|
|
- <li>Posts (title, content, author, publication date)</li>
|
|
|
|
|
- <li>Categories (name and description)</li>
|
|
|
|
|
- <li>Users (username, email, display name)</li>
|
|
|
|
|
- <li>Comments (content, author, date, threading)</li>
|
|
|
|
|
- </ul>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="info-item">
|
|
|
|
|
- <h4>Requirements</h4>
|
|
|
|
|
- <ul>
|
|
|
|
|
- <li>Database access to WordPress database</li>
|
|
|
|
|
- <li>WordPress database with standard structure</li>
|
|
|
|
|
- <li>Backup of your current data (recommended)</li>
|
|
|
|
|
- </ul>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div class="info-item">
|
|
|
|
|
- <h4>Important Notes</h4>
|
|
|
|
|
- <ul>
|
|
|
|
|
- <li>Existing data with same identifiers will be skipped</li>
|
|
|
|
|
- <li>WordPress content is processed for compatibility</li>
|
|
|
|
|
- <li>WordPress users are mapped to your user system</li>
|
|
|
|
|
- </ul>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </main>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <script>
|
|
|
|
|
- // WordPress Import JavaScript
|
|
|
|
|
- document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
- const form = document.querySelector('.import-form');
|
|
|
|
|
- const testBtn = document.querySelector('button[name="test_connection"]');
|
|
|
|
|
- const importBtn = document.querySelector('button[name="start_import"]');
|
|
|
|
|
-
|
|
|
|
|
- // Show loading state
|
|
|
|
|
- function setLoading(button, loading) {
|
|
|
|
|
- if (loading) {
|
|
|
|
|
- button.disabled = true;
|
|
|
|
|
- button.dataset.originalText = button.textContent;
|
|
|
|
|
- button.textContent = button.dataset.loadingText || 'Loading...';
|
|
|
|
|
- } else {
|
|
|
|
|
- button.disabled = false;
|
|
|
|
|
- button.textContent = button.dataset.originalText;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Test connection loading
|
|
|
|
|
- testBtn.addEventListener('click', function() {
|
|
|
|
|
- setLoading(this, true);
|
|
|
|
|
- this.dataset.loadingText = 'Testing connection...';
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- // Import loading
|
|
|
|
|
- importBtn.addEventListener('click', function() {
|
|
|
|
|
- setLoading(this, true);
|
|
|
|
|
- this.dataset.loadingText = 'Importing...';
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- // Reset loading on form submit
|
|
|
|
|
- form.addEventListener('submit', function() {
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- setLoading(testBtn, false);
|
|
|
|
|
- setLoading(importBtn, false);
|
|
|
|
|
- }, 1000);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- // Auto-focus first empty field
|
|
|
|
|
- const firstEmpty = form.querySelector('input[value=""], input:not([value])');
|
|
|
|
|
- if (firstEmpty) {
|
|
|
|
|
- firstEmpty.focus();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- </script>
|
|
|
|
|
-</body>
|
|
|
|
|
-</html>
|
|
|