403Webshell
Server IP : 38.190.208.107  /  Your IP : 216.73.217.46
Web Server : nginx/1.28.1
System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64
User : root ( 0)
PHP Version : 8.2.28
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/test20.chuangfenglink.xyz/wp-content/themes/woodmart-child/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/test20.chuangfenglink.xyz/wp-content/themes/woodmart-child/functions.php
<?php
/**
 * Enqueue script and styles for child theme
 */
function woodmart_child_enqueue_styles() {
 wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'woodmart-style' ), woodmart_get_theme_info( 'Version' ) );
}
add_action( 'wp_enqueue_scripts', 'woodmart_child_enqueue_styles', 10010 );

/**
 * WordPress 自动压缩上传图片(JPG/PNG/WebP)
 * 配合七牛云插件自动同步压缩后的图片
 * 免费、无插件、纯本地压缩
 */
add_filter('wp_handle_upload', 'auto_compress_images_on_upload');
function auto_compress_images_on_upload($upload) {
    // 只处理图片
    $type = $upload['type'];
    $file_path = $upload['file'];

    // 允许压缩的图片类型
    $allowed_types = array('image/jpeg', 'image/png', 'image/webp');

    if (!in_array($type, $allowed_types)) return $upload;

    // 压缩质量(1-100,推荐 80,肉眼无损,体积缩小50%+)
    $quality = 80;

    // 获取图片信息
    $info = getimagesize($file_path);
    $mime = $info['mime'];

    // 根据类型压缩
    switch ($mime) {
        case 'image/jpeg':
            $image = imagecreatefromjpeg($file_path);
            imagejpeg($image, $file_path, $quality);
            imagedestroy($image);
            break;
        case 'image/png':
            $image = imagecreatefrompng($file_path);
            imagealphablending($image, true);
            imagesavealpha($image, true);
            // PNG 压缩等级 0-9
            imagepng($image, $file_path, 5);
            imagedestroy($image);
            break;
        case 'image/webp':
            if (function_exists('imagecreatefromwebp')) {
                $image = imagecreatefromwebp($file_path);
                imagewebp($image, $file_path, $quality);
                imagedestroy($image);
            }
            break;
    }

    return $upload;
}

/**
 * 自动压缩 WordPress 生成的缩略图
 */
add_filter('wp_generate_attachment_metadata', 'auto_compress_thumbnails', 10, 2);
function auto_compress_thumbnails($metadata, $attachment_id) {
    $upload_dir = wp_upload_dir();
    $file_path = $upload_dir['basedir'] . '/' . dirname($metadata['file']) . '/';

    // 压缩所有尺寸缩略图
    foreach ($metadata['sizes'] as $size => $value) {
        $thumb_file = $file_path . $value['file'];
        $mime = getimagesize($thumb_file)['mime'];
        $quality = 80;

        if ($mime == 'image/jpeg') {
            $image = imagecreatefromjpeg($thumb_file);
            imagejpeg($image, $thumb_file, $quality);
            imagedestroy($image);
        } elseif ($mime == 'image/png') {
            $image = imagecreatefrompng($thumb_file);
            imagealphablending($image, true);
            imagesavealpha($image, true);
            imagepng($image, $thumb_file, 5);
            imagedestroy($image);
        }
    }

    return $metadata;
}

// 禁用Gravatar头像外部请求(控制台干净无报错)
add_filter('pre_option_show_avatars', '__return_zero');

add_action('template_redirect', function() {
    ob_start(function($html) {
        $html = preg_replace(
            '#https://cdn\.chuangfenglink\.xyz/test20\.chuangfenglink\.xyz/(\d{4}/\d{2}/xts-[a-z0-9_\-]+\.css\?ver=[0-9\.]+)#i',
            'https://test20.chuangfenglink.xyz/wp-content/uploads/$1',
            $html
        );
        return $html;
    });
}, 1);

Youez - 2016 - github.com/yon3zu
LinuXploit