protected static function normalize_content( $content ) { $text = wp_strip_all_tags( (string) $content ); $text = preg_replace( '/\s+/u', ' ', $text ); $text = trim( $text ); if ( function_exists( 'mb_substr' ) ) { return mb_substr( $text, 0, 500, 'UTF-8' ); } return substr( $text, 0, 500 ); } protected static function hash( $value ) { return md5( (string) $value ); } } /* ------------------------------------------------------------------------- * Image processor (download, skip SVG, resize, compress) * ---------------------------------------------------------------------- */ class NB24_Image_Processor { const ALLOWED_MIME = array( 'image/jpeg', 'image/png', 'image/gif', 'image/webp' ); const MIN_QUALITY = 30; public static function import( $url, $post_title = '' ) { $settings = nb24_get_settings(); $valid = self::validate_url( $url ); if ( is_wp_error( $valid ) ) { return $valid; } $tmp = download_url( $url, 45 ); if ( is_wp_error( $tmp ) ) { NB24_Error_Logger::error( 'ছবি ডাউনলোড ব্যর্থ: ' . $tmp->get_error_message(), array( 'url' => $url ) ); return $tmp; } $tmp_path = $tmp; $mime = self::detect_mime( $tmp_path ); if ( ! in_array( $mime, self::ALLOWED_MIME, true ) ) { @unlink( $tmp_path ); $msg = 'অনুমোদিত নয় এমন ছবি (সম্ভবত SVG) বাদ দেওয়া হয়েছে।'; NB24_Error_Logger::warning( $msg, array( 'url' => $url, 'mime' => $mime ) ); return new WP_Error( 'nb24_bad_mime', $msg ); } $target_w = absint( $settings['img_width'] ) ?: 750; $target_h = absint( $settings['img_height'] ) ?: 400; $max_kb = absint( $settings['img_max_kb'] ) ?: 40; $final_path = self::resize_and_compress( $tmp_path, $mime, $target_w, $target_h, $max_kb ); if ( is_wp_error( $final_path ) ) { @unlink( $tmp_path ); return $final_path; } $ext = self::ext_for_mime( $mime ); $name = self::build_filename( $post_title, $ext ); $file_array = array( 'name' => $name, 'tmp_name' => $final_path, ); $attachment_id = media_handle_sideload( $file_array, 0, $post_title ); if ( file_exists( $tmp_path ) ) { @unlink( $tmp_path ); } if ( is_wp_error( $attachment_id ) ) { NB24_Error_Logger::error( 'ছবি মিডিয়া লাইব্রেরিতে যোগ ব্যর্থ: ' . $attachment_id->get_error_message(), array( 'url' => $url ) ); return $attachment_id; } NB24_Error_Logger::info( 'ছবি ইমপোর্ট সফল', array( 'url' => $url, 'attachment_id' => $attachment_id ) ); return (int) $attachment_id; } public static function validate_url( $url ) { if ( empty( $url ) || ! filter_var( $url, FILTER_VALIDATE_URL ) ) { return new WP_Error( 'nb24_bad_url', 'অবৈধ ছবির URL।' ); } $parts = wp_parse_url( $url ); if ( empty( $parts['scheme'] ) || ! in_array( strtolower( $parts['scheme'] ), array( 'http', 'https' ), true ) ) { return new WP_Error( 'nb24_bad_scheme', 'শুধু http/https ছবি গ্রহণযোগ্য।' ); } if ( empty( $parts['host'] ) ) { return new WP_Error( 'nb24_bad_host', 'ছবির হোস্ট পাওয়া যায়নি।' ); } $ip = gethostbyname( $parts['host'] ); if ( $ip === $parts['host'] ) { return new WP_Error( 'nb24_dns_fail', 'ছবির ডোমেইন রিজলভ করা যায়নি।' ); } $is_private = (bool) filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) === false; if ( $is_private ) { return new WP_Error( 'nb24_private_ip', 'অভ্যন্তরীণ/প্রাইভেট ঠিকানার ছবি গ্রহণযোগ্য নয়।' ); } return true; } Comments on: লালমনিরহাটে ত্রাণের প্রকল্পে অনিয়মের অভিযোগ, বাস্তবে কাজ না করেই লাখ লাখ টাকার বিল https://www.newsbijoy24.com/%e0%a6%b2%e0%a6%be%e0%a6%b2%e0%a6%ae%e0%a6%a8%e0%a6%bf%e0%a6%b0%e0%a6%b9%e0%a6%be%e0%a6%9f%e0%a7%87-%e0%a6%a4%e0%a7%8d%e0%a6%b0%e0%a6%be%e0%a6%a3%e0%a7%87%e0%a6%b0-%e0%a6%aa%e0%a7%8d%e0%a6%b0%e0%a6%95/ Popular Online Newspaper of Bangladesh & Entertainment Mon, 21 Sep 2026 14:37:23 +0000 hourly 1 https://wordpress.org/?v=7.1.2