ajax_test_interface.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>AJAX WordPress Import Test</title>
  5. <style>
  6. body { font-family: Arial, sans-serif; margin: 20px; }
  7. .container { max-width: 800px; margin: 0 auto; }
  8. .form-group { margin-bottom: 15px; }
  9. label { display: block; margin-bottom: 5px; font-weight: bold; }
  10. input, button { padding: 8px; margin-bottom: 10px; }
  11. button { background: #007cba; color: white; border: none; cursor: pointer; margin-right: 10px; }
  12. button:hover { background: #005a87; }
  13. .log { background: #f5f5f5; border: 1px solid #ddd; padding: 10px; margin-top: 20px; height: 300px; overflow-y: auto; font-family: monospace; font-size: 12px; }
  14. .success { color: green; }
  15. .error { color: red; }
  16. .info { color: blue; }
  17. </style>
  18. </head>
  19. <body>
  20. <div class="container">
  21. <h1>AJAX WordPress Import Test</h1>
  22. <p>This bypasses form submission issues by using AJAX requests.</p>
  23. <div class="form-group">
  24. <label>Host:</label>
  25. <input type="text" id="wp_host" value="10.15.10.8">
  26. </div>
  27. <div class="form-group">
  28. <label>Database:</label>
  29. <input type="text" id="wp_database" value="valtsu_valtsu">
  30. </div>
  31. <div class="form-group">
  32. <label>Username:</label>
  33. <input type="text" id="wp_username" value="">
  34. </div>
  35. <div class="form-group">
  36. <label>Password:</label>
  37. <input type="password" id="wp_password" value="">
  38. </div>
  39. <div class="form-group">
  40. <button onclick="testConnection()">Test Connection</button>
  41. <button onclick="importCategories()">Import Categories</button>
  42. <button onclick="importUsers()">Import Users</button>
  43. <button onclick="importPosts()">Import Posts</button>
  44. <button onclick="clearLog()">Clear Log</button>
  45. </div>
  46. <div id="log" class="log"></div>
  47. </div>
  48. <script>
  49. function log(message, type = 'info') {
  50. const logDiv = document.getElementById('log');
  51. const timestamp = new Date().toLocaleTimeString();
  52. const className = type === 'error' ? 'error' : type === 'success' ? 'success' : 'info';
  53. logDiv.innerHTML += `<div class="${className}">[${timestamp}] ${message}</div>`;
  54. logDiv.scrollTop = logDiv.scrollHeight;
  55. }
  56. function getConfig() {
  57. return {
  58. wp_host: document.getElementById('wp_host').value,
  59. wp_database: document.getElementById('wp_database').value,
  60. wp_username: document.getElementById('wp_username').value,
  61. wp_password: document.getElementById('wp_password').value
  62. };
  63. }
  64. function makeRequest(action) {
  65. const config = getConfig();
  66. const params = new URLSearchParams({...config, action});
  67. log(`Making request: ${action}`, 'info');
  68. return fetch(`ajax_import_test.php?${params}`)
  69. .then(response => response.json())
  70. .then(data => {
  71. if (data.success) {
  72. log(`✓ ${data.message} (${data.step})`, 'success');
  73. if (data.stats) {
  74. log(`Stats: ${JSON.stringify(data.stats)}`, 'info');
  75. }
  76. if (data.result) {
  77. log(`Result: ${JSON.stringify(data.result)}`, 'info');
  78. }
  79. } else {
  80. log(`✗ ${data.message} (${data.step})`, 'error');
  81. if (data.error) {
  82. log(`Error details: ${data.error.file}:${data.error.line}`, 'error');
  83. }
  84. }
  85. return data;
  86. })
  87. .catch(error => {
  88. log(`Network error: ${error.message}`, 'error');
  89. throw error;
  90. });
  91. }
  92. function testConnection() {
  93. makeRequest('test_connection');
  94. }
  95. function importCategories() {
  96. makeRequest('import_categories');
  97. }
  98. function importUsers() {
  99. makeRequest('import_users');
  100. }
  101. function importPosts() {
  102. makeRequest('import_posts');
  103. }
  104. function clearLog() {
  105. document.getElementById('log').innerHTML = '';
  106. }
  107. // Auto-focus username field
  108. document.addEventListener('DOMContentLoaded', function() {
  109. document.getElementById('wp_username').focus();
  110. });
  111. </script>
  112. </body>
  113. </html>