scratch – Blame information for rev 29

Subversion Repositories:
Rev:
Rev Author Line No. Line
28 office 1 <?php
2  
3 ###########################################################################
4 ## Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3 ##
5 ###########################################################################
6  
7 require_once('inc/pseudocrypt.php');
8 require_once('inc/functions.php');
9 require_once('config.php');
10  
11 #### Build the user path.
12 $userPath = join(
13 DIRECTORY_SEPARATOR,
14 array(
15 $STORE_FOLDER,
16 $SHARED_EDITOR_FILE
17 )
18 );
19  
20 #### Check for path traversals
21 $pathPart = pathinfo($userPath);
22 if (strcasecmp(
23 realpath($pathPart['dirname']), realpath($STORE_FOLDER)) != 0)
24 return;
25  
29 office 26 switch($_SERVER['REQUEST_METHOD']) {
27 case 'POST':
28 #### Retrieve uploaded file.
29 if(!isset($_POST['data']) or empty($_POST['data']))
30 return;
31  
28 office 32 #### Store the file.
29 office 33 atomized_put_contents($userPath, $_POST['data']);
28 office 34 break;
29 office 35 case 'GET':
36 if(!file_exists($userPath))
37 return;
28 office 38 header('Content-Type: text/html; charset=utf-8');
29 office 39 echo atomized_get_contents($userPath);
28 office 40 break;
41 }
42