diff --git a/README.md b/README.md index d9b77b479..15711b7ae 100644 --- a/README.md +++ b/README.md @@ -126,11 +126,11 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *First Build*: 30th April, 2015 -+ *Last Build*: 5th March, 2018 ++ *Last Build*: 6th March, 2018 + *Version*: 2.6.17 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **183587** ++ *Line count*: **183633** + *Field count*: **1645** + *File count*: **1169** + *Folder count*: **189** diff --git a/admin/README.txt b/admin/README.txt index d9b77b479..15711b7ae 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -126,11 +126,11 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *First Build*: 30th April, 2015 -+ *Last Build*: 5th March, 2018 ++ *Last Build*: 6th March, 2018 + *Version*: 2.6.17 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **183587** ++ *Line count*: **183633** + *Field count*: **1645** + *File count*: **1169** + *Folder count*: **189** diff --git a/admin/assets/images/icons/getsnippets.png b/admin/assets/images/icons/getsnippets.png new file mode 100644 index 000000000..cbe68e80e Binary files /dev/null and b/admin/assets/images/icons/getsnippets.png differ diff --git a/admin/compiler/joomla_3/component.xml b/admin/compiler/joomla_3/component.xml index f2a5d84e3..e1503f55e 100644 --- a/admin/compiler/joomla_3/component.xml +++ b/admin/compiler/joomla_3/component.xml @@ -71,7 +71,7 @@ access.xml config.xml - controller.php###ENCRYPT_FILE### + controller.php###WHMCS_ENCRYPT_FILE### index.html ###component###.php###EXSTRA_ADMIN_FILES### assets diff --git a/admin/compiler/joomla_3/settings.json b/admin/compiler/joomla_3/settings.json index f9fcc2cf3..a56267742 100644 --- a/admin/compiler/joomla_3/settings.json +++ b/admin/compiler/joomla_3/settings.json @@ -216,10 +216,10 @@ }, "dynamic": { "admin": { - "vdm.php": { + "whmcs.php": { "path": "c0mp0n3nt/admin", "rename": false, - "type": "encrypt" + "type": "whmcs" }, "Helper_email.php": { "path": "c0mp0n3nt/admin/helpers", diff --git a/admin/compiler/joomla_3/vdm.php b/admin/compiler/joomla_3/whmcs.php similarity index 97% rename from admin/compiler/joomla_3/vdm.php rename to admin/compiler/joomla_3/whmcs.php index 3c541e902..ca0e36ddd 100644 --- a/admin/compiler/joomla_3/vdm.php +++ b/admin/compiler/joomla_3/whmcs.php @@ -29,4 +29,4 @@ defined('_JEXEC') or die('Restricted access'); // No direct access to this file defined('_JEXEC') or die('Restricted access'); -###VDM_ENCRYPTION_BODY### +###WHMCS_ENCRYPTION_BODY### diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 18e8363a1..99f355f86 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -471,11 +471,18 @@ class Get public $layoutData = array(); /** - * The Advanced Encryption Switch + * The Encryption Types + * + * @var array + */ + public $cryptionTypes = array('basic','medium','whmcs'); + + /** + * The WHMCS Encryption Switch * * @var boolean */ - public $advancedEncryption = false; + public $whmcsEncryption = false; /** * The Basic Encryption Switch @@ -484,6 +491,13 @@ class Get */ public $basicEncryption = false; + /** + * The Medium Encryption Switch + * + * @var boolean + */ + public $mediumEncryption = false; + /** * The Custom field Switch per view * @@ -1956,16 +1970,21 @@ class Get { $field->properties = array_values($field->properties); } - // check if we have advanced encryption - if (4 == $field->store && (!isset($this->advancedEncryption) || !$this->advancedEncryption)) + // check if we have WHMCS encryption + if (4 == $field->store && (!isset($this->whmcsEncryption) || !$this->whmcsEncryption)) { - $this->advancedEncryption = true; + $this->whmcsEncryption = true; } // check if we have basic encryption elseif (3 == $field->store && (!isset($this->basicEncryption) || !$this->basicEncryption)) { $this->basicEncryption = true; } + // check if we have better encryption + elseif (5 == $field->store && (!isset($this->mediumEncryption) || !$this->mediumEncryption)) + { + $this->mediumEncryption = true; + } // get the last used version $field->history = $this->getHistoryWatch('field', $id); @@ -3701,21 +3720,34 @@ class Get // build local bucket foreach ($found as $target) { - // check if the target is valid URL or path - if ((!filter_var($target, FILTER_VALIDATE_URL) === false && ComponentbuilderHelper::urlExists($target)) - || (JPath::clean($target) === $target && JFile::exists($target))) + // check if user has permission to use EXTERNAL code (we may add a custom access switch - use ADMIN for now) + if ($this->user->authorise('core.admin', 'com_componentbuilder')) { - $this->getExternalCodeString($target, $bucket); + // check if the target is valid URL or path + if ((!filter_var($target, FILTER_VALIDATE_URL) === false && ComponentbuilderHelper::urlExists($target)) + || (JPath::clean($target) === $target && JFile::exists($target))) + { + $this->getExternalCodeString($target, $bucket); + } + // give notice that target is not a valid url/path + else + { + // set key + $key = '[EXTERNA'.'LCODE='.$target.']'; + // set the notice + $this->app->enqueueMessage(JText::_('

External Code Warning

'), 'Warning'); + $this->app->enqueueMessage(JText::sprintf('The %s is not a valid url/path!', $key), 'Warning'); + $this->app->enqueueMessage('
', 'Warning'); + // remove the placeholder + $bucket[$key] = ''; + } } - // give notice that target is not a valid url/path else { // set key $key = '[EXTERNA'.'LCODE='.$target.']'; // set the notice - $this->app->enqueueMessage(JText::_('

External Code Warning

