示例#1
0
function wsOnMessage($clientID, $message, $messageLength, $binary)
{
    global $Server;
    $ip = long2ip($Server->wsClients[$clientID][6]);
    if ($message == "quit") {
        //Send the message to everyone but the person who said it
        foreach ($Server->wsClients as $id => $client) {
            if ($id != $clientID) {
                if ($Server->{"userData"}["{$id}"] == $Server->{"userData"}["{$clientID}"]) {
                    $Server->wsSend($id, json_decode($Server->{"deviceData"}["{$clientID}"])->{"device-details"});
                }
            }
        }
        $Server->wsRemoveClient($clientID);
    } else {
        if ($message == "show") {
            //        $Server->wsSend($clientID, ">oauth::" . $Server->{"data"}["$clientID"]." profile id::".$Server->{"userData"}["$clientID"]).
            //            " device::".$Server->{"deviceData"}["$clientID"];
            $logout = array("oauth" => json_decode($Server->{"deviceData"}["{$clientID}"])->{"device-details"});
            $Server->wsSend($clientID, json_encode($logout));
        } else {
            if ($message == "test") {
                $Server->log("message froma  server");
            } else {
                if ($message == "BROADCAST_LOGIN") {
                    $Server->log($message);
                    foreach ($Server->wsClients as $id => $client) {
                        if ($id != $clientID) {
                            if ($Server->{"userData"}["{$id}"] == $Server->{"userData"}["{$clientID}"]) {
                                $myres = array("LOGIN" => json_decode($Server->{"deviceData"}["{$clientID}"])->{"device-details"});
                                $Server->wsSend($id, json_encode($myres));
                            }
                        }
                    }
                } else {
                    if ($message == "BROADCAST_LOGOUT") {
                        $Server->log($message);
                        foreach ($Server->wsClients as $id => $client) {
                            if ($id != $clientID) {
                                if ($Server->{"userData"}["{$id}"] == $Server->{"userData"}["{$clientID}"]) {
                                    $myres = array("LOGOUT" => json_decode($Server->{"deviceData"}["{$clientID}"])->{"device-details"});
                                    $Server->wsSend($id, json_encode($myres));
                                }
                            }
                        }
                    } else {
                        if ($message == "BROADCAST_LOGOUT_ALL") {
                            $Server->log($message);
                            foreach ($Server->wsClients as $id => $client) {
                                if ($Server->{"userData"}["{$id}"] == $Server->{"userData"}["{$clientID}"]) {
                                    $myres = array("LOGOUT_ALL" => "logout from your device please!");
                                    $Server->wsSend($id, json_encode($myres));
                                }
                            }
                        } else {
                            $Server->{"data"}["{$clientID}"] = $message;
                            $myres = array("oauth" => $Server->{"data"}["{$clientID}"]);
                            $Server->wsSend($clientID, json_encode($myres));
                            $Server->{"flags"}["{$clientID}"] = "false";
                            /*
                             * fetch the user data and store
                             */
                            $Server->{"userData"}["{$clientID}"] = get_profile_id_from_oauth($Server->{"data"}["{$clientID}"]);
                            $Server->{"deviceData"}["{$clientID}"] = get_device_data($Server->{"userData"}["{$clientID}"], $Server->{"data"}["{$clientID}"]);
                        }
                    }
                }
            }
        }
    }
    //    else
    //    {
    //        $Server->log("some ass sent this".$message);
    //      $Server->wsSend($clientID, "get lost:");
    //    }
}
示例#2
0
        $activity_data = array('user_id' => $user_ID, 'device_id' => $devices_ID, 'activity_type' => '', 'activity_notes' => $note, 'activity_date' => date("Y-m-d"));
        $activity_row = getRow("SELECT * FROM `activity_log` WHERE `user_id` ='{$user_ID}'");
        if ($activity_row == null) {
            insertData('activity_log', $activity_data);
            echo "<h3 class='success-msg'>Device Added Successfully.</h3>";
        } else {
            $where = array('user_id' => $user_ID);
            $data = updateData('activity_log', $activity_data, $where);
            echo "<h3 class='success-msg'>Device Updated Successfully.</h3>";
        }
    }
}
if (!empty($_SESSION['user_id'])) {
    $user_data = get_user_data($_SESSION['user_id']);
    $name = $user_data->f_name . ' ' . $user_data->l_name;
    if ($device_data = get_device_data($_SESSION['user_id'])) {
        $purchase_date = $device_data->purchase_date ? $device_data->purchase_date : '';
        $price = $device_data->price ? $device_data->price : '';
        $imei = $device_data->imei_string ? $device_data->imei_string : '';
        $serial = $device_data->serial_num ? $device_data->serial_num : '';
        $phone = $device_data->phone_num ? $device_data->phone_num : '';
        $purchaser = $device_data->purchaser ? $device_data->purchaser : '';
        $model = $device_data->model ? $device_data->model : '';
        $manufac = $device_data->make ? $device_data->make : '';
        $carrie = $device_data->carrier ? $device_data->carrier : '';
        $status = $device_data->device_status ? $device_data->device_status : '';
        $note = get_user_note($_SESSION['user_id']) ? get_user_note($_SESSION['user_id']) : '';
    } else {
        $purchase_date = '';
        $price = '';
        $imei = '';