Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
@@ -68,87 +68,12 @@ class Bootstrap
|
||||
|
||||
public static function getSystemConfiguration($globalIniFile = '', $wsIniFile = '', $wsName = '')
|
||||
{
|
||||
$readGlobalIniFile = false;
|
||||
$readWsIniFile = false;
|
||||
|
||||
if (empty($globalIniFile)) {
|
||||
$globalIniFile = PATH_CORE . 'config' . PATH_SEP . 'env.ini';
|
||||
// (!) Backward compatibility, the original function is in System class
|
||||
if (! class_exists("System")) {
|
||||
require_once PATH_CORE . "classes" . PATH_SEP . "class.system.php";
|
||||
}
|
||||
|
||||
if (empty($wsIniFile)) {
|
||||
if (defined('PATH_DB')) {
|
||||
// if we're on a valid workspace env.
|
||||
if (empty($wsName)) {
|
||||
$uriParts = explode('/', getenv("REQUEST_URI"));
|
||||
if (isset($uriParts[1])) {
|
||||
if (substr($uriParts[1], 0, 3) == 'sys') {
|
||||
$wsName = substr($uriParts[1], 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
$wsIniFile = PATH_DB . $wsName . PATH_SEP . 'env.ini';
|
||||
}
|
||||
}
|
||||
|
||||
$readGlobalIniFile = file_exists($globalIniFile) ? true : false;
|
||||
$readWsIniFile = file_exists($wsIniFile) ? true : false;
|
||||
|
||||
if (isset($_SESSION['PROCESSMAKER_ENV'])) {
|
||||
$md5 = array();
|
||||
|
||||
if ($readGlobalIniFile) {
|
||||
$md5[] = md5_file($globalIniFile);
|
||||
}
|
||||
if ($readWsIniFile) {
|
||||
$md5[] = md5_file($wsIniFile);
|
||||
}
|
||||
$hash = implode('-', $md5);
|
||||
|
||||
if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) {
|
||||
$_SESSION['PROCESSMAKER_ENV']['from_cache'] = 1;
|
||||
return $_SESSION['PROCESSMAKER_ENV'];
|
||||
}
|
||||
}
|
||||
|
||||
// default configuration
|
||||
$error_reporting_default = defined('E_DEPRECATED') ? E_ALL & ~E_DEPRECATED : E_ALL;
|
||||
$error_reporting_default = defined('E_STRICT') ? $error_reporting_default & ~E_STRICT : $error_reporting_default;
|
||||
|
||||
$config = array('debug' => 0, 'debug_sql' => 0, 'debug_time' => 0, 'debug_calendar' => 0, 'wsdl_cache' => 1, 'memory_limit' => "256M",
|
||||
'time_zone' => 'America/New_York', 'memcached' => 0, 'memcached_server' => '', 'default_skin' => 'neoclassic', 'default_lang' => 'en',
|
||||
'proxy_host' => '', 'proxy_port' => '', 'proxy_user' => '', 'proxy_pass' => '' , 'size_log_file' => 5000000 , 'number_log_file' => 5,
|
||||
'ie_cookie_lifetime' => 1, 'error_reporting' => $error_reporting_default, 'display_errors' => 'On');
|
||||
|
||||
// read the global env.ini configuration file
|
||||
if ($readGlobalIniFile && ($globalConf = @parse_ini_file($globalIniFile)) !== false) {
|
||||
$config = array_merge($config, $globalConf);
|
||||
}
|
||||
|
||||
// Workspace environment configuration
|
||||
if ($readWsIniFile && ($wsConf = @parse_ini_file($wsIniFile)) !== false) {
|
||||
$config = array_merge($config, $wsConf);
|
||||
}
|
||||
|
||||
// validation debug config, only binary value is valid; debug = 1, to enable
|
||||
$config['debug'] = $config['debug'] == 1 ? 1 : 0;
|
||||
|
||||
if ($config['proxy_pass'] != '') {
|
||||
$config['proxy_pass'] = G::decrypt($config['proxy_pass'], 'proxy_pass');
|
||||
}
|
||||
|
||||
$md5 = array();
|
||||
if ($readGlobalIniFile) {
|
||||
$md5[] = md5_file($globalIniFile);
|
||||
}
|
||||
if ($readWsIniFile) {
|
||||
$md5[] = md5_file($wsIniFile);
|
||||
}
|
||||
$hash = implode('-', $md5);
|
||||
|
||||
$_SESSION['PROCESSMAKER_ENV'] = $config;
|
||||
$_SESSION['PROCESSMAKER_ENV_HASH'] = $hash;
|
||||
|
||||
return $config;
|
||||
return System::getSystemConfiguration($globalIniFile, $wsIniFile, $wsName);
|
||||
}
|
||||
|
||||
public static function registerSystemClasses()
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Core;
|
||||
|
||||
class ClassLoader
|
||||
{
|
||||
private static $includePath;
|
||||
protected static $instance;
|
||||
|
||||
/**
|
||||
* Creates a new <tt>SplClassLoader</tt> that loads classes of the
|
||||
* specified namespace.
|
||||
*
|
||||
* @param string $ns The namespace to use.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
defined("DS") || define("DS", DIRECTORY_SEPARATOR);
|
||||
defined("NS") || define("NS", "\\");
|
||||
|
||||
spl_autoload_register(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ProcessMaker\Core\ClassLoader
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(self::$instance)) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base include path for all class files in the namespace of this class loader.
|
||||
*
|
||||
* @return string $includePath
|
||||
*/
|
||||
public function getIncludePaths()
|
||||
{
|
||||
return self::$includePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls this class loader from the SPL autoloader stack.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
public function add($namespace, $sourceDir)
|
||||
{
|
||||
if (empty($namespace)) {
|
||||
self::$includePath[] = $sourceDir . (substr($sourceDir, -1) == DS ? "" : DS);
|
||||
} else {
|
||||
self::$includePath[$namespace] = $sourceDir . (substr($sourceDir, -1) == DS ? "" : DS);
|
||||
}
|
||||
}
|
||||
|
||||
function loadClass($className)
|
||||
{
|
||||
var_dump(self::$includePath); die;
|
||||
$className = ltrim($className, NS);
|
||||
|
||||
foreach (self::$includePath as $path) {
|
||||
if ($lastPos = strrpos($className, NS)) {
|
||||
$namespace = substr($className, 0, $lastPos);
|
||||
var_dump($namespace);
|
||||
$className = substr($className, $lastPos + 1);
|
||||
$subpath = str_replace(NS, DS, $namespace) . DS;
|
||||
}
|
||||
|
||||
|
||||
$filename = $path . $subpath . $className . ".php";
|
||||
var_dump($filename);
|
||||
|
||||
if (file_exists($filename)) {
|
||||
require $filename . ".php";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $className The name of the class to load.
|
||||
* @return void
|
||||
*/
|
||||
public function loadClass2($className)
|
||||
{
|
||||
if (null === $this->_namespace || $this->_namespace.$this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace.$this->_namespaceSeparator))) {
|
||||
$fileName = '';
|
||||
$namespace = '';
|
||||
|
||||
if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
|
||||
$namespace = substr($className, 0, $lastNsPos);
|
||||
$className = substr($className, $lastNsPos + 1);
|
||||
$fileName = str_replace($this->_namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->_fileExtension;
|
||||
|
||||
require ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Util;
|
||||
|
||||
/**
|
||||
* Singleton Class Logger
|
||||
*
|
||||
* This Utility is useful to log local messages
|
||||
* @package ProcessMaker\Util
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class Logger
|
||||
{
|
||||
private static $instance;
|
||||
private $logFile;
|
||||
private $fp;
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
$this->logFile = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'processmaker.log';
|
||||
if (! file_exists($this->logFile)) {
|
||||
if (! touch($this->logFile)) {
|
||||
error_log("ProcessMaker Log file can't be created!");
|
||||
}
|
||||
chmod($this->logFile, 0777);
|
||||
}
|
||||
|
||||
$this->fp = fopen($this->logFile, "a+");
|
||||
}
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(self::$instance)) {
|
||||
self::$instance = new Logger();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function setLogLine()
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
$this->setLog(date('Y-m-d H:i:s') . " ");
|
||||
|
||||
foreach ($args as $str) {
|
||||
$this->setLog((is_string($str) ? $str : var_export($str, true)) . PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
public function setLogInline()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$this->setLog(date('Y-m-d H:i:s') . " ");
|
||||
|
||||
foreach ($args as $str) {
|
||||
$this->setLog((is_string($str) ? $str : var_export($str, true)) . " ");
|
||||
}
|
||||
}
|
||||
|
||||
public function setLog($str)
|
||||
{
|
||||
fwrite($this->fp, $str);
|
||||
}
|
||||
|
||||
public static function log()
|
||||
{
|
||||
$me = Logger::getInstance();
|
||||
$args = func_get_args();
|
||||
|
||||
call_user_func_array(array($me, 'setLogLine'), $args);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -66,7 +66,10 @@ class System
|
||||
'proxy_user' => '',
|
||||
'proxy_pass' => '',
|
||||
'size_log_file' => 5000000,
|
||||
'number_log_file' => 5
|
||||
'number_log_file' => 5,
|
||||
'ie_cookie_lifetime' => 1,
|
||||
'error_reporting' => "",
|
||||
'display_errors' => 'On'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1088,7 +1091,13 @@ class System
|
||||
}
|
||||
}
|
||||
|
||||
// default configuration
|
||||
// default configuration for "error_reporting" conf
|
||||
if (empty(self::$defaultConfig["error_reporting"])) {
|
||||
$errorReportingDefault = defined('E_DEPRECATED') ? E_ALL & ~E_DEPRECATED : E_ALL;
|
||||
$errorReportingDefault = defined('E_STRICT') ? $errorReportingDefault & ~E_STRICT : $errorReportingDefault;
|
||||
self::$defaultConfig["error_reporting"] = $errorReportingDefault;
|
||||
}
|
||||
|
||||
$config = self::$defaultConfig;
|
||||
|
||||
// read the global env.ini configuration file
|
||||
|
||||
Reference in New Issue
Block a user