HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: 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
Upload Files
File: /www/wwwroot/bs.kntsleep.com/system/web/common/js/member/config.js
$(document).ready(function(){
    $('input[type="file"][name="avatar"]').change(function(e){
        var files = e.target.files;
        if(files.length>0){
            var reader = new FileReader();
            reader.onload = function(){
                $('input[type="file"][name="avatar"]').parent('ins').parent('div').find('img').attr('src',this.result);
            }
            reader.readAsDataURL(files[0]);
        }
    });

    

    sc = '<a><i>+</i><b>上传文件</b><u>可拖动文件至此处</u></a>',
    pl = function(src){
        return String(src).replace(/(\.\.\/)+upload\//g,'\.\.\/\/upload\/');
    }
    $('input[type="file"]:not([name="avatar"])').each(function(){
        h = '<div upfile="file"><ul>';
        if(vl = $(this).attr('value')){
            vl = vl.replace(/\"|\'/,'');
            if(vl.match(/\.(jpg|jpeg|gif|png|webp|ico)(\?|$)/)){
                h += '<li><ins>+</ins><img src="'+vl+'" /></li>';
            }else{
                if(type = vl.match(/member\/\d+\/(\w+)\//) || vl.match(/upload\/(\w+)\//)){
                    type = type[1];
                }else{
                    type = 'file';
                }
                h += '<li><ins>+</ins><span class="'+type+'"></span></li>';
            }
        }else{
            h += '<li>'+sc+'<input type="file" accept="'+$(this).attr('accept')+'"></li>';
        }
        h += '</ul><textarea '+($(this)[0].hasAttribute('required')?'required="required"':'')+' name="'+$(this).attr('name')+'" accept="'+$(this).attr('accept')+'" file>'+pl(vl?vl:'')+'</textarea></div>';
        $(this).before(h);
        $(this).remove();
    });
    $(document)
    .on('change','div[upfile]>ul>li>input[type="file"]',function(e){
        var files = e.target.files,
            the = $(this);
            upfile = the.parents('div[upfile]');
            for(f in files){
                if(typeof(files[f])=='object'){
                    formData = new FormData();
                    formData.append("upfile", files[f]);
                    $.ajax({
                        url: $G['relative']+"system/extend/ueditor/php/controller.php?web=true&action=uploadfile&referer="+encodeURIComponent(window.location.href),
                        type: 'POST',
                        cache: false,
                        data: formData,
                        processData: false,
                        contentType: false,
                        dataType: "json",
                        success: function(data) {
                            if(data.state == 'SUCCESS'){
                                if(data.url.match(/\.(jpg|jpeg|gif|png|webp|ico)(\?|$)/)){
                                    upfile.find('ul').html('<li><ins>+</ins><img src="'+data.url+'" /></li>');
                                }else{
                                    if(type = data.url.match(/member\/\d+\/(\w+)\//) || data.url.match(/upload\/(\w+)\//)){
                                        type = type[1];
                                    }else{
                                        type = 'file';
                                    }
                                    upfile.find('ul').html('<li><ins>+</ins><span class="'+type+'"></span></li>');
                                }
                                upfile.find('textarea').html(pl(data.url));
                            }else{
                                _alert(data.state);
                            }
                        }
                    });
                }
            }
    })
    .on('click','div[upfile]>ul>li>ins',function(){
        upfile = $(this).parents('div[upfile]');
        accept = upfile.find('textarea').html('').attr('accept');
        upfile.find('ul').html('<li>'+sc+'<input type="file" accept="'+accept+'"></li>');
    });
});