PHP 5 Практика создания Web сайтов

Embed Size (px)

Citation preview

WEB-

- - 2005

681.3.068+800.925 32.973.26-018.1 89 . ., . ., . . 5. Web-. .: -, 2005. 960 : . ISBN 5-94157-552-1 5 , Web-. MySQL, Web-, , Flash PDF-. , , , , , FTP-, . , HTML , Web-. - Web-, Web-. Web- 681.3.068+800.92 5 32.973.26-018.1 : . . .

89

02429 24.07.00. 25.07.05. 70100'/,. . . . . 77,4. . 4000 . 1181 "-", 194354, -, . , 5. - Ns 77.99.02.953..006421.11.04 11.11,2004 . . " "" 199034, -, 9 , 12 I S B N 5-94157-552-1 . ., . ., . ., 2005 , "-", 2005

1 1 2 3

I.

5

5

1. Web- Apache 1.1. Web- Apache 2.0.0 1.1.1. Windows 1.1.2. Apache 1.1.3. Linux 1.2. Web- Apache 2.0.0 1.2.1. Apache 1.2.2. 5 1.3. PHP.INI 1.3.1. 1.3.2. 1.3.3. 1.3.4. 1.3.5. 1.3.6. 1.3.7. 1.3.8. 1.3.9. 2. MySQL 2.1. MySQL 2.1.1. MySQL Windows 2.1.2. MySQL Linux 2.2. SQL- 2.2.1. 2.2.2. 2.2.3. 2.2.4. 2.2.5. MySQL

7 7 7 13 16 19 19 23 26 26 28 28 30 31 32 32 33 33 39 39 40 43 44 45 46 48 48 49

IV 2.2.6. (SQL) 2.2.7. 2.2.8. 2.3. MySQL 2.3.1. MySQL 2.3.2. MySQL 2.4. phpMyAdmin 2.4.1. phpMyAdmin 2.4.2. phpMyAdmin 2.4.3. phpMyAdmin 2.4.4. 2.4.5. 2.4.6. 3. HTTP

50 77 80 81 81 92 108 109 115 124 131 135 140 143 143 147 150 152 152 153 153 154 154 154 154 154 155 155 155 155 156 158 158 158 160 162 164 168 170 170 171 176 181

3.1. HTTP- 3.2. 3.2.1. session_cache_limiter session_cache_expire 3.3. HTTP- 3.3.1. Accept 3.3.2. Accept-Charset 3.3.3. Accept-Language 3.3.4. Allow 3.3.5. Connection 3.3.6. Date 3.3.7. Expires 3.3.8. From 3.3.9. Last-Modified 3.3.10. Location 3.3.11. Referer 3.4. : HTTP- 3.5. : HTTP- 4. "" 4.1. JavaScript 4.1.1. JavaScript 4.2. , cookies? 4.3. 4.4. IP- 4.5. 4.6. 4.7. 4.8. ( ) 4.9. 4.10.

4.11. 4.11.1. 4.11.2. CSS: 4.11.3. 4.11.4. 4.11.5. 5. 5.1. , 5.1.1. 5.1.2. 5.1.3. HTML- 5.2. 5.3. 5.3.1. 5.3.2. 5.4. , cookie 5.4.1. cookie 5.4.2. cookie 5.5. 5.6. 5.6.1. display_errors 5.6.2. error-^reporting 5.6.3. variablesjorder 5.6.4. openbasedir 5.6.5. disable^Junctions 5.6.6. a/low_url_fopen 5.6.7. register_globals 5.7. MySQL

V 202 207 208 210 212 212 215 215 216 217 218 220 224 224 226 227 228 229 230 233 233 233 233 234 234 234 235 236

II.

241

6. 7. 7.1. CMS 7.1.1. (CMS) 7.1.2. 7.1.3. 7.2. CMS 7.2.1. 7.2.2. 7.2.3. 7.3.

243 249 251 251 251 252 254 254 257 259 266

