Update website
This commit is contained in:
parent
a0b0d3dae7
commit
ae7ef6ad45
3151 changed files with 566766 additions and 48 deletions
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the Bool2Text transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the Bool2Text transformations plugins.
|
||||
*/
|
||||
abstract class Bool2TextTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Converts Boolean values to text (default \'T\' and \'F\').'
|
||||
. ' First option is for TRUE, second for FALSE. Nonzero=true.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Bool2Text']);
|
||||
|
||||
if ($buffer == '0') {
|
||||
return $options[1]; // return false label
|
||||
}
|
||||
|
||||
return $options[0]; // or true one if nonzero
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Bool2Text';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for syntax highlighted editors using CodeMirror
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\IOTransformationsPlugin;
|
||||
use stdClass;
|
||||
use function htmlspecialchars;
|
||||
use function strtolower;
|
||||
|
||||
/**
|
||||
* Provides common methods for all the CodeMirror syntax highlighted editors
|
||||
*/
|
||||
abstract class CodeMirrorEditorTransformationPlugin extends IOTransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html for input field to override default textarea.
|
||||
* Note: Return empty string if default textarea is required.
|
||||
*
|
||||
* @param array $column column details
|
||||
* @param int $row_id row number
|
||||
* @param string $column_name_appendix the name attribute
|
||||
* @param array $options transformation options
|
||||
* @param string $value Current field value
|
||||
* @param string $text_dir text direction
|
||||
* @param int $tabindex tab index
|
||||
* @param int $tabindex_for_value offset for the values tabindex
|
||||
* @param int $idindex id index
|
||||
*
|
||||
* @return string the html for input field
|
||||
*/
|
||||
public function getInputHtml(
|
||||
array $column,
|
||||
$row_id,
|
||||
$column_name_appendix,
|
||||
array $options,
|
||||
$value,
|
||||
$text_dir,
|
||||
$tabindex,
|
||||
$tabindex_for_value,
|
||||
$idindex
|
||||
) {
|
||||
$html = '';
|
||||
if (! empty($value)) {
|
||||
$html = '<input type="hidden" name="fields_prev' . $column_name_appendix
|
||||
. '" value="' . htmlspecialchars($value) . '">';
|
||||
}
|
||||
$class = 'transform_' . strtolower(static::getName()) . '_editor';
|
||||
|
||||
return $html . '<textarea name="fields' . $column_name_appendix . '"'
|
||||
. ' dir="' . $text_dir . '" class="' . $class . '">'
|
||||
. htmlspecialchars($value) . '</textarea>';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the date format transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use PhpMyAdmin\Sanitize;
|
||||
use PhpMyAdmin\Util;
|
||||
use stdClass;
|
||||
use function checkdate;
|
||||
use function gmdate;
|
||||
use function htmlspecialchars;
|
||||
use function mb_strlen;
|
||||
use function mb_strtolower;
|
||||
use function mb_substr;
|
||||
use function mktime;
|
||||
use function preg_match;
|
||||
use function strtotime;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the date format transformations plugins.
|
||||
*/
|
||||
abstract class DateFormatTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Displays a TIME, TIMESTAMP, DATETIME or numeric unix timestamp'
|
||||
. ' column as formatted date. The first option is the offset (in'
|
||||
. ' hours) which will be added to the timestamp (Default: 0). Use'
|
||||
. ' second option to specify a different date/time format string.'
|
||||
. ' Third option determines whether you want to see local date or'
|
||||
. ' UTC one (use "local" or "utc" strings) for that. According to'
|
||||
. ' that, date format has different value - for "local" see the'
|
||||
. ' documentation for PHP\'s strftime() function and for "utc" it'
|
||||
. ' is done using gmdate() function.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
$buffer = (string) $buffer;
|
||||
// possibly use a global transform and feed it with special options
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['DateFormat']);
|
||||
|
||||
// further operations on $buffer using the $options[] array.
|
||||
$options[2] = mb_strtolower($options[2]);
|
||||
|
||||
if (empty($options[1])) {
|
||||
if ($options[2] === 'local') {
|
||||
$options[1] = __('%B %d, %Y at %I:%M %p');
|
||||
} else {
|
||||
$options[1] = 'Y-m-d H:i:s';
|
||||
}
|
||||
}
|
||||
|
||||
$timestamp = -1;
|
||||
|
||||
// INT columns will be treated as UNIX timestamps
|
||||
// and need to be detected before the verification for
|
||||
// MySQL TIMESTAMP
|
||||
if ($meta->type === 'int') {
|
||||
$timestamp = $buffer;
|
||||
|
||||
// Detect TIMESTAMP(6 | 8 | 10 | 12 | 14)
|
||||
// TIMESTAMP (2 | 4) not supported here.
|
||||
// (Note: prior to MySQL 4.1, TIMESTAMP has a display size
|
||||
// for example TIMESTAMP(8) means YYYYMMDD)
|
||||
} else {
|
||||
if (preg_match('/^(\d{2}){3,7}$/', $buffer)) {
|
||||
if (mb_strlen($buffer) == 14 || mb_strlen($buffer) == 8) {
|
||||
$offset = 4;
|
||||
} else {
|
||||
$offset = 2;
|
||||
}
|
||||
|
||||
$aDate = [];
|
||||
$aDate['year'] = (int) mb_substr($buffer, 0, $offset);
|
||||
$aDate['month'] = (int) mb_substr($buffer, $offset, 2);
|
||||
$aDate['day'] = (int) mb_substr($buffer, $offset + 2, 2);
|
||||
$aDate['hour'] = (int) mb_substr($buffer, $offset + 4, 2);
|
||||
$aDate['minute'] = (int) mb_substr($buffer, $offset + 6, 2);
|
||||
$aDate['second'] = (int) mb_substr($buffer, $offset + 8, 2);
|
||||
|
||||
if (checkdate($aDate['month'], $aDate['day'], $aDate['year'])) {
|
||||
$timestamp = mktime(
|
||||
$aDate['hour'],
|
||||
$aDate['minute'],
|
||||
$aDate['second'],
|
||||
$aDate['month'],
|
||||
$aDate['day'],
|
||||
$aDate['year']
|
||||
);
|
||||
}
|
||||
// If all fails, assume one of the dozens of valid strtime() syntaxes
|
||||
// (https://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html)
|
||||
} else {
|
||||
if (preg_match('/^[0-9]\d{1,9}$/', $buffer)) {
|
||||
$timestamp = (int) $buffer;
|
||||
} else {
|
||||
$timestamp = strtotime($buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If all above failed, maybe it's a Unix timestamp already?
|
||||
if ($timestamp < 0 && preg_match('/^[1-9]\d{1,9}$/', $buffer)) {
|
||||
$timestamp = $buffer;
|
||||
}
|
||||
|
||||
// Reformat a valid timestamp
|
||||
if ($timestamp >= 0) {
|
||||
$timestamp -= (int) $options[0] * 60 * 60;
|
||||
$source = $buffer;
|
||||
if ($options[2] === 'local') {
|
||||
$text = Util::localisedDate(
|
||||
$timestamp,
|
||||
$options[1]
|
||||
);
|
||||
} elseif ($options[2] === 'utc') {
|
||||
$text = gmdate($options[1], $timestamp);
|
||||
} else {
|
||||
$text = 'INVALID DATE TYPE';
|
||||
}
|
||||
|
||||
return '<dfn onclick="alert(\'' . Sanitize::jsFormat($source, false) . '\');" title="'
|
||||
. htmlspecialchars((string) $source) . '">' . htmlspecialchars((string) $text) . '</dfn>';
|
||||
}
|
||||
|
||||
return htmlspecialchars((string) $buffer);
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Date Format';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the download transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use PhpMyAdmin\Url;
|
||||
use stdClass;
|
||||
use function array_merge;
|
||||
use function htmlspecialchars;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the download transformations plugins.
|
||||
*/
|
||||
abstract class DownloadTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Displays a link to download the binary data of the column. You can'
|
||||
. ' use the first option to specify the filename, or use the second'
|
||||
. ' option as the name of a column which contains the filename. If'
|
||||
. ' you use the second option, you need to set the first option to'
|
||||
. ' the empty string.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
global $row, $fields_meta;
|
||||
|
||||
if (isset($options[0]) && ! empty($options[0])) {
|
||||
$cn = $options[0]; // filename
|
||||
} else {
|
||||
if (isset($options[1]) && ! empty($options[1])) {
|
||||
foreach ($fields_meta as $key => $val) {
|
||||
if ($val->name == $options[1]) {
|
||||
$pos = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($pos)) {
|
||||
$cn = $row[$pos];
|
||||
}
|
||||
}
|
||||
if (empty($cn)) {
|
||||
$cn = 'binary_file.dat';
|
||||
}
|
||||
}
|
||||
|
||||
$link = '<a href="' . Url::getFromRoute(
|
||||
'/transformation/wrapper',
|
||||
array_merge($options['wrapper_params'], [
|
||||
'ct' => 'application/octet-stream',
|
||||
'cn' => $cn,
|
||||
])
|
||||
);
|
||||
$link .= '" title="' . htmlspecialchars($cn);
|
||||
$link .= '" class="disableAjax">' . htmlspecialchars($cn);
|
||||
$link .= '</a>';
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Download';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the external transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use stdClass;
|
||||
use const E_USER_DEPRECATED;
|
||||
use function count;
|
||||
use function fclose;
|
||||
use function feof;
|
||||
use function fgets;
|
||||
use function fwrite;
|
||||
use function htmlspecialchars;
|
||||
use function is_resource;
|
||||
use function proc_close;
|
||||
use function proc_open;
|
||||
use function sprintf;
|
||||
use function strlen;
|
||||
use function trigger_error;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the external transformations plugins.
|
||||
*/
|
||||
abstract class ExternalTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'LINUX ONLY: Launches an external application and feeds it the column'
|
||||
. ' data via standard input. Returns the standard output of the'
|
||||
. ' application. The default is Tidy, to pretty-print HTML code.'
|
||||
. ' For security reasons, you have to manually edit the file'
|
||||
. ' libraries/classes/Plugins/Transformations/Abs/ExternalTransformationsPlugin.php'
|
||||
. ' and list the tools you want to make available.'
|
||||
. ' The first option is then the number of the program you want to'
|
||||
. ' use. The second option should be blank for historical reasons.'
|
||||
. ' The third option, if set to 1, will convert the output using'
|
||||
. ' htmlspecialchars() (Default 1). The fourth option, if set to 1,'
|
||||
. ' will prevent wrapping and ensure that the output appears all on'
|
||||
. ' one line (Default 1).'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables no-wrapping
|
||||
*
|
||||
* @param array $options transformation options
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function applyTransformationNoWrap(array $options = [])
|
||||
{
|
||||
if (! isset($options[3]) || $options[3] == '') {
|
||||
$nowrap = true;
|
||||
} elseif ($options[3] == '1' || $options[3] == 1) {
|
||||
$nowrap = true;
|
||||
} else {
|
||||
$nowrap = false;
|
||||
}
|
||||
|
||||
return $nowrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
// possibly use a global transform and feed it with special options
|
||||
|
||||
// further operations on $buffer using the $options[] array.
|
||||
|
||||
$allowed_programs = [];
|
||||
|
||||
// WARNING:
|
||||
//
|
||||
// It's up to administrator to allow anything here. Note that users may
|
||||
// specify any parameters, so when programs allow output redirection or
|
||||
// any other possibly dangerous operations, you should write wrapper
|
||||
// script that will publish only functions you really want.
|
||||
//
|
||||
// Add here program definitions like (note that these are NOT safe
|
||||
// programs):
|
||||
//
|
||||
//$allowed_programs[0] = '/usr/local/bin/tidy';
|
||||
//$allowed_programs[1] = '/usr/local/bin/validate';
|
||||
|
||||
// no-op when no allowed programs
|
||||
if (count($allowed_programs) === 0) {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions(
|
||||
$options,
|
||||
$cfg['DefaultTransformations']['External']
|
||||
);
|
||||
|
||||
if (isset($allowed_programs[$options[0]])) {
|
||||
$program = $allowed_programs[$options[0]];
|
||||
} else {
|
||||
$program = $allowed_programs[0];
|
||||
}
|
||||
|
||||
if (isset($options[1]) && strlen((string) $options[1]) > 0) {
|
||||
trigger_error(sprintf(
|
||||
__(
|
||||
'You are using the external transformation command line'
|
||||
. ' options field, which has been deprecated for security reasons.'
|
||||
. ' Add all command line options directly to the definition in %s.'
|
||||
),
|
||||
'[code]libraries/classes/Plugins/Transformations/Abs/ExternalTransformationsPlugin.php[/code]'
|
||||
), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
// needs PHP >= 4.3.0
|
||||
$newstring = '';
|
||||
$descriptorspec = [
|
||||
0 => [
|
||||
'pipe',
|
||||
'r',
|
||||
],
|
||||
1 => [
|
||||
'pipe',
|
||||
'w',
|
||||
],
|
||||
];
|
||||
$process = proc_open($program . ' ' . $options[1], $descriptorspec, $pipes);
|
||||
if (is_resource($process)) {
|
||||
fwrite($pipes[0], $buffer);
|
||||
fclose($pipes[0]);
|
||||
|
||||
while (! feof($pipes[1])) {
|
||||
$newstring .= fgets($pipes[1], 1024);
|
||||
}
|
||||
fclose($pipes[1]);
|
||||
// we don't currently use the return value
|
||||
proc_close($process);
|
||||
}
|
||||
|
||||
if ($options[2] == 1 || $options[2] == '2') {
|
||||
$retstring = htmlspecialchars($newstring);
|
||||
} else {
|
||||
$retstring = $newstring;
|
||||
}
|
||||
|
||||
return $retstring;
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'External';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the formatted transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use stdClass;
|
||||
use function strtr;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the formatted transformations plugins.
|
||||
*/
|
||||
abstract class FormattedTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Displays the contents of the column as-is, without running it'
|
||||
. ' through htmlspecialchars(). That is, the column is assumed'
|
||||
. ' to contain valid HTML.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
return '<iframe srcdoc="'
|
||||
. strtr($buffer, '"', '\'')
|
||||
. '" sandbox=""></iframe>';
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Formatted';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the hex transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use stdClass;
|
||||
use function bin2hex;
|
||||
use function chunk_split;
|
||||
use function intval;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the hex transformations plugins.
|
||||
*/
|
||||
abstract class HexTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Displays hexadecimal representation of data. Optional first'
|
||||
. ' parameter specifies how often space will be added (defaults'
|
||||
. ' to 2 nibbles).'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
// possibly use a global transform and feed it with special options
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Hex']);
|
||||
$options[0] = intval($options[0]);
|
||||
|
||||
if ($options[0] < 1) {
|
||||
return bin2hex($buffer);
|
||||
}
|
||||
|
||||
return chunk_split(bin2hex($buffer), $options[0], ' ');
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Hex';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the link transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use PhpMyAdmin\Url;
|
||||
use stdClass;
|
||||
use function htmlspecialchars;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the link transformations plugins.
|
||||
*/
|
||||
abstract class ImageLinkTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Displays a link to download this image.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
// must disable the page loader, see
|
||||
// https://wiki.phpmyadmin.net/pma/Page_loader#Bypassing_the_page_loader
|
||||
$link = '<a class="disableAjax" target="_blank" rel="noopener noreferrer" href="';
|
||||
$link .= Url::getFromRoute('/transformation/wrapper', $options['wrapper_params']);
|
||||
$link .= '" alt="[' . htmlspecialchars($buffer);
|
||||
$link .= ']">[BLOB]</a>';
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'ImageLink';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the image upload input transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\IOTransformationsPlugin;
|
||||
use PhpMyAdmin\Url;
|
||||
use stdClass;
|
||||
use function bin2hex;
|
||||
use function intval;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the image upload transformations plugins.
|
||||
*/
|
||||
abstract class ImageUploadTransformationsPlugin extends IOTransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Image upload functionality which also displays a thumbnail.'
|
||||
. ' The options are the width and height of the thumbnail'
|
||||
. ' in pixels. Defaults to 100 X 100.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html for input field to override default textarea.
|
||||
* Note: Return empty string if default textarea is required.
|
||||
*
|
||||
* @param array $column column details
|
||||
* @param int $row_id row number
|
||||
* @param string $column_name_appendix the name attribute
|
||||
* @param array $options transformation options
|
||||
* @param string $value Current field value
|
||||
* @param string $text_dir text direction
|
||||
* @param int $tabindex tab index
|
||||
* @param int $tabindex_for_value offset for the values tabindex
|
||||
* @param int $idindex id index
|
||||
*
|
||||
* @return string the html for input field
|
||||
*/
|
||||
public function getInputHtml(
|
||||
array $column,
|
||||
$row_id,
|
||||
$column_name_appendix,
|
||||
array $options,
|
||||
$value,
|
||||
$text_dir,
|
||||
$tabindex,
|
||||
$tabindex_for_value,
|
||||
$idindex
|
||||
) {
|
||||
$html = '';
|
||||
$src = '';
|
||||
if (! empty($value)) {
|
||||
$html = '<input type="hidden" name="fields_prev' . $column_name_appendix
|
||||
. '" value="' . bin2hex($value) . '">';
|
||||
$html .= '<input type="hidden" name="fields' . $column_name_appendix
|
||||
. '" value="' . bin2hex($value) . '">';
|
||||
$src = Url::getFromRoute('/transformation/wrapper', $options['wrapper_params']);
|
||||
}
|
||||
$html .= '<img src="' . $src . '" width="'
|
||||
. (isset($options[0]) ? intval($options[0]) : '100') . '" height="'
|
||||
. (isset($options[1]) ? intval($options[1]) : '100') . '" alt="'
|
||||
. __('Image preview here') . '">';
|
||||
$html .= '<br><input type="file" name="fields_upload'
|
||||
. $column_name_appendix . '" accept="image/*" class="image-upload">';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of scripts (filename) required for plugin
|
||||
* initialization and handling
|
||||
*
|
||||
* @return array javascripts to be included
|
||||
*/
|
||||
public function getScripts()
|
||||
{
|
||||
return ['transformations/image_upload.js'];
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Image upload';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the inline transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use PhpMyAdmin\Url;
|
||||
use stdClass;
|
||||
use function array_merge;
|
||||
use function defined;
|
||||
use function htmlspecialchars;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the inline transformations plugins.
|
||||
*/
|
||||
abstract class InlineTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Displays a clickable thumbnail. The options are the maximum width'
|
||||
. ' and height in pixels. The original aspect ratio is preserved.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Inline']);
|
||||
|
||||
if (defined('PMA_IS_GD2') && PMA_IS_GD2 === 1) {
|
||||
return '<a href="' . Url::getFromRoute('/transformation/wrapper', $options['wrapper_params'])
|
||||
. '" rel="noopener noreferrer" target="_blank"><img src="'
|
||||
. Url::getFromRoute('/transformation/wrapper', array_merge($options['wrapper_params'], [
|
||||
'resize' => 'jpeg',
|
||||
'newWidth' => (int) $options[0],
|
||||
'newHeight' => (int) $options[1],
|
||||
]))
|
||||
. '" alt="[' . htmlspecialchars($buffer) . ']" border="0"></a>';
|
||||
}
|
||||
|
||||
return '<img src="' . Url::getFromRoute('/transformation/wrapper', $options['wrapper_params'])
|
||||
. '" alt="[' . htmlspecialchars($buffer) . ']" width="320" height="240">';
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Inline';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the long to IPv4 transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use PhpMyAdmin\Utils\FormatConverter;
|
||||
use stdClass;
|
||||
use function htmlspecialchars;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the long to IPv4 transformations plugins.
|
||||
*/
|
||||
abstract class LongToIPv4TransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Converts an (IPv4) Internet network address stored as a BIGINT'
|
||||
. ' into a string in Internet standard dotted format.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
return htmlspecialchars(FormatConverter::longToIp($buffer));
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Long To IPv4';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the prepend/append transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use stdClass;
|
||||
use function htmlspecialchars;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the prepend/append transformations plugins.
|
||||
*/
|
||||
abstract class PreApPendTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Prepends and/or Appends text to a string. First option is text'
|
||||
. ' to be prepended, second is appended (enclosed in single'
|
||||
. ' quotes, default empty string).'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['PreApPend']);
|
||||
|
||||
//just prepend and/or append the options to the original text
|
||||
return htmlspecialchars($options[0]) . htmlspecialchars($buffer)
|
||||
. htmlspecialchars($options[1]);
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'PreApPend';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the regex validation input transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\IOTransformationsPlugin;
|
||||
use stdClass;
|
||||
use function htmlspecialchars;
|
||||
use function preg_match;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the regex validation
|
||||
* input transformations plugins.
|
||||
*/
|
||||
abstract class RegexValidationTransformationsPlugin extends IOTransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Validates the string using regular expression '
|
||||
. 'and performs insert only if string matches it. '
|
||||
. 'The first option is the Regular Expression.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
// reset properties of object
|
||||
$this->reset();
|
||||
if (! empty($options[0]) && ! preg_match($options[0], $buffer)) {
|
||||
$this->success = false;
|
||||
$this->error = sprintf(
|
||||
__('Validation failed for the input string %s.'),
|
||||
htmlspecialchars($buffer)
|
||||
);
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Regex Validation';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the SQL transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Html\Generator;
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the SQL transformations plugins.
|
||||
*/
|
||||
abstract class SQLTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Formats text as SQL query with syntax highlighting.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
return Generator::formatSql($buffer);
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'SQL';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the substring transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use stdClass;
|
||||
use function htmlspecialchars;
|
||||
use function mb_strlen;
|
||||
use function mb_substr;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the substring transformations plugins.
|
||||
*/
|
||||
abstract class SubstringTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Displays a part of a string. The first option is the number of'
|
||||
. ' characters to skip from the beginning of the string (Default 0).'
|
||||
. ' The second option is the number of characters to return (Default:'
|
||||
. ' until end of string). The third option is the string to append'
|
||||
. ' and/or prepend when truncation occurs (Default: "…").'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
// possibly use a global transform and feed it with special options
|
||||
|
||||
// further operations on $buffer using the $options[] array.
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Substring']);
|
||||
|
||||
$optionZero = (int) $options[0];
|
||||
|
||||
if ($options[1] !== 'all') {
|
||||
$newtext = mb_substr(
|
||||
(string) $buffer,
|
||||
$optionZero,
|
||||
(int) $options[1]
|
||||
);
|
||||
} else {
|
||||
$newtext = mb_substr((string) $buffer, $optionZero);
|
||||
}
|
||||
|
||||
$length = mb_strlen($newtext);
|
||||
$baselength = mb_strlen((string) $buffer);
|
||||
if ($length != $baselength) {
|
||||
if ($optionZero !== 0) {
|
||||
$newtext = $options[2] . $newtext;
|
||||
}
|
||||
|
||||
if ($length + $optionZero != $baselength) {
|
||||
$newtext .= $options[2];
|
||||
}
|
||||
}
|
||||
|
||||
return htmlspecialchars($newtext);
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Substring';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the text file upload input transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\IOTransformationsPlugin;
|
||||
use stdClass;
|
||||
use function htmlspecialchars;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the text file upload
|
||||
* input transformations plugins.
|
||||
*/
|
||||
abstract class TextFileUploadTransformationsPlugin extends IOTransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'File upload functionality for TEXT columns. '
|
||||
. 'It does not have a textarea for input.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html for input field to override default textarea.
|
||||
* Note: Return empty string if default textarea is required.
|
||||
*
|
||||
* @param array $column column details
|
||||
* @param int $row_id row number
|
||||
* @param string $column_name_appendix the name attribute
|
||||
* @param array $options transformation options
|
||||
* @param string $value Current field value
|
||||
* @param string $text_dir text direction
|
||||
* @param int $tabindex tab index
|
||||
* @param int $tabindex_for_value offset for the values tabindex
|
||||
* @param int $idindex id index
|
||||
*
|
||||
* @return string the html for input field
|
||||
*/
|
||||
public function getInputHtml(
|
||||
array $column,
|
||||
$row_id,
|
||||
$column_name_appendix,
|
||||
array $options,
|
||||
$value,
|
||||
$text_dir,
|
||||
$tabindex,
|
||||
$tabindex_for_value,
|
||||
$idindex
|
||||
) {
|
||||
$html = '';
|
||||
if (! empty($value)) {
|
||||
$html = '<input type="hidden" name="fields_prev' . $column_name_appendix
|
||||
. '" value="' . htmlspecialchars($value) . '">';
|
||||
$html .= '<input type="hidden" name="fields' . $column_name_appendix
|
||||
. '" value="' . htmlspecialchars($value) . '">';
|
||||
}
|
||||
$html .= '<input type="file" name="fields_upload'
|
||||
. $column_name_appendix . '">';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Text file upload';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the image link transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use PhpMyAdmin\Sanitize;
|
||||
use PhpMyAdmin\Template;
|
||||
use stdClass;
|
||||
use function htmlspecialchars;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the image link transformations plugins.
|
||||
*/
|
||||
abstract class TextImageLinkTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Displays an image and a link; the column contains the filename. The'
|
||||
. ' first option is a URL prefix like "https://www.example.com/". The'
|
||||
. ' second and third options are the width and the height in pixels.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['TextImageLink']);
|
||||
$url = $options[0] . $buffer;
|
||||
/* Do not allow javascript links */
|
||||
if (! Sanitize::checkLink($url, true, true)) {
|
||||
return htmlspecialchars($url);
|
||||
}
|
||||
|
||||
$template = new Template();
|
||||
|
||||
return $template->render('plugins/text_image_link_transformations', [
|
||||
'url' => $url,
|
||||
'width' => (int) $options[1],
|
||||
'height' => (int) $options[2],
|
||||
'buffer' => $buffer,
|
||||
]);
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'Image Link';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* Abstract class for the link transformations plugins
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Plugins\Transformations\Abs;
|
||||
|
||||
use PhpMyAdmin\Plugins\TransformationsPlugin;
|
||||
use PhpMyAdmin\Sanitize;
|
||||
use stdClass;
|
||||
use function htmlspecialchars;
|
||||
|
||||
/**
|
||||
* Provides common methods for all of the link transformations plugins.
|
||||
*/
|
||||
abstract class TextLinkTransformationsPlugin extends TransformationsPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the transformation description of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInfo()
|
||||
{
|
||||
return __(
|
||||
'Displays a link; the column contains the filename. The first option'
|
||||
. ' is a URL prefix like "https://www.example.com/". The second option'
|
||||
. ' is a title for the link.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual work of each specific transformations plugin.
|
||||
*
|
||||
* @param string $buffer text to be transformed
|
||||
* @param array $options transformation options
|
||||
* @param stdClass|null $meta meta information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function applyTransformation($buffer, array $options = [], ?stdClass $meta = null)
|
||||
{
|
||||
$cfg = $GLOBALS['cfg'];
|
||||
$options = $this->getOptions($options, $cfg['DefaultTransformations']['TextLink']);
|
||||
$url = ($options[0] ?? '') . (isset($options[2]) && $options[2] ? '' : $buffer);
|
||||
/* Do not allow javascript links */
|
||||
if (! Sanitize::checkLink($url, true, true)) {
|
||||
return htmlspecialchars($url);
|
||||
}
|
||||
|
||||
return '<a href="'
|
||||
. htmlspecialchars($url)
|
||||
. '" title="'
|
||||
. htmlspecialchars($options[1] ?? '')
|
||||
. '" target="_blank" rel="noopener noreferrer">'
|
||||
. htmlspecialchars($options[1] ?? $buffer)
|
||||
. '</a>';
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
/**
|
||||
* Gets the transformation name of the specific plugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'TextLink';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue