| 1 | package App::cpanel; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '0.006'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our @EXPORT_OK = qw(dispatch_cmd_print dispatch_cmd_raw_p dir_walk_p); | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | App::cpanel - CLI for cPanel UAPI and API 2 | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | =begin markdown | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | # PROJECT STATUS | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | [](https://metacpan.org/pod/App::cpanel) | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =end markdown | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | $ cpanel uapi Notifications get_notifications_count | ||||||||||||||||||||||||||||||||||||||||||
| 23 | $ cpanel uapi ResourceUsage get_usages | ||||||||||||||||||||||||||||||||||||||||||
| 24 | $ cpanel uapi Fileman list_files dir=public_html | ||||||||||||||||||||||||||||||||||||||||||
| 25 | $ cpanel uapi Fileman get_file_content dir=public_html file=index.html | ||||||||||||||||||||||||||||||||||||||||||
| 26 | $ cpanel download public_html/index.html | ||||||||||||||||||||||||||||||||||||||||||
| 27 | $ cpanel api2 Fileman fileop op=chmod metadata=0755 sourcefiles=public_html/cgi-bin/hello-world | ||||||||||||||||||||||||||||||||||||||||||
| 28 | $ cpanel api2 Fileman fileop op=unlink sourcefiles=public_html/cgi-bin/hello-world | ||||||||||||||||||||||||||||||||||||||||||
| 29 | $ cpanel api2 Fileman mkdir path= name=new-dir-at-top | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | # this one is one at a time but can overwrite files | ||||||||||||||||||||||||||||||||||||||||||
| 32 | $ cpanel api2 Fileman savefile dir=public_html/cgi-bin filename=hello-world content="$(cat public_html/cgi-bin/hello-world)" | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # this is multiple files but refuses to overwrite | ||||||||||||||||||||||||||||||||||||||||||
| 34 | $ cpanel upload public_html/cgi-bin hello-world | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # download | ||||||||||||||||||||||||||||||||||||||||||
| 37 | $ cpanel mirror public_html public_html cpanel localfs | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # upload | ||||||||||||||||||||||||||||||||||||||||||
| 39 | $ cpanel mirror public_html public_html localfs cpanel | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | CLI for cPanel UAPI and also API 2, due to missing functionality in UAPI. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | Stores session token in F<~/.cpanel-token>, a two-line file. First line | ||||||||||||||||||||||||||||||||||||||||||
| 46 | is the URL component that goes after C<cpsess>. Second is the C<cpsession> | ||||||||||||||||||||||||||||||||||||||||||
| 47 | cookie, which you can get from your browser's DevTools. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | Stores relevant domain name in F<~/.cpanel-domain>. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | Exportable: | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | =head2 dispatch_cmd_print | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | Will print the return value, using L<Mojo::Util/dumper> except for | ||||||||||||||||||||||||||||||||||||||||||
| 58 | C<download>. | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | =head2 dispatch_cmd_raw_p | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | Returns a promise of the decoded JSON value or C<download>ed content. | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | =head2 dir_walk_p | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | Takes C<$from_dir>, C<$to_dir>, C<$from_map>, C<$to_map>. Copies the | ||||||||||||||||||||||||||||||||||||||||||
| 67 | information in the first directory to the second, using the respective | ||||||||||||||||||||||||||||||||||||||||||
| 68 | maps. Assumes UNIX-like semantics in filenames, i.e. C<$dir/$file>. | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | Returns a promise of completion. | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | The maps are hash-refs whose values are functions, and the keys are: | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | =head3 ls | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | Takes C<$dir>. Returns a promise of two hash-refs, of directories and of | ||||||||||||||||||||||||||||||||||||||||||
| 77 | files. Each has keys of relative filename, values are an array-ref | ||||||||||||||||||||||||||||||||||||||||||
| 78 | containing a string octal number representing UNIX permissions, and a | ||||||||||||||||||||||||||||||||||||||||||
| 79 | number giving the C<mtime>. Must reject if does not exist. | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | =head3 mkdir | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | Takes C<$dir>. Returns a promise of having created the directory. | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | =head3 read | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | Takes C<$dir>, C<$file>. Returns a promise of the file contents. | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | =head3 write | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | Takes C<$dir>, C<$file>. Returns a promise of having written the file | ||||||||||||||||||||||||||||||||||||||||||
| 92 | contents. | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =head3 chmod | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | Takes C<$path>, C<$perms>. Returns a promise of having changed the | ||||||||||||||||||||||||||||||||||||||||||
| 97 | permissions. | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | L<https://documentation.cpanel.net/display/DD/Guide+to+UAPI> | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | L<https://documentation.cpanel.net/display/DD/Guide+to+cPanel+API+2> | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | Ed J | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 112 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | use Mojo::URL; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | use Mojo::UserAgent; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | use Mojo::File qw(path); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | use Mojo::Util qw(dumper encode); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | my %cmd2func = ( | |||||||||||||||||||||||||||||||||||||||||
| 124 | uapi => [ \&uapi_p, 1 ], | ||||||||||||||||||||||||||||||||||||||||||
| 125 | download => [ \&download_p, 0 ], | ||||||||||||||||||||||||||||||||||||||||||
| 126 | upload => [ \&upload_p, 1 ], | ||||||||||||||||||||||||||||||||||||||||||
| 127 | api2 => [ \&api2_p, 1 ], | ||||||||||||||||||||||||||||||||||||||||||
| 128 | mirror => [ \&mirror_p, 1 ], | ||||||||||||||||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | my $token_file = "$ENV{HOME}/.cpanel-token"; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | my $domain_file = "$ENV{HOME}/.cpanel-domain"; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | my %localfs_map = ( | |||||||||||||||||||||||||||||||||||||||||
| 133 | ls => \&localfs_ls, | ||||||||||||||||||||||||||||||||||||||||||
| 134 | mkdir => \&localfs_mkdir, | ||||||||||||||||||||||||||||||||||||||||||
| 135 | read => \&localfs_read, | ||||||||||||||||||||||||||||||||||||||||||
| 136 | write => \&localfs_write, | ||||||||||||||||||||||||||||||||||||||||||
| 137 | chmod => \&localfs_chmod, | ||||||||||||||||||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | my %cpanel_map = ( | |||||||||||||||||||||||||||||||||||||||||
| 140 | ls => \&cpanel_ls, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | mkdir => \&cpanel_mkdir, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | read => \&cpanel_read, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | write => \&cpanel_write, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | chmod => \&cpanel_chmod, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | our %MAP2HASH = ( | |||||||||||||||||||||||||||||||||||||||||
| 147 | localfs => \%localfs_map, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | cpanel => \%cpanel_map, | ||||||||||||||||||||||||||||||||||||||||||
| 149 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub dispatch_cmd_print { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_cmd_print: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $cmd = shift; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | die "No command\n" unless $cmd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | die "Unknown command '$cmd'\n" unless my $info = $cmd2func{$cmd}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $p = dispatch_cmd_raw_p($cmd, @_); | |||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | $p = $p->then(\&dumper) if $info->[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $p->then(sub { print @_ }, sub { warn encode 'UTF-8', join '', @_ })->wait; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub dispatch_cmd_raw_p { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch_cmd_raw_p: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $cmd = shift; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | die "No command\n" unless $cmd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | die "Unknown command '$cmd'\n" unless my $info = $cmd2func{$cmd}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | goto &{$info->[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub api_request { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_request: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my ($method, $domain, $token, $parts, $args, @extra_args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my ($url_token, $cookie_token) = split /\s+/, $token; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $url = Mojo::URL->new("https://$domain:2083"); | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $url->path(join '/', '', "cpsess$url_token", @$parts); | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | $url->query(%$args) if $args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | CORE::state $ua = Mojo::UserAgent->new; # state as needs to live long enough to complete request | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $ua->$method( | |||||||||||||||||||||||||||||||||||||||||
| 175 | $url->to_abs . "", | ||||||||||||||||||||||||||||||||||||||||||
| 176 | { Cookie => "cpsession=$cookie_token" }, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | @extra_args, | ||||||||||||||||||||||||||||||||||||||||||
| 178 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub read_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_file: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | die "$file: $!\n" unless -f $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | die "$file: too readable\n" if (stat $file)[2] & 0044; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | local $/; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | open my $fh, $file or die "$file: $!\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $content = <$fh>; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | die "No content in '$file'\n" unless $content; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $content =~ s/^\s*(.*?)\s*$/$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $content; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub read_token { read_file($token_file) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_token: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | sub read_domain { read_file($domain_file) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_domain: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub _error_or_json { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_error_or_json: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $res = $_[0]->res; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | die $res->code . ": " . $res->message . "\n" if $res->code != 200; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $res->json; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | sub _uapi_error_or_json { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uapi_error_or_json: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $json = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if (!$json->{status}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | die join '', "Failed:\n", | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | map "$_\n", map @{ $json->{$_} || [] }, qw(errors warnings); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$json->{$_} || []
MC/DC0%0/1
$json->{$_} || []
$json->{$_}
Truth table0%0/2
A
A= $json->{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $json; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub uapi_p { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uapi_p: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my ($module, $function, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | die "No module\n" unless $module; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | die "No function\n" unless $function; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my ($token, $domain) = (read_token(), read_domain()); | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | my $args_hash = ref($args[0]) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | ? $args[0] | ||||||||||||||||||||||||||||||||||||||||||
| 218 | : { map split('=', $_, 2), @args } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | if @args; | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $tx_p = api_request 'get_p', $domain, $token, | |||||||||||||||||||||||||||||||||||||||||
| 221 | [ 'execute', $module, $function ], | ||||||||||||||||||||||||||||||||||||||||||
| 222 | $args_hash; | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $tx_p->then(\&_error_or_json)->then(\&_uapi_error_or_json); | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub download_p { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
download_p: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | die "No file\n" unless $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my ($token, $domain) = (read_token(), read_domain()); | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $tx_p = api_request 'get_p', $domain, $token, | |||||||||||||||||||||||||||||||||||||||||
| 231 | [ 'download' ], | ||||||||||||||||||||||||||||||||||||||||||
| 232 | { skipencode => 1, file => $file }; | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | $tx_p->then(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $res = $_[0]->res; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | die $res->code . ": " . $res->message . "\n" if $res->code != 200; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $res->body; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub make_upload_form { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_upload_form: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $dir = shift; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $counter = 0; | |||||||||||||||||||||||||||||||||||||||||
| 243 | +{ | ||||||||||||||||||||||||||||||||||||||||||
| 244 | dir => $dir, | ||||||||||||||||||||||||||||||||||||||||||
| 245 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $p = path $_; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ('file-' . ++$counter => { | |||||||||||||||||||||||||||||||||||||||||
| 248 | filename => $p->basename, | ||||||||||||||||||||||||||||||||||||||||||
| 249 | content => $p->slurp, | ||||||||||||||||||||||||||||||||||||||||||
| 250 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 251 | } @_, | ||||||||||||||||||||||||||||||||||||||||||
| 252 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | sub upload_p { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upload_p: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my ($dir, @files) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | die "No dir\n" unless $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | die "No files\n" unless @files; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my ($token, $domain) = (read_token(), read_domain()); | |||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $tx_p = api_request 'post_p', $domain, $token, | |||||||||||||||||||||||||||||||||||||||||
| 261 | [ 'execute', 'Fileman', 'upload_files' ], | ||||||||||||||||||||||||||||||||||||||||||
| 262 | undef, | ||||||||||||||||||||||||||||||||||||||||||
| 263 | form => make_upload_form($dir, @files), | ||||||||||||||||||||||||||||||||||||||||||
| 264 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $tx_p->then(\&_error_or_json)->then(\&_uapi_error_or_json); | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | sub _api2_error_or_json { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_api2_error_or_json: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $json = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my $result = $json->{cpanelresult}; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if (!$result or !$result->{event}{result} or $result->{error}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $result && $result->{"event"}{"result"} or $result->{"error"}
$result && $result->{'event'}{'result'}
MC/DC0%0/3
not $result && $result->{"event"}{"result"} or $result->{"error"}
$result
$result->{'event'}{'result'}
$result->{"error"}
Truth table0%0/4
not(A && B) or C
A= $resultB= $result->{'event'}{'result'}C= $result->{"error"}
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | die join '', "Failed:\n", | ||||||||||||||||||||||||||||||||||||||||||
| 273 | map "$_\n", | ||||||||||||||||||||||||||||||||||||||||||
| 274 | ($result->{error} ? $result->{error} : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | (map "$_->{src}: $_->{err}", grep !$_->{result}, @{$result->{data} || []}), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$result->{'data'} || []
MC/DC0%0/1
$result->{'data'} || []
$result->{'data'}
Truth table0%0/2
A
A= $result->{'data'}
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $json; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub api2_p { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api2_p: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my ($module, $function, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | die "No module\n" unless $module; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | die "No function\n" unless $function; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my ($token, $domain) = (read_token(), read_domain()); | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | my $args_hash = ref($args[0]) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | ? $args[0] | ||||||||||||||||||||||||||||||||||||||||||
| 288 | : { map split('=', $_, 2), @args } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | if @args; | ||||||||||||||||||||||||||||||||||||||||||
| 290 | my $tx_p = api_request 'post_p', $domain, $token, | ||||||||||||||||||||||||||||||||||||||||||
| 291 | [ qw(json-api cpanel) ], | ||||||||||||||||||||||||||||||||||||||||||
| 292 | { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | cpanel_jsonapi_module => $module, | ||||||||||||||||||||||||||||||||||||||||||
| 294 | cpanel_jsonapi_func => $function, | ||||||||||||||||||||||||||||||||||||||||||
| 295 | cpanel_jsonapi_apiversion => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | %{ $args_hash || {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args_hash || {}
MC/DC0%0/1
$args_hash || {}
$args_hash
Truth table0%0/2
A
A= $args_hash
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $tx_p->then(\&_error_or_json)->then(\&_api2_error_or_json); | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | 3 | ▶ | sub dir_walk_p { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir_walk_p: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 3 | my ($from_dir, $to_dir, $from_map, $to_map) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 3 | my $from_dir_perms; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | ▶ | $to_map->{ls}->($to_dir)->catch(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | # only create if ls fails | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 3 | $to_map->{mkdir}->($to_dir) | |||||||||||||||||||||||||||||||||||||||||
| 307 | 3 | ▶ | })->then(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 3 | $from_map->{ls}->(path($from_dir)->dirname) | |||||||||||||||||||||||||||||||||||||||||
| 309 | 3 | ▶ | })->then(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 3 | my ($dirs, $files) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 3 | ▶ | $from_dir_perms = $dirs->{path($from_dir)->basename}[0] || '0755'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dirs{path($from_dir)->basename}[0] || '0755'
MC/DC0%0/1
$$dirs{path($from_dir)->basename}[0] || '0755'
$$dirs{path($from_dir)->basename}[0]
Truth table50%1/2
A
A= $$dirs{path($from_dir)->basename}[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 3 | ▶ | })->then(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 3 | $to_map->{chmod}->($to_dir, $from_dir_perms) | |||||||||||||||||||||||||||||||||||||||||
| 314 | 3 | ▶ | })->then(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 3 | $from_map->{ls}->($from_dir) | |||||||||||||||||||||||||||||||||||||||||
| 316 | 3 | ▶ | })->then(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 3 | my ($dirs, $files) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 3 | my @dir_create_p = map | |||||||||||||||||||||||||||||||||||||||||
| 319 | dir_walk_p("$from_dir/$_", "$to_dir/$_", $from_map, $to_map), | ||||||||||||||||||||||||||||||||||||||||||
| 320 | sort keys %$dirs; | ||||||||||||||||||||||||||||||||||||||||||
| 321 | my @file_create_p = map { | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 3 | my $this_file = $_; | |||||||||||||||||||||||||||||||||||||||||
| 323 | $from_map->{read}->($from_dir, $this_file) | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 3 | ▶ | ->then(sub { $to_map->{write}->($to_dir, $this_file, $_[0]) }) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 3 | ▶ | ->then(sub { $to_map->{chmod}->("$to_dir/$this_file", $files->{$this_file}[0]) }) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 3 | } sort keys %$files; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 3 | ▶ | return Mojo::Promise->resolve(1) unless @dir_create_p + @file_create_p; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 2 | Mojo::Promise->all(@dir_create_p, @file_create_p); | |||||||||||||||||||||||||||||||||||||||||
| 329 | 3 | }); | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | sub mirror_p { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mirror_p: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my ($from_dir, $to_dir, $from_map, $to_map) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | die "No from_dir\n" unless $from_dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | die "No to_dir\n" unless $to_dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | die "No from_map\n" unless $from_map; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | die "No to_map\n" unless $to_map; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | die "Invalid from_map\n" unless $from_map = $MAP2HASH{$from_map}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | die "Invalid to_map\n" unless $to_map = $MAP2HASH{$to_map}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | dir_walk_p $from_dir, $to_dir, $from_map, $to_map; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | sub localfs_ls { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
localfs_ls: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my ($dir) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $dir_path = path($dir); | |||||||||||||||||||||||||||||||||||||||||
| 346 | my %files = map { | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ($_->basename => [ sprintf("%04o", $_->lstat->mode & 07777), $_->lstat->mtime ]) | |||||||||||||||||||||||||||||||||||||||||
| 348 | } $dir_path->list({hidden => 1})->each; | ||||||||||||||||||||||||||||||||||||||||||
| 349 | my %dirs = map { | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ($_->basename => [ sprintf("%04o", $_->lstat->mode & 07777), $_->lstat->mtime ]) | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | } $dir_path->list({dir => 1, hidden => 1})->grep(sub { !$files{$_->basename} })->each; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | Mojo::Promise->resolve(\%dirs, \%files); | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | sub localfs_mkdir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
localfs_mkdir: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my ($dir) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my $dir_path = path($dir); | |||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $dir_path->make_path; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | Mojo::Promise->resolve(1); | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | sub localfs_read { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
localfs_read: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my ($dir, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my $path = path($dir)->child($file); | |||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | Mojo::Promise->resolve($path->slurp); | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | sub localfs_write { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
localfs_write: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my ($dir, $file, $content) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $path = path($dir)->child($file); | |||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $path->spurt($content); | |||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | Mojo::Promise->resolve(1); | |||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | sub localfs_chmod { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
localfs_chmod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my ($path, $perms) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $path = path($path); | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $path->chmod(oct $perms); | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | Mojo::Promise->resolve(1); | |||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | sub cpanel_ls { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpanel_ls: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my ($dir) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | uapi_p(qw(Fileman list_files), { dir => $dir })->then(sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my (%dirs, %files); | |||||||||||||||||||||||||||||||||||||||||
| 386 | ($_->{type} eq 'dir' ? \%dirs : \%files)->{$_->{file}} = | ||||||||||||||||||||||||||||||||||||||||||
| 387 | [ $_->{nicemode}, $_->{mtime} ] | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | for @{ $_[0]->{data} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | (\%dirs, \%files); | |||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | sub cpanel_read { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpanel_read: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my ($dir, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | download_p "$dir/$file"; | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | sub cpanel_mkdir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpanel_mkdir: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my ($dir) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $dir = path $dir; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | api2_p qw(Fileman mkdir), { path => $dir->dirname, name => $dir->basename }; | |||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | sub cpanel_write { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpanel_write: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my ($dir, $file, $content) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | api2_p qw(Fileman savefile), { | |||||||||||||||||||||||||||||||||||||||||
| 407 | dir => $dir, filename => $file, content => $content, | ||||||||||||||||||||||||||||||||||||||||||
| 408 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | sub cpanel_chmod { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpanel_chmod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my ($path, $perms) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | api2_p qw(Fileman fileop), { | |||||||||||||||||||||||||||||||||||||||||
| 414 | op => 'chmod', metadata => $perms, sourcefiles => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 415 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||