commit | author | age
|
086696
|
1 |
<?php |
M |
2 |
|
|
3 |
/* |
|
4 |
Copyright (c) 2007, Till Brehm, projektfarm Gmbh |
|
5 |
All rights reserved. |
|
6 |
|
|
7 |
Redistribution and use in source and binary forms, with or without modification, |
|
8 |
are permitted provided that the following conditions are met: |
|
9 |
|
|
10 |
* Redistributions of source code must retain the above copyright notice, |
|
11 |
this list of conditions and the following disclaimer. |
|
12 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
13 |
this list of conditions and the following disclaimer in the documentation |
|
14 |
and/or other materials provided with the distribution. |
|
15 |
* Neither the name of ISPConfig nor the names of its contributors |
|
16 |
may be used to endorse or promote products derived from this software without |
|
17 |
specific prior written permission. |
|
18 |
|
|
19 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
20 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
21 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
22 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
23 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
24 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
26 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
27 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
28 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 |
*/ |
|
30 |
|
|
31 |
class validate_ftpuser { |
7fe908
|
32 |
|
086696
|
33 |
/* |
M |
34 |
Validator function to check if a given dir is ok. |
|
35 |
*/ |
|
36 |
function ftp_dir($field_name, $field_value, $validator) { |
|
37 |
global $app; |
7fe908
|
38 |
|
e23c47
|
39 |
$primary_id = (isset($app->tform->primary_id) && $app->tform->primary_id > 0)?$app->tform->primary_id:$app->remoting_lib->primary_id; |
TB |
40 |
$primary_id = $app->functions->intval($primary_id); |
|
41 |
|
|
42 |
if($primary_id == 0 && !isset($app->remoting_lib->dataRecord['parent_domain_id'])) { |
7fe908
|
43 |
$errmsg = $validator['errmsg']; |
MC |
44 |
if(isset($app->tform->wordbook[$errmsg])) { |
|
45 |
return $app->tform->wordbook[$errmsg]."<br>\r\n"; |
|
46 |
} else { |
|
47 |
return $errmsg."<br>\r\n"; |
|
48 |
} |
|
49 |
} |
|
50 |
|
e23c47
|
51 |
if($primary_id > 0) { |
TB |
52 |
//* get parent_domain_id from website |
cc7a82
|
53 |
$ftp_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM ftp_user WHERE ftp_user_id = ?", $primary_id); |
e23c47
|
54 |
if(!is_array($ftp_data) || $ftp_data["parent_domain_id"] < 1) { |
TB |
55 |
$errmsg = $validator['errmsg']; |
|
56 |
if(isset($app->tform->wordbook[$errmsg])) { |
|
57 |
return $app->tform->wordbook[$errmsg]."<br>\r\n"; |
|
58 |
} else { |
|
59 |
return $errmsg."<br>\r\n"; |
|
60 |
} |
7fe908
|
61 |
} else { |
e23c47
|
62 |
$parent_domain_id = $ftp_data["parent_domain_id"]; |
7fe908
|
63 |
} |
e23c47
|
64 |
} else { |
TB |
65 |
//* get parent_domain_id from dataRecord when we have a insert operation trough remote API |
|
66 |
$parent_domain_id = $app->functions->intval($app->remoting_lib->dataRecord['parent_domain_id']); |
7fe908
|
67 |
} |
MC |
68 |
|
cc7a82
|
69 |
$domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = ?", $parent_domain_id); |
7fe908
|
70 |
if(!is_array($domain_data) || $domain_data["domain_id"] < 1) { |
MC |
71 |
$errmsg = $validator['errmsg']; |
|
72 |
if(isset($app->tform->wordbook[$errmsg])) { |
|
73 |
return $app->tform->wordbook[$errmsg]."<br>\r\n"; |
|
74 |
} else { |
|
75 |
return $errmsg."<br>\r\n"; |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
$doc_root = $domain_data["document_root"]; |
|
80 |
$is_ok = false; |
|
81 |
if($doc_root == $field_value) $is_ok = true; |
|
82 |
|
|
83 |
$doc_root .= "/"; |
|
84 |
if(substr($field_value, 0, strlen($doc_root)) == $doc_root) $is_ok = true; |
|
85 |
|
|
86 |
if(stristr($field_value, '..') or stristr($field_value, './') or stristr($field_value, '/.')) $is_ok = false; |
|
87 |
|
615a0a
|
88 |
//* Final check if docroot path of website is >= 5 chars |
T |
89 |
if(strlen($doc_root) < 5) $is_ok = false; |
7fe908
|
90 |
|
MC |
91 |
if($is_ok == false) { |
|
92 |
$errmsg = $validator['errmsg']; |
|
93 |
if(isset($app->tform->wordbook[$errmsg])) { |
|
94 |
return $app->tform->wordbook[$errmsg]."<br>\r\n"; |
|
95 |
} else { |
|
96 |
return $errmsg."<br>\r\n"; |
|
97 |
} |
|
98 |
} |
086696
|
99 |
} |
7fe908
|
100 |
|
MC |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
} |