���� ������
�� ������� ������������� ������� ������� �������� ����������� Web-����������, ���������� php-�������� ������ � �������� �� MySQL, ������, ������� Smarty, ������� ������� � �������� �������, �������� ������ �� ������, ��������� ������ html-����
�������� ������
����������� ������� "������������ ������", ���������� ��� ������� ������ php-������:
- ������ - login.php - �������� 1 (�1)
- ������� ����� ��� ����� ������/������, ��������� ����������� � ��, ������������ �������� ������������ ��������� ������. � ������ �������� �������� ����������� ��������������� �� �2
- ������ - album.php - �2
- ��������� ������������� �����������, ��������� � �������. ������� ����� ��� �������� (upload) ������ ����������� � ��������� �� C3 ��� ������� submit. ������� ����� ��� ������ ���������� ����������� � ��������� �� �4 ��� ������� submit
- ������ - upload.php (�3)
- ���������� ����������� ������������� �����������. ������� ����� ��� ���������� ������� � ������� � ��������� �� C2 ��� ������� submit
- ��������� - delete.php (�4)
- ���������� ��������� ����������� � ��������. ������� ����� � �������� "������������� �������?" ��� �������� ���������� ����������� � ��������� �� C2 ��� ������� submit
�������� ����������
1. Smarty. ��� ������� C2-C4 ������� ���� ����������� ������� �� Smarty (��. ������ ����). ���������� ����� ���� ������������
2. ��������������. ��� �������������� ���������� ������������ �������� ������ (���������� ���������� Web-����������), �������� ����������� �������� ������� ������� ��� ����� ������/������
3. ������. ������ ��� �������������� ������������� ������ ��������� �� ������� �� MySQL kappa (��������� ��� ������� � �� ���� ������� ������) � ��������� ��������:
- ������� users � ������ login, password
- � ���� login - ������������� ������������ (�������� ��������� ����� � ������ ��������, ����� � ���� �������������, �� 16 ��������, ���������� � �����). ���� password ������ ������ ������������ � ������������� ���� (� �������, ����� ������������ ������� md5). ������� � ������� ����������� ���� �� ���� ������ ��� ��������� �������
- ������� images � ������ id, caption
- ���� id - ������������� ����������� (�����), ������������� ������������� ��� ���������� ����������� (AUTO_INCREMENT). � ���� caption �������� ������� � ����������� - ������ � ��������� UTF-8 ������ �� 256 ��������
������ ��� ����������� � �� ������ ��������� � ������� ������ ����������������� ����� Smarty (��������, [.Database])
4. �������� �������. ��� ����������� ����������� ������ ��������� � �������� $HOME/public_html/images. ���������� ���������� ������ ����� (rwx) �� ������� images ��� ������� ������ wwwrun (setfacl). ��� �������� ����������� ��� ������������� ��� N.jpg (��������), ��� N - ����� ������������ ����������� (����� ������������ id �����������)
5. �������. ��� ������ � �� ����������� � ���� ��������� �������: ����������� � ��, ����������/�������� ���������� � �������, ����� ���������� � �������. ��������� ������� � ��������� ���� bd_functions.inc � ���������� �� ������ �������� (require_once)
������ MVC � �������������� Smarty
�������� �������:- C2: PHP ������� ������ "url, �������", ������ �������� ���� ������, �������������� ����������� <img src="url"/> � ������� � ������������
- C3: PHP �������� url �����������, ������ ������ �������� � ����� ��� caption
- �4: PHP �������� url ����������� � caption, ������ ������ �������� � ����� ��� "������������� �������?"
�� ������� ����� ���������� Smarty �������������� ���������: id �����������, url ��� action � ������ � �.�.
������ ����������� ������ C4:
<?php require_once("config.inc.php"); require_once("db.inc.php"); require_once("auth.inc.php"); require_once("Smarty.class.php"); db_connect(); auth_check(); ... $id = ### �������� id ���������� ����������� ����� $_GET ###; $src = ### ������������ url ��� img �� id ###; $action = ### ������������ action url �� id ###; $caption = ### �������� caption �� �� �� id ###; ... db_disconnect(); $smarty = new Smarty; $smarty->assign("id", $id); $smarty->assign("src", $src); $smarty->assign("action", $action); $smarty->assign("caption", $caption); $smarty->display("delete.tpl"); ?>
�������� ������ ������
������� ����������� � 8 ������ ��� ������� ���������� �����, ������������� ��� ������ ������������ ������. ��� ���� ������� ������ ���� ��������� ���������, ��������� ������ ��������������� ����������� �������, ����� ������ �������� ����������� �������. ��� ������������ ������ ����� �������, ������� ���� ����������� ����� ������ ���� ����� �����.