C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$RC7O0L9\function.inc.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?php

function dbg(&$arg)
{
    echo 
'<PRE>';
    
print_r($arg);
    echo 
'</PRE>';
}

function 
GetLocText($arg$opt=true)
{
    global 
$PMS_text;
    if (isset(
$PMS_text["$arg"]))
    {
        if (
$opt
        {
            return 
nl2br(htmlspecialchars($PMS_text["$arg"], ENT_QUOTES));
        } else
        {
            return 
$PMS_text["$arg"];
        }    
    } else
    {
        if (
$opt
        {
            return 
' ';
        } else
        {
            return 
'&nbsp;';
        }
    }
}

function 
AddSlash($arg)
{
    if (
$GLOBALS['PMS']['os']=='win')
    {
        return ((
substr($arg, -1)=='/')||(substr($arg, -1)=='\\'))?$arg:"$arg\\";
    } else
    {
        return (
substr($arg, -1)=='/')?$arg:"$arg/";
    }    
}

function 
DecodeGET($arg)
{
    
$rs='';
    
$i=0;
    for (
$i=0$i<strlen($arg); $i+=2)
    {
        if ((
$i+1)<strlen($arg))
        {
            
$rs.=chr((((hexdec($arg{$i}.$arg{$i+1})^($GLOBALS['PMS']['key2']&255))-($GLOBALS['PMS']['key1']&255))&255));
        }        
    }
    return 
trim($rs);
}

function 
EncodeGET($arg)
{
    
$arg trim((string)$arg);
    
$rs='';
    for (
$i=0$i<strlen($arg); $i++)
    {        
        
$rs.=sprintf('%02x',((ord($arg{$i})+($GLOBALS['PMS']['key1']&255))&255)^($GLOBALS['PMS']['key2']&255));
    }    
    return 
$rs;
}

function 
DecodePOST($arg)
{
    return 
DecodeGET($arg);
}

function 
EncodePOST($arg)
{
    return 
EncodeGET($arg);
}

function 
GetPath($arg1$arg2)
{
    return 
realpath(AddSlash($arg1).$arg2);
}

function 
GetParPath($arg)
{
    if (
$GLOBALS['PMS']['os']=='win')
    {
        
$pos=strrpos($arg'\\');
        if (
$pos !== false)
        {
            
$path=substr($arg,0,$pos+1);        
        }
    } else
    {
        
$pos=strrpos($arg'/');
        if (
$pos !== false)
        {
            
$path=substr($arg,0,$pos+1);
            return (
$path=='/')?'/':substr($path0strlen($path)-1);
        }
    }
    return 
'';
}

function 
CheckWorkDir()
{
    if ((
$rs=fileperms(AddSlash($GLOBALS['PMS']['pmsdir']).'work'))!==false)
    {
        return 
$rs&511;        
    }
    return -
1;
}

function 
RandomCode()
{
    
srand((double)microtime()*1000000);
    
$cs='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    
$rs='';
    while(
strlen($rs)<10)
    {
        
$rs.=substr($cs,(rand()%(strlen($cs))),1);
    }
    return 
$rs;
}

function 
DisplayError($arg1$arg2='')
{
    echo 
"<SPAN class=error>$arg1</SPAN>";
    if (!empty(
$arg2)) echo "<BR><SPAN class=text1>[$arg2]</SPAN>";
    echo 
'<BR>';
}

function 
DisplayMessage($arg1$arg2='')
{
    echo 
"<SPAN class=message>$arg1</SPAN>";
    if (!empty(
$arg2)) echo "<BR><SPAN class=text1>[$arg2]</SPAN>";
    echo 
'<BR>';
}

function 
GetDirName($arg)
{
    global 
$PMS;
    switch (
$PMS['os'])
    {
        case 
'linux':    if ($arg=='/'
                        {
                            return 
$arg;
                        } else
                        {
                            
$rs substr(strrchr($arg'/'), 1);
                            return 
$rs;
                        }
                        break;

        case 
'win':        $rs substr(strrchr($arg'\\'), 1);
                        return 
$rs;

    }
    return 
$arg;
}

function 
GetStartDir()
{
    return 
realpath(AddSlash($GLOBALS['PMS']['directory']['docroot']).$GLOBALS['PMS']['directory']['startdir']);
}

function 
FormatFile($arg$hl=false$br=true)
{
    if (
CheckFilesize($arg))
    {
        if (
$hl)
        {
            @
highlight_file($arg);
            return 
true;
        } elseif (
$fh = @fopen($arg'r'))
        {
            
$buffer='';
            while (!@
feof($fh))
            {
                
$buffer .= @fgets($fh4096);
                
$lines explode("\n"$buffer);
                
$cnt count($lines);
                if (
$cnt 0)
                {
                    for (
$i=0$i<($cnt-1); $i++)
                    {
                        echo 
htmlentities(rtrim($lines[$i])).(($br)?"<BR>":"\n");
                    }
                    
$buffer=$lines[$cnt-1];
                }
            }
            echo 
htmlentities(rtrim($buffer));
            @
fclose($fh);
            return 
true;
        }
    }
    return 
false;
}

function 
CheckFilesize($arg)
{
    global 
$PMS;
    if (
filesize($arg) > $PMS['max_filesize'])
    {
        echo 
GetLocText('msg_filesize');
        
$PMS['fs_msg']=true
        return 
false;
    }
    return 
true;
}

function 
FileExists($arg)
{
    return (@
is_file($arg)===false)?false:true;
}

function 
DirExists($arg)
{
    return (@
is_dir($arg)===false)?false:true;
}

function 
GetPerm($arg1$arg2=0)
{    
    global 
$_POST;
    
$tab=Array
    (
        
'su' => 2048,
        
'sg' => 1024,
        
'st' => 512,    
        
'ur' => 256,
        
'uw' => 128,
        
'ue' => 64,
        
'gr' => 32,
        
'gw' => 16,
        
'ge' => 8,
        
'or' => 4,
        
'ow' => 2,
        
'oe' => 1,
    );
    if (isset(
$tab[$arg1]))
    {
        return (isset(
$_POST[$arg1])&&(HandlePost($_POST[$arg1])==1)||(((octdec(($arg2==1)?$GLOBALS['PMS']['defpermdir']:$GLOBALS['PMS']['defpermfile']))&$tab[$arg1])!=0))?' checked':'';
    }    
    return 
'';
}

function 
GetPermCode()
{
    global 
$_POST;
    
$tab=Array
    (    
        
'su' => 2048,
        
'sg' => 1024,
        
'st' => 512,    
        
'ur' => 256,
        
'uw' => 128,
        
'ue' => 64,
        
'gr' => 32,
        
'gw' => 16,
        
'ge' => 8,
        
'or' => 4,
        
'ow' => 2,
        
'oe' => 1,
    );
    
$rs=0;
    
reset($_POST);
    while (list(
$key,$val) = each($_POST))
    {
        if (isset(
$tab[$key])&&($val==1))
        {
            
$rs|=$tab[$key];
        }
    }
    return 
sprintf('%04o'$rs);    
}

function 
PermRWX2Dec($arg)
{
    
$rs=0;
    
$rs|=($arg{1}=='r')?256:0;
    
$rs|=($arg{2}=='w')?128:0;
    
$rs|=($arg{3}=='x')?64:(($arg{3}=='s')?2112:(($arg{3}=='S')?2048:0));
    
$rs|=($arg{4}=='r')?32:0;
    
$rs|=($arg{5}=='w')?16:0;
    
$rs|=($arg{6}=='x')?8:(($arg{6}=='s')?1032:(($arg{6}=='S')?1024:0));
    
$rs|=($arg{7}=='r')?4:0;
    
$rs|=($arg{8}=='w')?2:0;
    
$rs|=($arg{9}=='x')?1:(($arg{9}=='t')?513:(($arg{9}=='T')?512:0));
    return 
$rs;
}

function 
PermDec2RWX($arg)
{
    
$rs='';
    
$rs.=(($arg&256)!=0)?'r':'-';
    
$rs.=(($arg&128)!=0)?'w':'-';
    
$rs.=(($arg&64)!=0)?((($arg&2048)!=0)?'s':'x'):((($arg&2048)!=0)?'S':'-');
    
$rs.=(($arg&32)!=0)?'r':'-';
    
$rs.=(($arg&16)!=0)?'w':'-';
    
$rs.=(($arg&8)!=0)?((($arg&1024)!=0)?'s':'x'):((($arg&1024)!=0)?'S':'-');
    
$rs.=(($arg&4)!=0)?'r':'-';
    
$rs.=(($arg&2)!=0)?'w':'-';
    
$rs.=(($arg&1)!=0)?((($arg&512)!=0)?'t':'x'):((($arg&512)!=0)?'T':'-');
    return 
$rs;    
}

function 
HandlePost($arg)
{
    if (
get_magic_quotes_gpc()||get_magic_quotes_runtime())
    {
        
$arg=stripslashes($arg);
    }
    if (
ini_get('magic_quotes_sybase')==1)
    {
        
$arg=str_replace("''""'"$arg);
    }
    
$arg=str_replace('"','&quot;',$arg);
    return 
$arg;
}

function 
HandlePostText(&$arg)
{
    if (
get_magic_quotes_gpc()||get_magic_quotes_runtime())
    {
        
$arg=stripslashes($arg);
    }
    if (
ini_get('magic_quotes_sybase')==1)
    {
        
$arg=str_replace("''""'"$arg);
    }
    
$arg=str_replace("\r\n""\n"$arg);
}
?>