HEX
Server: Apache/2.4.59 (Debian)
System: Linux keymana 4.19.0-21-cloud-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64
User: lijunjie (1003)
PHP: 7.4.33
Disabled: 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_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/uileague/wp-content/themes/uileague/functions.php
<?php
date_default_timezone_set('PRC');

@ini_set('upload_max_size', '25M');
@ini_set('post_max_size', '25M');
@ini_set('max_execution_time', '300');

add_filter('automatic_updater_disabled', '__return_true'); //关闭自动更新

//Wordpress 5.0+ 禁用 Gutenberg 编辑器
add_filter('use_block_editor_for_post', '__return_false');
remove_action('wp_enqueue_scripts', 'wp_common_block_scripts_and_styles');

function orm_hide_admin_bar_settings()
{
?>
    <style type="text/css">
        .show-admin-bar {
            display: none;
        }
    </style>
<?php
}

function orm_disable_admin_bar()
{

    add_filter('show_admin_bar', '__return_false');
    add_action(
        'admin_print_scripts-profile.php',
        'orm_hide_admin_bar_settings'
    );
}
add_action('init', 'orm_disable_admin_bar', 9);

function current_url()
{
    global $wp;
    return home_url($wp->request);
}

function fix_in_app()
{
    if ($_SERVER['HTTP_USER_AGENT'] == "Flutter-UILeague") {
        echo '<style>
            header,footer{display:none;}
            @media (max-width: 800px){
                body .body-content {
                    margin-top: 0 !important;
                }
            }
        </style>';
    }
}

function is_menu_active($url)
{
    return $url == current_url();
}

function echo_json($result)
{
    echo fmt_json($result);
};

function fmt_json($result)
{
    return preg_replace_callback(
        '/\\\\u([0-9a-zA-Z]{4})/',
        function ($matches) {
            return mb_convert_encoding(pack('H*', $matches[1]), 'UTF-8', 'UTF-16');
        },
        json_encode($result)
    );
}

function ef_get_page($title)
{
    $page = get_page_by_title($title);
    return get_permalink($page->ID);
}

function aiden_get_page($title)
{  //根据页面标题获取页面
    $page = get_page_by_title($title);
    return get_permalink($page->ID);
}

/**
 * 执行 curl post 请求
 */
function curl_post($url, $data = null)
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($curl, CURLOPT_POST, 1);
    if ($data != null) {
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    }
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($curl);
    curl_close($curl);
    return json_decode($output, true);
}

function encrypt($data)
{
    $key_256bit = "FlVKQloXnOso8fNiN/cJIz6z8hrFqyo+ErnOtuQ6Up0=";
    // Remove the base64 encoding from our key
    $encryption_key = base64_decode($key_256bit);
    // Generate an initialization vector
    $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
    // Encrypt the data using AES 256 encryption in CBC mode using our encryption key and initialization vector.
    $encrypted = openssl_encrypt($data, 'aes-256-cbc', $encryption_key, 0, $iv);
    // The $iv is just as important as the key for decrypting, so save it with our encrypted data using a unique separator (::)
    $handled = bin2hex(base64_decode($encrypted));
    return (bin2hex($iv) . $handled);
}

function decrypt($data)
{
    $key_256bit = "FlVKQloXnOso8fNiN/cJIz6z8hrFqyo+ErnOtuQ6Up0=";
    // Remove the base64 encoding from our key
    $encryption_key = base64_decode($key_256bit);
    $iv             = hex2bin(substr($data, 0, 32));
    $encrypted_data = hex2bin(substr($data, 32, strlen($data) - 32));
    $handled_data   = base64_encode($encrypted_data);
    $decrypted      = openssl_decrypt($handled_data, 'aes-256-cbc', $encryption_key, 0, $iv);
    return $decrypted;
}

add_filter('login_footer', 'always_checked_rememberme');  //WordPress登录时有个“记住我的登录信息”勾选,默认14天内将自动登录,除非你手动注销。如果你总是忘记勾选这个复选框,这本文的技巧将帮你自动勾选。
function always_checked_rememberme()
{
    echo "<script>document.getElementById('rememberme').checked = true;</script>";
}

add_filter('auth_cookie_expiration', 'custom_login_cookie');  //想延长自动登录时间
function custom_login_cookie()
{
    return 31536000; // one year in seconds
}


/**
 * WordPress 多用媒体库只显示用户自己上传的文件
 * http://www.wazhuti.com/1897.html
 */
//在文章编辑页面的[添加媒体]只显示用户自己上传的文件
function my_upload_media($wp_query_obj)
{
    global $current_user, $pagenow;
    if (!is_a($current_user, 'WP_User'))
        return;
    if ('admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments')
        return;
    if (!current_user_can('manage_options') && !current_user_can('manage_media_library'))
        $wp_query_obj->set('author', $current_user->ID);
    return;
}
add_action('pre_get_posts', 'my_upload_media');

//在[媒体库]只显示用户上传的文件
function my_media_library($wp_query)
{
    if (strpos($_SERVER['REQUEST_URI'], '/wp-admin/upload.php') !== false) {
        if (!current_user_can('manage_options') && !current_user_can('manage_media_library')) {
            global $current_user;
            $wp_query->set('author', $current_user->id);
        }
    }
}
add_filter('parse_query', 'my_media_library');


function curPageURL()
{
    $pageURL = 'http';

    if ($_SERVER["HTTPS"] == "on") {
        $pageURL .= "s";
    }
    $pageURL .= "://";

    if ($_SERVER["SERVER_PORT"] != "80") {
        $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
    } else {
        $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
    }
    return $pageURL;
}




//(新版)WordPress让媒体文件也有分类和标签
function ludou_create_media_category()
{
    $args = array(
        'label' => '媒体分类',
        'hierarchical' => true,
        'show_admin_column' => true,
        'show_ui'      => true,
        'query_var'    => true,
        'rewrite'      => true,
    );

    register_taxonomy('attachment_category', 'attachment', $args);
}

add_action('init', 'ludou_create_media_category');


/**
 * 显示php错误
 */
function show_php_error()
{
    ini_set('display_errors', 1); //错误信息
    ini_set('display_startup_errors', 1); //php启动错误信息
    error_reporting(-1);
}

// 导入静态方法
include_once 'JwtAuth.php';
include_once 'ApiStatus.php';
require_once 'helper/helper.php';