Reference (include) php file in content summary
If you have a custom module for your site, put the file in that module directory, add it to the mymodule.info file, 

file[] = external.inc


and put the include statement in the mymodule.module file. Use the model here if you are unfamiliar.

Make the code a function, named for instance mymodule_standard_summary(), and then use:

&lt;?php
print mymodule_standard_summary();
?&gt;


in the summary of your nodes. This should get you started.

EDIT:

Rather than trying to embed your code in the page like this:

&lt;?php
  // Embedded code
  print $result;
?&gt;


instead you should set it up in a function in your file like this:

function mymodule_standard_summary() {
  // Your code
  return $result;
}


I hope this makes it a little clearer.