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/dk/wp-content/themes/food/page-competition_legal.php
<?php
/* Template Name: competition_legal  */

get_header('competition');

if (!is_user_logged_in()) {
    //auth_redirect(); //跳转到登录页面
//    $HOMEURL =  esc_url(home_url('login')) ;
    $HOMEURL = esc_url(home_url('/'));
    echo "<script>setTimeout(window.location='" . $HOMEURL . "',50)</script>";
    exit();
}

$current_user = wp_get_current_user();

// 获取当前用户的ID
$user_id = $current_user->ID;

// 获取当前用户的用户名
$user_login = $current_user->user_login;

// 获取当前用户的邮箱
$user_email = $current_user->user_email;

// 获取当前用户的显示名称
$display_name = $current_user->display_name;

////电话
//$phone = get_user_meta($user_id, 'phone', true);
//
////年龄
//$age = get_user_meta($user_id, 'age', true);

$wpuseravatarID = get_user_meta($user_id, 'wp_user_avatar_id', true); //用户头像id
$wpuseravatar = wp_get_attachment_url($wpuseravatarID);

$wp_user_avatar_url = get_user_meta($user_id, 'wp_user_avatar_url', true); //用户头像id
if($wp_user_avatar_url == ''){
    $wp_user_avatar_url =   get_template_directory_uri() . '/food-app/img/mmc/img_cover.png';
}

$vueVersion = time();
?>

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>用户信息</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">

        <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/vue.min.js"></script>
        <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/vue.min.js"></script>

        <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/qs.js"></script>
        <link href="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/antd.min.css"
              rel="stylesheet">
        <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/moment.min.js"></script>
    </head>
    <body>
    <div id="app">
        <yq-header :search_text="submit_info.search_text" @search="hdSearch"></yq-header>


        <section class="w-100  md:w-[768px] md:mx-auto xl:w-[1280px] text-gray-600 body-font relative ">
            <div class="container px-1 pb-1 mx-auto form_section">

                <div class=" w-full mx-auto">

                    <section class="text-gray-600 body-font">
                        <div class="container py-1 mx-auto flex flex-wrap">
                            <div class="flex flex-wrap ">
                                <div class="p-[0.1rem] w-full md:w-1/4 ">
<!--                                <div class="p-[0.1rem] w-1/4 ">-->
                                    <div class="flex border-2 rounded-[0.1rem] border-gray-200 border-opacity-50 p-1 sm:flex-row flex-col">
<!--                                        <div class="w-16 h-16 sm:mr-8 sm:mb-0 mb-4 inline-flex items-center justify-center rounded-full bg-indigo-100 text-indigo-500 flex-shrink-0">-->
<!--                                            <svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-8 h-8" viewBox="0 0 24 24">-->
<!--                                                <path d="M22 12h-4l-3 9L9 3l-3 9H2"></path>-->
<!--                                            </svg>-->
<!--                                        </div>-->
                                        <div class="flex-grow text-[0.2rem]">
                                            <h2 class="text-gray-900 title-font font-medium">參賽條件</h2>
                                            <p class="leading-relaxed ">法律責任</p>
<!--                                            <a class="mt-3 text-indigo-500 inline-flex items-center">Learn More-->
<!--                                                <svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-4 h-4 ml-2" viewBox="0 0 24 24">-->
<!--                                                    <path d="M5 12h14M12 5l7 7-7 7"></path>-->
<!--                                                </svg>-->
<!--                                            </a>-->
                                        </div>
                                    </div>
                                </div>
                                <div class="p-[0.1rem] w-full md:w-3/4">
<!--                                <div class="p-[0.1rem] w-3/4">-->
                                    <div class="flex border-2 rounded-[0.1rem] border-gray-200 border-opacity-50 p-1 sm:flex-row flex-col">
