124 lines
4.7 KiB
PHP
124 lines
4.7 KiB
PHP
<?php
|
|
|
|
$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>');
|
|
|
|
$page=\DB::getAll("SELECT * FROM `pages` WHERE `id`=? LIMIT 1", $_GET['id']);
|
|
if ($_GET['id']) $smarty -> assign( 'page', $page );
|
|
|
|
|
|
$dostup = 0;
|
|
if ( $_SESSION['dostup']=='a' ) $dostup = 1;
|
|
if ($page[0]['user_id']){
|
|
if ( $_SESSION['user_id'] == $page[0]['user_id']) $dostup = 1;
|
|
}else{
|
|
if ($_SESSION['dostup']=='u')$dostup=1;
|
|
}
|
|
if ($dostup==0)header( 'Location: /403/' );
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
07.01.20223
|
|
Получаем список категорий
|
|
---------------------------------------------------------------------- */
|
|
|
|
$smarty -> assign( 'pages_category', \DB::getAll("SELECT * FROM `pages_category` WHERE `status`=1" ) );
|
|
|
|
|
|
unset($a);
|
|
|
|
|
|
|
|
|
|
if ($_POST){
|
|
/* ----------------------------------------------------------------------
|
|
07.01.20223
|
|
Принимаем входящие данные
|
|
---------------------------------------------------------------------- */
|
|
if ($_GET['id']){
|
|
\DB::set("UPDATE `pages` SET `title`=?, `txt`=?, `t`=?, `category`=? WHERE `id`=?", array($_POST['title'], $_POST['txt'], time(), $_POST['category'], $_GET['id'] ) );
|
|
$id=$_GET['id'];
|
|
}else{
|
|
$id=\DB::add("INSERT INTO `pages` (`title`, `txt`, `t`, `category`, `user_id`, `status`) VALUES (?,?,?,?,?,1)", array($_POST['title'], $_POST['txt'], time(), $_POST['category'], $_SESSION['user_id']) );
|
|
}
|
|
header( 'Location: /page/' . $id );
|
|
}
|
|
/*
|
|
//проверяем авторизацию
|
|
if ( $_SESSION['dostup'] !=='a' ) header( 'Location: /403/' );
|
|
|
|
|
|
//загружаем обложку
|
|
if (@$_FILES['oblozhka']['tmp_name']){
|
|
if ( preg_match( '/[.](jpg)|(jpeg)|(JPG)|(JPEG)$/', $_FILES['oblozhka']['name'] ) ) {
|
|
require_once MYDIR . '/api/php/genpass.php';
|
|
$src = $_FILES['oblozhka']['tmp_name'];
|
|
$f1 = generate_password(30);
|
|
$original=MYDIR . '/img/pages/' . $f1 . '.jpg';
|
|
@mkdir(MYDIR . '/img/pages/', 0700);
|
|
copy( $src, $original );
|
|
// из оригинала создаем обложку
|
|
require_once MYDIR . '/api/php/img2.php';
|
|
$obl=MYDIR . '/img/pages/' . $f1 . '_obl.jpg';
|
|
rimg($original, 900, 300, $obl, 95);
|
|
// из оригинала создаем превью
|
|
require_once MYDIR . '/api/php/img2.php';
|
|
$obl_prw=MYDIR . '/img/pages/' . $f1 . '_obl_prw.jpg';
|
|
rimg($original, 400, 400, $obl_prw, 95);
|
|
$_POST['oblozhka']=$f1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($_POST){
|
|
|
|
function ekr ($text) {
|
|
$old1 = array("'");
|
|
$new1 = array("'");
|
|
$text = str_replace($old1, $new1, $text);
|
|
return $text;
|
|
}
|
|
|
|
$res['tip']='blog';
|
|
$res['user_id']=$_SESSION['user_id'];
|
|
$res['public']=$_POST['public'];
|
|
$res['parent']=$_POST['parent'];
|
|
$res['t']=time();
|
|
$res['alias']=$_POST['alias'];
|
|
$res['txt']=ekr($_POST['txt']);
|
|
unset($_POST['parent']);
|
|
unset($_POST['public']);
|
|
unset($_POST['alias']);
|
|
unset($_POST['txt']);
|
|
unset($_POST['ok']);
|
|
$res['json']=json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
|
|
|
if (ID)
|
|
$db->update('pages', $res);
|
|
else
|
|
$db->add('pages', $res);
|
|
header( 'Location: /' );
|
|
}
|
|
|
|
//выбираем редактор:
|
|
switch ( $mod_settings['editor'] ) {
|
|
case '1':
|
|
$smarty -> assign( 'editor', '<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>');
|
|
break;
|
|
case '2':
|
|
$smarty -> assign( 'editor', '<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>');
|
|
break;
|
|
default:
|
|
$smarty -> assign( 'editor', '<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>');
|
|
}
|
|
/* выбираем категорию */
|
|
/*unset($a);
|
|
$a['tip']='category';
|
|
//$list_cat=$db -> get_massiv ( 'pages', $a );
|
|
|
|
$smarty -> assign( 'list', $db -> get_massiv ( 'pages', $a ) );
|
|
//загружаем список картинок
|
|
unset($a);
|
|
$a['page_id']=ID;
|
|
//$smarty -> assign( 'img', $db -> get_massiv ( 'img', $a) );*/
|
|
?>
|