fileeditor

Gesponsorde koppelingen

PHP script bestanden

  1. fileeditor

« Lees de omschrijving en reacties

[index.php]

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<?php
/*------------------------------*/
/*----------FileEditor----------*/
/*-Copyright By Wessel Bruinsma-*/
/*------------------------------*/

session_start();
?>

<html>
    <head>
        <title>
            FileEditor
        </title>
        <link rel="stylesheet" href="style.css" type="text/css">
    </head>
    <body>
        <?php
        if (isset($_GET['editor']))
            echo '<form action="index.php?path='.$_GET['path'].'&save&editor" method="POST">';
        ?>

        <div id="Kop">
        FileEditor
        </div>
        <div id="Dat">
        <?php
        /*----------------*/
        /*-----CONFIG-----*/
        /*----------------*/
                
        //System

        $StartDirectory = ''; //Niks is de relative map.
        $DoNotGoOutOfAboveDir = false;
        $WritePermission = true;
        $SupervisorInIP = '';  //Scheiden door een puntkomma: ';'.
        
        //Style

        $AutoUpdate = true;
        $StyleWidth = '50%';
        $StyleTopColor = '32CD32'; //Hex.
        $StyleMiddleColor = 'FFA500'; //Hex.
        $StyleBottomColor = '87CEEB'; //Hex.
        
        /*HANDLEIDING
        Zet deze 'index.php' in de map waar hij moet komen.
        Vul vervolgens de CONFIG in naar wens en het is klaar voor gebruik.
        Voor de bovenstaande gevens in voor de style, en die zal dan worden aangemaakt.
        -----------*/
        
        /*HIERONDER NIKS MEER BEWERKEN*/

        $StartDirectory = str_replace('\\','/',$StartDirectory);
        $buff = explode(';',$SupervisorInIP);
        $IpTrue = false;
        for ($nr = 0;$nr < count($buff);$nr++)
        {

            if ($buff[$nr] == $_SERVER['REMOTE_ADDR'])
                $IpTrue = true;
        }

        if (!file_exists('BlokkedIps'))
        {

            fclose(fopen('BlokkedIps','w'));
            chmod('BlokkedIps',0777);
        }

        if (!file_exists('style.css') || $AutoUpdate == tru)
        {

            $handle = fopen('style.css','w');
            fwrite($handle,'BODY
{
    background-color: #C0C0C0;
    color: #000000;
    font-size: 12pt;
    margin: 0;
    padding: 5;
}

#Kop, #Dat, #Foot
{
    border: #000000 solid 1px;
    font-family: Arial;
    margin: 1px;
    padding: 1px;
    width: '
.$StyleWidth.';
    text-align: left;
    color: #000000;
}

#Kop
{
    background-color: #'
.$StyleTopColor.';
    font-weight: bold;
    padding: 2pt;
    margin-bottom: 0px;
}

#Dat
{
    background-color: #'
.$StyleMiddleColor.';
    padding: 2pt;
    margin-top: -1px;
    margin-bottom: -1px;
}

#Foot
{
    background-color: #'
.$StyleBottomColor.';
    padding: 2pt;
    margin-top: 0px;
}

A
{
    text-decoration: none;
    color: #00008B;
}

A:hover
{
    text-decoration: none;
    color: #0000CD;
    position: relative;
    left: 2;
}

#Mod
{
    font-size: 10pt;
    width: 30%;
    margin: -1px;
    padding: 1px;
    float: right;
    border: #000000 solid 1px;
    background-color: #00BFFF;
}

INPUT
{
    font-size: 9pt;
    border: #000000 solid 1px;
    background-color: #FFFFFF;
    margin: 1pt;
    padding: 1pt;
    font-family: Arial;
}

INPUT:hover
{
    font-size: 9pt;
    border: #000000 solid 1px;
    background-color: #C0C0C0;
    margin: 1pt;
    padding: 1pt;
}

#TxtArea
{
    font-size: 9pt;
    border: #000000 solid 1px;
    background-color: #FFFFFF;
    font-family: Arial;
    margin: 1pt;
    padding: 1pt;
}

#Line
{
    height: 1pt;
    margin-bottom: 3pt;
    margin-top: 3pt;
}'
);
        fclose($handle);
    }
        function
