-
Notifications
You must be signed in to change notification settings - Fork 11
/
Driver.class.php
41 lines (34 loc) · 1.06 KB
/
Driver.class.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
<?php
// vim: set ai ts=4 sw=4 ft=php:
namespace FreePBX\modules\Firewall;
class Driver {
public function getDriver() {
static $driverObject = false;
if (!$driverObject) {
// firewalld is really slow. REALLY slow. Disabled.
$driver = "Iptables";
$fn = __DIR__."/drivers/$driver.class.php";
if (!file_exists($fn)) {
throw new \Exception("Unknown driver $driver");
}
// Note the double slash here so we don't escape the single quote.
// Turn on syntax highlighting if it's not obvious.
$class = '\FreePBX\modules\Firewall\Drivers\\'.$driver;
// Do we need to load it?
if (!class_exists($class)) {
// Woah there, cowboy. This file COULD be run as root. If it is, then the Validator class should exist.
if (class_exists('\FreePBX\modules\Firewall\Validator')) {
$v = new Validator;
$v->secureInclude("drivers/$driver.class.php");
} else {
include $fn;
}
} else {
// Debugging
throw new \Exception("How did $class already exist?");
}
$driverObject = new $class();
}
return $driverObject;
}
}