/home/vianto5/distritosatelite.mx/wp-content/plugins/litespeed-cache/src
NameSizeModeActions
cdn/-0755rm
data_structure/-0755rm
activation.cls.php180400644editdlrm
admin-display.cls.php501090644editdlrm
admin-settings.cls.php130780644editdlrm
admin.cls.php62760644editdlrm
api.cls.php101510644editdlrm
avatar.cls.php94610644editdlrm
base.cls.php387470644editdlrm
cdn.cls.php181830644editdlrm
cloud-auth-callback.trait.php238870644editdlrm
cloud-auth-ip.trait.php20940644editdlrm
cloud-auth.trait.php93600644editdlrm
cloud-misc.trait.php111230644editdlrm
cloud-node.trait.php60900644editdlrm
cloud-queue-svc.cls.php96420644editdlrm
cloud-request.trait.php197230644editdlrm
cloud.cls.php88480644editdlrm
conf.cls.php200000644editdlrm
control.cls.php249130644editdlrm
core.cls.php220460644editdlrm
crawler-map.cls.php228330644editdlrm
crawler.cls.php449890644editdlrm
css.cls.php70340644editdlrm
data.cls.php227330644editdlrm
data.upgrade.func.php65640644editdlrm
db-optm.cls.php157160644editdlrm
debug2.cls.php188320644editdlrm
doc.cls.php55770644editdlrm
error.cls.php75300644editdlrm
esi.cls.php327950644editdlrm
file.cls.php204720644editdlrm
guest.cls.php22630644editdlrm
gui.cls.php358170644editdlrm
health.cls.php46940644editdlrm
htaccess.cls.php305260644editdlrm
img-optm-manage.trait.php306270644editdlrm
img-optm-notify.trait.php91130644editdlrm
img-optm-pull.trait.php139630644editdlrm
img-optm-send.trait.php215450644editdlrm
img-optm.cls.php52650644editdlrm
img.cls.php114270644editdlrm
import.cls.php43720644editdlrm
import.preset.cls.php56100644editdlrm
lang.cls.php174300644editdlrm
localization.cls.php39410644editdlrm
media.cls.php451170644editdlrm
metabox.cls.php54190644editdlrm
object-cache-wp.cls.php192680644editdlrm
object-cache.cls.php223460644editdlrm
object.lib.php141800644editdlrm
optimax.cls.php124290644editdlrm
optimize.cls.php393350644editdlrm
optimizer.cls.php129730644editdlrm
placeholder.cls.php179500644editdlrm
purge.cls.php363300644editdlrm
report.cls.php76680644editdlrm
rest.cls.php104040644editdlrm
root.cls.php150180644editdlrm
router.cls.php213620644editdlrm
str.cls.php31560644editdlrm
tag.cls.php94810644editdlrm
task.cls.php91930644editdlrm
tool.cls.php46870644editdlrm
ucss.cls.php74510644editdlrm
utility.cls.php284930644editdlrm
vary.cls.php218420644editdlrm
vpi.cls.php42120644editdlrm
Edit: /home/vianto5/distritosatelite.mx/wp-content/plugins/litespeed-cache/src/avatar.cls.php (9461B)
rewritten URL to avoid duplicates. * * @var array */ private $_avatar_realtime_gen_dict = []; /** * Init. * * @since 1.4 */ public function __construct() { $this->_tb = Data::cls()->tb( 'avatar' ); if ( ! $this->conf( self::O_DISCUSS_AVATAR_CACHE ) ) { return; } self::debug2( '[Avatar] init' ); $this->_conf_cache_ttl = $this->conf( self::O_DISCUSS_AVATAR_CACHE_TTL ); add_filter( 'get_avatar_url', [ $this, 'crawl_avatar' ] ); $this->_summary = self::get_summary(); } /** * Check whether DB table is needed. * * @since 3.0 * @access public * @return bool */ public function need_db() { return (bool) $this->conf( self::O_DISCUSS_AVATAR_CACHE ); } /** * Serve static avatar by md5 (used by local static route). * * @since 3.0 * @access public * @param string $md5 MD5 hash of original avatar URL. * @return void */ public function serve_static( $md5 ) { global $wpdb; self::debug( '[Avatar] is avatar request' ); // No generation for any request when avatar cache is off — fall through to the regular WP 404, same as the no-matched-record path below. if ( ! $this->conf( self::O_DISCUSS_AVATAR_CACHE ) ) { self::debug( '[Avatar] bypassed serving as avatar cache is off' ); return; } if ( strlen( $md5 ) !== 32 ) { self::debug( '[Avatar] wrong md5 ' . $md5 ); return; } $url = $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->prepare( 'SELECT url FROM `' . $this->_tb . '` WHERE md5 = %s', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared $md5 ) ); if ( ! $url ) { self::debug( '[Avatar] no matched url for md5 ' . $md5 ); return; } $generated_url = $this->_generate( $url ); if ( $generated_url === $url ) { self::debug( '[Avatar] generation failed; bypassing redirect' ); return; } wp_safe_redirect( $generated_url ); exit; } /** * Localize/replace avatar URL with cached one (filter callback). * * @since 3.0 * @access public * @param string $url Original avatar URL. * @return string Rewritten/cached avatar URL (or original). */ public function crawl_avatar( $url ) { if ( ! $url ) { return $url; } // Check if already generated in this request. if ( ! empty( $this->_avatar_realtime_gen_dict[ $url ] ) ) { self::debug2( '[Avatar] already in dict [url] ' . $url ); return $this->_avatar_realtime_gen_dict[ $url ]; } $realpath = $this->_realpath( $url ); $mtime = file_exists( $realpath ) ? filemtime( $realpath ) : false; if ( $mtime && time() - (int) $mtime <= $this->_conf_cache_ttl ) { self::debug2( '[Avatar] cache file exists [url] ' . $url ); return $this->_rewrite( $url, $mtime ); } // Only handle gravatar or known remote avatar providers; keep generic check for "gravatar.com". if ( strpos( $url, 'gravatar.com' ) === false ) { return $url; } // Throttle generation. if ( ! empty( $this->_summary['curr_request'] ) && time() - (int) $this->_summary['curr_request'] < 300 ) { self::debug2( '[Avatar] Bypass generating due to interval limit [url] ' . $url ); return $url; } // Generate immediately and track for this request. $this->_avatar_realtime_gen_dict[ $url ] = $this->_generate( $url ); return $this->_avatar_realtime_gen_dict[ $url ]; } /** * Count queued avatars (expired ones) for cron. * * @since 3.0 * @access public * @return int|false */ public function queue_count() { global $wpdb; // Avatar cache option is the module-level switch: no queue and no table creation side effect when off. if ( ! $this->conf( self::O_DISCUSS_AVATAR_CACHE ) ) { return 0; } if ( ! Data::cls()->tb_exist( 'avatar' ) ) { Data::cls()->tb_create( 'avatar' ); } $cnt = $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->prepare( 'SELECT COUNT(*) FROM `' . $this->_tb . '` WHERE dateline < %d', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared time() - $this->_conf_cache_ttl ) ); return (int) $cnt; } /** * Build final local URL for cached avatar. * * @since 3.0 * @param string $url Original URL. * @param int|null $time Optional filemtime for cache busting. * @return string Local URL. */ private function _rewrite( $url, $time = null ) { $qs = $time ? '?ver=' . $time : ''; return LITESPEED_STATIC_URL . '/avatar/' . $this->_filepath( $url ) . $qs; } /** * Generate filesystem realpath for cache file. * * @since 3.0 * @access private * @param string $url Original URL. * @return string Absolute filesystem path. */ private function _realpath( $url ) { return LITESPEED_STATIC_DIR . '/avatar/' . $this->_filepath( $url ); } /** * Get relative filepath for cached avatar. * * @since 4.0 * @param string $url Original URL. * @return string Relative path under avatar/ (may include blog id). */ private function _filepath( $url ) { $filename = md5( $url ) . '.jpg'; if ( is_multisite() ) { $filename = get_current_blog_id() . '/' . $filename; } return $filename; } /** * Cron generation for expired avatars. * * @since 3.0 * @access public * @param bool $force Bypass throttle. * @return void */ public static function cron( $force = false ) { global $wpdb; $_instance = self::cls(); if ( ! $_instance->conf( self::O_DISCUSS_AVATAR_CACHE ) ) { self::debug( '[Avatar] bypassed cron as avatar cache is off' ); return; } if ( ! $_instance->queue_count() ) { self::debug( '[Avatar] no queue' ); return; } // For cron, need to check request interval too. if ( ! $force ) { if ( ! empty( $_instance->_summary['curr_request'] ) && time() - (int) $_instance->_summary['curr_request'] < 300 ) { self::debug( '[Avatar] curr_request too close' ); return; } } $list = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->prepare( 'SELECT url FROM `' . $_instance->_tb . '` WHERE dateline < %d ORDER BY id DESC LIMIT %d', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared time() - $_instance->_conf_cache_ttl, (int) apply_filters( 'litespeed_avatar_limit', 30 ) ) ); self::debug( '[Avatar] cron job [count] ' . ( $list ? count( $list ) : 0 ) ); if ( $list ) { foreach ( $list as $v ) { self::debug( '[Avatar] cron job [url] ' . $v->url ); $_instance->_generate( $v->url ); } } } /** * Download and store the avatar locally, then update DB row. * * @since 3.0 * @access private * @param string $url Original avatar URL. * @return string Rewritten local URL (fallback to original on failure). */ private function _generate( $url ) { global $wpdb; $file = $this->_realpath( $url ); // Mark request start self::save_summary( [ 'curr_request' => time(), ] ); $temp = File::download( $url, $file, 180 ); self::debug( '[Avatar] _generate [url] ' . $url ); if ( is_wp_error( $temp ) ) { self::debug( '[Avatar] failed to get: ' . $temp->get_error_code() ); return $url; } // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged if ( false === @getimagesize( $temp ) || ! File::publish_temp_file( $temp, $file ) ) { wp_delete_file( $temp ); self::debug( '[Avatar] failed to validate or save the image.' ); return $url; } // Save summary data self::save_summary( [ 'last_spent' => time() - (int) $this->_summary['curr_request'], 'last_request' => $this->_summary['curr_request'], 'curr_request' => 0, ] ); // Update/insert DB record $md5 = md5( $url ); $existed = $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->prepare( 'UPDATE `' . $this->_tb . '` SET dateline = %d WHERE md5 = %s', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared time(), $md5 ) ); if ( ! $existed ) { $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->prepare( 'INSERT INTO `' . $this->_tb . '` (url, md5, dateline) VALUES (%s, %s, %d)', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared $url, $md5, time() ) ); } self::debug( '[Avatar] saved avatar ' . $file ); return $this->_rewrite( $url ); } /** * Handle all request actions from main cls. * * @since 3.0 * @access public * @return void */ public function handler() { $type = Router::verify_type(); switch ( $type ) { case self::TYPE_GENERATE: self::cron( true ); break; default: break; } Admin::redirect(); } }