I wrote a script today that makes sure the apache process has write access to specific folder in my path (mostly upload directories) and I wanted to give the administrator account a list of the commands to run in order to fix the permissions.

To get the current user name:

$userInfo = posix_getpwuid(posix_getuid());
$user = $userInfo['name'];    

To get the current group name:

$groupInfo = posix_getgrgid(posix_getgid());
$group = $groupInfo = $groupInfo['name'];