2010-01-20 16:55:27 +00:00
< ? php
/**
2010-01-25 10:06:34 +00:00
* This file is part of the Froxlor project .
2010-01-20 16:55:27 +00:00
* Copyright ( c ) 2003 - 2009 the SysCP Team ( see authors ) .
2010-01-25 10:06:34 +00:00
* Copyright ( c ) 2010 the Froxlor Team ( see authors ) .
2010-01-20 16:55:27 +00:00
*
* For the full copyright and license information , please view the COPYING
* file that was distributed with this source code . You can also view the
2010-01-25 10:06:34 +00:00
* COPYING file online at http :// files . froxlor . org / misc / COPYING . txt
2010-01-20 16:55:27 +00:00
*
* @ copyright ( c ) the authors
2010-01-25 10:06:34 +00:00
* @ author Florian Lippert < flo @ syscp . org > ( 2003 - 2009 )
* @ author Froxlor team < team @ froxlor . org > ( 2010 - )
* @ license GPLv2 http :// files . froxlor . org / misc / COPYING . txt
2010-01-20 16:55:27 +00:00
* @ package Panel
2011-05-04 09:59:20 +00:00
*
2010-01-20 16:55:27 +00:00
*/
define ( 'AREA' , 'admin' );
2013-11-18 11:53:33 +00:00
require './lib/init.php' ;
2010-01-20 16:55:27 +00:00
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'id' ])) {
2010-01-20 16:55:27 +00:00
$id = intval ( $_POST [ 'id' ]);
2013-11-06 07:46:45 +00:00
} elseif ( isset ( $_GET [ 'id' ])) {
2010-01-20 16:55:27 +00:00
$id = intval ( $_GET [ 'id' ]);
}
2013-11-06 07:46:45 +00:00
if ( $page == 'customers'
&& $userinfo [ 'customers' ] != '0'
) {
if ( $action == '' ) {
2011-03-19 12:43:01 +00:00
// clear request data
unset ( $_SESSION [ 'requestData' ]);
2011-06-18 17:48:16 +00:00
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " viewed admin_customers " );
$fields = array (
'c.loginname' => $lng [ 'login' ][ 'username' ],
'a.loginname' => $lng [ 'admin' ][ 'admin' ],
'c.name' => $lng [ 'customer' ][ 'name' ],
2012-10-16 23:06:29 +00:00
'c.email' => $lng [ 'customer' ][ 'email' ],
2010-01-20 16:55:27 +00:00
'c.firstname' => $lng [ 'customer' ][ 'firstname' ],
'c.company' => $lng [ 'customer' ][ 'company' ],
'c.diskspace' => $lng [ 'customer' ][ 'diskspace' ],
'c.diskspace_used' => $lng [ 'customer' ][ 'diskspace' ] . ' (' . $lng [ 'panel' ][ 'used' ] . ')' ,
'c.traffic' => $lng [ 'customer' ][ 'traffic' ],
2013-02-25 10:18:12 +00:00
'c.traffic_used' => $lng [ 'customer' ][ 'traffic' ] . ' (' . $lng [ 'panel' ][ 'used' ] . ')'
2010-01-20 16:55:27 +00:00
);
2013-02-25 10:18:12 +00:00
if ( $settings [ 'system' ][ 'backup_enabled' ] == '1' ) {
$field [ 'c.backup_allowed' ] = $lng [ 'backup_allowed' ];
2010-01-20 16:55:27 +00:00
}
2011-06-18 17:48:16 +00:00
2013-11-18 08:09:06 +00:00
$paging = new paging ( $userinfo , TABLE_PANEL_CUSTOMERS , $fields , $settings [ 'panel' ][ 'paging' ], $settings [ 'panel' ][ 'natsorting' ]);
2010-01-20 16:55:27 +00:00
$customers = '' ;
2013-11-06 07:46:45 +00:00
$result_stmt = Database :: prepare ( "
SELECT `c` .* , `a` . `loginname` AS `adminname`
FROM `" . TABLE_PANEL_CUSTOMERS . "` `c` , `" . TABLE_PANEL_ADMINS . "` `a`
WHERE " .
( $userinfo [ 'customers_see_all' ] ? '' : " `c`.`adminid` = :adminid AND " ) . "
`c` . `adminid` = `a` . `adminid` " .
$paging -> getSqlWhere ( true ) . " " .
$paging -> getSqlOrderBy ( $settings [ 'panel' ][ 'natsorting' ]) . " " .
$paging -> getSqlLimit ()
);
Database :: pexecute ( $result_stmt , array ( 'adminid' => $userinfo [ 'adminid' ]));
$num_rows = Database :: num_rows ();
$paging -> setEntries ( $num_rows );
2010-01-20 16:55:27 +00:00
$sortcode = $paging -> getHtmlSortCode ( $lng , true );
$arrowcode = $paging -> getHtmlArrowCode ( $filename . '?page=' . $page . '&s=' . $s );
$searchcode = $paging -> getHtmlSearchCode ( $lng );
$pagingcode = $paging -> getHtmlPagingCode ( $filename . '?page=' . $page . '&s=' . $s );
$i = 0 ;
$count = 0 ;
2013-11-06 07:46:45 +00:00
while ( $row = $result_stmt -> fetch ( PDO :: FETCH_ASSOC )) {
if ( $paging -> checkDisplay ( $i )) {
$domains_stmt = Database :: prepare ( "
SELECT COUNT ( `id` ) AS `domains`
FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = : cid
AND `parentdomainid` = '0'
AND `id` <> : stdd "
);
Database :: pexecute ( $domains_stmt , array ( 'cid' => $row [ 'customerid' ], 'stdd' => $row [ 'standardsubdomain' ]));
$domains = $domains_stmt -> fetch ( PDO :: FETCH_ASSOC );
2010-01-20 16:55:27 +00:00
$row [ 'domains' ] = intval ( $domains [ 'domains' ]);
$row [ 'traffic_used' ] = round ( $row [ 'traffic_used' ] / ( 1024 * 1024 ), $settings [ 'panel' ][ 'decimal_places' ]);
$row [ 'traffic' ] = round ( $row [ 'traffic' ] / ( 1024 * 1024 ), $settings [ 'panel' ][ 'decimal_places' ]);
$row [ 'diskspace_used' ] = round ( $row [ 'diskspace_used' ] / 1024 , $settings [ 'panel' ][ 'decimal_places' ]);
$row [ 'diskspace' ] = round ( $row [ 'diskspace' ] / 1024 , $settings [ 'panel' ][ 'decimal_places' ]);
2010-04-15 10:39:47 +00:00
$last_login = (( int ) $row [ 'lastlogin_succ' ] == 0 ) ? $lng [ 'panel' ][ 'neverloggedin' ] : date ( 'd.m.Y' , $row [ 'lastlogin_succ' ]);
2010-04-15 11:00:27 +00:00
2011-02-08 11:53:24 +00:00
/**
* percent - values for progressbar
*/
2011-10-04 09:21:38 +00:00
//For Disk usage
2011-02-08 11:53:24 +00:00
if ( $row [ 'diskspace' ] > 0 ) {
2011-10-04 09:21:38 +00:00
$disk_percent = round (( $row [ 'diskspace_used' ] * 100 ) / $row [ 'diskspace' ], 2 );
$disk_doublepercent = round ( $disk_percent * 2 , 2 );
2011-02-08 11:53:24 +00:00
} else {
2011-10-04 09:21:38 +00:00
$disk_percent = 0 ;
$disk_doublepercent = 0 ;
}
if ( $row [ 'traffic' ] > 0 ) {
$traffic_percent = round (( $row [ 'traffic_used' ] * 100 ) / $row [ 'traffic' ], 2 );
$traffic_doublepercent = round ( $traffic_percent * 2 , 2 );
} else {
$traffic_percent = 0 ;
$traffic_doublepercent = 0 ;
2011-02-08 11:53:24 +00:00
}
2013-10-05 18:06:23 +00:00
$islocked = 0 ;
2013-11-06 07:46:45 +00:00
if ( $row [ 'loginfail_count' ] >= $settings [ 'login' ][ 'maxloginattempts' ]
2010-04-15 11:00:27 +00:00
&& $row [ 'lastlogin_fail' ] > ( time () - $settings [ 'login' ][ 'deactivatetime' ])
) {
2013-10-05 18:06:23 +00:00
$islocked = 1 ;
2010-04-15 11:00:27 +00:00
}
2010-09-20 07:56:32 +00:00
$row = str_replace_array ( '-1' , 'UL' , $row , 'diskspace traffic mysqls emails email_accounts email_forwarders ftps tickets subdomains email_autoresponder' );
2010-01-20 16:55:27 +00:00
$row = htmlentities_array ( $row );
eval ( " \$ customers.= \" " . getTemplate ( " customers/customers_customer " ) . " \" ; " );
$count ++ ;
}
$i ++ ;
}
2013-11-06 07:46:45 +00:00
$customercount = $num_rows ;
2010-01-20 16:55:27 +00:00
eval ( " echo \" " . getTemplate ( " customers/customers " ) . " \" ; " );
2013-11-06 07:46:45 +00:00
} elseif ( $action == 'su'
&& $id != 0
) {
$result_stmt = Database :: prepare ( "
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE `customerid` = : id " .
( $userinfo [ 'customers_see_all' ] ? '' : " AND `adminid` = :adminid " )
);
2013-11-08 08:31:51 +00:00
$params = array ( 'id' => $id );
if ( $userinfo [ 'customers_see_all' ] == '0' ) {
$params [ 'adminid' ] = $userinfo [ 'adminid' ];
}
$result = Database :: pexecute_first ( $result_stmt , $params );
2013-11-06 07:46:45 +00:00
2010-01-20 16:55:27 +00:00
$destination_user = $result [ 'loginname' ];
2013-11-06 07:46:45 +00:00
if ( $destination_user != '' ) {
2013-03-23 07:59:20 +00:00
if ( $result [ 'deactivated' ] == '1' ) {
standard_error ( " usercurrentlydeactivated " , $destination_user );
}
2013-11-06 07:46:45 +00:00
$result_stmt = Database :: prepare ( "
SELECT * FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = : id
AND `hash` = : hash "
);
2013-11-08 08:31:51 +00:00
$result = Database :: pexecute_first ( $result_stmt , array ( 'id' => $userinfo [ 'userid' ], 'hash' => $s ));
2010-01-20 16:55:27 +00:00
$s = md5 ( uniqid ( microtime (), 1 ));
2013-11-06 07:46:45 +00:00
$insert = Database :: prepare ( "
INSERT INTO `" . TABLE_PANEL_SESSIONS . "` SET
`hash` = : hash ,
`userid` = : id ,
`ipaddress` = : ip ,
`useragent` = : ua ,
`lastactivity` = : lastact ,
`language` = : lang ,
`adminsession` = '0' "
);
2013-11-08 08:31:51 +00:00
Database :: pexecute ( $insert , array (
2013-11-06 07:46:45 +00:00
'hash' => $s ,
'id' => $id ,
'ip' => $result [ 'ipaddress' ],
'ua' => $result [ 'useragent' ],
'lastact' => time (),
'lang' => $result [ 'language' ]
));
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_INFO , " switched user and is now ' " . $destination_user . " ' " );
2013-11-11 08:59:03 +00:00
$target = ( isset ( $_GET [ 'target' ]) ? $_GET [ 'target' ] : 'index' );
$redirect = " customer_ " . $target . " .php " ;
if ( ! file_exists ( FROXLOR_INSTALL_DIR . " / " . $redirect )) {
$redirect = " customer_index.php " ;
}
redirectTo ( $redirect , array ( 's' => $s ), true );
2013-11-06 07:46:45 +00:00
} else {
redirectTo ( 'index.php' , array ( 'action' => 'login' ));
2010-01-20 16:55:27 +00:00
}
2013-11-06 07:46:45 +00:00
} elseif ( $action == 'unlock'
&& $id != 0
) {
$result_stmt = Database :: prepare ( "
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE `customerid` = : id " .
( $userinfo [ 'customers_see_all' ] ? '' : " AND `adminid` = :adminid " )
);
2013-11-08 08:31:51 +00:00
$result = Database :: pexecute_first ( $result_stmt , array ( 'id' => $id , 'adminid' => $userinfo [ 'adminid' ]));
2013-11-06 07:46:45 +00:00
if ( $result [ 'loginname' ] != '' ) {
if ( isset ( $_POST [ 'send' ])
&& $_POST [ 'send' ] == 'send'
) {
$result_stmt = Database :: prepare ( "
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
2011-06-18 17:48:16 +00:00
`loginfail_count` = '0'
2013-11-06 07:46:45 +00:00
WHERE `customerid` = : id "
2010-11-09 09:32:52 +00:00
);
2013-11-06 07:46:45 +00:00
Database :: pexecute ( $result_stmt , array ( 'id' => $id ));
redirectTo ( $filename , array ( 'page' => $page , 's' => $s ));
} else {
2010-11-09 09:32:52 +00:00
ask_yesno ( 'customer_reallyunlock' , $filename , array ( 'id' => $id , 'page' => $page , 'action' => $action ), $result [ 'loginname' ]);
}
}
2013-11-06 07:46:45 +00:00
} elseif ( $action == 'delete'
&& $id != 0
) {
$result_stmt = Database :: prepare ( "
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE `customerid` = : id " .
( $userinfo [ 'customers_see_all' ] ? '' : " AND `adminid` = :adminid " )
);
2013-11-08 08:31:51 +00:00
$params = array ( 'id' => $id );
if ( $userinfo [ 'customers_see_all' ] == '0' ) {
$params [ 'adminid' ] = $userinfo [ 'adminid' ];
}
$result = Database :: pexecute_first ( $result_stmt , $params );
2013-11-06 07:46:45 +00:00
if ( $result [ 'loginname' ] != '' ) {
if ( isset ( $_POST [ 'send' ])
&& $_POST [ 'send' ] == 'send'
) {
$databases_stmt = Database :: prepare ( "
SELECT * FROM `" . TABLE_PANEL_DATABASES . "`
WHERE `customerid` = : id ORDER BY `dbserver` "
);
Database :: pexecute ( $databases_stmt , array ( 'id' => $id ));
Database :: needRoot ( true );
2010-01-20 16:55:27 +00:00
$last_dbserver = 0 ;
2013-11-06 07:46:45 +00:00
while ( $row_database = $databases_stmt -> fetch ( PDO :: FETCH_ASSOC )) {
if ( $last_dbserver != $row_database [ 'dbserver' ]) {
Database :: needRoot ( true , $row_database [ 'dbserver' ]);
Database :: query ( 'FLUSH PRIVILEGES;' );
2010-01-20 16:55:27 +00:00
$last_dbserver = $row_database [ 'dbserver' ];
}
2013-11-06 07:46:45 +00:00
if ( Database :: getAttribute ( PDO :: ATTR_SERVER_VERSION ) < '5.0.2' ) {
2012-11-19 18:22:21 +00:00
// failsafe if user has been deleted manually (requires MySQL 4.1.2+)
2013-11-06 07:46:45 +00:00
$stmt = Database :: prepare ( " REVOKE ALL PRIVILEGES, GRANT OPTION FROM ` " . $row_database [ 'databasename' ] . " ` " );
Database :: pexecute ( $stmt , array (), false );
2012-11-19 18:22:21 +00:00
}
2013-11-06 07:46:45 +00:00
$host_res_stmt = Database :: prepare ( "
SELECT `Host` FROM `mysql` . `user`
WHERE `User` = : dbname "
);
Database :: pexecute ( $host_res_stmt , array ( 'dbname' => $row_database [ 'databasename' ]));
while ( $host = $host_res_stmt -> fetch ( PDO :: FETCH_ASSOC )) {
2012-11-19 18:22:21 +00:00
// as of MySQL 5.0.2 this also revokes privileges. (requires MySQL 4.1.2+)
2013-11-06 07:46:45 +00:00
$drop_stmt = Database :: prepare ( " DROP USER :dbname@:host " );
Database :: pexecute ( $drop_stmt , array ( ':dbname' => $row_database [ 'databasename' ], ':host' => $host [ 'Host' ]), false );
2010-01-20 16:55:27 +00:00
}
2013-11-06 07:46:45 +00:00
$drop_stmt = Database :: prepare ( " DROP DATABASE IF EXISTS ` " . $row_database [ 'databasename' ] . " ` " );
Database :: pexecute ( $drop_stmt );
}
Database :: query ( 'FLUSH PRIVILEGES;' );
Database :: needRoot ( false );
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_PANEL_CUSTOMERS . " ` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_PANEL_DATABASES . " ` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_PANEL_DOMAINS . " ` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$domains_deleted = $stmt -> rowCount ();
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_PANEL_HTPASSWDS . " ` WHERE` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_PANEL_HTACCESS . " ` WHERE` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_PANEL_SESSIONS . " ` WHERE `customerid` = :id AND `adminsession` = '0' " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_PANEL_TRAFFIC . " ` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_MAIL_USERS . " ` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_MAIL_VIRTUAL . " ` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$result2_stmt = Database :: prepare ( " SELECT `username` FROM ` " . TABLE_FTP_USERS . " ` WHERE `customerid` = :id " );
Database :: pexecute ( $result2_stmt , array ( 'id' => $id ));
while ( $row = $result2_stmt -> fetch ( PDO :: FETCH_ASSOC )) {
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_FTP_QUOTATALLIES . " ` WHERE `name` = :name " );
Database :: pexecute ( $stmt , array ( 'name' => $row [ 'username' ]));
}
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_FTP_GROUPS . " ` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_FTP_USERS . " ` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_MAIL_AUTORESPONDER . " ` WHERE `customerid` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
2010-05-10 08:42:50 +00:00
2010-06-16 12:28:32 +00:00
// Delete all waiting "create user" -tasks for this user, #276
// Note: the WHERE selects part of a serialized array, but it should be safe this way
2013-11-06 07:46:45 +00:00
$del_stmt = Database :: prepare ( "
DELETE FROM `" . TABLE_PANEL_TASKS . "`
WHERE `type` = '2' AND `data` LIKE : loginname "
);
Database :: pexecute ( $del_stmt , array ( ':loginname' => " %: { $result [ 'loginname' ] } ;% " ));
2010-06-16 12:28:32 +00:00
2010-05-10 08:42:50 +00:00
// remove everything APS-related, #216
2013-11-06 07:46:45 +00:00
$apsresult_stmt = Database :: prepare ( " SELECT `ID` FROM ` " . TABLE_APS_INSTANCES . " ` WHERE `CustomerID` = :id " );
Database :: pexecute ( $apsresult_stmt , array ( 'id' => $id ));
while ( $apsrow = $apsresult_stmt -> fetch ( PDO :: FETCH_ASSOC )) {
2010-05-10 08:42:50 +00:00
// remove all package related settings
2013-11-06 07:46:45 +00:00
$del_stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_APS_SETTINGS . " ` WHERE `InstanceID` = :iid " );
Database :: pexecute ( $del_stmt , array ( 'iid' => $apsrow [ 'ID' ]));
2010-05-10 08:42:50 +00:00
// maybe some leftovers in the tasks
2013-11-06 07:46:45 +00:00
$del_stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_APS_TASKS . " ` WHERE `InstanceID` = :iid " );
Database :: pexecute ( $del_stmt , array ( 'iid' => $apsrow [ 'ID' ]));
2010-05-10 08:42:50 +00:00
}
// now remove all user instances
2013-11-06 07:46:45 +00:00
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_APS_INSTANCES . " ` WHERE `CustomerID` = :id' " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
2010-05-10 08:42:50 +00:00
// eventually some temp-setting-leftovers
2013-11-06 07:46:45 +00:00
$stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_APS_TEMP_SETTINGS . " ` WHERE `CustomerID` = :id " );
Database :: pexecute ( $stmt , array ( 'id' => $id ));
2010-05-10 08:42:50 +00:00
// eof APS-related removings, #216
2010-01-20 16:55:27 +00:00
$admin_update_query = " UPDATE ` " . TABLE_PANEL_ADMINS . " ` SET `customers_used` = `customers_used` - 1 " ;
$admin_update_query .= " , `domains_used` = `domains_used` - 0 " . ( int )( $domains_deleted - $result [ 'subdomains_used' ]);
2013-11-06 07:46:45 +00:00
if ( $result [ 'mysqls' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `mysqls_used` = `mysqls_used` - 0 " . ( int ) $result [ 'mysqls' ];
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'emails' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `emails_used` = `emails_used` - 0 " . ( int ) $result [ 'emails' ];
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_accounts' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `email_accounts_used` = `email_accounts_used` - 0 " . ( int ) $result [ 'email_accounts' ];
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_forwarders' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `email_forwarders_used` = `email_forwarders_used` - 0 " . ( int ) $result [ 'email_forwarders' ];
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_quota' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `email_quota_used` = `email_quota_used` - 0 " . ( int ) $result [ 'email_quota' ];
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_autoresponder' ] != '-1' ) {
2013-03-11 23:39:38 +00:00
$admin_update_query .= " , `email_autoresponder_used` = `email_autoresponder_used` - 0 " . ( int ) $result [ 'email_autoresponder' ];
2010-09-20 07:56:32 +00:00
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'subdomains' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `subdomains_used` = `subdomains_used` - 0 " . ( int ) $result [ 'subdomains' ];
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'ftps' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `ftps_used` = `ftps_used` - 0 " . ( int ) $result [ 'ftps' ];
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'tickets' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `tickets_used` = `tickets_used` - 0 " . ( int ) $result [ 'tickets' ];
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'aps_packages' ] != '-1' ) {
2013-03-11 23:39:38 +00:00
$admin_update_query .= " , `aps_packages_used` = `aps_packages_used` - 0 " . ( int ) $result [ 'aps_packages' ];
2010-05-10 08:42:50 +00:00
}
2013-11-06 07:46:45 +00:00
if (( $result [ 'diskspace' ] / 1024 ) != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `diskspace_used` = `diskspace_used` - 0 " . ( int ) $result [ 'diskspace' ];
}
$admin_update_query .= " WHERE `adminid` = ' " . ( int ) $result [ 'adminid' ] . " ' " ;
2013-11-06 07:46:45 +00:00
Database :: query ( $admin_update_query );
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_INFO , " deleted user ' " . $result [ 'loginname' ] . " ' " );
2010-10-23 10:20:23 +00:00
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' );
2011-06-18 17:48:16 +00:00
2013-03-29 19:10:37 +00:00
if ( isset ( $_POST [ 'delete_userfiles' ])
&& ( int ) $_POST [ 'delete_userfiles' ] == 1
) {
2010-10-23 10:20:23 +00:00
inserttask ( '6' , $result [ 'loginname' ]);
2010-01-24 11:30:15 +00:00
}
2011-06-18 17:48:16 +00:00
2013-03-29 19:10:37 +00:00
// Using filesystem - quota, insert a task which cleans the filesystem - quota
inserttask ( '10' );
2011-06-18 17:48:16 +00:00
2010-01-30 15:30:47 +00:00
/*
* move old tickets to archive
*/
2013-11-06 10:08:48 +00:00
$tickets = ticket :: customerHasTickets ( $id );
2013-11-06 07:46:45 +00:00
if ( $tickets !== false && isset ( $tickets [ 0 ])) {
foreach ( $tickets as $ticket ) {
2010-01-30 15:30:47 +00:00
$now = time ();
2013-11-06 10:08:48 +00:00
$mainticket = ticket :: getInstanceOf ( $userinfo , $settings , ( int ) $ticket );
2010-01-30 15:30:47 +00:00
$mainticket -> Set ( 'lastchange' , $now , true , true );
$mainticket -> Set ( 'lastreplier' , '1' , true , true );
$mainticket -> Set ( 'status' , '3' , true , true );
$mainticket -> Update ();
$mainticket -> Archive ();
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " archived ticket ' " . $mainticket -> Get ( 'subject' ) . " ' " );
}
2011-06-18 17:48:16 +00:00
}
2013-11-06 07:46:45 +00:00
redirectTo ( $filename , array ( 'page' => $page , 's' => $s ));
2011-06-18 17:48:16 +00:00
2013-11-06 07:46:45 +00:00
} else {
2010-01-24 11:30:15 +00:00
ask_yesno_withcheckbox ( 'admin_customer_reallydelete' , 'admin_customer_alsoremovefiles' , $filename , array ( 'id' => $id , 'page' => $page , 'action' => $action ), $result [ 'loginname' ]);
2010-01-20 16:55:27 +00:00
}
}
2013-11-06 07:46:45 +00:00
} elseif ( $action == 'add' ) {
if ( $userinfo [ 'customers_used' ] < $userinfo [ 'customers' ]
|| $userinfo [ 'customers' ] == '-1'
) {
if ( isset ( $_POST [ 'send' ])
&& $_POST [ 'send' ] == 'send'
) {
2010-01-20 16:55:27 +00:00
$name = validate ( $_POST [ 'name' ], 'name' );
$firstname = validate ( $_POST [ 'firstname' ], 'first name' );
$company = validate ( $_POST [ 'company' ], 'company' );
$street = validate ( $_POST [ 'street' ], 'street' );
$zipcode = validate ( $_POST [ 'zipcode' ], 'zipcode' , '/^[0-9 \-A-Z]*$/' );
$city = validate ( $_POST [ 'city' ], 'city' );
$phone = validate ( $_POST [ 'phone' ], 'phone' , '/^[0-9\- \+\(\)\/]*$/' );
$fax = validate ( $_POST [ 'fax' ], 'fax' , '/^[0-9\- \+\(\)\/]*$/' );
$email = $idna_convert -> encode ( validate ( $_POST [ 'email' ], 'email' ));
$customernumber = validate ( $_POST [ 'customernumber' ], 'customer number' , '/^[A-Za-z0-9 \-]*$/Di' );
$def_language = validate ( $_POST [ 'def_language' ], 'default language' );
2011-05-12 16:58:01 +00:00
$gender = intval_ressource ( $_POST [ 'gender' ]);
2010-01-20 16:55:27 +00:00
2013-11-06 07:46:45 +00:00
$diskspace = intval_ressource ( $_POST [ 'diskspace' ]);
if ( isset ( $_POST [ 'diskspace_ul' ])) {
2010-01-20 16:55:27 +00:00
$diskspace = - 1 ;
}
$traffic = doubleval_ressource ( $_POST [ 'traffic' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'traffic_ul' ])) {
2010-01-20 16:55:27 +00:00
$traffic = - 1 ;
}
$subdomains = intval_ressource ( $_POST [ 'subdomains' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'subdomains_ul' ])) {
2010-01-20 16:55:27 +00:00
$subdomains = - 1 ;
}
$emails = intval_ressource ( $_POST [ 'emails' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'emails_ul' ])) {
2010-01-20 16:55:27 +00:00
$emails = - 1 ;
}
$email_accounts = intval_ressource ( $_POST [ 'email_accounts' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_accounts_ul' ])) {
2010-01-20 16:55:27 +00:00
$email_accounts = - 1 ;
}
$email_forwarders = intval_ressource ( $_POST [ 'email_forwarders' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_forwarders_ul' ])) {
2010-01-20 16:55:27 +00:00
$email_forwarders = - 1 ;
}
2013-11-06 07:46:45 +00:00
if ( $settings [ 'system' ][ 'mail_quota_enabled' ] == '1' ) {
2010-01-20 16:55:27 +00:00
$email_quota = validate ( $_POST [ 'email_quota' ], 'email_quota' , '/^\d+$/' , 'vmailquotawrong' , array ( '0' , '' ));
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_quota_ul' ])) {
2010-01-20 16:55:27 +00:00
$email_quota = - 1 ;
}
2013-11-06 07:46:45 +00:00
} else {
2010-01-20 16:55:27 +00:00
$email_quota = - 1 ;
}
2011-06-18 17:48:16 +00:00
2013-11-06 07:46:45 +00:00
if ( $settings [ 'autoresponder' ][ 'autoresponder_active' ] == '1' ) {
2010-09-20 07:56:32 +00:00
$email_autoresponder = intval_ressource ( $_POST [ 'email_autoresponder' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_autoresponder_ul' ])) {
2010-09-20 07:56:32 +00:00
$email_autoresponder = - 1 ;
}
2013-11-06 07:46:45 +00:00
} else {
2010-09-20 07:56:32 +00:00
$email_autoresponder = 0 ;
}
2010-01-20 16:55:27 +00:00
2011-03-30 12:37:57 +00:00
$email_imap = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_imap' ])) {
2011-03-30 12:37:57 +00:00
$email_imap = intval_ressource ( $_POST [ 'email_imap' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$email_pop3 = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_pop3' ])) {
2011-03-30 12:37:57 +00:00
$email_pop3 = intval_ressource ( $_POST [ 'email_pop3' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$ftps = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'ftps' ])) {
2011-03-30 12:37:57 +00:00
$ftps = intval_ressource ( $_POST [ 'ftps' ]);
2013-11-06 07:46:45 +00:00
}
if ( isset ( $_POST [ 'ftps_ul' ])) {
2010-01-20 16:55:27 +00:00
$ftps = - 1 ;
}
$tickets = ( $settings [ 'ticket' ][ 'enabled' ] == 1 ? intval_ressource ( $_POST [ 'tickets' ]) : 0 );
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'tickets_ul' ])
&& $settings [ 'ticket' ][ 'enabled' ] == '1'
) {
2010-01-20 16:55:27 +00:00
$tickets = - 1 ;
}
$mysqls = intval_ressource ( $_POST [ 'mysqls' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'mysqls_ul' ])) {
2010-01-20 16:55:27 +00:00
$mysqls = - 1 ;
}
2013-11-06 07:46:45 +00:00
if ( $settings [ 'aps' ][ 'aps_active' ] == '1' ) {
2010-01-20 16:55:27 +00:00
$number_of_aps_packages = intval_ressource ( $_POST [ 'number_of_aps_packages' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'number_of_aps_packages_ul' ])) {
2010-01-20 16:55:27 +00:00
$number_of_aps_packages = - 1 ;
}
2013-11-06 07:46:45 +00:00
} else {
2010-01-20 16:55:27 +00:00
$number_of_aps_packages = 0 ;
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$createstdsubdomain = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'createstdsubdomain' ])) {
2011-03-30 12:37:57 +00:00
$createstdsubdomain = intval ( $_POST [ 'createstdsubdomain' ]);
2013-11-06 07:46:45 +00:00
}
2010-05-11 06:19:44 +00:00
$password = validate ( $_POST [ 'new_customer_password' ], 'password' );
2010-12-02 09:52:56 +00:00
// only check if not empty,
// cause empty == generate password automatically
2013-11-06 07:46:45 +00:00
if ( $password != '' ) {
2010-12-02 09:52:56 +00:00
$password = validatePassword ( $password );
}
2011-06-18 17:48:16 +00:00
2011-04-24 00:18:50 +00:00
$backup_allowed = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'backup_allowed' ])) {
2011-04-24 00:18:50 +00:00
$backup_allowed = intval ( $_POST [ 'backup_allowed' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2013-11-06 07:46:45 +00:00
if ( $backup_allowed != 0 ) {
2011-04-24 00:18:50 +00:00
$backup_allowed = 1 ;
}
2011-06-18 17:48:16 +00:00
2011-05-12 16:58:01 +00:00
// gender out of range? [0,2]
if ( $gender < 0 || $gender > 2 ) {
$gender = 0 ;
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$sendpassword = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'sendpassword' ])) {
2011-03-30 12:37:57 +00:00
$sendpassword = intval ( $_POST [ 'sendpassword' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$phpenabled = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'phpenabled' ])) {
2011-03-30 12:37:57 +00:00
$phpenabled = intval ( $_POST [ 'phpenabled' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$perlenabled = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'perlenabled' ])) {
2011-03-30 12:37:57 +00:00
$perlenabled = intval ( $_POST [ 'perlenabled' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$store_defaultindex = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'store_defaultindex' ])) {
2011-03-30 12:37:57 +00:00
$store_defaultindex = intval ( $_POST [ 'store_defaultindex' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2010-01-20 16:55:27 +00:00
$diskspace = $diskspace * 1024 ;
$traffic = $traffic * 1024 * 1024 ;
2013-11-06 07:46:45 +00:00
if (((( $userinfo [ 'diskspace_used' ] + $diskspace ) > $userinfo [ 'diskspace' ]) && ( $userinfo [ 'diskspace' ] / 1024 ) != '-1' )
2010-01-20 16:55:27 +00:00
|| ((( $userinfo [ 'mysqls_used' ] + $mysqls ) > $userinfo [ 'mysqls' ]) && $userinfo [ 'mysqls' ] != '-1' )
|| ((( $userinfo [ 'emails_used' ] + $emails ) > $userinfo [ 'emails' ]) && $userinfo [ 'emails' ] != '-1' )
|| ((( $userinfo [ 'email_accounts_used' ] + $email_accounts ) > $userinfo [ 'email_accounts' ]) && $userinfo [ 'email_accounts' ] != '-1' )
|| ((( $userinfo [ 'email_forwarders_used' ] + $email_forwarders ) > $userinfo [ 'email_forwarders' ]) && $userinfo [ 'email_forwarders' ] != '-1' )
|| ((( $userinfo [ 'email_quota_used' ] + $email_quota ) > $userinfo [ 'email_quota' ]) && $userinfo [ 'email_quota' ] != '-1' && $settings [ 'system' ][ 'mail_quota_enabled' ] == '1' )
2010-09-20 07:56:32 +00:00
|| ((( $userinfo [ 'email_autoresponder_used' ] + $email_autoresponder ) > $userinfo [ 'email_autoresponder' ]) && $userinfo [ 'email_autoresponder' ] != '-1' && $settings [ 'autoresponder' ][ 'autoresponder_active' ] == '1' )
2010-01-20 16:55:27 +00:00
|| ((( $userinfo [ 'ftps_used' ] + $ftps ) > $userinfo [ 'ftps' ]) && $userinfo [ 'ftps' ] != '-1' )
|| ((( $userinfo [ 'tickets_used' ] + $tickets ) > $userinfo [ 'tickets' ]) && $userinfo [ 'tickets' ] != '-1' )
|| ((( $userinfo [ 'subdomains_used' ] + $subdomains ) > $userinfo [ 'subdomains' ]) && $userinfo [ 'subdomains' ] != '-1' )
|| ((( $userinfo [ 'aps_packages_used' ] + $number_of_aps_packages ) > $userinfo [ 'aps_packages' ]) && $userinfo [ 'aps_packages' ] != '-1' && $settings [ 'aps' ][ 'aps_active' ] == '1' )
|| (( $diskspace / 1024 ) == '-1' && ( $userinfo [ 'diskspace' ] / 1024 ) != '-1' )
|| ( $mysqls == '-1' && $userinfo [ 'mysqls' ] != '-1' )
|| ( $emails == '-1' && $userinfo [ 'emails' ] != '-1' )
|| ( $email_accounts == '-1' && $userinfo [ 'email_accounts' ] != '-1' )
|| ( $email_forwarders == '-1' && $userinfo [ 'email_forwarders' ] != '-1' )
|| ( $email_quota == '-1' && $userinfo [ 'email_quota' ] != '-1' && $settings [ 'system' ][ 'mail_quota_enabled' ] == '1' )
2010-09-20 07:56:32 +00:00
|| ( $email_autoresponder == '-1' && $userinfo [ 'email_autoresponder' ] != '-1' && $settings [ 'autoresponder' ][ 'autoresponder_active' ] == '1' )
2010-01-20 16:55:27 +00:00
|| ( $ftps == '-1' && $userinfo [ 'ftps' ] != '-1' )
|| ( $tickets == '-1' && $userinfo [ 'tickets' ] != '-1' )
|| ( $subdomains == '-1' && $userinfo [ 'subdomains' ] != '-1' )
2013-11-06 07:46:45 +00:00
|| ( $number_of_aps_packages == '-1' && $userinfo [ 'aps_packages' ] != '-1' )
) {
2010-01-20 16:55:27 +00:00
standard_error ( 'youcantallocatemorethanyouhave' );
exit ;
}
// Either $name and $firstname or the $company must be inserted
2013-11-06 07:46:45 +00:00
if ( $name == '' && $company == '' ) {
2010-01-20 16:55:27 +00:00
standard_error ( array ( 'stringisempty' , 'myname' ));
2013-11-06 07:46:45 +00:00
} elseif ( $firstname == '' && $company == '' ) {
2010-01-20 16:55:27 +00:00
standard_error ( array ( 'stringisempty' , 'myfirstname' ));
2013-11-06 07:46:45 +00:00
} elseif ( $email == '' ) {
2010-01-20 16:55:27 +00:00
standard_error ( array ( 'stringisempty' , 'emailadd' ));
2013-11-06 07:46:45 +00:00
} elseif ( ! validateEmail ( $email )) {
2010-01-20 16:55:27 +00:00
standard_error ( 'emailiswrong' , $email );
2013-11-06 07:46:45 +00:00
} else {
if ( isset ( $_POST [ 'new_loginname' ])
&& $_POST [ 'new_loginname' ] != ''
) {
2010-01-20 16:55:27 +00:00
$accountnumber = intval ( $settings [ 'system' ][ 'lastaccountnumber' ]);
2010-05-11 06:19:44 +00:00
$loginname = validate ( $_POST [ 'new_loginname' ], 'loginname' , '/^[a-z0-9\-_]+$/i' );
2010-01-20 16:55:27 +00:00
// Accounts which match systemaccounts are not allowed, filtering them
2013-11-06 07:46:45 +00:00
if ( preg_match ( '/^' . preg_quote ( $settings [ 'customer' ][ 'accountprefix' ], '/' ) . '([0-9]+)/' , $loginname )) {
2010-01-20 16:55:27 +00:00
standard_error ( 'loginnameissystemaccount' , $settings [ 'customer' ][ 'accountprefix' ]);
}
2013-11-06 07:46:45 +00:00
// Additional filtering for Bug #962
if ( function_exists ( 'posix_getpwnam' )
&& ! in_array ( " posix_getpwnam " , explode ( " , " , ini_get ( 'disable_functions' )))
&& posix_getpwnam ( $loginname )
) {
2011-12-06 15:04:35 +00:00
standard_error ( 'loginnameissystemaccount' , $settings [ 'customer' ][ 'accountprefix' ]);
}
2013-11-06 07:46:45 +00:00
} else {
2010-01-20 16:55:27 +00:00
$accountnumber = intval ( $settings [ 'system' ][ 'lastaccountnumber' ]) + 1 ;
$loginname = $settings [ 'customer' ][ 'accountprefix' ] . $accountnumber ;
}
// Check if the account already exists
2013-11-06 07:46:45 +00:00
$loginname_check_stmt = Database :: prepare ( "
SELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname` = : loginname "
);
2013-11-08 08:31:51 +00:00
$loginname_check = Database :: pexecute_first ( $loginname_check_stmt , array ( 'loginname' => $loginname ));
2010-01-20 16:55:27 +00:00
2013-11-06 07:46:45 +00:00
$loginname_check_admin_stmt = Database :: prepare ( "
SELECT `loginname` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `loginname` = : loginname "
);
2013-11-08 08:31:51 +00:00
$loginname_check_admin = Database :: pexecute_first ( $loginname_check_admin_stmt , array ( 'loginname' => $loginname ));
2010-01-20 16:55:27 +00:00
2013-11-06 07:46:45 +00:00
if ( strtolower ( $loginname_check [ 'loginname' ]) == strtolower ( $loginname )
|| strtolower ( $loginname_check_admin [ 'loginname' ]) == strtolower ( $loginname )
) {
2010-01-20 16:55:27 +00:00
standard_error ( 'loginnameexists' , $loginname );
2013-11-06 07:46:45 +00:00
} elseif ( ! validateUsername ( $loginname , $settings [ 'panel' ][ 'unix_names' ], 14 - strlen ( $settings [ 'customer' ][ 'mysqlprefix' ]))) {
2010-01-20 16:55:27 +00:00
standard_error ( 'loginnameiswrong' , $loginname );
}
$guid = intval ( $settings [ 'system' ][ 'lastguid' ]) + 1 ;
$documentroot = makeCorrectDir ( $settings [ 'system' ][ 'documentroot_prefix' ] . '/' . $loginname );
2013-11-06 07:46:45 +00:00
if ( file_exists ( $documentroot )) {
2010-01-20 16:55:27 +00:00
standard_error ( 'documentrootexists' , $documentroot );
}
2013-11-06 07:46:45 +00:00
if ( $createstdsubdomain != '1' ) {
2010-01-20 16:55:27 +00:00
$createstdsubdomain = '0' ;
}
2013-11-06 07:46:45 +00:00
if ( $phpenabled != '0' ) {
2010-01-20 16:55:27 +00:00
$phpenabled = '1' ;
}
2013-11-06 07:46:45 +00:00
if ( $perlenabled != '0' ) {
2010-07-22 06:02:38 +00:00
$perlenabled = '1' ;
}
2013-11-06 07:46:45 +00:00
if ( $password == '' ) {
2010-01-20 16:55:27 +00:00
$password = substr ( md5 ( uniqid ( microtime (), 1 )), 12 , 6 );
}
2011-02-08 11:53:24 +00:00
$_theme = $settings [ 'panel' ][ 'default_theme' ];
2013-11-06 07:46:45 +00:00
$ins_data = array (
'adminid' => $userinfo [ 'adminid' ],
'loginname' => $loginname ,
'passwd' => md5 ( $password ),
'name' => $name ,
'firstname' => $firstname ,
'gender' => $gender ,
'company' => $company ,
'street' => $street ,
'zipcode' => $zipcode ,
'city' => $city ,
'phone' => $phone ,
'fax' => $fax ,
'email' => $email ,
'customerno' => $customernumber ,
'lang' => $def_language ,
'docroot' => $documentroot ,
'guid' => $guid ,
'diskspace' => $diskspace ,
'traffic' => $traffic ,
'subdomains' => $subdomains ,
'emails' => $emails ,
'email_accounts' => $email_accounts ,
'email_forwarders' => $email_forwarders ,
'email_quota' => $email_quota ,
'ftps' => $ftps ,
'tickets' => $tickets ,
'mysqls' => $mysqls ,
'phpenabled' => $phpenabled ,
'imap' => $email_imap ,
'pop3' => $email_pop3 ,
'aps' => $number_of_aps_packages ,
'perlenabled' => $perlenabled ,
'email_autoresponder' => $email_autoresponder ,
'backup_allowed' => $backup_allowed ,
'theme' => $theme
);
$ins_stmt = Database :: prepare ( "
INSERT INTO `" . TABLE_PANEL_CUSTOMERS . "` SET
`adminid` = : adminid ,
`loginname` = : loginname ,
`password` = : passwd ,
`name` = : name ,
`firstname` = : firstname ,
`gender` = : gender ,
`company` = : company ,
`street` = : street ,
`zipcode` = : zipcode ,
`city` = : city ,
`phone` = : phone ,
`fax` = : fax ,
`email` = : email ,
`customernumber` = : customerno ,
`def_language` = : lang ,
`documentroot` = : docroot ,
`guid` = : guid ,
`diskspace` = : diskspace ,
`traffic` = : traffic ,
`subdomains` = : subdomains ,
`emails` = : emails ,
`email_accounts` = : email_accounts ,
`email_forwarders` = : email_forwarders ,
`email_quota` = : email_quota ,
`ftps` = : ftps ,
`tickets` = : tickets ,
2013-11-06 10:29:40 +00:00
`mysqls` = : mysqls ,
2011-06-18 17:48:16 +00:00
`standardsubdomain` = '0' ,
2013-11-06 07:46:45 +00:00
`phpenabled` = : phpenabled ,
`imap` = : imap ,
`pop3` = : pop3 ,
`aps_packages` = : aps ,
`perlenabled` = : perlenabled ,
`email_autoresponder` = : email_autoresponder ,
`backup_allowed` = : backup_allowed ,
`theme` = : theme "
2011-02-08 11:53:24 +00:00
);
2013-11-06 07:46:45 +00:00
Database :: pexecute ( $ins_stmt , $ins_data );
$customerid = Database :: lastInsertId ();
2010-01-20 16:55:27 +00:00
$admin_update_query = " UPDATE ` " . TABLE_PANEL_ADMINS . " ` SET `customers_used` = `customers_used` + 1 " ;
2013-11-06 07:46:45 +00:00
if ( $mysqls != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `mysqls_used` = `mysqls_used` + 0 " . ( int ) $mysqls ;
}
2013-11-06 07:46:45 +00:00
if ( $emails != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `emails_used` = `emails_used` + 0 " . ( int ) $emails ;
}
2013-11-06 07:46:45 +00:00
if ( $email_accounts != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `email_accounts_used` = `email_accounts_used` + 0 " . ( int ) $email_accounts ;
}
2013-11-06 07:46:45 +00:00
if ( $email_forwarders != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `email_forwarders_used` = `email_forwarders_used` + 0 " . ( int ) $email_forwarders ;
}
2013-11-06 07:46:45 +00:00
if ( $email_quota != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `email_quota_used` = `email_quota_used` + 0 " . ( int ) $email_quota ;
}
2013-11-06 07:46:45 +00:00
if ( $email_autoresponder != '-1'
&& $settings [ 'autoresponder' ][ 'autoresponder_active' ] == 1
) {
2010-09-20 07:56:32 +00:00
$admin_update_query .= " , `email_autoresponder_used` = `email_autoresponder_used` + 0 " . ( int ) $email_autoresponder ;
}
2013-11-06 07:46:45 +00:00
if ( $subdomains != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `subdomains_used` = `subdomains_used` + 0 " . ( int ) $subdomains ;
}
2013-11-06 07:46:45 +00:00
if ( $ftps != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `ftps_used` = `ftps_used` + 0 " . ( int ) $ftps ;
}
2013-11-06 07:46:45 +00:00
if ( $tickets != '-1'
&& $settings [ 'ticket' ][ 'enabled' ] == 1
) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `tickets_used` = `tickets_used` + 0 " . ( int ) $tickets ;
}
2013-11-06 07:46:45 +00:00
if (( $diskspace / 1024 ) != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `diskspace_used` = `diskspace_used` + 0 " . ( int ) $diskspace ;
}
2013-11-06 07:46:45 +00:00
if ( $number_of_aps_packages != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `aps_packages_used` = `aps_packages_used` + 0 " . ( int ) $number_of_aps_packages ;
}
$admin_update_query .= " WHERE `adminid` = ' " . ( int ) $userinfo [ 'adminid' ] . " ' " ;
2013-11-06 07:46:45 +00:00
Database :: query ( $admin_update_query );
2010-01-20 16:55:27 +00:00
2013-11-06 07:46:45 +00:00
$upd_stmt = Database :: prepare ( "
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET
`value` = : guid
WHERE `settinggroup` = 'system' AND `varname` = 'lastguid' "
);
Database :: pexecute ( $upd_stmt , array ( 'guid' => $guid ));
if ( $accountnumber != intval ( $settings [ 'system' ][ 'lastaccountnumber' ])) {
$upd_stmt = Database :: prepare ( "
UPDATE `" . TABLE_PANEL_SETTINGS . "` SET
`value` = : accno
WHERE `settinggroup` = 'system' AND `varname` = 'lastaccountnumber' "
);
Database :: pexecute ( $upd_stmt , array ( 'accno' => $accountnumber ));
2010-01-20 16:55:27 +00:00
}
$log -> logAction ( ADM_ACTION , LOG_INFO , " added user ' " . $loginname . " ' " );
2010-10-23 10:20:23 +00:00
inserttask ( '2' , $loginname , $guid , $guid , $store_defaultindex );
2010-01-20 16:55:27 +00:00
2013-03-29 19:10:37 +00:00
// Using filesystem - quota, insert a task which cleans the filesystem - quota
inserttask ( '10' );
2010-01-20 16:55:27 +00:00
2013-03-29 19:10:37 +00:00
// Add htpasswd for the webalizer stats
2013-11-06 07:46:45 +00:00
if ( CRYPT_STD_DES == 1 ) {
2010-01-20 16:55:27 +00:00
$saltfordescrypt = substr ( md5 ( uniqid ( microtime (), 1 )), 4 , 2 );
$htpasswdPassword = crypt ( $password , $saltfordescrypt );
2013-11-06 07:46:45 +00:00
} else {
2010-01-20 16:55:27 +00:00
$htpasswdPassword = crypt ( $password );
}
2013-11-06 07:46:45 +00:00
$ins_stmt = Database :: prepare ( "
INSERT INTO `" . TABLE_PANEL_HTPASSWDS . "` SET
`customerid` = : customerid ,
`username` = : username ,
`password` = : passwd ,
`path` = : path "
);
$ins_data = array (
'customerid' => $customerid ,
'username' => $loginname ,
'passwd' => $htpasswdPassword
);
if ( $settings [ 'system' ][ 'awstats_enabled' ] == '1' ) {
$ins_data [ 'path' ] = makeCorrectDir ( $documentroot . '/awstats/' );
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " automatically added awstats htpasswd for user ' " . $loginname . " ' " );
2013-11-06 07:46:45 +00:00
} else {
$ins_data [ 'path' ] = makeCorrectDir ( $documentroot . '/webalizer/' );
2010-03-22 12:36:59 +00:00
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " automatically added webalizer htpasswd for user ' " . $loginname . " ' " );
}
2013-11-06 07:46:45 +00:00
Database :: pexecute ( $ins_stmt , $ins_data );
2010-01-20 16:55:27 +00:00
2010-10-23 10:20:23 +00:00
inserttask ( '1' );
2013-04-14 16:41:21 +00:00
$cryptPassword = makeCryptPassword ( $password );
2013-11-06 07:46:45 +00:00
// FTP-User
$ins_stmt = Database :: prepare ( "
INSERT INTO `" . TABLE_FTP_USERS . "` SET `customerid` = : customerid , `username` = : username ,
`password` = : passwd , `homedir` = : homedir , `login_enabled` = 'y' , `uid` = : guid , `gid` = : guid "
);
$ins_data = array (
'customerid' => $customerid ,
'username' => $loginname ,
'passwd' => $cryptPassword ,
'homedir' => $documentroot ,
'guid' => $guid
);
Database :: pexecute ( $ins_stmt , $ins_data );
// FTP-Group
$ins_stmt = Database :: prepare ( "
INSERT INTO `" . TABLE_FTP_GROUPS . "` SET `customerid` = : customerid , `groupname` = : groupname , `gid` = : guid , `members` = : members "
);
$ins_data = array (
'customerid' => $customerid ,
'groupname' => $loginname ,
'guid' => $guid ,
'members' => $loginname
);
Database :: pexecute ( $ins_stmt , $ins_data );
// FTP-Quotatallies
$ins_stmt = Database :: prepare ( "
INSERT INTO `" . TABLE_FTP_QUOTATALLIES . "` SET `name` = : name , `quota_type` = 'user' , `bytes_in_used` = '0' ,
`bytes_out_used` = '0' , `bytes_xfer_used` = '0' , `files_in_used` = '0' , `files_out_used` = '0' , `files_xfer_used` = '0' "
);
Database :: pexecute ( $ins_stmt , array ( 'name' => $loginname ));
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " automatically added ftp-account for user ' " . $loginname . " ' " );
2013-11-06 07:46:45 +00:00
if ( $createstdsubdomain == '1' ) {
2010-04-02 13:51:25 +00:00
if ( isset ( $settings [ 'system' ][ 'stdsubdomain' ])
&& $settings [ 'system' ][ 'stdsubdomain' ] != ''
) {
$_stdsubdomain = $loginname . '.' . $settings [ 'system' ][ 'stdsubdomain' ];
2013-11-06 07:46:45 +00:00
} else {
2010-04-02 13:51:25 +00:00
$_stdsubdomain = $loginname . '.' . $settings [ 'system' ][ 'hostname' ];
}
2013-11-06 07:46:45 +00:00
$ins_data = array (
'domain' => $_stdsubdomain ,
'customerid' => $customerid ,
'adminid' => $userinfo [ 'adminid' ],
'docroot' => $documentroot ,
'adddate' => date ( 'Y-m-d' )
);
$ins_stmt = Database :: prepare ( "
INSERT INTO `" . TABLE_PANEL_DOMAINS . "` SET
`domain` = : domain ,
`customerid` = : customerid ,
`adminid` = : adminid ,
`parentdomainid` = '-1' ,
`documentroot` = : docroot ,
`zonefile` = '' ,
`isemaildomain` = '0' ,
`caneditdomain` = '0' ,
`openbasedir` = '1' ,
`speciallogfile` = '0' ,
2013-11-07 09:26:54 +00:00
`specialsettings` = '' ,
2013-11-06 07:46:45 +00:00
`add_date` = : adddate "
);
Database :: pexecute ( $ins_stmt , $ins_data );
$domainid = Database :: lastInsertId ();
2013-09-24 15:32:40 +00:00
// set ip <-> domain connection
2013-11-06 07:46:45 +00:00
$ins_stmt = Database :: prepare ( "
2013-11-09 12:56:27 +00:00
INSERT INTO `".TABLE_DOMAINTOIP."` SET `id_domain` = : domainid , `id_ipandports` = : ipid "
2013-09-24 15:32:40 +00:00
);
2013-11-06 07:46:45 +00:00
Database :: pexecute ( $ins_stmt , array ( 'domainid' => $domainid , 'ipid' => $settings [ 'system' ][ 'defaultip' ]));
2013-09-24 15:32:40 +00:00
2013-11-06 07:46:45 +00:00
$upd_stmt = Database :: prepare ( "
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `standardsubdomain` = : domainid WHERE `customerid` = : customerid "
);
Database :: pexecute ( $upd_stmt , array ( 'domainid' => $domainid , 'customerid' => $customerid ));
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " automatically added standardsubdomain for user ' " . $loginname . " ' " );
2010-10-23 10:20:23 +00:00
inserttask ( '1' );
2010-01-20 16:55:27 +00:00
}
2013-11-06 07:46:45 +00:00
if ( $sendpassword == '1' ) {
2010-01-20 16:55:27 +00:00
$replace_arr = array (
'FIRSTNAME' => $firstname ,
'NAME' => $name ,
'COMPANY' => $company ,
'SALUTATION' => getCorrectUserSalutation ( array ( 'firstname' => $firstname , 'name' => $name , 'company' => $company )),
'USERNAME' => $loginname ,
'PASSWORD' => $password
);
// Get mail templates from database; the ones from 'admin' are fetched for fallback
2013-11-06 07:46:45 +00:00
$result_stmt = Database :: prepare ( "
SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = : adminid AND `language` = : deflang AND `templategroup` = 'mails' AND `varname` = 'createcustomer_subject' "
);
2013-11-08 08:31:51 +00:00
$result = Database :: pexecute_first ( $result_stmt , array ( 'adminid' => $userinfo [ 'adminid' ], 'deflang' => $def_language ));
2010-01-20 16:55:27 +00:00
$mail_subject = html_entity_decode ( replace_variables ((( $result [ 'value' ] != '' ) ? $result [ 'value' ] : $lng [ 'mails' ][ 'createcustomer' ][ 'subject' ]), $replace_arr ));
2013-11-06 07:46:45 +00:00
$result_stmt = Database :: prepare ( "
SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = : adminid AND `language` = : deflang AND `templategroup` = 'mails' AND `varname` = 'createcustomer_mailbody' "
);
2013-11-08 08:31:51 +00:00
$result = Database :: pexecute_first ( $result_stmt , array ( 'adminid' => $userinfo [ 'adminid' ], 'deflang' => $def_language ));
2010-01-20 16:55:27 +00:00
$mail_body = html_entity_decode ( replace_variables ((( $result [ 'value' ] != '' ) ? $result [ 'value' ] : $lng [ 'mails' ][ 'createcustomer' ][ 'mailbody' ]), $replace_arr ));
2010-03-03 08:51:13 +00:00
$_mailerror = false ;
try {
$mail -> Subject = $mail_subject ;
$mail -> AltBody = $mail_body ;
2010-03-05 07:13:00 +00:00
$mail -> MsgHTML ( str_replace ( " \n " , " <br /> " , $mail_body ));
2010-03-03 08:51:13 +00:00
$mail -> AddAddress ( $email , getCorrectUserSalutation ( array ( 'firstname' => $firstname , 'name' => $name , 'company' => $company )));
$mail -> Send ();
} catch ( phpmailerException $e ) {
$mailerr_msg = $e -> errorMessage ();
$_mailerror = true ;
} catch ( Exception $e ) {
$mailerr_msg = $e -> getMessage ();
$_mailerror = true ;
}
2010-01-20 16:55:27 +00:00
2010-03-03 08:51:13 +00:00
if ( $_mailerror ) {
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_ERR , " Error sending mail: " . $mailerr_msg );
standard_error ( 'errorsendingmail' , $email );
}
$mail -> ClearAddresses ();
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " automatically sent password to user ' " . $loginname . " ' " );
}
2013-11-11 08:59:03 +00:00
redirectTo ( $filename , array ( 'page' => $page , 's' => $s ));
2010-01-20 16:55:27 +00:00
}
2013-11-06 07:46:45 +00:00
} else {
2010-01-20 16:55:27 +00:00
$language_options = '' ;
2013-11-06 07:46:45 +00:00
while ( list ( $language_file , $language_name ) = each ( $languages )) {
2010-09-27 09:53:12 +00:00
$language_options .= makeoption ( $language_name , $language_file , $settings [ 'panel' ][ 'standardlanguage' ], true );
2010-01-20 16:55:27 +00:00
}
$diskspace_ul = makecheckbox ( 'diskspace_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
$traffic_ul = makecheckbox ( 'traffic_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
$subdomains_ul = makecheckbox ( 'subdomains_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
$emails_ul = makecheckbox ( 'emails_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
$email_accounts_ul = makecheckbox ( 'email_accounts_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
$email_forwarders_ul = makecheckbox ( 'email_forwarders_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
$email_quota_ul = makecheckbox ( 'email_quota_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
2010-09-20 07:56:32 +00:00
$email_autoresponder_ul = makecheckbox ( 'email_autoresponder_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
2010-01-20 16:55:27 +00:00
$ftps_ul = makecheckbox ( 'ftps_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
$tickets_ul = makecheckbox ( 'tickets_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
$mysqls_ul = makecheckbox ( 'mysqls_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
$number_of_aps_packages_ul = makecheckbox ( 'number_of_aps_packages_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , '0' , true , true );
2011-06-18 17:48:16 +00:00
2011-05-12 16:58:01 +00:00
$gender_options = makeoption ( $lng [ 'gender' ][ 'undef' ], 0 , true , true , true );
$gender_options .= makeoption ( $lng [ 'gender' ][ 'male' ], 1 , null , true , true );
$gender_options .= makeoption ( $lng [ 'gender' ][ 'female' ], 2 , null , true , true );
2011-06-18 17:48:16 +00:00
2011-02-08 11:53:24 +00:00
$customer_add_data = include_once dirname ( __FILE__ ) . '/lib/formfields/admin/customer/formfield.customer_add.php' ;
$customer_add_form = htmlform :: genHTMLForm ( $customer_add_data );
$title = $customer_add_data [ 'customer_add' ][ 'title' ];
$image = $customer_add_data [ 'customer_add' ][ 'image' ];
2010-01-20 16:55:27 +00:00
eval ( " echo \" " . getTemplate ( " customers/customers_add " ) . " \" ; " );
}
}
2013-11-06 07:46:45 +00:00
} elseif ( $action == 'edit'
&& $id != 0
) {
2013-11-06 10:29:40 +00:00
$result_data = array ( 'id' => $id );
2013-11-06 07:46:45 +00:00
$result_stmt = Database :: prepare ( "
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
2013-11-06 10:29:40 +00:00
WHERE `customerid` = : id " . ( $userinfo['customers_see_all'] ? '' : " AND `adminid` = : adminid " )
2013-11-06 07:46:45 +00:00
);
2013-11-06 10:29:40 +00:00
if ( $userinfo [ 'customers_see_all' ] == '0' ) {
$result_data [ 'adminid' ] = $userinfo [ 'adminid' ];
}
$result = Database :: pexecute_first ( $result_stmt , $result_data );
2013-11-06 07:46:45 +00:00
if ( $result [ 'loginname' ] != '' ) {
if ( isset ( $_POST [ 'send' ])
&& $_POST [ 'send' ] == 'send'
) {
2010-01-20 16:55:27 +00:00
$name = validate ( $_POST [ 'name' ], 'name' );
$firstname = validate ( $_POST [ 'firstname' ], 'first name' );
$company = validate ( $_POST [ 'company' ], 'company' );
$street = validate ( $_POST [ 'street' ], 'street' );
$zipcode = validate ( $_POST [ 'zipcode' ], 'zipcode' , '/^[0-9 \-A-Z]*$/' );
$city = validate ( $_POST [ 'city' ], 'city' );
$phone = validate ( $_POST [ 'phone' ], 'phone' , '/^[0-9\- \+\(\)\/]*$/' );
$fax = validate ( $_POST [ 'fax' ], 'fax' , '/^[0-9\- \+\(\)\/]*$/' );
$email = $idna_convert -> encode ( validate ( $_POST [ 'email' ], 'email' ));
$customernumber = validate ( $_POST [ 'customernumber' ], 'customer number' , '/^[A-Za-z0-9 \-]*$/Di' );
$def_language = validate ( $_POST [ 'def_language' ], 'default language' );
2010-05-11 06:19:44 +00:00
$password = validate ( $_POST [ 'new_customer_password' ], 'new password' );
2011-05-18 11:56:18 +00:00
$gender = intval_ressource ( $_POST [ 'gender' ]);
2010-01-20 16:55:27 +00:00
2013-11-06 07:46:45 +00:00
$diskspace = intval_ressource ( $_POST [ 'diskspace' ]);
if ( isset ( $_POST [ 'diskspace_ul' ])) {
2010-01-20 16:55:27 +00:00
$diskspace = - 1 ;
}
$traffic = doubleval_ressource ( $_POST [ 'traffic' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'traffic_ul' ])) {
2010-01-20 16:55:27 +00:00
$traffic = - 1 ;
}
$subdomains = intval_ressource ( $_POST [ 'subdomains' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'subdomains_ul' ])) {
2010-01-20 16:55:27 +00:00
$subdomains = - 1 ;
}
$emails = intval_ressource ( $_POST [ 'emails' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'emails_ul' ])) {
2010-01-20 16:55:27 +00:00
$emails = - 1 ;
}
$email_accounts = intval_ressource ( $_POST [ 'email_accounts' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_accounts_ul' ])) {
2010-01-20 16:55:27 +00:00
$email_accounts = - 1 ;
}
$email_forwarders = intval_ressource ( $_POST [ 'email_forwarders' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_forwarders_ul' ])) {
2010-01-20 16:55:27 +00:00
$email_forwarders = - 1 ;
}
2013-11-06 07:46:45 +00:00
if ( $settings [ 'system' ][ 'mail_quota_enabled' ] == '1' ) {
2010-01-20 16:55:27 +00:00
$email_quota = validate ( $_POST [ 'email_quota' ], 'email_quota' , '/^\d+$/' , 'vmailquotawrong' , array ( '0' , '' ));
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_quota_ul' ])) {
2010-01-20 16:55:27 +00:00
$email_quota = - 1 ;
}
2013-11-06 07:46:45 +00:00
} else {
2010-01-20 16:55:27 +00:00
$email_quota = - 1 ;
}
2013-11-06 07:46:45 +00:00
if ( $settings [ 'autoresponder' ][ 'autoresponder_active' ] == '1' ) {
2010-09-20 07:56:32 +00:00
$email_autoresponder = intval_ressource ( $_POST [ 'email_autoresponder' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_autoresponder_ul' ])) {
2010-09-20 07:56:32 +00:00
$email_autoresponder = - 1 ;
}
2013-11-06 07:46:45 +00:00
} else {
2010-09-20 07:56:32 +00:00
$email_autoresponder = 0 ;
2011-06-18 17:48:16 +00:00
}
2010-09-20 07:56:32 +00:00
2011-03-30 12:37:57 +00:00
$email_imap = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_imap' ])) {
2011-03-30 12:37:57 +00:00
$email_imap = intval_ressource ( $_POST [ 'email_imap' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$email_pop3 = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'email_pop3' ])) {
2011-03-30 12:37:57 +00:00
$email_pop3 = intval_ressource ( $_POST [ 'email_pop3' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$ftps = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'ftps' ])) {
2011-03-30 12:37:57 +00:00
$ftps = intval_ressource ( $_POST [ 'ftps' ]);
2013-11-06 07:46:45 +00:00
}
if ( isset ( $_POST [ 'ftps_ul' ])) {
2010-01-20 16:55:27 +00:00
$ftps = - 1 ;
}
$tickets = ( $settings [ 'ticket' ][ 'enabled' ] == 1 ? intval_ressource ( $_POST [ 'tickets' ]) : 0 );
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'tickets_ul' ])
&& $settings [ 'ticket' ][ 'enabled' ] == '1'
) {
2010-01-20 16:55:27 +00:00
$tickets = - 1 ;
}
2011-06-18 17:48:16 +00:00
2011-04-24 00:18:50 +00:00
$backup_allowed = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'backup_allowed' ])) {
2011-04-24 00:18:50 +00:00
$backup_allowed = intval ( $_POST [ 'backup_allowed' ]);
2013-11-06 07:46:45 +00:00
}
if ( $backup_allowed != '0' ) {
2011-04-24 00:18:50 +00:00
$backup_allowed = 1 ;
}
2010-01-20 16:55:27 +00:00
2011-05-12 16:58:01 +00:00
// gender out of range? [0,2]
if ( $gender < 0 || $gender > 2 ) {
$gender = 0 ;
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$mysqls = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'mysqls' ])) {
2011-03-30 12:37:57 +00:00
$mysqls = intval_ressource ( $_POST [ 'mysqls' ]);
2013-11-06 07:46:45 +00:00
}
if ( isset ( $_POST [ 'mysqls_ul' ])) {
2010-01-20 16:55:27 +00:00
$mysqls = - 1 ;
}
2013-11-06 07:46:45 +00:00
if ( $settings [ 'aps' ][ 'aps_active' ] == '1' ) {
2010-02-21 21:09:48 +00:00
$number_of_aps_packages = intval_ressource ( $_POST [ 'number_of_aps_packages' ]);
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'number_of_aps_packages_ul' ])) {
2010-02-21 21:09:48 +00:00
$number_of_aps_packages = - 1 ;
}
2013-11-06 07:46:45 +00:00
} else {
2010-02-21 21:09:48 +00:00
$number_of_aps_packages = 0 ;
2010-01-20 16:55:27 +00:00
}
2011-03-30 12:37:57 +00:00
$createstdsubdomain = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'createstdsubdomain' ])) {
2011-03-30 12:37:57 +00:00
$createstdsubdomain = intval ( $_POST [ 'createstdsubdomain' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$deactivated = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'deactivated' ])) {
2011-03-30 12:37:57 +00:00
$deactivated = intval ( $_POST [ 'deactivated' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$phpenabled = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'phpenabled' ])) {
2011-03-30 12:37:57 +00:00
$phpenabled = intval ( $_POST [ 'phpenabled' ]);
2013-11-06 07:46:45 +00:00
}
2011-06-18 17:48:16 +00:00
2011-03-30 12:37:57 +00:00
$perlenabled = 0 ;
2013-11-06 07:46:45 +00:00
if ( isset ( $_POST [ 'perlenabled' ])) {
2011-03-30 12:37:57 +00:00
$perlenabled = intval ( $_POST [ 'perlenabled' ]);
2013-11-06 07:46:45 +00:00
}
2010-01-20 16:55:27 +00:00
$diskspace = $diskspace * 1024 ;
$traffic = $traffic * 1024 * 1024 ;
2013-11-06 07:46:45 +00:00
if (((( $userinfo [ 'diskspace_used' ] + $diskspace - $result [ 'diskspace' ]) > $userinfo [ 'diskspace' ]) && ( $userinfo [ 'diskspace' ] / 1024 ) != '-1' )
2010-01-20 16:55:27 +00:00
|| ((( $userinfo [ 'mysqls_used' ] + $mysqls - $result [ 'mysqls' ]) > $userinfo [ 'mysqls' ]) && $userinfo [ 'mysqls' ] != '-1' )
|| ((( $userinfo [ 'emails_used' ] + $emails - $result [ 'emails' ]) > $userinfo [ 'emails' ]) && $userinfo [ 'emails' ] != '-1' )
|| ((( $userinfo [ 'email_accounts_used' ] + $email_accounts - $result [ 'email_accounts' ]) > $userinfo [ 'email_accounts' ]) && $userinfo [ 'email_accounts' ] != '-1' )
|| ((( $userinfo [ 'email_forwarders_used' ] + $email_forwarders - $result [ 'email_forwarders' ]) > $userinfo [ 'email_forwarders' ]) && $userinfo [ 'email_forwarders' ] != '-1' )
|| ((( $userinfo [ 'email_quota_used' ] + $email_quota - $result [ 'email_quota' ]) > $userinfo [ 'email_quota' ]) && $userinfo [ 'email_quota' ] != '-1' && $settings [ 'system' ][ 'mail_quota_enabled' ] == '1' )
2010-09-20 07:56:32 +00:00
|| ((( $userinfo [ 'email_autoresponder_used' ] + $email_autoresponder - $result [ 'email_autoresponder' ]) > $userinfo [ 'email_autoresponder' ]) && $userinfo [ 'email_autoresponder' ] != '-1' && $settings [ 'autoresponder' ][ 'autoresponder_active' ] == '1' )
2010-01-20 16:55:27 +00:00
|| ((( $userinfo [ 'ftps_used' ] + $ftps - $result [ 'ftps' ]) > $userinfo [ 'ftps' ]) && $userinfo [ 'ftps' ] != '-1' )
|| ((( $userinfo [ 'tickets_used' ] + $tickets - $result [ 'tickets' ]) > $userinfo [ 'tickets' ]) && $userinfo [ 'tickets' ] != '-1' )
|| ((( $userinfo [ 'subdomains_used' ] + $subdomains - $result [ 'subdomains' ]) > $userinfo [ 'subdomains' ]) && $userinfo [ 'subdomains' ] != '-1' )
|| (( $diskspace / 1024 ) == '-1' && ( $userinfo [ 'diskspace' ] / 1024 ) != '-1' )
|| ((( $userinfo [ 'aps_packages' ] + $number_of_aps_packages - $result [ 'aps_packages' ]) > $userinfo [ 'aps_packages' ]) && $userinfo [ 'aps_packages' ] != '-1' && $settings [ 'aps' ][ 'aps_active' ] == '1' )
|| ( $mysqls == '-1' && $userinfo [ 'mysqls' ] != '-1' )
|| ( $emails == '-1' && $userinfo [ 'emails' ] != '-1' )
|| ( $email_accounts == '-1' && $userinfo [ 'email_accounts' ] != '-1' )
|| ( $email_forwarders == '-1' && $userinfo [ 'email_forwarders' ] != '-1' )
|| ( $email_quota == '-1' && $userinfo [ 'email_quota' ] != '-1' && $settings [ 'system' ][ 'mail_quota_enabled' ] == '1' )
2010-09-20 07:56:32 +00:00
|| ( $email_autoresponder == '-1' && $userinfo [ 'email_autoresponder' ] != '-1' && $settings [ 'autoresponder' ][ 'autoresponder_active' ] == '1' )
2010-01-20 16:55:27 +00:00
|| ( $ftps == '-1' && $userinfo [ 'ftps' ] != '-1' )
|| ( $tickets == '-1' && $userinfo [ 'tickets' ] != '-1' )
|| ( $subdomains == '-1' && $userinfo [ 'subdomains' ] != '-1' )
2013-11-06 07:46:45 +00:00
|| ( $number_of_aps_packages == '-1' && $userinfo [ 'aps_packages' ] != '-1' )
) {
2010-01-20 16:55:27 +00:00
standard_error ( 'youcantallocatemorethanyouhave' );
exit ;
}
// Either $name and $firstname or the $company must be inserted
2013-11-06 07:46:45 +00:00
if ( $name == '' && $company == '' ) {
2010-01-20 16:55:27 +00:00
standard_error ( array ( 'stringisempty' , 'myname' ));
2013-11-06 07:46:45 +00:00
} elseif ( $firstname == '' && $company == '' ) {
2010-01-20 16:55:27 +00:00
standard_error ( array ( 'stringisempty' , 'myfirstname' ));
2013-11-06 07:46:45 +00:00
} elseif ( $email == '' ) {
2010-01-20 16:55:27 +00:00
standard_error ( array ( 'stringisempty' , 'emailadd' ));
2013-11-06 07:46:45 +00:00
} elseif ( ! validateEmail ( $email )) {
2010-01-20 16:55:27 +00:00
standard_error ( 'emailiswrong' , $email );
2013-11-06 07:46:45 +00:00
} else {
if ( $password != '' ) {
2010-03-17 07:51:16 +00:00
$password = validatePassword ( $password );
2010-01-20 16:55:27 +00:00
$password = md5 ( $password );
2013-11-06 07:46:45 +00:00
} else {
2010-01-20 16:55:27 +00:00
$password = $result [ 'password' ];
}
2013-11-06 07:46:45 +00:00
if ( $createstdsubdomain != '1' ) {
2010-01-20 16:55:27 +00:00
$createstdsubdomain = '0' ;
}
2013-11-06 07:46:45 +00:00
if ( $createstdsubdomain == '1'
&& $result [ 'standardsubdomain' ] == '0'
) {
2010-04-02 13:51:25 +00:00
if ( isset ( $settings [ 'system' ][ 'stdsubdomain' ])
&& $settings [ 'system' ][ 'stdsubdomain' ] != ''
) {
$_stdsubdomain = $result [ 'loginname' ] . '.' . $settings [ 'system' ][ 'stdsubdomain' ];
2013-11-06 07:46:45 +00:00
} else {
2010-04-02 13:51:25 +00:00
$_stdsubdomain = $result [ 'loginname' ] . '.' . $settings [ 'system' ][ 'hostname' ];
}
2013-11-06 07:46:45 +00:00
$ins_data = array (
'domain' => $_stdsubdomain ,
'customerid' => $result [ 'customerid' ],
'adminid' => $userinfo [ 'adminid' ],
'docroot' => $result [ 'documentroot' ],
'adddate' => date ( 'Y-m-d' )
);
$ins_stmt = Database :: prepare ( "
INSERT INTO `" . TABLE_PANEL_DOMAINS . "` SET
`domain` = : domain ,
`customerid` = : customerid ,
`adminid` = : adminid ,
2013-09-24 15:32:40 +00:00
`parentdomainid` = '-1' ,
2013-11-06 07:46:45 +00:00
`documentroot` = : docroot ,
2013-09-24 15:32:40 +00:00
`zonefile` = '' ,
`isemaildomain` = '0' ,
`caneditdomain` = '0' ,
`openbasedir` = '1' ,
`speciallogfile` = '0' ,
2013-11-07 09:26:54 +00:00
`specialsettings` = '' ,
2013-11-06 07:46:45 +00:00
`add_date` = : adddate "
2013-09-24 15:32:40 +00:00
);
2013-11-06 07:46:45 +00:00
Database :: pexecute ( $ins_stmt , $ins_data );
$domainid = Database :: lastInsertId ();
2013-09-24 15:32:40 +00:00
// set ip <-> domain connection
2013-11-06 07:46:45 +00:00
$ins_stmt = Database :: prepare ( "
INSERT INTO `".TABLE_DOMAINTOIP."` SET `id_domain` = : domainid , `id_ipandports` = : ipid ' "
2013-09-24 15:32:40 +00:00
);
2013-11-06 07:46:45 +00:00
Database :: pexecute ( $ins_stmt , array ( 'domainid' => $domainid , 'ipid' => $settings [ 'system' ][ 'defaultip' ]));
$upd_stmt = Database :: prepare ( "
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `standardsubdomain` = : domainid WHERE `customerid` = : customerid "
2013-09-24 15:32:40 +00:00
);
2013-11-06 07:46:45 +00:00
Database :: pexecute ( $upd_stmt , array ( 'domainid' => $domainid , 'customerid' => $result [ 'customerid' ]));
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " automatically added standardsubdomain for user ' " . $result [ 'loginname' ] . " ' " );
2010-10-23 10:20:23 +00:00
inserttask ( '1' );
2010-01-20 16:55:27 +00:00
}
2013-11-06 07:46:45 +00:00
if ( $createstdsubdomain == '0'
&& $result [ 'standardsubdomain' ] != '0'
) {
$del_stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_PANEL_DOMAINS . " ` WHERE `id` = :stdsub " );
Database :: pexecute ( $del_stmt , array ( 'stdsub' => $result [ 'standardsubdomain' ]));
$del_stmt = Database :: prepare ( " DELETE FROM ` " . TABLE_DOMAINTOIP . " ` WHERE `id_domain` = :stdsub " );
Database :: pexecute ( $del_stmt , array ( 'stdsub' => $result [ 'standardsubdomain' ]));
$del_stmt = Database :: prepare ( " UPDATE ` " . TABLE_PANEL_CUSTOMERS . " ` SET `standardsubdomain`= '0' WHERE `customerid` = :customerid " );
Database :: pexecute ( $del_stmt , array ( 'customerid' => $result [ 'customerid' ]));
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_NOTICE , " automatically deleted standardsubdomain for user ' " . $result [ 'loginname' ] . " ' " );
2010-10-23 10:20:23 +00:00
inserttask ( '1' );
2010-01-20 16:55:27 +00:00
}
2013-11-06 07:46:45 +00:00
if ( $deactivated != '1' ) {
2010-01-20 16:55:27 +00:00
$deactivated = '0' ;
}
2013-11-06 07:46:45 +00:00
if ( $phpenabled != '0' ) {
2010-01-20 16:55:27 +00:00
$phpenabled = '1' ;
}
2013-11-06 07:46:45 +00:00
if ( $perlenabled != '0' ) {
2010-07-22 06:02:38 +00:00
$perlenabled = '1' ;
}
2013-11-06 07:46:45 +00:00
if ( $phpenabled != $result [ 'phpenabled' ]
|| $perlenabled != $result [ 'perlenabled' ]
) {
2010-10-23 10:20:23 +00:00
inserttask ( '1' );
2010-01-20 16:55:27 +00:00
}
2013-11-06 07:46:45 +00:00
// activate/deactivate customer services
if ( $deactivated != $result [ 'deactivated' ]) {
$yesno = (( $deactivated ) ? 'N' : 'Y' );
$pop3 = (( $deactivated ) ? '0' : ( int ) $result [ 'pop3' ]);
$imap = (( $deactivated ) ? '0' : ( int ) $result [ 'imap' ]);
$upd_stmt = Database :: prepare ( "
UPDATE `" . TABLE_MAIL_USERS . "` SET `postfix` = : yesno , `pop3` = : pop3 , `imap` = : imap WHERE `customerid` = : customerid "
);
Database :: pexecute ( $upd_stmt , array ( 'yesno' => $yesno , 'pop3' => $pop3 , 'imap' => $imap , 'customerid' => $id ));
$upd_stmt = Database :: prepare ( "
UPDATE `" . TABLE_FTP_USERS . "` SET `login_enabled` = : yesno WHERE `customerid` = : customerid "
);
Database :: pexecute ( $upd_stmt , array ( 'yesno' => $yesno , 'customerid' => $id ));
2011-06-18 17:48:16 +00:00
2013-11-06 07:46:45 +00:00
$upd_stmt = Database :: prepare ( "
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `deactivated` = : deactivated WHERE `customerid` = : customerid "
);
Database :: pexecute ( $upd_stmt , array ( 'deactivated' => $deactivated , 'customerid' => $id ));
// Retrieve customer's databases
$databases_stmt = Database :: prepare ( " SELECT * FROM " . TABLE_PANEL_DATABASES . " WHERE customerid = :customerid ORDER BY `dbserver` " );
Database :: pexecute ( $databases_stmt , array ( 'customerid' => $id ));
Database :: needRoot ( true );
2011-03-18 15:14:12 +00:00
$last_dbserver = 0 ;
2013-11-06 07:46:45 +00:00
// For each of them
while ( $row_database = $databases_stmt -> fetch ( PDO :: FETCH_ASSOC )) {
2011-03-18 15:14:12 +00:00
2013-11-06 07:46:45 +00:00
if ( $last_dbserver != $row_database [ 'dbserver' ]) {
Database :: query ( 'FLUSH PRIVILEGES;' );
Database :: needRoot ( true , $row_database [ 'dbserver' ]);
2011-03-18 15:14:12 +00:00
$last_dbserver = $row_database [ 'dbserver' ];
}
2013-11-06 07:46:45 +00:00
foreach ( array_unique ( explode ( ',' , $settings [ 'system' ][ 'mysql_access_host' ])) as $mysql_access_host ) {
2011-03-18 15:14:12 +00:00
$mysql_access_host = trim ( $mysql_access_host );
2011-06-18 17:48:16 +00:00
2013-11-06 07:46:45 +00:00
// Prevent access, if deactivated
if ( $deactivated ) {
2012-11-19 18:22:21 +00:00
// failsafe if user has been deleted manually (requires MySQL 4.1.2+)
2013-11-06 07:46:45 +00:00
$stmt = Database :: prepare ( " REVOKE ALL PRIVILEGES, GRANT OPTION FROM ` " . $row_database [ 'databasename' ] . " ` " );
Database :: pexecute ( $stmt , array (), false );
} else {
// Otherwise grant access
Database :: query ( 'GRANT ALL PRIVILEGES ON `' . $row_database [ 'databasename' ] . '`.* TO `' . $row_database [ 'databasename' ] . '`@`' . $mysql_access_host . '`' );
Database :: query ( 'GRANT ALL PRIVILEGES ON `' . str_replace ( '_' , '\_' , $row_database [ 'databasename' ]) . '` . * TO `' . $row_database [ 'databasename' ] . '`@`' . $mysql_access_host . '`' );
2011-03-18 15:14:12 +00:00
}
}
}
/* At last flush the new privileges */
2013-11-06 07:46:45 +00:00
Database :: query ( 'FLUSH PRIVILEGES;' );
Database :: needRoot ( false );
2011-06-18 17:48:16 +00:00
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_INFO , " deactivated user ' " . $result [ 'loginname' ] . " ' " );
2010-10-23 10:20:23 +00:00
inserttask ( '1' );
2010-01-20 16:55:27 +00:00
}
// Disable or enable POP3 Login for customers Mail Accounts
2013-11-06 07:46:45 +00:00
if ( $email_pop3 != $result [ 'pop3' ]) {
$upd_stmt = Database :: prepare ( " UPDATE ` " . TABLE_MAIL_USERS . " ` SET `pop3` = :pop3 WHERE `customerid` = :customerid " );
Database :: pexecute ( $upd_stmt , array ( 'pop3' => $email_pop3 , 'customerid' => $id ));
2010-01-20 16:55:27 +00:00
}
// Disable or enable IMAP Login for customers Mail Accounts
2013-11-06 07:46:45 +00:00
if ( $email_imap != $result [ 'imap' ]) {
$upd_stmt = Database :: prepare ( " UPDATE ` " . TABLE_MAIL_USERS . " ` SET `imap` = :imap WHERE `customerid` = :customerid " );
Database :: pexecute ( $upd_stmt , array ( 'pop3' => $email_imap , 'customerid' => $id ));
2010-01-20 16:55:27 +00:00
}
2013-11-06 07:46:45 +00:00
$upd_data = array (
'customerid' => $id ,
'passwd' => $password ,
'name' => $name ,
'firstname' => $firstname ,
'gender' => $gender ,
'company' => $company ,
'street' => $street ,
'zipcode' => $zipcode ,
'city' => $city ,
'phone' => $phone ,
'fax' => $fax ,
'email' => $email ,
'customerno' => $customernumber ,
'lang' => $def_language ,
'diskspace' => $diskspace ,
'traffic' => $traffic ,
'subdomains' => $subdomains ,
'emails' => $emails ,
'email_accounts' => $email_accounts ,
'email_forwarders' => $email_forwarders ,
'email_quota' => $email_quota ,
'ftps' => $ftps ,
'tickets' => $tickets ,
'mysqls' => $mysqls ,
'deactivated' => $deactivated ,
'phpenabled' => $phpenabled ,
'imap' => $email_imap ,
'pop3' => $email_pop3 ,
'aps' => $number_of_aps_packages ,
'perlenabled' => $perlenabled ,
'email_autoresponder' => $email_autoresponder ,
'backup_allowed' => $backup_allowed
);
$upd_stmt = Database :: prepare ( "
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
`name` = : name ,
`firstname` = : firstname ,
`gender` = : gender ,
`company` = : company ,
`street` = : street ,
`zipcode` = : zipcode ,
`city` = : city ,
`phone` = : phone ,
`fax` = : fax ,
`email` = : email ,
`customernumber` = : customerno ,
`def_language` = : lang ,
`password` = : passwd ,
`diskspace` = : diskspace ,
`traffic` = : traffic ,
`subdomains` = : subdomains ,
`emails` = : emails ,
`email_accounts` = : email_accounts ,
`email_forwarders` = : email_forwarders ,
`ftps` = : ftps ,
`tickets` = : tickets ,
2013-11-06 10:29:40 +00:00
`mysqls` = : mysqls ,
2013-11-06 07:46:45 +00:00
`deactivated` = : deactivated ,
`phpenabled` = : phpenabled ,
`email_quota` = : email_quota ,
`imap` = : imap ,
`pop3` = : pop3 ,
`aps_packages` = : aps ,
`perlenabled` = : perlenabled ,
`email_autoresponder` = : email_autoresponder ,
`backup_allowed` = : backup_allowed
WHERE `customerid` = : customerid "
);
Database :: pexecute ( $upd_stmt , $upd_data );
2010-01-20 16:55:27 +00:00
2013-03-29 19:10:37 +00:00
// Using filesystem - quota, insert a task which cleans the filesystem - quota
inserttask ( '10' );
2011-06-18 17:48:16 +00:00
2013-11-06 07:46:45 +00:00
$admin_update_query = " UPDATE ` " . TABLE_PANEL_ADMINS . " ` SET `customers_used` = `customers_used` " ;
if ( $mysqls != '-1' || $result [ 'mysqls' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `mysqls_used` = `mysqls_used` " ;
2013-11-06 07:46:45 +00:00
if ( $mysqls != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " + 0 " . ( int ) $mysqls . " " ;
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'mysqls' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'mysqls' ] . " " ;
}
}
2013-11-06 07:46:45 +00:00
if ( $emails != '-1' || $result [ 'emails' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `emails_used` = `emails_used` " ;
2013-11-06 07:46:45 +00:00
if ( $emails != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " + 0 " . ( int ) $emails . " " ;
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'emails' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'emails' ] . " " ;
}
}
2013-11-06 07:46:45 +00:00
if ( $email_accounts != '-1' || $result [ 'email_accounts' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `email_accounts_used` = `email_accounts_used` " ;
2013-11-06 07:46:45 +00:00
if ( $email_accounts != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " + 0 " . ( int ) $email_accounts . " " ;
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_accounts' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'email_accounts' ] . " " ;
}
}
2013-11-06 07:46:45 +00:00
if ( $email_forwarders != '-1' || $result [ 'email_forwarders' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `email_forwarders_used` = `email_forwarders_used` " ;
2013-11-06 07:46:45 +00:00
if ( $email_forwarders != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " + 0 " . ( int ) $email_forwarders . " " ;
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_forwarders' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'email_forwarders' ] . " " ;
}
}
2013-11-06 07:46:45 +00:00
if ( $email_quota != '-1' || $result [ 'email_quota' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `email_quota_used` = `email_quota_used` " ;
2013-11-06 07:46:45 +00:00
if ( $email_quota != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " + 0 " . ( int ) $email_quota . " " ;
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_quota' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'email_quota' ] . " " ;
}
}
2013-11-06 07:46:45 +00:00
if ( $email_autoresponder != '-1' || $result [ 'email_autoresponder' ] != '-1' ) {
2010-09-20 07:56:32 +00:00
$admin_update_query .= " , `email_autoresponder_used` = `email_autoresponder_used` " ;
2013-11-06 07:46:45 +00:00
if ( $email_autoresponder != '-1' ) {
2010-09-20 07:56:32 +00:00
$admin_update_query .= " + 0 " . ( int ) $email_autoresponder . " " ;
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_autoresponder' ] != '-1' ) {
2010-09-20 07:56:32 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'email_autoresponder' ] . " " ;
}
}
2013-11-06 07:46:45 +00:00
if ( $subdomains != '-1' || $result [ 'subdomains' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `subdomains_used` = `subdomains_used` " ;
2013-11-06 07:46:45 +00:00
if ( $subdomains != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " + 0 " . ( int ) $subdomains . " " ;
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'subdomains' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'subdomains' ] . " " ;
}
}
2013-11-06 07:46:45 +00:00
if ( $ftps != '-1' || $result [ 'ftps' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `ftps_used` = `ftps_used` " ;
2013-11-06 07:46:45 +00:00
if ( $ftps != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " + 0 " . ( int ) $ftps . " " ;
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'ftps' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'ftps' ] . " " ;
}
}
2013-11-06 07:46:45 +00:00
if ( $tickets != '-1' || $result [ 'tickets' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `tickets_used` = `tickets_used` " ;
2013-11-06 07:46:45 +00:00
if ( $tickets != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " + 0 " . ( int ) $tickets . " " ;
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'tickets' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'tickets' ] . " " ;
}
}
2013-11-06 07:46:45 +00:00
if (( $diskspace / 1024 ) != '-1' || ( $result [ 'diskspace' ] / 1024 ) != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `diskspace_used` = `diskspace_used` " ;
2013-11-06 07:46:45 +00:00
if (( $diskspace / 1024 ) != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " + 0 " . ( int ) $diskspace . " " ;
}
2013-11-06 07:46:45 +00:00
if (( $result [ 'diskspace' ] / 1024 ) != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'diskspace' ] . " " ;
}
}
2013-11-06 07:46:45 +00:00
if ( $number_of_aps_packages != '-1' || $result [ 'aps_packages' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " , `aps_packages_used` = `aps_packages_used` " ;
2013-11-06 07:46:45 +00:00
if ( $number_of_aps_packages != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " + 0 " . ( int ) $number_of_aps_packages . " " ;
}
2013-11-06 07:46:45 +00:00
if ( $result [ 'aps_packages' ] != '-1' ) {
2010-01-20 16:55:27 +00:00
$admin_update_query .= " - 0 " . ( int ) $result [ 'aps_packages' ] . " " ;
}
}
$admin_update_query .= " WHERE `adminid` = ' " . ( int ) $result [ 'adminid' ] . " ' " ;
2013-11-06 07:46:45 +00:00
Database :: query ( $admin_update_query );
2010-01-20 16:55:27 +00:00
$log -> logAction ( ADM_ACTION , LOG_INFO , " edited user ' " . $result [ 'loginname' ] . " ' " );
$redirect_props = Array (
'page' => $page ,
's' => $s
);
redirectTo ( $filename , $redirect_props );
}
2013-11-06 07:46:45 +00:00
} else {
2010-01-20 16:55:27 +00:00
$language_options = '' ;
2013-11-06 07:46:45 +00:00
while ( list ( $language_file , $language_name ) = each ( $languages )) {
2010-01-20 16:55:27 +00:00
$language_options .= makeoption ( $language_name , $language_file , $result [ 'def_language' ], true );
}
$result [ 'traffic' ] = round ( $result [ 'traffic' ] / ( 1024 * 1024 ), $settings [ 'panel' ][ 'decimal_places' ]);
$result [ 'diskspace' ] = round ( $result [ 'diskspace' ] / 1024 , $settings [ 'panel' ][ 'decimal_places' ]);
$result [ 'email' ] = $idna_convert -> decode ( $result [ 'email' ]);
2013-11-06 07:46:45 +00:00
$diskspace_ul = makecheckbox ( 'diskspace_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'diskspace' ], true , true );
if ( $result [ 'diskspace' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'diskspace' ] = '' ;
}
$traffic_ul = makecheckbox ( 'traffic_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'traffic' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'traffic' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'traffic' ] = '' ;
}
$subdomains_ul = makecheckbox ( 'subdomains_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'subdomains' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'subdomains' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'subdomains' ] = '' ;
}
$emails_ul = makecheckbox ( 'emails_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'emails' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'emails' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'emails' ] = '' ;
}
$email_accounts_ul = makecheckbox ( 'email_accounts_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'email_accounts' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_accounts' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'email_accounts' ] = '' ;
}
$email_forwarders_ul = makecheckbox ( 'email_forwarders_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'email_forwarders' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_forwarders' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'email_forwarders' ] = '' ;
}
$email_quota_ul = makecheckbox ( 'email_quota_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'email_quota' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_quota' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'email_quota' ] = '' ;
}
2010-09-20 07:56:32 +00:00
$email_autoresponder_ul = makecheckbox ( 'email_autoresponder_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'email_autoresponder' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'email_autoresponder' ] == '-1' ) {
2010-09-20 07:56:32 +00:00
$result [ 'email_autoresponder' ] = '' ;
}
2010-01-20 16:55:27 +00:00
$ftps_ul = makecheckbox ( 'ftps_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'ftps' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'ftps' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'ftps' ] = '' ;
}
$tickets_ul = makecheckbox ( 'tickets_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'tickets' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'tickets' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'tickets' ] = '' ;
}
$mysqls_ul = makecheckbox ( 'mysqls_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'mysqls' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'mysqls' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'mysqls' ] = '' ;
}
$number_of_aps_packages_ul = makecheckbox ( 'number_of_aps_packages_ul' , $lng [ 'customer' ][ 'unlimited' ], '-1' , false , $result [ 'aps_packages' ], true , true );
2013-11-06 07:46:45 +00:00
if ( $result [ 'aps_packages' ] == '-1' ) {
2010-01-20 16:55:27 +00:00
$result [ 'aps_packages' ] = '' ;
}
$result = htmlentities_array ( $result );
2011-02-08 11:53:24 +00:00
2011-05-12 16:58:01 +00:00
$gender_options = makeoption ( $lng [ 'gender' ][ 'undef' ], 0 , ( $result [ 'gender' ] == '0' ? true : false ), true , true );
$gender_options .= makeoption ( $lng [ 'gender' ][ 'male' ], 1 , ( $result [ 'gender' ] == '1' ? true : false ), true , true );
$gender_options .= makeoption ( $lng [ 'gender' ][ 'female' ], 2 , ( $result [ 'gender' ] == '2' ? true : false ), true , true );
2011-06-18 17:48:16 +00:00
2011-02-08 11:53:24 +00:00
$customer_edit_data = include_once dirname ( __FILE__ ) . '/lib/formfields/admin/customer/formfield.customer_edit.php' ;
$customer_edit_form = htmlform :: genHTMLForm ( $customer_edit_data );
$title = $customer_edit_data [ 'customer_edit' ][ 'title' ];
$image = $customer_edit_data [ 'customer_edit' ][ 'image' ];
2010-01-20 16:55:27 +00:00
eval ( " echo \" " . getTemplate ( " customers/customers_edit " ) . " \" ; " );
}
}
}
}