File: /var/www/html/wp-content/uploads/codex-homepage-src/codex_apply_homepage.php
<?php
$key = isset( $_GET['key'] ) ? (string) $_GET['key'] : '';
if ( 'codex-homepage-20260324' !== $key ) {
http_response_code( 403 );
echo 'forbidden';
exit;
}
$source_dir = __DIR__;
$root_dir = __DIR__;
while ( $root_dir !== dirname( $root_dir ) ) {
if ( file_exists( $root_dir . '/wp-load.php' ) ) {
require_once $root_dir . '/wp-load.php';
break;
}
$root_dir = dirname( $root_dir );
}
$theme_dir = function_exists( 'get_template_directory' ) ? get_template_directory() : dirname( __DIR__, 2 ) . '/themes/thegem-elementor';
$files = array(
'ethnic-home-hero.php' => $theme_dir . '/inc/ethnic-home-hero.php',
'ethnic-home-hero.css' => $theme_dir . '/css/ethnic-home-hero.css',
'ethnic-home-hero.js' => $theme_dir . '/js/ethnic-home-hero.js',
);
$result = array();
foreach ( $files as $source_name => $target_path ) {
$source_path = $source_dir . '/' . $source_name;
if ( ! file_exists( $source_path ) ) {
http_response_code( 500 );
echo 'missing source: ' . $source_name;
exit;
}
$bytes = file_put_contents( $target_path, file_get_contents( $source_path ), LOCK_EX );
if ( false === $bytes ) {
http_response_code( 500 );
echo 'failed writing: ' . $target_path;
exit;
}
$result[] = basename( $target_path ) . ':' . $bytes;
}
header( 'Content-Type: text/plain; charset=utf-8' );
echo implode( "\n", $result );