|
@@ -0,0 +1,130 @@
|
|
|
|
|
+<!DOCTYPE html>
|
|
|
|
|
+<html>
|
|
|
|
|
+<head>
|
|
|
|
|
+ <title>AJAX WordPress Import Test</title>
|
|
|
|
|
+ <style>
|
|
|
|
|
+ body { font-family: Arial, sans-serif; margin: 20px; }
|
|
|
|
|
+ .container { max-width: 800px; margin: 0 auto; }
|
|
|
|
|
+ .form-group { margin-bottom: 15px; }
|
|
|
|
|
+ label { display: block; margin-bottom: 5px; font-weight: bold; }
|
|
|
|
|
+ input, button { padding: 8px; margin-bottom: 10px; }
|
|
|
|
|
+ button { background: #007cba; color: white; border: none; cursor: pointer; margin-right: 10px; }
|
|
|
|
|
+ button:hover { background: #005a87; }
|
|
|
|
|
+ .log { background: #f5f5f5; border: 1px solid #ddd; padding: 10px; margin-top: 20px; height: 300px; overflow-y: auto; font-family: monospace; font-size: 12px; }
|
|
|
|
|
+ .success { color: green; }
|
|
|
|
|
+ .error { color: red; }
|
|
|
|
|
+ .info { color: blue; }
|
|
|
|
|
+ </style>
|
|
|
|
|
+</head>
|
|
|
|
|
+<body>
|
|
|
|
|
+ <div class="container">
|
|
|
|
|
+ <h1>AJAX WordPress Import Test</h1>
|
|
|
|
|
+ <p>This bypasses form submission issues by using AJAX requests.</p>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="form-group">
|
|
|
|
|
+ <label>Host:</label>
|
|
|
|
|
+ <input type="text" id="wp_host" value="10.15.10.8">
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="form-group">
|
|
|
|
|
+ <label>Database:</label>
|
|
|
|
|
+ <input type="text" id="wp_database" value="valtsu_valtsu">
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="form-group">
|
|
|
|
|
+ <label>Username:</label>
|
|
|
|
|
+ <input type="text" id="wp_username" value="">
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="form-group">
|
|
|
|
|
+ <label>Password:</label>
|
|
|
|
|
+ <input type="password" id="wp_password" value="">
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="form-group">
|
|
|
|
|
+ <button onclick="testConnection()">Test Connection</button>
|
|
|
|
|
+ <button onclick="importCategories()">Import Categories</button>
|
|
|
|
|
+ <button onclick="importUsers()">Import Users</button>
|
|
|
|
|
+ <button onclick="importPosts()">Import Posts</button>
|
|
|
|
|
+ <button onclick="clearLog()">Clear Log</button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div id="log" class="log"></div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <script>
|
|
|
|
|
+ function log(message, type = 'info') {
|
|
|
|
|
+ const logDiv = document.getElementById('log');
|
|
|
|
|
+ const timestamp = new Date().toLocaleTimeString();
|
|
|
|
|
+ const className = type === 'error' ? 'error' : type === 'success' ? 'success' : 'info';
|
|
|
|
|
+ logDiv.innerHTML += `<div class="${className}">[${timestamp}] ${message}</div>`;
|
|
|
|
|
+ logDiv.scrollTop = logDiv.scrollHeight;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function getConfig() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ wp_host: document.getElementById('wp_host').value,
|
|
|
|
|
+ wp_database: document.getElementById('wp_database').value,
|
|
|
|
|
+ wp_username: document.getElementById('wp_username').value,
|
|
|
|
|
+ wp_password: document.getElementById('wp_password').value
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function makeRequest(action) {
|
|
|
|
|
+ const config = getConfig();
|
|
|
|
|
+ const params = new URLSearchParams({...config, action});
|
|
|
|
|
+
|
|
|
|
|
+ log(`Making request: ${action}`, 'info');
|
|
|
|
|
+
|
|
|
|
|
+ return fetch(`ajax_import_test.php?${params}`)
|
|
|
|
|
+ .then(response => response.json())
|
|
|
|
|
+ .then(data => {
|
|
|
|
|
+ if (data.success) {
|
|
|
|
|
+ log(`✓ ${data.message} (${data.step})`, 'success');
|
|
|
|
|
+ if (data.stats) {
|
|
|
|
|
+ log(`Stats: ${JSON.stringify(data.stats)}`, 'info');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (data.result) {
|
|
|
|
|
+ log(`Result: ${JSON.stringify(data.result)}`, 'info');
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log(`✗ ${data.message} (${data.step})`, 'error');
|
|
|
|
|
+ if (data.error) {
|
|
|
|
|
+ log(`Error details: ${data.error.file}:${data.error.line}`, 'error');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return data;
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(error => {
|
|
|
|
|
+ log(`Network error: ${error.message}`, 'error');
|
|
|
|
|
+ throw error;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function testConnection() {
|
|
|
|
|
+ makeRequest('test_connection');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function importCategories() {
|
|
|
|
|
+ makeRequest('import_categories');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function importUsers() {
|
|
|
|
|
+ makeRequest('import_users');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function importPosts() {
|
|
|
|
|
+ makeRequest('import_posts');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function clearLog() {
|
|
|
|
|
+ document.getElementById('log').innerHTML = '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Auto-focus username field
|
|
|
|
|
+ document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
+ document.getElementById('wp_username').focus();
|
|
|
|
|
+ });
|
|
|
|
|
+ </script>
|
|
|
|
|
+</body>
|
|
|
|
|
+</html>
|