403Webshell
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/3951577/root/tmp/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/3951577/root/tmp/fix_meta_titles_length.php
<?php
require '/var/www/clients/client2/web20/web/wp-load.php';
global $wpdb;

$suffix = ' | Drogentest-Online.de';
$suffix_len = mb_strlen($suffix);
$max_len = 55;
$updated = 0;
$stripped = 0;
$shortened = 0;

$rows = $wpdb->get_results("
    SELECT pm.meta_id, pm.post_id, pm.meta_value, p.post_type, p.post_name
    FROM {$wpdb->postmeta} pm
    JOIN {$wpdb->posts} p ON pm.post_id = p.ID
    WHERE pm.meta_key = '_dgt_meta_title'
    AND pm.meta_value != ''
    AND p.post_status = 'publish'
");

foreach ($rows as $r) {
    $title = $r->meta_value;
    $changed = false;

    // Strip suffix if present
    if (mb_substr($title, -$suffix_len) === $suffix) {
        $title = mb_substr($title, 0, mb_strlen($title) - $suffix_len);
        $stripped++;
        $changed = true;
    }

    // Shorten if still too long
    if (mb_strlen($title) > $max_len) {
        $short = mb_substr($title, 0, $max_len);
        $last_space = mb_strrpos($short, ' ');
        if ($last_space > 30) {
            $short = mb_substr($short, 0, $last_space);
        }
        $short = rtrim($short, ' -–,;:/&');
        $title = $short;
        $shortened++;
        $changed = true;
    }

    if ($changed) {
        $wpdb->update($wpdb->postmeta, array('meta_value' => $title), array('meta_id' => $r->meta_id));
        $updated++;
        echo "[{$r->post_type}] {$r->post_name}: " . mb_strlen($title) . " chars => {$title}\n";
    }
}

// Also fix term meta titles
$term_rows = $wpdb->get_results("
    SELECT tm.meta_id, tm.term_id, tm.meta_value, t.name, tt.taxonomy
    FROM {$wpdb->termmeta} tm
    JOIN {$wpdb->terms} t ON tm.term_id = t.term_id
    JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id
    WHERE tm.meta_key = '_dgt_meta_title'
    AND tm.meta_value != ''
");

foreach ($term_rows as $r) {
    $title = $r->meta_value;
    $changed = false;

    if (mb_substr($title, -$suffix_len) === $suffix) {
        $title = mb_substr($title, 0, mb_strlen($title) - $suffix_len);
        $stripped++;
        $changed = true;
    }

    if (mb_strlen($title) > $max_len) {
        $short = mb_substr($title, 0, $max_len);
        $last_space = mb_strrpos($short, ' ');
        if ($last_space > 30) {
            $short = mb_substr($short, 0, $last_space);
        }
        $short = rtrim($short, ' -–,;:/&');
        $title = $short;
        $shortened++;
        $changed = true;
    }

    if ($changed) {
        $wpdb->update($wpdb->termmeta, array('meta_value' => $title), array('meta_id' => $r->meta_id));
        $updated++;
        echo "[{$r->taxonomy}] {$r->name}: " . mb_strlen($title) . " chars => {$title}\n";
    }
}

echo "\nDone: $updated updated ($stripped suffix-stripped, $shortened shortened)\n";

Youez - 2016 - github.com/yon3zu
LinuXploit