first commit

This commit is contained in:
2026-02-08 21:16:11 +01:00
commit e17b7026fd
8881 changed files with 1160453 additions and 0 deletions

View File

@@ -0,0 +1,142 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2022 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
use Joomla\CMS\Factory;
use NRFramework\Executer;
defined('_JEXEC') or die('Restricted access');
class Captcha extends Text
{
/**
* Exclude all common fields
*
* @var mixed
*/
protected $excludeFields = [
'name',
'required',
'size',
'value',
'placeholder',
'browserautocomplete',
'inputcssclass'
];
/**
* This is bullshit. We should call setField() in the Field's Class constructor so we can access the field's ID correctly. Consider this as a workround.
*
* @return string
*/
private function getSessionNamespace()
{
return 'cf.' . $this->getField()->key . '.captcha';
}
/**
* Set field object
*
* @param mixed $field Object or Array Field options
*/
public function setField($field)
{
parent::setField($field);
// Once we start calling $this->setField() in the constructo, we can get rid of this line.
$this->field->required = true;
$complexity = isset($this->field->complexity) ? $this->field->complexity : '';
switch ($complexity)
{
case 'high':
$min = 1;
$max = 30;
$comparators = ['+', '-', '*'];
break;
case 'medium':
$min = 1;
$max = 20;
$comparators = ['+', '-'];
break;
// low
default:
$min = 1;
$max = 10;
$comparators = ['+'];
}
// Pick random numbers
$number1 = rand($min, $max);
$number2 = rand($min, $max);
// Pick a random math comparison operator
shuffle($comparators);
$comparator = end($comparators);
// Calculate the Captcha answer
$equation = "return ($number1 $comparator $number2)";
$executer = new Executer($equation);
$answer = $executer->run();
// Store the Captcha answer in the Session object.
Factory::getSession()->set($this->getSessionNamespace(), $answer);
// Pass data to template
$this->field->question = [
'number1' => $number1,
'number2' => $number2,
'comparator' => $comparator,
];;
return $this;
}
/**
* Validate field value
*
* @param mixed $value The field's value to validate
*
* @return mixed True on success, throws an exception on error
*/
public function validate(&$value)
{
// In case this is a submission via URL, skip the check.
if (Factory::getApplication()->input->get('task') == 'optin')
{
return true;
}
$math_solution = (string) Factory::getSession()->get($this->getSessionNamespace());
$field = $this->getField();
// Once we start calling $this->setField() in the constructor we can easily find the field's name by using $this->field->name instead of relying on the submitted data.
$user_solution = (string) $this->data['captcha_' . $field->key];
// In v3.2.9 we added an option to set the Wrong Answer Text in the Field Settings. In the previous version we were using a language strings instead.
// To prevnt breaking the user's form, we need to check whether the new option is available. Otherwise we fallback to the old language string.
// We can get rid of compatibility check in a few months.
$wrong_answer_text = isset($field->wrong_answer_text) && !empty($field->wrong_answer_text) ? $field->wrong_answer_text : \JText::_('COM_CONVERTFORMS_FIELD_CAPTCHA_WRONG_ANSWER');
if ($math_solution !== $user_solution)
{
$this->throwError($wrong_answer_text);
}
}
}
?>

View File

@@ -0,0 +1,38 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Checkbox extends \ConvertForms\FieldChoice
{
/**
* Indicates whether it accepts multiple values
*
* @var bool
*/
protected $multiple = true;
/**
* Remove common fields from the form rendering
*
* @var mixed
*/
protected $excludeFields = array(
'placeholder',
'browserautocomplete',
'size',
);
}
?>

View File

@@ -0,0 +1,46 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Divider extends \ConvertForms\Field
{
/**
* Remove common fields from the form rendering
*
* @var mixed
*/
protected $excludeFields = [
'name',
'placeholder',
'browserautocomplete',
'size',
'required',
'label',
'description',
'cssclass',
'hidelabel',
'inputcssclass',
'value'
];
/**
* Indicates the default required behavior on the form
*
* @var bool
*/
protected $required = false;
}
?>

View File

