Skip to content

Commit

Permalink
Merge pull request #17 from mokeyjay/develop
Browse files Browse the repository at this point in the history
5.1
  • Loading branch information
mokeyjay authored Sep 6, 2022
2 parents a8b6b4b + 3c79407 commit f4590b3
Show file tree
Hide file tree
Showing 15 changed files with 298 additions and 197 deletions.
26 changes: 9 additions & 17 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,24 @@ Both APIs automatically return the respective cross-domain header according to `
> The `image` and `url` keys are for compatibility purposes for users of 4.x or earlier versions, they can be ignored
## 🆙 Upgrading Guide
### Upgrading From 5.0 to 5.1
1. [Download the Source Code](https://github.com/mokeyjay/pixiv-daily-ranking-widget/releases/latest)
2. Unzip and overwrite the `app` and `index.php` to on your server
3. This version adds a new image-hosting, you can modify the `image_hosting` configuration in `config.php` as you needed

### Upgrading From 4.x to 5.0
1. Check the code comment of `image_hosting` item in [config.php](config.php#L90), select the most suitable image hosting option and fill it in your `config.php`
### Upgrading From 4.x to 5.x
1. Check the code comment of `image_hosting` item in [config.php](config.php#L88), select the most suitable image hosting option and fill it in your `config.php`
2. Delete all files in `storage/app` to enable the application refreshing the ranking data

## 🌟 Changelog
### New Features
- Supporting cross-domain on the APIs
- Scheduled job to clear historical logs
- Supporting 8 free image hosts
- JD, Riyugo, FiftyEight image hosting
- `static_cdn` configuration, you can choose the front-end static resource CDN provider
### Optimizations
- Picture display effect
- Left and right arrows will now be hidden automatically
- Display arwork title and author on mouse hover
- Upgrade front-end dependency packages to their latest while reducing amount of dependencies
- Improved logging function
- Enrich interface data to fit more use cases
- Replace Baidu Analytics with Google Analytics
- Update default User Agent
### Fixes
- Project URL cannot be retrieved correctly under certain scenarios
- A blank image will be downloaded under certain scenarios
- Rewritten left and right arrows, fixed some issues with it
### Other
- Removed the invalid Alibaba image hosting option
- Removed the invalid Baidu, Imgstop image hosting option
- Replace Google Analytics with Baidu Analytics

[History](doc/log.en.md)

Expand Down
26 changes: 9 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,24 @@
> `image``url` 两个键是为了兼容 4.x 及之前版本的用户,无需理会
## 🆙 升级指南
### 从 5.0 升级到 5.1
1. [下载源代码](https://github.com/mokeyjay/Pixiv-daily-ranking-widget/releases/latest)
2. 解压缩,将其中的 `app``index.php` 覆盖到线上环境
3. 此版本添加了新的图床,你可以按需修改 `config.php` 中的 `image_hosting` 配置项

### 从 4.x 升级到 5.0
1. 查看 [config.php](config.php#L90)`image_hosting` 配置项的注释说明,选择适合你的图床配置,填写到你线上环境的 `config.php`
### 从 4.x 升级到 5.x
1. 查看 [config.php](config.php#L88)`image_hosting` 配置项的注释说明,选择适合你的图床配置,填写到你线上环境的 `config.php`
2. 删除 `storage/app` 下的所有文件,让程序重新获取排行榜数据

## 🌟 更新日志
### 新增
- 支持跨域请求的数据接口
- clear-log 任务用于清除历史日志文件
- 共计 8 个国内外公开、免费的图床
- 京东、薄荷、58图床
- `static_cdn` 配置项,可以选择前端静态资源 CDN 供应商
### 优化
- 图片显示效果
- 左右翻页箭头现在会自动隐藏了
- 鼠标悬浮时显示作品标题及作者名称
- 升级前端依赖包至最新、减少依赖
- 完善日志记录功能
- 丰富接口数据以适应更多场景
- 将百度统计更换为谷歌统计
- 更新默认 UA
### 修复
- 部分情况下无法正确获取项目 url 的问题
- 部分情况下可能会下载到空白图片的问题
- 重写了左右翻页箭头,修复了它的一些问题
### 其他
- 去掉失效的阿里巴巴图床
- 去掉失效的百度、映画图床
- 将谷歌分析更换为百度统计

[历史更新日志](doc/log.md)

Expand Down
45 changes: 0 additions & 45 deletions app/ImageHosting/Baidu.php

This file was deleted.

42 changes: 42 additions & 0 deletions app/ImageHosting/FiftyEight.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace app\ImageHosting;

use app\Libs\Curl;
use app\Libs\Log;

/**
* 58 同城图床(有时会和谐一些图)
* 鸣谢:[@metowolf](https://github.com/metowolf)
* Class FiftyEight
* @package app\ImageHosting
*/
class FiftyEight extends ImageHosting
{
public function upload($path)
{
$data = [
'Pic-Size' => '0*0',
'Pic-Encoding' => 'base64',
'Pic-Path' => '/nowater/webim/big/',
'Pic-Data' => base64_encode(file_get_contents($path)),
];
$result = Curl::post('https://upload.58cdn.com.cn/json', json_encode($data), [
CURLOPT_HTTPHEADER => [
'Origin: https://ai.58.com',
'Referer: https://ai.58.com/pc/'
],
]);

$data['Pic-Data'] = '(数据长度:' . strlen($data['Pic-Data']) . '';
Log::write('[58图床]上传:' . json_encode($data));
Log::write('[58图床]返回:' . $result);

if (empty($result) || stripos($result, 'n_v2') !== 0) {
Log::write('[58图床]上传失败', 'ERROR');
return false;
}

return 'https://pic3.58cdn.com.cn/nowater/webim/big/' . $result;
}
}
51 changes: 0 additions & 51 deletions app/ImageHosting/Imgstop.php

This file was deleted.

46 changes: 46 additions & 0 deletions app/ImageHosting/Jd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace app\ImageHosting;

use app\Libs\Curl;
use app\Libs\Log;

/**
* 京东
* Class Jd
* @package app\ImageHosting
* @url https://www.jd.com/
*/
class Jd extends ImageHosting
{
public function upload($path)
{
$data = [
'appId' => 'im.customer',
'aid' => 'undefined',
'clientType' => 'comet',
'pin' => 'undefined',
's' => 'data:image/jpg;base64,' . base64_encode(file_get_contents($path)),
];
$result = Curl::post('https://imio.jd.com/uploadfile/file/post.do', $data, [
CURLOPT_HTTPHEADER => [
'accept: application/json, text/plain, */*',
'referer: https://jdcs.jd.com/jdchat/custom.action?entry=jd_fwztc',
'origin: https://jdcs.jd.com',
'Upgrade-insecure-requests: 1',
],
]);

$data['s'] = '(数据长度:' . strlen($data['s']) . '';
Log::write('[京东]上传:' . json_encode($data));
Log::write('[京东]返回:' . $result);

preg_match_all('|https://(.*?)"|', $result, $result);
if (!empty($result[1][0])) {
return "https://{$result[1][0]}";
}

Log::write('[京东]上传失败', 'ERROR');
return false;
}
}
44 changes: 44 additions & 0 deletions app/ImageHosting/Riyugo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace app\ImageHosting;

use app\Libs\Curl;
use app\Libs\Log;
use app\Libs\Str;

/**
* 薄荷图床(国内,香港腾讯云)
* Class riyugo
* @package app\ImageHosting
* @url https://riyugo.com/
*/
class Riyugo extends ImageHosting
{
public function upload($path)
{
$data = [
'name' => pathinfo($path, PATHINFO_BASENAME),
'uuid' => 'o_1gbng' . Str::random(22),
'nameMode' => 'isRenameMode',
'file' => Curl::getCurlFile($path),
];
$result = Curl::post('https://4ae.cn/localup.php', $data, [
CURLOPT_HTTPHEADER => [
'accept: */*',
'referer: https://riyugo.com/',
'origin: https://riyugo.com',
],
]);

Log::write('[薄荷图床]上传:' . json_encode($data));
Log::write('[薄荷图床]返回:' . $result);

$json = json_decode($result, true);
if (isset($json['result']) && $json['result'] == 'success' && !empty($json['url'])) {
return $json['url'];
}

Log::write('[薄荷图床]上传失败', 'ERROR');
return false;
}
}
2 changes: 1 addition & 1 deletion app/ImageHosting/Saoren.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use app\Libs\Str;

/**
* 骚人图床(国内)
* 骚人图床(国内,有鉴黄,偶尔会有图 404
* Class Saoren
* @package app\ImageHosting
* @url https://tu.sao.ren/
Expand Down
Loading

0 comments on commit f4590b3

Please sign in to comment.