VI 8. 8.1. 8.2. 8.3. " " 8.4. - 8.4.1. 8.5. 9. 9.1. MySQL 9.2. CMS 10. "" 10.1. 10.2. 10.3. 11. "" " " 11.1. 11.2. 11.3. 11.4. 11.5.

333 335 336 341 377 378 384 394 394 396 403 404 405 410 430 430 432 437 453 459 481 481 483 486 511 511 512 514 519 522 522 529 532 533 535 536 536

12. 12.1. 12.1.1. 12.2. 13. 13.1. 13.1.1. 13.1.2. SMTP, POP IMAP 13.1.3. 13.2. 13.2.1. mail 13.2.2. SMTP- 13.3. 13.3.1. ( Content-Type) 13.3.2. ( Content-Transfer-Encoding) 13.3.3. Content-Disposition 13.3.4. ,

14. 14.1. PowerCounter 14.2. PowerCounter

VII 543 543 556

I I I . WEB-

617

15. 15.1. 15.2. 16. - 17. 17.1. 17.2. 17.2.1. 17.2.2. 17.2.3. 18. 18.1. 18.2.

619 620 622 633 661 662 664 669 672 677 678 678 701

IV. 5

711

19. 19.1. 20. "" 20.1. .20.2. 20.3. 21. 21.1. 21.1.1. 21.1.2. 21.1.3. 21.1.4. 21.1.5. 21.1.6.

713 714 723 723 730 787 809 809 809 811 812 813 813 815

VIII 21.2. 21.2.1. 21.2.2. 21.2.3. 21.2.4. 21.2.5. 21.2.6.

816 818 833 838 844 846 850

V.

5

855

22. . GDLib 22.1. 22.1.1. Windows 22.2. 22.2.1. gdjnfo 22.2.2. exifjmagetype 22.2.3. exif_read_data 22.2.4. read_exif data 22.2.5. exif thumbnail 22.2.6. getimagesize 22.2.7. imagesx 22.2.8. imagesy 22.2.9. image_type_to_mime_type 22.2.10. imagetypes 22.3. 22.3.1. imagecreate 22.3.2. imagecreatetruecolor 22.3.3. imagecreatefromjpeg 22.3.4. imageinterlace 22.3.5. imagecreatefromgif. 22.3.6. imagecreatefrompng 22.3.7. imagesavealpha 22.3.8. imagecreatefromgd 22.3.9. imagecreatefromgd2 22.3.10. imagecreatefromgd2part 22.3.11. imagecreatefromstring 22.3.12. imagecreatefromwbmp 22.3.13. imagecreatefromxbm 22.3.14. imagecreatefromxpm 22.3.15. imagedestroy 22.4. 22.4.1. imagecopy 22.4.2. imagecopymerge 22.4.3. imagecopymergegray 22. imagecopyresampled

857 857 858 859 859 860 860 862 862 862 863 863 863 864 865 865 865 865 866 866 867 867 867 868 868 868 868 869 869 870 870 870 870 870 871

'.

.

22.4.5. irnagecopyresized 22.4.6. imagerotate 22.4.7. image/liter. 22.5. 22.5.1. imagejpeg 22.5.2. imagegif. 22.5.3. imagepng 22.5.4. imagegd 22.5.5. imagegd2 22.5.6. imagexbm 22.5.7'. imagewbmp 22.5.8. image2wbmp 22.5.9. jpeg2wbmp 22.5.10. png2wbtnp 22.6. 22.6.1. imagefontheight 22.6.2. imagefontwidth 22.6.3. imageftbbox 22.6.4. imagettfbbox 22.6.5. imagepsbbox 22.6.6. imagefttext 22.6.7. imagettftext 22.6.8. imagepstext 22.6.9. imagepsloadfont 22.6.10. imageloadfont 22.6.11. imagepscopyfont 22.6.12. imagepsfreefont 22.6.13. imagepsencodefont 22.6.14. imagepsextendfont 22.6.15. imagepsslantfont 22.6.16. imagechar 22.6.17. imagecharup 22.6.18. imagestring 22.6.19. imagestringup 22.7. 22.7.1. imagealphablending 22.7.2. imagesetthickness 22.7.3. imagesetstyle 22.7.4. imagesetbrush 22.7.5. imagesettile... 22.7'.6. imagelayerejfect 22.7.7'. imageantialias 22.8. 22.8.1. imagesetpixel 22.8.2. imageline 22.8.3. imagedashedline