'), 'Warning'); - $this->app->enqueueMessage(JText::sprintf('The %s is not a valid url/path!', $key), 'Warning'); - $this->app->enqueueMessage('
', 'Warning'); + $this->app->enqueueMessage(JText::sprintf('%s, you do not have permission to use EXTERNALCODE feature (so it was removed from the compilation), please contact you system administrator for more info!
(admin access required)', $this->user->get('name')), 'Error'); // remove the placeholder $bucket[$key] = ''; } diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index 72e7e09b2..ab6e28519 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -272,11 +272,18 @@ class Fields extends Structure public $basicEncryptionBuilder = array(); /** - * Advnaced Encryption Builder + * WHMCS Encryption Builder * * @var array */ - public $advancedEncryptionBuilder = array(); + public $whmcsEncryptionBuilder = array(); + + /** + * Medium Encryption Builder + * + * @var array + */ + public $mediumEncryptionBuilder = array(); /** * Get Items Method List String Fix Builder @@ -1330,7 +1337,7 @@ class Fields extends Structure */ public function buildSiteFieldData($view, $field, $set, $type) { - $decode = array('json', 'base64', 'basic_encryption', 'advance_encryption'); + $decode = array('json', 'base64', 'basic_encryption', 'whmcs_encryption', 'medium_encryption'); $textareas = array('textarea', 'editor'); if (isset($this->siteFields[$view][$field]) && ComponentbuilderHelper::checkArray($this->siteFields[$view][$field])) { @@ -2075,10 +2082,16 @@ class Fields extends Structure $this->buildSiteFieldData($viewName, $name, 'basic_encryption', $typeName); break; case 4: - // ADVANCE_ENCRYPTION_VDMKEY - $this->advancedEncryptionBuilder[$viewName][] = $name; + // WHMCS_ENCRYPTION_VDMKEY + $this->whmcsEncryptionBuilder[$viewName][] = $name; // Site settings of each field if needed - $this->buildSiteFieldData($viewName, $name, 'advance_encryption', $typeName); + $this->buildSiteFieldData($viewName, $name, 'whmcs_encryption', $typeName); + break; + case 5: + // MEDIUM_ENCRYPTION_LOCALFILE + $this->mediumEncryptionBuilder[$viewName][] = $name; + // Site settings of each field if needed + $this->buildSiteFieldData($viewName, $name, 'medium_encryption', $typeName); break; default: // JSON_ARRAY_ENCODE diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index 3898f0b1f..1ef1ff464 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -377,7 +377,7 @@ class Interpretation extends Fields return implode(PHP_EOL, $init); } - public function setVDMCryption() + public function setWHMCSCryption() { // make sure we have the correct file if (isset($this->componentData->whmcs_key) && ComponentbuilderHelper::checkString($this->componentData->whmcs_key)) @@ -385,7 +385,7 @@ class Interpretation extends Fields // Get the basic encryption. $basickey = ComponentbuilderHelper::getCryptKey('basic'); // Get the encryption object. - $basic = new FOFEncryptAes($basickey, 128); + $basic = new FOFEncryptAes($basickey); if (!empty($this->componentData->whmcs_key) && $basickey && !is_numeric($this->componentData->whmcs_key) && $this->componentData->whmcs_key === base64_encode(base64_decode($this->componentData->whmcs_key, true))) { // basic decrypt data whmcs_key. @@ -398,9 +398,9 @@ class Interpretation extends Fields $theKey = base64_encode(serialize($key)); // set the script $encrypt[] = "/**"; - $encrypt[] = "* " . $this->setLine(__LINE__) . "VDM Class "; + $encrypt[] = "* " . $this->setLine(__LINE__) . "WHMCS Class "; $encrypt[] = "**/"; - $encrypt[] = PHP_EOL . "class VDM"; + $encrypt[] = PHP_EOL . "class WHMCS"; $encrypt[] = "{"; $encrypt[] = "\tpublic \$_key = false;"; $encrypt[] = "\tpublic \$_is = false;"; @@ -570,85 +570,159 @@ class Interpretation extends Fields { // ###ENCRYPT_FILE### $this->fileContentStatic['###ENCRYPT_FILE###'] = ''; - if ((isset($this->basicEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder)) || (isset($this->advancedEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder)) || $this->componentData->add_license) + if ((isset($this->basicEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder)) || + (isset($this->mediumEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->mediumEncryptionBuilder)) || + (isset($this->whmcsEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->whmcsEncryptionBuilder)) || + $this->componentData->add_license) { - if (isset($this->advancedEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder) || $this->componentData->add_license) + if (isset($this->whmcsEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->whmcsEncryptionBuilder) || $this->componentData->add_license) { - // set advanced encrypt file into place - $target = array('admin' => 'encrypt'); - $done = $this->buildDynamique($target, 'encrypt'); - // the text for the file ###VDM_ENCRYPTION_BODY### - $this->fileContentDynamic['encrypt']['###VDM_ENCRYPTION_BODY###'] = $this->setVDMCryption(); + // set whmcs encrypt file into place + $target = array('admin' => 'whmcs'); + $done = $this->buildDynamique($target, 'whmcs'); + // the text for the file ###WHMCS_ENCRYPTION_BODY### + $this->fileContentDynamic['whmcs']['###WHMCS_ENCRYPTION_BODY###'] = $this->setWHMCSCryption(); // ###ENCRYPT_FILE### - $this->fileContentStatic['###ENCRYPT_FILE###'] = PHP_EOL . "\t\t\tvdm.php"; + $this->fileContentStatic['###WHMCS_ENCRYPT_FILE###'] = PHP_EOL . "\t\t\twhmcs.php"; } // get component name $component = $this->fileContentStatic['###component###']; // set the getCryptKey function to the helper class $function = array(); - if (isset($this->basicEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder)) + // start building the getCryptKey function/class method + $function[] = PHP_EOL . PHP_EOL . "\t/**"; + $function[] = "\t * Get The Encryption Keys"; + $function[] = "\t *"; + $function[] = "\t * @param string \$type The type of key"; + $function[] = "\t * @param string/bool \$default The return value if no key was found"; + $function[] = "\t *"; + $function[] = "\t * @return string On success"; + $function[] = "\t *"; + $function[] = "\t **/"; + $function[] = "\tpublic static function getCryptKey(\$type, \$default = false)"; + $function[] = "\t{"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Get the global params"; + $function[] = "\t\t\$params = JComponentHelper::getParams('com_" . $component . "', true);"; + // add the basic option + if (isset($this->basicEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder)) { - $function[] = PHP_EOL . PHP_EOL . "\tpublic static function getCryptKey(\$type, \$default = null)"; - $function[] = "\t{"; - $function[] = "\t\t//" . $this->setLine(__LINE__) . " Get the global params"; - $function[] = "\t\t\$params = JComponentHelper::getParams('com_" . $component . "', true);"; - $function[] = "\t\tif ('advanced' === \$type)"; - $function[] = "\t\t{"; - $function[] = "\t\t\t\$advanced_key = \$params->get('advanced_key', \$default);"; - $function[] = "\t\t\tif (\$advanced_key)"; - $function[] = "\t\t\t{"; - $function[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " load the file"; - $function[] = "\t\t\t\tJLoader::import( 'vdm', JPATH_COMPONENT_ADMINISTRATOR);"; - $function[] = PHP_EOL . "\t\t\t\t\$the = new VDM(\$advanced_key);"; - $function[] = PHP_EOL . "\t\t\t\treturn \$the->_key;"; - $function[] = "\t\t\t}"; - $function[] = "\t\t}"; - $function[] = "\t\telseif ('basic' === \$type)"; - $function[] = "\t\t{"; - $function[] = "\t\t\t\$basic_key = \$params->get('basic_key', \$default);"; - $function[] = "\t\t\tif (\$basic_key)"; - $function[] = "\t\t\t{"; - $function[] = "\t\t\t\treturn \$basic_key;"; - $function[] = "\t\t\t}"; - $function[] = "\t\t}"; - $function[] = "\t\treturn false;"; - $function[] = "\t}"; - } - elseif (isset($this->advancedEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder)) - { - $function[] = PHP_EOL . PHP_EOL . "\tpublic static function getCryptKey(\$type, \$default = null)"; - $function[] = "\t{"; - $function[] = "\t\tif ('advanced' === \$type)"; - $function[] = "\t\t{"; - $function[] = "\t\t\t//" . $this->setLine(__LINE__) . " Get the global params"; - $function[] = "\t\t\t\$params = JComponentHelper::getParams('com_" . $component . "', true);"; - $function[] = "\t\t\t\$advanced_key = \$params->get('advanced_key', \$default);"; - $function[] = "\t\t\tif (\$advanced_key)"; - $function[] = "\t\t\t{"; - $function[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " load the file"; - $function[] = "\t\t\t\tJLoader::import( 'vdm', JPATH_COMPONENT_ADMINISTRATOR);"; - $function[] = PHP_EOL . "\t\t\t\t\$the = new VDM(\$advanced_key);"; - $function[] = PHP_EOL . "\t\t\t\treturn \$the->_key;"; - $function[] = "\t\t\t}"; - $function[] = "\t\t}"; - $function[] = "\t\treturn false;"; - $function[] = "\t}"; - } - elseif (isset($this->basicEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder)) - { - $function[] = PHP_EOL . PHP_EOL . "\tpublic static function getCryptKey(\$type, \$default = null)"; - $function[] = "\t{"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Basic Encryption Type"; $function[] = "\t\tif ('basic' === \$type)"; $function[] = "\t\t{"; - $function[] = "\t\t\t//" . $this->setLine(__LINE__) . " Get the global params"; - $function[] = "\t\t\t\$params = JComponentHelper::getParams('com_" . $component . "', true);"; $function[] = "\t\t\t\$basic_key = \$params->get('basic_key', \$default);"; - $function[] = "\t\t\tif (\$basic_key)"; + $function[] = "\t\t\tif (self::checkString(\$basic_key))"; $function[] = "\t\t\t{"; $function[] = "\t\t\t\treturn \$basic_key;"; $function[] = "\t\t\t}"; $function[] = "\t\t}"; - $function[] = "\t\treturn false;"; + } + // add the medium option + if (isset($this->mediumEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->mediumEncryptionBuilder)) + { + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Medium Encryption Type"; + $function[] = "\t\tif ('medium' === \$type)"; + $function[] = "\t\t{"; + $function[] = "\t\t\t//" . $this->setLine(__LINE__) . " check if medium key is already loaded."; + $function[] = "\t\t\tif (self::checkString(self::\$mediumCryptKey))"; + $function[] = "\t\t\t{"; + $function[] = "\t\t\t\treturn (self::\$mediumCryptKey !== 'none') ? trim(self::\$mediumCryptKey) : \$default;"; + $function[] = "\t\t\t}"; + $function[] = "\t\t\t//" . $this->setLine(__LINE__) . " get the path to the medium encryption key."; + $function[] = "\t\t\t\$medium_key_path = \$params->get('medium_key_path', null);"; + $function[] = "\t\t\tif (self::checkString(\$medium_key_path))"; + $function[] = "\t\t\t{"; + $function[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " load the key from the file."; + $function[] = "\t\t\t\tif (self::getMediumCryptKey(\$medium_key_path))"; + $function[] = "\t\t\t\t{"; + $function[] = "\t\t\t\t\treturn trim(self::\$mediumCryptKey);"; + $function[] = "\t\t\t\t}"; + $function[] = "\t\t\t}"; + $function[] = "\t\t}"; + } + // add the whmcs option + if (isset($this->whmcsEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->whmcsEncryptionBuilder) || $this->componentData->add_license) + { + $function[] = "\t\t//" . $this->setLine(__LINE__) . " WHMCS Encryption Type"; + $function[] = "\t\tif ('whmcs' === \$type || 'advanced' === \$type)"; + $function[] = "\t\t{"; + $function[] = "\t\t\t\$key = \$params->get('advanced_key', \$default);"; + $function[] = "\t\t\tif (self::checkString(\$key))"; + $function[] = "\t\t\t{"; + $function[] = "\t\t\t\t//" . $this->setLine(__LINE__) . " load the file"; + $function[] = "\t\t\t\tJLoader::import( 'whmcs', JPATH_COMPONENT_ADMINISTRATOR);"; + $function[] = PHP_EOL . "\t\t\t\t\$the = new WHMCS(\$key);"; + $function[] = PHP_EOL . "\t\t\t\treturn \$the->_key;"; + $function[] = "\t\t\t}"; + $function[] = "\t\t}"; + } + // end the function + $function[] = PHP_EOL . "\t\treturn \$default;"; + $function[] = "\t}"; + // set the getMediumCryptKey class/method + if (isset($this->mediumEncryptionBuilder) && ComponentbuilderHelper::checkArray($this->mediumEncryptionBuilder)) + { + $function[] = PHP_EOL . PHP_EOL . "\t/**"; + $function[] = "\t * The Medium Encryption Key"; + $function[] = "\t *"; + $function[] = "\t * @var string/bool"; + $function[] = "\t **/"; + $function[] = "\tprotected static \$mediumCryptKey = false;"; + $function[] = PHP_EOL . "\t/**"; + $function[] = "\t * Get The Medium Encryption Key"; + $function[] = "\t *"; + $function[] = "\t * @param string \$path The path to the medium crypt key folder"; + $function[] = "\t *"; + $function[] = "\t * @return string On success"; + $function[] = "\t *"; + $function[] = "\t **/"; + $function[] = "\tpublic static function getMediumCryptKey(\$path)"; + $function[] = "\t{"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Prep the path a little"; + $function[] = "\t\t\$path = '/'. trim('/', str_replace('//', '/', \$path));"; + $function[] = "\t\t/jimport('joomla.filesystem.folder');"; + $function[] = "\t\t///" . $this->setLine(__LINE__) . " Check if folder exist"; + $function[] = "\t\t/if (!JFolder::exists(\$path))"; + $function[] = "\t\t/{"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Lock key."; + $function[] = "\t\t\tself::\$mediumCryptKey = 'none';"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Set the error message."; + $function[] = "\t\t\tJFactory::getApplication()->enqueueMessage(JText::_('" . $this->langPrefix . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');"; + $function[] = "\t\t\treturn false;"; + $function[] = "\t\t/}"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Create FileName and set file path"; + $function[] = "\t\t\$filePath = \$path.'/.'.md5('medium_crypt_key_file');"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Check if we already have the file set"; + $function[] = "\t\tif ((self::\$mediumCryptKey = @file_get_contents(\$filePath)) !== FALSE)"; + $function[] = "\t\t{"; + $function[] = "\t\t\treturn true;"; + $function[] = "\t\t}"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Set the key for the first time"; + $function[] = "\t\tself::\$mediumCryptKey = self::randomkey(128);"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Open the key file"; + $function[] = "\t\t\$fh = fopen(\$filePath, 'w');"; + $function[] = "\t\tif (!is_resource(\$fh))"; + $function[] = "\t\t{"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Lock key."; + $function[] = "\t\t\tself::\$mediumCryptKey = 'none';"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Set the error message."; + $function[] = "\t\t\tJFactory::getApplication()->enqueueMessage(JText::_('" . $this->langPrefix . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');"; + $function[] = "\t\t\treturn false;"; + $function[] = "\t\t}"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Write to the key file"; + $function[] = "\t\tif (!fwrite(\$fh, self::\$mediumCryptKey))"; + $function[] = "\t\t{"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Close key file."; + $function[] = "\t\t\tfclose(\$fh);"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Lock key."; + $function[] = "\t\t\tself::\$mediumCryptKey = 'none';"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Set the error message."; + $function[] = "\t\t\tJFactory::getApplication()->enqueueMessage(JText::_('" . $this->langPrefix . "_CONFIG_MEDIUM_KEY_PATH_ERROR'), 'Error');"; + $function[] = "\t\t\treturn false;"; + $function[] = "\t\t}"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Close key file."; + $function[] = "\t\tfclose(\$fh);"; + $function[] = "\t\t//" . $this->setLine(__LINE__) . " Key is set."; + $function[] = PHP_EOL . "\t\treturn true;"; $function[] = "\t}"; } // return the help methods @@ -1614,33 +1688,30 @@ class Interpretation extends Fields { if (strpos($get['selection']['select'], $field) !== false) { - if ($array['decode'] === 'json') + if ('json' === $array['decode']) { $if = PHP_EOL . "\t" . $tab . "\tif (" . $this->fileContentStatic['###Component###'] . "Helper::checkJson(" . $string . "->" . $field . "))" . PHP_EOL . "\t" . $tab . "\t{"; // json_decode $decoder = $string . "->" . $field . " = json_decode(" . $string . "->" . $field . ", true);"; - // TODO Use the type of field to prepare it even more for use in the view } - elseif ($array['decode'] === 'base64') + elseif ('base64' === $array['decode']) { $if = PHP_EOL . "\t" . $tab . "\tif (!empty(" . $string . "->" . $field . ") && " . $string . "->" . $field . " === base64_encode(base64_decode(" . $string . "->" . $field . ")))" . PHP_EOL . "\t" . $tab . "\t{"; // base64_decode $decoder = $string . "->" . $field . " = base64_decode(" . $string . "->" . $field . ");"; - // TODO Use the type of field to prepare it even more for use in the view } - elseif ($array['decode'] === 'basic_encryption') + elseif (strpos($array['decode'], '_encryption') !== false) { - $if = PHP_EOL . "\t" . $tab . "\tif (!empty(" . $string . "->" . $field . ") && \$basickey && !is_numeric(" . $string . "->" . $field . ") && " . $string . "->" . $field . " === base64_encode(base64_decode(" . $string . "->" . $field . ", true)))" . PHP_EOL . "\t" . $tab . "\t{"; - // basic decryption - $decoder = $string . "->" . $field . " = rtrim(\$basic->decryptString(" . $string . "->" . $field . "), " . '"\0"' . ");"; - $this->siteDecrypt['basic'][$code] = true; - } - elseif ($array['decode'] === 'advance_encryption') - { - $if = PHP_EOL . "\t" . $tab . "\tif (!empty(" . $string . "->" . $field . ") && \$advancedkey && !is_numeric(" . $string . "->" . $field . ") && " . $string . "->" . $field . " === base64_encode(base64_decode(" . $string . "->" . $field . ", true)))" . PHP_EOL . "\t" . $tab . "\t{"; - // advanced decryption - $decoder = $string . "->" . $field . " = rtrim(\$advanced->decryptString(" . $string . "->" . $field . "), " . '"\0"' . ");"; - $this->siteDecrypt['advanced'][$code] = true; + foreach ($this->cryptionTypes as $cryptionType) + { + if ($cryptionType.'_encryption' === $array['decode']) + { + $if = PHP_EOL . "\t" . $tab . "\tif (!empty(" . $string . "->" . $field . ") && \$".$cryptionType."key && !is_numeric(" . $string . "->" . $field . ") && " . $string . "->" . $field . " === base64_encode(base64_decode(" . $string . "->" . $field . ", true)))" . PHP_EOL . "\t" . $tab . "\t{"; + // set decryption + $decoder = $string . "->" . $field . " = rtrim(\$".$cryptionType."->decryptString(" . $string . "->" . $field . "), " . '"\0"' . ");"; + $this->siteDecrypt[$cryptionType][$code] = true; + } + } } // build decoder string @@ -2093,9 +2164,12 @@ class Interpretation extends Fields { if (ComponentbuilderHelper::checkObject($get)) { - $this->siteDecrypt['basic'][$code] = false; - $this->siteDecrypt['advanced'][$code] = false; - + // set the site decription switches + foreach ($this->cryptionTypes as $cryptionType) + { + $this->siteDecrypt[$cryptionType][$code] = false; + } + // start loadin the get Item $getItem = PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get a db connection."; $getItem .= PHP_EOL . "\t" . $tab . "\t\$db = JFactory::getDbo();"; $getItem .= PHP_EOL . PHP_EOL . $tab . "\t\t//" . $this->setLine(__LINE__) . " Create a new query object."; @@ -2198,27 +2272,20 @@ class Interpretation extends Fields $asBucket[] = $main_get['as']; } } - - if ((isset($this->siteDecrypt['basic'][$code]) && $this->siteDecrypt['basic'][$code]) || (isset($this->siteDecrypt['advanced'][$code]) && $this->siteDecrypt['advanced'][$code])) + // set the scripts + $Component = $this->fileContentStatic['###Component###']; + $script = ''; + foreach ($this->cryptionTypes as $cryptionType) { - $Component = $this->fileContentStatic['###Component###']; - $script = ''; - if (isset($this->siteDecrypt['basic'][$code]) && $this->siteDecrypt['basic'][$code]) + if (isset($this->siteDecrypt[$cryptionType][$code]) && $this->siteDecrypt[$cryptionType][$code]) { - $script .= PHP_EOL . PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the basic encryption."; - $script .= PHP_EOL . "\t" . $tab . "\t\$basickey = " . $Component . "Helper::getCryptKey('basic');"; - $script .= PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the encryption object."; - $script .= PHP_EOL . "\t" . $tab . "\t\$basic = new FOFEncryptAes(\$basickey, 128);"; + $script .= PHP_EOL . PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the ".$cryptionType." encryption."; + $script .= PHP_EOL . "\t" . $tab . "\t\$".$cryptionType."key = ".$Component."Helper::getCryptKey('".$cryptionType."');"; + $script .= PHP_EOL . "\t" . $tab . "\t//".$this->setLine(__LINE__)." Get the encryption object."; + $script .= PHP_EOL . "\t" . $tab . "\t\$".$cryptionType." = new FOFEncryptAes(\$".$cryptionType."key);"; } - if (isset($this->siteDecrypt['advanced'][$code]) && $this->siteDecrypt['advanced'][$code]) - { - $script .= PHP_EOL . PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the advanced encryption."; - $script .= PHP_EOL . "\t" . $tab . "\t\$advancedkey = " . $Component . "Helper::getCryptKey('advanced');"; - $script .= PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the encryption object."; - $script .= PHP_EOL . "\t" . $tab . "\t\$advanced = new FOFEncryptAes(\$advancedkey, 256);"; - } - $getItem = $script . $getItem; } + $getItem = $script . $getItem; // setup Globals $getItem .= $this->setCustomViewGlobals($get->global, '$data', $asBucket, $tab); // setup the custom gets that returns multipal values @@ -2497,8 +2564,11 @@ class Interpretation extends Fields { foreach ($main_get->custom_get as $get) { - $this->siteDecrypt['basic'][$code] = false; - $this->siteDecrypt['advanced'][$code] = false; + // set the site decription switch + foreach ($this->cryptionTypes as $cryptionType) + { + $this->siteDecrypt[$cryptionType][$code] = false; + } // set the method defaults $default = $this->setCustomViewMethodDefaults($get, $code); // build custom method @@ -2676,26 +2746,20 @@ class Interpretation extends Fields $methods .= PHP_EOL . "\t\treturn false;"; $methods .= PHP_EOL . "\t}"; - if ((isset($this->siteDecrypt['basic'][$code]) && $this->siteDecrypt['basic'][$code]) || (isset($this->siteDecrypt['advanced'][$code]) && $this->siteDecrypt['advanced'][$code])) + // set the script if it was found + $Component = $this->fileContentStatic['###Component###']; + $script = ''; + foreach ($this->cryptionTypes as $cryptionType) { - $Component = $this->fileContentStatic['###Component###']; - $script = ''; - if ($this->siteDecrypt['basic'][$code]) + if (isset($this->siteDecrypt[$cryptionType][$code]) && $this->siteDecrypt[$cryptionType][$code]) { - $script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the basic encryption."; - $script .= PHP_EOL . "\t\t\$basickey = " . $Component . "Helper::getCryptKey('basic');"; - $script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the encryption object."; - $script .= PHP_EOL . "\t\t\$basic = new FOFEncryptAes(\$basickey, 128);" . PHP_EOL; + $script .= PHP_EOL . "\t\t//".$this->setLine(__LINE__)." Get the ".$cryptionType." encryption."; + $script .= PHP_EOL . "\t\t\$".$cryptionType."key = ".$Component."Helper::getCryptKey('".$cryptionType."');"; + $script .= PHP_EOL . "\t\t//".$this->setLine(__LINE__)." Get the encryption object."; + $script .= PHP_EOL . "\t\t\$".$cryptionType." = new FOFEncryptAes(\$".$cryptionType."key);".PHP_EOL; } - if ($this->siteDecrypt['advanced'][$code]) - { - $script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the advanced encryption."; - $script .= PHP_EOL . "\t\t\$advancedkey = " . $Component . "Helper::getCryptKey('advanced');"; - $script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the encryption object."; - $script .= PHP_EOL . "\t\t\$advanced = new FOFEncryptAes(\$advancedkey, 256);" . PHP_EOL; - } - $methods = str_replace('###CRYPT###', $script, $methods); } + $methods = str_replace('###CRYPT###', $script, $methods); } // insure the crypt placeholder is removed $methods = str_replace('###CRYPT###', '', $methods); @@ -2802,9 +2866,14 @@ class Interpretation extends Fields public function setCustomViewGetItems(&$get, $code) { $getItem = ''; - $this->siteDecrypt['basic'][$code] = false; - $this->siteDecrypt['advanced'][$code] = false; + // set the site decrypt switch + foreach ($this->cryptionTypes as $cryptionType) + { + $this->siteDecrypt[$cryptionType][$code] = false; + } + // set the component name $Component = $this->fileContentStatic['###Component###']; + // start load the get item if (ComponentbuilderHelper::checkObject($get)) { $getItem .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Insure all item fields are adapted where needed."; @@ -2892,26 +2961,19 @@ class Interpretation extends Fields } } - if ($this->siteDecrypt['basic'][$code] || $this->siteDecrypt['advanced'][$code]) + // set the script if found + $script = ''; + foreach ($this->cryptionTypes as $cryptionType) { - $script = ''; - if ($this->siteDecrypt['basic'][$code]) + if ($this->siteDecrypt[$cryptionType][$code]) { - $script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the basic encryption."; - $script .= PHP_EOL . "\t\t\$basickey = " . $Component . "Helper::getCryptKey('basic');"; + $script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the ".$cryptionType." encryption."; + $script .= PHP_EOL . "\t\t\$".$cryptionType."key = " . $Component . "Helper::getCryptKey('".$cryptionType."');"; $script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the encryption object."; - $script .= PHP_EOL . "\t\t\$basic = new FOFEncryptAes(\$basickey, 128);"; + $script .= PHP_EOL . "\t\t\$".$cryptionType." = new FOFEncryptAes(\$".$cryptionType."key);"; } - if ($this->siteDecrypt['advanced'][$code]) - { - $script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the advanced encryption."; - $script .= PHP_EOL . "\t\t\$advancedkey = " . $Component . "Helper::getCryptKey('advanced');"; - $script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the encryption object."; - $script .= PHP_EOL . "\t\t\$advanced = new FOFEncryptAes(\$advancedkey, 256);"; - } - $getItem = $script . $getItem; } - return $getItem; + return $script.$getItem; } public function setCustomViewDisplayMethod(&$view) @@ -4177,37 +4239,23 @@ class Interpretation extends Fields $script .= PHP_EOL . "\t\t\t}"; } } + // get the component name + $Component = $this->fileContentStatic['###Component###']; // decryption - if ((isset($this->basicEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder[$view])) || (isset($this->advancedEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder[$view]))) + foreach ($this->cryptionTypes as $cryptionType) { - $Component = $this->fileContentStatic['###Component###']; - if (isset($this->basicEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder[$view])) + if (isset($this->{$cryptionType.'EncryptionBuilder'}[$view]) && ComponentbuilderHelper::checkArray($this->{$cryptionType.'EncryptionBuilder'}[$view])) { - $script .= PHP_EOL . PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Get the basic encryption."; - $script .= PHP_EOL . "\t\t\t\$basickey = " . $Component . "Helper::getCryptKey('basic');"; - $script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Get the encryption object."; - $script .= PHP_EOL . "\t\t\t\$basic = new FOFEncryptAes(\$basickey, 128);"; - foreach ($this->basicEncryptionBuilder[$view] as $baseString) + $script .= PHP_EOL . PHP_EOL."\t\t\t//".$this->setLine(__LINE__)." Get the ".$cryptionType." encryption."; + $script .= PHP_EOL . "\t\t\t\$".$cryptionType."key = ".$Component."Helper::getCryptKey('".$cryptionType."');"; + $script .= PHP_EOL . "\t\t\t//".$this->setLine(__LINE__)." Get the encryption object."; + $script .= PHP_EOL . "\t\t\t\$".$cryptionType." = new FOFEncryptAes(\$".$cryptionType."key);"; + foreach ($this->{$cryptionType.'EncryptionBuilder'}[$view] as $baseString) { - $script .= PHP_EOL . PHP_EOL . "\t\t\tif (!empty(\$item->" . $baseString . ") && \$basickey && !is_numeric(\$item->" . $baseString . ") && \$item->" . $baseString . " === base64_encode(base64_decode(\$item->" . $baseString . ", true)))"; + $script .= PHP_EOL . PHP_EOL."\t\t\tif (!empty(\$item->".$baseString.") && \$".$cryptionType."key && !is_numeric(\$item->".$baseString.") && \$item->".$baseString." === base64_encode(base64_decode(\$item->".$baseString.", true)))"; $script .= PHP_EOL . "\t\t\t{"; - $script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " basic decrypt data " . $baseString . "."; - $script .= PHP_EOL . "\t\t\t\t\$item->" . $baseString . " = rtrim(\$basic->decryptString(\$item->" . $baseString . "), " . '"\0"' . ");"; - $script .= PHP_EOL . "\t\t\t}"; - } - } - if (isset($this->advancedEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder[$view])) - { - $script .= PHP_EOL . PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Get the advanced encryption key."; - $script .= PHP_EOL . "\t\t\t\$advancedkey = " . $Component . "Helper::getCryptKey('advanced');"; - $script .= PHP_EOL . "\t\t\t//" . $this->setLine(__LINE__) . " Get the encryption object."; - $script .= PHP_EOL . "\t\t\t\$advanced = new FOFEncryptAes(\$advancedkey, 256);"; - foreach ($this->advancedEncryptionBuilder[$view] as $baseString) - { - $script .= PHP_EOL . PHP_EOL . "\t\t\tif (!empty(\$item->" . $baseString . ") && \$advancedkey && !is_numeric(\$item->" . $baseString . ") && \$item->" . $baseString . " === base64_encode(base64_decode(\$item->" . $baseString . ", true)))"; - $script .= PHP_EOL . "\t\t\t{"; - $script .= PHP_EOL . "\t\t\t\t//" . $this->setLine(__LINE__) . " advanced decrypt data " . $baseString . "."; - $script .= PHP_EOL . "\t\t\t\t\$item->" . $baseString . " = rtrim(\$advanced->decryptString(\$item->" . $baseString . "), " . '"\0"' . ");"; + $script .= PHP_EOL . "\t\t\t\t//".$this->setLine(__LINE__)." ".$cryptionType." decrypt data ".$baseString."."; + $script .= PHP_EOL . "\t\t\t\t\$item->".$baseString." = rtrim(\$".$cryptionType."->decryptString(\$item->".$baseString."), " . '"\0"' . ");"; $script .= PHP_EOL . "\t\t\t}"; } } @@ -4285,36 +4333,21 @@ class Interpretation extends Fields } } // turn string into encrypted string - if ((isset($this->basicEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder[$view])) || (isset($this->advancedEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder[$view]))) + $Component = $this->fileContentStatic['###Component###']; + foreach ($this->cryptionTypes as $cryptionType) { - $Component = $this->fileContentStatic['###Component###']; - if (isset($this->basicEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->basicEncryptionBuilder[$view])) + if (isset($this->{$cryptionType.'EncryptionBuilder'}[$view]) && ComponentbuilderHelper::checkArray($this->{$cryptionType.'EncryptionBuilder'}[$view])) { - $script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the basic encryption key."; - $script .= PHP_EOL . "\t\t\$basickey = " . $Component . "Helper::getCryptKey('basic');"; + $script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the ".$cryptionType." encryption key."; + $script .= PHP_EOL . "\t\t\$".$cryptionType."key = " . $Component . "Helper::getCryptKey('".$cryptionType."');"; $script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the encryption object"; - $script .= PHP_EOL . "\t\t\$basic = new FOFEncryptAes(\$basickey, 128);"; - foreach ($this->basicEncryptionBuilder[$view] as $baseString) + $script .= PHP_EOL . "\t\t\$".$cryptionType." = new FOFEncryptAes(\$".$cryptionType."key);"; + foreach ($this->{$cryptionType.'EncryptionBuilder'}[$view] as $baseString) { $script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Encrypt data " . $baseString . "."; - $script .= PHP_EOL . "\t\tif (isset(\$data['" . $baseString . "']) && \$basickey)"; + $script .= PHP_EOL . "\t\tif (isset(\$data['" . $baseString . "']) && \$".$cryptionType."key)"; $script .= PHP_EOL . "\t\t{"; - $script .= PHP_EOL . "\t\t\t\$data['" . $baseString . "'] = \$basic->encryptString(\$data['" . $baseString . "']);"; - $script .= PHP_EOL . "\t\t}"; - } - } - if (isset($this->advancedEncryptionBuilder[$view]) && ComponentbuilderHelper::checkArray($this->advancedEncryptionBuilder[$view])) - { - $script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the advanced encryption key."; - $script .= PHP_EOL . "\t\t\$advancedkey = " . $Component . "Helper::getCryptKey('advanced');"; - $script .= PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Get the encryption object"; - $script .= PHP_EOL . "\t\t\$advanced = new FOFEncryptAes(\$advancedkey, 256);"; - foreach ($this->advancedEncryptionBuilder[$view] as $baseString) - { - $script .= PHP_EOL . PHP_EOL . "\t\t//" . $this->setLine(__LINE__) . " Encrypt data " . $baseString . "."; - $script .= PHP_EOL . "\t\tif (isset(\$data['" . $baseString . "']) && \$advancedkey)"; - $script .= PHP_EOL . "\t\t{"; - $script .= PHP_EOL . "\t\t\t\$data['" . $baseString . "'] = \$advanced->encryptString(\$data['" . $baseString . "']);"; + $script .= PHP_EOL . "\t\t\t\$data['" . $baseString . "'] = \$".$cryptionType."->encryptString(\$data['" . $baseString . "']);"; $script .= PHP_EOL . "\t\t}"; } } @@ -11593,8 +11626,10 @@ class Interpretation extends Fields // add the fix if this view has the need for it $fix = ''; // encryption switches - $basicCrypt = false; - $advancedCrypt = false; + foreach ($this->cryptionTypes as $cryptionType) + { + ${$cryptionType.'Crypt'} = false; + } // setup correct core target $coreLoad = false; if (isset($this->permissionCore[$view])) @@ -11662,9 +11697,15 @@ class Interpretation extends Fields $suffix_decode = ''; break; case 4: - // ADVANCE_ENCRYPTION_VDMKEY - $decode = '$advanced->decryptString'; - $advancedCrypt = true; + // WHMCS_ENCRYPTION_WHMCS + $decode = '$whmcs->decryptString'; + $whmcsCrypt = true; + $suffix_decode = ''; + break; + case 5: + // MEDIUM_ENCRYPTION_LOCALFILE + $decode = '$medium->decryptString'; + $mediumCrypt = true; $suffix_decode = ''; break; default: @@ -11740,13 +11781,19 @@ class Interpretation extends Fields $fix .= PHP_EOL . "\t" . $tab . "\t\t\tif (\$basickey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))"; $fix .= PHP_EOL . "\t" . $tab . "\t\t\t{"; } - if ($item['method'] == 4) + elseif ($item['method'] == 5) { $taber = "\t"; - $fix .= PHP_EOL . "\t" . $tab . "\t\t\tif (\$advancedkey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))"; + $fix .= PHP_EOL . "\t" . $tab . "\t\t\tif (\$mediumkey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))"; $fix .= PHP_EOL . "\t" . $tab . "\t\t\t{"; } - if ($item['method'] == 3 || $item['method'] == 4) + elseif ($item['method'] == 4) + { + $taber = "\t"; + $fix .= PHP_EOL . "\t" . $tab . "\t\t\tif (\$whmcskey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))"; + $fix .= PHP_EOL . "\t" . $tab . "\t\t\t{"; + } + if ($item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5) { $fix .= PHP_EOL . "\t" . $tab . "\t\t\t\t//" . $this->setLine(__LINE__) . " decrypt " . $item['name']; } @@ -11853,27 +11900,20 @@ class Interpretation extends Fields // add custom php to getitems method $fix .= $this->getCustomScriptBuilder('php_getitems', $view, PHP_EOL . PHP_EOL . $tab); - if ($basicCrypt) + // load the encryption object if needed + $script = ''; + foreach ($this->cryptionTypes as $cryptionType) { - $script = PHP_EOL . PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the basic encryption key."; - $script .= PHP_EOL . "\t" . $tab . "\t\$basickey = " . $Component . "Helper::getCryptKey('basic');"; - $script .= PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the encryption object."; - $script .= PHP_EOL . "\t" . $tab . "\t\$basic = new FOFEncryptAes(\$basickey, 128);"; - // add the encryption script - $fix = $script . $fix; + if (${$cryptionType.'Crypt'}) + { + $script .= PHP_EOL . PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the ".$cryptionType." encryption key."; + $script .= PHP_EOL . "\t" . $tab . "\t\$".$cryptionType."key = " . $Component . "Helper::getCryptKey('".$cryptionType."');"; + $script .= PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the encryption object."; + $script .= PHP_EOL . "\t" . $tab . "\t\$".$cryptionType." = new FOFEncryptAes(\$".$cryptionType."key);"; + } } - - if ($advancedCrypt) - { - $script = PHP_EOL . PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the advanced encryption key."; - $script .= PHP_EOL . "\t" . $tab . "\t\$advancedkey = " . $Component . "Helper::getCryptKey('advanced');"; - $script .= PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . " Get the encryption object."; - $script .= PHP_EOL . "\t" . $tab . "\t\$advanced = new FOFEncryptAes(\$advancedkey, 256);"; - // add the encryption script - $fix = $script . $fix; - } - - return $fix; + // add the encryption script + return $script . $fix; } public function setSelectionTranslationFix($views, $Component, $tab = '') @@ -12726,6 +12766,18 @@ class Interpretation extends Fields $nameList = ComponentbuilderHelper::safeString($menu['name']); $nameUpper = ComponentbuilderHelper::safeString($menu['name'], 'U'); $this->langContent['adminsys'][$lang . '_' . $nameUpper] = $menu['name']; + // sanitize url + if (strpos($menu['link'], 'http') === false) + { + $menu['link'] = str_replace('/administrator/index.php?', '', $menu['link']); + $menu['link'] = str_replace('administrator/index.php?', '', $menu['link']); + // check if the index is still there + if (strpos($menu['link'], 'index.php?') !== false) + { + $menu['link'] = str_replace('/index.php?', '', $menu['link']); + $menu['link'] = str_replace('index.php?', '', $menu['link']); + } + } // urlencode $menu['link'] = htmlspecialchars($menu['link'], ENT_XML1, 'UTF-8'); // add custom menu @@ -12747,6 +12799,18 @@ class Interpretation extends Fields $nameList = ComponentbuilderHelper::safeString($menu['name']); $nameUpper = ComponentbuilderHelper::safeString($menu['name'], 'U'); $this->langContent['adminsys'][$lang . '_' . $nameUpper] = $menu['name']; + // sanitize url + if (strpos($menu['link'], 'http') === false) + { + $menu['link'] = str_replace('/administrator/index.php?', '', $menu['link']); + $menu['link'] = str_replace('administrator/index.php?', '', $menu['link']); + // check if the index is still there + if (strpos($menu['link'], 'index.php?') !== false) + { + $menu['link'] = str_replace('/index.php?', '', $menu['link']); + $menu['link'] = str_replace('index.php?', '', $menu['link']); + } + } // urlencode $menu['link'] = htmlspecialchars($menu['link'], ENT_XML1, 'UTF-8'); // add custom menu @@ -14280,25 +14344,70 @@ function vdm_dkim() { */ public function setEncryptionConfigFieldsets($lang) { + // enable the loading of dynamic field sets + $dynamicAddFields = array(); // Add encryption if needed - if ((isset($this->basicEncryption) && $this->basicEncryption) || (isset($this->advancedEncryption) && $this->advancedEncryption)) + if ((isset($this->basicEncryption) && $this->basicEncryption) || + (isset($this->whmcsEncryption) && $this->whmcsEncryption) || + (isset($this->mediumEncryption) && $this->mediumEncryption) || + $this->componentData->add_license || + (isset($this->configFieldSetsCustomField['Encryption Settings']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Encryption Settings']))) { + $dynamicAddFields[] = "Encryption Settings"; // start building field set for encryption functions $this->configFieldSets[] = "\tconfigFieldSets[] = "\t\t" . 'name="encryption_config"'; $this->configFieldSets[] = "\t\t" . 'label="' . $lang . '_ENCRYPTION_LABEL"'; $this->configFieldSets[] = "\t\t" . 'description="' . $lang . '_ENCRYPTION_DESC">'; + // set tab lang - $this->langContent[$this->lang][$lang . '_ENCRYPTION_LABEL'] = "Encryption Settings"; - $this->langContent[$this->lang][$lang . '_ENCRYPTION_DESC'] = "The encryption key for the field encryption is set here."; + if (((isset($this->basicEncryption) && $this->basicEncryption) || + (isset($this->mediumEncryption) && $this->mediumEncryption) || + (isset($this->whmcsEncryption) && $this->whmcsEncryption)) && + $this->componentData->add_license && $this->componentData->license_type == 3) + { + $this->langContent[$this->lang][$lang . '_ENCRYPTION_LABEL'] = "License & Encryption Settings"; + $this->langContent[$this->lang][$lang . '_ENCRYPTION_DESC'] = "The license & encryption keys are set here."; + // add the next dynamic option + $dynamicAddFields[] = "License & Encryption Settings"; + } + elseif (((isset($this->basicEncryption) && $this->basicEncryption) || + (isset($this->mediumEncryption) && $this->mediumEncryption) || + (isset($this->whmcsEncryption) && $this->whmcsEncryption)) && + $this->componentData->add_license && $this->componentData->license_type == 2) + { + $this->langContent[$this->lang][$lang . '_ENCRYPTION_LABEL'] = "Update & Encryption Settings"; + $this->langContent[$this->lang][$lang . '_ENCRYPTION_DESC'] = "The update & encryption keys are set here."; + // add the next dynamic option + $dynamicAddFields[] = "Update & Encryption Settings"; + } + elseif ($this->componentData->add_license && $this->componentData->license_type == 3) + { + $this->langContent[$this->lang][$lang . '_ENCRYPTION_LABEL'] = "License Settings"; + $this->langContent[$this->lang][$lang . '_ENCRYPTION_DESC'] = "The license key is set here."; + // add the next dynamic option + $dynamicAddFields[] = "License Settings"; + } + elseif ($this->componentData->add_license && $this->componentData->license_type == 2) + { + $this->langContent[$this->lang][$lang . '_ENCRYPTION_LABEL'] = "Update Settings"; + $this->langContent[$this->lang][$lang . '_ENCRYPTION_DESC'] = "The update key is set here."; + // add the next dynamic option + $dynamicAddFields[] = "Update Settings"; + } + else + { + $this->langContent[$this->lang][$lang . '_ENCRYPTION_LABEL'] = "Encryption Settings"; + $this->langContent[$this->lang][$lang . '_ENCRYPTION_DESC'] = "The encryption key for the field encryption is set here."; + } if (isset($this->basicEncryption) && $this->basicEncryption) { // set field lang - $this->langContent[$this->lang][$lang . '_BASIC_KEY_LABEL'] = "Basic Key (basic encryption)"; + $this->langContent[$this->lang][$lang . '_BASIC_KEY_LABEL'] = "Basic Key"; $this->langContent[$this->lang][$lang . '_BASIC_KEY_DESC'] = "Set the basic local key here."; $this->langContent[$this->lang][$lang . '_BASIC_KEY_NOTE_LABEL'] = "Basic Encryption"; - $this->langContent[$this->lang][$lang . '_BASIC_KEY_NOTE_DESC'] = "When using the basic encryption please use a 32 character passphrase.
Never change this passphrase once it is set! DATA WILL GET CORRUPTED IF YOU DO!"; + $this->langContent[$this->lang][$lang . '_BASIC_KEY_NOTE_DESC'] = "When using the basic encryption please use set a 32 character passphrase.
Never change this passphrase once it is set! DATA WILL GET CORRUPTED IF YOU DO!"; // set the field $this->configFieldSets[] = "\t\t" . ''; $this->configFieldSets[] = "\t\t" . 'configFieldSets[] = "\t\t\t" . 'size="60"'; $this->configFieldSets[] = "\t\t\t" . 'default=""'; $this->configFieldSets[] = "\t\t/>"; - } - - if (isset($this->advancedEncryption) && $this->advancedEncryption) + } + if (isset($this->mediumEncryption) && $this->mediumEncryption) { // set field lang - $this->langContent[$this->lang][$lang . '_VDM_KEY_LABEL'] = "Advanced Key (advanced encryption)"; - $this->langContent[$this->lang][$lang . '_VDM_KEY_DESC'] = "Add the advanced key here."; - $this->langContent[$this->lang][$lang . '_VDM_KEY_NOTE_LABEL'] = "Advanced Encryption"; - $this->langContent[$this->lang][$lang . '_VDM_KEY_NOTE_DESC'] = "When using the advanced encryption you need to get an advanced key from " . $this->componentData->companyname . ".
Never change this advanced key once it is set! DATA WILL GET CORRUPTED IF YOU DO!"; + $this->langContent[$this->lang][$lang . '_MEDIUM_KEY_LABEL'] = "Medium Key (Path)"; + $this->langContent[$this->lang][$lang . '_MEDIUM_KEY_DESC'] = "Set the full path to where the key file must be stored. Make sure it is behind the root folder of your website, so that it is not public accessible."; + $this->langContent[$this->lang][$lang . '_MEDIUM_KEY_NOTE_LABEL'] = "Medium Encryption"; + $this->langContent[$this->lang][$lang . '_MEDIUM_KEY_NOTE_DESC'] = "When using the medium encryption option, the system generates its own key and stores it in a file at the folder/path you set here.
Never change this key once it is set, or remove the key file! DATA WILL GET CORRUPTED IF YOU DO! Also make sure the full path to where the the key file should be stored, is behind the root folder of your website/system, so that it is not public accessible. Making a backup of this key file over a secure connection is recommended!"; // set the field - $this->configFieldSets[] = "\t\t" . ''; - $this->configFieldSets[] = "\t\t" . 'configFieldSets[] = "\t\t" . ''; + $this->configFieldSets[] = "\t\t" . 'configFieldSets[] = "\t\t\t" . 'type="text"'; - $this->configFieldSets[] = "\t\t\t" . 'label="' . $lang . '_VDM_KEY_LABEL"'; - $this->configFieldSets[] = "\t\t\t" . 'description="' . $lang . '_VDM_KEY_DESC"'; + $this->configFieldSets[] = "\t\t\t" . 'label="' . $lang . '_MEDIUM_KEY_LABEL"'; + $this->configFieldSets[] = "\t\t\t" . 'description="' . $lang . '_MEDIUM_KEY_DESC"'; + $this->configFieldSets[] = "\t\t\t" . 'size="160"'; + $this->configFieldSets[] = "\t\t\t" . 'filter="PATH"'; + $this->configFieldSets[] = "\t\t\t" . 'hint="/home/user/hiddenfolder123/"'; + $this->configFieldSets[] = "\t\t\t" . 'default=""'; + $this->configFieldSets[] = "\t\t/>"; + // set some error message if the path does not exist + $this->langContent[$this->lang][$lang . '_MEDIUM_KEY_PATH_ERROR'] = "Medium key path (for encryption of various fields) does not exist, or is not writable. Please check the path and update it in the global option of this component."; + } + if (isset($this->whmcsEncryption) && $this->whmcsEncryption || $this->componentData->add_license) + { + // set field lang label and description + if ($this->componentData->add_license && $this->componentData->license_type == 3) + { + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_LABEL'] = "License Key"; + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_DESC'] = "Add the license key you recieved from " . $this->componentData->companyname . " here."; + } + elseif ($this->componentData->add_license && $this->componentData->license_type == 2) + { + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_LABEL'] = "Update Key"; + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_DESC'] = "Add the update key you recieved from " . $this->componentData->companyname . " here."; + } + else + { + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_LABEL'] = "WHMCS Key"; + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_DESC'] = "Add the key you recieved from " . $this->componentData->companyname . " here."; + } + // ajust the notice based on license + if (isset($this->whmcsEncryption) && $this->whmcsEncryption) + { + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_NOTE_LABEL'] = "Field Encryption (whmcs)"; + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_NOTE_DESC'] = "When using this (whmcs) encryption you need to get a key from " . $this->componentData->companyname . ".
Never change this key once it is set! DATA WILL GET CORRUPTED IF YOU DO!"; + } + else + { + if ($this->componentData->license_type == 3) + { + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_NOTE_LABEL'] = "Your License Key"; + } + elseif ($this->componentData->license_type == 2) + { + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_NOTE_LABEL'] = "Your Update Key"; + } + else + { + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_NOTE_LABEL'] = "Your Key (whmcs)"; + } + $this->langContent[$this->lang][$lang . '_WHMCS_KEY_NOTE_DESC'] = "You need to get this key from " . $this->componentData->companyname . "."; + } + // set the fields + $this->configFieldSets[] = "\t\t" . ''; + $this->configFieldSets[] = "\t\t" . 'configFieldSets[] = "\t\t\t" . 'type="text"'; + $this->configFieldSets[] = "\t\t\t" . 'label="' . $lang . '_WHMCS_KEY_LABEL"'; + $this->configFieldSets[] = "\t\t\t" . 'description="' . $lang . '_WHMCS_KEY_DESC"'; $this->configFieldSets[] = "\t\t\t" . 'size="60"'; $this->configFieldSets[] = "\t\t\t" . 'default=""'; $this->configFieldSets[] = "\t\t/>"; } - // add custom Encryption Settings fields - if (isset($this->configFieldSetsCustomField['Encryption Settings']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Encryption Settings'])) + // load the dynamic field sets + foreach ($dynamicAddFields as $dynamicAddField) { - $this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Encryption Settings']); - unset($this->configFieldSetsCustomField['Encryption Settings']); + // add custom Encryption Settings fields + if (isset($this->configFieldSetsCustomField[$dynamicAddField]) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField[$dynamicAddField])) + { + $this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField[$dynamicAddField]); + unset($this->configFieldSetsCustomField[$dynamicAddField]); + } } // close that fieldset $this->configFieldSets[] = "\t"; diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index 21315c31c..519361895 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -3898,18 +3898,29 @@ abstract class ComponentbuilderHelper return implode($key); } - public static function getCryptKey($type, $default = null) + /** + * Get The Encryption Keys + * + * @param string $type The type of key + * @param string/bool $default The return value if no key was found + * + * @return string On success + * + **/ + public static function getCryptKey($type, $default = false) { + // Get the global params + $params = JComponentHelper::getParams('com_componentbuilder', true); + // Basic Encryption Type if ('basic' === $type) { - // Get the global params - $params = JComponentHelper::getParams('com_componentbuilder', true); $basic_key = $params->get('basic_key', $default); - if ($basic_key) + if (self::checkString($basic_key)) { return $basic_key; } } - return false; + + return $default; } } diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 03d0f1a0e..0e3ae827b 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -2258,8 +2258,8 @@ COM_COMPONENTBUILDER_CONFIG_BACKUP_PACKAGE_NAME_HINT="JCB_Backup_[YEAR]_[MONTH]_ COM_COMPONENTBUILDER_CONFIG_BACKUP_PACKAGE_NAME_LABEL="Package Name" COM_COMPONENTBUILDER_CONFIG_BACKUP_PACKAGE_NAME_MESSAGE="Error! Please add name here." COM_COMPONENTBUILDER_CONFIG_BASIC_KEY_DESC="Set the basic local key here." -COM_COMPONENTBUILDER_CONFIG_BASIC_KEY_LABEL="Basic Key (basic encryption)" -COM_COMPONENTBUILDER_CONFIG_BASIC_KEY_NOTE_DESC="When using the basic encryption please use a 32 character passphrase.
Never change this passphrase once it is set! DATA WILL GET CORRUPTED IF YOU DO!" +COM_COMPONENTBUILDER_CONFIG_BASIC_KEY_LABEL="Basic Key" +COM_COMPONENTBUILDER_CONFIG_BASIC_KEY_NOTE_DESC="When using the basic encryption please use set a 32 character passphrase.
Never change this passphrase once it is set! DATA WILL GET CORRUPTED IF YOU DO!" COM_COMPONENTBUILDER_CONFIG_BASIC_KEY_NOTE_LABEL="Basic Encryption" COM_COMPONENTBUILDER_CONFIG_CHECK_TIMER_DESC="Set the intervals for the auto checkin fuction of tables that checks out the items to an user." COM_COMPONENTBUILDER_CONFIG_CHECK_TIMER_LABEL="Check in timer" @@ -3181,6 +3181,7 @@ COM_COMPONENTBUILDER_DASHBOARD_FIELDTYPES="Fieldtypes

