HEX
Server: nginx
System: Linux pool64-304-45.dca.atomicsites.net 5.10.0-31-amd64 #1 SMP Debian 5.10.221-1 (2024-07-14) x86_64
User: (0)
PHP: 8.4.18
Disabled: pcntl_fork
Upload Files
File: //scripts/at-wpcli-config.php
<?php

/**
 * /scripts/at-wpcli-config.php - allow using wp cli even with a broken site
 *
 * Enabled via the WP_CONFIG_PATH environment variable
 *
 * 1. attempt to parse the wp-config.php and pull out the $table_prefix
 * 2. change the location of mu-plugins to only load our mu-plugins
 * 3. set ABSPATH
 * 4. load up WordPress
 */

function _at_specific_get_table_prefix_t_variable( $filename ) {
	$found_prefix_var = false;
	foreach( token_get_all( file_get_contents( $filename ) ) as $idx => $token ) {
		if ( ! is_array( $token ) ) {
			continue;
		}
		if ( ! $found_prefix_var ) {
			if ( T_VARIABLE === $token[0] && '$table_prefix' === $token[1] ) {
				$found_prefix_var = true;
			}
			continue;
		}
		if ( T_CONSTANT_ENCAPSED_STRING === $token[0] ) {
			return $token[1];
		}
	}
}

function _at_specific_get_parsed_table_prefix( $filename ) {
	if ( null !== $table_prefix_t_var = _at_specific_get_table_prefix_t_variable( $filename ) ) {
		$parsed = parse_ini_string( sprintf( 'table_prefix=%s', $table_prefix_t_var ) );
		if ( is_array( $parsed ) && array_key_exists( 'table_prefix', $parsed ) ) {
			return $parsed['table_prefix'];
		}
	}
}

$possible_table_prefix = _at_specific_get_parsed_table_prefix( "/srv/htdocs/wp-config.php" );
if ( null !== $possible_table_prefix ) {
	$table_prefix = $possible_table_prefix;
} else {
	require '/srv/htdocs/wp-config.php';
	return;
}

define( 'WPMU_PLUGIN_DIR', '/wordpress/mu-plugins/' );

if ( !defined('ABSPATH') )
	  define('ABSPATH', '/srv/htdocs/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');