Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
konstantinov course work.docx
Скачиваний:
3
Добавлен:
01.07.2025
Размер:
5 Мб
Скачать
☆
    1. Визуальная часть

Не без необходимой является визуализация портала. Для этого в уже имеющемся файле index.php добавим меню с преходами на другие страницы и подключим для красивого оформления файл default.css. Содержимое файлов см. Приложения (trains.com).

В результате получаем:

В основном классе подключаем страницу map.html. С помощью чего при нажатии на карту открывается новое окно с увеличенной картой железных дорог Украины, на которой можно рассмотреть все необходимые маршруты.

<div id="content">

<div><img src="images/img08.jpg" alt="" width="740" height="220" /> </div>

<div class="boxed">

<h3>Карта железных дорог Украины.</h3>

<p><a href="map.html"><img src="images/ukraine.jpg" width="660" height="380" alt="Карта железных дорог Украины"></a></p>

</div>

</div>

<div style="clear: both;"> </div>

</div>

Кроме этого в левом верхнем углу имеется логотип портала “Trains Portal”, при нажатии на который происходит переход на домашнюю страницу. И строкой ниже надпись осуществляет переход на сайт ДонНУ.

Так же имеется тег footer, который отображает ссылки переходов на страницу Научного Руководителя и страницу разработчика курсовой работы.

Данный файл является домашней страницей. Т.к. у нас имеется еще 3 кнопки в меню: Маршрут, Разработчик и Контакты; мы создаем подобные файлы way.php, developer.php и contact.php соответственно, в которых будет изменен только класс «content».

Их содержимое см. Приложения (trains.com).

В результате чего при переходе на данные страницы получаем:

Данное окно выплывает при переходе на страницу Разработчик. Здесь отображена информация о разработчике данной работы и научном руководителе, с сопровождающимися логотипами.

Переходя на следующую страницу по кнопке Контакты мы получаем ее отображение в том же стиле, но в основной ее части уже указаны ссылки на определенные страницы сайта университета.

Так же в качестве наглядного совершенства на страницах используются некоторые изображения. Находятся они на C:/xampp/htdocs/trains.com/images

    1. Работа с пользователями

Еще одна немало важная часть портала – это работа самого пользователя на портале. Основная цель разработчика, дать пользователю информацию о необходимом ему маршруте. Для этого в файл way.php добавляем обращение к базе данных:

<?php

if (isset($_POST['ActionWay'])) {

$first_station = $_POST['first_station'];

$last_station = $_POST['last_station'];

include "php/function.php";

$user = new DBconnect();

$user->ConnectionDB("localhost","root","","account_of_trains");

$user->GetWay($first_station,$last_station);

}

?>

И в самом файле function.php создаем функцию GetWay, в которой запишем запрос к базе данных о выводе необходимой пользователю информации.

public function GetWay($first_station, $last_station){

echo "<caption><p><b>Маршрут</b></p></caption>";

echo '<table border="1" bordercolor=#135293 align="center" bgcolor=#85C329>';

echo "<tr>";

echo "<th>№ Маршрута</th> <th>Начало</th> <th>Конец</th> <th>Цена</th> <th>Дата</th> </tr>";

$query = "SELECT `number`, `first_station`, `last_station`, `price`, `send_date` FROM sp_way WHERE first_station='".$first_station."' and last_station='".$last_station."'";

//echo $query;

$result=mysqli_query($this->handler,$query);

$row = mysqli_fetch_array($result);

echo

"<th>" . $row[0] . "</th>" . " " .

"<th>" . $row[1] . "</th>" . " " .

"<th>" . $row[2] . "</th>" . " " .

"<th>" . $row[3] . "</th>" . " " .

"<th>" . $row[4] . "</th>";

echo "</tr>";

echo "</table>";

return true;

}

После ввода пользователем, необходимые ему, начальную и конечную станции и при нажатии на кнопку “Вывести информацию” страница обращается к базе и она возвращает нам таблицу с:

  • Номером маршрута

  • Начальной станцией

  • Конечной станцией

  • Ценой маршрута

  • Датой отправки поезда по заданному маршруту

Вывод:

В результате проделанной работы с помощью таких языков программирования, как sql, php, html, css и java-script мы спроектировали портал железной дороги с подсистемой учета поездов, в которой каждый пользователь может найти необходимую ему информацию при обращении к базе данных. Так же в полученном портале есть возможность вести учет маршрутов ж/д поездов, добавляя новые с необходимой информацией и удаляя уже устарелые маршруты, имея права администратора.

ЗАКЛЮЧЕНИЕ

С быстрым развитием интернет сети, программисты создают все больше удобств, для жизни человечества. Проблема о создании web -порталов учета железнодорожных поездов актуальна в наше время. Во первых автоматизированная подсистема учета железнодорожных поездов облегчает жизнь административному персоналу. С ее помощью можно мгновенно создавать новые маршруты и изменять даты отправок поездов. А во вторых она так же удобна для пользователей. Пользователи могут преждевременно просмотреть все существующие маршруты и даты их отправок онлайн.

В ходе данной работы был получен полнофункциональный web-портал с подсистемой учета ж/д поездов, полностью готовый к применению. Данный сайт ориентирован на станции железнодорожных поездов и самих пассажиров. С его помощью люди наделенные правами администратора смогут управлять учетом маршрутов поездов, а обычные пользователи - получать необходимую информацию по имеющимся маршрутам работая на данном портале. При размещении его в глобальной сети география распространения возрастает до масштабов всего мира.

