2014-03-10 16:02:09 -04:00
|
|
|
<?php
|
2014-03-12 18:20:35 -04:00
|
|
|
namespace Maveriks;
|
2014-03-10 16:02:09 -04:00
|
|
|
|
2014-03-12 18:20:35 -04:00
|
|
|
use Maveriks\Util;
|
2014-04-02 17:23:31 -04:00
|
|
|
use ProcessMaker\Services;
|
2014-04-03 12:24:20 -04:00
|
|
|
use ProcessMaker\Services\Api;
|
|
|
|
|
use Luracast\Restler\RestException;
|
2014-03-10 16:02:09 -04:00
|
|
|
|
|
|
|
|
class WebApplication
|
|
|
|
|
{
|
|
|
|
|
protected $rootDir = "";
|
|
|
|
|
protected $workflowDir = "";
|
2014-04-02 18:08:34 -04:00
|
|
|
protected $workspaceDir = "";
|
|
|
|
|
protected $workspaceCacheDir = "";
|
2014-03-10 16:02:09 -04:00
|
|
|
protected $requestUri = "";
|
2014-04-01 16:29:02 -04:00
|
|
|
protected $responseMultipart = array();
|
2014-03-10 16:02:09 -04:00
|
|
|
|
2014-03-13 10:23:50 -04:00
|
|
|
const RUNNING_DEFAULT = "default.running";
|
|
|
|
|
const RUNNING_INDEX = "index.running";
|
2014-03-10 16:02:09 -04:00
|
|
|
const RUNNING_WORKFLOW = "workflow.running";
|
|
|
|
|
const RUNNING_API = "api.running";
|
|
|
|
|
|
2014-03-13 10:23:50 -04:00
|
|
|
const SERVICE_API = "service.api";
|
|
|
|
|
const REDIRECT_DEFAULT = "redirect.default";
|
2014-03-10 16:02:09 -04:00
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
defined("DS") || define("DS", DIRECTORY_SEPARATOR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $rootDir
|
|
|
|
|
*/
|
|
|
|
|
public function setRootDir($rootDir)
|
|
|
|
|
{
|
|
|
|
|
$this->rootDir = $rootDir;
|
|
|
|
|
$this->workflowDir = $rootDir . DS . "workflow" . DS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getRootDir()
|
|
|
|
|
{
|
|
|
|
|
return $this->rootDir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $requestUri
|
|
|
|
|
*/
|
|
|
|
|
public function setRequestUri($requestUri)
|
|
|
|
|
{
|
|
|
|
|
$this->requestUri = $requestUri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getRequestUri()
|
|
|
|
|
{
|
|
|
|
|
return $this->requestUri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function route()
|
|
|
|
|
{
|
2014-03-13 10:23:50 -04:00
|
|
|
if ($this->requestUri === "/") {
|
|
|
|
|
if (file_exists("index.html")) {
|
|
|
|
|
return self::RUNNING_INDEX;
|
|
|
|
|
} else {
|
|
|
|
|
return self::RUNNING_DEFAULT;
|
|
|
|
|
}
|
2014-04-25 11:32:13 -04:00
|
|
|
} elseif (substr($this->requestUri, 1, 3) === "api"
|
|
|
|
|
&& count(explode("/", $this->requestUri)) >= 4 // url api pattern: /api/1.0/<workspace>/<resource>
|
|
|
|
|
) {
|
2014-03-10 16:02:09 -04:00
|
|
|
return self::RUNNING_API;
|
|
|
|
|
} else {
|
|
|
|
|
return self::RUNNING_WORKFLOW;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function run($type = "")
|
|
|
|
|
{
|
|
|
|
|
switch ($type) {
|
|
|
|
|
case self::SERVICE_API:
|
|
|
|
|
$request = $this->parseApiRequestUri();
|
|
|
|
|
$this->loadEnvironment($request["workspace"]);
|
2014-03-11 18:05:50 -04:00
|
|
|
|
2014-03-10 16:02:09 -04:00
|
|
|
Util\Logger::log("API::Dispatching ".$_SERVER["REQUEST_METHOD"]." ".$request["uri"]);
|
2014-04-02 15:06:44 -04:00
|
|
|
if (isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtoupper($_SERVER["HTTP_X_REQUESTED_WITH"]) == 'MULTIPART') {
|
2014-04-01 16:29:02 -04:00
|
|
|
$this->multipart($request["uri"], $request["version"]);
|
|
|
|
|
} else {
|
|
|
|
|
$this->dispatchApiRequest($request["uri"], $request["version"]);
|
|
|
|
|
}
|
2014-04-02 18:08:34 -04:00
|
|
|
Util\Logger::log("API::End Dispatch");
|
2014-03-10 16:02:09 -04:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 16:29:02 -04:00
|
|
|
/**
|
|
|
|
|
* This method performs the functionality of multipart
|
|
|
|
|
*
|
|
|
|
|
* @param string $version. Version Api
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
|
|
|
|
* @copyright Colosa - Bolivia
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function multipart($uri, $version = "1.0")
|
|
|
|
|
{
|
|
|
|
|
$stringInput = file_get_contents('php://input');
|
2014-04-03 12:24:20 -04:00
|
|
|
if (empty($stringInput)) {
|
|
|
|
|
$rest = new \Maveriks\Extension\Restler();
|
|
|
|
|
$rest->setMessage(new RestException(Api::STAT_APP_EXCEPTION, "Invalid Request, multipart without body."));
|
|
|
|
|
exit();
|
|
|
|
|
} else {
|
|
|
|
|
$input = json_decode($stringInput);
|
|
|
|
|
if (empty($input->calls)) {
|
|
|
|
|
$rest = new \Maveriks\Extension\Restler();
|
|
|
|
|
$rest->setMessage(new RestException(Api::STAT_APP_EXCEPTION, "Invalid Request, multipart body without calls."));
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2014-04-01 16:29:02 -04:00
|
|
|
}
|
2014-04-03 12:24:20 -04:00
|
|
|
|
2014-04-01 16:29:02 -04:00
|
|
|
$baseUrl = (empty($input->base_url)) ? $uri : $input->base_url;
|
|
|
|
|
foreach($input->calls as $value) {
|
|
|
|
|
$_SERVER["REQUEST_METHOD"] = (empty($value->method)) ? 'GET' : $value->method;
|
|
|
|
|
$uriTemp = trim($baseUrl) . trim($value->url);
|
2014-04-09 10:52:53 -04:00
|
|
|
if (strpos($uriTemp, '?') !== false) {
|
|
|
|
|
$dataGet = explode('?', $uriTemp);
|
2014-04-09 11:40:36 -04:00
|
|
|
parse_str($dataGet[1], $_GET);
|
2014-04-09 10:52:53 -04:00
|
|
|
}
|
2014-04-02 10:16:21 -04:00
|
|
|
$inputExecute = (empty($value->data)) ? '' : json_encode($value->data);
|
2014-04-01 16:29:02 -04:00
|
|
|
$this->responseMultipart[] = $this->dispatchApiRequest($uriTemp, $version, true, $inputExecute);
|
|
|
|
|
}
|
2014-04-02 10:16:21 -04:00
|
|
|
echo json_encode($this->responseMultipart);
|
2014-04-01 16:29:02 -04:00
|
|
|
}
|
|
|
|
|
|
2014-03-10 16:02:09 -04:00
|
|
|
/**
|
|
|
|
|
* This method dispatch rest/api service
|
|
|
|
|
*
|
|
|
|
|
* @author Erik Amaru Ortiz <erik@colosa.com>
|
|
|
|
|
*/
|
2014-04-01 16:29:02 -04:00
|
|
|
public function dispatchApiRequest($uri, $version = "1.0", $multipart = false, $inputExecute = '')
|
2014-03-10 16:02:09 -04:00
|
|
|
{
|
|
|
|
|
// to handle a request with "OPTIONS" method
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
|
|
|
|
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEADERS');
|
|
|
|
|
header('Access-Control-Allow-Headers: authorization, content-type');
|
|
|
|
|
header("Access-Control-Allow-Credentials", "false");
|
|
|
|
|
header('Access-Control-Max-Age: 60');
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Enable this header to allow "Cross Domain AJAX" requests;
|
|
|
|
|
* This works because processmaker is handling correctly requests with method 'OPTIONS'
|
|
|
|
|
* that automatically is sent by a client using XmlHttpRequest or similar.
|
|
|
|
|
*/
|
|
|
|
|
header('Access-Control-Allow-Origin: *');
|
|
|
|
|
|
2014-04-02 17:23:31 -04:00
|
|
|
require_once $this->rootDir . "framework/src/Maveriks/Extension/Restler/UploadFormat.php";
|
|
|
|
|
|
2014-03-10 16:02:09 -04:00
|
|
|
// $servicesDir contains directory where Services Classes are allocated
|
2014-04-02 16:51:28 -04:00
|
|
|
$servicesDir = $this->workflowDir . 'engine' . DS . 'src' . DS . 'ProcessMaker' . DS . 'Services' . DS;
|
2014-03-10 16:02:09 -04:00
|
|
|
// $apiDir - contains directory to scan classes and add them to Restler
|
|
|
|
|
$apiDir = $servicesDir . 'Api' . DS;
|
|
|
|
|
// $apiIniFile - contains file name of api ini configuration
|
|
|
|
|
$apiIniFile = $servicesDir . DS . 'api.ini';
|
|
|
|
|
// $authenticationClass - contains the class name that validate the authentication for Restler
|
2014-04-02 16:51:28 -04:00
|
|
|
$authenticationClass = 'ProcessMaker\\Services\\OAuth2\\Server';
|
2014-03-10 16:02:09 -04:00
|
|
|
// $pmOauthClientId - contains PM Local OAuth Id (Web Designer)
|
|
|
|
|
$pmOauthClientId = 'x-pm-local-client';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Load Api ini file for Rest Service
|
|
|
|
|
*/
|
2014-04-02 18:08:34 -04:00
|
|
|
$config = array();
|
|
|
|
|
|
2014-03-10 16:02:09 -04:00
|
|
|
if (file_exists($apiIniFile)) {
|
2014-04-02 18:08:34 -04:00
|
|
|
$cachedConfig = $this->workspaceCacheDir . "api-config.php";
|
|
|
|
|
|
|
|
|
|
// verify if config cache file exists, is array and the last modification date is the same when cache was created.
|
|
|
|
|
if (! file_exists($cachedConfig) || ! is_array($config = include($cachedConfig)) || $config["_chk"] != filemtime($apiIniFile)) {
|
|
|
|
|
$config = Util\Common::parseIniFile($apiIniFile);
|
|
|
|
|
$config["_chk"] = filemtime($apiIniFile);
|
|
|
|
|
if (! is_dir(dirname($cachedConfig))) {
|
|
|
|
|
Util\Common::mk_dir(dirname($cachedConfig));
|
|
|
|
|
}
|
|
|
|
|
file_put_contents($cachedConfig, "<?php return " . var_export($config, true).";");
|
|
|
|
|
Util\Logger::log("Configuration cache was loaded and cached to: $cachedConfig");
|
|
|
|
|
} else {
|
|
|
|
|
Util\Logger::log("Loading Api Configuration from: $cachedConfig");
|
|
|
|
|
}
|
2014-03-10 16:02:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setting current workspace to Api class
|
2014-04-02 17:23:31 -04:00
|
|
|
Services\Api::setWorkspace(SYS_SYS);
|
2014-04-24 17:39:49 -04:00
|
|
|
$cacheDir = defined("PATH_C")? PATH_C: sys_get_temp_dir();
|
|
|
|
|
|
|
|
|
|
$sysConfig = \System::getSystemConfiguration();
|
|
|
|
|
|
|
|
|
|
\Luracast\Restler\Defaults::$cacheDirectory = $cacheDir;
|
|
|
|
|
$productionMode = (bool) !(isset($sysConfig["service_api_debug"]) && $sysConfig["service_api_debug"]);
|
|
|
|
|
|
|
|
|
|
Util\Logger::log("Serving API mode: " . ($productionMode? "production": "development"));
|
2014-03-10 16:02:09 -04:00
|
|
|
|
|
|
|
|
// create a new Restler instance
|
2014-04-01 11:18:29 -04:00
|
|
|
//$rest = new \Luracast\Restler\Restler();
|
2014-04-24 17:39:49 -04:00
|
|
|
$rest = new \Maveriks\Extension\Restler($productionMode);
|
2014-04-01 16:29:02 -04:00
|
|
|
// setting flag for multipart to Restler
|
|
|
|
|
$rest->setFlagMultipart($multipart);
|
|
|
|
|
$rest->inputExecute = $inputExecute;
|
2014-03-10 16:02:09 -04:00
|
|
|
// setting api version to Restler
|
|
|
|
|
$rest->setAPIVersion($version);
|
|
|
|
|
// adding $authenticationClass to Restler
|
|
|
|
|
$rest->addAuthenticationClass($authenticationClass, '');
|
|
|
|
|
|
|
|
|
|
// Setting database connection source
|
|
|
|
|
list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
|
|
|
|
|
$port = empty($port) ? '' : ";port=$port";
|
2014-04-02 17:23:31 -04:00
|
|
|
Services\OAuth2\Server::setDatabaseSource(DB_USER, DB_PASS, DB_ADAPTER.":host=$host;dbname=".DB_NAME.$port);
|
2014-03-10 16:02:09 -04:00
|
|
|
|
|
|
|
|
// Setting default OAuth Client id, for local PM Web Designer
|
2014-04-02 17:23:31 -04:00
|
|
|
Services\OAuth2\Server::setPmClientId($pmOauthClientId);
|
2014-03-10 16:02:09 -04:00
|
|
|
|
|
|
|
|
$rest->setOverridingFormats('JsonFormat', 'UploadFormat');
|
|
|
|
|
|
|
|
|
|
$isPluginRequest = strpos($uri, '/plugin-') !== false ? true : false;
|
|
|
|
|
|
|
|
|
|
if ($isPluginRequest) {
|
|
|
|
|
$tmp = explode('/', $uri);
|
|
|
|
|
array_shift($tmp);
|
|
|
|
|
$tmp = array_shift($tmp);
|
|
|
|
|
$tmp = explode('-', $tmp);
|
|
|
|
|
$pluginName = $tmp[1];
|
|
|
|
|
$uri = str_replace('/plugin-'.$pluginName, '', $uri);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-02 17:23:31 -04:00
|
|
|
// Override $_SERVER['REQUEST_URI'] to Restler handles the modified url
|
2014-03-10 16:02:09 -04:00
|
|
|
$_SERVER['REQUEST_URI'] = $uri;
|
|
|
|
|
|
|
|
|
|
if (! $isPluginRequest) { // if it is not a request for a plugin endpoint
|
|
|
|
|
// scan all api directory to find api classes
|
2014-03-12 18:20:35 -04:00
|
|
|
$classesList = Util\Common::rglob($apiDir . "/*");
|
2014-03-10 16:02:09 -04:00
|
|
|
|
|
|
|
|
foreach ($classesList as $classFile) {
|
|
|
|
|
if (pathinfo($classFile, PATHINFO_EXTENSION) === 'php') {
|
2014-04-02 16:51:28 -04:00
|
|
|
$namespace = '\\ProcessMaker\\Services\\' . str_replace(
|
2014-04-02 17:23:31 -04:00
|
|
|
DIRECTORY_SEPARATOR,
|
|
|
|
|
'\\',
|
|
|
|
|
str_replace('.php', '', str_replace($servicesDir, '', $classFile))
|
|
|
|
|
);
|
2014-03-10 16:02:09 -04:00
|
|
|
$rest->addAPIClass($namespace);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// adding aliases for Restler
|
2014-04-02 18:08:34 -04:00
|
|
|
if (array_key_exists('alias', $config)) {
|
|
|
|
|
foreach ($config['alias'] as $alias => $aliasData) {
|
2014-03-10 16:02:09 -04:00
|
|
|
if (is_array($aliasData)) {
|
|
|
|
|
foreach ($aliasData as $label => $namespace) {
|
|
|
|
|
$namespace = '\\' . ltrim($namespace, '\\');
|
|
|
|
|
$rest->addAPIClass($namespace, $alias);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// hook to get rest api classes from plugins
|
|
|
|
|
// if (class_exists('PMPluginRegistry')) {
|
|
|
|
|
// $pluginRegistry = & PMPluginRegistry::getSingleton();
|
|
|
|
|
// $plugins = $pluginRegistry->getRegisteredRestServices();
|
|
|
|
|
//
|
|
|
|
|
// if (is_array($plugins) && array_key_exists($pluginName, $plugins)) {
|
|
|
|
|
// foreach ($plugins[$pluginName] as $class) {
|
|
|
|
|
// $rest->addAPIClass($class['namespace']);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rest->handle();
|
2014-04-24 17:39:49 -04:00
|
|
|
|
2014-04-01 16:29:02 -04:00
|
|
|
if ($rest->flagMultipart === true) {
|
|
|
|
|
return $rest->responseMultipart;
|
|
|
|
|
}
|
2014-03-10 16:02:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function parseApiRequestUri()
|
|
|
|
|
{
|
|
|
|
|
$url = explode("/", $this->requestUri);
|
|
|
|
|
array_shift($url);
|
|
|
|
|
array_shift($url);
|
|
|
|
|
$version = array_shift($url);
|
|
|
|
|
$workspace = array_shift($url);
|
|
|
|
|
$restUri = "";
|
|
|
|
|
|
|
|
|
|
foreach ($url as $urlPart) {
|
|
|
|
|
$restUri .= "/" . $urlPart;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return array(
|
|
|
|
|
"uri" => $restUri,
|
|
|
|
|
"version" => $version,
|
|
|
|
|
"workspace" => $workspace
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-17 11:54:09 -04:00
|
|
|
public function loadEnvironment($workspace = "")
|
2014-03-10 16:02:09 -04:00
|
|
|
{
|
|
|
|
|
$lang = "en";
|
|
|
|
|
|
2014-03-14 15:53:41 -04:00
|
|
|
define("SYS_LANG", $lang);
|
|
|
|
|
define("PATH_SEP", DIRECTORY_SEPARATOR);
|
|
|
|
|
|
|
|
|
|
define("PATH_TRUNK", $this->rootDir . PATH_SEP);
|
|
|
|
|
define("PATH_OUTTRUNK", realpath($this->rootDir . "/../") . PATH_SEP);
|
|
|
|
|
define("PATH_HOME", $this->rootDir . PATH_SEP . "workflow" . PATH_SEP);
|
|
|
|
|
|
|
|
|
|
define("PATH_HTML", PATH_HOME . "public_html" . PATH_SEP);
|
|
|
|
|
define("PATH_RBAC_HOME", PATH_TRUNK . "rbac" . PATH_SEP);
|
|
|
|
|
define("PATH_GULLIVER_HOME", PATH_TRUNK . "gulliver" . PATH_SEP);
|
|
|
|
|
define("PATH_GULLIVER", PATH_GULLIVER_HOME . "system" . PATH_SEP); //gulliver system classes
|
|
|
|
|
define("PATH_GULLIVER_BIN", PATH_GULLIVER_HOME . "bin" . PATH_SEP); //gulliver bin classes
|
|
|
|
|
define("PATH_TEMPLATE", PATH_GULLIVER_HOME . "templates" . PATH_SEP);
|
|
|
|
|
define("PATH_THIRDPARTY", PATH_GULLIVER_HOME . "thirdparty" . PATH_SEP);
|
|
|
|
|
define("PATH_RBAC", PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP); //to enable rbac version 2
|
|
|
|
|
define("PATH_RBAC_CORE", PATH_RBAC_HOME . "engine" . PATH_SEP);
|
|
|
|
|
define("PATH_CORE", PATH_HOME . "engine" . PATH_SEP);
|
|
|
|
|
define("PATH_CLASSES", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP);
|
|
|
|
|
define("PATH_SKINS", PATH_CORE . "skins" . PATH_SEP);
|
|
|
|
|
define("PATH_SKIN_ENGINE", PATH_CORE . "skinEngine" . PATH_SEP);
|
|
|
|
|
define("PATH_METHODS", PATH_CORE . "methods" . PATH_SEP);
|
|
|
|
|
define("PATH_XMLFORM", PATH_CORE . "xmlform" . PATH_SEP);
|
|
|
|
|
define("PATH_CONFIG", PATH_CORE . "config" . PATH_SEP);
|
|
|
|
|
define("PATH_PLUGINS", PATH_CORE . "plugins" . PATH_SEP);
|
|
|
|
|
define("PATH_HTMLMAIL", PATH_CORE . "html_templates" . PATH_SEP);
|
|
|
|
|
define("PATH_TPL", PATH_CORE . "templates" . PATH_SEP);
|
|
|
|
|
define("PATH_TEST", PATH_CORE . "test" . PATH_SEP);
|
|
|
|
|
define("PATH_FIXTURES", PATH_TEST . "fixtures" . PATH_SEP);
|
|
|
|
|
define("PATH_RTFDOCS", PATH_CORE . "rtf_templates" . PATH_SEP);
|
|
|
|
|
define("PATH_DYNACONT", PATH_CORE . "content" . PATH_SEP . "dynaform" . PATH_SEP);
|
|
|
|
|
define("SYS_UPLOAD_PATH", PATH_HOME . "public_html/files/" );
|
|
|
|
|
define("PATH_UPLOAD", PATH_HTML . "files" . PATH_SEP);
|
|
|
|
|
define("PATH_WORKFLOW_MYSQL_DATA", PATH_CORE . "data" . PATH_SEP . "mysql" . PATH_SEP);
|
|
|
|
|
define("PATH_RBAC_MYSQL_DATA", PATH_RBAC_CORE . "data" . PATH_SEP . "mysql" . PATH_SEP);
|
|
|
|
|
define("FILE_PATHS_INSTALLED", PATH_CORE . "config" . PATH_SEP . "paths_installed.php");
|
|
|
|
|
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);
|
2014-03-10 16:02:09 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
\Bootstrap::registerSystemClasses();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$config = \System::getSystemConfiguration();
|
|
|
|
|
|
2014-03-13 12:57:01 -04:00
|
|
|
// Do not change any of these settings directly, use env.ini instead
|
2014-03-14 15:53:41 -04:00
|
|
|
ini_set( "display_errors", $config["display_errors"]);
|
|
|
|
|
ini_set( "error_reporting", $config["error_reporting"]);
|
|
|
|
|
ini_set( "short_open_tag", "On" ); // ??
|
|
|
|
|
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"]);
|
|
|
|
|
define("MEMCACHED_ENABLED", $config["memcached"]);
|
|
|
|
|
define("MEMCACHED_SERVER", $config["memcached_server"]);
|
|
|
|
|
define("TIME_ZONE", $config["time_zone"]);
|
|
|
|
|
define("SYS_SKIN", $config["default_skin"]);
|
2014-03-10 16:02:09 -04:00
|
|
|
|
|
|
|
|
// set include path
|
|
|
|
|
set_include_path(
|
|
|
|
|
PATH_CORE . PATH_SEPARATOR .
|
|
|
|
|
PATH_THIRDPARTY . PATH_SEPARATOR .
|
2014-03-14 15:53:41 -04:00
|
|
|
PATH_THIRDPARTY . "pear" . PATH_SEPARATOR .
|
2014-03-10 16:02:09 -04:00
|
|
|
PATH_RBAC_CORE . PATH_SEPARATOR .
|
|
|
|
|
get_include_path()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Setting Up Workspace
|
|
|
|
|
*/
|
|
|
|
|
|
2014-03-14 15:33:34 -04:00
|
|
|
if (! file_exists( FILE_PATHS_INSTALLED )) {
|
|
|
|
|
throw new \Exception("Can't locate system file: " . FILE_PATHS_INSTALLED);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-10 16:02:09 -04:00
|
|
|
// include the server installed configuration
|
2014-03-14 15:53:41 -04:00
|
|
|
require_once PATH_CORE . "config" . PATH_SEP . "paths_installed.php";
|
2014-03-14 15:33:34 -04:00
|
|
|
|
|
|
|
|
// defining system constant when a valid server environment exists
|
2014-03-14 15:53:41 -04:00
|
|
|
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);
|
2014-03-10 16:02:09 -04:00
|
|
|
|
2014-03-17 11:54:09 -04:00
|
|
|
if (empty($workspace)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 15:53:41 -04:00
|
|
|
define("SYS_SYS", $workspace);
|
2014-03-10 16:02:09 -04:00
|
|
|
|
2014-03-14 15:53:41 -04:00
|
|
|
if (! file_exists( PATH_DB . SYS_SYS . "/db.php" )) {
|
|
|
|
|
throw new \Exception(\G::loadTranslation("ID_NOT_WORKSPACE"));
|
2014-03-14 15:33:34 -04:00
|
|
|
}
|
2014-03-14 15:53:41 -04:00
|
|
|
require_once (PATH_DB . SYS_SYS . "/db.php");
|
2014-03-14 15:33:34 -04:00
|
|
|
|
|
|
|
|
// defining constant for workspace shared directory
|
2014-04-02 18:08:34 -04:00
|
|
|
$this->workspaceDir = PATH_DB . SYS_SYS . PATH_SEP;
|
|
|
|
|
$this->workspaceCacheDir = PATH_DB . SYS_SYS . PATH_SEP . "cache" . PATH_SEP;
|
|
|
|
|
|
|
|
|
|
define("PATH_WORKSPACE", $this->workspaceDir);
|
2014-03-14 15:33:34 -04:00
|
|
|
// including workspace shared classes -> particularlly for pmTables
|
2014-03-10 16:02:09 -04:00
|
|
|
|
2014-03-14 15:33:34 -04:00
|
|
|
set_include_path(get_include_path() . PATH_SEPARATOR . PATH_WORKSPACE);
|
2014-03-10 16:02:09 -04:00
|
|
|
|
|
|
|
|
// smarty constants
|
2014-03-20 13:15:12 -04:00
|
|
|
define( "PATH_SMARTY_C", PATH_C . "smarty" . PATH_SEP . "c" );
|
|
|
|
|
define( "PATH_SMARTY_CACHE", PATH_C . "smarty" . PATH_SEP . "cache" );
|
2014-03-14 15:53:41 -04:00
|
|
|
|
|
|
|
|
define("PATH_DATA_SITE", PATH_DATA . "sites/" . SYS_SYS . "/");
|
|
|
|
|
define("PATH_DOCUMENT", PATH_DATA_SITE . "files/");
|
|
|
|
|
define("PATH_DATA_MAILTEMPLATES", PATH_DATA_SITE . "mailTemplates/");
|
|
|
|
|
define("PATH_DATA_PUBLIC", PATH_DATA_SITE . "public/");
|
|
|
|
|
define("PATH_DATA_REPORTS", PATH_DATA_SITE . "reports/");
|
|
|
|
|
define("PATH_DYNAFORM", PATH_DATA_SITE . "xmlForms/");
|
|
|
|
|
define("PATH_IMAGES_ENVIRONMENT_FILES", PATH_DATA_SITE . "usersFiles" . PATH_SEP);
|
|
|
|
|
define("PATH_IMAGES_ENVIRONMENT_USERS", PATH_DATA_SITE . "usersPhotographies" . PATH_SEP);
|
|
|
|
|
|
|
|
|
|
if (is_file(PATH_DATA_SITE.PATH_SEP . ".server_info")) {
|
|
|
|
|
$SERVER_INFO = file_get_contents(PATH_DATA_SITE.PATH_SEP.".server_info");
|
2014-03-10 16:02:09 -04:00
|
|
|
$SERVER_INFO = unserialize($SERVER_INFO);
|
|
|
|
|
|
2014-03-14 15:53:41 -04:00
|
|
|
define("SERVER_NAME", $SERVER_INFO ["SERVER_NAME"]);
|
|
|
|
|
define("SERVER_PORT", $SERVER_INFO ["SERVER_PORT"]);
|
2014-03-10 16:02:09 -04:00
|
|
|
} else {
|
|
|
|
|
echo "WARNING! No server info found!";
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-20 13:15:12 -04:00
|
|
|
/**
|
|
|
|
|
* Global definitions, before it was the defines.php file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// URL Key
|
|
|
|
|
define( "URL_KEY", 'c0l0s40pt1mu59r1m3' );
|
|
|
|
|
|
|
|
|
|
// Other definitions
|
|
|
|
|
define( 'TIMEOUT_RESPONSE', 100 ); //web service timeout
|
|
|
|
|
define( 'APPLICATION_CODE', 'ProcessMaker' ); //to login like workflow system
|
|
|
|
|
define( 'MAIN_POFILE', 'processmaker' );
|
|
|
|
|
define( 'PO_SYSTEM_VERSION', 'PM 4.0.1' );
|
|
|
|
|
|
|
|
|
|
// Environment definitions
|
|
|
|
|
define( 'G_PRO_ENV', 'PRODUCTION' );
|
|
|
|
|
define( 'G_DEV_ENV', 'DEVELOPMENT' );
|
|
|
|
|
define( 'G_TEST_ENV', 'TEST' );
|
|
|
|
|
|
|
|
|
|
// Number of files per folder at PATH_UPLOAD (cases documents)
|
|
|
|
|
define( 'APPLICATION_DOCUMENTS_PER_FOLDER', 1000 );
|
|
|
|
|
|
|
|
|
|
// 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' );
|
|
|
|
|
define( 'PML_DOWNLOAD_URL', PML_SERVER . '/syspmLibrary/en/green/services/download' );
|
|
|
|
|
|
2014-03-10 16:02:09 -04:00
|
|
|
// create memcached singleton
|
2014-03-14 15:53:41 -04:00
|
|
|
//\Bootstrap::LoadClass("memcached");
|
2014-03-10 16:02:09 -04:00
|
|
|
//$memcache = PMmemcached::getSingleton( SYS_SYS );
|
|
|
|
|
|
|
|
|
|
\Propel::init(PATH_CONFIG . "databases.php");
|
2014-03-17 11:54:09 -04:00
|
|
|
|
2014-03-18 11:03:40 -04:00
|
|
|
\Bootstrap::LoadTranslationObject(defined( 'SYS_LANG' ) ? SYS_LANG : "en");
|
|
|
|
|
|
2014-03-17 11:54:09 -04:00
|
|
|
return true;
|
2014-03-10 16:02:09 -04:00
|
|
|
}
|
|
|
|
|
}
|