From 6bd243b6f91b2223617a3bc5f2f578336ca37c70 Mon Sep 17 00:00:00 2001
From: BigCoke233
Date: Sat, 11 Apr 2020 17:12:09 +0800
Subject: =?UTF-8?q?:apple:=20Fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?=
=?UTF-8?q?=E5=A4=87=E4=BB=BD=EF=BC=8C=E4=BC=98=E5=8C=96=E5=90=8E=E5=8F=B0?=
=?UTF-8?q?=E6=A0=B7=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
libs/Options.php | 125 +++++++++++++++++++++++++++++++++----------------------
1 file changed, 76 insertions(+), 49 deletions(-)
(limited to 'libs/Options.php')
diff --git a/libs/Options.php b/libs/Options.php
index b74fb86..13ec8ea 100755
--- a/libs/Options.php
+++ b/libs/Options.php
@@ -8,51 +8,41 @@ function themeConfig($form) {
* 主题设置备份
* From https://qqdie.com/archives/typecho-templates-backup-and-restore.html
*/
+ $str1 = explode('/themes/', Helper::options()->themeUrl);
+ $str2 = explode('/', $str1[1]);
+ $name=$str2[0];
$db = Typecho_Db::get();
- $sjdq=$db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:Miracles'));
- $ysj = $sjdq['value'];
- if(isset($_POST['type'])){
- if($_POST["type"]=="备份设置"){
- if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:MiraclesBackup'))){
- $update = $db->update('table.options')->rows(array('value'=>$ysj))->where('name = ?', 'theme:MiraclesBackup');
- $updateRows= $db->query($update);
- echo ' 备份已更新,即将自动刷新。如过您的浏览器没有自动跳转请点击';?>这里
-insert('table.options')
- ->rows(array('name' => 'theme:MiraclesBackup','user' => '0','value' => $ysj));
- $insertId = $db->query($insert);
- echo '备份完成,即将自动刷新。如过您的浏览器没有自动跳转请点击';
-?>这里
-fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:'.$name));
+ $ysj = $sjdq['value'];
+ if(isset($_POST['type'])){
+ if($_POST["type"]=="备份模板设置数据"){
+ if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:'.$name.'bf'))){
+ $update = $db->update('table.options')->rows(array('value'=>$ysj))->where('name = ?', 'theme:'.$name.'bf');
+ $updateRows= $db->query($update);
+ }else{
+ if($ysj){
+ $insert = $db->insert('table.options')
+ ->rows(array('name' => 'theme:'.$name.'bf','user' => '0','value' => $ysj));
+ $insertId = $db->query($insert);
+ }
+ }
}
- }
- if($_POST["type"]=="还原设置"){
- if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:MiraclesBackup'))){
- $sjdub=$db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:MiraclesBackup'));
- $bsj = $sjdub['value'];
- $update = $db->update('table.options')->rows(array('value'=>$bsj))->where('name = ?', 'theme:Miracles');
- $updateRows= $db->query($update);
- echo '检测到模板备份数据,恢复完成,即将自动刷新。如过您的浏览器没有自动跳转请点击';
-?>这里
-没有模板备份数据,恢复不了哦!';
+ if($_POST["type"]=="还原模板设置数据"){
+ if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:'.$name.'bf'))){
+ $sjdub=$db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:'.$name.'bf'));
+ $bsj = $sjdub['value'];
+ $update = $db->update('table.options')->rows(array('value'=>$bsj))->where('name = ?', 'theme:'.$name);
+ $updateRows= $db->query($update);
+ }
}
+ if($_POST["type"]=="删除备份数据"){
+ if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:'.$name.'bf'))){
+ $delete = $db->delete('table.options')->where ('name = ?', 'theme:'.$name.'bf');
+ $deletedRows = $db->query($delete);
+ }
}
- if($_POST["type"]=="删除设置备份"){
- if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:MiraclesBackup'))){
- $delete = $db->delete('table.options')->where ('name = ?', 'theme:MiraclesBackup');
- $deletedRows = $db->query($delete);
- echo '删除成功,请等待自动刷新,如果等不到请点击';
-?>这里
-备份不存在!';
- }
- }
-}
+ }
+
/**
* 设置样式+面板
@@ -66,14 +56,51 @@ function themeConfig($form) {
欢迎使用 Miracles 主题,目前版本是:'. $ver .'
作者博客:Eltrac\'s |
帮助文档:WIKI |
- 问题反馈:issues
-