science-ation/chat.ajax.php

27 lines
936 B
PHP

<?php
require_once('common.inc.php');
//authent_required();
if(array_key_exists('collapsed', $_POST)){
$_SESSION['chat_collapsed'] = $_POST['collapsed'];
}
if(!array_key_exists('subject', $_POST) || !array_key_exists('action', $_POST)){
exit;
}
$params = array();
$params[] = 'since=' . (array_key_exists('since', $_POST) ? intval($_POST['since']) : 0);
$params[] = 'subject=' . urlencode($_POST['subject']);
if(array_key_exists('message', $_POST)){
$message = htmlspecialchars($_POST['message']);
$params[] = 'message=' . urlencode($message);
}
$params[] = 'user=' . urlencode($_SESSION['name']);
$params[] = 'fairname=' . urlencode($config['fairname']);
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://sfiab.ca/messageExchange.php');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, implode('&', $params));
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);
echo $result;