<!--                                        <div class="w-16 h-16 sm:mr-8 sm:mb-0 mb-4 inline-flex items-center justify-center rounded-full bg-indigo-100 text-indigo-500 flex-shrink-0">-->
<!--                                            <svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-10 h-10" viewBox="0 0 24 24">-->
<!--                                                <path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"></path>-->
<!--                                                <circle cx="12" cy="7" r="4"></circle>-->
<!--                                            </svg>-->
<!--                                        </div>-->
                                        <div class="flex-grow text-[0.2rem]">
                                            <h2 class="text-gray-900 title-font font-medium mb-1">法律責任</h2>
                                            <p class="leading-relaxed ">1)我們會在訂單支付成功後1-3天內發貨(節假日順延,部分特殊商品七天內發貨),送達時間視快遞配送時間而定
                                                2)如遇不可抗力因素,配送到達時間可能略有延遲。
                                                3)由於商品存放倉庫位置不同,一個訂單中的商品可能會被折開為多個包裹配送。 不同的包裹配送時間會略有不同。
                                                4)包裹發出後,系統將物流資訊更新至顧客的訂單資訊中,顧客可通過“個人中心-訂單管理”追跡包裹。</p>
<!--                                            <a class="mt-3 text-indigo-500 inline-flex items-center">Learn More-->
<!--                                                <svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-4 h-4 ml-2" viewBox="0 0 24 24">-->
<!--                                                    <path d="M5 12h14M12 5l7 7-7 7"></path>-->
<!--                                                </svg>-->
<!--                                            </a>-->
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>

                </div>
            </div>
        </section>
        <div style="height: 80px"></div>
        <yq-footer :year_text="year_text"></yq-footer>
    </div>

    <script>
        const local_url = '<?php echo $local_url ?>'
        const domain = '<?php echo esc_url(home_url('/')); ?>'

        const app = {
            el: "#app",
            components: {
                'yq-header': httpVueLoader('<?php showFoodAppPath('components/yq-header-competition.vue?v=' . $vueVersion) ?>'),
                'yq-footer': httpVueLoader('<?php showFoodAppPath('components/yq-footer-competition.vue?v=' . $vueVersion) ?>'),
            },
            data() {
                return {
                    year_text: <?php echo date("Y") ?>,
                    token: '',

                    action: 'update',
                    id: '0',

                    name: "",
                    content: "",
                    start_date: "0000-00-00 00:00:00",
                    end_date: "0000-00-00 00:00:00",

                    score: "0",

                    status: "1",

                    user_id: "<?php echo $user_id; ?>",
                    user_login: "<?php echo $user_login; ?>",
                    user_email: "<?php echo $user_email; ?>",
                    display_name: "<?php echo $display_name; ?>",

                    img_id: "<?php echo $wpuseravatarID; ?>",
                    img_url: "<?php echo $wp_user_avatar_url; ?>",
                    img_id_has_uploaded: false,


                    fileList: [],
                    videoFileList: [],
                    uploading: false,


                    //page
                    submit_info: {
                        price_pre: '0',
                        price_next: '0',
                        order_name: '日期',
                        search_text: ''
                    },

                }
            },
            computed: {
                //自定义请求头
                headers() {
                    return {
                        'Authorization': 'Bearer ' + this.token,
                    }
                }
            },

            mounted() {
                // let id = this.$route.query.id;
                // this.type = this.getQueryString("type"); //参数名1
                // this.id = this.getQueryString("id"); //参数名1
                // console.log("id => ", this.id);

                // if (window.localStorage) {
                //     console.log("This browser supports localStorage");
                //     // alert('This browser supports localStorage');
                // } else {
                //     alert('This browser does NOT support localStorage');
                // }

                // localStorage.user_id = 3; // this.user_id;
                // this.user_id = localStorage.user_id;
                // // this.user_id = this.getQueryString("user_id");
                // console.log('user_id => ' + this.user_id);
                // this.user_name = localStorage.user_name;
                // console.log('user_name => ' + this.user_name);

                // this.token = this.getQueryString("token");
                // console.log('token => ' + this.token);

                // this.action = this.getQueryString("action");
                // console.log('action => ' + this.action);
                //
                // if (this.action === 'update') {
                //     this.initForm();
                // }
            },
            methods: {
                changeFormState() {
                    this.textFieldDisabled = !this.textFieldDisabled;
                },
                submitForm() {

                    this.status = this.radioValue
                    const up_img_id = this.img_id_has_uploaded ? this.img_id : null;
                    // const up_video_id = this.video_file_id_has_uploaded ? this.video_file_id : null;

                    // var stringTime = this.start_date; //'2012-10-12 22:37:33';
                    // var timestamp = Date.parse(new Date(stringTime));
                    // var live_timestamp = timestamp / 1000;
                    // // console.log(timestamp + '就是' + stringTime + '时间戳 ' + live_timestamp);
                    // console.log(stringTime + ' 时间戳 => ' + live_timestamp);

                    // console.log(this.start_date + ' 处理前 => ' + this.end_date);
                    // this.start_date = this.date2Db(this.start_date)
                    // this.end_date = this.date2Db(this.end_date)
                    // console.log(this.start_date + ' 处理后 => ' + this.end_date);

                    // console.log('video_file_id_has_uploaded => ' + this.video_file_id_has_uploaded + ', up_video_id => ' + up_video_id + ', video_file_id => ' + this.video_file_id + ' video_url => ' + this.video_url);

                    let formData = {
                        'module': 'user',
                        'action': 'index',
                        'a': 'updateWpUser',

                        'func_action': 'competition_user_info',

                        'user_id': this.user_id,

                        'display_name': this.display_name,
                        'phone': this.phone,
                        'age': this.age,


                        'wp_user_avatar_id': up_img_id,
                        'wp_user_avatar_url': this.img_url,

                        // 'status': this.status,

                        // 'debugmod': 1,
                    }


                    console.log(' formData => ');
                    console.log(formData);

                    axios({
                        method: 'post',
                        // headers: {
                        //     'Authorization': 'Bearer ' + this.token,
                        // },
                        url: '/api/',
                        data: Qs.stringify(formData)
                    })
                        .then((response) => {
                            // console.log(response);
                            let data = response.data
                            console.log('submitForm', data);

                            if (data.rc === 0) {

                                // if (this.action === 'add') {
                                //     // let backData = data.data;
                                //     this.id = data.id;
                                //
                                //     console.log('add done id =>' + this.id);
                                // }

                                // this.action = 'update';

                                antd.notification.success({
                                    message: 'Submit Success',
                                });

                                // this.initForm()
                            }
                        })
                        .catch(function (error) {
                            console.log(error);
                        });
                },

                // initForm() {
                //     axios({
                //         method: 'post',
                //         // url: '//dk.smart1space.site/api',
                //         url: '/api',
                //         data: Qs.stringify({
                //             'module': 'ranking',
                //             'action': 'index',
                //             'a': 'getActivityListInfoByPage',
                //             id: this.id,
                //
                //             pageNum: 1,
                //             pageSize: 1,
                //         })
                //         // , headers: {
                //         //     'Authorization': 'Bearer ' + this.token,
                //         // }
                //     })
                //         .then((response) => {
                //             // console.log(response);
                //             let data = response.data
                //             // console.log(data);
                //             console.log("data.rc => ", data.rc);
                //
                //             if (data.rc === 0) {
                //                 // this.tag_id = data.data.main.tag_id;
                //                 // this.series_id = data.data.main.id;
                //
                //                 // console.log("post_data => ", data.data[0]);
                //                 var post_data = data.data[0];
                //
                //                 this.id = post_data.id;
                //                 this.name = post_data.name;
                //                 this.content = post_data.content;
                //                 // console.log("post_content => ", this.post_content);
                //
                //                 // var d = new Date(post_data.live_time * 1000);
                //                 // console.log("this.live_time date => ", d);
                //                 //
                //                 // let live_time = this.formatDate3(d, 'yyyy-mm-dd hh:ii:ss');
                //                 // console.log(live_time); // 2016-07-06 16:19
                //
                //                 let start_date_db = post_data.start_date;
                //                 let start_date_arr = start_date_db.split(" ");
                //                 this.start_date = start_date_arr[0] + 'T' + start_date_arr[1]
                //                 // console.log("start_date => ", this.start_date);
                //                 // str="jpg|bmp|gif|ico|png";
                //
                //
                //                 //'2017-06-01T08:30:06'
                //                 this.end_date = this.date2Input(post_data.end_date);// post_data.end_date;
                //                 // console.log("end_date => ", this.end_date);
                //
                //                 this.status = post_data.status;
                //
                //                 this.radioValue = parseInt(this.status);
                //                 // console.log("status => ", this.status);
                //
                //
                //                 this.img_id = post_data.img_id;
                //                 this.img_url = post_data.img_url;
                //
                //                 this.video_file_id = post_data.video_file_id;
                //                 this.video_url = post_data.video_url;
                //
                //                 // this.videoFileList = [this.video_file_id];
                //
                //                 // var img_url = post_data.post.img1_url;
                //                 // if (img_url.startsWith('http')) {
                //                 //     console.log("字符串是以http开头的!");
                //                 //
                //                 //     this.img1_url = img_url.replace("http://", "https://")
                //                 // } else {
                //                 //     this.img1_url = img_url;
                //                 // }
                //
                //                 this.has_customize = true;
                //                 this.textFieldDisabled = false;
                //             }
                //         })
                //         .catch(function (error) {
                //             console.log(error);
                //         });
                // },

                getQueryString(name) {
                    let reg = `(^|&)${name}=([^&]*)(&|$)`
                    let r = window.location.search.substr(1).match(reg);
                    if (r != null) return unescape(r[2]);
                    return null;
                },

                beforeUpload(file) {
                    // console.log('beforeUpload', file);
                    const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
                    if (!isJpgOrPng) {
                        this.$message.error('You can only upload JPG/PNG file!');
                    }
                    const isLt8M = file.size / 1024 / 1024 < 10;
                    if (!isLt8M) {
                        this.$message.error('Image must smaller than 10MB!');
                    }
                    // return isJpgOrPng && isLt8M;

                    this.fileList = [file]; // [...this.fileList, file];
                    // return false;
                    return isJpgOrPng && isLt8M;
                },

                handleRemove(file) {
                    const index = this.fileList.indexOf(file);
                    const newFileList = this.fileList.slice();
                    newFileList.splice(index, 1);
                    this.fileList = newFileList;
                },

                //图片上传文件
                uploadHandleChangeImg() {
                    this.uploadHandleChange(false);
                },

                uploadHandleChange(isVideo = false) {
                    // const {fileList} = this;
                    // const formData = new FormData();
                    // fileList.forEach(file => {
                    //     formData.append('files[]', file);
                    // });
                    this.uploading = true;

                    // let file = e.target.files[0]
                    var file = this.fileList[0]
                    // if (isVideo) {
                    //     file = this.videoFileList[0];
                    // }

                    /* eslint-disable no-undef */
                    let param = new FormData()  // 创建form对象
                    param.append('images', file)  // 通过append向form对象添加数据
                    param.append('user_id', this.user_id) // 添加form表单中其他数据
                    param.append('img_upload_verify', 'imgE5FCDG3HQA4B1NOPIJ2RSTUV67KL') // 添加form表单中其他数据

                    // console.log(param.get('tang_file')) // FormData私有类对象,访问不到,可以通过get判断值是否传进去
                    let config = {
                        headers: {'Authorization': 'Bearer ' + this.token}
                    }
                    // axios.post('https://app.tangchinese.org/api-app-data?module=upload&action=upload_app', param, config)
                    //axios.post('<?php //echo $domain_url; ?>//' + '/wp_upload_img', param, config)
                    axios.post(domain + '/wp_upload_img', param, config)
                        .then(response => {
                            // console.log(response)
                            console.log(response.data)

                            var model = response.data;

                            if (model.rc == 0) {
                                if (isVideo) {
                                    this.video_file_id = model.id;
                                    this.video_url = model.url;
                                    this.video_file_id_has_uploaded = true;
                                } else {
                                    this.img_id = model.id;
                                    this.img_url = model.url;

                                    this.img_id_has_uploaded = true;
                                }

                                this.uploading = false;

                                antd.notification.success({
                                    message: 'upload successfully.',
                                });
                            } else {
                                antd.notification.error({
                                    message: 'upload failed.',
                                });
                            }
                        })
                        .catch(error => {
                            console.log(error)
                            antd.notification.error({
                                message: 'upload failed.',
                            });
                        })
                }
                ,

                ///page
                searchSubmit() {
                    this.page_num = 1
                    this.get_product()
                },
                hdSearch(e) {
                    this.submit_info.search_text = e
                    this.searchSubmit()
                },
            },
        }

        function init() {
            new Vue(app)
        }
    </script>
    <script src="<?php echo get_template_directory_uri(); ?>/food-app/ranking/creating_page_js/antd.min.js"
            onload="init()"></script>

<?php //get_footer('food'); ?>
<?php get_footer('competition'); ?>