2010-01-27 08:54:31 +00:00
< ? php
/**
* This file is part of the Froxlor project .
* Copyright ( c ) 2003 - 2009 the SysCP Team ( see authors ) .
* Copyright ( c ) 2010 the Froxlor Team ( see authors ) .
*
* For the full copyright and license information , please view the COPYING
* file that was distributed with this source code . You can also view the
* COPYING file online at http :// files . froxlor . org / misc / COPYING . txt
*
* @ copyright ( c ) the authors
* @ author Florian Lippert < flo @ syscp . org > ( 2003 - 2009 )
* @ author Froxlor team < team @ froxlor . org > ( 2010 - )
* @ license GPLv2 http :// files . froxlor . org / misc / COPYING . txt
* @ package Panel
2011-05-04 09:59:20 +00:00
*
2010-01-27 08:54:31 +00:00
*/
define ( 'AREA' , 'admin' );
/**
* Include our init . php , which manages Sessions , Language etc .
*/
require ( " ./lib/init.php " );
if ( isset ( $_POST [ 'id' ]))
{
$id = intval ( $_POST [ 'id' ]);
}
elseif ( isset ( $_GET [ 'id' ]))
{
$id = intval ( $_GET [ 'id' ]);
}
if ( $page == 'domains'
|| $page == 'overview' )
{
// Let's see how many customers we have
$countcustomers = $db -> query_first ( " SELECT COUNT(`customerid`) as `countcustomers` FROM ` " . TABLE_PANEL_CUSTOMERS . " ` " . ( $userinfo [ 'customers_see_all' ] ? '' : " WHERE `adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ) . " " );
$countcustomers = ( int ) $countcustomers [ 'countcustomers' ];
if ( $action == '' )
{
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " viewed admin_domains " );
$fields = array (
'd.domain' => $lng [ 'domains' ][ 'domainname' ],
'c.name' => $lng [ 'customer' ][ 'name' ],
'c.firstname' => $lng [ 'customer' ][ 'firstname' ],
'c.company' => $lng [ 'customer' ][ 'company' ],
'c.loginname' => $lng [ 'login' ][ 'username' ],
'd.aliasdomain' => $lng [ 'domains' ][ 'aliasdomain' ]
);
$paging = new paging ( $userinfo , $db , TABLE_PANEL_DOMAINS , $fields , $settings [ 'panel' ][ 'paging' ], $settings [ 'panel' ][ 'natsorting' ]);
$domains = '' ;
2012-12-02 14:16:22 +00:00
$result = $db -> query ( " SELECT `d`.*, `c`.`loginname`, `c`.`name`, `c`.`firstname`, `c`.`company`, `c`.`standardsubdomain`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain` " . " FROM ` " . TABLE_PANEL_DOMAINS . " ` `d` " . " LEFT JOIN ` " . TABLE_PANEL_CUSTOMERS . " ` `c` USING(`customerid`) " . " LEFT JOIN ` " . TABLE_PANEL_DOMAINS . " ` `ad` ON `d`.`aliasdomain`=`ad`.`id` WHERE `d`.`parentdomainid`='0' " . ( $userinfo [ 'customers_see_all' ] ? '' : " AND `d`.`adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ) . " " . $paging -> getSqlWhere ( true ) . " " . $paging -> getSqlOrderBy () . " " . $paging -> getSqlLimit ());
2010-01-27 08:54:31 +00:00
$paging -> setEntries ( $db -> num_rows ( $result ));
$sortcode = $paging -> getHtmlSortCode ( $lng );
$arrowcode = $paging -> getHtmlArrowCode ( $filename . '?page=' . $page . '&s=' . $s );
$searchcode = $paging -> getHtmlSearchCode ( $lng );
$pagingcode = $paging -> getHtmlPagingCode ( $filename . '?page=' . $page . '&s=' . $s );
$domain_array = array ();
while ( $row = $db -> fetch_array ( $result ))
{
$row [ 'domain' ] = $idna_convert -> decode ( $row [ 'domain' ]);
$row [ 'aliasdomain' ] = $idna_convert -> decode ( $row [ 'aliasdomain' ]);
2012-12-02 14:16:22 +00:00
$resultips = $db -> query ( " SELECT `ips`.* FROM ` " . TABLE_DOMAINTOIP . " ` AS `dti`, ` " . TABLE_PANEL_IPSANDPORTS . " ` AS `ips` WHERE `dti`.`id_ipandports` = `ips`.`id` AND `dti`.`id_domain` = " . ( int ) $row [ 'id' ]);
$row [ 'ipandport' ] = '' ;
while ( $rowip = $db -> fetch_array ( $resultips ))
2010-01-27 08:54:31 +00:00
{
2012-12-02 14:16:22 +00:00
if ( filter_var ( $rowip [ 'ip' ], FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ))
{
$row [ 'ipandport' ] .= '[' . $rowip [ 'ip' ] . ']:' . $rowip [ 'port' ] . " \n " ;
}
else
{
$row [ 'ipandport' ] .= $rowip [ 'ip' ] . ':' . $rowip [ 'port' ] . " \n " ;
}
2010-01-27 08:54:31 +00:00
}
2012-12-02 14:16:22 +00:00
$row [ 'ipandport' ] = substr ( $row [ 'ipandport' ], 0 , - 1 );
2010-01-27 08:54:31 +00:00
if ( ! isset ( $domain_array [ $row [ 'domain' ]]))
{
$domain_array [ $row [ 'domain' ]] = $row ;
}
else
{
$domain_array [ $row [ 'domain' ]] = array_merge ( $row , $domain_array [ $row [ 'domain' ]]);
}
if ( isset ( $row [ 'aliasdomainid' ]) && $row [ 'aliasdomainid' ] != NULL && isset ( $row [ 'aliasdomain' ]) && $row [ 'aliasdomain' ] != '' )
{
if ( ! isset ( $domain_array [ $row [ 'aliasdomain' ]]))
{
$domain_array [ $row [ 'aliasdomain' ]] = array ();
}
$domain_array [ $row [ 'aliasdomain' ]][ 'domainaliasid' ] = $row [ 'id' ];
$domain_array [ $row [ 'aliasdomain' ]][ 'domainalias' ] = $row [ 'domain' ];
}
}
/**
* We need ksort / krsort here to make sure idna - domains are also sorted correctly
*/
if ( $paging -> sortfield == 'd.domain'
&& $paging -> sortorder == 'asc' )
{
ksort ( $domain_array );
}
elseif ( $paging -> sortfield == 'd.domain'
&& $paging -> sortorder == 'desc' )
{
krsort ( $domain_array );
}
$i = 0 ;
$count = 0 ;
foreach ( $domain_array as $row )
{
if ( isset ( $row [ 'domain' ]) && $row [ 'domain' ] != '' && $paging -> checkDisplay ( $i ))
{
$row [ 'customername' ] = getCorrectFullUserDetails ( $row );
$row = htmlentities_array ( $row );
2013-04-29 08:02:44 +00:00
// display a nice list of IP's
$row [ 'ipandport' ] = str_replace ( " \n " , " <br /> " , $row [ 'ipandport' ]);
2010-01-27 08:54:31 +00:00
eval ( " \$ domains.= \" " . getTemplate ( " domains/domains_domain " ) . " \" ; " );
$count ++ ;
}
$i ++ ;
}
2010-05-04 06:43:23 +00:00
$domainscount = $db -> num_rows ( $result );
2010-01-27 08:54:31 +00:00
// Display the list
eval ( " echo \" " . getTemplate ( " domains/domains " ) . " \" ; " );
}
elseif ( $action == 'delete'
&& $id != 0 )
{
$result = $db -> query_first ( " SELECT `d`.`id`, `d`.`domain`, `d`.`customerid`, `d`.`documentroot`, `d`.`isemaildomain`, `d`.`zonefile` FROM ` " . TABLE_PANEL_DOMAINS . " ` `d`, ` " . TABLE_PANEL_CUSTOMERS . " ` `c` WHERE `d`.`id`=' " . ( int ) $id . " ' AND `d`.`id` <> `c`.`standardsubdomain` " . ( $userinfo [ 'customers_see_all' ] ? '' : " AND `d`.`adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ));
$alias_check = $db -> query_first ( 'SELECT COUNT(`id`) AS `count` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `aliasdomain`=\'' . ( int ) $id . '\'' );
if ( $result [ 'domain' ] != ''
2011-02-06 09:57:31 +00:00
&& $alias_check [ 'count' ] == 0
) {
2010-01-27 08:54:31 +00:00
if ( isset ( $_POST [ 'send' ])
&& $_POST [ 'send' ] == 'send' )
{
2010-04-07 07:47:20 +00:00
/*
* check for APS packages used with this domain , #110
*/
if ( domainHasApsInstances ( $id ))
{
standard_error ( 'domains_cantdeletedomainwithapsinstances' );
}
2010-08-06 05:43:28 +00:00
// check for deletion of main-domains which are logically subdomains, #329
$rsd_sql = '' ;
$remove_subbutmain_domains = isset ( $_POST [ 'delete_userfiles' ]) ? 1 : 0 ;
if ( $remove_subbutmain_domains == 1 )
{
$rsd_sql .= ' OR `ismainbutsubto` = "' . ( int ) $id . '"' ;
}
$query = 'SELECT `id` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE (`id`="' . ( int ) $id . '" OR `parentdomainid`="' . ( int ) $id . '"' . $rsd_sql . ') AND `isemaildomain`="1"' ;
2010-01-27 08:54:31 +00:00
$subResult = $db -> query ( $query );
$idString = array ();
while ( $subRow = $db -> fetch_array ( $subResult ))
{
$idString [] = '`domainid` = "' . ( int ) $subRow [ 'id' ] . '"' ;
}
$idString = implode ( ' OR ' , $idString );
if ( $idString != '' )
{
$query = 'DELETE FROM `' . TABLE_MAIL_USERS . '` WHERE ' . $idString ;
$db -> query ( $query );
$query = 'DELETE FROM `' . TABLE_MAIL_VIRTUAL . '` WHERE ' . $idString ;
$db -> query ( $query );
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " deleted domain/s from mail-tables " );
}
2010-08-06 05:43:28 +00:00
$db -> query ( " DELETE FROM ` " . TABLE_PANEL_DOMAINS . " ` WHERE `id`=' " . ( int ) $id . " ' OR `parentdomainid`=' " . ( int ) $result [ 'id' ] . " ' " . $rsd_sql );
2010-01-27 08:54:31 +00:00
$deleted_domains = ( int ) $db -> affected_rows ();
$db -> query ( " UPDATE ` " . TABLE_PANEL_CUSTOMERS . " ` SET `subdomains_used` = `subdomains_used` - " . ( int )( $deleted_domains - 1 ) . " WHERE `customerid` = ' " . ( int ) $result [ 'customerid' ] . " ' " );
$db -> query ( " UPDATE ` " . TABLE_PANEL_ADMINS . " ` SET `domains_used` = `domains_used` - 1 WHERE `adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " );
$db -> query ( 'UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `standardsubdomain`=\'0\' WHERE `standardsubdomain`=\'' . ( int ) $result [ 'id' ] . '\' AND `customerid`=\'' . ( int ) $result [ 'customerid' ] . '\'' );
2012-12-02 14:16:22 +00:00
$db -> query ( " DELETE FROM ` " . TABLE_DOMAINTOIP . " ` WHERE `id_domain` = ' " . ( int ) $id . " ' " );
2010-07-14 06:37:08 +00:00
$db -> query ( " DELETE FROM ` " . TABLE_PANEL_DOMAINREDIRECTS . " ` WHERE `did` = ' " . ( int ) $id . " ' " );
2010-01-27 08:54:31 +00:00
$log -> logAction ( ADM_ACTION , LOG_INFO , " deleted domain/subdomains (# " . $result [ 'id' ] . " ) " );
updateCounters ();
inserttask ( '1' );
2011-12-06 14:43:34 +00:00
2013-02-25 10:18:12 +00:00
// Using nameserver, insert a task which rebuilds the server config
2013-03-29 19:10:37 +00:00
inserttask ( '4' );
2010-01-27 08:54:31 +00:00
redirectTo ( $filename , Array ( 'page' => $page , 's' => $s ));
}
2011-02-06 09:57:31 +00:00
elseif ( $alias_check [ 'count' ] > 0 ) {
standard_error ( 'domains_cantdeletedomainwithaliases' );
}
2010-01-27 08:54:31 +00:00
else
{
2010-08-06 05:43:28 +00:00
$showcheck = false ;
if ( domainHasMainSubDomains ( $id ))
{
$showcheck = true ;
}
ask_yesno_withcheckbox ( 'admin_domain_reallydelete' , 'remove_subbutmain_domains' , $filename , array ( 'id' => $id , 'page' => $page , 'action' => $action ), $idna_convert -> decode ( $result [ 'domain' ]), $showcheck );
2010-01-27 08:54:31 +00:00
}
}
}
elseif ( $action == 'add' )
{
if ( $userinfo [ 'domains_used' ] < $userinfo [ 'domains' ]
|| $userinfo [ 'domains' ] == '-1' )
{
if ( isset ( $_POST [ 'send' ])
&& $_POST [ 'send' ] == 'send' )
{
if ( $_POST [ 'domain' ] == $settings [ 'system' ][ 'hostname' ])
{
standard_error ( 'admin_domain_emailsystemhostname' );
exit ;
}
$domain = $idna_convert -> encode ( preg_replace ( Array ( '/\:(\d)+$/' , '/^https?\:\/\//' ), '' , validate ( $_POST [ 'domain' ], 'domain' )));
$subcanemaildomain = intval ( $_POST [ 'subcanemaildomain' ]);
2011-06-16 18:54:54 +00:00
2011-03-30 12:37:57 +00:00
$isemaildomain = 0 ;
if ( isset ( $_POST [ 'isemaildomain' ]))
2010-01-27 08:54:31 +00:00
$isemaildomain = intval ( $_POST [ 'isemaildomain' ]);
2011-06-16 18:54:54 +00:00
2011-03-30 12:37:57 +00:00
$email_only = 0 ;
if ( isset ( $_POST [ 'email_only' ]))
$email_only = intval ( $_POST [ 'email_only' ]);
2011-06-16 18:54:54 +00:00
2011-03-30 12:37:57 +00:00
$wwwserveralias = 0 ;
if ( isset ( $_POST [ 'wwwserveralias' ]))
$wwwserveralias = intval ( $_POST [ 'wwwserveralias' ]);
2011-06-16 18:54:54 +00:00
2011-03-30 12:37:57 +00:00
$speciallogfile = 0 ;
if ( isset ( $_POST [ 'speciallogfile' ]))
$speciallogfile = intval ( $_POST [ 'speciallogfile' ]);
2011-06-16 18:54:54 +00:00
2010-01-27 08:54:31 +00:00
$aliasdomain = intval ( $_POST [ 'alias' ]);
2010-08-06 05:43:28 +00:00
$issubof = intval ( $_POST [ 'issubof' ]);
2010-01-27 08:54:31 +00:00
$customerid = intval ( $_POST [ 'customerid' ]);
$customer = $db -> query_first ( " SELECT * FROM ` " . TABLE_PANEL_CUSTOMERS . " ` WHERE `customerid`=' " . ( int ) $customerid . " ' " . ( $userinfo [ 'customers_see_all' ] ? '' : " AND `adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ) . " " );
if ( empty ( $customer )
|| $customer [ 'customerid' ] != $customerid )
{
standard_error ( 'customerdoesntexist' );
}
if ( $userinfo [ 'customers_see_all' ] == '1' )
{
$adminid = intval ( $_POST [ 'adminid' ]);
$admin = $db -> query_first ( " SELECT * FROM ` " . TABLE_PANEL_ADMINS . " ` WHERE `adminid`=' " . ( int ) $adminid . " ' AND ( `domains_used` < `domains` OR `domains` = '-1' ) " );
if ( empty ( $admin )
|| $admin [ 'adminid' ] != $adminid )
{
standard_error ( 'admindoesntexist' );
}
}
else
{
$adminid = $userinfo [ 'adminid' ];
$admin = $userinfo ;
}
$documentroot = $customer [ 'documentroot' ];
2011-05-01 11:27:24 +00:00
$registration_date = trim ( $_POST [ 'registration_date' ]);
$registration_date = validate ( $registration_date , 'registration_date' , '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/' , '' , array ( '0000-00-00' , '0' , '' ));
2010-01-27 08:54:31 +00:00
if ( $userinfo [ 'change_serversettings' ] == '1' )
{
2013-02-28 08:31:33 +00:00
$caneditdomain = isset ( $_POST [ 'caneditdomain' ]) ? intval ( $_POST [ 'caneditdomain' ]) : 0 ;
2013-02-25 10:18:12 +00:00
$isbinddomain = '0' ;
$zonefile = '' ;
if ( $settings [ 'system' ][ 'bind_enable' ] == '1' ) {
if ( isset ( $_POST [ 'isbinddomain' ])) {
$isbinddomain = intval ( $_POST [ 'isbinddomain' ]);
}
$zonefile = validate ( $_POST [ 'zonefile' ], 'zonefile' );
}
2010-01-27 08:54:31 +00:00
if ( isset ( $_POST [ 'dkim' ]))
{
$dkim = intval ( $_POST [ 'dkim' ]);
}
else
{
$dkim = '1' ;
}
$specialsettings = validate ( str_replace ( " \r \n " , " \n " , $_POST [ 'specialsettings' ]), 'specialsettings' , '/^[^\0]*$/' );
validate ( $_POST [ 'documentroot' ], 'documentroot' );
2013-03-20 19:37:37 +00:00
// If path is empty and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
// set default path to subdomain or domain name
2010-01-27 08:54:31 +00:00
if ( isset ( $_POST [ 'documentroot' ])
2013-03-20 19:37:37 +00:00
&& ( $_POST [ 'documentroot' ] != '' ))
2010-01-27 08:54:31 +00:00
{
if ( substr ( $_POST [ 'documentroot' ], 0 , 1 ) != '/'
2013-03-20 19:37:37 +00:00
&& ! preg_match ( '/^https?\:\/\//' , $_POST [ 'documentroot' ]))
2010-01-27 08:54:31 +00:00
{
$documentroot .= '/' . $_POST [ 'documentroot' ];
}
else
{
$documentroot = $_POST [ 'documentroot' ];
}
}
2013-03-20 19:37:37 +00:00
elseif ( isset ( $_POST [ 'documentroot' ])
&& ( $_POST [ 'documentroot' ] == '' )
&& ( $settings [ 'system' ][ 'documentroot_use_default_value' ] == 1 ))
{
$documentroot = makeCorrectDir ( $customer [ 'documentroot' ] . '/' . $domain );
}
2010-01-27 08:54:31 +00:00
}
else
{
2013-02-25 10:18:12 +00:00
$isbinddomain = '0' ;
if ( $settings [ 'system' ][ 'bind_enable' ] == '1' ) {
$isbinddomain = '1' ;
}
2010-01-27 08:54:31 +00:00
$caneditdomain = '1' ;
$zonefile = '' ;
$dkim = '1' ;
$specialsettings = '' ;
}
if ( $userinfo [ 'caneditphpsettings' ] == '1'
|| $userinfo [ 'change_serversettings' ] == '1' )
{
2013-02-25 10:18:12 +00:00
$openbasedir = isset ( $_POST [ 'openbasedir' ]) ? intval ( $_POST [ 'openbasedir' ]) : 0 ;
2010-01-27 08:54:31 +00:00
2013-07-05 08:54:52 +00:00
if (( int ) $settings [ 'system' ][ 'mod_fcgid' ] == 1 || ( int ) $settings [ 'phpfpm' ][ 'enabled' ] == 1 )
2010-01-27 08:54:31 +00:00
{
$phpsettingid = ( int ) $_POST [ 'phpsettingid' ];
$phpsettingid_check = $db -> query_first ( " SELECT * FROM ` " . TABLE_PANEL_PHPCONFIGS . " ` WHERE `id` = " . ( int ) $phpsettingid );
if ( ! isset ( $phpsettingid_check [ 'id' ])
|| $phpsettingid_check [ 'id' ] == '0'
|| $phpsettingid_check [ 'id' ] != $phpsettingid )
{
standard_error ( 'phpsettingidwrong' );
}
2013-07-14 09:23:52 +00:00
if ( ( int ) $settings [ 'system' ][ 'mod_fcgid' ] == 1 ) {
$mod_fcgid_starter = validate ( $_POST [ 'mod_fcgid_starter' ], 'mod_fcgid_starter' , '/^[0-9]*$/' , '' , array ( '-1' , '' ));
$mod_fcgid_maxrequests = validate ( $_POST [ 'mod_fcgid_maxrequests' ], 'mod_fcgid_maxrequests' , '/^[0-9]*$/' , '' , array ( '-1' , '' ));
} else {
$mod_fcgid_starter = '-1' ;
$mod_fcgid_maxrequests = '-1' ;
}
2010-01-27 08:54:31 +00:00
}
else
{
2013-07-05 08:54:52 +00:00
if (( int ) $settings [ 'phpfpm' ][ 'enabled' ] == 1 ) {
$phpsettingid = $settings [ 'phpfpm' ][ 'defaultini' ];
} else {
$phpsettingid = $settings [ 'system' ][ 'mod_fcgid_defaultini' ];
}
2010-01-27 08:54:31 +00:00
$mod_fcgid_starter = '-1' ;
$mod_fcgid_maxrequests = '-1' ;
}
}
else
{
$openbasedir = '1' ;
2013-07-05 08:54:52 +00:00
if (( int ) $settings [ 'phpfpm' ][ 'enabled' ] == 1 ) {
$phpsettingid = $settings [ 'phpfpm' ][ 'defaultini' ];
} else {
$phpsettingid = $settings [ 'system' ][ 'mod_fcgid_defaultini' ];
}
2010-01-27 08:54:31 +00:00
$mod_fcgid_starter = '-1' ;
$mod_fcgid_maxrequests = '-1' ;
}
if ( $userinfo [ 'ip' ] != " -1 " )
{
$admin_ip = $db -> query_first ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `id`=' " . ( int ) $userinfo [ 'ip' ] . " ' ORDER BY `ip`, `port` ASC " );
$additional_ip_condition = ' AND `ip` = \'' . $admin_ip [ 'ip' ] . '\' ' ;
}
else
{
$additional_ip_condition = '' ;
}
2012-12-02 14:16:22 +00:00
$ipandports = array ();
2013-05-08 14:34:04 +00:00
if ( isset ( $_POST [ 'ipandport' ]) && ! is_array ( $_POST [ 'ipandport' ])) {
2012-12-02 14:16:22 +00:00
$_POST [ 'ipandport' ] = unserialize ( $_POST [ 'ipandport' ]);
}
2010-01-27 08:54:31 +00:00
2013-05-08 14:34:04 +00:00
if ( isset ( $_POST [ 'ipandport' ]) && is_array ( $_POST [ 'ipandport' ])) {
foreach ( $_POST [ 'ipandport' ] as $ipandport ) {
$ipandport = intval ( $ipandport );
$ipandport_check = $db -> query_first ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `id` = ' " . $db -> escape ( $ipandport ) . " ' " . $additional_ip_condition );
if ( ! isset ( $ipandport_check [ 'id' ])
|| $ipandport_check [ 'id' ] == '0'
|| $ipandport_check [ 'id' ] != $ipandport
) {
2012-12-02 14:16:22 +00:00
standard_error ( 'ipportdoesntexist' );
2013-05-08 14:34:04 +00:00
} else {
2012-12-02 14:16:22 +00:00
$ipandports [] = $ipandport ;
}
}
2010-01-27 08:54:31 +00:00
}
2013-05-08 14:34:04 +00:00
if ( $settings [ 'system' ][ 'use_ssl' ] == " 1 "
&& isset ( $_POST [ 'ssl_ipandport' ])
) {
2011-05-18 11:18:41 +00:00
$ssl_redirect = 0 ;
if ( isset ( $_POST [ 'ssl_redirect' ])) {
$ssl_redirect = ( int ) $_POST [ 'ssl_redirect' ];
}
2010-01-27 08:54:31 +00:00
2012-12-02 14:16:22 +00:00
$ssl_ipandports = array ();
2013-05-08 14:34:04 +00:00
if ( isset ( $_POST [ 'ssl_ipandport' ]) && ! is_array ( $_POST [ 'ssl_ipandport' ])) {
2012-12-02 14:16:22 +00:00
$_POST [ 'ssl_ipandport' ] = unserialize ( $_POST [ 'ssl_ipandport' ]);
2010-01-27 08:54:31 +00:00
}
2012-12-02 14:16:22 +00:00
// Verify SSL-Ports
if ( isset ( $_POST [ 'ssl_ipandport' ]) && is_array ( $_POST [ 'ssl_ipandport' ]))
2010-01-27 08:54:31 +00:00
{
2012-12-02 14:16:22 +00:00
foreach ( $_POST [ 'ssl_ipandport' ] as $ssl_ipandport )
{
$ssl_ipandport = intval ( $ssl_ipandport );
$ssl_ipandport_check = $db -> query_first ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `id` = ' " . $db -> escape ( $ssl_ipandport ) . " ' " . $additional_ip_condition );
if ( ! isset ( $ssl_ipandport_check [ 'id' ])
|| $ssl_ipandport_check [ 'id' ] == '0'
|| $ssl_ipandport_check [ 'id' ] != $ssl_ipandport )
{
standard_error ( 'ipportdoesntexist' );
}
else
{
$ssl_ipandports [] = $ssl_ipandport ;
}
}
2010-01-27 08:54:31 +00:00
}
2012-12-02 14:16:22 +00:00
2010-01-27 08:54:31 +00:00
}
else
{
$ssl_redirect = 0 ;
}
if ( ! preg_match ( '/^https?\:\/\//' , $documentroot ))
{
2010-05-31 08:28:12 +00:00
if ( strstr ( $documentroot , " : " ) !== FALSE )
{
standard_error ( 'pathmaynotcontaincolon' );
}
else
{
$documentroot = makeCorrectDir ( $documentroot );
}
2010-01-27 08:54:31 +00:00
}
$domain_check = $db -> query_first ( " SELECT `id`, `domain` FROM ` " . TABLE_PANEL_DOMAINS . " ` WHERE `domain` = ' " . $db -> escape ( strtolower ( $domain )) . " ' " );
$aliasdomain_check = array (
'id' => 0
);
if ( $aliasdomain != 0 )
{
2012-12-02 14:16:22 +00:00
// Overwrite given ipandports with these of the "main" domain
$ipandports = array ();
$origipresult = $db -> query ( " SELECT `id_ipandports` FROM ` " . TABLE_DOMAINTOIP . " ` WHERE `id_domain` = ' " . ( int ) $aliasdomain . " ' " );
while ( $origip = $db -> fetch_array ( $origipresult ))
{
$ipandports [] = $origip [ 'id_ipandports' ];
}
2010-04-29 07:40:55 +00:00
// also check ip/port combination to be the same, #176
2010-05-10 05:37:24 +00:00
$aliasdomain_check = $db -> query_first ( 'SELECT `d`.`id` FROM `' . TABLE_PANEL_DOMAINS . '` `d`,`' . TABLE_PANEL_CUSTOMERS . '` `c` WHERE `d`.`customerid`=\'' . ( int ) $customerid . '\' AND `d`.`aliasdomain` IS NULL AND `d`.`id`<>`c`.`standardsubdomain` AND `c`.`customerid`=\'' . ( int ) $customerid . '\' AND `d`.`id`=\'' . ( int ) $aliasdomain . '\' AND `d`.`ipandport` = \'' . ( int ) $ipandport . '\'' );
2010-01-27 08:54:31 +00:00
}
2012-12-02 14:16:22 +00:00
if ( count ( $ipandports ) == 0 )
{
standard_error ( 'noipportgiven' );
}
2010-01-27 08:54:31 +00:00
if ( $openbasedir != '1' )
{
$openbasedir = '0' ;
}
if ( $speciallogfile != '1' )
{
$speciallogfile = '0' ;
}
if ( $isbinddomain != '1' )
{
$isbinddomain = '0' ;
}
if ( $isemaildomain != '1' )
{
$isemaildomain = '0' ;
}
if ( $email_only == '1' )
{
$isemaildomain = '1' ;
}
else
{
$email_only = '0' ;
}
if ( $subcanemaildomain != '1'
&& $subcanemaildomain != '2'
&& $subcanemaildomain != '3' )
{
$subcanemaildomain = '0' ;
}
if ( $dkim != '1' )
{
$dkim = '0' ;
}
if ( $wwwserveralias != '1' )
{
$wwwserveralias = '0' ;
}
if ( $caneditdomain != '1' )
{
$caneditdomain = '0' ;
}
2011-06-16 18:54:54 +00:00
2010-08-06 05:43:28 +00:00
if ( $issubof <= '0' )
{
$issubof = '0' ;
}
2010-01-27 08:54:31 +00:00
if ( $domain == '' )
{
standard_error ( array ( 'stringisempty' , 'mydomain' ));
}
2011-04-16 13:13:43 +00:00
/* Check whether domain validation is enabled and if, validate the domain */
elseif ( $settings [ 'system' ][ 'validate_domain' ] && ! validateDomain ( $domain ))
2010-01-27 08:54:31 +00:00
{
standard_error ( array ( 'stringiswrong' , 'mydomain' ));
}
elseif ( $documentroot == '' )
{
standard_error ( array ( 'stringisempty' , 'mydocumentroot' ));
}
elseif ( $customerid == 0 )
{
standard_error ( 'adduserfirst' );
}
elseif ( strtolower ( $domain_check [ 'domain' ]) == strtolower ( $domain ))
{
standard_error ( 'domainalreadyexists' , $idna_convert -> decode ( $domain ));
}
elseif ( $aliasdomain_check [ 'id' ] != $aliasdomain )
{
standard_error ( 'domainisaliasorothercustomer' );
}
else
{
$params = array (
'page' => $page ,
'action' => $action ,
'domain' => $domain ,
'customerid' => $customerid ,
'adminid' => $adminid ,
'documentroot' => $documentroot ,
'alias' => $aliasdomain ,
'isbinddomain' => $isbinddomain ,
'isemaildomain' => $isemaildomain ,
'email_only' => $email_only ,
'subcanemaildomain' => $subcanemaildomain ,
'caneditdomain' => $caneditdomain ,
'zonefile' => $zonefile ,
'dkim' => $dkim ,
'speciallogfile' => $speciallogfile ,
'wwwserveralias' => $wwwserveralias ,
2013-05-08 14:34:04 +00:00
'ipandport' => serialize ( $ipandports ),
2010-01-27 08:54:31 +00:00
'ssl_redirect' => $ssl_redirect ,
2013-05-08 14:34:04 +00:00
'ssl_ipandport' => serialize ( $ssl_ipandports ),
2010-01-27 08:54:31 +00:00
'openbasedir' => $openbasedir ,
'phpsettingid' => $phpsettingid ,
'mod_fcgid_starter' => $mod_fcgid_starter ,
'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests ,
'specialsettings' => $specialsettings ,
2010-08-06 05:43:28 +00:00
'registration_date' => $registration_date ,
'issubof' => $issubof
2010-01-27 08:54:31 +00:00
);
$security_questions = array (
2011-06-16 18:54:54 +00:00
'reallydisablesecuritysetting' => ( $openbasedir == '0' && $userinfo [ 'change_serversettings' ] == '1' ),
2010-01-27 08:54:31 +00:00
'reallydocrootoutofcustomerroot' => ( substr ( $documentroot , 0 , strlen ( $customer [ 'documentroot' ])) != $customer [ 'documentroot' ] && ! preg_match ( '/^https?\:\/\//' , $documentroot ))
);
2010-09-20 06:07:54 +00:00
$question_nr = 1 ;
2010-01-27 08:54:31 +00:00
foreach ( $security_questions as $question_name => $question_launch )
{
if ( $question_launch !== false )
{
$params [ $question_name ] = $question_name ;
if ( ! isset ( $_POST [ $question_name ])
|| $_POST [ $question_name ] != $question_name )
{
2010-09-20 06:07:54 +00:00
ask_yesno ( 'admin_domain_' . $question_name , $filename , $params , $question_nr );
2010-01-27 08:54:31 +00:00
exit ;
}
}
2010-09-20 06:07:54 +00:00
$question_nr ++ ;
2010-01-27 08:54:31 +00:00
}
2012-12-02 14:16:22 +00:00
$db -> query ( " INSERT INTO ` " . TABLE_PANEL_DOMAINS . " ` SET
`domain` = '" . $db->escape($domain) . "' ,
`customerid` = '" . (int)$customerid . "' ,
`adminid` = '" . (int)$adminid . "' ,
`documentroot` = '" . $db->escape($documentroot) . "' ,
`aliasdomain` = " . (( $aliasdomain != 0) ? ' \ '' . $db->escape ( $aliasdomain ) . ' \ '' : 'NULL') . " ,
`zonefile` = '" . $db->escape($zonefile) . "' ,
`dkim` = '" . $db->escape($dkim) . "' ,
`wwwserveralias` = '" . $db->escape($wwwserveralias) . "' ,
`isbinddomain` = '" . $db->escape($isbinddomain) . "' ,
`isemaildomain` = '" . $db->escape($isemaildomain) . "' ,
`email_only` = '" . $db->escape($email_only) . "' ,
`subcanemaildomain` = '" . $db->escape($subcanemaildomain) . "' ,
`caneditdomain` = '" . $db->escape($caneditdomain) . "' ,
`openbasedir` = '" . $db->escape($openbasedir) . "' ,
`speciallogfile` = '" . $db->escape($speciallogfile) . "' ,
`specialsettings` = '" . $db->escape($specialsettings) . "' ,
`ssl_redirect` = '" . $ssl_redirect . "' ,
`add_date` = '" . $db->escape(time()) . "' ,
`registration_date` = '" . $db->escape($registration_date) . "' ,
`phpsettingid` = '" . (int)$phpsettingid . "' ,
`mod_fcgid_starter` = '" . (int)$mod_fcgid_starter . "' ,
`mod_fcgid_maxrequests` = '" . (int)$mod_fcgid_maxrequests . "' ,
`ismainbutsubto` = '".(int)$issubof."'
" );
2010-01-27 08:54:31 +00:00
$domainid = $db -> insert_id ();
$db -> query ( " UPDATE ` " . TABLE_PANEL_ADMINS . " ` SET `domains_used` = `domains_used` + 1 WHERE `adminid` = ' " . ( int ) $adminid . " ' " );
2012-12-02 14:16:22 +00:00
foreach ( $ipandports as $ipportid ) {
$db -> query ( " INSERT INTO ` " . TABLE_DOMAINTOIP . " ` SET
`id_domain` = '" . $domainid . "' ,
`id_ipandports` = '" . (int)$ipportid . "' ;
" );
}
foreach ( $ssl_ipandports as $ssl_ipportid ) {
$db -> query ( " INSERT INTO ` " . TABLE_DOMAINTOIP . " ` SET
`id_domain` = '" . $domainid . "' ,
`id_ipandports` = '" . (int)$ssl_ipportid . "' ;
" );
}
2010-01-27 08:54:31 +00:00
$log -> logAction ( ADM_ACTION , LOG_INFO , " added domain ' " . $domain . " ' " );
inserttask ( '1' );
2011-12-06 14:43:34 +00:00
2013-03-29 19:10:37 +00:00
// Using nameserver, insert a task which rebuilds the server config
inserttask ( '4' );
2010-01-27 08:54:31 +00:00
redirectTo ( $filename , Array ( 'page' => $page , 's' => $s ));
}
}
else
{
$customers = makeoption ( $lng [ 'panel' ][ 'please_choose' ], 0 , 0 , true );
$result_customers = $db -> query ( " SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM ` " . TABLE_PANEL_CUSTOMERS . " ` " . ( $userinfo [ 'customers_see_all' ] ? '' : " WHERE `adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ) . " ORDER BY `name` ASC " );
while ( $row_customer = $db -> fetch_array ( $result_customers ))
{
$customers .= makeoption ( getCorrectFullUserDetails ( $row_customer ) . ' (' . $row_customer [ 'loginname' ] . ')' , $row_customer [ 'customerid' ]);
}
$admins = '' ;
if ( $userinfo [ 'customers_see_all' ] == '1' )
{
$result_admins = $db -> query ( " SELECT `adminid`, `loginname`, `name` FROM ` " . TABLE_PANEL_ADMINS . " ` WHERE `domains_used` < `domains` OR `domains` = '-1' ORDER BY `name` ASC " );
while ( $row_admin = $db -> fetch_array ( $result_admins ))
{
$admins .= makeoption ( getCorrectFullUserDetails ( $row_admin ) . ' (' . $row_admin [ 'loginname' ] . ')' , $row_admin [ 'adminid' ], $userinfo [ 'adminid' ]);
}
}
if ( $userinfo [ 'ip' ] == " -1 " )
{
$result_ipsandports = $db -> query ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `ssl`='0' ORDER BY `ip`, `port` ASC " );
$result_ssl_ipsandports = $db -> query ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `ssl`='1' ORDER BY `ip`, `port` ASC " );
}
else
{
$admin_ip = $db -> query_first ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `id`=' " . ( int ) $userinfo [ 'ip' ] . " ' ORDER BY `ip`, `port` ASC " );
$result_ipsandports = $db -> query ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `ssl`='0' AND `ip`=' " . $admin_ip [ 'ip' ] . " ' ORDER BY `ip`, `port` ASC " );
$result_ssl_ipsandports = $db -> query ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `ssl`='1' AND `ip`=' " . $admin_ip [ 'ip' ] . " ' ORDER BY `ip`, `port` ASC " );
}
2012-12-02 14:16:22 +00:00
// Build array holding all IPs and Ports available to this admin
$ipsandports = array ();
2010-01-27 08:54:31 +00:00
while ( $row_ipandport = $db -> fetch_array ( $result_ipsandports ))
{
if ( filter_var ( $row_ipandport [ 'ip' ], FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ))
{
$row_ipandport [ 'ip' ] = '[' . $row_ipandport [ 'ip' ] . ']' ;
}
2012-12-02 14:16:22 +00:00
$ipsandports [] = array ( 'label' => $row_ipandport [ 'ip' ] . ':' . $row_ipandport [ 'port' ], 'value' => $row_ipandport [ 'id' ]);
2010-01-27 08:54:31 +00:00
}
2012-12-02 14:16:22 +00:00
$ssl_ipsandports = array ();
2010-01-27 08:54:31 +00:00
while ( $row_ssl_ipandport = $db -> fetch_array ( $result_ssl_ipsandports ))
{
if ( filter_var ( $row_ssl_ipandport [ 'ip' ], FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ))
{
$row_ssl_ipandport [ 'ip' ] = '[' . $row_ssl_ipandport [ 'ip' ] . ']' ;
}
2012-12-02 14:16:22 +00:00
$ssl_ipsandports [] = array ( 'label' => $row_ssl_ipandport [ 'ip' ] . ':' . $row_ssl_ipandport [ 'port' ], 'value' => $row_ssl_ipandport [ 'id' ]);
2010-01-27 08:54:31 +00:00
}
$standardsubdomains = array ();
$result_standardsubdomains = $db -> query ( 'SELECT `id` FROM `' . TABLE_PANEL_DOMAINS . '` `d`, `' . TABLE_PANEL_CUSTOMERS . '` `c` WHERE `d`.`id`=`c`.`standardsubdomain`' );
while ( $row_standardsubdomain = $db -> fetch_array ( $result_standardsubdomains ))
{
$standardsubdomains [] = $db -> escape ( $row_standardsubdomain [ 'id' ]);
}
if ( count ( $standardsubdomains ) > 0 )
{
$standardsubdomains = 'AND `d`.`id` NOT IN (' . join ( ',' , $standardsubdomains ) . ') ' ;
}
else
{
$standardsubdomains = '' ;
}
$domains = makeoption ( $lng [ 'domains' ][ 'noaliasdomain' ], 0 , NULL , true );
$result_domains = $db -> query ( " SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM ` " . TABLE_PANEL_DOMAINS . " ` `d`, ` " . TABLE_PANEL_CUSTOMERS . " ` `c` WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid`=0 " . $standardsubdomains . ( $userinfo [ 'customers_see_all' ] ? '' : " AND `d`.`adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ) . " AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC " );
while ( $row_domain = $db -> fetch_array ( $result_domains ))
{
2010-08-06 08:46:55 +00:00
$domains .= makeoption ( $idna_convert -> decode ( $row_domain [ 'domain' ]) . ' (' . $row_domain [ 'loginname' ] . ')' , $row_domain [ 'id' ]);
}
2011-06-16 18:54:54 +00:00
2010-08-06 08:46:55 +00:00
$subtodomains = makeoption ( $lng [ 'domains' ][ 'nosubtomaindomain' ], 0 , NULL , true );
$result_domains = $db -> query ( " SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM ` " . TABLE_PANEL_DOMAINS . " ` `d`, ` " . TABLE_PANEL_CUSTOMERS . " ` `c` WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid`=0 AND `d`.`ismainbutsubto`=0 " . $standardsubdomains . ( $userinfo [ 'customers_see_all' ] ? '' : " AND `d`.`adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ) . " AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC " );
while ( $row_domain = $db -> fetch_array ( $result_domains ))
{
$subtodomains .= makeoption ( $idna_convert -> decode ( $row_domain [ 'domain' ]) . ' (' . $row_domain [ 'loginname' ] . ')' , $row_domain [ 'id' ]);
2010-01-27 08:54:31 +00:00
}
$phpconfigs = '' ;
$configs = $db -> query ( " SELECT * FROM ` " . TABLE_PANEL_PHPCONFIGS . " ` " );
while ( $row = $db -> fetch_array ( $configs ))
{
2013-07-05 08:54:52 +00:00
if (( int ) $settings [ 'phpfpm' ][ 'enabled' ] == 1 ) {
$phpconfigs .= makeoption ( $row [ 'description' ], $row [ 'id' ], $settings [ 'phpfpm' ][ 'defaultini' ], true , true );
} else {
$phpconfigs .= makeoption ( $row [ 'description' ], $row [ 'id' ], $settings [ 'system' ][ 'mod_fcgid_defaultini' ], true , true );
}
2010-01-27 08:54:31 +00:00
}
$subcanemaildomain = makeoption ( $lng [ 'admin' ][ 'subcanemaildomain' ][ 'never' ], '0' , '0' , true , true ) . makeoption ( $lng [ 'admin' ][ 'subcanemaildomain' ][ 'choosableno' ], '1' , '0' , true , true ) . makeoption ( $lng [ 'admin' ][ 'subcanemaildomain' ][ 'choosableyes' ], '2' , '0' , true , true ) . makeoption ( $lng [ 'admin' ][ 'subcanemaildomain' ][ 'always' ], '3' , '0' , true , true );
$add_date = date ( 'Y-m-d' );
2011-02-08 11:53:24 +00:00
$domain_add_data = include_once dirname ( __FILE__ ) . '/lib/formfields/admin/domains/formfield.domains_add.php' ;
$domain_add_form = htmlform :: genHTMLForm ( $domain_add_data );
$title = $domain_add_data [ 'domain_add' ][ 'title' ];
$image = $domain_add_data [ 'domain_add' ][ 'image' ];
2010-01-27 08:54:31 +00:00
eval ( " echo \" " . getTemplate ( " domains/domains_add " ) . " \" ; " );
}
}
}
elseif ( $action == 'edit'
&& $id != 0 )
{
2011-06-16 18:54:54 +00:00
$result = $db -> query_first ( " SELECT `d`.*, `c`.`customerid` FROM ` " . TABLE_PANEL_DOMAINS . " ` `d`
LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING ( `customerid` )
WHERE `d` . `parentdomainid` = '0'
AND `d` . `id` = '" . (int)$id . "' "
2010-02-21 21:09:48 +00:00
. ( $userinfo [ 'customers_see_all' ] ? '' : " AND `d`.`adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ));
2010-01-27 08:54:31 +00:00
if ( $result [ 'domain' ] != '' )
{
$subdomains = $db -> query_first ( 'SELECT COUNT(`id`) AS count FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `parentdomainid`=\'' . ( int ) $result [ 'id' ] . '\'' );
$subdomains = $subdomains [ 'count' ];
$alias_check = $db -> query_first ( 'SELECT COUNT(`id`) AS count FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `aliasdomain`=\'' . ( int ) $result [ 'id' ] . '\'' );
$alias_check = $alias_check [ 'count' ];
$domain_emails_result = $db -> query ( 'SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders` FROM `' . TABLE_MAIL_VIRTUAL . '` WHERE `customerid` = "' . ( int ) $result [ 'customerid' ] . '" AND `domainid` = "' . ( int ) $result [ 'id' ] . '" ' );
$emails = $db -> num_rows ( $domain_emails_result );
$email_forwarders = 0 ;
$email_accounts = 0 ;
while ( $domain_emails_row = $db -> fetch_array ( $domain_emails_result ))
{
if ( $domain_emails_row [ 'destination' ] != '' )
{
$domain_emails_row [ 'destination' ] = explode ( ' ' , makeCorrectDestination ( $domain_emails_row [ 'destination' ]));
$email_forwarders += count ( $domain_emails_row [ 'destination' ]);
if ( in_array ( $domain_emails_row [ 'email_full' ], $domain_emails_row [ 'destination' ]))
{
$email_forwarders -= 1 ;
$email_accounts ++ ;
}
}
}
2012-12-02 14:16:22 +00:00
$ipsresult = $db -> query ( " SELECT `id_ipandports` FROM ` " . TABLE_DOMAINTOIP . " ` WHERE `id_domain` = ' " . ( int ) $result [ 'id' ] . " ' " );
$usedips = array ();
while ( $ipsresultrow = $db -> fetch_array ( $ipsresult ))
{
$usedips [] = $ipsresultrow [ 'id_ipandports' ];
}
2010-01-27 08:54:31 +00:00
if ( isset ( $_POST [ 'send' ])
&& $_POST [ 'send' ] == 'send' )
{
$customer = $customer_old = $db -> query_first ( " SELECT * FROM " . TABLE_PANEL_CUSTOMERS . " WHERE `customerid`=' " . ( int ) $result [ 'customerid' ] . " ' " );
if ( isset ( $_POST [ 'customerid' ])
&& ( $customerid = intval ( $_POST [ 'customerid' ])) != $result [ 'customerid' ]
&& $settings [ 'panel' ][ 'allow_domain_change_customer' ] == '1' )
{
$customer = $db -> query_first ( " SELECT * FROM ` " . TABLE_PANEL_CUSTOMERS . " ` WHERE `customerid`=' " . ( int ) $customerid . " ' AND (`subdomains_used` + " . ( int ) $subdomains . " <= `subdomains` OR `subdomains` = '-1' ) AND (`emails_used` + " . ( int ) $emails . " <= `emails` OR `emails` = '-1' ) AND (`email_forwarders_used` + " . ( int ) $email_forwarders . " <= `email_forwarders` OR `email_forwarders` = '-1' ) AND (`email_accounts_used` + " . ( int ) $email_accounts . " <= `email_accounts` OR `email_accounts` = '-1' ) " . ( $userinfo [ 'customers_see_all' ] ? '' : " AND `adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ) . " " );
if ( empty ( $customer )
|| $customer [ 'customerid' ] != $customerid )
{
standard_error ( 'customerdoesntexist' );
}
}
else
{
$customerid = $result [ 'customerid' ];
}
$admin = $admin_old = $db -> query_first ( " SELECT * FROM ` " . TABLE_PANEL_ADMINS . " ` WHERE `adminid`=' " . ( int ) $result [ 'adminid' ] . " ' " );
if ( $userinfo [ 'customers_see_all' ] == '1' )
{
if ( isset ( $_POST [ 'adminid' ])
&& ( $adminid = intval ( $_POST [ 'adminid' ])) != $result [ 'adminid' ]
&& $settings [ 'panel' ][ 'allow_domain_change_admin' ] == '1' )
{
$admin = $db -> query_first ( " SELECT * FROM ` " . TABLE_PANEL_ADMINS . " ` WHERE `adminid`=' " . ( int ) $adminid . " ' AND ( `domains_used` < `domains` OR `domains` = '-1' ) " );
if ( empty ( $admin )
|| $admin [ 'adminid' ] != $adminid )
{
standard_error ( 'admindoesntexist' );
}
}
else
{
$adminid = $result [ 'adminid' ];
}
}
else
{
$adminid = $result [ 'adminid' ];
}
$aliasdomain = intval ( $_POST [ 'alias' ]);
2010-08-06 05:43:28 +00:00
$issubof = intval ( $_POST [ 'issubof' ]);
2010-01-27 08:54:31 +00:00
$subcanemaildomain = intval ( $_POST [ 'subcanemaildomain' ]);
2013-02-28 08:31:33 +00:00
$caneditdomain = isset ( $_POST [ 'caneditdomain' ]) ? intval ( $_POST [ 'caneditdomain' ]) : 0 ;
2011-05-01 11:27:24 +00:00
$registration_date = trim ( $_POST [ 'registration_date' ]);
$registration_date = validate ( $registration_date , 'registration_date' , '/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/' , '' , array ( '0000-00-00' , '0' , '' ));
2010-01-27 08:54:31 +00:00
2011-03-30 12:37:57 +00:00
$isemaildomain = 0 ;
if ( isset ( $_POST [ 'isemaildomain' ]))
$isemaildomain = intval ( $_POST [ 'isemaildomain' ]);
2011-06-16 18:54:54 +00:00
2011-03-30 12:37:57 +00:00
$email_only = 0 ;
if ( isset ( $_POST [ 'email_only' ]))
$email_only = intval ( $_POST [ 'email_only' ]);
2011-06-16 18:54:54 +00:00
2011-03-30 12:37:57 +00:00
$wwwserveralias = 0 ;
if ( isset ( $_POST [ 'wwwserveralias' ]))
$wwwserveralias = intval ( $_POST [ 'wwwserveralias' ]);
2011-06-16 18:54:54 +00:00
2012-03-08 14:11:25 +00:00
$speciallogfile = 0 ;
if ( isset ( $_POST [ 'speciallogfile' ]))
$speciallogfile = intval ( $_POST [ 'speciallogfile' ]);
2010-01-27 08:54:31 +00:00
if ( $userinfo [ 'change_serversettings' ] == '1' )
{
2013-02-25 10:18:12 +00:00
$isbinddomain = $result [ 'isbinddomain' ];
$zonefile = $result [ 'zonefile' ];
if ( $settings [ 'system' ][ 'bind_enable' ] == '1' ) {
if ( isset ( $_POST [ 'isbinddomain' ])) {
2013-04-19 13:32:10 +00:00
$isbinddomain = ( int ) $_POST [ 'isbinddomain' ];
2013-09-18 21:29:41 +00:00
} else {
2013-09-19 06:04:25 +00:00
$isbinddomain = 0 ;
2013-02-25 10:18:12 +00:00
}
$zonefile = validate ( $_POST [ 'zonefile' ], 'zonefile' );
}
2010-01-27 08:54:31 +00:00
if ( $settings [ 'dkim' ][ 'use_dkim' ] == '1' )
{
2012-06-25 07:27:39 +00:00
$dkim = isset ( $_POST [ 'dkim' ]) ? 1 : 0 ;
2010-01-27 08:54:31 +00:00
}
else
{
$dkim = $result [ 'dkim' ];
}
$specialsettings = validate ( str_replace ( " \r \n " , " \n " , $_POST [ 'specialsettings' ]), 'specialsettings' , '/^[^\0]*$/' );
$documentroot = validate ( $_POST [ 'documentroot' ], 'documentroot' );
if ( $documentroot == '' )
{
2013-03-20 19:37:37 +00:00
// If path is empty and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
// set default path to subdomain or domain name
if ( $settings [ 'system' ][ 'documentroot_use_default_value' ] == 1 )
{
$documentroot = makeCorrectDir ( $customer [ 'documentroot' ] . '/' . $result [ 'domain' ]);
}
else
{
$documentroot = $customer [ 'documentroot' ];
}
2010-01-27 08:54:31 +00:00
}
2010-05-12 06:52:11 +00:00
2010-05-31 08:28:12 +00:00
if ( ! preg_match ( '/^https?\:\/\//' , $documentroot )
&& strstr ( $documentroot , " : " ) !== FALSE
) {
2010-05-12 06:52:11 +00:00
standard_error ( 'pathmaynotcontaincolon' );
}
2010-01-27 08:54:31 +00:00
}
else
{
$isbinddomain = $result [ 'isbinddomain' ];
$zonefile = $result [ 'zonefile' ];
$dkim = $result [ 'dkim' ];
$specialsettings = $result [ 'specialsettings' ];
$documentroot = $result [ 'documentroot' ];
}
2013-09-23 07:35:33 +00:00
$speciallogverified = ( isset ( $_POST [ 'speciallogverified' ]) ? ( int ) $_POST [ 'speciallogverified' ] : 0 );
2010-01-27 08:54:31 +00:00
if ( $userinfo [ 'caneditphpsettings' ] == '1'
|| $userinfo [ 'change_serversettings' ] == '1' )
{
2013-02-25 10:18:12 +00:00
$openbasedir = isset ( $_POST [ 'openbasedir' ]) ? intval ( $_POST [ 'openbasedir' ]) : 0 ;
2010-01-27 08:54:31 +00:00
2013-07-14 09:23:52 +00:00
if (( int ) $settings [ 'system' ][ 'mod_fcgid' ] == 1 || ( int ) $settings [ 'phpfpm' ][ 'enabled' ] == 1 )
2010-01-27 08:54:31 +00:00
{
$phpsettingid = ( int ) $_POST [ 'phpsettingid' ];
$phpsettingid_check = $db -> query_first ( " SELECT * FROM ` " . TABLE_PANEL_PHPCONFIGS . " ` WHERE `id` = " . ( int ) $phpsettingid );
if ( ! isset ( $phpsettingid_check [ 'id' ])
|| $phpsettingid_check [ 'id' ] == '0'
|| $phpsettingid_check [ 'id' ] != $phpsettingid )
{
standard_error ( 'phpsettingidwrong' );
}
2013-07-14 09:23:52 +00:00
if (( int ) $settings [ 'system' ][ 'mod_fcgid' ] == 1 ) {
$mod_fcgid_starter = validate ( $_POST [ 'mod_fcgid_starter' ], 'mod_fcgid_starter' , '/^[0-9]*$/' , '' , array ( '-1' , '' ));
$mod_fcgid_maxrequests = validate ( $_POST [ 'mod_fcgid_maxrequests' ], 'mod_fcgid_maxrequests' , '/^[0-9]*$/' , '' , array ( '-1' , '' ));
} else {
$mod_fcgid_starter = $result [ 'mod_fcgid_starter' ];
$mod_fcgid_maxrequests = $result [ 'mod_fcgid_maxrequests' ];
}
2010-01-27 08:54:31 +00:00
}
else
{
$phpsettingid = $result [ 'phpsettingid' ];
$mod_fcgid_starter = $result [ 'mod_fcgid_starter' ];
$mod_fcgid_maxrequests = $result [ 'mod_fcgid_maxrequests' ];
}
}
else
{
$openbasedir = $result [ 'openbasedir' ];
$phpsettingid = $result [ 'phpsettingid' ];
$mod_fcgid_starter = $result [ 'mod_fcgid_starter' ];
$mod_fcgid_maxrequests = $result [ 'mod_fcgid_maxrequests' ];
}
2013-04-29 08:02:44 +00:00
$ipandports = array ();
if ( isset ( $_POST [ 'ipandport' ]) && ! is_array ( $_POST [ 'ipandport' ])) {
2012-12-02 14:16:22 +00:00
$_POST [ 'ipandport' ] = unserialize ( $_POST [ 'ipandport' ]);
}
2013-04-29 08:02:44 +00:00
if ( isset ( $_POST [ 'ipandport' ]) && is_array ( $_POST [ 'ipandport' ])) {
foreach ( $_POST [ 'ipandport' ] as $ipandport ) {
2013-09-27 14:28:33 +00:00
if ( trim ( $ipandport ) == " " ) continue ;
2013-04-29 08:02:44 +00:00
$ipandport = intval ( $ipandport );
2013-09-27 14:28:33 +00:00
$ipandport_check = $db -> query_first ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `id` = ' " . $db -> escape ( $ipandport ) . " ' " );
2013-04-29 08:02:44 +00:00
if ( ! isset ( $ipandport_check [ 'id' ])
|| $ipandport_check [ 'id' ] == '0'
|| $ipandport_check [ 'id' ] != $ipandport
) {
standard_error ( 'ipportdoesntexist' );
} else {
$ipandports [] = $ipandport ;
}
}
2010-01-27 08:54:31 +00:00
}
if ( $settings [ 'system' ][ 'use_ssl' ] == " 1 "
2012-12-02 14:16:22 +00:00
&& isset ( $_POST [ 'ssl_ipandport' ]))
2010-01-27 08:54:31 +00:00
{
2012-06-25 07:27:39 +00:00
$ssl = 1 ; // if ssl is set and != 0, it can only be 1
2011-05-18 11:18:41 +00:00
$ssl_redirect = 0 ;
if ( isset ( $_POST [ 'ssl_redirect' ])) {
$ssl_redirect = ( int ) $_POST [ 'ssl_redirect' ];
}
2010-01-27 08:54:31 +00:00
2012-12-02 14:16:22 +00:00
$ssl_ipandports = array ();
2013-04-29 08:02:44 +00:00
if ( isset ( $_POST [ 'ssl_ipandport' ]) && ! is_array ( $_POST [ 'ssl_ipandport' ])) {
2012-12-02 14:16:22 +00:00
$_POST [ 'ssl_ipandport' ] = unserialize ( $_POST [ 'ssl_ipandport' ]);
}
2013-04-29 08:02:44 +00:00
if ( isset ( $_POST [ 'ssl_ipandport' ]) && is_array ( $_POST [ 'ssl_ipandport' ])) {
foreach ( $_POST [ 'ssl_ipandport' ] as $ssl_ipandport ) {
2013-09-27 14:28:33 +00:00
if ( trim ( $ssl_ipandport ) == " " ) continue ;
2012-12-02 14:16:22 +00:00
$ssl_ipandport = intval ( $ssl_ipandport );
2013-09-27 14:28:33 +00:00
$ssl_ipandport_check = $db -> query_first ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `id` = ' " . $db -> escape ( $ssl_ipandport ) . " ' " );
2013-04-29 08:02:44 +00:00
if ( ! isset ( $ssl_ipandport_check [ 'id' ])
2012-12-02 14:16:22 +00:00
|| $ssl_ipandport_check [ 'id' ] == '0'
2013-04-29 08:02:44 +00:00
|| $ssl_ipandport_check [ 'id' ] != $ssl_ipandport
) {
2012-12-02 14:16:22 +00:00
standard_error ( 'ipportdoesntexist' );
2013-04-29 08:02:44 +00:00
} else {
2012-12-02 14:16:22 +00:00
$ssl_ipandports [] = $ssl_ipandport ;
}
}
2010-01-27 08:54:31 +00:00
}
}
else
{
$ssl_redirect = 0 ;
2013-09-19 17:36:06 +00:00
$ssl_ipandports [] = '' ;
2010-01-27 08:54:31 +00:00
}
if ( ! preg_match ( '/^https?\:\/\//' , $documentroot ))
{
$documentroot = makeCorrectDir ( $documentroot );
}
if ( $openbasedir != '1' )
{
$openbasedir = '0' ;
}
if ( $isbinddomain != '1' )
{
$isbinddomain = '0' ;
}
if ( $isemaildomain != '1' )
{
$isemaildomain = '0' ;
}
if ( $email_only == '1' )
{
$isemaildomain = '1' ;
}
else
{
$email_only = '0' ;
}
if ( $subcanemaildomain != '1'
&& $subcanemaildomain != '2'
&& $subcanemaildomain != '3' )
{
$subcanemaildomain = '0' ;
}
if ( $dkim != '1' )
{
$dkim = '0' ;
}
if ( $caneditdomain != '1' )
{
$caneditdomain = '0' ;
}
$aliasdomain_check = array (
'id' => 0
);
2013-05-02 08:38:44 +00:00
if ( $aliasdomain != 0 ) {
// Overwrite given ipandports with these of the "main" domain
$ipandports = array ();
$origipresult = $db -> query ( " SELECT `id_ipandports` FROM ` " . TABLE_DOMAINTOIP . " ` WHERE `id_domain` = ' " . ( int ) $aliasdomain . " ' " );
while ( $origip = $db -> fetch_array ( $origipresult )) {
$ipandports [] = $origip [ 'id_ipandports' ];
}
$aliasdomain_check = $db -> query_first ( " SELECT `d`.`id` FROM ` " . TABLE_PANEL_DOMAINS . " ` `d`, ` " . TABLE_PANEL_CUSTOMERS . " ` `c`
WHERE `d` . `customerid` = '" . (int)$customerid . "'
AND `d` . `aliasdomain` IS NULL AND
`d` . `id` <> `c` . `standardsubdomain`
AND `c` . `customerid` = '" . (int)$customerid . "'
AND `d` . `id` = '" . (int)$aliasdomain . "' " );
}
if ( count ( $ipandports ) == 0 ) {
standard_error ( 'noipportgiven' );
2010-01-27 08:54:31 +00:00
}
if ( $aliasdomain_check [ 'id' ] != $aliasdomain )
{
standard_error ( 'domainisaliasorothercustomer' );
}
2011-06-16 18:54:54 +00:00
2010-08-06 05:43:28 +00:00
if ( $issubof <= '0' )
{
$issubof = '0' ;
}
2010-01-27 08:54:31 +00:00
$params = array (
'id' => $id ,
'page' => $page ,
'action' => $action ,
'customerid' => $customerid ,
'adminid' => $adminid ,
'documentroot' => $documentroot ,
'alias' => $aliasdomain ,
'isbinddomain' => $isbinddomain ,
'isemaildomain' => $isemaildomain ,
'email_only' => $email_only ,
'subcanemaildomain' => $subcanemaildomain ,
'caneditdomain' => $caneditdomain ,
'zonefile' => $zonefile ,
'dkim' => $dkim ,
'wwwserveralias' => $wwwserveralias ,
'ssl_redirect' => $ssl_redirect ,
'openbasedir' => $openbasedir ,
'phpsettingid' => $phpsettingid ,
'mod_fcgid_starter' => $mod_fcgid_starter ,
'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests ,
'specialsettings' => $specialsettings ,
2010-08-06 05:43:28 +00:00
'registration_date' => $registration_date ,
2012-03-08 14:11:25 +00:00
'issubof' => $issubof ,
2012-12-02 14:16:22 +00:00
'speciallogfile' => $speciallogfile ,
2013-09-23 07:35:33 +00:00
'speciallogverified' => $speciallogverified ,
2012-12-02 14:16:22 +00:00
'ipandport' => serialize ( $ipandports ),
'ssl_ipandport' => serialize ( $ssl_ipandports )
2010-01-27 08:54:31 +00:00
);
$security_questions = array (
2011-06-16 18:54:54 +00:00
'reallydisablesecuritysetting' => ( $openbasedir == '0' && $userinfo [ 'change_serversettings' ] == '1' ),
2010-01-27 08:54:31 +00:00
'reallydocrootoutofcustomerroot' => ( substr ( $documentroot , 0 , strlen ( $customer [ 'documentroot' ])) != $customer [ 'documentroot' ] && ! preg_match ( '/^https?\:\/\//' , $documentroot ))
);
foreach ( $security_questions as $question_name => $question_launch )
{
if ( $question_launch !== false )
{
$params [ $question_name ] = $question_name ;
if ( ! isset ( $_POST [ $question_name ])
|| $_POST [ $question_name ] != $question_name )
{
ask_yesno ( 'admin_domain_' . $question_name , $filename , $params );
exit ;
}
}
}
if ( $documentroot != $result [ 'documentroot' ]
|| $ssl_redirect != $result [ 'ssl_redirect' ]
|| $wwwserveralias != $result [ 'wwwserveralias' ]
|| $openbasedir != $result [ 'openbasedir' ]
|| $phpsettingid != $result [ 'phpsettingid' ]
|| $mod_fcgid_starter != $result [ 'mod_fcgid_starter' ]
|| $mod_fcgid_maxrequests != $result [ 'mod_fcgid_maxrequests' ]
|| $specialsettings != $result [ 'specialsettings' ]
2010-08-06 05:43:28 +00:00
|| $aliasdomain != $result [ 'aliasdomain' ]
2011-09-19 09:00:50 +00:00
|| $issubof != $result [ 'ismainbutsubto' ]
2012-03-08 14:11:25 +00:00
|| $email_only != $result [ 'email_only' ]
2013-09-23 07:35:33 +00:00
|| ( $speciallogfile != $result [ 'speciallogfile' ] && $speciallogverified == '1' ))
2010-01-27 08:54:31 +00:00
{
inserttask ( '1' );
}
2013-09-23 07:35:33 +00:00
if ( $speciallogfile != $result [ 'speciallogfile' ] && $speciallogverified != '1' ) {
$speciallogfile = $result [ 'speciallogfile' ];
}
2012-03-08 14:11:25 +00:00
2010-01-27 08:54:31 +00:00
if ( $isbinddomain != $result [ 'isbinddomain' ]
|| $zonefile != $result [ 'zonefile' ]
2012-12-02 14:16:22 +00:00
|| $dkim != $result [ 'dkim' ])
2010-01-27 08:54:31 +00:00
{
2013-03-29 19:10:37 +00:00
inserttask ( '4' );
2010-01-27 08:54:31 +00:00
}
if ( $isemaildomain == '0'
&& $result [ 'isemaildomain' ] == '1' )
{
$db -> query ( " DELETE FROM ` " . TABLE_MAIL_USERS . " ` WHERE `domainid`=' " . ( int ) $id . " ' " );
$db -> query ( " DELETE FROM ` " . TABLE_MAIL_VIRTUAL . " ` WHERE `domainid`=' " . ( int ) $id . " ' " );
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " deleted domain # " . $id . " from mail-tables " );
}
$updatechildren = '' ;
if ( $subcanemaildomain == '0'
&& $result [ 'subcanemaildomain' ] != '0' )
{
$updatechildren = ', `isemaildomain`=\'0\' ' ;
}
elseif ( $subcanemaildomain == '3'
&& $result [ 'subcanemaildomain' ] != '3' )
{
$updatechildren = ', `isemaildomain`=\'1\' ' ;
}
if ( $customerid != $result [ 'customerid' ]
&& $settings [ 'panel' ][ 'allow_domain_change_customer' ] == '1' )
{
$db -> query ( " UPDATE ` " . TABLE_MAIL_USERS . " ` SET `customerid` = ' " . ( int ) $customerid . " ' WHERE `domainid` = ' " . ( int ) $result [ 'id' ] . " ' " );
$db -> query ( " UPDATE ` " . TABLE_MAIL_VIRTUAL . " ` SET `customerid` = ' " . ( int ) $customerid . " ' WHERE `domainid` = ' " . ( int ) $result [ 'id' ] . " ' " );
$db -> query ( " UPDATE ` " . TABLE_PANEL_CUSTOMERS . " ` SET `subdomains_used` = `subdomains_used` + ' " . ( int ) $subdomains . " ', `emails_used` = `emails_used` + ' " . ( int ) $emails . " ', `email_forwarders_used` = `email_forwarders_used` + ' " . ( int ) $email_forwarders . " ', `email_accounts_used` = `email_accounts_used` + ' " . ( int ) $email_accounts . " ' WHERE `customerid` = ' " . ( int ) $customerid . " ' " );
$db -> query ( " UPDATE ` " . TABLE_PANEL_CUSTOMERS . " ` SET `subdomains_used` = `subdomains_used` - ' " . ( int ) $subdomains . " ', `emails_used` = `emails_used` - ' " . ( int ) $emails . " ', `email_forwarders_used` = `email_forwarders_used` - ' " . ( int ) $email_forwarders . " ', `email_accounts_used` = `email_accounts_used` - ' " . ( int ) $email_accounts . " ' WHERE `customerid` = ' " . ( int ) $result [ 'customerid' ] . " ' " );
}
if ( $adminid != $result [ 'adminid' ]
&& $settings [ 'panel' ][ 'allow_domain_change_admin' ] == '1' )
{
$db -> query ( " UPDATE ` " . TABLE_PANEL_ADMINS . " ` SET `domains_used` = `domains_used` + 1 WHERE `adminid` = ' " . ( int ) $adminid . " ' " );
$db -> query ( " UPDATE ` " . TABLE_PANEL_ADMINS . " ` SET `domains_used` = `domains_used` - 1 WHERE `adminid` = ' " . ( int ) $result [ 'adminid' ] . " ' " );
}
2012-07-23 23:06:45 +00:00
$ssfs = isset ( $_POST [ 'specialsettingsforsubdomains' ]) ? 1 : 0 ;
2010-01-29 09:30:55 +00:00
if ( $ssfs == 1 )
{
$upd_specialsettings = " , `specialsettings`=' " . $db -> escape ( $specialsettings ) . " ' " ;
2011-06-16 18:54:54 +00:00
}
else
2010-01-29 09:30:55 +00:00
{
$upd_specialsettings = '' ;
$db -> query ( " UPDATE ` " . TABLE_PANEL_DOMAINS . " ` SET `specialsettings`='' WHERE `parentdomainid`=' " . ( int ) $id . " ' " );
$log -> logAction ( ADM_ACTION , LOG_INFO , " removed specialsettings on all subdomains of domain # " . $id );
}
2011-06-16 18:54:54 +00:00
2012-12-02 14:16:22 +00:00
$result = $db -> query ( " UPDATE ` " . TABLE_PANEL_DOMAINS . " ` SET
`customerid` = '" . (int)$customerid . "' ,
`adminid` = '" . (int)$adminid . "' ,
`documentroot` = '" . $db->escape($documentroot) . "' ,
`ssl_redirect` = '" . (int)$ssl_redirect . "' ,
`aliasdomain` = " . (( $aliasdomain != 0 && $alias_check == 0) ? ' \ '' . $db->escape ( $aliasdomain ) . ' \ '' : 'NULL') . " ,
`isbinddomain` = '" . $db->escape($isbinddomain) . "' ,
`isemaildomain` = '" . $db->escape($isemaildomain) . "' ,
`email_only` = '" . $db->escape($email_only) . "' ,
`subcanemaildomain` = '" . $db->escape($subcanemaildomain) . "' ,
`dkim` = '" . $db->escape($dkim) . "' ,
`caneditdomain` = '" . $db->escape($caneditdomain) . "' ,
`zonefile` = '" . $db->escape($zonefile) . "' ,
`wwwserveralias` = '" . $db->escape($wwwserveralias) . "' ,
`openbasedir` = '" . $db->escape($openbasedir) . "' ,
`speciallogfile` = '" . $db->escape($speciallogfile) . "' ,
`phpsettingid` = '" . $db->escape($phpsettingid) . "' ,
`mod_fcgid_starter` = '" . $db->escape($mod_fcgid_starter) . "' ,
`mod_fcgid_maxrequests` = '" . $db->escape($mod_fcgid_maxrequests) . "' ,
`specialsettings` = '" . $db->escape($specialsettings) . "' ,
`registration_date` = '" . $db->escape($registration_date) . "' ,
`ismainbutsubto` = '" . (int)$issubof . "' WHERE `id` = '" . (int)$id . "'
" );
$result = $db -> query ( " UPDATE ` " . TABLE_PANEL_DOMAINS . " ` SET
`customerid` = '" . (int)$customerid . "' ,
`adminid` = '" . (int)$adminid . "' ,
`openbasedir` = '" . $db->escape($openbasedir) . "' ,
`phpsettingid` = '" . $db->escape($phpsettingid) . "' ,
`mod_fcgid_starter` = '" . $db->escape($mod_fcgid_starter) . "' ,
`mod_fcgid_maxrequests` = '" . $db->escape($mod_fcgid_maxrequests) . "'
" . $upd_specialsettings . $updatechildren . "
WHERE `parentdomainid` = '" . (int)$id . "'
" );
2013-05-02 08:38:44 +00:00
// FIXME check how many we got and if the amount of assigned IP's
// has changed so we can insert a config-rebuild task if only
// the ip's of this domain were changed
2012-12-02 14:16:22 +00:00
// Cleanup domain <-> ip mapping
$db -> query ( " DELETE FROM ` " . TABLE_DOMAINTOIP . " ` WHERE `id_domain` = ' " . ( int ) $id . " ' " );
foreach ( $ipandports as $ipportid ) {
$db -> query ( " INSERT INTO ` " . TABLE_DOMAINTOIP . " ` SET
`id_domain` = '" . (int)$id . "' ,
`id_ipandports` = '" . (int)$ipportid . "' ;
" );
}
foreach ( $ssl_ipandports as $ssl_ipportid ) {
$db -> query ( " INSERT INTO ` " . TABLE_DOMAINTOIP . " ` SET
`id_domain` = '" . (int)$id . "' ,
`id_ipandports` = '" . (int)$ssl_ipportid . "' ;
" );
}
// Cleanup domain <-> ip mapping for subdomains
$domainidsresult = $db -> query ( " SELECT `id` FROM ` " . TABLE_PANEL_DOMAINS . " ` WHERE `parentdomainid`=' " . ( int ) $id . " ' " );
while ( $row = $db -> fetch_array ( $domainidsresult )) {
$db -> query ( " DELETE FROM ` " . TABLE_DOMAINTOIP . " ` WHERE `id_domain` = ' " . ( int ) $row [ 'id' ] . " ' " );
foreach ( $ipandports as $ipportid ) {
$db -> query ( " INSERT INTO ` " . TABLE_DOMAINTOIP . " ` SET
`id_domain` = '" . (int)$row[' id '] . "' ,
`id_ipandports` = '" . (int)$ipportid . "' ;
" );
}
foreach ( $ssl_ipandports as $ssl_ipportid ) {
$db -> query ( " INSERT INTO ` " . TABLE_DOMAINTOIP . " ` SET
`id_domain` = '" . (int)$row[' id '] . "' ,
`id_ipandports` = '" . (int)$ssl_ipportid . "' ;
" );
}
}
2010-01-27 08:54:31 +00:00
$log -> logAction ( ADM_ACTION , LOG_INFO , " edited domain # " . $id );
$redirect_props = Array (
'page' => $page ,
's' => $s
);
redirectTo ( $filename , $redirect_props );
}
else
{
if ( $settings [ 'panel' ][ 'allow_domain_change_customer' ] == '1' )
{
$customers = '' ;
$result_customers = $db -> query ( " SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM ` " . TABLE_PANEL_CUSTOMERS . " ` WHERE ( (`subdomains_used` + " . ( int ) $subdomains . " <= `subdomains` OR `subdomains` = '-1' ) AND (`emails_used` + " . ( int ) $emails . " <= `emails` OR `emails` = '-1' ) AND (`email_forwarders_used` + " . ( int ) $email_forwarders . " <= `email_forwarders` OR `email_forwarders` = '-1' ) AND (`email_accounts_used` + " . ( int ) $email_accounts . " <= `email_accounts` OR `email_accounts` = '-1' ) " . ( $userinfo [ 'customers_see_all' ] ? '' : " AND `adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ) . " ) OR `customerid` = ' " . ( int ) $result [ 'customerid' ] . " ' ORDER BY `name` ASC " );
while ( $row_customer = $db -> fetch_array ( $result_customers ))
{
$customers .= makeoption ( getCorrectFullUserDetails ( $row_customer ) . ' (' . $row_customer [ 'loginname' ] . ')' , $row_customer [ 'customerid' ], $result [ 'customerid' ]);
}
}
else
{
$customer = $db -> query_first ( " SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM ` " . TABLE_PANEL_CUSTOMERS . " ` WHERE `customerid` = ' " . ( int ) $result [ 'customerid' ] . " ' " );
$result [ 'customername' ] = getCorrectFullUserDetails ( $customer ) . ' (' . $customer [ 'loginname' ] . ')' ;
}
if ( $userinfo [ 'customers_see_all' ] == '1' )
{
if ( $settings [ 'panel' ][ 'allow_domain_change_admin' ] == '1' )
{
$admins = '' ;
$result_admins = $db -> query ( " SELECT `adminid`, `loginname`, `name` FROM ` " . TABLE_PANEL_ADMINS . " ` WHERE (`domains_used` < `domains` OR `domains` = '-1') OR `adminid` = ' " . ( int ) $result [ 'adminid' ] . " ' ORDER BY `name` ASC " );
while ( $row_admin = $db -> fetch_array ( $result_admins ))
{
$admins .= makeoption ( getCorrectFullUserDetails ( $row_admin ) . ' (' . $row_admin [ 'loginname' ] . ')' , $row_admin [ 'adminid' ], $result [ 'adminid' ]);
}
}
else
{
$admin = $db -> query_first ( " SELECT `adminid`, `loginname`, `name` FROM ` " . TABLE_PANEL_ADMINS . " ` WHERE `adminid` = ' " . ( int ) $result [ 'adminid' ] . " ' " );
$result [ 'adminname' ] = getCorrectFullUserDetails ( $admin ) . ' (' . $admin [ 'loginname' ] . ')' ;
}
}
$result [ 'domain' ] = $idna_convert -> decode ( $result [ 'domain' ]);
$domains = makeoption ( $lng [ 'domains' ][ 'noaliasdomain' ], 0 , NULL , true );
$result_domains = $db -> query ( " SELECT `d`.`id`, `d`.`domain` FROM ` " . TABLE_PANEL_DOMAINS . " ` `d`, ` " . TABLE_PANEL_CUSTOMERS . " ` `c` WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid`=0 AND `d`.`id`<>' " . ( int ) $result [ 'id' ] . " ' AND `c`.`standardsubdomain`<>`d`.`id` AND `d`.`customerid`=' " . ( int ) $result [ 'customerid' ] . " ' AND `c`.`customerid`=`d`.`customerid` ORDER BY `d`.`domain` ASC " );
while ( $row_domain = $db -> fetch_array ( $result_domains ))
{
$domains .= makeoption ( $idna_convert -> decode ( $row_domain [ 'domain' ]), $row_domain [ 'id' ], $result [ 'aliasdomain' ]);
}
2010-08-27 05:53:25 +00:00
2010-08-06 05:43:28 +00:00
$subtodomains = makeoption ( $lng [ 'domains' ][ 'nosubtomaindomain' ], 0 , NULL , true );
2010-08-27 06:08:52 +00:00
$result_domains = $db -> query ( " SELECT `d`.`id`, `d`.`domain` FROM ` " . TABLE_PANEL_DOMAINS . " ` `d`, ` " . TABLE_PANEL_CUSTOMERS . " ` `c` WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid`=0 AND `d`.`id`<>' " . ( int ) $result [ 'id' ] . " ' AND `c`.`standardsubdomain`<>`d`.`id` AND `c`.`customerid`=`d`.`customerid` " . ( $userinfo [ 'customers_see_all' ] ? '' : " AND `d`.`adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ) . " ORDER BY `d`.`domain` ASC " );
2010-08-06 05:43:28 +00:00
while ( $row_domain = $db -> fetch_array ( $result_domains ))
{
$subtodomains .= makeoption ( $idna_convert -> decode ( $row_domain [ 'domain' ]), $row_domain [ 'id' ], $result [ 'ismainbutsubto' ]);
}
2010-01-27 08:54:31 +00:00
if ( $userinfo [ 'ip' ] == " -1 " )
{
$result_ipsandports = $db -> query ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `ssl`='0' ORDER BY `ip`, `port` ASC " );
$result_ssl_ipsandports = $db -> query ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `ssl`='1' ORDER BY `ip`, `port` ASC " );
}
else
{
$admin_ip = $db -> query_first ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `id`=' " . ( int ) $userinfo [ 'ip' ] . " ' ORDER BY `ip`, `port` ASC " );
$result_ipsandports = $db -> query ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `ssl`='0' AND `ip`=' " . $admin_ip [ 'ip' ] . " ' ORDER BY `ip`, `port` ASC " );
$result_ssl_ipsandports = $db -> query ( " SELECT `id`, `ip`, `port` FROM ` " . TABLE_PANEL_IPSANDPORTS . " ` WHERE `ssl`='1' AND `ip`=' " . $admin_ip [ 'ip' ] . " ' ORDER BY `ip`, `port` ASC " );
}
2012-12-02 14:16:22 +00:00
$ipsandports = array ();
2010-01-27 08:54:31 +00:00
while ( $row_ipandport = $db -> fetch_array ( $result_ipsandports ))
{
if ( filter_var ( $row_ipandport [ 'ip' ], FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ))
{
$row_ipandport [ 'ip' ] = '[' . $row_ipandport [ 'ip' ] . ']' ;
}
2012-12-02 14:16:22 +00:00
$ipsandports [] = array ( 'label' => $row_ipandport [ 'ip' ] . ':' . $row_ipandport [ 'port' ], 'value' => $row_ipandport [ 'id' ]);
2010-01-27 08:54:31 +00:00
}
2012-12-02 14:16:22 +00:00
$ssl_ipsandports = array ();
2010-01-27 08:54:31 +00:00
while ( $row_ssl_ipandport = $db -> fetch_array ( $result_ssl_ipsandports ))
{
if ( filter_var ( $row_ssl_ipandport [ 'ip' ], FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ))
{
$row_ssl_ipandport [ 'ip' ] = '[' . $row_ssl_ipandport [ 'ip' ] . ']' ;
}
2012-12-02 14:16:22 +00:00
$ssl_ipsandports [] = array ( 'label' => $row_ssl_ipandport [ 'ip' ] . ':' . $row_ssl_ipandport [ 'port' ], 'value' => $row_ssl_ipandport [ 'id' ]);
2010-01-27 08:54:31 +00:00
}
$result [ 'specialsettings' ] = $result [ 'specialsettings' ];
2013-02-25 10:18:12 +00:00
2010-01-27 08:54:31 +00:00
$subcanemaildomain = makeoption ( $lng [ 'admin' ][ 'subcanemaildomain' ][ 'never' ], '0' , $result [ 'subcanemaildomain' ], true , true );
$subcanemaildomain .= makeoption ( $lng [ 'admin' ][ 'subcanemaildomain' ][ 'choosableno' ], '1' , $result [ 'subcanemaildomain' ], true , true );
$subcanemaildomain .= makeoption ( $lng [ 'admin' ][ 'subcanemaildomain' ][ 'choosableyes' ], '2' , $result [ 'subcanemaildomain' ], true , true );
$subcanemaildomain .= makeoption ( $lng [ 'admin' ][ 'subcanemaildomain' ][ 'always' ], '3' , $result [ 'subcanemaildomain' ], true , true );
$speciallogfile = ( $result [ 'speciallogfile' ] == 1 ? $lng [ 'panel' ][ 'yes' ] : $lng [ 'panel' ][ 'no' ]);
$result [ 'add_date' ] = date ( 'Y-m-d' , $result [ 'add_date' ]);
$phpconfigs = '' ;
$phpconfigs_result = $db -> query ( " SELECT * FROM ` " . TABLE_PANEL_PHPCONFIGS . " ` " );
2012-12-02 14:16:22 +00:00
while ( $phpconfigs_row = $db -> fetch_array ( $phpconfigs_result )) {
2010-01-27 08:54:31 +00:00
$phpconfigs .= makeoption ( $phpconfigs_row [ 'description' ], $phpconfigs_row [ 'id' ], $result [ 'phpsettingid' ], true , true );
}
$result = htmlentities_array ( $result );
2011-02-08 11:53:24 +00:00
$domain_edit_data = include_once dirname ( __FILE__ ) . '/lib/formfields/admin/domains/formfield.domains_edit.php' ;
$domain_edit_form = htmlform :: genHTMLForm ( $domain_edit_data );
$title = $domain_edit_data [ 'domain_edit' ][ 'title' ];
$image = $domain_edit_data [ 'domain_edit' ][ 'image' ];
2013-03-27 11:30:37 +00:00
$speciallogwarning = sprintf ( $lng [ 'admin' ][ 'speciallogwarning' ], $lng [ 'admin' ][ 'delete_statistics' ]);
2010-01-27 08:54:31 +00:00
eval ( " echo \" " . getTemplate ( " domains/domains_edit " ) . " \" ; " );
}
}
}
}