Ex: This particular sample was in PHP so Wordpress comes to mind. Plugins in particular are notorious for poor programming practices that allow such file inclusions.
[1] Disallowing by extension doesn't always work as some filters allow img.php.png or img.png.php. Besides this, an image can skip the .php altogether and still be executed as a PHP script
Ex: https://security.stackexchange.com/a/32970 and https://security.stackexchange.com/a/32969
Note however, this doesn't just apply to PHP. There are potential vectors in Perl, Python and Ruby when adequate measures are not taken to sanitise user input and filter arbitrary uploads.
`location ~ .php$ { [forward to fcgi] }`
This is a common configuration that allows the client to execute any php file within the web root. If you accidentally allow a php file to be uploaded, it may be executed.
Instead something like the following means that the web server will not allow arbitrary php files to be executed, only the ones you want to be executed:
`location ~ /(index\.php|wp-admin/ajax.php)$ { [cgi] }`
(Just an approximation - I don't feel like looking up the exact expression I use.)
The site owners can't, in most cases, poke around to see what is in the code. And the code often contains hooks that inject various things into the installation.
The other route in is through scripts like TimThumb, which is included in a lot of themes. TT has had some serious security holes in it, the last one being fairly recent that allows for remote file execution. At that point, at least the account hosting the file is a goner.