corrade-http-templates – Blame information for rev 4

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