From d22277878254cf33fd63ca1bf12b215f4e030a27 Mon Sep 17 00:00:00 2001 From: Marius Burkard Date: Mon, 4 Jan 2016 11:12:49 +0100 Subject: [PATCH] - merged different fixes and updates from foreign branches --- install/install.php | 11 + install/lib/installer_base.lib.php | 78 +++++ install/sql/ispconfig3.sql | 5 + install/tpl/server.ini.master | 6 +- interface/lib/classes/functions.inc.php | 328 ++++++++++++++++++ interface/lib/classes/listform.inc.php | 33 +- interface/lib/classes/remote.d/client.inc.php | 42 ++- interface/lib/classes/tform_base.inc.php | 3 + .../lib/classes/validate_password.inc.php | 3 +- .../web/admin/directive_snippets_edit.php | 53 ++- .../web/admin/directive_snippets_list.php | 43 ++- .../admin/form/directive_snippets.tform.php | 2 +- .../web/admin/form/server_config.tform.php | 104 ++++++ .../admin/list/directive_snippets.list.php | 9 + .../templates/directive_snippets_edit.htm | 12 +- .../templates/directive_snippets_list.htm | 9 +- .../templates/server_config_server_edit.htm | 6 + interface/web/client/client_del.php | 4 +- interface/web/client/client_list.php | 24 +- interface/web/client/form/client.tform.php | 12 +- interface/web/client/form/reseller.tform.php | 16 +- interface/web/client/list/client.list.php | 11 + .../web/client/templates/clients_list.htm | 17 +- .../web/mail/templates/mail_domain_edit.htm | 2 +- interface/web/sites/ajax_get_json.php | 13 +- interface/web/sites/database_quota_stats.php | 75 ++-- interface/web/sites/form/database.tform.php | 2 +- .../web/sites/form/web_vhost_domain.tform.php | 18 +- .../templates/web_vhost_domain_admin_list.htm | 10 +- .../templates/web_vhost_domain_advanced.htm | 10 +- .../sites/templates/web_vhost_domain_edit.htm | 69 +++- interface/web/sites/web_vhost_domain_edit.php | 268 ++++++++++++-- .../themes/default/templates/sidenav.tpl.htm | 11 +- server/conf/hhvm_starter.master | 2 +- server/conf/nginx_vhost.conf.master | 24 +- server/conf/vhost.conf.master | 1 + server/lib/classes/cronjob.inc.php | 31 +- server/mods-available/web_module.inc.php | 24 +- .../plugins-available/apache2_plugin.inc.php | 24 +- server/plugins-available/nginx_plugin.inc.php | 132 ++++++- .../shelluser_jailkit_plugin.inc.php | 24 +- 41 files changed, 1396 insertions(+), 175 deletions(-) diff --git a/install/install.php b/install/install.php index 0236820ce9..cab7069d39 100644 --- a/install/install.php +++ b/install/install.php @@ -246,6 +246,8 @@ $conf['services']['xmpp'] = false; if($install_mode == 'standard') { + $inst->dbmaster = $inst->db; + //* Create the MySQL database $inst->configure_database(); @@ -500,6 +502,9 @@ if($install_mode == 'standard') { $inst->install_crontab(); } else swriteln('[ERROR] Cron not found'); + swriteln('Detect IP addresses'); + $inst->detect_ips(); + swriteln('Restarting services ...'); if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1'); if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart')); @@ -696,6 +701,9 @@ if($install_mode == 'standard') { swriteln('Configuring Pureftpd'); $inst->configure_pureftpd(); } + + swriteln('Detect IP addresses'); + $inst->detect_ips(); //** Configure DNS if(strtolower($inst->simple_query('Configure DNS Server', array('y', 'n'), 'y','configure_dns')) == 'y') { @@ -866,6 +874,9 @@ if($install_mode == 'standard') { if($conf['nginx']['php_fpm_init_script'] != '') system($inst->getinitcommand($conf['nginx']['php_fpm_init_script'], 'reload')); if($conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload')); } + + swriteln('Detect IP addresses'); + $inst->detect_ips(); diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index db83e05981..be878c1fe7 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -371,6 +371,84 @@ class installer_base { } + + public function detect_ips(){ + global $conf; + + exec("ip addr show | awk '/global/ { print $2 }' | cut -d '/' -f 1", $output, $retval); + + if($retval == 0){ + if(is_array($output) && !empty($output)){ + foreach($output as $line){ + $line = trim($line); + $ip_type = ''; + if (filter_var($line, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + $ip_type = 'IPv4'; + } + if (filter_var($line, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + $ip_type = 'IPv6'; + } + if($ip_type == '') continue; + if($this->db->dbHost != $this->dbmaster->dbHost){ + $this->dbmaster->query('INSERT INTO server_ip ( + sys_userid, sys_groupid, sys_perm_user, sys_perm_group, + sys_perm_other, server_id, client_id, ip_type, ip_address, + virtualhost, virtualhost_port + ) VALUES ( + 1, + 1, + "riud", + "riud", + "", + ' . $conf['server_id'] . ', + 0, + "'.$ip_type.'", + "'.$line.'", + "y", + "80,443" + )'); + $server_ip_id = $this->dbmaster->insertID(); + $this->db->query('INSERT INTO server_ip ( + server_php_id, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, + sys_perm_other, server_id, client_id, ip_type, ip_address, + virtualhost, virtualhost_port + ) VALUES ( + '.$server_ip_id.', + 1, + 1, + "riud", + "riud", + "", + ' . $conf['server_id'] . ', + 0, + "'.$ip_type.'", + "'.$line.'", + "y", + "80,443" + )'); + } else { + $this->db->query('INSERT INTO server_ip ( + sys_userid, sys_groupid, sys_perm_user, sys_perm_group, + sys_perm_other, server_id, client_id, ip_type, ip_address, + virtualhost, virtualhost_port + ) VALUES ( + 1, + 1, + "riud", + "riud", + "", + ' . $conf['server_id'] . ', + 0, + "'.$ip_type.'", + "'.$line.'", + "y", + "80,443" + )'); + } + } + } + } + } public function grant_master_database_rights($verbose = false) { global $conf; diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 1c56118ae1..672f94bae4 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -257,6 +257,9 @@ CREATE TABLE `client` ( `customer_no_counter` int(11) NOT NULL DEFAULT '0', `added_date` date NOT NULL DEFAULT '0000-00-00', `added_by` varchar(255) DEFAULT NULL, + `validation_status` enum('accept','review','reject') NOT NULL DEFAULT 'accept', + `risk_score` int(10) unsigned NOT NULL DEFAULT '0', + `activation_code` varchar(10) NOT NULL DEFAULT '', PRIMARY KEY (`client_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -455,6 +458,7 @@ CREATE TABLE IF NOT EXISTS `directive_snippets` ( `customer_viewable` ENUM('n','y') NOT NULL DEFAULT 'n', `required_php_snippets` varchar(255) NOT NULL DEFAULT '', `active` enum('n','y') NOT NULL DEFAULT 'y', + `master_directive_snippets_id` int(11) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`directive_snippets_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -1946,6 +1950,7 @@ CREATE TABLE `web_domain` ( `enable_pagespeed` ENUM('y','n') NOT NULL DEFAULT 'n', `http_port` int(11) unsigned NOT NULL DEFAULT '80', `https_port` int(11) unsigned NOT NULL DEFAULT '443', + `folder_directive_snippets` text NOT NULL, PRIMARY KEY (`domain_id`), UNIQUE KEY `serverdomain` ( `server_id` , `ip_address`, `domain` ) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master index 286dc077b5..1f7df52936 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -18,6 +18,7 @@ admin_notify_events=1 backup_dir=/var/backup backup_dir_is_mount=n backup_mode=rootgz +backup_time=0:00 backup_delete=n monit_url= monit_user= @@ -46,7 +47,7 @@ relayhost_password= mailbox_size_limit=0 message_size_limit=0 mailbox_quota_stats=y -realtime_blackhole_list= +realtime_blackhole_list=zen.spamhaus.org overquota_notify_admin=y overquota_notify_client=y overquota_notify_freq=7 @@ -78,7 +79,6 @@ apps_vhost_ip=_default_ apps_vhost_servername= 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 htaccess_allow_override=All -enable_spdy=y awstats_conf_dir=/etc/awstats awstats_data_dir=/var/lib/awstats awstats_pl=/usr/lib/cgi-bin/awstats.pl @@ -131,7 +131,7 @@ fastcgi_config_syntax=1 [jailkit] jailkit_chroot_home=/home/[username] jailkit_chroot_app_sections=basicshell editors extendedshell netutils ssh sftp scp groups jk_lsh -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 +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 jailkit_chroot_cron_programs=/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php [vlogger] diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index 8ec4496453..92f6f17bc9 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -390,6 +390,334 @@ class functions { return getimagesizefromstring($string); } } + + public function password($minLength = 10, $special = false){ + global $app; + + $iteration = 0; + $password = ""; + $maxLength = $minLength + 5; + $length = $this->getRandomInt($minLength, $maxLength); + + while($iteration < $length){ + $randomNumber = (floor(((mt_rand() / mt_getrandmax()) * 100)) % 94) + 33; + if(!$special){ + if (($randomNumber >=33) && ($randomNumber <=47)) { continue; } + if (($randomNumber >=58) && ($randomNumber <=64)) { continue; } + if (($randomNumber >=91) && ($randomNumber <=96)) { continue; } + if (($randomNumber >=123) && ($randomNumber <=126)) { continue; } + } + $iteration++; + $password .= chr($randomNumber); + } + $app->uses('validate_password'); + if($app->validate_password->password_check('', $password, '') !== false) $password = $this->password($minLength, $special); + return $password; + } + + public function getRandomInt($min, $max){ + return floor((mt_rand() / mt_getrandmax()) * ($max - $min + 1)) + $min; + } + + public function generate_customer_no(){ + global $app; + // generate customer no. + $customer_no = mt_rand(100000, 999999); + while($app->db->queryOneRecord("SELECT client_id FROM client WHERE customer_no = '".$customer_no."'")){ + $customer_no = mt_rand(100000, 999999); + } + + return $customer_no; + } + + public function generate_activation_code(){ + + $activation_code = str_pad(mt_rand(0, 99999999), 8, '0', STR_PAD_LEFT); + + return $activation_code; + } + + public function client_activate($client_id){ + global $app, $conf; + + if(!is_file(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php')) return false; + include(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php'); + + $context = stream_context_create(array( + 'ssl' => array( + 'verify_peer' => false, + 'verify_peer_name' => false, + ) + )); + + $soap_client = new SoapClient(null, array('location' => $robot_conf['soap']['soap_location'], + 'uri' => $robot_conf['soap']['soap_uri'], + 'trace' => 1, + 'exceptions' => 1, + 'stream_context' => $context)); + + + try { + if($session_id = $soap_client->login($robot_conf['soap']['username'] , $robot_conf['soap']['password'])) { + //echo 'Logged successfull. Session ID:'.$session_id.'
'; + } + $error = ''; + $client_record = $soap_client->client_get($session_id, $client_id); + + $client_record['password'] = $this->password(); + if(trim($client_record['customer_no']) == '') $client_record['customer_no'] = $this->generate_customer_no(); + $client_record['username'] = 'c'.$client_record['customer_no']; + //die($client_record['customer_no']); + //$client_record['locked'] = 'n'; + $client_record['canceled'] = 'n'; + $soap_client->client_update($session_id, $client_id, 0, $client_record); + + $app->db->query("UPDATE client SET validation_status = 'accept', activation_code = '' WHERE client_id = ".$client_id); + + $activation_letter_filename = ISPC_ROOT_PATH.'/pdf/activation_letters/c'.$client_id.'-'.$client_record['activation_code'].'.pdf'; + if(is_file($activation_letter_filename)) unlink($activation_letter_filename); + + $webdetails['ispconfiguser'] = $client_record['username']; + $webdetails['ispconfigpassword'] = $client_record['password']; + $webdetails['customer_no'] = $client_record['customer_no']; + $webdetails['contact'] = ($client_record['contact_firstname'] != ''? $client_record['contact_firstname'].' ' : '').$client_record['contact_name']; + $webdetails['salutation_de'] = ($client_record['gender'] == 'f'? 'Frau' : 'Herr'); + $webdetails['salutation_en'] = ($client_record['gender'] == 'f'? 'Mrs.' : 'Mr.'); + $webdetails['ispconfigurl'] = 'http'.($_SERVER['HTTPS'] == 'on'? 's' : '').'://'.$_SERVER['HTTP_HOST']; + $webdetails['signature_de'] = $robot_conf['textbaustein']['emailfooter']; + $webdetails['signature_en'] = $robot_conf['textbaustein_en']['emailfooter']; + + if($error == ''){ + // send email with login details + $invoice_client_settings = $app->db->queryOneRecord("SELECT * FROM invoice_client_settings WHERE client_id = ".intval($client_id)); + $company = $app->db->queryOneRecord("SELECT * FROM invoice_company WHERE invoice_company_id = ".$invoice_client_settings['invoice_company_id']); + + $subject = '['.$company['company_name_short'].'] Zugangsdaten zu unserem Kundeninterface / Login details for our customer interface'; + + $app->uses('tpl'); + $tpl = new tpl; + $tpl->newTemplate(ISPC_WEB_PATH."/client/templates/ispconfig_login.master"); + $tpl->setVar($webdetails); + $message = $tpl->grab(); + + if($robot_conf['production_mode']){ + $app->functions->mail(trim($client_record['email']), $subject, $message, 'support@timmehosting.de', '', 'application/pdf', '', '', 'f.timme@timmehosting.de,hetzner@timmehosting.de', 'TimmeHosting.de Support'); + + $app->db->query("INSERT INTO `th_robot_message` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `client_id`, `subject`, `message`, `message_sent_date`, `message_sent_tstamp`, `email_from`, `email_to`, `email_to_bcc`) VALUES(1, 1, 'riud', 'riud', '', ".intval($client_id).", '".$app->db->quote($subject)."', '".$app->db->quote($message)."', '".date('Y-m-d')."', ".time().", 'support@timmehosting.de', '".trim($client_record['email'])."', 'f.timme@timmehosting.de,hetzner@timmehosting.de')"); + } + } + + if($soap_client->logout($session_id)) { + //echo 'Logged out.
'; + } + + } catch (SoapFault $e) { + //$error .= $client->__getLastResponse(); + $error .= 'SOAP Error: '.$e->getMessage(); + } + } + + public function client_activation_failed($client){ + global $app, $conf; + + if(!is_file(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php')) return false; + include(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php'); + + $client_id = intval($client['client_id']); + $webdetails['contact'] = ($client['contact_firstname'] != ''? $client['contact_firstname'].' ' : '').$client['contact_name']; + $webdetails['salutation_de'] = ($client['gender'] == 'f'? 'Frau' : 'Herr'); + $webdetails['salutation_en'] = ($client['gender'] == 'f'? 'Mrs.' : 'Mr.'); + $webdetails['signature_de'] = $robot_conf['textbaustein']['emailfooter']; + $webdetails['signature_en'] = $robot_conf['textbaustein_en']['emailfooter']; + + + // send email with login details + $invoice_client_settings = $app->db->queryOneRecord("SELECT * FROM invoice_client_settings WHERE client_id = ".intval($client_id)); + $company = $app->db->queryOneRecord("SELECT * FROM invoice_company WHERE invoice_company_id = ".$invoice_client_settings['invoice_company_id']); + $subject = '['.$company['company_name_short'].'] Aktivierung Ihres Kundenaccounts fehlgeschlagen / Activation of your customer account failed'; + + $app->uses('tpl'); + $tpl = new tpl; + $tpl->newTemplate(ISPC_WEB_PATH."/client/templates/ispconfig_client_activation_failed.master"); + $tpl->setVar($webdetails); + $message = $tpl->grab(); + + if($robot_conf['production_mode']){ + $app->functions->mail(trim($client['email']), $subject, $message, 'support@timmehosting.de', '', 'application/pdf', '', '', 'f.timme@timmehosting.de,hetzner@timmehosting.de', 'TimmeHosting.de Support'); + + $app->db->query("INSERT INTO `th_robot_message` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `client_id`, `subject`, `message`, `message_sent_date`, `message_sent_tstamp`, `email_from`, `email_to`, `email_to_bcc`) VALUES(1, 1, 'riud', 'riud', '', ".intval($client_id).", '".$app->db->quote($subject)."', '".$app->db->quote($message)."', '".date('Y-m-d')."', ".time().", 'support@timmehosting.de', '".trim($client['email'])."', 'f.timme@timmehosting.de,hetzner@timmehosting.de')"); + } + } + + public function client_review($client_id){ + global $app, $conf; + + if(!is_file(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php')) return false; + include(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php'); + + $context = stream_context_create(array( + 'ssl' => array( + 'verify_peer' => false, + 'verify_peer_name' => false, + ) + )); + + $soap_client = new SoapClient(null, array('location' => $robot_conf['soap']['soap_location'], + 'uri' => $robot_conf['soap']['soap_uri'], + 'trace' => 1, + 'exceptions' => 1, + 'stream_context' => $context)); + + try { + if($session_id = $soap_client->login($robot_conf['soap']['username'] , $robot_conf['soap']['password'])) { + //echo 'Logged successfull. Session ID:'.$session_id.'
'; + } + $error = ''; + $client_record = $soap_client->client_get($session_id, $client_id); + + if(trim($client_record['customer_no']) == ''){ + $client_record['customer_no'] = $this->generate_customer_no(); + $soap_client->client_update($session_id, $client_id, 0, $client_record); + } + + $activation_code = $this->generate_activation_code(); + $app->db->query("UPDATE client SET activation_code = '".$activation_code."'".($client_record['validation_status'] != 'review'? ", validation_status = 'review'" : "")." WHERE client_id = ".$client_id); + + $webdetails['customer_no'] = $client_record['customer_no']; + $webdetails['contact'] = ($client_record['contact_firstname'] != ''? $client_record['contact_firstname'].' ' : '').$client_record['contact_name']; + $webdetails['salutation_de'] = ($client_record['gender'] == 'f'? 'Frau' : 'Herr'); + $webdetails['salutation_en'] = ($client_record['gender'] == 'f'? 'Mrs.' : 'Mr.'); + $webdetails['signature_de'] = $robot_conf['textbaustein']['emailfooter']; + $webdetails['signature_en'] = $robot_conf['textbaustein_en']['emailfooter']; + $webdetails['email'] = $client_record['email']; + include ISPC_LIB_PATH.'/lang/'.strtolower($client_record['language']).'.lng'; + $webdetails['latest_activation_date'] = date($wb['conf_format_dateshort'], $client_record['created_at'] + 14 * 86400); + + if($error == ''){ + // send email with login details + $invoice_client_settings = $app->db->queryOneRecord("SELECT * FROM invoice_client_settings WHERE client_id = ".intval($client_id)); + $company = $app->db->queryOneRecord("SELECT * FROM invoice_company WHERE invoice_company_id = ".$invoice_client_settings['invoice_company_id']); + + $subject = '['.$company['company_name_short'].'] Aktivierung Ihres Kundenkontos / Activation of your customer account'; + $webdetails['company_name_short'] = $company['company_name_short']; + + $app->uses('tpl'); + $tpl = new tpl; + $tpl->newTemplate(ISPC_WEB_PATH."/client/templates/ispconfig_client_activation_email.master"); + $tpl->setVar($webdetails); + $message = $tpl->grab(); + + if($robot_conf['production_mode']){ + $app->functions->mail(trim($client_record['email']), $subject, $message, 'support@timmehosting.de', '', 'application/pdf', '', '', 'f.timme@timmehosting.de,hetzner@timmehosting.de', 'TimmeHosting.de Support'); + + $app->db->query("INSERT INTO `th_robot_message` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `client_id`, `subject`, `message`, `message_sent_date`, `message_sent_tstamp`, `email_from`, `email_to`, `email_to_bcc`) VALUES(1, 1, 'riud', 'riud', '', ".intval($client_id).", '".$app->db->quote($subject)."', '".$app->db->quote($message)."', '".date('Y-m-d')."', ".time().", 'support@timmehosting.de', '".trim($client_record['email'])."', 'f.timme@timmehosting.de,hetzner@timmehosting.de')"); + } + } + + // create activation letter pdf + $app->uses('pdf'); + $app->pdf->AliasNbPages(); + $app->pdf->createActivationLetter($client_id); + + $pdf_content = $app->pdf->Output('doc.pdf', 'S'); + + $activation_letter_filename = ISPC_ROOT_PATH.'/pdf/activation_letters/c'.$client_id.'-'.$activation_code.'.pdf'; + file_put_contents($activation_letter_filename, $pdf_content); + + if(is_file($activation_letter_filename)){ + include(ISPC_WEB_PATH.'/billing/lib/onlinebrief24/Net/SFTP.php'); + $sftp = new Net_SFTP('api.letterei-onlinebrief.de'); + if (!$sftp->login($company['onlinebrief24_user'], $company['onlinebrief24_password'])) { + $error_msg = $app->lng('onlinebrief24_login_failed_txt'); + $app->error($error_msg); + } + $upload_filename = ($company['onlinebrief24_print'] == 'coloured'? '1' : '0').'00'.($client_record['country'] == 'DE'? '1' : '0').'000000000-c'.$client_id.'-'.$activation_code.'.pdf'; + //die($upload_filename); + $sftp->chdir('upload/api'); + $sftp->put($upload_filename, $activation_letter_filename, NET_SFTP_LOCAL_FILE); + } + + if($soap_client->logout($session_id)) { + //echo 'Logged out.
'; + } + + } catch (SoapFault $e) { + //$error .= $client->__getLastResponse(); + $error .= 'SOAP Error: '.$e->getMessage(); + } + } + + public function client_reject($client_id){ + global $app, $conf; + + if(!is_file(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php')) return false; + include(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php'); + + $context = stream_context_create(array( + 'ssl' => array( + 'verify_peer' => false, + 'verify_peer_name' => false, + ) + )); + + $soap_client = new SoapClient(null, array('location' => $robot_conf['soap']['soap_location'], + 'uri' => $robot_conf['soap']['soap_uri'], + 'trace' => 1, + 'exceptions' => 1, + 'stream_context' => $context)); + + try { + if($session_id = $soap_client->login($robot_conf['soap']['username'] , $robot_conf['soap']['password'])) { + //echo 'Logged successfull. Session ID:'.$session_id.'
'; + } + $error = ''; + $client_record = $soap_client->client_get($session_id, $client_id); + + $client_record['locked'] = 'y'; + $client_record['canceled'] = 'y'; + $soap_client->client_update($session_id, $client_id, 0, $client_record); + + $app->db->query("UPDATE client SET validation_status = 'reject', activation_code = '' WHERE client_id = ".$client_id); + $app->db->query("DELETE FROM th_order WHERE client_id = ".$client_id); + + $activation_letter_filename = ISPC_ROOT_PATH.'/pdf/activation_letters/c'.$client_id.'-'.$client_record['activation_code'].'.pdf'; + if(is_file($activation_letter_filename)) unlink($activation_letter_filename); + + $webdetails['contact'] = ($client_record['contact_firstname'] != ''? $client_record['contact_firstname'].' ' : '').$client_record['contact_name']; + $webdetails['salutation_de'] = ($client_record['gender'] == 'f'? 'Frau' : 'Herr'); + $webdetails['salutation_en'] = ($client_record['gender'] == 'f'? 'Mrs.' : 'Mr.'); + $webdetails['signature_de'] = $robot_conf['textbaustein']['emailfooter']; + $webdetails['signature_en'] = $robot_conf['textbaustein_en']['emailfooter']; + + if($error == ''){ + // send email with login details + $invoice_client_settings = $app->db->queryOneRecord("SELECT * FROM invoice_client_settings WHERE client_id = ".intval($client_id)); + $company = $app->db->queryOneRecord("SELECT * FROM invoice_company WHERE invoice_company_id = ".$invoice_client_settings['invoice_company_id']); + + $subject = '['.$company['company_name_short'].'] Sperrung Ihres Kundenaccounts / Suspension of your customer account'; + + $app->uses('tpl'); + $tpl = new tpl; + $tpl->newTemplate(ISPC_WEB_PATH."/client/templates/ispconfig_client_rejection.master"); + $tpl->setVar($webdetails); + $message = $tpl->grab(); + + if($robot_conf['production_mode']){ + $app->functions->mail(trim($client_record['email']), $subject, $message, 'support@timmehosting.de', '', 'application/pdf', '', '', 'f.timme@timmehosting.de,hetzner@timmehosting.de', 'TimmeHosting.de Support'); + + $app->db->query("INSERT INTO `th_robot_message` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `client_id`, `subject`, `message`, `message_sent_date`, `message_sent_tstamp`, `email_from`, `email_to`, `email_to_bcc`) VALUES(1, 1, 'riud', 'riud', '', ".intval($client_id).", '".$app->db->quote($subject)."', '".$app->db->quote($message)."', '".date('Y-m-d')."', ".time().", 'support@timmehosting.de', '".trim($client_record['email'])."', 'f.timme@timmehosting.de,hetzner@timmehosting.de')"); + } + } + + if($soap_client->logout($session_id)) { + //echo 'Logged out.
'; + } + + } catch (SoapFault $e) { + //$error .= $client->__getLastResponse(); + $error .= 'SOAP Error: '.$e->getMessage(); + } + } } diff --git a/interface/lib/classes/listform.inc.php b/interface/lib/classes/listform.inc.php index d4ed752549..120e6523b4 100644 --- a/interface/lib/classes/listform.inc.php +++ b/interface/lib/classes/listform.inc.php @@ -257,10 +257,23 @@ class listform { $searchval = $year.'-'.$month.'-'.$day; } } + + if($i['datatype'] == 'BOOLEAN' && $searchval != ''){ + if (!function_exists('boolval')) { + $searchval = (bool) $searchval; + if($searchval === true){ + $searchval = 'TRUE'; + } else { + $searchval = 'FALSE'; + } + } else { + $searchval = boolval($searchval)? 'TRUE' : 'FALSE'; + } + } // if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and"; if(isset($searchval) && $searchval != ''){ - $sql_where .= " ".($table != ''? $table.'.' : $this->listDef['table'].'.')."$field ".$i['op']." '".$app->db->quote($i['prefix'].$searchval.$i['suffix'])."' and"; + $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"; } } } @@ -384,7 +397,7 @@ class listform { if(isset($vars['show_page_back']) && $vars['show_page_back'] == 1){ $content .= '
  • '; - $content .= '
  • + $content .= '
  • '; } $prev = -1; @@ -501,6 +514,14 @@ class listform { case 'CURRENCY': $record[$key] = $app->functions->currency_format($record[$key]); break; + + case 'BOOLEAN': + if (!function_exists('boolval')) { + $record[$key] = (bool) $record[$key]; + } else { + $record[$key] = boolval($record[$key]); + } + break; default: $record[$key] = htmlentities(stripslashes($record[$key]), ENT_QUOTES, $conf["html_content_encoding"]); @@ -564,6 +585,14 @@ class listform { case 'CURRENCY': $record[$key] = str_replace(',', '.', $record[$key]); break; + + case 'BOOLEAN': + if (!function_exists('boolval')) { + $record[$key] = (bool) $record[$key]; + } else { + $record[$key] = boolval($record[$key]); + } + break; } } } diff --git a/interface/lib/classes/remote.d/client.inc.php b/interface/lib/classes/remote.d/client.inc.php index cccc04f110..e44fd82713 100644 --- a/interface/lib/classes/remote.d/client.inc.php +++ b/interface/lib/classes/remote.d/client.inc.php @@ -526,22 +526,24 @@ class remoting_client extends remoting { * @param int client id * @param string new password * @return bool true if success - * @author Julio Montoya BeezNest 2010 * */ public function client_change_password($session_id, $client_id, $new_password) { global $app; + $app->uses('auth'); + if(!$this->checkPerm($session_id, 'client_change_password')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $client_id = $app->functions->intval($client_id); + $client = $app->db->queryOneRecord("SELECT client_id FROM client WHERE client_id = ?", $client_id); if($client['client_id'] > 0) { - $sql = "UPDATE client SET password = md5(?) WHERE client_id = ?"; + $new_password = $app->auth->crypt_password($new_password); + $sql = "UPDATE client SET password = ? WHERE client_id = ?"; $app->db->query($sql, $new_password, $client_id); - $sql = "UPDATE sys_user SET passwort = md5(?) WHERE client_id = ?"; + $sql = "UPDATE sys_user SET passwort = ? WHERE client_id = ?"; $app->db->query($sql, $new_password, $client_id); return true; } else { @@ -681,6 +683,38 @@ class remoting_client extends remoting { return $returnval; } + + public function client_activate($session_id, $params){ + global $app; + /* + if (!$this->checkPerm($session_id, 'client_update')){ + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + */ + + if(!is_file(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php')){ + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $client = $app->db->queryOneRecord("SELECT * FROM client WHERE customer_no = '".$app->db->quote($params['customer_no'])."' AND email = '".$app->db->quote($params['email'])."' AND activation_code = '".$app->db->quote($params['activation_code'])."' AND validation_status = 'review'"); + //file_put_contents('/tmp/test.txt', "SELECT * FROM client WHERE customer_no = '".$app->db->quote($params['customer_no'])."' AND email = '".$app->db->quote($params['email'])."' AND activation_code = '".$app->db->quote($params['activation_code'])."' AND validation_status = 'review'"); + + if(is_array($client) && !empty($client)){ + $client_id = intval($client['client_id']); + + $app->functions->client_activate($client_id); + + return true; + } else { + $client = $app->db->queryOneRecord("SELECT * FROM client WHERE email = '".$app->db->quote($params['email'])."' AND validation_status = 'review'"); + if(is_array($client) && !empty($client)){ + $app->functions->client_activation_failed($client); + } + return false; + } + } } diff --git a/interface/lib/classes/tform_base.inc.php b/interface/lib/classes/tform_base.inc.php index 2e53d2773b..87e7a68e58 100644 --- a/interface/lib/classes/tform_base.inc.php +++ b/interface/lib/classes/tform_base.inc.php @@ -878,6 +878,9 @@ class tform_base { case 'TRIM': $returnval = trim($returnval); break; + case 'NOWHITESPACE': + $returnval = preg_replace('/\s+/', '', $returnval); + break; default: $this->errorMessage .= "Unknown Filter: ".$filter['type']; break; diff --git a/interface/lib/classes/validate_password.inc.php b/interface/lib/classes/validate_password.inc.php index da044c6053..f36f16220c 100644 --- a/interface/lib/classes/validate_password.inc.php +++ b/interface/lib/classes/validate_password.inc.php @@ -33,6 +33,7 @@ class validate_password { private function _get_password_strength($password) { $length = strlen($password); + $points = 0; if ($length < 5) { return 1; @@ -53,7 +54,7 @@ class validate_password { $different += 1; } - if (preg_match('/[`~!@#$%^&*()_+|\\=-\[\]}{\';:\/?.>,<" ]/', $password)) { + if (preg_match('/[`~!@#$%^&*()_+|\\=\-\[\]}{\';:\/?.>,<" ]/', $password)) { $points += 1; $different += 1; } diff --git a/interface/web/admin/directive_snippets_edit.php b/interface/web/admin/directive_snippets_edit.php index 06cea79fff..f5c48aff41 100644 --- a/interface/web/admin/directive_snippets_edit.php +++ b/interface/web/admin/directive_snippets_edit.php @@ -47,7 +47,56 @@ $app->auth->check_module_permissions('admin'); // Loading classes $app->uses('tpl,tform,tform_actions'); -// let tform_actions handle the page -$app->tform_actions->onLoad(); +class page_action extends tform_actions { + + function onShow() { + global $app, $conf; + + if($this->id > 0){ + $record = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ".intval($this->id)); + if($record['master_directive_snippets_id'] > 0){ + unset($app->tform->formDef["tabs"]['directive_snippets']['fields']['name'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['type'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['snippet'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['required_php_snippets']); + } + unset($record); + } + + parent::onShow(); + } + + function onShowEnd() { + global $app, $conf; + + $is_master = false; + if($this->id > 0){ + if($this->dataRecord['master_directive_snippets_id'] > 0){ + $is_master = true; + $app->tpl->setVar("name", $this->dataRecord['name']); + $app->tpl->setVar("type", $this->dataRecord['type']); + $app->tpl->setVar("snippet", $this->dataRecord['snippet']); + } + } + $app->tpl->setVar("is_master", $is_master); + + parent::onShowEnd(); + } + + function onSubmit() { + global $app, $conf; + + if($this->id > 0){ + $record = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ".intval($this->id)); + if($record['master_directive_snippets_id'] > 0){ + unset($app->tform->formDef["tabs"]['directive_snippets']['fields']['name'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['type'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['snippet'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['required_php_snippets']); + } + unset($record); + } + + parent::onSubmit(); + } + +} + +$page = new page_action; +$page->onLoad(); ?> diff --git a/interface/web/admin/directive_snippets_list.php b/interface/web/admin/directive_snippets_list.php index 5fb75c7593..1376ef02f6 100644 --- a/interface/web/admin/directive_snippets_list.php +++ b/interface/web/admin/directive_snippets_list.php @@ -46,7 +46,48 @@ $app->auth->check_module_permissions('admin'); $app->uses('listform_actions'); -$app->listform_actions->onLoad(); +class list_action extends listform_actions { + + public function prepareDataRow($rec) + { + global $app; + + $rec = $app->listform->decode($rec); + + //* Alternating datarow colors + $this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF'; + $rec['bgcolor'] = $this->DataRowColor; + + $rec['is_master'] = $rec['master_directive_snippets_id']; + //* substitute value for select fields + if(is_array($app->listform->listDef['item']) && count($app->listform->listDef['item']) > 0) { + foreach($app->listform->listDef['item'] as $field) { + $key = $field['field']; + if(isset($field['formtype']) && $field['formtype'] == 'SELECT') { + if(strtolower($rec[$key]) == 'y' or strtolower($rec[$key]) == 'n') { + // Set a additional image variable for bolean fields + $rec['_'.$key.'_'] = (strtolower($rec[$key]) == 'y')?'x16/tick_circle.png':'x16/cross_circle.png'; + } + //* substitute value for select field + $rec[$key] = @$field['value'][$rec[$key]]; + } + } + } + //* The variable "id" contains always the index variable + $rec['id'] = $rec[$this->idx_key]; + return $rec; + } + +} +$list = new list_action; +$list->SQLOrderBy = 'ORDER BY directive_snippets.name'; +$list->onLoad(); + +//$app->listform_actions->SQLExtWhere = 'master_directive_snippets_id = 0'; +/* +$app->listform_actions->SQLOrderBy = 'ORDER BY directive_snippets.name'; +$app->listform_actions->onLoad(); +*/ ?> diff --git a/interface/web/admin/form/directive_snippets.tform.php b/interface/web/admin/form/directive_snippets.tform.php index 0c2502c6c4..4d34fefb59 100644 --- a/interface/web/admin/form/directive_snippets.tform.php +++ b/interface/web/admin/form/directive_snippets.tform.php @@ -110,7 +110,7 @@ $form["tabs"]['directive_snippets'] = array ( 'formtype' => 'CHECKBOXARRAY', 'default' => '', 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "SELECT directive_snippets_id,name FROM directive_snippets WHERE type = 'php' AND active = 'y'ORDER BY name", + 'querystring' => "SELECT directive_snippets_id,name FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name", 'keyfield' => 'directive_snippets_id', 'valuefield' => 'name' ), diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index adc55b190f..7e37550eb4 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -191,6 +191,110 @@ $form["tabs"]['server'] = array( 'width' => '40', 'maxlength' => '255' ), + 'backup_time' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => '0:00', + 'value' => array( '0:00' => '0:00h', + '0:15' => '0:15h', + '0:30' => '0:30h', + '0:45' => '0:45h', + '1:00' => '1:00h', + '1:15' => '1:15h', + '1:30' => '1:30h', + '1:45' => '1:45h', + '2:00' => '2:00h', + '2:15' => '2:15h', + '2:30' => '2:30h', + '2:45' => '2:45h', + '3:00' => '3:00h', + '3:15' => '3:15h', + '3:30' => '3:30h', + '3:45' => '3:45h', + '4:00' => '4:00h', + '4:15' => '4:15h', + '4:30' => '4:30h', + '4:45' => '4:45h', + '5:00' => '5:00h', + '5:15' => '5:15h', + '5:30' => '5:30h', + '5:45' => '5:45h', + '6:00' => '6:00h', + '6:15' => '6:15h', + '6:30' => '6:30h', + '6:45' => '6:45h', + '7:00' => '7:00h', + '7:15' => '7:15h', + '7:30' => '7:30h', + '7:45' => '7:45h', + '8:00' => '8:00h', + '8:15' => '8:15h', + '8:30' => '8:30h', + '8:45' => '8:45h', + '9:00' => '9:00h', + '9:15' => '9:15h', + '9:30' => '9:30h', + '9:45' => '9:45h', + '10:00' => '10:00h', + '10:15' => '10:15h', + '10:30' => '10:30h', + '10:45' => '10:45h', + '11:00' => '11:00h', + '11:15' => '11:15h', + '11:30' => '11:30h', + '11:45' => '11:45h', + '12:00' => '12:00h', + '12:15' => '12:15h', + '12:30' => '12:30h', + '12:45' => '12:45h', + '13:00' => '13:00h', + '13:15' => '13:15h', + '13:30' => '13:30h', + '13:45' => '13:45h', + '14:00' => '14:00h', + '14:15' => '14:15h', + '14:30' => '14:30h', + '14:45' => '14:45h', + '15:00' => '15:00h', + '15:15' => '15:15h', + '15:30' => '15:30h', + '15:45' => '15:45h', + '16:00' => '16:00h', + '16:15' => '16:15h', + '16:30' => '16:30h', + '16:45' => '16:45h', + '17:00' => '17:00h', + '17:15' => '17:15h', + '17:30' => '17:30h', + '17:45' => '17:45h', + '18:00' => '18:00h', + '18:15' => '18:15h', + '18:30' => '18:30h', + '18:45' => '18:45h', + '19:00' => '19:00h', + '19:15' => '19:15h', + '19:30' => '19:30h', + '19:45' => '19:45h', + '20:00' => '20:00h', + '20:15' => '20:15h', + '20:30' => '20:30h', + '20:45' => '20:45h', + '21:00' => '21:00h', + '21:15' => '21:15h', + '21:30' => '21:30h', + '21:45' => '21:45h', + '22:00' => '22:00h', + '22:15' => '22:15h', + '22:30' => '22:30h', + '22:45' => '22:45h', + '23:00' => '23:00h', + '23:15' => '23:15h', + '23:30' => '23:30h', + '23:45' => '23:45h', + ), + 'width' => '40', + 'maxlength' => '255' + ), 'backup_delete' => array( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', diff --git a/interface/web/admin/list/directive_snippets.list.php b/interface/web/admin/list/directive_snippets.list.php index 078cebf860..c41bcd5786 100644 --- a/interface/web/admin/list/directive_snippets.list.php +++ b/interface/web/admin/list/directive_snippets.list.php @@ -83,5 +83,14 @@ $liste["item"][] = array( 'field' => "customer_viewable", 'suffix' => "", 'width' => "", 'value' => array('y' => "
    ".$app->lng('yes_txt')."
    ", 'n' => "
    ".$app->lng('no_txt')."
    ")); + +$liste["item"][] = array( 'field' => "master_directive_snippets_id", + 'datatype' => "BOOLEAN", + 'formtype' => "SELECT", + 'op' => "IS", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array(0 => $app->lng('select_directive_snippet_txt'), 1 => $app->lng('select_master_directive_snippet_txt'))); ?> diff --git a/interface/web/admin/templates/directive_snippets_edit.htm b/interface/web/admin/templates/directive_snippets_edit.htm index 054c5bcec7..b5adc5838c 100644 --- a/interface/web/admin/templates/directive_snippets_edit.htm +++ b/interface/web/admin/templates/directive_snippets_edit.htm @@ -7,23 +7,27 @@
    -
    +
    {tmpl_var name='name'}
    +
    -
    {tmpl_var name='type'} -
    +
    -
      {tmpl_var name='variables_txt'}: {DOCROOT}, {DOCROOT_CLIENT}, {FASTCGIPASS} +
    {tmpl_var name='snippet'}
    +
     {tmpl_var name='variables_txt'}: {DOCROOT}, {FASTCGIPASS}, {PHPFALLBACKFASTCGIPASS}
    +
    {tmpl_var name='required_php_snippets'}
    +
    diff --git a/interface/web/admin/templates/directive_snippets_list.htm b/interface/web/admin/templates/directive_snippets_list.htm index bf43d42428..602c71a07c 100644 --- a/interface/web/admin/templates/directive_snippets_list.htm +++ b/interface/web/admin/templates/directive_snippets_list.htm @@ -17,6 +17,7 @@ + {tmpl_var name='search_limit'} @@ -24,6 +25,7 @@ + @@ -36,21 +38,22 @@ {tmpl_var name="name"} {tmpl_var name="type"} {tmpl_var name="customer_viewable"} + {tmpl_var name="master_directive_snippets_id"} - + - {tmpl_var name='globalsearch_noresults_text_txt'} + {tmpl_var name='globalsearch_noresults_text_txt'} - + diff --git a/interface/web/admin/templates/server_config_server_edit.htm b/interface/web/admin/templates/server_config_server_edit.htm index 5de81546dd..d8724fc527 100644 --- a/interface/web/admin/templates/server_config_server_edit.htm +++ b/interface/web/admin/templates/server_config_server_edit.htm @@ -62,6 +62,12 @@
    +
    +
    + +
    diff --git a/interface/web/client/client_del.php b/interface/web/client/client_del.php index 3e0d6bccb3..4344118b0e 100644 --- a/interface/web/client/client_del.php +++ b/interface/web/client/client_del.php @@ -162,8 +162,8 @@ class page_action extends tform_actions { } } - - + $activation_letter_filename = ISPC_ROOT_PATH.'/pdf/activation_letters/c'.$client_id.'-'.$this->dataRecord['activation_code'].'.pdf'; + if(is_file($activation_letter_filename)) unlink($activation_letter_filename); } } diff --git a/interface/web/client/client_list.php b/interface/web/client/client_list.php index 43cc028b5b..b5f2ed0186 100644 --- a/interface/web/client/client_list.php +++ b/interface/web/client/client_list.php @@ -17,10 +17,22 @@ $app->auth->check_module_permissions('client'); $app->uses('listform_actions'); -$app->listform_actions->SQLOrderBy = 'ORDER BY client.company_name, client.contact_name, client.client_id'; -$app->listform_actions->SQLExtWhere = "client.limit_client = 0"; -$app->listform_actions->SQLExtSelect = ', LOWER(client.country) as countryiso'; -$app->listform_actions->onLoad(); - - +class list_action extends listform_actions { + function onShow() { + global $app; + + if(is_file(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php')){ + $app->tpl->setVar('has_robot', true); + } + + parent::onShow(); + } + +} + +$list = new list_action; +$list->SQLOrderBy = 'ORDER BY client.company_name, client.contact_name, client.client_id'; +$list->SQLExtWhere = "client.limit_client = 0"; +$list->SQLExtSelect = ', LOWER(client.country) as countryiso'; +$list->onLoad(); ?> diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php index eab4e022e1..88d6872ceb 100644 --- a/interface/web/client/form/client.tform.php +++ b/interface/web/client/form/client.tform.php @@ -385,7 +385,9 @@ $form["tabs"]['address'] = array ( 'filters' => array( 0 => array( 'event' => 'SAVE', 'type' => 'TRIM'), 1 => array( 'event' => 'SAVE', - 'type' => 'TOUPPER') + 'type' => 'TOUPPER'), + 2 => array( 'event' => 'SAVE', + 'type' => 'NOWHITESPACE') ), ), 'company_id' => array ( @@ -456,7 +458,9 @@ $form["tabs"]['address'] = array ( 'filters' => array( 0 => array( 'event' => 'SAVE', 'type' => 'TRIM'), 1 => array( 'event' => 'SAVE', - 'type' => 'TOUPPER') + 'type' => 'TOUPPER'), + 2 => array( 'event' => 'SAVE', + 'type' => 'NOWHITESPACE') ), ), 'bank_account_swift' => array ( @@ -472,7 +476,9 @@ $form["tabs"]['address'] = array ( 'filters' => array( 0 => array( 'event' => 'SAVE', 'type' => 'TRIM'), 1 => array( 'event' => 'SAVE', - 'type' => 'TOUPPER') + 'type' => 'TOUPPER'), + 2 => array( 'event' => 'SAVE', + 'type' => 'NOWHITESPACE') ), ), 'notes' => array ( diff --git a/interface/web/client/form/reseller.tform.php b/interface/web/client/form/reseller.tform.php index a858643185..1a8b30392e 100644 --- a/interface/web/client/form/reseller.tform.php +++ b/interface/web/client/form/reseller.tform.php @@ -334,6 +334,10 @@ $form["tabs"]['address'] = array ( 1 => array ( 'type' => 'NOTEMPTY', 'errmsg'=> 'email_error_empty'), ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}$/i', + 'errmsg'=> 'email_error_isemail'), + ), 'default' => '', 'value' => '', 'separator' => '', @@ -384,7 +388,9 @@ $form["tabs"]['address'] = array ( 'filters' => array( 0 => array( 'event' => 'SAVE', 'type' => 'TRIM'), 1 => array( 'event' => 'SAVE', - 'type' => 'TOUPPER') + 'type' => 'TOUPPER'), + 2 => array( 'event' => 'SAVE', + 'type' => 'NOWHITESPACE') ), ), 'company_id' => array ( @@ -455,7 +461,9 @@ $form["tabs"]['address'] = array ( 'filters' => array( 0 => array( 'event' => 'SAVE', 'type' => 'TRIM'), 1 => array( 'event' => 'SAVE', - 'type' => 'TOUPPER') + 'type' => 'TOUPPER'), + 2 => array( 'event' => 'SAVE', + 'type' => 'NOWHITESPACE') ), ), 'bank_account_swift' => array ( @@ -471,7 +479,9 @@ $form["tabs"]['address'] = array ( 'filters' => array( 0 => array( 'event' => 'SAVE', 'type' => 'TRIM'), 1 => array( 'event' => 'SAVE', - 'type' => 'TOUPPER') + 'type' => 'TOUPPER'), + 2 => array( 'event' => 'SAVE', + 'type' => 'NOWHITESPACE') ), ), 'notes' => array ( diff --git a/interface/web/client/list/client.list.php b/interface/web/client/list/client.list.php index 40af2a7b01..ae41bef408 100644 --- a/interface/web/client/list/client.list.php +++ b/interface/web/client/list/client.list.php @@ -114,5 +114,16 @@ $liste["item"][] = array( 'field' => "country", ), 'width' => "", 'value' => ""); + +if(is_file(ISPC_WEB_PATH.'/robot/lib/robot_config.inc.php')){ + $liste["item"][] = array( 'field' => "validation_status", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('accept' => 'accept', 'review' => 'review', 'reject' => 'reject')); +} ?> diff --git a/interface/web/client/templates/clients_list.htm b/interface/web/client/templates/clients_list.htm index 27d4b7da66..67bc598a0a 100644 --- a/interface/web/client/templates/clients_list.htm +++ b/interface/web/client/templates/clients_list.htm @@ -23,6 +23,7 @@ + {tmpl_var name='search_limit'} @@ -33,6 +34,7 @@ + @@ -48,7 +50,16 @@ {tmpl_var name="username"} {tmpl_var name="city"} {tmpl_var name="country"} + {tmpl_var name="validation_status"} + +    + + +    + + + @@ -59,14 +70,14 @@ - - {tmpl_var name='globalsearch_noresults_text_txt'} + + {tmpl_var name='globalsearch_noresults_text_txt'} - + diff --git a/interface/web/mail/templates/mail_domain_edit.htm b/interface/web/mail/templates/mail_domain_edit.htm index 307b0d1531..960f4462bc 100644 --- a/interface/web/mail/templates/mail_domain_edit.htm +++ b/interface/web/mail/templates/mail_domain_edit.htm @@ -86,7 +86,7 @@ -
    +
    diff --git a/interface/web/sites/ajax_get_json.php b/interface/web/sites/ajax_get_json.php index b9b9b03d4e..c115b17c6f 100644 --- a/interface/web/sites/ajax_get_json.php +++ b/interface/web/sites/ajax_get_json.php @@ -92,7 +92,7 @@ if($type == 'getphpfastcgi'){ $sql_where .= ")"; } - if($php_type == 'php-fpm'){ + if($php_type == 'php-fpm' || ($php_type == 'hhvm' && $server_type == 'nginx')){ $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ?".$sql_where, $server_id); } elseif($php_type == 'fast-cgi'){ $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ?".$sql_where, $server_id); @@ -100,7 +100,7 @@ if($type == 'getphpfastcgi'){ $php_select = ""; if(is_array($php_records) && !empty($php_records)) { foreach( $php_records as $php_record) { - if($php_type == 'php-fpm'){ + if($php_type == 'php-fpm' || ($php_type == 'hhvm' && $server_type == 'nginx')){ $php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir']; } else { $php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir']; @@ -192,12 +192,13 @@ if($type == 'get_use_loadindicator'){ if ($type == 'getdirectivesnippet') { $server_type = 'apache'; $web_config = $app->getconf->get_server_config($server_id, 'web'); - if (!empty($web_config['server_type'])) - $server_type = $web_config['server_type']; + if (!empty($web_config['server_type'])) $server_type = $web_config['server_type']; - $snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND type = ? ORDER BY name ASC", $server_type); + $m_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND master_directive_snippets_id > 0 AND type = ? ORDER BY name ASC", $server_type); + + $snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND master_directive_snippets_id = 0 AND type = ? ORDER BY name ASC", $server_type); - $json = json_encode($snippets); + $json = json_encode(array('m_snippets' => $m_snippets, 'snippets' => $snippets)); } if($type == 'getclientssldata'){ diff --git a/interface/web/sites/database_quota_stats.php b/interface/web/sites/database_quota_stats.php index 7815faa45b..54fd4fe45a 100644 --- a/interface/web/sites/database_quota_stats.php +++ b/interface/web/sites/database_quota_stats.php @@ -19,21 +19,26 @@ $app->uses('functions'); $app->load('listform_actions'); -$tmp_rec = $app->db->queryOneRecord("SELECT data from monitor_data WHERE type = 'database_size' ORDER BY created DESC"); +$tmp_rec = $app->db->queryAllRecords("SELECT server_id, data from monitor_data WHERE type = 'database_size' ORDER BY created DESC"); $monitor_data = array(); -$tmp_array = unserialize($tmp_rec['data']); - -foreach($tmp_array as $database_name => $data) { - $db_name = $data['database_name']; - - $temp = $app->db->queryOneRecord("SELECT client.username, web_database.database_quota FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name = ?", $db_name); - - $monitor_data[$db_name]['database_name'] = $data['database_name']; - $monitor_data[$db_name]['client'] = isset($temp['username']) ? $temp['username'] : ''; - $monitor_data[$db_name]['used'] = isset($data['size']) ? $data['size'] : 0; - $monitor_data[$db_name]['quota'] = isset($temp['database_quota']) ? $temp['database_quota'] : 0; - - unset($temp); +if(is_array($tmp_rec)) { + for($i = 0; $i < count($tmp_rec); $i++) { + $tmp_array = unserialize($tmp_rec[$i]['data']); + $server_id = $tmp_rec[$i]['server_id']; + + foreach($tmp_array as $database_name => $data) { + $db_name = $data['database_name']; + + $temp = $app->db->queryOneRecord("SELECT client.username, web_database.database_quota FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name = ?", $db_name); + if(is_array($temp) && !empty($temp)) { + $monitor_data[$server_id.'.'.$db_name]['database_name'] = $data['database_name']; + $monitor_data[$server_id.'.'.$db_name]['client'] = isset($temp['username']) ? $temp['username'] : ''; + $monitor_data[$server_id.'.'.$db_name]['used'] = isset($data['size']) ? $data['size'] : 0; + $monitor_data[$server_id.'.'.$db_name]['quota'] = isset($temp['database_quota']) ? $temp['database_quota'] : 0; + } + unset($temp); + } + } } class list_action extends listform_actions { @@ -48,26 +53,36 @@ class list_action extends listform_actions { $rec['bgcolor'] = $this->DataRowColor; $database_name = $rec['database_name']; - - $rec['database'] = $monitor_data[$database_name]['database_name']; - $rec['client'] = $monitor_data[$database_name]['client']; - $rec['server_name'] = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ?", $rec['server_id'])['server_name']; - $rec['used'] = $monitor_data[$database_name]['used']; - $rec['quota'] = $monitor_data[$database_name]['quota']; - - if($rec['quota'] == 0){ - $rec['quota'] = $app->lng('unlimited'); - $rec['percentage'] = ''; + + if(!empty($monitor_data[$rec['server_id'].'.'.$database_name])){ + $rec['database'] = $monitor_data[$rec['server_id'].'.'.$database_name]['database_name']; + $rec['client'] = $monitor_data[$rec['server_id'].'.'.$database_name]['client']; + $rec['server_name'] = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ?", $rec['server_id'])['server_name']; + $rec['used'] = $monitor_data[$rec['server_id'].'.'.$database_name]['used']; + $rec['quota'] = $monitor_data[$rec['server_id'].'.'.$database_name]['quota']; + + if($rec['quota'] == 0){ + $rec['quota'] = $app->lng('unlimited'); + $rec['percentage'] = ''; + } else { + if ($rec['used'] > 0 ) $rec['percentage'] = round(100 * intval($rec['used']) / ( intval($rec['quota'])*1024*1024) ).'%'; + $rec['quota'] .= ' MB'; + } + + if ($rec['used'] > 0) $rec['used'] = $app->functions->formatBytes($rec['used']); } else { - if ($rec['used'] > 0 ) $rec['percentage'] = round(100 * intval($rec['used']) / ( intval($rec['quota'])*1024*1024) ).'%'; - $rec['quota'] .= ' MB'; + $web_database = $app->db->queryOneRecord("SELECT * FROM web_database WHERE database_id = ".$rec[$this->idx_key]); + $rec['database'] = $rec['database_name']; + $rec['server_name'] = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ?", $web_database['server_id'])['server_name']; + $sys_group = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE groupid = ".$web_database['sys_groupid']); + $client = $app->db->queryOneRecord("SELECT * FROM client WHERE client_id = ".$sys_group['client_id']); + $rec['client'] = $client['username']; + $rec['used'] = 'n/a'; + $rec['quota'] = 'n/a'; } - - if ($rec['used'] > 0) $rec['used'] = $app->functions->formatBytes($rec['used']); - $rec['id'] = $rec[$this->idx_key]; - return $rec; + return $rec; } } diff --git a/interface/web/sites/form/database.tform.php b/interface/web/sites/form/database.tform.php index da3bf9cef2..aef56f5514 100644 --- a/interface/web/sites/form/database.tform.php +++ b/interface/web/sites/form/database.tform.php @@ -90,7 +90,7 @@ $form["tabs"]['database'] = array ( 'formtype' => 'SELECT', 'default' => 'mysql', 'value' => array( - 'mongo' => 'MongoDB', + /*'mongo' => 'MongoDB',*/ 'mysql' => 'MySQL' ) ), diff --git a/interface/web/sites/form/web_vhost_domain.tform.php b/interface/web/sites/form/web_vhost_domain.tform.php index e0b3a03e2d..c447b1e851 100644 --- a/interface/web/sites/form/web_vhost_domain.tform.php +++ b/interface/web/sites/form/web_vhost_domain.tform.php @@ -48,12 +48,12 @@ if(isset($_SESSION['s']['var']['vhostdomain_type'])) { $vhostdomain_type = 'subdomain'; $form_title = "Subdomain"; $validator_function = 'sub_domain'; - $first_tab_title = "Subomain"; + $first_tab_title = "Subdomain"; } elseif($_SESSION['s']['var']['vhostdomain_type'] == 'aliasdomain') { $vhostdomain_type = 'aliasdomain'; $form_title = "Aliasdomain"; $validator_function = 'alias_domain'; - $first_tab_title = "Aliasomain"; + $first_tab_title = "Aliasdomain"; } } @@ -342,6 +342,18 @@ if($vhostdomain_type == 'domain') { 'errmsg'=> 'domain_error_autosub' ), ); + $form['tabs']['domain']['fields']['web_folder'] = array ( + 'datatype' => 'VARCHAR', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '@^((?!(.*\.\.)|(.*\./)|(.*//))[^/][\w/_\.\-]{1,100})?$@', + 'errmsg'=> 'web_folder_error_regex'), + ), + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ); } else { $form['tabs']['domain']['fields']['parent_domain_id']['datasource'] = array ( 'type' => 'SQL', @@ -352,7 +364,7 @@ if($vhostdomain_type == 'domain') { $form['tabs']['domain']['fields']['web_folder'] = array ( 'datatype' => 'VARCHAR', 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '@^((?!.*\.\.)[\w/_\.\-]{1,100})$@', + 'regex' => '@^((?!(.*\.\.)|(.*\./)|(.*//))[^/][\w/_\.\-]{1,100})?$@', 'errmsg'=> 'web_folder_error_regex'), ), 'formtype' => 'TEXT', diff --git a/interface/web/sites/templates/web_vhost_domain_admin_list.htm b/interface/web/sites/templates/web_vhost_domain_admin_list.htm index ccd16e21a6..9e12930d9a 100644 --- a/interface/web/sites/templates/web_vhost_domain_admin_list.htm +++ b/interface/web/sites/templates/web_vhost_domain_admin_list.htm @@ -17,7 +17,7 @@ - + {tmpl_var name="domain_txt"}{tmpl_var name="subdomain_txt"}{tmpl_var name="aliasdomain_txt"} @@ -26,7 +26,7 @@ - + @@ -40,7 +40,7 @@ {tmpl_var name="domain_id"} {tmpl_var name="active"} - {tmpl_var name="sys_groupid"} + {tmpl_var name="sys_groupid"} {tmpl_var name="server_id"} {tmpl_var name="parent_domain_id"} {tmpl_var name="domain"} @@ -52,13 +52,13 @@ - {tmpl_var name='globalsearch_noresults_text_txt'} + {tmpl_var name='globalsearch_noresults_text_txt'} - + diff --git a/interface/web/sites/templates/web_vhost_domain_advanced.htm b/interface/web/sites/templates/web_vhost_domain_advanced.htm index 3060caf336..04825cb0b5 100644 --- a/interface/web/sites/templates/web_vhost_domain_advanced.htm +++ b/interface/web/sites/templates/web_vhost_domain_advanced.htm @@ -34,6 +34,14 @@
    +
    + +
    +
    +
    + +
    +
    @@ -88,7 +96,7 @@
    - {tmpl_var name="available_nginx_directive_snippets_txt"}

     {tmpl_var name="nginx_directive_snippets_txt"}
    ----
     {tmpl_var name='variables_txt'}: {DOCROOT}, {FASTCGIPASS} + {tmpl_var name="available_nginx_directive_snippets_txt"}

     {tmpl_var name="nginx_directive_snippets_txt"}
    ----
     {tmpl_var name='variables_txt'}: {DOCROOT}, {FASTCGIPASS}, {PHPFALLBACKFASTCGIPASS}
    diff --git a/interface/web/sites/templates/web_vhost_domain_edit.htm b/interface/web/sites/templates/web_vhost_domain_edit.htm index 28d398bb7d..8ba2825ecb 100644 --- a/interface/web/sites/templates/web_vhost_domain_edit.htm +++ b/interface/web/sites/templates/web_vhost_domain_edit.htm @@ -74,7 +74,7 @@ {tmpl_var name='ip_address'}
    -
    + - {tmpl_var name="directive_snippets_id"} +
    + +
    +
    {tmpl_hook name="field_enable_pagespeed"}
    @@ -256,6 +261,7 @@ var serverId; var clientGroupId = jQuery('#client_group_id').val(); var serverIdDisabled = jQuery('#server_id_disabled').val(); + var serverType; if(serverIdDisabled > 0){ serverId = serverIdDisabled; } else { @@ -270,15 +276,22 @@ } adjustForm(true); reloadFastcgiPHPVersions(true); - + jQuery('#client_group_id').change(function(){ clientGroupId = $(this).val(); reloadWebIP(); reloadFastcgiPHPVersions(); }); - if(jQuery('#php').val() == 'fast-cgi' || jQuery('#php').val() == 'php-fpm'){ + if(jQuery('#php').val() == 'fast-cgi' || jQuery('#php').val() == 'php-fpm' || (jQuery('#php').val() == 'hhvm' && serverType == 'nginx')){ jQuery('.fastcgi_php_version:hidden').show(); + if(jQuery('#php').val() == 'hhvm'){ + jQuery('#fastcgi_php_version_txt').hide(); + jQuery('#fastcgi_php_fallback_version_txt').show(); + } else { + jQuery('#fastcgi_php_version_txt').show(); + jQuery('#fastcgi_php_fallback_version_txt').hide(); + } } else { jQuery('.fastcgi_php_version:visible').hide(); } @@ -286,8 +299,15 @@ jQuery('#php').change(function(){ reloadFastcgiPHPVersions(); - if(jQuery(this).val() == 'fast-cgi' || jQuery(this).val() == 'php-fpm'){ + if(jQuery(this).val() == 'fast-cgi' || jQuery(this).val() == 'php-fpm' || (jQuery(this).val() == 'hhvm' && serverType == 'nginx')){ jQuery('.fastcgi_php_version:hidden').show(); + if(jQuery(this).val() == 'hhvm'){ + jQuery('#fastcgi_php_version_txt').hide(); + jQuery('#fastcgi_php_fallback_version_txt').show(); + } else { + jQuery('#fastcgi_php_version_txt').show(); + jQuery('#fastcgi_php_fallback_version_txt').hide(); + } } else { jQuery('.fastcgi_php_version:visible').hide(); } @@ -323,6 +343,7 @@ function adjustForm(noFormChange){ jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getservertype"}, function(data) { if(data.servertype == "nginx"){ + serverType = 'nginx'; var selected = jQuery('#php').val(); jQuery('.apache').hide(); jQuery('.nginx').show(); @@ -346,6 +367,7 @@ jQuery('#php option[value="mod"]').hide(); jQuery('#php option[value="suphp"]').hide(); } else { + serverType = 'apache'; jQuery('.nginx').hide(); jQuery('.apache').show(); jQuery('#php option[value="fast-cgi"]').show(); @@ -365,16 +387,30 @@ function reloadDirectiveSnippets() { jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getdirectivesnippet"}, function(data) { - var options = ''; - for (var i = 0, len = data.length; i < len; i++) { + var options = ''; + options += ""; + for (var i = 0, len = data['m_snippets'].length; i < len; i++) { var isSelected = ''; if ($('#directive_snippets_id').val() == i + 1) { isSelected = 'selected="selected"'; } - options += ''; + options += ''; } + options += ''; + + options += ""; + for (var i = 0, len = data['snippets'].length; i < len; i++) { + var isSelected = ''; + + if ($('#directive_snippets_id').val() == i + 1) { + isSelected = 'selected="selected"'; + } + + options += ''; + } + options += ''; $('#directive_snippets_id').html(options).change(); }); @@ -434,5 +470,22 @@ ISPConfig.submitForm('pageForm','sites/web_vhost_domain_edit.php'); }); + + if($('#domain').val() == ''){ + $('#web_folder_domain').text('[DOMAIN]'); + } else { + $('#web_folder_domain').text($('#domain').val()); + } + $('#domain').bind('change keyup', function(){ + if($(this).val() == ''){ + $('#web_folder_domain').text('[DOMAIN]'); + } else { + $('#web_folder_domain').text($('#domain').val()); + } + }); + + $('#more_folder_directive_snippets').click(function(){ + $('.folder_directive_snippets:hidden:first').removeClass('hidden'); + }); diff --git a/interface/web/sites/web_vhost_domain_edit.php b/interface/web/sites/web_vhost_domain_edit.php index 6dcd7a31c0..86cc522008 100644 --- a/interface/web/sites/web_vhost_domain_edit.php +++ b/interface/web/sites/web_vhost_domain_edit.php @@ -236,14 +236,14 @@ class page_action extends tform_actions { if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm'; if($this->_vhostdomain_type == 'domain') { - if($this->dataRecord['php'] == 'php-fpm'){ + if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){ $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?)", ($this->id > 0 ? $this->dataRecord['server_id'] : $client['default_webserver']), $_SESSION['s']['user']['client_id']); } if($this->dataRecord['php'] == 'fast-cgi'){ $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?)", ($this->id > 0 ? $this->dataRecord['server_id'] : $client['default_webserver']), $_SESSION['s']['user']['client_id']); } } else { - if($this->dataRecord['php'] == 'php-fpm'){ + if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){ $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?)", $parent_domain['server_id'], $_SESSION['s']['user']['client_id']); } if($this->dataRecord['php'] == 'fast-cgi'){ @@ -253,7 +253,7 @@ class page_action extends tform_actions { $php_select = ""; if(is_array($php_records) && !empty($php_records)) { foreach( $php_records as $php_record) { - if($this->dataRecord['php'] == 'php-fpm'){ + if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){ $php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir']; } else { $php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir']; @@ -370,14 +370,14 @@ class page_action extends tform_actions { $selected_client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = ?", $selected_client_group_id); $sql_where = " AND (client_id = 0 OR client_id = ?)"; if($this->_vhostdomain_type == 'domain') { - if($this->dataRecord['php'] == 'php-fpm'){ + if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){ $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ?".$sql_where, ($this->id > 0 ? $this->dataRecord['server_id'] : $client['default_webserver']), $selected_client['client_id']); } if($this->dataRecord['php'] == 'fast-cgi') { $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ?".$sql_where, ($this->id > 0 ? $this->dataRecord['server_id'] : $client['default_webserver']), $selected_client['client_id']); } } else { - if($this->dataRecord['php'] == 'php-fpm'){ + if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){ $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?)", $parent_domain['server_id'], $_SESSION['s']['user']['client_id']); } if($this->dataRecord['php'] == 'fast-cgi') { @@ -387,7 +387,7 @@ class page_action extends tform_actions { $php_select = ""; if(is_array($php_records) && !empty($php_records)) { foreach( $php_records as $php_record) { - if($this->dataRecord['php'] == 'php-fpm'){ + if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){ $php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir']; } else { $php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir']; @@ -405,24 +405,46 @@ class page_action extends tform_actions { $sites_config = $app->getconf->get_global_config('sites'); if($sites_config['reseller_can_use_options']) { // Directive Snippets - $php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y'"); $php_directive_snippets_txt = ''; + $php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name"); if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){ + $php_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'
    '; foreach($php_directive_snippets as $php_directive_snippet){ $php_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $php_directive_snippet['snippet'] . PHP_EOL; - $php_directive_snippets_txt .= '['.$php_directive_snippet['name'].'] '; + $php_directive_snippets_txt .= '['.$php_directive_snippet['name'].']     '; + } + $php_directive_snippets_txt .= '

    '; + } + + $php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name"); + if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){ + $php_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'
    '; + foreach($php_directive_snippets as $php_directive_snippet){ + $php_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $php_directive_snippet['snippet'] . PHP_EOL; + $php_directive_snippets_txt .= '['.$php_directive_snippet['name'].']     '; } } if($php_directive_snippets_txt == '') $php_directive_snippets_txt = '------'; $app->tpl->setVar("php_directive_snippets_txt", $php_directive_snippets_txt); if($server_type == 'apache'){ - $apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y'"); $apache_directive_snippets_txt = ''; + $apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name"); if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){ + $apache_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'
    '; foreach($apache_directive_snippets as $apache_directive_snippet){ $apache_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $apache_directive_snippet['snippet'] . PHP_EOL; - $apache_directive_snippets_txt .= '['.$apache_directive_snippet['name'].'] '; + $apache_directive_snippets_txt .= '['.$apache_directive_snippet['name'].']     '; + } + $apache_directive_snippets_txt .= '

    '; + } + + $apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name"); + if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){ + $apache_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'
    '; + foreach($apache_directive_snippets as $apache_directive_snippet){ + $apache_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $apache_directive_snippet['snippet'] . PHP_EOL; + $apache_directive_snippets_txt .= '['.$apache_directive_snippet['name'].']     '; } } if($apache_directive_snippets_txt == '') $apache_directive_snippets_txt = '------'; @@ -430,24 +452,46 @@ class page_action extends tform_actions { } if($server_type == 'nginx'){ - $nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y'"); $nginx_directive_snippets_txt = ''; + $nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name"); if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){ + $nginx_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'
    '; foreach($nginx_directive_snippets as $nginx_directive_snippet){ $nginx_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $nginx_directive_snippet['snippet'] . PHP_EOL; - $nginx_directive_snippets_txt .= '['.$nginx_directive_snippet['name'].'] '; + $nginx_directive_snippets_txt .= '['.$nginx_directive_snippet['name'].']     '; + } + $nginx_directive_snippets_txt .= '

    '; + } + + $nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name"); + if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){ + $nginx_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'
    '; + foreach($nginx_directive_snippets as $nginx_directive_snippet){ + $nginx_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $nginx_directive_snippet['snippet'] . PHP_EOL; + $nginx_directive_snippets_txt .= '['.$nginx_directive_snippet['name'].']     '; } } if($nginx_directive_snippets_txt == '') $nginx_directive_snippets_txt = '------'; $app->tpl->setVar("nginx_directive_snippets_txt", $nginx_directive_snippets_txt); } - $proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y'"); $proxy_directive_snippets_txt = ''; + $proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name"); + if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){ + $proxy_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'
    '; + foreach($proxy_directive_snippets as $proxy_directive_snippet){ + $proxy_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $proxy_directive_snippet['snippet'] . PHP_EOL; + $proxy_directive_snippets_txt .= '['.$proxy_directive_snippet['name'].']     '; + } + $proxy_directive_snippets_txt .= '

    '; + } + + $proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name"); if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){ + $proxy_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'
    '; foreach($proxy_directive_snippets as $proxy_directive_snippet){ $proxy_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $proxy_directive_snippet['snippet'] . PHP_EOL; - $proxy_directive_snippets_txt .= '['.$proxy_directive_snippet['name'].'] '; + $proxy_directive_snippets_txt .= '['.$proxy_directive_snippet['name'].']     '; } } if($proxy_directive_snippets_txt == '') $proxy_directive_snippets_txt = '------'; @@ -516,6 +560,10 @@ class page_action extends tform_actions { unset($ips); if ($settings['use_domain_module'] != 'y') { + if(!isset($this->dataRecord["sys_groupid"])){ + $tmp = $app->db->queryOneRecord("SELECT sys_groupid FROM web_domain WHERE domain_id = ".$app->functions->intval($this->id)); + $this->dataRecord["sys_groupid"] = $tmp["sys_groupid"]; + } // Fill the client select field $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 ORDER BY client.company_name, client.contact_name, sys_group.name"; $clients = $app->db->queryAllRecords($sql); @@ -541,14 +589,14 @@ class page_action extends tform_actions { $selected_client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = ?", $selected_client_group_id); $sql_where = " AND (client_id = 0 OR client_id = ?)"; if($this->_vhostdomain_type == 'domain') { - if($this->dataRecord['php'] == 'php-fpm'){ + if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){ $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ?".$sql_where, $server_id, $selected_client['client_id']); } if($this->dataRecord['php'] == 'fast-cgi') { $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ?".$sql_where, $server_id, $selected_client['client_id']); } } else { - if($this->dataRecord['php'] == 'php-fpm'){ + if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){ $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ?", $parent_domain['server_id']); } if($this->dataRecord['php'] == 'fast-cgi') { @@ -558,7 +606,7 @@ class page_action extends tform_actions { $php_select = ""; if(is_array($php_records) && !empty($php_records)) { foreach( $php_records as $php_record) { - if($this->dataRecord['php'] == 'php-fpm'){ + if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){ $php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir']; } else { $php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir']; @@ -573,24 +621,46 @@ class page_action extends tform_actions { foreach($read_limits as $limit) $app->tpl->setVar($limit, ($limit == 'force_suexec' ? 'n' : 'y')); // Directive Snippets - $php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y'"); $php_directive_snippets_txt = ''; + $php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name"); if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){ + $php_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'
    '; foreach($php_directive_snippets as $php_directive_snippet){ $php_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $php_directive_snippet['snippet'] . PHP_EOL; - $php_directive_snippets_txt .= '['.$php_directive_snippet['name'].'] '; + $php_directive_snippets_txt .= '['.$php_directive_snippet['name'].']     '; + } + $php_directive_snippets_txt .= '

    '; + } + + $php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name"); + if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){ + $php_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'
    '; + foreach($php_directive_snippets as $php_directive_snippet){ + $php_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $php_directive_snippet['snippet'] . PHP_EOL; + $php_directive_snippets_txt .= '['.$php_directive_snippet['name'].']     '; } } if($php_directive_snippets_txt == '') $php_directive_snippets_txt = '------'; $app->tpl->setVar("php_directive_snippets_txt", $php_directive_snippets_txt); if($server_type == 'apache'){ - $apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y'"); $apache_directive_snippets_txt = ''; + $apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name"); + if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){ + $apache_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'
    '; + foreach($apache_directive_snippets as $apache_directive_snippet){ + $apache_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $apache_directive_snippet['snippet'] . PHP_EOL; + $apache_directive_snippets_txt .= '['.$apache_directive_snippet['name'].']     '; + } + $apache_directive_snippets_txt .= '

    '; + } + + $apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name"); if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){ + $apache_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'
    '; foreach($apache_directive_snippets as $apache_directive_snippet){ $apache_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $apache_directive_snippet['snippet'] . PHP_EOL; - $apache_directive_snippets_txt .= '['.$apache_directive_snippet['name'].'] '; + $apache_directive_snippets_txt .= '['.$apache_directive_snippet['name'].']     '; } } if($apache_directive_snippets_txt == '') $apache_directive_snippets_txt = '------'; @@ -598,24 +668,46 @@ class page_action extends tform_actions { } if($server_type == 'nginx'){ - $nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y'"); $nginx_directive_snippets_txt = ''; + $nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name"); + if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){ + $nginx_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'
    '; + foreach($nginx_directive_snippets as $nginx_directive_snippet){ + $nginx_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $nginx_directive_snippet['snippet'] . PHP_EOL; + $nginx_directive_snippets_txt .= '['.$nginx_directive_snippet['name'].']     '; + } + $nginx_directive_snippets_txt .= '

    '; + } + + $nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name"); if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){ + $nginx_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'
    '; foreach($nginx_directive_snippets as $nginx_directive_snippet){ $nginx_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $nginx_directive_snippet['snippet'] . PHP_EOL; - $nginx_directive_snippets_txt .= '['.$nginx_directive_snippet['name'].'] '; + $nginx_directive_snippets_txt .= '['.$nginx_directive_snippet['name'].']     '; } } if($nginx_directive_snippets_txt == '') $nginx_directive_snippets_txt = '------'; $app->tpl->setVar("nginx_directive_snippets_txt", $nginx_directive_snippets_txt); } - $proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y'"); $proxy_directive_snippets_txt = ''; + $proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name"); + if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){ + $proxy_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'
    '; + foreach($proxy_directive_snippets as $proxy_directive_snippet){ + $proxy_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $proxy_directive_snippet['snippet'] . PHP_EOL; + $proxy_directive_snippets_txt .= '['.$proxy_directive_snippet['name'].']     '; + } + $proxy_directive_snippets_txt .= '

    '; + } + + $proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name"); if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){ + $proxy_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'
    '; foreach($proxy_directive_snippets as $proxy_directive_snippet){ $proxy_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $proxy_directive_snippet['snippet'] . PHP_EOL; - $proxy_directive_snippets_txt .= '['.$proxy_directive_snippet['name'].'] '; + $proxy_directive_snippets_txt .= '['.$proxy_directive_snippet['name'].']     '; } } if($proxy_directive_snippets_txt == '') $proxy_directive_snippets_txt = '------'; @@ -730,6 +822,96 @@ class page_action extends tform_actions { if($sys_config['use_combobox'] == 'y') { $app->tpl->setVar('use_combobox', 'y'); } + + $directive_snippets_id_select = ''; + $server_type = $app->getconf->get_server_config($server_id, 'web'); + $server_type = $server_type['server_type']; + + $m_directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND master_directive_snippets_id > 0 AND type = ? ORDER BY name ASC", $server_type); + if(is_array($m_directive_snippets) && !empty($m_directive_snippets)){ + $directive_snippets_id_select .= ''; + foreach($m_directive_snippets as $m_directive_snippet){ + $directive_snippets_id_select .= ''; + } + $directive_snippets_id_select .= ''; + } + + $directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND master_directive_snippets_id = 0 AND type = ? ORDER BY name ASC", $server_type); + if(is_array($directive_snippets) && !empty($directive_snippets)){ + $directive_snippets_id_select .= ''; + foreach($directive_snippets as $directive_snippet){ + $directive_snippets_id_select .= ''; + } + $directive_snippets_id_select .= ''; + } + $app->tpl->setVar("directive_snippets_id", $directive_snippets_id_select); + + // folder_directive_snippets + if(isset($_POST['folder_directive_snippets']) && !isset($this->dataRecord['folder_directive_snippets'])){ + $this->dataRecord['folder_directive_snippets'] = ''; + if(is_array($_POST['folder_directive_snippets']) && !empty($_POST['folder_directive_snippets'])){ + foreach($_POST['folder_directive_snippets'] as $folder_directive_snippet){ + if(trim($folder_directive_snippet['folder']) != '' && intval($folder_directive_snippet['snippets_id']) > 0) $this->dataRecord['folder_directive_snippets'] .= trim($folder_directive_snippet['folder']).':'.intval($folder_directive_snippet['snippets_id'])."\n"; + } + } + $this->dataRecord['folder_directive_snippets'] = trim($this->dataRecord['folder_directive_snippets']); + } + + $master_directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND snippet LIKE '%{FOLDER}%' AND master_directive_snippets_id > 0 AND type = ? ORDER BY name ASC", $server_type); + $c_directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND snippet LIKE '%{FOLDER}%' AND master_directive_snippets_id = 0 AND type = ? ORDER BY name ASC", $server_type); + + $folder_directive_snippets = array(); + $this->dataRecord['folder_directive_snippets'] = str_replace("\r\n", "\n", $this->dataRecord['folder_directive_snippets']); + $this->dataRecord['folder_directive_snippets'] = str_replace("\r", "\n", $this->dataRecord['folder_directive_snippets']); + $folder_directive_snippets_lines = explode("\n", trim($this->dataRecord['folder_directive_snippets'])); + for($i=0;$i sizeof($folder_directive_snippets_lines)){ + $folder_directive_snippets[$i]['folder_directive_snippets_css'] = 'hidden'; + } else { + $folder_directive_snippets[$i]['folder_directive_snippets_css'] = ''; + } + if(trim($folder_directive_snippets_lines[$i]) != ''){ + list($folder_directive_snippets[$i]['folder_directive_snippets_folder'], $selected_snippet) = explode(':', trim($folder_directive_snippets_lines[$i])); + $folder_directive_snippets[$i]['folder_directive_snippets_id'] = ''; + if(is_array($master_directive_snippets) && !empty($master_directive_snippets)){ + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + foreach($master_directive_snippets as $master_directive_snippet){ + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + } + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + } + + if(is_array($c_directive_snippets) && !empty($c_directive_snippets)){ + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + foreach($c_directive_snippets as $c_directive_snippet){ + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + } + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + } + } else { + $folder_directive_snippets[$i]['folder_directive_snippets_folder'] = ''; + $folder_directive_snippets[$i]['folder_directive_snippets_id'] = ''; + if(is_array($master_directive_snippets) && !empty($master_directive_snippets)){ + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + foreach($master_directive_snippets as $master_directive_snippet){ + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + } + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + } + + if(is_array($c_directive_snippets) && !empty($c_directive_snippets)){ + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + foreach($c_directive_snippets as $c_directive_snippet){ + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + } + $folder_directive_snippets[$i]['folder_directive_snippets_id'] .= ''; + } + } + } + $app->tpl->setLoop('folder_directive_snippets', $folder_directive_snippets); + parent::onShowEnd(); } @@ -925,7 +1107,7 @@ class page_action extends tform_actions { // restore the server ID if the user is not admin and record is edited $tmp = $app->db->queryOneRecord("SELECT server_id, `system_user`, `system_group`, `web_folder`, `cgi`, `ssi`, `perl`, `ruby`, `python`, `suexec`, `errordocs`, `subdomain`, `ssl` FROM web_domain WHERE domain_id = ?", $this->id); $this->dataRecord["server_id"] = $tmp["server_id"]; - $this->dataRecord['web_folder'] = $tmp['web_folder']; // cannot be changed! + if($this->_vhostdomain_type != 'domain') $this->dataRecord['web_folder'] = $tmp['web_folder']; // cannot be changed! $this->dataRecord['system_user'] = $tmp['system_user']; $this->dataRecord['system_group'] = $tmp['system_group']; @@ -1095,7 +1277,31 @@ class page_action extends tform_actions { unset($app->tform->formDef["tabs"]['ssl']['fields']['enable_spdy']); } if($this->dataRecord["directive_snippets_id"] < 1) $this->dataRecord["enable_pagespeed"] = 'n'; - + + //print_r($_POST['folder_directive_snippets']); + //print_r($_POST['folder_directive_snippets_id']); + if(isset($_POST['folder_directive_snippets'])){ + $this->dataRecord['folder_directive_snippets'] = ''; + if(is_array($_POST['folder_directive_snippets']) && !empty($_POST['folder_directive_snippets'])){ + $existing_directive_snippets_folders = array(); + foreach($_POST['folder_directive_snippets'] as $folder_directive_snippet){ + $folder_directive_snippet['folder'] = trim($folder_directive_snippet['folder']); + if($folder_directive_snippet['folder'] != '' && intval($folder_directive_snippet['snippets_id']) > 0){ + if(substr($folder_directive_snippet['folder'], -1) != '/') $folder_directive_snippet['folder'] .= '/'; + if(substr($folder_directive_snippet['folder'], 0, 1) == '/') $folder_directive_snippet['folder'] = substr($folder_directive_snippet['folder'], 1); + if(in_array($folder_directive_snippet['folder'], $existing_directive_snippets_folders)){ + $app->tform->errorMessage .= $app->tform->lng("config_for_folder_exists_already_txt").'
    '; + } else { + $existing_directive_snippets_folders[] = $folder_directive_snippet['folder']; + } + $this->dataRecord['folder_directive_snippets'] .= $folder_directive_snippet['folder'].':'.intval($folder_directive_snippet['snippets_id'])."\n"; + } + if(!preg_match('@^((?!(.*\.\.)|(.*\./)|(.*//))[^/][\w/_\.\-]{1,100})?$@', $folder_directive_snippet['folder'])) $app->tform->errorMessage .= $app->tform->lng("web_folder_error_regex").'
    '; + } + } + $this->dataRecord['folder_directive_snippets'] = trim($this->dataRecord['folder_directive_snippets']); + } + parent::onSubmit(); } @@ -1169,7 +1375,7 @@ class page_action extends tform_actions { $sql = "UPDATE web_domain SET sys_groupid = ?, system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ?, added_date = ?, added_by = ? WHERE domain_id = ?"; $app->db->query($sql, $this->parent_domain_record['sys_groupid'], $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $added_date, $added_by, $this->id); } - + if(isset($this->dataRecord['folder_directive_snippets'])) $app->db->query("UPDATE web_domain SET folder_directive_snippets = ? WHERE domain_id = ?", $this->dataRecord['folder_directive_snippets'], $this->id); } function onBeforeUpdate () { @@ -1221,6 +1427,12 @@ class page_action extends tform_actions { } } + + function onAfterUpdate() { + global $app, $conf; + + if(isset($this->dataRecord['folder_directive_snippets'])) $app->db->query("UPDATE web_domain SET folder_directive_snippets = ? WHERE domain_id = ?", $this->dataRecord['folder_directive_snippets'], $this->id); + } } $page = new page_action; diff --git a/interface/web/themes/default/templates/sidenav.tpl.htm b/interface/web/themes/default/templates/sidenav.tpl.htm index 6064966cdb..be82bc92f7 100644 --- a/interface/web/themes/default/templates/sidenav.tpl.htm +++ b/interface/web/themes/default/templates/sidenav.tpl.htm @@ -1,17 +1,20 @@ -
    +