Skip to content

Instantly share code, notes, and snippets.

@derpixler
Last active August 29, 2015 14:28
Show Gist options
  • Save derpixler/a25cde17663b542e133a to your computer and use it in GitHub Desktop.
Save derpixler/a25cde17663b542e133a to your computer and use it in GitHub Desktop.
WordPress.com Network Filter
<?php
/* Load project specific wp-conifg.php
*
* This file is located at /share/wp-config.php and is used as Symlink under /usr/share/wordpress/
*/
$_DOMAIN = explode('.', $_SERVER['SERVER_NAME']);
if( count( $_DOMAIN ) == 2 ){
$__DOMAIN[2] = $_DOMAIN[1];
$__DOMAIN[1] = $_DOMAIN[0];
$_DOMAIN = $__DOMAIN;
}
$project_folder = 'projects';
if( $_DOMAIN[2] == 'inpsyde' ){
$project_folder = $_DOMAIN[2];
if( ! is_readable( '/var/www/' . $project_folder . '/' ) )
$project_folder = 'projects';
}else if( $_SERVER['SERVER_NAME'] == 'localhost' ){
$wp_config = '/var/www/'. $project_folder . '/blub/wp-config.php';
}
if( !isset( $wp_config ) ){
$wp_config = '/var/www/'. $project_folder . '/' . $_DOMAIN[1] . '/' . $_DOMAIN[2] . '/wp-config.php';
}
if( ! empty( $_SERVER['WP_CONFIG_PATH'] ) ){
$_DOMAIN[1] = $_SERVER['WP_CONFIG_PATH'];
}
if( ! file_exists( $wp_config ) ){
$wp_config_v1 = $wp_config;
$wp_config = '/var/www/' . $project_folder . '/' . $_DOMAIN[1] . '_' . $_DOMAIN[2] . '/wp-config.php';
}
if( ! file_exists( $wp_config ) ){
$wp_config = '/var/www/' . $project_folder . '/' . $_DOMAIN[1] . '/wp-config.php';
}
#special for MI
if( ! file_exists( $wp_config ) ){
if( $_DOMAIN[0] == 'mi' || $_DOMAIN[0] == 'mi_admin' ){
$wp_config = '/var/www/' . $project_folder . '/bla/wp-config.php';
}
}
if( ! file_exists( $wp_config ) )
trigger_error( 'die <i>wp-config.php</i> konnte nicht geladen werden! <br /><br /> Die <i>wp-config.php</i> kann in folgenden Verzeichnissen abgelegt werden: <br /><i>'. str_replace( $_DOMAIN[1] . $
}
if( ! file_exists( $wp_config ) ){
$wp_config = '/var/www/' . $project_folder . '/' . $_DOMAIN[1] . '/wp-config.php';
}
#special for MI
if( ! file_exists( $wp_config ) ){
if( $_DOMAIN[0] == 'mi' || $_DOMAIN[0] == 'mi_admin' ){
$wp_config = '/var/www/' . $project_folder . '/bla/wp-config.php';
}
}
if( ! file_exists( $wp_config ) )
trigger_error( 'die <i>wp-config.php</i> konnte nicht geladen werden! <br /><br /> Die <i>wp-config.php</i> kann in folgenden Verzeichnissen abgelegt werden: <br /><i>'. str_replace( $_DOMAIN[1] . $
if( ! is_readable( $wp_config ) )
trigger_error( "wp-config.php konnte nicht geladen werden! Dateirechte stimmen nicht!", E_USER_ERROR);
require_once( $wp_config );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment