mirror of
				https://github.com/mashirozx/sakura.git
				synced 2025-05-29 01:49:21 +08:00 
			
		
		
		
	
						commit
						b20c49314c
					
				| @ -7,7 +7,7 @@ | ||||
|  * @package Sakura | ||||
|  */ | ||||
|   | ||||
| define( 'SAKURA_VERSION', '3.3.2' ); | ||||
| define( 'SAKURA_VERSION', '3.3.3' ); | ||||
| define( 'BUILD_VERSION', '3' ); | ||||
| 
 | ||||
| //ini_set('display_errors', true);
 | ||||
| @ -1616,11 +1616,21 @@ function output_comments_qq_columns( $column_name, $comment_id ){ | ||||
|  */ | ||||
| add_filter( 'get_avatar', 'change_avatar', 10, 3 ); | ||||
| function change_avatar($avatar){ | ||||
|     global $comment; | ||||
|     global $comment,$sakura_privkey; | ||||
|     if ($comment) { | ||||
|         if( get_comment_meta( $comment->comment_ID, 'new_field_qq', true )){ | ||||
|             $qq_number =  get_comment_meta( $comment->comment_ID, 'new_field_qq', true ); | ||||
|             return '<img src="https://q2.qlogo.cn/headimg_dl?dst_uin='.$qq_number.'&spec=100" data-src="'.stripslashes($m[1]).'" class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">'; | ||||
|             if(akina_option('qq_avatar_link')=='off'){ | ||||
|                 return '<img src="https://q2.qlogo.cn/headimg_dl?dst_uin='.$qq_number.'&spec=100" data-src="'.stripslashes($m[1]).'" class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">'; | ||||
|             }elseif(akina_option('qq_avatar_link')=='type_3'){ | ||||
|                 $qqavatar = file_get_contents('http://ptlogin2.qq.com/getface?appid=1006102&imgtype=3&uin='.$qq_number); | ||||
|                 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); | ||||
|                 $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)">'; | ||||
|             } | ||||
|         }else{ | ||||
|             return $avatar ; | ||||
|         } | ||||
| @ -1719,7 +1729,7 @@ add_action('pre_comment_on_post', 'allow_more_tag_in_comment'); | ||||
|  * 随机图 | ||||
|  */ | ||||
| function create_sakura_table(){ | ||||
|     global $wpdb; | ||||
|     global $wpdb,$sakura_image_array,$sakura_privkey; | ||||
|     $sakura_table_name = $wpdb->base_prefix.'sakura'; | ||||
|     require_once(ABSPATH . "wp-admin/includes/upgrade.php");  | ||||
|     dbDelta("CREATE TABLE IF NOT EXISTS `" . $sakura_table_name . "` (
 | ||||
| @ -1728,20 +1738,30 @@ function create_sakura_table(){ | ||||
|         PRIMARY KEY (`mate_key`) | ||||
|         ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;");
 | ||||
|     //default data
 | ||||
|     $manifest = array( | ||||
|         "mate_key" => "manifest_json", | ||||
|         "mate_value" => file_get_contents(get_template_directory()."/manifest/manifest.json") | ||||
|     ); | ||||
|     $time = array( | ||||
|         "mate_key" => "json_time", | ||||
|         "mate_value" => date("Y-m-d H:i:s",time()) | ||||
|     ); | ||||
|     if ( !$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'manifest_json'") ){ | ||||
|         $manifest = array( | ||||
|             "mate_key" => "manifest_json", | ||||
|             "mate_value" => file_get_contents(get_template_directory()."/manifest/manifest.json") | ||||
|         ); | ||||
|         $wpdb->insert($sakura_table_name,$manifest); | ||||
|     } | ||||
|     if ( !$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'json_time'") ){ | ||||
|         $time = array( | ||||
|             "mate_key" => "json_time", | ||||
|             "mate_value" => date("Y-m-d H:i:s",time()) | ||||
|         ); | ||||
|         $wpdb->insert($sakura_table_name,$time); | ||||
|     } | ||||
|     if ( !$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'privkey'") ){ | ||||
|         $privkey = array( | ||||
|             "mate_key" => "privkey", | ||||
|             "mate_value" => wp_generate_password(8) | ||||
|         ); | ||||
|         $wpdb->insert($sakura_table_name,$privkey); | ||||
|     } | ||||
|     //reduce sql query
 | ||||
|     $sakura_image_array = $wpdb->get_var("SELECT `mate_value` FROM `wp_sakura` WHERE `mate_key`='manifest_json'"); | ||||
|     $sakura_privkey = $wpdb->get_var("SELECT `mate_value` FROM `wp_sakura` WHERE `mate_key`='privkey'"); | ||||
| } | ||||
| add_action( 'after_setup_theme', 'create_sakura_table' ); | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										100
									
								
								inc/api.php
									
									
									
									
									
								
							
							
						
						
									
										100
									
								
								inc/api.php
									
									
									
									
									
								
							| @ -20,18 +20,23 @@ add_action('rest_api_init', function () { | ||||
|         'methods' => 'GET', | ||||
|         'callback' => 'feature_gallery', | ||||
|     )); | ||||
|     register_rest_route('sakura/v1', '/image/manifest', array( | ||||
|     register_rest_route('sakura/v1', '/database/update', array( | ||||
|         'methods' => 'POST', | ||||
|         'callback' => 'update_manifest_json', | ||||
|         'callback' => 'update_database', | ||||
|     )); | ||||
|     register_rest_route('sakura/v1', '/qqinfo/json', array( | ||||
|         'methods' => 'GET', | ||||
|         'callback' => 'get_qq_info', | ||||
|     )); | ||||
|     register_rest_route('sakura/v1', '/qqinfo/avatar', array( | ||||
|         'methods' => 'GET', | ||||
|         'callback' => 'get_qq_avatar', | ||||
|     )); | ||||
| }); | ||||
| 
 | ||||
| /** | ||||
|  * QQ info | ||||
|  * https://sakura.2heng.xin/wp-json/sakura/v1/qqinfo/json | ||||
|  */ | ||||
| function get_qq_info(WP_REST_Request $request) | ||||
| { | ||||
| @ -219,26 +224,9 @@ function SMMS_API($image) | ||||
|     $Boundary = wp_generate_password(); | ||||
|     $bits = file_get_contents($filedata); | ||||
| 
 | ||||
|     $headers = array(); | ||||
|     array_push($headers, "Content-Type: multipart/form-data; boundary=$Boundary"); | ||||
|     array_push($headers, ''); | ||||
|     array_push($headers, "Authorization: Basic " . $client_id); | ||||
|     array_push($headers, ''); | ||||
|     array_push($headers, "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97"); | ||||
|     $headers = implode("\r\n", $headers); | ||||
| 
 | ||||
|     $fields = array(); | ||||
|     array_push($fields, "--" . $Boundary); | ||||
|     array_push($fields, "Content-Disposition: form-data; name=\"smfile\"; filename=\"$filename\"");
 | ||||
|     array_push($fields, ''); | ||||
|     array_push($fields, $bits); | ||||
|     array_push($fields, ''); | ||||
|     array_push($fields, "--" . $Boundary . "--"); | ||||
|     $fields = implode("\r\n", $fields); | ||||
| 
 | ||||
|     $args = array( | ||||
|         'headers' => $headers, | ||||
|         'body' => $fields, | ||||
|         "headers" => "Content-Type: multipart/form-data; boundary=$Boundary\r\n\r\nAuthorization: Basic $client_id\r\n\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97", | ||||
|         "body" => "--$Boundary\r\nContent-Disposition: form-data; name=\"smfile\"; filename=\"$filename\"\r\n\r\n$bits\r\n\r\n--$Boundary--" | ||||
|     ); | ||||
| 
 | ||||
|     $response = wp_remote_post($upload_url, $args); | ||||
| @ -337,8 +325,8 @@ EOS; | ||||
|  * @rest api接口路径:https://sakura.2heng.xin/wp-json/sakura/v1/image/cover | ||||
|  */ | ||||
| function cover_gallery() { | ||||
|     global $wpdb; | ||||
|     $img_array = json_decode($wpdb->get_var("SELECT `mate_value` FROM `wp_sakura` WHERE `mate_key`='manifest_json'"), true); | ||||
|     global $wpdb,$sakura_image_array; | ||||
|     $img_array = json_decode($sakura_image_array, true); | ||||
|     $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')) { | ||||
| @ -358,8 +346,8 @@ function cover_gallery() { | ||||
|  * @rest api接口路径:https://sakura.2heng.xin/wp-json/sakura/v1/image/feature | ||||
|  */ | ||||
| function feature_gallery() { | ||||
|     global $wpdb; | ||||
|     $img_array = json_decode($wpdb->get_var("SELECT `mate_value` FROM `wp_sakura` WHERE `mate_key`='manifest_json'"), true); | ||||
|     global $wpdb,$sakura_image_array; | ||||
|     $img_array = json_decode($sakura_image_array, true); | ||||
|     $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')) { | ||||
| @ -375,10 +363,10 @@ function feature_gallery() { | ||||
| } | ||||
| 
 | ||||
| /* | ||||
|  * update manifest.json rest api | ||||
|  * @rest api接口路径:https://sakura.2heng.xin/wp-json/sakura/v1/image/json | ||||
|  * update database rest api | ||||
|  * @rest api接口路径:https://sakura.2heng.xin/wp-json/sakura/v1/database/update | ||||
|  */ | ||||
| function update_manifest_json() { | ||||
| function update_database() { | ||||
|     $username = $_SERVER['PHP_AUTH_USER']; | ||||
|     $password = $_SERVER['PHP_AUTH_PW']; | ||||
|     $user = wp_authenticate($username, $password); | ||||
| @ -386,24 +374,26 @@ function update_manifest_json() { | ||||
|         if (in_array('administrator', (array) $user->roles)) { | ||||
|             global $wpdb; | ||||
|             $sakura_table_name = $wpdb->base_prefix.'sakura'; | ||||
|             $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); | ||||
|             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' => 'manifest.json has been stored into database' | ||||
|                 'message' => $message | ||||
|             ); | ||||
|             $result = new WP_REST_Response($output, 200); | ||||
|             $result->set_headers(array('Content-Type' => 'application/json')); | ||||
| @ -420,3 +410,29 @@ function update_manifest_json() { | ||||
|         return $result; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * QQ头像链接解密 | ||||
|  * https://sakura.2heng.xin/wp-json/sakura/v1/qqinfo/avatar | ||||
|  */ | ||||
| function get_qq_avatar(){ | ||||
|     global $sakura_privkey; | ||||
|     $encrypted=$_GET["qq"]; | ||||
|     if(isset($encrypted)){ | ||||
|         $encrypted = urldecode(base64_decode($encrypted)); | ||||
|         $qq_number = openssl_decrypt($encrypted, 'aes-128-cbc', $sakura_privkey, 0); | ||||
|         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'){ | ||||
|             $imgdata = file_get_contents($imgurl); | ||||
|             header("Content-type: image/jpeg"); | ||||
|             header("Cache-Control: max-age=86400"); | ||||
|             echo $imgdata; | ||||
|         }else{ | ||||
|             $response = new WP_REST_Response(); | ||||
|             $response->set_status(301); | ||||
|             $response->header('Location', $imgurl); | ||||
|             return $response; | ||||
|         } | ||||
|     }  | ||||
| } | ||||
|  | ||||
| @ -272,7 +272,7 @@ function optionsframework_page() { ?> | ||||
| 			<?php settings_fields( 'optionsframework' ); ?>
 | ||||
| 			<?php optionsframework_fields(); /* Settings */ ?>
 | ||||
| 			<div id="optionsframework-submit"> | ||||
| 				<input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save', 'sakaura' ); ?>" /> | ||||
| 				<input type="submit" class="button-primary" name="update" value="<?php _e( 'Save', 'sakura' ); ?>" /> | ||||
| 				<input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore default', 'sakura' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'All setting will be lost, sure?', 'sakura' ) ); ?>' );" /> | ||||
| 				<div class="clear"></div> | ||||
| 			</div> | ||||
| @ -491,4 +491,4 @@ if ( ! function_exists( 'akina_option' ) ) { | ||||
| 
 | ||||
| 		return $default; | ||||
| 	} | ||||
| } | ||||
| } | ||||
|  | ||||
										
											Binary file not shown.
										
									
								
							| @ -1,8 +1,8 @@ | ||||
| msgid "" | ||||
| msgstr "" | ||||
| "Project-Id-Version: Sakura\n" | ||||
| "POT-Creation-Date: 2019-12-04 15:07+0800\n" | ||||
| "PO-Revision-Date: 2019-12-04 15:15+0800\n" | ||||
| "POT-Creation-Date: 2019-12-13 14:51+0800\n" | ||||
| "PO-Revision-Date: 2019-12-13 14:51+0800\n" | ||||
| "Last-Translator: \n" | ||||
| "Language-Team: \n" | ||||
| "Language: en_US\n" | ||||
| @ -205,7 +205,7 @@ msgstr "" | ||||
| msgid "QQ" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: functions.php:1654 | ||||
| #: functions.php:1664 | ||||
| msgid "Sidebar" | ||||
| msgstr "" | ||||
| 
 | ||||
| @ -214,7 +214,7 @@ msgstr "" | ||||
| msgid "page %s " | ||||
| msgstr "" | ||||
| 
 | ||||
| #: inc/api.php:313 inc/theme_plus.php:727 | ||||
| #: inc/api.php:301 inc/theme_plus.php:727 | ||||
| msgid "The comment is private" | ||||
| msgstr "" | ||||
| 
 | ||||
| @ -1341,7 +1341,13 @@ msgid "About" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:906 | ||||
| msgid "Theme Sakura v" | ||||
| #, php-format | ||||
| msgid "" | ||||
| "Theme Sakura v %s  |  <a href=\"https://2heng.xin/theme-sakura/\">Theme " | ||||
| "document</a>  |  <a href=\"https://github.com/mashirozx/Sakura/\">Source " | ||||
| "code</a><a href=\"https://github.com/mashirozx/Sakura/releases/latest\"><img " | ||||
| "src=\"https://img.shields.io/github/release/mashirozx/Sakura.svg?style=flat-" | ||||
| "square\" alt=\"GitHub release\"></a>" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:912 | ||||
| @ -1623,27 +1629,51 @@ msgid "Enable human verification" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1139 | ||||
| msgid "Comment UA infomation" | ||||
| msgid "QQ avatar link encryption" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1140 | ||||
| msgid "Do not display the user's qq avatar links directly." | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1145 | ||||
| msgid "Off (default)" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1146 | ||||
| msgid "use redirect (general security)" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1147 | ||||
| msgid "fetch data at backend (high security)" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1148 | ||||
| msgid "fetch data at backend (high security,slow)" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1152 | ||||
| msgid "Comment UA infomation" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1153 | ||||
| msgid "" | ||||
| "Check to enable, display the user's browser, operating system information" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1146 | ||||
| #: options.php:1159 | ||||
| msgid "Enable disqus" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1147 | ||||
| #: options.php:1160 | ||||
| msgid "Enable disqus for comment" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1153 | ||||
| #: options.php:1166 | ||||
| msgid "Time Zone adjustment" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1154 | ||||
| #: options.php:1167 | ||||
| msgid "" | ||||
| "If the comment has a time difference problem adjust here, fill in an " | ||||
| "integer, the calculation method: actual_time = display_error_time - " | ||||
|  | ||||
| @ -3,7 +3,7 @@ msgid "" | ||||
| msgstr "" | ||||
| "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" | ||||
| "Project-Id-Version: Sakura\n" | ||||
| "POT-Creation-Date: 2019-12-04 15:07+0800\n" | ||||
| "POT-Creation-Date: 2019-12-13 14:50+0800\n" | ||||
| "PO-Revision-Date: 2019-11-01 14:27+0800\n" | ||||
| "Last-Translator: \n" | ||||
| "Language-Team: \n" | ||||
| @ -204,7 +204,7 @@ msgstr "" | ||||
| msgid "QQ" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: functions.php:1654 | ||||
| #: functions.php:1664 | ||||
| msgid "Sidebar" | ||||
| msgstr "" | ||||
| 
 | ||||
| @ -213,7 +213,7 @@ msgstr "" | ||||
| msgid "page %s " | ||||
| msgstr "" | ||||
| 
 | ||||
| #: inc/api.php:313 inc/theme_plus.php:727 | ||||
| #: inc/api.php:301 inc/theme_plus.php:727 | ||||
| msgid "The comment is private" | ||||
| msgstr "" | ||||
| 
 | ||||
| @ -1322,7 +1322,12 @@ msgid "About" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:906 | ||||
| msgid "Theme Sakura v" | ||||
| #, php-format | ||||
| msgid "" | ||||
| "Theme Sakura v %s  |  <a href=\"https://2heng.xin/theme-sakura/\">Theme document</a>  |  <a " | ||||
| "href=\"https://github.com/mashirozx/Sakura/\">Source code</a><a href=\"https://github.com/" | ||||
| "mashirozx/Sakura/releases/latest\"><img src=\"https://img.shields.io/github/release/mashirozx/" | ||||
| "Sakura.svg?style=flat-square\" alt=\"GitHub release\"></a>" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:912 | ||||
| @ -1592,26 +1597,50 @@ msgid "Enable human verification" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1139 | ||||
| msgid "Comment UA infomation" | ||||
| msgid "QQ avatar link encryption" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1140 | ||||
| msgid "Check to enable, display the user's browser, operating system information" | ||||
| msgid "Do not display the user's qq avatar links directly." | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1145 | ||||
| msgid "Off (default)" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1146 | ||||
| msgid "Enable disqus" | ||||
| msgid "use redirect (general security)" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1147 | ||||
| msgid "Enable disqus for comment" | ||||
| msgid "fetch data at backend (high security)" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1148 | ||||
| msgid "fetch data at backend (high security,slow)" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1152 | ||||
| msgid "Comment UA infomation" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1153 | ||||
| msgid "Check to enable, display the user's browser, operating system information" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1159 | ||||
| msgid "Enable disqus" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1160 | ||||
| msgid "Enable disqus for comment" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1166 | ||||
| msgid "Time Zone adjustment" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: options.php:1154 | ||||
| #: options.php:1167 | ||||
| msgid "" | ||||
| "If the comment has a time difference problem adjust here, fill in an integer, the calculation " | ||||
| "method: actual_time = display_error_time - the_integer_you_entered (unit: hour)" | ||||
|  | ||||
										
											Binary file not shown.
										
									
								
							| @ -1,8 +1,8 @@ | ||||
| msgid "" | ||||
| msgstr "" | ||||
| "Project-Id-Version: Sakura\n" | ||||
| "POT-Creation-Date: 2019-12-04 15:07+0800\n" | ||||
| "PO-Revision-Date: 2019-12-04 15:07+0800\n" | ||||
| "POT-Creation-Date: 2019-12-13 14:51+0800\n" | ||||
| "PO-Revision-Date: 2019-12-13 14:51+0800\n" | ||||
| "Last-Translator: \n" | ||||
| "Language-Team: \n" | ||||
| "Language: zh_CN\n" | ||||
| @ -207,7 +207,7 @@ msgstr "" | ||||
| msgid "QQ" | ||||
| msgstr "" | ||||
| 
 | ||||
| #: functions.php:1654 | ||||
| #: functions.php:1664 | ||||
| msgid "Sidebar" | ||||
| msgstr "侧栏" | ||||
| 
 | ||||
| @ -216,7 +216,7 @@ msgstr "侧栏" | ||||
| msgid "page %s " | ||||
| msgstr "第 %s 页 " | ||||
| 
 | ||||
| #: inc/api.php:313 inc/theme_plus.php:727 | ||||
| #: inc/api.php:301 inc/theme_plus.php:727 | ||||
| msgid "The comment is private" | ||||
| msgstr "该评论为私密评论" | ||||
| 
 | ||||
| @ -1365,8 +1365,19 @@ msgid "About" | ||||
| msgstr "关于" | ||||
| 
 | ||||
| #: options.php:906 | ||||
| msgid "Theme Sakura v" | ||||
| #, php-format | ||||
| msgid "" | ||||
| "Theme Sakura v %s  |  <a href=\"https://2heng.xin/theme-sakura/\">Theme " | ||||
| "document</a>  |  <a href=\"https://github.com/mashirozx/Sakura/\">Source " | ||||
| "code</a><a href=\"https://github.com/mashirozx/Sakura/releases/latest\"><img " | ||||
| "src=\"https://img.shields.io/github/release/mashirozx/Sakura.svg?style=flat-" | ||||
| "square\" alt=\"GitHub release\"></a>" | ||||
| msgstr "" | ||||
| "Theme Sakura v %s  |  <a href=\"https://2heng.xin/theme-sakura/\">主题说明</" | ||||
| "a>  |  <a href=\"https://github.com/mashirozx/Sakura/\">源码</a><a href=" | ||||
| "\"https://github.com/mashirozx/Sakura/releases/latest\"><img src=\"https://" | ||||
| "img.shields.io/github/release/mashirozx/Sakura.svg?style=flat-square\" alt=" | ||||
| "\"GitHub release\"></a>" | ||||
| 
 | ||||
| #: options.php:912 | ||||
| msgid "Check for Updates" | ||||
| @ -1667,27 +1678,51 @@ msgid "Enable human verification" | ||||
| msgstr "开启机器人验证" | ||||
| 
 | ||||
| #: options.php:1139 | ||||
| msgid "QQ avatar link encryption" | ||||
| msgstr "QQ头像链接加密" | ||||
| 
 | ||||
| #: options.php:1140 | ||||
| msgid "Do not display the user's qq avatar links directly." | ||||
| msgstr "不直接暴露用户QQ头像链接" | ||||
| 
 | ||||
| #: options.php:1145 | ||||
| msgid "Off (default)" | ||||
| msgstr "关闭(默认)" | ||||
| 
 | ||||
| #: options.php:1146 | ||||
| msgid "use redirect (general security)" | ||||
| msgstr "使用重定向(安全性低)" | ||||
| 
 | ||||
| #: options.php:1147 | ||||
| msgid "fetch data at backend (high security)" | ||||
| msgstr "后端获取头像数据(安全性高)" | ||||
| 
 | ||||
| #: options.php:1148 | ||||
| msgid "fetch data at backend (high security,slow)" | ||||
| msgstr "后端解析QQ头像接口(安全性高,慢)" | ||||
| 
 | ||||
| #: options.php:1152 | ||||
| msgid "Comment UA infomation" | ||||
| msgstr "评论UA信息" | ||||
| 
 | ||||
| #: options.php:1140 | ||||
| #: options.php:1153 | ||||
| msgid "" | ||||
| "Check to enable, display the user's browser, operating system information" | ||||
| msgstr "勾选开启,显示用户的浏览器,操作系统信息" | ||||
| 
 | ||||
| #: options.php:1146 | ||||
| #: options.php:1159 | ||||
| msgid "Enable disqus" | ||||
| msgstr "开启多说插件支持" | ||||
| 
 | ||||
| #: options.php:1147 | ||||
| #: options.php:1160 | ||||
| msgid "Enable disqus for comment" | ||||
| msgstr "多说已经凉了~~" | ||||
| 
 | ||||
| #: options.php:1153 | ||||
| #: options.php:1166 | ||||
| msgid "Time Zone adjustment" | ||||
| msgstr "时区调整" | ||||
| 
 | ||||
| #: options.php:1154 | ||||
| #: options.php:1167 | ||||
| msgid "" | ||||
| "If the comment has a time difference problem adjust here, fill in an " | ||||
| "integer, the calculation method: actual_time = display_error_time - " | ||||
|  | ||||
| @ -24,6 +24,8 @@ pip3 install Pillow | ||||
| pip install Pillow --user | ||||
| ``` | ||||
| 
 | ||||
| 用同样的方法安装`requests` | ||||
| 
 | ||||
| ### 运行 | ||||
| 把图片文件放到 `gallary` 目录,Windows 可直接双击 manifest.py,或者和其他操作系统一样,在 Terminal、Powershell、CMD 中运行: | ||||
| 
 | ||||
|  | ||||
| @ -43,47 +43,59 @@ class Single(object): | ||||
|       'webp': [self.webp, self.webp_th] | ||||
|     } | ||||
| 
 | ||||
|   #这个最好新建一个类 | ||||
|   def upload_manifest(self): | ||||
|     username = input('Enter your username: ') | ||||
|     password = input('Enter your password: ') | ||||
|     url = input('Enter your rest api url: ') | ||||
|     data_string = username + ':' + password | ||||
|   def main(self): | ||||
|     self.hash() | ||||
|     # if os.path.exists(self.jpeg) and os.path.exists(self.webp): | ||||
|     self.optimize() | ||||
|     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 = {'manifest': open('manifest.json', mode="rb")} | ||||
|     reply = requests.post(url, headers=headers, files=files) | ||||
|     files = {field: open(file, mode="rb")} | ||||
|     reply = requests.post(self.url, headers=headers, files=files) | ||||
|     print(json.loads(reply.content)['message']) | ||||
| 
 | ||||
|   def main(self): | ||||
|     self.hash() | ||||
|     # if os.path.exists(self.jpeg) and os.path.exists(self.webp): | ||||
|     self.optimize() | ||||
|     self.thumbnail() | ||||
|     self.manifest() | ||||
|     return self.mani | ||||
|     print('start uploading `manifest.json`...') | ||||
|     self.upload('manifest.json', 'manifest') | ||||
| 
 | ||||
| def main(): | ||||
| 
 | ||||
| def gen_manifest_json(): | ||||
|   onlyfiles = [f for f in os.listdir('gallary') if os.path.isfile(os.path.join('gallary', f))] | ||||
|   id = 1 | ||||
|   Manifest = {} | ||||
| 
 | ||||
|   for f in onlyfiles: | ||||
|       worker = Single(f, Manifest) | ||||
|       Manifest = worker.main() | ||||
|       print(str(id) + '/' + str(len(onlyfiles))) | ||||
|       id += 1 | ||||
| 
 | ||||
|     worker = Single(f, Manifest) | ||||
|     Manifest = worker.main() | ||||
|     print(str(id) + '/' + str(len(onlyfiles))) | ||||
|     id += 1 | ||||
|   with open('manifest.json', 'w+') as json_file: | ||||
|     json.dump(Manifest, json_file) | ||||
| 
 | ||||
|   up_json = Single(f, Manifest) | ||||
|   up_json.upload_manifest() | ||||
| 
 | ||||
| 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__': | ||||
|   main() | ||||
|   key = input('`manifest.json` saved. Press any key to quit.')  | ||||
|   key = input('`manifest.json` saved. Press any key to quit.') | ||||
|   quit() | ||||
|  | ||||
							
								
								
									
										15
									
								
								options.php
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								options.php
									
									
									
									
									
								
							| @ -903,7 +903,7 @@ function optionsframework_options() { | ||||
|          | ||||
|     $options[] = array( | ||||
|     'name' => __('About', 'sakura'),/*关于*/ | ||||
|     'desc' => __('Theme Sakura v'.SAKURA_VERSION.'  |  <a href="https://2heng.xin/theme-sakura/">Theme document</a>  |  <a href="https://github.com/mashirozx/Sakura/">Source code</a><a href="https://github.com/mashirozx/Sakura/releases/latest"><img src="https://img.shields.io/github/release/mashirozx/Sakura.svg?style=flat-square" alt="GitHub release"></a>', 'sakura'),/*Theme Sakura v'.SAKURA_VERSION.'  |  <a href="https://2heng.xin/theme-sakura/">主题说明</a>  |  <a href="https://github.com/mashirozx/Sakura/">源码</a><a href="https://github.com/mashirozx/Sakura/releases/latest"><img src="https://img.shields.io/github/release/mashirozx/Sakura.svg?style=flat-square" alt="GitHub release"></a>*/ | ||||
|     'desc' => sprintf(__('Theme Sakura v %s  |  <a href="https://2heng.xin/theme-sakura/">Theme document</a>  |  <a href="https://github.com/mashirozx/Sakura/">Source code</a><a href="https://github.com/mashirozx/Sakura/releases/latest"><img src="https://img.shields.io/github/release/mashirozx/Sakura.svg?style=flat-square" alt="GitHub release"></a>', 'sakura'), SAKURA_VERSION),/*Theme Sakura v'.SAKURA_VERSION.'  |  <a href="https://2heng.xin/theme-sakura/">主题说明</a>  |  <a href="https://github.com/mashirozx/Sakura/">源码</a><a href="https://github.com/mashirozx/Sakura/releases/latest"><img src="https://img.shields.io/github/release/mashirozx/Sakura.svg?style=flat-square" alt="GitHub release"></a>*/ | ||||
|     'id' => 'theme_intro', | ||||
|     'std' => '', | ||||
|     'type' => 'typography '); | ||||
| @ -1135,6 +1135,19 @@ function optionsframework_options() { | ||||
| 		'std' => '0', | ||||
| 		'type' => 'checkbox'); | ||||
| 
 | ||||
| 	$options[] = array( | ||||
| 		'name' => __('QQ avatar link encryption', 'sakura'),/*QQ头像链接加密*/ | ||||
| 		'desc' => __('Do not display the user\'s qq avatar links directly.', 'sakura'),/*不直接暴露用户qq头像链接*/ | ||||
| 		'id' => 'qq_avatar_link', | ||||
| 		'std' => "off", | ||||
| 		'type' => "select", | ||||
| 		'options' => array( | ||||
| 			'off' => __('Off (default)', 'sakura'),/*关闭(默认)*/ | ||||
| 			'type_1' => __('use redirect (general security)', 'sakura'),/*使用 重定向(安全性一般)'*/ | ||||
| 			'type_2' => __('fetch data at backend (high security)', 'sakura'),/*后端获取数据(安全性高)*/ | ||||
| 			'type_3' => __('fetch data at backend (high security,slow)', 'sakura'),/*后端获取数据(安全性高, 慢)*/ | ||||
| 		)); | ||||
| 
 | ||||
| 	$options[] = array( | ||||
| 		'name' => __('Comment UA infomation', 'sakura'),/*评论UA信息*/ | ||||
| 		'desc' => __('Check to enable, display the user\'s browser, operating system information', 'sakura'),/*勾选开启,显示用户的浏览器,操作系统信息*/ | ||||
|  | ||||
| @ -5,7 +5,7 @@ Theme URI: https://github.com/mashirozx/Sakura/ | ||||
| Author: Mashiro, Spirit, Louie, Fuzzz | ||||
| Author URI: http://2heng.xin | ||||
| Description: A wonderful branch of theme Akina | ||||
| Version: 3.3.2 | ||||
| Version: 3.3.3 | ||||
| License: GNU General Public License v2 or later | ||||
| License URI: http://www.gnu.org/licenses/gpl-2.0.html | ||||
| Text Domain: sakura | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user