2023-06-13 20:27:06 +08:00
|
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
|
|
|
|
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
|
|
|
|
* https://www.x-lf.com/
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Function;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Http\Controllers\Index;
|
|
|
|
|
use Illuminate\Contracts\Foundation\Application;
|
|
|
|
|
use Illuminate\Contracts\View\Factory;
|
|
|
|
|
use Illuminate\Contracts\View\View;
|
2023-06-22 15:21:42 +08:00
|
|
|
|
use Illuminate\Http\JsonResponse;
|
2023-06-27 23:46:40 +08:00
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
|
use Illuminate\Http\Request as HttpRequest;
|
2023-06-22 15:21:42 +08:00
|
|
|
|
use Illuminate\Mail\Message;
|
2023-06-13 20:27:06 +08:00
|
|
|
|
use Illuminate\Support\Facades\DB;
|
2023-06-22 15:21:42 +08:00
|
|
|
|
use Illuminate\Support\Facades\Mail;
|
2023-06-27 23:46:40 +08:00
|
|
|
|
use Illuminate\Support\Facades\Request;
|
2023-06-22 15:21:42 +08:00
|
|
|
|
use Illuminate\Support\Facades\Response;
|
2023-06-24 16:03:27 +08:00
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
2023-06-13 20:27:06 +08:00
|
|
|
|
|
|
|
|
|
class Link extends Controller
|
|
|
|
|
{
|
|
|
|
|
protected array $data;
|
2023-06-28 14:48:24 +08:00
|
|
|
|
private array $sendEmail;
|
2023-06-13 20:27:06 +08:00
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$data = new Index();
|
|
|
|
|
$this->data = $data->data;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-28 14:48:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 添加友链API
|
|
|
|
|
*
|
|
|
|
|
* @param HttpRequest $request 获取HTTP中 Request 数据
|
|
|
|
|
* @return JsonResponse 返回JSON数据
|
|
|
|
|
*/
|
2023-06-27 23:46:40 +08:00
|
|
|
|
public function apiCustomAdd(HttpRequest $request): JsonResponse
|
2023-06-22 15:21:42 +08:00
|
|
|
|
{
|
2023-06-24 16:03:27 +08:00
|
|
|
|
/** @var array $returnData Json的 return 返回值 */
|
|
|
|
|
/** @var Validator $dataCheck 数据判断 */
|
|
|
|
|
/** @var array $errorInfo 错误信息 */
|
2023-06-24 21:00:27 +08:00
|
|
|
|
/** @var array $errorSingle 输出单个错误信息 */
|
2023-06-22 15:21:42 +08:00
|
|
|
|
// 检查数据
|
2023-06-24 21:00:27 +08:00
|
|
|
|
$dataCheck = Validator::make($request->all(), [
|
2023-06-24 16:03:27 +08:00
|
|
|
|
'userEmail' => 'required|email',
|
|
|
|
|
'userServerHost' => 'required|string',
|
|
|
|
|
'userBlog' => 'required|string',
|
2023-06-24 21:00:27 +08:00
|
|
|
|
'userUrl' => 'required|regex:#[a-zA-z]+://[^\s]*#',
|
2023-06-24 16:03:27 +08:00
|
|
|
|
'userDescription' => 'required|string',
|
2023-06-24 21:00:27 +08:00
|
|
|
|
'userIcon' => 'required|regex:#[a-zA-z]+://[^\s]*#',
|
2023-06-24 16:03:27 +08:00
|
|
|
|
'checkRssJudge' => 'boolean',
|
2023-06-24 21:00:27 +08:00
|
|
|
|
'userRss' => 'string|regex:#[a-zA-z]+://[^\s]*#',
|
2023-06-24 16:03:27 +08:00
|
|
|
|
'userLocation' => 'required|int',
|
|
|
|
|
'userSelColor' => 'required|int',
|
2023-06-27 20:40:19 +08:00
|
|
|
|
'userRemark' => 'string',
|
2023-06-24 16:03:27 +08:00
|
|
|
|
]);
|
2023-06-22 15:21:42 +08:00
|
|
|
|
|
2023-06-24 16:03:27 +08:00
|
|
|
|
// 检查发现错误
|
|
|
|
|
if ($dataCheck->fails()) {
|
|
|
|
|
$errorType = array_keys($dataCheck->failed());
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach ($dataCheck->failed() as $valueData) {
|
|
|
|
|
$errorInfo[$errorType[$i]] = array_keys($valueData);
|
2023-06-24 21:00:27 +08:00
|
|
|
|
if ($i == 0) {
|
|
|
|
|
$errorSingle = [
|
|
|
|
|
'info' => $errorType[$i],
|
|
|
|
|
'need' => $errorInfo[$errorType[$i]],
|
|
|
|
|
];
|
|
|
|
|
}
|
2023-06-24 16:03:27 +08:00
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'DataFormatError',
|
|
|
|
|
'code' => 403,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '输入内容有错误',
|
2023-06-24 21:00:27 +08:00
|
|
|
|
'errorSingle' => $errorSingle,
|
2023-06-24 16:03:27 +08:00
|
|
|
|
'error' => $errorInfo,
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
} else {
|
2023-06-22 15:21:42 +08:00
|
|
|
|
// 检查数据
|
|
|
|
|
if (empty($request->checkRssJudge)) {
|
|
|
|
|
$request->checkRssJudge = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据数据库检查邮箱用户是否已存在
|
|
|
|
|
$resultBlog = DB::table('blog_link')
|
|
|
|
|
->where([
|
2023-06-24 21:00:27 +08:00
|
|
|
|
['blogOwnEmail', '=', $request->userEmail, 'or'],
|
|
|
|
|
['blogName', '=', $request->userBlog, 'or'],
|
|
|
|
|
['blogUrl', '=', $request->userUrl, 'or']
|
2023-06-22 15:21:42 +08:00
|
|
|
|
])->get()->toArray();
|
|
|
|
|
|
|
|
|
|
if (empty($resultBlog)) {
|
|
|
|
|
// 数据写入数据库
|
|
|
|
|
$insertData = DB::table('blog_link')
|
|
|
|
|
->insert([
|
|
|
|
|
'blogOwnEmail' => $request->userEmail,
|
|
|
|
|
'blogUrl' => $request->userUrl,
|
|
|
|
|
'blogName' => $request->userBlog,
|
|
|
|
|
'blogDescription' => $request->userDescription,
|
|
|
|
|
'blogIcon' => $request->userIcon,
|
|
|
|
|
'blogRssJudge' => $request->checkRssJudge,
|
|
|
|
|
'blogRSS' => $request->userRss,
|
|
|
|
|
'blogUserLocation' => $request->userLocation,
|
|
|
|
|
'blogSetColor' => $request->userSelColor,
|
2023-06-22 23:02:38 +08:00
|
|
|
|
'blogRemark' => $request->userRemark,
|
2023-06-22 15:21:42 +08:00
|
|
|
|
]);
|
|
|
|
|
if ($insertData) {
|
|
|
|
|
// 邮件发送系统
|
2023-06-24 21:00:27 +08:00
|
|
|
|
Mail::send('mail.link-custom-add', $request->toArray(), function (Message $mail) {
|
2023-06-22 15:21:42 +08:00
|
|
|
|
global $request;
|
2023-06-24 21:00:27 +08:00
|
|
|
|
$mail->from(env('MAIL_USERNAME'), env('APP_NAME'));
|
2023-06-22 15:21:42 +08:00
|
|
|
|
$mail->to($request->userEmail);
|
2023-06-24 21:00:27 +08:00
|
|
|
|
$mail->subject(env('APP_NAME') . '-友链等待审核通知');
|
2023-06-22 15:21:42 +08:00
|
|
|
|
});
|
|
|
|
|
// 消息成功通知
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'Success',
|
|
|
|
|
'code' => 200,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '您已成功申请',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'AlreadyUser',
|
|
|
|
|
'code' => 403,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '已有此用户,您是否已在本博客注册过',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-24 21:00:27 +08:00
|
|
|
|
return Response::json($returnData, $returnData['code']);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-28 14:48:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 搜索友链数据
|
|
|
|
|
*
|
|
|
|
|
* @param HttpRequest $request 获取HTTP中 Request 数据
|
|
|
|
|
* @return JsonResponse 返回JSON数据
|
|
|
|
|
*/
|
2023-06-27 23:46:40 +08:00
|
|
|
|
public function apiCustomSearch(HttpRequest $request): JsonResponse
|
2023-06-24 22:50:44 +08:00
|
|
|
|
{
|
|
|
|
|
/** @var array $returnData Json的 return 返回值 */
|
|
|
|
|
if (!empty($request->location_search)) {
|
|
|
|
|
if ($request->searchType == 'all') {
|
|
|
|
|
$resultData = DB::table('blog_link')
|
|
|
|
|
->where([
|
|
|
|
|
['blogName', 'LIKE', '%' . $request->location_search . '%', 'or'],
|
|
|
|
|
['blogUrl', 'LIKE', '%' . $request->location_search . '%', 'or'],
|
2023-06-27 20:58:17 +08:00
|
|
|
|
['blogOwnEmail', '=', $request->location_search, 'or']])
|
2023-06-27 23:46:40 +08:00
|
|
|
|
->select('id', 'blogName', 'blogUrl', 'blogDescription', 'blogIcon')
|
2023-06-24 22:50:44 +08:00
|
|
|
|
->orderBy('id')
|
|
|
|
|
->get()
|
|
|
|
|
->toArray();
|
|
|
|
|
if (!empty($resultData)) {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'Success',
|
|
|
|
|
'code' => 200,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '数据输出成功',
|
|
|
|
|
'data' => $resultData,
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'NoData',
|
|
|
|
|
'code' => 200,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '没有数据',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ($request->searchType == 'blogName') {
|
|
|
|
|
$resultData = DB::table('blog_link')
|
|
|
|
|
->where([['blogName', 'LIKE', '%' . $request->location_search . '%']])
|
2023-06-27 23:46:40 +08:00
|
|
|
|
->select('id', 'blogName', 'blogUrl', 'blogDescription', 'blogIcon')
|
2023-06-24 22:50:44 +08:00
|
|
|
|
->orderBy('id')
|
|
|
|
|
->get()
|
|
|
|
|
->toArray();
|
|
|
|
|
if (!empty($resultData)) {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'Success',
|
|
|
|
|
'code' => 200,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '数据输出成功',
|
|
|
|
|
'data' => $resultData,
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'NoData',
|
|
|
|
|
'code' => 200,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '没有数据',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
} elseif ($request->searchType == 'blogUrl') {
|
|
|
|
|
$resultData = DB::table('blog_link')
|
|
|
|
|
->where([['blogUrl', 'LIKE', '%' . $request->location_search . '%']])
|
2023-06-27 23:46:40 +08:00
|
|
|
|
->select('id', 'blogName', 'blogUrl', 'blogDescription', 'blogIcon')
|
2023-06-24 22:50:44 +08:00
|
|
|
|
->orderBy('id')
|
|
|
|
|
->get()
|
|
|
|
|
->toArray();
|
|
|
|
|
if (!empty($resultData)) {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'Success',
|
|
|
|
|
'code' => 200,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '数据输出成功',
|
|
|
|
|
'data' => $resultData,
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'NoData',
|
|
|
|
|
'code' => 200,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '没有数据',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'TypeError',
|
|
|
|
|
'code' => 403,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '类型错误请检查',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'SearchEmpty',
|
|
|
|
|
'code' => 403,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '搜索为空,请输入内容',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
2023-06-27 23:46:40 +08:00
|
|
|
|
return Response::json($returnData, $returnData['code']);
|
2023-06-24 22:50:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-28 14:48:24 +08:00
|
|
|
|
/**
|
|
|
|
|
* 检查数据验证是否正确
|
|
|
|
|
*
|
|
|
|
|
* @param HttpRequest $request 获取HTTP中 Request 数据
|
|
|
|
|
* @return JsonResponse 返回JSON数据
|
|
|
|
|
*/
|
|
|
|
|
public function apiCustomBlogCheck(HttpRequest $request): JsonResponse
|
|
|
|
|
{
|
|
|
|
|
/** @var array $returnData Json的 return 返回值 */
|
|
|
|
|
// 验证数据
|
|
|
|
|
$resultBlog = DB::table('blog_link')
|
|
|
|
|
->select('id', 'blogOwnEmail')
|
|
|
|
|
->find((int)$request->id);
|
|
|
|
|
if (!empty($resultBlog->id)) {
|
|
|
|
|
// 检查输入博客是否对应
|
|
|
|
|
if (!empty($resultBlog->blogOwnEmail)) {
|
|
|
|
|
if (strcmp($resultBlog->blogOwnEmail, $request->email) == 0) {
|
|
|
|
|
// 生成验证码(筛查内容)
|
|
|
|
|
$resultVerifyCode = DB::table('code')
|
|
|
|
|
->where([
|
|
|
|
|
['email', '=', $resultBlog->blogOwnEmail],
|
|
|
|
|
['type', '=', 'CODE-CUSTOM-CHECK'],
|
|
|
|
|
['time', '>', time()]])
|
|
|
|
|
->get()
|
|
|
|
|
->toArray();
|
|
|
|
|
// 不存在验证码,生成验证码并存入数据库中
|
|
|
|
|
if (empty($resultVerifyCode[0]->id)) {
|
|
|
|
|
// 生成6位数验证码
|
|
|
|
|
$verifyCode = null;
|
|
|
|
|
for ($i = 0; $i < 6; $i++)
|
|
|
|
|
$verifyCode .= rand(0, 9);
|
|
|
|
|
|
|
|
|
|
// 存入数据库
|
|
|
|
|
DB::table('code')
|
|
|
|
|
->insert([
|
|
|
|
|
'email' => $resultBlog->blogOwnEmail,
|
|
|
|
|
'code' => $verifyCode,
|
|
|
|
|
'type' => 'CODE-CUSTOM-CHECK',
|
|
|
|
|
'sendTime' => time(),
|
|
|
|
|
'time' => time()+900,
|
|
|
|
|
]);
|
|
|
|
|
// 数据整理
|
|
|
|
|
$this->sendEmail = [
|
|
|
|
|
'userEmail' => $resultBlog->blogOwnEmail,
|
|
|
|
|
'verifyCode' => $verifyCode,
|
|
|
|
|
'sendTime' => time(),
|
|
|
|
|
];
|
|
|
|
|
$this->apiCustomBlogCheckSendEmail();
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'Success',
|
|
|
|
|
'code' => 200,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '发送成功',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
// 存在验证码,检查验证码是否需要重新发送
|
|
|
|
|
$data = DB::table('code')
|
|
|
|
|
->where([
|
|
|
|
|
['email','=',$resultBlog->blogOwnEmail],
|
|
|
|
|
['type','=','CODE-CUSTOM-CHECK'],
|
|
|
|
|
['time','>',time()]])
|
|
|
|
|
->get()
|
|
|
|
|
->toArray();
|
|
|
|
|
$this->sendEmail = [
|
|
|
|
|
'userEmail' => $data[0]->email,
|
|
|
|
|
'verifyCode' => $data[0]->code,
|
|
|
|
|
'sendTime' => time(),
|
|
|
|
|
];
|
|
|
|
|
if ($resultVerifyCode[0]->sendTime < time()-60) {
|
|
|
|
|
// 发送验证码
|
|
|
|
|
DB::table('code')
|
|
|
|
|
->where([
|
|
|
|
|
['email','=',$resultBlog->blogOwnEmail],
|
|
|
|
|
['type','=','CODE-CUSTOM-CHECK'],
|
|
|
|
|
['time','>',time()]])
|
|
|
|
|
->update(['sendTime' => time()]);
|
|
|
|
|
$this->apiCustomBlogCheckSendEmail();
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'Success',
|
|
|
|
|
'code' => 200,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '重新发送成功',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
// 避免重复发送
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'SendingTimeTooFast',
|
|
|
|
|
'code' => 403,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '邮件重新发送时间过快',
|
|
|
|
|
'data' => [
|
|
|
|
|
'time' => 60 - (time() - $resultVerifyCode[0]->sendTime),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'EmailMismatch',
|
|
|
|
|
'code' => 403,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '邮箱与对应ID不匹配',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'NoEmail',
|
|
|
|
|
'code' => 403,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '对应ID没有绑定邮箱,请联系管理员',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$returnData = [
|
|
|
|
|
'output' => 'NoBlog',
|
|
|
|
|
'code' => 403,
|
|
|
|
|
'data' => [
|
|
|
|
|
'message' => '没有ID对应博客',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
return Response::json($returnData, $returnData['code']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 站长认证邮件发送模板
|
|
|
|
|
*
|
|
|
|
|
* @param array $data
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
private function apiCustomBlogCheckSendEmail(): void
|
|
|
|
|
{
|
|
|
|
|
// 验证通过发送邮件
|
|
|
|
|
Mail::send('mail.link-custom-check', $this->sendEmail, function (Message $mail) {
|
|
|
|
|
$mail->from(env('MAIL_USERNAME'), env('APP_NAME'));
|
|
|
|
|
$mail->to($this->sendEmail['userEmail']);
|
|
|
|
|
$mail->subject(env('APP_NAME') . '-验证码(友链自助修改)');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-27 23:46:40 +08:00
|
|
|
|
public function viewEditFriend($friendId): Application|Factory|View|RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
// 检查内容是否为空
|
|
|
|
|
if (!empty($friendId)) {
|
|
|
|
|
$this->data['webSubTitle'] = '修改友链';
|
|
|
|
|
|
|
|
|
|
// 检查这个ID是否存在
|
|
|
|
|
$resultBlog = DB::table('blog_link')
|
|
|
|
|
->find($friendId);
|
|
|
|
|
if (!empty($resultBlog->id)) {
|
|
|
|
|
// 检查是否存在Cookie作为已验证
|
|
|
|
|
if (Request::hasCookie('friend_edit')) {
|
|
|
|
|
// 检查COOKIE与所验证ID是否匹配
|
2023-06-28 14:48:24 +08:00
|
|
|
|
if (password_verify($friendId, Request::cookie('friend_edit'))) {
|
2023-06-27 23:46:40 +08:00
|
|
|
|
return view('function.edit-friend', $this->data);
|
|
|
|
|
} else {
|
2023-06-28 14:48:24 +08:00
|
|
|
|
response()->withCookie(cookie('friend_edit', null, time() - 1));
|
2023-06-27 23:46:40 +08:00
|
|
|
|
return Response::redirectTo(route('function.edit-search'));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 验证页面
|
|
|
|
|
// 加密用户邮箱
|
|
|
|
|
$this->data['blog'] = $resultBlog;
|
|
|
|
|
return view('function.edit-check', $this->data);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 不存在这一个ID用户
|
|
|
|
|
return Response::redirectTo(route('function.edit-search'));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// ID为空的时候就返回数据
|
|
|
|
|
return Response::redirectTo(route('function.edit-search'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function viewLink(HttpRequest $request): Factory|View|Application
|
2023-06-24 21:00:27 +08:00
|
|
|
|
{
|
|
|
|
|
$this->data['webSubTitle'] = '友链';
|
|
|
|
|
$this->GetFriendsLink($this->data);
|
|
|
|
|
return view('function.link', $this->data);
|
2023-06-22 15:21:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-13 20:27:06 +08:00
|
|
|
|
private function GetFriendsLink(array &$data): void
|
|
|
|
|
{
|
2023-06-24 21:00:27 +08:00
|
|
|
|
$data['blogLink'] = DB::table('blog_link')->whereNotIn('blog_link.blogLocation', [0])->get()->toArray();
|
2023-06-13 20:27:06 +08:00
|
|
|
|
$data['blogSort'] = DB::table('blog_sort')->orderBy('blog_sort.sort')->get()->toArray();
|
|
|
|
|
}
|
2023-06-24 21:00:27 +08:00
|
|
|
|
|
|
|
|
|
protected function viewMakeFriend(): Factory|View|Application
|
|
|
|
|
{
|
|
|
|
|
$this->data['webSubTitle'] = '添加友链';
|
|
|
|
|
$this->data['blogColor'] = DB::table('blog_color')
|
|
|
|
|
->orderBy('id')
|
|
|
|
|
->get()
|
|
|
|
|
->toArray();
|
|
|
|
|
$this->data['blogSort'] = DB::table('blog_sort')
|
|
|
|
|
->orderBy('sort')
|
|
|
|
|
->get()
|
|
|
|
|
->toArray();
|
|
|
|
|
return view('function.make-friend', $this->data);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-27 23:46:40 +08:00
|
|
|
|
protected function viewSearchFriends(): Factory|View|Application
|
2023-06-24 21:00:27 +08:00
|
|
|
|
{
|
2023-06-27 23:46:40 +08:00
|
|
|
|
$this->data['webSubTitle'] = '查询列表';
|
|
|
|
|
return view('function.edit-search', $this->data);
|
2023-06-24 21:00:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-27 23:46:40 +08:00
|
|
|
|
protected function viewSearchFriend($friendId): Factory|View|Application|RedirectResponse
|
2023-06-24 21:00:27 +08:00
|
|
|
|
{
|
|
|
|
|
$this->data['webSubTitle'] = '查询列表';
|
2023-06-27 23:46:40 +08:00
|
|
|
|
if (!empty($friendId)) {
|
|
|
|
|
// 检查 friendId 是否存在
|
|
|
|
|
$resultBlog = DB::table('blog_link')
|
|
|
|
|
->select('id','blogOwnEmail')
|
|
|
|
|
->find($friendId);
|
|
|
|
|
if (!empty($resultBlog->id)) {
|
|
|
|
|
$this->data['blog'] = $resultBlog;
|
|
|
|
|
return view('function.edit-check', $this->data);
|
|
|
|
|
} else {
|
|
|
|
|
return Response::redirectTo(route('function.edit-search'));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return Response::redirectTo(route('function.edit-search'));
|
|
|
|
|
}
|
2023-06-24 21:00:27 +08:00
|
|
|
|
}
|
2023-06-13 20:27:06 +08:00
|
|
|
|
}
|