From SeedCode Documentation

DayBackOnline: PHPrelay File

What is the PHPrelay file and why do I need one?

You will need to use a php Relay to connect (dayback.com) to your FileMaker Server.

DayBack comes with a simple PHP file (fmxjRelay.php) that you can use. This is the same file used in SeedCode's open source fmxj project and the file doesn't have any DayBack logic in it. It's real use is to let you keep your FileMaker account names and passwords on your FileMaker Server and out of DayBack. You can modify the file as you see fit.

You can download the PHP relay file here, rename it, and edit your account information by changing a couple lines to reflect a 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 allow http XMLRequests directly to the XML API from another domain, and changing this involves modifying the Web Server settings. Such a modification is actually pretty easy in Windows/IIS, but not so in Mac/FileMaker Server/Apache. In either case, dropping a single PHP relay file into the FileMaker Server's root directory is much easier AND gives you a private place to transform DayBack's usernames into your FileMaker account names.

Do I need to make any changes to the PHPrelay file?

Yes. The PHP relay file lets you hard-code login information used by DayBack into a file on your server... so this account information isn't stored on DayBack's servers or shared with DayBack. You also may need to make a few changes if you are running a multi-machine configuration of FMS.

Text Editor

The PHP relay file needs to be edited in a plain text format. The default text editor in Mac, TextEdit, is normally editing in rich text format. If you use TextEdit, make sure to change the settings when opening the PHP relay file by clicking the "Format" menu and then select "Make Plain Text".

In Windows, WordPad is a rich text editor, so you'll want to instead use the default plain text editor, notepad.

FileMaker Login

DayBack will pass the logged in user's DayBack user name (often the user's email address) into the relay: you can edit the relay file to pass the FileMaker account name and password for that user 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>";
}
}
//hardcoded credentials for all users
else{
$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):

//hardcoded credentials for all users
else{
$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 PHPrelay file on your FileMaker Sever 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:

//The 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 PHPrelay file isn't in the root directory?

Some third party hosting providers may have a special location for things like the PHPrelay, 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 file name 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.

Retrieved from http://archive.seedcode.com/pmwiki/index.php?n=DayBackOnline.PHPrelayFile
Page last modified on May 01, 2018, at 10:20 PM