Includes backend API, public-v2 frontend, database migrations, Composer config, and deployment/implementation docs. Config files with credentials are excluded via .gitignore. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
292 lines
10 KiB
PHP
292 lines
10 KiB
PHP
<?php
|
|
/**
|
|
* Web-based debug tool to check CreativeX data in database
|
|
* Access via browser: http://your-domain.com/debug_creativex.php
|
|
*/
|
|
|
|
require_once 'Database.php';
|
|
|
|
// Get tracking ID from URL parameter if provided
|
|
$testTrackingId = $_GET['tracking_id'] ?? '3eHhBk';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>CreativeX Debug Tool</title>
|
|
<style>
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
background: #f5f5f5;
|
|
}
|
|
.container {
|
|
background: white;
|
|
padding: 30px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
}
|
|
h1 {
|
|
color: #333;
|
|
border-bottom: 3px solid #007bff;
|
|
padding-bottom: 10px;
|
|
}
|
|
h2 {
|
|
color: #555;
|
|
margin-top: 30px;
|
|
}
|
|
.stat-box {
|
|
background: #f8f9fa;
|
|
padding: 15px;
|
|
border-radius: 5px;
|
|
margin: 15px 0;
|
|
border-left: 4px solid #007bff;
|
|
}
|
|
.stat-label {
|
|
font-weight: bold;
|
|
color: #666;
|
|
}
|
|
.stat-value {
|
|
font-size: 24px;
|
|
color: #007bff;
|
|
font-weight: bold;
|
|
}
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
margin: 20px 0;
|
|
}
|
|
th, td {
|
|
padding: 12px;
|
|
text-align: left;
|
|
border-bottom: 1px solid #ddd;
|
|
}
|
|
th {
|
|
background: #007bff;
|
|
color: white;
|
|
font-weight: 600;
|
|
}
|
|
tr:hover {
|
|
background: #f8f9fa;
|
|
}
|
|
.success {
|
|
color: #28a745;
|
|
font-weight: bold;
|
|
}
|
|
.error {
|
|
color: #dc3545;
|
|
font-weight: bold;
|
|
}
|
|
.search-box {
|
|
margin: 20px 0;
|
|
padding: 20px;
|
|
background: #e9ecef;
|
|
border-radius: 5px;
|
|
}
|
|
.search-box input {
|
|
padding: 10px;
|
|
font-size: 16px;
|
|
border: 1px solid #ccc;
|
|
border-radius: 4px;
|
|
width: 200px;
|
|
}
|
|
.search-box button {
|
|
padding: 10px 20px;
|
|
font-size: 16px;
|
|
background: #007bff;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
margin-left: 10px;
|
|
}
|
|
.search-box button:hover {
|
|
background: #0056b3;
|
|
}
|
|
.url-link {
|
|
color: #007bff;
|
|
text-decoration: none;
|
|
word-break: break-all;
|
|
}
|
|
.url-link:hover {
|
|
text-decoration: underline;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>🔍 CreativeX Debug Tool</h1>
|
|
|
|
<?php
|
|
try {
|
|
$db = new Database();
|
|
$pdo = $db->getConnection();
|
|
|
|
// 1. Check total count
|
|
$stmt = $pdo->query("SELECT COUNT(*) as total FROM creativex_scores");
|
|
$total = $stmt->fetchColumn();
|
|
?>
|
|
|
|
<div class="stat-box">
|
|
<div class="stat-label">Total CreativeX Records</div>
|
|
<div class="stat-value"><?php echo number_format($total); ?></div>
|
|
</div>
|
|
|
|
<h2>📊 Status Breakdown</h2>
|
|
<?php
|
|
$stmt = $pdo->query("SELECT status, COUNT(*) as count FROM creativex_scores GROUP BY status ORDER BY count DESC");
|
|
$hasData = false;
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
$hasData = true;
|
|
?>
|
|
<div class="stat-box">
|
|
<strong><?php echo htmlspecialchars($row['status']); ?>:</strong>
|
|
<span style="font-size: 20px; color: #28a745;"><?php echo number_format($row['count']); ?></span> records
|
|
</div>
|
|
<?php
|
|
}
|
|
if (!$hasData) {
|
|
echo '<p class="error">No status data found</p>';
|
|
}
|
|
?>
|
|
|
|
<h2>🔎 Search by Tracking ID</h2>
|
|
<div class="search-box">
|
|
<form method="GET">
|
|
<input type="text" name="tracking_id" placeholder="Enter Tracking ID" value="<?php echo htmlspecialchars($testTrackingId); ?>" />
|
|
<button type="submit">Search</button>
|
|
</form>
|
|
</div>
|
|
|
|
<?php
|
|
// Specific tracking ID check
|
|
if ($testTrackingId) {
|
|
?>
|
|
<h2>Results for Tracking ID: <?php echo htmlspecialchars($testTrackingId); ?></h2>
|
|
<?php
|
|
$stmt = $pdo->prepare("
|
|
SELECT tracking_id, quality_score, creativex_url, creativex_id, status, extracted_at
|
|
FROM creativex_scores
|
|
WHERE tracking_id = :tracking_id
|
|
ORDER BY extracted_at DESC
|
|
");
|
|
$stmt->execute(['tracking_id' => $testTrackingId]);
|
|
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if (empty($results)) {
|
|
?>
|
|
<div class="stat-box" style="border-left-color: #dc3545;">
|
|
<p class="error">❌ No CreativeX data found for tracking ID: <?php echo htmlspecialchars($testTrackingId); ?></p>
|
|
<p>This tracking ID has no records in the creativex_scores table.</p>
|
|
</div>
|
|
<?php
|
|
} else {
|
|
?>
|
|
<div class="stat-box" style="border-left-color: #28a745;">
|
|
<p class="success">✓ Found <?php echo count($results); ?> record(s)</p>
|
|
</div>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Status</th>
|
|
<th>Score</th>
|
|
<th>URL</th>
|
|
<th>CreativeX ID</th>
|
|
<th>Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($results as $row): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($row['status']); ?></td>
|
|
<td><strong><?php echo htmlspecialchars($row['quality_score']); ?></strong></td>
|
|
<td>
|
|
<?php if ($row['creativex_url']): ?>
|
|
<a href="<?php echo htmlspecialchars($row['creativex_url']); ?>" target="_blank" class="url-link">
|
|
<?php echo htmlspecialchars($row['creativex_url']); ?>
|
|
</a>
|
|
<?php else: ?>
|
|
<em>No URL</em>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?php echo htmlspecialchars($row['creativex_id']); ?></td>
|
|
<td><?php echo htmlspecialchars($row['extracted_at']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
|
|
<h2>📋 Recent 20 CreativeX Records</h2>
|
|
<?php
|
|
$stmt = $pdo->query("
|
|
SELECT tracking_id, filename, quality_score, creativex_url, creativex_id, status, extracted_at
|
|
FROM creativex_scores
|
|
ORDER BY extracted_at DESC
|
|
LIMIT 20
|
|
");
|
|
$recentRecords = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if (empty($recentRecords)) {
|
|
echo '<p class="error">No records found in creativex_scores table</p>';
|
|
} else {
|
|
?>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Tracking ID</th>
|
|
<th>Filename</th>
|
|
<th>Status</th>
|
|
<th>Score</th>
|
|
<th>URL</th>
|
|
<th>Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($recentRecords as $row): ?>
|
|
<tr>
|
|
<td>
|
|
<a href="?tracking_id=<?php echo urlencode($row['tracking_id']); ?>" style="color: #007bff; font-weight: bold;">
|
|
<?php echo htmlspecialchars($row['tracking_id']); ?>
|
|
</a>
|
|
</td>
|
|
<td><?php echo htmlspecialchars($row['filename'] ?? '-'); ?></td>
|
|
<td><?php echo htmlspecialchars($row['status']); ?></td>
|
|
<td><strong><?php echo htmlspecialchars($row['quality_score']); ?></strong></td>
|
|
<td>
|
|
<?php if ($row['creativex_url']): ?>
|
|
<a href="<?php echo htmlspecialchars($row['creativex_url']); ?>" target="_blank" class="url-link" title="<?php echo htmlspecialchars($row['creativex_url']); ?>">
|
|
Link
|
|
</a>
|
|
<?php else: ?>
|
|
<em>-</em>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?php echo htmlspecialchars($row['extracted_at']); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
<?php
|
|
} catch (Exception $e) {
|
|
?>
|
|
<div class="stat-box" style="border-left-color: #dc3545;">
|
|
<p class="error">❌ Error: <?php echo htmlspecialchars($e->getMessage()); ?></p>
|
|
</div>
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|