本文整理汇总了PHP中PMA_Util::replaceBinaryContents方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Util::replaceBinaryContents方法的具体用法?PHP PMA_Util::replaceBinaryContents怎么用?PHP PMA_Util::replaceBinaryContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_Util
的用法示例。
在下文中一共展示了PMA_Util::replaceBinaryContents方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _displayBinaryAsPrintable
/**
* Display binary columns as hex string if requested
* otherwise escape the contents using the best possible way
*
* @param string $content String to parse
* @param string $binary_or_blob binary' or 'blob'
* @param int $hexlength optional, get substring
*
* @return String Displayable version of the binary string
*
* @access private
*
* @see _getDataCellForGeometryColumns
* _getDataCellForNonNumericAndNonBlobColumns
* _handleNonPrintableContents
*/
private function _displayBinaryAsPrintable($content, $binary_or_blob, $hexlength = null)
{
if ($binary_or_blob === 'binary' && $_SESSION['tmpval']['display_binary_as_hex']) {
$content = bin2hex($content);
if ($hexlength !== null) {
$content = $GLOBALS['PMA_String']->substr($content, $hexlength);
}
} elseif (PMA_Util::containsNonPrintableAscii($content)) {
if (PMA_PHP_INT_VERSION < 50400) {
$content = htmlspecialchars(PMA_Util::replaceBinaryContents($content));
} else {
// The ENT_SUBSTITUTE option is available for PHP >= 5.4.0
$content = htmlspecialchars(PMA_Util::replaceBinaryContents($content), ENT_SUBSTITUTE);
}
}
return $content;
}
示例2: testReplaceBinaryContents
/**
* replace binary contents test
*
* @param string $a String
* @param string $e Expected output
*
* @return void
*
* @dataProvider replaceBinaryContentsDataProvider
*/
public function testReplaceBinaryContents($a, $e)
{
$this->assertEquals($e, PMA_Util::replaceBinaryContents($a));
}
示例3: _displayBinaryAsPrintable
/**
* Display binary fields as hex string for PHP <5.4,
* otherwise escape the contents if it may be displayed as hex
*
* @param string $content String to parse
* @param string $binary_or_blob 'binary' or 'blob'
* @param int $hexlength optional, get substring
*
* @return Displayable version of the binary string
*
* @access private
*
* @see _getDataCellForGeometryColumns
* _getDataCellForNonNumericAndNonBlobColumns
* _handleNonPrintableContents
*/
private function _displayBinaryAsPrintable($content, $binary_or_blob, $hexlength = null)
{
if (PMA_PHP_INT_VERSION < 50400 || $binary_or_blob === 'binary' && $_SESSION['tmp_user_values']['display_binary_as_hex'] && PMA_Util::containsNonPrintableAscii($content)) {
$content = bin2hex($content);
if ($hexlength !== null) {
$content = PMA_substr($content, $hexlength);
}
} else {
$content = htmlspecialchars(PMA_Util::replaceBinaryContents($content), ENT_SUBSTITUTE);
}
return $content;
}
示例4: PMA_getSpecialCharsAndBackupFieldForExistingRow
/**
* Prepares the field value and retrieve special chars, backup field and data array
*
* @param array $current_row a row of the table
* @param array $column description of column in given table
* @param array $extracted_columnspec associative array containing type,
* spec_in_brackets and possibly
* enum_set_values (another array)
* @param boolean $real_null_value whether column value null or not null
* @param array $gis_data_types list of GIS data types
* @param string $column_name_appendix string to append to column name in input
*
* @return array $real_null_value, $data, $special_chars, $backup_field,
* $special_chars_encoded
*/
function PMA_getSpecialCharsAndBackupFieldForExistingRow($current_row, $column, $extracted_columnspec, $real_null_value, $gis_data_types, $column_name_appendix)
{
$special_chars_encoded = '';
// (we are editing)
if (is_null($current_row[$column['Field']])) {
$real_null_value = true;
$current_row[$column['Field']] = '';
$special_chars = '';
$data = $current_row[$column['Field']];
} elseif ($column['True_Type'] == 'bit') {
$special_chars = PMA_Util::printableBitValue($current_row[$column['Field']], $extracted_columnspec['spec_in_brackets']);
} elseif (in_array($column['True_Type'], $gis_data_types)) {
// Convert gis data to Well Know Text format
$current_row[$column['Field']] = PMA_Util::asWKT($current_row[$column['Field']], true);
$special_chars = htmlspecialchars($current_row[$column['Field']]);
} else {
// special binary "characters"
if ($column['is_binary'] || $column['is_blob'] && !$GLOBALS['cfg']['ProtectBinary']) {
if ($_SESSION['tmp_user_values']['display_binary_as_hex'] && $GLOBALS['cfg']['ShowFunctionFields']) {
$current_row[$column['Field']] = bin2hex($current_row[$column['Field']]);
$column['display_binary_as_hex'] = true;
} else {
$current_row[$column['Field']] = PMA_Util::replaceBinaryContents($current_row[$column['Field']]);
}
}
// end if
$special_chars = htmlspecialchars($current_row[$column['Field']]);
//We need to duplicate the first \n or otherwise we will lose
//the first newline entered in a VARCHAR or TEXT column
$special_chars_encoded = PMA_Util::duplicateFirstNewline($special_chars);
$data = $current_row[$column['Field']];
}
// end if... else...
//when copying row, it is useful to empty auto-increment column
// to prevent duplicate key error
if (isset($_REQUEST['default_action']) && $_REQUEST['default_action'] === 'insert') {
if ($column['Key'] === 'PRI' && strpos($column['Extra'], 'auto_increment') !== false) {
$data = $special_chars_encoded = $special_chars = null;
}
}
// If a timestamp field value is not included in an update
// statement MySQL auto-update it to the current timestamp;
// however, things have changed since MySQL 4.1, so
// it's better to set a fields_prev in this situation
$backup_field = '<input type="hidden" name="fields_prev' . $column_name_appendix . '" value="' . htmlspecialchars($current_row[$column['Field']]) . '" />';
return array($real_null_value, $special_chars_encoded, $special_chars, $data, $backup_field);
}
示例5: _handleNonPrintableContents
/**
* Verifies what to do with non-printable contents (binary or BLOB)
* in Browse mode.
*
* @param string $category BLOB|BINARY|GEOMETRY
* @param string $content the binary content
* @param string $transformation_plugin transformation plugin.
* Can also be the default function:
* PMA_mimeDefaultFunction
* @param string $transform_options transformation parameters
* @param string $default_function default transformation function
* @param object $meta the meta-information about the field
* @param array $url_params parameters that should go to the
* download link
*
* @return mixed string or float
*
* @access private
*
* @see _getDataCellForBlobColumns(),
* _getDataCellForGeometryColumns(),
* _getDataCellForNonNumericAndNonBlobColumns(),
* _getSortedColumnMessage()
*/
private function _handleNonPrintableContents($category, $content, $transformation_plugin, $transform_options, $default_function, $meta, $url_params = array())
{
$result = '[' . $category;
if (is_null($content)) {
$result .= ' - NULL';
$size = 0;
} elseif (isset($content)) {
$size = strlen($content);
$display_size = PMA_Util::formatByteDown($size, 3, 1);
$result .= ' - ' . $display_size[0] . ' ' . $display_size[1];
}
$result .= ']';
if (gettype($transformation_plugin) == "object" && strpos($transformation_plugin::getMIMESubtype(), 'Octetstream')) {
$result = $content;
}
if ($size > 0) {
if ($default_function != $transformation_plugin) {
$result = $transformation_plugin->applyTransformation($result, $transform_options, $meta);
} else {
$result = $this->{$default_function}($result, array(), $meta);
if (stristr($meta->type, self::BLOB_FIELD) && $_SESSION['tmp_user_values']['display_blob']) {
// in this case, restart from the original $content
$result = htmlspecialchars(PMA_Util::replaceBinaryContents($content));
}
/* Create link to download */
if (count($url_params) > 0) {
$result = '<a href="tbl_get_field.php' . PMA_generate_common_url($url_params) . '">' . $result . '</a>';
}
}
}
return $result;
}