Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../var/softacul.../moodle29
File: check_utf8.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Does the database server claim to have support for UTF-8 Multibyte (utf8mb4) collation?
[2] Fix | Delete
*
[3] Fix | Delete
* libmysql supports utf8mb4 since 5.5.3 (same version as the MySQL server). mysqlnd supports utf8mb4 since 5.0.9.
[4] Fix | Delete
*
[5] Fix | Delete
* @return boolean
[6] Fix | Delete
*
[7] Fix | Delete
* @since CMS 3.5.0
[8] Fix | Delete
*/
[9] Fix | Delete
function serverClaimsUtf8mb4Support()
[10] Fix | Delete
{
[11] Fix | Delete
[12] Fix | Delete
if(!is_large_prefix_enabled()){
[13] Fix | Delete
return false;
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
$client_version = mysqli_get_client_info();
[17] Fix | Delete
[18] Fix | Delete
if (strpos($client_version, 'mysqlnd') !== false)
[19] Fix | Delete
{
[20] Fix | Delete
$client_version = preg_replace('/^\D+([\d.]+).*/', '$1', $client_version);
[21] Fix | Delete
[22] Fix | Delete
return version_compare($client_version, '5.0.9', '>=');
[23] Fix | Delete
}
[24] Fix | Delete
else
[25] Fix | Delete
{
[26] Fix | Delete
return version_compare($client_version, '5.5.3', '>=');
[27] Fix | Delete
}
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
function get_dbtype() {
[31] Fix | Delete
[32] Fix | Delete
$con = mysqli_connect("[[softdbhost]]","[[softdbuser]]","[[softdbpass]]","[[softdb]]");
[33] Fix | Delete
[34] Fix | Delete
$details = mysqli_get_server_info($con);
[35] Fix | Delete
[36] Fix | Delete
if(preg_match('/mariadb/is', $details)){
[37] Fix | Delete
return 'mariadb';
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
return 'mysqli';
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
function get_engine_type(){
[44] Fix | Delete
return 'innodb';
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Get the version of the database connector.
[49] Fix | Delete
*
[50] Fix | Delete
* @return string The database connector version.
[51] Fix | Delete
*
[52] Fix | Delete
* @since 12.1
[53] Fix | Delete
*/
[54] Fix | Delete
function getVersion(){
[55] Fix | Delete
global $con;
[56] Fix | Delete
[57] Fix | Delete
$con = mysqli_connect("[[softdbhost]]","[[softdbuser]]","[[softdbpass]]","[[softdb]]");
[58] Fix | Delete
[59] Fix | Delete
$ver = mysqli_get_server_info($con);
[60] Fix | Delete
[61] Fix | Delete
if(preg_match('/mariadb/is', $ver)){
[62] Fix | Delete
preg_match('/-(.*?)-mariadb/is', $ver, $matches);
[63] Fix | Delete
[64] Fix | Delete
if(empty($matches[1])){
[65] Fix | Delete
preg_match('/(.*?)-mariadb/is', $ver, $matches);
[66] Fix | Delete
}
[67] Fix | Delete
if(!empty($matches[1])){
[68] Fix | Delete
$ver = $matches[1];
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
return $ver;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
function get_row_format($table = null) {
[76] Fix | Delete
global $con;
[77] Fix | Delete
$rowformat = null;
[78] Fix | Delete
if (is_antelope_file_format_no_more_supported()) {
[79] Fix | Delete
$rowformat = 'Barracuda';
[80] Fix | Delete
return $rowformat;
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
$sql = "SHOW VARIABLES LIKE 'innodb_file_format'";
[84] Fix | Delete
$result = mysqli_query($con, $sql);
[85] Fix | Delete
if ($rec = $result->fetch_assoc()) {
[86] Fix | Delete
// MySQL 8 BC: information_schema.* returns the fields in upper case.
[87] Fix | Delete
$rec = array_change_key_case($rec, CASE_LOWER);
[88] Fix | Delete
if (isset($table)) {
[89] Fix | Delete
$rowformat = $rec['row_format'];
[90] Fix | Delete
} else {
[91] Fix | Delete
$rowformat = $rec['value'];
[92] Fix | Delete
}
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
return $rowformat;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
function is_antelope_file_format_no_more_supported() {
[99] Fix | Delete
// Breaking change: Antelope file format support has been removed from both MySQL and MariaDB.
[100] Fix | Delete
// The following InnoDB file format configuration parameters were deprecated and then removed:
[101] Fix | Delete
// - innodb_file_format
[102] Fix | Delete
// - innodb_file_format_check
[103] Fix | Delete
// - innodb_file_format_max
[104] Fix | Delete
// - innodb_large_prefix
[105] Fix | Delete
// 1. MySQL: deprecated in 5.7.7 and removed 8.0.0+.
[106] Fix | Delete
$ismysqlge8d0d0 = (get_dbtype() == 'mysqli') &&
[107] Fix | Delete
version_compare(getVersion(), '8.0.0', '>=');
[108] Fix | Delete
// 2. MariaDB: deprecated in 10.2.0 and removed 10.3.1+.
[109] Fix | Delete
$ismariadbge10d3d1 = (get_dbtype() == 'mariadb') &&
[110] Fix | Delete
version_compare(getVersion(), '10.3.1', '>=');
[111] Fix | Delete
[112] Fix | Delete
return $ismysqlge8d0d0 || $ismariadbge10d3d1;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
function is_compressed_row_format_supported($cached = true) {
[116] Fix | Delete
[117] Fix | Delete
$engine = get_engine_type();
[118] Fix | Delete
$info = getVersion();
[119] Fix | Delete
[120] Fix | Delete
if (version_compare($info, '5.5.0') < 0) {
[121] Fix | Delete
// MySQL 5.1 is not supported here because we cannot read the file format.
[122] Fix | Delete
$compressedrowformatsupported = false;
[123] Fix | Delete
[124] Fix | Delete
} else if ($engine !== 'innodb' and $engine !== 'xtradb') {
[125] Fix | Delete
// Other engines are not supported, most probably not compatible.
[126] Fix | Delete
$compressedrowformatsupported = false;
[127] Fix | Delete
[128] Fix | Delete
} else if (!is_file_per_table_enabled()) {
[129] Fix | Delete
$compressedrowformatsupported = false;
[130] Fix | Delete
[131] Fix | Delete
} else if (get_row_format() !== 'Barracuda') {
[132] Fix | Delete
$compressedrowformatsupported = false;
[133] Fix | Delete
[134] Fix | Delete
} else {
[135] Fix | Delete
// All the tests passed, we can safely use ROW_FORMAT=Compressed in sql statements.
[136] Fix | Delete
$compressedrowformatsupported = true;
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
return $compressedrowformatsupported;
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
function is_file_per_table_enabled() {
[143] Fix | Delete
global $con;
[144] Fix | Delete
$sql = "SHOW VARIABLES LIKE 'innodb_file_per_table'";
[145] Fix | Delete
$result = mysqli_query($con, $sql);
[146] Fix | Delete
if ($rec = $result->fetch_assoc()) {
[147] Fix | Delete
// MySQL 8 BC: information_schema.* returns the fields in upper case.
[148] Fix | Delete
$rec = array_change_key_case($rec, CASE_LOWER);
[149] Fix | Delete
if ($rec['value'] == 'ON') {
[150] Fix | Delete
return true;
[151] Fix | Delete
}
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
return false;
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
function get_row_format_sql($engine = null, $collation = null) {
[158] Fix | Delete
[159] Fix | Delete
$rowformat = '';
[160] Fix | Delete
$serverClaimsUtf8mb4Support = serverClaimsUtf8mb4Support();
[161] Fix | Delete
$engine = get_engine_type();
[162] Fix | Delete
[163] Fix | Delete
if (($engine === 'innodb' || $engine === 'xtradb') && !empty($serverClaimsUtf8mb4Support)) {
[164] Fix | Delete
if (is_compressed_row_format_supported()) {
[165] Fix | Delete
$rowformat = "ROW_FORMAT=COMPRESSED";
[166] Fix | Delete
} else {
[167] Fix | Delete
$rowformat = "ROW_FORMAT=DYNAMIC";
[168] Fix | Delete
}
[169] Fix | Delete
}
[170] Fix | Delete
return $rowformat;
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
function is_large_prefix_enabled() {
[174] Fix | Delete
global $con;
[175] Fix | Delete
[176] Fix | Delete
if (is_antelope_file_format_no_more_supported()) {
[177] Fix | Delete
// Breaking change: Antelope file format support has been removed, only Barracuda.
[178] Fix | Delete
return true;
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
$sql = "SHOW VARIABLES LIKE 'innodb_large_prefix'";
[182] Fix | Delete
$result = mysqli_query($con, $sql);
[183] Fix | Delete
if ($rec = $result->fetch_assoc()) {
[184] Fix | Delete
// MySQL 8 BC: information_schema.* returns the fields in upper case.
[185] Fix | Delete
$rec = array_change_key_case($rec, CASE_LOWER);
[186] Fix | Delete
if ($rec['value'] == 'ON') {
[187] Fix | Delete
return true;
[188] Fix | Delete
}
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
return false;
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
$serverClaimsUtf8mb4Support = serverClaimsUtf8mb4Support();
[195] Fix | Delete
$row_format = get_row_format_sql();
[196] Fix | Delete
[197] Fix | Delete
if(!empty($serverClaimsUtf8mb4Support) && !empty($row_format)){
[198] Fix | Delete
echo '<claim_utf8>utf8mb4</claim_utf8>';
[199] Fix | Delete
echo '</br>';
[200] Fix | Delete
echo '<row_format>'.$row_format.'</row_format>';
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
?>
[204] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function