I think apache runs under the user nobody group nobody. So basically any chmod commands you do must be executable by this user. Easy way around this is to chown all files which you want apache to be able to chmod to nobody:nobody.
You should then be able to simply run a chmod through exec like so
<?php
if($user=='secured') {
exec('chmod 777 '.$file);
}
?>
HTH
Bubble