-
Notifications
You must be signed in to change notification settings - Fork 3
/
rules.php
75 lines (71 loc) · 2.42 KB
/
rules.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
<?php
/*
* rules.php
*
* Copyright 2021 Jim Richardson <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* fetch rules
*/
//header('Access-Control-Allow-Origin: *');
require ('includes/master.inc.php');
define('cr','<br>');
define ('CR',PHP_EOL);
$version = "2.01";
$build = "2450-3347490875";
if ($argv[1] =='v' || $argv[1] == '-v' ) {
echo 'Rules v'.VERSION.' Copyright Noideer Software '.$settings['start_year'].' - '.date('Y').CR;
exit;
}
error_reporting (0);
include 'functions.php';
require __DIR__ . '/xpaw/SourceQuery/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
$x = strpos($_GET['host'],':');
$sport = substr($_GET['host'],$x+1);
$ip = substr($_GET['host'],0,$x);
define( 'SQ_SERVER_ADDR', $ip );
define( 'SQ_SERVER_PORT', $sport );
define( 'SQ_TIMEOUT', $settings['SQ_TIMEOUT'] );
define( 'SQ_ENGINE', SourceQuery::SOURCE );
$Query = new SourceQuery( );
try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
$rules = $Query->GetRules( );
}
catch( Exception $e )
{
$Exception = $e;
if (strpos($Exception,'Failed to read any data from socket')) {
$Exception = 'Failed to read any data from socket (module rules)';
}
$error = date("d/m/Y h:i:sa").' ('.$ip.':'.$sport.') '.$Exception;
//sprintf("[%14.14s]",$str2)
$mask = "%17.17s %-30.30s \n";
file_put_contents('logs/xpaw.log',$error.CR,FILE_APPEND);
}
$Query->Disconnect( );
if (isset($Exception)) {
exit;
}
echo '<table style="width:100%;table-layout: fixed;">';
foreach ($rules as $k=>$v) {
echo '<tr><td style="width:70%;word-wrap:break-word;text-align:left;">'.$k.'</td><td style="text-align:left;padding-left:3%;">'.$v.'</td></tr>';
}
echo '</table>';
?>