-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmc.php
269 lines (250 loc) · 8.75 KB
/
smc.php
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?php
$token=$_GET['token'];
if(!($token=="fG5pZKSf6BwcjM8cerw9ll7vMsDpxDasdqwd23r23sdasdasd")) {
echo "You are not authenticated.</p>";
die;
}
?>
<html>
<head>
<title>Snarl 2eb - Message Management Console</title>
<link rel="stylesheet" type="text/css" href="smc.css" />
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="./library/jquery-1.4.4.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="application/x-javascript">
<?php
$xml = simplexml_load_file("smcsettings.xml");
if ($xml->removehashtags['value'] != 'on') {$rht = 'true';} else {$rht='false';}
echo "var showhashinmsg=$rht;\n";
if ($xml->URLstoLinks['value'] == 'on') {$utl = 'true';} else {$utl='false';}
echo "var makeurlsclickable=$utl;\n";
echo "var numMsgs = " .$xml->msgperscreen['value'].";\n";
echo "var tagsize='" . $xml->TagsColText['value'] ."';\n";
echo "var hashtagsize='" .$xml->HashColText['value'] ."';\n";
echo "var msgsize='".$xml->MsgColText['value'] ."';\n";
echo "var badthresh = " . $xml->badthresh['value'] .";\n";
echo "var goodthresh = " . $xml->goodthresh['value'].";\n";
echo "var badcolor = '" . $xml->badcolor['value']."';\n";
echo "var medcolor = '" . $xml->medcolor['value']."';\n";
echo "var goodcolor = '" . $xml->goodcolor['value']."';\n";
echo "function Hilite(msg){\n";
$keywords = explode(" ", $xml->keywords['value']);
foreach($keywords as $keyword){
if (strlen($keyword) > 0){
echo " msg=msg.replace(/$keyword/gi,\"<strong style='background: aqua'>$keyword</strong>\");\n";
}
}
echo " return msg;\n";
echo "}\n";
?>
var msgdata;
var table;
var ogmsgbox;
function sendMsg(msg){
$("#dialog").dialog("close");
//alert (ogmsgbox.value);
$("#dialog").dialog("destroy");
}
function sendMsgDlg(){
ogmsgbox.value='';
$("#dialog").dialog({ title: 'Broadcast Message', width: 330 });
}
function showRow(m){
document.getElementById('showme').innerHTML=m;
}
function showData(){
//assumes empty table
var hashreg = new RegExp("/#[^ \n]+/", "i");
for (i=0; i<msgdata.length;i++){
//alert ("loading row: " + i + ": " + msgdata[i].msg_id);
var row = table.insertRow(i);
var id = msgdata[i].msg_id;
//onmouseover=showRowData()
var m = msgdata[i].msg_plain;
row.setAttribute('rowno', i);
row.onmouseover = function() {
var r= this.getAttribute('rowno');
showRow(msgdata[r].uid + "<BR/>" + msgdata[r].published + "<BR/>"+msgdata[r].msg_id); }
var cell = row.insertCell(-1);
var color = medcolor;
if (msgdata[i].score < badthresh) color=badcolor;
if (msgdata[i].score > goodthresh) color=goodcolor;
var element1 = document.createElement("input");
element1.type = "checkbox";
cell.setAttribute("bgColor",color);
cell.appendChild(element1);
//var div=document.createElement("div");
//div.style.border = "2px solid " + color;
//div.appendChild(element1);
//cell.appendChild(div);
if (tagsize != 'none'){
var cell = row.insertCell(-1);
cell.width="10%";
cell.innerHTML = "<p style='font-size:" + tagsize + "'>" + Hilite(msgdata[i].tags) +"</p>";
}
if (hashtagsize != 'none'){
var cell = row.insertCell(-1);
cell.width="10%";
var reg = /#[^ \n]+/g;
var ar = m.match(reg);
if (ar != null){
var str = ar.join(' ');
cell.innerHTML = "<p style='font-size:" + Hilite(hashtagsize) +"'>" + str +"</p>";
}
}
if (msgsize != 'none'){
var cell3 = row.insertCell(-1);
if (makeurlsclickable)
m=m.replace(/((www|http:\/\/)[^ \n]+)/, '<a href="$1" target="_blank">$1</a>');
if (!showhashinmsg){
while (m.indexOf('#')>0)
m=m.replace(/#[^ \n]+/, '');
}
cell3.innerHTML = "<p style='font-size:" + msgsize +"'>" + Hilite(m) +"</p>";
}
}
}
function amendReputation(repvalue){
for (i=table.rows.length -1; i>= 0; i--){
if (table.rows[i].cells[0].childNodes[0].checked){
$.get('./apiIncrementUserReputation.php?sname=' + msgdata[i].uid
+ '&delta=' + repvalue + '&type=p&msgid=' + msgdata[i].msg_id,
{async:false}, function(result){
if (result.substring(0,2) != 'OK'){
alert(result);
}
});
}
}
getData();
}
function clearTable(){
for (i=table.rows.length -1; i>= 0; i--){
table.deleteRow(i);
msgdata.splice(i, 1);
}
}
function flagNoise(){
var url = '';
for (i=table.rows.length -1; i>= 0; i--){
if (table.rows[i].cells[0].childNodes[0].checked){
url += msgdata[i].msg_id +",";
table.deleteRow(i);
msgdata.splice(i, 1);
}
}
if (url.length > 0){
url = url.substr(0,url.length -1);
$.get('./apiFlagNoise.php?msg=' + url,{async: false},function(result){
getData();
});
}
}
function setTroll(){
var url = '';
for (i=table.rows.length -1; i>= 0; i--){
if (table.rows[i].cells[0].childNodes[0].checked){
$.get('./apiSetUserTrollFlag.php?sname=' + msgdata[i].uid + '&to=Y', {async:false}, function(result){
if (result.substring(0,2) != 'OK'){
alert(result);
}
});
}
}
getData();
}
function getData(){
clearTable();
$.ajax({
url: './apiGetinq.php?r=' + numMsgs,
dataType: 'json',
success:
function(msg){
msgdata=eval(msg);
showData();
}
});
}
function checkAll(value){
for (i=0; i< table.rows.length; i++){
table.rows[i].cells[0].childNodes[0].checked=value;
}
}
function checkReverse(){
for (i=0; i< table.rows.length; i++){
var cb =table.rows[i].cells[0].childNodes[0];
cb.checked = !cb.checked;
}
}
function checkWord(){
var matchString= document.getElementById("checkword").value.toLowerCase();
for (i=0; i< table.rows.length; i++){
if (msgdata[i].msg_plain.toLowerCase().indexOf(matchString) != -1){
var cb =table.rows[i].cells[0].childNodes[0];
cb.checked=true;
}
}
}
function initialise(){
table = document.getElementById("msgtable");
ogmsgbox=document.getElementById('txtmsg');
getData();
}
</script>
</head>
<body onLoad='initialise();'>
<div style="float: left; width: 10%; top:60px; background:#fffff0; text-align:center;empty-cells: hide; font-size:small;position:fixed">
<div style="position:relative; width: 100%; height:200px; background:#f0fff0;">
Select:
<button style="width:120px;height:25px" onclick='checkAll(true);'>Check All</button>
<button style="width:120px;height:25px" onclick='checkAll(false);'>Uncheck All</button>
<button style="width:120px;height:25px" onclick='checkReverse();'>Reverse Selection</button>
<input type='text' id='checkword' style="width:90px"/>
<button style="width:25px;height:25px" onclick='checkWord();'>•</button>
<HR/>
Flag As:
<button style="width:120px;height:25px" onclick='flagNoise();'>Noise</button>
<button style="width:120px;height:25px" onclick='amendReputation(15);'>Good Message</button>
<button style="width:120px;height:25px" onclick='amendReputation(-50);'>Misinformation</button>
<button style="width:120px;height:25px" onclick='setTroll();'>Troll</button>
<HR/>
Outgoing Message
<button style="width:120px;height:25px" onclick='sendMsgDlg(true,false);'>Snarl Data</button>
<button style="width:120px;height:25px" onclick='sendMsgDlg(true, true);'>Data & SMS</button>
<button style="width:120px;height:25px" onclick='sendMsgDlg(false, true);'>SMS Only</button>
<HR/>
<span id='showme' style='font-size: x-small;'></span>
</div>
</div>
<div style="float: right; width: 90%; top:50px; text-align:center; background: #f0fff0;position:relative">
<Table id="msgtable"></table>
<?php
include 'params.php';
/* $color = "#F7F7F7";
if ($score < 33.33){
$color = "F1100";
}
if ($score > 66.66){
$color = "10F100";
}
echo "<tr><td bgcolor=$color><INPUT TYPE=CHECKBOX id='row$rowid'></td><td><small>".$row['tags']."</small></td><td><small>".$row['msg_html']."</small></td></tr>";
*/
?>
</div>
<div style="float: left; width: 100%; text-align: Left; color: white; background: green; font-size: 10pt;position:fixed;">
Snarl<BR/><small>Message Management Console</small>
<div id="buttondiv" style="position:relative; float:right; top: -14px; right: 100px; background-color:transparent; border: none;">
<button onclick="document.location.href='./rateuser.php';">Reputation Management</button>
<button onclick="document.location.href='./smcOptions.php';">Options</button>
<button onclick="document.location.href='./smcImages.php';">Images</button>
</div>
</div>
<div id="logodiv" style="position:fixed; display:inline; top: 0px; right: 0px; background-color:transparent ;background-image: url(./images/wp_small.png); height: 102px; width: 100px; border: none;"/>
<div id="dialog" title="Dialog Title" style="display:none;" >
<textarea id='txtmsg' rows="10" cols="30" style='align:center;'>
New Message here</textarea>
<button onclick='sendMsg();'>Send</button><button onclick='$("#dialog").dialog("destroy");'>Cancel</button>
</div>
</body>
</html>