corrade-http-templates

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 3  →  ?path2? @ 4
/groupChat/sendGroupMessage.php
@@ -10,37 +10,20 @@
## CONFIGURATION ##
###########################################################################
 
# Set this to the name of the group.
$GROUP = 'My Group';
# Set this to the group password.
$PASSWORD = 'mypassword';
# Set this to Corrade's HTTP Server URL.
$URL = 'http://corrade.hostname:8080';
require_once('config.php');
require_once('functions.php');
 
###########################################################################
## INTERNALS ##
###########################################################################
 
# If there is no "message" or "name" POST variable set then bail.
if(!isset($_POST['message']) || !isset($_POST['name'])) return;
# If there is no message set or no name set or if the message or the name
# are empty then do not proceed any further.
if(!isset($_POST['message']) ||
empty($_POST['message']) ||
!isset($_POST['name']) ||
empty($_POST['name'])) return;
 
###########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
function wasKeyValueGet($key, $data) {
return array_reduce(
explode(
"&",
$data
),
function($o, $p) {
$x = explode("=", $p);
return array_shift($x) != $o ? $o : array_shift($x);
},
$key
);
}
 
####
# I. Build the POST array to send to Corrade.
$params = array(
@@ -70,6 +53,7 @@
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars);
curl_setopt($curl, CURLOPT_ENCODING, true);
$result = curl_exec($curl);
curl_close($curl);
 
@@ -85,11 +69,11 @@
####
# V. Check the status of the command.
switch($status) {
case "True":
echo 'Message sent successfully!';
case "True": # Be silent if the message has been sent successfully.
# echo 'Message sent successfully!';
break;
default:
echo 'Corrade returned the error: '.urldecode(
default: # If an error occured, then return the error message.
echo 'Corrade failed to send the group message and reported the error: '.urldecode(
wasKeyValueGet(
"error",
$result