forked from sergejey/majordomo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.php
107 lines (81 loc) · 2.57 KB
/
command.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
<?php
/**
* RSS script
*
* @package MajorDoMo
* @author Serge Dzheigalo <[email protected]> http://smartliving.ru/
* @version 1.2
*/
include_once("./config.php");
include_once("./lib/loader.php");
startMeasure('TOTAL'); // start calculation of execution time
include_once(DIR_MODULES."application.class.php");
$session = new session("prj");
// connecting to database
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);
include_once("./load_settings.php");
Define('DEVIDER', 'и');
if ($qry!='')
{
if (!$session->data['logged_user'])
{
$user = SQLSelectOne("SELECT ID FROM users ORDER BY ID");
$user_id = $user['ID'];
}
else
{
$user_id=$session->data['logged_user'];
}
include_once(DIR_MODULES.'patterns/patterns.class.php');
$pt=new patterns();
$qrys = explode(' '.DEVIDER.' ', $qry);
$total = count($qrys);
for($i=0;$i<$total;$i++)
{
$room_id=0;
$rec = array();
$rec['ROOM_ID'] = (int)$room_id;
$rec['MEMBER_ID'] = $user_id;
$rec['MESSAGE'] = htmlspecialchars($qrys[$i]);
$rec['ADDED'] = date('Y-m-d H:i:s');
SQLInsert('shouts', $rec);
$pt->checkAllPatterns();
processCommand($qrys[$i]);
}
//Header("Location:command.php");exit;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script type="text/javascript">
function startSearch(event)
{
event.target.form.submit();
}
</script>
<form action="?" method="get" name="frmSearch">
<input type="text" name="qry" value="<?php echo $qry;?>" speech required x-webkit-speech onspeechchange="startSearch" /><input type="submit" name="Submit" value="Say" />
</form>
<?php if ($qry!='') {?>
<p>Command: <b><?php echo $qry ?></b></p>
<?php }?>
<?php
$qry="1";
if (!$limit) $limit = 20;
$res = SQLSelect("SELECT shouts.*, UNIX_TIMESTAMP(shouts.ADDED) as TM, users.NAME FROM shouts LEFT JOIN users ON shouts.MEMBER_ID=users.ID WHERE $qry ORDER BY shouts.ADDED DESC, ID DESC LIMIT ".(int)$limit);
$total = count($res);
for($i=0;$i<$total;$i++)
{
if ($res[$i]['MEMBER_ID']==0)
{
$res[$i]['NAME']='Alice';
}
echo date('H:i', $res[$i]['TM']).' <b>'.$res[$i]['NAME'].'</b>: '.$res[$i]['MESSAGE']."<br>";
}
?>
</body>
</html>