From 0b021e5e7d88cbb8332501a86fa60d6b35596dac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Wed, 9 Feb 2022 11:41:35 +0800
Subject: [PATCH 01/47] Fix broken extends.typecho.org link (#1315)
close #857
---
admin/copyright.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/admin/copyright.php b/admin/copyright.php
index a938086884..a952ed6d59 100644
--- a/admin/copyright.php
+++ b/admin/copyright.php
@@ -8,6 +8,6 @@
•
•
•
-
+
From 13dc5e87dd1d00b52cb772d4a17cee97791e5336 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Tue, 15 Feb 2022 11:10:15 +0800
Subject: [PATCH 02/47] Fix #1322 (#1323)
Great work!
---
var/Typecho/Config.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/var/Typecho/Config.php b/var/Typecho/Config.php
index d0cd705a09..cc1e882948 100644
--- a/var/Typecho/Config.php
+++ b/var/Typecho/Config.php
@@ -102,6 +102,7 @@ public function rewind(): void
* @access public
* @return mixed
*/
+ #[\ReturnTypeWillChange]
public function current()
{
return current($this->currentConfig);
@@ -124,6 +125,7 @@ public function next(): void
* @access public
* @return mixed
*/
+ #[\ReturnTypeWillChange]
public function key()
{
return key($this->currentConfig);
@@ -222,6 +224,7 @@ public function offsetExists($offset): bool
* @param mixed $offset
* @return mixed
*/
+ #[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->currentConfig[$offset] ?? null;
From f34d14280db442e26ff97d52c2949d0872ffe105 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Tue, 15 Feb 2022 11:10:47 +0800
Subject: [PATCH 03/47] Fix compatibility with PHP 8.1 (#1324)
* Fix compatibility with PHP 8.1
PHP Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in typecho/var/Widget/Archive.php on line 1292
* Fix login
* Fix write
* Fix manage
* Fix PHP Deprecated
---
admin/login.php | 4 ++--
admin/manage-comments.php | 2 +-
admin/manage-medias.php | 2 +-
admin/manage-pages.php | 2 +-
admin/manage-users.php | 2 +-
admin/write-page.php | 4 ++--
admin/write-post.php | 8 ++++----
var/Typecho/Response.php | 2 +-
var/Widget/Archive.php | 2 +-
var/Widget/User.php | 2 +-
10 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/admin/login.php b/admin/login.php
index 3c49bd3629..e51d5789d2 100644
--- a/admin/login.php
+++ b/admin/login.php
@@ -4,7 +4,7 @@
if ($user->hasLogin()) {
$response->redirect($options->adminUrl);
}
-$rememberName = htmlspecialchars(\Typecho\Cookie::get('__typecho_remember_name'));
+$rememberName = htmlspecialchars(\Typecho\Cookie::get('__typecho_remember_name', ''));
\Typecho\Cookie::delete('__typecho_remember_name');
$bodyClass = 'body-100';
@@ -25,7 +25,7 @@
-
+
- password) == 0): ?> class="hidden">
+
password ?? '') == 0): ?> class="hidden">
内容密码
response->redirect(defined('__TYPECHO_ADMIN__') ? $this->options->loginUrl .
- (0 === strpos($this->request->getReferer(), $this->options->loginUrl) ? '' :
+ (0 === strpos($this->request->getReferer() ?? '', $this->options->loginUrl) ? '' :
'?referer=' . urlencode($this->request->makeUriByRequest())) : $this->options->siteUrl, false);
}
}
From b0d78a81dc67368709911cc461589abcd608f7cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Mon, 21 Feb 2022 21:51:13 +0800
Subject: [PATCH 04/47] Fix #1326 (#1327)
---
var/Typecho/Validate.php | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/var/Typecho/Validate.php b/var/Typecho/Validate.php
index fbf753439a..ec89f89a9e 100644
--- a/var/Typecho/Validate.php
+++ b/var/Typecho/Validate.php
@@ -271,12 +271,12 @@ public function run(array $data, array $rules = null): array
foreach ($rules as $key => $rule) {
$this->key = $key;
$data[$key] = (is_array($data[$key]) ? 0 == count($data[$key])
- : 0 == strlen($data[$key])) ? null : $data[$key];
+ : 0 == strlen($data[$key] ?? '')) ? null : $data[$key];
foreach ($rule as $params) {
$method = $params[0];
- if ('required' != $method && 'confirm' != $method && 0 == strlen($data[$key])) {
+ if ('required' != $method && 'confirm' != $method && 0 == strlen($data[$key] ?? '')) {
continue;
}
@@ -319,11 +319,9 @@ public function confirm(?string $str, string $key): bool
*
* @access public
*
- * @param string|null $str 待处理的字符串
- *
* @return boolean
*/
- public function required(?string $str): bool
+ public function required(): bool
{
return !empty($this->data[$this->key]);
}
From b23277267a639523b017b65bd841e21dbf294c90 Mon Sep 17 00:00:00 2001
From: joyqi
Date: Thu, 24 Feb 2022 23:21:35 +0800
Subject: [PATCH 05/47] fix #1328
---
var/Typecho/Widget.php | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/var/Typecho/Widget.php b/var/Typecho/Widget.php
index 883dda86bb..e2665ead78 100644
--- a/var/Typecho/Widget.php
+++ b/var/Typecho/Widget.php
@@ -190,19 +190,24 @@ public static function alloc($params = null, $request = null, $disableSandboxOrC
/**
* alloc widget instance with alias
*
- * @param string $alias
+ * @param string|null $alias
* @param mixed $params
* @param mixed $request
* @param bool|callable $disableSandboxOrCallback
* @return $this
*/
public static function allocWithAlias(
- string $alias,
+ ?string $alias,
$params = null,
$request = null,
$disableSandboxOrCallback = true
): Widget {
- return self::widget(static::class . '@' . $alias, $params, $request, $disableSandboxOrCallback);
+ return self::widget(
+ static::class . (isset($alias) ? '@' . $alias : ''),
+ $params,
+ $request,
+ $disableSandboxOrCallback
+ );
}
/**
From 5f943d48b5cad36cad6fc8d7554417291fced56c Mon Sep 17 00:00:00 2001
From: joyqi
Date: Fri, 25 Feb 2022 21:16:12 +0800
Subject: [PATCH 06/47] fix #1329
---
var/Widget/Comments/Edit.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/var/Widget/Comments/Edit.php b/var/Widget/Comments/Edit.php
index d4a7f39e48..a21fb9506a 100644
--- a/var/Widget/Comments/Edit.php
+++ b/var/Widget/Comments/Edit.php
@@ -275,7 +275,7 @@ public function editComment(): bool
}
/** 评论插件接口 */
- self::pluginHandle()->edit($comment, $this);
+ $comment = self::pluginHandle()->edit($comment, $this);
/** 更新评论 */
$this->update($comment, $this->db->sql()->where('coid = ?', $coid));
From 17fcb2f08b5dd1efe84877143c901c741ba2e938 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Tue, 15 Mar 2022 16:09:32 +0800
Subject: [PATCH 07/47] Fix undefined Typecho\Db\Adapter_Exception (#1334)
---
install.php | 2 +-
var/Typecho/Request.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/install.php b/install.php
index 0a257eb7a0..137836764b 100644
--- a/install.php
+++ b/install.php
@@ -1051,7 +1051,7 @@ function install_step_2_perform()
$installDb = new \Typecho\Db($config['dbAdapter'], $config['dbPrefix']);
$installDb->addServer($dbConfig, \Typecho\Db::READ | \Typecho\Db::WRITE);
$installDb->query('SELECT 1=1');
- } catch (\Typecho\Db\Adapter_Exception $e) {
+ } catch (\Typecho\Db\Adapter\ConnectionException $e) {
install_raise_error(_t('对不起, 无法连接数据库, 请先检查数据库配置再继续进行安装'));
} catch (\Typecho\Db\Exception $e) {
install_raise_error(_t('安装程序捕捉到以下错误: " %s ". 程序被终止, 请检查您的配置信息.', $e->getMessage()));
diff --git a/var/Typecho/Request.php b/var/Typecho/Request.php
index 5e28e2de38..2fddd265b9 100644
--- a/var/Typecho/Request.php
+++ b/var/Typecho/Request.php
@@ -305,7 +305,7 @@ public function getPathInfo(): ?string
return $this->pathInfo;
}
- //参考Zend Framework对pahtinfo的处理, 更好的兼容性
+ //参考Zend Framework对pathinfo的处理, 更好的兼容性
$pathInfo = null;
//处理requestUri
From 0edb48fae0cc5b9feb686c7367974190074be334 Mon Sep 17 00:00:00 2001
From: joyqi
Date: Wed, 16 Mar 2022 21:05:22 +0800
Subject: [PATCH 08/47] fix #1335, close #1337
---
var/Widget/Archive.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/var/Widget/Archive.php b/var/Widget/Archive.php
index 1bd3b5ea62..6f70b23e93 100644
--- a/var/Widget/Archive.php
+++ b/var/Widget/Archive.php
@@ -1498,7 +1498,7 @@ public function feed()
'date' => $this->created,
'link' => $this->permalink,
'author' => $this->author,
- 'excerpt' => $this->description,
+ 'excerpt' => $this->___description(),
'comments' => $this->commentsNum,
'commentsFeedUrl' => $feedUrl,
'suffix' => $suffix
From 1b673e06ff459e3894b77bc1b63d7c2dae678f90 Mon Sep 17 00:00:00 2001
From: joyqi
Date: Tue, 22 Mar 2022 14:24:14 +0800
Subject: [PATCH 09/47] fix typecho/Dockerfile#9
---
install.php | 7 +++++++
var/Typecho/Validate.php | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/install.php b/install.php
index 137836764b..7962af11cb 100644
--- a/install.php
+++ b/install.php
@@ -1021,6 +1021,9 @@ function install_step_2_perform()
case 'SQLite':
$error = (new \Typecho\Validate())
->addRule('dbFile', 'required', _t('确认您的配置'))
+ ->addRule('dbFile', function (string $path) {
+ return !!preg_match("/^(\/[_a-z0-9-]+)*[a-z0-9]+\.[a-z0-9]{2,}$/i", $path);
+ }, _t('确认您的配置'))
->run($config);
break;
default:
@@ -1041,6 +1044,10 @@ function install_step_2_perform()
$dbConfig['port'] = intval($dbConfig['port']);
}
+ if (isset($dbConfig['file']) && preg_match("/^[a-z0-9]+\.[a-z0-9]{2,}$/i", $dbConfig['file'])) {
+ $dbConfig['file'] = __DIR__ . '/usr/' . $dbConfig['file'];
+ }
+
// check config file
if ($config['dbNext'] == 'config' && !install_check('config')) {
$code = install_config_file($config['dbAdapter'], $config['dbPrefix'], $dbConfig, true);
diff --git a/var/Typecho/Validate.php b/var/Typecho/Validate.php
index ec89f89a9e..4e37117289 100644
--- a/var/Typecho/Validate.php
+++ b/var/Typecho/Validate.php
@@ -221,7 +221,7 @@ public static function isInteger($str): bool
* @access public
*
* @param string $key 数值键值
- * @param string|array $rule 规则名称
+ * @param string|callable $rule 规则名称
* @param string $message 错误字符串
*
* @return $this
@@ -284,7 +284,7 @@ public function run(array $data, array $rules = null): array
$params[1] = $data[$key];
$params = array_slice($params, 1);
- if (!call_user_func_array(is_array($method) ? $method : [$this, $method], $params)) {
+ if (!call_user_func_array(is_callable($method) ? $method : [$this, $method], $params)) {
$result[$key] = $message;
break;
}
From ce7af58367cc809ffaa38e23b37a79ccb69c0df1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Thu, 24 Mar 2022 17:46:03 +0800
Subject: [PATCH 10/47] Optimize code (#1342)
---
install.php | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/install.php b/install.php
index 7962af11cb..3b193996f9 100644
--- a/install.php
+++ b/install.php
@@ -1061,7 +1061,7 @@ function install_step_2_perform()
} catch (\Typecho\Db\Adapter\ConnectionException $e) {
install_raise_error(_t('对不起, 无法连接数据库, 请先检查数据库配置再继续进行安装'));
} catch (\Typecho\Db\Exception $e) {
- install_raise_error(_t('安装程序捕捉到以下错误: " %s ". 程序被终止, 请检查您的配置信息.', $e->getMessage()));
+ install_raise_error(_t('安装程序捕捉到以下错误: "%s". 程序被终止, 请检查您的配置信息.', $e->getMessage()));
}
$code = install_config_file($config['dbAdapter'], $config['dbPrefix'], $dbConfig);
@@ -1091,12 +1091,14 @@ function install_step_2_perform()
try {
foreach ($tables as $table) {
- if ($type == 'Mysql') {
- $installDb->query("DROP TABLE IF EXISTS `{$table}`");
- } elseif ($type == 'Pgsql') {
- $installDb->query("DROP TABLE {$table}");
- } elseif ($type == 'SQLite') {
- $installDb->query("DROP TABLE {$table}");
+ switch ($type) {
+ case 'Mysql':
+ $installDb->query("DROP TABLE IF EXISTS `{$table}`");
+ break;
+ case 'Pgsql':
+ case 'SQLite':
+ $installDb->query("DROP TABLE {$table}");
+ break;
}
}
} catch (\Typecho\Db\Exception $e) {
From 0bdf8721e136d2068311aef3c503f2088d4fec5c Mon Sep 17 00:00:00 2001
From: fen
Date: Fri, 25 Mar 2022 12:08:22 +0800
Subject: [PATCH 11/47] add ignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 6b68ac9e7f..470b0e2c7d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@
*.sublime*
.sass-cache
config.rb
+prepros.config
/config.inc.php
/usr/uploads/
/usr/*.db
From 6100695d87eb3c9336e1074d30fd900a88aafb7c Mon Sep 17 00:00:00 2001
From: joyqi
Date: Fri, 25 Mar 2022 15:31:57 +0800
Subject: [PATCH 12/47] fix db exception
---
var/Typecho/Common.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/var/Typecho/Common.php b/var/Typecho/Common.php
index 27cf3e6888..07557dca3b 100644
--- a/var/Typecho/Common.php
+++ b/var/Typecho/Common.php
@@ -230,10 +230,10 @@ public static function error(\Throwable $exception)
//覆盖原始错误信息
$message = 'Database Server Error';
- if ($exception instanceof \Typecho\Db\Adapter\SQLException) {
+ if ($exception instanceof \Typecho\Db\Adapter\ConnectionException) {
$code = 503;
$message = 'Error establishing a database connection';
- } elseif ($exception instanceof \Typecho\Db\Query\Exception) {
+ } elseif ($exception instanceof \Typecho\Db\Adapter\SQLException) {
$message = 'Database Query Error';
}
}
From 4be93f27415404caf7fd7bbaafd84a9293cd017c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Mon, 28 Mar 2022 12:11:24 +0800
Subject: [PATCH 13/47] Fix missing mysqli_connect_errno (#1346)
---
var/Typecho/Db/Adapter/Mysqli.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/var/Typecho/Db/Adapter/Mysqli.php b/var/Typecho/Db/Adapter/Mysqli.php
index eee61fc30e..5f417a3cbb 100644
--- a/var/Typecho/Db/Adapter/Mysqli.php
+++ b/var/Typecho/Db/Adapter/Mysqli.php
@@ -64,7 +64,7 @@ public function connect(Config $config): \mysqli
}
/** 数据库异常 */
- throw new ConnectionException("Couldn't connect to database.");
+ throw new ConnectionException("Couldn't connect to database.", mysqli_connect_errno());
}
/**
From 2f3e15dfb84b4ca65cef82dd3148e859b3c16e53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Fri, 1 Apr 2022 11:12:54 +0800
Subject: [PATCH 14/47] Fix checkVersion (#1356)
---
var/Widget/Ajax.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/var/Widget/Ajax.php b/var/Widget/Ajax.php
index 01a774b73f..1b3b1d6ab4 100644
--- a/var/Widget/Ajax.php
+++ b/var/Widget/Ajax.php
@@ -59,7 +59,7 @@ public function checkVersion()
if (
isset($json['release'])
&& preg_match("/^[0-9\.]+$/", $json['release'])
- && version_compare($json['release'], $version, '>=')
+ && version_compare($json['release'], $version, '>')
) {
$result = [
'available' => 1,
From 2db893e80223593535be5f6ef574c8a41d57d04d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E7=BA=BF?=
<13816653+maoxian-1@users.noreply.github.com>
Date: Fri, 1 Apr 2022 14:07:08 +0800
Subject: [PATCH 15/47] Update install.php (#1357)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
修复宝塔面板的网站目录带.导致db路径校验不通过的问题
---
install.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/install.php b/install.php
index 3b193996f9..7b3b5e4650 100644
--- a/install.php
+++ b/install.php
@@ -1022,7 +1022,7 @@ function install_step_2_perform()
$error = (new \Typecho\Validate())
->addRule('dbFile', 'required', _t('确认您的配置'))
->addRule('dbFile', function (string $path) {
- return !!preg_match("/^(\/[_a-z0-9-]+)*[a-z0-9]+\.[a-z0-9]{2,}$/i", $path);
+ return !!preg_match("/^(\/[._a-z0-9-]+)*[a-z0-9]+\.[a-z0-9]{2,}$/i", $path);
}, _t('确认您的配置'))
->run($config);
break;
From c30b67d18d70c16de91f4cff7be0a353b3a416cc Mon Sep 17 00:00:00 2001
From: joyqi
Date: Fri, 1 Apr 2022 15:25:10 +0800
Subject: [PATCH 16/47] Update .gitignore
update gitignore
---
.gitignore | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore
index 470b0e2c7d..94fcdb9509 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,12 +25,13 @@
.sass-cache
config.rb
prepros.config
-/config.inc.php
-/usr/uploads/
-/usr/*.db
-/usr/plugins/
-!/usr/plugins/HelloWorld
-/usr/themes/
-!/usr/themes/default
+config.inc.*
+usr/uploads/
+usr/*.db
+usr/plugins/
+!usr/plugins/HelloWorld
+usr/themes/*
+!usr/themes/default
+!usr/themes/classic-22
node_modules/
/tools/tmp/
From ded268ef592deae2539e58e024776c6eafadf7b2 Mon Sep 17 00:00:00 2001
From: joyqi
Date: Fri, 1 Apr 2022 16:50:23 +0800
Subject: [PATCH 17/47] Pr/1344 (#1360)
* Add missing theme action
* Fix typo
* Optimize code
* Optimize code
* Update themes.php
* Simpler missing theme judgement
Co-authored-by: sy-records <52o@qq52o.cn>
---
admin/themes.php | 19 +++++++++++++++----
config.inc.sqlite.php | 27 +++++++++++++++++++++++++++
var/Widget/Options.php | 8 +++++++-
var/Widget/Themes/Config.php | 2 +-
var/Widget/Themes/Edit.php | 5 +++--
var/Widget/Themes/Files.php | 13 ++++++++++++-
6 files changed, 65 insertions(+), 9 deletions(-)
create mode 100644 config.inc.sqlite.php
diff --git a/admin/themes.php b/admin/themes.php
index 0358e67b2f..2a3a66011b 100644
--- a/admin/themes.php
+++ b/admin/themes.php
@@ -12,7 +12,7 @@
-
-
+
@@ -33,10 +33,21 @@
+ missingTheme): ?>
+
+
+ missingTheme); ?>
+
+ |
+
+
to($themes); ?>
next()): ?>
+ class="activated && !$options->missingTheme): ?>current">
|
@@ -46,9 +57,9 @@ class="activated): ?>current">
version): ?>: version() ?>
description); ?>
- theme != $themes->name): ?>
+ theme != $themes->name || $options->missingTheme): ?>
-
+
diff --git a/config.inc.sqlite.php b/config.inc.sqlite.php
new file mode 100644
index 0000000000..23e48892bb
--- /dev/null
+++ b/config.inc.sqlite.php
@@ -0,0 +1,27 @@
+addServer(array (
+ 'file' => '/Users/joyqi/Work/typecho/usr/62396a762847a.db',
+), \Typecho\Db::READ | \Typecho\Db::WRITE);
+\Typecho\Db::set($db);
+
+define('__TYPECHO_DEBUG__', true);
diff --git a/var/Widget/Options.php b/var/Widget/Options.php
index 0519b0e251..f520d5f4a6 100644
--- a/var/Widget/Options.php
+++ b/var/Widget/Options.php
@@ -46,6 +46,7 @@
* @property string $keywords
* @property string $lang
* @property string $theme
+ * @property string|null $missingTheme
* @property int $pageSize
* @property int $serverTimezone
* @property int $timezone
@@ -186,7 +187,12 @@ public function execute()
$this->plugins = unserialize($this->plugins);
/** 动态判断皮肤目录 */
- $this->theme = is_dir($this->themeFile($this->theme)) ? $this->theme : 'default';
+ $this->missingTheme = null;
+
+ if (!is_dir($this->themeFile($this->theme))) {
+ $this->missingTheme = $this->theme;
+ $this->theme = 'default';
+ }
/** 增加对SSL连接的支持 */
if ($this->request->isSecure() && 0 === strpos($this->siteUrl, 'http://')) {
diff --git a/var/Widget/Themes/Config.php b/var/Widget/Themes/Config.php
index 678a62526f..02bda8f85c 100644
--- a/var/Widget/Themes/Config.php
+++ b/var/Widget/Themes/Config.php
@@ -47,7 +47,7 @@ public static function isExists(): bool
$options = Options::alloc();
$configFile = $options->themeFile($options->theme, 'functions.php');
- if (file_exists($configFile)) {
+ if (!$options->missingTheme && file_exists($configFile)) {
require_once $configFile;
if (function_exists('themeConfig')) {
diff --git a/var/Widget/Themes/Edit.php b/var/Widget/Themes/Edit.php
index 64177a9f85..5b1cb1a453 100644
--- a/var/Widget/Themes/Edit.php
+++ b/var/Widget/Themes/Edit.php
@@ -36,7 +36,8 @@ public function changeTheme(string $theme)
$theme = trim($theme, './');
if (is_dir($this->options->themeFile($theme))) {
/** 删除原外观设置信息 */
- $this->delete($this->db->sql()->where('name = ?', 'theme:' . $this->options->theme));
+ $oldTheme = $this->options->missingTheme ?: $this->options->theme;
+ $this->delete($this->db->sql()->where('name = ?', 'theme:' . $oldTheme));
$this->update(['value' => $theme], $this->db->sql()->where('name = ?', 'theme'));
@@ -130,7 +131,7 @@ public function config(string $theme)
$form = Config::alloc()->config();
/** 验证表单 */
- if ($form->validate()) {
+ if (!Config::isExists() || $form->validate()) {
$this->response->goBack();
}
diff --git a/var/Widget/Themes/Files.php b/var/Widget/Themes/Files.php
index 80a073aaa3..a44ba92876 100644
--- a/var/Widget/Themes/Files.php
+++ b/var/Widget/Themes/Files.php
@@ -81,6 +81,17 @@ public function execute()
throw new Widget\Exception('风格文件不存在', 404);
}
+ /**
+ * 判断是否拥有写入权限
+ *
+ * @return bool
+ */
+ public static function isWriteable(): bool
+ {
+ return (!defined('__TYPECHO_THEME_WRITEABLE__') || __TYPECHO_THEME_WRITEABLE__)
+ && !Options::alloc()->missingTheme;
+ }
+
/**
* 获取菜单标题
*
@@ -111,7 +122,7 @@ public function currentIsWriteable(): bool
{
return is_writeable(Options::alloc()
->themeFile($this->currentTheme, $this->currentFile))
- && (!defined('__TYPECHO_THEME_WRITEABLE__') || __TYPECHO_THEME_WRITEABLE__);
+ && self::isWriteable();
}
/**
From d77a1ecad7698078fa583d21b5cde7bc93413d92 Mon Sep 17 00:00:00 2001
From: joyqi
Date: Fri, 1 Apr 2022 16:55:08 +0800
Subject: [PATCH 18/47] Delete config.inc.sqlite.php
---
config.inc.sqlite.php | 27 ---------------------------
1 file changed, 27 deletions(-)
delete mode 100644 config.inc.sqlite.php
diff --git a/config.inc.sqlite.php b/config.inc.sqlite.php
deleted file mode 100644
index 23e48892bb..0000000000
--- a/config.inc.sqlite.php
+++ /dev/null
@@ -1,27 +0,0 @@
-addServer(array (
- 'file' => '/Users/joyqi/Work/typecho/usr/62396a762847a.db',
-), \Typecho\Db::READ | \Typecho\Db::WRITE);
-\Typecho\Db::set($db);
-
-define('__TYPECHO_DEBUG__', true);
From d4068b1661f9c50b0ef0bd5b27605bfefe1296e1 Mon Sep 17 00:00:00 2001
From: joyqi
Date: Sat, 2 Apr 2022 15:33:17 +0800
Subject: [PATCH 19/47] fix #1363, close #1364
Add json request & response. Perform async service via json request.
---
var/Typecho/Http/Client.php | 16 +++++++++++++
var/Typecho/Request.php | 22 +++++++++++++++++
var/Widget/Contents/Post/Edit.php | 2 +-
var/Widget/Service.php | 40 +++++++++++++++----------------
4 files changed, 59 insertions(+), 21 deletions(-)
diff --git a/var/Typecho/Http/Client.php b/var/Typecho/Http/Client.php
index d45039c966..3c876b3648 100644
--- a/var/Typecho/Http/Client.php
+++ b/var/Typecho/Http/Client.php
@@ -151,6 +151,22 @@ public function setData($data, string $method = self::METHOD_POST): Client
return $this;
}
+ /**
+ * 设置需要请求的Json数据
+ *
+ * @param $data
+ * @param string $method
+ * @return $this
+ */
+ public function setJson($data, string $method = self::METHOD_POST): Client
+ {
+ $this->setData(json_encode($data), $method)
+ ->setMultipart(true)
+ ->setHeader('Content-Type', 'application/json');
+
+ return $this;
+ }
+
/**
* 设置方法名
*
diff --git a/var/Typecho/Request.php b/var/Typecho/Request.php
index 2fddd265b9..9d641e62f8 100644
--- a/var/Typecho/Request.php
+++ b/var/Typecho/Request.php
@@ -149,6 +149,18 @@ public function get(string $key, $default = null, ?bool &$exists = true)
$exists = false;
}
break;
+ case $key === '@json':
+ $exists = false;
+ if ($this->isJson()) {
+ $body = file_get_contents('php://input');
+
+ if (false !== $body) {
+ $exists = true;
+ $value = json_decode($body, true, 16);
+ $default = $default ?? $value;
+ }
+ }
+ break;
case isset($_GET[$key]):
$value = $_GET[$key];
break;
@@ -472,6 +484,16 @@ public function isAjax(): bool
return 'XMLHttpRequest' == $this->getHeader('X-Requested-With');
}
+ /**
+ * 判断是否为Json请求
+ *
+ * @return bool
+ */
+ public function isJson(): bool
+ {
+ return !!preg_match("/^\s*application\/json(;|$)/i", $this->getHeader('Content-Type', ''));
+ }
+
/**
* 判断输入是否满足要求
*
diff --git a/var/Widget/Contents/Post/Edit.php b/var/Widget/Contents/Post/Edit.php
index 08e8c7315c..9ececbe9fc 100644
--- a/var/Widget/Contents/Post/Edit.php
+++ b/var/Widget/Contents/Post/Edit.php
@@ -288,7 +288,7 @@ public function writePost()
self::pluginHandle()->finishPublish($contents, $this);
/** 发送ping */
- $trackback = array_unique(preg_split("/(\r|\n|\r\n)/", trim($this->request->trackback)));
+ $trackback = array_filter(array_unique(preg_split("/(\r|\n|\r\n)/", trim($this->request->trackback))));
Service::alloc()->sendPing($this, $trackback);
/** 设置提示信息 */
diff --git a/var/Widget/Service.php b/var/Widget/Service.php
index d440083ea1..2a30d6bd01 100644
--- a/var/Widget/Service.php
+++ b/var/Widget/Service.php
@@ -37,10 +37,11 @@ class Service extends BaseOptions implements ActionInterface
public function sendPingHandle()
{
/** 验证权限 */
- $token = $this->request->get('token');
- $permalink = $this->request->get('permalink');
- $title = $this->request->get('title');
- $excerpt = $this->request->get('excerpt');
+ $data = $this->request->get('@json');
+ $token = $data['token'] ?? '';
+ $permalink = $data['permalink'];
+ $title = $data['title'];
+ $excerpt = $data['excerpt'];
$response = ['trackback' => [], 'pingback' => []];
@@ -57,8 +58,8 @@ public function sendPingHandle()
set_time_limit(30);
}
- if (!empty($this->request->pingback)) {
- $links = $this->request->getArray('pingback');
+ if (!empty($data['pingback'])) {
+ $links = $data['pingback'];
$permalinkPart = parse_url($permalink);
/** 发送pingback */
@@ -114,8 +115,8 @@ public function sendPingHandle()
}
/** 发送trackback */
- if (!empty($this->request->trackback)) {
- $links = $this->request->getArray('trackback');
+ if (!empty($data['trackback'])) {
+ $links = $data['trackback'];
foreach ($links as $url) {
$client = Client::get();
@@ -179,9 +180,8 @@ public function sendPing(Contents $content, ?array $trackback = null)
$client->setHeader('User-Agent', $this->options->generator)
->setTimeout(2)
- ->setData($input)
- ->setMethod(Client::METHOD_POST)
- ->send($this->getServiceUrl());
+ ->setJson($input)
+ ->send($this->getServiceUrl('ping'));
} catch (Client\Exception $e) {
return;
}
@@ -191,9 +191,10 @@ public function sendPing(Contents $content, ?array $trackback = null)
/**
* 获取真实的 URL
*
+ * @param string $do 动作名
* @return string
*/
- private function getServiceUrl(): string
+ private function getServiceUrl(string $do): string
{
$url = Common::url('/action/service', $this->options->index);
@@ -214,7 +215,7 @@ private function getServiceUrl(): string
$url = Common::buildUrl($parts);
}
- return $url;
+ return $url . '?do=' . $do;
}
/**
@@ -233,13 +234,11 @@ public function requestService($method, $params = null)
try {
$client->setHeader('User-Agent', $this->options->generator)
->setTimeout(2)
- ->setData([
- 'do' => 'async',
- 'requests' => json_encode($this->asyncRequests),
+ ->setJson([
+ 'requests' => $this->asyncRequests,
'token' => Common::timeToken($this->options->secret)
])
- ->setMethod(Client::METHOD_POST)
- ->send($this->getServiceUrl());
+ ->send($this->getServiceUrl('async'));
} catch (Client\Exception $e) {
return;
}
@@ -260,7 +259,8 @@ public function requestService($method, $params = null)
public function asyncHandle()
{
/** 验证权限 */
- $token = $this->request->token;
+ $data = $this->request->get('@json');
+ $token = $data['token'] ?? '';
if (!Common::timeTokenValidate($token, $this->options->secret, 3)) {
throw new Exception(_t('禁止访问'), 403);
@@ -275,7 +275,7 @@ public function asyncHandle()
set_time_limit(30);
}
- $requests = json_decode($this->request->requests, true);
+ $requests = $data['requests'] ?? null;
$plugin = self::pluginHandle();
if (!empty($requests)) {
From 004db7c05620e68c5c64f12278500401146b0d1f Mon Sep 17 00:00:00 2001
From: joyqi
Date: Sat, 2 Apr 2022 16:41:37 +0800
Subject: [PATCH 20/47] Move language build trigger from workflows/dev to
workflows/release.
---
.github/workflows/Typecho-dev-Ci.yml | 7 -------
.github/workflows/Typecho-release-Ci.yml | 6 ++++++
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/Typecho-dev-Ci.yml b/.github/workflows/Typecho-dev-Ci.yml
index 9469ba3ee4..d24765f416 100644
--- a/.github/workflows/Typecho-dev-Ci.yml
+++ b/.github/workflows/Typecho-dev-Ci.yml
@@ -55,10 +55,3 @@ jobs:
asset_name: typecho.zip
asset_content_type: application/zip
max_releases: 1
- - name: Trigger build
- run: |
- curl -XPOST -H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \
- -H "Accept: application/vnd.github.everest-preview+json" \
- -H "Content-Type: application/json" \
- https://api.github.com/repos/typecho/languages/actions/workflows/update.yml/dispatches --data '{"ref": "master"}'
-
diff --git a/.github/workflows/Typecho-release-Ci.yml b/.github/workflows/Typecho-release-Ci.yml
index f91cd23abe..7a2f65fb53 100644
--- a/.github/workflows/Typecho-release-Ci.yml
+++ b/.github/workflows/Typecho-release-Ci.yml
@@ -37,3 +37,9 @@ jobs:
asset_path: ./typecho.zip
asset_name: typecho.zip
asset_content_type: application/zip
+ - name: Trigger langs build
+ run: |
+ curl -XPOST -H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \
+ -H "Accept: application/vnd.github.everest-preview+json" \
+ -H "Content-Type: application/json" \
+ https://api.github.com/repos/typecho/languages/actions/workflows/update.yml/dispatches --data '{"ref": "master"}'
\ No newline at end of file
From 7ebfe82de12e15a23c2f93ab32c59e9f6de0b6d3 Mon Sep 17 00:00:00 2001
From: joyqi
Date: Sat, 2 Apr 2022 18:10:28 +0800
Subject: [PATCH 21/47] fix #1361
---
admin/common-js.php | 14 ++++++++++++++
admin/css/style.css | 2 +-
admin/src/scss/_header.scss | 2 +-
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/admin/common-js.php b/admin/common-js.php
index fad1cd04f1..02a8c7a8ca 100644
--- a/admin/common-js.php
+++ b/admin/common-js.php
@@ -91,6 +91,7 @@ function checkScroll () {
$('#typecho-nav-list ul.root').each(function () {
const ul = $(this), nav = ul.parent();
+ let focused = false;
ul.on('click touchend', '.parent a', function (e) {
nav.removeClass('noexpanded').addClass('expanded');
@@ -102,6 +103,19 @@ function checkScroll () {
nav.removeClass('expanded').addClass('noexpanded');
return false;
}));
+
+ $('a', ul).focus(function () {
+ ul.addClass('expanded');
+ focused = true;
+ }).blur(function () {
+ focused = false;
+
+ setTimeout(function () {
+ if (!focused) {
+ ul.removeClass('expanded');
+ }
+ });
+ });
});
if ($('.typecho-login').length == 0) {
diff --git a/admin/css/style.css b/admin/css/style.css
index 6f42823a96..3ac26345dc 100644
--- a/admin/css/style.css
+++ b/admin/css/style.css
@@ -170,7 +170,7 @@ select { border: 1px solid #CCC; height: 28px; }
.typecho-head-nav #typecho-nav-list > ul.focus .parent a { font-weight: bold; }
-.typecho-head-nav #typecho-nav-list > ul.root:hover .child { display: block; }
+.typecho-head-nav #typecho-nav-list > ul.root:hover .child, .typecho-head-nav #typecho-nav-list > ul.root.expanded .child { display: block; }
.typecho-head-nav .operate { float: right; }
diff --git a/admin/src/scss/_header.scss b/admin/src/scss/_header.scss
index d66ed72b56..ab59273a9f 100644
--- a/admin/src/scss/_header.scss
+++ b/admin/src/scss/_header.scss
@@ -100,7 +100,7 @@ $color-nav-child-focus: #6DA1BB;
font-weight: bold;
}
- &.root:hover .child {
+ &.root:hover .child, &.root.expanded .child {
display: block;
}
}
From c78f7fda683caa195961bb0cfde7bfec1fce4914 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Sat, 2 Apr 2022 21:27:31 +0800
Subject: [PATCH 22/47] Fix pgsql reset id error (#1369)
---
var/Widget/Backup.php | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/var/Widget/Backup.php b/var/Widget/Backup.php
index b71795378d..33dc1c2136 100644
--- a/var/Widget/Backup.php
+++ b/var/Widget/Backup.php
@@ -189,7 +189,12 @@ private function import()
if (!empty($_FILES)) {
$file = array_pop($_FILES);
- if (0 == $file['error'] && is_uploaded_file($file['tmp_name'])) {
+ if(UPLOAD_ERR_NO_FILE == $file['error']) {
+ Notice::alloc()->set(_t('没有选择任何备份文件'), 'error');
+ $this->response->goBack();
+ }
+
+ if (UPLOAD_ERR_OK == $file['error'] && is_uploaded_file($file['tmp_name'])) {
$path = $file['tmp_name'];
} else {
Notice::alloc()->set(_t('备份文件上传失败'), 'error');
@@ -270,7 +275,7 @@ private function extractData($file)
}
// 针对PGSQL重置计数
- if (false !== strpos($this->db->getVersion(), 'pgsql')) {
+ if (false !== strpos(strtolower($this->db->getAdapterName()), 'pgsql')) {
foreach ($this->lastIds as $table => $id) {
$seq = $this->db->getPrefix() . $table . '_seq';
$this->db->query('ALTER SEQUENCE ' . $seq . ' RESTART WITH ' . ($id + 1));
From 34e5bf28616f69ab5594cf7aa52773cbee94a237 Mon Sep 17 00:00:00 2001
From: joyqi
Date: Mon, 4 Apr 2022 00:01:33 +0800
Subject: [PATCH 23/47] fix #1375
---
var/Typecho/Common.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/var/Typecho/Common.php b/var/Typecho/Common.php
index 07557dca3b..b66e5481bf 100644
--- a/var/Typecho/Common.php
+++ b/var/Typecho/Common.php
@@ -482,7 +482,7 @@ function ($matches) use ($allowableAttributes) {
*/
public static function filterSearchQuery(?string $query): string
{
- return isset($query) ? str_replace('-', ' ', self::slugName($query)) : '';
+ return isset($query) ? str_replace('-', ' ', self::slugName($query) ?? '') : '';
}
/**
From 61606a90695843831fd880c4ca4e032609cccedf Mon Sep 17 00:00:00 2001
From: joyqi
Date: Tue, 5 Apr 2022 22:53:39 +0800
Subject: [PATCH 24/47] fix #1380
---
var/Typecho/Common.php | 3 ++-
var/Widget/Options.php | 2 +-
var/Widget/Options/General.php | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/var/Typecho/Common.php b/var/Typecho/Common.php
index b66e5481bf..7dcddc7331 100644
--- a/var/Typecho/Common.php
+++ b/var/Typecho/Common.php
@@ -1359,7 +1359,8 @@ public static function mimeContentType(string $fileName): string
'ice' => 'x-conference/x-cooltalk',
'vrm' => 'x-world/x-vrml',
'rar' => 'application/x-rar-compressed',
- 'cab' => 'application/vnd.ms-cab-compressed'
+ 'cab' => 'application/vnd.ms-cab-compressed',
+ 'webp' => 'image/webp'
];
$part = explode('.', $fileName);
diff --git a/var/Widget/Options.php b/var/Widget/Options.php
index f520d5f4a6..941d33126e 100644
--- a/var/Widget/Options.php
+++ b/var/Widget/Options.php
@@ -671,7 +671,7 @@ protected function ___allowedAttachmentTypes(): array
$attachmentTypes = str_replace(
['@image@', '@media@', '@doc@'],
[
- 'gif,jpg,jpeg,png,tiff,bmp', 'mp3,mp4,mov,wmv,wma,rmvb,rm,avi,flv,ogg,oga,ogv',
+ 'gif,jpg,jpeg,png,tiff,bmp,webp', 'mp3,mp4,mov,wmv,wma,rmvb,rm,avi,flv,ogg,oga,ogv',
'txt,doc,docx,xls,xlsx,ppt,pptx,zip,rar,pdf'
],
$this->attachmentTypes
diff --git a/var/Widget/Options/General.php b/var/Widget/Options/General.php
index 8fad3f2437..0b8fde9ac8 100644
--- a/var/Widget/Options/General.php
+++ b/var/Widget/Options/General.php
@@ -272,7 +272,7 @@ public function form(): Form
}
$attachmentTypesOptions = [
- '@image@' => _t('图片文件') . ' (gif jpg jpeg png tiff bmp) ',
+ '@image@' => _t('图片文件') . ' (gif jpg jpeg png tiff bmp webp) ',
'@media@' => _t('多媒体文件') . ' (mp3 mp4 mov wmv wma rmvb rm avi flv ogg oga ogv) ',
'@doc@' => _t('常用档案文件') . ' (txt doc docx xls xlsx ppt pptx zip rar pdf) ',
'@other@' => _t(
From 3b03e0267b9e5464ac5c324300914f0cac4692d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Thu, 7 Apr 2022 11:26:02 +0800
Subject: [PATCH 25/47] Update admin welcome tip (#1389)
---
admin/welcome.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/admin/welcome.php b/admin/welcome.php
index 6c26136ad5..3aed8d2460 100644
--- a/admin/welcome.php
+++ b/admin/welcome.php
@@ -16,9 +16,9 @@
pass('contributor', true)): ?>
-
+ - pass('administrator', true) ? _e('查看我的站点') : _e('查看 "%s" 网站', $options->title); ?>
-
+ - title); ?>
From 997aa607ac529f9390f572e092649403cc9a88b2 Mon Sep 17 00:00:00 2001
From: joyqi
Date: Thu, 7 Apr 2022 11:28:28 +0800
Subject: [PATCH 26/47] fix words
---
admin/welcome.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/admin/welcome.php b/admin/welcome.php
index 3aed8d2460..e971b8416e 100644
--- a/admin/welcome.php
+++ b/admin/welcome.php
@@ -16,9 +16,9 @@
pass('contributor', true)): ?>
- - pass('administrator', true) ? _e('查看我的站点') : _e('查看 "%s" 网站', $options->title); ?>
+ - pass('administrator', true) ? _e('查看我的站点') : _e('查看网站'); ?>
- - title); ?>
+
From 3512fd41bf0ae23e033d86354a35e413802c960c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Thu, 14 Apr 2022 15:49:04 +0800
Subject: [PATCH 27/47] Enhancement of Typecho\Cookie (#1399)
---
var/Typecho/Cookie.php | 36 ++++++++++++++++++++++++++++++++++--
var/Typecho/Response.php | 12 ++++++++----
var/Widget/Init.php | 5 ++++-
3 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/var/Typecho/Cookie.php b/var/Typecho/Cookie.php
index 948b7a6844..010b9dbf16 100644
--- a/var/Typecho/Cookie.php
+++ b/var/Typecho/Cookie.php
@@ -27,6 +27,24 @@ class Cookie
*/
private static $path = '/';
+ /**
+ * @var string
+ * @access private
+ */
+ private static $domain = '';
+
+ /**
+ * @var bool
+ * @access private
+ */
+ private static $secure = false;
+
+ /**
+ * @var bool
+ * @access private
+ */
+ private static $httponly = false;
+
/**
* 获取前缀
*
@@ -51,6 +69,7 @@ public static function setPrefix(string $url)
self::$prefix = md5($url);
$parsed = parse_url($url);
+ self::$domain = $parsed['host'];
/** 在路径后面强制加上斜杠 */
self::$path = empty($parsed['path']) ? '/' : Common::url(null, $parsed['path']);
}
@@ -66,6 +85,19 @@ public static function getPath(): string
return self::$path;
}
+ /**
+ * 设置额外的选项
+ *
+ * @param array $options
+ * @return void
+ */
+ public static function setOptions(array $options)
+ {
+ self::$domain = $options['domain'] ?: self::$domain;
+ self::$secure = $options['secure'] ? (bool) $options['secure'] : false;
+ self::$httponly = $options['httponly'] ? (bool) $options['httponly'] : false;
+ }
+
/**
* 获取指定的COOKIE值
*
@@ -91,7 +123,7 @@ public static function set(string $key, $value, int $expire = 0)
{
$key = self::$prefix . $key;
$_COOKIE[$key] = $value;
- Response::getInstance()->setCookie($key, $value, $expire, self::$path);
+ Response::getInstance()->setCookie($key, $value, $expire, self::$path, self::$domain, self::$secure, self::$httponly);
}
/**
@@ -106,7 +138,7 @@ public static function delete(string $key)
return;
}
- Response::getInstance()->setCookie($key, '', -1, self::$path);
+ Response::getInstance()->setCookie($key, '', -1, self::$path, self::$domain, self::$secure, self::$httponly);
unset($_COOKIE[$key]);
}
}
diff --git a/var/Typecho/Response.php b/var/Typecho/Response.php
index fa11d56547..c9255153cb 100644
--- a/var/Typecho/Response.php
+++ b/var/Typecho/Response.php
@@ -200,7 +200,7 @@ public function sendHeaders()
// set cookie
foreach ($this->cookies as $cookie) {
- [$key, $value, $timeout, $path, $domain] = $cookie;
+ [$key, $value, $timeout, $path, $domain, $secure, $httponly] = $cookie;
if ($timeout > 0) {
$now = time();
@@ -209,7 +209,7 @@ public function sendHeaders()
$timeout = 1;
}
- setrawcookie($key, rawurlencode($value), $timeout, $path, $domain ?? '');
+ setrawcookie($key, rawurlencode($value), $timeout, $path, $domain, $secure, $httponly);
}
}
@@ -275,6 +275,8 @@ public function setHeader(string $name, string $value): Response
* @param integer $timeout 过期时间,默认为0,表示随会话时间结束
* @param string $path 路径信息
* @param string|null $domain 域名信息
+ * @param bool $secure 是否仅可通过安全的 HTTPS 连接传给客户端
+ * @param bool $httponly 是否仅可通过 HTTP 协议访问
* @return $this
*/
public function setCookie(
@@ -282,10 +284,12 @@ public function setCookie(
$value,
int $timeout = 0,
string $path = '/',
- string $domain = null
+ string $domain = '',
+ bool $secure = false,
+ bool $httponly = false
): Response {
if (!$this->sandbox) {
- $this->cookies[] = [$key, $value, $timeout, $path, $domain];
+ $this->cookies[] = [$key, $value, $timeout, $path, $domain, $secure, $httponly];
}
return $this;
diff --git a/var/Widget/Init.php b/var/Widget/Init.php
index 1ee7618729..6f81b0d2c3 100644
--- a/var/Widget/Init.php
+++ b/var/Widget/Init.php
@@ -93,7 +93,10 @@ public function execute()
}
/** cookie初始化 */
- Cookie::setPrefix($options->rootUrl);
+ Cookie::setPrefix($options->rootUrl);
+ if (defined('__TYPECHO_COOKIE_OPTIONS__')) {
+ Cookie::setOptions(__TYPECHO_COOKIE_OPTIONS__);
+ }
/** 初始化路由器 */
Router::setRoutes($options->routingTable);
From 9fd02529b16304ced224842fd8b788af59f7fdb9 Mon Sep 17 00:00:00 2001
From: Valpha <35476904+Valpha@users.noreply.github.com>
Date: Fri, 15 Apr 2022 13:50:13 +0800
Subject: [PATCH 28/47] Update write-js.php (#1400)
Add 'allow-same-origin' into sandbox's attrs to fix that the article preview page does not match the real page.
---
admin/write-js.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/admin/write-js.php b/admin/write-js.php
index d2ee78b7a4..de6e707158 100644
--- a/admin/write-js.php
+++ b/admin/write-js.php
@@ -281,7 +281,7 @@ function previewData(cid) {
var frame = $('')
.attr('src', './preview.php?cid=' + cid)
- .attr('sandbox', 'allow-scripts')
+ .attr('sandbox', 'allow-same-origin allow-scripts')
.appendTo(document.body);
frame.load(function () {
From 0fbb1aaea558403e1a97012ad7cec3bc3ee021c6 Mon Sep 17 00:00:00 2001
From: jrotty
Date: Fri, 15 Apr 2022 13:51:06 +0800
Subject: [PATCH 29/47] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=BC=A9=E7=95=A5?=
=?UTF-8?q?=E5=9B=BE=E6=94=AF=E6=8C=81=E8=AF=86=E5=88=ABwebp=E5=9B=BE?=
=?UTF-8?q?=E7=89=87=E5=90=8E=E7=BC=80=20(#1403)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 模板缩略图支持识别webp图片后缀
* Update Contents.php
Co-authored-by: 沈唁 <52o@qq52o.cn>
---
var/Widget/Base/Contents.php | 2 +-
var/Widget/Themes/Rows.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/var/Widget/Base/Contents.php b/var/Widget/Base/Contents.php
index 43b40501e2..184827aacf 100644
--- a/var/Widget/Base/Contents.php
+++ b/var/Widget/Base/Contents.php
@@ -554,7 +554,7 @@ public function filter(array $value): array
//增加数据信息
$value['attachment'] = new Config($content);
- $value['attachment']->isImage = in_array($content['type'], ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp']);
+ $value['attachment']->isImage = in_array($content['type'], ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp', 'webp']);
$value['attachment']->url = Upload::attachmentHandle($value);
if ($value['attachment']->isImage) {
diff --git a/var/Widget/Themes/Rows.php b/var/Widget/Themes/Rows.php
index 5a5b1ef3e4..5fdbdf8213 100644
--- a/var/Widget/Themes/Rows.php
+++ b/var/Widget/Themes/Rows.php
@@ -45,7 +45,7 @@ public function execute()
}
$screen = array_filter(glob($theme . '/*'), function ($path) {
- return preg_match("/screenshot\.(jpg|png|gif|bmp|jpeg)$/i", $path);
+ return preg_match("/screenshot\.(jpg|png|gif|bmp|jpeg|webp)$/i", $path);
});
if ($screen) {
From f8a9d95e43cf4ae73e9c38309029cdaaf9ab30d2 Mon Sep 17 00:00:00 2001
From: jrotty
Date: Sat, 23 Apr 2022 18:00:02 +0800
Subject: [PATCH 30/47] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=B3=A8=E9=87=8A=20(#?=
=?UTF-8?q?1411)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 修正注释
* 修正注释
---
var/Widget/Stat.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/var/Widget/Stat.php b/var/Widget/Stat.php
index db2c7a0b14..2fa16cadf6 100644
--- a/var/Widget/Stat.php
+++ b/var/Widget/Stat.php
@@ -238,7 +238,7 @@ protected function ___myPublishedCommentsNum(): int
}
/**
- * 获取当前用户显示的评论数目
+ * 获取当前用户待审核的评论数目
*
* @return integer
*/
@@ -251,7 +251,7 @@ protected function ___myWaitingCommentsNum(): int
}
/**
- * 获取当前用户显示的评论数目
+ * 获取当前用户垃圾评论数目
*
* @return integer
*/
@@ -289,7 +289,7 @@ protected function ___currentPublishedCommentsNum(): int
}
/**
- * 获取当前文章显示的评论数目
+ * 获取当前文章待审核的评论数目
*
* @return integer
*/
@@ -302,7 +302,7 @@ protected function ___currentWaitingCommentsNum(): int
}
/**
- * 获取当前文章显示的评论数目
+ * 获取当前文章垃圾评论数目
*
* @return integer
*/
From f31e6daf7b3a2fdfaf670f59b188f4adda7ac68f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Tue, 26 Apr 2022 10:29:26 +0800
Subject: [PATCH 31/47] Fix notice not clear (#1416)
---
admin/common-js.php | 11 ++++++-----
var/Typecho/Cookie.php | 18 ++++++++++++++++++
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/admin/common-js.php b/admin/common-js.php
index 02a8c7a8ca..592eb4dfdc 100644
--- a/admin/common-js.php
+++ b/admin/common-js.php
@@ -13,7 +13,9 @@
noticeType : $.cookie(prefix + '__typecho_notice_type'),
highlight : $.cookie(prefix + '__typecho_notice_highlight')
},
- path = '';
+ path = '',
+ domain = '',
+ secure = ;
if (!!cookies.notice && 'success|notice|error'.indexOf(cookies.noticeType) >= 0) {
var head = $('.typecho-head-nav'),
@@ -63,14 +65,13 @@ function checkScroll () {
});
});
-
- $.cookie(prefix + '__typecho_notice', null, {path : path});
- $.cookie(prefix + '__typecho_notice_type', null, {path : path});
+ $.cookie(prefix + '__typecho_notice', null, {path : path, domain: domain, secure: secure});
+ $.cookie(prefix + '__typecho_notice_type', null, {path : path, domain: domain, secure: secure});
}
if (cookies.highlight) {
$('#' + cookies.highlight).effect('highlight', 1000);
- $.cookie(prefix + '__typecho_notice_highlight', null, {path : path});
+ $.cookie(prefix + '__typecho_notice_highlight', null, {path : path, domain: domain, secure: secure});
}
})();
diff --git a/var/Typecho/Cookie.php b/var/Typecho/Cookie.php
index 010b9dbf16..ad23a6125d 100644
--- a/var/Typecho/Cookie.php
+++ b/var/Typecho/Cookie.php
@@ -85,6 +85,24 @@ public static function getPath(): string
return self::$path;
}
+ /**
+ * @access public
+ * @return string
+ */
+ public static function getDomain(): string
+ {
+ return self::$domain;
+ }
+
+ /**
+ * @access public
+ * @return bool
+ */
+ public static function getSecure(): bool
+ {
+ return self::$secure ?: false;
+ }
+
/**
* 设置额外的选项
*
From 437d296af5de9145215789809af8878ce4a33616 Mon Sep 17 00:00:00 2001
From: jrotty
Date: Fri, 29 Apr 2022 10:53:05 +0800
Subject: [PATCH 32/47] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AE=A1=E7=90=86?=
=?UTF-8?q?=E5=91=98=E8=BF=9B=E5=85=A5=E5=85=B6=E4=BB=96=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E6=96=87=E7=AB=A0=E5=88=97=E8=A1=A8=E6=97=B6=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E6=89=80=E6=9C=89=E6=96=87=E7=AB=A0=E7=9A=84bug=20(#1415)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 修复管理员进入其他用户文章列表时显示所有文章的bug
bug描述:当管理员在文章管理页面,点击所有查看所有文章后,再通过这个页面进入作者文章管理页面时,仍会显示所有文章而不是当前作者的文章
* Update manage-users.php
* Fix missing manage-posts
Co-authored-by: sy-records <52o@qq52o.cn>
---
admin/manage-posts.php | 2 +-
admin/manage-users.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/admin/manage-posts.php b/admin/manage-posts.php
index 21326eb3ba..17bbc89a66 100644
--- a/admin/manage-posts.php
+++ b/admin/manage-posts.php
@@ -172,7 +172,7 @@ class="i-exlink">
|
author(); ?>
+ href="adminUrl('manage-posts.php?__typecho_all_posts=off&uid=' . $posts->author->uid); ?>">author(); ?>
|
categories;
$length = count($categories); ?>
diff --git a/admin/manage-users.php b/admin/manage-users.php
index c4b8186b58..2c89818f25 100644
--- a/admin/manage-users.php
+++ b/admin/manage-users.php
@@ -64,7 +64,7 @@ class="i-caret-down">
| |
postsNum(); ?>
|
From 02937dc51ce706097a6dd183dccc874f0a7defc9 Mon Sep 17 00:00:00 2001
From: MBRjun Duplicate <55020690+MBRjun@users.noreply.github.com>
Date: Wed, 4 May 2022 09:31:59 +0800
Subject: [PATCH 33/47] Fix QUIC/https Mixed Content (#1423)
---
var/Typecho/Request.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/var/Typecho/Request.php b/var/Typecho/Request.php
index 9d641e62f8..c42c10a582 100644
--- a/var/Typecho/Request.php
+++ b/var/Typecho/Request.php
@@ -430,6 +430,7 @@ public function getReferer(): ?string
public function isSecure(): bool
{
return (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && !strcasecmp('https', $_SERVER['HTTP_X_FORWARDED_PROTO']))
+ || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && !strcasecmp('quic', $_SERVER['HTTP_X_FORWARDED_PROTO']))
|| (!empty($_SERVER['HTTP_X_FORWARDED_PORT']) && 443 == $_SERVER['HTTP_X_FORWARDED_PORT'])
|| (!empty($_SERVER['HTTPS']) && 'off' != strtolower($_SERVER['HTTPS']))
|| (!empty($_SERVER['SERVER_PORT']) && 443 == $_SERVER['SERVER_PORT'])
From ac33000ad00bab326d6cd6e99dafdff6b19118d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn>
Date: Sat, 7 May 2022 16:33:00 +0800
Subject: [PATCH 34/47] Add admin/footer.php begin plugin (#1426)
---
admin/footer.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/admin/footer.php b/admin/footer.php
index 5909bc0a58..92bc366b65 100644
--- a/admin/footer.php
+++ b/admin/footer.php
@@ -1,4 +1,5 @@
+begin(); ?>
|