IX_ 872 872 872 872 872 873 873 874 874 874 874 875 875 875 876 876 876 876 877 877 878 878 879 880 880 881 881 881 882 882 882 883 883 883 884 884 885 885 885 885 886 886 886 886 886 886

22.8.4. imagerectangle 22.8.5. imagepolygon 22.8.6. imagearc 22.8.7. imageellipse 22.8.8. imagefilledrectangle 22.8.9. imagefilledpolygon 22.8.10. imagefilkdarc 22.8.11. imagefilledellipse : 22.8.12. image/ill 22.8.13. imagefilltoborder 22.9. 22.9.1. imageistruecolor 22.9.2. imagetniecolortopalette 22.9.3. imagecolorallocate 22.9.4. imagecolorallocatealpha 22.9.5. imagecolordeallocate 22.9.6. imagecolorat 22.9.7. imagecolorsforindex 22.9.8. imagecolorresolve 22.9.9. imagecolorresolvealpha 22.9.10. imagecolorexact 22.9.11. imagecolorexactalpha 22.9.12. imagecolorclosest 22.9.13. imagecolorclosestalpha 22.9.14. imagecolorclosesthwb 22.9.15. imagecolorset 22.9.16. imagecolortransparent 22.9.17. imagecolorstotal 22.9.18. imagecolormatch 22.9.19. imagepalettecopy 22.9.20. imagegammacorred 22.10. 22.10.1. iptcembed 22.10.2. iptcparse 23. Flash. ming 23.1. 23.1.1. Windows 23.1.2. UNIX- 23.2. ming 23.2.1. SWFMovie 23.2.2. SWFShape 23.2.3. SWFDisplayltem 23.2.4. SWFGradient . 23.2.5. SWFBitmap 23.2.6. SWFFill 887 887 887 887 887 888 888 889 889 889 891 891 891 892 892 893 893 893 893 893 893 894 894 894 894 894 895 896 896 896 896 897 897 897 898 898 898 899 900 901 903 905 909 909 910

XI

23.2.7. SWFMorph 23.2.8. SWFText 23.2.9. SWFFont 23.2.10. SWFTextField 23.2.11. SWFSprite 23.2.12. SWFButton 23.2.13. SWFAction 23.3. 23.3.1. 23.3.2. . SWFBitmap 23.3.3. SWFMorph 23.3.4. action script SWFAction SWFButton 24. PDF-. ClibPDF 24.1. 24.1.1. Windows 24.1.2. UNIX- 24.2. PDF- 24.2.1. cpdf_open 24.2.2. cpdf_save_tojile 24.2.3. cpdf_page_init 24.2.4. cpdf_add_outline 24.2.5. cpdf_begin_text 24.2.6. cpdf_end_text 24.2.7. cpdf_set_/ont 24.2.8. cpdfjext 24.2.9. cpdf_set_text_rendering 24.2.10. cpdfmoveto 24.2.11. cpdfjineto 24.2.12. cpdf_stroke 24.2.13. cpdf_ finalize 24.2.14. cpdf_output_buffer 24.2.15. cpdf_close 24.2.16. 24.3. ClibPDF 24.3.1. cpdf_add_annotation 24.3.2. cpdf_arc 24.3.3. cpdf_circle 24.3.4. cpdfjclip 24.3.5. cpdf_closepath 24.3.6. cpdf_closepathjill_stroke 24.3.7. cpdf__closepath_stroke 24.3.8. cpdf_continue_text 24.3.9. cpdf_curveto 24.3.10. cpdfjill

