2015-05-05 03:00:01 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2016-01-08 00:43:09 +01:00
|
|
|
// ============================================================================
|
|
|
|
// Check role
|
|
|
|
// ============================================================================
|
|
|
|
|
2019-05-13 18:26:35 +02:00
|
|
|
if (checkRole(array('author'), false)) {
|
2018-07-17 23:58:01 +02:00
|
|
|
try {
|
|
|
|
$pageKey = isset($_POST['key']) ? $_POST['key'] : $layout['parameters'];
|
2018-08-02 17:06:53 +02:00
|
|
|
$page = new Page($pageKey);
|
2018-07-17 23:58:01 +02:00
|
|
|
} catch (Exception $e) {
|
2018-08-05 17:54:20 +02:00
|
|
|
Alert::set($L->g('You do not have sufficient permissions'));
|
2018-07-17 23:58:01 +02:00
|
|
|
Redirect::page('dashboard');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($page->username()!==$login->username()) {
|
|
|
|
// Add to syslog
|
2018-06-10 13:54:55 +02:00
|
|
|
$syslog->add(array(
|
2018-08-18 16:15:38 +02:00
|
|
|
'dictionaryKey'=>'access-denied',
|
2018-07-14 15:17:06 +02:00
|
|
|
'notes'=>$login->username()
|
2018-05-20 21:48:43 +02:00
|
|
|
));
|
2018-07-17 23:58:01 +02:00
|
|
|
|
2018-08-05 17:54:20 +02:00
|
|
|
Alert::set($L->g('You do not have sufficient permissions'));
|
2018-05-20 21:48:43 +02:00
|
|
|
Redirect::page('dashboard');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-05 03:00:01 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Functions
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-08-03 02:49:12 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Main before POST
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-05-05 03:00:01 +02:00
|
|
|
// ============================================================================
|
|
|
|
// POST Method
|
|
|
|
// ============================================================================
|
|
|
|
|
2017-09-10 23:09:44 +02:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
2018-07-17 23:58:01 +02:00
|
|
|
if ($_POST['type']==='delete') {
|
2018-07-10 18:37:46 +02:00
|
|
|
if (deletePage($_POST['key'])) {
|
2018-08-05 17:54:20 +02:00
|
|
|
Alert::set( $L->g('The changes have been saved') );
|
2017-06-23 00:41:00 +02:00
|
|
|
}
|
2018-07-10 18:37:46 +02:00
|
|
|
} else {
|
2018-07-13 18:30:42 +02:00
|
|
|
// If the checkbox is not selected the form doesn't send the field
|
|
|
|
$_POST['noindex'] = isset($_POST['noindex'])?true:false;
|
|
|
|
$_POST['nofollow'] = isset($_POST['nofollow'])?true:false;
|
|
|
|
$_POST['noarchive'] = isset($_POST['noarchive'])?true:false;
|
|
|
|
|
2017-06-23 00:41:00 +02:00
|
|
|
$key = editPage($_POST);
|
2018-07-10 18:37:46 +02:00
|
|
|
if ($key!==false) {
|
2018-08-05 17:54:20 +02:00
|
|
|
Alert::set( $L->g('The changes have been saved') );
|
2017-10-02 22:42:18 +02:00
|
|
|
Redirect::page('edit-content/'.$key);
|
2017-06-23 00:41:00 +02:00
|
|
|
}
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
2017-06-23 00:41:00 +02:00
|
|
|
|
2017-10-02 22:42:18 +02:00
|
|
|
Redirect::page('content');
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
2015-08-03 02:49:12 +02:00
|
|
|
// Main after POST
|
2015-05-05 03:00:01 +02:00
|
|
|
// ============================================================================
|
2018-07-17 19:13:01 +02:00
|
|
|
try {
|
|
|
|
$pageKey = $layout['parameters'];
|
2018-08-02 17:06:53 +02:00
|
|
|
$page = new Page($pageKey);
|
2018-07-17 19:13:01 +02:00
|
|
|
} catch (Exception $e) {
|
|
|
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$pageKey, LOG_TYPE_ERROR);
|
2017-10-02 22:42:18 +02:00
|
|
|
Redirect::page('content');
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 23:10:46 +02:00
|
|
|
// Images prefix directory
|
|
|
|
define('PAGE_IMAGES_KEY', $page->uuid());
|
|
|
|
|
|
|
|
// Images and thubmnails directories
|
|
|
|
if (IMAGE_RESTRICT) {
|
|
|
|
define('PAGE_IMAGES_DIRECTORY', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : HTML_PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/'));
|
|
|
|
define('PAGE_IMAGES_URL', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : DOMAIN_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/'));
|
|
|
|
define('PAGE_THUMBNAILS_DIRECTORY', PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.DS.'thumbnails'.DS);
|
|
|
|
define('PAGE_THUMBNAILS_HTML', HTML_PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/thumbnails/');
|
|
|
|
define('PAGE_THUMBNAILS_URL', DOMAIN_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/thumbnails/');
|
|
|
|
} else {
|
|
|
|
define('PAGE_IMAGES_DIRECTORY', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : HTML_PATH_UPLOADS));
|
|
|
|
define('PAGE_IMAGES_URL', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : DOMAIN_UPLOADS));
|
|
|
|
define('PAGE_THUMBNAILS_DIRECTORY', PATH_UPLOADS_THUMBNAILS);
|
|
|
|
define('PAGE_THUMBNAILS_HTML', HTML_PATH_UPLOADS_THUMBNAILS);
|
|
|
|
define('PAGE_THUMBNAILS_URL', DOMAIN_UPLOADS_THUMBNAILS);
|
|
|
|
}
|
|
|
|
|
2017-09-09 00:33:14 +02:00
|
|
|
// Title of the page
|
2018-08-05 17:54:20 +02:00
|
|
|
$layout['title'] .= ' - '.$L->g('Edit content').' - '.$page->title();
|