Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once($_SERVER['DOCUMENT_ROOT'] . '/Phenya/helpers.inc.php');
- if (file_exists(dirname(__DIR__) . '/Private/define_root_path.php'))
- include_once(dirname(__DIR__) .'/Private/define_root_path.php'); //объявляем путь к корню сайта (в файловой системе)
- else {
- echo 'Error: cannot define path to root: ' . dirname(__DIR__) . '/Private/define_root_path.php';
- exit();
- }
- include_once(DOC_ROOT . '/Phenya/helpers.inc.php');
- session_true_start();
- //подключаемся к БД
- $config = parse_ini_file(DOC_ROOT . '/ini/config_phenya.ini');
- include DOC_ROOT . '/includes/db.inc.php';
- if (isset($_POST['textarea'])) {
- $_SESSION['textarea'] = $_POST['textarea'];
- if (isset($_POST['select'])) {
- $_SESSION['select'] = $_POST['select'];
- }
- header('Location: ' . $_SERVER['PHP_SELF'], true, 303);
- exit();
- }
- if (isset($_SESSION['textarea'])) {
- $quote_text = $mysqli->real_escape_string($_SESSION['textarea']);
- $sql = "INSERT INTO `quotes` SET
- `quote`='$quote_text'";
- if (!$mysqli->query($sql))
- {
- $error = 'Error inserting quote: ' . $mysqli->error;
- include DOC_ROOT . '/error.html.php';
- exit();
- }
- if (isset($_SESSION['select'])) {
- $select = $_SESSION['select'];
- $quote_id = $mysqli->insert_id;
- $sql = "SELECT `id` FROM `categories`
- WHERE `name`='$select' LIMIT 1";
- if ($result = $mysqli->query($sql))
- {
- $category_id= mysqli_fetch_row($result)[0];
- mysqli_free_result($result);
- }
- else {
- $error = 'Error selecting quote category id: ' . $mysqli->error;
- include DOC_ROOT . '/error.html.php';
- exit();
- }
- $sql = "INSERT INTO `quote_category` SET
- `quote_id`=$quote_id,
- `category_id`=$category_id";
- if (!$mysqli->query($sql))
- {
- $error = 'Error inserting quote-category record: ' . $mysqli->error;
- include DOC_ROOT . '/error.html.php';
- exit();
- }
- }
- $_SESSION['output'] = 'Успешно добавили цитату.';
- header('Location: ' . "/Phenya/Admin/tpl_main.php",true,303);
- exit;
- }
- if (isset($_POST['pswd'])) {
- include DOC_ROOT . '/Phenya/Admin/pswd_check.php';
- header('Location: ' . "/Phenya/Admin/tpl_main.php",true,303);
- exit;
- }
- if (isset($_POST['back'])) {
- header('Location: ' . "/Phenya/",true,303);
- exit;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement