corrade-http-templates – Diff between revs 2 and 4
?pathlinks?
Rev 2 | Rev 4 | |||
---|---|---|---|---|
Line 12... | Line 12... | |||
12 | |
12 | |
|
13 | ########################################################################### |
13 | ########################################################################### |
|
14 | ## CONFIGURATION ## |
14 | ## CONFIGURATION ## |
|
Line 15... | Line -... | |||
15 | ########################################################################### |
- | ||
16 | |
- | ||
17 | # Set this to the name of the group. |
- | ||
18 | $GROUP = 'My Group'; |
- | ||
19 | # How many chat lines to store? |
15 | ########################################################################### |
|
20 | $CHAT_LINES = 10; |
16 | |
|
21 | # Set this to the group password. |
- | ||
22 | $PASSWORD = 'mypassword'; |
- | ||
Line 23... | Line 17... | |||
23 | # Set this to Corrade's HTTP Server URL. |
17 | require_once('config.php'); |
|
24 | $URL = 'http://corrade.hostname:8080'; |
18 | require_once('functions.php'); |
|
25 | |
19 | |
|
Line 26... | Line 20... | |||
26 | ########################################################################### |
20 | ########################################################################### |
|
27 | ## INTERNALS ## |
21 | ## INTERNALS ## |
|
28 | ########################################################################### |
22 | ########################################################################### |
|
29 | |
23 | |
|
30 | # Check if this is the group chat notification. |
24 | # Check if this is the group chat notification. |
|
31 | if(!isset($_POST['type']) || $_POST['type'] != "group") return; |
25 | if(!isset($_POST['type']) || $_POST['type'] != "group") return; |
|
32 | # Check that the notification is for the configured group. |
26 | # Check that the notification is for the configured group. |
|
33 | if(!isset($_POST['group']) || $_POST['group'] != $GROUP) return; |
27 | if(!isset($_POST['group']) || $_POST['group'] != $GROUP) return; |
|
34 | # Bail if "firstname", "lastname" or the "message" variables are blank. |
- | ||
35 | if($_POST['firstname'] == '' |
- | ||
36 | || $_POST['lastname'] == '' |
- | ||
37 | || $_POST['message'] == '') return; |
- | ||
38 | |
- | ||
39 | ########################################################################### |
- | ||
40 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
28 | # Bail if "firstname", "lastname" or the "message" variables are blank. |
|
41 | ########################################################################### |
- | ||
42 | function atomized_put_contents($file, $data) { |
- | ||
43 | $fp = fopen($file, "w+"); |
- | ||
44 | if (flock($fp, LOCK_EX)) { |
- | ||
45 | fwrite($fp, $data); |
- | ||
46 | fflush($fp); |
- | ||
47 | flock($fp, LOCK_UN); |
- | ||
48 | } |
- | ||
49 | fclose($fp); |
- | ||
50 | } |
- | ||
51 | ########################################################################### |
- | ||
52 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
- | ||
53 | ########################################################################### |
29 | if(!isset($_POST['firstname']) || |
|
54 | function atomized_get_contents($file) { |
30 | empty($_POST['firstname']) || |
|
55 | $fp = fopen($file, "r+"); |
- | ||
56 | $ct = ''; |
- | ||
57 | if (flock($fp, LOCK_SH)) { |
- | ||
58 | if (filesize($file)) { |
- | ||
59 | $ct = fread($fp, filesize($file)); |
- | ||
60 | } |
- | ||
61 | flock($fp, LOCK_UN); |
- | ||
Line 62... | Line 31... | |||
62 | } |
31 | !isset($_POST['lastname']) || |
|
63 | fclose($fp); |
32 | empty($_POST['lastname']) || |
|
64 | return $ct; |
33 | !isset($_POST['message']) || |