Skip to content

Commit

Permalink
Merge pull request #176 from mashirozx/dev
Browse files Browse the repository at this point in the history
update to v3.3.5
  • Loading branch information
mashirozx authored Dec 26, 2019
2 parents 5608a0d + 8b77fbd commit 9ddaad7
Show file tree
Hide file tree
Showing 21 changed files with 115 additions and 165 deletions.
2 changes: 1 addition & 1 deletion README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Sakura🌸: A Wonderful WordPress Theme
![PHP version](https://img.shields.io/badge/PHP-7.1+-4F5B93.svg?style=flat-square)
![WP version](https://img.shields.io/badge/WordPress-5.0+-0073aa.svg?style=flat-square)
[![GitHub release](https://img.shields.io/github/release/mashirozx/Sakura.svg?style=flat-square)](https://github.com/mashirozx/Sakura/releases/latest)
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/mashirozx/Sakura/latest.svg?style=flat-square)](https://github.com/mashirozx/Sakura/commits/)
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/mashirozx/Sakura/latest/dev.svg?style=flat-square)](https://github.com/mashirozx/Sakura/commits/dev)
[![](https://data.jsdelivr.com/v1/package/gh/moezx/cdn/badge)](https://www.jsdelivr.com/package/gh/moezx/cdn)

Modified based on theme [Akina (by Fuzzz)](http://www.akina.pw/themeakina) and [Siren (by Louie)](https://github.com/louie-senpai/Siren).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
![PHP version](https://shader.2heng.xin/badge/PHP-7.1+-4F5B93.svg?style=flat-square&logo=php)
![WP version](https://shader.2heng.xin/badge/WordPress-5.3-0073aa.svg?style=flat-square&logo=wordpress)
[![GitHub release](https://img.shields.io/github/v/release/mashirozx/Sakura.svg?style=flat-square&logo=github)](https://github.com/mashirozx/Sakura/releases/latest)
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/mashirozx/Sakura/latest.svg?style=flat-square&logo=git&color=important)](https://github.com/mashirozx/Sakura/commits/)
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/mashirozx/Sakura/latest/dev.svg?style=flat-square&logo=git&color=important)](https://github.com/mashirozx/Sakura/commits/dev)
[![](https://data.jsdelivr.com/v1/package/gh/moezx/cdn/badge)](https://www.jsdelivr.com/package/gh/moezx/cdn)

在 Louie 基于 Fuzzz 的 [Akina](http://www.akina.pw/themeakina) 主题修改的主题 [Siren](https://github.com/louie-senpai/Siren) 基础上三次修改 =.=
Expand Down
2 changes: 1 addition & 1 deletion cdn/css/lib.css
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions cdn/js/lib.js
100644 → 100755

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions cdn/js/src/10.materialize.min.js

This file was deleted.

2 changes: 0 additions & 2 deletions cdn/js/src/16.hls.js

This file was deleted.

4 changes: 2 additions & 2 deletions comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
'title_reply_to' => '<div class="graybar"><i class="fa fa-comments-o"></i>' . __('Leave a Reply to', 'sakura') . ' %s' . '</div>',
'cancel_reply_link' => __('Cancel Reply', 'sakura'),
'label_submit' => __('BiuBiuBiu~', 'sakura'),
'comment_field' => '<p><i class="iconfont icon-markdown"></i> Markdown Supported while <i class="fa fa-code" aria-hidden="true"></i> Forbidden</p><div class="comment-textarea"><textarea placeholder="' . __("You are a surprise that I will only meet once in my life", "sakura") . ' ..." name="comment" class="commentbody" id="comment" rows="5" tabindex="4"></textarea><label class="input-label">' . __("You are a surprise that I will only meet once in my life", "sakura") . ' ...</label></div>
'comment_field' => '<p style="font-style:italic"><a href="https://segmentfault.com/markdown" target="_blank"><i class="iconfont icon-markdown" style="color:#000"></i></a> Markdown Supported while <i class="fa fa-code" aria-hidden="true"></i> Forbidden</p><div class="comment-textarea"><textarea placeholder="' . __("You are a surprise that I will only meet once in my life", "sakura") . ' ..." name="comment" class="commentbody" id="comment" rows="5" tabindex="4"></textarea><label class="input-label">' . __("You are a surprise that I will only meet once in my life", "sakura") . ' ...</label></div>
<div id="upload-img-show"></div>
<!--插入表情面版-->
<p id="emotion-toggle" class="no-select">
Expand Down Expand Up @@ -92,7 +92,7 @@ class="tieba-bar">Tieba</th>
'author' =>
'<div class="popup cmt-popup cmt-author" onclick="cmt_showPopup(this)"><span class="popuptext" id="thePopup" style="margin-left: -115px;width: 230px;">' . __("Auto pull nickname and avatar with a QQ num. entered", "sakura")/*输入QQ号将自动拉取昵称和头像*/ . '</span><input type="text" placeholder="' . __("Nickname or QQ number", "sakura") /*昵称或QQ号*/. ' ' . ( $req ? '(' . __("Name* ", "sakura") . ')' : '') . '" name="author" id="author" value="' . esc_attr($comment_author) . '" size="22" autocomplete="off" tabindex="1" ' . ($req ? "aria-required='true'" : '' ). ' /></div>',
'email' =>
'<div class="popup cmt-popup" onclick="cmt_showPopup(this)"><span class="popuptext" id="thePopup" style="margin-left: -65px;width: 130px;">' . __("You\' receive notification by email", "sakura")/*你将收到回复通知*/ . '</span><input type="text" placeholder="' . __("email", "sakura") . ' ' . ( $req ? '(' . __("Must* ", "sakura") . ')' : '') . '" name="email" id="email" value="' . esc_attr($comment_author_email) . '" size="22" tabindex="1" autocomplete="off" ' . ($req ? "aria-required='true'" : '' ). ' /></div>',
'<div class="popup cmt-popup" onclick="cmt_showPopup(this)"><span class="popuptext" id="thePopup" style="margin-left: -65px;width: 130px;">' . __("You will receive notification by email", "sakura")/*你将收到回复通知*/ . '</span><input type="text" placeholder="' . __("email", "sakura") . ' ' . ( $req ? '(' . __("Must* ", "sakura") . ')' : '') . '" name="email" id="email" value="' . esc_attr($comment_author_email) . '" size="22" tabindex="1" autocomplete="off" ' . ($req ? "aria-required='true'" : '' ). ' /></div>',
'url' =>
'<div class="popup cmt-popup" onclick="cmt_showPopup(this)"><span class="popuptext" id="thePopup" style="margin-left: -55px;width: 110px;">' . __("Advertisement is forbidden 😀", "sakura")/*禁止小广告😀*/ . '</span><input type="text" placeholder="' . __("Site", "sakura") . '" name="url" id="url" value="' . esc_attr($comment_author_url) . '" size="22" autocomplete="off" tabindex="1" /></div></div>' . $robot_comments . $private_ms . $mail_notify ,
'qq' =>
Expand Down
1 change: 0 additions & 1 deletion footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class="aplayer"
data-fixed="true"
data-theme="orange">
</div>
<style>.skin-menu{left:auto;right:10px;}.changeSkin-gear{left:auto;right:5px;}</style>
<?php endif; ?>
</body>
</html>
9 changes: 5 additions & 4 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @package Sakura
*/

define( 'SAKURA_VERSION', '3.3.3' );
define( 'SAKURA_VERSION', '3.3.5' );
define( 'BUILD_VERSION', '3' );

//ini_set('display_errors', true);
Expand Down Expand Up @@ -470,7 +470,7 @@ function set_post_views() {
global $post;
$post_id = intval($post->ID);
if($post_id) {
$views = get_post_meta($post_id, 'views', true);
$views = (int)get_post_meta($post_id, 'views', true);
if(!update_post_meta($post_id, 'views', ($views + 1))) {
add_post_meta($post_id, 'views', 1, true);
}
Expand Down Expand Up @@ -1627,7 +1627,8 @@ function change_avatar($avatar){
preg_match('/:\"([^\"]*)\"/i',$qqavatar,$matches);
return '<img src="'.$matches[1].'" data-src="'.stripslashes($m[1]).'" class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">';
}else{
$encrypted = openssl_encrypt($qq_number, 'aes-128-cbc', $sakura_privkey, 0);
$iv = str_repeat($sakura_privkey, 2);
$encrypted = openssl_encrypt($qq_number, 'aes-128-cbc', $sakura_privkey, 0, $iv);
$encrypted = urlencode(base64_encode($encrypted));
return '<img src="'.rest_url("sakura/v1/qqinfo/avatar").'?qq='.$encrypted.'"class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">';
}
Expand Down Expand Up @@ -1687,7 +1688,7 @@ function markdown_parser($incoming_comment) {
$comment_markdown_content = $incoming_comment['comment_content'];
include 'inc/Parsedown.php';
$Parsedown = new Parsedown();
$incoming_comment['comment_content'] = $Parsedown->text($incoming_comment['comment_content']);
$incoming_comment['comment_content'] = $Parsedown->setUrlsLinked(false)->text($incoming_comment['comment_content']);
return $incoming_comment;
}
add_filter('preprocess_comment' , 'markdown_parser');
Expand Down
73 changes: 28 additions & 45 deletions inc/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'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(
Expand Down Expand Up @@ -275,7 +275,7 @@ function cache_search_json()

$posts = new WP_Query('posts_per_page=-1&post_status=publish&post_type=post');
while ($posts->have_posts()): $posts->the_post();
$output .= '{"type":"post","link":"' . get_post_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', get_the_content()))) . '},';
$output .= '{"type":"post","link":"' . get_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', get_the_content()))) . '},';
endwhile;
wp_reset_postdata();

Expand Down Expand Up @@ -351,9 +351,9 @@ function feature_gallery() {
$img = array_rand($img_array);
$img_domain = akina_option('cover_cdn') ? akina_option('cover_cdn') : get_template_directory_uri();
if(strpos($_SERVER['HTTP_ACCEPT'], 'image/webp')) {
$imgurl = $img_domain . "/manifest/" . $img_array[$img]["webp"][1];
$imgurl = $img_domain . "/manifest/" . $img_array[$img]["webp"][0];
} else {
$imgurl = $img_domain . "/manifest/" . $img_array[$img]["jpeg"][1];
$imgurl = $img_domain . "/manifest/" . $img_array[$img]["jpeg"][0];
}
$data = array('cover image');
$response = new WP_REST_Response($data);
Expand All @@ -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(
"mate_key" => "manifest_json",
"mate_value" => $manifest
);
$result = new WP_REST_Response($output, 401);
$result->set_headers(array('Content-Type' => 'application/json'));
return $result;
$time = array(
"mate_key" => "json_time",
"mate_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;
}

/**
Expand All @@ -419,8 +401,9 @@ function get_qq_avatar(){
global $sakura_privkey;
$encrypted=$_GET["qq"];
if(isset($encrypted)){
$iv = str_repeat($sakura_privkey, 2);
$encrypted = urldecode(base64_decode($encrypted));
$qq_number = openssl_decrypt($encrypted, 'aes-128-cbc', $sakura_privkey, 0);
$qq_number = openssl_decrypt($encrypted, 'aes-128-cbc', $sakura_privkey, 0, $iv);
preg_match('/^\d{3,}$/', $qq_number, $matches);
$imgurl='https://q2.qlogo.cn/headimg_dl?dst_uin='.$matches[0].'&spec=100';
if(akina_option('qq_avatar_link')=='type_2'){
Expand Down
32 changes: 17 additions & 15 deletions js/sakura-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,21 +525,23 @@ function killCoverVideo() {

function coverVideoIni() {
if ($('video').hasClass('hls')) {
var video = addComment.I('coverVideo');
var video_src = $('#coverVideo').attr('data-src');
if (Hls.isSupported()) {
var hls = new Hls();
hls.loadSource(video_src);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function () {
video.play();
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = video_src;
video.addEventListener('loadedmetadata', function () {
video.play();
});
}
$.getScript("https://cdn.jsdelivr.net/gh/mashirozx/[email protected]/cdn/js/src/16.hls.js", function(){
var video = addComment.I('coverVideo');
var video_src = $('#coverVideo').attr('data-src');
if (Hls.isSupported()) {
var hls = new Hls();
hls.loadSource(video_src);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function () {
video.play();
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = video_src;
video.addEventListener('loadedmetadata', function () {
video.play();
});
}
});
//console.info('ini:coverVideoIni()');
}
}
Expand Down
Binary file modified languages/en_US.mo
Binary file not shown.
19 changes: 10 additions & 9 deletions languages/en_US.po
Original file line number Diff line number Diff line change
@@ -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-25 10:43+0800\n"
"PO-Revision-Date: 2019-12-25 10:43+0800\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: en_US\n"
Expand Down Expand Up @@ -107,7 +107,7 @@ msgid "Name* "
msgstr ""

#: comments.php:95
msgid "You\\' receive notification by email"
msgid "You will receive notification by email"
msgstr ""

#: comments.php:95
Expand Down Expand Up @@ -205,7 +205,7 @@ msgstr ""
msgid "QQ"
msgstr ""

#: functions.php:1664
#: functions.php:1665
msgid "Sidebar"
msgstr ""

Expand Down Expand Up @@ -1303,15 +1303,16 @@ msgid ""
msgstr ""

#: options.php:879
msgid "Cover CDN"
msgid "Cover manifest"
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/[email protected], "
"Fill in the manifest path for random picture display, without adding a slash "
"at the end, for example: https://cdn.jsdelivr.net/gh/mashirozx/[email protected], "
"please refer to <a href = \"https: //github.com/mashirozx/Sakura/wiki/options"
"\">Wiki </a>"
"\">Wiki </a>. Click <a href = \"%s\">here</a> to update manifest"
msgstr ""

#: options.php:886
Expand Down Expand Up @@ -1409,7 +1410,7 @@ msgid ""
msgstr ""

#: options.php:973
msgid "The categories of articles that don\\t not show on homepage"
msgid "The categories of articles that don't not show on homepage"
msgstr ""

#: options.php:974 options.php:981
Expand Down
16 changes: 9 additions & 7 deletions languages/sakura.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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-25 10:43+0800\n"
"PO-Revision-Date: 2019-11-01 14:27+0800\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down Expand Up @@ -107,7 +107,7 @@ msgid "Name* "
msgstr ""

#: comments.php:95
msgid "You\\' receive notification by email"
msgid "You will receive notification by email"
msgstr ""

#: comments.php:95
Expand Down Expand Up @@ -204,7 +204,7 @@ msgstr ""
msgid "QQ"
msgstr ""

#: functions.php:1664
#: functions.php:1665
msgid "Sidebar"
msgstr ""

Expand Down Expand Up @@ -1287,14 +1287,16 @@ msgid ""
msgstr ""

#: options.php:879
msgid "Cover CDN"
msgid "Cover manifest"
msgstr ""

#: options.php:880
#, php-format
msgid ""
"Fill in the cdn path for random picture display, without adding a slash at the end, for "
"Fill in the manifest path for random picture display, without adding a slash at the end, for "
"example: https://cdn.jsdelivr.net/gh/mashirozx/[email protected], please refer to <a href = "
"\"https: //github.com/mashirozx/Sakura/wiki/options\">Wiki </a>"
"\"https: //github.com/mashirozx/Sakura/wiki/options\">Wiki </a>. Click <a href = \"%s\">here</"
"a> to update manifest"
msgstr ""

#: options.php:886
Expand Down Expand Up @@ -1387,7 +1389,7 @@ msgid ""
msgstr ""

#: options.php:973
msgid "The categories of articles that don\\t not show on homepage"
msgid "The categories of articles that don't not show on homepage"
msgstr ""

#: options.php:974 options.php:981
Expand Down
Binary file modified languages/zh_CN.mo
Binary file not shown.
Loading

0 comments on commit 9ddaad7

Please sign in to comment.