Skip to content

Commit a4e127a

Browse files
author
Marius Burkard
committed
Merge branch 'mergebranch' into 'master'
Feature merge See merge request !256
2 parents 0cc2861 + 18093fd commit a4e127a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1074
-176
lines changed

install/install.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@
246246

247247
if($install_mode == 'standard') {
248248

249+
$inst->dbmaster = $inst->db;
250+
249251
//* Create the MySQL database
250252
$inst->configure_database();
251253

@@ -500,6 +502,9 @@
500502
$inst->install_crontab();
501503
} else swriteln('[ERROR] Cron not found');
502504

505+
swriteln('Detect IP addresses');
506+
$inst->detect_ips();
507+
503508
swriteln('Restarting services ...');
504509
if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1');
505510
if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart'));
@@ -696,6 +701,9 @@
696701
swriteln('Configuring Pureftpd');
697702
$inst->configure_pureftpd();
698703
}
704+
705+
swriteln('Detect IP addresses');
706+
$inst->detect_ips();
699707

700708
//** Configure DNS
701709
if(strtolower($inst->simple_query('Configure DNS Server', array('y', 'n'), 'y','configure_dns')) == 'y') {
@@ -866,6 +874,9 @@
866874
if($conf['nginx']['php_fpm_init_script'] != '') system($inst->getinitcommand($conf['nginx']['php_fpm_init_script'], 'reload'));
867875
if($conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload'));
868876
}
877+
878+
swriteln('Detect IP addresses');
879+
$inst->detect_ips();
869880

870881

871882

install/lib/installer_base.lib.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,84 @@ public function add_database_server_record() {
371371

372372

373373
}
374+
375+
public function detect_ips(){
376+
global $conf;
377+
378+
exec("ip addr show | awk '/global/ { print $2 }' | cut -d '/' -f 1", $output, $retval);
379+
380+
if($retval == 0){
381+
if(is_array($output) && !empty($output)){
382+
foreach($output as $line){
383+
$line = trim($line);
384+
$ip_type = '';
385+
if (filter_var($line, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
386+
$ip_type = 'IPv4';
387+
}
388+
if (filter_var($line, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
389+
$ip_type = 'IPv6';
390+
}
391+
if($ip_type == '') continue;
392+
if($this->db->dbHost != $this->dbmaster->dbHost){
393+
$this->dbmaster->query('INSERT INTO server_ip (
394+
sys_userid, sys_groupid, sys_perm_user, sys_perm_group,
395+
sys_perm_other, server_id, client_id, ip_type, ip_address,
396+
virtualhost, virtualhost_port
397+
) VALUES (
398+
1,
399+
1,
400+
"riud",
401+
"riud",
402+
"",
403+
?,
404+
0,
405+
?,
406+
?,
407+
"y",
408+
"80,443"
409+
)', $conf['server_id'], $ip_type, $line);
410+
$server_ip_id = $this->dbmaster->insertID();
411+
$this->db->query('INSERT INTO server_ip (
412+
server_php_id, sys_userid, sys_groupid, sys_perm_user, sys_perm_group,
413+
sys_perm_other, server_id, client_id, ip_type, ip_address,
414+
virtualhost, virtualhost_port
415+
) VALUES (
416+
?,
417+
1,
418+
1,
419+
"riud",
420+
"riud",
421+
"",
422+
?,
423+
0,
424+
?,
425+
?,
426+
"y",
427+
"80,443"
428+
)', $server_ip_id, $conf['server_id'], $ip_type, $line);
429+
} else {
430+
$this->db->query('INSERT INTO server_ip (
431+
sys_userid, sys_groupid, sys_perm_user, sys_perm_group,
432+
sys_perm_other, server_id, client_id, ip_type, ip_address,
433+
virtualhost, virtualhost_port
434+
) VALUES (
435+
1,
436+
1,
437+
"riud",
438+
"riud",
439+
"",
440+
?,
441+
0,
442+
?,
443+
?,
444+
"y",
445+
"80,443"
446+
)', $conf['server_id'], $ip_type, $line);
447+
}
448+
}
449+
}
450+
}
451+
}
374452

375453
public function grant_master_database_rights($verbose = false) {
376454
global $conf;

install/sql/ispconfig3.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ CREATE TABLE `client` (
257257
`customer_no_counter` int(11) NOT NULL DEFAULT '0',
258258
`added_date` date NOT NULL DEFAULT '0000-00-00',
259259
`added_by` varchar(255) DEFAULT NULL,
260+
`validation_status` enum('accept','review','reject') NOT NULL DEFAULT 'accept',
261+
`risk_score` int(10) unsigned NOT NULL DEFAULT '0',
262+
`activation_code` varchar(10) NOT NULL DEFAULT '',
260263
PRIMARY KEY (`client_id`)
261264
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
262265

@@ -455,6 +458,7 @@ CREATE TABLE IF NOT EXISTS `directive_snippets` (
455458
`customer_viewable` ENUM('n','y') NOT NULL DEFAULT 'n',
456459
`required_php_snippets` varchar(255) NOT NULL DEFAULT '',
457460
`active` enum('n','y') NOT NULL DEFAULT 'y',
461+
`master_directive_snippets_id` int(11) unsigned NOT NULL DEFAULT '0',
458462
PRIMARY KEY (`directive_snippets_id`)
459463
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
460464

@@ -1946,6 +1950,7 @@ CREATE TABLE `web_domain` (
19461950
`enable_pagespeed` ENUM('y','n') NOT NULL DEFAULT 'n',
19471951
`http_port` int(11) unsigned NOT NULL DEFAULT '80',
19481952
`https_port` int(11) unsigned NOT NULL DEFAULT '443',
1953+
`folder_directive_snippets` text NOT NULL,
19491954
PRIMARY KEY (`domain_id`),
19501955
UNIQUE KEY `serverdomain` ( `server_id` , `ip_address`, `domain` )
19511956
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

install/tpl/server.ini.master

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ admin_notify_events=1
1818
backup_dir=/var/backup
1919
backup_dir_is_mount=n
2020
backup_mode=rootgz
21+
backup_time=0:00
2122
backup_delete=n
2223
monit_url=
2324
monit_user=
@@ -46,7 +47,7 @@ relayhost_password=
4647
mailbox_size_limit=0
4748
message_size_limit=0
4849
mailbox_quota_stats=y
49-
realtime_blackhole_list=
50+
realtime_blackhole_list=zen.spamhaus.org
5051
overquota_notify_admin=y
5152
overquota_notify_client=y
5253
overquota_notify_freq=7
@@ -78,7 +79,6 @@ apps_vhost_ip=_default_
7879
apps_vhost_servername=
7980
php_open_basedir=[website_path]/web:[website_path]/private:[website_path]/tmp:/var/www/[website_domain]/web:/srv/www/[website_domain]/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin
8081
htaccess_allow_override=All
81-
enable_spdy=y
8282
awstats_conf_dir=/etc/awstats
8383
awstats_data_dir=/var/lib/awstats
8484
awstats_pl=/usr/lib/cgi-bin/awstats.pl
@@ -131,7 +131,7 @@ fastcgi_config_syntax=1
131131
[jailkit]
132132
jailkit_chroot_home=/home/[username]
133133
jailkit_chroot_app_sections=basicshell editors extendedshell netutils ssh sftp scp groups jk_lsh
134-
jailkit_chroot_app_programs=/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico /usr/bin/mysql /usr/bin/mysqldump /usr/bin/git /usr/bin/git-receive-pack /usr/bin/git-upload-pack /usr/bin/unzip /usr/bin/zip /bin/tar /bin/rm /usr/bin/patch
134+
jailkit_chroot_app_programs=/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico /usr/bin/mysql /usr/bin/mysqldump /usr/bin/git /usr/bin/git-receive-pack /usr/bin/git-upload-pack /usr/bin/unzip /usr/bin/zip /bin/tar /bin/rm /usr/bin/patch /usr/bin/which /usr/lib/x86_64-linux-gnu/libmemcached.so.11 /usr/lib/x86_64-linux-gnu/libmemcachedutil.so.2 /usr/lib/x86_64-linux-gnu/libMagickWand-6.Q16.so.2 /opt/php-5.6.8/bin/php /opt/php-5.6.8/include /opt/php-5.6.8/lib
135135
jailkit_chroot_cron_programs=/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php
136136

137137
[vlogger]

interface/lib/classes/functions.inc.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,45 @@ public function getimagesizefromstring($string){
390390
return getimagesizefromstring($string);
391391
}
392392
}
393+
394+
public function password($minLength = 10, $special = false){
395+
global $app;
396+
397+
$iteration = 0;
398+
$password = "";
399+
$maxLength = $minLength + 5;
400+
$length = $this->getRandomInt($minLength, $maxLength);
401+
402+
while($iteration < $length){
403+
$randomNumber = (floor(((mt_rand() / mt_getrandmax()) * 100)) % 94) + 33;
404+
if(!$special){
405+
if (($randomNumber >=33) && ($randomNumber <=47)) { continue; }
406+
if (($randomNumber >=58) && ($randomNumber <=64)) { continue; }
407+
if (($randomNumber >=91) && ($randomNumber <=96)) { continue; }
408+
if (($randomNumber >=123) && ($randomNumber <=126)) { continue; }
409+
}
410+
$iteration++;
411+
$password .= chr($randomNumber);
412+
}
413+
$app->uses('validate_password');
414+
if($app->validate_password->password_check('', $password, '') !== false) $password = $this->password($minLength, $special);
415+
return $password;
416+
}
393417

418+
public function getRandomInt($min, $max){
419+
return floor((mt_rand() / mt_getrandmax()) * ($max - $min + 1)) + $min;
420+
}
421+
422+
public function generate_customer_no(){
423+
global $app;
424+
// generate customer no.
425+
$customer_no = mt_rand(100000, 999999);
426+
while($app->db->queryOneRecord("SELECT client_id FROM client WHERE customer_no = ?", $customer_no)) {
427+
$customer_no = mt_rand(100000, 999999);
428+
}
429+
430+
return $customer_no;
431+
}
394432
}
395433

396434
?>

interface/lib/classes/listform.inc.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,23 @@ public function getSearchSQL($sql_where = '')
257257
$searchval = $year.'-'.$month.'-'.$day;
258258
}
259259
}
260+
261+
if($i['datatype'] == 'BOOLEAN' && $searchval != ''){
262+
if (!function_exists('boolval')) {
263+
$searchval = (bool) $searchval;
264+
if($searchval === true){
265+
$searchval = 'TRUE';
266+
} else {
267+
$searchval = 'FALSE';
268+
}
269+
} else {
270+
$searchval = boolval($searchval)? 'TRUE' : 'FALSE';
271+
}
272+
}
260273

261274
// if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and";
262275
if(isset($searchval) && $searchval != ''){
263-
$sql_where .= " ".($table != ''? $table.'.' : $this->listDef['table'].'.')."$field ".$i['op']." '".$app->db->quote($i['prefix'].$searchval.$i['suffix'])."' and";
276+
$sql_where .= " ".($table != ''? $table.'.' : $this->listDef['table'].'.')."$field ".$i['op']." ".($i['datatype'] == 'BOOLEAN'? "" : "'").$app->db->quote($i['prefix'].$searchval.$i['suffix']).($i['datatype'] == 'BOOLEAN'? "" : "'")." and";
264277
}
265278
}
266279
}
@@ -384,7 +397,7 @@ public function getPagingHTML($vars)
384397
if(isset($vars['show_page_back']) && $vars['show_page_back'] == 1){
385398
$content .= '<li><a href="#" data-load-content="'.$vars['list_file'].'?page=0'.$vars['page_params'].'" aria-label="First">
386399
<span aria-hidden="true">&laquo;</span></a></li>';
387-
$content .= '<li><a href="#" data-load-content='.$vars['list_file'].'?page='.$vars['last_page'].$vars['page_params'].'" aria-label="Previous">
400+
$content .= '<li><a href="#" data-load-content="'.$vars['list_file'].'?page='.$vars['last_page'].$vars['page_params'].'" aria-label="Previous">
388401
<span aria-hidden="true">&lsaquo;</span></a></li>';
389402
}
390403
$prev = -1;
@@ -501,6 +514,14 @@ public function decode($record)
501514
case 'CURRENCY':
502515
$record[$key] = $app->functions->currency_format($record[$key]);
503516
break;
517+
518+
case 'BOOLEAN':
519+
if (!function_exists('boolval')) {
520+
$record[$key] = (bool) $record[$key];
521+
} else {
522+
$record[$key] = boolval($record[$key]);
523+
}
524+
break;
504525

505526
default:
506527
$record[$key] = htmlentities(stripslashes($record[$key]), ENT_QUOTES, $conf["html_content_encoding"]);
@@ -564,6 +585,14 @@ public function encode($record)
564585
case 'CURRENCY':
565586
$record[$key] = str_replace(',', '.', $record[$key]);
566587
break;
588+
589+
case 'BOOLEAN':
590+
if (!function_exists('boolval')) {
591+
$record[$key] = (bool) $record[$key];
592+
} else {
593+
$record[$key] = boolval($record[$key]);
594+
}
595+
break;
567596
}
568597
}
569598
}

