The PHP Relay for FileMaker Server

Important: These instructions are only necessary for older versions of FileMaker. If you have FileMaker 19 or higher, go here for instructions on setting up your calendar, which works in FileMaker client and in the browser through WebDirect.

For FileMaker Server

What is the PHP relay file and why do I need one?

To connect DayBack.com to your FileMaker Server, you will need to use a PHP relay file.

DayBack includes a straightforward PHP file called fmxjRelay.php that you can use for this purpose. This file is part of SeedCode's open-source fmxj project and doesn't contain any specific DayBack logic. Its main function is to keep your FileMaker account names and passwords securely on your FileMaker Server, rather than in DayBack. You are free to modify this file as needed.

You can download the PHP relay file here. After downloading, you can rename it and edit the file to include your FileMaker account information. Just change a couple of lines to reflect the FileMaker account name and password that have read/write access to your FileMaker file.

The technical reason for needing this file is that FileMaker Server does not permit HTTP XMLRequests directly to the XML API from a different domain, and altering this requires modifications to the Web Server settings. While this is relatively simple to do on Windows/IIS, it is more challenging on Mac/FileMaker Server/Apache. By using a PHP relay file, you avoid the need for complex modifications, making the process much easier. Additionally, it provides a secure location to transform DayBack's usernames into your FileMaker account names.

Do I need to make any changes to the PHP relay file?

Yes, you do. The PHP relay file allows you to securely hard-code login information that DayBack will use to access your FileMaker Server. This ensures that your account details remain on your server and are not stored or shared with DayBack. Additionally, you may need to make some adjustments if you're using a multi-machine configuration of FileMaker Server (FMS).

Editing the PHP Relay File

The PHP relay file must be edited in plain text format.

  • On Mac: The default text editor, TextEdit, typically works in rich text format. To edit the PHP relay file, open it in TextEdit, then go to the "Format" menu and select "Make Plain Text."
  • On Windows: WordPad is a rich text editor, so it's better to use Notepad, the default plain text editor, for editing the PHP relay file.

FileMaker Login

DayBack will pass the logged-in user's DayBack username (often the user's email address) to the relay. You can modify the relay file to map this to the corresponding FileMaker account name and password for that user, ensuring that the correct credentials are passed into FileMaker. Here are the lines you'll find in the relay file to change:

// Edit method for logging users into FMS
// Set to false if you plan on having all users logged into FMS with the same account
$loginByName = false;

// Define your FM credentials here
// FM credentials from posted user name($u). 
// The user name will be the DayBack account / email address.

if ($loginByName) {
	// set credentials based on the user's DayBack account name / email address.
	if ($u=="[email protected]") {
		$u="fmxj";
		$p="fmxj";
	} else if ($u=="<[email protected]>") {
		$u="<AnotherFileMakerUser>";
		$p="<AnotherFileMakerPassword>";
	}
} else {
        // hardcoded credentials for all users
	$u="fmxj";
	$p="fmxj";
}

If you would like to use one FileMaker account for every DayBack user you can just find the hard-coded user name at the bottom of the code block and change the username and password to match your account (this is set to "fmxj" for username and password by default):

} else {
        // hardcoded credentials for all users
	$u="fmxj";
	$p="fmxj";
}

If you would like to log users in based on their specific DayBack username you will need to set the $loginByName variable to true at the top of the code block shown above:

// Set to false if you plan on having all users logged into FMS with the same account
$loginByName = true;

Then you can utilize the If else statements below that to look for a specific DayBack account name and pass their corresponding FileMaker username and password:

// FM credentials from posted user name($u). 
// The user name will be the DayBack account / email address.
if ($loginByName) {
	//set credentials based on the user's DayBack account name / email address.
	if ($u=="[email protected]") {
		$u="fmxj";
		$p="fmxj";
	} else if ($u=="<[email protected]>") {
		$u="<AnotherFileMakerUser>";
		$p="<AnotherFileMakerPassword>";
	}
}

Tip: We recommend that you start with one account and verify that everything is working before moving on and adding all of your user accounts to the file.

Be sure that any FileMaker privilege sets used for DayBack users have the fmxml Extended Privilege enabled (to permit xml web publishing). Once you've edited the file, copy it to your FileMaker Server's Web Publishing Engine (WPE) root directory. This will need to be installed before DayBack can work with your FileMaker files.

Where does the file go?

You'll place the PHP relay file on your FileMaker Server in the Web Publishing root. 

In  FileMaker Server 13 and higher the locations are:

  • For IIS (Windows) through HTTP or HTTPS: [drive]:\Program Files\FileMaker\FileMaker Server\HTTPServer\Conf where [drive] is the drive on which the Web Publishing Engine component of your FileMaker Server deployment resides.
  • For Apache (OS X) through HTTP: /Library/FileMaker Server/HTTPServer/htdocs
  • For Apache (OS X) through HTTPS: /Library/FileMaker Server/HTTPServer/htdocs/httpsRoot

For  FileMaker Server 12 the locations are:

  • For IIS (Windows): <drive>:\Inetpub\wwwroot where <drive> is the drive on which the Web Publishing Engine component of your FileMaker Server deployment resides. 
  • For Apache (Mac OS): /Library/WebServer/Documents

Multi-Machine Server Configuration

If you have a multi-machine server configuration where your Web Server and Web Publishing Engine are on separate machines, then you'll need to make a few changes to the PHP relay file and your Source configuration in DayBack's Administrator Set-Up.

In this scenario, you want to put the PHP relay file in your Web Server root directory. When setting up your Sources in Administrator Settings, you will want to reference the IP address or Domain name of your Web Server. Essentially, DayBack makes its requests to the PHP relay file, which then relays these requests to your FileMaker Server's Web Publishing Engine. The changes that need to be made in the PHP relay file depend on whether your FileMaker Server is set to require secure connections.

SSL Not Required: if your FileMaker Server does not require SSL connections, and the Web Publishing Engine and Web Server are on separate machines then you want to change the $serverAddress variable to the IP address of the Web Publishing Engine. For example:

// FMS WPE address
$serverAddress="192.168.1.123";

SSL Required: if your FileMaker Server does require SSL connections, and the Web Publishing Engine and Web Server are on separate machines then you want to change the $serverAddress variable to the FQDN (Fully Qualified Domain Name) that is associated with the SSL Certificate. You will also need to change the $port variable to 443 and the $http variable to "https". For Example:

// he FQDN for our FMS
$serverAddress="yourserver.yourdomain.com";

// https protocol required by FMS
$http="https";

// SSL required so go through SSL port 443
$port=443;

What if my PHP relay file isn't in the root directory?

Some third-party hosting providers may have a special location for things like the PHP relay, so confirm with your hosting provider what URL should be used to access the PHP file. Then, the path can be added into the PHP relay filename field in the source settings, so the IP address field stays unchanged, but the relay file field might be SomeFolder/SomeSubFolder/emgsdayback.php

Whitelisting DayBack

In the PHPRelay file, you can limit the connections that the PHP relay will respond to by changing the following line:

header('Access-Control-Allow-Origin: *')

to:

header('Access-Control-Allow-Origin: app.dayback.com')

This way, only traffic from DayBack's servers will be allowed to retrieve the data from your FileMaker server.