<?php require '../../app/start.php'; if (!empty($_POST)) { $notifications = validate($_POST, ['title' => 'length-min:3|length-max:30']); if (count($notifications) > 0) { $_SESSION['notifications'] = $notifications; header('Location: ' . $_SERVER['HTTP_REFERER']); die; } $sql = "INSERT INTO pages (title, slug, meta_title, meta_description, content)\n\t\t\tVALUES (:title, :slug, :meta_title, :meta_description, :content)"; $insertPage = $db->prepare($sql); $insertPage->execute(['title' => $_POST['title'], 'slug' => !empty($_POST['slug']) ? $_POST['slug'] : latinize($_POST['title']), 'meta_title' => $_POST['meta_title'], 'meta_description' => $_POST['meta_description'], 'content' => $_POST['content']]); header('Location: ' . BASE_URL . '/admin/pages/index.php'); } $scripts = ['tinymce.php']; require VIEW_ROOT . '/admin/pages/add.php';
<?php require '../../app/start.php'; if (!empty($_POST)) { $id = $_POST['id']; $sort_id = $_POST['sort_id']; $title = $_POST['title']; $slug = latinize($title); $sql = 'UPDATE section SET sort_id = :sort_id, slug = :slug, title = :title WHERE id = :id'; $updateSection = $db->prepare($sql); $updateSection->execute(['id' => $id, 'sort_id' => $sort_id, 'slug' => $slug, 'title' => $title]); header('Location: ' . BASE_URL . '/admin/section/index.php'); } if (!isset($_GET['id'])) { header('Location: ' . BASE_URL . '/admin/section/index.php'); die; } $sql = 'SELECT id, sort_id, slug, title FROM section WHERE id = :id'; $section = $db->prepare($sql); $section->execute(['id' => $_GET['id']]); $section = $section->fetch(PDO::FETCH_ASSOC); require VIEW_ROOT . '/admin/section/edit.php';
require '../../app/start.php'; if (!empty($_POST)) { $notifications = validate($_POST, ['title' => 'length-min:3|length-max:30']); if (count($notifications) > 0) { $_SESSION['notifications'] = $notifications; header('Location: ' . $_SERVER['HTTP_REFERER']); die; } $sql = 'UPDATE pages SET slug = :slug, title = :title, meta_title = :meta_title, meta_description = :meta_description, content = :content WHERE id = :id'; $updatePage = $db->prepare($sql); $updatePage->execute(['id' => (int) $_POST['id'], 'title' => $_POST['title'], 'slug' => !empty($_POST['slug']) ? $_POST['slug'] : latinize($_POST['title']), 'meta_title' => $_POST['meta_title'], 'meta_description' => $_POST['meta_description'], 'content' => $_POST['content']]); header('Location: ' . BASE_URL . '/admin/pages/index.php'); } if (!isset($_GET['id'])) { header('Location: ' . BASE_URL . '/admin/pages/index.php'); die; } $sql = 'SELECT id, slug, title, meta_title, meta_description, content FROM pages WHERE id = :id'; $page = $db->prepare($sql); $page->execute(['id' => $_GET['id']]); $page = $page->fetch(PDO::FETCH_ASSOC); $scripts = ['tinymce.php']; require VIEW_ROOT . '/admin/pages/edit.php';
/** * Converts the text into a valid url slug. Removes accents from Latin characters * * @param string $string * * @return string * @author Aurimas Niekis <*****@*****.**> */ function slugify($string) { $string = latinize($string); $string = preg_replace('~[^\\pL\\d]+~u', '-', $string); $string = trim($string, '-'); $string = strtolower($string); return preg_replace('~[^-\\w]+~', '', $string); }
if (in_array($file_ext, $allowed)) { $random_name = $i . '-' . time() . '.' . $file_ext; // Create preview image if ($n == 0) { $n++; $image = 'preview-' . $random_name; image_resize($file_width, $file_height, 252, 252, $file_type, $file_tmp, $dir_uploads, $image); } // Create mini images image_resize($file_width, $file_height, 70, 70, $file_type, $file_tmp, $dir_uploads, 'mini-' . $random_name); // Create presentaion images image_resize($file_width, $file_height, 540, 540, $file_type, $file_tmp, $dir_uploads, 'present-' . $random_name); // Upload origianl images move_uploaded_file($file_tmp, $dir_uploads . '/original-' . $random_name); $images[$i]['image'] = 'present-' . $random_name; $images[$i]['mini_image'] = 'mini-' . $random_name; $images[$i]['original_image'] = 'original-' . $random_name; } } } } $sql = "INSERT INTO products (title, slug, image, images, `path`, category_id, company, count, price, description, characteristic, status)\n VALUES (:title, :slug, :image, :images, :path, :category_id, :company, :count, :price, :description, :characteristic, :status)"; $insertProduct = $db->prepare($sql); $insertProduct->execute(['title' => $_POST['title'], 'slug' => latinize($_POST['title']), 'image' => $image, 'images' => serialize($images), 'path' => $dir_images, 'category_id' => (int) $_POST['category_id'], 'company' => $_POST['company'], 'count' => (int) $_POST['count'], 'price' => (int) $_POST['price'], 'description' => $_POST['description'], 'characteristic' => $_POST['characteristic'], 'status' => (int) $_POST['status']]); header('Location: ' . BASE_URL . '/admin/products/index.php'); } $sql = 'SELECT id, slug, title FROM section'; $section = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC); $scripts = ['tinymce.php']; require VIEW_ROOT . '/admin/products/add.php';
die; } $sql = 'UPDATE products SET sort_id = :sort_id, category_id = :category_id, title = :title, slug = :slug, company = :company, count = :count, price = :price, description = :description, characteristic = :characteristic, status = :status WHERE id = :id'; $updateProduct = $db->prepare($sql); $updateProduct->execute(['id' => (int) $_POST['id'], 'sort_id' => (int) $_POST['sort_id'], 'category_id' => (int) $_POST['category_id'], 'title' => $_POST['title'], 'slug' => latinize($_POST['title']), 'company' => $_POST['company'], 'count' => (int) $_POST['count'], 'price' => (int) $_POST['price'], 'description' => $_POST['description'], 'characteristic' => $_POST['characteristic'], 'status' => (int) $_POST['status']]); header('Location: ' . BASE_URL . '/admin/products/index.php'); } if (!isset($_GET['id'])) { header('Location: ' . BASE_URL . '/admin/products/index.php'); die; } $sql = 'SELECT id, sort_id, category_id, slug, title, image, images, path, company, count, price, description, characteristic, status FROM products WHERE id = :id'; $product = $db->prepare($sql); $product->execute(['id' => $_GET['id']]); $product = $product->fetch(PDO::FETCH_ASSOC); $sql = 'SELECT id, slug, title FROM categories'; $categories = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC);