最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

The style.php file inside theme-engine folder has other content on FTP

programmeradmin1浏览0评论

I would like to change one image that is apparently still hosted on HTTP on my client's website so that it will be re-uploaded on HTTPS.

Using the Inspect feature of my Chrome browser, I spotted the file and it seems to be coming from a file referenced in a link tag with the following structure (altered slightly here for security reasons):

<link rel='stylesheet' id='SAMPLETHEME-theme-css-css' href='.php?ver=4.9.13' type='text/css' media='all' />

When I open the above file in my browser, it seems to be a CSS file and I can see where this old image is located and that it has an HTTP address, which needs to change.

After failing to find the file in the admin panel, I got access to the FTP location of the host. Inside the FTP, I looked for the corresponding folder under SAMPLETHEME-child and then navigate to /lib/theme-engine/ to find style.php. And I do find the file. Except that it does not have the same content as when I opened in the browser.

Does this .php file simply generate another new file when run? At least that's what I have gathered from its code. Below is what the file contains. But the image I am looking for I am still yet to find!

<?php
/**
 * Set header
 */
header( "Content-type: text/css", true );

/**
 * Set constants
 */
define( 'STYLESHEET_FILENAME', 'style.css' );
define( 'STYLESHEET_DEV_PATH', 'dev/' );

/**
 * Generates a CSS file based on different settings
 * @return string
 */
function generate_css() {
    /**
     * If merged stylesheet exists, load - else create a new file.
     */
    if ( file_exists( STYLESHEET_FILENAME ) ) {
        return file_get_contents( STYLESHEET_FILENAME );
    } else {

        /*
         *  Load WordPress core
         */
        define( 'WP_USE_THEMES', false );
        $parse_uri = explode( 'wp-content', $_SERVER['SCRIPT_FILENAME'] );
        require_once( $parse_uri[0] . 'wp-load.php' );

        /**
         * Prepare new merged stylesheet
         */
        $output = "";
        $files  = scandir( STYLESHEET_DEV_PATH );
        foreach ( $files as $file ) {
            // Parse CSS file
            $data = parse_file( $file );
            // Parse font variables
            $data = parse_font_style( $data );
            // Compress CSS and add to queue
            $output .= compress( $data );
        }

        /**
         * If production is running, save file
         */
        if ( get_option( 'getup_theme_production', false ) == true ) {
            file_put_contents( STYLESHEET_FILENAME, $output );
        }

        return $output;
    }
}

/**
 * Parse file
 *
 * @param $filename
 *
 * @return string
 */
function parse_file( $filename ) {
    $ext = pathinfo( $filename, PATHINFO_EXTENSION );
    if ( $ext == 'css' ) {
        $data = file_get_contents( STYLESHEET_DEV_PATH . $filename );

        /** Logic to parse variables **/

        return $data;
    }
}

/**
 * Compress CSS file
 *
 * @param $buffer string
 *
 * @return string
 */
function compress( $buffer ) {
    /* remove comments */
    $buffer = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer );
    /* remove tabs, spaces, newlines, etc. */
    $buffer = str_replace( array( "\r\n", "\r", "\n", "\t", '  ', '    ', '    ' ), '', $buffer );

    return $buffer;
}

/**
 * Parse and process font style variables
 *
 * @param $data
 *
 * @return string
 */
function parse_font_style( $data ) {
    $font_family = get_option( 'getup_theme_font_family', "'BRANDFILE', serif" );
    $font        = get_option( 'getup_theme_font', '+Sans:400,600,700' );

    $search  = array( '$font-family$', '$font$' );
    $replace = array( $font_family, $font );
    $data    = str_replace( $search, $replace, $data );

    return $data;
}

echo generate_css();
发布评论

评论列表(0)

  1. 暂无评论