Private
Server IP : 195.201.23.43  /  Your IP : 18.117.82.179
Web Server : Apache
System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
User : kdecoratie ( 1041)
PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/webmin/virtual-server/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/webmin/virtual-server/fetch-script-files.pl
#!/usr/bin/perl
# Download all files used by scripts to some directory

package virtual_server;
if (!$module_name) {
	$main::no_acl_check++;
	$ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
	$ENV{'WEBMIN_VAR'} ||= "/var/webmin";
	if ($0 =~ /^(.*)\/[^\/]+$/) {
		chdir($pwd = $1);
		}
	else {
		chop($pwd = `pwd`);
		}
	$0 = "$pwd/fetch-script-files.pl";
	require './virtual-server-lib.pl';
	$< == 0 || die "fetch-script-files.pl must be run as root";
	}
@OLDARGV = @ARGV;

# Parse command-line args
while(@ARGV) {
	$a = shift(@ARGV);
	if ($a eq "--dest") {
		$dest = shift(@ARGV);
		}
	elsif ($a !~ /^\-/) {
		push(@scripts, $a);
		}
	elsif ($a eq "--help") {
		&usage();
		}
	else {
		&usage("Unknown parameter $a");
		}
	}

$dest || die "usage: fetch-script-files.pl --dest dir";
if (!@scripts) {
	@scripts = &list_available_scripts();
	}

@rv = ( );
foreach $s (@scripts) {
	$script = &get_script($s);
	next if (!$script->{'enabled'});

	$d = { 'dom' => 'example.com' };
	foreach $ver (@{$script->{'versions'}}) {
		@files = &{$script->{'files_func'}}($d, $ver, undef, undef);
		foreach $f (grep { $_->{'url'} } @files) {
			next if ($f->{'nofetch'});
			next if ($f->{'virtualmin'});
			local $url = &convert_osdn_url($f->{'url'}) ||
				     $f->{'url'};
			local $destfile = "$dest/$f->{'file'}";
			next if (-r $destfile);		# Already gotten
			local $temp = &transname($f->{'file'});
			local $error;
			print "script:$script->{'name'} version:$ver url:$url\n";
			if ($url =~ /^http/) {
				# Via HTTP
				my ($host, $port, $page, $ssl) =
					&parse_http_url($f->{'url'});
				&http_download($host, $port, $page, $temp,
					       \$error, undef, $ssl, undef,
					       undef, undef, 1,
					       $f->{'nocache'});
				}
			elsif ($url =~ /^ftp:\/\/([^\/]+)(\/.*)/) {
				# Via FTP
				my ($host, $page) = ($1, $2);
				&ftp_download($host, $page, $temp, \$error);
				}
			if ($error) {
				# HTTP failed
				print "status: FAILED $error\n";
				}
			else {
				# Looks OK .. but was it really a file?
				$fmt = &compression_format($temp);
				$cont = undef;
				if (!$fmt && $temp =~ /\.(pl|php)$/i) {
					$cont = &read_file_contents($temp);
					}
				if (!$fmt &&
				    $cont !~ /^\#\!\s*\S+(perl|php)/i &&
				    $cont !~ /^\s*<\?php/i) {
					print "status: BADFILE\n";
					}
				else {
					@st = stat($temp);
					print "status: OK $st[7]\n";
					&copy_source_dest($temp, $destfile);
					&set_ownership_permissions(undef, undef,
						0755, $destfile);
					}
				}
			unlink($temp);
			}
		}
	}

sub usage
{
print "$_[0]\n\n" if ($_[0]);
print "Download files for some script.\n";
print "\n";
print "usage: fetch-script-files.pl\n";
exit(1);
}

Private