-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrawl_data.php
executable file
·159 lines (145 loc) · 4.26 KB
/
crawl_data.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
<?php
$starttime=microtime(true);
?>
<!doctype html>
<html>
<head>
<title>TS-N.NET Channeldeleter - Crawl Date</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<?php
require_once('config.php');
require_once('lang.php');
require_once('TeamSpeak3/TeamSpeak3.php');
try
{
$ts3_ServerInstance = TeamSpeak3::factory("serverquery://".$cfg["user"].":".$cfg["pass"]."@".$cfg["host"].":".$cfg["query"]."/");
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$cfg["user"].":".$cfg["pass"]."@".$cfg["host"].":".$cfg["query"]."/?server_port=".$cfg["voice"]);
require_once('mysql_connect.php');
try
{
$ts3_VirtualServer->selfUpdate(array('client_nickname'=>$queryname));
}
catch(Exception $e)
{
try
{
$ts3_VirtualServer->selfUpdate(array('client_nickname'=>$queryname2));
}
catch(Exception $e)
{
echo'<span class="red"><b>'.$lang['error'].$e->getCode().':</b> '.$e->getMessage().'</span><br>';
}
}
//Get the time
$todaydate=time();
$icontime=$todaydate-$warntime;
//Get a list of all channels
$tschanarr=$ts3_VirtualServer->channelList();
//Guardar todos os Cid dentro de uma array
foreach($tschanarr as $channel)
{
$tscid[]=$channel['cid'];
}
//Apagar todos os Icons
if($deleteicons==1)
{
echo'<b>'.$lang['hldelicon'].'</b><br>';
$count=0;
foreach($tschanarr as $channel)
{
if($channel['channel_icon_id']==$iconId) {
$channel->permRemoveByName('i_icon_id');
}
}
if($count>0)
{
echo $count.$lang['icondel'].'<br><br>';
}
else
{
echo $lang['iconnodel'].'<br><br>';
}
}
echo'<b>'.$lang['hlcrawl'].'</b><br>';
echo'<table>';
foreach($tschanarr as $channel)
{
$channelid=$channel['cid'];
$channelname=$channel['channel_name'];
$channelname=htmlspecialchars($channelname, ENT_QUOTES);
$userinchannel=$channel['total_clients'];
$chauserinchannelnnelpath=$channel->getPathway();
$channelpath=htmlspecialchars($channelpath, ENT_QUOTES);
echo'<tr><td>'.$lang['cid'].$channelid.' : </td><td>'.$channelname.'</td>';
$cidexists=$mysqlcon->query("SELECT * FROM $table_channel WHERE cid='$channelid'");
$cidexists=$cidexists->num_rows;
if($cidexists>0)
{
if($userinchannel>0)
{
echo'<td><span class="green">'.sprintf($lang['cidup'],$userinchannel).'</span></td></tr>';
$mysqlcon->query("UPDATE $table_channel SET lastuse='$todaydate',path='$channelpath' WHERE cid='$channelid'");
if($seticon==1)
{
if($channel['channel_icon_id']==$iconId) {
$channel->permRemoveByName('i_icon_id');
}
}
}
else
{
$lastusetime=$mysqlcon->query("SELECT lastuse FROM $table_channel WHERE cid='$channelid'");
$lastusetime=$lastusetime->fetch_row();
$mysqlcon->query("UPDATE $table_channel SET path='$channelpath' WHERE cid='$channelid'");
echo'<td><span class="red">'.$lang['cidnoup'].'</span></td>';
if($seticon==1 && !in_array($channelid, $nodelete) && $lastusetime[0]<$icontime && !$channel->isSpacer())
{
$children=$channel->getChildren();
if($children=="")
{
echo'<td><span class="blue">'.$lang['seticon'].'</span></td>';
$channel->permAssignByName('i_icon_id', $iconId);
}
}
echo'</tr>';
}
}
else
{
echo'<td><span class="blue">'.$lang['record'].'</span></td></tr>';
$mysqlcon->query("INSERT INTO $table_channel (cid, lastuse, path) VALUES ('$channelid','$todaydate','$channelpath')");
}
}
echo'</table><br><b>'.$lang['hlcleandb'].'</b><br><table>';
$count=1;
$cidexists=$mysqlcon->query("SELECT * FROM $table_channel");
while($row=$cidexists->fetch_row())
{
if(!in_array($row[0], $tscid))
{
echo'<tr><td>'.$lang['cid'].$row[0].' : </td><td>'.$row[2].'</td><td><span class="green">'.$lang['cleandb'].'</span><br></td></tr>';
$count=$count+1;
if(!$mysqlcon->query("DELETE FROM $table_channel WHERE cid=$row[0]"))
{
printf("Errormessage: %s\n", $mysqlcon->error);
}
}
}
echo'</table>';
if($count==1)
{
echo'<span class="red">'.$lang['nodel2'].'</span><br>';
}
}
catch(Exception $e)
{
echo'<span class="red"><b>'.$lang['error'].$e->getCode().':</b> '.$e->getMessage().'</span><br>';
}
$buildtime=microtime(true)-$starttime;
echo'<br>'.sprintf($lang['sitegen'],$buildtime);
?>
</body>
</html>