HOR-4527
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
parent
abe71a6ffe
commit
0d533e19d9
File diff suppressed because it is too large
Load Diff
@@ -1,108 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* dbInfo.php
|
||||
*
|
||||
*
|
||||
* {projectName}
|
||||
*
|
||||
*
|
||||
*/
|
||||
function lookup($target)
|
||||
{
|
||||
global $ntarget;
|
||||
$msg = $target . ' => ';
|
||||
//if( eregi('[a-zA-Z]', $target) )
|
||||
if( preg_match('[a-zA-Z]', $target)) //Made compatible to PHP 5.3
|
||||
global $ntarget;
|
||||
$msg = $target . ' => ';
|
||||
//if( eregi('[a-zA-Z]', $target) )
|
||||
if (preg_match('[a-zA-Z]', $target)) { //Made compatible to PHP 5.3
|
||||
$ntarget = gethostbyname($target);
|
||||
else
|
||||
$ntarget = gethostbyaddr($target);
|
||||
$msg .= $ntarget;
|
||||
return($msg);
|
||||
} else {
|
||||
$ntarget = gethostbyaddr($target);
|
||||
}
|
||||
$msg .= $ntarget;
|
||||
return($msg);
|
||||
}
|
||||
|
||||
function getDbServicesAvailables()
|
||||
{
|
||||
$servicesAvailables = Array();
|
||||
|
||||
$dbServices = Array(
|
||||
'mysql' => Array(
|
||||
'id' => 'mysql',
|
||||
'command' => 'mysql_connect',
|
||||
function getDbServicesAvailables()
|
||||
{
|
||||
$servicesAvailables = array();
|
||||
|
||||
$dbServices = array(
|
||||
'mysql' => array(
|
||||
'id' => 'mysql',
|
||||
'command' => 'mysqli_connect',
|
||||
'name' => 'MySql'
|
||||
),
|
||||
'pgsql' => Array(
|
||||
'pgsql' => array(
|
||||
'id' => 'pgsql',
|
||||
'command' => 'pg_connect',
|
||||
'name' => 'PostgreSQL'
|
||||
),
|
||||
'mssql' => Array(
|
||||
'mssql' => array(
|
||||
'id' => 'mssql',
|
||||
'command' => 'mssql_connect',
|
||||
'name' => 'Microsoft SQL Server'),
|
||||
'oracle'=> Array(
|
||||
'oracle'=> array(
|
||||
'id' => 'oracle',
|
||||
'command' => 'oci_connect',
|
||||
'name' => 'Oracle'
|
||||
),
|
||||
'informix'=> Array(
|
||||
'informix'=> array(
|
||||
'id' => 'informix',
|
||||
'command' => 'ifx_connect',
|
||||
'name' => 'Informix'
|
||||
),
|
||||
'sqlite' => Array(
|
||||
'sqlite' => array(
|
||||
'id' => 'sqlite',
|
||||
'command' => 'sqlite_open',
|
||||
'name' => 'SQLite'
|
||||
)
|
||||
);
|
||||
|
||||
foreach($dbServices as $service) {
|
||||
if(@function_exists($service['command'])){
|
||||
$servicesAvailables[] = $service;
|
||||
}
|
||||
}
|
||||
return $servicesAvailables;
|
||||
}
|
||||
);
|
||||
|
||||
foreach ($dbServices as $service) {
|
||||
if (@function_exists($service['command'])) {
|
||||
$servicesAvailables[] = $service;
|
||||
}
|
||||
}
|
||||
return $servicesAvailables;
|
||||
}
|
||||
|
||||
function getDbServerVersion($driver) {
|
||||
try{
|
||||
switch($driver)
|
||||
{
|
||||
function getDbServerVersion($driver)
|
||||
{
|
||||
try {
|
||||
switch ($driver) {
|
||||
case 'mysql':
|
||||
if($link = @mysql_connect( DB_HOST, DB_USER, DB_PASS)){
|
||||
$v = @mysql_get_server_info();
|
||||
if ($link = mysqli_connect(DB_HOST, DB_USER, DB_PASS)) {
|
||||
$v = mysqli_get_server_info($link);
|
||||
} else {
|
||||
throw new Exception(@mysql_error($link));
|
||||
throw new Exception(mysqli_error($link));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (isset($v))?$v:'none';
|
||||
} catch (Exception $e){
|
||||
return ($e->getMessage());
|
||||
}
|
||||
return (isset($v))?$v:'none';
|
||||
} catch (Exception $e) {
|
||||
return ($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists(PATH_METHODS . 'login/version-{projectName}.php'))
|
||||
{
|
||||
include('version-{projectName}.php');
|
||||
}
|
||||
else {
|
||||
define('PRG_VERSION', 'Development Version');
|
||||
if (file_exists(PATH_METHODS . 'login/version-{projectName}.php')) {
|
||||
include('version-{projectName}.php');
|
||||
} else {
|
||||
define('PRG_VERSION', 'Development Version');
|
||||
}
|
||||
|
||||
if (getenv('HTTP_CLIENT_IP')) {
|
||||
$ip = getenv('HTTP_CLIENT_IP');
|
||||
}
|
||||
elseif(getenv('HTTP_X_FORWARDED_FOR')) {
|
||||
$ip = getenv('HTTP_X_FORWARDED_FOR');
|
||||
$ip = getenv('HTTP_CLIENT_IP');
|
||||
} elseif (getenv('HTTP_X_FORWARDED_FOR')) {
|
||||
$ip = getenv('HTTP_X_FORWARDED_FOR');
|
||||
} else {
|
||||
$ip = getenv('REMOTE_ADDR');
|
||||
$ip = getenv('REMOTE_ADDR');
|
||||
}
|
||||
|
||||
$redhat = '';
|
||||
if ( file_exists ( '/etc/redhat-release' ) ) {
|
||||
$fnewsize = filesize( '/etc/redhat-release' );
|
||||
$fp = fopen( '/etc/redhat-release' , 'r' );
|
||||
$redhat = fread( $fp, $fnewsize );
|
||||
fclose( $fp );
|
||||
if (file_exists('/etc/redhat-release')) {
|
||||
$fnewsize = filesize('/etc/redhat-release');
|
||||
$fp = fopen('/etc/redhat-release', 'r');
|
||||
$redhat = fread($fp, $fnewsize);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
$redhat .= " (" . PHP_OS . ")";
|
||||
@@ -111,9 +109,11 @@ function lookup($target)
|
||||
//$dbNetView->loginDbServer(DB_USER, DB_PASS);
|
||||
|
||||
$availdb = '';
|
||||
foreach ( getDbServicesAvailables() as $key => $val ) {
|
||||
if ( $availdb != '' ) $availdb .= ', ';
|
||||
$availdb .= $val['name'];
|
||||
foreach (getDbServicesAvailables() as $key => $val) {
|
||||
if ($availdb != '') {
|
||||
$availdb .= ', ';
|
||||
}
|
||||
$availdb .= $val['name'];
|
||||
}
|
||||
|
||||
$Fields['SYSTEM'] = $redhat;
|
||||
@@ -122,7 +122,7 @@ function lookup($target)
|
||||
$Fields['DATABASE_NAME'] = DB_NAME;
|
||||
$Fields['PHP'] = phpversion();
|
||||
$Fields['FLUID'] = PRG_VERSION;
|
||||
$Fields['IP'] = lookup ($ip);
|
||||
$Fields['IP'] = lookup($ip);
|
||||
$Fields['ENVIRONMENT'] = SYS_SYS;
|
||||
$Fields['SERVER_SOFTWARE'] = getenv('SERVER_SOFTWARE');
|
||||
$Fields['SERVER_NAME'] = getenv('SERVER_NAME');
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
$smarty->display('blank.html');
|
||||
}
|
||||
else {
|
||||
$oHeadPublisher =& headPublisher::getSingleton();
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
if (isset($oHeadPublisher)) $header = $oHeadPublisher->printHeader();
|
||||
$smarty->assign('username', (isset($_SESSION['USR_USERNAME']) ? '(' . $_SESSION['USR_USERNAME'] . ' ' . G::LoadTranslation('ID_IN') . ' ' . SYS_SYS . ')' : '') );
|
||||
$smarty->assign('header', $header );
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
try {
|
||||
/* Render page */
|
||||
$oHeadPublisher = &headPublisher::getSingleton();
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
|
||||
$G_MAIN_MENU = "processmaker";
|
||||
$G_ID_MENU_SELECTED = "{menuId}_MNU_01";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
try {
|
||||
$oHeadPublisher = &headPublisher::getSingleton();
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
|
||||
$oHeadPublisher->addContent("{className}/{className}Application2"); //Adding a html file .html.
|
||||
$oHeadPublisher->addExtJsScript("{className}/{className}Application2", false); //Adding a javascript file .js
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
try {
|
||||
$oHeadPublisher = &headPublisher::getSingleton();
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
|
||||
$oHeadPublisher->addContent("{className}/{className}Application3"); //Adding a html file .html.
|
||||
$oHeadPublisher->addExtJsScript("{className}/{className}Application3", false); //Adding a javascript file .js
|
||||
|
||||
@@ -111,5 +111,5 @@ class {className}Plugin extends PMPlugin
|
||||
<!-- END BLOCK : dashboard -->
|
||||
}
|
||||
|
||||
$oPluginRegistry = &PMPluginRegistry::getSingleton();
|
||||
$oPluginRegistry = PMPluginRegistry::getSingleton();
|
||||
$oPluginRegistry->registerPlugin("{className}", __FILE__);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
try {
|
||||
global $Fields;
|
||||
$oHeadPublisher = &headPublisher::getSingleton();
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
|
||||
//SYS_SYS //Workspace name
|
||||
//PROCESS //Process UID
|
||||
|
||||
@@ -124,7 +124,7 @@ $docuroot = explode ( PATH_SEP , $_SERVER['DOCUMENT_ROOT'] );
|
||||
|
||||
//***************** Call Gulliver Classes **************************
|
||||
|
||||
$oHeadPublisher =& headPublisher::getSingleton();
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
|
||||
//***************** database and workspace definition ************************
|
||||
//if SYS_TEMP exists, the URL has a workspace, now we need to verify if exists their db.php file
|
||||
@@ -203,7 +203,7 @@ $docuroot = explode ( PATH_SEP , $_SERVER['DOCUMENT_ROOT'] );
|
||||
// //the singleton has a list of enabled plugins
|
||||
|
||||
// $sSerializedFile = PATH_DATA_SITE . 'plugin.singleton';
|
||||
// $oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||
// $oPluginRegistry = PMPluginRegistry::getSingleton();
|
||||
// if ( file_exists ($sSerializedFile) )
|
||||
// $oPluginRegistry->unSerializeInstance( file_get_contents ( $sSerializedFile ) );
|
||||
//
|
||||
@@ -297,7 +297,7 @@ $docuroot = explode ( PATH_SEP , $_SERVER['DOCUMENT_ROOT'] );
|
||||
|
||||
// ***************** enable rbac **************************
|
||||
|
||||
$RBAC =& RBAC::getSingleton();
|
||||
$RBAC = RBAC::getSingleton();
|
||||
$RBAC->sSystem = '{rbacProjectName}';
|
||||
|
||||
// ***************** Headers **************************
|
||||
|
||||
@@ -26,113 +26,115 @@
|
||||
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
if (isset( $_SESSION['CURRENT_PAGE_INITILIZATION'] ))
|
||||
eval( $_SESSION['CURRENT_PAGE_INITILIZATION'] );
|
||||
if (isset($_SESSION['CURRENT_PAGE_INITILIZATION'])) {
|
||||
eval($_SESSION['CURRENT_PAGE_INITILIZATION']);
|
||||
}
|
||||
|
||||
|
||||
// $json=new Services_JSON();
|
||||
if (! defined( 'XMLFORM_AJAX_PATH' ))
|
||||
define( 'XMLFORM_AJAX_PATH', PATH_XMLFORM );
|
||||
// $json=new Services_JSON();
|
||||
if (!defined('XMLFORM_AJAX_PATH')) {
|
||||
define('XMLFORM_AJAX_PATH', PATH_XMLFORM);
|
||||
}
|
||||
|
||||
$_DBArray = array ();
|
||||
if (isset( $_SESSION['_DBArray'] )) {
|
||||
$_DBArray = array();
|
||||
if (isset($_SESSION['_DBArray'])) {
|
||||
$_DBArray = $_SESSION['_DBArray'];
|
||||
}
|
||||
|
||||
$xmlFile = G::getUIDName( urlDecode( $_POST['form'] ) );
|
||||
$xmlFile = G::getUIDName(urlDecode($_POST['form']));
|
||||
$sPath = XMLFORM_AJAX_PATH;
|
||||
|
||||
//if the xmlform file doesn't exist, then try with the plugins folders
|
||||
if (! is_file( XMLFORM_AJAX_PATH . $xmlFile )) {
|
||||
$aux = explode( PATH_SEP, $xmlFile );
|
||||
if (!is_file(XMLFORM_AJAX_PATH . $xmlFile)) {
|
||||
$aux = explode(PATH_SEP, $xmlFile);
|
||||
//check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment
|
||||
if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) {
|
||||
if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) {
|
||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||
if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) {
|
||||
if ($oPluginRegistry->isRegisteredFolder($aux[0])) {
|
||||
$sPath = PATH_PLUGINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$G_FORM = new Form( $xmlFile, $sPath );
|
||||
$G_FORM->id = urlDecode( $_POST['form'] );
|
||||
$G_FORM->values = isset( $_SESSION[$G_FORM->id] ) ? $_SESSION[$G_FORM->id] : array ();
|
||||
$G_FORM = new Form($xmlFile, $sPath);
|
||||
$G_FORM->id = urlDecode($_POST['form']);
|
||||
$G_FORM->values = isset($_SESSION[$G_FORM->id]) ? $_SESSION[$G_FORM->id] : array();
|
||||
|
||||
$newValues = (Bootstrap::json_decode( urlDecode( stripslashes( $_POST['fields'] ) ) ));
|
||||
$newValues = (Bootstrap::json_decode(urlDecode(stripslashes($_POST['fields']))));
|
||||
|
||||
if (isset( $_POST['grid'] )) {
|
||||
$_POST['row'] = (int) $_POST['row'];
|
||||
$aAux = array ();
|
||||
if (isset($_POST['grid'])) {
|
||||
$_POST['row'] = (int)$_POST['row'];
|
||||
$aAux = array();
|
||||
|
||||
foreach ($newValues as $sKey => $newValue) {
|
||||
$newValue = (array) $newValue;
|
||||
$aKeys = array_keys( $newValue );
|
||||
if (count($aKeys)>0) {
|
||||
$aValues = array ();
|
||||
for ($i = 1; $i <= ($_POST['row'] - 1); $i ++) {
|
||||
$aValues[$i] = array ($aKeys[0] => '' );
|
||||
$newValue = (array)$newValue;
|
||||
$aKeys = array_keys($newValue);
|
||||
if (count($aKeys) > 0) {
|
||||
$aValues = array();
|
||||
for ($i = 1; $i <= ($_POST['row'] - 1); $i++) {
|
||||
$aValues[$i] = array($aKeys[0] => '');
|
||||
}
|
||||
$aValues[$_POST['row']] = array ($aKeys[0] => $newValue[$aKeys[0]] );
|
||||
$newValues[$sKey]->$_POST['grid'] = $aValues;
|
||||
unset( $newValues[$sKey]->$aKeys[0] );
|
||||
$aValues[$_POST['row']] = array($aKeys[0] => $newValue[$aKeys[0]]);
|
||||
$newValues[$sKey]->{$_POST['grid']} = $aValues;
|
||||
unset($newValues[$sKey]->{$aKeys[0]});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Next Lines re-build newValues array to send multiple dependent fields merged by row into a grid.
|
||||
if (sizeof( $newValues ) > 1 && isset( $_POST['grid'] )) {
|
||||
$fieldBase = array ();
|
||||
if (count($newValues) > 1 && isset($_POST['grid'])) {
|
||||
$fieldBase = array();
|
||||
foreach ($newValues as $key => $values) {
|
||||
for ($r2 = 1; $r2 <= $_POST['row']; $r2 ++) {
|
||||
for ($r2 = 1; $r2 <= $_POST['row']; $r2++) {
|
||||
foreach ($values as $class => $value) {
|
||||
if ($class == $_POST['grid']) {
|
||||
$value = (array) $value;
|
||||
$value = (array)$value;
|
||||
$arrayK = $value[$r2];
|
||||
foreach ($arrayK as $key2 => $val) {
|
||||
$fieldBase[$r2][$key2] = is_array( $val ) ? $val[$key2] : $val;
|
||||
$fieldBase[$r2][$key2] = is_array($val) ? $val[$key2] : $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$newValues[0]->$_POST['grid'] = $fieldBase;
|
||||
$newValues[0]->{$_POST['grid']} = $fieldBase;
|
||||
}
|
||||
|
||||
//Resolve dependencies
|
||||
//Returns an array ($dependentFields) with the names of the fields
|
||||
//that depends of fields passed through AJAX ($_GET/$_POST)
|
||||
//Returns all dependencies of all fields, this in grids
|
||||
$dependentFields = array ();
|
||||
$aux = array ();
|
||||
for ($r = 0; $r < sizeof( $newValues ); $r ++) {
|
||||
$newValues[$r] = (array) $newValues[$r];
|
||||
$G_FORM->setValues( $newValues[$r] );
|
||||
$dependentFields = array();
|
||||
$aux = array();
|
||||
for ($r = 0; $r < count($newValues); $r++) {
|
||||
$newValues[$r] = (array)$newValues[$r];
|
||||
$G_FORM->setValues($newValues[$r]);
|
||||
//Search dependent fields
|
||||
foreach ($newValues[$r] as $k => $v) {
|
||||
if (! is_array( $v )) {
|
||||
$myDependentFields = subDependencies( $k, $G_FORM, $aux );
|
||||
if (!is_array($v)) {
|
||||
$myDependentFields = subDependencies($k, $G_FORM, $aux);
|
||||
$_SESSION[$G_FORM->id][$k] = $v;
|
||||
} else {
|
||||
foreach ($v[$_POST['row']] as $k1 => $v1) {
|
||||
$myDependentFields = subDependencies( $k1, $G_FORM, $aux, $_POST['grid'] );
|
||||
$myDependentFields = subDependencies($k1, $G_FORM, $aux, $_POST['grid']);
|
||||
$_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1;
|
||||
$G_FORM->values[$_POST['grid']][$_POST['row']][$k1] = $v1;
|
||||
}
|
||||
}
|
||||
$dependentFields = array_merge( $dependentFields, $myDependentFields );
|
||||
$dependentFields = array_merge($dependentFields, $myDependentFields);
|
||||
}
|
||||
}
|
||||
|
||||
$dependentFields = array_unique( $dependentFields );
|
||||
$dependentFields = array_unique($dependentFields);
|
||||
|
||||
//Update when is depenfield set empty
|
||||
$newForm = $G_FORM->values;
|
||||
foreach($newForm as $fKey => $values){
|
||||
foreach($dependentFields as $att){
|
||||
if($att == $fKey){
|
||||
$newForm[$fKey] = '';
|
||||
foreach ($newForm as $fKey => $values) {
|
||||
foreach ($dependentFields as $att) {
|
||||
if ($att == $fKey) {
|
||||
$newForm[$fKey] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$G_FORM->values = $newForm;
|
||||
|
||||
@@ -148,7 +150,7 @@ if (isset($_POST["grid"])) {
|
||||
$arrayAux = (array)($fieldData);
|
||||
|
||||
foreach ($arrayAux as $index => $value) {
|
||||
$ereg = $ereg . (($ereg != null)? "|" : null) . $index; //Concatenate field
|
||||
$ereg = $ereg . (($ereg != null) ? "|" : null) . $index; //Concatenate field
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,10 +202,10 @@ if (isset($_POST["grid"]) && isset($_POST["gridField"])) {
|
||||
}
|
||||
|
||||
//Parse and update the new content
|
||||
$newContent = $G_FORM->getFields(PATH_CORE . "templates" . PATH_SEP . "xmlform.html", (isset($_POST["row"])? $_POST["row"] : -1));
|
||||
$newContent = $G_FORM->getFields(PATH_CORE . "templates" . PATH_SEP . "xmlform.html", (isset($_POST["row"]) ? $_POST["row"] : -1));
|
||||
|
||||
//Returns the dependentFields's content
|
||||
$sendContent = array ();
|
||||
$sendContent = array();
|
||||
$r = 0;
|
||||
|
||||
//Set data
|
||||
@@ -213,19 +215,19 @@ foreach ($dependentFields as $d) {
|
||||
$sendContent[$r]->name = $d;
|
||||
$sendContent[$r]->content = new stdclass();
|
||||
|
||||
if (! isset( $_POST['grid'] )) {
|
||||
if (isset( $G_FORM->fields[$d] )) {
|
||||
if (!isset($_POST['grid'])) {
|
||||
if (isset($G_FORM->fields[$d])) {
|
||||
foreach ($G_FORM->fields[$d] as $attribute => $value) {
|
||||
switch ($attribute) {
|
||||
case 'type':
|
||||
$sendContent[$r]->content->{$attribute} = $value;
|
||||
break;
|
||||
case 'options':
|
||||
$sendContent[$r]->content->{$attribute} = toJSArray( $value, $sendContent[$r]->content->type );
|
||||
$sendContent[$r]->content->{$attribute} = toJSArray($value, $sendContent[$r]->content->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sendContent[$r]->value = isset( $G_FORM->values[$d] ) ? $G_FORM->values[$d] : '';
|
||||
$sendContent[$r]->value = isset($G_FORM->values[$d]) ? $G_FORM->values[$d] : '';
|
||||
}
|
||||
} else {
|
||||
foreach ($G_FORM->fields[$_POST['grid']]->fields[$d] as $attribute => $value) {
|
||||
@@ -237,12 +239,12 @@ foreach ($dependentFields as $d) {
|
||||
if ($sendContent[$r]->content->type != "text" && $sendContent[$r]->content->type != "textarea") {
|
||||
$sendContent[$r]->content->{$attribute} = toJSArray($value);
|
||||
} else {
|
||||
$sendContent[$r]->content->{$attribute} = toJSArray((isset($value[$_POST["row"]])? array($value[$_POST["row"]]) : array()));
|
||||
$sendContent[$r]->content->{$attribute} = toJSArray((isset($value[$_POST["row"]]) ? array($value[$_POST["row"]]) : array()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$sendContent[$r]->value = isset( $G_FORM->values[$_POST['grid']][$_POST['row']][$d] ) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : '';
|
||||
$sendContent[$r]->value = isset($G_FORM->values[$_POST['grid']][$_POST['row']][$d]) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : '';
|
||||
}
|
||||
|
||||
$r = $r + 1;
|
||||
@@ -250,9 +252,9 @@ foreach ($dependentFields as $d) {
|
||||
|
||||
echo Bootstrap::json_encode($sendContent);
|
||||
|
||||
function toJSArray ($array, $type = '')
|
||||
function toJSArray($array, $type = '')
|
||||
{
|
||||
$result = array ();
|
||||
$result = array();
|
||||
foreach ($array as $k => $v) {
|
||||
$o = new stdclass();
|
||||
$o->key = $k;
|
||||
@@ -264,55 +266,62 @@ function toJSArray ($array, $type = '')
|
||||
return $result;
|
||||
}
|
||||
|
||||
function subDependencies ($k, &$G_FORM, &$aux, $grid = '')
|
||||
function subDependencies($k, &$G_FORM, &$aux, $grid = '')
|
||||
{
|
||||
if (array_search( $k, $aux ) !== FALSE)
|
||||
return array ();
|
||||
if (array_search($k, $aux) !== false) {
|
||||
return array();
|
||||
}
|
||||
if ($grid == '') {
|
||||
if (! array_key_exists( $k, $G_FORM->fields ))
|
||||
return array ();
|
||||
if (! isset( $G_FORM->fields[$k]->dependentFields ))
|
||||
return array ();
|
||||
$aux[] = $k;
|
||||
if (strpos( $G_FORM->fields[$k]->dependentFields, ',' ) !== false) {
|
||||
$myDependentFields = explode( ',', $G_FORM->fields[$k]->dependentFields );
|
||||
} else {
|
||||
$myDependentFields = explode( '|', $G_FORM->fields[$k]->dependentFields );
|
||||
if (!array_key_exists($k, $G_FORM->fields)) {
|
||||
return array();
|
||||
}
|
||||
for ($r = 0; $r < sizeof( $myDependentFields ); $r ++) {
|
||||
if ($myDependentFields[$r] == "")
|
||||
unset( $myDependentFields[$r] );
|
||||
if (!isset($G_FORM->fields[$k]->dependentFields)) {
|
||||
return array();
|
||||
}
|
||||
$aux[] = $k;
|
||||
if (strpos($G_FORM->fields[$k]->dependentFields, ',') !== false) {
|
||||
$myDependentFields = explode(',', $G_FORM->fields[$k]->dependentFields);
|
||||
} else {
|
||||
$myDependentFields = explode('|', $G_FORM->fields[$k]->dependentFields);
|
||||
}
|
||||
for ($r = 0; $r < count($myDependentFields); $r++) {
|
||||
if ($myDependentFields[$r] == "") {
|
||||
unset($myDependentFields[$r]);
|
||||
}
|
||||
}
|
||||
$mD = $myDependentFields;
|
||||
foreach( $mD as $ki) {
|
||||
$myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux ) );
|
||||
foreach ($mD as $ki) {
|
||||
$myDependentFields = array_merge($myDependentFields, subDependencies($ki, $G_FORM, $aux));
|
||||
}
|
||||
} else {
|
||||
if (! isset($G_FORM->fields[$grid])) {
|
||||
return array ();
|
||||
if (!isset($G_FORM->fields[$grid])) {
|
||||
return array();
|
||||
}
|
||||
if (!array_key_exists($k, $G_FORM->fields[$grid]->fields)) {
|
||||
return array();
|
||||
}
|
||||
if (!isset($G_FORM->fields[$grid]->fields[$k]->dependentFields)) {
|
||||
return array();
|
||||
}
|
||||
if (! array_key_exists( $k, $G_FORM->fields[$grid]->fields ))
|
||||
return array ();
|
||||
if (! isset( $G_FORM->fields[$grid]->fields[$k]->dependentFields ))
|
||||
return array ();
|
||||
|
||||
$aux[] = $k;
|
||||
|
||||
if (strpos( $G_FORM->fields[$grid]->fields[$k]->dependentFields, ',' ) !== false) {
|
||||
$myDependentFields = explode( ',', $G_FORM->fields[$grid]->fields[$k]->dependentFields );
|
||||
if (strpos($G_FORM->fields[$grid]->fields[$k]->dependentFields, ',') !== false) {
|
||||
$myDependentFields = explode(',', $G_FORM->fields[$grid]->fields[$k]->dependentFields);
|
||||
} else {
|
||||
$myDependentFields = explode( '|', $G_FORM->fields[$grid]->fields[$k]->dependentFields );
|
||||
$myDependentFields = explode('|', $G_FORM->fields[$grid]->fields[$k]->dependentFields);
|
||||
}
|
||||
|
||||
for ($r = 0; $r < sizeof( $myDependentFields ); $r ++) {
|
||||
if ($myDependentFields[$r] == "")
|
||||
unset( $myDependentFields[$r] );
|
||||
for ($r = 0; $r < count($myDependentFields); $r++) {
|
||||
if ($myDependentFields[$r] == "") {
|
||||
unset($myDependentFields[$r]);
|
||||
}
|
||||
}
|
||||
|
||||
$mD = $myDependentFields;
|
||||
|
||||
foreach( $mD as $ki) {
|
||||
$myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux, $grid) );
|
||||
foreach ($mD as $ki) {
|
||||
$myDependentFields = array_merge($myDependentFields, subDependencies($ki, $G_FORM, $aux, $grid));
|
||||
}
|
||||
|
||||
//Set field and the dependent field of the grid
|
||||
@@ -323,4 +332,3 @@ function subDependencies ($k, &$G_FORM, &$aux, $grid = '')
|
||||
|
||||
return $myDependentFields;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ if (isset($request)) {
|
||||
$_SESSION[$_POST["formID"]][$_POST["gridname"]] = (array)$_SESSION[$_POST["formID"]][$_POST["gridname"]];
|
||||
}
|
||||
ksort($_SESSION[$_POST["formID"]][$_POST["gridname"]]);
|
||||
$oFields = array();
|
||||
$oFields = [];
|
||||
$initialKey = 1;
|
||||
|
||||
foreach ($_SESSION[$_POST["formID"]][$_POST["gridname"]] as $key => $value) {
|
||||
@@ -66,12 +66,12 @@ if (isset($request)) {
|
||||
|
||||
|
||||
$bdUid = 'workflow';
|
||||
if (isset($_GET['type']) && $_GET['type']==='form' && isset($myForm->fields[$_GET['variable']]->sql)) {
|
||||
if (isset($_GET['type']) && $_GET['type'] === 'form' && isset($myForm->fields[$_GET['variable']]->sql)) {
|
||||
$sqlQuery = $myForm->fields[$_GET['variable']]->sql;
|
||||
if (isset($myForm->fields[$_GET['variable']]->sqlConnection) && !empty($myForm->fields[$_GET['variable']]->sqlConnection)) {
|
||||
$bdUid = $myForm->fields[$_GET['variable']]->sqlConnection;
|
||||
}
|
||||
} elseif (isset($_GET['type']) && $_GET['type']==='grid' && isset($myForm->fields[$_GET['grid']])) {
|
||||
} elseif (isset($_GET['type']) && $_GET['type'] === 'grid' && isset($myForm->fields[$_GET['grid']])) {
|
||||
foreach ($myForm->fields[$_GET['grid']] as $index => $value) {
|
||||
if (is_array($value) && isset($value[$_GET['variable']])) {
|
||||
$newObj = $value[$_GET['variable']];
|
||||
@@ -89,7 +89,7 @@ if (isset($request)) {
|
||||
$aDependentFieldsKeys = explode("|", base64_decode(str_rot13($_GET['dependentFieldsKeys'])));
|
||||
$aDependentFieldsValue = explode("|", $_GET['dependentFieldsValue']);
|
||||
if ($aDependentFieldsKeys) {
|
||||
$aDependentFields = array();
|
||||
$aDependentFields = [];
|
||||
foreach ($aDependentFieldsKeys as $nKey => $sFieldVar) {
|
||||
$sKeyDepFields = substr($sFieldVar, 2);
|
||||
$aDependentFields[$sKeyDepFields] = $aDependentFieldsValue[$nKey];
|
||||
@@ -105,7 +105,7 @@ if (isset($request)) {
|
||||
// Verify parsed array
|
||||
$sqlQuery = queryModified($parser->parsed, $_GET['input'], $searchType);
|
||||
|
||||
$aRows = Array();
|
||||
$aRows = [];
|
||||
try {
|
||||
$con = Propel::getConnection($bdUid);
|
||||
$con->begin();
|
||||
@@ -122,7 +122,7 @@ if (isset($request)) {
|
||||
$input = strtolower($_GET['input']);
|
||||
$len = strlen($input);
|
||||
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 0;
|
||||
$aResults = array();
|
||||
$aResults = [];
|
||||
$count = 0;
|
||||
$aRows = sortByChar($aRows, $input);
|
||||
|
||||
@@ -213,7 +213,7 @@ if (isset($request)) {
|
||||
}
|
||||
|
||||
// See above. Gross, but it works.
|
||||
$field = mysql_real_escape_string($_GET['fld']);
|
||||
$field = mysqli_real_escape_string($con->getResource(), $_GET['fld']);
|
||||
$field = str_replace("`", "", $field);
|
||||
|
||||
$query = "INSERT INTO $tableName ($primaryKeyField, $field) VALUES (?, ?)"; // '$gKey', '{$_GET['value']}')";
|
||||
@@ -235,8 +235,8 @@ if (isset($request)) {
|
||||
|
||||
function sortByChar($aRows, $charSel)
|
||||
{
|
||||
$aIniChar = array();
|
||||
$aRest = array();
|
||||
$aIniChar = [];
|
||||
$aRest = [];
|
||||
for ($i = 0; $i < count($aRows); $i++) {
|
||||
$aRow = $aRows[$i];
|
||||
$nCols = sizeof($aRow);
|
||||
|
||||
@@ -134,7 +134,7 @@ class Bootstrap
|
||||
|
||||
$filter = new InputFilter();
|
||||
|
||||
$smarty = new Smarty ();
|
||||
$smarty = new Smarty();
|
||||
$smarty->compile_dir = Bootstrap::sys_get_temp_dir();
|
||||
$smarty->cache_dir = Bootstrap::sys_get_temp_dir();
|
||||
$configDir = PATH_THIRDPARTY . 'smarty/configs';
|
||||
@@ -320,7 +320,7 @@ class Bootstrap
|
||||
if ($download) {
|
||||
Bootstrap::sendHeaders($fileNameIni, "text/plain", $download, $downloadFileName);
|
||||
} else {
|
||||
require_once ($filename);
|
||||
require_once($filename);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -334,7 +334,7 @@ class Bootstrap
|
||||
}
|
||||
} else {
|
||||
if (strpos($file, 'gulliver') !== false) {
|
||||
list ($path, $filename) = explode('gulliver', $file);
|
||||
list($path, $filename) = explode('gulliver', $file);
|
||||
}
|
||||
|
||||
$_SESSION['phpFileNotFound'] = $file;
|
||||
@@ -358,7 +358,7 @@ class Bootstrap
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function parseURI($uri, array $arrayFriendlyUri = null)
|
||||
public static function parseURI($uri, array $arrayFriendlyUri = null)
|
||||
{
|
||||
// *** process the $_POST with magic_quotes enabled
|
||||
// The magic_quotes_gpc feature has been DEPRECATED as of PHP 5.3.0.
|
||||
@@ -475,21 +475,21 @@ class Bootstrap
|
||||
*/
|
||||
public static function LoadTranslationObject($lang = SYS_LANG)
|
||||
{
|
||||
$defaultTranslations = Array();
|
||||
$foreignTranslations = Array();
|
||||
$defaultTranslations = array();
|
||||
$foreignTranslations = array();
|
||||
|
||||
// if the default translations table doesn't exist we can't proceed
|
||||
if (!is_file(PATH_LANGUAGECONT . 'translation.en')) {
|
||||
return null;
|
||||
}
|
||||
// load the translations table
|
||||
require_once (PATH_LANGUAGECONT . 'translation.en');
|
||||
require_once(PATH_LANGUAGECONT . 'translation.en');
|
||||
$defaultTranslations = $translation;
|
||||
|
||||
// if some foreign language was requested and its translation file
|
||||
// exists
|
||||
if ($lang != 'en' && file_exists(PATH_LANGUAGECONT . 'translation.' . $lang)) {
|
||||
require_once (PATH_LANGUAGECONT . 'translation.' . $lang); // load the foreign translations table
|
||||
require_once(PATH_LANGUAGECONT . 'translation.' . $lang); // load the foreign translations table
|
||||
$foreignTranslations = $translation;
|
||||
}
|
||||
|
||||
@@ -514,9 +514,9 @@ class Bootstrap
|
||||
* @param array list plugins active
|
||||
* @return void
|
||||
*/
|
||||
public static function LoadTranslationPlugins ($lang = SYS_LANG, $listPluginsActive)
|
||||
public static function LoadTranslationPlugins($lang = SYS_LANG, $listPluginsActive)
|
||||
{
|
||||
if ( ! ( is_array ( $listPluginsActive ) ) ) {
|
||||
if (! (is_array($listPluginsActive))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -528,17 +528,17 @@ class Bootstrap
|
||||
Translation::generateFileTranslationPlugin($namePlugin, 'en');
|
||||
}
|
||||
|
||||
if ( ($lang != 'en') && (!file_exists(PATH_LANGUAGECONT . $namePlugin . '.' . $lang)) ) {
|
||||
if (($lang != 'en') && (!file_exists(PATH_LANGUAGECONT . $namePlugin . '.' . $lang))) {
|
||||
Translation::generateFileTranslationPlugin($namePlugin, $lang);
|
||||
}
|
||||
|
||||
if (file_exists(PATH_LANGUAGECONT . $namePlugin . '.' . $lang)) {
|
||||
eval('global $translation'.$namePlugin.';');
|
||||
require_once (PATH_LANGUAGECONT . $namePlugin . '.' . $lang);
|
||||
require_once(PATH_LANGUAGECONT . $namePlugin . '.' . $lang);
|
||||
} else {
|
||||
if (file_exists(PATH_LANGUAGECONT . $namePlugin . '.en')) {
|
||||
eval('global $translation'.$namePlugin.';');
|
||||
require_once (PATH_LANGUAGECONT . $namePlugin . '.en');
|
||||
require_once(PATH_LANGUAGECONT . $namePlugin . '.en');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -575,7 +575,7 @@ class Bootstrap
|
||||
} catch (Exception $e) {
|
||||
global $G_PUBLISH;
|
||||
if (is_null($G_PUBLISH)) {
|
||||
$G_PUBLISH = new Publisher ();
|
||||
$G_PUBLISH = new Publisher();
|
||||
}
|
||||
if (count($G_PUBLISH->Parts) == 1) {
|
||||
array_shift($G_PUBLISH->Parts);
|
||||
@@ -594,7 +594,7 @@ class Bootstrap
|
||||
} else {
|
||||
$token = strtotime("now");
|
||||
PMException::registerErrorLog($e, $token);
|
||||
G::outRes( G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) );
|
||||
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)));
|
||||
die;
|
||||
}
|
||||
}
|
||||
@@ -676,7 +676,7 @@ class Bootstrap
|
||||
{
|
||||
// Get the current Include path, where the plugins directories should be
|
||||
if (!defined('PATH_SEPARATOR')) {
|
||||
define('PATH_SEPARATOR', (substr(PHP_OS, 0, 3) == 'WIN') ? ';' : ':' );
|
||||
define('PATH_SEPARATOR', (substr(PHP_OS, 0, 3) == 'WIN') ? ';' : ':');
|
||||
}
|
||||
$path = explode(PATH_SEPARATOR, get_include_path());
|
||||
|
||||
@@ -687,7 +687,7 @@ class Bootstrap
|
||||
if ($handle = opendir($baseDir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (strpos($file, '.php', 1) && !strpos($file, 'Peer.php', 1)) {
|
||||
require_once ($baseDir . PATH_SEP . $file);
|
||||
require_once($baseDir . PATH_SEP . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -756,19 +756,19 @@ class Bootstrap
|
||||
$fileConst = ($typeName == 'translation') ? 'translation.' . $locale : 'translation.' . $typeName . '.' . $locale;
|
||||
|
||||
if ($typeName == 'translation') {
|
||||
$defaultTranslations = Array();
|
||||
$foreignTranslations = Array();
|
||||
$defaultTranslations = array();
|
||||
$foreignTranslations = array();
|
||||
$calendarJs = '';
|
||||
|
||||
//load the translations table
|
||||
if (is_file(PATH_LANGUAGECONT . 'translation.en')) {
|
||||
require_once (PATH_LANGUAGECONT . 'translation.en');
|
||||
require_once(PATH_LANGUAGECONT . 'translation.en');
|
||||
$defaultTranslations = $translation;
|
||||
}
|
||||
|
||||
//if some foreign language was requested and its translation file exists
|
||||
if ($locale != 'en' && file_exists(PATH_LANGUAGECONT . 'translation.' . $locale)) {
|
||||
require_once (PATH_LANGUAGECONT . 'translation.' . $locale); //load the foreign translations table
|
||||
require_once(PATH_LANGUAGECONT . 'translation.' . $locale); //load the foreign translations table
|
||||
$foreignTranslations = $translation;
|
||||
}
|
||||
|
||||
@@ -790,7 +790,7 @@ class Bootstrap
|
||||
unset($typearray[count($typearray)]);
|
||||
$newName = implode('.', $typearray);
|
||||
if (file_exists(PATH_LANGUAGECONT . $newName)) {
|
||||
require_once (PATH_LANGUAGECONT . $newName);
|
||||
require_once(PATH_LANGUAGECONT . $newName);
|
||||
$return = '';
|
||||
eval('$return = "var TRANSLATIONS_" . strtoupper($typeName) . " = " . Bootstrap::json_encode($translation' . $typeName . ') . ";";');
|
||||
return $return;
|
||||
@@ -921,8 +921,7 @@ class Bootstrap
|
||||
|
||||
if (((in_array($browserName, $enabledBrowsers)) || (in_array('ALL', $enabledBrowsers))) && (!(in_array($browserName, $disabledBrowsers)))) {
|
||||
if ($cssFileInfo['__ATTRIBUTES__']['file'] == 'rtl.css') {
|
||||
|
||||
$oServerConf = & ServerConf::getSingleton();
|
||||
$oServerConf = ServerConf::getSingleton();
|
||||
if (!(defined('SYS_LANG'))) {
|
||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||
$syss = explode('://', $_SERVER['HTTP_REFERER']);
|
||||
@@ -997,7 +996,6 @@ class Bootstrap
|
||||
}
|
||||
|
||||
if (!$download) {
|
||||
|
||||
header('Pragma: cache');
|
||||
|
||||
if (file_exists($filename)) {
|
||||
@@ -1203,7 +1201,6 @@ class Bootstrap
|
||||
if (function_exists('json_encode')) {
|
||||
return json_encode($Json);
|
||||
} else {
|
||||
|
||||
$oJSON = new Services_JSON();
|
||||
return $oJSON->encode($Json);
|
||||
}
|
||||
@@ -1219,7 +1216,6 @@ class Bootstrap
|
||||
if (function_exists('json_decode')) {
|
||||
return json_decode($Json);
|
||||
} else {
|
||||
|
||||
$oJSON = new Services_JSON();
|
||||
return $oJSON->decode($Json);
|
||||
}
|
||||
@@ -1575,7 +1571,7 @@ class Bootstrap
|
||||
//start the search after the first string occurrence
|
||||
if (strpos($pv_browser_user_agent, $pv_search_string, $start_pos) !== false) {
|
||||
$start_pos = strpos($pv_browser_user_agent, $pv_search_string, $start_pos) + strlen($pv_search_string);
|
||||
if (!$pv_b_break_last || ( $pv_extra_search && strstr($pv_browser_user_agent, $pv_extra_search) )) {
|
||||
if (!$pv_b_break_last || ($pv_extra_search && strstr($pv_browser_user_agent, $pv_extra_search))) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -1683,7 +1679,7 @@ class Bootstrap
|
||||
$os_working_type = 'nt';
|
||||
} elseif (strstr($pv_browser_string, '95')) {
|
||||
$os_working_number = '95';
|
||||
} elseif (( strstr($pv_browser_string, '9x 4.9') ) || ( strstr($pv_browser_string, ' me') )) {
|
||||
} elseif ((strstr($pv_browser_string, '9x 4.9')) || (strstr($pv_browser_string, ' me'))) {
|
||||
$os_working_number = 'me';
|
||||
} elseif (strstr($pv_browser_string, '98')) {
|
||||
$os_working_number = '98';
|
||||
@@ -1699,9 +1695,9 @@ class Bootstrap
|
||||
} else {
|
||||
$os_working_number = 10;
|
||||
}
|
||||
} elseif (( $pv_browser_name == 'saf' ) || ( $pv_browser_name == 'cam' ) ||
|
||||
( ( $pv_browser_name == 'moz' ) && ( $pv_version_number >= 1.3 ) ) ||
|
||||
( ( $pv_browser_name == 'ie' ) && ( $pv_version_number >= 5.2 ) )) {
|
||||
} elseif (($pv_browser_name == 'saf') || ($pv_browser_name == 'cam') ||
|
||||
(($pv_browser_name == 'moz') && ($pv_version_number >= 1.3)) ||
|
||||
(($pv_browser_name == 'ie') && ($pv_version_number >= 5.2))) {
|
||||
$os_working_number = 10;
|
||||
}
|
||||
break;
|
||||
@@ -1712,23 +1708,23 @@ class Bootstrap
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} elseif (is_array($os_working_data) && ( $i == ( $i_count - 2 ) )) {
|
||||
} elseif (is_array($os_working_data) && ($i == ($i_count - 2))) {
|
||||
$j_count = count($os_working_data);
|
||||
for ($j = 0; $j < $j_count; $j++) {
|
||||
if (strstr($pv_browser_string, $os_working_data[$j])) {
|
||||
$os_working_type = 'unix'; //if the os is in the unix array, it's unix, obviously...
|
||||
$os_working_number = ( $os_working_data[$j] != 'unix' ) ? $os_working_data[$j] : ''; // assign sub unix version from the unix array
|
||||
$os_working_number = ($os_working_data[$j] != 'unix') ? $os_working_data[$j] : ''; // assign sub unix version from the unix array
|
||||
break;
|
||||
}
|
||||
}
|
||||
} elseif (is_array($os_working_data) && ( $i == ( $i_count - 1 ))) {
|
||||
} elseif (is_array($os_working_data) && ($i == ($i_count - 1))) {
|
||||
$j_count = count($os_working_data);
|
||||
for ($j = 0; $j < $j_count; $j++) {
|
||||
if (strstr($pv_browser_string, $os_working_data[$j])) {
|
||||
$os_working_type = 'lin';
|
||||
// assign linux distro from the linux array, there's a default
|
||||
//search for 'lin', if it's that, set version to ''
|
||||
$os_working_number = ( $os_working_data[$j] != 'linux' ) ? $os_working_data[$j] : '';
|
||||
$os_working_number = ($os_working_data[$j] != 'linux') ? $os_working_data[$j] : '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1827,7 +1823,7 @@ class Bootstrap
|
||||
}
|
||||
}
|
||||
// just for cases where we know it's a mobile device already
|
||||
if (!$mobile_os && ( $mobile_browser || $mobile_device || $mobile_server ) && strstr($pv_browser_user_agent, 'linux')) {
|
||||
if (!$mobile_os && ($mobile_browser || $mobile_device || $mobile_server) && strstr($pv_browser_user_agent, 'linux')) {
|
||||
$mobile_os = 'linux';
|
||||
$mobile_os_number = Bootstrap::get_item_version($pv_browser_user_agent, 'linux');
|
||||
}
|
||||
@@ -2176,7 +2172,7 @@ class Bootstrap
|
||||
switch ($DBEngine) {
|
||||
case 'mysql':
|
||||
$con = Propel::getConnection('workflow');
|
||||
return mysql_real_escape_string(stripslashes($sqlString), $con->getResource());
|
||||
return mysqli_real_escape_string($con->getResource(), stripslashes($sqlString));
|
||||
break;
|
||||
case 'myxml':
|
||||
$sqlString = str_replace('"', '""', $sqlString);
|
||||
@@ -2207,13 +2203,13 @@ class Bootstrap
|
||||
// Check if its a user template
|
||||
if (file_exists($file)) {
|
||||
//require_once( $file );
|
||||
include ($file);
|
||||
include($file);
|
||||
} else {
|
||||
// Try to get the global system template
|
||||
$file = PATH_TEMPLATE . PATH_SEP . $temp;
|
||||
//require_once( $file );
|
||||
if (file_exists($file)) {
|
||||
include ($file);
|
||||
include($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2295,8 +2291,8 @@ class Bootstrap
|
||||
$lang = defined(SYS_LANG) ? SYS_LANG : 'en';
|
||||
}
|
||||
$aux = explode(' ', $date); //para dividir la fecha del dia
|
||||
$date = explode('-', isset($aux[0]) ? $aux[0] : '00-00-00' ); //para obtener los dias, el mes, y el año.
|
||||
$time = explode(':', isset($aux[1]) ? $aux[1] : '00:00:00' ); //para obtener las horas, minutos, segundos.
|
||||
$date = explode('-', isset($aux[0]) ? $aux[0] : '00-00-00'); //para obtener los dias, el mes, y el año.
|
||||
$time = explode(':', isset($aux[1]) ? $aux[1] : '00:00:00'); //para obtener las horas, minutos, segundos.
|
||||
|
||||
|
||||
$year = (int) ((isset($date[0])) ? $date[0] : '0'); //year
|
||||
@@ -2309,7 +2305,7 @@ class Bootstrap
|
||||
$s = isset($time[2]) ? $time[2] : '00'; //second
|
||||
|
||||
|
||||
$MONTHS = Array();
|
||||
$MONTHS = array();
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$MONTHS[$i] = Bootstrap::LoadTranslation("ID_MONTH_$i", $lang);
|
||||
}
|
||||
@@ -2418,7 +2414,7 @@ class Bootstrap
|
||||
*/
|
||||
public function evalJScript($c)
|
||||
{
|
||||
print ("<script language=\"javascript\">{$c}</script>");
|
||||
print("<script language=\"javascript\">{$c}</script>");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2595,13 +2591,13 @@ class Bootstrap
|
||||
//To enable compatibility with soap login
|
||||
if ((Bootstrap::hashPassword($pass, $hashTypeCurrent) == $userPass) || ($pass === $hashTypeCurrent . ':' . $userPass)) {
|
||||
$acceptance = true;
|
||||
} else if ((Bootstrap::hashPassword($pass, $hashTypePrevious) == $userPass) || ($pass === $hashTypePrevious . ':' . $userPass)) {
|
||||
} elseif ((Bootstrap::hashPassword($pass, $hashTypePrevious) == $userPass) || ($pass === $hashTypePrevious . ':' . $userPass)) {
|
||||
$acceptance = true;
|
||||
}
|
||||
} else {
|
||||
if (Bootstrap::hashPassword($pass, $hashTypeCurrent) == $userPass) {
|
||||
$acceptance = true;
|
||||
} else if (Bootstrap::hashPassword($pass, $hashTypePrevious) == $userPass) {
|
||||
} elseif (Bootstrap::hashPassword($pass, $hashTypePrevious) == $userPass) {
|
||||
$acceptance = true;
|
||||
}
|
||||
}
|
||||
@@ -2613,7 +2609,7 @@ class Bootstrap
|
||||
* @param $string
|
||||
* @return mixed
|
||||
*/
|
||||
public function encryptOld ($string)
|
||||
public function encryptOld($string)
|
||||
{
|
||||
$consthashFx = self::hashFx;
|
||||
return $consthashFx($string);
|
||||
@@ -2630,7 +2626,7 @@ class Bootstrap
|
||||
$translationsTable = $Translations->getTranslationEnvironments();
|
||||
$inLang = false;
|
||||
foreach ($translationsTable as $locale) {
|
||||
if ($locale['LOCALE'] == $acceptLanguage){
|
||||
if ($locale['LOCALE'] == $acceptLanguage) {
|
||||
$inLang = true;
|
||||
break;
|
||||
}
|
||||
@@ -2638,7 +2634,6 @@ class Bootstrap
|
||||
$lang = $inLang?$acceptLanguage:'en';
|
||||
define("SYS_LANG", $lang);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2672,7 +2667,7 @@ class Bootstrap
|
||||
{
|
||||
$fileLog = $pathData .'sites'. PATH_SEP . $ws . PATH_SEP . 'log' . PATH_SEP . $file;
|
||||
|
||||
$registerLogger = &MonologProvider::getSingleton($channel, $fileLog);
|
||||
$registerLogger = MonologProvider::getSingleton($channel, $fileLog);
|
||||
$registerLogger->addLog($level, $message, $context);
|
||||
}
|
||||
|
||||
@@ -2747,6 +2742,4 @@ class Bootstrap
|
||||
}
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . PATH_DATA_SITE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,326 +1,325 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Controller Class
|
||||
* Implementing MVC Pattern
|
||||
*
|
||||
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
||||
* @package gulliver.system
|
||||
* @access private
|
||||
*/
|
||||
class Controller
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var boolean debug switch for general purpose
|
||||
*/
|
||||
public $debug = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array - private array to store proxy data
|
||||
*/
|
||||
private $__data__ = array ();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var object - private object to store the http request data
|
||||
*/
|
||||
private $__request__;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var object - headPublisher object to handle the output
|
||||
*/
|
||||
private $headPublisher = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string - response type var. possibles values: json|plain
|
||||
*/
|
||||
private $responseType = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string - layout to pass skinEngine
|
||||
*/
|
||||
private $layout = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string contains the pluin name, in case the controller is on a plugin
|
||||
*/
|
||||
private $pluginName = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string contains the plugin path
|
||||
*/
|
||||
private $pluginHomeDir = '';
|
||||
|
||||
/**
|
||||
* Magic setter method
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function __set ($name, $value)
|
||||
{
|
||||
$this->__data__[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter method
|
||||
*
|
||||
* @param string $name
|
||||
* @return string or NULL if the internal var doesn't exist
|
||||
*/
|
||||
public function __get ($name)
|
||||
{
|
||||
if (array_key_exists( $name, $this->__data__ )) {
|
||||
return $this->__data__[$name];
|
||||
}
|
||||
|
||||
$trace = debug_backtrace();
|
||||
trigger_error( 'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE );
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic isset method
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __isset ($name)
|
||||
{
|
||||
return isset( $this->__data__[$name] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic unset method
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __unset ($name)
|
||||
{
|
||||
unset( $this->__data__[$name] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Response type method
|
||||
*
|
||||
* @param string $type contains : json|plain
|
||||
*/
|
||||
public function setResponseType ($type)
|
||||
{
|
||||
$this->responseType = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* call to execute a internal proxy method and handle its exceptions
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function call ($name)
|
||||
{
|
||||
try {
|
||||
$result = $this->$name( $this->__request__ );
|
||||
if ($this->responseType == 'json') {
|
||||
print G::json_encode( $result );
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$result = new StdClass();
|
||||
if ($this->responseType != 'json') {
|
||||
Bootstrap::renderTemplate('controller.exception.tpl', array(
|
||||
'title' => 'Controller Exception',
|
||||
'message' => nl2br($e->getMessage()),
|
||||
'controller' => (function_exists( 'get_called_class' ) ? get_called_class() : 'Controller'),
|
||||
'exceptionClass' => get_class($e),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'trace' => $e->getTrace()
|
||||
));
|
||||
} else {
|
||||
$result->success = false;
|
||||
$result->msg = $e->getMessage();
|
||||
switch (get_class( $e )) {
|
||||
case 'Exception':
|
||||
$error = "SYSTEM ERROR";
|
||||
break;
|
||||
case 'PMException':
|
||||
$error = "PROCESSMAKER ERROR";
|
||||
break;
|
||||
case 'PropelException':
|
||||
$error = "DATABASE ERROR";
|
||||
break;
|
||||
case 'UserException':
|
||||
$error = "USER ERROR";
|
||||
break;
|
||||
}
|
||||
$result->error = $error;
|
||||
|
||||
$result->exception->class = get_class( $e );
|
||||
$result->exception->code = $e->getCode();
|
||||
print G::json_encode( $result );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the http request data
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function setHttpRequestData ($data)
|
||||
{
|
||||
if (! is_object( $this->__request__ )) {
|
||||
$this->__request__ = new stdclass();
|
||||
}
|
||||
if (is_array( $data )) {
|
||||
while ($var = each( $data )) {
|
||||
$this->__request__->$var['key'] = $var['value'];
|
||||
}
|
||||
} else {
|
||||
$this->__request__ = $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get debug var.
|
||||
* method
|
||||
*
|
||||
* @param boolan $val boolean value for debug var.
|
||||
*/
|
||||
public function setDebug ($val)
|
||||
{
|
||||
$this->debug = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get debug var.
|
||||
* method
|
||||
*/
|
||||
public function getDebug ()
|
||||
{
|
||||
if ($this->debug === null) {
|
||||
$this->debug = defined( 'DEBUG' ) && DEBUG ? true : false;
|
||||
}
|
||||
|
||||
return $this->debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* * HeadPublisher Functions Binding **
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include a particular extjs library or extension to the main output
|
||||
*
|
||||
* @param string $srcFile path of a extjs library or extension
|
||||
* @param boolean $debug debug flag to indicate if the js output will be minifield or not
|
||||
* $debug: true -> the js content will be not minified (readable)
|
||||
* false -> the js content will be minified
|
||||
*/
|
||||
public function includeExtJSLib ($srcFile, $debug = false)
|
||||
{
|
||||
$this->getHeadPublisher()->usingExtJs( $srcFile, ($debug ? $debug : $this->getDebug()) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Include a javascript file that is using extjs framework to the main output
|
||||
*
|
||||
* @param string $srcFile path of javascrit file to include
|
||||
* @param boolean $debug debug flag to indicate if the js output will be minifield or not
|
||||
* $debug: true -> the js content will be not minified (readable)
|
||||
* false -> the js content will be minified
|
||||
*/
|
||||
public function includeExtJS ($srcFile, $debug = false)
|
||||
{
|
||||
$this->getHeadPublisher()->addExtJsScript( $srcFile, ($debug ? $debug : $this->getDebug()) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Include a Html file to the main output
|
||||
*
|
||||
* @param string $file path of html file to include to the main output
|
||||
*/
|
||||
public function setView ($file)
|
||||
{
|
||||
$this->getHeadPublisher()->addContent( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set variables to be accesible by javascripts
|
||||
*
|
||||
* @param string $name contains var. name
|
||||
* @param string $value conatins var. value
|
||||
*/
|
||||
public function setJSVar ($name, $value)
|
||||
{
|
||||
$this->getHeadPublisher()->assign( $name, $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set variables to be accesible by the extjs layout template
|
||||
*
|
||||
* @param string $name contains var. name
|
||||
* @param string $value conatins var. value
|
||||
*/
|
||||
public function setVar ($name, $value)
|
||||
{
|
||||
$this->getHeadPublisher()->assignVar( $name, $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* method to get the local getHeadPublisher object
|
||||
*/
|
||||
public function getHeadPublisher ()
|
||||
{
|
||||
if (! is_object( $this->headPublisher )) {
|
||||
$this->headPublisher = headPublisher::getSingleton();
|
||||
}
|
||||
|
||||
return $this->headPublisher;
|
||||
}
|
||||
|
||||
public function setLayout ($layout)
|
||||
{
|
||||
$this->layout = $layout;
|
||||
}
|
||||
|
||||
public function render ($type = 'mvc')
|
||||
{
|
||||
G::RenderPage( 'publish', $type, null, $this->layout );
|
||||
}
|
||||
|
||||
public function header ($header)
|
||||
{
|
||||
G::header( $header );
|
||||
}
|
||||
|
||||
public function redirect ($url)
|
||||
{
|
||||
G::header( "Location: $url" );
|
||||
}
|
||||
|
||||
public function setPluginName($name)
|
||||
{
|
||||
$this->pluginName = $name;
|
||||
}
|
||||
|
||||
public function getPluginName()
|
||||
{
|
||||
return $this->pluginName;
|
||||
}
|
||||
|
||||
public function setPluginHomeDir($dir)
|
||||
{
|
||||
$this->pluginHomeDir = $dir;
|
||||
}
|
||||
|
||||
public function getPluginHomeDir()
|
||||
{
|
||||
return $this->pluginHomeDir;
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Controller Class
|
||||
* Implementing MVC Pattern
|
||||
*
|
||||
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
||||
* @package gulliver.system
|
||||
* @access private
|
||||
*/
|
||||
class Controller
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var boolean debug switch for general purpose
|
||||
*/
|
||||
public $debug = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array - private array to store proxy data
|
||||
*/
|
||||
private $__data__ = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var object - private object to store the http request data
|
||||
*/
|
||||
private $__request__;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var object - headPublisher object to handle the output
|
||||
*/
|
||||
private $headPublisher = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string - response type var. possibles values: json|plain
|
||||
*/
|
||||
private $responseType = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string - layout to pass skinEngine
|
||||
*/
|
||||
private $layout = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string contains the pluin name, in case the controller is on a plugin
|
||||
*/
|
||||
private $pluginName = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string contains the plugin path
|
||||
*/
|
||||
private $pluginHomeDir = '';
|
||||
|
||||
/**
|
||||
* Magic setter method
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->__data__[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter method
|
||||
*
|
||||
* @param string $name
|
||||
* @return string or NULL if the internal var doesn't exist
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (array_key_exists($name, $this->__data__)) {
|
||||
return $this->__data__[$name];
|
||||
}
|
||||
|
||||
$trace = debug_backtrace();
|
||||
trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic isset method
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
return isset($this->__data__[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic unset method
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __unset($name)
|
||||
{
|
||||
unset($this->__data__[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Response type method
|
||||
*
|
||||
* @param string $type contains : json|plain
|
||||
*/
|
||||
public function setResponseType($type)
|
||||
{
|
||||
$this->responseType = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* call to execute a internal proxy method and handle its exceptions
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function call($name)
|
||||
{
|
||||
try {
|
||||
$result = $this->$name($this->__request__);
|
||||
if ($this->responseType == 'json') {
|
||||
print G::json_encode($result);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$result = new StdClass();
|
||||
if ($this->responseType != 'json') {
|
||||
Bootstrap::renderTemplate('controller.exception.tpl', array(
|
||||
'title' => 'Controller Exception',
|
||||
'message' => nl2br($e->getMessage()),
|
||||
'controller' => (function_exists('get_called_class') ? get_called_class() : 'Controller'),
|
||||
'exceptionClass' => get_class($e),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'trace' => $e->getTrace()
|
||||
));
|
||||
} else {
|
||||
$result->success = false;
|
||||
$result->msg = $e->getMessage();
|
||||
switch (get_class($e)) {
|
||||
case 'Exception':
|
||||
$error = "SYSTEM ERROR";
|
||||
break;
|
||||
case 'PMException':
|
||||
$error = "PROCESSMAKER ERROR";
|
||||
break;
|
||||
case 'PropelException':
|
||||
$error = "DATABASE ERROR";
|
||||
break;
|
||||
case 'UserException':
|
||||
$error = "USER ERROR";
|
||||
break;
|
||||
}
|
||||
$result->error = $error;
|
||||
|
||||
$result->exception->class = get_class($e);
|
||||
$result->exception->code = $e->getCode();
|
||||
print G::json_encode($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the http request data
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function setHttpRequestData($data)
|
||||
{
|
||||
if (! is_object($this->__request__)) {
|
||||
$this->__request__ = new stdclass();
|
||||
}
|
||||
if (is_array($data)) {
|
||||
while ($var = each($data)) {
|
||||
$this->__request__->{$var['key']} = $var['value'];
|
||||
}
|
||||
} else {
|
||||
$this->__request__ = $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get debug var.
|
||||
* method
|
||||
*
|
||||
* @param boolan $val boolean value for debug var.
|
||||
*/
|
||||
public function setDebug($val)
|
||||
{
|
||||
$this->debug = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get debug var.
|
||||
* method
|
||||
*/
|
||||
public function getDebug()
|
||||
{
|
||||
if ($this->debug === null) {
|
||||
$this->debug = defined('DEBUG') && DEBUG ? true : false;
|
||||
}
|
||||
|
||||
return $this->debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* * HeadPublisher Functions Binding **
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include a particular extjs library or extension to the main output
|
||||
*
|
||||
* @param string $srcFile path of a extjs library or extension
|
||||
* @param boolean $debug debug flag to indicate if the js output will be minifield or not
|
||||
* $debug: true -> the js content will be not minified (readable)
|
||||
* false -> the js content will be minified
|
||||
*/
|
||||
public function includeExtJSLib($srcFile, $debug = false)
|
||||
{
|
||||
$this->getHeadPublisher()->usingExtJs($srcFile, ($debug ? $debug : $this->getDebug()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Include a javascript file that is using extjs framework to the main output
|
||||
*
|
||||
* @param string $srcFile path of javascrit file to include
|
||||
* @param boolean $debug debug flag to indicate if the js output will be minifield or not
|
||||
* $debug: true -> the js content will be not minified (readable)
|
||||
* false -> the js content will be minified
|
||||
*/
|
||||
public function includeExtJS($srcFile, $debug = false)
|
||||
{
|
||||
$this->getHeadPublisher()->addExtJsScript($srcFile, ($debug ? $debug : $this->getDebug()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Include a Html file to the main output
|
||||
*
|
||||
* @param string $file path of html file to include to the main output
|
||||
*/
|
||||
public function setView($file)
|
||||
{
|
||||
$this->getHeadPublisher()->addContent($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set variables to be accesible by javascripts
|
||||
*
|
||||
* @param string $name contains var. name
|
||||
* @param string $value conatins var. value
|
||||
*/
|
||||
public function setJSVar($name, $value)
|
||||
{
|
||||
$this->getHeadPublisher()->assign($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set variables to be accesible by the extjs layout template
|
||||
*
|
||||
* @param string $name contains var. name
|
||||
* @param string $value conatins var. value
|
||||
*/
|
||||
public function setVar($name, $value)
|
||||
{
|
||||
$this->getHeadPublisher()->assignVar($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* method to get the local getHeadPublisher object
|
||||
*/
|
||||
public function getHeadPublisher()
|
||||
{
|
||||
if (! is_object($this->headPublisher)) {
|
||||
$this->headPublisher = headPublisher::getSingleton();
|
||||
}
|
||||
|
||||
return $this->headPublisher;
|
||||
}
|
||||
|
||||
public function setLayout($layout)
|
||||
{
|
||||
$this->layout = $layout;
|
||||
}
|
||||
|
||||
public function render($type = 'mvc')
|
||||
{
|
||||
G::RenderPage('publish', $type, null, $this->layout);
|
||||
}
|
||||
|
||||
public function header($header)
|
||||
{
|
||||
G::header($header);
|
||||
}
|
||||
|
||||
public function redirect($url)
|
||||
{
|
||||
G::header("Location: $url");
|
||||
}
|
||||
|
||||
public function setPluginName($name)
|
||||
{
|
||||
$this->pluginName = $name;
|
||||
}
|
||||
|
||||
public function getPluginName()
|
||||
{
|
||||
return $this->pluginName;
|
||||
}
|
||||
|
||||
public function setPluginHomeDir($dir)
|
||||
{
|
||||
$this->pluginHomeDir = $dir;
|
||||
}
|
||||
|
||||
public function getPluginHomeDir()
|
||||
{
|
||||
return $this->pluginHomeDir;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,31 +30,27 @@
|
||||
* @package gulliver.system
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class database extends database_base
|
||||
{
|
||||
|
||||
public $iFetchType = MYSQL_ASSOC;
|
||||
public $iFetchType = MYSQLI_ASSOC;
|
||||
|
||||
/**
|
||||
* class database constructor
|
||||
* class database constructor.
|
||||
*
|
||||
* @param $sType adapter type
|
||||
* @param $sServer server
|
||||
* @param $sUser db user
|
||||
* @param $sPass db user password
|
||||
* @param $sDataBase Database name
|
||||
* @param string $sType adapter type
|
||||
* @param string $sServer server
|
||||
* @param string $sUser db user
|
||||
* @param string $sPass db user password
|
||||
* @param string $sDataBase Database name
|
||||
*/
|
||||
public function __construct ($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME)
|
||||
public function __construct($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME)
|
||||
{
|
||||
$this->sType = $sType;
|
||||
$this->sServer = $sServer;
|
||||
$this->sUser = $sUser;
|
||||
$this->sPass = $sPass;
|
||||
$this->sDataBase = $sDataBase;
|
||||
$this->oConnection = @mysql_connect( $sServer, $sUser, $sPass ) || null;
|
||||
$this->oConnection = mysqli_connect($sServer, $sUser, $sPass, $sDataBase) or die('Could not connect to database...');
|
||||
$this->sQuoteCharacter = '`';
|
||||
$this->nullString = 'null';
|
||||
}
|
||||
@@ -66,30 +62,29 @@ class database extends database_base
|
||||
* @param $aColumns array of columns
|
||||
* @return $sSql the sql sentence
|
||||
*/
|
||||
public function generateCreateTableSQL ($sTable, $aColumns)
|
||||
public function generateCreateTableSQL($sTable, $aColumns)
|
||||
{
|
||||
$sKeys = '';
|
||||
$sSQL = 'CREATE TABLE IF NOT EXISTS ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . '(';
|
||||
|
||||
foreach ($aColumns as $sColumnName => $aParameters) {
|
||||
if ($sColumnName != 'INDEXES') {
|
||||
|
||||
if ($sColumnName != '' && isset( $aParameters['Type'] ) && $aParameters['Type'] != '') {
|
||||
if ($sColumnName != '' && isset($aParameters['Type']) && $aParameters['Type'] != '') {
|
||||
$sSQL .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ' ' . $aParameters['Type'];
|
||||
|
||||
if (isset( $aParameters['Null'] ) && $aParameters['Null'] == 'YES') {
|
||||
if (isset($aParameters['Null']) && $aParameters['Null'] == 'YES') {
|
||||
$sSQL .= ' NULL';
|
||||
} else {
|
||||
$sSQL .= ' NOT NULL';
|
||||
$sSQL .= ' NOT NULL';
|
||||
}
|
||||
if (isset( $aParameters['AutoIncrement'] ) && $aParameters['AutoIncrement']) {
|
||||
if (isset($aParameters['AutoIncrement']) && $aParameters['AutoIncrement']) {
|
||||
$sSQL .= ' AUTO_INCREMENT PRIMARY KEY';
|
||||
}
|
||||
if (isset( $aParameters['Key'] ) && $aParameters['Key'] == 'PRI') {
|
||||
if (isset($aParameters['Key']) && $aParameters['Key'] == 'PRI') {
|
||||
$sKeys .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ',';
|
||||
}
|
||||
|
||||
if (isset( $aParameters['Default'] )) {
|
||||
if (isset($aParameters['Default'])) {
|
||||
$sSQL .= " DEFAULT '" . trim($aParameters['Default']) . "'";
|
||||
}
|
||||
|
||||
@@ -97,9 +92,9 @@ class database extends database_base
|
||||
}
|
||||
}
|
||||
}
|
||||
$sSQL = substr( $sSQL, 0, - 1 );
|
||||
$sSQL = substr($sSQL, 0, -1);
|
||||
if ($sKeys != '') {
|
||||
$sSQL .= ',PRIMARY KEY(' . substr( $sKeys, 0, - 1 ) . ')';
|
||||
$sSQL .= ',PRIMARY KEY(' . substr($sKeys, 0, -1) . ')';
|
||||
}
|
||||
$sSQL .= ')ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci' . $this->sEndLine;
|
||||
|
||||
@@ -112,7 +107,7 @@ class database extends database_base
|
||||
* @param $sTable table name
|
||||
* @return sql sentence string
|
||||
*/
|
||||
public function generateDropTableSQL ($sTable)
|
||||
public function generateDropTableSQL($sTable)
|
||||
{
|
||||
return 'DROP TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine;
|
||||
}
|
||||
@@ -123,7 +118,7 @@ class database extends database_base
|
||||
* @param $sTableOld old table name
|
||||
* @return $sSql sql sentence
|
||||
*/
|
||||
public function generateRenameTableSQL ($sTableOld)
|
||||
public function generateRenameTableSQL($sTableOld)
|
||||
{
|
||||
$sSQL = 'ALTER TABLE ' . $sTableOld . ' RENAME TO RBAC_' . $sTableOld;
|
||||
return $sSQL;
|
||||
@@ -136,7 +131,7 @@ class database extends database_base
|
||||
* @param $sColumn column name
|
||||
* @return $sSql sql sentence
|
||||
*/
|
||||
public function generateDropColumnSQL ($sTable, $sColumn)
|
||||
public function generateDropColumnSQL($sTable, $sColumn)
|
||||
{
|
||||
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . $this->sEndLine;
|
||||
return $sSQL;
|
||||
@@ -187,7 +182,6 @@ class database extends database_base
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* generate an add column sentence
|
||||
*
|
||||
@@ -196,9 +190,9 @@ class database extends database_base
|
||||
* @param $aParameters parameters of field like typo or if it can be null
|
||||
* @return $sSql sql sentence
|
||||
*/
|
||||
public function generateAddColumnSQL ($sTable, $sColumn, $aParameters)
|
||||
public function generateAddColumnSQL($sTable, $sColumn, $aParameters)
|
||||
{
|
||||
if (isset( $aParameters['Type'] ) && isset( $aParameters['Null'] )) {
|
||||
if (isset($aParameters['Type']) && isset($aParameters['Null'])) {
|
||||
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . ' ' . $aParameters['Type'];
|
||||
if ($aParameters['Null'] == 'YES') {
|
||||
$sSQL .= ' NULL';
|
||||
@@ -206,18 +200,18 @@ class database extends database_base
|
||||
$sSQL .= ' NOT NULL';
|
||||
}
|
||||
}
|
||||
if (isset( $aParameters['AutoIncrement'] ) && $aParameters['AutoIncrement']) {
|
||||
if (isset($aParameters['AutoIncrement']) && $aParameters['AutoIncrement']) {
|
||||
$sSQL .= ' AUTO_INCREMENT';
|
||||
}
|
||||
if (isset( $aParameters['PrimaryKey'] ) && $aParameters['PrimaryKey']) {
|
||||
if (isset($aParameters['PrimaryKey']) && $aParameters['PrimaryKey']) {
|
||||
$sSQL .= ' PRIMARY KEY';
|
||||
}
|
||||
if (isset( $aParameters['Unique'] ) && $aParameters['Unique']) {
|
||||
if (isset($aParameters['Unique']) && $aParameters['Unique']) {
|
||||
$sSQL .= ' UNIQUE';
|
||||
}
|
||||
|
||||
//we need to check the property AI
|
||||
if (isset( $aParameters['AI'] )) {
|
||||
if (isset($aParameters['AI'])) {
|
||||
if ($aParameters['AI'] == 1) {
|
||||
$sSQL .= ' AUTO_INCREMENT';
|
||||
} else {
|
||||
@@ -226,7 +220,7 @@ class database extends database_base
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset( $aParameters['Default'] )) {
|
||||
if (isset($aParameters['Default'])) {
|
||||
$sSQL .= " DEFAULT '" . $aParameters['Default'] . "'";
|
||||
}
|
||||
}
|
||||
@@ -243,13 +237,13 @@ class database extends database_base
|
||||
* @param $sColumnNewName column new name
|
||||
* @return $sSql sql sentence
|
||||
*/
|
||||
public function generateChangeColumnSQL ($sTable, $sColumn, $aParameters, $sColumnNewName = '')
|
||||
public function generateChangeColumnSQL($sTable, $sColumn, $aParameters, $sColumnNewName = '')
|
||||
{
|
||||
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' CHANGE COLUMN ' . $this->sQuoteCharacter . ($sColumnNewName != '' ? $sColumnNewName : $sColumn) . $this->sQuoteCharacter . ' ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter;
|
||||
if (isset( $aParameters['Type'] )) {
|
||||
if (isset($aParameters['Type'])) {
|
||||
$sSQL .= ' ' . $aParameters['Type'];
|
||||
}
|
||||
if (isset( $aParameters['Null'] )) {
|
||||
if (isset($aParameters['Null'])) {
|
||||
if ($aParameters['Null'] == 'YES') {
|
||||
$sSQL .= ' NULL';
|
||||
} else {
|
||||
@@ -269,15 +263,15 @@ class database extends database_base
|
||||
// }
|
||||
//}
|
||||
//else {
|
||||
if (isset( $aParameters['Default'] )) {
|
||||
if (trim( $aParameters['Default'] ) == '' && $aParameters['Type'] == 'datetime') {
|
||||
if (isset($aParameters['Default'])) {
|
||||
if (trim($aParameters['Default']) == '' && $aParameters['Type'] == 'datetime') {
|
||||
//do nothing
|
||||
} else {
|
||||
$sSQL .= " DEFAULT '" . $aParameters['Default'] . "'";
|
||||
}
|
||||
//}
|
||||
}
|
||||
if (! isset( $aParameters['Default'] ) && isset( $aParameters['Null'] ) && $aParameters['Null'] == 'YES') {
|
||||
if (!isset($aParameters['Default']) && isset($aParameters['Null']) && $aParameters['Null'] == 'YES') {
|
||||
$sSQL .= " DEFAULT NULL ";
|
||||
}
|
||||
//}
|
||||
@@ -291,11 +285,11 @@ class database extends database_base
|
||||
* @param $sTable table name
|
||||
* @return $sSql sql sentence
|
||||
*/
|
||||
public function generateGetPrimaryKeysSQL ($sTable)
|
||||
public function generateGetPrimaryKeysSQL($sTable)
|
||||
{
|
||||
try {
|
||||
if ($sTable == '') {
|
||||
throw new Exception( 'The table name cannot be empty!' );
|
||||
throw new Exception('The table name cannot be empty!');
|
||||
}
|
||||
return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' WHERE Seq_in_index = 1' . $this->sEndLine;
|
||||
} catch (Exception $oException) {
|
||||
@@ -309,11 +303,11 @@ class database extends database_base
|
||||
* @param $sTable table name
|
||||
* @return sql sentence
|
||||
*/
|
||||
public function generateDropPrimaryKeysSQL ($sTable)
|
||||
public function generateDropPrimaryKeysSQL($sTable)
|
||||
{
|
||||
try {
|
||||
if ($sTable == '') {
|
||||
throw new Exception( 'The table name cannot be empty!' );
|
||||
throw new Exception('The table name cannot be empty!');
|
||||
}
|
||||
return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP PRIMARY KEY' . $this->sEndLine;
|
||||
} catch (Exception $oException) {
|
||||
@@ -328,17 +322,17 @@ class database extends database_base
|
||||
* @param $aPrimaryKeys array of primary keys
|
||||
* @return sql sentence
|
||||
*/
|
||||
public function generateAddPrimaryKeysSQL ($sTable, $aPrimaryKeys)
|
||||
public function generateAddPrimaryKeysSQL($sTable, $aPrimaryKeys)
|
||||
{
|
||||
try {
|
||||
if ($sTable == '') {
|
||||
throw new Exception( 'The table name cannot be empty!' );
|
||||
throw new Exception('The table name cannot be empty!');
|
||||
}
|
||||
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' ADD PRIMARY KEY (';
|
||||
foreach ($aPrimaryKeys as $sKey) {
|
||||
$sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ',';
|
||||
}
|
||||
$sSQL = substr( $sSQL, 0, - 1 ) . ')' . $this->sEndLine;
|
||||
$sSQL = substr($sSQL, 0, -1) . ')' . $this->sEndLine;
|
||||
return $sSQL;
|
||||
} catch (Exception $oException) {
|
||||
throw $oException;
|
||||
@@ -352,14 +346,14 @@ class database extends database_base
|
||||
* @param $sIndexName index name
|
||||
* @return sql sentence
|
||||
*/
|
||||
public function generateDropKeySQL ($sTable, $sIndexName)
|
||||
public function generateDropKeySQL($sTable, $sIndexName)
|
||||
{
|
||||
try {
|
||||
if ($sTable == '') {
|
||||
throw new Exception( 'The table name cannot be empty!' );
|
||||
throw new Exception('The table name cannot be empty!');
|
||||
}
|
||||
if ($sIndexName == '') {
|
||||
throw new Exception( 'The column name cannot be empty!' );
|
||||
throw new Exception('The column name cannot be empty!');
|
||||
}
|
||||
return 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . ' DROP INDEX ' . $this->sQuoteCharacter . $sIndexName . $this->sQuoteCharacter . $this->sEndLine;
|
||||
} catch (Exception $oException) {
|
||||
@@ -376,7 +370,7 @@ class database extends database_base
|
||||
* @return sql sentence
|
||||
*/
|
||||
|
||||
public function generateAddKeysSQL ($sTable, $indexName, $aKeys)
|
||||
public function generateAddKeysSQL($sTable, $indexName, $aKeys)
|
||||
{
|
||||
try {
|
||||
$indexType = 'INDEX';
|
||||
@@ -388,7 +382,7 @@ class database extends database_base
|
||||
foreach ($aKeys as $sKey) {
|
||||
$sSQL .= $this->sQuoteCharacter . $sKey . $this->sQuoteCharacter . ', ';
|
||||
}
|
||||
$sSQL = substr( $sSQL, 0, - 2 );
|
||||
$sSQL = substr($sSQL, 0, -2);
|
||||
$sSQL .= ')' . $this->sEndLine;
|
||||
return $sSQL;
|
||||
} catch (Exception $oException) {
|
||||
@@ -401,7 +395,7 @@ class database extends database_base
|
||||
*
|
||||
* @return sql sentence
|
||||
*/
|
||||
public function generateShowTablesSQL ()
|
||||
public function generateShowTablesSQL()
|
||||
{
|
||||
return 'SHOW TABLES' . $this->sEndLine;
|
||||
}
|
||||
@@ -411,7 +405,7 @@ class database extends database_base
|
||||
*
|
||||
* @return sql sentence
|
||||
*/
|
||||
public function generateShowTablesLikeSQL ($sTable)
|
||||
public function generateShowTablesLikeSQL($sTable)
|
||||
{
|
||||
return "SHOW TABLES LIKE '" . $sTable . "'" . $this->sEndLine;
|
||||
}
|
||||
@@ -422,11 +416,11 @@ class database extends database_base
|
||||
* @param $sTable table name
|
||||
* @return sql sentence
|
||||
*/
|
||||
public function generateDescTableSQL ($sTable)
|
||||
public function generateDescTableSQL($sTable)
|
||||
{
|
||||
try {
|
||||
if ($sTable == '') {
|
||||
throw new Exception( 'The table name cannot be empty!' );
|
||||
throw new Exception('The table name cannot be empty!');
|
||||
}
|
||||
return 'DESC ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine;
|
||||
} catch (Exception $oException) {
|
||||
@@ -440,7 +434,7 @@ class database extends database_base
|
||||
* @param $sTable table name
|
||||
* @return sql sentence
|
||||
*/
|
||||
public function generateTableIndexSQL ($sTable)
|
||||
public function generateTableIndexSQL($sTable)
|
||||
{
|
||||
return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " " . $this->sEndLine;
|
||||
//return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " WHERE Key_name <> 'PRIMARY'" . $this->sEndLine;
|
||||
@@ -451,12 +445,14 @@ class database extends database_base
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function isConnected ()
|
||||
public function isConnected()
|
||||
{
|
||||
if (! $this->oConnection) {
|
||||
return false;
|
||||
$connect = false;
|
||||
if ($this->oConnection !== false) {
|
||||
$this->executeQuery('USE ' . $this->sDataBase);
|
||||
$connect = true;
|
||||
}
|
||||
return $this->executeQuery( 'USE ' . $this->sDataBase );
|
||||
return $connect;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,34 +461,34 @@ class database extends database_base
|
||||
* @param $sQuery sql query string
|
||||
* @return void
|
||||
*/
|
||||
public function logQuery ($sQuery)
|
||||
public function logQuery($sQuery)
|
||||
{
|
||||
try {
|
||||
$found = false;
|
||||
if (substr( $sQuery, 0, 6 ) == 'SELECT') {
|
||||
if (substr($sQuery, 0, 6) == 'SELECT') {
|
||||
$found = true;
|
||||
}
|
||||
if (substr( $sQuery, 0, 4 ) == 'SHOW') {
|
||||
if (substr($sQuery, 0, 4) == 'SHOW') {
|
||||
$found = true;
|
||||
}
|
||||
if (substr( $sQuery, 0, 4 ) == 'DESC') {
|
||||
if (substr($sQuery, 0, 4) == 'DESC') {
|
||||
$found = true;
|
||||
}
|
||||
if (substr( $sQuery, 0, 4 ) == 'USE ') {
|
||||
if (substr($sQuery, 0, 4) == 'USE ') {
|
||||
$found = true;
|
||||
}
|
||||
if (! $found) {
|
||||
if (!$found) {
|
||||
$logDir = PATH_DATA . 'log';
|
||||
if (! file_exists( $logDir )) {
|
||||
if (! mkdir( $logDir )) {
|
||||
if (!file_exists($logDir)) {
|
||||
if (!mkdir($logDir)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$logFile = "$logDir/query.log";
|
||||
$fp = fopen( $logFile, 'a+' );
|
||||
$fp = fopen($logFile, 'a+');
|
||||
if ($fp !== false) {
|
||||
fwrite( $fp, date( "Y-m-d H:i:s" ) . " " . $this->sDataBase . " " . $sQuery . "\n" );
|
||||
fclose( $fp );
|
||||
fwrite($fp, date("Y-m-d H:i:s") . " " . $this->sDataBase . " " . $sQuery . "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
} catch (Exception $oException) {
|
||||
@@ -505,20 +501,21 @@ class database extends database_base
|
||||
* @param $sQuery table name
|
||||
* @return void
|
||||
*/
|
||||
public function executeQuery ($sQuery)
|
||||
public function executeQuery($sQuery)
|
||||
{
|
||||
$this->logQuery( $sQuery );
|
||||
$this->logQuery($sQuery);
|
||||
|
||||
try {
|
||||
if ($this->oConnection) {
|
||||
@mysql_select_db( $this->sDataBase );
|
||||
|
||||
return @mysql_query( $sQuery );
|
||||
mysqli_select_db($this->oConnection, $this->sDataBase);
|
||||
$result = mysqli_query($this->oConnection, $sQuery);
|
||||
mysqli_use_result($this->oConnection);
|
||||
return $result;
|
||||
} else {
|
||||
throw new Exception( 'invalid connection to database ' . $this->sDataBase );
|
||||
throw new Exception('invalid connection to database ' . $this->sDataBase);
|
||||
}
|
||||
} catch (Exception $oException) {
|
||||
$this->logQuery( $oException->getMessage() );
|
||||
$this->logQuery($oException->getMessage());
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
@@ -529,20 +526,24 @@ class database extends database_base
|
||||
* @param $oDataset
|
||||
* @return the number of rows
|
||||
*/
|
||||
public function countResults ($oDataset)
|
||||
public function countResults($oDataset)
|
||||
{
|
||||
return @mysql_num_rows( $oDataset );
|
||||
return mysqli_num_rows($oDataset);
|
||||
}
|
||||
|
||||
/**
|
||||
* count an array of the registry from a dataset
|
||||
*
|
||||
* @param $oDataset
|
||||
* @param $dataSet
|
||||
* @return the registry
|
||||
*/
|
||||
public function getRegistry ($oDataset)
|
||||
public function getRegistry($dataSet)
|
||||
{
|
||||
return @mysql_fetch_array( $oDataset, $this->iFetchType );
|
||||
$response = null;
|
||||
if ($dataSet !== false) {
|
||||
$response = mysqli_fetch_array($dataSet, $this->iFetchType);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -550,80 +551,80 @@ class database extends database_base
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function close ()
|
||||
public function close()
|
||||
{
|
||||
@mysql_close( $this->oConnection );
|
||||
mysqli_close($this->oConnection);
|
||||
}
|
||||
|
||||
public function generateInsertSQL ($table, $data)
|
||||
public function generateInsertSQL($table, $data)
|
||||
{
|
||||
$fields = array ();
|
||||
$values = array ();
|
||||
$fields = array();
|
||||
$values = array();
|
||||
foreach ($data as $field) {
|
||||
$fields[] = $field['field'];
|
||||
if (! is_null( $field['value'] )) {
|
||||
if (!is_null($field['value'])) {
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$values[] = "'" . mysql_real_escape_string( $field['value'] ) . "'";
|
||||
$values[] = "'" . mysqli_real_escape_string($this->oConnection, $field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$values[] = mysql_real_escape_string( $field['value'] );
|
||||
$values[] = mysqli_real_escape_string($this->oConnection, $field['value']);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$values[] = $this->nullString;
|
||||
}
|
||||
}
|
||||
$fields = array_map( array ($this,'putQuotes'
|
||||
), $fields );
|
||||
$sql = sprintf( "INSERT INTO %s (%s) VALUES (%s)", $this->putQuotes( $table ), implode( ', ', $fields ), implode( ', ', $values ) );
|
||||
$fields = array_map(array($this, 'putQuotes'
|
||||
), $fields);
|
||||
$sql = sprintf("INSERT INTO %s (%s) VALUES (%s)", $this->putQuotes($table), implode(', ', $fields), implode(', ', $values));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function generateUpdateSQL ($table, $keys, $data)
|
||||
public function generateUpdateSQL($table, $keys, $data)
|
||||
{
|
||||
$fields = array ();
|
||||
$where = array ();
|
||||
$fields = array();
|
||||
$where = array();
|
||||
foreach ($data as $field) {
|
||||
if (! is_null( $field['value'] )) {
|
||||
if (!is_null($field['value'])) {
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$fields[] = $this->putQuotes( $field['field'] ) . " = '" . mysql_real_escape_string( $field['value'] ) . "'";
|
||||
$fields[] = $this->putQuotes($field['field']) . " = '" . mysqli_real_escape_string($this->oConnection, $field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$fields[] = $this->putQuotes( $field['field'] ) . " = " . mysql_real_escape_string( $field['value'] );
|
||||
$fields[] = $this->putQuotes($field['field']) . " = " . mysqli_real_escape_string($this->oConnection, $field['value']);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$values[] = $this->nullString;
|
||||
}
|
||||
if (in_array( $field['field'], $keys )) {
|
||||
$where[] = $fields[count( $fields ) - 1];
|
||||
if (in_array($field['field'], $keys)) {
|
||||
$where[] = $fields[count($fields) - 1];
|
||||
}
|
||||
}
|
||||
$sql = sprintf( "UPDATE %s SET %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $fields ), implode( ', ', $where ) );
|
||||
$sql = sprintf("UPDATE %s SET %s WHERE %s", $this->putQuotes($table), implode(', ', $fields), implode(', ', $where));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function generateDeleteSQL ($table, $keys, $data)
|
||||
public function generateDeleteSQL($table, $keys, $data)
|
||||
{
|
||||
$fields = array ();
|
||||
$where = array ();
|
||||
$fields = array();
|
||||
$where = array();
|
||||
foreach ($data as $field) {
|
||||
if (in_array( $field['field'], $keys )) {
|
||||
if (! is_null( $field['value'] )) {
|
||||
if (in_array($field['field'], $keys)) {
|
||||
if (!is_null($field['value'])) {
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$where[] = $this->putQuotes( $field['field'] ) . " = '" . mysql_real_escape_string( $field['value'] ) . "'";
|
||||
$where[] = $this->putQuotes($field['field']) . " = '" . mysqli_real_escape_string($this->oConnection, $field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$where[] = $this->putQuotes( $field['field'] ) . " = " . mysql_real_escape_string( $field['value'] );
|
||||
$where[] = $this->putQuotes($field['field']) . " = " . mysqli_real_escape_string($this->oConnection, $field['value']);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -631,25 +632,25 @@ class database extends database_base
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = sprintf( "DELETE FROM %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $where ) );
|
||||
$sql = sprintf("DELETE FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function generateSelectSQL ($table, $keys, $data)
|
||||
public function generateSelectSQL($table, $keys, $data)
|
||||
{
|
||||
$fields = array ();
|
||||
$where = array ();
|
||||
$fields = array();
|
||||
$where = array();
|
||||
foreach ($data as $field) {
|
||||
if (in_array( $field['field'], $keys )) {
|
||||
if (! is_null( $field['value'] )) {
|
||||
if (in_array($field['field'], $keys)) {
|
||||
if (!is_null($field['value'])) {
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$where[] = $this->putQuotes( $field['field'] ) . " = '" . mysql_real_escape_string( $field['value'] ) . "'";
|
||||
$where[] = $this->putQuotes($field['field']) . " = '" . mysqli_real_escape_string($this->oConnection, $field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$where[] = $this->putQuotes( $field['field'] ) . " = " . mysql_real_escape_string( $field['value'] );
|
||||
$where[] = $this->putQuotes($field['field']) . " = " . mysqli_real_escape_string($this->oConnection, $field['value']);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -657,11 +658,11 @@ class database extends database_base
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = sprintf( "SELECT * FROM %s WHERE %s", $this->putQuotes( $table ), implode( ', ', $where ) );
|
||||
$sql = sprintf("SELECT * FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
private function putQuotes ($element)
|
||||
private function putQuotes($element)
|
||||
{
|
||||
return $this->sQuoteCharacter . $element . $this->sQuoteCharacter;
|
||||
}
|
||||
@@ -676,14 +677,14 @@ class database extends database_base
|
||||
*
|
||||
* @return string $sConcat
|
||||
*/
|
||||
public function concatString ()
|
||||
public function concatString()
|
||||
{
|
||||
$nums = func_num_args();
|
||||
$vars = func_get_args();
|
||||
|
||||
$sConcat = " CONCAT(";
|
||||
for ($i = 0; $i < $nums; $i ++) {
|
||||
if (isset( $vars[$i] )) {
|
||||
for ($i = 0; $i < $nums; $i++) {
|
||||
if (isset($vars[$i])) {
|
||||
$sConcat .= $vars[$i];
|
||||
if (($i + 1) < $nums) {
|
||||
$sConcat .= ", ";
|
||||
@@ -693,7 +694,6 @@ class database extends database_base
|
||||
$sConcat .= ")";
|
||||
|
||||
return $sConcat;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -709,11 +709,10 @@ class database extends database_base
|
||||
*
|
||||
* @return string $sCompare
|
||||
*/
|
||||
public function getCaseWhen ($compareValue, $trueResult, $falseResult)
|
||||
public function getCaseWhen($compareValue, $trueResult, $falseResult)
|
||||
{
|
||||
$sCompare = "IF(" . $compareValue . ", " . $trueResult . ", " . $falseResult . ") ";
|
||||
return $sCompare;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -724,7 +723,7 @@ class database extends database_base
|
||||
*
|
||||
* @return string $sql
|
||||
*/
|
||||
public function createTableObjectPermission ()
|
||||
public function createTableObjectPermission()
|
||||
{
|
||||
$sql = "CREATE TABLE IF NOT EXISTS `OBJECT_PERMISSION` (
|
||||
`OP_UID` varchar(32) NOT NULL,
|
||||
@@ -754,9 +753,8 @@ class database extends database_base
|
||||
*
|
||||
* @return string $sql
|
||||
*/
|
||||
public function getSelectReport4 ()
|
||||
public function getSelectReport4()
|
||||
{
|
||||
|
||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||
$sqlGroupBy = " USER ";
|
||||
|
||||
@@ -772,7 +770,6 @@ class database extends database_base
|
||||
GROUP BY " . $sqlGroupBy;
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -783,7 +780,7 @@ class database extends database_base
|
||||
*
|
||||
* @return string $sql
|
||||
*/
|
||||
public function getSelectReport4Filter ($var)
|
||||
public function getSelectReport4Filter($var)
|
||||
{
|
||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||
$sqlGroupBy = " USER ";
|
||||
@@ -800,7 +797,6 @@ class database extends database_base
|
||||
GROUP BY " . $sqlGroupBy;
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -811,7 +807,7 @@ class database extends database_base
|
||||
*
|
||||
* @return string $sql
|
||||
*/
|
||||
public function getSelectReport5 ()
|
||||
public function getSelectReport5()
|
||||
{
|
||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||
$sqlGroupBy = " USER ";
|
||||
@@ -828,7 +824,6 @@ class database extends database_base
|
||||
GROUP BY " . $sqlGroupBy;
|
||||
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -839,9 +834,8 @@ class database extends database_base
|
||||
*
|
||||
* @return string $sql
|
||||
*/
|
||||
public function getSelectReport5Filter ($var)
|
||||
public function getSelectReport5Filter($var)
|
||||
{
|
||||
|
||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||
$sqlGroupBy = " USER ";
|
||||
|
||||
@@ -863,41 +857,39 @@ class database extends database_base
|
||||
* query functions for class class.net.php
|
||||
*
|
||||
*/
|
||||
public function getServerVersion ($driver, $dbIP, $dbPort, $dbUser, $dbPasswd, $dbSourcename)
|
||||
public function getServerVersion($driver, $dbIP, $dbPort, $dbUser, $dbPasswd, $dbSourcename)
|
||||
{
|
||||
|
||||
if ($link = @mysql_connect( $dbIP, $dbUser, $dbPasswd )) {
|
||||
$v = @mysql_get_server_info();
|
||||
if ($link = mysqli_connect($dbIP, $dbUser, $dbPasswd, $dbSourcename)) {
|
||||
$v = mysqli_get_server_info($link);
|
||||
} else {
|
||||
throw new Exception( @mysql_error( $link ) );
|
||||
throw new Exception(mysqli_error($link));
|
||||
}
|
||||
return (isset( $v )) ? $v : 'none';
|
||||
|
||||
return (isset($v)) ? $v : 'none';
|
||||
}
|
||||
|
||||
/*
|
||||
* query functions for class class.net.php, class.reportTables.php
|
||||
*
|
||||
*/
|
||||
public function getDropTable ($sTableName)
|
||||
public function getDropTable($sTableName)
|
||||
{
|
||||
$sql = 'DROP TABLE IF EXISTS `' . $sTableName . '`';
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function getTableDescription ($sTableName)
|
||||
public function getTableDescription($sTableName)
|
||||
{
|
||||
$sql = "DESC " . $sTableName;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function getFieldNull ()
|
||||
public function getFieldNull()
|
||||
{
|
||||
$fieldName = "Null";
|
||||
return $fieldName;
|
||||
}
|
||||
|
||||
public function getValidate ($validate)
|
||||
public function getValidate($validate)
|
||||
{
|
||||
$oValidate = $validate;
|
||||
return $oValidate;
|
||||
@@ -907,14 +899,14 @@ class database extends database_base
|
||||
* Determines whether a table exists
|
||||
* It is part of class.reportTables.php
|
||||
*/
|
||||
public function reportTableExist ()
|
||||
public function reportTableExist()
|
||||
{
|
||||
$filter = new InputFilter();
|
||||
$DB_NAME = $filter->validateInput(DB_NAME);
|
||||
$bExists = true;
|
||||
$oConnection = mysql_connect( DB_HOST, DB_USER, DB_PASS );
|
||||
mysql_select_db( $DB_NAME );
|
||||
$oDataset = mysql_query( 'SELECT COUNT(*) FROM REPORT_TABLE' ) || ($bExists = false);
|
||||
$oConnection = mysqli_connect(DB_HOST, DB_USER, DB_PASS);
|
||||
mysqli_select_db($oConnection, $DB_NAME);
|
||||
$oDataset = mysqli_query($oConnection, 'SELECT COUNT(*) FROM REPORT_TABLE') || ($bExists = false);
|
||||
|
||||
return $bExists;
|
||||
}
|
||||
@@ -922,7 +914,7 @@ class database extends database_base
|
||||
/**
|
||||
* It is part of class.pagedTable.php
|
||||
*/
|
||||
public function getLimitRenderTable ($nCurrentPage, $nRowsPerPage)
|
||||
public function getLimitRenderTable($nCurrentPage, $nRowsPerPage)
|
||||
{
|
||||
$sql = ' LIMIT ' . (($nCurrentPage - 1) * $nRowsPerPage) . ', ' . $nRowsPerPage;
|
||||
return $sql;
|
||||
@@ -930,32 +922,23 @@ class database extends database_base
|
||||
|
||||
/**
|
||||
* Determining the existence of a table
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param string $database
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function tableExists ($tableName, $database)
|
||||
public function tableExists($tableName, $database)
|
||||
{
|
||||
@mysql_select_db( $database );
|
||||
$tables = array ();
|
||||
$tablesResult = mysql_query( "SHOW TABLES FROM $database;" );
|
||||
while ($row = @mysql_fetch_row( $tablesResult )) {
|
||||
mysqli_select_db($this->oConnection, $database);
|
||||
$tables = array();
|
||||
$tablesResult = mysqli_query($this->oConnection, "SHOW TABLES FROM $database;");
|
||||
while ($row = mysqli_fetch_row($tablesResult)) {
|
||||
$tables[] = $row[0];
|
||||
}
|
||||
if (in_array( $tableName, $tables )) {
|
||||
if (in_array($tableName, $tables)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determining the existence of a table (Depricated)
|
||||
*/
|
||||
// function tableExists ($table, $db) {
|
||||
// $tables = mysql_list_tables ($db);
|
||||
// while (list ($temp) = @mysql_fetch_array ($tables)) {
|
||||
// if ($temp == $table) {
|
||||
// return TRUE;
|
||||
// }
|
||||
// }
|
||||
// return FALSE;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
*
|
||||
* @package gulliver.system
|
||||
*/
|
||||
|
||||
class DataBaseMaintenance
|
||||
{
|
||||
private $host;
|
||||
@@ -54,19 +53,19 @@ class DataBaseMaintenance
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* @param string $host is null
|
||||
* @param string $user is null
|
||||
* @param string $host is null
|
||||
* @param string $user is null
|
||||
* @param string $passwd is null
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function __construct ($host = null, $user = null, $passwd = null)
|
||||
public function __construct($host = null, $user = null, $passwd = null)
|
||||
{
|
||||
$this->tmpDir = './';
|
||||
$this->link = null;
|
||||
$this->dbName = null;
|
||||
$this->isWindows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
|
||||
if (isset( $host ) && isset( $user ) && isset( $passwd )) {
|
||||
if (isset($host) && isset($user) && isset($passwd)) {
|
||||
$this->host = $host;
|
||||
$this->user = $user;
|
||||
$this->passwd = $passwd;
|
||||
@@ -80,7 +79,7 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setUser ($user)
|
||||
public function setUser($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
@@ -92,7 +91,7 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setPasswd ($passwd)
|
||||
public function setPasswd($passwd)
|
||||
{
|
||||
$this->passwd = $passwd;
|
||||
}
|
||||
@@ -104,7 +103,7 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setHost ($host)
|
||||
public function setHost($host)
|
||||
{
|
||||
$this->host = $host;
|
||||
}
|
||||
@@ -116,11 +115,11 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setTempDir ($tmpDir)
|
||||
public function setTempDir($tmpDir)
|
||||
{
|
||||
$this->tmpDir = $tmpDir;
|
||||
if (! file_exists( $tmpDir )) {
|
||||
mkdir( $this->tmpDir );
|
||||
if (!file_exists($tmpDir)) {
|
||||
mkdir($this->tmpDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +128,7 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return $this->tmpDir
|
||||
*/
|
||||
public function getTempDir ()
|
||||
public function getTempDir()
|
||||
{
|
||||
return $this->tmpDir;
|
||||
}
|
||||
@@ -139,7 +138,7 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return $this->link
|
||||
*/
|
||||
public function status ()
|
||||
public function status()
|
||||
{
|
||||
return $$this->link;
|
||||
}
|
||||
@@ -151,25 +150,25 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function connect ($dbname = null)
|
||||
public function connect($dbname = null)
|
||||
{
|
||||
if ($this->link != null) {
|
||||
mysql_close( $this->link );
|
||||
mysqli_close($this->link);
|
||||
$this->link = null;
|
||||
}
|
||||
if (isset( $dbname )) {
|
||||
if (isset($dbname)) {
|
||||
$this->dbName = $dbname;
|
||||
}
|
||||
|
||||
$this->link = mysql_connect( $this->host, $this->user, $this->passwd );
|
||||
@mysql_query( "SET NAMES 'utf8';" );
|
||||
@mysql_query( "SET FOREIGN_KEY_CHECKS=0;" );
|
||||
if (! $this->link) {
|
||||
throw new Exception( "Couldn't connect to host {$this->host} with user {$this->user}" );
|
||||
$this->link = mysqli_connect($this->host, $this->user, $this->passwd, $this->dbName);
|
||||
if (!$this->link) {
|
||||
throw new Exception("Couldn't connect to host {$this->host} with user {$this->user}");
|
||||
}
|
||||
mysqli_query($this->link, "SET NAMES 'utf8';");
|
||||
mysqli_query($this->link, "SET FOREIGN_KEY_CHECKS=0;");
|
||||
|
||||
if ($this->dbName != null) {
|
||||
$this->selectDataBase( $this->dbName );
|
||||
$this->selectDataBase($this->dbName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +179,7 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setDbName ($dbname)
|
||||
public function setDbName($dbname)
|
||||
{
|
||||
$this->dbName = $dbname;
|
||||
}
|
||||
@@ -189,14 +188,15 @@ class DataBaseMaintenance
|
||||
* selectDataBase
|
||||
*
|
||||
* @param string $dbname
|
||||
* @param $dbname
|
||||
*
|
||||
* @return none
|
||||
* @throws Exception
|
||||
*/
|
||||
public function selectDataBase ($dbname)
|
||||
public function selectDataBase($dbname)
|
||||
{
|
||||
$this->setDbName( $dbname );
|
||||
if (! @mysql_select_db( $this->dbName, $this->link )) {
|
||||
throw new Exception( "Couldn't select database $dbname" );
|
||||
$this->setDbName($dbname);
|
||||
if (!mysqli_select_db($this->link, $this->dbName)) {
|
||||
throw new Exception("Couldn't select database $dbname");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,13 +207,13 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return $aRows
|
||||
*/
|
||||
public function query ($sql)
|
||||
public function query($sql)
|
||||
{
|
||||
$this->result = @mysql_query( $sql );
|
||||
$this->result = mysqli_query($this->link, $sql);
|
||||
if ($this->result) {
|
||||
$aRows = Array ();
|
||||
while ($aRow = @mysql_fetch_assoc( $this->result )) {
|
||||
array_push( $aRows, $aRow );
|
||||
$aRows = [];
|
||||
while ($aRow = mysqli_fetch_assoc($this->result)) {
|
||||
$aRows[] = $aRow;
|
||||
}
|
||||
return $aRows;
|
||||
} else {
|
||||
@@ -224,26 +224,26 @@ class DataBaseMaintenance
|
||||
/**
|
||||
* error
|
||||
*
|
||||
* @return @mysql_error()
|
||||
* @return mysqli_error()
|
||||
*/
|
||||
public function error ()
|
||||
public function error()
|
||||
{
|
||||
return @mysql_error( $this->link );
|
||||
return mysqli_error($this->link);
|
||||
}
|
||||
|
||||
/**
|
||||
* getTablesList
|
||||
*
|
||||
* @return $aRows
|
||||
* @return array
|
||||
*/
|
||||
public function getTablesList ()
|
||||
public function getTablesList()
|
||||
{
|
||||
$this->result = @mysql_query( "SHOW TABLES;" );
|
||||
$aRows = Array ();
|
||||
while ($aRow = mysql_fetch_row( $this->result )) {
|
||||
array_push( $aRows, $aRow[0] );
|
||||
$this->result = mysqli_query($this->link, 'SHOW TABLES;');
|
||||
$rows = [];
|
||||
while ($row = mysqli_fetch_row($this->result)) {
|
||||
$rows[] = $row[0];
|
||||
}
|
||||
return $aRows;
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,24 +253,24 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
function dumpData ($table)
|
||||
public function dumpData($table)
|
||||
{
|
||||
$this->outfile = $this->tmpDir . $table . '.dump';
|
||||
|
||||
//if the file exists delete it
|
||||
if (is_file( $this->outfile )) {
|
||||
@unlink( $this->outfile );
|
||||
if (is_file($this->outfile)) {
|
||||
@unlink($this->outfile);
|
||||
}
|
||||
|
||||
$sql = "SELECT * INTO OUTFILE '{$this->outfile}' FIELDS TERMINATED BY '\t|\t' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\t\t\r\r\n' FROM $table";
|
||||
// The mysql_escape_string function has been DEPRECATED as of PHP 5.3.0.
|
||||
// Commented that is not assigned to a variable.
|
||||
// mysql_escape_string("';");
|
||||
if (! @mysql_query( $sql )) {
|
||||
$ws = (!empty(config("system.workspace")))? config("system.workspace") : "Undefined Workspace";
|
||||
Bootstrap::registerMonolog('MysqlCron', 400, mysql_error(), array('sql'=>$sql), $ws, 'processmaker.log');
|
||||
$varRes = mysql_error() . "\n";
|
||||
G::outRes( $varRes );
|
||||
if (!@mysqli_query($this->link, $sql)) {
|
||||
$ws = (!empty(config('system.workspace'))) ? config('system.workspace') : 'Undefined Workspace';
|
||||
Bootstrap::registerMonolog('MysqlCron', 400, mysqli_error($this->link), ['sql' => $sql], $ws, 'processmaker.log');
|
||||
$varRes = mysqli_error($this->link) . "\n";
|
||||
G::outRes($varRes);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -283,15 +283,15 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
function restoreData ($backupFile)
|
||||
public function restoreData($backupFile)
|
||||
{
|
||||
$tableName = str_replace( '.dump', '', basename( $backupFile ) );
|
||||
$tableName = str_replace('.dump', '', basename($backupFile));
|
||||
$sql = "LOAD DATA INFILE '$backupFile' INTO TABLE $tableName FIELDS TERMINATED BY '\t|\t' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\t\t\r\r\n'";
|
||||
if (! @mysql_query( $sql )) {
|
||||
$ws = (!empty(config("system.workspace")))? config("system.workspace") : "Undefined Workspace";
|
||||
Bootstrap::registerMonolog('MysqlCron', 400, mysql_error(), array('sql'=>$sql), $ws, 'processmaker.log');
|
||||
$varRes = mysql_error() . "\n";
|
||||
G::outRes( $varRes );
|
||||
if (!@mysqli_query($this->link, $sql)) {
|
||||
$ws = (!empty(config("system.workspace"))) ? config("system.workspace") : "Wokspace Undefined";
|
||||
Bootstrap::registerMonolog('MysqlCron', 400, mysqli_error($this->link), ['sql' => $sql], $ws, 'processmaker.log');
|
||||
$varRes = mysqli_error($this->link) . "\n";
|
||||
G::outRes($varRes);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -304,26 +304,25 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function restoreAllData ($type = null)
|
||||
public function restoreAllData($type = null)
|
||||
{
|
||||
|
||||
$aTables = $this->getTablesList();
|
||||
|
||||
foreach ($aTables as $table) {
|
||||
if (isset( $type ) && $type == 'sql') {
|
||||
if (isset($type) && $type == 'sql') {
|
||||
$this->infile = $this->tmpDir . $table . ".sql";
|
||||
if (is_file( $this->infile )) {
|
||||
$queries = $this->restoreFromSql( $this->infile, true );
|
||||
if (! isset( $queries )) {
|
||||
if (is_file($this->infile)) {
|
||||
$queries = $this->restoreFromSql($this->infile, true);
|
||||
if (!isset($queries)) {
|
||||
$queries = "unknown";
|
||||
}
|
||||
printf( "%-59s%20s", "Restored table $table", "$queries queries\n" );
|
||||
printf("%-59s%20s", "Restored table $table", "$queries queries\n");
|
||||
}
|
||||
} else {
|
||||
$this->infile = $this->tmpDir . $table . ".dump";
|
||||
if (is_file( $this->infile )) {
|
||||
$this->restoreData( $this->infile );
|
||||
printf( "%20s %s %s\n", 'Restoring data from ', $this->infile, " in table $table" );
|
||||
if (is_file($this->infile)) {
|
||||
$this->restoreData($this->infile);
|
||||
printf("%20s %s %s\n", 'Restoring data from ', $this->infile, " in table $table");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -337,17 +336,17 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function createDb ($dbname, $drop = false)
|
||||
public function createDb($dbname, $drop = false)
|
||||
{
|
||||
if ($drop) {
|
||||
$sql = "DROP DATABASE IF EXISTS $dbname;";
|
||||
if (! @mysql_query( $sql )) {
|
||||
throw new Exception( mysql_error() );
|
||||
if (!mysqli_query($this->link, $sql)) {
|
||||
throw new Exception(mysqli_error($this->link));
|
||||
}
|
||||
}
|
||||
$sql = "CREATE DATABASE IF NOT EXISTS $dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
|
||||
if (! @mysql_query( $sql )) {
|
||||
throw new Exception( mysql_error() );
|
||||
if (!mysqli_query($this->link, $sql)) {
|
||||
throw new Exception(mysqli_error($this->link));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,24 +357,23 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function restoreFromSql2 ($sqlfile)
|
||||
public function restoreFromSql2($sqlfile)
|
||||
{
|
||||
|
||||
ini_set( 'memory_limit', '512M' );
|
||||
if (! is_file( $sqlfile )) {
|
||||
throw new Exception( "the $sqlfile doesn't exist!" );
|
||||
ini_set('memory_limit', '512M');
|
||||
if (!is_file($sqlfile)) {
|
||||
throw new Exception("the $sqlfile doesn't exist!");
|
||||
}
|
||||
$query = file_get_contents( $sqlfile );
|
||||
$mysqli = new mysqli( $this->host, $this->user, $this->passwd, $this->dbName );
|
||||
$query = file_get_contents($sqlfile);
|
||||
$mysqli = new mysqli($this->host, $this->user, $this->passwd, $this->dbName);
|
||||
|
||||
/* check connection */
|
||||
if (mysqli_connect_errno()) {
|
||||
printf( "Connect failed: %s\n", mysqli_connect_error() );
|
||||
printf("Connect failed: %s\n", mysqli_connect_error());
|
||||
exit();
|
||||
}
|
||||
|
||||
/* execute multi query */
|
||||
if ($mysqli->multi_query( $query )) {
|
||||
if ($mysqli->multi_query($query)) {
|
||||
do {
|
||||
/* store first result set */
|
||||
if ($result = $mysqli->store_result()) {
|
||||
@@ -383,7 +381,6 @@ class DataBaseMaintenance
|
||||
}
|
||||
$result->free();
|
||||
}
|
||||
|
||||
} while ($mysqli->next_result());
|
||||
}
|
||||
|
||||
@@ -398,12 +395,12 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function backupDataBase ($outfile)
|
||||
public function backupDataBase($outfile)
|
||||
{
|
||||
$password = escapeshellarg($this->passwd);
|
||||
|
||||
//On Windows, escapeshellarg() instead replaces percent signs, exclamation
|
||||
//marks (delayed variable substitution) and double quotes with spaces and
|
||||
|
||||
//On Windows, escapeshellarg() instead replaces percent signs, exclamation
|
||||
//marks (delayed variable substitution) and double quotes with spaces and
|
||||
//adds double quotes around the string.
|
||||
//See: http://php.net/manual/en/function.escapeshellarg.php
|
||||
if ($this->isWindows) {
|
||||
@@ -437,16 +434,16 @@ class DataBaseMaintenance
|
||||
|
||||
/**
|
||||
* string escapeshellargCustom ( string $arg , character $quotes)
|
||||
*
|
||||
* escapeshellarg() adds single quotes around a string and quotes/escapes any
|
||||
* existing single quotes allowing you to pass a string directly to a shell
|
||||
* function and having it be treated as a single safe argument. This function
|
||||
* should be used to escape individual arguments to shell functions coming
|
||||
* from user input. The shell functions include exec(), system() and the
|
||||
*
|
||||
* escapeshellarg() adds single quotes around a string and quotes/escapes any
|
||||
* existing single quotes allowing you to pass a string directly to a shell
|
||||
* function and having it be treated as a single safe argument. This function
|
||||
* should be used to escape individual arguments to shell functions coming
|
||||
* from user input. The shell functions include exec(), system() and the
|
||||
* backtick operator.
|
||||
*
|
||||
* On Windows, escapeshellarg() instead replaces percent signs, exclamation
|
||||
* marks (delayed variable substitution) and double quotes with spaces and
|
||||
*
|
||||
* On Windows, escapeshellarg() instead replaces percent signs, exclamation
|
||||
* marks (delayed variable substitution) and double quotes with spaces and
|
||||
* adds double quotes around the string.
|
||||
*/
|
||||
private function escapeshellargCustom($string, $quotes = "")
|
||||
@@ -489,57 +486,56 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return boolean false or true
|
||||
*/
|
||||
function restoreFromSql ($sqlfile, $type = 'file')
|
||||
public function restoreFromSql($sqlfile, $type = 'file')
|
||||
{
|
||||
ini_set( 'memory_limit', '64M' );
|
||||
if ($type == 'file' && ! is_file( $sqlfile )) {
|
||||
throw new Exception( "the $sqlfile doesn't exist!" );
|
||||
ini_set('memory_limit', '64M');
|
||||
if ($type == 'file' && !is_file($sqlfile)) {
|
||||
throw new Exception("the $sqlfile doesn't exist!");
|
||||
}
|
||||
|
||||
$metaFile = str_replace( '.sql', '.meta', $sqlfile );
|
||||
$metaFile = str_replace('.sql', '.meta', $sqlfile);
|
||||
|
||||
$queries = 0;
|
||||
|
||||
if (is_file( $metaFile )) {
|
||||
if (is_file($metaFile)) {
|
||||
echo "Using $metaFile as metadata.\n";
|
||||
$fp = fopen( $sqlfile, 'rb' );
|
||||
$fpmd = fopen( $metaFile, 'r' );
|
||||
while ($offset = fgets( $fpmd, 1024 )) {
|
||||
$buffer = intval( $offset ); //reading the size of $oData
|
||||
$query = fread( $fp, $buffer ); //reading string $oData
|
||||
$fp = fopen($sqlfile, 'rb');
|
||||
$fpmd = fopen($metaFile, 'r');
|
||||
while ($offset = fgets($fpmd, 1024)) {
|
||||
$buffer = intval($offset); //reading the size of $oData
|
||||
$query = fread($fp, $buffer); //reading string $oData
|
||||
$queries += 1;
|
||||
|
||||
if (! @mysql_query( $query )) {
|
||||
$varRes = mysql_error() . "\n";
|
||||
G::outRes( $varRes );
|
||||
if (!mysqli_query($this->link, $query)) {
|
||||
$varRes = mysqli_error($this->link) . "\n";
|
||||
G::outRes($varRes);
|
||||
$varRes = "==>" . $query . "<==\n";
|
||||
G::outRes( $varRes );
|
||||
G::outRes($varRes);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$queries = null;
|
||||
try {
|
||||
$mysqli = new mysqli( $this->host, $this->user, $this->passwd, $this->dbName );
|
||||
$mysqli = new mysqli($this->host, $this->user, $this->passwd, $this->dbName);
|
||||
/* check connection */
|
||||
if (mysqli_connect_errno()) {
|
||||
printf( "Connect failed: %s\n", mysqli_connect_error() );
|
||||
printf("Connect failed: %s\n", mysqli_connect_error());
|
||||
exit();
|
||||
}
|
||||
if ($type == 'file') {
|
||||
$query = file_get_contents( $sqlfile );
|
||||
} else if ($type == 'string') {
|
||||
if ($type === 'file') {
|
||||
$query = file_get_contents($sqlfile);
|
||||
} elseif ($type === 'string') {
|
||||
$query = $sqlfile;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (trim( $query ) == "") {
|
||||
if (trim($query) == "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* execute multi query */
|
||||
if ($mysqli->multi_query( $query )) {
|
||||
/* execute multi query */
|
||||
if ($mysqli->multi_query($query)) {
|
||||
do {
|
||||
/* store first result set */
|
||||
if ($result = $mysqli->store_result()) {
|
||||
@@ -554,16 +550,16 @@ class DataBaseMaintenance
|
||||
}
|
||||
} while ($mysqli->next_result());
|
||||
} else {
|
||||
throw new Exception( mysqli_error( $mysqli ) );
|
||||
throw new Exception(mysqli_error($mysqli));
|
||||
}
|
||||
|
||||
/* close connection */
|
||||
/* close connection */
|
||||
$mysqli->close();
|
||||
} catch (Exception $e) {
|
||||
echo $query;
|
||||
$token = strtotime("now");
|
||||
PMException::registerErrorLog($e, $token);
|
||||
G::outRes( G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) );
|
||||
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)));
|
||||
}
|
||||
}
|
||||
return $queries;
|
||||
@@ -576,20 +572,20 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return string $tableSchema
|
||||
*/
|
||||
function getSchemaFromTable ($tablename)
|
||||
public function getSchemaFromTable($tablename)
|
||||
{
|
||||
//$tableSchema = "/* Structure for table `$tablename` */\n";
|
||||
//$tableSchema .= "DROP TABLE IF EXISTS `$tablename`;\n\n";
|
||||
$tableSchema = "";
|
||||
$sql = "show create table `$tablename`; ";
|
||||
$result = @mysql_query( $sql );
|
||||
$result = mysqli_query($this->link, $sql);
|
||||
if ($result) {
|
||||
if ($row = mysql_fetch_assoc( $result )) {
|
||||
if ($row = mysqli_fetch_assoc($result)) {
|
||||
$tableSchema .= $row['Create Table'] . ";\n\n";
|
||||
}
|
||||
mysql_free_result( $result );
|
||||
mysqli_free_result($result);
|
||||
} else {
|
||||
G::outRes( mysql_error() );
|
||||
G::outRes(mysqli_error($this->link));
|
||||
}
|
||||
return $tableSchema;
|
||||
}
|
||||
@@ -601,12 +597,12 @@ class DataBaseMaintenance
|
||||
*
|
||||
* @return string $str
|
||||
*/
|
||||
function removeCommentsIntoString ($str)
|
||||
public function removeCommentsIntoString($str)
|
||||
{
|
||||
$str = preg_replace( '/\/\*[\w\W]*\*\//', '', $str );
|
||||
$str = preg_replace( "/--[\w\W]*\\n/", '', $str );
|
||||
$str = preg_replace( "/\/\/[\w\W]*\\n/", '', $str );
|
||||
$str = preg_replace( "/\#[\w\W]*\\n/", '', $str );
|
||||
$str = preg_replace('/\/\*[\w\W]*\*\//', '', $str);
|
||||
$str = preg_replace("/--[\w\W]*\\n/", '', $str);
|
||||
$str = preg_replace("/\/\/[\w\W]*\\n/", '', $str);
|
||||
$str = preg_replace("/\#[\w\W]*\\n/", '', $str);
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once ("DB.php");
|
||||
require_once("DB.php");
|
||||
|
||||
define( 'DB_ERROR_NO_SHOW_AND_CONTINUE', 0 );
|
||||
define( 'DB_ERROR_SHOW_AND_STOP', 1 );
|
||||
define( 'DB_ERROR_SHOW_AND_CONTINUE', 2 );
|
||||
define( 'DB_ERROR_SHOWALL_AND_STOP', 3 );
|
||||
define( 'DB_ERROR_SHOWALL_AND_CONTINUE', 4 );
|
||||
define('DB_ERROR_NO_SHOW_AND_CONTINUE', 0);
|
||||
define('DB_ERROR_SHOW_AND_STOP', 1);
|
||||
define('DB_ERROR_SHOW_AND_CONTINUE', 2);
|
||||
define('DB_ERROR_SHOWALL_AND_STOP', 3);
|
||||
define('DB_ERROR_SHOWALL_AND_CONTINUE', 4);
|
||||
|
||||
/**
|
||||
* DBConnection class definition
|
||||
@@ -49,10 +49,10 @@ define( 'DB_ERROR_SHOWALL_AND_CONTINUE', 4 );
|
||||
*/
|
||||
class DBConnection
|
||||
{
|
||||
var $db;
|
||||
var $db_error;
|
||||
var $errorLevel;
|
||||
var $type;
|
||||
public $db;
|
||||
public $db_error;
|
||||
public $errorLevel;
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* ***************************************************************
|
||||
@@ -93,7 +93,7 @@ class DBConnection
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
function DBConnection ($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
|
||||
public function DBConnection($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
|
||||
{
|
||||
$this->errorLevel = $errorLevel;
|
||||
if ($type == null) {
|
||||
@@ -101,36 +101,41 @@ class DBConnection
|
||||
}
|
||||
$this->type = $type;
|
||||
//print "<hr>$type $strServer, $strUser, $strPwd, $strDB <hr>";
|
||||
if ($type == "mysql") {
|
||||
$dsn = "mysql://$strUser:$strPwd@$strServer/$strDB";
|
||||
}
|
||||
if ($type == "pgsql") {
|
||||
//$dsn = "pgsql://postgres@$strServer/$strDB";
|
||||
$prt = ($strPort == 0 || $strPort == 5432 ? '' : ":$strPort");
|
||||
$dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB";
|
||||
}
|
||||
if ($type == "odbc") {
|
||||
$dsn = "odbc://$strUser:$strPwd@$strServer/$strDB";
|
||||
}
|
||||
if ($type == "mssql") {
|
||||
$strServer = substr( $strServer, 0, strpos( $strServer, ':' ) );
|
||||
$prt = ($strPort == 0 || $strPort == 1433 ? '' : ":$strPort");
|
||||
$dsn = "mssql://$strUser:$strPwd@$strServer$prt/$strDB";
|
||||
///--) $dsn = "mssql://$strUser:$strPwd@$strServer/$strDB";
|
||||
}
|
||||
if ($type == "oracle") {
|
||||
$dsn = "oci8://$strUser:$strPwd@$strServer/$strDB";
|
||||
switch ($type) {
|
||||
case 'mysql':
|
||||
$dsn = "mysql://$strUser:$strPwd@$strServer/$strDB";
|
||||
break;
|
||||
case 'pgsql':
|
||||
//$dsn = "pgsql://postgres@$strServer/$strDB";
|
||||
$prt = ($strPort == 0 || $strPort == 5432 ? '' : ":$strPort");
|
||||
$dsn = "pgsql://$strUser:$strPwd@$strServer$prt/$strDB";
|
||||
break;
|
||||
case 'odbc':
|
||||
$dsn = "odbc://$strUser:$strPwd@$strServer/$strDB";
|
||||
break;
|
||||
case 'mssql':
|
||||
$strServer = substr($strServer, 0, strpos($strServer, ':'));
|
||||
$prt = ($strPort == 0 || $strPort == 1433 ? '' : ":$strPort");
|
||||
$dsn = "mssql://$strUser:$strPwd@$strServer$prt/$strDB";
|
||||
///--) $dsn = "mssql://$strUser:$strPwd@$strServer/$strDB";
|
||||
break;
|
||||
case 'oracle':
|
||||
$dsn = "oci8://$strUser:$strPwd@$strServer/$strDB";
|
||||
break;
|
||||
default:
|
||||
$dsn = "mysql://$strUser:$strPwd@$strServer/$strDB";
|
||||
break;
|
||||
}
|
||||
$this->db_error = null;
|
||||
if ($type === 'myxml') {
|
||||
$this->db = XMLDB::connect( $strServer );
|
||||
$this->db = XMLDB::connect($strServer);
|
||||
} else {
|
||||
$this->db = DB::connect( $dsn );
|
||||
$this->db = DB::connect($dsn);
|
||||
}
|
||||
if (DB::isError( $this->db )) {
|
||||
if (DB::isError($this->db)) {
|
||||
$this->db_error = $this->db;
|
||||
$this->db = null;
|
||||
$this->logError( $this->db_error );
|
||||
$this->logError($this->db_error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +146,7 @@ class DBConnection
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function Reset ()
|
||||
public function Reset()
|
||||
{
|
||||
if ($this->db) {
|
||||
$this->db->disconnect();
|
||||
@@ -156,7 +161,7 @@ class DBConnection
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function Free ()
|
||||
public function Free()
|
||||
{
|
||||
$this->Reset();
|
||||
}
|
||||
@@ -168,7 +173,7 @@ class DBConnection
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function Close ()
|
||||
public function Close()
|
||||
{
|
||||
$this->Reset();
|
||||
}
|
||||
@@ -182,7 +187,7 @@ class DBConnection
|
||||
* @param string $errorLevel
|
||||
* @return void
|
||||
*/
|
||||
function logError ($obj, $errorLevel = null)
|
||||
public function logError($obj, $errorLevel = null)
|
||||
{
|
||||
global $_SESSION;
|
||||
global $_SERVER;
|
||||
@@ -190,11 +195,12 @@ class DBConnection
|
||||
$filter = new InputFilter();
|
||||
$_SERVER = $filter->xssFilterHard($_SERVER);
|
||||
$_SESSION = $filter->xssFilterHard($_SESSION);
|
||||
if (is_null( $errorLevel ))
|
||||
if (isset( $this->errorLevel )) {
|
||||
$errorLevel = $this->errorLevel;
|
||||
} else {
|
||||
$errorLevel = DB_ERROR_SHOWALL_AND_STOP; //for fatal errors the default is 3, show detailed and die.
|
||||
if (is_null($errorLevel)) {
|
||||
if (isset($this->errorLevel)) {
|
||||
$errorLevel = $this->errorLevel;
|
||||
} else {
|
||||
$errorLevel = DB_ERROR_SHOWALL_AND_STOP; //for fatal errors the default is 3, show detailed and die.
|
||||
}
|
||||
}
|
||||
|
||||
if ($errorLevel == DB_ERROR_SHOW_AND_STOP || $errorLevel == DB_ERROR_SHOW_AND_CONTINUE || $errorLevel == DB_ERROR_SHOWALL_AND_STOP || $errorLevel == DB_ERROR_SHOWALL_AND_CONTINUE) {
|
||||
@@ -205,9 +211,9 @@ class DBConnection
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
if (defined( 'DB_ERROR_BACKTRACE' ) && DB_ERROR_BACKTRACE) {
|
||||
if (defined('DB_ERROR_BACKTRACE') && DB_ERROR_BACKTRACE) {
|
||||
print "<table border = 1 width=400 class= 'sendMsgRojo'><tr><td><textarea rows='12' cols='180' style='width:100%;font-family:courier;white-space:pre-line;overflow:auto;border:none;'>";
|
||||
print ((htmlentities( DBConnection::traceError() ))) ;
|
||||
print((htmlentities(DBConnection::traceError()))) ;
|
||||
print "</textarea></td></tr></table>";
|
||||
}
|
||||
//G::setErrorHandler ( );
|
||||
@@ -225,7 +231,7 @@ class DBConnection
|
||||
* @param string $limit
|
||||
* @return string
|
||||
*/
|
||||
function traceError ($tts = 2, $limit = -1)
|
||||
public function traceError($tts = 2, $limit = -1)
|
||||
{
|
||||
$trace = debug_backtrace();
|
||||
$out = '';
|
||||
@@ -233,7 +239,7 @@ class DBConnection
|
||||
if ($tts > 0) {
|
||||
$tts --;
|
||||
} else {
|
||||
$out .= '[' . basename( $step['file'] ) . ': ' . $step['line'] . '] : ' . $step['function'] . '(' . DBConnection::printArgs( $step['args'] ) . ")\n";
|
||||
$out .= '[' . basename($step['file']) . ': ' . $step['line'] . '] : ' . $step['function'] . '(' . DBConnection::printArgs($step['args']) . ")\n";
|
||||
$limit --;
|
||||
if ($limit === 0) {
|
||||
return $out;
|
||||
@@ -250,31 +256,31 @@ class DBConnection
|
||||
* @param string $args
|
||||
* @return string
|
||||
*/
|
||||
function printArgs ($args)
|
||||
public function printArgs($args)
|
||||
{
|
||||
$out = '';
|
||||
if (is_array( $args )) {
|
||||
if (is_array($args)) {
|
||||
foreach ($args as $arg) {
|
||||
if ($out !== '') {
|
||||
$out .= ' ,';
|
||||
}
|
||||
if (is_string( $arg )) {
|
||||
if (is_string($arg)) {
|
||||
$out .= "'" . ($arg) . "'";
|
||||
} elseif (is_array( $arg )) {
|
||||
$out .= print_r( $arg, 1 );
|
||||
} elseif (is_object( $arg )) {
|
||||
$out .= get_class( $arg ); // print_r ( $arg ,1 );
|
||||
} elseif (! isset( $arg )) {
|
||||
} elseif (is_array($arg)) {
|
||||
$out .= print_r($arg, 1);
|
||||
} elseif (is_object($arg)) {
|
||||
$out .= get_class($arg); // print_r ( $arg ,1 );
|
||||
} elseif (! isset($arg)) {
|
||||
$out .= 'NULL';
|
||||
} else {
|
||||
$out .= sprintf( "%s", $arg );
|
||||
$out .= sprintf("%s", $arg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (! isset( $args )) {
|
||||
if (! isset($args)) {
|
||||
$out = 'NULL';
|
||||
} else {
|
||||
$out = print_r( $args, 1 );
|
||||
$out = print_r($args, 1);
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
@@ -287,16 +293,15 @@ class DBConnection
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function GetLastID ()
|
||||
public function GetLastID()
|
||||
{
|
||||
if (PEAR_DATABASE == "mysql") {
|
||||
return mysql_insert_id();
|
||||
if (PEAR_DATABASE === 'mysql') {
|
||||
$lastId = mysqli_insert_id($this->db);
|
||||
} else {
|
||||
$dberror = PEAR::raiseError( null, DB_ERROR_FEATURE_NOT_AVAILABLE, null, 'null', "getLastID with " . PEAR_DATABASE . ' database.', 'G_Error', true );
|
||||
DBconnection::logError( $dberror, DB_ERROR_SHOWALL_AND_STOP ); //this error will stop the execution, until we add this feature!!
|
||||
return $dberror;
|
||||
$dberror = PEAR::raiseError(null, DB_ERROR_FEATURE_NOT_AVAILABLE, null, 'null', "getLastID with " . PEAR_DATABASE . ' database.', 'G_Error', true);
|
||||
DBconnection::logError($dberror, DB_ERROR_SHOWALL_AND_STOP); //this error will stop the execution, until we add this feature!!
|
||||
$lastId = $dberror;
|
||||
}
|
||||
return mysql_insert_id();
|
||||
return $lastId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ class DBTable
|
||||
* @param array array of arguments key values
|
||||
* @return void
|
||||
*/
|
||||
public function load()
|
||||
public function load($sUID = null)
|
||||
{
|
||||
// bug::traceRoute();
|
||||
$ncount = 0;
|
||||
@@ -347,7 +347,7 @@ class DBTable
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function save()
|
||||
public function save($Fields = null, $labels = [], $options = [])
|
||||
{
|
||||
if ($this->is_new == true) {
|
||||
return $this->Insert();
|
||||
@@ -363,7 +363,7 @@ class DBTable
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete()
|
||||
public function delete($uid = null)
|
||||
{
|
||||
$stQry = "delete from `" . $this->table_name . "` ";
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -96,7 +96,7 @@ class headPublisher
|
||||
$this->addScriptCode(' var __usernameLogged__ = "' . (isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : '') . '";var SYS_LANG = "' . SYS_LANG . '";');
|
||||
}
|
||||
|
||||
public function &getSingleton()
|
||||
public static function &getSingleton()
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new headPublisher();
|
||||
@@ -360,7 +360,7 @@ class headPublisher
|
||||
//$head .= $this->getExtJsStylesheets();
|
||||
$head .= $this->getExtJsScripts();
|
||||
$head .= $this->getExtJsVariablesScript();
|
||||
$oServerConf = & ServerConf::getSingleton();
|
||||
$oServerConf = ServerConf::getSingleton();
|
||||
if ($oServerConf->isRtl(SYS_LANG)) {
|
||||
$head = $head . " <script type=\"text/javascript\" src=\"" . G::browserCacheFilesUrl("/js/ext/extjs_rtl.js") . "\"></script>\n";
|
||||
}
|
||||
@@ -752,7 +752,7 @@ class headPublisher
|
||||
$views = array();
|
||||
$keyState = "extJsViewState";
|
||||
$prefixExtJs = "ys-";
|
||||
$oServerConf = &ServerConf::getSingleton();
|
||||
$oServerConf = ServerConf::getSingleton();
|
||||
$deleteCache = true;
|
||||
|
||||
$sjson = $oServerConf->getProperty($keyState);
|
||||
|
||||
@@ -14,7 +14,7 @@ class HttpProxyController
|
||||
*
|
||||
* @var array - private array to store proxy data
|
||||
*/
|
||||
private $__data__ = array ();
|
||||
private $__data__ = array();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -26,7 +26,8 @@ class HttpProxyController
|
||||
|
||||
private $sendResponse = true;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->__request__ = new stdclass();
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@ class HttpProxyController
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function __set ($name, $value)
|
||||
public function __set($name, $value)
|
||||
{
|
||||
//echo "Setting '$name' to '$value'\n";
|
||||
$this->__data__[$name] = $value;
|
||||
@@ -48,10 +49,10 @@ class HttpProxyController
|
||||
* @param string $name
|
||||
* @return string or NULL if the internal var doesn't exist
|
||||
*/
|
||||
public function __get ($name)
|
||||
public function __get($name)
|
||||
{
|
||||
//echo "Getting '$name'\n";
|
||||
if (array_key_exists( $name, $this->__data__ )) {
|
||||
if (array_key_exists($name, $this->__data__)) {
|
||||
return $this->__data__[$name];
|
||||
}
|
||||
|
||||
@@ -69,10 +70,10 @@ class HttpProxyController
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __isset ($name)
|
||||
public function __isset($name)
|
||||
{
|
||||
//echo "Is '$name' set?\n";
|
||||
return isset( $this->__data__[$name] );
|
||||
return isset($this->__data__[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,10 +81,10 @@ class HttpProxyController
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function __unset ($name)
|
||||
public function __unset($name)
|
||||
{
|
||||
//echo "Unsetting '$name'\n";
|
||||
unset( $this->__data__[$name] );
|
||||
unset($this->__data__[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,11 +92,11 @@ class HttpProxyController
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function call ($name)
|
||||
public function call($name)
|
||||
{
|
||||
$result = new stdClass();
|
||||
try {
|
||||
$result = $this->$name( $this->__request__ );
|
||||
$result = $this->$name($this->__request__);
|
||||
|
||||
if (! $this->jsonResponse) {
|
||||
return null;
|
||||
@@ -104,11 +105,10 @@ class HttpProxyController
|
||||
if (! $result) {
|
||||
$result = $this->__data__;
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$result->success = false;
|
||||
$result->message = $result->msg = $e->getMessage();
|
||||
switch (get_class( $e )) {
|
||||
switch (get_class($e)) {
|
||||
case 'Exception':
|
||||
$error = "SYSTEM ERROR";
|
||||
break;
|
||||
@@ -124,13 +124,13 @@ class HttpProxyController
|
||||
}
|
||||
$result->error = $e->getMessage();
|
||||
$result->exception = new stdClass();
|
||||
$result->exception->class = get_class( $e );
|
||||
$result->exception->class = get_class($e);
|
||||
$result->exception->code = $e->getCode();
|
||||
$result->exception->trace = $e->getTraceAsString();
|
||||
}
|
||||
|
||||
if ($this->sendResponse) {
|
||||
print G::json_encode( $result );
|
||||
print G::json_encode($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,18 +139,18 @@ class HttpProxyController
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function setHttpRequestData ($data)
|
||||
public function setHttpRequestData($data)
|
||||
{
|
||||
if (is_array( $data )) {
|
||||
while ($var = each( $data )) {
|
||||
$this->__request__->$var['key'] = $var['value'];
|
||||
if (is_array($data)) {
|
||||
while ($var = each($data)) {
|
||||
$this->__request__->{$var['key']} = $var['value'];
|
||||
}
|
||||
} else {
|
||||
$this->__request__ = $data;
|
||||
}
|
||||
}
|
||||
|
||||
public function setJsonResponse ($bool)
|
||||
public function setJsonResponse($bool)
|
||||
{
|
||||
$this->jsonResponse = $bool;
|
||||
}
|
||||
@@ -160,9 +160,8 @@ class HttpProxyController
|
||||
*
|
||||
* @param boolean $val
|
||||
*/
|
||||
public function setSendResponse ($val)
|
||||
public function setSendResponse($val)
|
||||
{
|
||||
$this->sendResponse = $val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
/** @class: InputFilter (PHP4 & PHP5, with comments)
|
||||
* @project: PHP Input Filter
|
||||
* @date: 10-05-2005
|
||||
* @version: 1.2.2_php4/php5
|
||||
* @author: Daniel Morris
|
||||
* @contributors: Gianpaolo Racca, Ghislain Picard, Marco Wandschneider, Chris Tobin and Andrew Eddie.
|
||||
* @copyright: Daniel Morris
|
||||
* @email: dan@rootcube.com
|
||||
* @license: GNU General Public License (GPL)
|
||||
*/
|
||||
* @project: PHP Input Filter
|
||||
* @date: 10-05-2005
|
||||
* @version: 1.2.2_php4/php5
|
||||
* @author: Daniel Morris
|
||||
* @contributors: Gianpaolo Racca, Ghislain Picard, Marco Wandschneider, Chris Tobin and Andrew Eddie.
|
||||
* @copyright: Daniel Morris
|
||||
* @email: dan@rootcube.com
|
||||
* @license: GNU General Public License (GPL)
|
||||
*/
|
||||
class InputFilter
|
||||
{
|
||||
public $tagsArray;// default = empty array
|
||||
@@ -22,15 +22,15 @@ class InputFilter
|
||||
public $tagBlacklist = array('applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml');
|
||||
public $attrBlacklist = array('action', 'background', 'codebase', 'dynsrc', 'lowsrc'); // also will strip ALL event handlers
|
||||
|
||||
/**
|
||||
* Constructor for inputFilter class. Only first parameter is required.
|
||||
* @access constructor
|
||||
* @param Array $tagsArray - list of user-defined tags
|
||||
* @param Array $attrArray - list of user-defined attributes
|
||||
* @param int $tagsMethod - 0= allow just user-defined, 1= allow all but user-defined
|
||||
* @param int $attrMethod - 0= allow just user-defined, 1= allow all but user-defined
|
||||
* @param int $xssAuto - 0= only auto clean essentials, 1= allow clean blacklisted tags/attr
|
||||
*/
|
||||
/**
|
||||
* Constructor for inputFilter class. Only first parameter is required.
|
||||
* @access constructor
|
||||
* @param Array $tagsArray - list of user-defined tags
|
||||
* @param Array $attrArray - list of user-defined attributes
|
||||
* @param int $tagsMethod - 0= allow just user-defined, 1= allow all but user-defined
|
||||
* @param int $attrMethod - 0= allow just user-defined, 1= allow all but user-defined
|
||||
* @param int $xssAuto - 0= only auto clean essentials, 1= allow clean blacklisted tags/attr
|
||||
*/
|
||||
public function inputFilter($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1)
|
||||
{
|
||||
// make sure user defined arrays are in lowercase
|
||||
@@ -41,19 +41,19 @@ class InputFilter
|
||||
$attrArray[$i] = strtolower($attrArray[$i]);
|
||||
}
|
||||
// assign to member vars
|
||||
$this->tagsArray = (array) $tagsArray;
|
||||
$this->attrArray = (array) $attrArray;
|
||||
$this->tagsArray = (array)$tagsArray;
|
||||
$this->attrArray = (array)$attrArray;
|
||||
$this->tagsMethod = $tagsMethod;
|
||||
$this->attrMethod = $attrMethod;
|
||||
$this->xssAuto = $xssAuto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to be called by another php script. Processes for XSS and specified bad code.
|
||||
* @access public
|
||||
* @param Mixed $source - input string/array-of-string to be 'cleaned'
|
||||
* @return String $source - 'cleaned' version of input parameter
|
||||
*/
|
||||
/**
|
||||
* Method to be called by another php script. Processes for XSS and specified bad code.
|
||||
* @access public
|
||||
* @param Mixed $source - input string/array-of-string to be 'cleaned'
|
||||
* @return String $source - 'cleaned' version of input parameter
|
||||
*/
|
||||
public function process($source)
|
||||
{
|
||||
// clean all elements in this array
|
||||
@@ -75,15 +75,15 @@ class InputFilter
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to iteratively remove all unwanted tags and attributes
|
||||
* @access protected
|
||||
* @param String $source - input string to be 'cleaned'
|
||||
* @return String $source - 'cleaned' version of input parameter
|
||||
*/
|
||||
/**
|
||||
* Internal method to iteratively remove all unwanted tags and attributes
|
||||
* @access protected
|
||||
* @param String $source - input string to be 'cleaned'
|
||||
* @return String $source - 'cleaned' version of input parameter
|
||||
*/
|
||||
public function remove($source)
|
||||
{
|
||||
$loopCounter=0;
|
||||
$loopCounter = 0;
|
||||
// provides nested-tag protection
|
||||
while ($source != $this->filterTags($source)) {
|
||||
$source = $this->filterTags($source);
|
||||
@@ -92,12 +92,12 @@ class InputFilter
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to strip a string of certain tags
|
||||
* @access protected
|
||||
* @param String $source - input string to be 'cleaned'
|
||||
* @return String $source - 'cleaned' version of input parameter
|
||||
*/
|
||||
/**
|
||||
* Internal method to strip a string of certain tags
|
||||
* @access protected
|
||||
* @param String $source - input string to be 'cleaned'
|
||||
* @return String $source - 'cleaned' version of input parameter
|
||||
*/
|
||||
public function filterTags($source)
|
||||
{
|
||||
// filter pass setup
|
||||
@@ -119,8 +119,8 @@ class InputFilter
|
||||
// next start of tag (for nested tag assessment)
|
||||
$tagOpen_nested = strpos($fromTagOpen, '<');
|
||||
if (($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end)) {
|
||||
$preTag .= substr($postTag, 0, ($tagOpen_nested+1));
|
||||
$postTag = substr($postTag, ($tagOpen_nested+1));
|
||||
$preTag .= substr($postTag, 0, ($tagOpen_nested + 1));
|
||||
$postTag = substr($postTag, ($tagOpen_nested + 1));
|
||||
$tagOpen_start = strpos($postTag, '<');
|
||||
continue;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ class InputFilter
|
||||
list($tagName) = explode(' ', $currentTag);
|
||||
}
|
||||
// excludes all "non-regular" tagnames OR no tagname OR remove if xssauto is on and tag is blacklisted
|
||||
if ((!preg_match("/^[a-z][a-z0-9]*$/i",$tagName)) || (!$tagName) || ((in_array(strtolower($tagName), $this->tagBlacklist)) && ($this->xssAuto))) {
|
||||
if ((!preg_match("/^[a-z][a-z0-9]*$/i", $tagName)) || (!$tagName) || ((in_array(strtolower($tagName), $this->tagBlacklist)) && ($this->xssAuto))) {
|
||||
$postTag = substr($postTag, ($tagLength + 2));
|
||||
$tagOpen_start = strpos($postTag, '<');
|
||||
// don't append this tag
|
||||
@@ -154,15 +154,15 @@ class InputFilter
|
||||
}
|
||||
// this while is needed to support attribute values with spaces in!
|
||||
while ($currentSpace !== false) {
|
||||
$fromSpace = substr($tagLeft, ($currentSpace+1));
|
||||
$fromSpace = substr($tagLeft, ($currentSpace + 1));
|
||||
$nextSpace = strpos($fromSpace, ' ');
|
||||
$openQuotes = strpos($fromSpace, '"');
|
||||
$closeQuotes = strpos(substr($fromSpace, ($openQuotes+1)), '"') + $openQuotes + 1;
|
||||
$closeQuotes = strpos(substr($fromSpace, ($openQuotes + 1)), '"') + $openQuotes + 1;
|
||||
// another equals exists
|
||||
if (strpos($fromSpace, '=') !== false) {
|
||||
// opening and closing quotes exists
|
||||
if (($openQuotes !== false) && (strpos(substr($fromSpace, ($openQuotes+1)), '"') !== false)) {
|
||||
$attr = substr($fromSpace, 0, ($closeQuotes+1));
|
||||
if (($openQuotes !== false) && (strpos(substr($fromSpace, ($openQuotes + 1)), '"') !== false)) {
|
||||
$attr = substr($fromSpace, 0, ($closeQuotes + 1));
|
||||
} else {
|
||||
// one or neither exist
|
||||
$attr = substr($fromSpace, 0, $nextSpace);
|
||||
@@ -212,17 +212,17 @@ class InputFilter
|
||||
return $preTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to strip a tag of certain attributes
|
||||
* @access protected
|
||||
* @param Array $attrSet
|
||||
* @return Array $newSet
|
||||
*/
|
||||
/**
|
||||
* Internal method to strip a tag of certain attributes
|
||||
* @access protected
|
||||
* @param Array $attrSet
|
||||
* @return Array $newSet
|
||||
*/
|
||||
public function filterAttr($attrSet)
|
||||
{
|
||||
$newSet = array();
|
||||
// process attributes
|
||||
for ($i = 0; $i <count($attrSet); $i++) {
|
||||
for ($i = 0; $i < count($attrSet); $i++) {
|
||||
// skip blank spaces in tag
|
||||
if (!$attrSet[$i]) {
|
||||
continue;
|
||||
@@ -231,7 +231,7 @@ class InputFilter
|
||||
$attrSubSet = explode('=', trim($attrSet[$i]));
|
||||
list($attrSubSet[0]) = explode(' ', $attrSubSet[0]);
|
||||
// removes all "non-regular" attr names AND also attr blacklisted
|
||||
if ((!eregi("^[a-z]*$",$attrSubSet[0])) || (($this->xssAuto) && ((in_array(strtolower($attrSubSet[0]), $this->attrBlacklist)) || (substr($attrSubSet[0], 0, 2) == 'on')))) {
|
||||
if ((!preg_match("/^[a-z]*$/i", $attrSubSet[0])) || (($this->xssAuto) && ((in_array(strtolower($attrSubSet[0]), $this->attrBlacklist)) || (substr($attrSubSet[0], 0, 2) == 'on')))) {
|
||||
continue;
|
||||
}
|
||||
// xss attr value filtering
|
||||
@@ -250,12 +250,12 @@ class InputFilter
|
||||
$attrSubSet[1] = stripslashes($attrSubSet[1]);
|
||||
}
|
||||
// auto strip attr's with "javascript:
|
||||
if (((strpos(strtolower($attrSubSet[1]), 'expression') !== false) &&(strtolower($attrSubSet[0]) == 'style')) ||
|
||||
(strpos(strtolower($attrSubSet[1]), 'javascript:') !== false) ||
|
||||
(strpos(strtolower($attrSubSet[1]), 'behaviour:') !== false) ||
|
||||
(strpos(strtolower($attrSubSet[1]), 'vbscript:') !== false) ||
|
||||
(strpos(strtolower($attrSubSet[1]), 'mocha:') !== false) ||
|
||||
(strpos(strtolower($attrSubSet[1]), 'livescript:') !== false)
|
||||
if (((strpos(strtolower($attrSubSet[1]), 'expression') !== false) && (strtolower($attrSubSet[0]) == 'style')) ||
|
||||
(strpos(strtolower($attrSubSet[1]), 'javascript:') !== false) ||
|
||||
(strpos(strtolower($attrSubSet[1]), 'behaviour:') !== false) ||
|
||||
(strpos(strtolower($attrSubSet[1]), 'vbscript:') !== false) ||
|
||||
(strpos(strtolower($attrSubSet[1]), 'mocha:') !== false) ||
|
||||
(strpos(strtolower($attrSubSet[1]), 'livescript:') !== false)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
@@ -279,30 +279,34 @@ class InputFilter
|
||||
return $newSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to convert to plaintext
|
||||
* @access protected
|
||||
* @param String $source
|
||||
* @return String $source
|
||||
*/
|
||||
/**
|
||||
* Try to convert to plaintext
|
||||
* @access protected
|
||||
* @param String $source
|
||||
* @return String $source
|
||||
*/
|
||||
public function decode($source)
|
||||
{
|
||||
// url decode
|
||||
$source = html_entity_decode($source, ENT_QUOTES, "ISO-8859-1");
|
||||
// convert decimal
|
||||
$source = preg_replace('/&#(\d+);/me',"chr(\\1)", $source);// decimal notation
|
||||
$source = preg_replace_callback('/&#(\d+);/m', function ($matches) {
|
||||
return utf8_encode(chr($matches[1]));
|
||||
}, $source);// decimal notation
|
||||
// convert hex
|
||||
$source = preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)", $source);// hex notation
|
||||
$source = preg_replace_callback('/&#x([a-f0-9]+);/mi', function ($matches) {
|
||||
return utf8_encode(chr('0x' . $matches[1]));
|
||||
}, $source);// hex notation
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to be called by another php script. Processes for SQL injection
|
||||
* @access public
|
||||
* @param Mixed $source - input string/array-of-string to be 'cleaned'
|
||||
* @param Buffer $connection - An open MySQL connection
|
||||
* @return String $source - 'cleaned' version of input parameter
|
||||
*/
|
||||
/**
|
||||
* Method to be called by another php script. Processes for SQL injection
|
||||
* @access public
|
||||
* @param Mixed $source - input string/array-of-string to be 'cleaned'
|
||||
* @param Buffer $connection - An open MySQL connection
|
||||
* @return String $source - 'cleaned' version of input parameter
|
||||
*/
|
||||
public function safeSQL($source, &$connection)
|
||||
{
|
||||
// clean all elements in this array
|
||||
@@ -326,14 +330,14 @@ class InputFilter
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Chris Tobin
|
||||
* @author Daniel Morris
|
||||
* @access protected
|
||||
* @param String $source
|
||||
* @param Resource $connection - An open MySQL connection
|
||||
* @return String $source
|
||||
*/
|
||||
/**
|
||||
* @author Chris Tobin
|
||||
* @author Daniel Morris
|
||||
* @access protected
|
||||
* @param String $source
|
||||
* @param Resource $connection - An open MySQL connection
|
||||
* @return String $source
|
||||
*/
|
||||
public function quoteSmart($source, &$connection)
|
||||
{
|
||||
// strip slashes
|
||||
@@ -345,44 +349,37 @@ class InputFilter
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Chris Tobin
|
||||
* @author Daniel Morris
|
||||
* @access protected
|
||||
* @param String $source
|
||||
* @param Resource $connection - An open MySQL connection
|
||||
* @return String $source
|
||||
*/
|
||||
/**
|
||||
* @author Chris Tobin
|
||||
* @author Daniel Morris
|
||||
* @access protected
|
||||
* @param String $source
|
||||
* @param Resource $connection - An open MySQL connection
|
||||
* @return String $source
|
||||
*/
|
||||
public function escapeString($string, &$connection)
|
||||
{
|
||||
// depreciated function
|
||||
if (version_compare(phpversion(),"4.3.0", "<")) {
|
||||
mysql_escape_string($string);
|
||||
} else {
|
||||
// current function
|
||||
mysql_real_escape_string($string);
|
||||
}
|
||||
return $string;
|
||||
return mysqli_real_escape_string($connection, $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method removes tags/special characters
|
||||
* @author Marcelo Cuiza
|
||||
* @access protected
|
||||
* @param Array or String $input
|
||||
* @param String $type
|
||||
* @return Array or String $input
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal method removes tags/special characters
|
||||
* @author Marcelo Cuiza
|
||||
* @access protected
|
||||
* @param Array or String $input
|
||||
* @param String $type
|
||||
* @return Array or String $input
|
||||
*/
|
||||
public function xssFilter($input, $type = "")
|
||||
{
|
||||
if(is_array($input)) {
|
||||
if(sizeof($input)) {
|
||||
foreach($input as $i => $val) {
|
||||
if(is_array($val) && sizeof($val)) {
|
||||
if (is_array($input)) {
|
||||
if (count($input)) {
|
||||
foreach ($input as $i => $val) {
|
||||
if (is_array($val) && count($val)) {
|
||||
$input[$i] = $this->xssFilter($val);
|
||||
} else {
|
||||
if(!empty($val)) {
|
||||
if($type != "url") {
|
||||
if (!empty($val)) {
|
||||
if ($type != "url") {
|
||||
$inputFiltered = addslashes(htmlspecialchars(filter_var($val, FILTER_SANITIZE_STRING), ENT_COMPAT, 'UTF-8'));
|
||||
} else {
|
||||
$inputFiltered = filter_var($val, FILTER_SANITIZE_STRING);
|
||||
@@ -393,13 +390,13 @@ class InputFilter
|
||||
$input[$i] = $inputFiltered;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $input;
|
||||
} else {
|
||||
if(!isset($input) || trim($input) === '' || $input === NULL ) {
|
||||
if (!isset($input) || trim($input) === '' || $input === null) {
|
||||
return '';
|
||||
} else {
|
||||
if($type != "url") {
|
||||
if ($type != "url") {
|
||||
return addslashes(htmlspecialchars(filter_var($input, FILTER_SANITIZE_STRING), ENT_COMPAT, 'UTF-8'));
|
||||
} else {
|
||||
return filter_var($input, FILTER_SANITIZE_STRING);
|
||||
@@ -407,41 +404,41 @@ class InputFilter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method: remove malicious code, fix missing end tags, fix illegal nesting, convert deprecated tags, validate CSS, preserve rich formatting
|
||||
* @author Marcelo Cuiza
|
||||
* @access protected
|
||||
* @param Array or String $input
|
||||
* @param String $type (url)
|
||||
* @return Array or String $input
|
||||
*/
|
||||
function xssFilterHard($input, $type = "")
|
||||
{
|
||||
|
||||
/**
|
||||
* Internal method: remove malicious code, fix missing end tags, fix illegal nesting, convert deprecated tags, validate CSS, preserve rich formatting
|
||||
* @author Marcelo Cuiza
|
||||
* @access protected
|
||||
* @param Array or String $input
|
||||
* @param String $type (url)
|
||||
* @return Array or String $input
|
||||
*/
|
||||
public function xssFilterHard($input, $type = "")
|
||||
{
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$purifier = new HTMLPurifier($config);
|
||||
if(is_array($input)) {
|
||||
if(sizeof($input)) {
|
||||
foreach($input as $i => $val) {
|
||||
if(is_array($val) || is_object($val) && sizeof($val)) {
|
||||
if (is_array($input)) {
|
||||
if (count($input)) {
|
||||
foreach ($input as $i => $val) {
|
||||
if (is_array($val) || is_object($val) && count($val)) {
|
||||
$input[$i] = $this->xssFilterHard($val);
|
||||
} else {
|
||||
if(!empty($val)) {
|
||||
if(!is_object(G::json_decode($val))) {
|
||||
if (!empty($val)) {
|
||||
if (!is_object(G::json_decode($val))) {
|
||||
$inputFiltered = $purifier->purify($val);
|
||||
if($type != "url" && !strpos(basename($val), "=")) {
|
||||
$inputFiltered = htmlspecialchars($inputFiltered, ENT_NOQUOTES, 'UTF-8');
|
||||
if ($type != "url" && !strpos(basename($val), "=")) {
|
||||
$inputFiltered = htmlspecialchars($inputFiltered, ENT_NOQUOTES, 'UTF-8');
|
||||
} else {
|
||||
$inputFiltered = str_replace('&','&',$inputFiltered);
|
||||
$inputFiltered = str_replace('&', '&', $inputFiltered);
|
||||
}
|
||||
} else {
|
||||
$jsArray = G::json_decode($val,true);
|
||||
if(is_array($jsArray) && sizeof($jsArray)) {
|
||||
foreach($jsArray as $j => $jsVal){
|
||||
if(is_array($jsVal) && sizeof($jsVal)) {
|
||||
$jsArray = G::json_decode($val, true);
|
||||
if (is_array($jsArray) && count($jsArray)) {
|
||||
foreach ($jsArray as $j => $jsVal) {
|
||||
if (is_array($jsVal) && count($jsVal)) {
|
||||
$jsArray[$j] = $this->xssFilterHard($jsVal);
|
||||
} else {
|
||||
if(!empty($jsVal)) {
|
||||
if (!empty($jsVal)) {
|
||||
$jsArray[$j] = $purifier->purify($jsVal);
|
||||
}
|
||||
}
|
||||
@@ -450,7 +447,7 @@ class InputFilter
|
||||
} else {
|
||||
$inputFiltered = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$inputFiltered = "";
|
||||
}
|
||||
@@ -460,16 +457,16 @@ class InputFilter
|
||||
}
|
||||
return $input;
|
||||
} else {
|
||||
if(!isset($input) || empty($input)) {
|
||||
if (!isset($input) || empty($input)) {
|
||||
return '';
|
||||
} else {
|
||||
if(is_object($input)) {
|
||||
if(sizeof($input)) {
|
||||
foreach($input as $j => $jsVal){
|
||||
if(is_array($jsVal) || is_object($jsVal) && sizeof($jsVal)) {
|
||||
if (is_object($input)) {
|
||||
if (count($input)) {
|
||||
foreach ($input as $j => $jsVal) {
|
||||
if (is_array($jsVal) || is_object($jsVal) && count($jsVal)) {
|
||||
$input->j = $this->xssFilterHard($jsVal);
|
||||
} else {
|
||||
if(!empty($jsVal)) {
|
||||
if (!empty($jsVal)) {
|
||||
$input->j = $purifier->purify($jsVal);
|
||||
}
|
||||
}
|
||||
@@ -477,97 +474,101 @@ class InputFilter
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
if(!is_object(G::json_decode($input))) {
|
||||
if (!is_object(G::json_decode($input))) {
|
||||
$input = $purifier->purify($input);
|
||||
if($type != "url" && !strpos(basename($input), "=")) {
|
||||
if ($type != "url" && !strpos(basename($input), "=")) {
|
||||
$input = addslashes(htmlspecialchars($input, ENT_COMPAT, 'UTF-8'));
|
||||
} else {
|
||||
$input = str_replace('&','&',$input);
|
||||
$input = str_replace('&', '&', $input);
|
||||
}
|
||||
} else {
|
||||
$jsArray = G::json_decode($input,true);
|
||||
if(is_array($jsArray) && sizeof($jsArray)) {
|
||||
foreach($jsArray as $j => $jsVal){
|
||||
if(is_array($jsVal) || is_object($jsVal) && sizeof($jsVal)) {
|
||||
$jsArray = G::json_decode($input, true);
|
||||
if (is_array($jsArray) && count($jsArray)) {
|
||||
foreach ($jsArray as $j => $jsVal) {
|
||||
if (is_array($jsVal) || is_object($jsVal) && count($jsVal)) {
|
||||
$jsArray[$j] = $this->xssFilterHard($jsVal);
|
||||
} else {
|
||||
if(!empty($jsVal)) {
|
||||
if (!empty($jsVal)) {
|
||||
$jsArray[$j] = $purifier->purify($jsVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
$input = G::json_encode($jsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method: protect against SQL injection
|
||||
* @author Marcelo Cuiza
|
||||
* @access protected
|
||||
* @param String $con
|
||||
* @param String $query
|
||||
* @param Array $values
|
||||
* @return String $query
|
||||
*/
|
||||
function preventSqlInjection($query, $values = Array(), $con = NULL)
|
||||
|
||||
/**
|
||||
* Internal method: protect against SQL injection
|
||||
* @author Marcelo Cuiza
|
||||
* @access protected
|
||||
* @param String $con
|
||||
* @param String $query
|
||||
* @param array $values
|
||||
* @return String $query
|
||||
*/
|
||||
public function preventSqlInjection($query, $values = array(), $con = null)
|
||||
{
|
||||
if(is_array($values) && sizeof($values)) {
|
||||
foreach($values as $k1 => $val1) {
|
||||
$values[$k1] = mysql_real_escape_string($val1);
|
||||
if (empty($con)) {
|
||||
$con = Propel::getConnection('workflow');
|
||||
$con = $con->getResource();
|
||||
}
|
||||
if (is_array($values) && count($values)) {
|
||||
|
||||
foreach ($values as $k1 => $val1) {
|
||||
$values[$k1] = mysqli_real_escape_string($con, $val1);
|
||||
}
|
||||
|
||||
if ( get_magic_quotes_gpc() ) {
|
||||
foreach($values as $k => $val) {
|
||||
|
||||
if (get_magic_quotes_gpc()) {
|
||||
foreach ($values as $k => $val) {
|
||||
$values[$k] = stripslashes($val);
|
||||
}
|
||||
}
|
||||
$newquery = vsprintf($query,$values);
|
||||
$newQuery = vsprintf($query, $values);
|
||||
} else {
|
||||
//$newquery = mysql_real_escape_string($query);
|
||||
$newquery = $this->quoteSmart($this->decode($query), $con);
|
||||
$newQuery = $this->quoteSmart($this->decode($query), $con);
|
||||
}
|
||||
return $newquery;
|
||||
return $newQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method: validate user input
|
||||
* @author Marcelo Cuiza
|
||||
* @access protected
|
||||
* @param String $value (required)
|
||||
* @param Array or String $types ( string | int | float | boolean | path | nosql )
|
||||
* @param String $valType ( validate | sanitize )
|
||||
* @return String $value
|
||||
*/
|
||||
function validateInput($value, $types = 'string', $valType = 'sanitize')
|
||||
|
||||
/**
|
||||
* Internal method: validate user input
|
||||
* @author Marcelo Cuiza
|
||||
* @access protected
|
||||
* @param String $value (required)
|
||||
* @param Array or String $types ( string | int | float | boolean | path | nosql )
|
||||
* @param String $valType ( validate | sanitize )
|
||||
* @return String $value
|
||||
*/
|
||||
public function validateInput($value, $types = 'string', $valType = 'sanitize')
|
||||
{
|
||||
if(!isset($value) || empty($value)) {
|
||||
if (!isset($value) || empty($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if(is_array($types) && sizeof($types)){
|
||||
foreach($types as $type){
|
||||
if($valType == 'sanitize') {
|
||||
}
|
||||
|
||||
if (is_array($types) && count($types)) {
|
||||
foreach ($types as $type) {
|
||||
if ($valType == 'sanitize') {
|
||||
$value = $this->sanitizeInputValue($value, $type);
|
||||
} else {
|
||||
$value = $this->validateInputValue($value, $type);
|
||||
$value = $this->validateInputValue($value, $type);
|
||||
}
|
||||
}
|
||||
} elseif(is_string($types)) {
|
||||
if($types == 'sanitize' || $types == 'validate') {
|
||||
}
|
||||
} elseif (is_string($types)) {
|
||||
if ($types === 'sanitize' || $types === 'validate') {
|
||||
$valType = $types;
|
||||
$types = 'string';
|
||||
}
|
||||
if($valType == 'sanitize') {
|
||||
if ($valType === 'sanitize') {
|
||||
$value = $this->sanitizeInputValue($value, $types);
|
||||
} else {
|
||||
$value = $this->validateInputValue($value, $types);
|
||||
$value = $this->validateInputValue($value, $types);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -576,36 +577,36 @@ class InputFilter
|
||||
* @param $type
|
||||
* @return bool|int|mixed|string
|
||||
*/
|
||||
function sanitizeInputValue($value, $type) {
|
||||
|
||||
switch($type) {
|
||||
public function sanitizeInputValue($value, $type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'float':
|
||||
$value = filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND);
|
||||
break;
|
||||
break;
|
||||
case 'int':
|
||||
$value = (int)filter_var($value, FILTER_SANITIZE_NUMBER_INT);
|
||||
break;
|
||||
break;
|
||||
case 'boolean':
|
||||
$value = (boolean)filter_var($value, FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE);
|
||||
break;
|
||||
$value = (boolean)filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||
break;
|
||||
case 'path':
|
||||
if(!file_exists($value)) {
|
||||
if(!is_dir($value)) {
|
||||
if (!file_exists($value)) {
|
||||
if (!is_dir($value)) {
|
||||
$value = '';
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 'nosql':
|
||||
$value = (string)filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
|
||||
if(preg_match('/\b(or|and|xor|drop|insert|update|delete|select)\b/i' , $value, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
$value = substr($value,0,$matches[0][1]);
|
||||
if (preg_match('/\b(or|and|xor|drop|insert|update|delete|select)\b/i', $value, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
$value = substr($value, 0, $matches[0][1]);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
$value = (string)filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -613,39 +614,39 @@ class InputFilter
|
||||
* @param $type
|
||||
* @throws Exception
|
||||
*/
|
||||
function validateInputValue($value, $type) {
|
||||
|
||||
switch($type) {
|
||||
public function validateInputValue($value, $type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'float':
|
||||
$value = str_replace(',', '.', $value);
|
||||
if(!filter_var($value, FILTER_VALIDATE_FLOAT)) {
|
||||
throw new Exception('not a float value');
|
||||
if (!filter_var($value, FILTER_VALIDATE_FLOAT)) {
|
||||
throw new Exception('not a float value');
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 'int':
|
||||
if(!filter_var($value, FILTER_VALIDATE_INT)) {
|
||||
throw new Exception('not a int value');
|
||||
if (!filter_var($value, FILTER_VALIDATE_INT)) {
|
||||
throw new Exception('not a int value');
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 'boolean':
|
||||
if(!preg_match('/\b(yes|no|false|true|1|0)\b/i' , $value)) {
|
||||
if (!preg_match('/\b(yes|no|false|true|1|0)\b/i', $value)) {
|
||||
throw new Exception('not a boolean value');
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 'path':
|
||||
if(!file_exists($value)) {
|
||||
if(!is_dir($value)) {
|
||||
if (!file_exists($value)) {
|
||||
if (!is_dir($value)) {
|
||||
throw new Exception('not a valid path');
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 'nosql':
|
||||
if(preg_match('/\b(or|and|xor|drop|insert|update|delete|select)\b/i' , $value)) {
|
||||
if (preg_match('/\b(or|and|xor|drop|insert|update|delete|select)\b/i', $value)) {
|
||||
throw new Exception('sql command found');
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
if(!is_string($value)) {
|
||||
if (!is_string($value)) {
|
||||
throw new Exception('not a string value');
|
||||
}
|
||||
}
|
||||
@@ -655,7 +656,8 @@ class InputFilter
|
||||
* @param $pathFile
|
||||
* @return string
|
||||
*/
|
||||
function validatePath($pathFile) {
|
||||
public function validatePath($pathFile)
|
||||
{
|
||||
$sanitizefilteredPath = mb_ereg_replace("([\.]{2,})", '', $pathFile);
|
||||
$sanitizefilteredPath = mb_ereg_replace("(^~)", '', $sanitizefilteredPath);
|
||||
return $sanitizefilteredPath;
|
||||
@@ -664,23 +666,23 @@ class InputFilter
|
||||
/**
|
||||
* Filter only characters valids by regular expression
|
||||
*
|
||||
* @param mixed $data Data
|
||||
* @param mixed $data Data
|
||||
* @param mixed $regex Regular expression
|
||||
*
|
||||
* @return mixed Returns data with the characters valids by regular expression
|
||||
*/
|
||||
function xssRegexFilter($data, $regex)
|
||||
public function xssRegexFilter($data, $regex)
|
||||
{
|
||||
try {
|
||||
switch (gettype($data)) {
|
||||
case 'array':
|
||||
foreach ($data as $key => $value) {
|
||||
$data[$key] = $this->xssRegexFilter($value, (is_array($regex))? ((isset($regex[$key]))? $regex[$key] : '') : $regex);
|
||||
$data[$key] = $this->xssRegexFilter($value, (is_array($regex)) ? ((isset($regex[$key])) ? $regex[$key] : '') : $regex);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($regex != '') {
|
||||
$data = (preg_match_all($regex, $data, $arrayMatch))? implode('', $arrayMatch[0]) : '';
|
||||
$data = (preg_match_all($regex, $data, $arrayMatch)) ? implode('', $arrayMatch[0]) : '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class MonologProvider
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getSingleton ($channel, $fileLog)
|
||||
public static function getSingleton ($channel, $fileLog)
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new MonologProvider($channel, $fileLog);
|
||||
|
||||
@@ -33,20 +33,19 @@
|
||||
* @package gulliver.system
|
||||
* @access public
|
||||
*/
|
||||
|
||||
class pagedTable
|
||||
{
|
||||
public $xmlFormFile;
|
||||
public $currentPage;
|
||||
public $orderBy = '';
|
||||
public $filter = array ();
|
||||
public $filterType = array ();
|
||||
public $filter = array();
|
||||
public $filterType = array();
|
||||
public $searchBy = '';
|
||||
public $fastSearch = '';
|
||||
public $order = '';
|
||||
public $template = 'templates/paged-table.html';
|
||||
public $tpl;
|
||||
public $style = array ();
|
||||
public $style = array();
|
||||
public $rowsPerPage = 25;
|
||||
public $ownerPage;
|
||||
public $popupPage;
|
||||
@@ -105,30 +104,30 @@ class pagedTable
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function analizeSql ()
|
||||
public function analizeSql()
|
||||
{
|
||||
if (1 === preg_match( '/^\s*SELECT\s+(.+?)(?:\s+FROM\s+(.+?))(?:\s+WHERE\s+(.+?))?(?:\s+GROUP\s+BY\s+(.+?))?(?:\s+ORDER\s+BY\s+(.+?))?(?:\s+BETWEEN\s+(.+?)\s+AND\s+(.+?))?\s*$/im', $this->sqlSelect, $matches )) {
|
||||
if (1 === preg_match('/^\s*SELECT\s+(.+?)(?:\s+FROM\s+(.+?))(?:\s+WHERE\s+(.+?))?(?:\s+GROUP\s+BY\s+(.+?))?(?:\s+ORDER\s+BY\s+(.+?))?(?:\s+BETWEEN\s+(.+?)\s+AND\s+(.+?))?\s*$/im', $this->sqlSelect, $matches)) {
|
||||
$this->sqlSelect = 'SELECT ' . $matches[1] . (($matches[2] != '') ? ' FROM ' . $matches[2] : '');
|
||||
$this->sqlSelect = 'SELECT ' . $matches[1] . (($matches[2] != '') ? ' FROM ' . $matches[2] : '');
|
||||
} else {
|
||||
//echo('Warning: SQL Query is not well formed.');
|
||||
return;
|
||||
}
|
||||
$this->sqlFrom = isset( $matches[2] ) ? $matches[2] : '';
|
||||
$this->sqlWhere = isset( $matches[3] ) ? $matches[3] : '';
|
||||
$this->sqlGroupBy = isset( $matches[4] ) ? $matches[4] : '';
|
||||
$this->sqlOrderBy = isset( $matches[5] ) ? $matches[5] : '';
|
||||
$this->sqlFrom = isset($matches[2]) ? $matches[2] : '';
|
||||
$this->sqlWhere = isset($matches[3]) ? $matches[3] : '';
|
||||
$this->sqlGroupBy = isset($matches[4]) ? $matches[4] : '';
|
||||
$this->sqlOrderBy = isset($matches[5]) ? $matches[5] : '';
|
||||
$this->order = '';
|
||||
if ($this->sqlOrderBy != '') {
|
||||
if ($n = preg_match_all( '/\b([\w\.]+)\b(?:\s+(ASC|DESC))?,?/im', $this->sqlOrderBy, $matches, PREG_SET_ORDER )) {
|
||||
for ($r = 0; $r < $n; $r ++) {
|
||||
if (! isset( $matches[$r][2] )) {
|
||||
if ($n = preg_match_all('/\b([\w\.]+)\b(?:\s+(ASC|DESC))?,?/im', $this->sqlOrderBy, $matches, PREG_SET_ORDER)) {
|
||||
for ($r = 0; $r < $n; $r++) {
|
||||
if (!isset($matches[$r][2])) {
|
||||
$matches[$r][2] = '';
|
||||
}
|
||||
if ($matches[$r][2] == '') {
|
||||
$matches[$r][2] = 'ASC';
|
||||
}
|
||||
$ord = G::createUID( '', $matches[$r][1] ) . '=' . urlencode( $matches[$r][2] );
|
||||
$ord = G::createUID('', $matches[$r][1]) . '=' . urlencode($matches[$r][2]);
|
||||
if ($this->order == '') {
|
||||
$this->order = $ord;
|
||||
} else {
|
||||
@@ -137,7 +136,7 @@ class pagedTable
|
||||
}
|
||||
//Orden ascendente
|
||||
if ($n == 1) {
|
||||
$this->order = G::createUID( '', $matches[0][1] ) . '=' . $matches[0][2];
|
||||
$this->order = G::createUID('', $matches[0][1]) . '=' . $matches[0][2];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,7 +145,7 @@ class pagedTable
|
||||
$uniqueWhere = '';
|
||||
$this->fieldDataList = '';
|
||||
foreach ($this->fields as $r => $field) {
|
||||
if ((strpos( $this->notFields, ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||
if ((strpos($this->notFields, ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||
if ($uniqueWhere == '') {
|
||||
$uniqueWhere = (($this->sqlWhere != '') ? ('(' . $this->sqlWhere . ') AND (') : '(');
|
||||
} else {
|
||||
@@ -173,77 +172,78 @@ class pagedTable
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function prepareQuery ()
|
||||
public function prepareQuery()
|
||||
{
|
||||
//DBConnection
|
||||
if (! $this->sqlConnection) {
|
||||
if (!$this->sqlConnection) {
|
||||
$this->dbc = new DBConnection();
|
||||
} else {
|
||||
if (defined( 'DB_' . $this->sqlConnection . '_USER' )) {
|
||||
if (defined( 'DB_' . $this->sqlConnection . '_HOST' )) {
|
||||
eval( '$res[\'DBC_SERVER\'] = DB_' . $this->sqlConnection . '_HOST;' );
|
||||
if (defined('DB_' . $this->sqlConnection . '_USER')) {
|
||||
if (defined('DB_' . $this->sqlConnection . '_HOST')) {
|
||||
eval('$res[\'DBC_SERVER\'] = DB_' . $this->sqlConnection . '_HOST;');
|
||||
} else {
|
||||
$res['DBC_SERVER'] = DB_HOST;
|
||||
}
|
||||
if (defined( 'DB_' . $this->sqlConnection . '_USER' )) {
|
||||
eval( '$res[\'DBC_USERNAME\'] = DB_' . $this->sqlConnection . '_USER;' );
|
||||
if (defined('DB_' . $this->sqlConnection . '_USER')) {
|
||||
eval('$res[\'DBC_USERNAME\'] = DB_' . $this->sqlConnection . '_USER;');
|
||||
}
|
||||
if (defined( 'DB_' . $this->sqlConnection . '_PASS' )) {
|
||||
eval( '$res[\'DBC_PASSWORD\'] = DB_' . $this->sqlConnection . '_PASS;' );
|
||||
if (defined('DB_' . $this->sqlConnection . '_PASS')) {
|
||||
eval('$res[\'DBC_PASSWORD\'] = DB_' . $this->sqlConnection . '_PASS;');
|
||||
} else {
|
||||
$res['DBC_PASSWORD'] = DB_PASS;
|
||||
}
|
||||
if (defined( 'DB_' . $this->sqlConnection . '_NAME' )) {
|
||||
eval( '$res[\'DBC_DATABASE\'] = DB_' . $this->sqlConnection . '_NAME;' );
|
||||
if (defined('DB_' . $this->sqlConnection . '_NAME')) {
|
||||
eval('$res[\'DBC_DATABASE\'] = DB_' . $this->sqlConnection . '_NAME;');
|
||||
} else {
|
||||
$res['DBC_DATABASE'] = DB_NAME;
|
||||
}
|
||||
if (defined( 'DB_' . $this->sqlConnection . '_TYPE' )) {
|
||||
eval( '$res[\'DBC_TYPE\'] = DB_' . $this->sqlConnection . '_TYPE;' );
|
||||
if (defined('DB_' . $this->sqlConnection . '_TYPE')) {
|
||||
eval('$res[\'DBC_TYPE\'] = DB_' . $this->sqlConnection . '_TYPE;');
|
||||
} else {
|
||||
$res['DBC_TYPE'] = defined( 'DB_TYPE' ) ? DB_TYPE : 'mysql';
|
||||
$res['DBC_TYPE'] = defined('DB_TYPE') ? DB_TYPE : 'mysql';
|
||||
}
|
||||
$this->dbc = new DBConnection( $res['DBC_SERVER'], $res['DBC_USERNAME'], $res['DBC_PASSWORD'], $res['DBC_DATABASE'], $res['DBC_TYPE'] );
|
||||
$this->dbc = new DBConnection($res['DBC_SERVER'], $res['DBC_USERNAME'], $res['DBC_PASSWORD'], $res['DBC_DATABASE'], $res['DBC_TYPE']);
|
||||
} else {
|
||||
$dbc = new DBConnection();
|
||||
$dbs = new DBSession( $dbc );
|
||||
$res = $dbs->execute( "select * from DB_CONNECTION WHERE DBC_UID=" . $this->sqlConnection );
|
||||
$dbs = new DBSession($dbc);
|
||||
$res = $dbs->execute("select * from DB_CONNECTION WHERE DBC_UID=" . $this->sqlConnection);
|
||||
$res = $res->read();
|
||||
$this->dbc = new DBConnection( $res['DBC_SERVER'], $res['DBC_USERNAME'], $res['DBC_PASSWORD'], $res['DBC_DATABASE'] );
|
||||
$this->dbc = new DBConnection($res['DBC_SERVER'], $res['DBC_USERNAME'], $res['DBC_PASSWORD'], $res['DBC_DATABASE']);
|
||||
}
|
||||
}
|
||||
$this->ses = new DBSession( $this->dbc );
|
||||
$this->ses = new DBSession($this->dbc);
|
||||
//Query
|
||||
//Filter
|
||||
if (is_array( $this->filter )) {
|
||||
if (is_array($this->filter)) {
|
||||
$filterFields = $this->filter;
|
||||
} else {
|
||||
parse_str( $this->filter, $filterFields );
|
||||
parse_str($this->filter, $filterFields);
|
||||
}
|
||||
$this->aFilter = $filterFields;
|
||||
$filter = '';
|
||||
foreach ($filterFields as $field => $like) {
|
||||
if ($like != '') {
|
||||
if ($like !== '') {
|
||||
if ($filter !== '') {
|
||||
$filter .= ' AND ';
|
||||
}
|
||||
if (isset( $this->filterType[$field] )) {
|
||||
$like = mysqli_real_escape_string($this->dbc, $like);
|
||||
if (isset($this->filterType[$field])) {
|
||||
switch ($this->filterType[$field]) {
|
||||
case '=':
|
||||
$filter .= $field . ' = "' . mysql_real_escape_string( $like ) . '"';
|
||||
$filter .= $field . ' = "' . $like . '"';
|
||||
break;
|
||||
case '<>':
|
||||
$filter .= $field . ' <> "' . mysql_real_escape_string( $like ) . '"';
|
||||
$filter .= $field . ' <> "' . $like . '"';
|
||||
break;
|
||||
case 'contains':
|
||||
$filter .= $field . ' LIKE "%' . mysql_real_escape_string( $like ) . '%"';
|
||||
$filter .= $field . ' LIKE "%' . $like . '%"';
|
||||
break;
|
||||
case 'like':
|
||||
$filter .= $field . ' LIKE "' . mysql_real_escape_string( $like ) . '"';
|
||||
$filter .= $field . ' LIKE "' . $like . '"';
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$filter .= $field . ' = "' . mysql_real_escape_string( $like ) . '"';
|
||||
$filter .= $field . ' = "' . $like . '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,11 +251,11 @@ class pagedTable
|
||||
* QuickSearch
|
||||
*/
|
||||
if ($this->searchBy !== '') {
|
||||
$aSB = explode( '|', $this->searchBy );
|
||||
$aSB = explode('|', $this->searchBy);
|
||||
$subFilter = '';
|
||||
foreach ($aSB as $sBy) {
|
||||
$subFilter .= ($subFilter !== '') ? ' OR ' : '';
|
||||
$subFilter .= $sBy . ' LIKE "%' . G::sqlEscape( $this->fastSearch, $this->dbc->type ) . '%"';
|
||||
$subFilter .= $sBy . ' LIKE "%' . G::sqlEscape($this->fastSearch, $this->dbc->type) . '%"';
|
||||
}
|
||||
if ($subFilter !== '') {
|
||||
$filter .= ($filter !== '') ? ' AND ' : '';
|
||||
@@ -263,18 +263,18 @@ class pagedTable
|
||||
}
|
||||
}
|
||||
//Merge sort array defined by USER with the array defined by SQL
|
||||
parse_str( $this->order, $orderFields );
|
||||
parse_str( $this->orderBy, $orderFields2 );
|
||||
parse_str($this->order, $orderFields);
|
||||
parse_str($this->orderBy, $orderFields2);
|
||||
//User sort is more important (first in merge).
|
||||
$orderFields3 = array_merge( $orderFields2, $orderFields );
|
||||
$orderFields3 = array_merge($orderFields2, $orderFields);
|
||||
//User sort is overwrites XMLs definition.
|
||||
$orderFields = array_merge( $orderFields3, $orderFields2 );
|
||||
$orderFields = array_merge($orderFields3, $orderFields2);
|
||||
//Order (BY SQL DEFINITION AND USER'S DEFINITION)
|
||||
$this->aOrder = array ();
|
||||
$this->aOrder = array();
|
||||
$order = '';
|
||||
foreach ($orderFields as $field => $fieldOrder) {
|
||||
$field = G::getUIDName( $field, '' );
|
||||
$fieldOrder = strtoupper( $fieldOrder );
|
||||
$field = G::getUIDName($field, '');
|
||||
$fieldOrder = strtoupper($fieldOrder);
|
||||
if ($fieldOrder === 'A') {
|
||||
$fieldOrder = 'ASC';
|
||||
}
|
||||
@@ -305,57 +305,57 @@ class pagedTable
|
||||
* @param string xmlForm
|
||||
* @return string
|
||||
*/
|
||||
public function setupFromXmlform ($xmlForm)
|
||||
public function setupFromXmlform($xmlForm)
|
||||
{
|
||||
$this->xmlForm = $xmlForm;
|
||||
//Config
|
||||
$this->name = $xmlForm->name;
|
||||
$this->id = $xmlForm->id;
|
||||
$this->sqlConnection = ((isset( $this->xmlForm->sqlConnection )) ? $this->xmlForm->sqlConnection : '');
|
||||
if (isset( $_GET['page'] )) {
|
||||
$this->sqlConnection = ((isset($this->xmlForm->sqlConnection)) ? $this->xmlForm->sqlConnection : '');
|
||||
if (isset($_GET['page'])) {
|
||||
$this->currentPage = $_GET['page'];
|
||||
} else {
|
||||
$this->currentPage = 1;
|
||||
}
|
||||
if (isset( $_GET['order'] )) {
|
||||
$this->orderBy = urldecode( $_GET['order'] );
|
||||
if (isset($_GET['order'])) {
|
||||
$this->orderBy = urldecode($_GET['order']);
|
||||
} else {
|
||||
$this->orderBy = "";
|
||||
}
|
||||
if (isset( $_GET['filter'] )) {
|
||||
$this->filter = urldecode( $_GET['filter'] );
|
||||
if (isset($_GET['filter'])) {
|
||||
$this->filter = urldecode($_GET['filter']);
|
||||
} else {
|
||||
$this->filter = "";
|
||||
}
|
||||
$this->ajaxServer = G::encryptLink( '../gulliver/pagedTableAjax' );
|
||||
$this->ownerPage = G::encryptLink( SYS_CURRENT_URI );
|
||||
$this->ajaxServer = G::encryptLink('../gulliver/pagedTableAjax');
|
||||
$this->ownerPage = G::encryptLink(SYS_CURRENT_URI);
|
||||
//Needed for $mysql_real_escape_string
|
||||
$auxDbc = new DBConnection();
|
||||
if (isset( $this->xmlForm->sql )) {
|
||||
$this->sqlSelect = G::replaceDataField( $this->xmlForm->sql, $this->xmlForm->values );
|
||||
if (isset($this->xmlForm->sql)) {
|
||||
$this->sqlSelect = G::replaceDataField($this->xmlForm->sql, $this->xmlForm->values);
|
||||
} else {
|
||||
trigger_Error( 'Warning: sql query is empty', E_USER_WARNING );
|
||||
trigger_Error('Warning: sql query is empty', E_USER_WARNING);
|
||||
}
|
||||
// Config attributes from XMLFORM file
|
||||
$myAttributes = get_class_vars( get_class( $this ) );
|
||||
$myAttributes = get_class_vars(get_class($this));
|
||||
foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value) {
|
||||
if (array_key_exists( $atrib, $myAttributes )) {
|
||||
eval( 'settype($value,gettype($this->' . $atrib . '));' );
|
||||
if (array_key_exists($atrib, $myAttributes)) {
|
||||
eval('settype($value,gettype($this->' . $atrib . '));');
|
||||
if ($value !== '') {
|
||||
eval( '$this->' . $atrib . '=$value;' );
|
||||
eval('$this->' . $atrib . '=$value;');
|
||||
}
|
||||
}
|
||||
}
|
||||
//Prepare the fields
|
||||
$this->style = array ();
|
||||
$this->style = array();
|
||||
$this->gridWidth = "";
|
||||
$this->gridFields = "";
|
||||
$this->fieldsType = array ();
|
||||
$this->fieldsType = array();
|
||||
foreach ($this->xmlForm->fields as $f => $v) {
|
||||
$r = $f;
|
||||
$this->fields[$r]['Name'] = $this->xmlForm->fields[$f]->name;
|
||||
$this->fields[$r]['Type'] = $this->xmlForm->fields[$f]->type;
|
||||
if (isset( $this->xmlForm->fields[$f]->size )) {
|
||||
if (isset($this->xmlForm->fields[$f]->size)) {
|
||||
$this->fields[$r]['Size'] = $this->xmlForm->fields[$f]->size;
|
||||
}
|
||||
$this->fields[$r]['Label'] = $this->xmlForm->fields[$f]->label;
|
||||
@@ -372,7 +372,7 @@ class pagedTable
|
||||
$r = $f;
|
||||
//Parse the column properties
|
||||
foreach ($this->xmlForm->fields[$f] as $attribute => $value) {
|
||||
if (! is_object( $value )) {
|
||||
if (!is_object($value)) {
|
||||
$this->style[$r][$attribute] = $value;
|
||||
}
|
||||
}
|
||||
@@ -533,7 +533,7 @@ class pagedTable
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function count ()
|
||||
public function count()
|
||||
{
|
||||
$this->prepareQuery();
|
||||
return $this->query->count();
|
||||
@@ -546,51 +546,51 @@ class pagedTable
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function renderTitle ()
|
||||
public function renderTitle()
|
||||
{
|
||||
//Render Title
|
||||
$thereisnotitle = true;
|
||||
foreach ($this->fields as $r => $rval) {
|
||||
if ($this->fields[$r]['Type'] === 'title') {
|
||||
$this->tpl->assign( "title", $this->fields[$r]['Label'] );
|
||||
$this->tpl->assign("title", $this->fields[$r]['Label']);
|
||||
$thereisnotitle = false;
|
||||
}
|
||||
}
|
||||
if ($thereisnotitle) {
|
||||
$this->tpl->assign( "title", ' ' );
|
||||
$this->tpl->assign("title", ' ');
|
||||
}
|
||||
//Render headers
|
||||
$this->colCount = 0;
|
||||
$this->shownFields = '[';
|
||||
foreach ($this->fields as $r => $rval) {
|
||||
if ($this->style[$r]['showInTable'] != '0') {
|
||||
$this->tpl->newBlock( "headers" );
|
||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? 'DESC' : 'ASC');
|
||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '' : $sortOrder);
|
||||
$this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? urlencode( G::createUID( '', $this->fields[$r]['Name'] ) . '=' . $sortOrder ) : '') . '&page=' . $this->currentPage;
|
||||
$this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID( '', $this->fields[$r]['Name'] ) . '" , "' . $sortOrder . '");return false;';
|
||||
if (isset( $this->style[$r]['href'] )) {
|
||||
$this->tpl->assign( "href", $this->style[$r]['href'] );
|
||||
$this->tpl->newBlock("headers");
|
||||
$sortOrder = (((isset($this->aOrder[$this->fields[$r]['Name']])) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? 'DESC' : 'ASC');
|
||||
$sortOrder = (((isset($this->aOrder[$this->fields[$r]['Name']])) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '' : $sortOrder);
|
||||
$this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? urlencode(G::createUID('', $this->fields[$r]['Name']) . '=' . $sortOrder) : '') . '&page=' . $this->currentPage;
|
||||
$this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID('', $this->fields[$r]['Name']) . '" , "' . $sortOrder . '");return false;';
|
||||
if (isset($this->style[$r]['href'])) {
|
||||
$this->tpl->assign("href", $this->style[$r]['href']);
|
||||
}
|
||||
if (isset( $this->style[$r]['onsort'] )) {
|
||||
$this->tpl->assign( "onclick", htmlentities( $this->style[$r]['onsort'], ENT_QUOTES, 'UTF-8' ) );
|
||||
if (isset($this->style[$r]['onsort'])) {
|
||||
$this->tpl->assign("onclick", htmlentities($this->style[$r]['onsort'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
if (isset( $this->style[$r]['colWidth'] )) {
|
||||
$this->tpl->assign( "width", $this->style[$r]['colWidth'] );
|
||||
if (isset($this->style[$r]['colWidth'])) {
|
||||
$this->tpl->assign("width", $this->style[$r]['colWidth']);
|
||||
}
|
||||
if (isset( $this->style[$r]['colWidth'] )) {
|
||||
$this->tpl->assign( "widthPercent", ($this->style[$r]['colWidth'] * 100 / $this->totalWidth) . "%" );
|
||||
if (isset($this->style[$r]['colWidth'])) {
|
||||
$this->tpl->assign("widthPercent", ($this->style[$r]['colWidth'] * 100 / $this->totalWidth) . "%");
|
||||
}
|
||||
if (isset( $this->style[$r]['titleAlign'] )) {
|
||||
$this->tpl->assign( "align", 'text-align:' . $this->style[$r]['titleAlign'] . ';' );
|
||||
if (isset($this->style[$r]['titleAlign'])) {
|
||||
$this->tpl->assign("align", 'text-align:' . $this->style[$r]['titleAlign'] . ';');
|
||||
}
|
||||
if ($this->style[$r]['titleVisibility'] != '0') {
|
||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? 'b2' : '');
|
||||
$sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? 'b<' : $sortOrder);
|
||||
$this->tpl->assign( "header", $this->fields[$r]['Label'] . $sortOrder );
|
||||
$this->tpl->assign( 'displaySeparator', (($this->colCount == 0) || (! isset( $this->fields[$r]['Label'] )) || ($this->fields[$r]['Label'] === '')) ? 'display:none;' : '' );
|
||||
$sortOrder = (((isset($this->aOrder[$this->fields[$r]['Name']])) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? 'b2' : '');
|
||||
$sortOrder = (((isset($this->aOrder[$this->fields[$r]['Name']])) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? 'b<' : $sortOrder);
|
||||
$this->tpl->assign("header", $this->fields[$r]['Label'] . $sortOrder);
|
||||
$this->tpl->assign('displaySeparator', (($this->colCount == 0) || (!isset($this->fields[$r]['Label'])) || ($this->fields[$r]['Label'] === '')) ? 'display:none;' : '');
|
||||
} else {
|
||||
$this->tpl->assign( 'displaySeparator', 'display:none;' );
|
||||
$this->tpl->assign('displaySeparator', 'display:none;');
|
||||
}
|
||||
$this->colCount += 2;
|
||||
$this->shownFields .= ($this->shownFields !== '[') ? ',' : '';
|
||||
@@ -610,7 +610,7 @@ class pagedTable
|
||||
* @param eter string result
|
||||
* @return string
|
||||
*/
|
||||
public function renderField ($row, $r, $result)
|
||||
public function renderField($row, $r, $result)
|
||||
{
|
||||
global $G_DATE_FORMAT;
|
||||
//BEGIN: Special content: __sqlEdit__,__sqlDelete__
|
||||
@@ -620,10 +620,10 @@ class pagedTable
|
||||
$result['row__'] = $row;
|
||||
//END: Special content.
|
||||
//Merge $result with $xmlForm values (for default valuesSettings)
|
||||
$result = array_merge( $this->xmlForm->values, $result );
|
||||
$result = array_merge($this->xmlForm->values, $result);
|
||||
switch (true) {
|
||||
case ($this->style[$r]['data'] != ''):
|
||||
$value = ((isset( $result[$this->style[$r]['data']] )) ? $result[$this->style[$r]['data']] : '');
|
||||
$value = ((isset($result[$this->style[$r]['data']])) ? $result[$this->style[$r]['data']] : '');
|
||||
break;
|
||||
default:
|
||||
$value = $this->fields[$r]['Label'];
|
||||
@@ -631,37 +631,37 @@ class pagedTable
|
||||
switch ($this->fields[$r]['Type']) {
|
||||
case 'date':
|
||||
/*Accept dates like 20070515 without - or / to separate its parts*/
|
||||
if (strlen( $value ) <= 10 && strlen( $value ) > 4) {
|
||||
$value = str_replace( '/', '-', $value );
|
||||
if (strpos( $value, '-' ) === false) {
|
||||
$value = substr( $value, 0, 4 ) . '-' . substr( $value, 4, 2 ) . '-' . substr( $value, 6, 2 );
|
||||
if (strlen($value) <= 10 && strlen($value) > 4) {
|
||||
$value = str_replace('/', '-', $value);
|
||||
if (strpos($value, '-') === false) {
|
||||
$value = substr($value, 0, 4) . '-' . substr($value, 4, 2) . '-' . substr($value, 6, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->tpl->newBlock( "field" );
|
||||
$this->tpl->assign( 'width', $this->style[$r]['colWidth'] );
|
||||
$this->tpl->assign( 'widthPercent', ($this->style[$r]['colWidth'] * 100 / $this->totalWidth) . '%' );
|
||||
$this->tpl->assign( 'className', (isset( $this->style[$r]['colClassName'] ) && ($this->style[$r]['colClassName'])) ? $this->style[$r]['colClassName'] : $this->tdClass );
|
||||
$this->tpl->assign( 'style', $this->tdStyle );
|
||||
if (isset( $this->style[$r]['align'] )) {
|
||||
$this->tpl->assign( "align", $this->style[$r]['align'] );
|
||||
$this->tpl->newBlock("field");
|
||||
$this->tpl->assign('width', $this->style[$r]['colWidth']);
|
||||
$this->tpl->assign('widthPercent', ($this->style[$r]['colWidth'] * 100 / $this->totalWidth) . '%');
|
||||
$this->tpl->assign('className', (isset($this->style[$r]['colClassName']) && ($this->style[$r]['colClassName'])) ? $this->style[$r]['colClassName'] : $this->tdClass);
|
||||
$this->tpl->assign('style', $this->tdStyle);
|
||||
if (isset($this->style[$r]['align'])) {
|
||||
$this->tpl->assign("align", $this->style[$r]['align']);
|
||||
}
|
||||
if (isset( $this->style[$r]['colAlign'] )) {
|
||||
$this->tpl->assign( "align", $this->style[$r]['colAlign'] );
|
||||
if (isset($this->style[$r]['colAlign'])) {
|
||||
$this->tpl->assign("align", $this->style[$r]['colAlign']);
|
||||
}
|
||||
/**
|
||||
* BEGIN : Reeplace of @@, @%,...
|
||||
* in field's attributes like onclick, link,
|
||||
* ...
|
||||
*/
|
||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->onclick )) {
|
||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->onclick = G::replaceDataField( $this->style[$r]['onclick'], $result );
|
||||
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->onclick)) {
|
||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->onclick = G::replaceDataField($this->style[$r]['onclick'], $result);
|
||||
}
|
||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->link )) {
|
||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->link = G::replaceDataField( $this->style[$r]['link'], $result );
|
||||
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->link)) {
|
||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->link = G::replaceDataField($this->style[$r]['link'], $result);
|
||||
}
|
||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->value )) {
|
||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->value = G::replaceDataField( $this->style[$r]['value'], $result );
|
||||
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->value)) {
|
||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->value = G::replaceDataField($this->style[$r]['value'], $result);
|
||||
}
|
||||
/**
|
||||
* BREAK : Reeplace of @@, @%,...
|
||||
@@ -670,24 +670,24 @@ class pagedTable
|
||||
* Rendering of the field
|
||||
*/
|
||||
$this->xmlForm->setDefaultValues();
|
||||
$this->xmlForm->setValues( $result );
|
||||
$this->xmlForm->setValues($result);
|
||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->mode = 'view';
|
||||
if ((array_search( 'rendergrid', get_class_methods( get_class( $this->xmlForm->fields[$this->fields[$r]['Name']] ) ) ) !== false) || (array_search( 'renderGrid', get_class_methods( get_class( $this->xmlForm->fields[$this->fields[$r]['Name']] ) ) ) !== false)) {
|
||||
$htmlField = $this->xmlForm->fields[$this->fields[$r]['Name']]->renderGrid( array ($value
|
||||
), $this->xmlForm );
|
||||
$this->tpl->assign( "value", $htmlField[0] );
|
||||
if ((array_search('rendergrid', get_class_methods(get_class($this->xmlForm->fields[$this->fields[$r]['Name']]))) !== false) || (array_search('renderGrid', get_class_methods(get_class($this->xmlForm->fields[$this->fields[$r]['Name']]))) !== false)) {
|
||||
$htmlField = $this->xmlForm->fields[$this->fields[$r]['Name']]->renderGrid(array($value
|
||||
), $this->xmlForm);
|
||||
$this->tpl->assign("value", $htmlField[0]);
|
||||
} else {
|
||||
}
|
||||
/**
|
||||
* CONTINUE : Reeplace of @@, @%,...
|
||||
*/
|
||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->onclick )) {
|
||||
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->onclick)) {
|
||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->onclick = $this->style[$r]['onclick'];
|
||||
}
|
||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->link )) {
|
||||
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->link)) {
|
||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->link = $this->style[$r]['link'];
|
||||
}
|
||||
if (isset( $this->xmlForm->fields[$this->fields[$r]['Name']]->value )) {
|
||||
if (isset($this->xmlForm->fields[$this->fields[$r]['Name']]->value)) {
|
||||
$this->xmlForm->fields[$this->fields[$r]['Name']]->value = $this->style[$r]['value'];
|
||||
}
|
||||
/**
|
||||
@@ -703,43 +703,43 @@ class pagedTable
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function defaultStyle ()
|
||||
public function defaultStyle()
|
||||
{
|
||||
// for($r=1;$r<=sizeof($this->fields);$r++)
|
||||
foreach ($this->fields as $r => $rval) {
|
||||
$this->style[$r] = array ('showInTable' => '1','titleVisibility' => '1','colWidth' => '150','onclick' => '','event' => ''
|
||||
$this->style[$r] = array('showInTable' => '1', 'titleVisibility' => '1', 'colWidth' => '150', 'onclick' => '', 'event' => ''
|
||||
);
|
||||
//Some widths
|
||||
if (! (strpos( ' date linknew ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||
if (!(strpos(' date linknew ', ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||
$this->style[$r]['colWidth'] = '70';
|
||||
//Data source:
|
||||
}
|
||||
if (! (strpos( ' title button linknew image-text jslink ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||
if (!(strpos(' title button linknew image-text jslink ', ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||
$this->style[$r]['data'] = ''; //If the control is a link it shows the label
|
||||
} else {
|
||||
$this->style[$r]['data'] = $this->fields[$r]['Name']; //ELSE: The data value for that field
|
||||
}
|
||||
//Hidden fields
|
||||
if (! isset( $this->style[$r]['showInTable'] )) {
|
||||
if (! (strpos( ' title button endgrid2 submit password ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||
//Hidden fields
|
||||
if (!isset($this->style[$r]['showInTable'])) {
|
||||
if (!(strpos(' title button endgrid2 submit password ', ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||
$this->style[$r]['showInTable'] = '0';
|
||||
} else {
|
||||
$this->style[$r]['showInTable'] = '1';
|
||||
}
|
||||
}
|
||||
//Hidden titles
|
||||
if (! (strpos( ' linknew button endgrid2 ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||
if (!(strpos(' linknew button endgrid2 ', ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||
$this->style[$r]['titleVisibility'] = '0';
|
||||
}
|
||||
//Align titles
|
||||
$this->style[$r]['titleAlign'] = 'center';
|
||||
//Align fields
|
||||
if (isset( $_SESSION['SET_DIRECTION'] ) && (strcasecmp( $_SESSION['SET_DIRECTION'], 'rtl' ) === 0)) {
|
||||
if (isset($_SESSION['SET_DIRECTION']) && (strcasecmp($_SESSION['SET_DIRECTION'], 'rtl') === 0)) {
|
||||
$this->style[$r]['align'] = 'right';
|
||||
} else {
|
||||
$this->style[$r]['align'] = 'left';
|
||||
}
|
||||
if (! (strpos( ' linknew date ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) {
|
||||
if (!(strpos(' linknew date ', ' ' . $this->fields[$r]['Type'] . ' ') === false)) {
|
||||
$this->style[$r]['align'] = 'center';
|
||||
}
|
||||
}
|
||||
@@ -774,77 +774,76 @@ class pagedTable
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function renderTable ($block = '')
|
||||
public function renderTable($block = '')
|
||||
{
|
||||
|
||||
$filter = new InputFilter();
|
||||
$this->orderBy = $filter->xssFilterHard($this->orderBy);
|
||||
$this->currentPage = $filter->xssFilterHard($this->currentPage);
|
||||
$this->id = $filter->xssFilterHard($this->id);
|
||||
$this->name = $filter->xssFilterHard($this->name);
|
||||
$this->ownerPage = $filter->xssFilterHard($this->ownerPage);
|
||||
$this->orderBy = $filter->xssFilterHard($this->orderBy);
|
||||
$this->currentPage = $filter->xssFilterHard($this->currentPage);
|
||||
$this->id = $filter->xssFilterHard($this->id);
|
||||
$this->name = $filter->xssFilterHard($this->name);
|
||||
$this->ownerPage = $filter->xssFilterHard($this->ownerPage);
|
||||
// DBConnection
|
||||
$this->prepareQuery();
|
||||
//Query for get the number of rows
|
||||
$this->query = $this->ses->execute( $this->sql );
|
||||
$this->query = $this->ses->execute($this->sql);
|
||||
$this->totRows = $this->query->count();
|
||||
$this->totpages = ceil( $this->query->count() / $this->rowsPerPage );
|
||||
$this->totpages = ceil($this->query->count() / $this->rowsPerPage);
|
||||
//Query for obtain the records
|
||||
$this->query = $this->ses->execute( $this->sql . ' LIMIT ' . (($this->currentPage - 1) * $this->rowsPerPage) . ', ' . $this->rowsPerPage );
|
||||
$this->query = $this->ses->execute($this->sql . ' LIMIT ' . (($this->currentPage - 1) * $this->rowsPerPage) . ', ' . $this->rowsPerPage);
|
||||
// Prepare the template
|
||||
$this->tpl = new TemplatePower( PATH_CORE . $this->template );
|
||||
$this->tpl = new TemplatePower(PATH_CORE . $this->template);
|
||||
$this->tpl->prepare();
|
||||
/**
|
||||
* ******** HEAD BLOCK **************
|
||||
*/
|
||||
if (($block === '') || ($block === 'head')) {
|
||||
$this->tpl->newBlock( 'headBlock' );
|
||||
$this->tpl->assign( 'pagedTable_Id', $this->id );
|
||||
$this->tpl->assign( 'pagedTable_Name', $this->name );
|
||||
$this->tpl->assign( 'pagedTable_Height', $this->xmlForm->height );
|
||||
$this->xmlForm->home = $filter->xssFilterHard($this->xmlForm->home);
|
||||
$this->filterForm = $filter->xssFilterHard($this->filterForm);
|
||||
$this->menu = $filter->xssFilterHard($this->menu);
|
||||
if (file_exists( $this->xmlForm->home . $this->filterForm . '.xml' )) {
|
||||
$filterForm = new filterForm( $this->filterForm, $this->xmlForm->home );
|
||||
$this->tpl->newBlock('headBlock');
|
||||
$this->tpl->assign('pagedTable_Id', $this->id);
|
||||
$this->tpl->assign('pagedTable_Name', $this->name);
|
||||
$this->tpl->assign('pagedTable_Height', $this->xmlForm->height);
|
||||
$this->xmlForm->home = $filter->xssFilterHard($this->xmlForm->home);
|
||||
$this->filterForm = $filter->xssFilterHard($this->filterForm);
|
||||
$this->menu = $filter->xssFilterHard($this->menu);
|
||||
if (file_exists($this->xmlForm->home . $this->filterForm . '.xml')) {
|
||||
$filterForm = new filterForm($this->filterForm, $this->xmlForm->home);
|
||||
if ($this->menu === '') {
|
||||
$this->menu = 'gulliver/pagedTable_Options';
|
||||
}
|
||||
}
|
||||
if (file_exists( $this->xmlForm->home . $this->menu . '.xml' )) {
|
||||
$menu = new xmlMenu( $this->menu, $this->xmlForm->home );
|
||||
$this->tpl->newBlock( 'headerBlock' );
|
||||
if (file_exists($this->xmlForm->home . $this->menu . '.xml')) {
|
||||
$menu = new xmlMenu($this->menu, $this->xmlForm->home);
|
||||
$this->tpl->newBlock('headerBlock');
|
||||
$template = PATH_CORE . 'templates' . PATH_SEP . $menu->type . '.html';
|
||||
$menu->setValues( $this->xmlForm->values );
|
||||
$menu->setValues( array ('PAGED_TABLE_ID' => $this->id
|
||||
) );
|
||||
$menu->setValues( array ('PAGED_TABLE_FAST_SEARCH' => $this->fastSearch
|
||||
) );
|
||||
if (isset( $filterForm->name )) {
|
||||
$menu->setValues( array ('SEARCH_FILTER_FORM' => $filterForm->name
|
||||
) );
|
||||
$menu->setValues($this->xmlForm->values);
|
||||
$menu->setValues(array('PAGED_TABLE_ID' => $this->id
|
||||
));
|
||||
$menu->setValues(array('PAGED_TABLE_FAST_SEARCH' => $this->fastSearch
|
||||
));
|
||||
if (isset($filterForm->name)) {
|
||||
$menu->setValues(array('SEARCH_FILTER_FORM' => $filterForm->name
|
||||
));
|
||||
}
|
||||
$this->tpl->assign( 'content', $menu->render( $template, $scriptCode ) );
|
||||
$oHeadPublisher = & headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptFile( $menu->scriptURL );
|
||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
||||
$this->tpl->assign('content', $menu->render($template, $scriptCode));
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptFile($menu->scriptURL);
|
||||
$oHeadPublisher->addScriptCode($scriptCode);
|
||||
}
|
||||
if (file_exists( $this->xmlForm->home . $this->filterForm . '.xml' )) {
|
||||
$this->tpl->newBlock( 'headerBlock' );
|
||||
if (file_exists($this->xmlForm->home . $this->filterForm . '.xml')) {
|
||||
$this->tpl->newBlock('headerBlock');
|
||||
$this->filterForm_Id = $filterForm->id;
|
||||
$filterForm->type = 'filterform';
|
||||
$filterForm->ajaxServer = '../gulliver/defaultAjax';
|
||||
$template = PATH_CORE . 'templates/' . $filterForm->type . '.html';
|
||||
$filterForm->setValues( $this->xmlForm->values );
|
||||
$filterForm->setValues( array ('PAGED_TABLE_ID' => $this->id
|
||||
) );
|
||||
$filterForm->setValues( array ('PAGED_TABLE_FAST_SEARCH' => $this->fastSearch
|
||||
) );
|
||||
$this->tpl->assign( 'content', $filterForm->render( $template, $scriptCode ) );
|
||||
$oHeadPublisher = & headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptFile( $filterForm->scriptURL );
|
||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
||||
if (isset( $_SESSION )) {
|
||||
$filterForm->setValues($this->xmlForm->values);
|
||||
$filterForm->setValues(array('PAGED_TABLE_ID' => $this->id
|
||||
));
|
||||
$filterForm->setValues(array('PAGED_TABLE_FAST_SEARCH' => $this->fastSearch
|
||||
));
|
||||
$this->tpl->assign('content', $filterForm->render($template, $scriptCode));
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptFile($filterForm->scriptURL);
|
||||
$oHeadPublisher->addScriptCode($scriptCode);
|
||||
if (isset($_SESSION)) {
|
||||
$_SESSION[$filterForm->id] = $filterForm->values;
|
||||
}
|
||||
}
|
||||
@@ -853,169 +852,170 @@ class pagedTable
|
||||
* ******** CONTENT BLOCK **************
|
||||
*/
|
||||
if (($block === '') || ($block === 'content')) {
|
||||
$this->tpl->newBlock( 'contentBlock' );
|
||||
$this->tpl->assign( 'gridWidth', '=[' . substr( $this->gridWidth, 1 ) . ']' );
|
||||
$this->tpl->assign( 'fieldNames', '=[' . substr( $this->gridFields, 1 ) . ']' );
|
||||
$this->tpl->assign( 'ajaxUri', '="' . addslashes( $this->ajaxServer ) . '"' );
|
||||
$this->tpl->assign( 'currentUri', '="' . addslashes( $this->ownerPage ) . '"' );
|
||||
$this->tpl->assign( 'currentOrder', '="' . addslashes( $this->orderBy ) . '"' );
|
||||
$this->tpl->assign( 'currentPage', '=' . $this->currentPage );
|
||||
$this->tpl->assign( 'currentFilter', '="' . '"' );
|
||||
$this->tpl->assign( 'totalRows', '=' . $this->query->count() );
|
||||
$this->tpl->assign( 'rowsPerPage', '=' . $this->rowsPerPage );
|
||||
$this->tpl->assign( 'popupPage', '="' . addslashes( $this->popupPage ) . '"' );
|
||||
$this->tpl->assign( 'popupWidth', '=' . $this->popupWidth );
|
||||
$this->tpl->assign( 'popupHeight', '=' . $this->popupHeight );
|
||||
$this->tpl->assign( 'pagedTable_Id', $this->id );
|
||||
$this->tpl->assign( 'pagedTable_Name', $this->name );
|
||||
$this->tpl->assign( "pagedTable_JS", "{$this->id}.element=document.getElementById('pagedtable[{$this->id}]');" );
|
||||
$this->tpl->newBlock('contentBlock');
|
||||
$this->tpl->assign('gridWidth', '=[' . substr($this->gridWidth, 1) . ']');
|
||||
$this->tpl->assign('fieldNames', '=[' . substr($this->gridFields, 1) . ']');
|
||||
$this->tpl->assign('ajaxUri', '="' . addslashes($this->ajaxServer) . '"');
|
||||
$this->tpl->assign('currentUri', '="' . addslashes($this->ownerPage) . '"');
|
||||
$this->tpl->assign('currentOrder', '="' . addslashes($this->orderBy) . '"');
|
||||
$this->tpl->assign('currentPage', '=' . $this->currentPage);
|
||||
$this->tpl->assign('currentFilter', '="' . '"');
|
||||
$this->tpl->assign('totalRows', '=' . $this->query->count());
|
||||
$this->tpl->assign('rowsPerPage', '=' . $this->rowsPerPage);
|
||||
$this->tpl->assign('popupPage', '="' . addslashes($this->popupPage) . '"');
|
||||
$this->tpl->assign('popupWidth', '=' . $this->popupWidth);
|
||||
$this->tpl->assign('popupHeight', '=' . $this->popupHeight);
|
||||
$this->tpl->assign('pagedTable_Id', $this->id);
|
||||
$this->tpl->assign('pagedTable_Name', $this->name);
|
||||
$this->tpl->assign("pagedTable_JS", "{$this->id}.element=document.getElementById('pagedtable[{$this->id}]');");
|
||||
$this->renderTitle();
|
||||
//Render rows
|
||||
$gridRows = 0;
|
||||
for ($j = 0; $j < $this->query->count(); $j ++) {
|
||||
for ($j = 0; $j < $this->query->count(); $j++) {
|
||||
$result = $this->query->read();
|
||||
//if (($j>=(($this->currentPage-1)*$this->rowsPerPage))&&($j<(($this->currentPage)*$this->rowsPerPage)))
|
||||
//{
|
||||
$gridRows ++;
|
||||
$this->tpl->newBlock( "row" );
|
||||
$this->tpl->assign( "class", "Row" . (($j % 2) + 1) );
|
||||
$gridRows++;
|
||||
$this->tpl->newBlock("row");
|
||||
$this->tpl->assign("class", "Row" . (($j % 2) + 1));
|
||||
$this->tdStyle = '';
|
||||
$this->tdClass = '';
|
||||
foreach ($this->fields as $r => $rval) {
|
||||
if (strcasecmp( $this->fields[$r]['Type'], 'cellMark' ) == 0) {
|
||||
if (strcasecmp($this->fields[$r]['Type'], 'cellMark') == 0) {
|
||||
$result1 = $result;
|
||||
$result1['row__'] = $j + 1;
|
||||
$this->xmlForm->setDefaultValues();
|
||||
$this->xmlForm->setValues( $result1 );
|
||||
$result1 = array_merge( $this->xmlForm->values, $result1 );
|
||||
$this->tdStyle = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdStyle( $result1, $this->xmlForm );
|
||||
$this->tdClass = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdClass( $result1, $this->xmlForm );
|
||||
$this->xmlForm->setValues($result1);
|
||||
$result1 = array_merge($this->xmlForm->values, $result1);
|
||||
$this->tdStyle = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdStyle($result1, $this->xmlForm);
|
||||
$this->tdClass = $this->xmlForm->fields[$this->fields[$r]['Name']]->tdClass($result1, $this->xmlForm);
|
||||
} elseif ($this->style[$r]['showInTable'] != '0') {
|
||||
$this->renderField( $j + 1, $r, $result );
|
||||
$this->renderField($j + 1, $r, $result);
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
$this->tpl->assign( '_ROOT.gridRows', '=' . $gridRows ); //number of rows in the current page
|
||||
$this->tpl->newBlock( 'rowTag' );
|
||||
$this->tpl->assign( 'rowId', 'insertAtLast' );
|
||||
$this->tpl->assign('_ROOT.gridRows', '=' . $gridRows); //number of rows in the current page
|
||||
$this->tpl->newBlock('rowTag');
|
||||
$this->tpl->assign('rowId', 'insertAtLast');
|
||||
if ($this->currentPage > 1) {
|
||||
$firstUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=1';
|
||||
$firstUrl = $filter->xssFilterHard($firstUrl);
|
||||
$firstUrl = $filter->xssFilterHard($firstUrl);
|
||||
$firstAjax = $this->id . ".doGoToPage(1);return false;";
|
||||
$firstAjax = $filter->xssFilterHard($firstAjax);
|
||||
$firstAjax = $filter->xssFilterHard($firstAjax);
|
||||
$prevpage = $this->currentPage - 1;
|
||||
$prevUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $prevpage;
|
||||
$prevUrl = $filter->xssFilterHard($prevUrl);
|
||||
$prevUrl = $filter->xssFilterHard($prevUrl);
|
||||
$prevAjax = $this->id . ".doGoToPage(" . $prevpage . ");return false;";
|
||||
$prevAjax = $filter->xssFilterHard($prevAjax);
|
||||
$first = "<a href=\"" . htmlentities( $firstUrl, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $firstAjax . "\" class='firstPage'> </a>";
|
||||
$prev = "<a href=\"" . htmlentities( $prevUrl, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $prevAjax . "\" class='previousPage'> </a>";
|
||||
$prevAjax = $filter->xssFilterHard($prevAjax);
|
||||
$first = "<a href=\"" . htmlentities($firstUrl, ENT_QUOTES, 'utf-8') . "\" onclick=\"" . $firstAjax . "\" class='firstPage'> </a>";
|
||||
$prev = "<a href=\"" . htmlentities($prevUrl, ENT_QUOTES, 'utf-8') . "\" onclick=\"" . $prevAjax . "\" class='previousPage'> </a>";
|
||||
} else {
|
||||
$first = "<a class='noFirstPage'> </a>";
|
||||
$prev = "<a class='noPreviousPage'> </a>";
|
||||
}
|
||||
if ($this->currentPage < $this->totpages) {
|
||||
$lastUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $this->totpages;
|
||||
$lastUrl = $filter->xssFilterHard($lastUrl);
|
||||
$lastUrl = $filter->xssFilterHard($lastUrl);
|
||||
$lastAjax = $this->id . ".doGoToPage(" . $this->totpages . ");return false;";
|
||||
$lastAjax = $filter->xssFilterHard($lastAjax);
|
||||
$lastAjax = $filter->xssFilterHard($lastAjax);
|
||||
$nextpage = $this->currentPage + 1;
|
||||
$nextUrl = $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $nextpage;
|
||||
$nextUrl = $filter->xssFilterHard($nextUrl);
|
||||
$nextUrl = $filter->xssFilterHard($nextUrl);
|
||||
$nextAjax = $this->id . ".doGoToPage(" . $nextpage . ");return false;";
|
||||
$nextAjax = $filter->xssFilterHard($nextAjax);
|
||||
$next = "<a href=\"" . htmlentities( $nextUrl, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $nextAjax . "\" class='nextPage'> </a>";
|
||||
$last = "<a href=\"" . htmlentities( $lastUrl, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $lastAjax . "\" class='lastPage'> </a>";
|
||||
$nextAjax = $filter->xssFilterHard($nextAjax);
|
||||
$next = "<a href=\"" . htmlentities($nextUrl, ENT_QUOTES, 'utf-8') . "\" onclick=\"" . $nextAjax . "\" class='nextPage'> </a>";
|
||||
$last = "<a href=\"" . htmlentities($lastUrl, ENT_QUOTES, 'utf-8') . "\" onclick=\"" . $lastAjax . "\" class='lastPage'> </a>";
|
||||
} else {
|
||||
$next = "<a class='noNextPage'> </a>";
|
||||
$last = "<a class='noLastPage'> </a>";
|
||||
}
|
||||
$pagesEnum = '';
|
||||
for ($r = 1; $r <= $this->totpages; $r ++) {
|
||||
for ($r = 1; $r <= $this->totpages; $r++) {
|
||||
if (($r >= ($this->currentPage - 5)) && ($r <= ($this->currentPage + 5))) {
|
||||
$pageAjax = $this->id . ".doGoToPage(" . $r . ");return false;";
|
||||
if ($r != $this->currentPage) {
|
||||
$pageAjax = $filter->xssFilterHard($pageAjax);
|
||||
$pagesEnum .= " <a href=\"" . htmlentities( $this->ownerPage . '?order=' . $this->orderBy . '&page=' . $r, ENT_QUOTES, 'utf-8' ) . "\" onclick=\"" . $pageAjax . "\">" . $r . "</a>";
|
||||
if ($r != $this->currentPage) {
|
||||
$pageAjax = $filter->xssFilterHard($pageAjax);
|
||||
$pagesEnum .= " <a href=\"" . htmlentities($this->ownerPage . '?order=' . $this->orderBy . '&page=' . $r, ENT_QUOTES, 'utf-8') . "\" onclick=\"" . $pageAjax . "\">" . $r . "</a>";
|
||||
} else {
|
||||
$pagesEnum .= " <a>" . $r . "</a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->query->count() === 0) {
|
||||
$this->tpl->newBlock( 'norecords' );
|
||||
$this->tpl->assign( "columnCount", $this->colCount );
|
||||
$this->tpl->newBlock('norecords');
|
||||
$this->tpl->assign("columnCount", $this->colCount);
|
||||
$noRecordsFound = 'ID_NO_RECORDS_FOUND';
|
||||
if (G::LoadTranslation( $noRecordsFound )) {
|
||||
$noRecordsFound = G::LoadTranslation( $noRecordsFound );
|
||||
if (G::LoadTranslation($noRecordsFound)) {
|
||||
$noRecordsFound = G::LoadTranslation($noRecordsFound);
|
||||
}
|
||||
$this->tpl->assign( "noRecordsFound", $noRecordsFound );
|
||||
$this->tpl->assign("noRecordsFound", $noRecordsFound);
|
||||
}
|
||||
if (! $this->disableFooter) {
|
||||
$this->tpl->newBlock( "bottomFooter" );
|
||||
$this->tpl->assign( "columnCount", $this->colCount );
|
||||
$this->tpl->assign( "pagedTableId", $this->id );
|
||||
if (!$this->disableFooter) {
|
||||
$this->tpl->newBlock("bottomFooter");
|
||||
$this->tpl->assign("columnCount", $this->colCount);
|
||||
$this->tpl->assign("pagedTableId", $this->id);
|
||||
if (($this->query->count() !== 0)) {
|
||||
if ($this->totpages > 1) {
|
||||
$this->tpl->assign( "first", $first );
|
||||
$this->tpl->assign( "prev", $prev );
|
||||
$this->tpl->assign( "next", $next );
|
||||
$this->tpl->assign( "last", $last );
|
||||
$this->tpl->assign("first", $first);
|
||||
$this->tpl->assign("prev", $prev);
|
||||
$this->tpl->assign("next", $next);
|
||||
$this->tpl->assign("last", $last);
|
||||
}
|
||||
$this->tpl->assign( "currentPage", $this->currentPage );
|
||||
$this->tpl->assign( "totalPages", $this->totpages );
|
||||
$this->tpl->assign("currentPage", $this->currentPage);
|
||||
$this->tpl->assign("totalPages", $this->totpages);
|
||||
$firstRow = ($this->currentPage - 1) * $this->rowsPerPage + 1;
|
||||
$lastRow = $firstRow + $this->query->count() - 1;
|
||||
$this->tpl->assign( "firstRow", $firstRow );
|
||||
$this->tpl->assign( "lastRow", $lastRow );
|
||||
$this->tpl->assign( "totalRows", $this->totRows );
|
||||
$this->tpl->assign("firstRow", $firstRow);
|
||||
$this->tpl->assign("lastRow", $lastRow);
|
||||
$this->tpl->assign("totalRows", $this->totRows);
|
||||
} else {
|
||||
$this->tpl->assign( "indexStyle", 'visibility:hidden;' );
|
||||
$this->tpl->assign("indexStyle", 'visibility:hidden;');
|
||||
}
|
||||
if ($this->searchBy) {
|
||||
$this->tpl->assign( "fastSearchValue", $this->fastSearch );
|
||||
$this->tpl->assign("fastSearchValue", $this->fastSearch);
|
||||
} else {
|
||||
$this->tpl->assign( "fastSearchStyle", 'visibility:hidden;' );
|
||||
$this->tpl->assign("fastSearchStyle", 'visibility:hidden;');
|
||||
}
|
||||
if ($this->addRow) {
|
||||
if ($this->sqlInsert != '') {
|
||||
$this->tpl->assign( "insert", '<a href="#" onclick="pagedTable.event=\'Insert\';popup(\'' . $this->popupPage . '\');return false;">'./*G::LoadXml('labels','ID_ADD_NEW')*/ 'ID_ADD_NEW' . '</a>' );
|
||||
$this->tpl->assign("insert", '<a href="#" onclick="pagedTable.event=\'Insert\';popup(\'' . $this->popupPage . '\');return false;">' ./*G::LoadXml('labels','ID_ADD_NEW')*/
|
||||
'ID_ADD_NEW' . '</a>');
|
||||
}
|
||||
}
|
||||
$this->tpl->assign( "pagesEnum", $pagesEnum );
|
||||
}
|
||||
?>
|
||||
<script language='JavaScript'>
|
||||
var <?php echo $this->id?><?php echo ($this->name != '' ? '='.$this->name : '')?>=new G_PagedTable();
|
||||
<?php echo $this->id?>.id<?php echo '="'. addslashes($this->id) . '"'?>;
|
||||
<?php echo $this->id?>.name<?php echo '="'. addslashes($this->name) . '"'?>;
|
||||
<?php echo $this->id?>.ajaxUri<?php echo '="'. addslashes($this->ajaxServer) . '?ptID='.$this->id.'"'?>;
|
||||
<?php echo $this->id?>.currentOrder<?php echo '="'. addslashes($this->orderBy) . '"'?>;
|
||||
<?php echo $this->id?>.currentFilter;
|
||||
<?php echo $this->id?>.currentPage<?php echo '='. $this->currentPage?>;
|
||||
<?php echo $this->id?>.totalRows<?php echo '='.$this->query->count()?>;
|
||||
<?php echo $this->id?>.rowsPerPage<?php echo '='.$this->rowsPerPage?>;
|
||||
<?php echo $this->id?>.popupPage<?php echo '="'. addslashes($this->popupPage) . '?ptID='.$this->id.'"'?>;
|
||||
<?php echo $this->id?>.onUpdateField<?php echo '="'. addslashes($this->onUpdateField) . '"'?>;
|
||||
<?php echo $this->id?>.shownFields<?php echo '='.$this->shownFields ?>;
|
||||
$this->tpl->assign("pagesEnum", $pagesEnum);
|
||||
} ?>
|
||||
<script language='JavaScript'>
|
||||
var <?php echo $this->id?><?php echo($this->name != '' ? '=' . $this->name : '')?>=
|
||||
new G_PagedTable();
|
||||
<?php echo $this->id?>.id<?php echo '="' . addslashes($this->id) . '"'?>;
|
||||
<?php echo $this->id?>.name<?php echo '="' . addslashes($this->name) . '"'?>;
|
||||
<?php echo $this->id?>.ajaxUri<?php echo '="' . addslashes($this->ajaxServer) . '?ptID=' . $this->id . '"'?>;
|
||||
<?php echo $this->id?>.currentOrder<?php echo '="' . addslashes($this->orderBy) . '"'?>;
|
||||
<?php echo $this->id?>.currentFilter;
|
||||
<?php echo $this->id?>.currentPage<?php echo '=' . $this->currentPage?>;
|
||||
<?php echo $this->id?>.totalRows<?php echo '=' . $this->query->count()?>;
|
||||
<?php echo $this->id?>.rowsPerPage<?php echo '=' . $this->rowsPerPage?>;
|
||||
<?php echo $this->id?>.popupPage<?php echo '="' . addslashes($this->popupPage) . '?ptID=' . $this->id . '"'?>;
|
||||
<?php echo $this->id?>.onUpdateField<?php echo '="' . addslashes($this->onUpdateField) . '"'?>;
|
||||
<?php echo $this->id?>.shownFields<?php echo '=' . $this->shownFields ?>;
|
||||
|
||||
var panelPopup;
|
||||
var popupWidth<?php echo '='.$this->popupWidth?>;
|
||||
var popupHeight<?php echo '='.$this->popupHeight?>;
|
||||
var panelPopup;
|
||||
var popupWidth<?php echo '=' . $this->popupWidth?>;
|
||||
var popupHeight<?php echo '=' . $this->popupHeight?>;
|
||||
</script>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* ******** CLOSE BLOCK **************
|
||||
*/
|
||||
if (($block === '') || ($block === 'close')) {
|
||||
$this->tpl->newBlock( "closeBlock" );
|
||||
$this->tpl->newBlock("closeBlock");
|
||||
}
|
||||
$this->tpl->printToScreen();
|
||||
unset( $this->tpl );
|
||||
unset( $this->dbc );
|
||||
unset( $this->ses );
|
||||
unset($this->tpl);
|
||||
unset($this->dbc);
|
||||
unset($this->ses);
|
||||
$_SESSION['pagedTable[' . $this->id . ']'] = base64_encode(serialize($this));
|
||||
return;
|
||||
}
|
||||
@@ -1028,14 +1028,14 @@ class pagedTable
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
public function printForm ($filename, $data = array())
|
||||
public function printForm($filename, $data = array())
|
||||
{
|
||||
// $G_FORM = new Form($filename, PATH_XMLFORM);
|
||||
// echo $G_FORM->render(PATH_TPL . 'xmlform.html', $scriptContent);
|
||||
global $G_PUBLISH;
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $filename, '', $data, $this->popupSubmit );
|
||||
G::RenderPage( "publish", "blank" );
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', $filename, '', $data, $this->popupSubmit);
|
||||
G::RenderPage("publish", "blank");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1046,18 +1046,17 @@ class pagedTable
|
||||
* @param string $o
|
||||
* @return void
|
||||
*/
|
||||
function var_dump2 ($o)
|
||||
function var_dump2($o)
|
||||
{
|
||||
if (is_object( $o ) || is_array( $o )) {
|
||||
if (is_object($o) || is_array($o)) {
|
||||
foreach ($o as $key => $value) {
|
||||
echo ('<b>');
|
||||
var_dump( $key );
|
||||
echo ('</b>');
|
||||
print_r( $value );
|
||||
echo ('<br>');
|
||||
echo('<b>');
|
||||
var_dump($key);
|
||||
echo('</b>');
|
||||
print_r($value);
|
||||
echo('<br>');
|
||||
}
|
||||
} else {
|
||||
var_dump( $o );
|
||||
var_dump($o);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ class Publisher
|
||||
if ($Part['Template'] == 'grid') {
|
||||
print ('</form>') ;
|
||||
}
|
||||
$oHeadPublisher = & headPublisher::getSingleton();
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptFile( $G_FORM->scriptURL );
|
||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
||||
|
||||
@@ -535,7 +535,7 @@ class Publisher
|
||||
$mainPanelScript .= '});';
|
||||
$mainPanelScript .= 'function ' . $panelName . 'Clear(){';
|
||||
$mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . 'Tabs[r].style.display="none";}';
|
||||
$oHeadPublisher = & headPublisher::getSingleton();
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptCode( $mainPanelScript );
|
||||
|
||||
break;
|
||||
|
||||
@@ -204,7 +204,6 @@ class RBAC
|
||||
];
|
||||
$this->aliasPermissions['PM_CASES'] = [self::PM_GUEST_CASE];
|
||||
$this->aliasPermissions['PM_LOGIN'] = [self::PM_GUEST_CASE];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,37 +230,30 @@ class RBAC
|
||||
public function initRBAC()
|
||||
{
|
||||
if (is_null($this->userObj)) {
|
||||
|
||||
$this->userObj = new RbacUsers();
|
||||
}
|
||||
|
||||
if (is_null($this->systemObj)) {
|
||||
|
||||
$this->systemObj = new Systems();
|
||||
}
|
||||
|
||||
if (is_null($this->usersRolesObj)) {
|
||||
|
||||
$this->usersRolesObj = new UsersRoles();
|
||||
}
|
||||
|
||||
if (is_null($this->rolesObj)) {
|
||||
|
||||
$this->rolesObj = new Roles();
|
||||
}
|
||||
|
||||
if (is_null($this->permissionsObj)) {
|
||||
|
||||
$this->permissionsObj = new Permissions();
|
||||
}
|
||||
|
||||
if (is_null($this->rolesPermissionsObj)) {
|
||||
|
||||
$this->rolesPermissionsObj = new RolesPermissions();
|
||||
}
|
||||
|
||||
if (is_null($this->authSourcesObj)) {
|
||||
|
||||
$this->authSourcesObj = new AuthenticationSource();
|
||||
}
|
||||
//hook for RBAC plugins
|
||||
@@ -269,13 +261,11 @@ class RBAC
|
||||
if (is_dir($pathPlugins)) {
|
||||
if ($handle = opendir($pathPlugins)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (strpos($file, '.php', 1) && is_file($pathPlugins . PATH_SEP . $file) && substr($file, 0,
|
||||
6) == 'class.' && substr($file, -4) == '.php') {
|
||||
|
||||
if (strpos($file, '.php', 1) && is_file($pathPlugins . PATH_SEP . $file) &&
|
||||
substr($file, 0, 6) === 'class.' && substr($file, -4) === '.php') {
|
||||
$className = substr($file, 6, strlen($file) - 10);
|
||||
require_once($pathPlugins . PATH_SEP . $file);
|
||||
$this->aRbacPlugins[] = $className;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -873,9 +863,9 @@ class RBAC
|
||||
*/
|
||||
public function VerifyWithOtherAuthenticationSource($authType, $userFields, $strPass)
|
||||
{
|
||||
if ($authType == '' || $authType == 'MYSQL') {
|
||||
if ($authType === '' || $authType === 'MYSQL') {
|
||||
//check if the user is active
|
||||
if ($userFields['USR_STATUS'] != 1) {
|
||||
if ($userFields['USR_STATUS'] !== 1) {
|
||||
return -3; //inactive user
|
||||
}
|
||||
|
||||
@@ -886,13 +876,12 @@ class RBAC
|
||||
}
|
||||
|
||||
foreach ($this->aRbacPlugins as $className) {
|
||||
if (strtolower($className) == strtolower($authType)) {
|
||||
if (strtolower($className) === strtolower($authType)) {
|
||||
$plugin = new $className();
|
||||
$plugin->sAuthSource = $userFields["UID_AUTH_SOURCE"];
|
||||
$plugin->sAuthSource = $userFields['UID_AUTH_SOURCE'];
|
||||
$plugin->sSystem = $this->sSystem;
|
||||
|
||||
$bValidUser = false;
|
||||
$bValidUser = $plugin->VerifyLogin($userFields["USR_AUTH_USER_DN"], $strPass);
|
||||
$bValidUser = $plugin->VerifyLogin($userFields['USR_AUTH_USER_DN'], $strPass);
|
||||
if ($bValidUser === true) {
|
||||
return ($userFields['USR_UID']);
|
||||
} else {
|
||||
@@ -924,14 +913,16 @@ class RBAC
|
||||
{
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
$licenseManager =& PmLicenseManager::getSingleton();
|
||||
if (in_array(G::encryptOld($licenseManager->result),
|
||||
array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb'))) {
|
||||
$licenseManager = PmLicenseManager::getSingleton();
|
||||
if (in_array(
|
||||
G::encryptOld($licenseManager->result),
|
||||
['38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb']
|
||||
)) {
|
||||
return -7;
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
if (strlen($strPass) == 0) {
|
||||
if (strlen($strPass) === 0) {
|
||||
return -2;
|
||||
}
|
||||
//check if the user exists in the table RB_WORKFLOW.USERS
|
||||
@@ -955,12 +946,10 @@ class RBAC
|
||||
//Hook for RBAC plugins
|
||||
if ($authType != "mysql" && $authType != "") {
|
||||
$res = $this->VerifyWithOtherAuthenticationSource($authType, $this->userObj->fields, $strPass);
|
||||
|
||||
return $res;
|
||||
} else {
|
||||
$this->userObj->reuseUserFields = true;
|
||||
$res = $this->userObj->VerifyLogin($strUser, $strPass);
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
@@ -976,7 +965,6 @@ class RBAC
|
||||
public function verifyUser($strUser)
|
||||
{
|
||||
$res = $this->userObj->verifyUser($strUser);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -990,7 +978,6 @@ class RBAC
|
||||
public function verifyUserId($strUserId)
|
||||
{
|
||||
$res = $this->userObj->verifyUserId($strUserId);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -1051,24 +1038,24 @@ class RBAC
|
||||
*/
|
||||
public function createUser($dataCase = [], $rolCode = '')
|
||||
{
|
||||
if ($dataCase["USR_STATUS"] . "" == "1") {
|
||||
$dataCase["USR_STATUS"] = "ACTIVE";
|
||||
if ($dataCase['USR_STATUS'] . '' === '1') {
|
||||
$dataCase['USR_STATUS'] = 'ACTIVE';
|
||||
}
|
||||
|
||||
if ($dataCase["USR_STATUS"] . "" == "0") {
|
||||
$dataCase["USR_STATUS"] = "INACTIVE";
|
||||
if ($dataCase['USR_STATUS'] . '' === '0') {
|
||||
$dataCase['USR_STATUS'] = 'INACTIVE';
|
||||
}
|
||||
|
||||
if ($dataCase['USR_STATUS'] == 'ACTIVE') {
|
||||
if ($dataCase['USR_STATUS'] === 'ACTIVE') {
|
||||
$dataCase['USR_STATUS'] = 1;
|
||||
}
|
||||
if ($dataCase['USR_STATUS'] == 'INACTIVE') {
|
||||
if ($dataCase['USR_STATUS'] === 'INACTIVE') {
|
||||
$dataCase['USR_STATUS'] = 0;
|
||||
}
|
||||
|
||||
$userUid = $this->userObj->create($dataCase);
|
||||
|
||||
if ($rolCode != '') {
|
||||
if ($rolCode !== '') {
|
||||
$this->assignRoleToUser($userUid, $rolCode);
|
||||
}
|
||||
|
||||
@@ -1086,7 +1073,7 @@ class RBAC
|
||||
public function updateUser($dataCase = [], $rolCode = '')
|
||||
{
|
||||
if (isset($dataCase['USR_STATUS'])) {
|
||||
if ($dataCase['USR_STATUS'] == 'ACTIVE') {
|
||||
if ($dataCase['USR_STATUS'] === 'ACTIVE') {
|
||||
$dataCase['USR_STATUS'] = 1;
|
||||
}
|
||||
}
|
||||
@@ -1141,9 +1128,9 @@ class RBAC
|
||||
$userStatus = 1;
|
||||
}
|
||||
|
||||
$aFields = $this->userObj->load($userUid);
|
||||
$aFields['USR_STATUS'] = $userStatus;
|
||||
$this->userObj->update($aFields);
|
||||
$fields = $this->userObj->load($userUid);
|
||||
$fields['USR_STATUS'] = $userStatus;
|
||||
$this->userObj->update($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1194,7 +1181,7 @@ class RBAC
|
||||
*/
|
||||
public function createPermision($code)
|
||||
{
|
||||
return $this->permissionsObj->create(array('PER_CODE' => $code));
|
||||
return $this->permissionsObj->create(['PER_CODE' => $code]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1650,8 +1637,10 @@ class RBAC
|
||||
*/
|
||||
public function createAuthSource($dataCase)
|
||||
{
|
||||
$dataCase['AUTH_SOURCE_PASSWORD'] = G::encrypt($dataCase['AUTH_SOURCE_PASSWORD'],
|
||||
$dataCase['AUTH_SOURCE_SERVER_NAME']) . "_2NnV3ujj3w";
|
||||
$dataCase['AUTH_SOURCE_PASSWORD'] = G::encrypt(
|
||||
$dataCase['AUTH_SOURCE_PASSWORD'],
|
||||
$dataCase['AUTH_SOURCE_SERVER_NAME']
|
||||
) . "_2NnV3ujj3w";
|
||||
$this->authSourcesObj->create($dataCase);
|
||||
}
|
||||
|
||||
@@ -1666,8 +1655,10 @@ class RBAC
|
||||
*/
|
||||
public function updateAuthSource($dataCase)
|
||||
{
|
||||
$dataCase['AUTH_SOURCE_PASSWORD'] = G::encrypt($dataCase['AUTH_SOURCE_PASSWORD'],
|
||||
$dataCase['AUTH_SOURCE_SERVER_NAME']) . "_2NnV3ujj3w";
|
||||
$dataCase['AUTH_SOURCE_PASSWORD'] = G::encrypt(
|
||||
$dataCase['AUTH_SOURCE_PASSWORD'],
|
||||
$dataCase['AUTH_SOURCE_SERVER_NAME']
|
||||
) . "_2NnV3ujj3w";
|
||||
$this->authSourcesObj->update($dataCase);
|
||||
}
|
||||
|
||||
@@ -1928,14 +1919,18 @@ class RBAC
|
||||
$isAssignedNewpermissions = $this->getPermissionAssignedRole($aRow['ROL_UID'], $item['PER_UID']);
|
||||
$assignPermissions = true;
|
||||
if (!$isAssignedNewpermissions) {
|
||||
if ($aRow['ROL_CODE'] == 'PROCESSMAKER_OPERATOR' && in_array($item['PER_CODE'],
|
||||
$permissionsForOperator)) {
|
||||
if ($aRow['ROL_CODE'] == 'PROCESSMAKER_OPERATOR' && in_array(
|
||||
$item['PER_CODE'],
|
||||
$permissionsForOperator
|
||||
)) {
|
||||
$assignPermissions = false;
|
||||
}
|
||||
if (!in_array($aRow['ROL_CODE'], $perCodePM)) {
|
||||
$assignPermissions = false;
|
||||
$checkPermisionEdit = $this->getPermissionAssignedRole($aRow['ROL_UID'],
|
||||
'00000000000000000000000000000014');
|
||||
$checkPermisionEdit = $this->getPermissionAssignedRole(
|
||||
$aRow['ROL_UID'],
|
||||
'00000000000000000000000000000014'
|
||||
);
|
||||
if ($checkPermisionEdit && !in_array($item['PER_CODE'], $permissionsForOperator)) {
|
||||
$assignPermissions = true;
|
||||
}
|
||||
@@ -2025,4 +2020,3 @@ class RBAC
|
||||
return self::GUEST_USER_UID === $usrUid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,13 +29,12 @@
|
||||
* XmlFormFieldWYSIWYGEditor class definition
|
||||
* It is useful to see dynaforms how are built
|
||||
*
|
||||
* @package gulliver.system
|
||||
* @package gulliver.system
|
||||
* @author
|
||||
*
|
||||
* @copyright (C) 2012 by Colosa Development Team.
|
||||
*
|
||||
*/
|
||||
|
||||
class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
||||
{
|
||||
public $width = '100%';
|
||||
@@ -50,15 +49,18 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
||||
*
|
||||
* @author
|
||||
* @access public
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $owner
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function render ($value, $owner = null)
|
||||
public function render($value, $owner = null)
|
||||
{
|
||||
$value = ($value == '') ? '<br/>' : $value;
|
||||
$html = "<textArea class='tmceEditor' id='form[" . $this->name . "]' name='form[" . $this->name . "]' >" . htmlentities( $value, ENT_QUOTES, 'UTF-8' ) . "</textarea>";
|
||||
$html = "<textArea class='tmceEditor' id='form[" . $this->name . "]' name='form[" . $this->name . "]' >" . htmlentities($value,
|
||||
ENT_QUOTES, 'UTF-8') . "</textarea>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
@@ -68,19 +70,21 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
||||
*
|
||||
* @author
|
||||
* @access public
|
||||
*
|
||||
* @param string $element
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function attachEvents ($element)
|
||||
public function attachEvents($element)
|
||||
{
|
||||
$editorDefinition = 'tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce"; ';
|
||||
$editorDefinition .= 'var domainURL = "/sys'.config("system.workspace").'/'.SYS_LANG.'/'.SYS_SKIN.'/"';
|
||||
$serverConf =& ServerConf::getSingleton();
|
||||
$editorDefinition = 'tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce"; ';
|
||||
$editorDefinition .= 'var domainURL = "/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/"';
|
||||
$serverConf = ServerConf::getSingleton();
|
||||
|
||||
switch ($this->editorType){
|
||||
switch ($this->editorType) {
|
||||
case 'EMAIL_TEMPLATE':
|
||||
$editorDefinition.= '
|
||||
$editorDefinition .= '
|
||||
// is necessary the process uid variable in order to load the picker correctly
|
||||
var actualCaretPositionBookmark;
|
||||
var formProcessID = document.getElementById("form[pro_uid]").value;
|
||||
@@ -118,7 +122,7 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
||||
';
|
||||
break;
|
||||
case 'OUTPUT_DOCUMENT':
|
||||
$editorDefinition.= '
|
||||
$editorDefinition .= '
|
||||
// is necessary the process uid variable in order to load the picker correctly
|
||||
var formProcessID = document.getElementById("form[PRO_UID]").value;
|
||||
tinyMCE.init({
|
||||
@@ -156,7 +160,7 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
||||
break;
|
||||
|
||||
case 'DYNAFORM_TEMPLATE':
|
||||
$editorDefinition.= '
|
||||
$editorDefinition .= '
|
||||
var formProcessID = document.getElementById("form[PRO_UID]").value;
|
||||
var formDynaformID = document.getElementById("form[DYN_UID]").value;
|
||||
var actualCaretPositionBookmark;
|
||||
@@ -177,7 +181,7 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
||||
popup_css : "/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/default/dialog.css",
|
||||
skin : "o2k7",
|
||||
skin_variant : "silver",
|
||||
content_css : "/css/'.SYS_SKIN.'.css",
|
||||
content_css : "/css/' . SYS_SKIN . '.css",
|
||||
template_external_list_url : "js/template_list.js",
|
||||
external_link_list_url : "js/link_list.js",
|
||||
external_image_list_url : "js/image_list.js",
|
||||
@@ -207,7 +211,7 @@ class XmlFormFieldWYSIWYGEditor extends XmlFormField
|
||||
';
|
||||
break;
|
||||
default:
|
||||
$editorDefinition.= '
|
||||
$editorDefinition .= '
|
||||
tinyMCE.init({
|
||||
// General options
|
||||
mode : "textareas",
|
||||
|
||||
@@ -84,7 +84,7 @@ class XmlFormFieldXmlMenu extends XmlFormField
|
||||
$this->type = 'xmlmenuDyn';
|
||||
$template = PATH_CORE . 'templates/' . $this->type . '.html';
|
||||
$out = $this->xmlMenu->render( $template, $scriptCode );
|
||||
$oHeadPublisher = & headPublisher::getSingleton();
|
||||
$oHeadPublisher = headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptFile( $this->xmlMenu->scriptURL );
|
||||
$oHeadPublisher->addScriptCode( $scriptCode );
|
||||
return $out;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user