-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathui.php
More file actions
65 lines (57 loc) · 2.82 KB
/
Copy pathui.php
File metadata and controls
65 lines (57 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
*
* file name: ui.php
*
* Credits: This program is derived from a sample client script by Alejandro Gervasio
* posted here: http://www.devshed.com/c/a/PHP/An-Introduction-to-Sockets-in-PHP/
* Modified 2012 by R. Wade Schuette
* Augmented 2014 by Bruce Wilcox
* Refactored 2014 by Dave Morton
*
* Function -- a working skeleton of a client to the ChatScript Server
* NOTES: Be sure to put in your correct host, port, username, and bot name below!
*
* LEGAL STUFF:
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, or sell
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 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.
*/
// ============= user values ====
$host = "localhost"; // <<<<<<<<<<<<<<<<< YOUR CHATSCRIPT SERVER IP ADDRESS OR HOST-NAME GOES HERE
$port = 1024; // <<<<<<< your port number if different from 1024
$bot = ""; // <<<<<<< desired botname, or "" for default bot
//=========================
// Please do not change anything below this line.
$null = "\x00";
$postVars = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
extract($postVars);
if (isset($send))
{
// open client connection to TCP server
$userip = $_SERVER['REMOTE_ADDR']; // get actual ip address of user as his id
// To check for proxies you can replace the line above with the code below, but it is easily faked so it's insecure:
// $userip = isset($_SERVER['X_FORWARDED_FOR']) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
$msg = $userip.$null.$bot.$null.$message.$null;
// fifth parameter in fsockopen is timeout in seconds
if(!$fp=fsockopen($host,$port,$errstr,$errno,300))
{
trigger_error('Error opening socket',E_USER_ERROR);
}
// write message to socket server
$ret = '';
fputs($fp,$msg);
while (!feof($fp))
{
$ret .= fgets($fp, 512);
}
// close socket connection
fclose($fp);
exit($ret);
}