1
|
<?
|
2
|
function __autoload($class_name)
|
3
|
{
|
4
|
include "/var/www/Classes/{$class_name}.inc.php";
|
5
|
}
|
6
|
error_reporting(E_ALL);
|
7
|
ini_set('display_errors',1);
|
8
|
define('TVHEADEND','http://192.168.6.61:9981/');
|
9
|
define('database','/var/www/dvbchannels.sqlite');
|
10
|
define('database_work','/var/www/dvbchannels_work.sqlite');
|
11
|
define('database_2','/var/www/dvbchannels_useme.sqlite');
|
12
|
|
13
|
|
14
|
copy(database,database_work);
|
15
|
|
16
|
$db = new PDO2(new databaseCredentials('sqlite:'.database_work,"",""));
|
17
|
|
18
|
// Stop nagging when Freesat and NIT have differnt names
|
19
|
|
20
|
// BSkyB = Freesat
|
21
|
$syn["BBC 1 Yrks&Lin"] = "BBC 1 EYrks&L";
|
22
|
$syn["BBC 1 Wal HD"] = "BBC 1 Wales HD";
|
23
|
$syn["BBC Asian"] = "BBC Asian Net";
|
24
|
$syn["BBC London"] = "BBC London94.9";
|
25
|
$syn["BBC PARL'MNT"] = "BBC Parliament";
|
26
|
$syn["BBC R Scot."] = "BBC R Scotland";
|
27
|
$syn["BBC R1"] = "BBC Radio 1";
|
28
|
$syn["BBC R2"] = "BBC Radio 2";
|
29
|
$syn["BBC R3"] = "BBC Radio 3";
|
30
|
$syn["BBC R4 Ex"] = "BBC Radio 4 Ex";
|
31
|
$syn["BBC R4 FM"] = "BBC Radio 4 FM";
|
32
|
$syn["BBC R4 LW"] = "BBC Radio 4 LW";
|
33
|
$syn["6390"] = "BBC RB 1";
|
34
|
$syn["8900"] = "BBC RB HD";
|
35
|
$syn["BBC R n Gael"] = "BBC RnGaidheal";
|
36
|
$syn["BBC WS"] = "BBC World Sv";
|
37
|
$syn["BET:BlackEntTv"] = "BET";
|
38
|
$syn["Bloomberg"] = "Bloomberg TV";
|
39
|
$syn["CCTV News"] = "CCTV-NEWS";
|
40
|
$syn["SKY Challenge TV FSAT"] = "Challenge";
|
41
|
$syn["Chartshw Dnce"] = "ChartshowDance";
|
42
|
$syn["DAYSTAR"] = "DAYSTAR TV";
|
43
|
$syn["Food Netwrk+1"] = "Food Network+1";
|
44
|
$syn["FRANCE Eng"] = "France 24";
|
45
|
$syn["Inspiration"] = "Inspiration TV";
|
46
|
$syn["Jewellery Ch."] = "JEWELLERY CH";
|
47
|
$syn["Jewelry Maker"] = "JewelleryMaker";
|
48
|
$syn["mov4men+1"] = "Movies4Men+1";
|
49
|
$syn["PICK TV FSAT"] = "PICK TV";
|
50
|
$syn["Rocks & Co 1"] = "Rocks and Co1";
|
51
|
$syn["S4C"] = "S4C Digidol";
|
52
|
$syn["Smash Hits!"] = "Smashhits";
|
53
|
$syn["Smooth"] = "Smooth RadioUK";
|
54
|
$syn["Sonlife"] = "Sonlife TV";
|
55
|
|
56
|
$syn["10522 (Freesat 2)"] = "ITV Player";
|
57
|
$syn["10525 (ITV)"] = "ITV Player";
|
58
|
$syn["BBC iPlayer"] = "10527 (Freesat 1)";
|
59
|
$syn["Freesat4"] = "10528 (Freesat 4)";
|
60
|
$syn["10528 (Freesat 4)"] = "10528 (Freesat 4)";
|
61
|
$syn["OLYMP RED"] = "OLYMP RED";
|
62
|
|
63
|
|
64
|
// And reverse
|
65
|
foreach($syn as $was =>$is)
|
66
|
{
|
67
|
$syn[$is] = $was;
|
68
|
}
|
69
|
|
70
|
|
71
|
|
72
|
$all_multiplexes = array();
|
73
|
$mux_channels = array();
|
74
|
$service_types = array();
|
75
|
$last_seen = date('Y-m-d H:i:s');
|
76
|
$idx = 0;
|
77
|
|
78
|
$known_types = array('SDTV','HDTV-AC','Radio','SDTV-AC');
|
79
|
|
80
|
$channels = json_get(TVHEADEND . "channels?op=list");
|
81
|
echo "Update Channels\t";
|
82
|
foreach($channels as $channel)
|
83
|
{
|
84
|
if (!isset($channel->ch_icon))
|
85
|
{
|
86
|
$channel->ch_icon = "";
|
87
|
}
|
88
|
$db->performQuery( "INSERT OR REPLACE INTO channels (chid,channelname,channelnumber, logo,last_seen) VALUES (:chid,:chname,:channelnumber,:logo,:last_seen)",
|
89
|
$params=array('chid'=>$channel->chid,'chname'=>$channel->name,'channelnumber'=>$channel->number,'logo'=>$channel->ch_icon,'last_seen'=>$last_seen)
|
90
|
);
|
91
|
}
|
92
|
$db->performQuery("UPDATE channels set status = 'D' WHERE last_seen <> :ls",array('ls'=>$last_seen));
|
93
|
echo "[done]\n";
|
94
|
$adapters = json_get(TVHEADEND . "tv/adapter");
|
95
|
print_r($adapters);
|
96
|
|
97
|
|
98
|
$messages = array();
|
99
|
foreach($adapters as $a)
|
100
|
{
|
101
|
$adapter_id = $a->identifier;
|
102
|
|
103
|
$db->performQuery("SELECT * FROM adapters where adapter_id = :id",array('id'=>$adapter_id));
|
104
|
$known = $db->topResult();
|
105
|
$params = array(
|
106
|
'adapter_id'=>$a->identifier,
|
107
|
'adapter_name'=>$a->name,
|
108
|
'type'=>$a->type,
|
109
|
'path'=>$a->path,
|
110
|
'devicename'=>$a->devicename,
|
111
|
'deliverySystem'=>$a->deliverySystem,
|
112
|
'last_seen'=>$last_seen
|
113
|
);
|
114
|
if ($known == "")
|
115
|
{
|
116
|
echo "$adapter_id is new\n";
|
117
|
$db->performQuery("INSERT INTO adapters (adapter_id, adapter_name, type, path, devicename, last_seen,deliverySystem)
|
118
|
VALUES (:adapter_id, :adapter_name, :type, :path, :devicename, :last_seen,:deliverySystem)",$params);
|
119
|
$messages['adapters']['new'][] = "<tr><td style='border:1px solid black;'>{$a->name}</td><td style='border:1px solid black;'>{$a->identifier}</td><td style='border:1px solid black;'>{$a->deliverySystem}</td><td style='border:1px solid black;'>{$a->devicename}</td><td style='border:1px solid black;'>{$a->path}</td></tr>";
|
120
|
}
|
121
|
else
|
122
|
{
|
123
|
echo "$adapter_id is known\n";
|
124
|
if (
|
125
|
$known->adapter_id == $params['adapter_id'] &&
|
126
|
$known->adapter_name == $params['adapter_name'] &&
|
127
|
$known->path == $params['path'] &&
|
128
|
$known->deliverySystem == $params['deliverySystem'] &&
|
129
|
$known->devicename == $params['devicename']
|
130
|
)
|
131
|
{
|
132
|
// No Change
|
133
|
$db->performQuery("UPDATE adapters
|
134
|
set last_seen = :last_seen
|
135
|
WHERE adapter_id = :adapter_id",array('last_seen'=>$params['last_seen'],'adapter_id'=>$params['adapter_id']));
|
136
|
}
|
137
|
else
|
138
|
{
|
139
|
$db->performQuery("UPDATE adapters
|
140
|
set adapter_name = :adapter_name,
|
141
|
type = :type,
|
142
|
path = :path,
|
143
|
devicename = :devicename,
|
144
|
last_seen = :last_seen,
|
145
|
deliverySystem = :deliverySystem
|
146
|
WHERE adapter_id = :adapter_id",$params);
|
147
|
|
148
|
$messages['adapters']['change'][] = "<tr>".
|
149
|
wasnow($known->adapter_name,$params['adapter_name']).
|
150
|
wasnow($known->adapter_id,$params['adapter_id']).
|
151
|
wasnow($known->deliverySystem,$params['deliverySystem']).
|
152
|
wasnow($known->devicename,$params['devicename']).
|
153
|
wasnow($known->path,$params['path'])."</tr>";
|
154
|
}
|
155
|
}
|
156
|
|
157
|
|
158
|
$configs = array("0"=>"Unknown");
|
159
|
// Satellite DiSEqC configs
|
160
|
if ($a->deliverySystem == 'DVB-S')
|
161
|
{
|
162
|
$diseqc = json_get(TVHEADEND . "tablemgr?table=dvbsatconf%2F{$adapter_id}&op=get");
|
163
|
foreach($diseqc as $input)
|
164
|
{
|
165
|
$configs[$input->id] = $input;
|
166
|
$switch[$input->port] = $input->name;
|
167
|
}
|
168
|
ksort($switch);
|
169
|
}
|
170
|
|
171
|
// Now get the adaptor details
|
172
|
$adapter_info = json_get(TVHEADEND . "dvb/adapter/{$adapter_id}?op=load",'dvbadapters');
|
173
|
$adapter_info=$adapter_info[0];
|
174
|
if ($adapter_info->enabled == 1 )
|
175
|
{
|
176
|
echo "Process Multiplexes\n";
|
177
|
$muxes = json_get(TVHEADEND . "dvb/muxes/{$adapter_id}?op=get");
|
178
|
foreach($muxes as $mux)
|
179
|
{
|
180
|
if ($a->deliverySystem == 'DVB-S')
|
181
|
{
|
182
|
$mux->deliverySystem = $a->deliverySystem;
|
183
|
$mux->devicenicename = $a->name;
|
184
|
$mux->devicename = $a->devicename;
|
185
|
$mux->onid = isset($mux->onid) ? $mux->onid : "";
|
186
|
$mux->muxid = isset($mux->muxid) ? $mux->muxid : "";
|
187
|
$mux->network = isset($mux->network) ? $mux->network : "";
|
188
|
$mux->adapter = $adapter_info;
|
189
|
$mux->satconfname = $configs[$mux->satconf]->name;
|
190
|
$all_multiplexes[$mux->id] = $mux;
|
191
|
$mux->pol = $mux->pol == 'Horizontal' ? 'H' : $mux->pol;
|
192
|
$mux->pol = $mux->pol == 'Vertical' ? 'V' : $mux->pol;
|
193
|
}
|
194
|
else
|
195
|
{
|
196
|
$mux->deliverySystem = $a->deliverySystem;
|
197
|
$mux->devicenicename = $a->name;
|
198
|
$mux->devicename = $a->devicename;
|
199
|
$mux->pol = "";
|
200
|
$mux->onid = isset($mux->onid) ? $mux->onid : "";
|
201
|
$mux->muxid = isset($mux->muxid) ? $mux->muxid : "";
|
202
|
$mux->network = isset($mux->network) ? $mux->network : "";
|
203
|
$mux->adapter = $adapter_info;
|
204
|
$mux->satconfname = "";
|
205
|
$mux->satconf = 0;
|
206
|
}
|
207
|
$mux->freq = str_replace(",","",$mux->freq);
|
208
|
$mux->freq = number_format($mux->freq / 1000,3);
|
209
|
|
210
|
|
211
|
$db->performQuery($sql="SELECT * FROM multiplexes where adapter_id = :id AND freq = :freq AND pol = :pol AND satconf = :satconf",
|
212
|
$p=array(
|
213
|
':id'=>$adapter_id,
|
214
|
':freq'=>$mux->freq,
|
215
|
':pol'=>$mux->pol,
|
216
|
':satconf'=>$mux->satconf
|
217
|
)
|
218
|
);
|
219
|
$known = $db->topResult();
|
220
|
$params= array(
|
221
|
':adapter_id'=>(string)$adapter_id,
|
222
|
':freq'=>(string)$mux->freq,
|
223
|
':pol'=>(string)$mux->pol,
|
224
|
':satconf'=>(int)$mux->satconf,
|
225
|
':muxid'=>(string)$mux->muxid,
|
226
|
':mod'=>(string)$mux->mod,
|
227
|
':onid'=>(string)$mux->onid,
|
228
|
':nnetwork'=>(string)$mux->network,
|
229
|
':last_seen'=>$last_seen
|
230
|
|
231
|
);
|
232
|
if ($known == "")
|
233
|
{
|
234
|
|
235
|
echo "$adapter_id {$mux->freq} {$mux->pol} {$mux->satconf} is new\n";
|
236
|
$db->performQuery("INSERT INTO multiplexes (adapter_id, freq, pol, satconf, muxid, mod,onid,network,last_seen)
|
237
|
VALUES (:adapter_id, :freq, :pol, :satconf, :muxid, :mod,:onid,:nnetwork,:last_seen)",$params);
|
238
|
$messages['multiplexes']['new'][] = "<tr><td style='border:1px solid black;'>{$a->name}</td>
|
239
|
<td style='border:1px solid black;'>{$mux->freq}{$mux->pol}</td>
|
240
|
<td style='border:1px solid black;'>{$mux->satconfname}</td><td style='border:1px solid black;'>{$mux->muxid}</td>
|
241
|
<td style='border:1px solid black;'>{$mux->mod}</td><td style='border:1px solid black;'>{$mux->onid}</td>
|
242
|
<td style='border:1px solid black;'>{$mux->network}</td>
|
243
|
</tr>";
|
244
|
}
|
245
|
else
|
246
|
{
|
247
|
echo "$adapter_id {$mux->freq} {$mux->pol} {$mux->satconf}\t";
|
248
|
if (
|
249
|
$known->freq == $params[':freq'] &&
|
250
|
$known->pol == $params[':pol'] &&
|
251
|
$known->satconf == $params[':satconf'] &&
|
252
|
$known->muxid == $params[':muxid'] &&
|
253
|
$known->mod == $params[':mod'] &&
|
254
|
$known->onid == $params[':onid'] &&
|
255
|
(($known->network == $params[':nnetwork']) || ($known->network =='Freesat' && $params[':nnetwork'] == 'ASTRA') || ($known->network =='ASTRA' && $params[':nnetwork'] == 'Freesat'))
|
256
|
)
|
257
|
{
|
258
|
echo "[no change]\n";
|
259
|
// No Change
|
260
|
$db->performQuery("UPDATE multiplexes
|
261
|
set last_seen = :last_seen
|
262
|
WHERE id = :idd",array(':last_seen'=>$params[':last_seen'],':idd'=>$known->id));
|
263
|
}
|
264
|
else
|
265
|
{
|
266
|
echo "[update]\n";
|
267
|
unset($params[':adapter_id']);
|
268
|
$params['idd']=$known->id;
|
269
|
$db->performQuery("UPDATE multiplexes
|
270
|
set
|
271
|
last_seen = :last_seen,
|
272
|
freq = :freq,
|
273
|
pol = :pol,
|
274
|
satconf = :satconf,
|
275
|
muxid = :muxid,
|
276
|
mod = :mod,
|
277
|
onid = :onid,
|
278
|
network = :nnetwork
|
279
|
WHERE id = :idd",$params);
|
280
|
|
281
|
$messages['multiplexes']['change'][] = "<tr>".
|
282
|
wasnow($a->name,$a->name).
|
283
|
|
284
|
wasnow($known->freq.$known->pol,$params[':freq'].$params[':pol']).
|
285
|
wasnow($mux->satconfname,$mux->satconfname).
|
286
|
wasnow($known->muxid,$params[':muxid']).
|
287
|
wasnow($known->mod,$params[':mod']).
|
288
|
wasnow($known->onid,$params[':onid']).
|
289
|
wasnow($known->network,$params[':nnetwork']).
|
290
|
|
291
|
"</tr>";
|
292
|
}
|
293
|
}
|
294
|
|
295
|
|
296
|
|
297
|
|
298
|
}
|
299
|
|
300
|
// Now get the services
|
301
|
$services = json_get(TVHEADEND . "dvb/services/{$adapter_id}?op=get");
|
302
|
if ($a->deliverySystem == 'DVB-T'||1==1)
|
303
|
{
|
304
|
foreach($services as $service)
|
305
|
{
|
306
|
$service = fix_service($service);;
|
307
|
$service->satconfname = $a->deliverySystem == 'DVB-S' ? $configs[$service->satconf]->name : dvbtmux($service->freq);
|
308
|
$db->performQuery($sql="SELECT * FROM services where adapter_id = :id AND freq = :freq AND sid = :sid AND satconf = :satconf",
|
309
|
$p=array(
|
310
|
':id'=>$adapter_id,
|
311
|
':freq'=>$service->freq,
|
312
|
':sid'=>$service->sid,
|
313
|
':satconf'=>(int)$service->satconf
|
314
|
)
|
315
|
);
|
316
|
$known = $db->topResult();
|
317
|
|
318
|
$params= array(
|
319
|
':adapter_id'=>(string)$adapter_id,
|
320
|
':freq'=>(string)$service->freq,
|
321
|
':sid'=>(string)$service->sid,
|
322
|
':satconf'=>(int)$service->satconf,
|
323
|
':pmt'=>(string)$service->pmt,
|
324
|
':pcr'=>(string)$service->pcr,
|
325
|
':type'=>(string)$service->type,
|
326
|
':nnetwork'=>(string)$service->network,
|
327
|
':svcname'=>(string)$service->svcname,
|
328
|
':provider'=>(string)$service->provider,
|
329
|
':encryption'=>(string)$service->encryption,
|
330
|
':enabled'=>(string)$service->enabled,
|
331
|
':channel'=>(string)$service->channel,
|
332
|
':channelname'=>(string)$service->channelname,
|
333
|
':last_seen'=>$last_seen
|
334
|
);
|
335
|
if ($known == "")
|
336
|
{
|
337
|
|
338
|
echo "$adapter_id {$service->freq} {$service->satconf} {$service->svcname} is new\n";
|
339
|
$db->performQuery("INSERT INTO services (adapter_id, freq, sid, satconf, pmt, pcr,type,network,svcname,provider,encryption,enabled,channel,last_seen,channelname)
|
340
|
VALUES (:adapter_id, :freq, :sid, :satconf, :pmt, :pcr, :type, :nnetwork, :svcname, :provider, :encryption, :enabled, :channel, :last_seen,:channelname)",$params);
|
341
|
$messages['services']['new']["{$service->svcname}__{$service->freq}__{$a->name}"] = "<tr><td style='border:1px solid black;'>{$a->name}</td>
|
342
|
<td style='border:1px solid black;'>{$service->svcname}</td>
|
343
|
<td style='border:1px solid black;'>{$service->channelname}</td>
|
344
|
<td style='border:1px solid black;'>{$service->freq}</td>
|
345
|
<td style='border:1px solid black;'>{$service->satconfname}</td>
|
346
|
<td style='border:1px solid black;'>{$service->pmt}</td>
|
347
|
<td style='border:1px solid black;'>{$service->pcr}</td>
|
348
|
<td style='border:1px solid black;'>{$service->type}</td>
|
349
|
<td style='border:1px solid black;'>{$service->network}</td>
|
350
|
<td style='border:1px solid black;'>{$service->provider}</td>
|
351
|
<td style='border:1px solid black;'>{$service->encryption}</td>
|
352
|
<td style='border:1px solid black;'>{$service->channel}</td>
|
353
|
</tr>";
|
354
|
}
|
355
|
else
|
356
|
{
|
357
|
if (
|
358
|
$known->freq == $params[':freq'] &&
|
359
|
$known->satconf == $params[':satconf'] &&
|
360
|
(
|
361
|
str_replace(" ","",strtoupper($known->svcname)) == str_replace(" ","",strtoupper($params[':svcname']))
|
362
|
||
|
363
|
(issyn($known->svcname,$params[':svcname']) == true)
|
364
|
) &&
|
365
|
$known->channelname == $params[':channelname'] &&
|
366
|
$known->type == $params[':type'] &&
|
367
|
(($known->network == $params[':nnetwork']) || ($known->network =='ASTRA' && $params[':nnetwork'] == 'Freesat')) || (($known->network =='Freesat' && $params[':nnetwork'] == 'ASTRA')) &&
|
368
|
(($known->provider == $params[':provider']) || ($known->provider =='BSkyB' && $params[':provider'] == 'Freesat')) || (($known->provider =='Freesat' && $params[':provider'] == 'BSkyB')) &&
|
369
|
$known->encryption == $params[':encryption']
|
370
|
)
|
371
|
{
|
372
|
//echo "[no change]\n";
|
373
|
}
|
374
|
else
|
375
|
{
|
376
|
echo "[update]\n";
|
377
|
echo $mux->satconfname;
|
378
|
$messages['services']['change']["{$service->svcname}__{$service->freq}__{$a->name}"] = "<tr>".
|
379
|
wasnow($a->name,$a->name).
|
380
|
wasnow($known->svcname,$params[':svcname']).
|
381
|
wasnow($known->channelname,$params[':channelname']).
|
382
|
wasnow($known->freq,$params[':freq']).
|
383
|
wasnow($service->satconfname,$service->satconfname).
|
384
|
wasnow($known->pmt,$params[':pmt']).
|
385
|
wasnow($known->pcr,$params[':pcr']).
|
386
|
wasnow($known->type,$params[':type']).
|
387
|
wasnow($known->network,$params[':nnetwork']).
|
388
|
wasnow($known->provider,$params[':provider']).
|
389
|
wasnow($known->encryption,$params[':encryption']).
|
390
|
wasnow($known->channel,$params[':channel']).
|
391
|
"</tr>";
|
392
|
}
|
393
|
|
394
|
|
395
|
unset($params[':adapter_id']);
|
396
|
$params[':idd']=$known->id;
|
397
|
$db->performQuery($sql="UPDATE services
|
398
|
set
|
399
|
last_seen = :last_seen,
|
400
|
freq = :freq,
|
401
|
sid = :sid,
|
402
|
satconf = :satconf,
|
403
|
pmt = :pmt,
|
404
|
pcr = :pcr,
|
405
|
type = :type,
|
406
|
network = :nnetwork,
|
407
|
svcname = :svcname,
|
408
|
provider = :provider,
|
409
|
encryption = :encryption,
|
410
|
enabled = :enabled,
|
411
|
channelname = :channelname,
|
412
|
channel = :channel
|
413
|
|
414
|
WHERE id = :idd",$params);
|
415
|
|
416
|
}
|
417
|
}
|
418
|
}
|
419
|
}
|
420
|
}
|
421
|
$send_mail = false;
|
422
|
$message = "";
|
423
|
if (@count($messages['adapters']) > 0)
|
424
|
{
|
425
|
$send_mail = true;
|
426
|
$header_row = "<tr><th style='border:1px solid black;'>Name</th><th style='border:1px solid black;'>ID</th><th style='border:1px solid black;'>Type</th><th style='border:1px solid black;'>Device Name</th><th style='border:1px solid black;'>Path</th></tr>";
|
427
|
if (@count($messages['adapters']['new']) > 0)
|
428
|
{
|
429
|
$message .= "<h1>New Adapters</h1>";
|
430
|
$message .= "<table style='border:1px solid black;border-collapse:collapse'>";
|
431
|
$message .= $header_row;
|
432
|
foreach($messages['adapters']['new'] as $line)
|
433
|
{
|
434
|
$message .= $line;
|
435
|
}
|
436
|
$message .= "</table>";
|
437
|
}
|
438
|
|
439
|
if (@count($messages['adapters']['change']) > 0)
|
440
|
{
|
441
|
$message .= "<h1>Changed Adapters</h1>";
|
442
|
$message .= "<table style='border:1px solid black;border-collapse:collapse'>";
|
443
|
$message .= $header_row;
|
444
|
foreach($messages['adapters']['change'] as $line)
|
445
|
{
|
446
|
$message .= $line;
|
447
|
}
|
448
|
$message .= "</table>";
|
449
|
}
|
450
|
|
451
|
|
452
|
print_r($messages);
|
453
|
|
454
|
}
|
455
|
|
456
|
if (@count($messages['multiplexes']) > 0)
|
457
|
{
|
458
|
$send_mail = true;
|
459
|
$header_row = "<tr>
|
460
|
<th style='border:1px solid black;'>Adapter</th><th style='border:1px solid black;'>Frequency</th>
|
461
|
<th style='border:1px solid black;'>Sat Conf</th><th style='border:1px solid black;'>Mux ID</th>
|
462
|
<th style='border:1px solid black;'>Modulation</th><th style='border:1px solid black;'>NID</th>
|
463
|
<th style='border:1px solid black;'>Network</th>
|
464
|
|
465
|
|
466
|
</tr>";
|
467
|
if (@count($messages['multiplexes']['new']) > 0)
|
468
|
{
|
469
|
$message .= "<h1>New Multiplexes</h1>";
|
470
|
$message .= "<table style='border:1px solid black;border-collapse:collapse'>";
|
471
|
$message .= $header_row;
|
472
|
foreach($messages['multiplexes']['new'] as $line)
|
473
|
{
|
474
|
$message .= $line;
|
475
|
}
|
476
|
$message .= "</table>";
|
477
|
}
|
478
|
|
479
|
if (@count($messages['multiplexes']['change']) > 0)
|
480
|
{
|
481
|
$message .= "<h1>Changed Multiplexes</h1>";
|
482
|
$message .= "<table style='border:1px solid black;border-collapse:collapse'>";
|
483
|
$message .= $header_row;
|
484
|
foreach($messages['multiplexes']['change'] as $line)
|
485
|
{
|
486
|
$message .= $line;
|
487
|
}
|
488
|
$message .= "</table>";
|
489
|
}
|
490
|
|
491
|
|
492
|
print_r($messages);
|
493
|
|
494
|
}
|
495
|
|
496
|
if (@count($messages['services']) > 0)
|
497
|
{
|
498
|
$send_mail = true;
|
499
|
$header_row = "<tr>
|
500
|
<th style='border:1px solid black;'>Adapter</th>
|
501
|
<th style='border:1px solid black;'>Service Name</th>
|
502
|
<th style='border:1px solid black;'>Channel Name</th>
|
503
|
<th style='border:1px solid black;'>Freq</th>
|
504
|
<th style='border:1px solid black;'>Sat Conf</th>
|
505
|
<th style='border:1px solid black;'>PMT</th>
|
506
|
<th style='border:1px solid black;'>PCR</th>
|
507
|
<th style='border:1px solid black;'>Type</th>
|
508
|
<th style='border:1px solid black;'>Network</th>
|
509
|
<th style='border:1px solid black;'>Provider</th>
|
510
|
<th style='border:1px solid black;'>Encryption</th>
|
511
|
<th style='border:1px solid black;'>LCN</th>
|
512
|
</tr>";
|
513
|
if (@count($messages['services']['new']) > 0)
|
514
|
{
|
515
|
ksort($messages['services']['new']);
|
516
|
$message .= "<h1>New Services</h1>";
|
517
|
$message .= "<table style='border:1px solid black;border-collapse:collapse'>";
|
518
|
$message .= $header_row;
|
519
|
foreach($messages['services']['new'] as $line)
|
520
|
{
|
521
|
$message .= $line;
|
522
|
}
|
523
|
$message .= "</table>";
|
524
|
}
|
525
|
|
526
|
if (@count($messages['services']['change']) > 0)
|
527
|
{
|
528
|
ksort($messages['services']['change']);
|
529
|
$message .= "<h1>Changed Services</h1>";
|
530
|
$message .= "<table style='border:1px solid black;border-collapse:collapse'>";
|
531
|
$message .= $header_row;
|
532
|
foreach($messages['services']['change'] as $line)
|
533
|
{
|
534
|
$message .= $line;
|
535
|
}
|
536
|
$message .= "</table>";
|
537
|
}
|
538
|
|
539
|
|
540
|
print_r($messages);
|
541
|
|
542
|
}
|
543
|
|
544
|
|
545
|
|
546
|
if ($send_mail == true)
|
547
|
{
|
548
|
echo "Sending Email";
|
549
|
//send_mail('@gmail.com','@gmail.com','DVB Checker ' . date('H:i:s'),$message);
|
550
|
}
|
551
|
|
552
|
copy(database_work,database);
|
553
|
copy(database_work,database_2);
|
554
|
die();
|
555
|
|
556
|
|
557
|
// ==================================================================================================================
|
558
|
|
559
|
function print_array($array)
|
560
|
{
|
561
|
foreach($array as $item)
|
562
|
{
|
563
|
echo $item . "\t";
|
564
|
|
565
|
}
|
566
|
echo "\n";
|
567
|
}
|
568
|
|
569
|
|
570
|
function fix_service($service)
|
571
|
{
|
572
|
global $all_multiplexes,$mux_channels,$service_types;
|
573
|
$service_params = array(
|
574
|
'channelname'=>'',
|
575
|
'id'=>'',
|
576
|
'enabled'=>'',
|
577
|
'channel'=>'',
|
578
|
'sid'=>'',
|
579
|
'pmt'=>'',
|
580
|
'pcr'=>'',
|
581
|
'type'=>'',
|
582
|
'svcname'=>'',
|
583
|
'provider'=>'',
|
584
|
'network'=>'',
|
585
|
'encryption'=>'',
|
586
|
'mux'=>'',
|
587
|
'satconf'=>'',
|
588
|
'dvb_eit_enable'=>'',
|
589
|
'prefcapid'=>''
|
590
|
);
|
591
|
|
592
|
$service = (array)$service;
|
593
|
foreach($service as $key=>$value)
|
594
|
{
|
595
|
if (isset($service_params[$key]))
|
596
|
{
|
597
|
$service_params[$key] = $value;
|
598
|
}
|
599
|
else
|
600
|
{
|
601
|
$service_params["__".$key] = $value;
|
602
|
}
|
603
|
}
|
604
|
$service_params['freq'] = str_replace(",","",$service_params['mux']);
|
605
|
$service_params['freq'] = number_format($service_params['freq'] / 1000,3);
|
606
|
return (object)$service_params;
|
607
|
}
|
608
|
function json_get($url,$index='entries')
|
609
|
{
|
610
|
$json = json_decode(file_get_contents($url));
|
611
|
if ($index === false)
|
612
|
{
|
613
|
return $json;
|
614
|
}
|
615
|
else
|
616
|
{
|
617
|
return $json->$index;
|
618
|
}
|
619
|
}
|
620
|
|
621
|
|
622
|
function send_mail($from,$to,$subject,$body)
|
623
|
{
|
624
|
return false;; // Disabled for code sharing.
|
625
|
require_once "Mail.php";
|
626
|
require_once "Mail/mime.php";
|
627
|
|
628
|
$from = "DVB Checker. <{$from}>";
|
629
|
$to = "Kev <{$to}>";
|
630
|
$host = "ssl://smtp.gmail.com";
|
631
|
$port = "465";
|
632
|
$username = "@gmail.com";
|
633
|
$password = "";
|
634
|
|
635
|
$headers = array(
|
636
|
'From' => $from,
|
637
|
'To' => $to,
|
638
|
'Subject' => $subject
|
639
|
);
|
640
|
|
641
|
$smtp = Mail::factory(
|
642
|
'smtp',
|
643
|
array (
|
644
|
'host' => $host,
|
645
|
'port' => $port,
|
646
|
'auth' => true,
|
647
|
'username' => $username,
|
648
|
'password' => $password
|
649
|
)
|
650
|
);
|
651
|
|
652
|
$mime = new Mail_Mime();
|
653
|
|
654
|
$mime->setTXTBody(strip_tags($body));
|
655
|
$mime->setHTMLBody($body);
|
656
|
|
657
|
$body = $mime->get();
|
658
|
$headers = $mime->headers($headers);
|
659
|
|
660
|
|
661
|
$mail = $smtp->send($to, $headers, $body);
|
662
|
|
663
|
if (PEAR::isError($mail))
|
664
|
{
|
665
|
echo("<p>" . $mail->getMessage() . "</p>");
|
666
|
}
|
667
|
else
|
668
|
{
|
669
|
echo("<p>Message successfully sent!</p>");
|
670
|
}
|
671
|
}
|
672
|
|
673
|
function wasnow($was,$now)
|
674
|
{
|
675
|
if ($was == $now)
|
676
|
{
|
677
|
$now = str_replace("_","_<wbr>",$now);
|
678
|
return "<td style='border:1px solid black;'><span>{$now}</span></td>";
|
679
|
}
|
680
|
else
|
681
|
{
|
682
|
$was = str_replace("_","_<wbr>",$was);
|
683
|
$now = str_replace("_","_<wbr>",$now);
|
684
|
return "<td style='border:1px solid black;'><strike style='color:red'>{$was}</strike><br><span style='color:green'>{$now}</span></td>";
|
685
|
}
|
686
|
}
|
687
|
|
688
|
function dvbtmux($freq)
|
689
|
{
|
690
|
$freq = str_replace(",","",$freq);
|
691
|
$muxnames = array(698.0=>'BBC',737.8=>'D3+4',770.0=>'BBC HD',538.0=>'SDN',754.0=>'ArqA',762.0=>'ArqB',514.0=>'Local',554.0=>'Arq HD1',602.0=>'Arq HD2');
|
692
|
$muxname = isset($muxnames[(int)$freq]) ? $muxnames[(int)$freq] : "";
|
693
|
return $muxname;
|
694
|
}
|
695
|
|
696
|
|
697
|
function issyn($was,$now)
|
698
|
{
|
699
|
global $syn;
|
700
|
if (isset($syn[$was]) == false)
|
701
|
{
|
702
|
return false;
|
703
|
}
|
704
|
else
|
705
|
{
|
706
|
if ($syn[$was] == $now)
|
707
|
{
|
708
|
return true;
|
709
|
}
|
710
|
else
|
711
|
{
|
712
|
return false;
|
713
|
}
|
714
|
}
|
715
|
}
|
716
|
?>
|