Skip to content

Commit 6a001aa

Browse files
author
Till Brehm
committed
Merge branch 'stable-3.0.5' of git.ispconfig.org:ispconfig/ispconfig3 into stable-3.0.5
2 parents 9886873 + ac3c7b1 commit 6a001aa

File tree

10 files changed

+444
-84
lines changed

10 files changed

+444
-84
lines changed

install/lib/installer_base.lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ public function configure_postfix($options = '') {
690690
if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
691691

692692
//* These postconf commands will be executed on installation and update
693-
$server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']);
693+
$server_ini_rec = $this->db->queryOneRecord("SELECT config FROM `" . $this->db->quote($conf["mysql"]["database"]) . "`.`server` WHERE server_id = ".$conf['server_id']);
694694
$server_ini_array = ini_to_array(stripslashes($server_ini_rec['config']));
695695
unset($server_ini_rec);
696696

Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2013, Marius Cramer, pixcept KG
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+
//* The purpose of this library is to provide some general functions.
32+
//* This class is loaded automatically by the ispconfig framework.
33+
34+
abstract class ISPConfigRequest {
35+
/**
36+
* Get header data and contents from an url
37+
*
38+
* Calls an url and returns an array containing the http header and the page content
39+
*
40+
* @access public
41+
* @param string $url the url to call
42+
* @param string $store_in the file to store the data in instead of returning them
43+
* @return array The array with header data at index 0 and page content at index 1, returns boolean false on error. If $store_in is set only the headers are returned
44+
*/
45+
46+
47+
public static function get_with_headers($url, $store_in = null, $follow_redirects = false, $user_agent = false) {
48+
if($follow_redirects === true) $follow_redirects = 5;
49+
elseif($follow_redirects !== false) $follow_redirects--;
50+
51+
if(!$user_agent) $user_agent = 'pxFW GET proxy';
52+
53+
$url_info = parse_url($url);
54+
if(isset($url_info['scheme']) && $url_info['scheme'] == 'https') {
55+
$port = isset($url_info['port']) ? $url_info['port'] : 443;
56+
//@$fp = stream_socket_client('ssl://' . $url_info['host'] . ':' . $port, $errno, $errstr, 10, STREAM_CLIENT_CONNECT, stream_context_create(array('ssl' => array('ciphers' => 'ALL:!AES:!3DES:!RC4:@STRENGTH'))));
57+
@$fp = fsockopen('sslv3://' . $url_info['host'], $port, $errno, $errstr, 10);
58+
} else {
59+
$port = isset($url_info['port']) ? $url_info['port'] : 80;
60+
@$fp = fsockopen($url_info['host'], $port, $errno, $errstr, 10);
61+
}
62+
63+
if($store_in) {
64+
$outfp = fopen($store_in, 'w');
65+
if(!$outfp) return false;
66+
}
67+
if($fp) {
68+
stream_set_timeout($fp, 10);
69+
$head = 'GET ' . (isset($url_info['path']) ? $url_info['path'] : '/') . (isset($url_info['query']) ? '?' . $url_info['query'] : '');
70+
$head .= " HTTP/1.0\r\nHost: " . (isset($url_info['host']) ? $url_info['host'] : '') . "\r\n";
71+
$head .= "User-Agent: " . $user_agent . "\r\n";
72+
if(isset($url_info['user'])) {
73+
if(!array_key_exists('pass', $url_info)) $url_info['pass'] = '';
74+
$head .= "Authorization: basic " . base64_encode($url_info['user'] . ':' . $url_info['pass']) . "\r\n";
75+
}
76+
$head .= "Connection: Close\r\n";
77+
$head .= "Accept: */*\r\n\r\n";
78+
79+
$data = '';
80+
$eoheader = false;
81+
fputs($fp, $head);
82+
while(!feof($fp)) {
83+
if($header = fgets($fp, 1024)) {
84+
if($eoheader == true) {
85+
if($store_in) fputs($outfp, $header);
86+
else $data .= $header;
87+
continue;
88+
}
89+
90+
if ($header == "\r\n") {
91+
$eoheader = true;
92+
continue;
93+
} else {
94+
$header = trim($header);
95+
}
96+
$sc_pos = strpos($header, ':');
97+
if($sc_pos === false) {
98+
$headers['status'] = $header;
99+
$headers['http_code'] = intval(preg_replace('/^HTTP\/\d+\.\d+\s+(\d+)\s+.*$/', '$1', $header));
100+
} else {
101+
$label = substr($header, 0, $sc_pos);
102+
$value = substr($header, $sc_pos + 1);
103+
$headers[strtolower($label)] = trim($value);
104+
}
105+
}
106+
}
107+
fclose($fp);
108+
if(isset($headers['http_code']) && isset($headers['location']) && ($headers['http_code'] == 301 || $headers['http_code'] == 302) && $follow_redirects > 0) {
109+
if($store_in) fclose($outfp);
110+
return $self::get_with_headers($headers['location'], $store_in, $follow_redirects);
111+
}
112+
if($store_in) {
113+
fclose($outfp);
114+
115+
$code = intval(preg_replace('/^HTTP\/\d+\.\d+\s+(\d+)\s+.*$/', '$1', $headers['status']));
116+
if($code != 200) {
117+
return false;
118+
}
119+
return $headers;
120+
} else {
121+
return array($headers, $data);
122+
}
123+
} else {
124+
if($store_in) {
125+
fclose($outfp);
126+
@unlink($store_in);
127+
}
128+
return false;
129+
}
130+
}
131+
132+
/**
133+
* Gets the content of an url
134+
*
135+
* Checks for the php function file_get_contents and uses an alternative if not found
136+
*
137+
* @access public
138+
* @param string $url url to get
139+
* @return string url data including headers
140+
* @see file_get_contents
141+
*/
142+
public static function get($url) {
143+
if(function_exists('file_get_contents')) return file_get_contents($url);
144+
145+
$fp = fopen($url, 'r');
146+
$data = '';
147+
while(!feof($fp)) {
148+
$data .= fgets($fp, 8192);
149+
}
150+
fclose($fp);
151+
152+
return $data;
153+
}
154+
155+
156+
/**
157+
* Make a post request and get data
158+
*
159+
* Calls an url with a post request and returns the data - and optionally the header content
160+
*
161+
* @access public
162+
* @param string $url the url to call
163+
* @param string $data the post data to send
164+
* @param bool $get_headers if true, the function will return an array like PXUrl::get_with_headers(), otherwise the content is returned as a string
165+
* @return mixed Content data as string or - if get_headers is true - the array with header data at index 0 and page content at index 1
166+
* @see get_url_and_headers
167+
*/
168+
public static function post($url, $data, $get_headers = false, $user_agent = false) {
169+
$url_info = parse_url($url);
170+
if((isset($url_info['scheme']) && $url_info['scheme'] == 'https') || $url_info['port'] == 443) {
171+
$port = (!isset($url_info['port']) || !$url_info['port'] || $url_info['port'] == 443 || $url_info['port'] == 80) ? 443 : $url_info['port'];
172+
//@$fp = stream_socket_client('ssl://' . $url_info['host'] . ':' . $port, $errno, $errstr, 10, STREAM_CLIENT_CONNECT, stream_context_create(array('ssl' => array('ciphers' => 'ALL:!AES:!3DES:!RC4:@STRENGTH'))));
173+
@$fp = fsockopen('sslv3://' . $url_info['host'], $port, $errno, $errstr, 10);
174+
} else {
175+
$port = isset($url_info['port']) ? $url_info['port'] : 80;
176+
@$fp = fsockopen($url_info['host'], $port, $errno, $errstr, 10);
177+
}
178+
179+
if(!$fp) return '';
180+
181+
if(!$user_agent) $user_agent = 'pxFW GET proxy';
182+
183+
$header = 'POST ' . (isset($url_info['path']) ? $url_info['path'] : '/') . (isset($url_info['query']) ? '?' . @$url_info['query'] : '') . " HTTP/1.1\r\n";
184+
$header .= "Host: " . @$url_info['host'] . "\r\n";
185+
$header .= "User-Agent: " . $user_agent . "\r\n";
186+
if(isset($url_info['user'])) {
187+
if(!array_key_exists('pass', $url_info)) $url_info['pass'] = '';
188+
$header .= "Authorization: basic " . base64_encode($url_info['user'] . ':' . $url_info['pass']) . "\r\n";
189+
}
190+
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
191+
$header .= "Content-Length: " . strlen($data) . "\r\n";
192+
$header .= "Connection: close\r\n\r\n";
193+
$header .= $data . "\r\n\r\n";
194+
195+
fwrite($fp, $header);
196+
197+
$response = '';
198+
$eoheader = false;
199+
$header = '';
200+
$tmpdata = '';
201+
$chunked = false;
202+
$chunklen = 0;
203+
204+
while(!feof($fp)) {
205+
if($header = @fgets($fp, 1024)) {
206+
if($eoheader == true) {
207+
$response .= $header;
208+
continue;
209+
}
210+
211+
if ($header == "\r\n") {
212+
$eoheader = true;
213+
continue;
214+
} else {
215+
$tmpdata .= $header;
216+
if(preg_match('/Transfer-Encoding:\s+chunked/i', $tmpdata)) $chunked = true;
217+
}
218+
}
219+
}
220+
//var_dump($response, $chunked, $header);
221+
if($chunked == true) {
222+
$lines = explode("\n", $response);
223+
$response = '';
224+
$chunklen = 0;
225+
foreach($lines as $line) {
226+
$line .= "\n";
227+
if($chunklen <= 0) {
228+
if(preg_match('/^([0-9a-f]+)\s*$/is', $line, $matches)) {
229+
$chunklen = hexdec($matches[1]);
230+
}
231+
continue;
232+
}
233+
234+
if(strlen($line) > $chunklen) {
235+
//echo "Warnung: " . strlen($line) . " > " . $chunklen . "\n";
236+
$line = substr($line, 0, $chunklen);
237+
}
238+
$response .= $line;
239+
$chunklen -= strlen($line);
240+
}
241+
242+
$start = strpos($response, '<?xml');
243+
$end = strrpos($response, '>');
244+
if($start !== false && $end !== false) $response = substr($response, $start, $end - $start + 1);
245+
}
246+
247+
fclose($fp);
248+
249+
if($get_headers == true) {
250+
$tmpheaders = explode("\n", $tmpdata);
251+
$headers = array();
252+
foreach($tmpheaders as $cur) {
253+
if(preg_match('/^(\w+)\:\s*(.*)$/is', $cur, $matches)) {
254+
$headers["$matches[1]"] = trim($matches[2]);
255+
}
256+
}
257+
return array($headers, $response);
258+
} else return $response;
259+
}
260+
261+
}
262+
263+
?>

interface/lib/classes/validate_password.inc.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,27 @@ private function _get_password_strength($password) {
3838
return 1;
3939
}
4040

41+
$different = 0;
42+
if (preg_match('/[abcdefghijklnmopqrstuvwxyz]/', $password)) {
43+
$different += 1;
44+
}
45+
4146
if (preg_match('/[ABCDEFGHIJKLNMOPQRSTUVWXYZ]/', $password)) {
4247
$points += 1;
48+
$different += 1;
4349
}
4450

4551
if (preg_match('/[0123456789]/', $password)) {
4652
$points += 1;
53+
$different += 1;
4754
}
4855

4956
if (preg_match('/[`~!@#$%^&*()_+|\\=-[]}{\';:\/?.>,<" ]/', $password)) {
5057
$points += 1;
58+
$different += 1;
5159
}
5260

53-
if ($points == 0) {
61+
if ($points == 0 || $different < 3) {
5462
if ($length >= 5 && $length <= 6) {
5563
return 1;
5664
} else if ($length >= 7 && $length <= 8) {

interface/web/admin/lib/lang/de_system_config.lng

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ $wb['customer_no_template_error_regex_txt'] = 'Die Kundennummer-Vorlage enthält
6464
$wb['customer_no_start_txt'] = 'Kundennummer Startwert';
6565
$wb['customer_no_counter_txt'] = 'Kundennummer Zähler';
6666
$wb['session_timeout_txt'] = 'Session-Timeout (Minuten)';
67-
$wb['session_allow_endless_txt'] = '\\"Eingeloggt bleiben\\" aktivieren';
67+
$wb['session_allow_endless_txt'] = '&quot;Eingeloggt bleiben&quot; aktivieren';
6868
$wb['No'] = 'Nein';
6969
$wb['min_password_length_txt'] = 'Minimale Passwortlänge';
7070
$wb['min_password_strength_txt'] = 'Minimale Passwortstärke';

interface/web/admin/templates/directive_snippets_edit.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h2><tmpl_var name="list_head_txt"></h2>
1717
</div>
1818
<div class="ctrlHolder">
1919
<label for="snippet">{tmpl_var name='snippet_txt'}</label>
20-
<textarea name="snippet" id="snippet" rows='10' cols='50' style="width:400px;">{tmpl_var name='snippet'}</textarea><div class="nginx"> &nbsp; {tmpl_var name='variables_txt'}: <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{FASTCGIPASS}</a></div>
20+
<textarea name="snippet" id="snippet" rows='10' cols='50' style="width:400px;">{tmpl_var name='snippet'}</textarea><span class="nginx"> &nbsp; {tmpl_var name='variables_txt'}: </span><a href="javascript:void(0);" class="addPlaceholder nginx">{DOCROOT}</a><span class="nginx">, </span><a href="javascript:void(0);" class="addPlaceholder nginx">{FASTCGIPASS}</a>
2121
</div>
2222
<div class="ctrlHolder">
2323
<p class="label">{tmpl_var name='active_txt'}</p>

interface/web/index.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@
6060
unset($_SESSION['show_error_msg']);
6161
}
6262

63+
// read js.d files
64+
$js_d = ISPC_WEB_PATH . '/js/js.d';
65+
$js_d_files = array();
66+
if(@is_dir($js_d)) {
67+
$dir = opendir($js_d);
68+
while($file = readdir($dir)) {
69+
$filename = $js_d . '/' . $file;
70+
if($file === '.' || $file === '..' || !is_file($filename)) continue;
71+
if(substr($file, -3) !== '.js') continue;
72+
$js_d_files[] = array('file' => $file);
73+
}
74+
closedir($dir);
75+
}
76+
77+
if (!empty($js_d_files)) $app->tpl->setLoop('js_d_includes', $js_d_files);
78+
unset($js_d_files);
6379

6480
$app->tpl_defaults();
6581
$app->tpl->pparse();

0 commit comments

Comments
 (0)