core/api/modules/portfolio/index.php

82 lines
3.0 KiB
PHP
Executable File
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
/*
26.05.2017
Добавлена загрузка обложки
27.07.2017
Урезан код за счет удаления открытых SQL-запросов, все перенесено в апи
20.11.2017
Работа с ЧПУ - изменение данных
*/
$_SESSION['page_id']=ID;
$mod = new main(BD_NAME, BD_TYPE, BD_HOST, BD_USER, BD_PWD, MOD);
if ( $_SESSION['dostup'] !=='a' && $_SESSION['dostup'] !== 'e' ) header( 'Location: /403/' );
if (ID){
$page = $mod -> get_page ( ID );
$smarty -> assign( 'page', $page );
//проверяем доступ
if ( $_SESSION['dostup']=='e' ){
$access = 0;
if ( $_SESSION['user_id'] == $page[0]['user_id']) $access = 1;
if ( $access == 0 ) header( 'Location: /403/' );
}
}
unset($a);
//загружаем обложку
if ( @$_FILES['oblozhka']['tmp_name'] ) $_POST['img'] = $mod -> upload_main_img( $_FILES );
if ($_POST){
function ekr ($text) {
$old1 = array("'");
$new1 = array("&apos;");
$text = str_replace($old1, $new1, $text);
return $text;
}
$res['tip']='page';
$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: /page_all/' );
}
//выбираем редактор:
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';
$smarty -> assign( 'list', $db -> get_massiv ( 'pages', $a ) );
$smarty -> assign( 'img', $mod -> get_images ( ID ) );
$smarty -> assign( 'modal_settings', MYDIR . '/api/modules/' . MOD . '/modal.html' );
//загружаем список картинок
unset($a);
$a['page_id']=ID;
?>