core/api/modules/page_edit/index.php

101 lines
3.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
ini_set('display_errors', 0 );
$mod_settings2=\core::setSettingsMod($_GET['mod']);
$smarty -> assign( 'mainImgW', $mod_settings2['main-img-w'] );
$smarty -> assign( 'mainImgH', $mod_settings2['main-img-h'] );
/*
if ($db['type']=='mysql'){
\DB::set("CREATE TABLE IF NOT EXISTS `pages_img` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pages_id` int(10) NOT NULL,
`filename` varchar(30) NOT NULL,
PRIMARY KEY (`id`),
KEY `pages_id` (`pages_id`),
CONSTRAINT `pages_img_ibfk_1` FOREIGN KEY (`pages_id`) REFERENCES `pages` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
}else{
}
*/
if ( $_SESSION['dostup'] !=='a' && $_SESSION['dostup'] !== 'e' ) header( 'Location: /login/' );
$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>');
if ($_GET['id']){
$_SESSION['page_id']=$_GET['id'];
$page=\DB::getAll("SELECT * FROM `pages` WHERE `id`=? LIMIT 1", $_GET['id']);
$smarty -> assign( 'page', $page );
$img=\DB::getAll("SELECT * FROM `pages_img` WHERE `page_id`=?", $_GET['id']);
$smarty -> assign( 'img', $img );
}
/* ----------------------------------------------------------------------
14.12.2022
Получаем инфу о пользователе
---------------------------------------------------------------------- */
$smarty -> assign( 'userInfo', \core::getUserInfo( $_SESSION['user_id'] ) );
/* ----------------------------------------------------------------------
07.01.20223
Получаем список категорий
---------------------------------------------------------------------- */
$smarty -> assign( 'pages_category', \DB::getAll("SELECT * FROM `pages_category` WHERE `status`=1" ) );
if ($_POST){
/* ----------------------------------------------------------------------
07.01.20223
Принимаем входящие данные
---------------------------------------------------------------------- */
if ($_GET['id']){
\DB::set("UPDATE `pages` SET
`title`=?, `txt`=?, `t`=?, `keywords`=?, `alias`=?, `description`=?, `category`=?, `user_id`=?, `d`=? WHERE `id`=?", array(
$_POST['title'], $_POST['txt'], time(), $_POST['keywords'], $_POST['alias'], $_POST['description'], $_POST['category'], $_SESSION['user_id'], $_POST['d'], $_GET['id']
) );
$id=$_GET['id'];
}else{
$id=\DB::add("INSERT INTO `pages` (`title`, `txt`, `t`, `keywords`, `alias`, `description`, `category`, `user_id`, `d`, `status`) VALUES (?,?,?,?,?,?,?,?,?,1)", array(
$_POST['title'], $_POST['txt'],
time(), $_POST['keywords'],
$_POST['alias'], $_POST['description'], $_POST['category'], $_SESSION['user_id'], $_POST['d']
) );
}
header( 'Location: /page_edit/' . $id );
}
/* ----------------------------------------------------------------------
02.04.20223
Получаем список картинок
---------------------------------------------------------------------- */
if ($_GET['id']){
$img_list=\DB::getAll("SELECT * FROM `pages_img` WHERE `pages_id`=?", $_GET['id']);
$smarty -> assign( 'img_list', $img_list );
}
?>