$items = itemList(items); if (isset($_GET[id])) { $id = abs(clrInt($_GET[id])); delItem('items', $id); header('Location: admin.php'); } if (isset($_GET[order_id])) { $id = clrStr($_GET[order_id]); delItem('orders', $id); header('Location: admin.php'); } if ($_SERVER[REQUEST_METHOD] == "POST") { $name = clrStr($_POST['name']); $price = clrInt($_POST['price']); $photo = $_FILES['f']['name']; $quantity = clrInt($_POST['quantity']); $tmp_name = $_FILES['f']['tmp_name']; if (getItem($name, $price, $photo, $quantity)) { if (move_uploaded_file($tmp_name, "{$upload_dir}/{$photo}")) { header('Location: admin.php'); echo "Товар успешно добавлен!</br>"; } } else { echo "произошла ошибка!"; } } ?> <!DOCTYPE html> <html> <head> <title>Админка сайта</title>
<?php include "lib.php"; include "db.php"; if (!$_GET[order]) { header("Location: ../index.php"); exit; } $order = clrInt($_GET[order]); $html = file_get_contents("http://happyshop/shop/invoice.php?order={$order}"); include "mpdf60/mpdf.php"; $mpdf = new mPDF('utf-8', 'A4', '8', '', 10, 10, 7, 7, 10, 10); /*задаем формат, отступы и.т.д.*/ // $mpdf->charset_in = 'cp1251'; /*не забываем про русский*/ $stylesheet = file_get_contents('../style/invoice.css'); /*подключаем css*/ $mpdf->WriteHTML($stylesheet, 1); $mpdf->list_indent_first_level = 0; $mpdf->WriteHTML($html, 2); /*формируем pdf*/ $mpdf->Output("{$order}.pdf", 'I');
function prItem($userId) { global $link; $user = clrInt($userId); $sql = "SELECT quantity, price FROM orders WHERE userid = {$user}"; $result = mysqli_query($link, $sql) or die(mysqli_error($link)); $totalprice = array(); while ($row = mysqli_fetch_assoc($result)) { $totalprice[] = $row; } // mysqli_fetch_all($result, MYSQLI_ASSOC); $q = 0; foreach ($totalprice as $total) { $q += $total[quantity] * $total[price]; } return $q; }
<?php include "shop/db.php"; include "shop/lib.php"; define('BASKET', "{$_COOKIE['basket']}"); if (isset($_GET[id])) { $id = $_GET[id]; delItem('orders', $id); header("Location: basket.php"); } if ($_SERVER['REQUEST_METHOD'] == "POST") { $itemname = clrStr($_POST[itemname]); $itemprice = clrInt($_POST[itemprice]); $quantity = clrInt($_POST[cost]); $img = clrStr($_POST[image]); if ($quantity > 0) { order(BASKET, $itemname, $itemprice, $img, $quantity); } else { header("Refresh:3; url=../index.php#price"); echo "<h2> Неверное количество Товаров!</h2>"; } } $q = qtItem(BASKET); if ($q > 0) { echo "<h2>У Вас в корзине {$q} товаров!</h2>"; addOrder(); } else { echo "<h2>Ваша корзина пуста!</h2>"; } ?> <DOCTYPE html>
<?php setcookie('basket', "", 1, "/"); header("Refresh:5; url=../index.php"); include 'db.php'; include 'lib.php'; if($_SERVER['REQUEST_METHOD'] == "POST"){ $tel = clrStr($_POST[tel]); $post = clrStr($_POST[post]); $name = clrStr($_POST[name]); $order = clrInt($_POST[order]); $headers = 'From: Магазин Подгузников <*****@*****.**>' . "\r\n" . 'Reply-To: support@happydada.com.ua' . "\r\n" . "Content-Type: text/html; charset=UTF-8\r\n". 'X-Mailer: PHP/' . phpversion(); if ($tel && $post && $name){ echo "<h2>Спасибо за покупку!</h2></br></br>"; echo "<h2>Ваш заказ принят!</h2>"; echo "<h2>Ближайшее время с Вами свяжется наш оператор!</h2>"; // $bodymail = "Уважаемый(ая), $name!</br> Ваш заказ № $order принят, ожидайте звонка оператора!"; // $bodymail = "Уважаемый(ая), $name!</br> Ваш заказ № $order принят, ожидайте звонка оператора!"; $bodymail = file_get_contents("mail_1.html"); $bodymail .= orderMailList($order); $smallmail = file_get_contents("mail_3.html"); $bodymail .= $smallmail; mail($post, "Заказ № $order принят!", $bodymail, $headers); mail('*****@*****.**', "У Вас новый заказ № $filename", "Поступил новый заказ № $filename! Клиент - $name, телефон - $tel"); saveOrders($order, $name, $tel, $post); } else { echo "<h2>Некорректно указано Имя, Телефон или адрес Эл.Почты!</h2>"; } } else{