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/themify-.../themify
File: themify-import-functions.php
fclose($fh1);
[1000] Fix | Delete
fclose($fh2);
[1001] Fix | Delete
}
[1002] Fix | Delete
} else {
[1003] Fix | Delete
yield false;
[1004] Fix | Delete
}
[1005] Fix | Delete
}
[1006] Fix | Delete
[1007] Fix | Delete
public static function import_media(array $post, $blob = null, $generate = true) {
[1008] Fix | Delete
if (!empty($post['thumb'])) {
[1009] Fix | Delete
if (!current_user_can('upload_files')) {
[1010] Fix | Delete
$error = __('You aren`t allowed to upload file', 'themify');
[1011] Fix | Delete
} else {
[1012] Fix | Delete
global $wpdb;
[1013] Fix | Delete
$error = '';
[1014] Fix | Delete
$thumb = sanitize_text_field($post['thumb']);
[1015] Fix | Delete
$file_name = sanitize_file_name(wp_basename($thumb));
[1016] Fix | Delete
$type = wp_check_filetype( $file_name )['type'];
[1017] Fix | Delete
$sql = sprintf('`post_name` IN("%1$s","%1$s-1","%1$s-2","%1$s-3")',sanitize_title(pathinfo($file_name,PATHINFO_FILENAME)));
[1018] Fix | Delete
$query = $wpdb->get_row("SELECT ID,post_mime_type FROM {$wpdb->prefix}posts WHERE `post_type`='attachment' AND {$sql} AND `post_mime_type`='{$type}' LIMIT 1");
[1019] Fix | Delete
[1020] Fix | Delete
$isImage = 0 === strpos( $type, 'image/' );
[1021] Fix | Delete
$isVideo=$isImage===false && 0 === strpos( $type, 'video/' );
[1022] Fix | Delete
$attach_id = !empty($query) ? $query->ID : null;
[1023] Fix | Delete
if ($attach_id !== null) {
[1024] Fix | Delete
$duplicate = $isImage===true?wp_get_original_image_path($attach_id):get_attached_file( $attach_id );
[1025] Fix | Delete
if(!$duplicate && $isImage===true){
[1026] Fix | Delete
$duplicate=get_attached_file( $attach_id );
[1027] Fix | Delete
}
[1028] Fix | Delete
if ($duplicate && is_file($duplicate)) {
[1029] Fix | Delete
$size = (int) filesize($duplicate);
[1030] Fix | Delete
$mimeType = $query->post_mime_type;
[1031] Fix | Delete
}
[1032] Fix | Delete
}
[1033] Fix | Delete
unset($query, $sql,$type);
[1034] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/image.php';
[1035] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/file.php';
[1036] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/media.php';
[1037] Fix | Delete
if (!empty($blob)) {
[1038] Fix | Delete
if ($blob['error'] > 0) {
[1039] Fix | Delete
$error = __('Uploading error', 'themify');
[1040] Fix | Delete
} else {
[1041] Fix | Delete
$file = array(
[1042] Fix | Delete
'type' => $blob['type'],
[1043] Fix | Delete
'tmp_name' => $blob['tmp_name'],
[1044] Fix | Delete
'error' => 0,
[1045] Fix | Delete
'size' => $blob['size']
[1046] Fix | Delete
);
[1047] Fix | Delete
}
[1048] Fix | Delete
} else {
[1049] Fix | Delete
$tmp = download_url($thumb.'?polish=0');
[1050] Fix | Delete
if (is_wp_error($tmp)) {
[1051] Fix | Delete
$error = $tmp->get_error_message();
[1052] Fix | Delete
} else {
[1053] Fix | Delete
$file = array(
[1054] Fix | Delete
'size' => filesize($tmp),
[1055] Fix | Delete
'error' => 0,
[1056] Fix | Delete
'tmp_name' => $tmp
[1057] Fix | Delete
);
[1058] Fix | Delete
}
[1059] Fix | Delete
}
[1060] Fix | Delete
if ($error === '') {
[1061] Fix | Delete
$checked = wp_check_filetype_and_ext($file['tmp_name'], $file_name);
[1062] Fix | Delete
if (!empty($checked['type'])) {
[1063] Fix | Delete
$file['name'] = !empty($checked['proper_filename']) ? $checked['proper_filename'] : $file_name;
[1064] Fix | Delete
$isFileExist = isset($size) && $mimeType === $checked['type'] && abs($size - (int)$file['size']) < 15;
[1065] Fix | Delete
if ($isFileExist === true) {
[1066] Fix | Delete
$mbSize = (float) $size / MB_IN_BYTES;
[1067] Fix | Delete
if ($mbSize < 4) {//is below 4mb
[1068] Fix | Delete
$isFileExist = sha1_file($duplicate) === sha1_file($file['tmp_name']);
[1069] Fix | Delete
} else {
[1070] Fix | Delete
$chunkSize = 4096;
[1071] Fix | Delete
$maxCheck = 4 * MB_IN_BYTES; //check only the first 4mb
[1072] Fix | Delete
$i = (int) $maxCheck / $chunkSize;
[1073] Fix | Delete
$arr = self::compare_files($duplicate, $file['tmp_name'], $chunkSize);
[1074] Fix | Delete
foreach ($arr as $k => $v) {
[1075] Fix | Delete
if ($k === false || $v === false || $v !== $k) {
[1076] Fix | Delete
$isFileExist = false;
[1077] Fix | Delete
break;
[1078] Fix | Delete
}
[1079] Fix | Delete
if ($i <= 0) {
[1080] Fix | Delete
break;
[1081] Fix | Delete
}
[1082] Fix | Delete
--$i;
[1083] Fix | Delete
}
[1084] Fix | Delete
unset($maxCheck, $chunkSize, $i,$arr);
[1085] Fix | Delete
}
[1086] Fix | Delete
unset($duplicate, $mbSize);
[1087] Fix | Delete
}
[1088] Fix | Delete
unset($checked);
[1089] Fix | Delete
[1090] Fix | Delete
$post_id = !empty($post['post_id']) ? (int) $post['post_id'] : 0;
[1091] Fix | Delete
$term_id = (!$post_id && !empty($post['term_id'])) ? (int) $post['term_id'] : 0;
[1092] Fix | Delete
if ($isFileExist === false) {
[1093] Fix | Delete
$check = function_exists('check_upload_size') ? check_upload_size($file) : array('error' => 0);
[1094] Fix | Delete
if ($check['error'] === 0) {
[1095] Fix | Delete
$attach_id = media_handle_sideload($file, $post_id);
[1096] Fix | Delete
if (!$attach_id) {
[1097] Fix | Delete
$error = __('Uploading Error', 'themify');
[1098] Fix | Delete
} elseif (is_wp_error($attach_id)) {
[1099] Fix | Delete
$error = $attach_id->get_error_messages();
[1100] Fix | Delete
}
[1101] Fix | Delete
} else {
[1102] Fix | Delete
$error = $check['error'];
[1103] Fix | Delete
}
[1104] Fix | Delete
unset($check);
[1105] Fix | Delete
}
[1106] Fix | Delete
} else {
[1107] Fix | Delete
$error = __('Invalid file type', 'themify');
[1108] Fix | Delete
}
[1109] Fix | Delete
}
[1110] Fix | Delete
if (isset($file)) {
[1111] Fix | Delete
if (is_file($file['tmp_name'])) {
[1112] Fix | Delete
unlink($file['tmp_name']);
[1113] Fix | Delete
}
[1114] Fix | Delete
unset($file, $thumb,$tmp);
[1115] Fix | Delete
}
[1116] Fix | Delete
if ($error === '' && !empty($attach_id)) {
[1117] Fix | Delete
$attach_id=(int)$attach_id;
[1118] Fix | Delete
if($isImage===true){
[1119] Fix | Delete
if ($post_id > 0) {
[1120] Fix | Delete
set_post_thumbnail($post_id, $attach_id);
[1121] Fix | Delete
} elseif ($term_id > 0) {
[1122] Fix | Delete
update_term_meta($term_id, 'thumbnail_id', $attach_id);
[1123] Fix | Delete
}
[1124] Fix | Delete
unset($post_id, $term_id);
[1125] Fix | Delete
$imageMeta = wp_get_attachment_metadata($attach_id);
[1126] Fix | Delete
if ( empty($imageMeta['file'])) {
[1127] Fix | Delete
$data = wp_get_attachment_image_src($attach_id, 'full');
[1128] Fix | Delete
$src = $data[0];
[1129] Fix | Delete
$w = $h = '';
[1130] Fix | Delete
if (empty($data[1])) {
[1131] Fix | Delete
$size = themify_get_image_size($src);
[1132] Fix | Delete
if ($size !== false) {
[1133] Fix | Delete
$w = $size['w'];
[1134] Fix | Delete
$h = $size['h'];
[1135] Fix | Delete
}
[1136] Fix | Delete
} else {
[1137] Fix | Delete
$w = $data[1];
[1138] Fix | Delete
$h = $data[2];
[1139] Fix | Delete
}
[1140] Fix | Delete
$imageSizes['_orig_'] = array('file' => $src, $w, 'height' => $h);
[1141] Fix | Delete
unset($data);
[1142] Fix | Delete
} else {
[1143] Fix | Delete
$imageSizes = !empty($imageMeta['sizes']) ? $imageMeta['sizes'] : array();
[1144] Fix | Delete
$imageSizes['_orig_'] = array('file' => basename($imageMeta['file']), 'width' => $imageMeta['width'], 'height' => $imageMeta['height']);
[1145] Fix | Delete
$folder = '/' . dirname($imageMeta['file']) . '/';
[1146] Fix | Delete
$baseUrl = themify_upload_dir('baseurl') . $folder;
[1147] Fix | Delete
unset($imageMeta);
[1148] Fix | Delete
if ($generate === true) {
[1149] Fix | Delete
foreach ($imageSizes as $v) {
[1150] Fix | Delete
themify_get_image_size($baseUrl . $v['file']);
[1151] Fix | Delete
themify_create_webp($baseUrl . $v['file']);
[1152] Fix | Delete
}
[1153] Fix | Delete
}
[1154] Fix | Delete
$src = $baseUrl . $imageSizes['_orig_']['file'];
[1155] Fix | Delete
}
[1156] Fix | Delete
$img = '<img src="' . $src . '" class="wp-image-' . $attach_id . '"';
[1157] Fix | Delete
if (!empty($imageSizes['_orig_']['width'])) {
[1158] Fix | Delete
$img .= ' width="' . $imageSizes['_orig_']['width'] . '" height="' . $imageSizes['_orig_']['height'] . '"';
[1159] Fix | Delete
}
[1160] Fix | Delete
$img .= '>';
[1161] Fix | Delete
unset($imageSizes);
[1162] Fix | Delete
$img = function_exists('wp_filter_content_tags') ? wp_filter_content_tags($img) : wp_make_content_images_responsive($img);
[1163] Fix | Delete
}else{
[1164] Fix | Delete
$img='';
[1165] Fix | Delete
$src=wp_get_attachment_url($attach_id);
[1166] Fix | Delete
if($isVideo===true){
[1167] Fix | Delete
themify_get_video_size($src);
[1168] Fix | Delete
}
[1169] Fix | Delete
}
[1170] Fix | Delete
return array('html' => $img, 'id' => $attach_id, 'src' => $src);
[1171] Fix | Delete
}
[1172] Fix | Delete
}
[1173] Fix | Delete
return $error;
[1174] Fix | Delete
}
[1175] Fix | Delete
}
[1176] Fix | Delete
}
[1177] Fix | Delete
[1178] Fix | Delete
if (themify_is_ajax()) {
[1179] Fix | Delete
Themify_Import_Helper::init();
[1180] Fix | Delete
}
[1181] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function