Perl script -
#!/usr/bin/perl
$rootpw = $ARGV[0];
$cmd = $ARGV[1];
open(SUDO, "|sudo $cmd 2>&1 >/dev/null");
print SUDO $rootpw;
close(SUDO);
Now just exec this perl script via PHP -
system("whatever.pl rootpassword 'mycommand'");
Of course, this does assume you're running either a real OS like OpenBSD (man, I'm gonna get flamed. 🙂 or have a Linux distro that includes the sudo tool (like Slackware, the best Linux distro ever (I'm gonna get flamed again. 🙂)
I hereby disavow any damages you might cause/allow by actually running this. And no, I don't think it's a good idea, but I also believe in freedom of knowledge. 🙂