<?php // подключение библиотек require "secure/session.inc.php"; require "../inc/lib.inc.php"; require "../inc/db.inc.php"; $author = clearStr($_POST['author']); $title = clearStr($_POST['title']); $pubyear = clearStr($_POST['pubyear']); $price = clearStr($_POST['price']); if (!addItemToCatalog($title, $author, $pubyear, $price)) { echo 'Произошла ошибка при добавлении товара'; } else { header('Location: add2cat.php'); exit; }
$app->post("/country/{idCountry}/city/", function ($request, $response, $args) use($link) { if ($idCountry = getId($args['idCountry'], 'countries')) { $post = $request->getParsedBody(); $name = clearStr($post['Name']); $id = insertItem('cities', $name); if (bindItems('ccities', 'Id_Country', 'Id_city', $idCountry['id'], $id)) { return $response->withJson(array("id" => $id, 'idcountry' => $idCountry)); } } return $response->withJson(array('status' => 0, 'message' => "Failed to insert city")); }); /* Add new language */ $app->post("/country/{idCountry}/city/{idCity}/language", function ($request, $response, $args) use($link) { if ($idCity = getId($args['idCity'], 'cities')) { $post = $request->getParsedBody(); $name = clearStr($post['Name']); $id = insertItem('languages', $name); if (bindItems('clanguages', 'Id_City', 'Id_Language', $idCity['id'], $id)) { return $response->withJson(array("id" => $id)); } } return $response->withJson(array('status' => 0, 'message' => "Failed to insert city")); }); /* Delete country by Id */ $app->delete("/country/{id}/", function ($request, $response, $args) use($link) { $id = getId($args['id'], 'countries'); if ($id) { deleteId($id['id'], 'ccities', 'Id_Country', 'i'); deleteId($id['id'], 'countries', 'Id', 'i'); return $response->withJson(array('status' => 1, 'message' => "Country deleted sucsesfully")); } else {
<?php require "../classes/Lib.php"; require "../classes/DB.php"; require_once "session.inc.php"; //подгружаем блок head и стили require "../inc/head.inc.php"; $error_reg = substr(clearStr($_GET['error_reg']), 0, 114); //обрезаем get строку с ошибкой, так как она увеличивается каждую итерацию ?> <body> <?php if ($_SESSION['auth'] != 1 and $_SESSION['auth'] != 2) { ?> <p><div style='color: red;'><?php echo $error_reg; ?> </div></p> <?php } ?> <form action="helper.inc.php" method="post" name="order_form"> <?php if ($_SESSION['auth'] != 1 and $_SESSION['auth'] != 2) { ?> <div class="form-group"> <label for="login">Как вас зовут?</label> <input type="text" name="login" id="login"> </div> <div class="form-group"> <label for="email">Email</label>
<?php // подключение библиотек require "secure/session.inc.php"; require "../inc/lib.inc.php"; require "../inc/db.inc.php"; $title = clearStr($_POST['title']); $author = clearStr($_POST['author']); $pubyear = clearInt($_POST['pubyear']); $price = clearInt($_POST['price']); if (!addItemToCatalog($title, $author, $pubyear, $price)) { echo "Произошла ошибка при добавлении товара в каталог"; } else { header("Location: add2cat.php"); exit; }
<?php require "classes/Lib.php"; require "classes/DB.php"; require_once "inc/session.inc.php"; //подгружаем блок head и стили require "inc/head.inc.php"; $active1 = "active"; //форма авторизации отображается по умолчанию $content_active1 = "active in"; //контент формы авторизации отображается по умолчанию $error_reg = substr(clearStr($_GET['error_reg']), 0, 114); //обрезаем get строку с ошибкой, так как она увеличивается каждую итерацию $error_auth = substr(clearStr($_GET['error_msg']), 0, 114); //обрезаем get строку с ошибкой, так как она увеличивается каждую итерацию if (!empty($error_reg)) { unset($active1); unset($content_active1); $active2 = "active"; $content_active2 = "active in"; } $arr = getGood(); $getBucket = getBucket($bucket); $i = 0; if (!is_array($arr)) { $err = "Произошла ошибка при выводе товаров"; } if (!$arr) { $err = "Нет товаров для вывода"; } popUpGood($_GET['id']);
<?php session_start(); include "lib/lib.inc.php"; //підключення бібліотеки include "constants.php"; //костанти для підключення до сервева MySQL if (isset($_POST['buy'])) { $customer = clearStr($_POST['customer']); $email = clearStr($_POST['email']); $phone = clearStr($_POST['phone']); $address = clearStr($_POST['address']); $oid = $basket['orderid']; $dt = time(); if (empty($customer) || empty($email) || empty($phone) || empty($address)) { $_SESSION['error_enter'] = 1; //якщо хоча б одне поле пусте header("Location: {$_SERVER['HTTP_REFERER']}"); } else { $order = "{$customer}|{$email}|{$phone}|{$address}|{$oid}|{$dt}\n"; file_put_contents('orders/' . ORDERS_LOG, $order, FILE_APPEND); saveOrder($dt); //$dt в базі час заказу також будемо зберігати*/ header("Location: index.php?id=success_order"); } }
if (!isUserExist($login, $password)) { unset($login); // удаление переменной unset($password); echo "<result>Wrong login or password</result>"; } else { $_SESSION["userlogin"] = $login; echo "<result>ok</result>"; } break; case "registration": $login = clearStr($_POST["login"]); $password = clearStr($_POST["password"]); $name = clearStr($_POST["name"]); $country = clearStr($_POST["country"]); $email = clearStr($_POST["email"]); if (!isLoginFree($login)) { echo "<result>Login is not free</result>"; } elseif (!isMailFree($email)) { echo "<result>Email is not free</result>"; } else { addUser($login, $password, $name, $country, $email); echo "<result>ok</result>"; } break; case "Exit": unset($_SESSION["userlogin"]); echo "<result>ok</result>"; break; default: echo "<result>Some error</result>";
<?php require "../inc/lib.inc.php"; require "../inc/db.inc.php"; $news = clearStr($_POST['news']); $title = clearStr($_POST['title']); $text = $_POST['text']; $header = clearStr($_POST['header']); $date = time(); $image = $_FILES['image']['name']; if (isset($_POST['sent_request'])) { saveNews($news, $title, $header, $image, $text, $date); uploadFile($_FILES['image']); } ?> <form enctype="multipart/form-data" method="post"> <table cellspacing="5" cellpadding="3"> <tr> <td align="right">Выберите новость:</td> <td><select name="news"> <option value="politica"> Политика</option> <option value="sport"> Спорт</option> <option value="avto"> Авто</option> <option value="hiTech"> Hi-Tech</option> </select></td> </tr> <tr> <td align="right">Введите тему новости:</td> <td><input type="text" name="title"></td>
$msg = clearStr($_POST['msg']); $sql = "INSERT INTO msgs (name, email, msg) VALUES ('{$name}', '{$email}', '{$msg}')"; $res = $ms->query($sql) or die($ms->error); if (!$ms->errno) { echo "<span style='color:green;'>Сообщение успешно добавлено!</span><br/>"; header('Location: ' . $_SERVER['REQUEST_URI']); exit; } } ?> <!-- Сохранение записи в БД --> <!-- Удаление записи из БД --> <?php if ($_SERVER["REQUEST_METHOD"] == 'GET' && isset($_GET['del'])) { $del = (int) clearStr($_GET['del']); $sql = 'DELETE FROM msgs WHERE id = ' . $del; $ms->query($sql) or die($ms->error); header('Location: ' . $_SERVER['SCRIPT_NAME'] . '?id=gbook'); exit; } ?> <!-- Удаление записи из БД --> <h3>Оставьте запись в нашей Гостевой книге</h3> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?> "> Имя: <br /><input type="text" name="name" /><br /> Email: <br /><input type="text" name="email" /><br />
header("Location: login.php"); exit; } require "db.inc.php"; $dir = ''; if (move_uploaded_file($_FILES['filename']['tmp_name'], $dir . $_FILES['filename']['name'])) { } if (move_uploaded_file($_FILES['filename_det']['tmp_name'], $dir . $_FILES['filename_det']['name'])) { } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $name = clearStr($_POST['name']); $description = clearStr($_POST['description']); $description_full = clearStr($_POST['description_full']); $userquantity = clearStr($_POST['userquantity']); $location = clearStr($_POST['location']); $published_at = clearStr($_POST['published_at']); $pic_name = $_FILES['filename']['name']; $det_pic_name = $_FILES['filename_det']['name']; $sql = "INSERT INTO meeting(name, description, description_full, userquantity, location, published_at, pic_name, det_pic_name )\nVALUES ('{$name}', '{$description}', '{$description_full}','{$userquantity}', '{$location}', '{$published_at}', '{$pic_name}','{$det_pic_name}' )"; mysqli_query($link, $sql) or die(mysqli_error($link)); header("Location: index.php"); exit; } ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Добавление встреч</title> <link rel="stylesheet" href="css/bootstrap.css">
$password = clearStr($_POST['pass']); $email = clearStr($_POST['email']); regUser($name, $login, $password, $email, $phone, $role = "inactive"); if (!empty($error_reg)) { header("Location: /MyShop/?error_reg=" . $error_reg); exit; } else { header("Location: success.php"); exit; } } elseif (isset($_POST['logOut'])) { session_destroy(); header("Location:" . $_SERVER['SCRIPT_NAME']); exit; } elseif (!isset($_POST['del']) and !isset($_POST['update'])) { $title = clearStr($_POST['title']); $description = $_POST['description']; $price = clearInt($_POST['price']); $category = $_POST['category']; $cnt = count($_FILES['img']['name']); if ($cnt > 0) { for ($i = 0; $i < $cnt; $i++) { $tmpImgPath = $_FILES['img']['tmp_name'][$i]; if ($tmpImgPath != '') { $newImgPath = "../images/" . translate($_FILES['img']['name'][$i]); $imgs[] = $newImgPath; move_uploaded_file($tmpImgPath, $imgs[$i]); } } } addToCatalog($title, $description, $price, serialize($imgs), $category);
<?php require "../classes/Lib.php"; require "../classes/DB.php"; $email = clearStr($_GET['email']); $user_id = clearInt($_GET['user_id']); $active_key = clearStr($_GET['active_key']); if (confirmReg($user_id, $active_key)) { $message = "Успешное подтверждение регистрации. Теперь вы можете авторизоваться."; header("Refresh:4; ../index.php"); } else { $message = "Ошибка подтверждения регистрации. Для повторного подтверждения регистрации нажмите на <a href='{$_SERVER['PHP_SELF']}?re=re'>ссылку</a>"; } if (clearStr($_GET['re']) === 're') { regUserMailer($email, $user_id, $active_key); } //подгружаем блок head и стили require "../inc/head.inc.php"; ?> <body> <div class="container-fluid"> <div class="row"> <div class="col-md-10"> <h1 class="bg-success"><?php echo $message; ?> </h1> <p class="bg-info">Сейчас вы будете перенаправлены на главную. Если не хотите ждать нажмите на <a href='../index.php'>ссылку</a></a> </p> </div> </div>
<?php require_once 'core/init.php'; $date = $_POST['date']; $ip = $_POST['ip']; $url = $_POST['url']; $ua = $_POST['user_agent']; $os = $_POST['os']; if (isset($date) && isset($ip) && isset($url) && isset($ua) && isset($os)) { $db = new Database(); if (clearDate($date) !== NULL && clearIp($ip) !== NULL && clearStr($ua) !== NULL && clearStr($os) !== NULL) { $db->insertRow("INSERT INTO stats(date, url, ip_address, user_agent, os) VALUES(?, ?, ?, ?, ?)", [$date, $ip, $url, escape(ieDetect($ua)), escape(osDetect($os))]); } } else { Redirect::to('index.php'); }
define('DB_HOST', '127.0.0.1'); define('DB_LOGIN', 'root'); define('DB_PASSWORD', ''); define('DB_NAME', 'gbook'); $link = mysqli_connect(DB_HOST, DB_LOGIN, DB_PASSWORD, DB_NAME); ////////////////////////////// function clearStr($data) { global $link; return mysqli_real_escape_string($link, trim(strip_tags($data))); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $name = clearStr($_POST['name']); $email = clearStr($_POST['email']); $msg = clearStr($_POST['msg']); $sql = "INSERT INTO msgs(name, email, msg)\n VALUES('{$name}', '{$email}', '{$msg}')"; mysqli_query($link, $sql) or die(mysqli_error($link)); header('Location: ' . $_SERVER['REQUEST_URI']); exit; } if (isset($_GET['del'])) { $del = abs((int) $_GET['del']); if ($del) { $sql = "DELETE FROM msgs WHERE id={$del}"; mysqli_query($link, $sql) or die(mysqli_error($link)); header('Location: ' . $_SERVER['SCRIPT_NAME'] . '?id=gbook'); exit; } } /* Основные настройки */
<?php require "lib.inc.php"; require "db.inc.php"; $subject = clearStr($_POST['subject']); $email = clearStr($_POST['email']); $body = clearStr($_POST['body']); $time = time(); if (!addNewNews($subject, $email, $body, $time)) { echo 'Произошла ошибка при добавлении новости'; } else { header('Location: ' . $_SERVER['SCRIPT_NAME'] . '?id=contact'); //echo '<p>Если хотите отправить ещё одно письмо то нажмите <a href="index.php?id=contact">сюда</a></p>'; exit; }