" COM_COMPONENTBUILDER_DASHBOARD_FIELDTYPES_CATID="Category  For
Fieldtypes" COM_COMPONENTBUILDER_DASHBOARD_FIELDTYPE_ADD="Add Fieldtype

" COM_COMPONENTBUILDER_DASHBOARD_FIELD_ADD="Add Field

" +COM_COMPONENTBUILDER_DASHBOARD_GETSNIPPETS="Get Snippets

" COM_COMPONENTBUILDER_DASHBOARD_HELP_DOCUMENTS="Help Documents

" COM_COMPONENTBUILDER_DASHBOARD_HELP_DOCUMENT_ADD="Add Help Document

" COM_COMPONENTBUILDER_DASHBOARD_JOOMLA_COMPONENTS="Joomla Components

" @@ -3718,9 +3719,8 @@ COM_COMPONENTBUILDER_FIELD_ADD_JAVASCRIPT_VIEWS_FOOTER="Add Javascript Views Foo COM_COMPONENTBUILDER_FIELD_ADD_JAVASCRIPT_VIEWS_FOOTER_LABEL="Add JavaScript (views-footer)" COM_COMPONENTBUILDER_FIELD_ADD_JAVASCRIPT_VIEW_FOOTER="Add Javascript View Footer" COM_COMPONENTBUILDER_FIELD_ADD_JAVASCRIPT_VIEW_FOOTER_LABEL="Add JavaScript (view-footer)" -COM_COMPONENTBUILDER_FIELD_ADVANCE_ENCRYPTION_WHMCSKEY="Advance Encryption (WHMCS-key)" COM_COMPONENTBUILDER_FIELD_BASESIXTY_FOUR="base64" -COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALKEY="Basic Encryption (local-key)" +COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALDBKEY="Basic Encryption (local-DB-key)" COM_COMPONENTBUILDER_FIELD_BIGINT="BIGINT" COM_COMPONENTBUILDER_FIELD_CATID_DESCRIPTION="select one of the following categories" COM_COMPONENTBUILDER_FIELD_CATID_LABEL="Category" @@ -3789,6 +3789,7 @@ COM_COMPONENTBUILDER_FIELD_JSON="JSON" COM_COMPONENTBUILDER_FIELD_KEY="KEY" COM_COMPONENTBUILDER_FIELD_LONGTEXT="LONGTEXT" COM_COMPONENTBUILDER_FIELD_MEDIUMTEXT="MEDIUMTEXT" +COM_COMPONENTBUILDER_FIELD_MEDIUM_ENCRYPTION_LOCALFILEKEY="Medium Encryption (local-file-key)" COM_COMPONENTBUILDER_FIELD_MODIFIED_BY_DESC="The last user that modified this Field." COM_COMPONENTBUILDER_FIELD_MODIFIED_BY_LABEL="Modified By" COM_COMPONENTBUILDER_FIELD_MODIFIED_DATE_DESC="The date this Field was modified." @@ -3861,6 +3862,7 @@ COM_COMPONENTBUILDER_FIELD_UNIQUE_KEY="UNIQUE KEY" COM_COMPONENTBUILDER_FIELD_VARCHAR="VARCHAR" COM_COMPONENTBUILDER_FIELD_VERSION_DESC="A count of the number of times this Field has been revised." COM_COMPONENTBUILDER_FIELD_VERSION_LABEL="Revision" +COM_COMPONENTBUILDER_FIELD_WHMCSKEY_ENCRYPTION="WHMCS-key Encryption" COM_COMPONENTBUILDER_FIELD_XML="Xml" COM_COMPONENTBUILDER_FIELD_XML_DESCRIPTION="Text Area" COM_COMPONENTBUILDER_FIELD_XML_HINT="Field XML Go Here" @@ -5373,7 +5375,7 @@ COM_COMPONENTBUILDER_SERVER_PRIVATE="Private" COM_COMPONENTBUILDER_SERVER_PRIVATE_DESCRIPTION="Set the path to the private key." COM_COMPONENTBUILDER_SERVER_PRIVATE_HINT="/home/username/.ssh/id_rsa" COM_COMPONENTBUILDER_SERVER_PRIVATE_KEY="Private Key" -COM_COMPONENTBUILDER_SERVER_PRIVATE_KEY_DESCRIPTION="Add your private key here! Yes this field in encrypted in the DB, but if your DB gets compromised this key must also be considered compromised. The system path option is considered more secure and seen as best practice." +COM_COMPONENTBUILDER_SERVER_PRIVATE_KEY_DESCRIPTION="Add your private key here! Yes this field is encrypted in the DB, but if your DB gets compromised this key must also be considered compromised! The system path option is considered more secure and seen as best practice." COM_COMPONENTBUILDER_SERVER_PRIVATE_KEY_FILE_PATH="Private Key - File Path" COM_COMPONENTBUILDER_SERVER_PRIVATE_KEY_HINT="-----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQDPF9uyDuHtD+sCYBaEIV34uAc+eRa62souVUcmsVwKUUBbk7sY diff --git a/admin/layouts/server/linked_components_fullwidth.php b/admin/layouts/server/linked_components_fullwidth.php index 2e873c70e..65ab05ca8 100644 --- a/admin/layouts/server/linked_components_fullwidth.php +++ b/admin/layouts/server/linked_components_fullwidth.php @@ -28,7 +28,7 @@ defined('_JEXEC') or die('Restricted access'); // set the defaults -$items = $displayData->wamlinked_components; +$items = $displayData->wanlinked_components; $user = JFactory::getUser(); $id = $displayData->item->id; $edit = "index.php?option=com_componentbuilder&view=joomla_components&task=joomla_component.edit"; diff --git a/admin/models/componentbuilder.php b/admin/models/componentbuilder.php index 910bb317a..7e768ddc7 100644 --- a/admin/models/componentbuilder.php +++ b/admin/models/componentbuilder.php @@ -43,7 +43,7 @@ class ComponentbuilderModelComponentbuilder extends JModelList $icons = array(); // view groups array $viewGroups = array( - 'main' => array('png.compiler', 'png.joomla_component.add', 'png.joomla_components', 'png.admin_view.add', 'png.admin_views', 'png.custom_admin_view.add', 'png.custom_admin_views', 'png.site_view.add', 'png.site_views', 'png.template.add', 'png.templates', 'png.layout.add', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.libraries', 'png.snippet.add', 'png.snippets', 'png.field.add', 'png.fields', 'png.fields.catid', 'png.fieldtype.add', 'png.fieldtypes', 'png.fieldtypes.catid', 'png.language_translations', 'png.servers', 'png.help_document.add', 'png.help_documents') + 'main' => array('png.compiler', 'png.joomla_component.add', 'png.joomla_components', 'png.admin_view.add', 'png.admin_views', 'png.custom_admin_view.add', 'png.custom_admin_views', 'png.site_view.add', 'png.site_views', 'png.template.add', 'png.templates', 'png.layout.add', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.libraries', 'png.snippet.add', 'png.snippets', 'png||getsnippets||index.php?option=com_componentbuilder&view=get_snippets', 'png.field.add', 'png.fields', 'png.fields.catid', 'png.fieldtype.add', 'png.fieldtypes', 'png.fieldtypes.catid', 'png.language_translations', 'png.servers', 'png.help_document.add', 'png.help_documents') ); // view access array $viewAccess = array( diff --git a/admin/models/fields.php b/admin/models/fields.php index 6666d984b..187acf80e 100644 --- a/admin/models/fields.php +++ b/admin/models/fields.php @@ -239,8 +239,9 @@ class ComponentbuilderModelFields extends JModelList 0 => 'COM_COMPONENTBUILDER_FIELD_DEFAULT', 1 => 'COM_COMPONENTBUILDER_FIELD_JSON', 2 => 'COM_COMPONENTBUILDER_FIELD_BASESIXTY_FOUR', - 3 => 'COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALKEY', - 4 => 'COM_COMPONENTBUILDER_FIELD_ADVANCE_ENCRYPTION_WHMCSKEY' + 3 => 'COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALDBKEY', + 5 => 'COM_COMPONENTBUILDER_FIELD_MEDIUM_ENCRYPTION_LOCALFILEKEY', + 4 => 'COM_COMPONENTBUILDER_FIELD_WHMCSKEY_ENCRYPTION' ); // Now check if value is found in this array if (isset($storeArray[$value]) && ComponentbuilderHelper::checkString($storeArray[$value])) diff --git a/admin/models/fieldtype.php b/admin/models/fieldtype.php index 9835abd82..83d087812 100644 --- a/admin/models/fieldtype.php +++ b/admin/models/fieldtype.php @@ -304,8 +304,9 @@ class ComponentbuilderModelFieldtype extends JModelAdmin 0 => 'COM_COMPONENTBUILDER_FIELD_DEFAULT', 1 => 'COM_COMPONENTBUILDER_FIELD_JSON', 2 => 'COM_COMPONENTBUILDER_FIELD_BASESIXTY_FOUR', - 3 => 'COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALKEY', - 4 => 'COM_COMPONENTBUILDER_FIELD_ADVANCE_ENCRYPTION_WHMCSKEY' + 3 => 'COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALDBKEY', + 5 => 'COM_COMPONENTBUILDER_FIELD_MEDIUM_ENCRYPTION_LOCALFILEKEY', + 4 => 'COM_COMPONENTBUILDER_FIELD_WHMCSKEY_ENCRYPTION' ); // Now check if value is found in this array if (isset($storeArray[$value]) && ComponentbuilderHelper::checkString($storeArray[$value])) diff --git a/admin/models/forms/field.xml b/admin/models/forms/field.xml index 0011745e7..8a17c1fd1 100644 --- a/admin/models/forms/field.xml +++ b/admin/models/forms/field.xml @@ -327,8 +327,9 @@ - - + + +
+ hint="COM_COMPONENTBUILDER_SERVER_PRIVATE_KEY_HINT" + required="true" /> diff --git a/admin/models/joomla_component.php b/admin/models/joomla_component.php index 87567bb34..1cd2effc2 100644 --- a/admin/models/joomla_component.php +++ b/admin/models/joomla_component.php @@ -207,7 +207,7 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin // Get the basic encryption. $basickey = ComponentbuilderHelper::getCryptKey('basic'); // Get the encryption object. - $basic = new FOFEncryptAes($basickey, 128); + $basic = new FOFEncryptAes($basickey); if (!empty($item->whmcs_key) && $basickey && !is_numeric($item->whmcs_key) && $item->whmcs_key === base64_encode(base64_decode($item->whmcs_key, true))) { @@ -1346,7 +1346,7 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin // Get the basic encryption key. $basickey = ComponentbuilderHelper::getCryptKey('basic'); // Get the encryption object - $basic = new FOFEncryptAes($basickey, 128); + $basic = new FOFEncryptAes($basickey); // Encrypt data whmcs_key. if (isset($data['whmcs_key']) && $basickey) diff --git a/admin/models/joomla_components.php b/admin/models/joomla_components.php index c37258dd4..7185358c6 100644 --- a/admin/models/joomla_components.php +++ b/admin/models/joomla_components.php @@ -1707,7 +1707,7 @@ class ComponentbuilderModelJoomla_components extends JModelList // Get the basic encryption key. $basickey = ComponentbuilderHelper::getCryptKey('basic'); // Get the encryption object. - $basic = new FOFEncryptAes($basickey, 128); + $basic = new FOFEncryptAes($basickey); // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) diff --git a/admin/models/server.php b/admin/models/server.php index 4625aae10..ded405619 100644 --- a/admin/models/server.php +++ b/admin/models/server.php @@ -98,7 +98,7 @@ class ComponentbuilderModelServer extends JModelAdmin // Get the basic encryption. $basickey = ComponentbuilderHelper::getCryptKey('basic'); // Get the encryption object. - $basic = new FOFEncryptAes($basickey, 128); + $basic = new FOFEncryptAes($basickey); if (!empty($item->path) && $basickey && !is_numeric($item->path) && $item->path === base64_encode(base64_decode($item->path, true))) { @@ -170,7 +170,7 @@ class ComponentbuilderModelServer extends JModelAdmin * * @return mixed An array of data items on success, false on failure. */ - public function getWamlinked_components() + public function getWanlinked_components() { // Get the user object. $user = JFactory::getUser(); @@ -954,7 +954,7 @@ class ComponentbuilderModelServer extends JModelAdmin // Get the basic encryption key. $basickey = ComponentbuilderHelper::getCryptKey('basic'); // Get the encryption object - $basic = new FOFEncryptAes($basickey, 128); + $basic = new FOFEncryptAes($basickey); // Encrypt data path. if (isset($data['path']) && $basickey) diff --git a/admin/models/servers.php b/admin/models/servers.php index 7397bf528..8f58b1beb 100644 --- a/admin/models/servers.php +++ b/admin/models/servers.php @@ -288,7 +288,7 @@ class ComponentbuilderModelServers extends JModelList // Get the basic encryption key. $basickey = ComponentbuilderHelper::getCryptKey('basic'); // Get the encryption object. - $basic = new FOFEncryptAes($basickey, 128); + $basic = new FOFEncryptAes($basickey); // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) diff --git a/admin/views/server/view.html.php b/admin/views/server/view.html.php index ea5621a46..993a06a09 100644 --- a/admin/views/server/view.html.php +++ b/admin/views/server/view.html.php @@ -64,7 +64,7 @@ class ComponentbuilderViewServer extends JViewLegacy } // Get Linked view data - $this->wamlinked_components = $this->get('Wamlinked_components'); + $this->wanlinked_components = $this->get('Wanlinked_components'); // Set the toolbar $this->addToolBar(); diff --git a/componentbuilder.xml b/componentbuilder.xml index 437faf01c..811f380ab 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 5th March, 2018 + 6th March, 2018 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://joomlacomponentbuilder.com @@ -91,7 +91,7 @@ Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/compo access.xml config.xml - controller.php + controller.php###WHMCS_ENCRYPT_FILE### index.html componentbuilder.php README.txt diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php index feac8153b..013134935 100644 --- a/site/helpers/componentbuilder.php +++ b/site/helpers/componentbuilder.php @@ -2702,18 +2702,29 @@ abstract class ComponentbuilderHelper return implode($key); } - public static function getCryptKey($type, $default = null) + /** + * Get The Encryption Keys + * + * @param string $type The type of key + * @param string/bool $default The return value if no key was found + * + * @return string On success + * + **/ + public static function getCryptKey($type, $default = false) { + // Get the global params + $params = JComponentHelper::getParams('com_componentbuilder', true); + // Basic Encryption Type if ('basic' === $type) { - // Get the global params - $params = JComponentHelper::getParams('com_componentbuilder', true); $basic_key = $params->get('basic_key', $default); - if ($basic_key) + if (self::checkString($basic_key)) { return $basic_key; } } - return false; + + return $default; } }