Example #1
0
 public function init()
 {
     define('DBPATH', 'localhost');
     define('DBUSER', 'root');
     define('DBPASS', 'root');
     define('DBNAME', 'bdpinos');
     // session_start();
     global $dbh;
     $dbh = mysql_connect(DBPATH, DBUSER, DBPASS);
     mysql_selectdb(DBNAME, $dbh);
     if ($_GET['action'] == "chatheartbeat") {
         chatHeartbeat();
     }
     if ($_GET['action'] == "sendchat") {
         sendChat();
     }
     if ($_GET['action'] == "closechat") {
         closeChat();
     }
     if ($_GET['action'] == "startchatsession") {
         startChatSession();
     }
     if (!isset($_SESSION['chatHistory'])) {
         $_SESSION['chatHistory'] = array();
     }
     if (!isset($_SESSION['openChatBoxes'])) {
         $_SESSION['openChatBoxes'] = array();
     }
 }
Example #2
0
define('DBNAME', 'chat');
session_start();
global $dbh;
$dbh = mysql_connect(DBPATH, DBUSER, DBPASS);
mysql_selectdb(DBNAME, $dbh);
if ($_GET['action'] == "chatheartbeat") {
    chatHeartbeat();
}
if ($_GET['action'] == "sendchat") {
    sendChat();
}
if ($_GET['action'] == "closechat") {
    closeChat();
}
if ($_GET['action'] == "startchatsession") {
    startChatSession();
}
if (!isset($_SESSION['chatHistory'])) {
    $_SESSION['chatHistory'] = array();
}
if (!isset($_SESSION['openChatBoxes'])) {
    $_SESSION['openChatBoxes'] = array();
}
function chatHeartbeat()
{
    $sql = "select * from chat where (chat.to = '" . mysql_real_escape_string($_SESSION['username']) . "' AND recd = 0) order by id ASC";
    $query = mysql_query($sql);
    $items = '';
    $chatBoxes = array();
    while ($chat = mysql_fetch_array($query)) {
        if (!isset($_SESSION['openChatBoxes'][$chat['from']]) && isset($_SESSION['chatHistory'][$chat['from']])) {
Example #3
0
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

*/
session_start();

global $dbh;

if ($_GET['action'] == "chatheartbeat") { chatHeartbeat(); } 
if ($_GET['action'] == "sendchat") { sendChat(); } 
if ($_GET['action'] == "closechat") { closeChat(); } 
if ($_GET['action'] == "startchatsession") { startChatSession(); } 

if (!isset($_SESSION['chatHistory'])) {
	$_SESSION['chatHistory'] = array();	
}

if (!isset($_SESSION['openChatBoxes'])) {
	$_SESSION['openChatBoxes'] = array();	
}

function chatHeartbeat() {
	include("../static/site_config.php"); 
	include ("../static/clase_mysql.php");
	$miconexion = new clase_mysql;
	$miconexion->conectar($db_name,$db_host, $db_user,$db_password);
	$miconexion->consulta("select * from chat where (chat.to_ = '".$_SESSION['user']."' AND recd = 0) order by id_chat ASC");  
Example #4
0
$slug = Filter::text($_GET['slug']);
$project = Project::getProjectFromSlug($slug);
if ($_GET['action'] == "getonlineusers") {
    getOnlineUsers($slug);
}
if ($_GET['action'] == "chatheartbeat") {
    chatHeartbeat($slug, $pageId);
}
if ($_GET['action'] == "sendchat") {
    sendChat($pageId);
}
if ($_GET['action'] == "closechat") {
    closeChat();
}
if ($_GET['action'] == "startchatsession") {
    startChatSession($pageId);
}
if (!isset($_SESSION['chatHistory'])) {
    $_SESSION['chatHistory'] = array();
}
if (!isset($_SESSION['openChatBoxes'])) {
    $_SESSION['openChatBoxes'] = array();
}
function chatHeartbeat($slug, $pageId)
{
    //Add check for open chat boxes in order to keep track of multiple windows
    if (empty($_SESSION['openChatBoxes']["{$pageId}"])) {
        $_SESSION['openChatBoxes']["{$pageId}"] = 0;
        $lastRecord = 0;
    } else {
        $lastRecord = $_SESSION['openChatBoxes']["{$pageId}"];
<?php

require '../includes/init.php';
include 'chatFunctions.php';
if (check_login() == true) {
    $username = get_username();
    $enroll = get_enroll();
    $action = $_POST['action'];
    if (isset($_POST['roll'])) {
        $to_roll = mysql_real_escape_string($_POST['roll']);
    }
    if ($action == "startChatSession") {
        startChatSession($to_roll, $enroll);
    } else {
        if ($action == "sendChat") {
            $msg = $_POST['msg'];
            $to_user = mysql_real_escape_string($_POST['name']);
            $t = time() - 3;
            $sql = "SELECT NULL FROM stud_data WHERE usr_roll=" . $to_roll . " AND time>=" . $t;
            $result = mysql_query($sql);
            $count = mysql_num_rows($result);
            if ($count == 1) {
                sendChat($to_roll, $to_user, $msg, $enroll, $username);
            } else {
                echo "<root success='no'><user>" . $to_user . "</user></root>";
            }
        } else {
            if ($action == "getChat") {
                getChat($to_roll, $enroll);
            } else {
                if ($action == "setWritingStatus") {