FEATURE: First commit for ProcessMaker Rest Support
What is Functional - Restler thirdparty library added - Restler integration with gulliver added - Rest requests are dispatched by sysGeneric - Restler autodiscover for classes that implements Restler iAuthenticate interface added What Missing - ProcessMaker Api implemented yet - some rest api class are in workflow/engine/services/rest/*.php
This commit is contained in:
@@ -64,10 +64,11 @@
|
||||
define( 'PATH_WORKFLOW_MSSQL_DATA', PATH_CORE . 'data' . PATH_SEP.'mssql'.PATH_SEP);
|
||||
define( 'PATH_RBAC_MSSQL_DATA', PATH_RBAC_CORE . 'data' . PATH_SEP.'mssql'.PATH_SEP);
|
||||
define( 'PATH_CONTROLLERS', PATH_CORE . 'controllers' . PATH_SEP );
|
||||
define( 'PATH_SERVICES_REST', PATH_CORE . 'services' . PATH_SEP . 'rest' . PATH_SEP);
|
||||
|
||||
// include Gulliver Class
|
||||
require_once( PATH_GULLIVER . PATH_SEP . 'class.g.php');
|
||||
|
||||
|
||||
if(file_exists(FILE_PATHS_INSTALLED)) {
|
||||
// backward compatibility; parsing old definitions in the compiled path constant
|
||||
$tmp = file_get_contents(FILE_PATHS_INSTALLED);
|
||||
@@ -76,28 +77,28 @@
|
||||
@file_put_contents(FILE_PATHS_INSTALLED, str_replace('PATH_OUTTRUNK', 'PATH_DATA', $tmp));
|
||||
}
|
||||
// end backward compatibility
|
||||
|
||||
|
||||
// include the workspace installed configuration
|
||||
require_once FILE_PATHS_INSTALLED;
|
||||
|
||||
|
||||
// defining system constant when a valid workspace environment exists
|
||||
define('PATH_LANGUAGECONT', PATH_DATA . "META-INF" . PATH_SEP);
|
||||
define('PATH_CUSTOM_SKINS', PATH_DATA . 'skins' . PATH_SEP);
|
||||
define('PATH_TEMPORAL', PATH_C . 'dynEditor/');
|
||||
define('PATH_DB', PATH_DATA . 'sites' . PATH_SEP);
|
||||
// smarty constants
|
||||
// smarty constants
|
||||
define('PATH_SMARTY_C', PATH_C . 'smarty' . PATH_SEP . 'c');
|
||||
define('PATH_SMARTY_CACHE', PATH_C . 'smarty' . PATH_SEP . 'cache');
|
||||
|
||||
|
||||
if (!is_dir(PATH_SMARTY_C)) {
|
||||
G::mk_dir(PATH_SMARTY_C);
|
||||
}
|
||||
|
||||
if (!is_dir(PATH_SMARTY_CACHE)) {
|
||||
if (!is_dir(PATH_SMARTY_CACHE)) {
|
||||
G::mk_dir(PATH_SMARTY_CACHE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set include path
|
||||
set_include_path(
|
||||
PATH_CORE . PATH_SEPARATOR .
|
||||
@@ -110,7 +111,7 @@
|
||||
/**
|
||||
* Global definitions, before it was the defines.php file
|
||||
*/
|
||||
|
||||
|
||||
// URL Key
|
||||
define("URL_KEY", 'c0l0s40pt1mu59r1m3' );
|
||||
|
||||
@@ -134,7 +135,7 @@
|
||||
// Number of files per folder at PATH_UPLOAD (cases documents)
|
||||
define('APPLICATION_DOCUMENTS_PER_FOLDER', 1000);
|
||||
|
||||
// Server of ProcessMaker Library
|
||||
// Server of ProcessMaker Library
|
||||
define('PML_SERVER' , 'http://library.processmaker.com');
|
||||
define('PML_WSDL_URL' , PML_SERVER . '/syspmLibrary/en/green/services/wsdl');
|
||||
define('PML_UPLOAD_URL', PML_SERVER . '/syspmLibrary/en/green/services/uploadProcess');
|
||||
|
||||
30
workflow/engine/services/rest/Author.php
Normal file
30
workflow/engine/services/rest/Author.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
class Author
|
||||
{
|
||||
public $dp;
|
||||
|
||||
static $FIELDS = array('name', 'email');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
function get($id=NULL)
|
||||
{
|
||||
return is_null($id) ? 'GET: getting all records' : "Getting a record with id: $id";
|
||||
}
|
||||
|
||||
function post($request_data=NULL)
|
||||
{
|
||||
return 'POST: posting 1';
|
||||
}
|
||||
|
||||
function put($id=NULL, $request_data=NULL)
|
||||
{
|
||||
return 'PUT: update 1';
|
||||
}
|
||||
|
||||
function delete($id=NULL) {
|
||||
return 'DELETE: deleting '.$id;
|
||||
}
|
||||
}
|
||||
37
workflow/engine/services/rest/Bmi.php
Normal file
37
workflow/engine/services/rest/Bmi.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
class BMI {
|
||||
function index($height=162.6, $weight=84) {
|
||||
$result = new stdClass();
|
||||
|
||||
# 1 pound = 0.45359237 kilograms
|
||||
# 1 meter = 3.2808399 feet
|
||||
# 1 meter = 39.3700787 inches
|
||||
# 1 meter = 100 cms
|
||||
|
||||
#assume height is given in centimeters
|
||||
$cm = $height;
|
||||
#assume weight is given in kilograms
|
||||
$kg = $weight;
|
||||
|
||||
$meter = $cm / 100;
|
||||
$inches = $meter * 39.3700787;
|
||||
$feet = round($inches/12);
|
||||
$inches = $inches % 12;
|
||||
|
||||
$result->bmi = round($kg/($meter*$meter),2);
|
||||
$lb = round($kg/0.45359237,2);
|
||||
|
||||
if($result->bmi<18.5){
|
||||
$result->message = 'Underweight';
|
||||
}elseif ($result->bmi<=24.9){
|
||||
$result->message = 'Normal weight';
|
||||
}elseif ($result->bmi<=29.9){
|
||||
$result->message = 'Overweight';
|
||||
}else{
|
||||
$result->message = 'Obesity';
|
||||
}
|
||||
$result->metric = array('height'=>"$cm centimeter", 'weight'=>"$weight kilograms");
|
||||
$result->imperial = array('height'=>"$feet feet $inches inches", 'weight'=>"$lb pounds");
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
6
workflow/engine/services/rest/Say.php
Normal file
6
workflow/engine/services/rest/Say.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Say {
|
||||
function hello($to='world') {
|
||||
return "Hello $to!";
|
||||
}
|
||||
}
|
||||
15
workflow/engine/services/rest/Simple.php
Normal file
15
workflow/engine/services/rest/Simple.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
class Simple {
|
||||
function normal() {
|
||||
return 'open for all';
|
||||
}
|
||||
protected function restricted() {
|
||||
return 'protected method';
|
||||
}
|
||||
/**
|
||||
* @protected
|
||||
*/
|
||||
function restricted2(){
|
||||
return 'protected by comment';
|
||||
}
|
||||
}
|
||||
16
workflow/engine/services/rest/SimpleAuth.php
Normal file
16
workflow/engine/services/rest/SimpleAuth.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
class SimpleAuth implements iAuthenticate
|
||||
{
|
||||
const KEY = 'sample';
|
||||
|
||||
function __isAuthenticated()
|
||||
{
|
||||
print_r($_SERVER);
|
||||
return isset($_GET['key']) && $_GET['key']==SimpleAuth::KEY ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
function key()
|
||||
{
|
||||
return SimpleAuth::KEY;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* sysGeneric - ProcessMaker Bootstrap
|
||||
* sysGeneric - ProcessMaker Bootstrap
|
||||
* this file is used initialize main variables, redirect and dispatch all requests
|
||||
*/
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
// Defining the Home Directory
|
||||
$realdocuroot = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
|
||||
$docuroot = explode(PATH_SEP , $realdocuroot);
|
||||
|
||||
|
||||
array_pop($docuroot);
|
||||
$pathhome = implode(PATH_SEP, $docuroot) . PATH_SEP;
|
||||
|
||||
@@ -55,12 +55,12 @@
|
||||
// Including these files we get the PM paths and definitions (that should be just one file.
|
||||
require_once $pathhome . PATH_SEP . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php';
|
||||
require_once PATH_CORE . 'classes' . PATH_SEP . 'class.system.php';
|
||||
|
||||
|
||||
// starting session
|
||||
session_start();
|
||||
|
||||
$config = System::getSystemConfiguration();
|
||||
|
||||
|
||||
$e_all = defined('E_DEPRECATED') ? E_ALL & ~E_DEPRECATED : E_ALL;
|
||||
$e_all = defined('E_STRICT') ? $e_all & ~E_STRICT : $e_all;
|
||||
$e_all = $config['debug'] ? $e_all : $e_all & ~E_NOTICE;
|
||||
@@ -69,11 +69,11 @@
|
||||
ini_set('display_errors', $config['debug']);
|
||||
ini_set('error_reporting', $e_all);
|
||||
ini_set('short_open_tag', 'On');
|
||||
ini_set('default_charset', "UTF-8");
|
||||
ini_set('default_charset', "UTF-8");
|
||||
ini_set('memory_limit', $config['memory_limit']);
|
||||
ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']);
|
||||
ini_set('date.timezone', $config['time_zone']);
|
||||
|
||||
|
||||
define ('DEBUG_SQL_LOG', $config['debug_sql']);
|
||||
define ('DEBUG_TIME_LOG', $config['debug_time']);
|
||||
define ('DEBUG_CALENDAR_LOG', $config['debug_calendar']);
|
||||
@@ -87,7 +87,7 @@
|
||||
if (defined('PATH_DATA')) {
|
||||
$writableDirs[] = PATH_DATA;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
G::verifyWriteAccess($writableDirs);
|
||||
}
|
||||
@@ -154,12 +154,12 @@
|
||||
$virtualURITable['/(sys*)/(*.js)'] = 'jsMethod';
|
||||
$virtualURITable['/js/(*)'] = PATH_GULLIVER_HOME . 'js/';
|
||||
$virtualURITable['/jscore/(*)'] = PATH_CORE . 'js/';
|
||||
|
||||
|
||||
if ( defined('PATH_C') ) {
|
||||
$virtualURITable['/jsform/(*.js)'] = PATH_C . 'xmlform/';
|
||||
$virtualURITable['/extjs/(*)'] = PATH_C . 'ExtJs/';
|
||||
}
|
||||
|
||||
|
||||
$virtualURITable['/htmlarea/(*)'] = PATH_THIRDPARTY . 'htmlarea/';
|
||||
$virtualURITable['/sys[a-zA-Z][a-zA-Z0-9]{0,}()/'] = 'sysNamed';
|
||||
$virtualURITable['/(sys*)'] = FALSE;
|
||||
@@ -173,8 +173,11 @@
|
||||
$virtualURITable['/skins/'] = 'errorFile';
|
||||
$virtualURITable['/files/'] = 'errorFile';
|
||||
$virtualURITable['/[a-zA-Z][a-zA-Z0-9]{0,}()'] = 'sysUnnamed';
|
||||
$virtualURITable['/rest/(*)'] = 'rest-service';
|
||||
$virtualURITable['/(*)'] = PATH_HTML;
|
||||
|
||||
$isRestRequest = false;
|
||||
|
||||
// Verify if we need to redirect or stream the file, if G:VirtualURI returns true means we are going to redirect the page
|
||||
if ( G::virtualURI($_SERVER['REQUEST_URI'], $virtualURITable , $realPath )) {
|
||||
// review if the file requested belongs to public_html plugin
|
||||
@@ -198,13 +201,18 @@
|
||||
//The other parts are the realpath into public_html (no matter how many elements)
|
||||
$filePath = implode(PATH_SEP,$paths);
|
||||
$pluginFilename = PATH_PLUGINS . $pluginFolder . PATH_SEP . 'public_html'. PATH_SEP . $filePath;
|
||||
|
||||
|
||||
if ( file_exists ( $pluginFilename ) ) {
|
||||
G::streamFile ( $pluginFilename );
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
// if (substr($realPath, 0, 12) === 'rest-service') {
|
||||
// G::dispatchRestService();
|
||||
// die;
|
||||
// }
|
||||
|
||||
$requestUriArray = explode("/",$_SERVER['REQUEST_URI']);
|
||||
|
||||
if((isset($requestUriArray[1]))&&($requestUriArray[1] == 'skin')) {
|
||||
@@ -229,11 +237,11 @@
|
||||
|
||||
switch ($realPath) {
|
||||
case 'sysUnnamed' :
|
||||
require_once('sysUnnamed.php');
|
||||
require_once('sysUnnamed.php');
|
||||
die;
|
||||
break;
|
||||
case 'sysNamed' :
|
||||
header('location : ' . $_SERVER['REQUEST_URI'] . '/' .SYS_LANG. '/classic/login/login' );
|
||||
header('location : ' . $_SERVER['REQUEST_URI'] . '/' .SYS_LANG. '/classic/login/login' );
|
||||
die;
|
||||
break;
|
||||
case 'jsMethod' :
|
||||
@@ -248,15 +256,19 @@
|
||||
die;
|
||||
break;
|
||||
default :
|
||||
$realPath = explode('?', $realPath);
|
||||
$realPath[0] .= strpos(basename($realPath[0]), '.') === false ? '.php' : '';
|
||||
G::streamFile ( $realPath[0] );
|
||||
die;
|
||||
if (substr($realPath, 0, 12) == 'rest-service') {
|
||||
$isRestRequest = true;
|
||||
} else {
|
||||
$realPath = explode('?', $realPath);
|
||||
$realPath[0] .= strpos(basename($realPath[0]), '.') === false ? '.php' : '';
|
||||
G::streamFile ( $realPath[0] );
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the request correspond to valid php page, now parse the URI
|
||||
G::parseURI(getenv("REQUEST_URI"));
|
||||
G::parseURI(getenv("REQUEST_URI"), $isRestRequest);
|
||||
|
||||
// verify if index.html exists
|
||||
if (!file_exists(PATH_HTML . 'index.html')) { // if not, create it from template
|
||||
@@ -448,7 +460,7 @@
|
||||
}
|
||||
// log file for rbac database
|
||||
$con = Propel::getConnection('rbac');
|
||||
|
||||
|
||||
if ($con instanceof DebugConnection) {
|
||||
$con->setLogger($logger);
|
||||
}
|
||||
@@ -467,12 +479,12 @@
|
||||
|
||||
// Session Initializations
|
||||
ini_set('session.auto_start', '1');
|
||||
|
||||
|
||||
// The register_globals feature has been DEPRECATED as of PHP 5.3.0. default value Off.
|
||||
// ini_set( 'register_globals', 'Off' );
|
||||
//session_start();
|
||||
ob_start();
|
||||
|
||||
|
||||
// Rebuild the base Workflow translations if not exists
|
||||
if( ! is_file(PATH_LANGUAGECONT . 'translation.en') ){
|
||||
require_once ( "classes/model/Translation.php" );
|
||||
@@ -563,8 +575,12 @@
|
||||
$isControllerCall = true;
|
||||
}
|
||||
}
|
||||
// var_dump(SYS_SYS);
|
||||
// var_dump(SYS_TARGET);
|
||||
// var_dump($isRestRequest);
|
||||
// die;
|
||||
|
||||
if (!$isControllerCall && ! file_exists($phpFile)) {
|
||||
if (!$isControllerCall && ! file_exists($phpFile) && ! $isRestRequest) {
|
||||
$_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI'];
|
||||
header("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI']));
|
||||
die;
|
||||
@@ -609,9 +625,9 @@
|
||||
else {
|
||||
// this is the blank list to allow execute scripts with no login (without session started)
|
||||
$noLoginFiles = $noLoginFolders = array();
|
||||
$noLoginFiles[] = 'login';
|
||||
$noLoginFiles[] = 'login';
|
||||
$noLoginFiles[] = 'authentication';
|
||||
$noLoginFiles[] = 'login_Ajax';
|
||||
$noLoginFiles[] = 'login_Ajax';
|
||||
$noLoginFiles[] = 'dbInfo';
|
||||
$noLoginFiles[] = 'sysLoginVerify';
|
||||
$noLoginFiles[] = 'processes_Ajax';
|
||||
@@ -619,7 +635,7 @@
|
||||
$noLoginFiles[] = 'autoinstallProcesses';
|
||||
$noLoginFiles[] = 'autoinstallPlugins';
|
||||
$noLoginFiles[] = 'heartbeatStatus';
|
||||
$noLoginFiles[] = 'showLogoFile';
|
||||
$noLoginFiles[] = 'showLogoFile';
|
||||
$noLoginFiles[] = 'forgotPassword';
|
||||
$noLoginFiles[] = 'retrivePassword';
|
||||
$noLoginFiles[] = 'defaultAjaxDynaform';
|
||||
@@ -630,9 +646,13 @@
|
||||
$noLoginFolders[] = 'installer';
|
||||
|
||||
// This sentence is used when you lost the Session
|
||||
if ( !in_array(SYS_TARGET, $noLoginFiles) && !in_array(SYS_COLLECTION, $noLoginFolders) && $bWE != true && $collectionPlugin != 'services') {
|
||||
if (! in_array(SYS_TARGET, $noLoginFiles)
|
||||
&& ! in_array(SYS_COLLECTION, $noLoginFolders)
|
||||
&& $bWE != true && $collectionPlugin != 'services'
|
||||
&& ! $isRestRequest
|
||||
) {
|
||||
$bRedirect = true;
|
||||
|
||||
|
||||
if (isset($_GET['sid'])) {
|
||||
G::LoadClass('sessions');
|
||||
$oSessions = new Sessions();
|
||||
@@ -660,7 +680,7 @@
|
||||
else {
|
||||
$loginUrl = 'login/login'; // just set up the classic login
|
||||
}
|
||||
|
||||
|
||||
if (empty($_POST)) {
|
||||
header('location: ' . SYS_URI . $loginUrl . '?u=' . urlencode($_SERVER['REQUEST_URI']));
|
||||
}
|
||||
@@ -686,8 +706,9 @@
|
||||
$controller = new $controllerClass();
|
||||
$controller->setHttpRequestData($_REQUEST);
|
||||
$controller->call($controllerAction);
|
||||
}
|
||||
else {
|
||||
} elseif ($isRestRequest) {
|
||||
G::dispatchRestService(SYS_TARGET);
|
||||
} else {
|
||||
require_once $phpFile;
|
||||
}
|
||||
|
||||
@@ -700,5 +721,5 @@
|
||||
ob_end_flush();
|
||||
if (DEBUG_TIME_LOG) {
|
||||
G::logTimeByPage(); //log this page
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user