From a99102fdacedcde7f9903b4b53036f97f3897008 Mon Sep 17 00:00:00 2001 From: spirit Date: Sun, 15 Dec 2019 16:57:53 +0800 Subject: [PATCH] fetch manifest.json at backend --- inc/api.php | 64 ++++++++++++++++--------------------------- languages/en_US.mo | Bin 1500 -> 1500 bytes languages/en_US.po | 7 +++-- languages/sakura.pot | 6 ++-- languages/zh_CN.mo | Bin 33481 -> 33008 bytes languages/zh_CN.po | 16 ++++++++--- manifest/README.md | 2 -- manifest/manifest.py | 30 -------------------- options.php | 2 +- 9 files changed, 44 insertions(+), 83 deletions(-) diff --git a/inc/api.php b/inc/api.php index 5e2dfe0..1f2fcbd 100644 --- a/inc/api.php +++ b/inc/api.php @@ -21,7 +21,7 @@ add_action('rest_api_init', function () { 'callback' => 'feature_gallery', )); register_rest_route('sakura/v1', '/database/update', array( - 'methods' => 'POST', + 'methods' => 'GET', 'callback' => 'update_database', )); register_rest_route('sakura/v1', '/qqinfo/json', array( @@ -367,48 +367,30 @@ function feature_gallery() { * @rest api接口路径:https://sakura.2heng.xin/wp-json/sakura/v1/database/update */ function update_database() { - $username = $_SERVER['PHP_AUTH_USER']; - $password = $_SERVER['PHP_AUTH_PW']; - $user = wp_authenticate($username, $password); - if (is_a($user, 'WP_User')) { - if (in_array('administrator', (array) $user->roles)) { - global $wpdb; - $sakura_table_name = $wpdb->base_prefix.'sakura'; - if(isset($_FILES["manifest"])) { - $manifest = array( - "key" => "manifest_json", - "value" => file_get_contents($_FILES["manifest"]["tmp_name"]) - ); - $time = array( - "key" => "json_time", - "value" => date("Y-m-d H:i:s",time()) - ); - - $wpdb->query("DELETE FROM `wp_sakura` WHERE `mate_key` ='manifest_json'"); - $wpdb->query("DELETE FROM `wp_sakura` WHERE `mate_key` ='json_time'"); - $wpdb->insert($sakura_table_name,$manifest); - $wpdb->insert($sakura_table_name,$time); - $message = "manifest.json has been stored into database."; - } - $output = array( - 'status' => 200, - 'success' => true, - 'message' => $message - ); - $result = new WP_REST_Response($output, 200); - $result->set_headers(array('Content-Type' => 'application/json')); - return $result; - } - } else { - $output = array( - 'status' => 401, - 'success' => false, - 'message' => 'Not Authorized.' + global $wpdb; + $sakura_table_name = $wpdb->base_prefix.'sakura'; + $img_domain = akina_option('cover_cdn') ? akina_option('cover_cdn') : get_template_directory_uri(); + $manifest = file_get_contents($img_domain . "/manifest/manifest.json"); + if($manifest) { + $manifest = array( + "key" => "manifest_json", + "value" => $manifest ); - $result = new WP_REST_Response($output, 401); - $result->set_headers(array('Content-Type' => 'application/json')); - return $result; + $time = array( + "key" => "json_time", + "value" => date("Y-m-d H:i:s",time()) + ); + + $wpdb->query("DELETE FROM `wp_sakura` WHERE `mate_key` ='manifest_json'"); + $wpdb->query("DELETE FROM `wp_sakura` WHERE `mate_key` ='json_time'"); + $wpdb->insert($sakura_table_name,$manifest); + $wpdb->insert($sakura_table_name,$time); + $output = "manifest.json has been stored into database."; + }else{ + $output = "manifest.json not found, please ensure your url is corrent."; } + $result = new WP_REST_Response($output, 200); + return $result; } /** diff --git a/languages/en_US.mo b/languages/en_US.mo index b6bb5a717ff11121e384fff01d33133ef0a95b77..b9992f75c4ffe01ab0243ba0c57302ad91f5ef5a 100644 GIT binary patch delta 20 bcmcb^eTRF)7AAI61w#`n6NAmWnG~4;O7{jR delta 20 bcmcb^eTRF)7AAIM1w#`nQ^U=>nG~4;O6&$G diff --git a/languages/en_US.po b/languages/en_US.po index 090a9c3..532c211 100644 --- a/languages/en_US.po +++ b/languages/en_US.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Sakura\n" -"POT-Creation-Date: 2019-12-13 14:51+0800\n" -"PO-Revision-Date: 2019-12-13 14:51+0800\n" +"POT-Creation-Date: 2019-12-15 14:40+0800\n" +"PO-Revision-Date: 2019-12-15 14:40+0800\n" "Last-Translator: \n" "Language-Team: \n" "Language: en_US\n" @@ -1307,11 +1307,12 @@ msgid "Cover CDN" msgstr "" #: options.php:880 +#, php-format msgid "" "Fill in the cdn path for random picture display, without adding a slash at " "the end, for example: https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3, " "please refer to Wiki " +"\">Wiki . Click here to update manifest" msgstr "" #: options.php:886 diff --git a/languages/sakura.pot b/languages/sakura.pot index 7787ef0..b9320ef 100644 --- a/languages/sakura.pot +++ b/languages/sakura.pot @@ -3,7 +3,7 @@ msgid "" msgstr "" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" "Project-Id-Version: Sakura\n" -"POT-Creation-Date: 2019-12-13 14:50+0800\n" +"POT-Creation-Date: 2019-12-15 14:40+0800\n" "PO-Revision-Date: 2019-11-01 14:27+0800\n" "Last-Translator: \n" "Language-Team: \n" @@ -1291,10 +1291,12 @@ msgid "Cover CDN" msgstr "" #: options.php:880 +#, php-format msgid "" "Fill in the cdn path for random picture display, without adding a slash at the end, for " "example: https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3, please refer to Wiki " +"\"https: //github.com/mashirozx/Sakura/wiki/options\">Wiki . Click here to update manifest" msgstr "" #: options.php:886 diff --git a/languages/zh_CN.mo b/languages/zh_CN.mo index b42f935f5d38b590b4b499860f453f3876c2b075..f4480f5e0c3bc0be5807e18f7e50a7c59f75edb5 100644 GIT binary patch delta 7800 zcmYk>37n7B9>?)Bn9Yna3}#;~V;>BIL3XlaYwWwRGn2v?ioYd_n_HT4nQo+rLiR$I zq?E0cNXW%pl(eX%q`IH)JU_47^SVFp^E=OZo^zga&hz}I*F8MH#1C^y_%4($^}OSl z?B`q@ZVz$pC(2zTRqI?-qH{qQjlq~=*2dE085oMKQSG`}-WP|GkHm`j9#+D$mfyq( z=X@?O$+;PH7>iwLur%4Z7%W16{1Yc(sT4ZLsr4VyA@0VB_&p}!psL;gXQDcK z3DtflhT{jQ89Rf4ScDPu@4lg+5&ngmqQq+6lxCows4Z#=dtx~pgPQ8;SP$o7S=@%2 zp@XRVUBylqkm_7t?18MVTZjI*9ewIxw^e+If#e^dIy{Y( z27|CC#^M0flH?()=Vqg>dl_}z4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^{ru5d(_%G_IGKPAQp|yNOFg z4tWGogR+jhh{@!SXiGkr7)ku-Rk;b2-=aK;7)x14KGwr##jTpe2h+&9SJZny zeh;bCCD_@E$VXebl=3O>w2GgHt^5!C$;x@?=lqu}k3s$a->>mcL@ec6);8Pw4Z!B7 z@(Pvnh-t)jLPs6y|BcluGX5ZGPNaS{;AvN{NJ&}_;l0t`^vVgEB(`^3-fnh+`YeS<${az78cJL+rG~K8bQSX&iEU~ F{})zpGLirQ diff --git a/languages/zh_CN.po b/languages/zh_CN.po index 162f250..9fd26c6 100644 --- a/languages/zh_CN.po +++ b/languages/zh_CN.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Sakura\n" -"POT-Creation-Date: 2019-12-13 14:51+0800\n" -"PO-Revision-Date: 2019-12-13 14:51+0800\n" +"POT-Creation-Date: 2019-12-15 14:41+0800\n" +"PO-Revision-Date: 2019-12-15 14:41+0800\n" "Last-Translator: \n" "Language-Team: \n" "Language: zh_CN\n" @@ -1328,15 +1328,23 @@ msgid "Cover CDN" msgstr "封面图图片库" #: options.php:880 +#, fuzzy, php-format +#| msgid "" +#| "Fill in the cdn path for random picture display, without adding a slash " +#| "at the end, for example: https://cdn.jsdelivr.net/gh/mashirozx/" +#| "sakura@3.3.3, please refer to Wiki . Click here to update " +#| "manifest" msgid "" "Fill in the cdn path for random picture display, without adding a slash at " "the end, for example: https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3, " "please refer to Wiki " +"\">Wiki . Click here to update manifest" msgstr "" "填写 cdn 路径,用于随机图片展示,最后不用加斜杠,例:https://cdn.jsdelivr." "net/gh/mashirozx/sakura@3.3.3 ,更多信息请参考Wiki" +"mashirozx/Sakura/wiki/options\">Wiki。点击这里更新" +"manifest" #: options.php:886 msgid "Use the front-end library locally (lib.js、lib.css)" diff --git a/manifest/README.md b/manifest/README.md index 10c0fab..c34eb2b 100644 --- a/manifest/README.md +++ b/manifest/README.md @@ -24,8 +24,6 @@ pip3 install Pillow pip install Pillow --user ``` -用同样的方法安装`requests` - ### 运行 把图片文件放到 `gallary` 目录,Windows 可直接双击 manifest.py,或者和其他操作系统一样,在 Terminal、Powershell、CMD 中运行: diff --git a/manifest/manifest.py b/manifest/manifest.py index 9828390..0e7421c 100644 --- a/manifest/manifest.py +++ b/manifest/manifest.py @@ -7,8 +7,6 @@ Desc: Webp convertor import os import sys import json -import requests -import base64 import hashlib from PIL import Image @@ -50,29 +48,6 @@ class Single(object): self.manifest() return self.mani - -class Upload2Wordpress(object): - def __init__(self, username, password, url): - self.username = username - self.password = password - self.url = url - - def upload(self, file, field): - data_string = self.username + ':' + self.password - token = base64.b64encode(data_string.encode()).decode('utf-8') - headers = { - 'Authorization': 'Basic ' + token, - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97" - } - files = {field: open(file, mode="rb")} - reply = requests.post(self.url, headers=headers, files=files) - print(json.loads(reply.content)['message']) - - def main(self): - print('start uploading `manifest.json`...') - self.upload('manifest.json', 'manifest') - - def gen_manifest_json(): onlyfiles = [f for f in os.listdir('gallary') if os.path.isfile(os.path.join('gallary', f))] id = 1 @@ -88,11 +63,6 @@ def gen_manifest_json(): def main(): gen_manifest_json() - username = input('Enter your username: ') - password = input('Enter your password: ') - url = input('Enter your rest api url: ') - upload = Upload2Wordpress(username, password, url) - upload.main() if __name__ == '__main__': diff --git a/options.php b/options.php index 6df04e3..4d61858 100644 --- a/options.php +++ b/options.php @@ -877,7 +877,7 @@ function optionsframework_options() { $options[] = array( 'name' => __('Cover CDN', 'sakura'),/*封面图片库*/ - 'desc' => __('Fill in the cdn path for random picture display, without adding a slash at the end, for example: https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3, please refer to Wiki ', 'sakura'),/*填写 cdn 路径,用于随机图片展示,最后不用加斜杠,例:https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3 ,更多信息请参考Wiki*/ + 'desc' => sprintf(__('Fill in the cdn path for random picture display, without adding a slash at the end, for example: https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3, please refer to Wiki . Click here to update manifest', 'sakura'), rest_url('sakura/v1/database/update')),/*填写 cdn 路径,用于随机图片展示,最后不用加斜杠,例:https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3 ,更多信息请参考Wiki*/ 'id' => 'cover_cdn', 'std' => 'https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3', 'type' => 'text');