Do spells that have an area effect such as Burning Hands and Sleep apply to friendly creatures or is it okay to point the area towards a mixed group of friendly and hostile creatures and not worry for the friendly ones?
Spells require line of effect in order to affect a target. If you are completely obscured from a character (ie. you have total cover) then you can't be hit by that character (exception being a Spread which can fold around corners, in which case the origin of the spread must be in line of effect to the caster).
There are 3 main kinds of areas of effect that spells can have, burst, spread, and geometry (line, cone, cylinder, sphere).
Burst (and emanations, which are just persistent bursts):
A burst spell affects whatever it catches in its area, including creatures that you can't see. It can't affect creatures with total cover from its point of origin (in other words, its effects don't extend around corners).
Example: Prayer. Note that Total Cover is the same as not having line of effect.
A spread spell extends out like a burst but can turn corners. You select the point of origin, and the spell spreads out a given distance in all directions. Figure the area the spell effect fills by taking into account any turns the spell effect takes. The effect can extend around corners and into areas that you can't see. Figure distance by actual distance traveled, taking into account turns the spell effect takes. When determining distance for spread effects, count around walls, not through them. As with movement, do not trace diagonals across corners. You must designate the point of origin for such an effect, but you need not have line of effect (see below) to all portions of the effect.
Example: Fireball. Note that the description of Fireball includes:
If the damage caused to an interposing barrier shatters or breaks through it, the fireball may continue beyond the barrier if the area permits; otherwise it stops at the barrier just as any other spell effect does.
So, this suggests you might be able to affect a creature inside another creature with a spread, if there is a clear path to it or its stomach is about to burst (and the fireball damage is too much). I'll concede that MAYBE, if the dragon still has his mouth open, and all the various valves and sphincters in his digestive system are open, you might be able to affect a swallowed companion, but I find that tenuous without a detailed study of dragon biology.
Geometry: Cones and spheres are just descriptions of the previous 2 types.
When casting a cylinder-shaped spell, you select the spell's point of origin. This point is the center of a horizontal circle, and the spell shoots down from the circle, filling a cylinder. A cylinder-shaped spell ignores any obstructions within its area.
An untyped cylinder WOULD affect a swallowed creature, as RAW, although they may be restraining their thinking to 2d. Example: Flame Strike
A line-shaped spell shoots away from you in a line in the direction you designate. It starts from any corner of your square and extends to the limit of its range or until it strikes a barrier that blocks line of effect. A line-shaped spell affects all creatures in squares through which the line passes.
Example: Lightning Bolt
The same would apply to energy channeling (which is a burst).
So we see that we need Line of Effect, how do we define that?
Line of Effect:
Line of Effect: A line of effect is a straight, unblocked path that indicates what a spell can affect. A line of effect is canceled by a solid barrier. It's like line of sight for ranged weapons, except that it's not blocked by fog, darkness, and other factors that limit normal sight.
You must have a clear line of effect to any target that you cast a spell on or to any space in which you wish to create an effect. You must have a clear line of effect to the point of origin of any spell you cast.
A burst, cone, cylinder, or emanation spell affects only an area, creature, or object to which it has line of effect from its origin (a spherical burst's center point, a cone-shaped burst's starting point, a cylinder's circle, or an emanation's point of origin).
An otherwise solid barrier with a hole of at least 1 square foot through it does not block a spell's line of effect. Such an opening means that the 5-foot length of wall containing the hole is no longer considered a barrier for purposes of a spell's line of effect.
Unless you can argue that a dragon's stomach is not a solid barrier (in which case you shouldn't need to cut your way out of it), it blocks line of effect to creatures in it. It would only provide soft/partial cover to a creature behind it, but a swallowed creature is encased entirely with no chance of being able to peek around the dragon's bulk.
Edit: After further consideration, Lines are just jerks. Whether the barb gets electrified really depends on how you are implementing the rules, since in this case the last line (aha) of the description for lines completely contradicts the previous ones. It really depends on if you are playing 'pure' RAW, or actually basing your campaign in a 3-Dimensional world.
For example, assume you are in a circular hallway with a baddie against the wall. You lightning bolt him, and the bolt stops after hitting the wall behind him. Then the wall moves, and you find out the 'wall' was actually a sleeping dragon, one so massive you just assumed it was solid mass. Does the bolt now go through the dragon and out the other side, frying the baddies friends AND the dragon, or does it stop since it hit an object that really was solid, it just happened to be a creature.
Another example, what if your baddie was teamed up with a mole person, who had just his normal-sized head peeking out of the ground behind the baddie? Does the bolt arc down? What if there was a flying baddie hovering 5ft above the mole? 10ft? 100ft? What if you have all flying baddies, can you aim up? Would you hit all enemies in a 'ray' from you through the target? Would you hit all the enemies in a vertical plane?
Personally I resolve rules based on how I would imagine such an effect would work in real life (I imagine something like force lightning from Star Wars), but this is completely subjective and arbitrary.
Conclusion: Lines suck, I have no idea how they work.
The line about affecting yourself is in a section titled “Targets” and only applies to spells which allow you to choose targets. Spells like sleep don't let you choose targets, so that section doesn't apply at all, and everyone is affected, including you.
Now, sleep in particular has one minor saving grace in that it affects creatures with lower hit points first, so if you're the highest hit-point creature in the area of effect and the spell's hit point limit gets used up on your enemies, you won't be affected by the spell. That's a gamble though, as you have to guess the total hit points of the creatures around you correctly to pull that off, and guessing wrong can put you to sleep along with them. Unless you're an elf, in which case — go to town with it!