Scrollreveal+cat+datenews
This commit is contained in:
@@ -31,6 +31,7 @@ class AdminTwigExtension extends \Twig_Extension
|
||||
new \Twig_SimpleFilter('toYaml', [$this, 'toYamlFilter']),
|
||||
new \Twig_SimpleFilter('fromYaml', [$this, 'fromYamlFilter']),
|
||||
new \Twig_SimpleFilter('adminNicetime', [$this, 'adminNicetimeFilter']),
|
||||
new \Twig_SimpleFilter('nested', [$this, 'nestedFilter']),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -42,6 +43,23 @@ class AdminTwigExtension extends \Twig_Extension
|
||||
];
|
||||
}
|
||||
|
||||
public function nestedFilter($current, $name)
|
||||
{
|
||||
$path = explode('.', trim($name, '.'));
|
||||
|
||||
foreach ($path as $field) {
|
||||
if (is_object($current) && isset($current->{$field})) {
|
||||
$current = $current->{$field};
|
||||
} elseif (is_array($current) && isset($current[$field])) {
|
||||
$current = $current[$field];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $current;
|
||||
}
|
||||
|
||||
public function cloneFunc($obj)
|
||||
{
|
||||
return clone $obj;
|
||||
|
||||
@@ -170,11 +170,11 @@ class Admin
|
||||
|
||||
/** @var \DirectoryIterator $directory */
|
||||
foreach (new \DirectoryIterator($path) as $file) {
|
||||
if ($file->isDir() || $file->isDot() || Utils::startsWith($file->getBasename(), '.')) {
|
||||
if ($file->isDir() || $file->isDot() || Utils::startsWith($file->getFilename(), '.')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$lang = basename($file->getBasename(), '.yaml');
|
||||
$lang = $file->getBasename('.yaml');
|
||||
|
||||
$languages[$lang] = LanguageCodes::getNativeName($lang);
|
||||
|
||||
@@ -202,7 +202,7 @@ class Admin
|
||||
if ($file->isDir() || !preg_match('/^[^.].*.yaml$/', $file->getFilename())) {
|
||||
continue;
|
||||
}
|
||||
$configurations[] = basename($file->getBasename(), '.yaml');
|
||||
$configurations[] = $file->getBasename('.yaml');
|
||||
}
|
||||
|
||||
return $configurations;
|
||||
@@ -365,7 +365,7 @@ class Admin
|
||||
|
||||
$userKey = isset($credentials['username']) ? (string)$credentials['username'] : '';
|
||||
$ipKey = Uri::ip();
|
||||
$redirect = $this->base . $this->route;
|
||||
$redirect = isset($post['redirect']) ? $post['redirect'] : $this->base . $this->route;
|
||||
|
||||
// Check if the current IP has been used in failed login attempts.
|
||||
$attempts = count($rateLimiter->getAttempts($ipKey, 'ip'));
|
||||
@@ -595,7 +595,8 @@ class Admin
|
||||
}
|
||||
|
||||
if (!$post) {
|
||||
$post = isset($_POST['data']) ? $_POST['data'] : [];
|
||||
$post = $this->grav['uri']->post();
|
||||
$post = isset($post['data']) ? $post['data'] : [];
|
||||
}
|
||||
|
||||
// Check to see if a data type is plugin-provided, before looking into core ones
|
||||
@@ -637,12 +638,12 @@ class Admin
|
||||
$data[$type] = $obj;
|
||||
} elseif (preg_match('|users/|', $type)) {
|
||||
$obj = User::load(preg_replace('|users/|', '', $type));
|
||||
$obj->merge($post);
|
||||
$obj->merge($this->cleanUserPost($post));
|
||||
|
||||
$data[$type] = $obj;
|
||||
} elseif (preg_match('|user/|', $type)) {
|
||||
$obj = User::load(preg_replace('|user/|', '', $type));
|
||||
$obj->merge($post);
|
||||
$obj->merge($this->cleanUserPost($post));
|
||||
|
||||
$data[$type] = $obj;
|
||||
} elseif (preg_match('|config/|', $type)) {
|
||||
@@ -669,10 +670,10 @@ class Admin
|
||||
$obj->file = $file;
|
||||
$obj->page = $this->grav['pages']->get(dirname($obj->path));
|
||||
|
||||
$filename = pathinfo($obj->title)['filename'];
|
||||
$filename = str_replace(['@3x', '@2x'], '', $filename);
|
||||
if (isset(pathinfo($obj->title)['extension'])) {
|
||||
$filename .= '.' . pathinfo($obj->title)['extension'];
|
||||
$fileInfo = pathinfo($obj->title);
|
||||
$filename = str_replace(['@3x', '@2x'], '', $fileInfo['filename']);
|
||||
if (isset($fileInfo['extension'])) {
|
||||
$filename .= '.' . $fileInfo['extension'];
|
||||
}
|
||||
|
||||
if ($obj->page && isset($obj->page->media()[$filename])) {
|
||||
@@ -687,6 +688,25 @@ class Admin
|
||||
return $data[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean user form post and remove extra stuff that may be passed along
|
||||
*
|
||||
* @param $post
|
||||
* @return array
|
||||
*/
|
||||
protected function cleanUserPost($post)
|
||||
{
|
||||
// Clean fields for all users
|
||||
unset($post['hashed_password']);
|
||||
|
||||
// Clean field for users who shouldn't be able to modify these fields
|
||||
if (!$this->authorize(['admin.user', 'admin.super'])) {
|
||||
unset($post['access']);
|
||||
}
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
protected function hasErrorMessage()
|
||||
{
|
||||
$msgs = $this->grav['messages']->all();
|
||||
@@ -1418,6 +1438,9 @@ class Admin
|
||||
$path = "/{$path}";
|
||||
}
|
||||
|
||||
// Fix for entities in path causing looping...
|
||||
$path = urldecode($path);
|
||||
|
||||
$page = $path ? $pages->dispatch($path, true) : $pages->root();
|
||||
|
||||
if (!$page) {
|
||||
|
||||
@@ -7,6 +7,7 @@ use Grav\Common\Filesystem\Folder;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Media\Interfaces\MediaInterface;
|
||||
use Grav\Common\Page\Media;
|
||||
use Grav\Common\Page\Pages;
|
||||
use Grav\Common\Utils;
|
||||
use Grav\Common\Plugin;
|
||||
use Grav\Common\Theme;
|
||||
@@ -201,6 +202,29 @@ class AdminBaseController
|
||||
$this->redirectCode = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends JSON response and terminates the call.
|
||||
*
|
||||
* @param array $response
|
||||
* @param int $code
|
||||
* @return bool
|
||||
*/
|
||||
protected function sendJsonResponse(array $response, $code = 200)
|
||||
{
|
||||
// Make sure nothing extra gets written to the response.
|
||||
while (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
// JSON response.
|
||||
http_response_code($code);
|
||||
header('Content-Type: application/json');
|
||||
header('Cache-Control: no-cache, no-store, must-revalidate');
|
||||
|
||||
echo json_encode($response);
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles ajax upload for files.
|
||||
* Stores in a flash object the temporary file and deals with potential file errors.
|
||||
@@ -227,10 +251,10 @@ class AdminBaseController
|
||||
|
||||
$upload = $this->normalizeFiles($_FILES['data'], $settings->name);
|
||||
|
||||
$filename = trim($upload->file->name);
|
||||
$filename = $upload->file->name;
|
||||
|
||||
// Handle bad filenames.
|
||||
if (strtr($filename, "\t\n\r\0\x0b", '_____') !== $filename || rtrim($filename, '. ') !== $filename || preg_match('|\.php|', $filename)) {
|
||||
if (!Utils::checkFilename($filename)) {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'error',
|
||||
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_UPLOAD', null),
|
||||
@@ -287,6 +311,9 @@ class AdminBaseController
|
||||
$accepted = false;
|
||||
$errors = [];
|
||||
|
||||
// Do not trust mimetype sent by the browser
|
||||
$mime = Utils::getMimeByFilename($upload->file->name);
|
||||
|
||||
foreach ((array)$settings->accept as $type) {
|
||||
// Force acceptance of any file when star notation
|
||||
if ($type === '*') {
|
||||
@@ -295,15 +322,24 @@ class AdminBaseController
|
||||
}
|
||||
|
||||
$isMime = strstr($type, '/');
|
||||
$find = str_replace('*', '.*', $type);
|
||||
$find = str_replace(['.', '*'], ['\.', '.*'], $type);
|
||||
|
||||
$match = preg_match('#' . $find . '$#', $isMime ? $upload->file->type : $upload->file->name);
|
||||
if (!$match) {
|
||||
$message = $isMime ? 'The MIME type "' . $upload->file->type . '"' : 'The File Extension';
|
||||
$errors[] = $message . ' for the file "' . $upload->file->name . '" is not an accepted.';
|
||||
$accepted |= false;
|
||||
if ($isMime) {
|
||||
$match = preg_match('#' . $find . '$#', $mime);
|
||||
if (!$match) {
|
||||
$errors[] = 'The MIME type "' . $mime . '" for the file "' . $upload->file->name . '" is not an accepted.';
|
||||
} else {
|
||||
$accepted = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$accepted |= true;
|
||||
$match = preg_match('#' . $find . '$#', $upload->file->name);
|
||||
if (!$match) {
|
||||
$errors[] = 'The File Extension for the file "' . $upload->file->name . '" is not an accepted.';
|
||||
} else {
|
||||
$accepted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +404,7 @@ class AdminBaseController
|
||||
|
||||
// Generate random name if required
|
||||
if ($settings->random_name) { // TODO: document
|
||||
$extension = pathinfo($upload->file->name)['extension'];
|
||||
$extension = pathinfo($upload->file->name, PATHINFO_EXTENSION);
|
||||
$upload->file->name = Utils::generateRandomString(15) . '.' . $extension;
|
||||
}
|
||||
|
||||
@@ -875,7 +911,29 @@ class AdminBaseController
|
||||
$type = $uri->param('type');
|
||||
$field = $uri->param('field');
|
||||
|
||||
$this->taskRemoveMedia();
|
||||
// Get Blueprint
|
||||
$settings = (object) $this->admin->blueprints($blueprint)->schema()->getProperty($field);
|
||||
|
||||
// Get destination
|
||||
if ($this->grav['locator']->isStream($settings->destination)) {
|
||||
$destination = $this->grav['locator']->findResource($settings->destination, false, true);
|
||||
} else {
|
||||
$destination = Folder::getRelativePath(rtrim($settings->destination, '/'));
|
||||
$destination = $this->admin->getPagePathFromToken($destination);
|
||||
}
|
||||
|
||||
// Not in path
|
||||
if (!Utils::startsWith($path, $destination)) {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'error',
|
||||
'message' => 'Path not valid for this data type'
|
||||
];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only remove files from correct destination...
|
||||
$this->taskRemoveMedia($destination . '/' . basename($path));
|
||||
|
||||
if ($type === 'pages') {
|
||||
$page = $this->admin->page(true, $proute);
|
||||
@@ -892,9 +950,11 @@ class AdminBaseController
|
||||
|
||||
$page->save();
|
||||
} else {
|
||||
|
||||
$blueprint_prefix = $type === 'config' ? '' : $type . '.';
|
||||
$blueprint_name = str_replace(['config/', '/blueprints'], '', $blueprint);
|
||||
$blueprint_field = $blueprint_prefix . $blueprint_name . '.' . $field;
|
||||
|
||||
$files = $this->grav['config']->get($blueprint_field);
|
||||
|
||||
if ($files) {
|
||||
@@ -935,15 +995,17 @@ class AdminBaseController
|
||||
*
|
||||
* @return bool True if the action was performed
|
||||
*/
|
||||
public function taskRemoveMedia()
|
||||
public function taskRemoveMedia($filename = null)
|
||||
{
|
||||
if (!$this->canEditMedia()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$filename = base64_decode($this->grav['uri']->param('route'));
|
||||
if (!$filename) {
|
||||
$filename = base64_decode($this->route);
|
||||
if (is_null($filename)) {
|
||||
$filename = base64_decode($this->grav['uri']->param('route'));
|
||||
if (!$filename) {
|
||||
$filename = base64_decode($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
$file = File::instance($filename);
|
||||
|
||||
@@ -14,6 +14,7 @@ use Grav\Common\Page\Medium\Medium;
|
||||
use Grav\Common\Page\Page;
|
||||
use Grav\Common\Page\Pages;
|
||||
use Grav\Common\Page\Collection;
|
||||
use Grav\Common\Security;
|
||||
use Grav\Common\User\User;
|
||||
use Grav\Common\Utils;
|
||||
use Grav\Common\Backup\ZipBackup;
|
||||
@@ -465,7 +466,7 @@ class AdminController extends AdminBaseController
|
||||
/**
|
||||
* Handles updating Grav
|
||||
*
|
||||
* @return bool True if the action was performed
|
||||
* @return bool False if user has no permissions.
|
||||
*/
|
||||
public function taskUpdategrav()
|
||||
{
|
||||
@@ -478,14 +479,14 @@ class AdminController extends AdminBaseController
|
||||
$result = Gpm::selfupgrade();
|
||||
|
||||
if ($result) {
|
||||
$this->admin->json_response = [
|
||||
$json_response = [
|
||||
'status' => 'success',
|
||||
'type' => 'updategrav',
|
||||
'version' => $version,
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.GRAV_WAS_SUCCESSFULLY_UPDATED_TO') . ' ' . $version
|
||||
];
|
||||
} else {
|
||||
$this->admin->json_response = [
|
||||
$json_response = [
|
||||
'status' => 'error',
|
||||
'type' => 'updategrav',
|
||||
'version' => GRAV_VERSION,
|
||||
@@ -493,7 +494,7 @@ class AdminController extends AdminBaseController
|
||||
];
|
||||
}
|
||||
|
||||
return true;
|
||||
return $this->sendJsonResponse($json_response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -611,6 +612,8 @@ class AdminController extends AdminBaseController
|
||||
$reorder = true;
|
||||
$data = (array)$this->data;
|
||||
|
||||
$this->grav['twig']->twig_vars['current_form_data'] = $data;
|
||||
|
||||
// Special handler for user data.
|
||||
if ($this->view === 'user') {
|
||||
if (!$this->grav['user']->exists()) {
|
||||
@@ -645,13 +648,25 @@ class AdminController extends AdminBaseController
|
||||
// Ensure route is prefixed with a forward slash.
|
||||
$route = '/' . ltrim($route, '/');
|
||||
|
||||
// Check for valid frontmatter
|
||||
if (isset($data['frontmatter']) && !$this->checkValidFrontmatter($data['frontmatter'])) {
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_FRONTMATTER_COULD_NOT_SAVE'),
|
||||
'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// XSS Checks for page content
|
||||
$xss_whitelist = $this->grav['config']->get('security.xss_whitelist', 'admin.super');
|
||||
if (!$this->admin->authorize($xss_whitelist)) {
|
||||
$check_what = ['header' => isset($data['header']) ? $data['header'] : '', 'frontmatter' => isset($data['frontmatter']) ? $data['frontmatter'] : '', 'content' => isset($data['content']) ? $data['content'] : ''];
|
||||
$results = Security::detectXssFromArray($check_what);
|
||||
if (!empty($results)) {
|
||||
$this->admin->setMessage('<i class="fa fa-ban"></i> ' . $this->admin->translate('PLUGIN_ADMIN.XSS_ONSAVE_ISSUE'),
|
||||
'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$parent = $route && $route !== '/' && $route !== '.' && $route !== '/.' ? $pages->dispatch($route, true) : $pages->root();
|
||||
$original_order = (int)trim($obj->order(), '.');
|
||||
@@ -908,11 +923,13 @@ class AdminController extends AdminBaseController
|
||||
} catch (\Exception $e) {
|
||||
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->admin->json_response = ['status' => 'success', 'feed_data' => $feed_data];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -956,12 +973,17 @@ class AdminController extends AdminBaseController
|
||||
];
|
||||
} else {
|
||||
$this->admin->json_response = ['status' => 'error', 'message' => 'Cannot connect to the GPM'];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -979,7 +1001,7 @@ class AdminController extends AdminBaseController
|
||||
//No notifications cache (first time)
|
||||
$this->admin->json_response = ['status' => 'success', 'notifications' => [], 'need_update' => true];
|
||||
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
$need_update = false;
|
||||
@@ -996,7 +1018,7 @@ class AdminController extends AdminBaseController
|
||||
} catch (\Exception $e) {
|
||||
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->admin->json_response = [
|
||||
@@ -1004,6 +1026,8 @@ class AdminController extends AdminBaseController
|
||||
'notifications' => $notifications,
|
||||
'need_update' => $need_update
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1166,8 +1190,8 @@ class AdminController extends AdminBaseController
|
||||
'status' => 'error',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK')
|
||||
];
|
||||
echo json_encode($json_response);
|
||||
exit;
|
||||
|
||||
return $this->sendJsonResponse($json_response, 403);
|
||||
}
|
||||
|
||||
//check if there are packages that have this as a dependency. Abort and show which ones
|
||||
@@ -1182,8 +1206,8 @@ class AdminController extends AdminBaseController
|
||||
}
|
||||
|
||||
$json_response = ['status' => 'error', 'message' => $message];
|
||||
echo json_encode($json_response);
|
||||
exit;
|
||||
|
||||
return $this->sendJsonResponse($json_response, 200);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -1191,8 +1215,8 @@ class AdminController extends AdminBaseController
|
||||
$result = Gpm::uninstall($package, []);
|
||||
} catch (\Exception $e) {
|
||||
$json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
||||
echo json_encode($json_response);
|
||||
exit;
|
||||
|
||||
return $this->sendJsonResponse($json_response, 200);
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
@@ -1201,16 +1225,16 @@ class AdminController extends AdminBaseController
|
||||
'dependencies' => $dependencies,
|
||||
'message' => $this->admin->translate(is_string($result) ? $result : 'PLUGIN_ADMIN.UNINSTALL_SUCCESSFUL')
|
||||
];
|
||||
echo json_encode($json_response);
|
||||
exit;
|
||||
|
||||
return $this->sendJsonResponse($json_response, 200);
|
||||
}
|
||||
|
||||
$json_response = [
|
||||
'status' => 'error',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.UNINSTALL_FAILED')
|
||||
];
|
||||
echo json_encode($json_response);
|
||||
exit;
|
||||
|
||||
return $this->sendJsonResponse($json_response, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1230,8 +1254,8 @@ class AdminController extends AdminBaseController
|
||||
'status' => 'error',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK')
|
||||
];
|
||||
echo json_encode($json_response);
|
||||
exit;
|
||||
|
||||
$this->sendJsonResponse($json_response, 403);
|
||||
}
|
||||
|
||||
$url = "https://getgrav.org/download/{$type}s/$slug/$current_version";
|
||||
@@ -1363,7 +1387,7 @@ class AdminController extends AdminBaseController
|
||||
}
|
||||
|
||||
$download = urlencode(base64_encode($backup));
|
||||
$url = rtrim($this->grav['uri']->rootUrl(true), '/') . '/' . trim($this->admin->base,
|
||||
$url = rtrim($this->grav['uri']->rootUrl(false), '/') . '/' . trim($this->admin->base,
|
||||
'/') . '/task' . $param_sep . 'backup/download' . $param_sep . $download . '/admin-nonce' . $param_sep . Utils::getNonce('admin-form');
|
||||
|
||||
$log->content([
|
||||
@@ -1670,6 +1694,19 @@ class AdminController extends AdminBaseController
|
||||
return false;
|
||||
}
|
||||
|
||||
$filename = $_FILES['file']['name'];
|
||||
|
||||
// Handle bad filenames.
|
||||
if (!Utils::checkFilename($filename)) {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'error',
|
||||
'message' => sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_UPLOAD'),
|
||||
$filename, 'Bad filename')
|
||||
];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$grav_limit = $config->get('system.media.upload_limit', 0);
|
||||
// You should also check filesize here.
|
||||
if ($grav_limit > 0 && $_FILES['file']['size'] > $grav_limit) {
|
||||
@@ -1683,18 +1720,13 @@ class AdminController extends AdminBaseController
|
||||
|
||||
|
||||
// Check extension
|
||||
$fileParts = pathinfo($_FILES['file']['name']);
|
||||
|
||||
$fileExt = '';
|
||||
if (isset($fileParts['extension'])) {
|
||||
$fileExt = strtolower($fileParts['extension']);
|
||||
}
|
||||
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
// If not a supported type, return
|
||||
if (!$fileExt || !$config->get("media.types.{$fileExt}")) {
|
||||
if (!$extension || !$config->get("media.types.{$extension}")) {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'error',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.UNSUPPORTED_FILE_TYPE') . ': ' . $fileExt
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.UNSUPPORTED_FILE_TYPE') . ': ' . $extension
|
||||
];
|
||||
|
||||
return false;
|
||||
@@ -1720,7 +1752,7 @@ class AdminController extends AdminBaseController
|
||||
|
||||
// Upload it
|
||||
if (!move_uploaded_file($_FILES['file']['tmp_name'],
|
||||
sprintf('%s/%s', $path, $_FILES['file']['name']))
|
||||
sprintf('%s/%s', $path, $filename))
|
||||
) {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'error',
|
||||
@@ -1732,13 +1764,12 @@ class AdminController extends AdminBaseController
|
||||
|
||||
// Add metadata if needed
|
||||
$include_metadata = Grav::instance()['config']->get('system.media.auto_metadata_exif', false);
|
||||
$filename = $fileParts['basename'];
|
||||
$filename = str_replace(['@3x', '@2x'], '', $filename);
|
||||
$basename = str_replace(['@3x', '@2x'], '', pathinfo($filename, PATHINFO_BASENAME));
|
||||
|
||||
$metadata = [];
|
||||
|
||||
if ($include_metadata && isset($media[$filename])) {
|
||||
$img_metadata = $media[$filename]->metadata();
|
||||
if ($include_metadata && isset($media[$basename])) {
|
||||
$img_metadata = $media[$basename]->metadata();
|
||||
if ($img_metadata) {
|
||||
$metadata = $img_metadata;
|
||||
}
|
||||
@@ -1781,6 +1812,11 @@ class AdminController extends AdminBaseController
|
||||
|
||||
$filename = !empty($this->post['filename']) ? $this->post['filename'] : null;
|
||||
|
||||
// Handle bad filenames.
|
||||
if (!Utils::checkFilename($filename)) {
|
||||
$filename = null;
|
||||
}
|
||||
|
||||
if (!$filename) {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'error',
|
||||
@@ -1869,7 +1905,7 @@ class AdminController extends AdminBaseController
|
||||
protected function taskProcessMarkdown()
|
||||
{
|
||||
if (!$this->authorizeTask('process markdown', ['admin.pages', 'admin.super'])) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -2224,6 +2260,8 @@ class AdminController extends AdminBaseController
|
||||
|
||||
$admin_route = $this->admin->base;
|
||||
$this->setRedirect('/' . $language . $admin_route . '/' . $redirect);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2259,6 +2297,16 @@ class AdminController extends AdminBaseController
|
||||
}
|
||||
|
||||
$file_path = $_FILES['uploaded_file']['tmp_name'];
|
||||
|
||||
// Handle bad filenames.
|
||||
if (!Utils::checkFilename(basename($file_path))) {
|
||||
$this->admin->json_response = [
|
||||
'status' => 'error',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.UNKNOWN_ERRORS')
|
||||
];
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2313,9 +2361,10 @@ class AdminController extends AdminBaseController
|
||||
$aPage->template($obj->template());
|
||||
$aPage->validate();
|
||||
$aPage->filter();
|
||||
$aPage->save();
|
||||
|
||||
$this->grav->fireEvent('onAdminAfterSave', new Event(['page' => $obj]));
|
||||
$this->grav->fireEvent('onAdminSave', new Event(['page' => &$aPage]));
|
||||
$aPage->save();
|
||||
$this->grav->fireEvent('onAdminAfterSave', new Event(['page' => $aPage]));
|
||||
}
|
||||
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.SUCCESSFULLY_SWITCHED_LANGUAGE'), 'info');
|
||||
|
||||
Reference in New Issue
Block a user