@@ -0,0 +1,22 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Dropdown extends \ConvertForms\FieldChoice
{
}
?>

View File

@@ -0,0 +1,93 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Editor extends Textarea
{
/**
* Remove common fields from the form rendering
*
* @var mixed
*/
protected $excludeFields = [
'placeholder',
'browserautocomplete',
'size',
];
/**
* Event fired before the field options form is rendered in the backend
*
* @param object $form
*
* @return void
*/
protected function onAfterRenderOptionsForm(&$html)
{
// Remove the 'None' editor from dropdown options
$html = str_replace('<option value="none">Editor - None</option>', '', $html);
}
/**
* Renders the field's input element
*
* @return string HTML output
*/
protected function getInput()
{
$selected_editor = empty($this->field->editor) ? \JFactory::getConfig()->get('editor') : $this->field->editor;
if (!$selected_editor)
{
return \JText::sprintf('COM_CONVERTFORMS_EDITOR_NOT_FOUND', $selected_editor);
}
// Instantiate the editor
$editor = \Joomla\CMS\Editor\Editor::getInstance($selected_editor);
$id = $this->field->input_id;
$name = $this->field->input_name;
$contents = htmlspecialchars($this->field->value, ENT_COMPAT, 'UTF-8');
$width = '100%';
$height = (int) $this->field->height;
$row = 1;
$col = 10;
$buttons = false;
$author = null;
$asset = null;
$params = [
'readonly' => $this->field->readonly,
];
$this->field->richeditor = $editor->display($name, $contents, $width, $height, $col, $row, $buttons, $id, $author, $asset, $params);
return parent::getInput();
}
/**
* Return the HTML version of the submitted value.
*
* @param string $value
*
* @return string
*/
public function prepareValueHTML($value)
{
// Editor's value is already in HTML format in the database
return $value;
}
}
?>

View File

@@ -0,0 +1,63 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
use ConvertForms\Validate;
class Email extends \ConvertForms\Field
{
protected $inheritInputLayout = 'text';
/**
* Validate field value
*
* @param mixed $value The field's value to validate
*
* @return mixed True on success, throws an exception on error
*/
public function validate(&$value)
{
parent::validate($value);
if ($this->isEmpty($value))
{
return true;
}
if (!Validate::email($value) || $this->field->get('dnscheck') && !Validate::emaildns($value))
{
$this->throwError(\JText::sprintf('COM_CONVERTFORMS_FIELD_EMAIL_INVALID'), $this->field);
}
}
/**
* Prepare value to be displayed to the user as HTML/text
*
* @param mixed $value
*
* @return string
*/
public function prepareValueHTML($value)
{
if (!$value)
{
return;
}
return '<a target="_blank" href="mailto:' . $value . '">' . $value . '</a>';
}
}
?>

View File

@@ -0,0 +1,46 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2018 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class EmptySpace extends \ConvertForms\Field
{
/**
* Indicates the default required behavior on the form
*
* @var bool
*/
protected $required = false;
/**
* Remove common fields from the form rendering
*
* @var mixed
*/
protected $excludeFields = [
'name',
'placeholder',
'browserautocomplete',
'size',
'required',
'label',
'description',
'cssclass',
'hidelabel',
'inputcssclass',
'value'
];
}
?>

View File