При разработке web-портала были проанализированы современные web-технологии, позволяющие создавать интерактивные web-страницы. Наиболее подходящими для выполнения поставленной задачи оказались apache, php, mysql, css.

Разработанный сайт удовлетворяет всем требованиям, выдвинутые на этапе постановки задачи. При разработке web-сайта были использованы готовые модули аутентификации, общий вид портала и его визуализация default.css. Данные модули были доработаны с учетом специфики web-сайта и успешно внедрены в его структуру.

Созданный программный продукт отвечает всем выдвинутым требованиям и включает в себя:

  • Наличие блока регистрации и авторизации.

  • Работа с административной частью.

  • Работа с маршрутами.

  • Выборка маршрутов.

Список литературы

1. Эрик Дж. Брауде «Технология разработки программного обеспечения». СПб: «Издательский дом Питер», 2004 г.

2. Веллингтон, Томпсон, «Разработка web-приложений с помощью php и MySQL», 2005

3. Хоумер А., Улмен К., «Dynamic HTML. Справочник», - СПБ.: Питер, 2000.

5. Котеров Д.В. и Кастарев А.Ф. «PHP 5 в подлиннике. Наиболее полное руководство» 2005г. Изд.:BHV. - 1104 с.

6. MySQL Documentation: MySQL Reference Manuals [Электронный ресурс]: техническая документация по работе с MySQL. - MySQL Documentation, 2010. Режим доступа: www. URL: http://dev.mysql.com

7. Источник со справочной информацией языков HTML и CSS, [Электронный ресурс] http://htmlbook.ru/ © 2002–2014 Влад Мержевич, vlad@htmlbook.ru

ПРИЛОЖЕНИЯ (trains.com)

Данные файлы находятся на C:/xampp/htdocs/trails.com :

  1. index.php

<!DOCTYPE> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Trains.com</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="page"> <div id="sidebar"> <div id="logo"> <h1><a href="index.php">Trains Portal</a></h1> <h2><a href="http://www.donnu.edu.ua">by student of <b>D</b>on<b>N</b><b>U</b> <p>of the faculty of <b>Math & I.T.</b></p></a></h2> </div> <div id="menu"> <ul> <li class="first"><a href="#">Домашняя страница</a></li> <li><a href="way.php">Маршрут</a></li> <li><a href="developer.php">Разрабртчик</a></li> <li><a href="contact.php">Контакты</a></li> </ul> </div> <div id="login"> <h2 class="title1">Вести учет:</h2> <form id="form1" method="post" action="login.php"> <fieldset> <label for="inputtext1">Логин:</label> <input id="inputtext1" type="text" name="login" placeholder="login" maxlength="25" required/> <label for="inputtext2">Пароль:</label> <input id="inputtext2" type="password" name="password" placeholder="password" maxlength="25" required/> <input id="inputsubmit1" type="submit" name="inputsubmit1" value="Войти" /> </fieldset> </form> </div> </div> <div id="content">

<div><img src="images/img08.jpg" alt="" width="740" height="220" /> </div> <div class="boxed"> <h3>Карта железных дорог Украины.</h3> <p><a href="map.html"><img src="images/ukraine.jpg" width="660" height="380" alt="Карта железных дорог Украины"></a></p> </div> </div> <div style="clear: both;"> </div> </div> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <p id="legal">Copyright © 2014 Trains Portal. All Rights Reserved. Designed by <a href="http://vk.com/bg_74">Denis Konstantinov</a>.</p> <p id="links"><a href="http://math.donnu.edu.ua/ru-ru/departments/applied-mech/Teaching%20Staff/Pages/%D0%93%D0%BE%D0%BB%D1%8C%D1%86%D0%B5%D0%B2-%D0%90%D1%80%D0%BA%D0%B0%D0%B4%D1%96%D0%B9-%D0%A1%D0%B5%D1%80%D0%B3%D1%96%D0%B9%D0%BE%D0%B2%D0%B8%D1%87-.aspx">Научный Руководитель</a> </p> </div> </body> </html>

  1. login.php

<?php include "php/function.php"; $login = $_POST['login']; $password = $_POST['password']; $connection = new DBconnect(); $connection->ConnectionDB("localhost","root","","account_of_trains"); echo "YES ConnectBD"; echo $_POST['password']; if($connection->GetUser($login,$password) == false){ header("Location: index.php"); // $connection->CloseDB(); } if($connection->is_administrator == true){ session_start(); $_SESSION["login"] = $login; $_SESSION["password"] = $password; $_SESSION["role"] = "administrator"; $_SESSION["name"] = $connection->name; echo $connection->name; $_SESSION["suname"] = $connection->suname; echo $connection->suname; header("Location: administrator/administrator.php"); // $connection->CloseDB(); } ?>

  1. way.php

<!DOCTYPE> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Trains.com</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="page"> <div id="sidebar"> <div id="logo"> <h1><a href="index.php">Trains Portal</a></h1> <h2><a href="http://www.donnu.edu.ua">by student of <b>D</b>on<b>N</b><b>U</b> <p>of the faculty of <b>Math & I.T.</b></p></a></h2> </div> <div id="menu"> <ul> <li class="first"><a href="index.php">Домашняя страница</a></li> <li><a href="way.php">Маршрут</a></li> <li><a href="developer.php">Разрабртчик</a></li> <li><a href="contact.php">Контакты</a></li> </ul> </div> <div id="login"> <h2 class="title1">Вести учет:</h2> <form id="form1" method="post" action="login.php"> <fieldset> <label for="inputtext1">Логин:</label> <input id="inputtext1" type="text" name="login" placeholder="login" maxlength="25" required/> <label for="inputtext2">Пароль:</label> <input id="inputtext2" type="password" name="password" placeholder="password" maxlength="25" required/> <input id="inputsubmit1" type="submit" name="inputsubmit1" value="Войти"/> </fieldset> </form> </div> </div> <div id="content"> <div><img src="images/img08.jpg" alt="" width="740" height="220" /> </div> <div class="boxed orange"> <form name="number" action="Way.php" method="POST" accept-charset="utf-8"> <br> <p><b>Укажите маршрут</b><p> <input type="hidden" name="ActionWay" value="true"> <table> <th> <label for="first_station">Начальная станция</label> </th> <th> <input type="text" name="first_station" placeholder="введите название" maxlength="25" required> </th> </tr> <th> <label for="last_station">Конечная станция</label> </th> <th> <input type="text" name="last_station" placeholder="введите название" maxlength="30" required> </th> </tr> <th colspan="2"> <input name="submit" type="submit" value="вывести информацию"> </th> </table> <p align=right> Дата и время:<br> <SCRIPT Language="JavaScript"> var curDateTime = new Date() document.write(curDateTime.toLocaleString()) </SCRIPT> </p> </form> <?php if (isset($_POST['ActionWay'])) { $first_station = $_POST['first_station']; $last_station = $_POST['last_station']; include "php/function.php"; $user = new DBconnect(); $user->ConnectionDB("localhost","root","","account_of_trains"); $user->GetWay($first_station,$last_station); } ?> </div> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <p id="legal">Copyright © 2014 Trains Portal. All Rights Reserved. Designed by <a href="http://vk.com/bg_74">Denis Konstantinov</a>.</p> <p id="links"><a href="http://math.donnu.edu.ua/ru-ru/departments/applied-mech/Teaching%20Staff/Pages/%D0%93%D0%BE%D0%BB%D1%8C%D1%86%D0%B5%D0%B2-%D0%90%D1%80%D0%BA%D0%B0%D0%B4%D1%96%D0%B9-%D0%A1%D0%B5%D1%80%D0%B3%D1%96%D0%B9%D0%BE%D0%B2%D0%B8%D1%87-.aspx">Научный Руководитель</a> </p> </div> </body> </html>

  1. developer.php

<!DOCTYPE> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Trains.com</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="page"> <div id="sidebar"> <div id="logo"> <h1><a href="index.php">Trains Portal</a></h1> <h2><a href="http://www.donnu.edu.ua">by student of <b>D</b>on<b>N</b><b>U</b> <p>of the faculty of <b>Math & I.T.</b></p></a></h2> </div> <div id="menu"> <ul> <li class="first"><a href="index.php">Домашняя страница</a></li> <li><a href="way.php">Маршрут</a></li> <li><a href="developer.php">Разрабртчик</a></li> <li><a href="contact.php">Контакты</a></li> </ul> </div> <div id="login"> <h2 class="title1">Вести учет:</h2> <form id="form1" method="post" action="login.php"> <fieldset> <label for="inputtext1">Логин:</label> <input id="inputtext1" type="text" name="login" placeholder="login" maxlength="25" required/> <label for="inputtext2">Пароль:</label> <input id="inputtext2" type="password" name="password" placeholder="password" maxlength="25" required/> <input id="inputsubmit1" type="submit" name="inputsubmit1" value="Войти"/> </fieldset> </form> </div> </div> <div id="content"> <div><img src="images/img08.jpg" alt="" width="740" height="220" /> </div> <div class="boxed orange"> <br> <img src="images/donnu.jpg" width="100" height="100" class="right" /> <p><h3>Курсовая работа:</h3> <p>студента Донецкого Национального Университета <p>факльтета Математики и Информационных Технологий <p>специальности "Прикладная математика" (3-Ж) <img src="images/math.jpg" width="100" height="100" class="right" /> <p><a href="http://vk.com/bg_74">Константинова Дениса</a> <p>по теме: <h4>"Разработка автоматизированной подсистемы учета движения жлезнодорожных поездов".</h4> <br> <img src="images/golcev.jpg" width="100" height="130" class="right" /> <p><h3>Научный руководитель:</h3> <p>Доктор физико-математических наук, профессор, <p>кафедры прикладной механики и компьютерных технологий, <p>Гольцев Аркадий Сергеевич. </p> <br><p align=center>ДонНУ © 2014</p> </form> </div> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <p id="legal">Copyright © 2014 Trains Portal. All Rights Reserved. Designed by <a href="http://vk.com/bg_74">Denis Konstantinov</a>.</p> <p id="links"><a href="http://math.donnu.edu.ua/ru-ru/departments/applied-mech/Teaching%20Staff/Pages/%D0%93%D0%BE%D0%BB%D1%8C%D1%86%D0%B5%D0%B2-%D0%90%D1%80%D0%BA%D0%B0%D0%B4%D1%96%D0%B9-%D0%A1%D0%B5%D1%80%D0%B3%D1%96%D0%B9%D0%BE%D0%B2%D0%B8%D1%87-.aspx">Научный Руководитель</a> </p> </div> </body> </html>

  1. contact.php

<!DOCTYPE> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Trains.com</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="page"> <div id="sidebar"> <div id="logo"> <h1><a href="index.php">Trains Portal</a></h1> <h2><a href="http://www.donnu.edu.ua">by student of <b>D</b>on<b>N</b><b>U</b> <p>of the faculty of <b>Math & I.T.</b></p></a></h2> </div> <div id="menu"> <ul> <li class="first"><a href="index.php">Домашняя страница</a></li> <li><a href="way.php">Маршрут</a></li> <li><a href="developer.php">Разрабртчик</a></li> <li><a href="contact.php">Контакты</a></li> </ul> </div> <div id="login"> <h2 class="title1">Вести учет:</h2> <form id="form1" method="post" action="login.php"> <fieldset> <label for="inputtext1">Логин:</label> <input id="inputtext1" type="text" name="login" placeholder="login" maxlength="25" required/> <label for="inputtext2">Пароль:</label> <input id="inputtext2" type="password" name="password" placeholder="password" maxlength="25" required/> <input id="inputsubmit1" type="submit" name="inputsubmit1" value="Войти" /> </fieldset> </form> </div> </div> <div id="content"> <div><img src="images/img08.jpg" alt="" width="740" height="220" /> </div> <div class="boxed orange"> <br> <p><h3>Наши контакты:</h3> <img src="images/univer.jpg" width="150" height="150" class="right" /> <p><a href="http://www.donnu.edu.ua">Донецкий Национальный Университет</a> <p><a href="http://math.donnu.edu.ua/ru-ru/Pages/Default.aspx">Факльтет Математики и Информационных Технологий</a> <p><a href="http://math.donnu.edu.ua/ru-ru/departments/applied-mech/Pages/Default.aspx">Кафедра прикладной механики и компьютерных технологий</a> <p>Телефон: +380 (62) 302-92-31 <p>E-mail: <a href="amcot.dep@donnu.edu.ua">amcot.dep@donnu.edu.ua</a> <p>к. 00-806, пр. Гурова, 14, г. Донецк, Донецкая обл., 83001, Украина <br><br><p align=center>ДонНУ © 2014</p> </form> </div> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <p id="legal">Copyright © 2014 Trains Portal. All Rights Reserved. Designed by <a href="http://vk.com/bg_74">Denis Konstantinov</a>.</p> <p id="links"><a href="http://math.donnu.edu.ua/ru-ru/departments/applied-mech/Teaching%20Staff/Pages/%D0%93%D0%BE%D0%BB%D1%8C%D1%86%D0%B5%D0%B2-%D0%90%D1%80%D0%BA%D0%B0%D0%B4%D1%96%D0%B9-%D0%A1%D0%B5%D1%80%D0%B3%D1%96%D0%B9%D0%BE%D0%B2%D0%B8%D1%87-.aspx">Научный Руководитель</a> </p> </div> </body> </html>

  1. map.html

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Карта</title> </head> <body> <img src="images/ukraine.jpg" width="" height="" alt="Карта"> </body> </html>

  1. default.css

body { margin: 0; padding: 0; background-image: url(images/777.jpg); background-attachment: fixed; font-family: Georgia, "Times New Roman", Times, serif; font-size: 13px; color: #666666; } blockquote { font-style: italic; } a { color: #135293; } a:hover { text-decoration: none; } .title1 { margin: 0; padding: 10px 0; background: url(images/img07.gif) repeat-x left bottom; font-weight: normal; font-size: 129%; color: #FFFFFF; } .title2 { margin: 0; padding: 10px 0; background: url(images/img09.gif) repeat-x left bottom; font-size: 227%; font-weight: normal; color: #135293; } .title3 { margin: 0; padding: 10px 0; background: url(images/img11.gif) repeat-x left bottom; font-size: 129%; font-weight: normal; color: #FFFFFF; } .boxed { padding: 5px 30px 20px 30px; } .boxed p, .boxed ul, .boxed ol { line-height: 180%; } .orange { margin: 20px 30px; background: #FF9523 url(images/img10.gif) repeat-x; color: #FFFFFF; } .orange a { color: #FFFFFF; } .col-one { float: left; width: 300px; } .col-two { float: right; width: 300px; } #page { width: 980px; margin: 0 auto; background: #FFFFFF url(images/img01.gif) repeat-y; } #sidebar { float: left; width: 240px; } #logo { height: 220px; background: #FFFFFF url(images/img02.gif) repeat-y right top; } #logo h1, #logo h2 { margin: 0; text-align: center; font-weight: normal; font-style: italic; color: #9C9C9C; } #logo h1 { padding: 100px 0 0 0; background: url(images/img03.gif) no-repeat center center; font-size: 36px; } #logo h2 { font-size: 14px; } #logo a { color: #9C9C9C; text-decoration: none; } #menu { padding: 20px; background: #85C329 url(images/img04.gif) repeat-x; } #menu ul { margin: 0; padding: 0; list-style: none; } #menu li { padding: 10px 0; background: url(images/img05.gif) repeat-x; } #menu li.first { background: none; } #menu a { text-decoration: none; font-size: 129%; color: #FFFFFF; } #menu a:hover { text-decoration: underline; } #login { padding: 20px; background: url(images/img06.gif) repeat-x; } #login form { margin: 0; padding: 20px 0 0 0; } #login fieldset { margin: 0; padding: 0; border: none; } #login label { color: #FFFFFF; }

#inputtext1, #inputtext2 { width: 194px; margin-bottom: .5em; font: bold 100% Georgia, "Times New Roman", Times, serif; color: #666666; } #inputsubmit1 { margin-bottom: .5em; font: bold 100% Georgia, "Times New Roman", Times, serif; color: #666666; } #login a { color: #FFFFFF; } #content { float: right; width: 740px; } #footer { width: 980px; height: 120px; margin: 0 auto; background: url(images/img12.gif) repeat-x; } #footer p { margin: 0; font-size: 85%; } #links { float: left; width: 220px; height: 45px; padding: 35px 0 0 20px; background: url(images/img13.gif) repeat-x; } #links a { color: #FFFFFF; } #legal { float: right; width: 720px; height: 45px; padding: 35px 0 0 20px; } .right { float: right; }

Следующий файл находятся на C:/xampp/htdocs/trails.com/php :

  1. function.php

<?php class DBconnect { private $handler; public $is_administrator; public $name; public $suname; function __construct(){ $is_administrator=false; $name="NO"; $suname="NO"; } function ConnectionDB($hostname, $user, $password, $dbname) { $this->handler =new mysqli($hostname, $user, $password,$dbname); if(!$this->handler) echo 'Connection error'.mysql_error(); } public function CloseDB (){ mysql_close($this->handler); } public function ButtonExit ($ButtonName) { echo '<li>'; echo '<form name="login" action="php/AdminActionUser.php" method="POST" accept-charset="utf-8">'; echo '<input type="hidden" name="AdminActionUserExit" value="true">'; echo '<input name="submit" type="submit" id="AdminButtonExit" value=' . $ButtonName . '>'; echo '</form>'; echo '</li>'; } public function GetUser($login, $password){ $query = "SELECT name, suname, role FROM sp_user WHERE login='".$login."' and password='".$password."'"; //echo $query; $result=mysqli_query($this->handler,$query); $row = mysqli_fetch_array($result); if($row['role'] == 'administrator'){ $this->is_administrator=true; $this->name=$row['name']; $this->suname=$row['suname']; return true; } } public function ShowError ($message){ echo $message; } public function AllUser (){ echo "<caption><p><b>Таблица пользователей</b></p></caption>"; echo '<table>'; echo "<tr>";echo "<th>Логин</th> <th>Пароль</th> <th>Имя</th> <th>Фамилия</th> <th>Роль</th> </tr>"; $query = "SELECT `login`, `password`, `name`, `suname`, `role` FROM `sp_user`"; $result=mysqli_query($this->handler,$query); while($row = mysqli_fetch_array($result)) { echo "<th>" . $row['login'] . "</th>" . " " . "<th>" . $row['password'] . "</th>" . " " . "<th>" . $row['name'] . "</th>" . " " . "<th>" . $row['suname'] . "</th>" . " " . "<th>" . $row['role'] . "</th>"; echo "</tr>"; } echo "</table>"; } public function AddUser($login, $password, $name, $suname, $role) { $login_empty = True; $query = "SELECT `login` FROM `sp_user`"; $result=mysqli_query($this->handler,$query); while($row = mysqli_fetch_array($result)) { if ($row['login'] == $login) { $login_empty=False; return false; } } if ($login_empty == True){ $query = "INSERT INTO `sp_user`(`login`, `password`, `name`, `suname`, `role`) VALUES ('$login','$password','$name','$suname','$role')"; mysqli_query($this->handler,$query); } } public function Button ($ButtonLink, $ButtonClass, $ButtonName) { echo "<li>"; echo "<a href=" . $ButtonLink . " class=" . $ButtonClass . ">" . $ButtonName . "</a>"; echo "</li>"; } public function AdminWrapper () { echo'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru"> <head> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/style.css" type="text/css"/> <title>Trains.com | Администрирование</title> </head> <body> <div id="wrapper"> <div class="title"> <div class="title-top"> <div class="title-left"> <div class="title-right"> <div class="title-bottom"> <div class="title-top-left"> <div class="title-bottom-left"> <div class="title-top-right"> <div class="title-bottom-right"> <h1><span >Администратор</span></h1>'; echo "<p> Добро пожаловать " . $_SESSION["name"] . " " . $_SESSION["suname"]; echo "<p>"; echo' </div> </div> </div> </div> </div> </div> </div> </div> </div> <hr class="noscreen" /> <div class="content"> <div class="column-left"> <h3>МЕНЮ</h3> <a href="#skip-menu" class="hidden">Меню</a> <ul class="menu">'; } public function AdminColumnRight () { echo ' </ul> </div> <div id="skip-menu"></div> <div class="column-right"> <div class="box"> <div class="box-top"></div> <div class="box-in"> <ul class="main-list">'; } public function AdminFooter () { echo '</ul> </div> </div> <div class="box-bottom"> <hr class="noscreen" /> <div class="footer-info-left"><a href="http://vk.com/bg_74">Designed by Denis Konstantinov</a>, 2014.</div> </div> </div> <div class="cleaner"> </div> </div> </div> </body> </html>'; } public function DelUser ($login) { $query = "DELETE FROM `sp_user` WHERE `login`='$login'"; // echo $query; $result=mysqli_query($this->handler,$query); } public function AllWay (){ echo "<caption><p><b>Таблица маршрутов</b></p></caption>"; echo '<table>'; echo "<tr>"; echo "<th>№ Маршрута</th> <th>Начало</th> <th>Конец</th> <th>Цена</th> <th>Дата</th> </tr>"; $query = "SELECT `number`, `first_station`, `last_station`, `price` ,`send_date` FROM `sp_way`"; $result=mysqli_query($this->handler,$query); while($row = mysqli_fetch_array($result)) { echo "<th>" . $row['number'] . "</th>" . " " . "<th>" . $row['first_station'] . "</th>" . " " . "<th>" . $row['last_station'] . "</th>" . " " . "<th>" . $row['price'] . "</th>" . " " . "<th>" . $row['send_date'] . "</th>"; echo "</tr>"; } echo "</table>"; } public function AddWay($number, $first_station, $last_station, $price, $send_date) { $number_empty = True; $query = "SELECT `number` FROM `sp_way`"; $result=mysqli_query($this->handler,$query); while($row = mysqli_fetch_array($result)) { if ($row['number'] == $number) { $number_empty=False; return false; } } if ($number_empty == True){ $query = "INSERT INTO `sp_way`(`number`, `first_station`, `last_station`, `price`, `send_date`) VALUES ('$number','$first_station','$last_station','$price','$send_date')"; mysqli_query($this->handler,$query); } } public function DelWay ($number) { $query = "DELETE FROM `sp_way` WHERE `number`='$number'"; // echo $query; $result=mysqli_query($this->handler,$query); } public function GetWay($first_station, $last_station){ echo "<caption><p><b>Маршрут</b></p></caption>"; echo '<table border="1" bordercolor=#135293 align="center" bgcolor=#85C329>'; echo "<tr>"; echo "<th>№ Маршрута</th> <th>Начало</th> <th>Конец</th> <th>Цена</th> <th>Дата</th> </tr>"; $query = "SELECT `number`, `first_station`, `last_station`, `price`, `send_date` FROM sp_way WHERE first_station='".$first_station."' and last_station='".$last_station."'"; //echo $query; $result=mysqli_query($this->handler,$query); $row = mysqli_fetch_array($result); echo "<th>" . $row[0] . "</th>" . " " . "<th>" . $row[1] . "</th>" . " " . "<th>" . $row[2] . "</th>" . " " . "<th>" . $row[3] . "</th>" . " " . "<th>" . $row[4] . "</th>"; echo "</tr>"; echo "</table>"; return true; } } ?>

Следующие файлы находятся на C:/xampp/htdocs/trails.com/administrtor :

  1. administrator.php

<?php session_start(); include "../php/function.php"; $admin = new DBconnect(); $admin->ConnectionDB("localhost","root","","account_of_trains"); if($admin->GetUser($_SESSION["login"],$_SESSION["password"]) == false){ header("Location: ../index.php"); $admin->CloseDB(); } if($admin->is_administrator == true){ $admin->AdminWrapper(); $admin->Button("administrator.php", 'active', "Главная страница"); $admin->Button("administrator_user.php", 'active', "Пользователи"); $admin->Button("administrator_way.php", 'active', "Путь"); $admin->ButtonExit ("Выход"); $admin->AdminColumnRight (); echo "<h2>Добро пожаловать на страницу админстратора</h2>"; echo "<p>Здесь вы можете вести учет железно-дорожных поездов</p>"; echo "<p></p>"; $admin->AdminFooter (); } ?>

  1. administrator_user.php

<?php session_start(); include "../php/function.php"; $admin = new DBconnect(); $admin->ConnectionDB("localhost","root","","account_of_trains"); if($admin->GetUser($_SESSION["login"],$_SESSION["password"]) == false){ header("Location: ../index.php"); $admin->CloseDB(); } if($admin->is_administrator == true){ $admin->AdminWrapper(); $admin->Button("administrator.php", 'active', "Главная страница"); $admin->Button("administrator_user.php", 'active', "Пользователи"); $admin->Button("administrator_way.php", 'active', "Путь"); $admin->ButtonExit ("Выход"); $admin->AdminColumnRight (); $admin->AllUser(); include "php/AdminFormAddUser.php"; $admin->AdminFooter (); } ?>

  1. administrator_way.php

<?php session_start(); include "../php/function.php"; $admin = new DBconnect(); $admin->ConnectionDB("localhost","root","","account_of_trains"); if($admin->GetUser($_SESSION["login"],$_SESSION["password"]) == false){ header("Location: ../index.php"); $admin->CloseDB(); } if($admin->is_administrator == true){ $admin->AdminWrapper(); $admin->Button("administrator.php", 'active', "Главная страница"); $admin->Button("administrator_user.php", 'active', "Пользователи"); $admin->Button("administrator_way.php", 'active', "Путь"); $admin->ButtonExit ("Выход"); $admin->AdminColumnRight (); $admin->AllWay(); include "php/AdminFormAddWay.php"; $admin->AdminFooter (); } ?>

Следующий файл находятся на C:/xampp/htdocs/trails.com/administrator/css :

  1. style.css

* { margin: 0; padding: 0; } html { height: 100%; font-size: 62.5% } body { height: 100%; background-color: #10578D; text-align: center; font: 1.2em Verdana, Arial, Helvetica, sans-serif; } a:link, a:visited { color: #004F8B; text-decoration: underline; font-weight: bolder; } a:hover { text-decoration: none; } .noscreen { display: none; } .cleaner { clear: both; height: 0; font-size: 0; visibility: hidden; } .hidden { position: absolute; top: -10000px; left: 0; width: 1px; height: 1px; overflow: hidden; } #wrapper { width: 850px; margin: 60px auto 0 auto; padding-bottom: 90px; text-align: left; } .title { background-color: #282828; letter-spacing: 1px; width: 39em; } .title-top { background: url('../img/title-top.gif') repeat-x 0 0; } .title-left { background: url('../img/title-left.gif') repeat-y 0 0 } .title-right { background: url('../img/title-right.gif') repeat-y 100% 0 } .title-bottom { background: url('../img/title-bottom.gif') repeat-x 0 100% } .title-top-left { background: url('../img/title-top-left.gif') no-repeat 0 0; } .title-top-right { background: url('../img/title-top-right.gif') no-repeat 100% 0; } .title-bottom-left { background: url('../img/title-bottom-left.gif') no-repeat 0 100%; } .title-bottom-right { background: url('../img/title-bottom-right.gif') no-repeat 100% 100%; } .title p { color: #FFFFFF; margin: 4px 0 0 21px; padding-bottom: 12px; } h1 { font: normal 2.4em Georgia, "Times New Roman", Times, serif; color: #FFFFFF; padding-top: 25px; margin-left: 20px; } h1 a:link, h1 a:visited { color: #FFFFFF; text-decoration: none; font-weight: normal; } h1 span { color: #FFB849; } h2 { font: normal 1.5em Georgia, "Times New Roman", Times, serif; color: #004F8B; letter-spacing: 1px; background: url('../img/h2-bg.gif') no-repeat 0 53%; padding-left: 25px; margin-bottom: 7px; } ul.menu { list-style-type: none; } ul.menu li { background: url('../img/menu-li-divider.gif') no-repeat 50% 100%; padding: 18px 0; } ul.menu li a, ul.menu li a:visited { color: #FFFFFF; font-weight: normal; text-decoration: none; padding: 4px 7px; } ul.menu li a:hover, ul.menu li a.active { background-color: #002F53; } ul.menu li.last { background: none; } .content { width: 850px; margin: 19px auto 0 auto; } .column-left { float: left; width: 165px; text-align: center; color: #FFFFFF; } .column-left h3 { font: normal 1.5em Georgia, "Times New Roman", Times, serif; margin: 10px 0 7px 0; letter-spacing: 1px; } .column-right { margin: 0 0 0 191px; width: 650px; } .box-top { background: url('../img/box-top.gif') no-repeat 0 0; height: 12px; } .box { background: url('../img/box-bg.gif') repeat-y 0 0; } .box-in { background-color: #FFFFFF; padding: 0.8em 0 5em 0; margin: 0 6em 0 2em; } .box-in p { line-height: 1.6; margin: 0 0 10px 25px; color: #242424; } .box-bottom { background: url('../img/box-bottom.gif') no-repeat 0 100%; height: 48px; } ul.main-list {

list-style-type: none; margin: 14px 0 20px 25px; } ul.main-list li { line-height: 1.3; margin-bottom: 12px; color: #004F8B; padding-left: 27px; } table { width: 100%; /* Ширина таблицы */ border: 4px double black; /* Рамка вокруг таблицы */ border-collapse: collapse; /* Отображать только одинарные линии */ } th { text-align: center; /* Выравнивание по левому краю */ background: #ccc; /* Цвет фона ячеек */ padding: 5px; /* Поля вокруг содержимого ячеек */ border: 1px solid black; /* Граница вокруг ячеек */ } td { padding: 5px; /* Поля вокруг содержимого ячеек */ border: 1px solid black; /* Граница вокруг ячеек */ } .footer-info-left, .footer-info-right { font-size: 0.8em; color: #626262; position: relative; top: -7px; display: inline; } .footer-info-left { float: left; margin-left: 17px; } .footer-info-right { float: right; margin-right: 40px; } .footer-info-left a, .footer-info-left a:visited, .footer-info-right a, .footer-info-right a:visited { font-weight: normal; color: #626262; } #AdminButtonExit{ background: #242424; padding: 7px 30px; font-size: 13px; color: #FFFFFF; text-align: center; border: solid 0px #242424; cursor: pointer; } #AdminButtonExit:hover { background: #2E69E3; background: -moz-linear-gradient(0% 100% 90deg, #2E69E3, #59C2FF); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#59C2FF), to(#2E69E3)); }

Следующий файл находятся на C:/xampp/htdocs/trails.com/administrator/php :

  1. AdminActionUser.php

<?php session_start(); if (isset($_POST['AdminActionUserExit'])) { session_destroy(); header("Location: ../../index.php"); } if (isset($_POST['AdminActionUserAdd'])) { $login = $_POST['login']; $password = $_POST['password']; $name = $_POST['name']; $suname = $_POST['suname']; $role = $_POST['role']; include "../../php/function.php"; $admin = new DBconnect(); $admin->ConnectionDB("localhost","root","","account_of_trains"); $admin->AddUser($login, $password, $name, $suname, $role); header("Location: ../administrator_user.php"); } if (isset($_POST['AdminActionUserDel'])) { $login = $_POST['login']; include "../../php/function.php"; $admin = new DBconnect(); $admin->ConnectionDB("localhost","root","","account_of_trains"); $admin->DelUser($login); header("Location: ../administrator_user.php"); } ?>

  1. AdminActionWay.php

<?php session_start(); if (isset($_POST['AdminActionWayExit'])) { session_destroy(); header("Location: ../../index.php"); } if (isset($_POST['AdminActionWayAdd'])) { $number = $_POST['number']; $first_station = $_POST['first_station']; $last_station = $_POST['last_station']; $price = $_POST['price']; $send_date = $_POST['send_date']; include "../../php/function.php"; $admin = new DBconnect(); $admin->ConnectionDB("localhost","root","","account_of_trains"); $admin->AddWay($number, $first_station, $last_station, $price, $send_date); header("Location: ../administrator_way.php"); } if (isset($_POST['AdminActionWayDel'])) { $number = $_POST['number']; include "../../php/function.php"; $admin = new DBconnect(); $admin->ConnectionDB("localhost","root","","account_of_trains"); $admin->DelWay($number); header("Location: ../administrator_way.php"); } ?>

  1. AdminFormAddUser.php

<script type="text/javascript"> function proverka(input) { var value = input.value; var rep = /[0-9]/; if (rep.test(value)) { value = value.replace(rep, ''); input.value = value; Сonfirm("Поле не должно содержать цифру!"); } } </script> <form name="login" action="php/AdminActionUser.php" method="POST" accept-charset="utf-8"> <br> <p><b>Добовление пользоватля</b><p> <input type="hidden" name="AdminActionUserAdd" value="true"> <table> <tr> <th> <label for="login">Логин</label> </th> <th> <input type="text" name="login" placeholder="Логин" maxlength="25" onkeyup="return proverka(this);" required> </th> </tr> <th> <label for="password">Пароль</label> </th> <th> <input type="password" name="password" placeholder="Пароль" maxlength="25" required> </th> </tr> <th> <label for="name">Имя</label> </th> <th> <input type="text" name="name" placeholder="Имя" maxlength="30" onkeyup="return proverka(this);" required> </th> </tr> <th> <label for="suname">Фамилия</label> </th> <th> <input type="text" name="suname" placeholder="Фамилия" maxlength="30" onkeyup="return proverka(this);" required> </th> </tr> <th> <label for="role">Роль</label> </th> <th> <label><input type="radio" name="role" value="administrator"/> Администратор</label> <br /> </th> </tr> <th colspan="2"> <input name="submit" type="submit" value="Добавить"> </th> </table> </form> <form name="login" action="php/AdminActionUser.php" method="POST" accept-charset="utf-8"> <br> <p><b>Удаление пользователя</b><p> <input type="hidden" name="AdminActionUserDel" value="true"> <table> <tr> <th> <label for="login">Логин</label> </th> <th> <input type="text" name="login" placeholder="Логин" maxlength="25" onkeyup="return proverka(this);" required> </th> </tr> <th colspan="2"> <input name="submit" type="submit" value="удалить"> </th> </table> </form>

  1. AdminFormAddWay.php

<form name="number" action="php/AdminActionWay.php" method="POST" accept-charset="utf-8"> <br> <p><b>Добовление маршрута</b><p> <input type="hidden" name="AdminActionWayAdd" value="true"> <table> <tr> <th> <label for="number">Маршрут</label> </th> <th> <input type="text" name="number" placeholder="введите № маршрута" maxlength="25" required> </th> </tr> <th> <label for="first_station">Начальная станция</label> </th> <th> <input type="text" name="first_station" placeholder="введите название" maxlength="25" required> </th> </tr> <th> <label for="last_station">Конечная станция</label> </th> <th> <input type="text" name="last_station" placeholder="введите название" maxlength="30" required> </th> </tr> <th> <label for="price">Цена</label> </th> <th> <input type="text" name="price" placeholder="введите цену" maxlength="30" required> </th> </tr> <th> <label for="price">Дата</label> </th> <th> <input type="text" name="send_date" placeholder="введите дату" maxlength="30" required> </th> </tr> <th colspan="2"> <input name="submit" type="submit" value="Добавить"> </th> </table> </form> <form name="number" action="php/AdminActionWay.php" method="POST" accept-charset="utf-8"> <br> <p><b>Удаление маршрута</b><p> <input type="hidden" name="AdminActionWayDel" value="true"> <table> <tr> <th> <label for="number">Номер</label> </th> <th> <input type="text" name="number" placeholder="введите номер" maxlength="25" required> </th> </tr> <th colspan="2"> <input name="submit" type="submit" value="удалить"> </th> </table> </form>

  1. AdminActionExit.php

<?php

?>