63 lines
3.4 KiB
PHP
Executable File
63 lines
3.4 KiB
PHP
Executable File
<?php
|
||
|
||
ini_set('display_errors', 0);
|
||
|
||
if ($_SESSION['dostup'] !== 'a' && $_SESSION['dostup'] !== 'e') header('Location: /login/');
|
||
$_SESSION['id']=$_GET['id'];
|
||
$smarty->assign('editor', 'api/modules/page_edit/editor.html');
|
||
$smarty->assign('editor_js', '<script language="javascript" type="text/javascript" src="/api/soft/tinymce/4.3.12/tinymce.min.js"></script><script language="javascript" type="text/javascript" src="/api/soft/tinymce/4.3.12/load.php"></script>');
|
||
/* ----------------------------------------------------------------------
|
||
14.12.2022
|
||
Получаем инфу о пользователе
|
||
---------------------------------------------------------------------- */
|
||
$smarty->assign('userInfo', \core::getUserInfo($_SESSION['user_id']));
|
||
/* ----------------------------------------------------------------------
|
||
07.01.20223
|
||
Получаем список категорий
|
||
---------------------------------------------------------------------- */
|
||
$smarty->assign('pages_category', \DB::getAll("SELECT * FROM `content_category` WHERE `status`=1 AND `content_type`=? AND `site`=? ORDER BY `title`", ['page', $_SERVER['SERVER_NAME']]));
|
||
if (@$_POST) {
|
||
/* ----------------------------------------------------------------------
|
||
07.01.20223
|
||
Принимаем входящие данные
|
||
---------------------------------------------------------------------- */
|
||
$massiv['keywords']=$_POST['keywords'];
|
||
$massiv['description']=$_POST['description'];
|
||
$massiv['alias']=$_POST['alias'];
|
||
$massiv['d']=$_POST['d'];
|
||
$massiv['reyt']=0;
|
||
$massiv['comments']=1;
|
||
$massiv['socbtn']=1;
|
||
$status=($_POST['status']=='on')?1:0;
|
||
$json=\core::j($massiv);
|
||
switch (@$_POST['act']) {
|
||
case 'save':
|
||
\DB::set("UPDATE `content` SET `title`=?, `txt`=?, `status`=?, `category`=?, `site`=?, `json`=?, `content_type`=?, `time`=?, `user_id`=? WHERE `id`=?",
|
||
[$_POST['title'], $_POST['txt'], $status, $_POST['category'], $_SERVER['SERVER_NAME'], $json, 'page', time(), $_SESSION['user_id'], $_GET['id']]);
|
||
break;
|
||
case 'new':
|
||
$id = \DB::add("INSERT INTO `content` (`title`, `txt`, `status`, `category`, `site`, `json`, `content_type`, `time`,`user_id`) VALUES (
|
||
?,?,?,?,?,?,?,?,?)", [$_POST['title'], $_POST['txt'], $status, $_POST['category'], $_SERVER['SERVER_NAME'], $json, 'page', time(), $_SESSION['user_id']]
|
||
);
|
||
header('Location: /page_edit/' . $id);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
/* ----------------------------------------------------------------------
|
||
02.04.20223
|
||
Получаем список картинок
|
||
---------------------------------------------------------------------- */
|
||
if ($_GET['id']) {
|
||
$content=\DB::getRow("SELECT * FROM `content` WHERE `id`=? AND `site`=? LIMIT 1", [$_GET['id'], $_SERVER['SERVER_NAME']]);
|
||
$page=$content;
|
||
$j=\core::j($content['json']);
|
||
$smarty->assign('page', $page);
|
||
$smarty->assign('j', $j);
|
||
$img = \DB::getAll("SELECT * FROM `img` WHERE `content_id`=? AND `content_type`='page' AND `site`=?", [$_GET['id'], $_SERVER['SERVER_NAME']]);
|
||
for ($i=0;$i<count($img);$i++)
|
||
$img[$i]['uses']=\DB::getValue("SELECT `id` FROM `pages` WHERE `txt` LIKE '%" . $img[$i]['filename'] . "%' LIMIT 1");
|
||
$smarty->assign('img', $img);
|
||
}
|
||
?>
|