ipcheck()
        {

            $ret = true;
            $file = file('BlokkedIps');
            for ($nr = 0;$nr < count($file);$nr++)
            {

                $buf = explode(':',$file[$nr]);
                if ($buf[1] == $_SERVER['REMOTE_ADDR'])
                    $ret = false;
            }

            return $ret;
        }

        if ($StartDirectory != '')
            $StartDirectory = str_replace('\\','/',realpath($StartDirectory));
        function
ipban()
        {

            $buf = '';
            $file = file('BlokkedIps');
            for ($nr = 0;$nr < count($file);$nr++)
            {

                if ($nr == 0)
                    $buf .= chr(10);
                $file .= $file[$nr];
            }

            if ($buf != '')
                $file .= chr(10);
            $file .= ':'.$_SERVER['REMOTE_ADDR'].':';
            $handle = fopen('BlokkedIps','w');
            fwrite($handle,$file);
            fclose($handle);
        }
        function
insLine()
        {

            echo '<br><img src="LinePix.bmp" id="Line" alt="Line" width="100%" height="16pt">';
        }
        function
urlcheck($sdir,$path)
        {

            $sdir = str_replace('/','\\/',$sdir);
            if (ereg('^'.$sdir,$path))
            {

                return true;
            }

            else
            {
                return false;
            }
        }

        if ($DoNotGoOutOfAboveDir == true && isset($_GET['path']))
            $UC = urlcheck($StartDirectory,$_GET['path']);
        elseif (!isset($_GET['path']))
            $UC = true;
        else
            $UC = true;
        if ((!isset($_GET['editor']) && $UC == true) || $IpTrue)
        {

            if (isset($_GET['path']))
                $path = $_GET['path'];
            else
                $path = $StartDirectory;
            if (isset($_GET['editor']))
                $mod = 'File Edit';
            else
                $mod = 'Search File';
            echo '<div id="Mod">Mod: <u>'.$mod.'</u></div>';
            if ($start_dir == '')
            {

                $buff = substr($_SERVER['PHP_SELF'],1,strlen($_SERVER['PHP_SELF']));
                $buff = explode('/',$buff);
                if (count($buff) < 2)
                {

                    $start_dir = '/';
                }

                else
                {
                    $start_dir = '../'.$buff[count($buff)-2];
                }
            }

            $somedat = false;
            $canDo = true;
            $once = true;
            $start_dir = str_replace('\\', '/',$start_dir);
            if ($path == '')
            {

                $path_parent = '../';
                $path_with = '';
            }

            else
            {
                if ($path[strlen($path)-2] == '.')
                {

                    if (substr($path,strlen($path)-1,strlen($path)-1) != '/')
                        $path .= '/';
                    $path_parent = $path.'../';
                }

                else
                {
                    if (substr($path,strlen($path)-1,strlen($path)-1) != '/')
                        $path_parent = $path.'/';
                    else
                        $path_parent = $path;
                    $buf = explode('/',$path_parent);
                    $path_parent = '';
                    if (count($buf) > 3)
                    {

                        for ($nr = 0;$nr < count($buf)-3;$nr++)
                            $path_parent .= $buf[$nr].'/';
                    }

                    $path_parent .= $buf[count($buf)-3].'/';
                }

                
                if (substr($path,strlen($path)-1,strlen($path)-1) != '/')
                    $path .= '/';
                
                $path_with = $path;
            }

            
            if ($path == '')
                $startdir = $start_dir;
            else
                $startdir = $path;
            if ($handle = opendir($startdir))
            {

                while (false !== ($file = readdir($handle)))
                {

                    if ($canDo == true && $file == '..')
                    {

                        echo '<img src="IcoUp.bmp" alt="Level Up"> <a href="index.php?path='.$path_parent.'">Parent Directory</a>';
                        insLine();
                        $canDo = false;
                    }
elseif ($once == true && $file != '..') {
                        $noPar = true;
                        if ($_handle = opendir($startdir))
                        {

                            while (false !== ($_file = readdir($_handle)))
                            {

                                if ($_file == '..')
                                {

                                    $noPar = false;
                                }
                            }

                            if ($noPar)
                            {

                                echo '<img src="IcoUp.bmp" alt="Level Up"> <i>No Parent Directory</i>';
                                insLine();
                                $once = false;
                            }
                        }

                        closedir($_handle);
                    }
                }

                closedir($handle);
            }

            if ($handle = opendir($startdir))
            {

                while (false !== ($file = readdir($handle)))
                {

                    if ($file != '.' && $file != '..')
                    {

                        if (is_dir($path_with.$file))
                            echo '<br><img src="IcoMap.bmp" alt="Map"> <a href="index.php?path='.$path_with.$file.'">'.$file.'</a> - <i>Directory</i>';
                        else
                        {
                            if ($WritePermission == true || $IpTrue)
                                echo '<br><img src="IcoFile.bmp" alt="File"> <a href="index.php?editor&path='.$path_with.$file.'">'.$file.'</a> - <i>File</i> - <i>'.filesize($path_with.$file).' Bytes</i>';
                            else
                                echo '<br><img src="IcoFile.bmp" alt="File"> '.$file.' - <i>File</i> - <i>'.filesize($path_with.$file).' Bytes</i>';
                        }

                        $somedat = true;
                    }
                }

                closedir($handle);
            }

            
            if (!$somedat)
            {

                echo '<br>Er zijn geen bestanden gevonden...';
            }
        }

        elseif ((isset($_GET['path']) && (($IsPos == true || ($WritePermission == true && $UC == true)) || $IpTrue)))
        {

            if (isset($_GET['editor']))
                $mod = 'File Edit';
            else
                $mod = 'Search File';
            echo '<div id="Mod">Mod: <u>'.$mod.'</u></div>';
            echo 'File: ';
            $buff = $_GET['path'];
            $buff = explode('/',$buff);
            echo $buff[count($buff)-1];
            insLine();
            if (isset($_GET['save']) && isset($_SESSION['Save']) && $_SESSION['Save'] == 'Check' && ipcheck() == true && $WritePermission == true && $UC == true)
            {

                $handle = fopen($_GET['path'],'w');
                chmod($_GET['path'],0777);
                $txt = str_replace('$lt;','<',$_POST['txt']);
                fwrite($handle,$txt);
                fclose($handle);
                echo 'Opgeslagen...';
                session_unregister('Save');
                session_destroy();
            }
elseif (isset($_GET['save'])) {
                ipban();
                echo 'Wegens niet-gebruik van deze site om bestanden te<br>bewerken bent u geblokt om te bewerken!';
                $blocktwice = true;
            }

            if (ipcheck() == false && !isset($blocktwice))
            {

                ipban();
                echo 'Wegens niet-gebruik van deze site om bestanden te<br>bewerken bent u geblokt om te bewerken!';
            }

            $inBuf = '';
            for ($nr = 0;$nr < count($buff)-1; $nr++)
                $inBuf .= $buff[$nr].'/';
            $cont = '';
            $file = file($_GET['path']);
            for ($nr = 0;$nr < count($file);$nr++)
                $cont .= $file[$nr];
            $cont = str_replace('<','&lt;',$cont);
            ?>
<br>Content:<br>
            <textarea cols="100" rows="20" name="txt" id="TxtArea"><?php echo $cont; ?></textarea><br>
            <input type="submit" value="Opslaan"> |
            <input type="button" value="Terug" onClick="javascript:document.location='index.php?path=<?php echo $inBuf; ?>';">
            <?php
            $_SESSION
['Save'] = 'Check';
        }
elseif(isset($_GET['save']) && isset($_GET['editor'])) {
            echo 'Door dit illegale gebruik zal u worden geblokt.<br><input type="button" value="Terug" onClick="javascript:history.go(-1);">';
            ipban();
        }

        else
        {
            echo 'Deze functie is beperkt of de toegang is geweigerd door de webmaster.<br><input type="button" value="Terug" onClick="javascript:history.go(-1);">';
        }

        ?>

        </div>
        <div id="Foot"><i>
        Copyright &copy; By Wessel Bruinsma
        </i></div>
        <?php
        if (isset($_GET['editor']))
            echo '</form>';
        ?>

    </body>
</html>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.