HEX
Server: LiteSpeed
System: Linux melbournecleaninggroup 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: www-data (33)
PHP: 7.3.33-1+focal
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/html/wp-content/plugins/dologin/src/cli.cls.php
<?php
namespace dologin;
defined( 'WPINC' ) || exit;

use WP_CLI;

/**
 * Passwordless API CLI
 */
class CLI extends Instance {
	public function __construct() {
		defined( 'debug' ) && debug( 'CLI init' );
	}

	/**
	 * List all passwordless links
	 *
	 * ## OPTIONS
	 *
	 * ## EXAMPLES
	 *
	 *     # List all passwordless link
	 *     $ wp dologin list
	 *
	 */
	public function list() {
		$list = $this->cls( 'Admin' )->pswdless_log();
		foreach ( $list as $k => $v ) {
			$list[ $k ] = (array) $v;
			$user = get_user_by( 'id', $v->user_id );
			$list[ $k ][ 'Login_Name' ] = $user ? $user->user_login : 'N/A';
			$list[ $k ][ 'Expiration' ] = $v->expired_at > time() ? Util::readable_time( $v->expired_at - time(), 3600, false ) : __( 'Expired', 'dologin' );
			$list[ $k ][ 'Created_At' ] = Util::readable_time( $v->dateline );
		}
		if ( $list ) {
			WP_CLI\Utils\format_items( 'table', $list, array( 'id', 'Login_Name', 'Expiration', 'Created_At', 'onetime', 'active', 'count' ) );
		}
	}

	/**
	 * Generate a passwordless link for one username
	 *
	 * ## OPTIONS
	 *
	 * ## EXAMPLES
	 *
	 *     # Generate a passwordless link for one username
	 *     $ wp dologin gen root
	 *
	 */
	public function gen( $args ) {
		$uname = $args[ 0 ];
		$user = get_user_by( 'login', $uname );
		if ( ! $user ) {
			WP_CLI::error( __( 'No related user.', 'dologin' ) );
			return;
		}

		$link = $this->cls( 'Pswdless' )->gen_link( 'CLI-' . $user->display_name, $user->ID, true );
		WP_CLI::success( 'Link generated: ' . $link );
	}

	/**
	 * Delete a passwordless link w/ the ID in list
	 *
	 * ## OPTIONS
	 *
	 * ## EXAMPLES
	 *
	 *     # Delete the passwordless link (ID is 5)
	 *     $ wp dologin del 5
	 *
	 */
	public function del( $args ) {
		$id = $args[ 0 ];
		if ( ! $id ) {
			WP_CLI::error( __( 'No ID to delete.', 'dologin' ) );
			return;
		}

		$this->cls( 'Pswdless' )->del_link( $id );
		WP_CLI::success( 'Delete passwordless link successfully. ID = ' . $id );
	}
}