Ok here is a test working solution:
<?php
/*
Plugin Name: wpse26719
Plugin URI: http://en.bainternet.info
Description: Need to make a php file inside theme accessible via url
Version: 1.0
Author: Bainternet
Author URI: http://en.bainternet.info
*/
// Register a URL that will set this variable to true
add_action('generate_rewrite_rules', 'wpse26719_rw');
function wpse26719_rw($wp_rewrite) {
$newrules = array();
$new_rules['^adserver.js.php$'] = 'index.php?myjs=true';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
// Add myjs as a query var
add_action( 'query_vars', 'wpse26719_query_vars' );
function wpse26719_query_vars( $query_vars )
{
$query_vars[] = 'myjs';
return $query_vars;
}
// If this is done, we can access it later
// This example checks very early in the process:
// if the variable is set, we include our page and stop execution after it
add_action( 'parse_request', 'wpse26719_parse_request' );
function wpse26719_parse_request( &$wp )
{
if ( array_key_exists( 'myjs', $wp->query_vars ) ) {
include( dirname( __FILE__ ) . '/adserver.js.php' );
exit();
}
}