1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
Exec+ v1.02-000 - Copyright 2001-2003, All rights reserved
|
5
|
Created by André Ribeiro and Hélder Pereira
|
6
|
|
7
|
Redistribution and use in source and binary forms, with or without
|
8
|
modification, are permitted provided that the following conditions are met:
|
9
|
|
10
|
1. Redistributions of source code must retain the above copyright notice,
|
11
|
this list of conditions and the following disclaimer.
|
12
|
|
13
|
2. Redistributions in binary form must reproduce the above copyright
|
14
|
notice, this list of conditions and the following disclaimer in the
|
15
|
documentation and/or other materials provided with the distribution.
|
16
|
|
17
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
18
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
19
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
20
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
21
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
POSSIBILITY OF SUCH DAMAGE.
|
27
|
*/
|
28
|
|
29
|
/*
|
30
|
pfSense_MODULE: shaper
|
31
|
*/
|
32
|
|
33
|
##|+PRIV
|
34
|
##|*IDENT=page-diagnostics-patters
|
35
|
##|*NAME=Diagnostics: Patterns page
|
36
|
##|*DESCR=Allow access to the 'Diagnostics: Patterns' page.
|
37
|
##|*MATCH=patterns.php*
|
38
|
##|-PRIV
|
39
|
|
40
|
require("guiconfig.inc");
|
41
|
|
42
|
//Move the upload file to /usr/local/share/protocols (is_uploaded_file must use tmp_name as argument)
|
43
|
if (($_POST['submit'] == gettext("Upload Pattern file")) && is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
|
44
|
if(fileExtension($_FILES['ulfile']['name'])) {
|
45
|
if (!is_array($config['l7shaper']['custom_pat']))
|
46
|
$config['l7shaper']['custom_pat'] = array();
|
47
|
|
48
|
$config['l7shaper']['custom_pat'][$_FILES['ulfile']['name']] = base64_encode(file_get_contents($_FILES['ulfile']['tmp_name']));
|
49
|
write_config(sprintf(gettext("Added custom l7 pattern %s"), $_FILES['ulfile']['name']));
|
50
|
move_uploaded_file($_FILES['ulfile']['tmp_name'], "/usr/local/share/protocols/" . $_FILES['ulfile']['name']);
|
51
|
$ulmsg = gettext("Uploaded file to") . " /usr/local/share/protocols/" . htmlentities($_FILES['ulfile']['name']);
|
52
|
}
|
53
|
else
|
54
|
$ulmsg = gettext("Warning: You must upload a file with .pat extension.");
|
55
|
}
|
56
|
|
57
|
//Check if file has correct extension (.pat)
|
58
|
function fileExtension($nameFile) {
|
59
|
$format = substr($nameFile, -4);
|
60
|
return ($format == ".pat");
|
61
|
}
|
62
|
|
63
|
$pgtitle = array(gettext("Diagnostics"), gettext("Add layer7 pattern"));
|
64
|
include("head.inc");
|
65
|
?>
|
66
|
|
67
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
68
|
<?php include("fbegin.inc"); ?>
|
69
|
<?php if ($ulmsg) echo "<p class=\"red\"><strong>" . $ulmsg . "</strong></p>\n"; ?>
|
70
|
<div id="mainarea">
|
71
|
<form action="diag_patterns.php" method="post" enctype="multipart/form-data" name="frmPattern">
|
72
|
<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="upload pattern">
|
73
|
<tr>
|
74
|
<td colspan="4" valign="top" class="listtopic"><?=gettext("Upload layer7 pattern file");?></td>
|
75
|
</tr>
|
76
|
<tr>
|
77
|
<td align="right"><strong><?=gettext("File to upload:");?></strong></td>
|
78
|
<td valign="top" class="label">
|
79
|
<input name="ulfile" type="file" class="formfld file" id="ulfile" />
|
80
|
</td>
|
81
|
</tr>
|
82
|
<tr>
|
83
|
<td valign="top"> </td>
|
84
|
<td valign="top" class="label">
|
85
|
<input name="submit" type="submit" class="button" id="upload" value="<?=gettext("Upload Pattern file");?>" />
|
86
|
</td>
|
87
|
</tr>
|
88
|
<tr>
|
89
|
<td colspan="2" valign="top" height="16"></td>
|
90
|
</tr>
|
91
|
</table>
|
92
|
</form>
|
93
|
</div>
|
94
|
<?php include("fend.inc"); ?>
|
95
|
</body>
|
96
|
</html>
|