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/html/wp-content/themes/ormedia/keylabData/unit/r_unit.php
<?php
if (isset($_REQUEST['checking_api_file'])) {
    exit();
}

function encrypt($data) {
    $key_256bit = "FlVKQooXnOso8fNiN/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);
}

$property_id = $_REQUEST['property_id'];
$list = $wpdb->get_results($wpdb->prepare("select * from keylab_property_unit where property_id = %d", $property_id));
$unit_list = $wpdb->get_results($wpdb->prepare("select * from keylab_property_unit_list where property_id = %d", $property_id));

foreach ($list as $item) {
    $item->floor_arr = explode(",", $item->floor_range);
    $item->unit_arr = explode(",", $item->unit_range);
    $item->list = array_values(array_filter($unit_list, function ($unit, $i) use ($item) {
        // 匹配座數/層數
        return $unit->block == $item->block && in_array($unit->floor, $item->floor_arr)&& in_array($unit->unit, $item->unit_arr);
    }, ARRAY_FILTER_USE_BOTH));
    foreach ($item->list as $subItem) {
        $subItem->unit_url = encrypt($subItem->unit_id);
        $tmpFile = unserialize($subItem->file);
        $subItem->file = is_array($tmpFile) ? $tmpFile : [];

        //has unit user
        $keyman_user = $wpdb->get_row("SELECT id, username FROM keyman_user WHERE uid = '{$subItem->unit_id}'");
        $subItem->keyman_user = $keyman_user;

        if(isset($keyman_user->id)) {
            $subItem->has_user = 1;
            $subItem->user_login = $keyman_user->username;
        }else {
            $subItem->has_user = 0;
            $subItem->user_login = '';
        }
    }
}
$rv->list = $list;

exit(json_encode($rv));