Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/flow-flo.../libs/cakephp/utility
File: Text.php
}
[1000] Fix | Delete
[1001] Fix | Delete
/**
[1002] Fix | Delete
* Converts the decimal value of a multibyte character string
[1003] Fix | Delete
* to a string
[1004] Fix | Delete
*
[1005] Fix | Delete
* @param array $array Array
[1006] Fix | Delete
* @return string
[1007] Fix | Delete
*/
[1008] Fix | Delete
public static function ascii(array $array)
[1009] Fix | Delete
{
[1010] Fix | Delete
$ascii = '';
[1011] Fix | Delete
[1012] Fix | Delete
foreach ($array as $utf8) {
[1013] Fix | Delete
if ($utf8 < 128) {
[1014] Fix | Delete
$ascii .= chr($utf8);
[1015] Fix | Delete
} elseif ($utf8 < 2048) {
[1016] Fix | Delete
$ascii .= chr(192 + (($utf8 - ($utf8 % 64)) / 64));
[1017] Fix | Delete
$ascii .= chr(128 + ($utf8 % 64));
[1018] Fix | Delete
} else {
[1019] Fix | Delete
$ascii .= chr(224 + (($utf8 - ($utf8 % 4096)) / 4096));
[1020] Fix | Delete
$ascii .= chr(128 + ((($utf8 % 4096) - ($utf8 % 64)) / 64));
[1021] Fix | Delete
$ascii .= chr(128 + ($utf8 % 64));
[1022] Fix | Delete
}
[1023] Fix | Delete
}
[1024] Fix | Delete
[1025] Fix | Delete
return $ascii;
[1026] Fix | Delete
}
[1027] Fix | Delete
[1028] Fix | Delete
/**
[1029] Fix | Delete
* Converts filesize from human readable string to bytes
[1030] Fix | Delete
*
[1031] Fix | Delete
* @param string $size Size in human readable string like '5MB', '5M', '500B', '50kb' etc.
[1032] Fix | Delete
* @param mixed $default Value to be returned when invalid size was used, for example 'Unknown type'
[1033] Fix | Delete
* @return mixed Number of bytes as integer on success, `$default` on failure if not false
[1034] Fix | Delete
* @throws \InvalidArgumentException On invalid Unit type.
[1035] Fix | Delete
* @link https://book.cakephp.org/3/en/core-libraries/text.html#Cake\Utility\Text::parseFileSize
[1036] Fix | Delete
*/
[1037] Fix | Delete
public static function parseFileSize($size, $default = false)
[1038] Fix | Delete
{
[1039] Fix | Delete
if (ctype_digit($size)) {
[1040] Fix | Delete
return (int)$size;
[1041] Fix | Delete
}
[1042] Fix | Delete
$size = strtoupper($size);
[1043] Fix | Delete
[1044] Fix | Delete
$l = -2;
[1045] Fix | Delete
$i = array_search(substr($size, -2), ['KB', 'MB', 'GB', 'TB', 'PB'], true);
[1046] Fix | Delete
if ($i === false) {
[1047] Fix | Delete
$l = -1;
[1048] Fix | Delete
$i = array_search(substr($size, -1), ['K', 'M', 'G', 'T', 'P'], true);
[1049] Fix | Delete
}
[1050] Fix | Delete
if ($i !== false) {
[1051] Fix | Delete
$size = (float)substr($size, 0, $l);
[1052] Fix | Delete
[1053] Fix | Delete
return (int)($size * pow(1024, $i + 1));
[1054] Fix | Delete
}
[1055] Fix | Delete
[1056] Fix | Delete
if (substr($size, -1) === 'B' && ctype_digit(substr($size, 0, -1))) {
[1057] Fix | Delete
$size = substr($size, 0, -1);
[1058] Fix | Delete
[1059] Fix | Delete
return (int)$size;
[1060] Fix | Delete
}
[1061] Fix | Delete
[1062] Fix | Delete
if ($default !== false) {
[1063] Fix | Delete
return $default;
[1064] Fix | Delete
}
[1065] Fix | Delete
throw new InvalidArgumentException('No unit type.');
[1066] Fix | Delete
}
[1067] Fix | Delete
[1068] Fix | Delete
/**
[1069] Fix | Delete
* Get the default transliterator.
[1070] Fix | Delete
*
[1071] Fix | Delete
* @return \Transliterator|null Either a Transliterator instance, or `null`
[1072] Fix | Delete
* in case no transliterator has been set yet.
[1073] Fix | Delete
* @since 3.7.0
[1074] Fix | Delete
*/
[1075] Fix | Delete
public static function getTransliterator()
[1076] Fix | Delete
{
[1077] Fix | Delete
return static::$_defaultTransliterator;
[1078] Fix | Delete
}
[1079] Fix | Delete
[1080] Fix | Delete
/**
[1081] Fix | Delete
* Set the default transliterator.
[1082] Fix | Delete
*
[1083] Fix | Delete
* @param \Transliterator $transliterator A `Transliterator` instance.
[1084] Fix | Delete
* @return void
[1085] Fix | Delete
* @since 3.7.0
[1086] Fix | Delete
*/
[1087] Fix | Delete
public static function setTransliterator(\Transliterator $transliterator)
[1088] Fix | Delete
{
[1089] Fix | Delete
static::$_defaultTransliterator = $transliterator;
[1090] Fix | Delete
}
[1091] Fix | Delete
[1092] Fix | Delete
/**
[1093] Fix | Delete
* Get default transliterator identifier string.
[1094] Fix | Delete
*
[1095] Fix | Delete
* @return string Transliterator identifier.
[1096] Fix | Delete
*/
[1097] Fix | Delete
public static function getTransliteratorId()
[1098] Fix | Delete
{
[1099] Fix | Delete
return static::$_defaultTransliteratorId;
[1100] Fix | Delete
}
[1101] Fix | Delete
[1102] Fix | Delete
/**
[1103] Fix | Delete
* Set default transliterator identifier string.
[1104] Fix | Delete
*
[1105] Fix | Delete
* @param string $transliteratorId Transliterator identifier.
[1106] Fix | Delete
* @return void
[1107] Fix | Delete
*/
[1108] Fix | Delete
public static function setTransliteratorId($transliteratorId)
[1109] Fix | Delete
{
[1110] Fix | Delete
$transliterator = transliterator_create($transliteratorId);
[1111] Fix | Delete
if ($transliterator === null) {
[1112] Fix | Delete
throw new Exception('Unable to create transliterator for id: ' . $transliteratorId);
[1113] Fix | Delete
}
[1114] Fix | Delete
[1115] Fix | Delete
static::setTransliterator($transliterator);
[1116] Fix | Delete
static::$_defaultTransliteratorId = $transliteratorId;
[1117] Fix | Delete
}
[1118] Fix | Delete
[1119] Fix | Delete
/**
[1120] Fix | Delete
* Transliterate string.
[1121] Fix | Delete
*
[1122] Fix | Delete
* @param string $string String to transliterate.
[1123] Fix | Delete
* @param \Transliterator|string|null $transliterator Either a Transliterator
[1124] Fix | Delete
* instance, or a transliterator identifier string. If `null`, the default
[1125] Fix | Delete
* transliterator (identifier) set via `setTransliteratorId()` or
[1126] Fix | Delete
* `setTransliterator()` will be used.
[1127] Fix | Delete
* @return string
[1128] Fix | Delete
* @see https://secure.php.net/manual/en/transliterator.transliterate.php
[1129] Fix | Delete
*/
[1130] Fix | Delete
public static function transliterate($string, $transliterator = null)
[1131] Fix | Delete
{
[1132] Fix | Delete
if (!$transliterator) {
[1133] Fix | Delete
$transliterator = static::$_defaultTransliterator ?: static::$_defaultTransliteratorId;
[1134] Fix | Delete
}
[1135] Fix | Delete
[1136] Fix | Delete
$return = transliterator_transliterate($transliterator, $string);
[1137] Fix | Delete
if ($return === false) {
[1138] Fix | Delete
throw new Exception(sprintf('Unable to transliterate string: %s', $string));
[1139] Fix | Delete
}
[1140] Fix | Delete
[1141] Fix | Delete
return $return;
[1142] Fix | Delete
}
[1143] Fix | Delete
[1144] Fix | Delete
/**
[1145] Fix | Delete
* Returns a string with all spaces converted to dashes (by default),
[1146] Fix | Delete
* characters transliterated to ASCII characters, and non word characters removed.
[1147] Fix | Delete
*
[1148] Fix | Delete
* ### Options:
[1149] Fix | Delete
*
[1150] Fix | Delete
* - `replacement`: Replacement string. Default '-'.
[1151] Fix | Delete
* - `transliteratorId`: A valid transliterator id string.
[1152] Fix | Delete
* If `null` (default) the transliterator (identifier) set via
[1153] Fix | Delete
* `setTransliteratorId()` or `setTransliterator()` will be used.
[1154] Fix | Delete
* If `false` no transliteration will be done, only non words will be removed.
[1155] Fix | Delete
* - `preserve`: Specific non-word character to preserve. Default `null`.
[1156] Fix | Delete
* For e.g. this option can be set to '.' to generate clean file names.
[1157] Fix | Delete
*
[1158] Fix | Delete
* @param string $string the string you want to slug
[1159] Fix | Delete
* @param array|string $options If string it will be use as replacement character
[1160] Fix | Delete
* or an array of options.
[1161] Fix | Delete
* @return string
[1162] Fix | Delete
* @see setTransliterator()
[1163] Fix | Delete
* @see setTransliteratorId()
[1164] Fix | Delete
*/
[1165] Fix | Delete
public static function slug($string, $options = [])
[1166] Fix | Delete
{
[1167] Fix | Delete
if (is_string($options)) {
[1168] Fix | Delete
$options = ['replacement' => $options];
[1169] Fix | Delete
}
[1170] Fix | Delete
$options += [
[1171] Fix | Delete
'replacement' => '-',
[1172] Fix | Delete
'transliteratorId' => null,
[1173] Fix | Delete
'preserve' => null,
[1174] Fix | Delete
];
[1175] Fix | Delete
[1176] Fix | Delete
if ($options['transliteratorId'] !== false) {
[1177] Fix | Delete
$string = static::transliterate($string, $options['transliteratorId']);
[1178] Fix | Delete
}
[1179] Fix | Delete
[1180] Fix | Delete
$regex = '^\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}';
[1181] Fix | Delete
if ($options['preserve']) {
[1182] Fix | Delete
$regex .= preg_quote($options['preserve'], '/');
[1183] Fix | Delete
}
[1184] Fix | Delete
$quotedReplacement = preg_quote((string)$options['replacement'], '/');
[1185] Fix | Delete
$map = [
[1186] Fix | Delete
'/[' . $regex . ']/mu' => $options['replacement'],
[1187] Fix | Delete
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
[1188] Fix | Delete
];
[1189] Fix | Delete
if (is_string($options['replacement']) && strlen($options['replacement']) > 0) {
[1190] Fix | Delete
$map[sprintf('/[%s]+/mu', $quotedReplacement)] = $options['replacement'];
[1191] Fix | Delete
}
[1192] Fix | Delete
$string = preg_replace(array_keys($map), $map, $string);
[1193] Fix | Delete
[1194] Fix | Delete
return $string;
[1195] Fix | Delete
}
[1196] Fix | Delete
}
[1197] Fix | Delete
[1198] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function