How do I attach a php file to an arbitrary slug and still have access to the wp-core functions?

I do this pretty regularly and have no issue with using functions in WordPress core. You can hook a bit earlier though and skip the 404 and header bits. In functions.php:

function wpa88013_parse_query( $wp ){
    if ( 'nlm-admin-thumbnail' == $wp->query_vars['pagename'] ) {
        include( dirname( __FILE__ ) . '/thumbnail.php' );
        exit;
    }
}
add_action( 'parse_query', 'wpa88013_parse_query' );

And some example code in thumbnail.php:

<?php
$content = "foo\n\nbar";
echo apply_filters( 'the_content', $content );

$post_id = 1;
echo get_the_post_thumbnail( $post_id );

I’ve just tested this in the twentytwelve theme and it works as expected.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)