@@ -0,0 +1,361 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.path');
use ConvertForms\Helper;
use ConvertForms\Validate;
use NRFramework\File;
use Joomla\Registry\Registry;
class FileUpload extends \ConvertForms\Field
{
/**
* The default upload folder
*
* @var string
*/
protected $default_upload_folder = '/media/com_convertforms/uploads/{randomid}_{file.basename}';
/**
* Remove common fields from the form rendering
*
* @var mixed
*/
protected $excludeFields = [
'size',
'value',
'browserautocomplete',
'placeholder',
'inputcssclass'
];
/**
* Set field object
*
* @param mixed $field Object or Array Field options
*/
public function setField($field)
{
parent::setField($field);
$field = $this->field;
if (!isset($field->limit_files))
{
$field->limit_files = 1;
}
if (!isset($field->upload_types) || empty($field->upload_types))
{
$field->upload_types = 'image/*';
}
// Accept multiple values
if ((int) $field->limit_files != 1)
{
$field->input_name .= '[]';
}
return $this;
}
/**
* Validate field value
*
* @param mixed $value The field's value to validate
*
* @return mixed True on success, throws an exception on error
*/
public function validate(&$value)
{
$is_required = $this->field->get('required');
$max_files_allowed = $this->field->get('limit_files', 1);
$allowed_types = $this->field->get('upload_types');
$upload_folder = $this->field->get('upload_folder_type', 'auto') == 'auto' ? $this->default_upload_folder : $this->field->get('upload_folder', $this->default_upload_folder);
// Remove null and empty values
$value = is_array($value) ? $value : (array) $value;
$value = array_filter($value);
// We expect a not empty array
if ($is_required && empty($value))
{
$this->throwError(\JText::_('COM_CONVERTFORMS_FIELD_REQUIRED'));
}
// Do we have the correct number of files?
if ($max_files_allowed > 0 && count($value) > $max_files_allowed)
{
$this->throwError(\JText::sprintf('COM_CONVERTFORMS_UPLOAD_MAX_FILES_LIMIT', $max_files_allowed));
}
// Validate file paths
foreach ($value as $key => &$source_file)
{
$source_file = base64_decode($source_file);
$source_file_info = File::pathinfo($source_file);
$source_basename = $source_file_info['basename'];
if (!\JFile::exists($source_file))
{
$this->throwError(\JText::sprintf('COM_CONVERTFORMS_UPLOAD_FILE_IS_MISSING', $source_basename));
}
// Although the file is already checked during upload, make another sanity check here.
File::checkMimeOrDie($allowed_types, ['tmp_name' => $source_file]);
// Remove the random ID added to file's name during upload process
$source_file_info['filename'] = preg_replace('#cf_(.*?)_(.*?)#', '', $source_file_info['filename']);
$source_file_info['basename'] = preg_replace('#cf_(.*?)_(.*?)#', '', $source_basename);
$source_file_info['index'] = $key + 1;
// Replace Smart Tags in the upload folder value
// Unfortunately at this time, we don't have submitted data available yet and so, we can't replace field-based Smart Tags. See @todo below.
$SmartTags = new \NRFramework\SmartTags();
$SmartTags->add($source_file_info, 'file.');
$destination_file = JPATH_ROOT . DIRECTORY_SEPARATOR . $SmartTags->replace($upload_folder);
// Validate destination file
$destination_file_info = File::pathinfo($destination_file);
if (!isset($destination_file_info['extension']))
{
$destination_file = implode(DIRECTORY_SEPARATOR, [$destination_file_info['dirname'], $destination_file_info['basename'], $source_basename]);
}
// Move uploaded file to the destination folder after the form passes all validation checks.
// Thus, if an error is triggered by another field, the file will remain in the temp folder and the user will be able to re-submit the form.
$this->app->registerEvent('onConvertFormsSubmissionBeforeSave', function(&$data) use ($key, $source_file, $destination_file)
{
try
{
// get the data
$tmpData = $data;
if (defined('nrJ4'))
{
$tmpData = $data->getArgument('0');
}
// This is a temporary workaround to support field-based Smart Tags in the upload folder
// @todo 1: We need to prepare $data with ConvertFormsModelConversion->prepare() and pass it down to Submission::replaceSmartTags() in order for submitted values to be prepared with each field prepare() method.
// @todo 2: Do Smart Tags replacement once. Merge previous replacement for file Smart Tags with this one.
$SmartTags = new \NRFramework\SmartTags();
$SmartTags->add($tmpData['params'], 'field.');
$destination_file = $SmartTags->replace($destination_file);
// Move uploaded file from the temp folder to the destination folder.
$destination_file = File::move($source_file, $destination_file);
// Give a chance to manipulate the file with a hook.
// We can move the file to another folder, rename it, resize it or even uploaded it to a cloud storage service.
$this->app->triggerEvent('onConvertFormsFileUpload', [&$destination_file, $tmpData]);
// Always save the relative path to the database.
$destination_file = Helper::pathTorelative($destination_file);
// Update fields' value
$tmpData['params'][$this->field->get('name')][$key] = $destination_file;
// Set back the new value to $data object
if (defined('nrJ4'))
{
$data->setArgument(0, $tmpData);
}
else
{
$data = $tmpData;
}
} catch (\Throwable $th)
{
$this->throwError($th->getMessage());
}
});
}
}
/**
* Event fired before the field options form is rendered in the backend
*
* @param object $form
*
* @return void
*/
protected function onBeforeRenderOptionsForm($form)
{
// Set the maximum upload size limit to the respective options form field
$max_upload_size_str = \JHtml::_('number.bytes', \JUtility::getMaxUploadSize());
$max_upload_size_int = (int) $max_upload_size_str;
$form->setFieldAttribute('max_file_size', 'max', $max_upload_size_int);
$desc_lang_str = $form->getFieldAttribute('max_file_size', 'description');
$desc = \JText::sprintf($desc_lang_str, $max_upload_size_str);
$form->setFieldAttribute('max_file_size', 'description', $desc);
}
/**
* Ajax method triggered by System Plugin during file upload.
*
* @param string $form_id
* @param string $field_key
*
* @return array
*/
public function onAjax($form_id, $field_key)
{
// Make sure we have a valid form and a field key
if (!$form_id || !$field_key)
{
$this->uploadDie('COM_CONVERTFORMS_UPLOAD_ERROR');
}
// Get field settings
if (!$upload_field_settings = \ConvertForms\Form::getFieldSettingsByKey($form_id, $field_key))
{
$this->uploadDie('COM_CONVERTFORMS_UPLOAD_ERROR_INVALID_FIELD');
}
$allow_unsafe = $upload_field_settings->get('allow_unsafe', false);
// Make sure we have a valid file passed
if (!$file = $this->app->input->files->get('file', null, ($allow_unsafe ? 'raw' : 'cmd')))
{
$this->uploadDie('COM_CONVERTFORMS_UPLOAD_ERROR_INVALID_FILE');
}
// In case we allow multiple uploads the file parameter is a 2 levels array.
$first_property = array_pop($file);
if (is_array($first_property))
{
$file = $first_property;
}
// Upload temporarily to the default upload folder
$allowed_types = $upload_field_settings->get('upload_types');
try {
$uploaded_filename = File::upload($file, null, $allowed_types, $allow_unsafe, 'cf_');
return [
// Since the path of the uploaded file will be included in the form's POST data, obfuscate the path for security reasons.
// This will also prevent Akeeba Admin Tools DFIShield from mistakenly blocking File Uploads.
'file' => base64_encode($uploaded_filename),
];
} catch (\Throwable $th)
{
$this->uploadDie($th->getMessage());
}
}
/**
* DropzoneJS detects errors based on the response error code.
*
* @param string $error_message
*
* @return void
*/
private function uploadDie($error_message)
{
http_response_code('500');
die(\JText::_($error_message));
}
/**
* Prepare value to be displayed to the user as plain text
*
* @param mixed $value
*
* @return string
*/
public function prepareValue($value)
{
if (!$value)
{
return;
}
$value = (array) $value;
foreach ($value as &$link)
{
$link = Helper::absURL($link);
}
return implode(', ', $value);
}
/**
* Prepare value to be displayed to the user as HTML/text
*
* @param mixed $value
*
* @return string
*/
public function prepareValueHTML($value)
{
if (!$value)
{
return;
}
$links = (array) $value;
$value = '';
foreach ($links as $link)
{
$link = Helper::absURL($link);
$value .= '<div><a download href="' . $link . '">' . File::pathinfo($link)['basename'] . '</a></div>';
}
return '<div class="cf-links">' . $value . '</div>';
}
/**
* Display a text before the form options
*
* @return string The text to display
*/
protected function getOptionsFormHeader()
{
$html = '';
$temp_folder = File::getTempFolder();
if (!@is_writable($temp_folder))
{
$html .= '
<div class="alert alert-danger">
' . \JText::sprintf('COM_CONVERTFORMS_FILEUPLOAD_TEMP_FOLDER_NOT_WRITABLE', $temp_folder) . '
</div>
';
}
// Check if the Fileinfo PHP extension is installed required to detect the mime type.
if (!extension_loaded('fileinfo') || !function_exists('mime_content_type'))
{
$html .= '
<div class="alert alert-danger">
' . \JText::sprintf('COM_CONVERTFORMS_FILEUPLOAD_MIME_CONTENT_TYPE_MISSING') . '
</div>
';
}
return $html;
}
}

