mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-11 23:19:05 +00:00
Fixed & Add Article accessible content method
This commit is contained in:
@@ -369,11 +369,7 @@ class UserController extends Controller
|
||||
public function invite()
|
||||
{
|
||||
if (Order::uid()->active()->where('origin_amount', '>', 0)->doesntExist()) {
|
||||
return Response::view(
|
||||
'auth.error',
|
||||
['message' => trans('user.purchase_required').' <a class="btn btn-sm btn-danger" href="/">'.trans('common.back').'</a>'],
|
||||
402
|
||||
);
|
||||
return Response::view('auth.error', ['message' => trans('user.purchase_required').' <a class="btn btn-sm btn-danger" href="/">'.trans('common.back').'</a>'], 402);
|
||||
}
|
||||
|
||||
return view('user.invite', [
|
||||
@@ -511,11 +507,9 @@ class UserController extends Controller
|
||||
public function charge(Request $request): ?JsonResponse
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'coupon_sn' => [
|
||||
'required', Rule::exists('coupon', 'sn')->where(static function ($query) {
|
||||
$query->whereType(3)->whereStatus(0);
|
||||
}),
|
||||
],
|
||||
'coupon_sn' => ['required', Rule::exists('coupon', 'sn')->where(static function ($query) {
|
||||
$query->whereType(3)->whereStatus(0);
|
||||
})],
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
@@ -33,10 +33,7 @@ class ArticleService extends BaseService
|
||||
public function getContent()
|
||||
{
|
||||
$content = self::$article->content;
|
||||
if (! UserService::getInstance()->isActivePaying()) {
|
||||
$this->formatAccessable($content);
|
||||
}
|
||||
|
||||
$this->formatAccessable($content);
|
||||
$this->formatValuables($content);
|
||||
|
||||
return $content;
|
||||
@@ -44,21 +41,31 @@ class ArticleService extends BaseService
|
||||
|
||||
private function formatAccessable(&$body)
|
||||
{
|
||||
while (strpos($body, '<!--access start-->') !== false) {
|
||||
$accessData = $this->getInBetween($body, '<!--access start-->', '<!--access end-->');
|
||||
if ($accessData) {
|
||||
$body = strtr($body, [
|
||||
$accessData => '<div class="user-no-access"><i class="icon wb-lock" aria-hidden="true"></i>'.__('You must have a valid subscription to view content in this area!').'</div>',
|
||||
]);
|
||||
$noAccess = ! UserService::getInstance()->isActivePaying();
|
||||
|
||||
if ($noAccess) {
|
||||
while ($this->getInBetween($body, '<!--access_mode_1 start-->', '<!--access_mode_1 end-->', true) !== '') {
|
||||
$accessArea = $this->getInBetween($body, '<!--access_mode_1 start-->', '<!--access_mode_1 end-->');
|
||||
if ($accessArea) {
|
||||
$body = strtr($body,
|
||||
[$accessArea => '<div class="user-no-access"><i class="icon wb-lock" aria-hidden="true"></i>'.__('You must have a valid subscription to view content in this area!').'</div>']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while ($this->getInBetween($body, '<!--access_mode_2 start-->', '<!--access_mode_2 end-->', true) !== '') {
|
||||
$accessArea = $this->getInBetween($body, '<!--access_mode_2 start-->', '<!--access_mode_2 end-->');
|
||||
$hasAccessArea = $this->getInBetween($accessArea, '<!--access_mode_2 start-->', '<!--access_mode_2 else-->', true);
|
||||
$noAccessArea = $this->getInBetween($accessArea, '<!--access_mode_2 else-->', '<!--access_mode_2 end-->', true);
|
||||
$body = strtr($body, [$accessArea => $accessArea && $noAccess ? $noAccessArea : $hasAccessArea]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getInBetween($input, $start, $end): string
|
||||
private function getInBetween($input, $start, $end, $bodyOnly = false): string
|
||||
{
|
||||
$substr = substr($input, strlen($start) + strpos($input, $start), (strlen($input) - strpos($input, $end)) * (-1));
|
||||
$substr = substr($input, strpos($input, $start) + strlen($start), strpos($input, $end) - strlen($input));
|
||||
|
||||
return $start.$substr.$end;
|
||||
return $bodyOnly ? $substr : $start.$substr.$end;
|
||||
}
|
||||
|
||||
private function formatValuables(&$body)
|
||||
|
||||
@@ -23,5 +23,6 @@
|
||||
"We won't ask for your password again for a few hours.": "确认完成后,接下来几个小时内您不需再输入密码。",
|
||||
"You are receiving this email because we received a password reset request for your account.": "您收到此电子邮件是因为我们收到了您帐户的密码重设请求。",
|
||||
"Your email address is not verified.": "您的电子邮件尚未验证通过",
|
||||
"You have not responded this ticket in :num hours, System has closed your ticket.": "超过:num小时未回复工单,系统已自动关闭了您的工单"
|
||||
"You have not responded this ticket in :num hours, System has closed your ticket.": "超过:num小时未回复工单,系统已自动关闭了您的工单",
|
||||
"You must have a valid subscription to view the content in this area!": "您必须拥有有效套餐才可以查看该区域的内容!"
|
||||
}
|
||||
|
||||
@@ -118,15 +118,14 @@
|
||||
|
||||
tinymce.init({
|
||||
selector: 'textarea', // change this value according to your HTML
|
||||
plugins: [
|
||||
'advlist', 'autolink', 'link', 'image', 'lists', 'charmap', 'preview', 'anchor', 'pagebreak',
|
||||
'searchreplace', 'wordcount', 'visualblocks', 'visualchars', 'code', 'fullscreen', 'insertdatetime',
|
||||
'media', 'table', 'emoticons', 'template', 'help',
|
||||
],
|
||||
toolbar: 'undo redo | styles | bold italic | alignleft aligncenter alignright alignjustify | ' +
|
||||
'bullist numlist outdent indent | link image | print preview media fullscreen | ' +
|
||||
'forecolor backcolor emoticons | help',
|
||||
menubar: 'favs file edit view insert format tools table help',
|
||||
plugins: 'advlist autolink code emoticons help image importcss link lists media preview quickbars searchreplace table visualblocks visualchars wordcount',
|
||||
toolbar: 'undo redo | styles | bold italic forecolor backcolor emoticons| alignleft aligncenter alignright alignjustify | bullist numlist outdent ' +
|
||||
'indent | link image media',
|
||||
menubar: 'view edit insert format table tools help',
|
||||
link_default_target: '_blank',
|
||||
quickbars_insert_toolbar: 'quicktable image media',
|
||||
quickbars_selection_toolbar: 'bold italic underline | blocks | bullist numlist | blockquote quicklink',
|
||||
extended_valid_elements: 'i[class|aria-hidden]',
|
||||
language: '{{app()->getLocale()}}',
|
||||
content_css: '/assets/bundle/app.min.css',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user