| | |
| | | require(SCRIPT_PATH."/lib/app.inc.php"); |
| | | |
| | | set_time_limit(0); |
| | | ini_set('error_reporting', E_ALL & ~E_NOTICE); |
| | | |
| | | // make sure server_id is always an int |
| | | $conf['server_id'] = intval($conf['server_id']); |
| | |
| | | if($rec['traffic_quota_lock'] != 'y' && ($web_config['overtraffic_notify_admin'] == 'y' || $web_config['overtraffic_notify_client'] == 'y')) { |
| | | |
| | | $placeholders = array('{domain}' => $rec['domain'], |
| | | '{admin_mail}' => $global_config['admin_mail']); |
| | | '{admin_mail}' => ($global_config['admin_mail'] != ''? $global_config['admin_mail'] : 'root')); |
| | | |
| | | $recipients = array(); |
| | | //* send email to admin |
| | |
| | | // send notification - everything ok again |
| | | if($rec['last_quota_notification'] && $web_config['overquota_notify_onok'] == 'y' && ($web_config['overquota_notify_admin'] == 'y' || $web_config['overquota_notify_client'] == 'y')) { |
| | | $placeholders = array('{domain}' => $rec['domain'], |
| | | '{admin_mail}' => $global_config['admin_mail'], |
| | | '{admin_mail}' => ($global_config['admin_mail'] != ''? $global_config['admin_mail'] : 'root'), |
| | | '{used}' => $rec['used'], |
| | | '{soft}' => $rec['soft'], |
| | | '{hard}' => $rec['hard'], |
| | |
| | | $app->dbmaster->datalogUpdate('web_domain', "last_quota_notification = CURDATE()", 'domain_id', $rec['domain_id']); |
| | | |
| | | $placeholders = array('{domain}' => $rec['domain'], |
| | | '{admin_mail}' => $global_config['admin_mail'], |
| | | '{admin_mail}' => ($global_config['admin_mail'] != ''? $global_config['admin_mail'] : 'root'), |
| | | '{used}' => $rec['used'], |
| | | '{soft}' => $rec['soft'], |
| | | '{hard}' => $rec['hard'], |
| | |
| | | // send notification - everything ok again |
| | | if($rec['last_quota_notification'] && $mail_config['overquota_notify_onok'] == 'y' && ($mail_config['overquota_notify_admin'] == 'y' || $mail_config['overquota_notify_client'] == 'y')) { |
| | | $placeholders = array('{email}' => $rec['email'], |
| | | '{admin_mail}' => $global_config['admin_mail'], |
| | | '{admin_mail}' => ($global_config['admin_mail'] != ''? $global_config['admin_mail'] : 'root'), |
| | | '{used}' => $rec['used'], |
| | | '{name}' => $rec['name'], |
| | | '{quota}' => $rec['quota'], |
| | |
| | | $app->dbmaster->datalogUpdate('mail_user', "last_quota_notification = CURDATE()", 'mailuser_id', $rec['mailuser_id']); |
| | | |
| | | $placeholders = array('{email}' => $rec['email'], |
| | | '{admin_mail}' => $global_config['admin_mail'], |
| | | '{admin_mail}' => ($global_config['admin_mail'] != ''? $global_config['admin_mail'] : 'root'), |
| | | '{used}' => $rec['used'], |
| | | '{name}' => $rec['name'], |
| | | '{quota}' => $rec['quota'], |
| | |
| | | |
| | | } |
| | | |
| | | #######################################################################################################
|
| | | // Create website backups
|
| | | #######################################################################################################
|
| | | function formatBytes($size, $precision = 2) {
|
| | | $base=log($size)/log(1024);
|
| | | $suffixes=array('','k','M','G','T'); |
| | | return round(pow(1024,$base-floor($base)),$precision).$suffixes[floor($base)];
|
| | | }
|
| | |
|
| | | $server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
|
| | | $backup_dir = $server_config['backup_dir'];
|
| | | ####################################################################################################### |
| | | // Create website backups |
| | | ####################################################################################################### |
| | | |
| | | $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); |
| | | $backup_dir = $server_config['backup_dir']; |
| | | $backup_mode = $server_config['backup_mode']; |
| | | if($backup_mode == '') $backup_mode = 'userzip'; |
| | | |
| | |
| | | $web_backup_file = 'web'.$web_id.'_'.date('Y-m-d_H-i').'.tar.gz'; |
| | | exec('tar pczf '.escapeshellarg($web_backup_dir.'/'.$web_backup_file).' --exclude=backup\* --directory '.escapeshellarg($web_path).' .', $tmp_output, $retval); |
| | | } |
| | | if($retval == 0){ |
| | | if($retval == 0 || $backup_mode != 'userzip'){ // tar can return 1 (due to harmless warings) and still create valid backups |
| | | chown($web_backup_dir.'/'.$web_backup_file, 'root'); |
| | | chgrp($web_backup_dir.'/'.$web_backup_file, 'root'); |
| | | chmod($web_backup_dir.'/'.$web_backup_file, 0750); |
| | |
| | | } |
| | | |
| | | $app->system->web_folder_protection($web_path,true); |
| | | |
| | | } |
| | | |
| | | /* If backup_interval is set to none and we have a |
| | |
| | | $db_id = $rec['database_id']; |
| | | $db_name = $rec['database_name']; |
| | | $db_backup_file = 'db_'.$db_name.'_'.date('Y-m-d_H-i').'.sql'; |
| | | $command = "mysqldump -h '".escapeshellcmd($clientdb_host)."' -u '".escapeshellcmd($clientdb_user)."' -p'".escapeshellcmd($clientdb_password)."' -c --add-drop-table --create-options --quick --result-file='".$db_backup_dir.'/'.$db_backup_file."' '".$db_name."'"; |
| | | //$command = "mysqldump -h '".escapeshellcmd($clientdb_host)."' -u '".escapeshellcmd($clientdb_user)."' -p'".escapeshellcmd($clientdb_password)."' -c --add-drop-table --create-options --quick --result-file='".$db_backup_dir.'/'.$db_backup_file."' '".$db_name."'"; |
| | | $command = "mysqldump -h ".escapeshellarg($clientdb_host)." -u ".escapeshellarg($clientdb_user)." -p".escapeshellarg($clientdb_password)." -c --add-drop-table --create-options --quick --result-file='".$db_backup_dir.'/'.$db_backup_file."' '".$db_name."'"; |
| | | exec($command, $tmp_output, $retval); |
| | | |
| | | //* Compress the backup with gzip |
| | |
| | | unset($clientdb_password); |
| | | |
| | | } |
| | | |
| | | // remove non-existing backups from database |
| | | $backups = $app->db->queryAllRecords("SELECT * FROM web_backup WHERE server_id = ".$conf['server_id']); |
| | | if(is_array($backups) && !empty($backups)){ |
| | | foreach($backups as $backup){ |
| | | $backup_file = $backup_dir.'/web'.$backup['parent_domain_id'].'/'.$backup['filename']; |
| | | if(!is_file($backup_file)){ |
| | | $sql = "DELETE FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$backup['parent_domain_id']." AND filename = '".$backup['filename']."'"; |
| | | $app->db->query($sql); |
| | | if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |