138 lines
6.8 KiB
PHP
138 lines
6.8 KiB
PHP
<?php
|
|
$page_title = "SEO Checker";
|
|
$page_description = "Paste your HTML and get instant feedback on your on-page SEO.";
|
|
$html_input = '';
|
|
$seo_results = null;
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['html_content'])) {
|
|
$html_input = $_POST['html_content'];
|
|
// Basic analysis simulation
|
|
if (!empty($html_input)) {
|
|
$doc = new DOMDocument();
|
|
@$doc->loadHTML($html_input);
|
|
$title = $doc->getElementsByTagName('title')->item(0)->nodeValue ?? 'Not found';
|
|
$description = 'Not found';
|
|
$metas = $doc->getElementsByTagName('meta');
|
|
for ($i = 0; $i < $metas->length; $i++) {
|
|
$meta = $metas->item($i);
|
|
if (strtolower($meta->getAttribute('name')) == 'description') {
|
|
$description = $meta->getAttribute('content');
|
|
break;
|
|
}
|
|
}
|
|
$h1_count = $doc->getElementsByTagName('h1')->length;
|
|
|
|
$seo_results = [
|
|
'score' => 75, // Dummy score
|
|
'title' => $title,
|
|
'description' => $description,
|
|
'h1_count' => $h1_count,
|
|
'advice' => 'This is a basic analysis. For a full report, our AI would check for keyword density, image alt tags, mobile-friendliness, and more!'
|
|
];
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo $page_title; ?> - Flatlogic LAMP Demo</title>
|
|
<meta name="description" content="<?php echo $page_description; ?>">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body class="d-flex flex-column min-vh-100">
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="/">
|
|
<i class="bi bi-box-seam"></i>
|
|
Flatlogic<span style="color: #6366F1;">Vibes</span>
|
|
</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="vibe.php">Vibe Generator</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="sandbox.php">PHP Sandbox</a></li>
|
|
<li class="nav-item"><a class="nav-link active" aria-current="page" href="seo.php">SEO Checker</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="admin.php">Admin</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container my-5">
|
|
<div class="row">
|
|
<div class="col-lg-8 mx-auto">
|
|
<div class="text-center mb-5">
|
|
<h1 class="display-5 fw-bold">SEO Checker</h1>
|
|
<p class="lead">Paste your site's HTML below to get an instant (simulated) SEO analysis.</p>
|
|
</div>
|
|
|
|
<div class="card p-4 shadow-sm">
|
|
<form action="seo.php" method="POST">
|
|
<div class="mb-3">
|
|
<label for="html_content" class="form-label">HTML Content</label>
|
|
<textarea class="form-control" id="html_content" name="html_content" rows="10" placeholder="<html>...</html>"><?php echo htmlspecialchars($html_input); ?></textarea>
|
|
</div>
|
|
<div class="text-center">
|
|
<button type="submit" class="btn btn-primary btn-lg">
|
|
<i class="bi bi-search"></i> Analyze SEO
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<?php if ($seo_results): ?>
|
|
<div class="card p-4 mt-5 shadow-sm">
|
|
<h2 class="h3 mb-4 text-center">Analysis Results</h2>
|
|
<div class="row">
|
|
<div class="col-md-4 text-center">
|
|
<div class="display-1 fw-bold text-primary"><?php echo $seo_results['score']; ?></div>
|
|
<div class="h5">Overall Score</div>
|
|
</div>
|
|
<div class="col-md-8">
|
|
<ul class="list-group list-group-flush">
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<strong>Title Tag:</strong>
|
|
<span class="badge bg-light text-dark"><?php echo htmlspecialchars(substr($seo_results['title'], 0, 50)); ?>...</span>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<strong>Meta Description:</strong>
|
|
<span class="badge bg-light text-dark"><?php echo htmlspecialchars(substr($seo_results['description'], 0, 50)); ?>...</span>
|
|
</li>
|
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
|
<strong>H1 Tags Found:</strong>
|
|
<span class="badge bg-<?php echo $seo_results['h1_count'] === 1 ? 'success' : 'warning'; ?>"><?php echo $seo_results['h1_count']; ?></span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<hr>
|
|
<div class="mt-3">
|
|
<h4 class="h5">AI-Powered Advice:</h4>
|
|
<p class="mb-0 fst-italic"><?php echo htmlspecialchars($seo_results['advice']); ?></p>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="py-4 mt-auto bg-light">
|
|
<div class="container text-center">
|
|
<p class="mb-0 text-muted">© <?php echo date("Y"); ?> Flatlogic. All rights reserved.</p>
|
|
</div>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
</body>
|
|
</html>
|