CODE STYLE class.pmScript.php
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* class.pmScript.php
|
* class.pmScript.php
|
||||||
|
*
|
||||||
* @package workflow.engine.ProcessMaker
|
* @package workflow.engine.ProcessMaker
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
@@ -32,58 +33,61 @@
|
|||||||
// License: LGPL, see LICENSE
|
// License: LGPL, see LICENSE
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PMScript - PMScript class
|
* PMScript - PMScript class
|
||||||
|
*
|
||||||
* @author Julio Cesar Laura Avenda<64>o <juliocesar@colosa.com>
|
* @author Julio Cesar Laura Avenda<64>o <juliocesar@colosa.com>
|
||||||
* last modify 2008.08.13 by Erik Amaru Ortiz <erik@colosa.com>
|
* last modify 2008.08.13 by Erik Amaru Ortiz <erik@colosa.com>
|
||||||
* last modify comment was added and adapted the catch errors
|
* last modify comment was added and adapted the catch errors
|
||||||
* @copyright 2007 COLOSA
|
* @copyright 2007 COLOSA
|
||||||
*/
|
*/
|
||||||
function __autoload($sClassName)
|
function __autoload ($sClassName)
|
||||||
{
|
{
|
||||||
if (defined('SYS_SYS')) {
|
if (defined( 'SYS_SYS' )) {
|
||||||
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||||
if (file_exists($sPath . $sClassName . '.php')) {
|
if (file_exists( $sPath . $sClassName . '.php' )) {
|
||||||
require_once $sPath . $sClassName . '.php';
|
require_once $sPath . $sClassName . '.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Start - Custom functions
|
//Start - Custom functions
|
||||||
G::LoadClass('pmFunctions');
|
G::LoadClass( 'pmFunctions' );
|
||||||
//End - Custom functions
|
//End - Custom functions
|
||||||
//call plugin
|
//call plugin
|
||||||
if (class_exists('folderData')) {
|
if (class_exists( 'folderData' )) {
|
||||||
//$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $Fields['APP_TITLE'], $sUsrUid);
|
//$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $Fields['APP_TITLE'], $sUsrUid);
|
||||||
$oPluginRegistry = &PMPluginRegistry::getSingleton();
|
$oPluginRegistry = &PMPluginRegistry::getSingleton();
|
||||||
$aAvailablePmFunctions = $oPluginRegistry->getPmFunctions();
|
$aAvailablePmFunctions = $oPluginRegistry->getPmFunctions();
|
||||||
foreach ($aAvailablePmFunctions as $key => $class) {
|
foreach ($aAvailablePmFunctions as $key => $class) {
|
||||||
$filePlugin = PATH_PLUGINS . $class . PATH_SEP . 'classes' . PATH_SEP . 'class.pmFunctions.php';
|
$filePlugin = PATH_PLUGINS . $class . PATH_SEP . 'classes' . PATH_SEP . 'class.pmFunctions.php';
|
||||||
if (file_exists($filePlugin)) {
|
if (file_exists( $filePlugin )) {
|
||||||
include_once( $filePlugin);
|
include_once ($filePlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//end plugin
|
//end plugin
|
||||||
//Add External Triggers
|
//Add External Triggers
|
||||||
$dir = G::ExpandPath("classes") . 'triggers';
|
$dir = G::ExpandPath( "classes" ) . 'triggers';
|
||||||
$filesArray = array();
|
$filesArray = array ();
|
||||||
if (file_exists($dir)) {
|
if (file_exists( $dir )) {
|
||||||
if ($handle = opendir($dir)) {
|
if ($handle = opendir( $dir )) {
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir( $handle ))) {
|
||||||
if (($file != ".") && ($file != "..")) {
|
if (($file != ".") && ($file != "..")) {
|
||||||
$extFile = explode(".", $file);
|
$extFile = explode( ".", $file );
|
||||||
if ($extFile[sizeof($extFile) - 1] == 'php') {
|
if ($extFile[sizeof( $extFile ) - 1] == 'php') {
|
||||||
include_once( $dir . PATH_SEP . $file);
|
include_once ($dir . PATH_SEP . $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir( $handle );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PMScript - PMScript class
|
* PMScript - PMScript class
|
||||||
|
*
|
||||||
* @copyright 2007 COLOSA
|
* @copyright 2007 COLOSA
|
||||||
* @package workflow.engine.ProcessMaker
|
* @package workflow.engine.ProcessMaker
|
||||||
*/
|
*/
|
||||||
@@ -93,12 +97,12 @@ class PMScript
|
|||||||
/**
|
/**
|
||||||
* Original fields
|
* Original fields
|
||||||
*/
|
*/
|
||||||
public $aOriginalFields = array();
|
public $aOriginalFields = array ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields to use
|
* Fields to use
|
||||||
*/
|
*/
|
||||||
public $aFields = array();
|
public $aFields = array ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Script
|
* Script
|
||||||
@@ -117,224 +121,185 @@ class PMScript
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of the class PMScript
|
* Constructor of the class PMScript
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function PMScript()
|
public function PMScript ()
|
||||||
{
|
{
|
||||||
$this->aFields['__ERROR__'] = 'none';
|
$this->aFields['__ERROR__'] = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the fields to use
|
* Set the fields to use
|
||||||
|
*
|
||||||
* @param array $aFields
|
* @param array $aFields
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setFields($aFields=array())
|
public function setFields ($aFields = array())
|
||||||
{
|
{
|
||||||
if (!is_array($aFields)) {
|
if (! is_array( $aFields )) {
|
||||||
$aFields = array();
|
$aFields = array ();
|
||||||
}
|
}
|
||||||
$this->aOriginalFields = $this->aFields = $aFields;
|
$this->aOriginalFields = $this->aFields = $aFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the current script
|
* Set the current script
|
||||||
|
*
|
||||||
* @param string $sScript
|
* @param string $sScript
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setScript($sScript='')
|
public function setScript ($sScript = '')
|
||||||
{
|
{
|
||||||
$this->sScript = $sScript;
|
$this->sScript = $sScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify the syntax
|
* Verify the syntax
|
||||||
|
*
|
||||||
* @param string $sScript
|
* @param string $sScript
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function validSyntax($sScript)
|
public function validSyntax ($sScript)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function executeAndCatchErrors($sScript, $sCode)
|
public function executeAndCatchErrors ($sScript, $sCode)
|
||||||
{
|
{
|
||||||
ob_start('handleFatalErrors');
|
ob_start( 'handleFatalErrors' );
|
||||||
set_error_handler('handleErrors');
|
set_error_handler( 'handleErrors' );
|
||||||
$_SESSION['_CODE_'] = $sCode;
|
$_SESSION['_CODE_'] = $sCode;
|
||||||
eval($sScript);
|
eval( $sScript );
|
||||||
unset($_SESSION['_CODE_']);
|
unset( $_SESSION['_CODE_'] );
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the current script
|
* Execute the current script
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute ()
|
||||||
{
|
{
|
||||||
$sScript = "";
|
$sScript = "";
|
||||||
$iAux = 0;
|
$iAux = 0;
|
||||||
$bEqual = false;
|
$bEqual = false;
|
||||||
$iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]'
|
$iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' . '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
|
||||||
. '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/',
|
|
||||||
$this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
|
||||||
if ($iOcurrences) {
|
if ($iOcurrences) {
|
||||||
for ($i = 0; $i < $iOcurrences; $i++) {
|
for ($i = 0; $i < $iOcurrences; $i ++) {
|
||||||
$sAux = substr($this->sScript, $iAux, $aMatch[0][$i][1] - $iAux);
|
$sAux = substr( $this->sScript, $iAux, $aMatch[0][$i][1] - $iAux );
|
||||||
if (!$bEqual) {
|
if (! $bEqual) {
|
||||||
if (strpos($sAux, '==') !== false) {
|
if (strpos( $sAux, '==' ) !== false) {
|
||||||
$bEqual = false;
|
$bEqual = false;
|
||||||
} else {
|
} else {
|
||||||
if (strpos($sAux, '=') !== false) {
|
if (strpos( $sAux, '=' ) !== false) {
|
||||||
$bEqual = true;
|
$bEqual = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (strpos($sAux, ';') !== false) {
|
if (strpos( $sAux, ';' ) !== false) {
|
||||||
$bEqual = false;
|
$bEqual = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
eval("if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['"
|
eval( "if (!isset(\$this->aFields['" . $aMatch[2][$i][0] . "'])) { \$this->aFields['" . $aMatch[2][$i][0] . "'] = null; }" );
|
||||||
. $aMatch[2][$i][0] . "'] = null; }");
|
|
||||||
} else {
|
} else {
|
||||||
eval( "if (!isset(\$this->aFields"
|
eval( "if (!isset(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")) { \$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . " = null; }" );
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")) { \$this->aFields"
|
|
||||||
. (isset($aMatch[2][$i][0]) ? "['" . $aMatch[2][$i][0]
|
|
||||||
. "']" : '') . $aMatch[5][$i][0] . " = null; }");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sScript .= $sAux;
|
$sScript .= $sAux;
|
||||||
$iAux = $aMatch[0][$i][1] + strlen($aMatch[0][$i][0]);
|
$iAux = $aMatch[0][$i][1] + strlen( $aMatch[0][$i][0] );
|
||||||
switch ($aMatch[1][$i][0]) {
|
switch ($aMatch[1][$i][0]) {
|
||||||
case '@':
|
case '@':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "pmToString(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
$sScript .= "pmToString(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "pmToString(\$this->aFields"
|
$sScript .= "pmToString(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '%':
|
case '%':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "pmToInteger(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
$sScript .= "pmToInteger(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "pmToInteger(\$this->aFields"
|
$sScript .= "pmToInteger(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '#':
|
case '#':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "pmToFloat(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
$sScript .= "pmToFloat(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "pmToFloat(\$this->aFields"
|
$sScript .= "pmToFloat(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "pmToUrl(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
$sScript .= "pmToUrl(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "pmToUrl(\$this->aFields"
|
$sScript .= "pmToUrl(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "pmSqlEscape(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
$sScript .= "pmSqlEscape(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "pmSqlEscape(\$this->aFields"
|
$sScript .= "pmSqlEscape(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '=':
|
case '=':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -342,17 +307,12 @@ class PMScript
|
|||||||
$this->affected_fields[] = $aMatch[2][$i][0];
|
$this->affected_fields[] = $aMatch[2][$i][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sScript .= substr($this->sScript, $iAux);
|
$sScript .= substr( $this->sScript, $iAux );
|
||||||
$sScript = "try {\n" . $sScript . "\n} catch (Exception \$oException) {\n "
|
$sScript = "try {\n" . $sScript . "\n} catch (Exception \$oException) {\n " . " \$this->aFields['__ERROR__'] = utf8_encode(\$oException->getMessage());\n}";
|
||||||
. " \$this->aFields['__ERROR__'] = utf8_encode(\$oException->getMessage());\n}";
|
|
||||||
//echo '<pre>-->'; print_r($this->aFields); echo '<---</pre>';
|
//echo '<pre>-->'; print_r($this->aFields); echo '<---</pre>';
|
||||||
$this->executeAndCatchErrors($sScript, $this->sScript);
|
$this->executeAndCatchErrors( $sScript, $this->sScript );
|
||||||
for ($i = 0; $i < count($this->affected_fields); $i++) {
|
for ($i = 0; $i < count( $this->affected_fields ); $i ++) {
|
||||||
$_SESSION['TRIGGER_DEBUG']['DATA'][] = Array(
|
$_SESSION['TRIGGER_DEBUG']['DATA'][] = Array ('key' => $this->affected_fields[$i],'value' => isset( $this->aFields[$this->affected_fields[$i]] ) ? $this->aFields[$this->affected_fields[$i]] : ''
|
||||||
'key' => $this->affected_fields[$i],
|
|
||||||
'value' => isset($this->aFields[$this->affected_fields[$i]])
|
|
||||||
? $this->aFields[$this->affected_fields[$i]]
|
|
||||||
: ''
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
//echo '<pre>-->'; print_r($_SESSION['TRIGGER_DEBUG']['DATA']); echo '<---</pre>';
|
//echo '<pre>-->'; print_r($_SESSION['TRIGGER_DEBUG']['DATA']); echo '<---</pre>';
|
||||||
@@ -360,178 +320,141 @@ class PMScript
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluate the current script
|
* Evaluate the current script
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function evaluate()
|
public function evaluate ()
|
||||||
{
|
{
|
||||||
$bResult = null;
|
$bResult = null;
|
||||||
$sScript = '';
|
$sScript = '';
|
||||||
$iAux = 0;
|
$iAux = 0;
|
||||||
$bEqual = false;
|
$bEqual = false;
|
||||||
$variableIsDefined = true;
|
$variableIsDefined = true;
|
||||||
$iOcurrences = preg_match_all('/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]'
|
$iOcurrences = preg_match_all( '/\@(?:([\@\%\#\?\$\=])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]' . '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE );
|
||||||
. '*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/',
|
|
||||||
$this->sScript, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
|
||||||
if ($iOcurrences) {
|
if ($iOcurrences) {
|
||||||
for ($i = 0; $i < $iOcurrences; $i++) {
|
for ($i = 0; $i < $iOcurrences; $i ++) {
|
||||||
// if the variables for that condition has not been previously defined then $variableIsDefined
|
// if the variables for that condition has not been previously defined then $variableIsDefined
|
||||||
// is set to false
|
// is set to false
|
||||||
if (!isset($this->aFields[$aMatch[2][$i][0]])) {
|
if (! isset( $this->aFields[$aMatch[2][$i][0]] )) {
|
||||||
// $variableIsDefined = false;
|
// $variableIsDefined = false;
|
||||||
$this->aFields[$aMatch[2][$i][0]] = '';
|
$this->aFields[$aMatch[2][$i][0]] = '';
|
||||||
}
|
}
|
||||||
$sAux = substr($this->sScript, $iAux, $aMatch[0][$i][1] - $iAux);
|
$sAux = substr( $this->sScript, $iAux, $aMatch[0][$i][1] - $iAux );
|
||||||
if (!$bEqual) {
|
if (! $bEqual) {
|
||||||
if (strpos($sAux, '=') !== false) {
|
if (strpos( $sAux, '=' ) !== false) {
|
||||||
$bEqual = true;
|
$bEqual = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (strpos($sAux, ';') !== false) {
|
if (strpos( $sAux, ';' ) !== false) {
|
||||||
$bEqual = false;
|
$bEqual = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sScript .= $sAux;
|
$sScript .= $sAux;
|
||||||
$iAux = $aMatch[0][$i][1] + strlen($aMatch[0][$i][0]);
|
$iAux = $aMatch[0][$i][1] + strlen( $aMatch[0][$i][0] );
|
||||||
switch ($aMatch[1][$i][0]) {
|
switch ($aMatch[1][$i][0]) {
|
||||||
case '@':
|
case '@':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "pmToString(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
$sScript .= "pmToString(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "pmToString(\$this->aFields"
|
$sScript .= "pmToString(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '%':
|
case '%':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "pmToInteger(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
$sScript .= "pmToInteger(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "pmToInteger(\$this->aFields"
|
$sScript .= "pmToInteger(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '#':
|
case '#':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "pmToFloat(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
$sScript .= "pmToFloat(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "pmToFloat(\$this->aFields"
|
$sScript .= "pmToFloat(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "pmToUrl(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
$sScript .= "pmToUrl(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "pmToUrl(\$this->aFields"
|
$sScript .= "pmToUrl(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '$':
|
case '$':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "pmSqlEscape(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
$sScript .= "pmSqlEscape(\$this->aFields['" . $aMatch[2][$i][0] . "'])";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "pmSqlEscape(\$this->aFields"
|
$sScript .= "pmSqlEscape(\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0] . ")";
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0] . ")";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '=':
|
case '=':
|
||||||
if ($bEqual) {
|
if ($bEqual) {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($aMatch[5][$i][0])) {
|
if (! isset( $aMatch[5][$i][0] )) {
|
||||||
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
$sScript .= "\$this->aFields['" . $aMatch[2][$i][0] . "']";
|
||||||
} else {
|
} else {
|
||||||
$sScript .= "\$this->aFields"
|
$sScript .= "\$this->aFields" . (isset( $aMatch[2][$i][0] ) ? "['" . $aMatch[2][$i][0] . "']" : '') . $aMatch[5][$i][0];
|
||||||
. (isset($aMatch[2][$i][0])
|
|
||||||
? "['" . $aMatch[2][$i][0] . "']"
|
|
||||||
: '') . $aMatch[5][$i][0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sScript .= substr($this->sScript, $iAux);
|
$sScript .= substr( $this->sScript, $iAux );
|
||||||
$sScript = '$bResult = ' . $sScript . ';';
|
$sScript = '$bResult = ' . $sScript . ';';
|
||||||
// checks if the syntax is valid or if the variables in that condition has been previously defined
|
// checks if the syntax is valid or if the variables in that condition has been previously defined
|
||||||
if ($this->validSyntax($sScript) && $variableIsDefined) {
|
if ($this->validSyntax( $sScript ) && $variableIsDefined) {
|
||||||
$this->bError = false;
|
$this->bError = false;
|
||||||
eval($sScript);
|
eval( $sScript );
|
||||||
} else {
|
} else {
|
||||||
// echo "<script> alert('".G::loadTranslation('MSG_CONDITION_NOT_DEFINED')."'); </script>";
|
// echo "<script> alert('".G::loadTranslation('MSG_CONDITION_NOT_DEFINED')."'); </script>";
|
||||||
G::SendTemporalMessage('MSG_CONDITION_NOT_DEFINED', 'error', 'labels');
|
G::SendTemporalMessage( 'MSG_CONDITION_NOT_DEFINED', 'error', 'labels' );
|
||||||
$this->bError = true;
|
$this->bError = true;
|
||||||
}
|
}
|
||||||
return $bResult;
|
return $bResult;
|
||||||
@@ -540,60 +463,65 @@ class PMScript
|
|||||||
|
|
||||||
//Start - Private functions
|
//Start - Private functions
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert to string
|
* Convert to string
|
||||||
|
*
|
||||||
* @param variant $vValue
|
* @param variant $vValue
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function pmToString($vValue)
|
function pmToString ($vValue)
|
||||||
{
|
{
|
||||||
return (string) $vValue;
|
return (string) $vValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert to integer
|
* Convert to integer
|
||||||
|
*
|
||||||
* @param variant $vValue
|
* @param variant $vValue
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
function pmToInteger($vValue)
|
function pmToInteger ($vValue)
|
||||||
{
|
{
|
||||||
return (int) $vValue;
|
return (int) $vValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert to float
|
* Convert to float
|
||||||
|
*
|
||||||
* @param variant $vValue
|
* @param variant $vValue
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
function pmToFloat($vValue)
|
function pmToFloat ($vValue)
|
||||||
{
|
{
|
||||||
return (float) $vValue;
|
return (float) $vValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert to Url
|
* Convert to Url
|
||||||
|
*
|
||||||
* @param variant $vValue
|
* @param variant $vValue
|
||||||
* @return url
|
* @return url
|
||||||
*/
|
*/
|
||||||
function pmToUrl($vValue)
|
function pmToUrl ($vValue)
|
||||||
{
|
{
|
||||||
return urlencode($vValue);
|
return urlencode( $vValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert to data base escaped string
|
* Convert to data base escaped string
|
||||||
|
*
|
||||||
* @param variant $vValue
|
* @param variant $vValue
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function pmSqlEscape($vValue)
|
function pmSqlEscape ($vValue)
|
||||||
{
|
{
|
||||||
return G::sqlEscape($vValue);
|
return G::sqlEscape( $vValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
//End - Private functions
|
//End - Private functions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* * *************************************************************************
|
/* * *************************************************************************
|
||||||
* Error handler
|
* Error handler
|
||||||
* author: Julio Cesar Laura Avenda<64>o <juliocesar@colosa.com>
|
* author: Julio Cesar Laura Avenda<64>o <juliocesar@colosa.com>
|
||||||
@@ -607,13 +535,13 @@ function pmSqlEscape($vValue)
|
|||||||
* @param string $errline
|
* @param string $errline
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handleErrors($errno, $errstr, $errfile, $errline)
|
function handleErrors ($errno, $errstr, $errfile, $errline)
|
||||||
{
|
{
|
||||||
if ($errno != '' && ($errno != 8) && ($errno != 2048)) {
|
if ($errno != '' && ($errno != 8) && ($errno != 2048)) {
|
||||||
if (isset($_SESSION['_CODE_'])) {
|
if (isset( $_SESSION['_CODE_'] )) {
|
||||||
$sCode = $_SESSION['_CODE_'];
|
$sCode = $_SESSION['_CODE_'];
|
||||||
unset($_SESSION['_CODE_']);
|
unset( $_SESSION['_CODE_'] );
|
||||||
registerError(1, $errstr, $errline - 1, $sCode);
|
registerError( 1, $errstr, $errline - 1, $sCode );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -624,50 +552,44 @@ function handleErrors($errno, $errstr, $errfile, $errline)
|
|||||||
* @return buffer
|
* @return buffer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function handleFatalErrors($buffer)
|
function handleFatalErrors ($buffer)
|
||||||
{
|
{
|
||||||
if (preg_match('/(error<\/b>:)(.+)(<br)/', $buffer, $regs)) {
|
if (preg_match( '/(error<\/b>:)(.+)(<br)/', $buffer, $regs )) {
|
||||||
$err = preg_replace('/<.*?>/', '', $regs[2]);
|
$err = preg_replace( '/<.*?>/', '', $regs[2] );
|
||||||
$aAux = explode(' in ', $err);
|
$aAux = explode( ' in ', $err );
|
||||||
$sCode = $_SESSION['_CODE_'];
|
$sCode = $_SESSION['_CODE_'];
|
||||||
unset($_SESSION['_CODE_']);
|
unset( $_SESSION['_CODE_'] );
|
||||||
registerError(2, $aAux[0], 0, $sCode);
|
registerError( 2, $aAux[0], 0, $sCode );
|
||||||
if (strpos($_SERVER['REQUEST_URI'], '/cases/cases_Step') !== false) {
|
if (strpos( $_SERVER['REQUEST_URI'], '/cases/cases_Step' ) !== false) {
|
||||||
if (strpos($_SERVER['REQUEST_URI'], '&ACTION=GENERATE') !== false) {
|
if (strpos( $_SERVER['REQUEST_URI'], '&ACTION=GENERATE' ) !== false) {
|
||||||
G::LoadClass('case');
|
G::LoadClass( 'case' );
|
||||||
$oCase = new Cases();
|
$oCase = new Cases();
|
||||||
$aNextStep = $oCase->getNextStep($_SESSION['PROCESS'],
|
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
|
||||||
$_SESSION['APPLICATION'],
|
|
||||||
$_SESSION['INDEX'],
|
|
||||||
$_SESSION['STEP_POSITION']);
|
|
||||||
if ($_SESSION['TRIGGER_DEBUG']['ISSET']) {
|
if ($_SESSION['TRIGGER_DEBUG']['ISSET']) {
|
||||||
$_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER';
|
$_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER';
|
||||||
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
|
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
|
||||||
$aNextStep['PAGE'] = $aNextStep['PAGE'] . '&breakpoint=triggerdebug';
|
$aNextStep['PAGE'] = $aNextStep['PAGE'] . '&breakpoint=triggerdebug';
|
||||||
}
|
}
|
||||||
G::header('Location: ' . $aNextStep['PAGE']);
|
G::header( 'Location: ' . $aNextStep['PAGE'] );
|
||||||
die;
|
die();
|
||||||
}
|
}
|
||||||
$_SESSION['_NO_EXECUTE_TRIGGERS_'] = 1;
|
$_SESSION['_NO_EXECUTE_TRIGGERS_'] = 1;
|
||||||
G::header('Location: ' . $_SERVER['REQUEST_URI']);
|
G::header( 'Location: ' . $_SERVER['REQUEST_URI'] );
|
||||||
die;
|
die();
|
||||||
} else {
|
} else {
|
||||||
G::LoadClass('case');
|
G::LoadClass( 'case' );
|
||||||
$oCase = new Cases();
|
$oCase = new Cases();
|
||||||
$aNextStep = $oCase->getNextStep($_SESSION['PROCESS'],
|
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
|
||||||
$_SESSION['APPLICATION'],
|
|
||||||
$_SESSION['INDEX'],
|
|
||||||
$_SESSION['STEP_POSITION']);
|
|
||||||
if ($_SESSION['TRIGGER_DEBUG']['ISSET']) {
|
if ($_SESSION['TRIGGER_DEBUG']['ISSET']) {
|
||||||
$_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER';
|
$_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER';
|
||||||
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
|
$_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE'];
|
||||||
$aNextStep['PAGE'] = $aNextStep['PAGE'] . '&breakpoint=triggerdebug';
|
$aNextStep['PAGE'] = $aNextStep['PAGE'] . '&breakpoint=triggerdebug';
|
||||||
}
|
}
|
||||||
if (strpos($aNextStep['PAGE'], 'TYPE=ASSIGN_TASK&UID=-1') !== false) {
|
if (strpos( $aNextStep['PAGE'], 'TYPE=ASSIGN_TASK&UID=-1' ) !== false) {
|
||||||
G::SendMessageText('Fatal error in trigger', 'error');
|
G::SendMessageText( 'Fatal error in trigger', 'error' );
|
||||||
}
|
}
|
||||||
G::header('Location: ' . $aNextStep['PAGE']);
|
G::header( 'Location: ' . $aNextStep['PAGE'] );
|
||||||
die;
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $buffer;
|
return $buffer;
|
||||||
@@ -682,11 +604,10 @@ function handleFatalErrors($buffer)
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function registerError($iType, $sError, $iLine, $sCode)
|
function registerError ($iType, $sError, $iLine, $sCode)
|
||||||
{
|
{
|
||||||
$sType = ($iType == 1 ? 'ERROR' : 'FATAL');
|
$sType = ($iType == 1 ? 'ERROR' : 'FATAL');
|
||||||
$_SESSION['TRIGGER_DEBUG']['ERRORS'][][$sType] = $sError . ($iLine > 0 ? ' (line ' . $iLine . ')' : '')
|
$_SESSION['TRIGGER_DEBUG']['ERRORS'][][$sType] = $sError . ($iLine > 0 ? ' (line ' . $iLine . ')' : '') . ':<br /><br />' . $sCode;
|
||||||
. ':<br /><br />' . $sCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -695,7 +616,7 @@ function registerError($iType, $sError, $iLine, $sCode)
|
|||||||
* @param type $connection
|
* @param type $connection
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
function getEngineDataBaseName($connection)
|
function getEngineDataBaseName ($connection)
|
||||||
{
|
{
|
||||||
$aDNS = $connection->getDSN();
|
$aDNS = $connection->getDSN();
|
||||||
return $aDNS["phptype"];
|
return $aDNS["phptype"];
|
||||||
@@ -707,7 +628,7 @@ function getEngineDataBaseName($connection)
|
|||||||
* @param type $sql
|
* @param type $sql
|
||||||
* @param type $connection
|
* @param type $connection
|
||||||
*/
|
*/
|
||||||
function executeQueryOci($sql, $connection, $aParameter=array())
|
function executeQueryOci ($sql, $connection, $aParameter = array())
|
||||||
{
|
{
|
||||||
|
|
||||||
$aDNS = $connection->getDSN();
|
$aDNS = $connection->getDSN();
|
||||||
@@ -719,53 +640,53 @@ function executeQueryOci($sql, $connection, $aParameter=array())
|
|||||||
|
|
||||||
if ($sPort != "1521") {
|
if ($sPort != "1521") {
|
||||||
// if not default port
|
// if not default port
|
||||||
$conn = oci_connect($sUsername, $sPassword, $sHostspec . ":" . $sPort . "/" . $sDatabse);
|
$conn = oci_connect( $sUsername, $sPassword, $sHostspec . ":" . $sPort . "/" . $sDatabse );
|
||||||
} else {
|
} else {
|
||||||
$conn = oci_connect($sUsername, $sPassword, $sHostspec . "/" . $sDatabse);
|
$conn = oci_connect( $sUsername, $sPassword, $sHostspec . "/" . $sDatabse );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$conn) {
|
if (! $conn) {
|
||||||
$e = oci_error();
|
$e = oci_error();
|
||||||
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
|
trigger_error( htmlentities( $e['message'], ENT_QUOTES ), E_USER_ERROR );
|
||||||
return $e;
|
return $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case preg_match("/^(SELECT|SHOW|DESCRIBE|DESC|WITH)\s/i", $sql):
|
case preg_match( "/^(SELECT|SHOW|DESCRIBE|DESC|WITH)\s/i", $sql ):
|
||||||
$stid = oci_parse($conn, $sql);
|
$stid = oci_parse( $conn, $sql );
|
||||||
if (count($aParameter) > 0) {
|
if (count( $aParameter ) > 0) {
|
||||||
foreach ($aParameter as $key => $val) {
|
foreach ($aParameter as $key => $val) {
|
||||||
oci_bind_by_name($stid, $key, $val);
|
oci_bind_by_name( $stid, $key, $val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oci_execute($stid, OCI_DEFAULT);
|
oci_execute( $stid, OCI_DEFAULT );
|
||||||
|
|
||||||
$result = Array();
|
$result = Array ();
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
|
while ($row = oci_fetch_array( $stid, OCI_ASSOC + OCI_RETURN_NULLS )) {
|
||||||
$result[$i++] = $row;
|
$result[$i ++] = $row;
|
||||||
}
|
}
|
||||||
oci_free_statement($stid);
|
oci_free_statement( $stid );
|
||||||
oci_close($conn);
|
oci_close( $conn );
|
||||||
return $result;
|
return $result;
|
||||||
break;
|
break;
|
||||||
case preg_match("/^(INSERT|UPDATE|DELETE)\s/i", $sql):
|
case preg_match( "/^(INSERT|UPDATE|DELETE)\s/i", $sql ):
|
||||||
$stid = oci_parse($conn, $sql);
|
$stid = oci_parse( $conn, $sql );
|
||||||
$isValid = true;
|
$isValid = true;
|
||||||
if (count($aParameter) > 0) {
|
if (count( $aParameter ) > 0) {
|
||||||
foreach ($aParameter as $key => $val) {
|
foreach ($aParameter as $key => $val) {
|
||||||
oci_bind_by_name($stid, $key, $val);
|
oci_bind_by_name( $stid, $key, $val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$objExecute = oci_execute($stid, OCI_DEFAULT);
|
$objExecute = oci_execute( $stid, OCI_DEFAULT );
|
||||||
if ($objExecute) {
|
if ($objExecute) {
|
||||||
oci_commit($conn);
|
oci_commit( $conn );
|
||||||
} else {
|
} else {
|
||||||
oci_rollback($conn);
|
oci_rollback( $conn );
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
}
|
}
|
||||||
oci_free_statement($stid);
|
oci_free_statement( $stid );
|
||||||
oci_close($conn);
|
oci_close( $conn );
|
||||||
if ($isValid) {
|
if ($isValid) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -774,18 +695,18 @@ function executeQueryOci($sql, $connection, $aParameter=array())
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Stored procedures
|
// Stored procedures
|
||||||
$stid = oci_parse($conn, $sql);
|
$stid = oci_parse( $conn, $sql );
|
||||||
$aParameterRet = array();
|
$aParameterRet = array ();
|
||||||
if (count($aParameter) > 0) {
|
if (count( $aParameter ) > 0) {
|
||||||
foreach ($aParameter as $key => $val) {
|
foreach ($aParameter as $key => $val) {
|
||||||
$aParameterRet[$key] = $val;
|
$aParameterRet[$key] = $val;
|
||||||
// The third parameter ($aParameterRet[$key]) returned a value by reference.
|
// The third parameter ($aParameterRet[$key]) returned a value by reference.
|
||||||
oci_bind_by_name($stid, $key, $aParameterRet[$key]);
|
oci_bind_by_name( $stid, $key, $aParameterRet[$key] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$objExecute = oci_execute($stid, OCI_DEFAULT);
|
$objExecute = oci_execute( $stid, OCI_DEFAULT );
|
||||||
oci_free_statement($stid);
|
oci_free_statement( $stid );
|
||||||
oci_close($conn);
|
oci_close( $conn );
|
||||||
return $aParameterRet;
|
return $aParameterRet;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user