On my system (probably on yours too) you can test for pipe input by looking into /proc/$$/fd/0 - which is the standard input (stdin) file descriptor symlink.
Here's an example script and three examples of it in use:
# file: example.sh
bash$ ls | ./example.sh
bash$ ./example.sh < input.txt
Also, if you want to read the input that was piped into the script, you can simply use cat to read it from the pipe.
if readlink /proc/$$/fd/0 | grep -q "^pipe:"; then
echo "Pipe input:"
elif file $( readlink /proc/$$/fd/0 ) | grep -q "character special"; then
echo "Standard input:"
echo "File input:"
cat # read from stdin and write to stdout