zdgtl 10 months ago

Installing Plugin JWT and Activate

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Include the wp-config.php file to get the ABSPATH constant
require_once('wp-config.php');

// Define the WP_PLUGIN_DIR constant dynamically
define('WP_PLUGIN_DIR', ABSPATH . 'wp-content/plugins/');

// Fungsi untuk menambahkan konfigurasi ke wp-config.php
function add_config_line($wp_config_path, $line) {
    $config_contents = file_get_contents($wp_config_path);
    
    // Cek apakah line sudah ada di wp-config.php
    if (strpos($config_contents, $line) === false) {
        // Tambahkan line sebelum baris "/* That's all, stop editing!"
        $config_contents = preg_replace('/\/\* That\'s all, stop editing! \*\//', "$line\n\n/* That's all, stop editing! */", $config_contents);
        
        file_put_contents($wp_config_path, $config_contents);
    }
}

// Path ke wp-config.php
$wp_config_path = ABSPATH . 'wp-config.php';

// Konfigurasi yang akan ditambahkan
$jwt_key_config = "define('JWT_AUTH_SECRET_KEY', 'your-top-secret-key');";
$jwt_cors_config = "define('JWT_AUTH_CORS_ENABLE', true);";

// Tambahkan konfigurasi ke wp-config.php
add_config_line($wp_config_path, $jwt_key_config);
add_config_line($wp_config_path, $jwt_cors_config);

// Download plugin dari URL
$url = 'https://downloads.wordpress.org/plugin/jwt-authentication-for-wp-rest-api.1.3.4.zip';
$tmp_file = tempnam(sys_get_temp_dir(), 'jwt-authentication-for-wp-rest-api');
$fp = fopen($tmp_file, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
fclose($fp);

// Ekstrak plugin ke direktori wp-content/plugins
$zip = new ZipArchive;
$zip->open($tmp_file);
$zip->extractTo(WP_PLUGIN_DIR);
$zip->close();

// Aktifkan plugin
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
activate_plugin('jwt-authentication-for-wp-rest-api/jwt-auth.php');
?>


0
567

PMA Multiple Check

1743468932.jpg
zdgtl
3 months ago
Kumpulan Perintah PHP dari Internet

Kumpulan Perintah PHP dari Internet

1743468932.jpg
zdgtl
10 months ago
FTP login Checker

FTP login Checker

1743468932.jpg
zdgtl
10 months ago
Remote upload PHP Script

Remote upload PHP Script

1743468932.jpg
zdgtl
10 months ago

Host Live Checker

1743468932.jpg
zdgtl
9 months ago