1 |
f63d5b66
|
Helder Pereira
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
Exec+ v1.02-000 - Copyright 2001-2003, All rights reserved
|
5 |
1d7ba683
|
ayvis
|
Created by André Ribeiro and Hélder Pereira
|
6 |
f63d5b66
|
Helder Pereira
|
|
7 |
1b90e2d5
|
Renato Botelho
|
Redistribution and use in source and binary forms, with or without
|
8 |
|
|
modification, are permitted provided that the following conditions are met:
|
9 |
f63d5b66
|
Helder Pereira
|
|
10 |
1b90e2d5
|
Renato Botelho
|
1. Redistributions of source code must retain the above copyright notice,
|
11 |
|
|
this list of conditions and the following disclaimer.
|
12 |
f63d5b66
|
Helder Pereira
|
|
13 |
1b90e2d5
|
Renato Botelho
|
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 |
f63d5b66
|
Helder Pereira
|
|
17 |
1b90e2d5
|
Renato Botelho
|
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 |
f63d5b66
|
Helder Pereira
|
*/
|
28 |
|
|
|
29 |
1b90e2d5
|
Renato Botelho
|
/*
|
30 |
174722ac
|
sbeaver
|
pfSense_MODULE: shaper
|
31 |
13d193c2
|
Scott Ullrich
|
*/
|
32 |
|
|
|
33 |
f63d5b66
|
Helder Pereira
|
##|+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 |
174722ac
|
sbeaver
|
// Defining this here ensures that both instances (button name and POST check) are identical
|
43 |
|
|
$buttonlabel = gettext("Upload Pattern file");
|
44 |
|
|
|
45 |
f63d5b66
|
Helder Pereira
|
//Move the upload file to /usr/local/share/protocols (is_uploaded_file must use tmp_name as argument)
|
46 |
174722ac
|
sbeaver
|
if (($_POST['submit'] == $buttonlabel) && is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
|
47 |
f63d5b66
|
Helder Pereira
|
if(fileExtension($_FILES['ulfile']['name'])) {
|
48 |
b5388f03
|
Renato Botelho
|
if (!is_array($config['l7shaper']['custom_pat']))
|
49 |
|
|
$config['l7shaper']['custom_pat'] = array();
|
50 |
|
|
|
51 |
|
|
$config['l7shaper']['custom_pat'][$_FILES['ulfile']['name']] = base64_encode(file_get_contents($_FILES['ulfile']['tmp_name']));
|
52 |
|
|
write_config(sprintf(gettext("Added custom l7 pattern %s"), $_FILES['ulfile']['name']));
|
53 |
f63d5b66
|
Helder Pereira
|
move_uploaded_file($_FILES['ulfile']['tmp_name'], "/usr/local/share/protocols/" . $_FILES['ulfile']['name']);
|
54 |
f8ec8de4
|
Renato Botelho
|
$ulmsg = gettext("Uploaded file to") . " /usr/local/share/protocols/" . htmlentities($_FILES['ulfile']['name']);
|
55 |
174722ac
|
sbeaver
|
$class = 'alert-success';
|
56 |
|
|
}
|
57 |
|
|
else {
|
58 |
|
|
$ulmsg = gettext("Error: You must upload a file with .pat extension.");
|
59 |
|
|
$class = 'alert-danger';
|
60 |
f63d5b66
|
Helder Pereira
|
}
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
//Check if file has correct extension (.pat)
|
64 |
|
|
function fileExtension($nameFile) {
|
65 |
1b90e2d5
|
Renato Botelho
|
$format = substr($nameFile, -4);
|
66 |
|
|
return ($format == ".pat");
|
67 |
f63d5b66
|
Helder Pereira
|
}
|
68 |
|
|
|
69 |
f8ec8de4
|
Renato Botelho
|
$pgtitle = array(gettext("Diagnostics"), gettext("Add layer7 pattern"));
|
70 |
f63d5b66
|
Helder Pereira
|
include("head.inc");
|
71 |
174722ac
|
sbeaver
|
|
72 |
|
|
if($ulmsg)
|
73 |
|
|
print_info_box($ulmsg, $class);
|
74 |
|
|
|
75 |
|
|
require('classes/Form.class.php');
|
76 |
|
|
|
77 |
|
|
$form = new Form(new Form_Button(
|
78 |
|
|
submit,
|
79 |
|
|
$buttonlabel,
|
80 |
|
|
null
|
81 |
|
|
));
|
82 |
|
|
|
83 |
|
|
$form->setMultipartEncoding();
|
84 |
|
|
|
85 |
|
|
$section = new Form_Section('Upload Layer7 pattern file');
|
86 |
|
|
|
87 |
|
|
$filepicker = new Form_Input(
|
88 |
|
|
'ulfile',
|
89 |
|
|
'File to upload',
|
90 |
|
|
'file',
|
91 |
|
|
''
|
92 |
|
|
);
|
93 |
|
|
|
94 |
|
|
$section->addInput($filepicker)->setHelp('Choose the file you wish to upload (*.pat)');
|
95 |
|
|
|
96 |
|
|
$form->add($section);
|
97 |
|
|
print($form);
|
98 |
|
|
|
99 |
|
|
include("foot.inc");
|