28 |
29 | 30 |
31 | 32 |
33 | 34 |
35 | -------------------------------------------------------------------------------- /webui/code/index.php: -------------------------------------------------------------------------------- 1 | 5 |

Status

6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
ServiceStatus
DNS IP
Pi-Hole:8081/admin
VPN Connection
29 |
30 | 31 | -------------------------------------------------------------------------------- /webui/code/init.php: -------------------------------------------------------------------------------- 1 | lastErrorMsg(); 17 | exit; 18 | } 19 | foreach($sqls as $sql){ 20 | $ret = $db->exec($sql); 21 | if(!$ret) { 22 | echo $db->lastErrorMsg(); 23 | exit; 24 | } 25 | } 26 | $db->close(); 27 | exit; 28 | } 29 | function UpdateDNSMasqDomains($restartDNS = true){ 30 | $db = new SQLite3(DATABASE_FILE); 31 | if(!$db) { 32 | echo $db->lastErrorMsg(); 33 | exit; 34 | } 35 | $dnsmasqconf = ''; 36 | $ret = $db->query( 'SELECT * FROM domains' ); 37 | while ( $row = $ret->fetchArray() ) { 38 | $dnsmasqconf .= "address=/".$row['domain']."/".$row['ipaddress']."\n"; 39 | } 40 | $db->close(); 41 | file_put_contents('/etc/dnsmasq.d/smartgw.conf',$dnsmasqconf); 42 | if($restartDNS) {restartDNS();} 43 | } 44 | 45 | function restartDNS(){ 46 | /*exec('ps -ef|grep pihole-FTL|grep -v grep', $exeout, $return); 47 | if ($return == 0) { 48 | exec('/usr/bin/sudo /usr/sbin/service pihole-FTL restart', $exeout, $return); 49 | }else{ 50 | exec('ps -ef|grep dnsmasq| grep -v local-dnsmasq.conf | grep -v grep', $exeout, $return); 51 | if ($return == 0) { 52 | exec('/usr/bin/sudo /usr/sbin/service dnsmasq restart', $exeout, $return); 53 | } 54 | }*/ 55 | } 56 | 57 | 58 | class Paginator { 59 | 60 | private $_conn; 61 | private $_limit; 62 | private $_page; 63 | private $_query; 64 | private $_total; 65 | private $_databasefile; 66 | 67 | public function __construct($database_file, $count_query ) { 68 | $this->_databasefile = $database_file; 69 | 70 | $this->_conn = new SQLite3($this->_databasefile); 71 | if(!$this->_conn) { 72 | echo $this->_conn->lastErrorMsg(); 73 | exit; 74 | } 75 | $ret = $this->_conn->querySingle( $count_query ); 76 | $this->_total = $ret; 77 | $this->_conn->close(); 78 | } 79 | 80 | public function getData($query, $limit = 100, $page = 1 ) { 81 | 82 | 83 | $this->_query = $query; 84 | $this->_limit = $limit; 85 | $this->_page = $page; 86 | 87 | if ( $this->_limit == 'all' ) { 88 | $query = $this->_query; 89 | } else { 90 | $query = $this->_query . " LIMIT " . ( ( $this->_page - 1 ) * $this->_limit ) . ", $this->_limit"; 91 | } 92 | 93 | $this->_conn = new SQLite3($this->_databasefile); 94 | if(!$this->_conn) { 95 | echo $this->_conn->lastErrorMsg(); 96 | exit; 97 | } 98 | 99 | $ret = $this->_conn->query( $query ); 100 | $results = []; 101 | while ( $row = $ret->fetchArray() ) { 102 | $results[] = $row; 103 | } 104 | $this->_conn->close(); 105 | 106 | $result = new stdClass(); 107 | $result->page = $this->_page; 108 | $result->limit = $this->_limit; 109 | $result->total = $this->_total; 110 | $result->data = $results; 111 | 112 | return $result; 113 | } 114 | 115 | public function createLinks( $links, $list_class ) { 116 | if ( $this->_limit == 'all' ) { 117 | return ''; 118 | } 119 | 120 | $last = ceil( $this->_total / $this->_limit ); 121 | 122 | $start = ( ( $this->_page - $links ) > 0 ) ? $this->_page - $links : 1; 123 | $end = ( ( $this->_page + $links ) < $last ) ? $this->_page + $links : $last; 124 | 125 | $html = '
    '; 126 | 127 | $class = ( $this->_page == 1 ) ? "disabled" : ""; 128 | $html .= '
  • «
  • '; 129 | 130 | if ( $start > 1 ) { 131 | $html .= '
  • 1
  • '; 132 | $html .= '
  • ...
  • '; 133 | } 134 | 135 | for ( $i = $start ; $i <= $end; $i++ ) { 136 | $class = ( $this->_page == $i ) ? "active" : ""; 137 | $html .= '
  • ' . $i . '
  • '; 138 | } 139 | 140 | if ( $end < $last ) { 141 | $html .= '
  • ...
  • '; 142 | $html .= '
  • ' . $last . '
  • '; 143 | } 144 | 145 | $class = ( $this->_page == $last ) ? "disabled" : ""; 146 | $html .= '
  • »
  • '; 147 | 148 | $html .= '
'; 149 | 150 | return $html; 151 | } 152 | } -------------------------------------------------------------------------------- /webui/code/vpnconnection.php: -------------------------------------------------------------------------------- 1 |