source: devel/www/sunrisechat/webchatsend.php@ 89

Last change on this file since 89 was 89, checked in by george, 17 years ago

Přidáno: Chybějící soubory nového webu centrály.

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1<?php
2
3function AddPart($Text)
4{
5 global $Data;
6 $Data .= $Text.'|';
7}
8
9// Sending message
10function Send($Command,$Text)
11{
12 global $Data;
13 //echo($Command.'-'.$Text);
14 $ProtocolVersion = 2;
15 //$IP = '192.168.0.1';
16 $IP = $_SESSION['IP'];
17 $DestinationIP = '';
18 if(!array_key_exists('ID',$_SESSION)) $_SESSION['ID'] = rand(100000,999999);
19 $ID = $_SESSION['ID'];
20 $DestinationID = '0';
21 $Sequence = 0;
22 $Filename = '/tmp/sunrisechatin';
23 $Color = 0;
24
25 $Data = '';
26 AddPart($ProtocolVersion);// Version of protocol
27 AddPart($DestinationIP); // Destination IP
28 AddPart($DestinationID); // Destination ID
29 AddPart($IP); // Source IP
30 AddPart($ID); // Source ID
31 if(!array_key_exists('sequence',$_SESSION)) $_SESSION['sequence'] = 1;
32 $_SESSION['sequence'] = $_SESSION['sequence'] + 1;
33 AddPart($_SESSION['sequence']); // Sequence command number
34 AddPart($Command); // Command
35 if($Command == 'Message')
36 {
37 AddPart($Color); // User text color
38 AddPart($Text); // Command data
39 $RoomName = 'Všichni';
40 AddPart($RoomName); // Room name
41 AddPart(0); // Public or private room
42 }
43 if($Command == 'Connect')
44 {
45 $Nick = $_SESSION['nick'];
46 AddPart($Nick); // User name
47 $NickTime = '27.6.2005 13:49:24';
48 AddPart($NickTime); // User name time
49 }
50 if($Command == 'UserInfo')
51 {
52 $Nick = $_SESSION['nick'];
53 AddPart($Nick); // User name
54 $NickTime = '27.6.2005 13:49:24';
55 AddPart($NickTime); // User name time
56 $Reason = '';
57 AddPart($Reason); // Away mode reason
58 $Status = 'Online';
59 AddPart($Status); // User status
60 $HostName = GetHostByAddr($IP);
61 //$HostName = 'centrala';
62 AddPart($HostName); // Local host name
63 $OSVersion = 'Fedora Core 4';
64 AddPart($OSVersion); // OS version
65 $OSUser = 'Guest';
66 AddPart($OSUser); // Logged user
67 $Uptime = '27.6.2005 13:49:24';
68 AddPart($Uptime); // Application uptime
69 $Client = 'Web SunriseChat';
70 AddPart($Client); // Name of client application
71 $ClientVersion = '1.0';
72 AddPart($ClientVersion); // Version of application
73 $CoreVersion = '2.5';
74 AddPart($CoreVersion); // SunriseChatCoreVersion
75 $Now = '27.6.2005 13:49:24';
76 AddPart($Now); // Local system time
77 $DetailInfo = $_SESSION['DetailInfo'];
78 AddPart($DetailInfo); // Detailed info about user
79 }
80 //echo('Command: '.$Command.' Text: '.$Text.' Data: '.$Data.'<br>');
81
82 // Save data to file
83 $File = fopen($Filename,'a+');
84 $Data = StrTr($Data, "\xA9\xAB\xAE\xB9\xBB\xBE", "\x8A\x8D\x8E\x9A\x9D\x9E");
85 $Data = fputs($File, $Data."\n");
86 fclose($File);
87}
88
89?>
Note: See TracBrowser for help on using the repository browser.