| | |
| | | $app->plugins->registerEvent('web_folder_update',$this->plugin_name,'web_folder_update'); |
| | | $app->plugins->registerEvent('web_folder_delete',$this->plugin_name,'web_folder_delete'); |
| | | |
| | | $app->plugins->registerEvent('ftp_user_delete',$this->plugin_name,'ftp_user_delete'); |
| | | |
| | | } |
| | | |
| | | // Handle the creation of SSL certificates |
| | |
| | | |
| | | //* Create a SSL Certificate |
| | | if($data['new']['ssl_action'] == 'create') { |
| | | |
| | | //* Rename files if they exist |
| | | if(file_exists($key_file)) rename($key_file,$key_file.'.bak'); |
| | | if(file_exists($key_file2)) rename($key_file2,$key_file2.'.bak'); |
| | | if(file_exists($csr_file)) rename($csr_file,$csr_file.'.bak'); |
| | | if(file_exists($crt_file)) rename($crt_file,$crt_file.'.bak'); |
| | | |
| | | $rand_file = $ssl_dir.'/random_file'; |
| | | $rand_data = md5(uniqid(microtime(),1)); |
| | | for($i=0; $i<1000; $i++) { |
| | |
| | | output_password = $ssl_password |
| | | |
| | | [ req_distinguished_name ] |
| | | C = ".$data['new']['ssl_country']." |
| | | ST = ".$data['new']['ssl_state']." |
| | | L = ".$data['new']['ssl_locality']." |
| | | O = ".$data['new']['ssl_organisation']." |
| | | OU = ".$data['new']['ssl_organisation_unit']." |
| | | C = ".trim($data['new']['ssl_country'])." |
| | | ST = ".trim($data['new']['ssl_state'])." |
| | | L = ".trim($data['new']['ssl_locality'])." |
| | | O = ".trim($data['new']['ssl_organisation'])." |
| | | OU = ".trim($data['new']['ssl_organisation_unit'])." |
| | | CN = $domain |
| | | emailAddress = webmaster@".$data['new']['domain']." |
| | | |
| | |
| | | } |
| | | if($data['new']['system_user'] == 'root' or $data['new']['system_group'] == 'root') { |
| | | $app->log('Websites cannot be owned by the root user or group.',LOGLEVEL_WARN); |
| | | return 0; |
| | | } |
| | | if(trim($data['new']['domain']) == '') { |
| | | $app->log('domain is empty',LOGLEVEL_WARN); |
| | | return 0; |
| | | } |
| | | |
| | |
| | | * website root has to be owned by the root user and we have to chmod it to 755 then |
| | | */ |
| | | |
| | | //* Check if there is a jailkit user for this site |
| | | //* Check if there is a jailkit user or cronjob for this site |
| | | $tmp = $app->db->queryOneRecord('SELECT count(shell_user_id) as number FROM shell_user WHERE parent_domain_id = '.$data['new']['domain_id']." AND chroot = 'jailkit'"); |
| | | if($tmp['number'] > 0) { |
| | | $tmp2 = $app->db->queryOneRecord('SELECT count(id) as number FROM cron WHERE parent_domain_id = '.$data['new']['domain_id']." AND `type` = 'chrooted'"); |
| | | if($tmp['number'] > 0 || $tmp2['number'] > 0) { |
| | | $this->_exec('chmod 755 '.escapeshellcmd($data['new']['document_root'])); |
| | | $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root'])); |
| | | } |
| | |
| | | $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']).'/log/error.log'); |
| | | |
| | | |
| | | //* Write the custom php.ini file, if custom_php_ini filed is not empty |
| | | //* Write the custom php.ini file, if custom_php_ini fieled is not empty |
| | | $custom_php_ini_dir = $web_config['website_basedir'].'/conf/'.$data['new']['system_user']; |
| | | if(!is_dir($web_config['website_basedir'].'/conf')) mkdir($web_config['website_basedir'].'/conf'); |
| | | |
| | | //* add open_basedir restriction to custom php.ini content, required for suphp only |
| | | if(!stristr($data['new']['custom_php_ini'],'open_basedir') && $data['new']['php'] == 'suphp') { |
| | | $data['new']['custom_php_ini'] .= "\nopen_basedir = '".$data['new']['php_open_basedir']."'\n"; |
| | | } |
| | | //* Create custom php.ini |
| | | if(trim($data['new']['custom_php_ini']) != '') { |
| | | $has_custom_php_ini = true; |
| | | if(!is_dir($custom_php_ini_dir)) mkdir($custom_php_ini_dir); |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | public function ftp_user_delete($event_name,$data) { |
| | | global $app, $conf; |
| | | |
| | | $ftpquota_file = $data['old']['dir'].'/.ftpquota'; |
| | | if(file_exists($ftpquota_file)) unlink($ftpquota_file); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * This function is called when a Webdav-User is inserted, updated or deleted. |
| | |
| | | $value = escapeshellcmd(trim($value)); |
| | | $key = escapeshellcmd(trim($key)); |
| | | switch (strtolower($value)) { |
| | | case 'on': |
| | | case 'off': |
| | | case '1': |
| | | case '0': |
| | | // PHP-FPM might complain about invalid boolean value if you use 0 |
| | | $value = 'off'; |
| | | case '1': |
| | | case 'on': |
| | | case 'off': |
| | | case 'true': |
| | | case 'false': |
| | | case 'yes': |