Skip to content

Commit

Permalink
Merge branch 'beta' pending v5.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
gav- committed Aug 21, 2017
2 parents 2095449 + 7d60dcf commit eca2bb6
Show file tree
Hide file tree
Showing 97 changed files with 78,301 additions and 2,561 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ Packages
RESTfm.ini.php
RESTfm.komodoproject
tools
unit_coverage_report
.DS_Store
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
### 5.0.0 (Released 2017-08-21) ###
- Update diagnostics report for FMS 16.
- Update Mac OS X installer for FMS 16.
Protocol changes:
- Simplified nav section.
Internal:
- New internal message class greatly improves programming of database
backends and I/O formats.
- New unit testing framework improves robustness.
- RESTfm now ustilises PHP namespaces (PHP 5.3+).

### 4.0.9 (Released 2017-01-05) ###
- Update Mac OS X installer to identify OS version 10.12 (a.k.a macOS Sierra)

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2011-2015 Goya Pty Ltd.
Copyright (c) 2011-2017 Goya Pty Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
33 changes: 33 additions & 0 deletions PHPUnit/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
PHPUnit

Copyright (c) 2001-2016, Sebastian Bergmann <[email protected]>.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

* Neither the name of Sebastian Bergmann nor the names of his
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions PHPUnit/phpunit
74,153 changes: 74,153 additions & 0 deletions PHPUnit/phpunit-4.8.31.phar

Large diffs are not rendered by default.

64 changes: 30 additions & 34 deletions RESTfm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* RESTfm - FileMaker RESTful Web Service
*
* @copyright
* Copyright (c) 2011-2015 Goya Pty Ltd.
* Copyright (c) 2011-2017 Goya Pty Ltd.
*
* @license
* Licensed under The MIT License. For full copyright and license information,
Expand All @@ -26,14 +26,16 @@
$startTimeUs = microtime(TRUE);

// Ensure E_STRICT is removed for PHP 5.4+
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
//error_reporting(E_ALL & ~E_STRICT); // Dev. level reporting
//error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
error_reporting(E_ALL & ~E_STRICT); // Dev. level reporting

// x-debug's html error output makes CLI debugging with cURL a PITA.
// x-debug's html error output makes CLI debugging with cURL a problem.
ini_set('html_errors', FALSE);

require_once 'lib/RESTfm/RESTfmConfig.php';
if (RESTfmConfig::getVar('settings', 'diagnostics') === TRUE) {
// RESTfm autoloader for lib classes.
require_once 'lib/autoload.php';

if (RESTfm\Config::getVar('settings', 'diagnostics') === TRUE) {
ini_set('display_errors', '1');
} else {
// Don't display errors to end clients.
Expand All @@ -42,12 +44,10 @@

require_once 'lib/RESTfm/init_paths.php';

// Tonic library
require_once 'lib/tonic/lib/tonic.php';

require_once 'lib/RESTfm/Version.php';
require_once 'lib/RESTfm/RESTfmRequest.php';
require_once 'lib/RESTfm/RESTfmDump.php';

// Tonic URI resources:
require_once 'lib/uriRoot.php';
require_once 'lib/uriDatabaseConstant.php';
require_once 'lib/uriDatabaseLayout.php';
Expand All @@ -59,12 +59,8 @@
//require_once 'lib/uriField.php';
require_once 'lib/uriBulk.php';

// For testing and debugging.
//require_once 'lib/uriTest.php';


// Ensure we are using SSL if mandated.
if (RESTfmConfig::getVar('settings', 'SSLOnly')) {
if (RESTfm\Config::getVar('settings', 'SSLOnly')) {
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ||
$_SERVER['SERVER_PORT'] == 443) {
// OK, we are good.
Expand All @@ -83,19 +79,19 @@

// Setup tonic config for new request.
$requestConfig = array(
'baseUri' => RESTfmConfig::getVar('settings', 'baseURI'),
'acceptFormats' => RESTfmConfig::getVar('settings', 'formats'),
'baseUri' => RESTfm\Config::getVar('settings', 'baseURI'),
'acceptFormats' => RESTfm\Config::getVar('settings', 'formats'),
);
// Work around IIS7 mangling of REQUEST_URI when rewriting URLs.
if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
$requestConfig['uri'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
}

// Handle request.
$request = new RESTfmRequest($requestConfig);
RESTfmDump::requestData($request);
$request = new RESTfm\Request($requestConfig);
RESTfm\Dump::requestData($request);
try {
if (RESTfmConfig::getVar('settings', 'diagnostics') === TRUE) {
if (RESTfm\Config::getVar('settings', 'diagnostics') === TRUE) {
require_once 'lib/RESTfm/diagnostic_checks.php';
}
$request->parse();
Expand All @@ -105,24 +101,24 @@
// Allow the squashing of all 2XX response codes to 200, for clients
// that can't handle anything else.
if (preg_match('/^2\d\d$/', $response->code)) {
$restfmParameters = $request->getRESTfmParameters();
$restfmParameters = $request->getParameters();
if (isset($restfmParameters->RFMsquash2XX)) {
$response->code = Response::OK; // 200
$response->code = Tonic\Response::OK; // 200
}
}

RESTfmDump::requestParsed($request);
} catch (ResponseException $e) {
RESTfm\Dump::requestParsed($request);
} catch (Tonic\ResponseException $e) {
switch ($e->getCode()) {
case Response::UNAUTHORIZED:
case Tonic\Response::UNAUTHORIZED:
// Modify the response code from Unauthorized to Forbidden for
// data formats handled by applications.

$response = $e->response($request);
$format = $request->mostAcceptable(RESTfmConfig::getFormats());
$format = $request->mostAcceptable(RESTfm\Config::getFormats());
if ($format != 'html' && $format != 'txt' &&
RESTfmConfig::getVar('settings', 'forbiddenOnUnauthorized')) {
$response->code = Response::FORBIDDEN;
RESTfm\Config::getVar('settings', 'forbiddenOnUnauthorized')) {
$response->code = Tonic\Response::FORBIDDEN;
break;
}

Expand All @@ -134,10 +130,10 @@
}
}

if (RESTfmConfig::getVar('settings', 'diagnostics') === TRUE) {
if (RESTfm\Config::getVar('settings', 'diagnostics') === TRUE) {
// Add profiling information.
if (is_a($response, 'RESTfmResponse')) {
// In some early startup errors, we may not be RESTfmResponse, so we
if (is_a($response, 'RESTfm\Response')) {
// In some early startup errors, we may not be RESTfm\Response, so we
// checked.

// Real/wall time (ms)
Expand All @@ -161,9 +157,9 @@

// Add maximum POST size and memory limit information for all RESTfm 2xx
// responses where a username was specified (non-guest).
if ( is_a($response, 'RESTfmResponse') &&
if ( is_a($response, 'RESTfm\Response') &&
preg_match('/^2\d\d$/', $response->code) ) {
$requestUsername = $request->getRESTfmCredentials()->getUsername();
$requestUsername = $request->getCredentials()->getUsername();
if (! empty($requestUsername)) {
// All RESTfm URIs perform a database query to validate credentials,
// so all RESTfm 2xx responses imply successful authorisation.
Expand All @@ -176,7 +172,7 @@

// Final response output.
$response->output();
RESTfmDump::responseBody($response);
RESTfm\Dump::responseBody($response);

exit;

Expand Down
2 changes: 1 addition & 1 deletion contrib/install-RESTfm.OSX/shared-functions
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ check_FMSVersion() {
fi
log_success_msg "$MSGPREFIX $FMS_VERSION"
;;
'14'|'15')
'14'|'15'|'16')
log_success_msg "$MSGPREFIX $FMS_VERSION"
;;
*)
Expand Down
4 changes: 2 additions & 2 deletions css/RESTfm.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Basic formatting for RESTfm html output.
*
* @copyright
* Copyright (c) 2011-2015 Goya Pty Ltd.
* Copyright (c) 2011-2017 Goya Pty Ltd.
*
* @license
* Licensed under The MIT License. For full copyright and license information,
Expand Down Expand Up @@ -59,7 +59,7 @@ h3 {
}

th {
font-size: 0.8em;
font-size: 0.9em;
text-align: left;
vertical-align: top;
}
Expand Down
Binary file modified css/RESTfm.logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion css/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* RESTfm Demonstration Web Application.
*
* @copyright
* Copyright (c) 2011-2015 Goya Pty Ltd.
* Copyright (c) 2011-2017 Goya Pty Ltd.
*
* @license
* Licensed under The MIT License. For full copyright and license information,
Expand Down
4 changes: 2 additions & 2 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* RESTfm Demonstration Web Application.
*
* @copyright
* Copyright (c) 2011-2015 Goya Pty Ltd.
* Copyright (c) 2011-2017 Goya Pty Ltd.
*
* @license
* Licensed under The MIT License. For full copyright and license information,
Expand All @@ -30,7 +30,7 @@
</head>
<body>
<div id="content" class="content">
<a target="_blank" href="http://www.restfm.com"><img id="logo" width="106" height="36" src="css/RESTfm.logo.png" alt="RESTfm logo"></a>
<a target="_blank" href="http://www.restfm.com"><img id="logo" width="106" height="33" src="css/RESTfm.logo.png" alt="RESTfm logo"></a>
<div id="credentials">
<div id="login_block">
<div class="hide_on_auth">
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* RESTfm report redirection.
*
* @copyright
* Copyright (c) 2011-2015 Goya Pty Ltd.
* Copyright (c) 2011-2017 Goya Pty Ltd.
*
* @license
* Licensed under The MIT License. For full copyright and license information,
Expand Down
6 changes: 3 additions & 3 deletions js/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ RESTfm.refreshResults = function(browseTo) {

// Keep navigation URIs provided by RESTfm server.
RESTfm.navURIs = {};
$.each(data['nav'], function (index, row) {
RESTfm.navURIs[row['name']] = row['href'];
$.each(data['nav'], function (name, href) {
RESTfm.navURIs[name] = href;
});

// Remember the last successful URI.
Expand Down Expand Up @@ -639,7 +639,7 @@ RESTfm.checkVersion = function(serverVersion) {
}

if (RESTfm.version.indexOf('VERSION') >= 0 &&
serverVersion.indexOf('UNKNOWN') >= 0 ) {
serverVersion.indexOf('GIT') >= 0 ) {
return;
}

Expand Down
6 changes: 2 additions & 4 deletions lib/RESTfm/BackendAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* RESTfm - FileMaker RESTful Web Service
*
* @copyright
* Copyright (c) 2011-2015 Goya Pty Ltd.
* Copyright (c) 2011-2017 Goya Pty Ltd.
*
* @license
* Licensed under The MIT License. For full copyright and license information,
Expand All @@ -17,9 +17,7 @@
* Gavin Stewart
*/

require 'OpsDatabaseAbstract.php';
require 'OpsLayoutAbstract.php';
require 'OpsRecordAbstract.php';
namespace RESTfm;

/**
* Defines interface for initialisation of database backend, and factory
Expand Down
35 changes: 12 additions & 23 deletions lib/RESTfm/BackendFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* RESTfm - FileMaker RESTful Web Service
*
* @copyright
* Copyright (c) 2011-2015 Goya Pty Ltd.
* Copyright (c) 2011-2017 Goya Pty Ltd.
*
* @license
* Licensed under The MIT License. For full copyright and license information,
Expand All @@ -17,10 +17,7 @@
* Gavin Stewart
*/

require_once 'RESTfmConfig.php';
require_once 'RESTfmRequest.php';
require_once 'RESTfmCredentials.php';
require_once 'BackendAbstract.php';
namespace RESTfm;

/**
* (Database) Backend Factory - instantiates appropriate database backend.
Expand All @@ -36,45 +33,37 @@ class BackendFactory {
/**
* Instantiate and return the appropriate backend object.
*
* @param RESTfmRequest $request
* @param Request $request
* Originating request containing credentials for backend authentication.
*
* @param string $database
* Database name.
*
* @throws RESTfmResponseException
* @throws ResponseException
* When no appropriate backend found.
*
* @return BackendAbstract
*/
public static function make (RESTfmRequest $request, $database = NULL) {
public static function make (Request $request, $database = NULL) {
// FileMaker is the default, but $database may map to a PDO backend.
$type = self::BACKEND_FILEMAKER;
if ($database !== NULL && RESTfmConfig::checkVar('databasePDOMap', $database)) {
if ($database !== NULL && Config::checkVar('databasePDOMap', $database)) {
$type = self::BACKEND_PDO;
}

// Identify backend class.
$backendName = 'Backend' . $type;
$classPath = dirname(__FILE__) . DIRECTORY_SEPARATOR .
$backendName . DIRECTORY_SEPARATOR .
$backendName . '.php';
if (!file_exists($classPath)) {
throw new RESTfmResponseException('Unknown backend: ' . $type, 500);
}
require_once($classPath);
$backendClassName = 'RESTfm\\Backend' . $type . '\\' . 'Backend';

$restfmCredentials = $request->getRESTfmCredentials();
$restfmCredentials = $request->getCredentials();

if ($type === self::BACKEND_PDO) {
$backendObject = new $backendName(
RESTfmConfig::getVar('databasePDOMap', $database),
$backendObject = new $backendClassName(
Config::getVar('databasePDOMap', $database),
$restfmCredentials->getUsername(),
$restfmCredentials->getPassword()
);
} else { # Default to FileMaker
$backendObject = new $backendName(
RESTfmConfig::getVar('database', 'hostspec'),
$backendObject = new $backendClassName(
Config::getVar('database', 'hostspec'),
$restfmCredentials->getUsername(),
$restfmCredentials->getPassword()
);
Expand Down
Loading

0 comments on commit eca2bb6

Please sign in to comment.