Esempio n. 1
0
 public static function credentialsForUserWithRole($userRole)
 {
     $credentials = \Wordfence\ExKit\Config::get("user.{$userRole}", null, false);
     if ($credentials === null) {
         \Wordfence\ExKit\Cli::write("Please enter the username and password for a user with the \"{$userRole}\" role.");
         $username = \Wordfence\ExKit\Cli::prompt("Username", '');
         $password = \Wordfence\ExKit\Cli::prompt("Password", '');
         $credentials = [self::USER_CREDENTIALS_USERNAME_KEY => $username, self::USER_CREDENTIALS_PASSWORD_KEY => $password];
         \Wordfence\ExKit\Config::set("user.{$userRole}", $credentials);
     }
     return $credentials;
 }
Esempio n. 2
0
 public static function get($key, $defaultValue = null, $shouldPrompt = true, $promptMessage = null)
 {
     self::_autoloadConfigurationFile();
     if (isset(self::$_cachedConfig[$key])) {
         return self::$_cachedConfig[$key];
     }
     if ($shouldPrompt) {
         $value = \Wordfence\ExKit\Cli::prompt($promptMessage === null ? $key : $promptMessage, $defaultValue);
         self::set($key, $value);
         return $value;
     }
     return $defaultValue;
 }
Esempio n. 3
0
#!/usr/bin/env php
<?php 
require __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
use Wordfence\ExKit\WPAuthentication;
use Wordfence\ExKit\Cli;
//Prompt for something
$value = Cli::prompt("Enter a value", 'some default');
Cli::write('Value: ' . $value);
//Prompt for the baseURL early if needed
Endpoint::baseURL();
//Log in as a subscriber
$session = new \Requests_Session();
WPAuthentication::logInAsUserRole($session, WPAuthentication::USER_ROLE_SUBSCRIBER);
Cli::write('[+] Logged in', 'green', null);