Skip to content
Permalink
Browse files

Add Clear Stat Cache dev button

  • Loading branch information...
SeinopSys committed Aug 14, 2019
1 parent 85c09dc commit f9081f528dd619144f2ed8b229bee2cae5f9468b
@@ -1,33 +1,23 @@
<?php
namespace App\Controllers;
use App\Appearances;
use App\Auth;
use App\CoreUtils;
use App\CSRFProtection;
use App\DB;
use App\Input;
use App\JSON;
use App\Logs;
use App\Models\Appearance;
use App\Models\DiscordMember;
use App\Models\Logs\Log;
use App\Models\Notice;
use App\Models\Post;
use App\Models\UsefulLink;
use App\Models\User;
use App\Models\UserPref;
use App\Pagination;
use App\Permission;
use App\PostgresDbWrapper;
use App\Posts;
use App\RegExp;
use App\Response;
use App\UserPrefs;
use App\Users;
use GuzzleHttp\Command\Guzzle\GuzzleClient;
use IPTools\IP;
use RestCord\DiscordClient;
class AdminController extends Controller {
public $do = 'admin';
@@ -557,4 +547,12 @@ public function noticesApi($params){
CoreUtils::notAllowed();
}
}
public function statCacheApi() {
if ($this->action !== 'DELETE')
CoreUtils::notAllowed();
clearstatcache();
Response::done();
}
}
@@ -130,6 +130,8 @@ private function _setTarget($params){
}
public function sync($params){
Response::fail('The Discord account link got severed, you will need to re-link your account.', ['segway' => true]);
$this->_setTarget($params);
$discordUser = $this->_target->discord_member;
@@ -128,7 +128,7 @@ public function get_approval_entry(){
FROM log__post_lock pl
LEFT JOIN log l ON l.reftype = 'post_lock' AND l.refid = pl.entryid
WHERE $where_query
ORDER BY pl.entryid ASC
ORDER BY pl.entryid
LIMIT 1", $where_bind
);
}
@@ -327,9 +327,9 @@ public function getLi(bool $view_only = false, bool $cachebust_url = false, bool
$HTML .= $post_label.$posted_at.$post_type.$reserved_at.$finished_at.$locked_at;
if (!empty($this->fullsize))
$HTML .= "<span class='info-line'><a href='{$this->fullsize}' class='original color-green' target='_blank' rel='noopener'><span class='typcn typcn-link'></span> Original image</a></span>";
$HTML .= "<span class='info-line'><a href='{$this->fullsize}' class='original' target='_blank' rel='noopener'><span class='typcn typcn-link'></span> Original image</a></span>";
if (!$approved && Permission::sufficient('staff'))
$HTML .= "<span class='info-line'><a href='{$this->reserver->getOpenSubmissionsURL()}' class='color-blue' target='_blank' rel='noopener'><span class='typcn typcn-arrow-forward'></span> View open submissions</a></span>";
$HTML .= "<span class='info-line'><a href='{$this->reserver->getOpenSubmissionsURL()}' target='_blank' rel='noopener'><span class='typcn typcn-arrow-forward'></span> View open submissions</a></span>";
}
else $HTML .= $post_label.$posted_at.$reserved_at;
}
@@ -403,7 +403,7 @@ public function getActionsHTML($view_only, bool $hide_reserver_status, bool $ena
}
if (!empty($Buttons)){
if ($view_only !== false)
$HTML .= "<div><a href='$view_only' class='btn blue typcn typcn-arrow-forward'>View</a></div>";
$HTML .= "<div><a href='$view_only' class='btn link typcn typcn-arrow-forward'>View</a></div>";
else {
$regularButton = \count($Buttons) < 3;
foreach ($Buttons as $b){
@@ -163,7 +163,7 @@
}
if (!cdExists || diff.past){
clearCD();
$.API.get('/about/upcoming', $.mkAjaxHandler(function(){
$.API.get('/about/upcoming', function(){
if (!this.status) return console.error(`Failed to load upcoming event list: ${this.message}`);

const $uc = $('#upcoming');
@@ -172,7 +172,7 @@
$uc.addClass('hidden');
else $uc.removeClass('hidden');
window.setUpcomingCountdown();
}));
});
return;
}
let text;
@@ -540,11 +540,11 @@

$.Dialog.wait(title,'Signing out');

$.API.post('/da-auth/sign-out',$.mkAjaxHandler(function(){
$.API.post('/da-auth/sign-out', function(){
if (!this.status) return $.Dialog.fail(title,this.message);

$.Navigation.reload();
}));
});
});
});

@@ -556,7 +556,7 @@
if ($sessionUpdating === null)
return;

$.API.get('/da-auth/status', $.mkAjaxHandler(function(){
$.API.get('/da-auth/status', function(){
if ($sessionUpdating === null)
return;

@@ -568,7 +568,7 @@
if (this.deleted === true)
$.Dialog.fail(sessionRefTitle, "We couldn't refresh your DeviantArt session automatically so you have been signed out. Due to elements on the page assuming you are signed in some actions will not work as expected until the page is reloaded.");
$sessionUpdating.html(this.loggedIn).removeClass('updating-session');
}));
});
}, pollInterval);
}

@@ -43,13 +43,13 @@

waitingList[this.appearanceId] = [this];

