corrade-http-templates – Blame information for rev 41

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 ###########################################################################
11 ## CONFIGURATION ##
12 ###########################################################################
13  
14 require_once('config.php');
15 require_once('functions.php');
16  
17 ###########################################################################
18 ## INTERNALS ##
19 ###########################################################################
20  
21 # Check if this is the group chat notification.
22 if(!isset($_POST['type']) || $_POST['type'] != "message") return;
4 eva 23 # Check that we have all the required variables.
1 eva 24 if(!isset($_POST['firstname']) ||
4 eva 25 empty($_POST['firstname']) ||
1 eva 26 !isset($_POST['lastname']) ||
4 eva 27 empty($_POST['lastname']) ||
28 !isset($_POST['message']) ||
29 empty($_POST['message'])) return;
1 eva 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 ?>