-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathposttext.php
More file actions
executable file
·94 lines (79 loc) · 3.06 KB
/
posttext.php
File metadata and controls
executable file
·94 lines (79 loc) · 3.06 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!--
Smart Chat
Authors:
Rishi Dua <https://github.com/rishirdua>
Harvineet Singh <https://github.com/harvineet>
File Desciption: processes user input during chat so they can say something in the chat room
This projected is licensed under the terms of the MIT license. See LICENCE.txt for details
-->
<?php
//error_reporting(0);
$category = "default";
include("config.php");
include("lists.php");
$user = $_GET['u'];
$text = $_GET['t'];
echo $text;
$type = 0; // default to user regular message => css class: usermsg
$post = 0; // only post if it's a valid user
$header = " ";
if( $user == $admin_id ) {
// system message => css class: systemmsg
$type = 1;
$post = 1;
}
else
{
$file = file_get_contents($users_file);
$lines = explode("\n",$file);
$num = count($lines);
if( !(strpos($text, '/me') === false) && ( strpos($text, '/me') == 0 || strpos($text, '/me') == 1) ) {
$type = 2; // user action message => css class: actionmsg
}
// use uid to grab username from users file
for( $i = 0; $i < $num; $i++ ) {
$data = explode(",",$lines[$i]);
$uid = $data[0];
if( $user == $uid && count($data) > 1 ) {
$post = 1;
if( $type == 0 ) {
$header = $data[1] . ": ";
}
else if ($type == 2) {
$header = $data[1] . " ";
$text = substr($text,4);
}
}
}
}
/*$text = preg_replace('/<.*?>/','',$text);*/
$text = htmlspecialchars($text);
// Patch for Turkish Language in MESSAGE.
// Codes from http://www.uspto.gov/teas/standardCharacterSet.html
$trans = array("%u015F"=>"ş","%u015E"=>"Ş","%u0131"=>"ı","%u0130"=>"İ","%u011F"=>"ğ","%u011E"=>"Ğ","ö"=>"ö","Ö"=>"O","ü"=>"ü","Ü"=>"Ü","ç"=>"ç","Ç"=>"Ç");
$text=strtr($text,$trans);
//Smileys
$text=str_replace(":)","<img src='images/smile.PNG' border=0 align='absmiddle'>",$text);
$text=str_replace(":(","<img src='images/sad.PNG' border=0 align='absmiddle'>",$text);
$text=str_replace(";)","<img src='images/wink.PNG' border=0 align='absmiddle'>",$text);
$text=str_replace(":p","<img src='images/tongue.PNG' border=0 align='absmiddle'>",$text);
$text=str_replace(":P","<img src='images/tongue.PNG' border=0 align='absmiddle'>",$text);
$text=str_replace(":D","<img src='images/laugh.PNG' border=0 align='absmiddle'>",$text);
$text=str_replace(":d","<img src='images/laugh.PNG' border=0 align='absmiddle'>",$text);
//$text=str_replace(":roll","<img src='images/rollface.gif' border=0 align='absmiddle'>",$text);
//$text=str_replace(":cheers","<img src='images/cheers.gif' border=0 align='absmiddle'>",$text);
$text=str_replace(":kiss","<img src='images/kiss.PNG' border=0 align='absmiddle'>",$text);
$fp = fopen($buffer_file,"a");
if( $header && $text !== false && $post == 1) {
fputs($fp, "$type\n");
if ($type == 0) {
fputs($fp, "<div class=\"cb\"><b>" . $header . "</b>". $text ."</div> \n");
$reco = rtrim(shell_exec("python recommend.py 1 \"" . $text . "\""))."\n";
file_put_contents($recommend_file, $reco, FILE_APPEND);
}
else {
fputs($fp, "<div class=\"cb-error\"><b>" . $header . "</b>" . $text . "</div> \n");
}
}
fclose($fp);
?>