corrade-http-templates – Diff between revs 4 and 41

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 4 Rev 41
1 <?php 1 <?php
2   2  
3 ########################################################################### 3 ###########################################################################
4 ## Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 ## 4 ## Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 ##
5 ########################################################################### 5 ###########################################################################
6 ## This is a script that stores instant messages to a local file inside ## 6 ## This is a script that stores instant messages to a local file inside ##
7 ## a sub-directory from the current path. ## 7 ## a sub-directory from the current path. ##
8 ########################################################################### 8 ###########################################################################
9   -  
10 # Send the response back to Corrade. -  
11 http_response_code(200); -  
12   9  
13 ########################################################################### 10 ###########################################################################
14 ## CONFIGURATION ## 11 ## CONFIGURATION ##
15 ########################################################################### 12 ###########################################################################
16   13  
17 require_once('config.php'); 14 require_once('config.php');
18 require_once('functions.php'); 15 require_once('functions.php');
19   16  
20 ########################################################################### 17 ###########################################################################
21 ## INTERNALS ## 18 ## INTERNALS ##
22 ########################################################################### 19 ###########################################################################
23   20  
24 # Check if this is the group chat notification. 21 # Check if this is the group chat notification.
25 if(!isset($_POST['type']) || $_POST['type'] != "message") return; 22 if(!isset($_POST['type']) || $_POST['type'] != "message") return;
26 # Check that we have all the required variables. 23 # Check that we have all the required variables.
27 if(!isset($_POST['firstname']) || 24 if(!isset($_POST['firstname']) ||
28 empty($_POST['firstname']) || 25 empty($_POST['firstname']) ||
29 !isset($_POST['lastname']) || 26 !isset($_POST['lastname']) ||
30 empty($_POST['lastname']) || 27 empty($_POST['lastname']) ||
31 !isset($_POST['message']) || 28 !isset($_POST['message']) ||
32 empty($_POST['message'])) return; 29 empty($_POST['message'])) return;
33 30
34 #### 31 ####
35 # I. Get the path to the configured chat directory. 32 # I. Get the path to the configured chat directory.
36 $chatPath = realpath($CHAT_DIRECTORY); 33 $chatPath = realpath($CHAT_DIRECTORY);
37   34  
38 #### 35 ####
39 # II. Get the user path. 36 # II. Get the user path.
40 $userPath = join( 37 $userPath = join(
41 DIRECTORY_SEPARATOR, 38 DIRECTORY_SEPARATOR,
42 array( 39 array(
43 $CHAT_DIRECTORY, 40 $CHAT_DIRECTORY,
44 ucfirst( 41 ucfirst(
45 strtolower( 42 strtolower(
46 $_POST['firstname'] 43 $_POST['firstname']
47 ) 44 )
48 ) .' '. 45 ) .' '.
49 ucfirst( 46 ucfirst(
50 strtolower( 47 strtolower(
51 $_POST['lastname'] 48 $_POST['lastname']
52 ) 49 )
53 ).'.log' 50 ).'.log'
54 ) 51 )
55 ); 52 );
56   53  
57 #### 54 ####
58 # III. Check that the file will be placed within the chat directory. 55 # III. Check that the file will be placed within the chat directory.
59 $pathPart = pathinfo($userPath); 56 $pathPart = pathinfo($userPath);
60 if(realpath($pathPart['dirname']) != $chatPath) 57 if(realpath($pathPart['dirname']) != $chatPath)
61 die; 58 die;
62   59  
63 storeAvatarConversation( 60 storeAvatarConversation(
64 $_POST['firstname'], 61 $_POST['firstname'],
65 $_POST['lastname'], 62 $_POST['lastname'],
66 $_POST['message'], 63 $_POST['message'],
67 $userPath, 64 $userPath,
68 $CHAT_LINES 65 $CHAT_LINES
69 ); 66 );
70   67  
71 ?> 68 ?>
72   69