911 911 912 913 915 .....915 917 917 917 918 920 921 924 925 925 925 926 926 926 926 927 928 928 928 929 929 929 930 930 930 930 930 930 933 933 933 934 934 934 934 934 935 935 935

XII 24.3.11. cpdf_fuuilize_page 24.3.12. cpdf_global_set_document_limits 24.3.13. cpdfjmportjpeg 24.3.14. cpdf_place_inline_image 24.3.15. cpdf_newpath 24.3.16. cpdf_rect 24.3.. cpdf_save 24.3.18. cpdf_restore 24.3.19. cpdf_rotate 24.3.20. cpdf_rotate_text 24.3.21. cpdf_scale 24.3.22. cpdf_set_action_url 24.3.23. cpdf_set_char_spacing 24.3.24. cpdf_set_creator 24.3.25. cpdf_set_current_page 24.3.26. cpdf_set_horiz_scaling 24.3.27. cpdf_set_keywords 24.3.28. cpdfjset leading 24.3.29. cpdf_set_page_animation 24.3.30. cpdf_set_subject 24.3.31. cpdf_set_text_matrix 24.3.32. cpdf_set_text_pos 24.3.33. cpdf_set_text_rise 24.3.34. cpdf_set_title 24.3.35. cpdf_set_word_spacing 24.3.36. cpdf_setdash 24.3.37. cpdf_setrgbcolor 24.3.38. cpdf_setflat 24.3.39. cpdf_show_xy 24.3.40. cpdf_stringwidth 24.3.41. cpdftranslate . -

935 935 936 936 936 937 937 937 937 938 938 938 938 938 938 939 939 939 939 940 940 940 940 940 940 941 941 941 941 941 941 942 943 944

, 2004 ., "-" " 5", 5. , , , , . , , . , , , . , , , , , . , , , 5 Web- . , , HTML, Web- 5. Web-, . Web , , . , , Web Web- . , , Web- Apache MySQL. , Flash PDF-. CD, Web-, Web- MySQL phpMyAdmin,

_

