Improved the internal session handel of JCB. Fixed gh-487 that removed the data size when creating a new field.

This commit is contained in:
2019-11-08 18:07:08 +02:00
parent 010a134e1a
commit 6539862534
38 changed files with 1582 additions and 564 deletions

View File

@ -7001,7 +7001,7 @@ class Get
(trim($lineContent) === $endHTML || strpos($lineContent, $endHTML) !== false)))
{
// trim the placeholder and if there is still data then load it
if ($_line = $this->addLineChecker($endReplace, 2, $lineContent))
if (isset($endReplace) && ($_line = $this->addLineChecker($endReplace, 2, $lineContent)) !== false)
{
$codeBucket[$pointer[$targetKey]][] = $_line;
}
@ -7360,9 +7360,9 @@ class Get
/**
* Check if this line should be added
*
* @param strin $replaceKey The key to remove from line
* @param int $type The line type
* @param string $lineContent The line to check
* @param string $replaceKey The key to remove from line
* @param int $type The line type
* @param string $lineContent The line to check
*
* @return bool true on success
*

View File

@ -1829,7 +1829,7 @@ class Fields extends Structure
// add to lang array
$this->setLangContent($this->lang, $langValue, $option);
// now add to option set
$grouped_['option'][$option] = array('value' => $valueKeyArray[0], 'text' => $langValue);
$grouped_['option'][$option] = array('value' => $option, 'text' => $langValue);
$optionArray[$option] = $langValue;
// set order
$order_['option' . $option] = $option;
@ -2357,7 +2357,7 @@ class Fields extends Structure
}
else
{
$this->siteFieldData['decode'][$array['site']][$code][$array['as']][$array['key']] = array('decode' => array($set), 'type' => $type);
$this->siteFieldData['decode'][$array['site']][$code][$array['as']][$array['key']] = array('decode' => array($set), 'type' => $type, 'admin_view' => $view);
}
}
// set the uikit checker
@ -3052,8 +3052,8 @@ class Fields extends Structure
$this->buildSiteFieldData($view_name_single, $name, 'json', $typeName);
}
// load the json list display fix
if (($listSwitch || $listJoin) && $typeName != 'repeatable' && $typeName != 'subform')
// load the model list display fix
if (($listSwitch || $listJoin) && (($typeName != 'repeatable' && $typeName != 'subform') || $field['settings']->store == 6))
{
if (ComponentbuilderHelper::checkArray($options))
{

View File

@ -1835,11 +1835,11 @@ class Interpretation extends Fields
// base64_decode
$decoder = $string . "->" . $field . " = base64_decode(" . $string . "->" . $field . ");";
}
elseif (strpos($decode, '_encryption') !== false)
elseif (strpos($decode, '_encryption') !== false || 'expert_mode' === $decode)
{
foreach ($this->cryptionTypes as $cryptionType)
{
if ($cryptionType . '_encryption' === $decode)
if ($cryptionType . '_encryption' === $decode || $cryptionType . '_mode' === $decode)
{
if ('expert' !== $cryptionType)
{
@ -1847,10 +1847,10 @@ class Interpretation extends Fields
// set decryption
$decoder = $string . "->" . $field . " = rtrim(\$" . $cryptionType . "->decryptString(" . $string . "->" . $field . "), " . '"\0"' . ");";
}
elseif (isset($this->{$cryptionType . 'FieldModeling'}[$code][$field]))
elseif (isset($this->{$cryptionType . 'FieldModeling'}[$array['admin_view']][$field]))
{
$_placeholder_for_field = array('[[[field]]]' => $string . "->" . $field);
$fieldDecode .= $this->setPlaceholders(PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . implode(PHP_EOL . $this->_t(1) . $tab . $this->_t(1), $this->{$cryptionType . 'FieldModeling'}[$code][$field]['get']), $_placeholder_for_field);
$fieldDecode .= $this->setPlaceholders(PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . implode(PHP_EOL . $this->_t(1) . $tab . $this->_t(1), $this->{$cryptionType . 'FieldModeling'}[$array['admin_view']][$field]['get']), $_placeholder_for_field);
}
// activate site decryption
$this->siteDecrypt[$cryptionType][$code] = true;
@ -12955,9 +12955,7 @@ class Interpretation extends Fields
break;
case 6:
// EXPERT_ENCRYPTION
$decode = '///////////////////////////////////////////';
$expertCrypt = true;
$suffix_decode = '';
break;
default:
// JSON_ARRAY_ENCODE
@ -12968,7 +12966,7 @@ class Interpretation extends Fields
break;
}
if ($item['type'] === 'usergroup' && !$export)
if ($item['type'] === 'usergroup' && !$export && $item['method'] != 6)
{
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " decode " . $item['name'];
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$" . $item['name'] . "Array = " . $decode . "(\$item->" . $item['name'] . $suffix_decode . ");";
@ -12991,7 +12989,7 @@ class Interpretation extends Fields
$fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(4) . "\$item->".$item['name']." = implode('|',\$".$item['name']."Array);";
$fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "}";
} */
elseif ($item['translation'] && !$export)
elseif ($item['translation'] && !$export && $item['method'] != 6)
{
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " decode " . $item['name'];
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$" . $item['name'] . "Array = " . $decode . "(\$item->" . $item['name'] . $suffix_decode . ");";
@ -13007,40 +13005,49 @@ class Interpretation extends Fields
}
else
{
if ($item['method'] == 2 || $item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5)
if ($item['method'] == 2 || $item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5 || $item['method'] == 6)
{
$taber = '';
if ($item['method'] == 3)
// expert mode (dev must do it all)
if ($item['method'] == 6)
{
$taber = $this->_t(1);
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$basickey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{";
}
elseif ($item['method'] == 5)
{
$taber = $this->_t(1);
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$mediumkey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{";
}
elseif ($item['method'] == 4)
{
$taber = $this->_t(1);
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$whmcskey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{";
}
if ($item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5)
{
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "//" . $this->setLine(__LINE__) . " decrypt " . $item['name'];
$_placeholder_for_field = array('[[[field]]]' => "\$item->" . $item['name']);
$fix .= $this->setPlaceholders(PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . implode(PHP_EOL . $this->_t(1) . $tab . $this->_t(3), $this->expertFieldModeling[$viewName_single][$item['name']]['get']), $_placeholder_for_field);
}
else
{
$fix .= PHP_EOL . $this->_t(1) . $tab . $taber . $this->_t(3) . "//" . $this->setLine(__LINE__) . " decode " . $item['name'];
}
$fix .= PHP_EOL . $this->_t(1) . $tab . $taber . $this->_t(3) . "\$item->" . $item['name'] . " = " . $decode . "(\$item->" . $item['name'] . ");";
$taber = '';
if ($item['method'] == 3)
{
$taber = $this->_t(1);
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$basickey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{";
}
elseif ($item['method'] == 5)
{
$taber = $this->_t(1);
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$mediumkey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{";
}
elseif ($item['method'] == 4)
{
$taber = $this->_t(1);
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$whmcskey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{";
}
if ($item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5)
{
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "//" . $this->setLine(__LINE__) . " decrypt " . $item['name'];
}
else
{
$fix .= PHP_EOL . $this->_t(1) . $tab . $taber . $this->_t(3) . "//" . $this->setLine(__LINE__) . " decode " . $item['name'];
}
$fix .= PHP_EOL . $this->_t(1) . $tab . $taber . $this->_t(3) . "\$item->" . $item['name'] . " = " . $decode . "(\$item->" . $item['name'] . ");";
if ($item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5)
{
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "}";
if ($item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5)
{
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "}";
}
}
}
else

View File

@ -834,13 +834,13 @@ abstract class ComponentbuilderHelper
*/
public static function getContributorDetails($filename, $type = 'snippet')
{
// start loading he contributor details
// start loading the contributor details
$contributor = array();
// get the path & content
switch ($type)
{
case 'snippet':
$path = $snippetPath.$filename;
$path = self::$snippetPath.$filename;
// get the file if available
$content = self::getFileContents($path);
if (self::checkJson($content))
@ -2043,17 +2043,17 @@ abstract class ComponentbuilderHelper
/**
* the Butler
* the Butler
**/
public static $session = array();
/**
* the Butler Assistant
* the Butler Assistant
**/
protected static $localSession = array();
/**
* start a session if not already set, and load with data
* start a session if not already set, and load with data
**/
public static function loadSession()
{
@ -2066,7 +2066,7 @@ abstract class ComponentbuilderHelper
}
/**
* give Session more to keep
* give Session more to keep
**/
public static function set($key, $value)
{
@ -2081,7 +2081,7 @@ abstract class ComponentbuilderHelper
}
/**
* get info from Session
* get info from Session
**/
public static function get($key, $default = null)
{
@ -4304,12 +4304,12 @@ abstract class ComponentbuilderHelper
}
/**
* Composer Switch
* Composer Switch
**/
protected static $composer = array();
/**
* Load the Composer Vendors
* Load the Composer Vendors
**/
public static function composerAutoload($target)
{
@ -4330,7 +4330,7 @@ abstract class ComponentbuilderHelper
/**
* Load the Composer Vendor phpseclib
* Load the Composer Vendor phpseclib
**/
protected static function composephpseclib()
{
@ -4338,6 +4338,8 @@ abstract class ComponentbuilderHelper
require_once JPATH_SITE . '/libraries/phpseclib/vendor/autoload.php';
// do not load again
self::$composer['phpseclib'] = true;
return true;
}
@ -6101,7 +6103,15 @@ abstract class ComponentbuilderHelper
{
$query->from($db->quoteName('#_'.$main.'_'.$table));
}
$query->where($db->quoteName($whereString) . ' '.$operator.' (' . implode(',',$where) . ')');
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator)
{
$query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())