-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathguifi_unsolclic.inc.php
612 lines (502 loc) · 20.8 KB
/
guifi_unsolclic.inc.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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
<?php
/**
* @file guifi_unsolclic.inc.php
*/
function array_flatten(array $array, array $return = array(), $prefix=null, $parentName=null, $nivell=0) {
$counter = 1;
foreach ($array as $k => $item) {
if (is_array($item)){
if ((strcmp($parentName, 'interfaces')==0)||(strcmp($parentName, 'links')==0)||(strcmp($parentName, 'radios')==0)) {
$name = $counter;
} else
$name = $k;
if ($prefix) $name = $prefix.'_'.$name;
$return = array_flatten($item, $return, $name, $k, $nivell++);
}elseif ($item) {
if ((strcmp($parentName, 'interfaces')==0)||(strcmp($parentName, 'links')==0)||(strcmp($parentName, 'radios')==0)) {
$name = $counter;
} else
$name = $k;
if ($prefix)$name = $prefix.'_'.$name;
$return[$name] = $item;
}
$counter++;
}
return $return;
}
function clientModeError($device){
$output = null;
if ($device->radios[0]['mode'] == 'client') {
$links = 0;
foreach ($device->radios[0]['interfaces'] as $interface_id => $interface)
foreach ($interface['ipv4'] as $ipv4_id => $ipv4)
if (isset($ipv4['links'])) foreach ($ipv4['links'] as $key => $link) {
if ($link['link_type'] == 'ap/client') {
$links++;
break;
}
}
if ($links == 0) {
$output .= t("# Generat per a:\n");
$output .= t("# {{ firmware_name }}\n");
$output .= t("# ERROR: Radio is in client mode but has no AP selected, please add a link to the AP at: ")."<a href=". base_path() ."guifi/device/$device->id/edit>http://guifi.net/guifi/device/$device->id/edit\n";
}
}
return $output;
}
// Generador dels unsolclic
function guifi_unsolclic($dev, $format = 'html') {
global $rc_startup;
global $ospf_zone;
global $otype;
$paramPrefixes = array("zone", "node", "user", "device", "firmware", "radio", "interface", "ipv4", "link", "linkedto_");
$otype = $format;
$dev = (object)$dev;
$flattenDev = array_flatten((array)$dev,array());
if (isValidConfiguracioUSC($dev->usc_id)) {
// carreguem el Twig , versió utilitzada 1.91
include_once('contrib/Twig/Autoloader.php');
// FINAL. Treure el fitxer unsolclic resultant com a mime text/plain
//drupal_set_header('Content-Type: text/plain; charset=utf-8');
// PFC passos
// 1. Recuperar informacio del trasto
// 1.a Recuperar el id de model del trasto (del camp extra de device)
$modelId = $dev->mid;
// recollir la configuracio unscolclic actual
$uscId = $dev->usc_id;
// 1.b recollir de la BD la informacio del model
$model = guifi_get_model($modelId);
// 1.c recollir les característiques del model
// aixo no es fa servir per res!!!!
$caractModel = guifi_get_caractmodel($modelId);
// 2. Recuperar informacio del firmware
// 2.a Recuperar el id del firmware del trasto(del camp extra de device)
$firmwareName = $dev->variable['firmware'];
$firmwareId = $dev->fid;
// 2.b recollir de la BD la informacio del firmware
$firmware = guifi_get_firmware($firmwareName);
// 2.c recollir els parametres del firmware
// tampoc es fa servir per RES!!!!!!
$paramsFirmware = guifi_get_paramsFirmware($firmwareId);
// 3. Recuperar la configuracióUnSolClic tq modelid i firmware:id
$configuracioUSC = guifi_get_configuracioUSC($modelId,$firmwareId,$uscId);
// 3.a recuperar la plantilla de la configuracio
$plantilla = $configuracioUSC['plantilla']; // a plantilla hi ha el contingut de la plantilla del unsolclic
// 4. recuperar TOTS els parametres variables associats al trasto
//$paramsDevice = guifi_get_paramsDevice($dev->id);
$paramsDevice = guifi_get_paramsClientDevice($dev->id);
// 5. Indexar els els parametres variables associats al trasto
$indexedParamsDevice = guifi_indexa_paramsDevice($paramsDevice, $paramPrefixes);
// 6. recuperar els parametres de la plantilla
$paramsconfiguracioUSC = guifi_get_paramsconfiguracioUSC($uscId);
// 6.B. recuperar els la informacio de la configuracio de fabricant-model-firmware
$paramsMMF = guifi_get_paramsMMF($dev->id);
// 4.b Comprovacions sobre el Device
$clientModeNoAPError = clientModeError($dev);
if ($clientModeNoAPError) {
$plantilla = $clientModeNoAPError;
}
$totalParameters = array_merge($indexedParamsDevice, $paramsMMF, $flattenDev);
// altres parametres fixes; TODO posar-lo com a parametre fixe de la plantilla
$totalParameters['ospf_name'] ='backbone';
// proves de twig
$zone = guifi_zone_load($totalParameters['zone_id']);
list($primary_dns,$secondary_dns, $ternary_dns) = explode(' ',guifi_get_dns($zone,3));
$totalParameters['zone_primary_dns'] = $primary_dns;
$totalParameters['zone_secondary_dns'] = $secondary_dns;
$totalParameters['zone_ternary_dns'] = $ternary_dns;
list($primary_ntp,$secondary_ntp) = explode(' ',guifi_get_ntp($zone));
$totalParameters['zone_primary_ntp'] = $primary_ntp;
$totalParameters['zone_secondary_ntp'] = $secondary_ntp;
if ($paramsconfiguracioUSC) {
// 7. substituir els parametres a la plantilla
foreach ($paramsconfiguracioUSC as $tupla) {
$param = $tupla['nom'];
$valor = $tupla['valor'];
$dinamic = $tupla['dinamic'];
$origen = $tupla['origen'];
if($dinamic==true) {
// DINAMIC s'ha de fer una segona passatda per buscar el origen de veritat
$valor = $totalParameters[$origen];
}
$totalParameters[$param] = $valor;
//echo "\n<br>param '$param' $dinamic = '$valor $origen' ";
}
Twig_Autoloader::register();
$loader = new Twig_Loader_String();
//$loader = new Twig_Loader_Filesystem('/home/albert/workspace/guifinet/drupal-6.22/sites/all/modules/guifi/firmware');
$twig = new Twig_Environment($loader);
$totalParameters['dev'] = $dev;
$twig->addFunction('ip2long', new Twig_Function_Function('ip2long'));
$twig->addFunction('long2ip', new Twig_Function_Function('long2ip'));
$twig->addFunction('t', new Twig_Function_Function('t'));
$twig->addFunction('guifi_to_7bits', new Twig_Function_Function('guifi_to_7bits'));
$twig->addFunction('guifi_get_alchemy_ifs', new Twig_Function_Function('guifi_get_alchemy_ifs'));
$twig->addFunction('guifi_main_ip', new Twig_Function_Function('guifi_main_ip'));
$twig->addFunction('explode', new Twig_Function_Function('explode'));
$escaper = new Twig_Extension_Escaper(true);
$twig->addExtension($escaper);
//$plantilla = $twig->render($configuracioUSC['template_file'], $twigVars);
$plantilla = $twig->render($plantilla, $totalParameters);
//
}
if ($totalParameters['manufacturer_name']!='Ubiquiti')
$plantilla = str_replace("\n", "\n<br />", $plantilla);
echo $plantilla;
die;
}
if ($dev->variable['firmware'] == 'n/a') {
_outln_comment(t("ERROR: I do need a firmware selected at the radio web interface: ").'<a href="'.base_path().'/guifi/device/'.$dev->id.'/edit">http://guifi.net/guifi/device/'.$dev->id.'/edit');
return;
} else {
_outln_comment(t("Generated for:"));
_outln_comment($dev->variable['firmware']);
}
foreach (glob(drupal_get_path('module', 'guifi') .'/firmware/*.inc.php', GLOB_BRACE) as $firm_inc_php){
include_once("$firm_inc_php");
// echo "<br>$firm_inc_php";
}
if ($dev->radios[0]['mode'] == 'client') {
$links = 0;
foreach ($dev->radios[0]['interfaces'] as $interface_id => $interface)
foreach ($interface['ipv4'] as $ipv4_id => $ipv4)
if (isset($ipv4['links'])) foreach ($ipv4['links'] as $key => $link) {
if ($link['link_type'] == 'ap/client') {
$links++;
break;
}
}
if ($links == 0) {
_outln_comment(t("ERROR: Radio is in client mode but has no AP selected, please add a link to the AP at: ").'<a href="'.base_path().'guifi/device/'.$dev->id.'/edit">http://guifi.net/guifi/device/'.$dev->id.'/edit');
return;
}
}
switch ($dev->variable['firmware']) {
case 'RouterOSv2.9':
case 'RouterOSv3.x':
case 'RouterOSv4.0+':
case 'RouterOSv4.7+':
case 'RouterOSv5.x':
case 'RouterOSv6.x':
unsolclic_routeros($dev);
exit;
break;
case 'DD-guifi':
case 'DD-WRTv23':
case 'Alchemy':
case 'Talisman':
unsolclic_wrt($dev);
exit;
break;
case 'AirOsv221':
case 'AirOsv30':
case 'AirOsv3.6+':
unsolclic_airos($dev);
exit;
break;
// case 'AirOsv52':
// unsolclic_airos52($dev);
// exit;
// break;
case 'GuifiStationOS1.0':
unsolclic_guifistationos($dev);
exit;
break;
// case 'qMpv1': // Use a generic one is better
case preg_match('/^qMp/',$dev->variable['firmware']) == 1:
unsolclic_qmp($dev);
exit;
break;
}
$unsolclic='unsolclic_'.$dev->variable['firmware'];
if(function_exists(${unsolclic})){
${unsolclic}($dev);
exit;
}
else
unsolclic_todo($dev);
}
function _out_file($txt,$file) {
global $otype;
if ($otype == 'html')
print '<pre>echo "'.$txt.'" > '.$file.'</pre>';
else
print 'echo "'.$txt.'" > '.$file;
}
function _outln($string = '') {
global $otype;
print $string;
if ($otype == 'html') print "\n<br />"; else print "\n";
}
function _outln_comment($string = '') {
global $otype;
print "# ".$string;
if ($otype == 'html') print "\n<br />"; else print "\n";
}
function _outln_comment_get($string = '') {
global $otype;
$output = "# $string \n";
if ($otype == 'html') $output .= "<br />";
return $output;
}
function _outln_nvram($parameter, $value) {
global $otype;
print "nvram set ".$parameter.'="';
if (strlen($value) <= 80) {
print $value;
} else {
$pos = 0;
if ($otype == 'html') print "\n<br />"; else print "\n";
do {
print substr($value, $pos * 80, 80).'\\';
$pos ++;
if ($otype == 'html') print "\n<br />"; else print "\n";
} while (strlen(substr($value,($pos-1) * 80)) > 80);
}
print('"');
if ($otype == 'html') print "\n<br />"; else print "\n";
}
function _out_nvram($parameter,$value = NULL) {
global $otype;
print "nvram set ".$parameter.'="';
if (!empty($value))
print $value;
if ($otype == 'html') print "\n<br />"; else print "\n";
}
function _out($value = '', $end = '') {
global $otype;
print " ".$value.$end;
if ($otype == 'html') print "\n<br />"; else print "\n";
}
function guifi_unsolclic_if($id, $itype) {
return db_fetch_object(db_query("SELECT i.id, a.ipv4, a.netmask FROM {guifi_interfaces} i LEFT JOIN {guifi_ipv4} a ON i.id=a.interface_id AND a.id=0 WHERE device_id = %d AND interface_type = '%s' LIMIT 1",$id,$itype));
}
function guifi_get_dns($zone,$max = 3) {
$dns = array();
if (!empty($zone->dns_servers))
$dns = explode(",",$zone->dns_servers);
while (count($dns) < $max) {
$zone = db_fetch_object(db_query("SELECT dns_servers, master FROM {guifi_zone} WHERE id=%d",$zone->master));
if (!empty($zone->dns_servers))
$dns = array_merge($dns,explode(",",$zone->dns_servers));
if ($zone->master == 0) {
break;
}
}
while (count($dns) > $max)
array_pop($dns);
return implode(" ",$dns);
}
function guifi_get_ospf_zone($zone) {
$ospf = array();
if (!empty($zone->ospf_zone))
return $zone->ospf_zone;
do {
$zone = db_fetch_object(db_query("SELECT dns_servers, master FROM {guifi_zone} WHERE id=%d",$zone->master));
if (!empty($zone->ospf_zone))
return $zone->ospf_zone;
} while ($zone->master > 0);
return '0';
}
function guifi_get_ntp($zone,$max = 3) {
$ntp = array();
if (!empty($zone->ntp_servers))
$ntp = explode(",",$zone->ntp_servers);
while (count($ntp) < $max) {
$zone = db_fetch_object(db_query("SELECT ntp_servers, master FROM {guifi_zone} WHERE id=%d",$zone->master));
if (!empty($zone->ntp_servers))
$ntp = array_merge($ntp,explode(",",$zone->ntp_servers));
if ($zone->master == 0) {
break;
}
}
while (count($ntp) > $max)
array_pop($ntp);
return implode(" ",$ntp);
}
function guifi_get_model($mid) {
$modelInfo = db_fetch_array(db_query("select * from {guifi_model_specs} where mid=%d limit 1",$mid));
if (!empty($modelInfo)){
//var_dump($modelInfo);
}
return $modelInfo;
}
function guifi_get_caractmodel($mid) {
$caractModelInfo = db_fetch_array(db_query("select * from {guifi_caracteristiquesModel} where mid=%d limit 1",$mid));
if (!empty($caractModelInfo)){
//var_dump(caractModelInfo);
}
return $caractModelInfo;
}
function guifi_get_paramsFirmware($fid) {
$paramsFirmwareInfo = db_fetch_array(db_query("select * from {guifi_parametresFirmware} where fid='%d'",$fid));
if (!empty($paramsFirmwareInfo)){
//var_dump($paramsFirmwareInfo);
}
return $paramsFirmwareInfo;
}
function guifi_get_configuracioUSC($mid, $fid, $uscid) {
//var_dump("Call guifi_get_configuracioUSC($mid, $fid, $uscid)");
$configuracioUSCInfo = db_fetch_array(db_query("select id, mid, fid, enabled, tipologia, plantilla, template_file from {guifi_configuracioUnSolclic} where mid=%d and fid=%d and id = %d limit 1",$mid, $fid, $uscid));
if (!empty($configuracioUSCInfo)){
} else {
unsolclic_todo($dev);die;
var_dump("NO m'arriba cap plantilla per a Model:$mid Firmware:$fid USCid:$uscid !!!!");
}
return $configuracioUSCInfo;
}
function guifi_get_paramsconfiguracioUSC($uscid) {
$qry = db_query("select p.nom, c.valor, c.dinamic, p.origen
from {guifi_parametresConfiguracioUnsolclic} c,
{guifi_parametres} p
where c.pid = p.id and c.uscid= %d",$uscid);
while ($param = db_fetch_array($qry)) {
$params[] = $param;
}
//w($params);
return $params;
}
function guifi_get_paramsMMF($devId) {
$qry = db_query(" select
d.usc_id,
usc.tipologia, usc.enabled ,
u.name usc_creator_nick,
m.model model_name,
mf.name as manufacturer_name,
f.nom as firmware_name,
f.descripcio as firmware_description
from
guifi_devices d
JOIN guifi_configuracioUnSolclic usc on usc.id = d.usc_id
JOIN users u ON u.uid = usc.user_created
JOIN guifi_model_specs m on m.mid = usc.mid
JOIN guifi_manufacturer mf on mf.fid = m.fid
JOIN guifi_firmware f on f.id = usc.fid
where d.id = %d",$devId);
$param = db_fetch_array($qry);
return $param;
}
// DEPRECATED!!!
function guifi_get_paramsDevice($device_id) {
/* $qry = db_query("select
z.id zone_id, z.title zone_name, z.dns_servers zone_dns_servers, z.ntp_servers zone_ntp_servers, z.graph_server zone_graph_server, z.ospf_zone zone_ospf_zone, z.zone_mode zone_zone_mode, z.proxy_id zone_proxy_id, z.voip_id zone_voip_id, */
$qry = db_query("select
z.id zone_id, z.title zone_name, z.dns_servers zone_dns_servers, z.ntp_servers zone_ntp_servers, z.graph_server zone_graph_server, z.ospf_zone zone_ospf_zone, z.proxy_id zone_proxy_id, z.voip_id zone_voip_id,
n.nid node_id, n.title node_name, loc.lat node_lat, loc.lon node_lon, loc.graph_server node_node_graph_server,
u.uid user_id, u.name user_name, u.mail user_mail,
d.nick as device_name, d.type device_type,
r.radiodev_counter radio_order, r.ssid radio_ssid, r.mode radio_mode, r.protocol radio_protocol, r.channel radio_channel, r.antenna_gain radio_antenna_gain, r.antenna_angle radio_antenna_angle, r.antenna_azimuth radio_antenna_azimuth, r.clients_accepted radio_clients_accepted, r.antenna_mode radio_antenna_mode, r.ly_mb_in radio_ly_mb_in ,r.ly_mb_out radio_ly_mb_out,
i.id interface_id, i.interface_type, i.mac interface_mac,
ip.ipv4 ipv4_ip, ip.netmask ipv4_netmask, ip.ipv4_type,
l.link_type, l.routing link_routing,l.flag link_working
from
node n
JOIN guifi_devices d ON d.nid = n.nid
JOIN guifi_location loc ON loc.id = n.nid
JOIN guifi_zone z ON z.id = loc.zone_id
JOIN users u ON u.uid = n.uid
JOIN guifi_radios r ON r.id = d.id
JOIN guifi_interfaces i ON i.device_id = d.id
JOIN guifi_ipv4 ip ON ip.interface_id = i.id
JOIN guifi_links l ON l.interface_id = i.id
where
d.id = %d
order by radio_order asc, interface_type asc",$device_id);
while ($param = db_fetch_array($qry)) {
$params[] = $param;
}
//var_dump($params);
return $params;
}
function guifi_get_paramsClientDevice($device_id) {
/* $qry = db_query("
SELECT
z.id zone_id, z.title zone_name, z.dns_servers zone_dns_servers, z.ntp_servers zone_ntp_servers, z.graph_server zone_graph_server, z.ospf_zone zone_ospf_zone, z.zone_mode zone_zone_mode, z.proxy_id zone_proxy_id, z.voip_id zone_voip_id,
*/
$qry = db_query("
SELECT
z.id zone_id, z.title zone_name, z.dns_servers zone_dns_servers, z.ntp_servers zone_ntp_servers, z.graph_server zone_graph_server, z.ospf_zone zone_ospf_zone, z.proxy_id zone_proxy_id, z.voip_id zone_voip_id,
n.nid node_id, n.title node_name, loc.lat node_lat, loc.lon node_lon, loc.graph_server node_node_graph_server,
u.uid user_id, u.name user_name, u.mail user_mail,
d.nick as device_name, d.type device_type, d.id as device_id,
r.radiodev_counter radio_order, r.ssid radio_ssid, r.mode radio_mode, r.protocol radio_protocol, r.channel radio_channel, r.antenna_gain radio_antenna_gain, r.antenna_angle radio_antenna_angle, r.antenna_azimuth radio_antenna_azimuth, r.clients_accepted radio_clients_accepted, r.antenna_mode radio_antenna_mode, r.ly_mb_in radio_ly_mb_in ,r.ly_mb_out radio_ly_mb_out,
i.id interface_id, i.interface_type, i.mac interface_mac, i.radiodev_counter interface_radiodev_counter,
ip.ipv4 ipv4_ip, ip.netmask ipv4_netmask, ip.ipv4_type ,
l.link_type, l.routing link_routing,l.flag link_working,
r2.ssid linkedto_ssid, r2.protocol linkedto_protocol, r2.channel linkedto_channel, r2.clients_accepted linkedto_clients_accepted,
ip2.ipv4 as linkedto_gateway, ip2.netmask linkedto_netmask
FROM
node n
JOIN guifi_devices d ON d.nid = n.nid
JOIN guifi_location loc ON loc.id = n.nid
JOIN guifi_zone z ON z.id = loc.zone_id
JOIN users u ON u.uid = n.uid
JOIN guifi_radios r ON r.id = d.id
JOIN guifi_interfaces i ON i.device_id = d.id
JOIN guifi_ipv4 ip ON ip.interface_id = i.id
JOIN guifi_links l ON l.interface_id = i.id
JOIN guifi_links l2 ON l.id = l2.id and l2.device_id != d.id
JOIN guifi_interfaces i2 on i2.id = l2.interface_id
LEFT JOIN guifi_radios r2 on r2.id = i2.device_id and r2.radiodev_counter = i2.radiodev_counter
JOIN guifi_ipv4 ip2 ON ip2.interface_id = i2.id
WHERE
d.id = %d
order by radio_order asc, interface_type asc",$device_id);
while ($param = db_fetch_array($qry)) {
$params[] = $param;
}
//var_dump($params);die;
return $params;
}
function guifi_indexa_paramsDevice($arrayParametres, $paramPrefixes) {
$index = 1;
foreach ($arrayParametres as $registre) {
//var_dump($registre);
//echo "<hr>";
foreach ($registre as $clau=>$valor) {
// comprovar existencia del prefix a la clau
if (guifi_usc_comprova_clau_prefix($clau, $paramPrefixes)){
// comprovar que no sigui el mateix calor que el que hem guardat pel registre anterior
$previ = $index-1;
$inserir = true;
if (!array_key_exists($clau.$index, $resultat)){
// comprovem valor anterior
/*
if (isset($resultat[$clau.$previ])) {
echo "<br>Existeix l'anterior resultat[$clau$previ]";
if ($resultat[$clau.$previ]==$valor) {
echo " i son iguals! no inserim ";
$inserir = false;
}
else {
echo " i son DIFERENTS!";
$inserir = true;
}
}*/
}
//if ($inserir) {
//echo "<br>afegim resultat[$clau$index]";
// indexant
//$resultat[$clau.".".$index] = $valor;
// sense indexar
$resultat[$clau] = $valor;
//}
}
}
$index++;
}
return $resultat;
}
function guifi_usc_comprova_clau_prefix($clau, $paramPrefixes) {
foreach ($paramPrefixes as $prefix) {
//echo "<br>buscant a ". $clau . " el ".$prefix;
if (stripos($clau, $prefix)!==false) return true;
}
return false;
}
function isValidConfiguracioUSC($uscid){
$result = db_fetch_object(db_query("SELECT id, enabled FROM {guifi_configuracioUnSolclic} WHERE id = %d AND enabled = 1 LIMIT 1",$uscid));
if (!empty($result->enabled)) return true;
return false;
}
?>