<?php require_once '../../../lib/pusher/Pusher.php'; include '../../config.php'; require_once 'Activity.php'; date_default_timezone_set('UTC'); $chat_info = $_POST['chat_info']; if (!isset($_POST['chat_info'])) { header("HTTP/1.0 400 Bad Request"); echo 'chat_info must be provided'; } $options = sanitise_input($chat_info); $activity = new Activity('chat-message', $options['text'], $options); $pusher = new Pusher(APP_KEY, APP_SECRET, APP_ID); $data = $activity->getMessage(); $response = $pusher->trigger(PRESENCE_CHANNEL_NAME, 'chat_message', $data, null, true); header('Cache-Control: no-cache, must-revalidate'); header('Content-type: application/json'); $result = array('activity' => $data, 'pusherResponse' => $response); echo json_encode($result); function get_channel_name($http_referer) { // not allowed :, / % # $pattern = "/(\\W)+/"; $channel_name = preg_replace($pattern, '-', $http_referer); return $channel_name; } function sanitise_input($chat_info) { $email = isset($chat_info['email']) ? $chat_info['email'] : ''; $options = array();
require_once 'lib/squeeks-Pusher-PHP/lib/Pusher.php'; require_once '../../src/php/Activity.php'; require_once 'config.php'; $activity_type = $_GET['activity_type']; $activity_data = null; $email = null; if (isset($_GET['activity_data'])) { $activity_data = $_GET['activity_data']; } if (isset($_GET['email'])) { $email = $_GET['email']; } $action_text = getActionText($activity_type, $activity_data); $activity = new Activity($activity_type, $action_text, $email); $pusher = new Pusher(APP_KEY, APP_SECRET, APP_ID); $pusher->trigger('site-activity', $activity_type, $activity->getMessage()); /****************************************************************************************/ function getActionText($activity_type, $activity_data) { $action_text = 'just did something unrecognisable.'; switch ($activity_type) { case 'page-load': $action_text = 'just navigated to the Activity Streams example page.'; break; case 'test-event': $action_text = 'just clicked the <em>Send Test</em> button.'; break; case 'scroll': $action_text = 'just scrolled to the ' . $activity_data['position'] . ' of the page'; break; case 'like':