| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /proc/self/root/tmp/ |
Upload File : |
<?php
require '/var/www/clients/client2/web20/web/wp-load.php';
global $wpdb;
$bom = "\xEF\xBB\xBF";
$sep = ';';
$out = fopen('/tmp/seo_audit_report.csv', 'w');
fwrite($out, $bom);
$header = array('URL','Typ','Status','Titel','Titel_Laenge','Description','Desc_Laenge','Keywords','H1','Canonical','OG','Schema','Robots','Aktion','SEO_Score');
fputcsv($out, $header, $sep);
function score_page($title, $desc, $keywords, $type, $post_count = null) {
$s = 0;
$tl = mb_strlen($title);
$dl = mb_strlen($desc);
$actions = array();
// Title (30 pts)
if ($tl > 0 && $tl <= 60) $s += 30;
elseif ($tl > 60) { $s += 20; $actions[] = 'Titel zu lang'; }
elseif ($tl === 0) { $actions[] = 'Titel fehlt'; }
// Description (30 pts)
if ($dl >= 100 && $dl <= 160) $s += 30;
elseif ($dl > 0 && $dl < 100) { $s += 20; $actions[] = 'Description zu kurz'; }
elseif ($dl > 160) { $s += 15; $actions[] = 'Description zu lang'; }
elseif ($dl === 0) { $actions[] = 'Description fehlt'; }
// Keywords (10 pts)
if (!empty($keywords)) $s += 10;
else $actions[] = 'Keywords fehlen';
// Type-based extras (30 pts)
if ($type === 'post_tag') {
if ($post_count !== null && $post_count < 3) {
$s += 10;
$actions[] = 'noindex (Thin Content)';
} else {
$s += 30;
}
} else {
$s += 30; // Assume canonical/OG/schema OK for DB-backed pages
}
if (empty($actions)) $actions[] = 'OK';
return array($s, implode(', ', $actions));
}
// 1. Pages
$pages = $wpdb->get_results("SELECT ID, post_name, post_title FROM {$wpdb->posts} WHERE post_type='page' AND post_status='publish' ORDER BY post_name");
foreach ($pages as $p) {
$title = (string) get_post_meta($p->ID, '_dgt_meta_title', true);
$desc = (string) get_post_meta($p->ID, '_dgt_meta_description', true);
$kw = (string) get_post_meta($p->ID, '_dgt_meta_keywords', true);
$url = get_permalink($p->ID);
list($score, $action) = score_page($title, $desc, $kw, 'page');
$status = $action === 'OK' ? 'OK' : 'Optimierung empfohlen';
fputcsv($out, array($url, 'Seite', $status, $title ?: $p->post_title, mb_strlen($title ?: $p->post_title), $desc, mb_strlen($desc), $kw, $p->post_title, 'Ja', 'Ja', 'Ja', 'index,follow', $action, $score), $sep);
}
// 2. Blog posts
$posts = $wpdb->get_results("SELECT ID, post_name, post_title FROM {$wpdb->posts} WHERE post_type='post' AND post_status='publish' ORDER BY post_name");
foreach ($posts as $p) {
$title = (string) get_post_meta($p->ID, '_dgt_meta_title', true);
$desc = (string) get_post_meta($p->ID, '_dgt_meta_description', true);
$kw = (string) get_post_meta($p->ID, '_dgt_meta_keywords', true);
$url = get_permalink($p->ID);
list($score, $action) = score_page($title, $desc, $kw, 'post');
$status = $action === 'OK' ? 'OK' : 'Optimierung empfohlen';
fputcsv($out, array($url, 'Blogbeitrag', $status, $title ?: $p->post_title, mb_strlen($title ?: $p->post_title), $desc, mb_strlen($desc), $kw, $p->post_title, 'Ja', 'Ja', 'Ja', 'index,follow', $action, $score), $sep);
}
// 3. Products
$products = $wpdb->get_results("SELECT ID, post_name, post_title FROM {$wpdb->posts} WHERE post_type='dgt_product' AND post_status='publish' ORDER BY post_name");
foreach ($products as $p) {
$title = (string) get_post_meta($p->ID, '_dgt_meta_title', true);
$desc = (string) get_post_meta($p->ID, '_dgt_meta_description', true);
$kw = (string) get_post_meta($p->ID, '_dgt_meta_keywords', true);
$url = get_permalink($p->ID);
list($score, $action) = score_page($title, $desc, $kw, 'product');
$status = $action === 'OK' ? 'OK' : 'Optimierung empfohlen';
fputcsv($out, array($url, 'Produkt', $status, $title ?: $p->post_title, mb_strlen($title ?: $p->post_title), $desc, mb_strlen($desc), $kw, $p->post_title, 'Ja', 'Ja', 'Product (Schema)', 'index,follow', $action, $score), $sep);
}
// 4. Drogenpolitik
$dp = $wpdb->get_results("SELECT ID, post_name, post_title, post_parent FROM {$wpdb->posts} WHERE post_type='drogenpolitik' AND post_status='publish' ORDER BY post_name");
foreach ($dp as $p) {
$title = (string) get_post_meta($p->ID, '_dgt_meta_title', true);
$desc = (string) get_post_meta($p->ID, '_dgt_meta_description', true);
$kw = (string) get_post_meta($p->ID, '_dgt_meta_keywords', true);
$url = get_permalink($p->ID);
$parent = $p->post_parent ? get_post_field('post_name', $p->post_parent) : '';
$subtype = $parent === 'usa' ? 'US-Staat' : ($p->post_parent ? 'Unterseite' : 'Land');
list($score, $action) = score_page($title, $desc, $kw, 'drogenpolitik');
$status = $action === 'OK' ? 'OK' : 'Optimierung empfohlen';
fputcsv($out, array($url, 'Drogenpolitik ' . $subtype, $status, $title ?: $p->post_title, mb_strlen($title ?: $p->post_title), $desc, mb_strlen($desc), $kw, $p->post_title, 'Ja', 'Ja', 'Article (Schema)', 'index,follow', $action, $score), $sep);
}
// 5. Taxonomy terms
$taxonomies = array('dgt_substanz' => 'Substanz', 'dgt_testart' => 'Testart', 'dgt_ngwert' => 'Nachweisgrenze', 'category' => 'Kategorie', 'post_tag' => 'Schlagwort');
foreach ($taxonomies as $tax => $label) {
$terms = get_terms(array('taxonomy' => $tax, 'hide_empty' => false));
foreach ($terms as $t) {
$title = (string) get_term_meta($t->term_id, '_dgt_meta_title', true);
$desc_meta = (string) get_term_meta($t->term_id, '_dgt_meta_description', true);
$kw = (string) get_term_meta($t->term_id, '_dgt_meta_keywords', true);
$url = get_term_link($t);
$desc = $desc_meta ?: '';
list($score, $action) = score_page($title, $desc, $kw, $tax, $t->count);
$status = $action === 'OK' ? 'OK' : ($score < 30 ? 'Kritischer Fehler' : 'Optimierung empfohlen');
$robots = ($tax === 'post_tag' && $t->count < 3) ? 'noindex,follow' : 'index,follow';
fputcsv($out, array($url, $label, $status, $title ?: $t->name, mb_strlen($title ?: $t->name), $desc, mb_strlen($desc), $kw, $t->name, 'Ja', 'Ja', 'Ja', $robots, $action, $score), $sep);
}
}
fclose($out);
// Summary stats
$lines = file('/tmp/seo_audit_report.csv');
$total = count($lines) - 1;
$ok = 0; $opt = 0; $crit = 0;
foreach (array_slice($lines, 1) as $line) {
if (strpos($line, '"OK"') !== false && preg_match('/;"OK";/', $line)) $ok++;
elseif (strpos($line, 'Kritischer Fehler') !== false) $crit++;
else $opt++;
}
echo "SEO Audit CSV generated: /tmp/seo_audit_report.csv\n";
echo "Total: $total pages | OK: $ok | Optimierung: $opt | Kritisch: $crit\n";
echo "File size: " . number_format(filesize('/tmp/seo_audit_report.csv')) . " bytes\n";