$.API.post(`/cg/appearance/${this.appearanceId}/link-targets?hex`, $.mkAjaxHandler(data => {
$.API.post(`/cg/appearance/${this.appearanceId}/link-targets?hex`, data => {
if (!data.status) return this.displayError(data.message);

$.each(waitingList[this.appearanceId], (_, picker) => {
picker.fillSwatchBox(data.list);
});
}));
});
}
fillSwatchBox(list){
this.$swatchBox.removeClass('loading').children().first().nextAll().remove();
@@ -80,7 +80,7 @@

const ids = deviationIDArray.join(',');

$.API.post('/admin/mass-approve', { ids }, $.mkAjaxHandler(function(){
$.API.post('/admin/mass-approve', { ids }, function(){
if (!this.status) return $.Dialog.fail(false, this.message);

if (this.html){
@@ -91,10 +91,24 @@
if (this.message)
$.Dialog.success(false, this.message, true);
else $.Dialog.close();
}));
});
}
})();

$('#clear-stat-cache').on('click', e => {
e.preventDefault();

$.Dialog.wait('Clearing file stat cache');

$.API.delete('/admin/stat-cache', function () {
if (!this.status) return $.Dialog.fail(false, this.message);

if (this.message)
$.Dialog.success(false, this.message, true);
else $.Dialog.close();
});
});

const deviationIO = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (!entry.isIntersecting)
@@ -107,13 +121,13 @@
postID = el.dataset.postId,
viewonly = el.dataset.viewonly;

$.API.get(`/post/${postID}/lazyload`,{viewonly},$.mkAjaxHandler(function(){
$.API.get(`/post/${postID}/lazyload`,{viewonly},function(){
if (!this.status) return $.Dialog.fail(`Cannot load post ${postID}`, this.message);

$.loadImages(this.html).then(function(resp){
$(el).closest('.image').replaceWith(resp.$el);
});
}));
});
});
});
const imageIO = new IntersectionObserver(entries => {
@@ -32,7 +32,7 @@
$this.addClass('typcn-times color-red').css('cursor','not-allowed').off('click');
};

$.API.get(`/admin/logs/details/${EntryID}`,$.mkAjaxHandler(function(){
$.API.get(`/admin/logs/details/${EntryID}`, function(){
if (!this.status){
if (this.unclickable === true)
$this.replaceWith($this.text().trim());
@@ -61,7 +61,7 @@
$dataDiv.insertAfter($this).slideDown();
Time.update();
$this.addClass('typcn-minus color-darkblue');
})).always(function(){
}).always(function(){
requesting = false;
$this.removeClass('typcn-refresh');
}).fail(fail);
@@ -13,7 +13,7 @@

$.Dialog.wait(`Editing link #${linkid}`, 'Retrieving link information from server');

$.API.get(`/admin/usefullinks/${linkid}`,$.mkAjaxHandler(function(){
$.API.get(`/admin/usefullinks/${linkid}`, function(){
if (!this.status) return $.Dialog.fail(false, this.message);

let data = this;
@@ -23,7 +23,7 @@
$form.find('input[name=title]').val(data.title);
$form.find('select[name=minrole]').val(data.minrole);
});
}));
});
});
$uflol.on('click','.delete-link',function(){
let $li = $(this).closest('[id^=ufl-]'),
@@ -34,15 +34,15 @@

$.Dialog.wait(false, 'Removing link');

$.API.delete(`/admin/usefullinks/${linkId}`,$.mkAjaxHandler(function(){
$.API.delete(`/admin/usefullinks/${linkId}`, function(){
if (!this.status) return $.Dialog.fail(false, this.message);

$li.remove();
$('#ufl-link-'+linkId).remove();
if ($sbUflContainer.is(':empty'))
$sbUflContainer.hide();
$.Dialog.close();
}));
});
});
});
$('#add-link').on('click',function(){
@@ -113,11 +113,11 @@
list.push($(this).find('.typcn-arrow-move').remove().end().attr('id').split('-').pop());
});

$.API.post('/admin/usefullinks/reorder', {list:list.join(',')}, $.mkAjaxHandler(function(){
$.API.post('/admin/usefullinks/reorder', {list:list.join(',')}, function(){
if (!this.status) return $.Dialog.fail(false, this.message);

$.Navigation.reload(true);
}));
});
}
});
})();
@@ -131,7 +131,7 @@
$.Dialog.success(false, 'Hello response received', true);
});

$.API.get('/admin/wsdiag/hello', { priv, clientid }, $.mkAjaxHandler(function(){
$.API.get('/admin/wsdiag/hello', { priv, clientid }, function(){
if (!this.status) return $.Dialog.fail(false, this.message);

if (!responseReceived)
@@ -146,6 +146,6 @@
$w.off('ws-hello');
$.Dialog.fail(false, 'Hello response timed out');
}, timeout);
}));
});
});
})();
@@ -84,15 +84,15 @@
if (EQG)
data.eqg = true;

$.API.post('/cg/full/reorder', data, $.mkAjaxHandler(function(){
$.API.post('/cg/full/reorder', data, function(){
if (!this.status) return $.Dialog.fail(false, this.message);

$fullList.removeClass('sorting').html(this.html);
reobserve();
$ReorderBtn.removeClass('typcn-tick green').addClass('typcn-arrow-unsorted darkblue').html('Re-order');
$ReorderCancelBtn.addClass('hidden');
$.Dialog.close();
}));
});
}
});

@@ -151,9 +151,9 @@
source: (q, callback) => {
if (appearanceAutocompleteCache.has(q))
return callback(appearanceAutocompleteCache.get(q));
$.API.get(`/cg/appearances`, { q, EQG }, $.mkAjaxHandler(data => {
$.API.get(`/cg/appearances`, { q, EQG }, data => {
callback(appearanceAutocompleteCache.set(q, data));
}));
});
},
templates: {
header: () => `<div class="aa-header">

0 comments on commit f9081f5

Please sign in to comment.
You can’t perform that action at this time.