App-WordPressTools
view release on metacpan or search on metacpan
script/wp-tools view on Meta::CPAN
my $password = `grep DB_PASSWORD <$wp_configq | grep -v '$definition_check_string' | cut -d \\' -f 4`;
my $database = `grep DB_NAME <$wp_configq | grep -v '$definition_check_string' | cut -d \\' -f 4`;
#disallow starting whitespace
$username =~ s/^[\r\n]+//;
$password =~ s/^[\r\n]+//;
$database =~ s/^[\r\n]+//;
chomp $username;
chomp $password;
chomp $database;
if ($username =~ /[\r\n]/ || $password =~ /[\r\n]/ || $database =~ /[\r\n]/) {
die "Multiple credentials found in $args->{'path'}/wp-config.php. Cannot determine which to use. Backup operation halted.";
}
open (my $fh, '>', $defaults_file) or die "Cannot write to $defaults_file: $!";
close $fh;
chmod(0600, $defaults_file) or die "Cannot chmod $defaults_file: $!";
write_text($defaults_file,"[client]\nuser=$username\npassword=$password");
my $databaseq = shell_quote($database);
$dump_command = "mysqldump --defaults-file=$defaults_file $databaseq 2>&1 >$db_file";
my $result = `$dump_command`;
#acceptable failure states for databaseless accounts
if ($result =~ $no_db_regex) {
script/wp-tools view on Meta::CPAN
my $password = `grep DB_PASSWORD <$wp_configq | grep -v '$definition_check_string' | cut -d \\' -f 4`;
my $database = `grep DB_NAME <$wp_configq | grep -v '$definition_check_string' | cut -d \\' -f 4`;
#disallow starting whitespace
$username =~ s/^[\r\n]+//;
$password =~ s/^[\r\n]+//;
$database =~ s/^[\r\n]+//;
chomp $username;
chomp $password;
chomp $database;
if ($username =~ /[\r\n]/ || $password =~ /[\r\n]/ || $database =~ /[\r\n]/) {
die "Multiple credentials found in $args->{'path'}/wp-config.php. Cannot determine which to use. Restoration operation halted.";
}
open (my $fh, '>', $defaults_file) or die "Cannot write to $defaults_file: $!";
close $fh;
chmod(0600, $defaults_file) or die "Cannot chmod $defaults_file: $!";
write_text($defaults_file,"[client]\nuser=$username\npassword=$password");
my $databaseq = shell_quote($database);
`mysql --defaults-file=$defaults_file $databaseq <$db_file`;
if ($?) {
die "Failed to restore database";
}
script/wp-tools view on Meta::CPAN
my $prefix = `grep table_prefix <$wp_configq | grep -v '$definition_check_string' | cut -d \\' -f 2` || 'wp_';
$prefix =~ s/[^\w_-]//g;
#disallow starting whitespace
$username =~ s/^[\r\n]+//;
$password =~ s/^[\r\n]+//;
$database =~ s/^[\r\n]+//;
chomp $username;
chomp $password;
chomp $database;
if ($username =~ /[\r\n]/ || $password =~ /[\r\n]/ || $database =~ /[\r\n]/) {
die "Multiple credentials found in $args->{'path'}/wp-config.php. Cannot determine which to use. Upgrade operation halted.";
}
if ($prefix =~ /[\r\n]/) {
die "Multiple database prefixes found in $args->{'path'}/wp-config.php. Cannot determine which to use. Upgrade operation halted.";
}
open (my $fh, '>', $defaults_file) or die "Cannot write to $defaults_file: $!";
close $fh;
chmod(0600, $defaults_file) or die "Cannot chmod $defaults_file: $!";
write_text($defaults_file,"[client]\nuser=$username\npassword=$password");
my $table = "${prefix}options";
my $databaseq = shell_quote($database);
( run in 0.235 second using v1.01-cache-2.11-cpan-a5abf4f5562 )