Enable Gzip Compression

Add the following code to typecho’s config.inc.php

/** Enable gzip compression */
ob_start('ob_gzhandler');

Remove Address Bar index.php

In Typeho background settings in the address rewrite select wordpress style, set pseudo-static for typecho, as follows:

if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php$1 last;
}

Site Setup Https

Add the following code to the configuration file.

define('__TYPECHO_SECURE__',true);

Bypass Proxy to Get IP

Add the following code to the configuration file

if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
    $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
    $_SERVER['REMOTE_ADDR'] = $list[0];}

Modify Gravatar Avatar to QQ Avatar

Search within the Common.php file in the blog’s root directory under /var/Typecho (get gravatar avatar address) or roughly at line 816

/**
    * Get QQ avatar, if it fails, get Gravatar avatar.
    * 
    * @param string $mail 
    * @param int $size 
    * @param string $rating 
    * @param string $default 
    * @param bool $isSecure 
    * @return string
    */
    public static function gravatarUrl($mail, $size, $rating, $default, $isSecure = false)
     {
        $reg = "/^\d{5,11}@[qQ][Qq]\.(com)$/";
        if (preg_match($reg, $mail)) {
            $img    = explode("@", $mail);
            $url = "//q2.qlogo.cn/headimg_dl?dst_uin={$img[0]}&spec=100";
        } else {
            if (defined('__TYPECHO_GRAVATAR_PREFIX__')) {
                $url = __TYPECHO_GRAVATAR_PREFIX__;
            } else {
                $url = $isSecure ? 'https://sdn.geekzu.org' : 'https://gravatar.inwao.com';
                $url .= '/avatar/';
            }
            if (!empty($mail)) {
                $url .= md5(strtolower(trim($mail)));
            }
            $url .= '?s=' . $size;
            $url .= '&r=' . $rating;
            $url .= '&d=' . $default;
        }
        return $url;
    }

Modify the File Upload Path

Open the following file var/Widget/Upload.php and modify the upload directory.

/**
 * Upload component
 *
 * @ Author Qi Ning
 * @ category typecho
 * @ Widgets
 */
class Upload extends Contents implements ActionInterface
{
    // Upload the file directory.
    public constant UPLOAD_DIR = 'usr/uploads'; /*** UPLOAD_DIR = 'usr/uploads'.
 
    /**
     * Delete files.
     *
     * Array of parameters $content file-related information
     * Returns bool
     */
    public static function deleteHandle(array $content): bool
    {
        $result = Plugin::factory(Upload::class)->trigger($hasDeleted)->deleteHandle($content); { If ($hasDeleted) is deleted, deleteHandle($content) is deleted.
        If ($hasDeleted) {
            Return $result; }
        }
 
        return @unlink(__TYPECHO_ROOT_DIR__ . '/' . $content['attachment]-> path); } }
    }