View File

@@ -0,0 +1,130 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
use \ConvertForms\Helper;
class Hcaptcha extends \ConvertForms\Field
{
/**
* Exclude all common fields
*
* @var mixed
*/
protected $excludeFields = array(
'name',
'required',
'size',
'value',
'placeholder',
'browserautocomplete',
'inputcssclass'
);
/**
* Set field object
*
* @param mixed $field Object or Array Field options
*/
public function setField($field)
{
parent::setField($field);
$this->field->required = true;
// When captcha is in invisible mode, don't show the control group
if ($this->field->hcaptcha_type == 'invisible')
{
$this->field->cssclass .= 'hide';
}
return $this;
}
/**
* Get the hCaptcha Site Key used in Javascript code
*
* @return string
*/
public function getSiteKey()
{
return Helper::getComponentParams()->get('hcaptcha_sitekey');
}
/**
* Get the hCaptcha Secret Key used in communication between the website and the hCaptcha server
*
* @return string
*/
public function getSecretKey()
{
return Helper::getComponentParams()->get('hcaptcha_secretkey');
}
/**
* Validate field value
*
* @param mixed $value The field's value to validate
*
* @return mixed True on success, throws an exception on error
*/
public function validate(&$value)
{
if (!$this->field->get('required'))
{
return true;
}
// In case this is a submission via URL, skip the check.
if (\JFactory::getApplication()->input->get('task') == 'optin')
{
return true;
}
$hcaptcha = new \NRFramework\Integrations\HCaptcha(
['secret' => $this->getSecretKey()]
);
$response = isset($this->data['h-captcha-response']) ? $this->data['h-captcha-response'] : null;
$hcaptcha->validate($response);
if (!$hcaptcha->success())
{
throw new \Exception($hcaptcha->getLastError());
}
}
/**
* Display a text before the form options
*
* @return string The text to display
*/
protected function getOptionsFormHeader()
{
if ($this->getSiteKey() && $this->getSecretKey())
{
return;
}
$url = \JURI::base() . 'index.php?option=com_config&view=component&component=com_convertforms#hcaptcha';
return
\JText::_('COM_CONVERTFORMS_FIELD_RECAPTCHA_KEYS_NOTE') .
' <a onclick=\'window.open("' . $url . '", "cfrecaptcha", "width=1000, height=750");\' href="#">'
. \JText::_("COM_CONVERTFORMS_FIELD_HCAPTCHA_CONFIGURE") .
'</a>.';
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2018 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Heading extends \ConvertForms\Field
{
/**
* Indicates the default required behavior on the form
*
* @var bool
*/
protected $required = false;
/**
* Remove common fields from the form rendering
*
* @var mixed
*/
protected $excludeFields = array(
'name',
'placeholder',
'browserautocomplete',
'size',
'required',
'hidelabel',
'inputcssclass',
'value'
);
}
?>

View File

@@ -0,0 +1,58 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Hidden extends \ConvertForms\Field
{
/**
* Remove common fields from the form rendering
*
* @var mixed
*/
protected $excludeFields = [
'label',
'placeholder',
'description',
'cssclass',
'hidelabel',
'browserautocomplete',
'size',
'inputcssclass'
];
/**
* Indicates the default required behavior on the form
*
* @var bool
*/
protected $required = false;
/**
* Set field object
*
* @param mixed $field Object or Array Field options
*/
public function setField($field)
{
parent::setField($field);
// Always hide the container of a hidden field
$this->field->cssclass = 'cf-hide';
return $this;
}
}
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Number extends \ConvertForms\Field
{
/**
* Filter user value before saving into the database
*
* @var string
*/
protected $filterInput = 'FLOAT';
}
?>

View File

@@ -0,0 +1,24 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
use ConvertForms\Validate;
class Password extends \ConvertForms\Field
{
protected $inheritInputLayout = 'text';
}
?>

View File

@@ -0,0 +1,50 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Radio extends \ConvertForms\FieldChoice
{
/**
* Remove common fields from the form rendering
*
* @var mixed
*/
protected $excludeFields = array(
'placeholder',
'browserautocomplete',
'size',
);
/**
* Radio buttons expect single text value. So we need to transform the submitted array data to string.
*
* @param mixed $input User input value
*
* @return mixed The filtered user input
*/
public function filterInput($input)
{
$value = parent::filterInput($input);
if (is_array($value) && isset($value[0]))
{
return $value[0];
}
return $value;
}
}
?>

View File

@@ -0,0 +1,128 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
use \ConvertForms\Helper;
class Recaptcha extends \ConvertForms\Field
{
/**
* Exclude all common fields
*
* @var mixed
*/
protected $excludeFields = array(
'name',
'required',
'size',
'value',
'placeholder',
'browserautocomplete',
'inputcssclass'
);
/**
* Set field object
*
* @param mixed $field Object or Array Field options
*/
public function setField($field)
{
parent::setField($field);
$this->field->required = true;
return $this;
}
/**
* Get the reCAPTCHA Site Key used in Javascript code
*
* @return string
*/
public function getSiteKey()
{
return Helper::getComponentParams()->get('recaptcha_sitekey');
}
/**
* Get the reCAPTCHA Secret Key used in communication between the website and the reCAPTCHA server
*
* @return string
*/
public function getSecretKey()
{
return Helper::getComponentParams()->get('recaptcha_secretkey');
}
/**
* Validate field value
*
* @param mixed $value The field's value to validate
*
* @return mixed True on success, throws an exception on error
*/
public function validate(&$value)
{
if (!$this->field->get('required'))
{
return true;
}
// In case this is a submission via URL, skip the check.
if (\JFactory::getApplication()->input->get('task') == 'optin')
{
return true;
}
jimport('recaptcha', JPATH_PLUGINS . '/system/nrframework/helpers/wrappers');
$recaptcha = new \NR_ReCaptcha(
['secret' => $this->getSecretKey()]
);
$response = isset($this->data['g-recaptcha-response']) ? $this->data['g-recaptcha-response'] : null;
$recaptcha->validate($response);
if (!$recaptcha->success())
{
throw new \Exception($recaptcha->getLastError());
}
}
/**
* Display a text before the form options
*
* @return string The text to display
*/
protected function getOptionsFormHeader()
{
if ($this->getSiteKey() && $this->getSecretKey())
{
return;
}
$url = \JURI::base() . 'index.php?option=com_config&view=component&component=com_convertforms#recaptcha';
return
\JText::_('COM_CONVERTFORMS_FIELD_RECAPTCHA_KEYS_NOTE') .
' <a onclick=\'window.open("' . $url . '", "cfrecaptcha", "width=1000, height=750");\' href="#">'
. \JText::_("COM_CONVERTFORMS_FIELD_RECAPTCHA_CONFIGURE") .
'</a>.';
}
}
?>

View File

@@ -0,0 +1,60 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
use \ConvertForms\Helper;
class RecaptchaV2Invisible extends \ConvertForms\Field\Recaptcha
{
/**
* Set field object
*
* @param mixed $field Object or Array Field options
*/
public function setField($field)
{
parent::setField($field);
// When the widget is shown at the bottom right or left position, we need to remove the .control-group's div default padding.
if ($this->field->badge != 'inline')
{
$this->field->cssclass .= 'cf-no-padding';
}
return $this;
}
/**
* Get the reCAPTCHA Site Key used in Javascript code
*
* @return string
*/
public function getSiteKey()
{
return Helper::getComponentParams()->get('recaptcha_sitekey_invs');
}
/**
* Get the reCAPTCHA Secret Key used in communication between the website and the reCAPTCHA server
*
* @return string
*/
public function getSecretKey()
{
return Helper::getComponentParams()->get('recaptcha_secretkey_invs');
}
}
?>

View File

@@ -0,0 +1,43 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Submit extends \ConvertForms\Field
{
/**
* Remove common fields from the form rendering
*
* @var mixed
*/
protected $excludeFields = array(
'name',
'description',
'label',
'placeholder',
'required',
'hidelabel',
'browserautocomplete',
'value',
);
/**
* Indicates the default required behavior on the form
*
* @var bool
*/
protected $required = false;
}
?>

View File

@@ -0,0 +1,39 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Tel extends \ConvertForms\Field
{
protected $inheritInputLayout = 'text';
/**
* Prepare value to be displayed to the user as HTML/text
*
* @param mixed $value
*
* @return string
*/
public function prepareValueHTML($value)
{
if (!$value)
{
return;
}
return '<a href="tel:' . $value . '">' . $value . '</a>';
}
}
?>

View File

@@ -0,0 +1,84 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
use Joomla\String\StringHelper;
defined('_JEXEC') or die('Restricted access');
class Text extends \ConvertForms\Field
{
/**
* Validate form submitted value
*
* @param mixed $value The field's value to validate (Passed by reference)
*
* @return mixed True on success, throws an exception on error
*/
public function validate(&$value)
{
$isEmpty = $this->isEmpty($value);
$isRequired = $this->field->get('required');
// If the field is empty and its not required, skip validation
if ($isEmpty && !$isRequired)
{
return;
}
if ($isEmpty && $isRequired)
{
$this->throwError(\JText::_('COM_CONVERTFORMS_FIELD_REQUIRED'), $field_options);
}
// Validate Min / Max characters
$min_chars = $this->field->get('minchars', 0);
$max_chars = $this->field->get('maxchars', 0);
$value_length = StringHelper::strlen($value);
if ($min_chars > 0 && $value_length < $min_chars)
{
$this->throwError(\JText::sprintf('COM_CONVERTFORMS_FIELD_VALIDATION_MIN_CHARS', $min_chars, $value_length), $field_options);
}
if ($max_chars > 0 && $value_length > $max_chars)
{
$this->throwError(\JText::sprintf('COM_CONVERTFORMS_FIELD_VALIDATION_MAX_CHARS', $max_chars, $value_length), $field_options);
}
// Validate Min / Max words
$min_words = $this->field->get('minwords', 0);
$max_words = $this->field->get('maxwords', 0);
// Find words count
$words_temp = preg_replace('/\s+/', ' ', trim($value));
$words_temp = array_filter(explode(' ', $words_temp));
$words_count = count($words_temp);
if ($min_words > 0 && $words_count < $min_words)
{
$this->throwError(\JText::sprintf('COM_CONVERTFORMS_FIELD_VALIDATION_MIN_WORDS', $min_words, $words_count), $field_options);
}
if ($max_words > 0 && $words_count > $max_words)
{
$this->throwError(\JText::sprintf('COM_CONVERTFORMS_FIELD_VALIDATION_MAX_WORDS', $max_words, $words_count), $field_options);
}
// Let's do some filtering.
$value = $this->filterInput($value);
}
}
?>

View File

@@ -0,0 +1,21 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
class Textarea extends \ConvertForms\Field\Text
{
}
?>

View File

@@ -0,0 +1,63 @@
<?php
/**
* @package Convert Forms
* @version 3.2.12 Free
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
namespace ConvertForms\Field;
defined('_JEXEC') or die('Restricted access');
use ConvertForms\Validate;
class Url extends \ConvertForms\Field
{
protected $inheritInputLayout = 'text';
/**
* Validate field value
*
* @param mixed $value The field's value to validate
*
* @return mixed True on success, throws an exception on error
*/
public function validate(&$value)
{
parent::validate($value);
if ($this->isEmpty($value))
{
return true;
}
if (!Validate::url($value))
{
$this->throwError(\JText::sprintf('COM_CONVERTFORMS_FIELD_URL_INVALID'));
}
}
/**
* Prepare value to be displayed to the user as HTML/text
*
* @param mixed $value
*
* @return string
*/
public function prepareValueHTML($value)
{
if (!$value)
{
return;
}
return '<a href="' . $value . '">' . $value . '</a>';
}
}
?>