interface/lib/classes/remote.d/client.inc.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,22 +526,24 @@ public function client_get_all($session_id) {
526526
* @param int client id
527527
* @param string new password
528528
* @return bool true if success
529-
* @author Julio Montoya <gugli100@gmail.com> BeezNest 2010
530529
*
531530
*/
532531
public function client_change_password($session_id, $client_id, $new_password) {
533532
global $app;
534533

534+
$app->uses('auth');
535+
535536
if(!$this->checkPerm($session_id, 'client_change_password')) {
536537
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
537538
return false;
538539
}
539-
$client_id = $app->functions->intval($client_id);
540+
540541
$client = $app->db->queryOneRecord("SELECT client_id FROM client WHERE client_id = ?", $client_id);
541542
if($client['client_id'] > 0) {
542-
$sql = "UPDATE client SET password = md5(?) WHERE client_id = ?";
543+
$new_password = $app->auth->crypt_password($new_password);
544+
$sql = "UPDATE client SET password = ? WHERE client_id = ?";
543545
$app->db->query($sql, $new_password, $client_id);
544-
$sql = "UPDATE sys_user SET passwort = md5(?) WHERE client_id = ?";
546+
$sql = "UPDATE sys_user SET passwort = ? WHERE client_id = ?";
545547
$app->db->query($sql, $new_password, $client_id);
546548
return true;
547549
} else {
@@ -681,7 +683,6 @@ public function client_login_get($session_id,$username,$password,$remote_ip = ''
681683

682684
return $returnval;
683685
}
684-
685686
}
686687

687688
?>

interface/lib/classes/tform_base.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,9 @@ function filterField($field_name, $field_value, $filters, $filter_event) {
878878
case 'TRIM':
879879
$returnval = trim($returnval);
880880
break;
881+
case 'NOWHITESPACE':
882+
$returnval = preg_replace('/\s+/', '', $returnval);
883+
break;
881884
default:
882885
$this->errorMessage .= "Unknown Filter: ".$filter['type'];
883886
break;

interface/lib/classes/validate_password.inc.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class validate_password {
3333

3434
private function _get_password_strength($password) {
3535
$length = strlen($password);
36+
3637
$points = 0;
3738
if ($length < 5) {
3839
return 1;
@@ -53,7 +54,7 @@ private function _get_password_strength($password) {
5354
$different += 1;
5455
}
5556

56-
if (preg_match('/[`~!@#$%^&*()_+|\\=-\[\]}{\';:\/?.>,<" ]/', $password)) {
57+
if (preg_match('/[`~!@#$%^&*()_+|\\=\-\[\]}{\';:\/?.>,<" ]/', $password)) {
5758
$points += 1;
5859
$different += 1;
5960
}

0 commit comments

Comments
 (0)