Web- Apache, MySQL PHP 5.0.0. , , Web-, . Web- JT- SoftTime, , (http://www.softtime.ru/forum/), . , Web-.

, 24 , , -. 5 . , Web- 5. 1 5, Web- Apache MySQL. Apache ( php.ini). 2 MySQL: MySQL, SQL-, MySQL, , Web- MySQL phpMyAdmin. 3 HTTP-. 4 " " . , . 5, . Web-, , : , , , , , , (" "). , , 6.

3

7 : . 8 . 9 . "" 10. 11 "" " ". 12 . 13 , , , , , . 14 . Web-. 15 . 16 FTP-. 17 Web-. 18 . , 1921, . , , , , . 22 5 GD. Flash ( Ming) 23. 24 PDF- ClibPDF.

"-", .

4

, " 5", "-" 2004 . . [email protected], http://www.softtime.ru/. , , http://www.softtime.ru/forum/.

I 5

1

Web- Apache1.1. Web- Apache 2.0.0 Web- Apache 2.0.0 Windows Linux. , , , Apache http://www.apache.org.

1.1.1. Windows Web- Apache Windows , Windows TCP/IP. Windows 2000 Windows XP . , .

^7

^ [

, Web- Apache Windows, Apache 2.0.0 Windows. POSIX, Apache Windows.

Apache Windows , . , Apache. , , . Microsoft Visual Studio. , .

I. 5

^

Apache , , msi '___\/132_*_.1.

httpd_BepcnH_win32_*_.msi Microsoft Installer (. 1.1).

Welcome to the Installation Wizard for Apache HTTP Server 2.0.48The Installation Wizard will allow you to modify, repair, or remove Apache HTTP Server 2.0.48. To continue, click Next.

Next>

Cancel

. 1.1. Windows Installer

: Far, Norton Commander . ., .

Next, , . 1.2. Apache (. 1.3). , . 1.4, : , . , -

1. Web- Apache

locaihost (. . 1.4). , (80 8080). Apache HTTP Server 2.0 - Installation Wizard License Agreement Please read the following license agreement carefully.

The Apache Software License, Version 1.1 opyright (c) 2001 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials

1

Cancel

. 1.. Apache 2.0 # Apache HTTP Server 2.0 - Installation WizardServer I n f o r m a t i o n Please enter your server's information.

Network Domain (e.g. sotnenet.com) jlocalhost ' ; . ' : . : ;

Server Name (e.g; www.somenet.com): jlocalhost Administrator's Email Address (e.g. webmastersomenet.com):

Install Apache HTTP Server 2.0 programs and shortcuts for: (* for All Users, on Port 80, as a Service Recommended. only for the Current User, on Port 8080, when started Manually.

. *-

. 1.10. Web- Apache

1.1.2. Apache Windows Apache : ApacheMonitor; Windows; ; .

14

I. 5

Apache ApacheMonitor Web- Apache ApacheMonitor . , 1.11, Start, Stop Restart , .Apache Service Monitor

Start

Setvices Connect

\pache/2.0.49 (Win32)

. 1.11. Apache

Apache Windows , Apache , 80 (. . 1.4), Apache Windows. | | | |

Services ApacheMonitor. , . 1.12, Apache2. , . Windows . (. 1.12) (. 1.13), .

1. Web- Apache **

15

% (; I

()Apache2 : Apache/2.0.48 (Win32) ' [ .. ... Monitors .. Supports I.. ... ... .. ... .. | | _*

%- %DNS-iviHeHT *$}HDD Temperat.,. ^Machine Debug... %M5 Software Sh,.. *&>NetMeeting Re.,. feNVIDIA Driver... ^Office Source E... 4Plug and Play *&QoSRSVP %SplDer Guard f...

BDV4HVI /KLTJ

... ^Windows Audio .. ^Windows Installer ... : ::

/ -V ',.. ..;' '-'

. .: : " OFF C:\DOCUME-1\CEPrELOCALS~1\Temp\ . Sleepycal Software: Berkeley DB 3.2.9a: (January 2 1 , 2003) :

. 2.37. MySQL

2. MySQL

129

, MySQL (. 2.38).1 ' 3 phpMyAdmin lacalhost - phpMyAdmin 2.5.5-pll - Microsoft Internet Enplo er; ""

i ! } http://phpmyadmin

Z g j **

/ Ihost ]( ) ...

| *~ ID root

,

-

Query 0

^

t

i

/'.::. 11

iocaihost mysq

SHOW PROCESSLIS1'

/?

. 2.38. , MySQL

MySQL MySQL. , MySQL, (. 2.39).1 phpMyAdmin localhost - phpMyAdmin 2.5.5-pll - Micranlt Internet Esploi er hlt

13*J :

! | T !

^ 'phpmyadmin

** |

localhost [( * ! ! [ :*'1>

User overview niwJ 5 1 root %

0

USAGE

localhost H1 %

ALL PRIVILEGES ALL PRIVILEGrS ALL PRIVILEGES

, MySQL -

. 2.39. MySQL

130

I. 5

1 phpMyAdmin localhost - phpMyAdmin 2.5.5 pi 1 - Microsoft Internet Explorer ;

; ji^J http://phpmyadmln

**

localhost | ( )... _] hiti ]^|| I] ||| ] '

~ f Jautrtrtcis! .eepnf. Counter >3rt --;* 5. ! ; . =:

J

. 2.40. , MySQL9PhpMyAdmin I. .i .ilhusl phpMyAdmin 2.5.5 pi 1 - Mlrrnsnlt Interne) Fxplori ci j - ^ i http://phpiny admin

() j forum (5) -autotrade calc count counter dcart forum 'zl I ecej f 1 SQL LaTeX ^ CSV Ms Excel ~ ft