Willkommen bei WordPress. Dies ist dein erster Beitrag. Bearbeite oder lösche ihn und beginne mit dem Schreiben!
Hallo Welt!
von raredesign | Dez 3, 2019 | Allgemein | 0 Kommentare
Cokiee Shell
Current Path : /usr/local/siteapps/bbclone-0.48-13/scripts/ |
Current File : //usr/local/siteapps/bbclone-0.48-13/scripts/reconfigure |
#!/usr/bin/perl -w use strict; use File::Path; use File::Copy; use File::Find; my %params; my %psa_params; my @imp_params = qw( vhost_path domain_name install_prefix ssl_target_directory bbc_mainsite ); my $is_error=0; sub print_out { my ($text) = @_; print STDERR $text; } sub check_parameter { my ($param) = @_; unless (defined $params{$param}){ return 0; } else { return 1; } } sub modify_file { my ($fname, $fparams) = @_; unless (open F, $fname){ print_out "reconfigure: can't open file `$fname` for reading\n"; return 0; } my $file_content; while (<F>){ $file_content .= $_; } close F; my ($k,$v); while (($k,$v)=each(%$fparams)){ $file_content =~ s/\@\@${k}\@\@/$v/g; } unless (open F, ">$fname"){ print_out "reconfigure: can't open file `$fname` for writing\n"; return 0; } print F $file_content; close F; return 1; } sub mysql_quote { my ($qstr) = @_; unless (defined $qstr) { return ''; } # replace ' for \' # replace \ for \\ $qstr =~ s/\\/\\\\/g; $qstr =~ s/'/\\'/g; return $qstr; } sub php_quote { my ($qstr) = @_; unless (defined $qstr) { return ''; } # replace ' for \' # replace \ for \\ $qstr =~ s/\\/\\\\/g; $qstr =~ s/'/\\'/g; return $qstr; } sub shell_quote { my ($qstr) = @_; unless (defined $qstr) { return ''; } # replace ' for \' # replace \ for \\ $qstr =~ s/\\/\\\\/g; $qstr =~ s/"/\\\"/g; $qstr =~ s/\$/\\\$/g; return $qstr; } # parse input to hash while (<STDIN>){ my ($k,$v); if (/^([^=]+)=(.+)$/){ $v = $2; chomp $v; $k = $1; $params{"$k"} = $v; } } # parse plesk config file open PSACONF, '/etc/psa/psa.conf'; while (<PSACONF>){ chomp; unless (/^#/){ if (/^(\s*[_a-zA-Z]+)\s+(.+?)\s*$/){ $psa_params{$1} = $2; } } } close PSACONF; # check important parameters foreach (@imp_params){ unless (check_parameter($_)){ print_out "reconfigure: parameter `$_` not found\n"; $is_error = 1; } } if ($is_error){ exit 1; } # check SSL my $ssl_enable; my $documents_directory; if ($params{'ssl_target_directory'} eq 'true'){ $documents_directory = 'httpsdocs'; $ssl_enable = "1"; } else { $documents_directory = 'httpdocs'; $ssl_enable = "0"; } my $root_dir = $params{'vhost_path'}.'/'.$documents_directory.'/'.$params{'install_prefix'}; # generate config file my $config_file = "${root_dir}/conf/config.php"; my $config_file_content = ''; sub check_and_generate_param { my ($param_name, $param_value, $param_default_value) = @_; my $res = "\$${param_name} = '"; if ((!defined $param_value || $param_value eq '') && defined $param_default_value) { $res .= php_quote($param_default_value); } else { $res .= php_quote($param_value); } $res .= "';\n"; return $res; } $config_file_content = "<?php\n"; $config_file_content .= check_and_generate_param('BBC_SHOW_CONFIG', $params{bbc_show_config}, '1'); $config_file_content .= check_and_generate_param('BBC_TITLEBAR', $params{bbc_titlebar}, 'Statistics for %SERVER generated the %DATE'); $config_file_content .= check_and_generate_param('BBC_LANGUAGE', $params{bbc_language}, 'en'); $config_file_content .= check_and_generate_param('BBC_MAXTIME', $params{bbc_maxtime}, '1800'); $config_file_content .= check_and_generate_param('BBC_MAXVISIBLE', $params{bbc_maxvisible}, '100'); $config_file_content .= check_and_generate_param('BBC_MAXOS', $params{bbc_maxos}, '10'); $config_file_content .= check_and_generate_param('BBC_MAXBROWSER', $params{bbc_maxbrowser}, '10'); $config_file_content .= check_and_generate_param('BBC_MAXEXTENSION', $params{max_extension}, '10'); $config_file_content .= check_and_generate_param('BBC_MAXROBOT', $params{bbc_maxrobot}, '10'); $config_file_content .= check_and_generate_param('BBC_MAXPAGE', $params{bbc_maxpage}, '10'); $config_file_content .= check_and_generate_param('BBC_MAXORIGIN', $params{bbc_maxorigin}, '10'); $config_file_content .= check_and_generate_param('BBC_IGNOREIP', $params{bbc_ignoreip}); $config_file_content .= check_and_generate_param('BBC_IGNORE_REFER', $params{bbc_ignore_refer}, ''); $config_file_content .= check_and_generate_param('BBC_OWN_REFER', $params{bbc_own_refer}, '1'); my @detailed_stat_fields = qw( id time visits ext dns refer os browser ip page search ); my @params_stat_fields = (); foreach my $field (@detailed_stat_fields) { if (defined $params{'bbc_stat_field_' . $field} && $params{'bbc_stat_field_' . $field} ne '') { push @params_stat_fields, $field; } } $config_file_content .= check_and_generate_param('BBC_DETAILED_STAT_FIELDS', join(', ', @params_stat_fields)); $config_file_content .= check_and_generate_param('BBC_GENERAL_ALIGN_STYLE', $params{bbc_general_align_style}, 'center'); $config_file_content .= check_and_generate_param('BBC_TITLE_SIZE', $params{bbc_title_size}, '12'); $config_file_content .= check_and_generate_param('BBC_SUBTITLE_SIZE', $params{bbc_subtitle_size}, '8'); $config_file_content .= check_and_generate_param('BBC_TEXT_SIZE', $params{bbc_text_size}, '10'); $config_file_content .= "\n?>"; unless (open F, ">${config_file}") { print_out "Unable to open config file `${config_file}`\n"; exit 1; } print F $config_file_content; close F;
Cokiee Shell Web 1.0, Coded By Razor
Neueste Kommentare