예제 #1
0
/**
上传文件管理
king_upfile()
*/
function king_upfile()
{
    global $king;
    $s = $king->access('#upfile');
    $is = kc_get('is');
    //$is==1为用户上传
    switch ($is) {
        case 1:
            if (!$king->isModule('portal')) {
                kc_error($king->lang->get('system/error/param'));
            }
            $_sql = 'select f.kid,f.kpath,f.ndate,u.username,f.ktitle from %s_upfile f,%s_user u where f.adminid=0 and f.userid=u.userid order by f.ndate desc,kid desc';
            $name = $king->lang->get('system/upfile/username');
            $field = 'adminid';
            //用户上传的话,ADMINID=0
            break;
        default:
            $_sql = 'select f.kid,f.kpath,f.ndate,a.adminname,f.ktitle from %s_upfile f,%a_admin a where f.userid=0 and f.adminid=a.adminid order by f.ndate desc,kid desc';
            $name = $king->lang->get('system/admin/name');
            $field = 'userid';
            //ADMIN上传的话USERID=0
    }
    //准备开始列表
    $_cmd = array('delete_upfile' => $king->lang->get('system/common/del'));
    $_manage = "'<a href=\"../'+K[1]+'\" target=\"_blank\">'+\$.kc_icon('g7')+'</a>'";
    $_manage .= "+'<a href=\"javascript:;\" class=\"k_ajax\" rel=\"{CMD:\\'upfile_edt\\',kid:'+K[0]+',METHOD:\\'GET\\'}\">'+\$.kc_icon('e5')+'</a>'";
    $_manage .= "+'<a href=\"javascript:;\" class=\"k_ajax\" rel=\"{CMD:\\'delete_upfile\\',list:'+K[0]+'}\">'+\$.kc_icon('g5','" . $king->lang->get('system/common/del') . "')+'</a>'";
    $_js = array("\$.kc_list(K[0],K[1],0,0,1,K[4])", $_manage, "K[5]", "K[2]", "K[3]");
    /*
    id      ID
    tit     标题
    is      是否显示id
    isgray  是否灰度
    ico     图标
    space   缩进
    listico 列表页专用的前置ico
    */
    $s = $king->openList($_cmd, '', $_js, $king->db->pagelist('manage.php?action=upfile&is=' . $is . '&pid=PID&rn=RN', $king->db->getRows_number('%s_upfile', "{$field}=0")));
    $s .= 'll(\'' . $king->lang->get('system/upfile/files') . '\',\'manage\',\'' . $king->lang->get('system/common/title') . '\',\'' . $name . '\',\'' . $king->lang->get('system/common/date') . '\',1);';
    if (!($res = $king->db->getRows($_sql, 1))) {
        $res = array();
    }
    foreach ($res as $rs) {
        $s .= 'll(' . $rs['kid'] . ',\'' . $rs['kpath'] . '\',\'' . $rs['adminname'] . '\',\'' . kc_formatdate($rs['ndate']) . '\',\'' . kc_f_ico($rs['kpath']) . '\',\'' . $rs['ktitle'] . '\',0);';
    }
    //结束列表
    $s .= $king->closeList();
    $left = array(array('href' => 'manage.php?action=upfile', 'ico' => 'e6', 'title' => $king->lang->get('system/upfile/admin'), 'class' => $is ? '' : 'sel'));
    if ($king->isModule('portal')) {
        $left[] = array('href' => 'manage.php?action=upfile&is=1', 'ico' => 'a6', 'title' => $king->lang->get('system/upfile/user'), 'class' => $is ? 'sel' : '');
    }
    $king->skin->output($king->lang->get('system/title/upfile'), $left, '', $s);
}
예제 #2
0
/**
	返回文件类型图标的完整HTML代码
	@param string $_name  文件名或路径
	@return string
*/
function kc_f_kc_icon($name)
{
    $icon = kc_f_ico($name);
    return kc_icon($icon, $name);
}
예제 #3
0
/**
	重命名文件或文件夹
*/
function king_ajax_rename()
{
    global $king;
    $king->access('webftp_rename');
    $isdir = kc_post('isdir', 2, 1);
    $path = kc_post('path');
    $file = kc_post('file', 0, 1);
    $id = kc_post('id');
    $new = kc_post($id);
    if (!kc_validate($new, '/^[A-Za-z0-9\\.\\_]+$/')) {
        kc_ajax('', kc_icon('a1'), '', "alert('" . $king->lang->get('webftp/error/newname') . "')");
    }
    kc_f_rename($path . $file, $path . $new);
    $s = "<a rel=\"{CMD:'right',path:'{$path}{$new}/',ID:'ftp_root',leftopen:1,IS:2}\" class=\"k_ajax\" href=\"javascript:;\">{$new}</a>";
    $js = '';
    $oldID = 'k_brow_right_' . _path2id($path . $file);
    $newID = 'k_brow_right_' . _path2id($path . $new);
    if ($isdir) {
        //目录
        //在原有的项目下面添加一个新的,并在下面中删除掉老的
        $js .= "\$('#{$oldID}').after(iii('b1','{$path}','{$new}','--','" . kc_formatdate(kc_f_mtime($path . $new)) . "'));";
    } else {
        $js .= "\$('#{$oldID}').after(iii('" . kc_f_ico($new) . "','{$path}','{$new}','" . kc_f_size(kc_f_filesize($path . $new)) . "','" . kc_formatdate(kc_f_mtime($path . $new)) . "'));";
    }
    $js .= "\$.kc_ready('#{$newID}');";
    $js .= "\$('#{$oldID}').remove();";
    $cachepath = "system/filemanage/{$path}index";
    $king->cache->del($cachepath);
    //清理缓存
    $js .= "\$.kc_close();";
    kc_ajax('', '', '', $js);
}