Guest User

litespeed cache plugin script_uri wordpress error

a guest
May 13th, 2020
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 16.80 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The core plugin router class.
  4.  *
  5.  * This generate the valid action.
  6.  *
  7.  * @since       1.1.0
  8.  * @since       1.5 Moved into /inc
  9.  */
  10. namespace LiteSpeed;
  11. defined( 'WPINC' ) || exit;
  12.  
  13. class Router extends Instance
  14. {
  15.     protected static $_instance;
  16.  
  17.     const NONCE = 'LSCWP_NONCE';
  18.     const ACTION = 'LSCWP_CTRL';
  19.  
  20.     const ACTION_SAVE_HTACCESS = 'save-htaccess';
  21.     const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network';
  22.     const ACTION_DB_OPTM = 'db_optm';
  23.     const ACTION_PLACEHOLDER = 'placeholder';
  24.     const ACTION_AVATAR = 'avatar';
  25.     const ACTION_SAVE_SETTINGS = 'save-settings';
  26.     const ACTION_CLOUD = 'cloud';
  27.     const ACTION_IMG_OPTM = 'img_optm';
  28.     const ACTION_HEALTH = 'health';
  29.     const ACTION_CRAWLER = 'crawler';
  30.     const ACTION_PURGE = 'purge';
  31.     const ACTION_CONF = 'conf';
  32.     const ACTION_ACTIVATION = 'activation';
  33.     const ACTION_CSS = 'css';
  34.     const ACTION_IMPORT = 'import';
  35.     const ACTION_REPORT = 'report';
  36.     const ACTION_DEBUG2 = 'debug2';
  37.     const ACTION_CDN_QUIC = 'cdn_quic';
  38.     const ACTION_CDN_CLOUDFLARE = 'cdn_cloudflare';
  39.  
  40.     const TYPE = 'litespeed_type';
  41.  
  42.     private static $_esi_enabled ;
  43.     private static $_is_ajax ;
  44.     private static $_is_logged_in ;
  45.     private static $_ip ;
  46.     private static $_action ;
  47.     private static $_is_admin_ip ;
  48.     private static $_frontend_path ;
  49.  
  50.     /**
  51.      * Check if can run optimize
  52.      *
  53.      * @since  1.3
  54.      * @since  2.3.1 Relocated from cdn.cls
  55.      * @access public
  56.      */
  57.     public static function can_optm()
  58.     {
  59.         $can = true ;
  60.  
  61.         if ( is_admin() ) {
  62.             $can = false ;
  63.         }
  64.         elseif ( is_feed() ) {
  65.             $can = false ;
  66.         }
  67.         elseif ( is_preview() ) {
  68.             $can = false ;
  69.         }
  70.         elseif ( self::is_ajax() ) {
  71.             $can = false ;
  72.         }
  73.  
  74.         if ( self::_is_login_page() ) {
  75.             Debug2::debug( '[Router] Optm bypassed: login/reg page' ) ;
  76.             $can = false ;
  77.         }
  78.  
  79.         $can_final = apply_filters( 'litespeed_can_optm', $can ) ;
  80.  
  81.         if ( $can_final != $can ) {
  82.             Debug2::debug( '[Router] Optm bypassed: filter' ) ;
  83.         }
  84.  
  85.         return $can_final ;
  86.     }
  87.  
  88.     /**
  89.      * Check referer page to see if its from admin
  90.      *
  91.      * @since 2.4.2.1
  92.      * @access public
  93.      */
  94.     public static function from_admin()
  95.     {
  96.         return ! empty( $_SERVER[ 'HTTP_REFERER' ] ) && strpos( $_SERVER[ 'HTTP_REFERER' ], get_admin_url() ) === 0 ;
  97.     }
  98.  
  99.     /**
  100.      * Check if it can use CDN replacement
  101.      *
  102.      * @since  1.2.3
  103.      * @since  2.3.1 Relocated from cdn.cls
  104.      * @access public
  105.      */
  106.     public static function can_cdn()
  107.     {
  108.         $can = true ;
  109.  
  110.         if ( is_admin() ) {
  111.             if ( ! self::is_ajax() ) {
  112.                 Debug2::debug2( '[Router] CDN bypassed: is not ajax call' ) ;
  113.                 $can = false ;
  114.             }
  115.  
  116.             if ( self::from_admin() ) {
  117.                 Debug2::debug2( '[Router] CDN bypassed: ajax call from admin' ) ;
  118.                 $can = false ;
  119.             }
  120.         }
  121.         elseif ( is_feed() ) {
  122.             $can = false ;
  123.         }
  124.         elseif ( is_preview() ) {
  125.             $can = false ;
  126.         }
  127.  
  128.         /**
  129.          * Bypass cron to avoid deregister jq notice `Do not deregister the <code>jquery-core</code> script in the administration area.`
  130.          * @since  2.7.2
  131.          */
  132.         if ( defined( 'DOING_CRON' ) ) {
  133.             $can = false ;
  134.         }
  135.  
  136.         /**
  137.          * Bypass login/reg page
  138.          * @since  1.6
  139.          */
  140.         if ( self::_is_login_page() ) {
  141.             Debug2::debug( '[Router] CDN bypassed: login/reg page' ) ;
  142.             $can = false ;
  143.         }
  144.  
  145.         /**
  146.          * Bypass post/page link setting
  147.          * @since 2.9.8.5
  148.          */
  149.         if (
  150.             strpos( $_SERVER[ 'REQUEST_URI' ], rest_get_url_prefix() . '/wp/v2/media' ) !== false
  151.             && strpos( $_SERVER[ 'HTTP_REFERER' ], 'wp-admin') !== false
  152.         ) {
  153.             Debug2::debug( '[Router] CDN bypassed: wp-json on admin page' ) ;
  154.             $can = false ;
  155.         }
  156.  
  157.         $can_final = apply_filters( 'litespeed_can_cdn', $can ) ;
  158.  
  159.         if ( $can_final != $can ) {
  160.             Debug2::debug( '[Router] CDN bypassed: filter' ) ;
  161.         }
  162.  
  163.         return $can_final ;
  164.     }
  165.  
  166.     /**
  167.      * Check if is login page or not
  168.      *
  169.      * @since  2.3.1
  170.      * @access protected
  171.      */
  172.     protected static function _is_login_page()
  173.     {
  174.         if ( in_array( $GLOBALS[ 'pagenow' ], array( 'wp-login.php', 'wp-register.php' ), true ) ) {
  175.             return true ;
  176.         }
  177.  
  178.         return false ;
  179.     }
  180.  
  181.     /**
  182.      * Crawler simulate role
  183.      *
  184.      * @since  1.9.1
  185.      * @access public
  186.      */
  187.     public function is_crawler_role_simulation()
  188.     {
  189.         if( is_admin() ) {
  190.             return ;
  191.         }
  192.  
  193.         if ( empty( $_COOKIE[ 'litespeed_role' ] ) || empty( $_COOKIE[ 'litespeed_hash' ] ) ) {
  194.             return ;
  195.         }
  196.  
  197.         Debug2::debug( '[Router] starting crawler role validation' ) ;
  198.  
  199.         // Check if is from crawler
  200.         if ( empty( $_SERVER[ 'HTTP_USER_AGENT' ] ) || strpos( $_SERVER[ 'HTTP_USER_AGENT' ], Crawler::FAST_USER_AGENT ) !== 0 ) {
  201.             Debug2::debug( '[Router] user agent not match' ) ;
  202.             return ;
  203.         }
  204.  
  205.         // Hash validation
  206.         $hash = Crawler::get_option( Crawler::ITEM_HASH ) ;
  207.         if ( ! $hash || $_COOKIE[ 'litespeed_hash' ] != $hash ) {
  208.             Debug2::debug( '[Router] crawler hash not match ' . $_COOKIE[ 'litespeed_hash' ] . ' != ' . $hash ) ;
  209.             return ;
  210.         }
  211.  
  212.         $role_uid = $_COOKIE[ 'litespeed_role' ] ;
  213.         Debug2::debug( '[Router] role simulate litespeed_role uid ' . $role_uid ) ;
  214.  
  215.         wp_set_current_user( $role_uid ) ;
  216.     }
  217.  
  218.     /**
  219.      * Get user id
  220.      *
  221.      * @since  1.6.2
  222.      */
  223.     public static function get_uid()
  224.     {
  225.         if ( defined( 'LITESPEED_WP_UID' ) ) {
  226.             return LITESPEED_WP_UID ;
  227.         }
  228.  
  229.         $user = wp_get_current_user() ;
  230.         $user_id = $user->ID ;
  231.  
  232.         Debug2::debug( '[Router] get_uid: ' . $user_id, 3 ) ;
  233.  
  234.         define( 'LITESPEED_WP_UID', $user_id ) ;
  235.  
  236.         return LITESPEED_WP_UID ;
  237.     }
  238.  
  239.     /**
  240.      * Get user role
  241.      *
  242.      * @since  1.6.2
  243.      */
  244.     public static function get_role( $uid = null )
  245.     {
  246.         if ( defined( 'LITESPEED_WP_ROLE' ) ) {
  247.             return LITESPEED_WP_ROLE ;
  248.         }
  249.  
  250.         if ( $uid === null ) {
  251.             $uid = self::get_uid() ;
  252.         }
  253.  
  254.         $role = false ;
  255.         if ( $uid ) {
  256.             $user = get_userdata( $uid ) ;
  257.             if ( isset( $user->roles ) && is_array( $user->roles ) ) {
  258.                 $tmp = array_values( $user->roles ) ;
  259.                 $role = array_shift( $tmp ) ;
  260.             }
  261.         }
  262.         Debug2::debug( '[Router] get_role: ' . $role ) ;
  263.  
  264.         if ( ! $role ) {
  265.             return $role ;
  266.             // Guest user
  267.             Debug2::debug( '[Router] role: guest' ) ;
  268.  
  269.             /**
  270.              * Fix double login issue
  271.              * The previous user init refactoring didn't fix this bcos this is in login process and the user role could change
  272.              * @see  https://github.com/litespeedtech/lscache_wp/commit/69e7bc71d0de5cd58961bae953380b581abdc088
  273.              * @since  2.9.8 Won't assign const if in login process
  274.              */
  275.             if ( substr_compare( wp_login_url(), $GLOBALS[ 'pagenow' ], -strlen( $GLOBALS[ 'pagenow' ] ) ) === 0 ) {
  276.                 return $role ;
  277.             }
  278.         }
  279.  
  280.         define( 'LITESPEED_WP_ROLE', $role ) ;
  281.  
  282.         return LITESPEED_WP_ROLE ;
  283.     }
  284.  
  285.     /**
  286.      * Get frontend path
  287.      *
  288.      * @since 1.2.2
  289.      * @access public
  290.      * @return boolean
  291.      */
  292.     public static function frontend_path()//todo: move to htaccess.cls ?
  293.     {
  294.         if ( ! isset( self::$_frontend_path ) ) {
  295.             $frontend = rtrim( ABSPATH, '/' ) ; // /home/user/public_html/frontend
  296.             // get home path failed. Trac ticket #37668 (e.g. frontend:/blog backend:/wordpress)
  297.             if ( ! $frontend ) {
  298.                 Debug2::debug( '[Router] No ABSPATH, generating from home option' ) ;
  299.                 $frontend = parse_url( get_option( 'home' ) ) ;
  300.                 $frontend = ! empty( $frontend[ 'path' ] ) ? $frontend[ 'path' ] : '' ;
  301.                 $frontend = $_SERVER[ 'DOCUMENT_ROOT' ] . $frontend ;
  302.             }
  303.             $frontend = realpath( $frontend ) ;
  304.  
  305.             self::$_frontend_path = $frontend ;
  306.         }
  307.         return self::$_frontend_path ;
  308.     }
  309.  
  310.     /**
  311.      * Check if ESI is enabled or not
  312.      *
  313.      * @since 1.2.0
  314.      * @access public
  315.      * @return boolean
  316.      */
  317.     public static function esi_enabled()
  318.     {
  319.         if ( ! isset( self::$_esi_enabled ) ) {
  320.             self::$_esi_enabled = defined( 'LITESPEED_ON' ) && Conf::val( Base::O_ESI ) ;
  321.         }
  322.         return self::$_esi_enabled ;
  323.     }
  324.  
  325.     /**
  326.      * Check if crawler is enabled on server level
  327.      *
  328.      * @since 1.1.1
  329.      * @access public
  330.      */
  331.     public static function can_crawl()
  332.     {
  333.         if ( isset( $_SERVER[ 'X-LSCACHE' ] ) && strpos( $_SERVER[ 'X-LSCACHE' ], 'crawler' ) === false ) {
  334.             return false;
  335.         }
  336.  
  337.         // CLI will bypass this check as crawler library can always do the 428 check
  338.         if ( defined( 'LITESPEED_CLI' ) ) {
  339.             return true;
  340.         }
  341.  
  342.         return true;
  343.     }
  344.  
  345.     /**
  346.      * Check action
  347.      *
  348.      * @since 1.1.0
  349.      * @access public
  350.      * @return string
  351.      */
  352.     public static function get_action()
  353.     {
  354.         if ( ! isset( self::$_action ) ) {
  355.             self::$_action = false;
  356.             self::get_instance()->verify_action() ;
  357.             if ( self::$_action ) {
  358.                 defined( 'LSCWP_LOG' ) && Debug2::debug( '[Router] LSCWP_CTRL verified: ' . var_export( self::$_action, true ) ) ;
  359.             }
  360.  
  361.         }
  362.         return self::$_action ;
  363.     }
  364.  
  365.     /**
  366.      * Check if is logged in
  367.      *
  368.      * @since 1.1.3
  369.      * @access public
  370.      * @return boolean
  371.      */
  372.     public static function is_logged_in()
  373.     {
  374.         if ( ! isset( self::$_is_logged_in ) ) {
  375.             self::$_is_logged_in = is_user_logged_in() ;
  376.         }
  377.         return self::$_is_logged_in ;
  378.     }
  379.  
  380.     /**
  381.      * Check if is ajax call
  382.      *
  383.      * @since 1.1.0
  384.      * @access public
  385.      * @return boolean
  386.      */
  387.     public static function is_ajax()
  388.     {
  389.         if ( ! isset( self::$_is_ajax ) ) {
  390.             self::$_is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ;
  391.         }
  392.         return self::$_is_ajax ;
  393.     }
  394.  
  395.     /**
  396.      * Check if is admin ip
  397.      *
  398.      * @since 1.1.0
  399.      * @access public
  400.      * @return boolean
  401.      */
  402.     public static function is_admin_ip()
  403.     {
  404.         if ( ! isset( self::$_is_admin_ip ) ) {
  405.             $ips = Conf::val( Base::O_DEBUG_IPS ) ;
  406.  
  407.             self::$_is_admin_ip = self::get_instance()->ip_access( $ips ) ;
  408.         }
  409.         return self::$_is_admin_ip ;
  410.     }
  411.  
  412.     /**
  413.      * Get type value
  414.      *
  415.      * @since 1.6
  416.      * @access public
  417.      */
  418.     public static function verify_type()
  419.     {
  420.         if ( empty( $_REQUEST[ self::TYPE ] ) ) {
  421.             Debug2::debug( '[Router] no type', 2 ) ;
  422.             return false ;
  423.         }
  424.  
  425.         Debug2::debug( '[Router] parsed type: ' . $_REQUEST[ self::TYPE ], 2 ) ;
  426.  
  427.         return $_REQUEST[ self::TYPE ] ;
  428.     }
  429.  
  430.     /**
  431.      * Check privilege and nonce for the action
  432.      *
  433.      * @since 1.1.0
  434.      * @access private
  435.      */
  436.     private function verify_action()
  437.     {
  438.         if ( empty( $_REQUEST[ Router::ACTION ] ) ) {
  439.             Debug2::debug2( '[Router] LSCWP_CTRL bypassed empty' ) ;
  440.             return ;
  441.         }
  442.  
  443.         $action = $_REQUEST[ Router::ACTION ] ;
  444.         $_is_public_action = false ;
  445.  
  446.         // Each action must have a valid nonce unless its from admin ip and is public action
  447.         // Validate requests nonce (from admin logged in page or cli)
  448.         if ( ! $this->verify_nonce( $action ) ) {
  449.             // check if it is from admin ip
  450.             if ( ! $this->is_admin_ip() ) {
  451.                 Debug2::debug( '[Router] LSCWP_CTRL query string - did not match admin IP: ' . $action ) ;
  452.                 return ;
  453.             }
  454.  
  455.             // check if it is public action
  456.             if ( ! in_array( $action, array(
  457.                     Core::ACTION_QS_NOCACHE,
  458.                     Core::ACTION_QS_PURGE,
  459.                     Core::ACTION_QS_PURGE_SINGLE,
  460.                     Core::ACTION_QS_SHOW_HEADERS,
  461.                     Core::ACTION_QS_PURGE_ALL,
  462.                     Core::ACTION_QS_PURGE_EMPTYCACHE,
  463.                     ) ) ) {
  464.                 Debug2::debug( '[Router] LSCWP_CTRL query string - did not match admin IP Actions: ' . $action ) ;
  465.                 return ;
  466.             }
  467.  
  468.             $_is_public_action = true ;
  469.         }
  470.  
  471.         /* Now it is a valid action, lets log and check the permission */
  472.         Debug2::debug( '[Router] LSCWP_CTRL: ' . $action ) ;
  473.  
  474.         // OK, as we want to do something magic, lets check if its allowed
  475.         $_is_multisite = is_multisite() ;
  476.         $_is_network_admin = $_is_multisite && is_network_admin() ;
  477.         $_can_network_option = $_is_network_admin && current_user_can( 'manage_network_options' ) ;
  478.         $_can_option = current_user_can( 'manage_options' ) ;
  479.  
  480.         switch ( $action ) {
  481.             // Save htaccess
  482.             case self::ACTION_SAVE_HTACCESS:
  483.                 if ( ( ! $_is_multisite && $_can_option ) || $_can_network_option ) {
  484.                     self::$_action = $action ;
  485.                 }
  486.                 return ;
  487.  
  488.             // Save network settings
  489.             case self::ACTION_SAVE_SETTINGS_NETWORK:
  490.                 if ( $_can_network_option ) {
  491.                     self::$_action = $action ;
  492.                 }
  493.                 return ;
  494.  
  495.             case Core::ACTION_PURGE_BY:
  496.                 if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || $_can_option || self::is_ajax() ) ) {//here may need more security
  497.                     self::$_action = $action ;
  498.                 }
  499.                 return ;
  500.  
  501.             case self::ACTION_DB_OPTM:
  502.                 if ( $_can_network_option || $_can_option ) {
  503.                     self::$_action = $action ;
  504.                 }
  505.                 return ;
  506.  
  507.             case Core::ACTION_PURGE_EMPTYCACHE:// todo: moved to purge.cls type action
  508.                 if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || ( ! $_is_multisite && $_can_option ) ) ) {
  509.                     self::$_action = $action ;
  510.                 }
  511.                 return ;
  512.  
  513.             case Core::ACTION_QS_NOCACHE:
  514.             case Core::ACTION_QS_PURGE:
  515.             case Core::ACTION_QS_PURGE_SINGLE:
  516.             case Core::ACTION_QS_SHOW_HEADERS:
  517.             case Core::ACTION_QS_PURGE_ALL:
  518.             case Core::ACTION_QS_PURGE_EMPTYCACHE:
  519.                 if ( defined( 'LITESPEED_ON' ) && ( $_is_public_action || self::is_ajax() ) ) {
  520.                     self::$_action = $action ;
  521.                 }
  522.                 return ;
  523.  
  524.             case self::ACTION_PURGE:
  525.             case self::ACTION_PLACEHOLDER:
  526.             case self::ACTION_AVATAR:
  527.             case self::ACTION_IMG_OPTM:
  528.             case self::ACTION_CLOUD:
  529.             case self::ACTION_CDN_CLOUDFLARE:
  530.             case self::ACTION_CDN_QUIC:
  531.             case self::ACTION_CRAWLER:
  532.             case self::ACTION_IMPORT:
  533.             case self::ACTION_REPORT:
  534.             case self::ACTION_CSS:
  535.             case self::ACTION_CONF:
  536.             case self::ACTION_ACTIVATION:
  537.             case self::ACTION_HEALTH:
  538.             case self::ACTION_SAVE_SETTINGS: // Save settings
  539.                 if ( $_can_option && ! $_is_network_admin ) {
  540.                     self::$_action = $action ;
  541.                 }
  542.                 return ;
  543.  
  544.             case self::ACTION_DEBUG2:
  545.                 if ( $_can_network_option || $_can_option ) {
  546.                     self::$_action = $action ;
  547.                 }
  548.                 return ;
  549.  
  550.             case Core::ACTION_DISMISS:
  551.                 /**
  552.                  * Non ajax call can dismiss too
  553.                  * @since  2.9
  554.                  */
  555.                 // if ( self::is_ajax() ) {
  556.                 self::$_action = $action ;
  557.                 // }
  558.                 return ;
  559.  
  560.             default:
  561.                 Debug2::debug( '[Router] LSCWP_CTRL match falied: ' . $action ) ;
  562.                 return ;
  563.         }
  564.  
  565.     }
  566.  
  567.     /**
  568.      * Verify nonce
  569.      *
  570.      * @since 1.1.0
  571.      * @access private
  572.      * @param  string $action
  573.      * @return bool
  574.      */
  575.     private function verify_nonce( $action )
  576.     {
  577.         if ( ! isset( $_REQUEST[Router::NONCE] ) || ! wp_verify_nonce( $_REQUEST[Router::NONCE], $action ) ) {
  578.             return false ;
  579.         }
  580.         else{
  581.             return true ;
  582.         }
  583.     }
  584.  
  585.     /**
  586.      * Check if the ip is in the range
  587.      *
  588.      * @since 1.1.0
  589.      * @access private
  590.      * @param  string $ip_list IP list
  591.      * @return bool
  592.      */
  593.     private function ip_access( $ip_list )
  594.     {
  595.         if ( ! $ip_list ) {
  596.             return false ;
  597.         }
  598.         if ( ! isset( self::$_ip ) ) {
  599.             self::$_ip = $this->get_ip() ;
  600.         }
  601.         // $uip = explode('.', $_ip) ;
  602.         // if(empty($uip) || count($uip) != 4) Return false ;
  603.         // foreach($ip_list as $key => $ip) $ip_list[$key] = explode('.', trim($ip)) ;
  604.         // foreach($ip_list as $key => $ip) {
  605.         //  if(count($ip) != 4) continue ;
  606.         //  for($i = 0 ; $i <= 3 ; $i++) if($ip[$i] == '*') $ip_list[$key][$i] = $uip[$i] ;
  607.         // }
  608.         return in_array( self::$_ip, $ip_list ) ;
  609.     }
  610.  
  611.     /**
  612.      * Get client ip
  613.      *
  614.      * @since 1.1.0
  615.      * @since  1.6.5 changed to public
  616.      * @access public
  617.      * @return string
  618.      */
  619.     public static function get_ip()
  620.     {
  621.         $_ip = '' ;
  622.         if ( function_exists( 'apache_request_headers' ) ) {
  623.             $apache_headers = apache_request_headers() ;
  624.             $_ip = ! empty( $apache_headers['True-Client-IP'] ) ? $apache_headers['True-Client-IP'] : false ;
  625.             if ( ! $_ip ) {
  626.                 $_ip = ! empty( $apache_headers['X-Forwarded-For'] ) ? $apache_headers['X-Forwarded-For'] : false ;
  627.                 $_ip = explode( ", ", $_ip ) ;
  628.                 $_ip = array_shift( $_ip ) ;
  629.             }
  630.  
  631.         }
  632.  
  633.         if ( ! $_ip ) {
  634.             $_ip = ! empty( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : false ;
  635.         }
  636.         return $_ip ;
  637.     }
  638.  
  639.     /**
  640.      * Check if opcode cache is enabled
  641.      *
  642.      * @since  1.8.2
  643.      * @access public
  644.      */
  645.     public static function opcache_enabled()
  646.     {
  647.         return function_exists( 'opcache_reset' ) && ini_get( 'opcache.enable' ) ;
  648.     }
  649.  
  650.     /**
  651.      * Handle static files
  652.      *
  653.      * @since  3.0
  654.      */
  655.     public static function serve_static()
  656.     {
  657.         if( array_key_exists('SCRIPT_URI', $_SERVER)) {
  658.        
  659.             if ( strpos( $_SERVER[ 'SCRIPT_URI' ], LITESPEED_STATIC_URL . '/' ) !== 0 ) {
  660.                 return ;
  661.             }
  662.        
  663.        
  664.  
  665.             $path = substr( $_SERVER[ 'SCRIPT_URI' ], strlen( LITESPEED_STATIC_URL . '/' ) ) ;
  666.             $path = explode( '/', $path, 2 ) ;
  667.  
  668.         }
  669.  
  670.         if ( empty( $path[ 0 ] ) || empty( $path[ 1 ] ) ) {
  671.             return ;
  672.         }
  673.  
  674.         switch ( $path[ 0 ] ) {
  675.             case 'avatar' :
  676.                 Avatar::get_instance()->serve_satic( $path[ 1 ] ) ;
  677.                 break ;
  678.  
  679.             case 'cssjs' :
  680.                 Optimize::get_instance()->serve_satic( $path[ 1 ] ) ;
  681.                 break ;
  682.  
  683.             default :
  684.                 break ;
  685.         }
  686.  
  687.     }
  688.  
  689.     /**
  690.      * Handle all request actions from main cls
  691.      *
  692.      * This is different than other handlers
  693.      *
  694.      * @since  3.0
  695.      * @access public
  696.      */
  697.     public static function handler( $cls )
  698.     {
  699.         // CDN is child namespaces
  700.         if ( $cls == self::ACTION_CDN_QUIC || $cls == self::ACTION_CDN_CLOUDFLARE ) {
  701.             $cls = str_replace( '_', '\\', $cls );
  702.         }
  703.  
  704.         $cls = __NAMESPACE__ . '\\' . $cls;
  705.  
  706.         if ( method_exists( $cls, 'handler' ) ) {
  707.             return $cls::handler();
  708.         }
  709.     }
  710.  
  711. }
Add Comment
Please, Sign In to add comment