core/api/modules/page_edit/ajax.php

75 lines
2.3 KiB
PHP
Raw Normal View History

2022-12-11 13:55:49 +05:00
<?php
2023-01-25 14:20:32 +05:00
ini_set( 'display_errors', 1 );
2022-12-11 13:55:49 +05:00
switch(@$_POST['act']) {
2023-08-14 09:15:58 +05:00
2023-08-28 22:47:07 +05:00
case 'enable-comments':
\DB::set("UPDATE `pages` SET `" . $_POST['pole'] . "`=? WHERE `id`=?", array($_POST['val'], $_POST['id']));
break;
2023-08-14 09:15:58 +05:00
case 'save-text':
if (@$_POST['act'] == 'save') {
\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']
));
} 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);
}
break;
2022-12-11 13:55:49 +05:00
case 'foto_upload':
2023-08-28 22:47:07 +05:00
upload_img('pages', $_SESSION['id'], 0)
2022-12-11 13:55:49 +05:00
break;
2023-04-09 19:52:26 +05:00
case 'save-settings':
$json=\json::to_j($_POST);
$id=\DB::getValue("SELECT `id` FROM `settings` WHERE `mod`='page_edit' LIMIT 1");
if ($id)
\DB::set("UPDATE `settings` SET `json` =? WHERE `mod`='page_edit' LIMIT 1", $json);
else
\DB::add("INSERT INTO `settings` (`mod`, `json`) VALUES (?, ?)", array('page_edit', $json));
break;
2023-01-25 14:20:32 +05:00
/*
2022-12-11 13:55:49 +05:00
case 'update_settings':
unset($_POST['act']);
$db->update_settings($_POST);
break;
case 'upload_main_img':
//echo 'uploader';
$settings_mod = $db -> get_settings_json($_POST['mod']);
unset($_POST['act']);
$tmp_name = $db -> upload_img( $_FILES, 'pages', 'main_img');
$db -> resize_img($tmp_name, $settings_mod['w'], $settings_mod['h'], 80, false, 'pages');
$db -> resize_img($tmp_name, $settings_mod['p_w'], $settings_mod['p_h'], 80, true, 'pages');
unset($a);
$a['id']=$_POST['id'];
$json=$db->get_val('pages', $a, 'json');
$massiv=$db->from_j($db-> clear_json($json));
$massiv['main_img']=$tmp_name;
$json=$db->to_j($massiv);
$db->free_sql( "UPDATE `pages` SET `json` = '" . $json . "' WHERE `id` = " . $_POST['id'] );
echo $tmp_name;
break;
2023-01-25 14:20:32 +05:00
*/
2022-12-11 13:55:49 +05:00
default:
}
?>