corrade-http-templates – Blame information for rev 1

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;
26 # Bail if "firstname", "lastname" or the "message" variables are blank.
27 if(!isset($_POST['firstname']) ||
28 !isset($_POST['lastname']) ||
29 !isset($_POST['message'])) return;
30  
31 ####
32 # I. Get the path to the configured chat directory.
33 $chatPath = realpath($CHAT_DIRECTORY);
34  
35 ####
36 # II. Get the user path.
37 $userPath = join(
38 DIRECTORY_SEPARATOR,
39 array(
40 $CHAT_DIRECTORY,
41 ucfirst(
42 strtolower(
43 $_POST['firstname']
44 )
45 ) .' '.
46 ucfirst(
47 strtolower(
48 $_POST['lastname']
49 )
50 ).'.log'
51 )
52 );
53  
54 ####
55 # III. Check that the file will be placed within the chat directory.
56 $pathPart = pathinfo($userPath);
57 if(realpath($pathPart['dirname']) != $chatPath)
58 die;
59  
60 storeAvatarConversation(
61 $_POST['firstname'],
62 $_POST['lastname'],
63 $_POST['message'],
64 $userPath,
65 $CHAT_LINES
66 );
67  
68 ?>