/home/mjc1/public_html/j3demo/webhard/ajax.dir_json_process.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
function _pr($v){
    echo 
"<pre>";
    
print_r($v);
    echo 
"</pre>";
}
    
extract($_POST);

    
$array json_decode($json_val);

    if(
$dmode>'0'){
        
//print_r($_POST);
        
$dir_array null;
        
$dir_sub null;
        
$dir_parent null;
        
$cnt 0;
        for(
$i=0;$i<count($array);$i++){
            
$exp explode("/",$array[$i]);
            
$vp ""$vpn "";
            for(
$j=1;$j<$dmode;$j++){
                
$vp .= $exp[$j]."/";
            }
            for(
$j=1;$j<=$dmode;$j++){
                
$vpn .= $exp[$j]."/";
            }
            
$vp substr($vp,0,strlen($vp)-1);
            
$vpn substr($vpn,0,strlen($vpn)-1);

            
//$vp = $exp[$dmode-1];
            
$v $exp[$dmode];
            if(
$dmode=='1'){ $vp ""; }
            if(
$vp==$parent && $v!=''){
                if(
count($dir_array)==0){
                    
$dir_array[$cnt] = $v;
                    
$dir_parent[$cnt] = $vpn
                    if(
$exp[$dmode+1]!=''){ $dir_sub[$cnt] += 1; }
                } else {
                    
$key array_search($v,$dir_array)."";
                    if(
$key==''){
                        
$cnt++;
                        
$dir_array[$cnt] = $v;
                        
$dir_parent[$cnt] = $vpn
                        if(
$exp[$dmode+1]!=''){ $dir_sub[$cnt] += 1; }
                    } else {
                        if(
$exp[$dmode+1]!=''){ $dir_sub[$cnt] += 1; }
                    }
                }
            }
        }


        foreach(
$dir_array as $key=>$val){
            
$dmode_next $dmode+1;
            if(
$dmode=='1'){ $dir_parent[$key] = $val; }
            if(
$dir_sub[$key]!=''){ $sub_mark "<div class='pm_dir icon-plus-squared pointer open_sub_dir' data-level='{$dmode}'><span class='none'>".$dir_parent[$key]."</span></div>"; } else { $sub_mark "<div class='pm_dir icon-folder-empty'><span class='none'>".$dir_parent[$key]."</span></div>"; }
            
$ml 15+(($dmode-1)*15);
            
$ck "<input type='radio' name='dir_ck' value='{$dir_parent[$key]}'>";
            echo 
"<li>{$sub_mark} {$ck} <span class='dir_click_class' data-dir='{$dir_parent[$key]}'>{$val}</span><ul class='dir{$dmode_next}_class' style='margin-left:15px;'></ul></li>";
        }
    }

?>