{
    my $status = $php{status} || 'disabled';
    if ($status eq 'enabled')
    {
	use esmith::AccountsDB;
	my $adb = esmith::AccountsDB->open_ro();
	foreach my $ibay ($adb->ibays)
	{
	    local $dynamicContent = $ibay->prop('CgiBin') || 'disabled';
	    if ($dynamicContent eq 'enabled')
	    {
		$OUT .= "\n<Directory /home/e-smith/files/ibays/" . $ibay->key . "/html>\n";
		$OUT .= "    AddType application/x-httpd-php .php .php3 .phtml\n";
		$OUT .= "    AddType application/x-httpd-php-source .phps\n";

                # Set the upload_tmp_folder where php can upload files
                my $tmpdir = $ibay->prop('PHPTmpDir') || 'enabled';
                $tmpdir = ('/var/cache/e-smith/files/ibays/' . $ibay->key . '/tmp') if $tmpdir eq 'enabled';
                $OUT .= "    php_admin_value upload_tmp_dir $tmpdir\n" unless ($tmpdir eq 'disabled' || ! -d $tmpdir);

                # Set the session folder where php can store its session instead of in global dir
                my $sessdir = $ibay->prop('PHPSessionDir') || 'enabled';
                $sessdir = ('/var/cache/e-smith/files/ibays/' . $ibay->key . '/session') if $sessdir eq 'enabled';
                $OUT .= "    php_admin_value session.save_path $sessdir\n" unless ($sessdir eq 'disabled' || ! -d $sessdir);

		# Set the sandbox within which PHP is confined to play
		my $basedir = $ibay->prop('PHPBaseDir')
		    || ("/home/e-smith/files/ibays/" . $ibay->key . "/");
		$basedir = $tmpdir . ":" . $basedir unless ($tmpdir eq 'disabled' || ! -d $tmpdir); 
		$basedir = $sessdir . ":" . $basedir unless ($sessdir eq 'disabled' || ! -d $sessdir);
		$OUT .= "    php_admin_value open_basedir $basedir\n";
		$OUT .= "</Directory>\n";
	    }
	}
    }
}
