From d1d772f7902fda16e4261b6aa2f5c7829c97c481 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Thu, 22 Jul 2010 06:02:38 +0000 Subject: [PATCH] - added possibility to run perl-scripts (if allowed by admin) via directory-options - for use in lighttpd you have to add "mod_cgi" to the modules-list (and maybe patch lighttpd-cron if perl is not installed in /usr/bin) --- admin_customers.php | 24 ++++++++-- customer_extras.php | 47 +++++++++++++++++-- install/froxlor.sql | 4 +- .../updates/froxlor/0.9/update_0.9.inc.php | 12 +++++ .../function.customerHasPerlEnabled.php | 42 +++++++++++++++++ lib/tables.inc.php | 2 +- lng/english.lng.php | 4 ++ lng/german.lng.php | 4 ++ .../jobs/cron_tasks.inc.http.10.apache.php | 37 ++++++++++++++- .../jobs/cron_tasks.inc.http.20.lighttpd.php | 16 +++++++ templates/admin/customers/customers_add.tpl | 4 ++ templates/admin/customers/customers_edit.tpl | 4 ++ templates/customer/extras/htaccess.tpl | 7 +-- templates/customer/extras/htaccess_add.tpl | 6 +++ templates/customer/extras/htaccess_edit.tpl | 6 +++ .../customer/extras/htaccess_htaccess.tpl | 1 + .../debian_etch/lighttpd/etc_lighttpd.conf | 1 + .../debian_lenny/lighttpd/etc_lighttpd.conf | 1 + .../gentoo/lighttpd/etc_lighttpd.conf | 1 + .../ubuntu_hardy/lighttpd/etc_lighttpd.conf | 1 + .../ubuntu_lucid/lighttpd/etc_lighttpd.conf | 1 + 21 files changed, 209 insertions(+), 16 deletions(-) create mode 100644 lib/functions/froxlor/function.customerHasPerlEnabled.php diff --git a/admin_customers.php b/admin_customers.php index 4e4c931d..f0e10cc0 100644 --- a/admin_customers.php +++ b/admin_customers.php @@ -67,7 +67,8 @@ if($page == 'customers' 'c.email_quota_used' => $lng['customer']['email_quota'] . ' (' . $lng['panel']['used'] . ')', 'c.deactivated' => $lng['admin']['deactivated'], 'c.lastlogin_succ' => $lng['admin']['lastlogin_succ'], - 'c.phpenabled' => $lng['admin']['phpenabled'] + 'c.phpenabled' => $lng['admin']['phpenabled'], + 'c.perlenabled' => $lng['admin']['perlenabled'] ); if($settings['ticket']['enabled'] == 1) @@ -423,6 +424,7 @@ if($page == 'customers' $password = validatePassword($password); $sendpassword = intval($_POST['sendpassword']); $phpenabled = intval($_POST['phpenabled']); + $perlenabled = intval($_POST['perlenabled']); $diskspace = $diskspace * 1024; $traffic = $traffic * 1024 * 1024; @@ -525,12 +527,17 @@ if($page == 'customers' $phpenabled = '1'; } + if($perlenabled != '0') + { + $perlenabled = '1'; + } + if($password == '') { $password = substr(md5(uniqid(microtime(), 1)), 12, 6); } - $result = $db->query("INSERT INTO `" . TABLE_PANEL_CUSTOMERS . "` (`adminid`, `loginname`, `password`, `name`, `firstname`, `company`, `street`, `zipcode`, `city`, `phone`, `fax`, `email`, `customernumber`, `def_language`, `documentroot`, `guid`, `diskspace`, `traffic`, `subdomains`, `emails`, `email_accounts`, `email_forwarders`, `email_quota`, `ftps`, `tickets`, `mysqls`, `standardsubdomain`, `phpenabled`, `imap`, `pop3`, `aps_packages`) VALUES ('" . (int)$userinfo['adminid'] . "', '" . $db->escape($loginname) . "', '" . md5($password) . "', '" . $db->escape($name) . "', '" . $db->escape($firstname) . "', '" . $db->escape($company) . "', '" . $db->escape($street) . "', '" . $db->escape($zipcode) . "', '" . $db->escape($city) . "', '" . $db->escape($phone) . "', '" . $db->escape($fax) . "', '" . $db->escape($email) . "', '" . $db->escape($customernumber) . "','" . $db->escape($def_language) . "', '" . $db->escape($documentroot) . "', '" . $db->escape($guid) . "', '" . $db->escape($diskspace) . "', '" . $db->escape($traffic) . "', '" . $db->escape($subdomains) . "', '" . $db->escape($emails) . "', '" . $db->escape($email_accounts) . "', '" . $db->escape($email_forwarders) . "', '" . $db->escape($email_quota) . "', '" . $db->escape($ftps) . "', '" . $db->escape($tickets) . "', '" . $db->escape($mysqls) . "', '0', '" . $db->escape($phpenabled) . "', '" . $db->escape($email_imap) . "', '" . $db->escape($email_pop3) . "', '" . (int)$number_of_aps_packages . "')"); + $result = $db->query("INSERT INTO `" . TABLE_PANEL_CUSTOMERS . "` (`adminid`, `loginname`, `password`, `name`, `firstname`, `company`, `street`, `zipcode`, `city`, `phone`, `fax`, `email`, `customernumber`, `def_language`, `documentroot`, `guid`, `diskspace`, `traffic`, `subdomains`, `emails`, `email_accounts`, `email_forwarders`, `email_quota`, `ftps`, `tickets`, `mysqls`, `standardsubdomain`, `phpenabled`, `imap`, `pop3`, `aps_packages`, `perlenabled`) VALUES ('" . (int)$userinfo['adminid'] . "', '" . $db->escape($loginname) . "', '" . md5($password) . "', '" . $db->escape($name) . "', '" . $db->escape($firstname) . "', '" . $db->escape($company) . "', '" . $db->escape($street) . "', '" . $db->escape($zipcode) . "', '" . $db->escape($city) . "', '" . $db->escape($phone) . "', '" . $db->escape($fax) . "', '" . $db->escape($email) . "', '" . $db->escape($customernumber) . "','" . $db->escape($def_language) . "', '" . $db->escape($documentroot) . "', '" . $db->escape($guid) . "', '" . $db->escape($diskspace) . "', '" . $db->escape($traffic) . "', '" . $db->escape($subdomains) . "', '" . $db->escape($emails) . "', '" . $db->escape($email_accounts) . "', '" . $db->escape($email_forwarders) . "', '" . $db->escape($email_quota) . "', '" . $db->escape($ftps) . "', '" . $db->escape($tickets) . "', '" . $db->escape($mysqls) . "', '0', '" . $db->escape($phpenabled) . "', '" . $db->escape($email_imap) . "', '" . $db->escape($email_pop3) . "', '" . (int)$number_of_aps_packages . "', '" . $db->escape($perlenabled) . "')"); $customerid = $db->insert_id(); $admin_update_query = "UPDATE `" . TABLE_PANEL_ADMINS . "` SET `customers_used` = `customers_used` + 1"; @@ -729,6 +736,7 @@ if($page == 'customers' $email_pop3 = makeyesno('email_pop3', '1', '0', '1'); $sendpassword = makeyesno('sendpassword', '1', '0', '1'); $phpenabled = makeyesno('phpenabled', '1', '0', '1'); + $perlenabled = makeyesno('perlenabled', '1', '0', '0'); eval("echo \"" . getTemplate("customers/customers_add") . "\";"); } } @@ -852,6 +860,7 @@ if($page == 'customers' $createstdsubdomain = intval($_POST['createstdsubdomain']); $deactivated = intval($_POST['deactivated']); $phpenabled = intval($_POST['phpenabled']); + $perlenabled = intval($_POST['perlenabled']); $diskspace = $diskspace * 1024; $traffic = $traffic * 1024 * 1024; @@ -956,7 +965,13 @@ if($page == 'customers' $phpenabled = '1'; } - if($phpenabled != $result['phpenabled']) + if($perlenabled != '0') + { + $perlenabled = '1'; + } + + if($phpenabled != $result['phpenabled'] + || $perlenabled != $result['perlenabled']) { inserttask('1'); } @@ -984,7 +999,7 @@ if($page == 'customers' $db->query("UPDATE `" . TABLE_MAIL_USERS . "` SET `imap`='" . (int)$email_imap . "' WHERE `customerid`='" . (int)$id . "'"); } - $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `name`='" . $db->escape($name) . "', `firstname`='" . $db->escape($firstname) . "', `company`='" . $db->escape($company) . "', `street`='" . $db->escape($street) . "', `zipcode`='" . $db->escape($zipcode) . "', `city`='" . $db->escape($city) . "', `phone`='" . $db->escape($phone) . "', `fax`='" . $db->escape($fax) . "', `email`='" . $db->escape($email) . "', `customernumber`='" . $db->escape($customernumber) . "', `def_language`='" . $db->escape($def_language) . "', `password` = '" . $password . "', `diskspace`='" . $db->escape($diskspace) . "', `traffic`='" . $db->escape($traffic) . "', `subdomains`='" . $db->escape($subdomains) . "', `emails`='" . $db->escape($emails) . "', `email_accounts` = '" . $db->escape($email_accounts) . "', `email_forwarders`='" . $db->escape($email_forwarders) . "', `ftps`='" . $db->escape($ftps) . "', `tickets`='" . $db->escape($tickets) . "', `mysqls`='" . $db->escape($mysqls) . "', `deactivated`='" . $db->escape($deactivated) . "', `phpenabled`='" . $db->escape($phpenabled) . "', `email_quota`='" . $db->escape($email_quota) . "', `imap`='" . $db->escape($email_imap) . "', `pop3`='" . $db->escape($email_pop3) . "', `aps_packages`='" . (int)$number_of_aps_packages . "' WHERE `customerid`='" . (int)$id . "'"); + $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `name`='" . $db->escape($name) . "', `firstname`='" . $db->escape($firstname) . "', `company`='" . $db->escape($company) . "', `street`='" . $db->escape($street) . "', `zipcode`='" . $db->escape($zipcode) . "', `city`='" . $db->escape($city) . "', `phone`='" . $db->escape($phone) . "', `fax`='" . $db->escape($fax) . "', `email`='" . $db->escape($email) . "', `customernumber`='" . $db->escape($customernumber) . "', `def_language`='" . $db->escape($def_language) . "', `password` = '" . $password . "', `diskspace`='" . $db->escape($diskspace) . "', `traffic`='" . $db->escape($traffic) . "', `subdomains`='" . $db->escape($subdomains) . "', `emails`='" . $db->escape($emails) . "', `email_accounts` = '" . $db->escape($email_accounts) . "', `email_forwarders`='" . $db->escape($email_forwarders) . "', `ftps`='" . $db->escape($ftps) . "', `tickets`='" . $db->escape($tickets) . "', `mysqls`='" . $db->escape($mysqls) . "', `deactivated`='" . $db->escape($deactivated) . "', `phpenabled`='" . $db->escape($phpenabled) . "', `email_quota`='" . $db->escape($email_quota) . "', `imap`='" . $db->escape($email_imap) . "', `pop3`='" . $db->escape($email_pop3) . "', `aps_packages`='" . (int)$number_of_aps_packages . "', `perlenabled`='" . $db->escape($perlenabled) . "' WHERE `customerid`='" . (int)$id . "'"); $admin_update_query = "UPDATE `" . TABLE_PANEL_ADMINS . "` SET `customers_used` = `customers_used` "; if($mysqls != '-1' @@ -1249,6 +1264,7 @@ if($page == 'customers' $createstdsubdomain = makeyesno('createstdsubdomain', '1', '0', (($result['standardsubdomain'] != '0') ? '1' : '0')); $phpenabled = makeyesno('phpenabled', '1', '0', $result['phpenabled']); + $perlenabled = makeyesno('perlenabled', '1', '0', $result['perlenabled']); $deactivated = makeyesno('deactivated', '1', '0', $result['deactivated']); $email_imap = makeyesno('email_imap', '1', '0', $result['imap']); $email_pop3 = makeyesno('email_pop3', '1', '0', $result['pop3']); diff --git a/customer_extras.php b/customer_extras.php index e1b21d5d..af426067 100644 --- a/customer_extras.php +++ b/customer_extras.php @@ -221,10 +221,11 @@ elseif($page == 'htaccess') 'options_indexes' => $lng['extras']['view_directory'], 'error404path' => $lng['extras']['error404path'], 'error403path' => $lng['extras']['error403path'], - 'error500path' => $lng['extras']['error500path'] + 'error500path' => $lng['extras']['error500path'], + 'options_cgi' => $lng['extras']['execute_perl'] ); $paging = new paging($userinfo, $db, TABLE_PANEL_HTACCESS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']); - $result = $db->query("SELECT `id`, `path`, `options_indexes`, `error404path`, `error403path`, `error500path` FROM `" . TABLE_PANEL_HTACCESS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()); + $result = $db->query("SELECT * FROM `" . TABLE_PANEL_HTACCESS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()); $paging->setEntries($db->num_rows($result)); $sortcode = $paging->getHtmlSortCode($lng); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); @@ -234,6 +235,8 @@ elseif($page == 'htaccess') $count = 0; $htaccess = ''; + $cperlenabled = customerHasPerlEnabled($userinfo['customerid']); + while($row = $db->fetch_array($result)) { if($paging->checkDisplay($i)) @@ -241,10 +244,14 @@ elseif($page == 'htaccess') if(strpos($row['path'], $userinfo['documentroot']) === 0) { $row['path'] = substr($row['path'], strlen($userinfo['documentroot'])); + // don't show nothing wehn it's the docroot, show slash + if ($row['path'] == '') { $row['path'] = '/'; } } $row['options_indexes'] = str_replace('1', $lng['panel']['yes'], $row['options_indexes']); $row['options_indexes'] = str_replace('0', $lng['panel']['no'], $row['options_indexes']); + $row['options_cgi'] = str_replace('1', $lng['panel']['yes'], $row['options_cgi']); + $row['options_cgi'] = str_replace('0', $lng['panel']['no'], $row['options_cgi']); $row = htmlentities_array($row); eval("\$htaccess.=\"" . getTemplate("extras/htaccess_htaccess") . "\";"); $count++; @@ -293,6 +300,15 @@ elseif($page == 'htaccess') standard_error('invalidpath'); } + if(isset($_POST['options_cgi'])) + { + $options_cgi = intval($_POST['options_cgi']); + } + else + { + $options_cgi = '0'; + } + if(($_POST['error404path'] === '') || (validateUrl($idna_convert->encode($_POST['error404path'])))) { @@ -333,7 +349,15 @@ elseif($page == 'htaccess') } else { - $db->query('INSERT INTO `' . TABLE_PANEL_HTACCESS . '` (`customerid`, `path`, `options_indexes`, `error404path`, `error403path`, `error500path` ) VALUES ("' . (int)$userinfo['customerid'] . '", "' . $db->escape($path) . '", "' . $db->escape($_POST['options_indexes'] == '1' ? '1' : '0') . '", "' . $db->escape($error404path) . '", "' . $db->escape($error403path) . '", "' . $db->escape($error500path) . '" )'); + $db->query('INSERT INTO `' . TABLE_PANEL_HTACCESS . '` SET + `customerid` = "'.(int)$userinfo['customerid'].'", + `path` = "'.$db->escape($path).'", + `options_indexes` = "'.$db->escape($_POST['options_indexes'] == '1' ? '1' : '0').'", + `error404path` = "'.$db->escape($error404path).'", + `error403path` = "'.$db->escape($error403path).'", + `error500path` = "'.$db->escape($error500path).'", + `options_cgi` = "'.$db->escape($options_cgi).'"'); + $log->logAction(USR_ACTION, LOG_INFO, "added htaccess for '" . $path . "'"); inserttask('1'); redirectTo($filename, Array('page' => $page, 's' => $s)); @@ -343,6 +367,8 @@ elseif($page == 'htaccess') { $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit']); $options_indexes = makeyesno('options_indexes', '1', '0', '0'); + $cperlenabled = customerHasPerlEnabled($userinfo['customerid']); + $options_cgi = makeyesno('options_cgi', '1', '0', '0'); eval("echo \"" . getTemplate("extras/htaccess_add") . "\";"); } } @@ -359,12 +385,18 @@ elseif($page == 'htaccess') && $_POST['send'] == 'send') { $option_indexes = intval($_POST['options_indexes']); + $options_cgi = isset($_POST['options_cgi']) ? intval($_POST['options_cgi']) : 0; if($option_indexes != '1') { $option_indexes = '0'; } + if($options_cgi != '1') + { + $options_cgi = '0'; + } + if(($_POST['error404path'] === '') || (validateUrl($idna_convert->encode($_POST['error404path'])))) { @@ -398,10 +430,11 @@ elseif($page == 'htaccess') if(($option_indexes != $result['options_indexes']) || ($error404path != $result['error404path']) || ($error403path != $result['error403path']) - || ($error500path != $result['error500path'])) + || ($error500path != $result['error500path']) + || ($options_cgi != $result['options_cgi'])) { inserttask('1'); - $db->query('UPDATE `' . TABLE_PANEL_HTACCESS . '` SET `options_indexes` = "' . $db->escape($option_indexes) . '", `error404path` = "' . $db->escape($error404path) . '", `error403path` = "' . $db->escape($error403path) . '", `error500path` = "' . $db->escape($error500path) . '" WHERE `customerid` = "' . (int)$userinfo['customerid'] . '" AND `id` = "' . (int)$id . '"'); + $db->query('UPDATE `' . TABLE_PANEL_HTACCESS . '` SET `options_indexes` = "' . $db->escape($option_indexes) . '", `error404path` = "' . $db->escape($error404path) . '", `error403path` = "' . $db->escape($error403path) . '", `error500path` = "' . $db->escape($error500path) . '", `options_cgi` = "' . $db->escape($options_cgi) . '" WHERE `customerid` = "' . (int)$userinfo['customerid'] . '" AND `id` = "' . (int)$id . '"'); $log->logAction(USR_ACTION, LOG_INFO, "edited htaccess for '" . str_replace($userinfo['documentroot'], '', $result['path']) . "'"); } @@ -412,12 +445,16 @@ elseif($page == 'htaccess') if(strpos($result['path'], $userinfo['documentroot']) === 0) { $result['path'] = substr($result['path'], strlen($userinfo['documentroot'])); + // don't show nothing wehn it's the docroot, show slash + if ($result['path'] == '') { $result['path'] = '/'; } } $result['error404path'] = $result['error404path']; $result['error403path'] = $result['error403path']; $result['error500path'] = $result['error500path']; $options_indexes = makeyesno('options_indexes', '1', '0', $result['options_indexes']); + $cperlenabled = customerHasPerlEnabled($userinfo['customerid']); + $options_cgi = makeyesno('options_cgi', '1', '0', $result['options_cgi']); $result = htmlentities_array($result); eval("echo \"" . getTemplate("extras/htaccess_edit") . "\";"); } diff --git a/install/froxlor.sql b/install/froxlor.sql index 140908d8..c921967f 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -227,6 +227,7 @@ CREATE TABLE `panel_customers` ( `imap` tinyint(1) NOT NULL default '1', `aps_packages` int(5) NOT NULL default '0', `aps_packages_used` int(5) NOT NULL default '0', + `perlenabled` tinyint(1) NOT NULL default '0', PRIMARY KEY (`customerid`), UNIQUE KEY `loginname` (`loginname`) ) TYPE=MyISAM ; @@ -356,6 +357,7 @@ CREATE TABLE `panel_htaccess` ( `error403path` varchar(255) NOT NULL default '', `error500path` varchar(255) NOT NULL default '', `error401path` varchar(255) NOT NULL default '', + `options_cgi` tinyint(1) NOT NULL default '0', PRIMARY KEY (`id`) ) TYPE=MyISAM ; @@ -452,7 +454,7 @@ INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) V INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (18, 'system', 'vmail_homedir', '/var/customers/mail/'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (19, 'system', 'bindconf_directory', '/etc/bind/'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (20, 'system', 'bindreload_command', '/etc/init.d/bind9 reload'); -INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (22, 'panel', 'version', '0.9.11-svn1'); +INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (22, 'panel', 'version', '0.9.11-svn2'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (23, 'system', 'hostname', 'SERVERNAME'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (24, 'login', 'maxloginattempts', '3'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (25, 'login', 'deactivatetime', '900'); diff --git a/install/updates/froxlor/0.9/update_0.9.inc.php b/install/updates/froxlor/0.9/update_0.9.inc.php index 1afb24e5..d42f3bc3 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -897,3 +897,15 @@ if(isFroxlorVersion('0.9.10')) updateToVersion('0.9.11-svn1'); } + +if(isFroxlorVersion('0.9.11-svn1')) +{ + showUpdateStep("Updating from 0.9.11-svn1 to 0.9.11-svn2", false); + + showUpdateStep("Adding perl/CGI directory fields"); + $db->query("ALTER TABLE `".TABLE_PANEL_HTACCESS."` ADD `options_cgi` tinyint(1) NOT NULL default '0' AFTER `error401path`;"); + $db->query("ALTER TABLE `".TABLE_PANEL_CUSTOMERS."` ADD `perlenabled` tinyint(1) NOT NULL default '0' AFTER `aps_packages_used`;"); + lastStepStatus(0); + + updateToVersion('0.9.11-svn2'); +} diff --git a/lib/functions/froxlor/function.customerHasPerlEnabled.php b/lib/functions/froxlor/function.customerHasPerlEnabled.php new file mode 100644 index 00000000..fc7c0cf0 --- /dev/null +++ b/lib/functions/froxlor/function.customerHasPerlEnabled.php @@ -0,0 +1,42 @@ + (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Functions + * @version $Id$ + */ + +/* + * Function customerHasPerlEnabled + * + * returns true or false whether perl is + * enabled for the given customer + * + * @param int customer-id + * + * @return boolean + */ +function customerHasPerlEnabled($cid = 0) +{ + global $db; + + if($cid > 0) + { + $result = $db->query_first("SELECT `perlenabled` FROM `".TABLE_PANEL_CUSTOMERS."` WHERE `customerid` = '".(int)$cid."'"); + if(is_array($result) + && isset($result['perlenabled']) + ) { + return ($result['perlenabled'] == '1') ? true : false; + } + } + return false; +} diff --git a/lib/tables.inc.php b/lib/tables.inc.php index cd724a5a..312d94cf 100644 --- a/lib/tables.inc.php +++ b/lib/tables.inc.php @@ -72,7 +72,7 @@ define('PACKAGE_ENABLED', 2); // VERSION INFO -$version = '0.9.11-svn1'; +$version = '0.9.11-svn2'; $dbversion = '2'; $branding = ''; diff --git a/lng/english.lng.php b/lng/english.lng.php index afcb6f25..0bb53b9e 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1443,4 +1443,8 @@ $lng['serversettings']['panel_password_regex']['title'] = 'Regular expression fo $lng['serversettings']['panel_password_regex']['description'] = 'Here you can set a regular expression for passwords-complexity.
Empty = no specific requirement
(regex help/examples)'; $lng['error']['notrequiredpasswordcomplexity'] = 'The specified password-complexity was not satisfied (regex: %s)'; +// ADDED IN FROXLOR 0.9.11-svn2 +$lng['extras']['execute_perl'] = 'Execute perl/CGI'; +$lng['admin']['perlenabled'] = 'Perl enabled'; + ?> diff --git a/lng/german.lng.php b/lng/german.lng.php index 4784f0d1..4c49c787 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1426,4 +1426,8 @@ $lng['serversettings']['panel_password_regex']['title'] = 'Regulärer Ausdru $lng['serversettings']['panel_password_regex']['description'] = 'Hier können Sie einen regulären Ausdruck für Passwort-Komplexität festlegen.
Leer = keine bestimmten Anforderungen
(RegEx Hilfe/Beispiele)'; $lng['error']['notrequiredpasswordcomplexity'] = 'Die vorgegebene Passwort-Komplexität wurde nicht erfüllt (Regex: %s)'; +// ADDED IN FROXLOR 0.9.11-svn2 +$lng['extras']['execute_perl'] = 'Perl/CGI ausführen'; +$lng['admin']['perlenabled'] = 'Perl verfügbar'; + ?> diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index b5705784..c84b0fcb 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -803,19 +803,41 @@ class apache if(is_dir($row_diroptions['path'])) { + $cperlenabled = customerHasPerlEnabled($row_diroptions['customerid']); + $this->diroptions_data[$diroptions_filename].= '' . "\n"; if(isset($row_diroptions['options_indexes']) && $row_diroptions['options_indexes'] == '1') { - $this->diroptions_data[$diroptions_filename].= ' Options +Indexes' . "\n"; + $this->diroptions_data[$diroptions_filename].= ' Options +Indexes'; + + // add perl options if enabled + if($cperlenabled + && isset($row_diroptions['options_cgi']) + && $row_diroptions['options_cgi'] == '1') + { + $this->diroptions_data[$diroptions_filename].= ' ExecCGI -MultiViews +SymLinksIfOwnerMatch'."\n"; + } else { + $this->diroptions_data[$diroptions_filename].= "\n"; + } fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options +Indexes' . "\n"); } if(isset($row_diroptions['options_indexes']) && $row_diroptions['options_indexes'] == '0') { - $this->diroptions_data[$diroptions_filename].= ' Options -Indexes' . "\n"; + $this->diroptions_data[$diroptions_filename].= ' Options -Indexes'; + + // add perl options if enabled + if($cperlenabled + && isset($row_diroptions['options_cgi']) + && $row_diroptions['options_cgi'] == '1') + { + $this->diroptions_data[$diroptions_filename].= ' ExecCGI -MultiViews +SymLinksIfOwnerMatch'."\n"; + } else { + $this->diroptions_data[$diroptions_filename].= "\n"; + } fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options -Indexes' . "\n"); } @@ -837,6 +859,17 @@ class apache $this->diroptions_data[$diroptions_filename].= ' ErrorDocument 500 ' . $row_diroptions['error500path'] . "\n"; } + if($cperlenabled + && isset($row_diroptions['options_cgi']) + && $row_diroptions['options_cgi'] == '1') + { + $this->diroptions_data[$diroptions_filename].= ' AllowOverride None' . "\n"; + $this->diroptions_data[$diroptions_filename].= ' AddHandler cgi-script .cgi .pl' . "\n"; + $this->diroptions_data[$diroptions_filename].= ' Order allow,deny' . "\n"; + $this->diroptions_data[$diroptions_filename].= ' Allow from all' . "\n"; + fwrite($this->debugHandler, ' cron_tasks: Task3 - Enabling perl execution' . "\n"); + } + if(count($row_diroptions['htpasswds']) > 0) { $htpasswd_filename = makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $row_diroptions['customerid'] . '-' . md5($row_diroptions['path']) . '.htpasswd'); diff --git a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php index 2e73e889..84689fb7 100644 --- a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php @@ -531,6 +531,22 @@ class lighttpd { $path_options = $error_string; } + + if(customerHasPerlEnabled($domain['customerid']) + && $row['options_cgi'] != '0') + { + $path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1)); + mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']); + + // We need to remove the last slash, otherwise the regex wouldn't work + $path = substr($path, 0, -1); + $path_options.= ' $HTTP["url"] =~ "^' . $path . '($|/)" {' . "\n"; + $path_options.= "\t" . 'cgi.assign = (' . "\n"; + $path_options.= "\t\t" . '".pl" => "/usr/bin/perl",' . "\n"; + $path_options.= "\t\t" . '".cgi" => "/usr/bin/perl"' . "\n"; + $path_options.= "\t" . ')' . "\n"; + $path_options.= ' }' . "\n\n"; + } } return $path_options; diff --git a/templates/admin/customers/customers_add.tpl b/templates/admin/customers/customers_add.tpl index e6ceeb6f..327d672b 100644 --- a/templates/admin/customers/customers_add.tpl +++ b/templates/admin/customers/customers_add.tpl @@ -148,6 +148,10 @@ $header {$lng['admin']['phpenabled']}? $phpenabled + + {$lng['admin']['perlenabled']}? + $perlenabled + {$lng['aps']['numberofapspackages']}: diff --git a/templates/admin/customers/customers_edit.tpl b/templates/admin/customers/customers_edit.tpl index 459ceb34..b980262a 100644 --- a/templates/admin/customers/customers_edit.tpl +++ b/templates/admin/customers/customers_edit.tpl @@ -153,6 +153,10 @@ $header {$lng['admin']['phpenabled']}? $phpenabled + + {$lng['admin']['perlenabled']}? + $perlenabled + {$lng['aps']['numberofapspackages']}: diff --git a/templates/customer/extras/htaccess.tpl b/templates/customer/extras/htaccess.tpl index 7fd785ff..2f7fb083 100644 --- a/templates/customer/extras/htaccess.tpl +++ b/templates/customer/extras/htaccess.tpl @@ -5,7 +5,7 @@ $header - + @@ -13,16 +13,17 @@ $header + $htaccess - + - +
 {$lng['menue']['extras']['pathoptions']}{$searchcode}{$searchcode}
{$lng['panel']['path']}  {$arrowcode['path']}{$lng['extras']['error404path']}  {$arrowcode['error404path']} {$lng['extras']['error403path']}  {$arrowcode['error403path']} {$lng['extras']['error500path']}  {$arrowcode['error500path']}{$lng['extras']['execute_perl']}  {$arrowcode['options_cgi']}
{$pagingcode}{$pagingcode}
{$lng['extras']['pathoptions_add']}{$lng['extras']['pathoptions_add']}
diff --git a/templates/customer/extras/htaccess_add.tpl b/templates/customer/extras/htaccess_add.tpl index 1ba88bdf..ed48db73 100644 --- a/templates/customer/extras/htaccess_add.tpl +++ b/templates/customer/extras/htaccess_add.tpl @@ -34,6 +34,12 @@ $header + + + {$lng['extras']['execute_perl']}: + $options_cgi + + diff --git a/templates/customer/extras/htaccess_edit.tpl b/templates/customer/extras/htaccess_edit.tpl index 6c4d4f39..6bc0385b 100644 --- a/templates/customer/extras/htaccess_edit.tpl +++ b/templates/customer/extras/htaccess_edit.tpl @@ -32,6 +32,12 @@ $header + + + {$lng['extras']['execute_perl']}: + $options_cgi + + diff --git a/templates/customer/extras/htaccess_htaccess.tpl b/templates/customer/extras/htaccess_htaccess.tpl index fc1c2a1f..51631bb0 100644 --- a/templates/customer/extras/htaccess_htaccess.tpl +++ b/templates/customer/extras/htaccess_htaccess.tpl @@ -4,6 +4,7 @@ {$row['error404path']} {$row['error403path']} {$row['error500path']} + {$row['options_cgi']} {$lng['panel']['edit']} {$lng['panel']['delete']} diff --git a/templates/misc/configfiles/debian_etch/lighttpd/etc_lighttpd.conf b/templates/misc/configfiles/debian_etch/lighttpd/etc_lighttpd.conf index 6ea1e80e..14e7e42f 100644 --- a/templates/misc/configfiles/debian_etch/lighttpd/etc_lighttpd.conf +++ b/templates/misc/configfiles/debian_etch/lighttpd/etc_lighttpd.conf @@ -12,6 +12,7 @@ server.modules = ( "mod_access", "mod_auth", "mod_fastcgi", + "mod_cgi", "mod_accesslog" ) diff --git a/templates/misc/configfiles/debian_lenny/lighttpd/etc_lighttpd.conf b/templates/misc/configfiles/debian_lenny/lighttpd/etc_lighttpd.conf index 6ea1e80e..14e7e42f 100644 --- a/templates/misc/configfiles/debian_lenny/lighttpd/etc_lighttpd.conf +++ b/templates/misc/configfiles/debian_lenny/lighttpd/etc_lighttpd.conf @@ -12,6 +12,7 @@ server.modules = ( "mod_access", "mod_auth", "mod_fastcgi", + "mod_cgi", "mod_accesslog" ) diff --git a/templates/misc/configfiles/gentoo/lighttpd/etc_lighttpd.conf b/templates/misc/configfiles/gentoo/lighttpd/etc_lighttpd.conf index 8f860f7c..171c1e5a 100644 --- a/templates/misc/configfiles/gentoo/lighttpd/etc_lighttpd.conf +++ b/templates/misc/configfiles/gentoo/lighttpd/etc_lighttpd.conf @@ -12,6 +12,7 @@ server.modules = ( "mod_access", "mod_auth", "mod_fastcgi", + "mod_cgi", "mod_accesslog" ) diff --git a/templates/misc/configfiles/ubuntu_hardy/lighttpd/etc_lighttpd.conf b/templates/misc/configfiles/ubuntu_hardy/lighttpd/etc_lighttpd.conf index 6ea1e80e..14e7e42f 100644 --- a/templates/misc/configfiles/ubuntu_hardy/lighttpd/etc_lighttpd.conf +++ b/templates/misc/configfiles/ubuntu_hardy/lighttpd/etc_lighttpd.conf @@ -12,6 +12,7 @@ server.modules = ( "mod_access", "mod_auth", "mod_fastcgi", + "mod_cgi", "mod_accesslog" ) diff --git a/templates/misc/configfiles/ubuntu_lucid/lighttpd/etc_lighttpd.conf b/templates/misc/configfiles/ubuntu_lucid/lighttpd/etc_lighttpd.conf index 6ea1e80e..14e7e42f 100644 --- a/templates/misc/configfiles/ubuntu_lucid/lighttpd/etc_lighttpd.conf +++ b/templates/misc/configfiles/ubuntu_lucid/lighttpd/etc_lighttpd.conf @@ -12,6 +12,7 @@ server.modules = ( "mod_access", "mod_auth", "mod_fastcgi", + "mod_cgi", "mod_accesslog" )