Example #1
0
/**
	右侧列表
*/
function king_ajax_brow_right()
{
    global $king;
    $filetype = '';
    $is = '';
    $jsfun = '';
    $path = '';
    $info = inc_brow();
    extract($info);
    $s = "<table cellspacing=\"0\">";
    $s .= "<tr id=\"brow_top\"><th>";
    $s .= "<a href=\"javascript:;\" id=\"a_brow_upfile\" class=\"k_ajax fr\" rel=\"{{$verbs},CMD:'brow_upfile',isopen:1,path:'{$path}',IS:1,ID:'brow_top'}\">";
    $s .= kc_icon('j4') . $king->lang->get('system/common/upfile') . "</a>";
    $s .= "<a href=\"javascript:;\" id=\"a_brow_md\" class=\"k_ajax fr\" rel=\"{{$verbs},CMD:'brow_md',path:'{$path}',isopen:1,IS:1,ID:'brow_top'}\">";
    $s .= kc_icon('h1') . $king->lang->get('system/common/md') . "</a>";
    $s .= "<tt title=\"{$path}\">" . kc_icon('b1') . "/" . kc_short($path, 12, 15) . "</tt>";
    $s .= "</th></tr></table>";
    $s .= "<table cellspacing=\"0\">";
    $s .= "<tr>";
    $s .= $filetype == 0 ? '<th class="line">&nbsp;Image</th>' : '';
    $s .= "<th class=\"l line\">&nbsp;FileName</th><th class=\"line r\">Size&nbsp;</th><th class=\"line r\"></th></tr>";
    $i = 0;
    kc_f_md($path);
    $folders = kc_f_getdir($path, $king->getfext($filetype));
    foreach ($folders as $val) {
        $s .= "<tr class=\"bg" . $i++ % 2 . "\">";
        //插入
        $insert = "onClick=\"\$('#{$id}').val('{$path}{$val}');";
        $insert .= $is ? $jsfun : "\$.kc_close()";
        $insert .= "\" title=\"" . $king->lang->get('system/common/insert') . "\"";
        if ($filetype == 0) {
            //图片
            $s .= "<td><span><a {$insert} href=\"javascript:;\" class=\"img\"><img src=\"../{$path}{$val}\" /></a></span></td>";
            $s .= "<td><a href=\"../{$path}{$val}\" target=\"_blank\" >" . kc_short($val) . "</a></td>";
        } else {
            $s .= "<td {$insert}><label>" . kc_f_kc_icon($val) . kc_short($val) . '</label></td>';
        }
        $s .= '<td class="r">' . kc_f_size(kc_f_filesize($path . $val)) . '</td>';
        $s .= '<td class="r">';
        $s .= "<a href=\"javascript:;\" {$insert}>" . kc_icon('l4') . "</a>";
        //删除文件
        $s .= "<a href=\"javascript:;\" class=\"k_ajax\" rel=\"{{$verbs},CMD:'delete_browfile',path:'{$path}',file:'{$val}',IS:1}\">" . kc_icon('j2', $king->lang->get('system/common/delete')) . "</a>";
        /*
        */
        $s .= '</td></tr>';
    }
    $s .= '</table>';
    $js = "\$('#browleft>p>a>em').removeClass('sel');\$('#k_brow_sub_" . _path2id(substr($path, 0, -1)) . "').addClass('sel')";
    kc_ajax('', $s, '', $js);
}
Example #2
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);
}